personals/.obsidian/plugins/obsidian-reminder-plugin/main.js

17152 lines
558 KiB
JavaScript
Raw Normal View History

2024-09-10 17:23:53 +02:00
/*
THIS IS A GENERATED/BUNDLED FILE BY ESBUILD
if you want to view the source, please visit the github repository of this plugin
*/
"use strict";
var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __commonJS = (cb, mod) => function __require() {
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
};
var __export = (target, all) => {
for (var name in all)
__defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
if (from && typeof from === "object" || typeof from === "function") {
for (let key of __getOwnPropNames(from))
if (!__hasOwnProp.call(to, key) && key !== except)
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
}
return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var __async = (__this, __arguments, generator) => {
return new Promise((resolve, reject) => {
var fulfilled = (value) => {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
};
var rejected = (value) => {
try {
step(generator.throw(value));
} catch (e) {
reject(e);
}
};
var step = (x) => x.done ? resolve(x.value) : Promise.resolve(x.value).then(fulfilled, rejected);
step((generator = generator.apply(__this, __arguments)).next());
});
};
// node_modules/moment/moment.js
var require_moment = __commonJS({
"node_modules/moment/moment.js"(exports, module2) {
(function(global2, factory) {
typeof exports === "object" && typeof module2 !== "undefined" ? module2.exports = factory() : typeof define === "function" && define.amd ? define(factory) : global2.moment = factory();
})(exports, function() {
"use strict";
var hookCallback;
function hooks() {
return hookCallback.apply(null, arguments);
}
function setHookCallback(callback) {
hookCallback = callback;
}
function isArray2(input) {
return input instanceof Array || Object.prototype.toString.call(input) === "[object Array]";
}
function isObject(input) {
return input != null && Object.prototype.toString.call(input) === "[object Object]";
}
function hasOwnProp(a, b) {
return Object.prototype.hasOwnProperty.call(a, b);
}
function isObjectEmpty(obj) {
if (Object.getOwnPropertyNames) {
return Object.getOwnPropertyNames(obj).length === 0;
} else {
var k;
for (k in obj) {
if (hasOwnProp(obj, k)) {
return false;
}
}
return true;
}
}
function isUndefined(input) {
return input === void 0;
}
function isNumber2(input) {
return typeof input === "number" || Object.prototype.toString.call(input) === "[object Number]";
}
function isDate(input) {
return input instanceof Date || Object.prototype.toString.call(input) === "[object Date]";
}
function map(arr, fn) {
var res = [], i, arrLen = arr.length;
for (i = 0; i < arrLen; ++i) {
res.push(fn(arr[i], i));
}
return res;
}
function extend(a, b) {
for (var i in b) {
if (hasOwnProp(b, i)) {
a[i] = b[i];
}
}
if (hasOwnProp(b, "toString")) {
a.toString = b.toString;
}
if (hasOwnProp(b, "valueOf")) {
a.valueOf = b.valueOf;
}
return a;
}
function createUTC(input, format2, locale2, strict) {
return createLocalOrUTC(input, format2, locale2, strict, true).utc();
}
function defaultParsingFlags() {
return {
empty: false,
unusedTokens: [],
unusedInput: [],
overflow: -2,
charsLeftOver: 0,
nullInput: false,
invalidEra: null,
invalidMonth: null,
invalidFormat: false,
userInvalidated: false,
iso: false,
parsedDateParts: [],
era: null,
meridiem: null,
rfc2822: false,
weekdayMismatch: false
};
}
function getParsingFlags(m) {
if (m._pf == null) {
m._pf = defaultParsingFlags();
}
return m._pf;
}
var some;
if (Array.prototype.some) {
some = Array.prototype.some;
} else {
some = function(fun) {
var t = Object(this), len = t.length >>> 0, i;
for (i = 0; i < len; i++) {
if (i in t && fun.call(this, t[i], i, t)) {
return true;
}
}
return false;
};
}
function isValid(m) {
if (m._isValid == null) {
var flags = getParsingFlags(m), parsedParts = some.call(flags.parsedDateParts, function(i) {
return i != null;
}), isNowValid = !isNaN(m._d.getTime()) && flags.overflow < 0 && !flags.empty && !flags.invalidEra && !flags.invalidMonth && !flags.invalidWeekday && !flags.weekdayMismatch && !flags.nullInput && !flags.invalidFormat && !flags.userInvalidated && (!flags.meridiem || flags.meridiem && parsedParts);
if (m._strict) {
isNowValid = isNowValid && flags.charsLeftOver === 0 && flags.unusedTokens.length === 0 && flags.bigHour === void 0;
}
if (Object.isFrozen == null || !Object.isFrozen(m)) {
m._isValid = isNowValid;
} else {
return isNowValid;
}
}
return m._isValid;
}
function createInvalid(flags) {
var m = createUTC(NaN);
if (flags != null) {
extend(getParsingFlags(m), flags);
} else {
getParsingFlags(m).userInvalidated = true;
}
return m;
}
var momentProperties = hooks.momentProperties = [], updateInProgress = false;
function copyConfig(to2, from2) {
var i, prop, val, momentPropertiesLen = momentProperties.length;
if (!isUndefined(from2._isAMomentObject)) {
to2._isAMomentObject = from2._isAMomentObject;
}
if (!isUndefined(from2._i)) {
to2._i = from2._i;
}
if (!isUndefined(from2._f)) {
to2._f = from2._f;
}
if (!isUndefined(from2._l)) {
to2._l = from2._l;
}
if (!isUndefined(from2._strict)) {
to2._strict = from2._strict;
}
if (!isUndefined(from2._tzm)) {
to2._tzm = from2._tzm;
}
if (!isUndefined(from2._isUTC)) {
to2._isUTC = from2._isUTC;
}
if (!isUndefined(from2._offset)) {
to2._offset = from2._offset;
}
if (!isUndefined(from2._pf)) {
to2._pf = getParsingFlags(from2);
}
if (!isUndefined(from2._locale)) {
to2._locale = from2._locale;
}
if (momentPropertiesLen > 0) {
for (i = 0; i < momentPropertiesLen; i++) {
prop = momentProperties[i];
val = from2[prop];
if (!isUndefined(val)) {
to2[prop] = val;
}
}
}
return to2;
}
function Moment2(config) {
copyConfig(this, config);
this._d = new Date(config._d != null ? config._d.getTime() : NaN);
if (!this.isValid()) {
this._d = new Date(NaN);
}
if (updateInProgress === false) {
updateInProgress = true;
hooks.updateOffset(this);
updateInProgress = false;
}
}
function isMoment(obj) {
return obj instanceof Moment2 || obj != null && obj._isAMomentObject != null;
}
function warn(msg) {
if (hooks.suppressDeprecationWarnings === false && typeof console !== "undefined" && console.warn) {
console.warn("Deprecation warning: " + msg);
}
}
function deprecate(msg, fn) {
var firstTime = true;
return extend(function() {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(null, msg);
}
if (firstTime) {
var args = [], arg, i, key, argLen = arguments.length;
for (i = 0; i < argLen; i++) {
arg = "";
if (typeof arguments[i] === "object") {
arg += "\n[" + i + "] ";
for (key in arguments[0]) {
if (hasOwnProp(arguments[0], key)) {
arg += key + ": " + arguments[0][key] + ", ";
}
}
arg = arg.slice(0, -2);
} else {
arg = arguments[i];
}
args.push(arg);
}
warn(
msg + "\nArguments: " + Array.prototype.slice.call(args).join("") + "\n" + new Error().stack
);
firstTime = false;
}
return fn.apply(this, arguments);
}, fn);
}
var deprecations = {};
function deprecateSimple(name, msg) {
if (hooks.deprecationHandler != null) {
hooks.deprecationHandler(name, msg);
}
if (!deprecations[name]) {
warn(msg);
deprecations[name] = true;
}
}
hooks.suppressDeprecationWarnings = false;
hooks.deprecationHandler = null;
function isFunction(input) {
return typeof Function !== "undefined" && input instanceof Function || Object.prototype.toString.call(input) === "[object Function]";
}
function set(config) {
var prop, i;
for (i in config) {
if (hasOwnProp(config, i)) {
prop = config[i];
if (isFunction(prop)) {
this[i] = prop;
} else {
this["_" + i] = prop;
}
}
}
this._config = config;
this._dayOfMonthOrdinalParseLenient = new RegExp(
(this._dayOfMonthOrdinalParse.source || this._ordinalParse.source) + "|" + /\d{1,2}/.source
);
}
function mergeConfigs(parentConfig, childConfig) {
var res = extend({}, parentConfig), prop;
for (prop in childConfig) {
if (hasOwnProp(childConfig, prop)) {
if (isObject(parentConfig[prop]) && isObject(childConfig[prop])) {
res[prop] = {};
extend(res[prop], parentConfig[prop]);
extend(res[prop], childConfig[prop]);
} else if (childConfig[prop] != null) {
res[prop] = childConfig[prop];
} else {
delete res[prop];
}
}
}
for (prop in parentConfig) {
if (hasOwnProp(parentConfig, prop) && !hasOwnProp(childConfig, prop) && isObject(parentConfig[prop])) {
res[prop] = extend({}, res[prop]);
}
}
return res;
}
function Locale(config) {
if (config != null) {
this.set(config);
}
}
var keys;
if (Object.keys) {
keys = Object.keys;
} else {
keys = function(obj) {
var i, res = [];
for (i in obj) {
if (hasOwnProp(obj, i)) {
res.push(i);
}
}
return res;
};
}
var defaultCalendar = {
sameDay: "[Today at] LT",
nextDay: "[Tomorrow at] LT",
nextWeek: "dddd [at] LT",
lastDay: "[Yesterday at] LT",
lastWeek: "[Last] dddd [at] LT",
sameElse: "L"
};
function calendar(key, mom, now2) {
var output = this._calendar[key] || this._calendar["sameElse"];
return isFunction(output) ? output.call(mom, now2) : output;
}
function zeroFill(number, targetLength, forceSign) {
var absNumber = "" + Math.abs(number), zerosToFill = targetLength - absNumber.length, sign2 = number >= 0;
return (sign2 ? forceSign ? "+" : "" : "-") + Math.pow(10, Math.max(0, zerosToFill)).toString().substr(1) + absNumber;
}
var formattingTokens = /(\[[^\[]*\])|(\\)?([Hh]mm(ss)?|Mo|MM?M?M?|Do|DDDo|DD?D?D?|ddd?d?|do?|w[o|w]?|W[o|W]?|Qo?|N{1,5}|YYYYYY|YYYYY|YYYY|YY|y{2,4}|yo?|gg(ggg?)?|GG(GGG?)?|e|E|a|A|hh?|HH?|kk?|mm?|ss?|S{1,9}|x|X|zz?|ZZ?|.)/g, localFormattingTokens = /(\[[^\[]*\])|(\\)?(LTS|LT|LL?L?L?|l{1,4})/g, formatFunctions = {}, formatTokenFunctions = {};
function addFormatToken(token2, padded, ordinal2, callback) {
var func = callback;
if (typeof callback === "string") {
func = function() {
return this[callback]();
};
}
if (token2) {
formatTokenFunctions[token2] = func;
}
if (padded) {
formatTokenFunctions[padded[0]] = function() {
return zeroFill(func.apply(this, arguments), padded[1], padded[2]);
};
}
if (ordinal2) {
formatTokenFunctions[ordinal2] = function() {
return this.localeData().ordinal(
func.apply(this, arguments),
token2
);
};
}
}
function removeFormattingTokens(input) {
if (input.match(/\[[\s\S]/)) {
return input.replace(/^\[|\]$/g, "");
}
return input.replace(/\\/g, "");
}
function makeFormatFunction(format2) {
var array = format2.match(formattingTokens), i, length;
for (i = 0, length = array.length; i < length; i++) {
if (formatTokenFunctions[array[i]]) {
array[i] = formatTokenFunctions[array[i]];
} else {
array[i] = removeFormattingTokens(array[i]);
}
}
return function(mom) {
var output = "", i2;
for (i2 = 0; i2 < length; i2++) {
output += isFunction(array[i2]) ? array[i2].call(mom, format2) : array[i2];
}
return output;
};
}
function formatMoment(m, format2) {
if (!m.isValid()) {
return m.localeData().invalidDate();
}
format2 = expandFormat(format2, m.localeData());
formatFunctions[format2] = formatFunctions[format2] || makeFormatFunction(format2);
return formatFunctions[format2](m);
}
function expandFormat(format2, locale2) {
var i = 5;
function replaceLongDateFormatTokens(input) {
return locale2.longDateFormat(input) || input;
}
localFormattingTokens.lastIndex = 0;
while (i >= 0 && localFormattingTokens.test(format2)) {
format2 = format2.replace(
localFormattingTokens,
replaceLongDateFormatTokens
);
localFormattingTokens.lastIndex = 0;
i -= 1;
}
return format2;
}
var defaultLongDateFormat = {
LTS: "h:mm:ss A",
LT: "h:mm A",
L: "MM/DD/YYYY",
LL: "MMMM D, YYYY",
LLL: "MMMM D, YYYY h:mm A",
LLLL: "dddd, MMMM D, YYYY h:mm A"
};
function longDateFormat(key) {
var format2 = this._longDateFormat[key], formatUpper = this._longDateFormat[key.toUpperCase()];
if (format2 || !formatUpper) {
return format2;
}
this._longDateFormat[key] = formatUpper.match(formattingTokens).map(function(tok) {
if (tok === "MMMM" || tok === "MM" || tok === "DD" || tok === "dddd") {
return tok.slice(1);
}
return tok;
}).join("");
return this._longDateFormat[key];
}
var defaultInvalidDate = "Invalid date";
function invalidDate() {
return this._invalidDate;
}
var defaultOrdinal = "%d", defaultDayOfMonthOrdinalParse = /\d{1,2}/;
function ordinal(number) {
return this._ordinal.replace("%d", number);
}
var defaultRelativeTime = {
future: "in %s",
past: "%s ago",
s: "a few seconds",
ss: "%d seconds",
m: "a minute",
mm: "%d minutes",
h: "an hour",
hh: "%d hours",
d: "a day",
dd: "%d days",
w: "a week",
ww: "%d weeks",
M: "a month",
MM: "%d months",
y: "a year",
yy: "%d years"
};
function relativeTime(number, withoutSuffix, string, isFuture) {
var output = this._relativeTime[string];
return isFunction(output) ? output(number, withoutSuffix, string, isFuture) : output.replace(/%d/i, number);
}
function pastFuture(diff2, output) {
var format2 = this._relativeTime[diff2 > 0 ? "future" : "past"];
return isFunction(format2) ? format2(output) : format2.replace(/%s/i, output);
}
var aliases = {};
function addUnitAlias(unit, shorthand) {
var lowerCase = unit.toLowerCase();
aliases[lowerCase] = aliases[lowerCase + "s"] = aliases[shorthand] = unit;
}
function normalizeUnits(units) {
return typeof units === "string" ? aliases[units] || aliases[units.toLowerCase()] : void 0;
}
function normalizeObjectUnits(inputObject) {
var normalizedInput = {}, normalizedProp, prop;
for (prop in inputObject) {
if (hasOwnProp(inputObject, prop)) {
normalizedProp = normalizeUnits(prop);
if (normalizedProp) {
normalizedInput[normalizedProp] = inputObject[prop];
}
}
}
return normalizedInput;
}
var priorities = {};
function addUnitPriority(unit, priority) {
priorities[unit] = priority;
}
function getPrioritizedUnits(unitsObj) {
var units = [], u;
for (u in unitsObj) {
if (hasOwnProp(unitsObj, u)) {
units.push({ unit: u, priority: priorities[u] });
}
}
units.sort(function(a, b) {
return a.priority - b.priority;
});
return units;
}
function isLeapYear(year) {
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
}
function absFloor(number) {
if (number < 0) {
return Math.ceil(number) || 0;
} else {
return Math.floor(number);
}
}
function toInt(argumentForCoercion) {
var coercedNumber = +argumentForCoercion, value = 0;
if (coercedNumber !== 0 && isFinite(coercedNumber)) {
value = absFloor(coercedNumber);
}
return value;
}
function makeGetSet(unit, keepTime) {
return function(value) {
if (value != null) {
set$1(this, unit, value);
hooks.updateOffset(this, keepTime);
return this;
} else {
return get(this, unit);
}
};
}
function get(mom, unit) {
return mom.isValid() ? mom._d["get" + (mom._isUTC ? "UTC" : "") + unit]() : NaN;
}
function set$1(mom, unit, value) {
if (mom.isValid() && !isNaN(value)) {
if (unit === "FullYear" && isLeapYear(mom.year()) && mom.month() === 1 && mom.date() === 29) {
value = toInt(value);
mom._d["set" + (mom._isUTC ? "UTC" : "") + unit](
value,
mom.month(),
daysInMonth(value, mom.month())
);
} else {
mom._d["set" + (mom._isUTC ? "UTC" : "") + unit](value);
}
}
}
function stringGet(units) {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units]();
}
return this;
}
function stringSet(units, value) {
if (typeof units === "object") {
units = normalizeObjectUnits(units);
var prioritized = getPrioritizedUnits(units), i, prioritizedLen = prioritized.length;
for (i = 0; i < prioritizedLen; i++) {
this[prioritized[i].unit](units[prioritized[i].unit]);
}
} else {
units = normalizeUnits(units);
if (isFunction(this[units])) {
return this[units](value);
}
}
return this;
}
var match1 = /\d/, match2 = /\d\d/, match3 = /\d{3}/, match4 = /\d{4}/, match6 = /[+-]?\d{6}/, match1to2 = /\d\d?/, match3to4 = /\d\d\d\d?/, match5to6 = /\d\d\d\d\d\d?/, match1to3 = /\d{1,3}/, match1to4 = /\d{1,4}/, match1to6 = /[+-]?\d{1,6}/, matchUnsigned = /\d+/, matchSigned = /[+-]?\d+/, matchOffset = /Z|[+-]\d\d:?\d\d/gi, matchShortOffset = /Z|[+-]\d\d(?::?\d\d)?/gi, matchTimestamp = /[+-]?\d+(\.\d{1,3})?/, matchWord = /[0-9]{0,256}['a-z\u00A0-\u05FF\u0700-\uD7FF\uF900-\uFDCF\uFDF0-\uFF07\uFF10-\uFFEF]{1,256}|[\u0600-\u06FF\/]{1,256}(\s*?[\u0600-\u06FF]{1,256}){1,2}/i, regexes;
regexes = {};
function addRegexToken(token2, regex, strictRegex) {
regexes[token2] = isFunction(regex) ? regex : function(isStrict, localeData2) {
return isStrict && strictRegex ? strictRegex : regex;
};
}
function getParseRegexForToken(token2, config) {
if (!hasOwnProp(regexes, token2)) {
return new RegExp(unescapeFormat(token2));
}
return regexes[token2](config._strict, config._locale);
}
function unescapeFormat(s) {
return regexEscape(
s.replace("\\", "").replace(
/\\(\[)|\\(\])|\[([^\]\[]*)\]|\\(.)/g,
function(matched, p1, p2, p3, p4) {
return p1 || p2 || p3 || p4;
}
)
);
}
function regexEscape(s) {
return s.replace(/[-\/\\^$*+?.()|[\]{}]/g, "\\$&");
}
var tokens = {};
function addParseToken(token2, callback) {
var i, func = callback, tokenLen;
if (typeof token2 === "string") {
token2 = [token2];
}
if (isNumber2(callback)) {
func = function(input, array) {
array[callback] = toInt(input);
};
}
tokenLen = token2.length;
for (i = 0; i < tokenLen; i++) {
tokens[token2[i]] = func;
}
}
function addWeekParseToken(token2, callback) {
addParseToken(token2, function(input, array, config, token3) {
config._w = config._w || {};
callback(input, config._w, config, token3);
});
}
function addTimeToArrayFromToken(token2, input, config) {
if (input != null && hasOwnProp(tokens, token2)) {
tokens[token2](input, config._a, config, token2);
}
}
var YEAR = 0, MONTH = 1, DATE = 2, HOUR = 3, MINUTE = 4, SECOND = 5, MILLISECOND = 6, WEEK = 7, WEEKDAY = 8;
function mod(n, x) {
return (n % x + x) % x;
}
var indexOf;
if (Array.prototype.indexOf) {
indexOf = Array.prototype.indexOf;
} else {
indexOf = function(o) {
var i;
for (i = 0; i < this.length; ++i) {
if (this[i] === o) {
return i;
}
}
return -1;
};
}
function daysInMonth(year, month) {
if (isNaN(year) || isNaN(month)) {
return NaN;
}
var modMonth = mod(month, 12);
year += (month - modMonth) / 12;
return modMonth === 1 ? isLeapYear(year) ? 29 : 28 : 31 - modMonth % 7 % 2;
}
addFormatToken("M", ["MM", 2], "Mo", function() {
return this.month() + 1;
});
addFormatToken("MMM", 0, 0, function(format2) {
return this.localeData().monthsShort(this, format2);
});
addFormatToken("MMMM", 0, 0, function(format2) {
return this.localeData().months(this, format2);
});
addUnitAlias("month", "M");
addUnitPriority("month", 8);
addRegexToken("M", match1to2);
addRegexToken("MM", match1to2, match2);
addRegexToken("MMM", function(isStrict, locale2) {
return locale2.monthsShortRegex(isStrict);
});
addRegexToken("MMMM", function(isStrict, locale2) {
return locale2.monthsRegex(isStrict);
});
addParseToken(["M", "MM"], function(input, array) {
array[MONTH] = toInt(input) - 1;
});
addParseToken(["MMM", "MMMM"], function(input, array, config, token2) {
var month = config._locale.monthsParse(input, token2, config._strict);
if (month != null) {
array[MONTH] = month;
} else {
getParsingFlags(config).invalidMonth = input;
}
});
var defaultLocaleMonths = "January_February_March_April_May_June_July_August_September_October_November_December".split(
"_"
), defaultLocaleMonthsShort = "Jan_Feb_Mar_Apr_May_Jun_Jul_Aug_Sep_Oct_Nov_Dec".split("_"), MONTHS_IN_FORMAT = /D[oD]?(\[[^\[\]]*\]|\s)+MMMM?/, defaultMonthsShortRegex = matchWord, defaultMonthsRegex = matchWord;
function localeMonths(m, format2) {
if (!m) {
return isArray2(this._months) ? this._months : this._months["standalone"];
}
return isArray2(this._months) ? this._months[m.month()] : this._months[(this._months.isFormat || MONTHS_IN_FORMAT).test(format2) ? "format" : "standalone"][m.month()];
}
function localeMonthsShort(m, format2) {
if (!m) {
return isArray2(this._monthsShort) ? this._monthsShort : this._monthsShort["standalone"];
}
return isArray2(this._monthsShort) ? this._monthsShort[m.month()] : this._monthsShort[MONTHS_IN_FORMAT.test(format2) ? "format" : "standalone"][m.month()];
}
function handleStrictParse(monthName, format2, strict) {
var i, ii, mom, llc = monthName.toLocaleLowerCase();
if (!this._monthsParse) {
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
for (i = 0; i < 12; ++i) {
mom = createUTC([2e3, i]);
this._shortMonthsParse[i] = this.monthsShort(
mom,
""
).toLocaleLowerCase();
this._longMonthsParse[i] = this.months(mom, "").toLocaleLowerCase();
}
}
if (strict) {
if (format2 === "MMM") {
ii = indexOf.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format2 === "MMM") {
ii = indexOf.call(this._shortMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._longMonthsParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._longMonthsParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortMonthsParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeMonthsParse(monthName, format2, strict) {
var i, mom, regex;
if (this._monthsParseExact) {
return handleStrictParse.call(this, monthName, format2, strict);
}
if (!this._monthsParse) {
this._monthsParse = [];
this._longMonthsParse = [];
this._shortMonthsParse = [];
}
for (i = 0; i < 12; i++) {
mom = createUTC([2e3, i]);
if (strict && !this._longMonthsParse[i]) {
this._longMonthsParse[i] = new RegExp(
"^" + this.months(mom, "").replace(".", "") + "$",
"i"
);
this._shortMonthsParse[i] = new RegExp(
"^" + this.monthsShort(mom, "").replace(".", "") + "$",
"i"
);
}
if (!strict && !this._monthsParse[i]) {
regex = "^" + this.months(mom, "") + "|^" + this.monthsShort(mom, "");
this._monthsParse[i] = new RegExp(regex.replace(".", ""), "i");
}
if (strict && format2 === "MMMM" && this._longMonthsParse[i].test(monthName)) {
return i;
} else if (strict && format2 === "MMM" && this._shortMonthsParse[i].test(monthName)) {
return i;
} else if (!strict && this._monthsParse[i].test(monthName)) {
return i;
}
}
}
function setMonth(mom, value) {
var dayOfMonth;
if (!mom.isValid()) {
return mom;
}
if (typeof value === "string") {
if (/^\d+$/.test(value)) {
value = toInt(value);
} else {
value = mom.localeData().monthsParse(value);
if (!isNumber2(value)) {
return mom;
}
}
}
dayOfMonth = Math.min(mom.date(), daysInMonth(mom.year(), value));
mom._d["set" + (mom._isUTC ? "UTC" : "") + "Month"](value, dayOfMonth);
return mom;
}
function getSetMonth(value) {
if (value != null) {
setMonth(this, value);
hooks.updateOffset(this, true);
return this;
} else {
return get(this, "Month");
}
}
function getDaysInMonth() {
return daysInMonth(this.year(), this.month());
}
function monthsShortRegex(isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, "_monthsRegex")) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsShortStrictRegex;
} else {
return this._monthsShortRegex;
}
} else {
if (!hasOwnProp(this, "_monthsShortRegex")) {
this._monthsShortRegex = defaultMonthsShortRegex;
}
return this._monthsShortStrictRegex && isStrict ? this._monthsShortStrictRegex : this._monthsShortRegex;
}
}
function monthsRegex(isStrict) {
if (this._monthsParseExact) {
if (!hasOwnProp(this, "_monthsRegex")) {
computeMonthsParse.call(this);
}
if (isStrict) {
return this._monthsStrictRegex;
} else {
return this._monthsRegex;
}
} else {
if (!hasOwnProp(this, "_monthsRegex")) {
this._monthsRegex = defaultMonthsRegex;
}
return this._monthsStrictRegex && isStrict ? this._monthsStrictRegex : this._monthsRegex;
}
}
function computeMonthsParse() {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var shortPieces = [], longPieces = [], mixedPieces = [], i, mom;
for (i = 0; i < 12; i++) {
mom = createUTC([2e3, i]);
shortPieces.push(this.monthsShort(mom, ""));
longPieces.push(this.months(mom, ""));
mixedPieces.push(this.months(mom, ""));
mixedPieces.push(this.monthsShort(mom, ""));
}
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
for (i = 0; i < 12; i++) {
shortPieces[i] = regexEscape(shortPieces[i]);
longPieces[i] = regexEscape(longPieces[i]);
}
for (i = 0; i < 24; i++) {
mixedPieces[i] = regexEscape(mixedPieces[i]);
}
this._monthsRegex = new RegExp("^(" + mixedPieces.join("|") + ")", "i");
this._monthsShortRegex = this._monthsRegex;
this._monthsStrictRegex = new RegExp(
"^(" + longPieces.join("|") + ")",
"i"
);
this._monthsShortStrictRegex = new RegExp(
"^(" + shortPieces.join("|") + ")",
"i"
);
}
addFormatToken("Y", 0, 0, function() {
var y = this.year();
return y <= 9999 ? zeroFill(y, 4) : "+" + y;
});
addFormatToken(0, ["YY", 2], 0, function() {
return this.year() % 100;
});
addFormatToken(0, ["YYYY", 4], 0, "year");
addFormatToken(0, ["YYYYY", 5], 0, "year");
addFormatToken(0, ["YYYYYY", 6, true], 0, "year");
addUnitAlias("year", "y");
addUnitPriority("year", 1);
addRegexToken("Y", matchSigned);
addRegexToken("YY", match1to2, match2);
addRegexToken("YYYY", match1to4, match4);
addRegexToken("YYYYY", match1to6, match6);
addRegexToken("YYYYYY", match1to6, match6);
addParseToken(["YYYYY", "YYYYYY"], YEAR);
addParseToken("YYYY", function(input, array) {
array[YEAR] = input.length === 2 ? hooks.parseTwoDigitYear(input) : toInt(input);
});
addParseToken("YY", function(input, array) {
array[YEAR] = hooks.parseTwoDigitYear(input);
});
addParseToken("Y", function(input, array) {
array[YEAR] = parseInt(input, 10);
});
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
hooks.parseTwoDigitYear = function(input) {
return toInt(input) + (toInt(input) > 68 ? 1900 : 2e3);
};
var getSetYear = makeGetSet("FullYear", true);
function getIsLeapYear() {
return isLeapYear(this.year());
}
function createDate(y, m, d, h, M, s, ms) {
var date;
if (y < 100 && y >= 0) {
date = new Date(y + 400, m, d, h, M, s, ms);
if (isFinite(date.getFullYear())) {
date.setFullYear(y);
}
} else {
date = new Date(y, m, d, h, M, s, ms);
}
return date;
}
function createUTCDate(y) {
var date, args;
if (y < 100 && y >= 0) {
args = Array.prototype.slice.call(arguments);
args[0] = y + 400;
date = new Date(Date.UTC.apply(null, args));
if (isFinite(date.getUTCFullYear())) {
date.setUTCFullYear(y);
}
} else {
date = new Date(Date.UTC.apply(null, arguments));
}
return date;
}
function firstWeekOffset(year, dow, doy) {
var fwd = 7 + dow - doy, fwdlw = (7 + createUTCDate(year, 0, fwd).getUTCDay() - dow) % 7;
return -fwdlw + fwd - 1;
}
function dayOfYearFromWeeks(year, week, weekday, dow, doy) {
var localWeekday = (7 + weekday - dow) % 7, weekOffset = firstWeekOffset(year, dow, doy), dayOfYear = 1 + 7 * (week - 1) + localWeekday + weekOffset, resYear, resDayOfYear;
if (dayOfYear <= 0) {
resYear = year - 1;
resDayOfYear = daysInYear(resYear) + dayOfYear;
} else if (dayOfYear > daysInYear(year)) {
resYear = year + 1;
resDayOfYear = dayOfYear - daysInYear(year);
} else {
resYear = year;
resDayOfYear = dayOfYear;
}
return {
year: resYear,
dayOfYear: resDayOfYear
};
}
function weekOfYear(mom, dow, doy) {
var weekOffset = firstWeekOffset(mom.year(), dow, doy), week = Math.floor((mom.dayOfYear() - weekOffset - 1) / 7) + 1, resWeek, resYear;
if (week < 1) {
resYear = mom.year() - 1;
resWeek = week + weeksInYear(resYear, dow, doy);
} else if (week > weeksInYear(mom.year(), dow, doy)) {
resWeek = week - weeksInYear(mom.year(), dow, doy);
resYear = mom.year() + 1;
} else {
resYear = mom.year();
resWeek = week;
}
return {
week: resWeek,
year: resYear
};
}
function weeksInYear(year, dow, doy) {
var weekOffset = firstWeekOffset(year, dow, doy), weekOffsetNext = firstWeekOffset(year + 1, dow, doy);
return (daysInYear(year) - weekOffset + weekOffsetNext) / 7;
}
addFormatToken("w", ["ww", 2], "wo", "week");
addFormatToken("W", ["WW", 2], "Wo", "isoWeek");
addUnitAlias("week", "w");
addUnitAlias("isoWeek", "W");
addUnitPriority("week", 5);
addUnitPriority("isoWeek", 5);
addRegexToken("w", match1to2);
addRegexToken("ww", match1to2, match2);
addRegexToken("W", match1to2);
addRegexToken("WW", match1to2, match2);
addWeekParseToken(
["w", "ww", "W", "WW"],
function(input, week, config, token2) {
week[token2.substr(0, 1)] = toInt(input);
}
);
function localeWeek(mom) {
return weekOfYear(mom, this._week.dow, this._week.doy).week;
}
var defaultLocaleWeek = {
dow: 0,
doy: 6
};
function localeFirstDayOfWeek() {
return this._week.dow;
}
function localeFirstDayOfYear() {
return this._week.doy;
}
function getSetWeek(input) {
var week = this.localeData().week(this);
return input == null ? week : this.add((input - week) * 7, "d");
}
function getSetISOWeek(input) {
var week = weekOfYear(this, 1, 4).week;
return input == null ? week : this.add((input - week) * 7, "d");
}
addFormatToken("d", 0, "do", "day");
addFormatToken("dd", 0, 0, function(format2) {
return this.localeData().weekdaysMin(this, format2);
});
addFormatToken("ddd", 0, 0, function(format2) {
return this.localeData().weekdaysShort(this, format2);
});
addFormatToken("dddd", 0, 0, function(format2) {
return this.localeData().weekdays(this, format2);
});
addFormatToken("e", 0, 0, "weekday");
addFormatToken("E", 0, 0, "isoWeekday");
addUnitAlias("day", "d");
addUnitAlias("weekday", "e");
addUnitAlias("isoWeekday", "E");
addUnitPriority("day", 11);
addUnitPriority("weekday", 11);
addUnitPriority("isoWeekday", 11);
addRegexToken("d", match1to2);
addRegexToken("e", match1to2);
addRegexToken("E", match1to2);
addRegexToken("dd", function(isStrict, locale2) {
return locale2.weekdaysMinRegex(isStrict);
});
addRegexToken("ddd", function(isStrict, locale2) {
return locale2.weekdaysShortRegex(isStrict);
});
addRegexToken("dddd", function(isStrict, locale2) {
return locale2.weekdaysRegex(isStrict);
});
addWeekParseToken(["dd", "ddd", "dddd"], function(input, week, config, token2) {
var weekday = config._locale.weekdaysParse(input, token2, config._strict);
if (weekday != null) {
week.d = weekday;
} else {
getParsingFlags(config).invalidWeekday = input;
}
});
addWeekParseToken(["d", "e", "E"], function(input, week, config, token2) {
week[token2] = toInt(input);
});
function parseWeekday2(input, locale2) {
if (typeof input !== "string") {
return input;
}
if (!isNaN(input)) {
return parseInt(input, 10);
}
input = locale2.weekdaysParse(input);
if (typeof input === "number") {
return input;
}
return null;
}
function parseIsoWeekday(input, locale2) {
if (typeof input === "string") {
return locale2.weekdaysParse(input) % 7 || 7;
}
return isNaN(input) ? null : input;
}
function shiftWeekdays(ws, n) {
return ws.slice(n, 7).concat(ws.slice(0, n));
}
var defaultLocaleWeekdays = "Sunday_Monday_Tuesday_Wednesday_Thursday_Friday_Saturday".split("_"), defaultLocaleWeekdaysShort = "Sun_Mon_Tue_Wed_Thu_Fri_Sat".split("_"), defaultLocaleWeekdaysMin = "Su_Mo_Tu_We_Th_Fr_Sa".split("_"), defaultWeekdaysRegex = matchWord, defaultWeekdaysShortRegex = matchWord, defaultWeekdaysMinRegex = matchWord;
function localeWeekdays(m, format2) {
var weekdays = isArray2(this._weekdays) ? this._weekdays : this._weekdays[m && m !== true && this._weekdays.isFormat.test(format2) ? "format" : "standalone"];
return m === true ? shiftWeekdays(weekdays, this._week.dow) : m ? weekdays[m.day()] : weekdays;
}
function localeWeekdaysShort(m) {
return m === true ? shiftWeekdays(this._weekdaysShort, this._week.dow) : m ? this._weekdaysShort[m.day()] : this._weekdaysShort;
}
function localeWeekdaysMin(m) {
return m === true ? shiftWeekdays(this._weekdaysMin, this._week.dow) : m ? this._weekdaysMin[m.day()] : this._weekdaysMin;
}
function handleStrictParse$1(weekdayName, format2, strict) {
var i, ii, mom, llc = weekdayName.toLocaleLowerCase();
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._shortWeekdaysParse = [];
this._minWeekdaysParse = [];
for (i = 0; i < 7; ++i) {
mom = createUTC([2e3, 1]).day(i);
this._minWeekdaysParse[i] = this.weekdaysMin(
mom,
""
).toLocaleLowerCase();
this._shortWeekdaysParse[i] = this.weekdaysShort(
mom,
""
).toLocaleLowerCase();
this._weekdaysParse[i] = this.weekdays(mom, "").toLocaleLowerCase();
}
}
if (strict) {
if (format2 === "dddd") {
ii = indexOf.call(this._weekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format2 === "ddd") {
ii = indexOf.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
} else {
if (format2 === "dddd") {
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else if (format2 === "ddd") {
ii = indexOf.call(this._shortWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._minWeekdaysParse, llc);
return ii !== -1 ? ii : null;
} else {
ii = indexOf.call(this._minWeekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._weekdaysParse, llc);
if (ii !== -1) {
return ii;
}
ii = indexOf.call(this._shortWeekdaysParse, llc);
return ii !== -1 ? ii : null;
}
}
}
function localeWeekdaysParse(weekdayName, format2, strict) {
var i, mom, regex;
if (this._weekdaysParseExact) {
return handleStrictParse$1.call(this, weekdayName, format2, strict);
}
if (!this._weekdaysParse) {
this._weekdaysParse = [];
this._minWeekdaysParse = [];
this._shortWeekdaysParse = [];
this._fullWeekdaysParse = [];
}
for (i = 0; i < 7; i++) {
mom = createUTC([2e3, 1]).day(i);
if (strict && !this._fullWeekdaysParse[i]) {
this._fullWeekdaysParse[i] = new RegExp(
"^" + this.weekdays(mom, "").replace(".", "\\.?") + "$",
"i"
);
this._shortWeekdaysParse[i] = new RegExp(
"^" + this.weekdaysShort(mom, "").replace(".", "\\.?") + "$",
"i"
);
this._minWeekdaysParse[i] = new RegExp(
"^" + this.weekdaysMin(mom, "").replace(".", "\\.?") + "$",
"i"
);
}
if (!this._weekdaysParse[i]) {
regex = "^" + this.weekdays(mom, "") + "|^" + this.weekdaysShort(mom, "") + "|^" + this.weekdaysMin(mom, "");
this._weekdaysParse[i] = new RegExp(regex.replace(".", ""), "i");
}
if (strict && format2 === "dddd" && this._fullWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (strict && format2 === "ddd" && this._shortWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (strict && format2 === "dd" && this._minWeekdaysParse[i].test(weekdayName)) {
return i;
} else if (!strict && this._weekdaysParse[i].test(weekdayName)) {
return i;
}
}
}
function getSetDayOfWeek(input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var day = this._isUTC ? this._d.getUTCDay() : this._d.getDay();
if (input != null) {
input = parseWeekday2(input, this.localeData());
return this.add(input - day, "d");
} else {
return day;
}
}
function getSetLocaleDayOfWeek(input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
var weekday = (this.day() + 7 - this.localeData()._week.dow) % 7;
return input == null ? weekday : this.add(input - weekday, "d");
}
function getSetISODayOfWeek(input) {
if (!this.isValid()) {
return input != null ? this : NaN;
}
if (input != null) {
var weekday = parseIsoWeekday(input, this.localeData());
return this.day(this.day() % 7 ? weekday : weekday - 7);
} else {
return this.day() || 7;
}
}
function weekdaysRegex(isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, "_weekdaysRegex")) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysStrictRegex;
} else {
return this._weekdaysRegex;
}
} else {
if (!hasOwnProp(this, "_weekdaysRegex")) {
this._weekdaysRegex = defaultWeekdaysRegex;
}
return this._weekdaysStrictRegex && isStrict ? this._weekdaysStrictRegex : this._weekdaysRegex;
}
}
function weekdaysShortRegex(isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, "_weekdaysRegex")) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysShortStrictRegex;
} else {
return this._weekdaysShortRegex;
}
} else {
if (!hasOwnProp(this, "_weekdaysShortRegex")) {
this._weekdaysShortRegex = defaultWeekdaysShortRegex;
}
return this._weekdaysShortStrictRegex && isStrict ? this._weekdaysShortStrictRegex : this._weekdaysShortRegex;
}
}
function weekdaysMinRegex(isStrict) {
if (this._weekdaysParseExact) {
if (!hasOwnProp(this, "_weekdaysRegex")) {
computeWeekdaysParse.call(this);
}
if (isStrict) {
return this._weekdaysMinStrictRegex;
} else {
return this._weekdaysMinRegex;
}
} else {
if (!hasOwnProp(this, "_weekdaysMinRegex")) {
this._weekdaysMinRegex = defaultWeekdaysMinRegex;
}
return this._weekdaysMinStrictRegex && isStrict ? this._weekdaysMinStrictRegex : this._weekdaysMinRegex;
}
}
function computeWeekdaysParse() {
function cmpLenRev(a, b) {
return b.length - a.length;
}
var minPieces = [], shortPieces = [], longPieces = [], mixedPieces = [], i, mom, minp, shortp, longp;
for (i = 0; i < 7; i++) {
mom = createUTC([2e3, 1]).day(i);
minp = regexEscape(this.weekdaysMin(mom, ""));
shortp = regexEscape(this.weekdaysShort(mom, ""));
longp = regexEscape(this.weekdays(mom, ""));
minPieces.push(minp);
shortPieces.push(shortp);
longPieces.push(longp);
mixedPieces.push(minp);
mixedPieces.push(shortp);
mixedPieces.push(longp);
}
minPieces.sort(cmpLenRev);
shortPieces.sort(cmpLenRev);
longPieces.sort(cmpLenRev);
mixedPieces.sort(cmpLenRev);
this._weekdaysRegex = new RegExp("^(" + mixedPieces.join("|") + ")", "i");
this._weekdaysShortRegex = this._weekdaysRegex;
this._weekdaysMinRegex = this._weekdaysRegex;
this._weekdaysStrictRegex = new RegExp(
"^(" + longPieces.join("|") + ")",
"i"
);
this._weekdaysShortStrictRegex = new RegExp(
"^(" + shortPieces.join("|") + ")",
"i"
);
this._weekdaysMinStrictRegex = new RegExp(
"^(" + minPieces.join("|") + ")",
"i"
);
}
function hFormat() {
return this.hours() % 12 || 12;
}
function kFormat() {
return this.hours() || 24;
}
addFormatToken("H", ["HH", 2], 0, "hour");
addFormatToken("h", ["hh", 2], 0, hFormat);
addFormatToken("k", ["kk", 2], 0, kFormat);
addFormatToken("hmm", 0, 0, function() {
return "" + hFormat.apply(this) + zeroFill(this.minutes(), 2);
});
addFormatToken("hmmss", 0, 0, function() {
return "" + hFormat.apply(this) + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
});
addFormatToken("Hmm", 0, 0, function() {
return "" + this.hours() + zeroFill(this.minutes(), 2);
});
addFormatToken("Hmmss", 0, 0, function() {
return "" + this.hours() + zeroFill(this.minutes(), 2) + zeroFill(this.seconds(), 2);
});
function meridiem(token2, lowercase) {
addFormatToken(token2, 0, 0, function() {
return this.localeData().meridiem(
this.hours(),
this.minutes(),
lowercase
);
});
}
meridiem("a", true);
meridiem("A", false);
addUnitAlias("hour", "h");
addUnitPriority("hour", 13);
function matchMeridiem(isStrict, locale2) {
return locale2._meridiemParse;
}
addRegexToken("a", matchMeridiem);
addRegexToken("A", matchMeridiem);
addRegexToken("H", match1to2);
addRegexToken("h", match1to2);
addRegexToken("k", match1to2);
addRegexToken("HH", match1to2, match2);
addRegexToken("hh", match1to2, match2);
addRegexToken("kk", match1to2, match2);
addRegexToken("hmm", match3to4);
addRegexToken("hmmss", match5to6);
addRegexToken("Hmm", match3to4);
addRegexToken("Hmmss", match5to6);
addParseToken(["H", "HH"], HOUR);
addParseToken(["k", "kk"], function(input, array, config) {
var kInput = toInt(input);
array[HOUR] = kInput === 24 ? 0 : kInput;
});
addParseToken(["a", "A"], function(input, array, config) {
config._isPm = config._locale.isPM(input);
config._meridiem = input;
});
addParseToken(["h", "hh"], function(input, array, config) {
array[HOUR] = toInt(input);
getParsingFlags(config).bigHour = true;
});
addParseToken("hmm", function(input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
getParsingFlags(config).bigHour = true;
});
addParseToken("hmmss", function(input, array, config) {
var pos1 = input.length - 4, pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
getParsingFlags(config).bigHour = true;
});
addParseToken("Hmm", function(input, array, config) {
var pos = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos));
array[MINUTE] = toInt(input.substr(pos));
});
addParseToken("Hmmss", function(input, array, config) {
var pos1 = input.length - 4, pos2 = input.length - 2;
array[HOUR] = toInt(input.substr(0, pos1));
array[MINUTE] = toInt(input.substr(pos1, 2));
array[SECOND] = toInt(input.substr(pos2));
});
function localeIsPM(input) {
return (input + "").toLowerCase().charAt(0) === "p";
}
var defaultLocaleMeridiemParse = /[ap]\.?m?\.?/i, getSetHour = makeGetSet("Hours", true);
function localeMeridiem(hours2, minutes2, isLower) {
if (hours2 > 11) {
return isLower ? "pm" : "PM";
} else {
return isLower ? "am" : "AM";
}
}
var baseConfig = {
calendar: defaultCalendar,
longDateFormat: defaultLongDateFormat,
invalidDate: defaultInvalidDate,
ordinal: defaultOrdinal,
dayOfMonthOrdinalParse: defaultDayOfMonthOrdinalParse,
relativeTime: defaultRelativeTime,
months: defaultLocaleMonths,
monthsShort: defaultLocaleMonthsShort,
week: defaultLocaleWeek,
weekdays: defaultLocaleWeekdays,
weekdaysMin: defaultLocaleWeekdaysMin,
weekdaysShort: defaultLocaleWeekdaysShort,
meridiemParse: defaultLocaleMeridiemParse
};
var locales = {}, localeFamilies = {}, globalLocale;
function commonPrefix(arr1, arr2) {
var i, minl = Math.min(arr1.length, arr2.length);
for (i = 0; i < minl; i += 1) {
if (arr1[i] !== arr2[i]) {
return i;
}
}
return minl;
}
function normalizeLocale(key) {
return key ? key.toLowerCase().replace("_", "-") : key;
}
function chooseLocale(names) {
var i = 0, j, next, locale2, split2;
while (i < names.length) {
split2 = normalizeLocale(names[i]).split("-");
j = split2.length;
next = normalizeLocale(names[i + 1]);
next = next ? next.split("-") : null;
while (j > 0) {
locale2 = loadLocale(split2.slice(0, j).join("-"));
if (locale2) {
return locale2;
}
if (next && next.length >= j && commonPrefix(split2, next) >= j - 1) {
break;
}
j--;
}
i++;
}
return globalLocale;
}
function isLocaleNameSane(name) {
return name.match("^[^/\\\\]*$") != null;
}
function loadLocale(name) {
var oldLocale = null, aliasedRequire;
if (locales[name] === void 0 && typeof module2 !== "undefined" && module2 && module2.exports && isLocaleNameSane(name)) {
try {
oldLocale = globalLocale._abbr;
aliasedRequire = require;
aliasedRequire("./locale/" + name);
getSetGlobalLocale(oldLocale);
} catch (e) {
locales[name] = null;
}
}
return locales[name];
}
function getSetGlobalLocale(key, values) {
var data;
if (key) {
if (isUndefined(values)) {
data = getLocale(key);
} else {
data = defineLocale(key, values);
}
if (data) {
globalLocale = data;
} else {
if (typeof console !== "undefined" && console.warn) {
console.warn(
"Locale " + key + " not found. Did you forget to load it?"
);
}
}
}
return globalLocale._abbr;
}
function defineLocale(name, config) {
if (config !== null) {
var locale2, parentConfig = baseConfig;
config.abbr = name;
if (locales[name] != null) {
deprecateSimple(
"defineLocaleOverride",
"use moment.updateLocale(localeName, config) to change an existing locale. moment.defineLocale(localeName, config) should only be used for creating a new locale See http://momentjs.com/guides/#/warnings/define-locale/ for more info."
);
parentConfig = locales[name]._config;
} else if (config.parentLocale != null) {
if (locales[config.parentLocale] != null) {
parentConfig = locales[config.parentLocale]._config;
} else {
locale2 = loadLocale(config.parentLocale);
if (locale2 != null) {
parentConfig = locale2._config;
} else {
if (!localeFamilies[config.parentLocale]) {
localeFamilies[config.parentLocale] = [];
}
localeFamilies[config.parentLocale].push({
name,
config
});
return null;
}
}
}
locales[name] = new Locale(mergeConfigs(parentConfig, config));
if (localeFamilies[name]) {
localeFamilies[name].forEach(function(x) {
defineLocale(x.name, x.config);
});
}
getSetGlobalLocale(name);
return locales[name];
} else {
delete locales[name];
return null;
}
}
function updateLocale(name, config) {
if (config != null) {
var locale2, tmpLocale, parentConfig = baseConfig;
if (locales[name] != null && locales[name].parentLocale != null) {
locales[name].set(mergeConfigs(locales[name]._config, config));
} else {
tmpLocale = loadLocale(name);
if (tmpLocale != null) {
parentConfig = tmpLocale._config;
}
config = mergeConfigs(parentConfig, config);
if (tmpLocale == null) {
config.abbr = name;
}
locale2 = new Locale(config);
locale2.parentLocale = locales[name];
locales[name] = locale2;
}
getSetGlobalLocale(name);
} else {
if (locales[name] != null) {
if (locales[name].parentLocale != null) {
locales[name] = locales[name].parentLocale;
if (name === getSetGlobalLocale()) {
getSetGlobalLocale(name);
}
} else if (locales[name] != null) {
delete locales[name];
}
}
}
return locales[name];
}
function getLocale(key) {
var locale2;
if (key && key._locale && key._locale._abbr) {
key = key._locale._abbr;
}
if (!key) {
return globalLocale;
}
if (!isArray2(key)) {
locale2 = loadLocale(key);
if (locale2) {
return locale2;
}
key = [key];
}
return chooseLocale(key);
}
function listLocales() {
return keys(locales);
}
function checkOverflow(m) {
var overflow, a = m._a;
if (a && getParsingFlags(m).overflow === -2) {
overflow = a[MONTH] < 0 || a[MONTH] > 11 ? MONTH : a[DATE] < 1 || a[DATE] > daysInMonth(a[YEAR], a[MONTH]) ? DATE : a[HOUR] < 0 || a[HOUR] > 24 || a[HOUR] === 24 && (a[MINUTE] !== 0 || a[SECOND] !== 0 || a[MILLISECOND] !== 0) ? HOUR : a[MINUTE] < 0 || a[MINUTE] > 59 ? MINUTE : a[SECOND] < 0 || a[SECOND] > 59 ? SECOND : a[MILLISECOND] < 0 || a[MILLISECOND] > 999 ? MILLISECOND : -1;
if (getParsingFlags(m)._overflowDayOfYear && (overflow < YEAR || overflow > DATE)) {
overflow = DATE;
}
if (getParsingFlags(m)._overflowWeeks && overflow === -1) {
overflow = WEEK;
}
if (getParsingFlags(m)._overflowWeekday && overflow === -1) {
overflow = WEEKDAY;
}
getParsingFlags(m).overflow = overflow;
}
return m;
}
var extendedIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})-(?:\d\d-\d\d|W\d\d-\d|W\d\d|\d\d\d|\d\d))(?:(T| )(\d\d(?::\d\d(?::\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, basicIsoRegex = /^\s*((?:[+-]\d{6}|\d{4})(?:\d\d\d\d|W\d\d\d|W\d\d|\d\d\d|\d\d|))(?:(T| )(\d\d(?:\d\d(?:\d\d(?:[.,]\d+)?)?)?)([+-]\d\d(?::?\d\d)?|\s*Z)?)?$/, tzRegex = /Z|[+-]\d\d(?::?\d\d)?/, isoDates = [
["YYYYYY-MM-DD", /[+-]\d{6}-\d\d-\d\d/],
["YYYY-MM-DD", /\d{4}-\d\d-\d\d/],
["GGGG-[W]WW-E", /\d{4}-W\d\d-\d/],
["GGGG-[W]WW", /\d{4}-W\d\d/, false],
["YYYY-DDD", /\d{4}-\d{3}/],
["YYYY-MM", /\d{4}-\d\d/, false],
["YYYYYYMMDD", /[+-]\d{10}/],
["YYYYMMDD", /\d{8}/],
["GGGG[W]WWE", /\d{4}W\d{3}/],
["GGGG[W]WW", /\d{4}W\d{2}/, false],
["YYYYDDD", /\d{7}/],
["YYYYMM", /\d{6}/, false],
["YYYY", /\d{4}/, false]
], isoTimes = [
["HH:mm:ss.SSSS", /\d\d:\d\d:\d\d\.\d+/],
["HH:mm:ss,SSSS", /\d\d:\d\d:\d\d,\d+/],
["HH:mm:ss", /\d\d:\d\d:\d\d/],
["HH:mm", /\d\d:\d\d/],
["HHmmss.SSSS", /\d\d\d\d\d\d\.\d+/],
["HHmmss,SSSS", /\d\d\d\d\d\d,\d+/],
["HHmmss", /\d\d\d\d\d\d/],
["HHmm", /\d\d\d\d/],
["HH", /\d\d/]
], aspNetJsonRegex = /^\/?Date\((-?\d+)/i, rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),?\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|([+-]\d{4}))$/, obsOffsets = {
UT: 0,
GMT: 0,
EDT: -4 * 60,
EST: -5 * 60,
CDT: -5 * 60,
CST: -6 * 60,
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
PST: -8 * 60
};
function configFromISO(config) {
var i, l, string = config._i, match = extendedIsoRegex.exec(string) || basicIsoRegex.exec(string), allowTime, dateFormat, timeFormat, tzFormat, isoDatesLen = isoDates.length, isoTimesLen = isoTimes.length;
if (match) {
getParsingFlags(config).iso = true;
for (i = 0, l = isoDatesLen; i < l; i++) {
if (isoDates[i][1].exec(match[1])) {
dateFormat = isoDates[i][0];
allowTime = isoDates[i][2] !== false;
break;
}
}
if (dateFormat == null) {
config._isValid = false;
return;
}
if (match[3]) {
for (i = 0, l = isoTimesLen; i < l; i++) {
if (isoTimes[i][1].exec(match[3])) {
timeFormat = (match[2] || " ") + isoTimes[i][0];
break;
}
}
if (timeFormat == null) {
config._isValid = false;
return;
}
}
if (!allowTime && timeFormat != null) {
config._isValid = false;
return;
}
if (match[4]) {
if (tzRegex.exec(match[4])) {
tzFormat = "Z";
} else {
config._isValid = false;
return;
}
}
config._f = dateFormat + (timeFormat || "") + (tzFormat || "");
configFromStringAndFormat(config);
} else {
config._isValid = false;
}
}
function extractFromRFC2822Strings(yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
var result = [
untruncateYear(yearStr),
defaultLocaleMonthsShort.indexOf(monthStr),
parseInt(dayStr, 10),
parseInt(hourStr, 10),
parseInt(minuteStr, 10)
];
if (secondStr) {
result.push(parseInt(secondStr, 10));
}
return result;
}
function untruncateYear(yearStr) {
var year = parseInt(yearStr, 10);
if (year <= 49) {
return 2e3 + year;
} else if (year <= 999) {
return 1900 + year;
}
return year;
}
function preprocessRFC2822(s) {
return s.replace(/\([^()]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").replace(/^\s\s*/, "").replace(/\s\s*$/, "");
}
function checkWeekday(weekdayStr, parsedInput, config) {
if (weekdayStr) {
var weekdayProvided = defaultLocaleWeekdaysShort.indexOf(weekdayStr), weekdayActual = new Date(
parsedInput[0],
parsedInput[1],
parsedInput[2]
).getDay();
if (weekdayProvided !== weekdayActual) {
getParsingFlags(config).weekdayMismatch = true;
config._isValid = false;
return false;
}
}
return true;
}
function calculateOffset(obsOffset, militaryOffset, numOffset) {
if (obsOffset) {
return obsOffsets[obsOffset];
} else if (militaryOffset) {
return 0;
} else {
var hm = parseInt(numOffset, 10), m = hm % 100, h = (hm - m) / 100;
return h * 60 + m;
}
}
function configFromRFC2822(config) {
var match = rfc2822.exec(preprocessRFC2822(config._i)), parsedArray;
if (match) {
parsedArray = extractFromRFC2822Strings(
match[4],
match[3],
match[2],
match[5],
match[6],
match[7]
);
if (!checkWeekday(match[1], parsedArray, config)) {
return;
}
config._a = parsedArray;
config._tzm = calculateOffset(match[8], match[9], match[10]);
config._d = createUTCDate.apply(null, config._a);
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
getParsingFlags(config).rfc2822 = true;
} else {
config._isValid = false;
}
}
function configFromString(config) {
var matched = aspNetJsonRegex.exec(config._i);
if (matched !== null) {
config._d = new Date(+matched[1]);
return;
}
configFromISO(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
configFromRFC2822(config);
if (config._isValid === false) {
delete config._isValid;
} else {
return;
}
if (config._strict) {
config._isValid = false;
} else {
hooks.createFromInputFallback(config);
}
}
hooks.createFromInputFallback = deprecate(
"value provided is not in a recognized RFC2822 or ISO format. moment construction falls back to js Date(), which is not reliable across all browsers and versions. Non RFC2822/ISO date formats are discouraged. Please refer to http://momentjs.com/guides/#/warnings/js-date/ for more info.",
function(config) {
config._d = new Date(config._i + (config._useUTC ? " UTC" : ""));
}
);
function defaults(a, b, c) {
if (a != null) {
return a;
}
if (b != null) {
return b;
}
return c;
}
function currentDateArray(config) {
var nowValue = new Date(hooks.now());
if (config._useUTC) {
return [
nowValue.getUTCFullYear(),
nowValue.getUTCMonth(),
nowValue.getUTCDate()
];
}
return [nowValue.getFullYear(), nowValue.getMonth(), nowValue.getDate()];
}
function configFromArray(config) {
var i, date, input = [], currentDate, expectedWeekday, yearToUse;
if (config._d) {
return;
}
currentDate = currentDateArray(config);
if (config._w && config._a[DATE] == null && config._a[MONTH] == null) {
dayOfYearFromWeekInfo(config);
}
if (config._dayOfYear != null) {
yearToUse = defaults(config._a[YEAR], currentDate[YEAR]);
if (config._dayOfYear > daysInYear(yearToUse) || config._dayOfYear === 0) {
getParsingFlags(config)._overflowDayOfYear = true;
}
date = createUTCDate(yearToUse, 0, config._dayOfYear);
config._a[MONTH] = date.getUTCMonth();
config._a[DATE] = date.getUTCDate();
}
for (i = 0; i < 3 && config._a[i] == null; ++i) {
config._a[i] = input[i] = currentDate[i];
}
for (; i < 7; i++) {
config._a[i] = input[i] = config._a[i] == null ? i === 2 ? 1 : 0 : config._a[i];
}
if (config._a[HOUR] === 24 && config._a[MINUTE] === 0 && config._a[SECOND] === 0 && config._a[MILLISECOND] === 0) {
config._nextDay = true;
config._a[HOUR] = 0;
}
config._d = (config._useUTC ? createUTCDate : createDate).apply(
null,
input
);
expectedWeekday = config._useUTC ? config._d.getUTCDay() : config._d.getDay();
if (config._tzm != null) {
config._d.setUTCMinutes(config._d.getUTCMinutes() - config._tzm);
}
if (config._nextDay) {
config._a[HOUR] = 24;
}
if (config._w && typeof config._w.d !== "undefined" && config._w.d !== expectedWeekday) {
getParsingFlags(config).weekdayMismatch = true;
}
}
function dayOfYearFromWeekInfo(config) {
var w, weekYear, week, weekday, dow, doy, temp, weekdayOverflow, curWeek;
w = config._w;
if (w.GG != null || w.W != null || w.E != null) {
dow = 1;
doy = 4;
weekYear = defaults(
w.GG,
config._a[YEAR],
weekOfYear(createLocal(), 1, 4).year
);
week = defaults(w.W, 1);
weekday = defaults(w.E, 1);
if (weekday < 1 || weekday > 7) {
weekdayOverflow = true;
}
} else {
dow = config._locale._week.dow;
doy = config._locale._week.doy;
curWeek = weekOfYear(createLocal(), dow, doy);
weekYear = defaults(w.gg, config._a[YEAR], curWeek.year);
week = defaults(w.w, curWeek.week);
if (w.d != null) {
weekday = w.d;
if (weekday < 0 || weekday > 6) {
weekdayOverflow = true;
}
} else if (w.e != null) {
weekday = w.e + dow;
if (w.e < 0 || w.e > 6) {
weekdayOverflow = true;
}
} else {
weekday = dow;
}
}
if (week < 1 || week > weeksInYear(weekYear, dow, doy)) {
getParsingFlags(config)._overflowWeeks = true;
} else if (weekdayOverflow != null) {
getParsingFlags(config)._overflowWeekday = true;
} else {
temp = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy);
config._a[YEAR] = temp.year;
config._dayOfYear = temp.dayOfYear;
}
}
hooks.ISO_8601 = function() {
};
hooks.RFC_2822 = function() {
};
function configFromStringAndFormat(config) {
if (config._f === hooks.ISO_8601) {
configFromISO(config);
return;
}
if (config._f === hooks.RFC_2822) {
configFromRFC2822(config);
return;
}
config._a = [];
getParsingFlags(config).empty = true;
var string = "" + config._i, i, parsedInput, tokens2, token2, skipped, stringLength = string.length, totalParsedInputLength = 0, era, tokenLen;
tokens2 = expandFormat(config._f, config._locale).match(formattingTokens) || [];
tokenLen = tokens2.length;
for (i = 0; i < tokenLen; i++) {
token2 = tokens2[i];
parsedInput = (string.match(getParseRegexForToken(token2, config)) || [])[0];
if (parsedInput) {
skipped = string.substr(0, string.indexOf(parsedInput));
if (skipped.length > 0) {
getParsingFlags(config).unusedInput.push(skipped);
}
string = string.slice(
string.indexOf(parsedInput) + parsedInput.length
);
totalParsedInputLength += parsedInput.length;
}
if (formatTokenFunctions[token2]) {
if (parsedInput) {
getParsingFlags(config).empty = false;
} else {
getParsingFlags(config).unusedTokens.push(token2);
}
addTimeToArrayFromToken(token2, parsedInput, config);
} else if (config._strict && !parsedInput) {
getParsingFlags(config).unusedTokens.push(token2);
}
}
getParsingFlags(config).charsLeftOver = stringLength - totalParsedInputLength;
if (string.length > 0) {
getParsingFlags(config).unusedInput.push(string);
}
if (config._a[HOUR] <= 12 && getParsingFlags(config).bigHour === true && config._a[HOUR] > 0) {
getParsingFlags(config).bigHour = void 0;
}
getParsingFlags(config).parsedDateParts = config._a.slice(0);
getParsingFlags(config).meridiem = config._meridiem;
config._a[HOUR] = meridiemFixWrap(
config._locale,
config._a[HOUR],
config._meridiem
);
era = getParsingFlags(config).era;
if (era !== null) {
config._a[YEAR] = config._locale.erasConvertYear(era, config._a[YEAR]);
}
configFromArray(config);
checkOverflow(config);
}
function meridiemFixWrap(locale2, hour, meridiem2) {
var isPm;
if (meridiem2 == null) {
return hour;
}
if (locale2.meridiemHour != null) {
return locale2.meridiemHour(hour, meridiem2);
} else if (locale2.isPM != null) {
isPm = locale2.isPM(meridiem2);
if (isPm && hour < 12) {
hour += 12;
}
if (!isPm && hour === 12) {
hour = 0;
}
return hour;
} else {
return hour;
}
}
function configFromStringAndArray(config) {
var tempConfig, bestMoment, scoreToBeat, i, currentScore, validFormatFound, bestFormatIsValid = false, configfLen = config._f.length;
if (configfLen === 0) {
getParsingFlags(config).invalidFormat = true;
config._d = new Date(NaN);
return;
}
for (i = 0; i < configfLen; i++) {
currentScore = 0;
validFormatFound = false;
tempConfig = copyConfig({}, config);
if (config._useUTC != null) {
tempConfig._useUTC = config._useUTC;
}
tempConfig._f = config._f[i];
configFromStringAndFormat(tempConfig);
if (isValid(tempConfig)) {
validFormatFound = true;
}
currentScore += getParsingFlags(tempConfig).charsLeftOver;
currentScore += getParsingFlags(tempConfig).unusedTokens.length * 10;
getParsingFlags(tempConfig).score = currentScore;
if (!bestFormatIsValid) {
if (scoreToBeat == null || currentScore < scoreToBeat || validFormatFound) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
if (validFormatFound) {
bestFormatIsValid = true;
}
}
} else {
if (currentScore < scoreToBeat) {
scoreToBeat = currentScore;
bestMoment = tempConfig;
}
}
}
extend(config, bestMoment || tempConfig);
}
function configFromObject(config) {
if (config._d) {
return;
}
var i = normalizeObjectUnits(config._i), dayOrDate = i.day === void 0 ? i.date : i.day;
config._a = map(
[i.year, i.month, dayOrDate, i.hour, i.minute, i.second, i.millisecond],
function(obj) {
return obj && parseInt(obj, 10);
}
);
configFromArray(config);
}
function createFromConfig(config) {
var res = new Moment2(checkOverflow(prepareConfig(config)));
if (res._nextDay) {
res.add(1, "d");
res._nextDay = void 0;
}
return res;
}
function prepareConfig(config) {
var input = config._i, format2 = config._f;
config._locale = config._locale || getLocale(config._l);
if (input === null || format2 === void 0 && input === "") {
return createInvalid({ nullInput: true });
}
if (typeof input === "string") {
config._i = input = config._locale.preparse(input);
}
if (isMoment(input)) {
return new Moment2(checkOverflow(input));
} else if (isDate(input)) {
config._d = input;
} else if (isArray2(format2)) {
configFromStringAndArray(config);
} else if (format2) {
configFromStringAndFormat(config);
} else {
configFromInput(config);
}
if (!isValid(config)) {
config._d = null;
}
return config;
}
function configFromInput(config) {
var input = config._i;
if (isUndefined(input)) {
config._d = new Date(hooks.now());
} else if (isDate(input)) {
config._d = new Date(input.valueOf());
} else if (typeof input === "string") {
configFromString(config);
} else if (isArray2(input)) {
config._a = map(input.slice(0), function(obj) {
return parseInt(obj, 10);
});
configFromArray(config);
} else if (isObject(input)) {
configFromObject(config);
} else if (isNumber2(input)) {
config._d = new Date(input);
} else {
hooks.createFromInputFallback(config);
}
}
function createLocalOrUTC(input, format2, locale2, strict, isUTC) {
var c = {};
if (format2 === true || format2 === false) {
strict = format2;
format2 = void 0;
}
if (locale2 === true || locale2 === false) {
strict = locale2;
locale2 = void 0;
}
if (isObject(input) && isObjectEmpty(input) || isArray2(input) && input.length === 0) {
input = void 0;
}
c._isAMomentObject = true;
c._useUTC = c._isUTC = isUTC;
c._l = locale2;
c._i = input;
c._f = format2;
c._strict = strict;
return createFromConfig(c);
}
function createLocal(input, format2, locale2, strict) {
return createLocalOrUTC(input, format2, locale2, strict, false);
}
var prototypeMin = deprecate(
"moment().min is deprecated, use moment.max instead. http://momentjs.com/guides/#/warnings/min-max/",
function() {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other < this ? this : other;
} else {
return createInvalid();
}
}
), prototypeMax = deprecate(
"moment().max is deprecated, use moment.min instead. http://momentjs.com/guides/#/warnings/min-max/",
function() {
var other = createLocal.apply(null, arguments);
if (this.isValid() && other.isValid()) {
return other > this ? this : other;
} else {
return createInvalid();
}
}
);
function pickBy(fn, moments) {
var res, i;
if (moments.length === 1 && isArray2(moments[0])) {
moments = moments[0];
}
if (!moments.length) {
return createLocal();
}
res = moments[0];
for (i = 1; i < moments.length; ++i) {
if (!moments[i].isValid() || moments[i][fn](res)) {
res = moments[i];
}
}
return res;
}
function min() {
var args = [].slice.call(arguments, 0);
return pickBy("isBefore", args);
}
function max() {
var args = [].slice.call(arguments, 0);
return pickBy("isAfter", args);
}
var now = function() {
return Date.now ? Date.now() : +new Date();
};
var ordering = [
"year",
"quarter",
"month",
"week",
"day",
"hour",
"minute",
"second",
"millisecond"
];
function isDurationValid(m) {
var key, unitHasDecimal = false, i, orderLen = ordering.length;
for (key in m) {
if (hasOwnProp(m, key) && !(indexOf.call(ordering, key) !== -1 && (m[key] == null || !isNaN(m[key])))) {
return false;
}
}
for (i = 0; i < orderLen; ++i) {
if (m[ordering[i]]) {
if (unitHasDecimal) {
return false;
}
if (parseFloat(m[ordering[i]]) !== toInt(m[ordering[i]])) {
unitHasDecimal = true;
}
}
}
return true;
}
function isValid$1() {
return this._isValid;
}
function createInvalid$1() {
return createDuration(NaN);
}
function Duration(duration) {
var normalizedInput = normalizeObjectUnits(duration), years2 = normalizedInput.year || 0, quarters = normalizedInput.quarter || 0, months2 = normalizedInput.month || 0, weeks2 = normalizedInput.week || normalizedInput.isoWeek || 0, days2 = normalizedInput.day || 0, hours2 = normalizedInput.hour || 0, minutes2 = normalizedInput.minute || 0, seconds2 = normalizedInput.second || 0, milliseconds2 = normalizedInput.millisecond || 0;
this._isValid = isDurationValid(normalizedInput);
this._milliseconds = +milliseconds2 + seconds2 * 1e3 + minutes2 * 6e4 + hours2 * 1e3 * 60 * 60;
this._days = +days2 + weeks2 * 7;
this._months = +months2 + quarters * 3 + years2 * 12;
this._data = {};
this._locale = getLocale();
this._bubble();
}
function isDuration(obj) {
return obj instanceof Duration;
}
function absRound(number) {
if (number < 0) {
return Math.round(-1 * number) * -1;
} else {
return Math.round(number);
}
}
function compareArrays(array1, array2, dontConvert) {
var len = Math.min(array1.length, array2.length), lengthDiff = Math.abs(array1.length - array2.length), diffs = 0, i;
for (i = 0; i < len; i++) {
if (dontConvert && array1[i] !== array2[i] || !dontConvert && toInt(array1[i]) !== toInt(array2[i])) {
diffs++;
}
}
return diffs + lengthDiff;
}
function offset(token2, separator) {
addFormatToken(token2, 0, 0, function() {
var offset2 = this.utcOffset(), sign2 = "+";
if (offset2 < 0) {
offset2 = -offset2;
sign2 = "-";
}
return sign2 + zeroFill(~~(offset2 / 60), 2) + separator + zeroFill(~~offset2 % 60, 2);
});
}
offset("Z", ":");
offset("ZZ", "");
addRegexToken("Z", matchShortOffset);
addRegexToken("ZZ", matchShortOffset);
addParseToken(["Z", "ZZ"], function(input, array, config) {
config._useUTC = true;
config._tzm = offsetFromString(matchShortOffset, input);
});
var chunkOffset = /([\+\-]|\d\d)/gi;
function offsetFromString(matcher, string) {
var matches = (string || "").match(matcher), chunk, parts, minutes2;
if (matches === null) {
return null;
}
chunk = matches[matches.length - 1] || [];
parts = (chunk + "").match(chunkOffset) || ["-", 0, 0];
minutes2 = +(parts[1] * 60) + toInt(parts[2]);
return minutes2 === 0 ? 0 : parts[0] === "+" ? minutes2 : -minutes2;
}
function cloneWithOffset(input, model) {
var res, diff2;
if (model._isUTC) {
res = model.clone();
diff2 = (isMoment(input) || isDate(input) ? input.valueOf() : createLocal(input).valueOf()) - res.valueOf();
res._d.setTime(res._d.valueOf() + diff2);
hooks.updateOffset(res, false);
return res;
} else {
return createLocal(input).local();
}
}
function getDateOffset(m) {
return -Math.round(m._d.getTimezoneOffset());
}
hooks.updateOffset = function() {
};
function getSetOffset(input, keepLocalTime, keepMinutes) {
var offset2 = this._offset || 0, localAdjust;
if (!this.isValid()) {
return input != null ? this : NaN;
}
if (input != null) {
if (typeof input === "string") {
input = offsetFromString(matchShortOffset, input);
if (input === null) {
return this;
}
} else if (Math.abs(input) < 16 && !keepMinutes) {
input = input * 60;
}
if (!this._isUTC && keepLocalTime) {
localAdjust = getDateOffset(this);
}
this._offset = input;
this._isUTC = true;
if (localAdjust != null) {
this.add(localAdjust, "m");
}
if (offset2 !== input) {
if (!keepLocalTime || this._changeInProgress) {
addSubtract(
this,
createDuration(input - offset2, "m"),
1,
false
);
} else if (!this._changeInProgress) {
this._changeInProgress = true;
hooks.updateOffset(this, true);
this._changeInProgress = null;
}
}
return this;
} else {
return this._isUTC ? offset2 : getDateOffset(this);
}
}
function getSetZone(input, keepLocalTime) {
if (input != null) {
if (typeof input !== "string") {
input = -input;
}
this.utcOffset(input, keepLocalTime);
return this;
} else {
return -this.utcOffset();
}
}
function setOffsetToUTC(keepLocalTime) {
return this.utcOffset(0, keepLocalTime);
}
function setOffsetToLocal(keepLocalTime) {
if (this._isUTC) {
this.utcOffset(0, keepLocalTime);
this._isUTC = false;
if (keepLocalTime) {
this.subtract(getDateOffset(this), "m");
}
}
return this;
}
function setOffsetToParsedOffset() {
if (this._tzm != null) {
this.utcOffset(this._tzm, false, true);
} else if (typeof this._i === "string") {
var tZone = offsetFromString(matchOffset, this._i);
if (tZone != null) {
this.utcOffset(tZone);
} else {
this.utcOffset(0, true);
}
}
return this;
}
function hasAlignedHourOffset(input) {
if (!this.isValid()) {
return false;
}
input = input ? createLocal(input).utcOffset() : 0;
return (this.utcOffset() - input) % 60 === 0;
}
function isDaylightSavingTime() {
return this.utcOffset() > this.clone().month(0).utcOffset() || this.utcOffset() > this.clone().month(5).utcOffset();
}
function isDaylightSavingTimeShifted() {
if (!isUndefined(this._isDSTShifted)) {
return this._isDSTShifted;
}
var c = {}, other;
copyConfig(c, this);
c = prepareConfig(c);
if (c._a) {
other = c._isUTC ? createUTC(c._a) : createLocal(c._a);
this._isDSTShifted = this.isValid() && compareArrays(c._a, other.toArray()) > 0;
} else {
this._isDSTShifted = false;
}
return this._isDSTShifted;
}
function isLocal() {
return this.isValid() ? !this._isUTC : false;
}
function isUtcOffset() {
return this.isValid() ? this._isUTC : false;
}
function isUtc() {
return this.isValid() ? this._isUTC && this._offset === 0 : false;
}
var aspNetRegex = /^(-|\+)?(?:(\d*)[. ])?(\d+):(\d+)(?::(\d+)(\.\d*)?)?$/, isoRegex = /^(-|\+)?P(?:([-+]?[0-9,.]*)Y)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)W)?(?:([-+]?[0-9,.]*)D)?(?:T(?:([-+]?[0-9,.]*)H)?(?:([-+]?[0-9,.]*)M)?(?:([-+]?[0-9,.]*)S)?)?$/;
function createDuration(input, key) {
var duration = input, match = null, sign2, ret, diffRes;
if (isDuration(input)) {
duration = {
ms: input._milliseconds,
d: input._days,
M: input._months
};
} else if (isNumber2(input) || !isNaN(+input)) {
duration = {};
if (key) {
duration[key] = +input;
} else {
duration.milliseconds = +input;
}
} else if (match = aspNetRegex.exec(input)) {
sign2 = match[1] === "-" ? -1 : 1;
duration = {
y: 0,
d: toInt(match[DATE]) * sign2,
h: toInt(match[HOUR]) * sign2,
m: toInt(match[MINUTE]) * sign2,
s: toInt(match[SECOND]) * sign2,
ms: toInt(absRound(match[MILLISECOND] * 1e3)) * sign2
};
} else if (match = isoRegex.exec(input)) {
sign2 = match[1] === "-" ? -1 : 1;
duration = {
y: parseIso(match[2], sign2),
M: parseIso(match[3], sign2),
w: parseIso(match[4], sign2),
d: parseIso(match[5], sign2),
h: parseIso(match[6], sign2),
m: parseIso(match[7], sign2),
s: parseIso(match[8], sign2)
};
} else if (duration == null) {
duration = {};
} else if (typeof duration === "object" && ("from" in duration || "to" in duration)) {
diffRes = momentsDifference(
createLocal(duration.from),
createLocal(duration.to)
);
duration = {};
duration.ms = diffRes.milliseconds;
duration.M = diffRes.months;
}
ret = new Duration(duration);
if (isDuration(input) && hasOwnProp(input, "_locale")) {
ret._locale = input._locale;
}
if (isDuration(input) && hasOwnProp(input, "_isValid")) {
ret._isValid = input._isValid;
}
return ret;
}
createDuration.fn = Duration.prototype;
createDuration.invalid = createInvalid$1;
function parseIso(inp, sign2) {
var res = inp && parseFloat(inp.replace(",", "."));
return (isNaN(res) ? 0 : res) * sign2;
}
function positiveMomentsDifference(base, other) {
var res = {};
res.months = other.month() - base.month() + (other.year() - base.year()) * 12;
if (base.clone().add(res.months, "M").isAfter(other)) {
--res.months;
}
res.milliseconds = +other - +base.clone().add(res.months, "M");
return res;
}
function momentsDifference(base, other) {
var res;
if (!(base.isValid() && other.isValid())) {
return { milliseconds: 0, months: 0 };
}
other = cloneWithOffset(other, base);
if (base.isBefore(other)) {
res = positiveMomentsDifference(base, other);
} else {
res = positiveMomentsDifference(other, base);
res.milliseconds = -res.milliseconds;
res.months = -res.months;
}
return res;
}
function createAdder(direction, name) {
return function(val, period) {
var dur, tmp;
if (period !== null && !isNaN(+period)) {
deprecateSimple(
name,
"moment()." + name + "(period, number) is deprecated. Please use moment()." + name + "(number, period). See http://momentjs.com/guides/#/warnings/add-inverted-param/ for more info."
);
tmp = val;
val = period;
period = tmp;
}
dur = createDuration(val, period);
addSubtract(this, dur, direction);
return this;
};
}
function addSubtract(mom, duration, isAdding, updateOffset) {
var milliseconds2 = duration._milliseconds, days2 = absRound(duration._days), months2 = absRound(duration._months);
if (!mom.isValid()) {
return;
}
updateOffset = updateOffset == null ? true : updateOffset;
if (months2) {
setMonth(mom, get(mom, "Month") + months2 * isAdding);
}
if (days2) {
set$1(mom, "Date", get(mom, "Date") + days2 * isAdding);
}
if (milliseconds2) {
mom._d.setTime(mom._d.valueOf() + milliseconds2 * isAdding);
}
if (updateOffset) {
hooks.updateOffset(mom, days2 || months2);
}
}
var add2 = createAdder(1, "add"), subtract = createAdder(-1, "subtract");
function isString(input) {
return typeof input === "string" || input instanceof String;
}
function isMomentInput(input) {
return isMoment(input) || isDate(input) || isString(input) || isNumber2(input) || isNumberOrStringArray(input) || isMomentInputObject(input) || input === null || input === void 0;
}
function isMomentInputObject(input) {
var objectTest = isObject(input) && !isObjectEmpty(input), propertyTest = false, properties = [
"years",
"year",
"y",
"months",
"month",
"M",
"days",
"day",
"d",
"dates",
"date",
"D",
"hours",
"hour",
"h",
"minutes",
"minute",
"m",
"seconds",
"second",
"s",
"milliseconds",
"millisecond",
"ms"
], i, property, propertyLen = properties.length;
for (i = 0; i < propertyLen; i += 1) {
property = properties[i];
propertyTest = propertyTest || hasOwnProp(input, property);
}
return objectTest && propertyTest;
}
function isNumberOrStringArray(input) {
var arrayTest = isArray2(input), dataTypeTest = false;
if (arrayTest) {
dataTypeTest = input.filter(function(item) {
return !isNumber2(item) && isString(input);
}).length === 0;
}
return arrayTest && dataTypeTest;
}
function isCalendarSpec(input) {
var objectTest = isObject(input) && !isObjectEmpty(input), propertyTest = false, properties = [
"sameDay",
"nextDay",
"lastDay",
"nextWeek",
"lastWeek",
"sameElse"
], i, property;
for (i = 0; i < properties.length; i += 1) {
property = properties[i];
propertyTest = propertyTest || hasOwnProp(input, property);
}
return objectTest && propertyTest;
}
function getCalendarFormat(myMoment, now2) {
var diff2 = myMoment.diff(now2, "days", true);
return diff2 < -6 ? "sameElse" : diff2 < -1 ? "lastWeek" : diff2 < 0 ? "lastDay" : diff2 < 1 ? "sameDay" : diff2 < 2 ? "nextDay" : diff2 < 7 ? "nextWeek" : "sameElse";
}
function calendar$1(time, formats) {
if (arguments.length === 1) {
if (!arguments[0]) {
time = void 0;
formats = void 0;
} else if (isMomentInput(arguments[0])) {
time = arguments[0];
formats = void 0;
} else if (isCalendarSpec(arguments[0])) {
formats = arguments[0];
time = void 0;
}
}
var now2 = time || createLocal(), sod = cloneWithOffset(now2, this).startOf("day"), format2 = hooks.calendarFormat(this, sod) || "sameElse", output = formats && (isFunction(formats[format2]) ? formats[format2].call(this, now2) : formats[format2]);
return this.format(
output || this.localeData().calendar(format2, this, createLocal(now2))
);
}
function clone() {
return new Moment2(this);
}
function isAfter(input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || "millisecond";
if (units === "millisecond") {
return this.valueOf() > localInput.valueOf();
} else {
return localInput.valueOf() < this.clone().startOf(units).valueOf();
}
}
function isBefore(input, units) {
var localInput = isMoment(input) ? input : createLocal(input);
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || "millisecond";
if (units === "millisecond") {
return this.valueOf() < localInput.valueOf();
} else {
return this.clone().endOf(units).valueOf() < localInput.valueOf();
}
}
function isBetween(from2, to2, units, inclusivity) {
var localFrom = isMoment(from2) ? from2 : createLocal(from2), localTo = isMoment(to2) ? to2 : createLocal(to2);
if (!(this.isValid() && localFrom.isValid() && localTo.isValid())) {
return false;
}
inclusivity = inclusivity || "()";
return (inclusivity[0] === "(" ? this.isAfter(localFrom, units) : !this.isBefore(localFrom, units)) && (inclusivity[1] === ")" ? this.isBefore(localTo, units) : !this.isAfter(localTo, units));
}
function isSame(input, units) {
var localInput = isMoment(input) ? input : createLocal(input), inputMs;
if (!(this.isValid() && localInput.isValid())) {
return false;
}
units = normalizeUnits(units) || "millisecond";
if (units === "millisecond") {
return this.valueOf() === localInput.valueOf();
} else {
inputMs = localInput.valueOf();
return this.clone().startOf(units).valueOf() <= inputMs && inputMs <= this.clone().endOf(units).valueOf();
}
}
function isSameOrAfter(input, units) {
return this.isSame(input, units) || this.isAfter(input, units);
}
function isSameOrBefore(input, units) {
return this.isSame(input, units) || this.isBefore(input, units);
}
function diff(input, units, asFloat) {
var that, zoneDelta, output;
if (!this.isValid()) {
return NaN;
}
that = cloneWithOffset(input, this);
if (!that.isValid()) {
return NaN;
}
zoneDelta = (that.utcOffset() - this.utcOffset()) * 6e4;
units = normalizeUnits(units);
switch (units) {
case "year":
output = monthDiff(this, that) / 12;
break;
case "month":
output = monthDiff(this, that);
break;
case "quarter":
output = monthDiff(this, that) / 3;
break;
case "second":
output = (this - that) / 1e3;
break;
case "minute":
output = (this - that) / 6e4;
break;
case "hour":
output = (this - that) / 36e5;
break;
case "day":
output = (this - that - zoneDelta) / 864e5;
break;
case "week":
output = (this - that - zoneDelta) / 6048e5;
break;
default:
output = this - that;
}
return asFloat ? output : absFloor(output);
}
function monthDiff(a, b) {
if (a.date() < b.date()) {
return -monthDiff(b, a);
}
var wholeMonthDiff = (b.year() - a.year()) * 12 + (b.month() - a.month()), anchor = a.clone().add(wholeMonthDiff, "months"), anchor2, adjust;
if (b - anchor < 0) {
anchor2 = a.clone().add(wholeMonthDiff - 1, "months");
adjust = (b - anchor) / (anchor - anchor2);
} else {
anchor2 = a.clone().add(wholeMonthDiff + 1, "months");
adjust = (b - anchor) / (anchor2 - anchor);
}
return -(wholeMonthDiff + adjust) || 0;
}
hooks.defaultFormat = "YYYY-MM-DDTHH:mm:ssZ";
hooks.defaultFormatUtc = "YYYY-MM-DDTHH:mm:ss[Z]";
function toString() {
return this.clone().locale("en").format("ddd MMM DD YYYY HH:mm:ss [GMT]ZZ");
}
function toISOString(keepOffset) {
if (!this.isValid()) {
return null;
}
var utc = keepOffset !== true, m = utc ? this.clone().utc() : this;
if (m.year() < 0 || m.year() > 9999) {
return formatMoment(
m,
utc ? "YYYYYY-MM-DD[T]HH:mm:ss.SSS[Z]" : "YYYYYY-MM-DD[T]HH:mm:ss.SSSZ"
);
}
if (isFunction(Date.prototype.toISOString)) {
if (utc) {
return this.toDate().toISOString();
} else {
return new Date(this.valueOf() + this.utcOffset() * 60 * 1e3).toISOString().replace("Z", formatMoment(m, "Z"));
}
}
return formatMoment(
m,
utc ? "YYYY-MM-DD[T]HH:mm:ss.SSS[Z]" : "YYYY-MM-DD[T]HH:mm:ss.SSSZ"
);
}
function inspect() {
if (!this.isValid()) {
return "moment.invalid(/* " + this._i + " */)";
}
var func = "moment", zone = "", prefix, year, datetime, suffix;
if (!this.isLocal()) {
func = this.utcOffset() === 0 ? "moment.utc" : "moment.parseZone";
zone = "Z";
}
prefix = "[" + func + '("]';
year = 0 <= this.year() && this.year() <= 9999 ? "YYYY" : "YYYYYY";
datetime = "-MM-DD[T]HH:mm:ss.SSS";
suffix = zone + '[")]';
return this.format(prefix + year + datetime + suffix);
}
function format(inputString) {
if (!inputString) {
inputString = this.isUtc() ? hooks.defaultFormatUtc : hooks.defaultFormat;
}
var output = formatMoment(this, inputString);
return this.localeData().postformat(output);
}
function from(time, withoutSuffix) {
if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
return createDuration({ to: this, from: time }).locale(this.locale()).humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function fromNow(withoutSuffix) {
return this.from(createLocal(), withoutSuffix);
}
function to(time, withoutSuffix) {
if (this.isValid() && (isMoment(time) && time.isValid() || createLocal(time).isValid())) {
return createDuration({ from: this, to: time }).locale(this.locale()).humanize(!withoutSuffix);
} else {
return this.localeData().invalidDate();
}
}
function toNow(withoutSuffix) {
return this.to(createLocal(), withoutSuffix);
}
function locale(key) {
var newLocaleData;
if (key === void 0) {
return this._locale._abbr;
} else {
newLocaleData = getLocale(key);
if (newLocaleData != null) {
this._locale = newLocaleData;
}
return this;
}
}
var lang = deprecate(
"moment().lang() is deprecated. Instead, use moment().localeData() to get the language configuration. Use moment().locale() to change languages.",
function(key) {
if (key === void 0) {
return this.localeData();
} else {
return this.locale(key);
}
}
);
function localeData() {
return this._locale;
}
var MS_PER_SECOND = 1e3, MS_PER_MINUTE = 60 * MS_PER_SECOND, MS_PER_HOUR = 60 * MS_PER_MINUTE, MS_PER_400_YEARS = (365 * 400 + 97) * 24 * MS_PER_HOUR;
function mod$1(dividend, divisor) {
return (dividend % divisor + divisor) % divisor;
}
function localStartOfDate(y, m, d) {
if (y < 100 && y >= 0) {
return new Date(y + 400, m, d) - MS_PER_400_YEARS;
} else {
return new Date(y, m, d).valueOf();
}
}
function utcStartOfDate(y, m, d) {
if (y < 100 && y >= 0) {
return Date.UTC(y + 400, m, d) - MS_PER_400_YEARS;
} else {
return Date.UTC(y, m, d);
}
}
function startOf(units) {
var time, startOfDate;
units = normalizeUnits(units);
if (units === void 0 || units === "millisecond" || !this.isValid()) {
return this;
}
startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
switch (units) {
case "year":
time = startOfDate(this.year(), 0, 1);
break;
case "quarter":
time = startOfDate(
this.year(),
this.month() - this.month() % 3,
1
);
break;
case "month":
time = startOfDate(this.year(), this.month(), 1);
break;
case "week":
time = startOfDate(
this.year(),
this.month(),
this.date() - this.weekday()
);
break;
case "isoWeek":
time = startOfDate(
this.year(),
this.month(),
this.date() - (this.isoWeekday() - 1)
);
break;
case "day":
case "date":
time = startOfDate(this.year(), this.month(), this.date());
break;
case "hour":
time = this._d.valueOf();
time -= mod$1(
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
MS_PER_HOUR
);
break;
case "minute":
time = this._d.valueOf();
time -= mod$1(time, MS_PER_MINUTE);
break;
case "second":
time = this._d.valueOf();
time -= mod$1(time, MS_PER_SECOND);
break;
}
this._d.setTime(time);
hooks.updateOffset(this, true);
return this;
}
function endOf(units) {
var time, startOfDate;
units = normalizeUnits(units);
if (units === void 0 || units === "millisecond" || !this.isValid()) {
return this;
}
startOfDate = this._isUTC ? utcStartOfDate : localStartOfDate;
switch (units) {
case "year":
time = startOfDate(this.year() + 1, 0, 1) - 1;
break;
case "quarter":
time = startOfDate(
this.year(),
this.month() - this.month() % 3 + 3,
1
) - 1;
break;
case "month":
time = startOfDate(this.year(), this.month() + 1, 1) - 1;
break;
case "week":
time = startOfDate(
this.year(),
this.month(),
this.date() - this.weekday() + 7
) - 1;
break;
case "isoWeek":
time = startOfDate(
this.year(),
this.month(),
this.date() - (this.isoWeekday() - 1) + 7
) - 1;
break;
case "day":
case "date":
time = startOfDate(this.year(), this.month(), this.date() + 1) - 1;
break;
case "hour":
time = this._d.valueOf();
time += MS_PER_HOUR - mod$1(
time + (this._isUTC ? 0 : this.utcOffset() * MS_PER_MINUTE),
MS_PER_HOUR
) - 1;
break;
case "minute":
time = this._d.valueOf();
time += MS_PER_MINUTE - mod$1(time, MS_PER_MINUTE) - 1;
break;
case "second":
time = this._d.valueOf();
time += MS_PER_SECOND - mod$1(time, MS_PER_SECOND) - 1;
break;
}
this._d.setTime(time);
hooks.updateOffset(this, true);
return this;
}
function valueOf() {
return this._d.valueOf() - (this._offset || 0) * 6e4;
}
function unix() {
return Math.floor(this.valueOf() / 1e3);
}
function toDate() {
return new Date(this.valueOf());
}
function toArray2() {
var m = this;
return [
m.year(),
m.month(),
m.date(),
m.hour(),
m.minute(),
m.second(),
m.millisecond()
];
}
function toObject() {
var m = this;
return {
years: m.year(),
months: m.month(),
date: m.date(),
hours: m.hours(),
minutes: m.minutes(),
seconds: m.seconds(),
milliseconds: m.milliseconds()
};
}
function toJSON() {
return this.isValid() ? this.toISOString() : null;
}
function isValid$2() {
return isValid(this);
}
function parsingFlags() {
return extend({}, getParsingFlags(this));
}
function invalidAt() {
return getParsingFlags(this).overflow;
}
function creationData() {
return {
input: this._i,
format: this._f,
locale: this._locale,
isUTC: this._isUTC,
strict: this._strict
};
}
addFormatToken("N", 0, 0, "eraAbbr");
addFormatToken("NN", 0, 0, "eraAbbr");
addFormatToken("NNN", 0, 0, "eraAbbr");
addFormatToken("NNNN", 0, 0, "eraName");
addFormatToken("NNNNN", 0, 0, "eraNarrow");
addFormatToken("y", ["y", 1], "yo", "eraYear");
addFormatToken("y", ["yy", 2], 0, "eraYear");
addFormatToken("y", ["yyy", 3], 0, "eraYear");
addFormatToken("y", ["yyyy", 4], 0, "eraYear");
addRegexToken("N", matchEraAbbr);
addRegexToken("NN", matchEraAbbr);
addRegexToken("NNN", matchEraAbbr);
addRegexToken("NNNN", matchEraName);
addRegexToken("NNNNN", matchEraNarrow);
addParseToken(
["N", "NN", "NNN", "NNNN", "NNNNN"],
function(input, array, config, token2) {
var era = config._locale.erasParse(input, token2, config._strict);
if (era) {
getParsingFlags(config).era = era;
} else {
getParsingFlags(config).invalidEra = input;
}
}
);
addRegexToken("y", matchUnsigned);
addRegexToken("yy", matchUnsigned);
addRegexToken("yyy", matchUnsigned);
addRegexToken("yyyy", matchUnsigned);
addRegexToken("yo", matchEraYearOrdinal);
addParseToken(["y", "yy", "yyy", "yyyy"], YEAR);
addParseToken(["yo"], function(input, array, config, token2) {
var match;
if (config._locale._eraYearOrdinalRegex) {
match = input.match(config._locale._eraYearOrdinalRegex);
}
if (config._locale.eraYearOrdinalParse) {
array[YEAR] = config._locale.eraYearOrdinalParse(input, match);
} else {
array[YEAR] = parseInt(input, 10);
}
});
function localeEras(m, format2) {
var i, l, date, eras = this._eras || getLocale("en")._eras;
for (i = 0, l = eras.length; i < l; ++i) {
switch (typeof eras[i].since) {
case "string":
date = hooks(eras[i].since).startOf("day");
eras[i].since = date.valueOf();
break;
}
switch (typeof eras[i].until) {
case "undefined":
eras[i].until = Infinity;
break;
case "string":
date = hooks(eras[i].until).startOf("day").valueOf();
eras[i].until = date.valueOf();
break;
}
}
return eras;
}
function localeErasParse(eraName, format2, strict) {
var i, l, eras = this.eras(), name, abbr, narrow;
eraName = eraName.toUpperCase();
for (i = 0, l = eras.length; i < l; ++i) {
name = eras[i].name.toUpperCase();
abbr = eras[i].abbr.toUpperCase();
narrow = eras[i].narrow.toUpperCase();
if (strict) {
switch (format2) {
case "N":
case "NN":
case "NNN":
if (abbr === eraName) {
return eras[i];
}
break;
case "NNNN":
if (name === eraName) {
return eras[i];
}
break;
case "NNNNN":
if (narrow === eraName) {
return eras[i];
}
break;
}
} else if ([name, abbr, narrow].indexOf(eraName) >= 0) {
return eras[i];
}
}
}
function localeErasConvertYear(era, year) {
var dir = era.since <= era.until ? 1 : -1;
if (year === void 0) {
return hooks(era.since).year();
} else {
return hooks(era.since).year() + (year - era.offset) * dir;
}
}
function getEraName() {
var i, l, val, eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
val = this.clone().startOf("day").valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
return eras[i].name;
}
if (eras[i].until <= val && val <= eras[i].since) {
return eras[i].name;
}
}
return "";
}
function getEraNarrow() {
var i, l, val, eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
val = this.clone().startOf("day").valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
return eras[i].narrow;
}
if (eras[i].until <= val && val <= eras[i].since) {
return eras[i].narrow;
}
}
return "";
}
function getEraAbbr() {
var i, l, val, eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
val = this.clone().startOf("day").valueOf();
if (eras[i].since <= val && val <= eras[i].until) {
return eras[i].abbr;
}
if (eras[i].until <= val && val <= eras[i].since) {
return eras[i].abbr;
}
}
return "";
}
function getEraYear() {
var i, l, dir, val, eras = this.localeData().eras();
for (i = 0, l = eras.length; i < l; ++i) {
dir = eras[i].since <= eras[i].until ? 1 : -1;
val = this.clone().startOf("day").valueOf();
if (eras[i].since <= val && val <= eras[i].until || eras[i].until <= val && val <= eras[i].since) {
return (this.year() - hooks(eras[i].since).year()) * dir + eras[i].offset;
}
}
return this.year();
}
function erasNameRegex(isStrict) {
if (!hasOwnProp(this, "_erasNameRegex")) {
computeErasParse.call(this);
}
return isStrict ? this._erasNameRegex : this._erasRegex;
}
function erasAbbrRegex(isStrict) {
if (!hasOwnProp(this, "_erasAbbrRegex")) {
computeErasParse.call(this);
}
return isStrict ? this._erasAbbrRegex : this._erasRegex;
}
function erasNarrowRegex(isStrict) {
if (!hasOwnProp(this, "_erasNarrowRegex")) {
computeErasParse.call(this);
}
return isStrict ? this._erasNarrowRegex : this._erasRegex;
}
function matchEraAbbr(isStrict, locale2) {
return locale2.erasAbbrRegex(isStrict);
}
function matchEraName(isStrict, locale2) {
return locale2.erasNameRegex(isStrict);
}
function matchEraNarrow(isStrict, locale2) {
return locale2.erasNarrowRegex(isStrict);
}
function matchEraYearOrdinal(isStrict, locale2) {
return locale2._eraYearOrdinalRegex || matchUnsigned;
}
function computeErasParse() {
var abbrPieces = [], namePieces = [], narrowPieces = [], mixedPieces = [], i, l, eras = this.eras();
for (i = 0, l = eras.length; i < l; ++i) {
namePieces.push(regexEscape(eras[i].name));
abbrPieces.push(regexEscape(eras[i].abbr));
narrowPieces.push(regexEscape(eras[i].narrow));
mixedPieces.push(regexEscape(eras[i].name));
mixedPieces.push(regexEscape(eras[i].abbr));
mixedPieces.push(regexEscape(eras[i].narrow));
}
this._erasRegex = new RegExp("^(" + mixedPieces.join("|") + ")", "i");
this._erasNameRegex = new RegExp("^(" + namePieces.join("|") + ")", "i");
this._erasAbbrRegex = new RegExp("^(" + abbrPieces.join("|") + ")", "i");
this._erasNarrowRegex = new RegExp(
"^(" + narrowPieces.join("|") + ")",
"i"
);
}
addFormatToken(0, ["gg", 2], 0, function() {
return this.weekYear() % 100;
});
addFormatToken(0, ["GG", 2], 0, function() {
return this.isoWeekYear() % 100;
});
function addWeekYearFormatToken(token2, getter) {
addFormatToken(0, [token2, token2.length], 0, getter);
}
addWeekYearFormatToken("gggg", "weekYear");
addWeekYearFormatToken("ggggg", "weekYear");
addWeekYearFormatToken("GGGG", "isoWeekYear");
addWeekYearFormatToken("GGGGG", "isoWeekYear");
addUnitAlias("weekYear", "gg");
addUnitAlias("isoWeekYear", "GG");
addUnitPriority("weekYear", 1);
addUnitPriority("isoWeekYear", 1);
addRegexToken("G", matchSigned);
addRegexToken("g", matchSigned);
addRegexToken("GG", match1to2, match2);
addRegexToken("gg", match1to2, match2);
addRegexToken("GGGG", match1to4, match4);
addRegexToken("gggg", match1to4, match4);
addRegexToken("GGGGG", match1to6, match6);
addRegexToken("ggggg", match1to6, match6);
addWeekParseToken(
["gggg", "ggggg", "GGGG", "GGGGG"],
function(input, week, config, token2) {
week[token2.substr(0, 2)] = toInt(input);
}
);
addWeekParseToken(["gg", "GG"], function(input, week, config, token2) {
week[token2] = hooks.parseTwoDigitYear(input);
});
function getSetWeekYear(input) {
return getSetWeekYearHelper.call(
this,
input,
this.week(),
this.weekday(),
this.localeData()._week.dow,
this.localeData()._week.doy
);
}
function getSetISOWeekYear(input) {
return getSetWeekYearHelper.call(
this,
input,
this.isoWeek(),
this.isoWeekday(),
1,
4
);
}
function getISOWeeksInYear() {
return weeksInYear(this.year(), 1, 4);
}
function getISOWeeksInISOWeekYear() {
return weeksInYear(this.isoWeekYear(), 1, 4);
}
function getWeeksInYear() {
var weekInfo = this.localeData()._week;
return weeksInYear(this.year(), weekInfo.dow, weekInfo.doy);
}
function getWeeksInWeekYear() {
var weekInfo = this.localeData()._week;
return weeksInYear(this.weekYear(), weekInfo.dow, weekInfo.doy);
}
function getSetWeekYearHelper(input, week, weekday, dow, doy) {
var weeksTarget;
if (input == null) {
return weekOfYear(this, dow, doy).year;
} else {
weeksTarget = weeksInYear(input, dow, doy);
if (week > weeksTarget) {
week = weeksTarget;
}
return setWeekAll.call(this, input, week, weekday, dow, doy);
}
}
function setWeekAll(weekYear, week, weekday, dow, doy) {
var dayOfYearData = dayOfYearFromWeeks(weekYear, week, weekday, dow, doy), date = createUTCDate(dayOfYearData.year, 0, dayOfYearData.dayOfYear);
this.year(date.getUTCFullYear());
this.month(date.getUTCMonth());
this.date(date.getUTCDate());
return this;
}
addFormatToken("Q", 0, "Qo", "quarter");
addUnitAlias("quarter", "Q");
addUnitPriority("quarter", 7);
addRegexToken("Q", match1);
addParseToken("Q", function(input, array) {
array[MONTH] = (toInt(input) - 1) * 3;
});
function getSetQuarter(input) {
return input == null ? Math.ceil((this.month() + 1) / 3) : this.month((input - 1) * 3 + this.month() % 3);
}
addFormatToken("D", ["DD", 2], "Do", "date");
addUnitAlias("date", "D");
addUnitPriority("date", 9);
addRegexToken("D", match1to2);
addRegexToken("DD", match1to2, match2);
addRegexToken("Do", function(isStrict, locale2) {
return isStrict ? locale2._dayOfMonthOrdinalParse || locale2._ordinalParse : locale2._dayOfMonthOrdinalParseLenient;
});
addParseToken(["D", "DD"], DATE);
addParseToken("Do", function(input, array) {
array[DATE] = toInt(input.match(match1to2)[0]);
});
var getSetDayOfMonth = makeGetSet("Date", true);
addFormatToken("DDD", ["DDDD", 3], "DDDo", "dayOfYear");
addUnitAlias("dayOfYear", "DDD");
addUnitPriority("dayOfYear", 4);
addRegexToken("DDD", match1to3);
addRegexToken("DDDD", match3);
addParseToken(["DDD", "DDDD"], function(input, array, config) {
config._dayOfYear = toInt(input);
});
function getSetDayOfYear(input) {
var dayOfYear = Math.round(
(this.clone().startOf("day") - this.clone().startOf("year")) / 864e5
) + 1;
return input == null ? dayOfYear : this.add(input - dayOfYear, "d");
}
addFormatToken("m", ["mm", 2], 0, "minute");
addUnitAlias("minute", "m");
addUnitPriority("minute", 14);
addRegexToken("m", match1to2);
addRegexToken("mm", match1to2, match2);
addParseToken(["m", "mm"], MINUTE);
var getSetMinute = makeGetSet("Minutes", false);
addFormatToken("s", ["ss", 2], 0, "second");
addUnitAlias("second", "s");
addUnitPriority("second", 15);
addRegexToken("s", match1to2);
addRegexToken("ss", match1to2, match2);
addParseToken(["s", "ss"], SECOND);
var getSetSecond = makeGetSet("Seconds", false);
addFormatToken("S", 0, 0, function() {
return ~~(this.millisecond() / 100);
});
addFormatToken(0, ["SS", 2], 0, function() {
return ~~(this.millisecond() / 10);
});
addFormatToken(0, ["SSS", 3], 0, "millisecond");
addFormatToken(0, ["SSSS", 4], 0, function() {
return this.millisecond() * 10;
});
addFormatToken(0, ["SSSSS", 5], 0, function() {
return this.millisecond() * 100;
});
addFormatToken(0, ["SSSSSS", 6], 0, function() {
return this.millisecond() * 1e3;
});
addFormatToken(0, ["SSSSSSS", 7], 0, function() {
return this.millisecond() * 1e4;
});
addFormatToken(0, ["SSSSSSSS", 8], 0, function() {
return this.millisecond() * 1e5;
});
addFormatToken(0, ["SSSSSSSSS", 9], 0, function() {
return this.millisecond() * 1e6;
});
addUnitAlias("millisecond", "ms");
addUnitPriority("millisecond", 16);
addRegexToken("S", match1to3, match1);
addRegexToken("SS", match1to3, match2);
addRegexToken("SSS", match1to3, match3);
var token, getSetMillisecond;
for (token = "SSSS"; token.length <= 9; token += "S") {
addRegexToken(token, matchUnsigned);
}
function parseMs(input, array) {
array[MILLISECOND] = toInt(("0." + input) * 1e3);
}
for (token = "S"; token.length <= 9; token += "S") {
addParseToken(token, parseMs);
}
getSetMillisecond = makeGetSet("Milliseconds", false);
addFormatToken("z", 0, 0, "zoneAbbr");
addFormatToken("zz", 0, 0, "zoneName");
function getZoneAbbr() {
return this._isUTC ? "UTC" : "";
}
function getZoneName() {
return this._isUTC ? "Coordinated Universal Time" : "";
}
var proto = Moment2.prototype;
proto.add = add2;
proto.calendar = calendar$1;
proto.clone = clone;
proto.diff = diff;
proto.endOf = endOf;
proto.format = format;
proto.from = from;
proto.fromNow = fromNow;
proto.to = to;
proto.toNow = toNow;
proto.get = stringGet;
proto.invalidAt = invalidAt;
proto.isAfter = isAfter;
proto.isBefore = isBefore;
proto.isBetween = isBetween;
proto.isSame = isSame;
proto.isSameOrAfter = isSameOrAfter;
proto.isSameOrBefore = isSameOrBefore;
proto.isValid = isValid$2;
proto.lang = lang;
proto.locale = locale;
proto.localeData = localeData;
proto.max = prototypeMax;
proto.min = prototypeMin;
proto.parsingFlags = parsingFlags;
proto.set = stringSet;
proto.startOf = startOf;
proto.subtract = subtract;
proto.toArray = toArray2;
proto.toObject = toObject;
proto.toDate = toDate;
proto.toISOString = toISOString;
proto.inspect = inspect;
if (typeof Symbol !== "undefined" && Symbol.for != null) {
proto[Symbol.for("nodejs.util.inspect.custom")] = function() {
return "Moment<" + this.format() + ">";
};
}
proto.toJSON = toJSON;
proto.toString = toString;
proto.unix = unix;
proto.valueOf = valueOf;
proto.creationData = creationData;
proto.eraName = getEraName;
proto.eraNarrow = getEraNarrow;
proto.eraAbbr = getEraAbbr;
proto.eraYear = getEraYear;
proto.year = getSetYear;
proto.isLeapYear = getIsLeapYear;
proto.weekYear = getSetWeekYear;
proto.isoWeekYear = getSetISOWeekYear;
proto.quarter = proto.quarters = getSetQuarter;
proto.month = getSetMonth;
proto.daysInMonth = getDaysInMonth;
proto.week = proto.weeks = getSetWeek;
proto.isoWeek = proto.isoWeeks = getSetISOWeek;
proto.weeksInYear = getWeeksInYear;
proto.weeksInWeekYear = getWeeksInWeekYear;
proto.isoWeeksInYear = getISOWeeksInYear;
proto.isoWeeksInISOWeekYear = getISOWeeksInISOWeekYear;
proto.date = getSetDayOfMonth;
proto.day = proto.days = getSetDayOfWeek;
proto.weekday = getSetLocaleDayOfWeek;
proto.isoWeekday = getSetISODayOfWeek;
proto.dayOfYear = getSetDayOfYear;
proto.hour = proto.hours = getSetHour;
proto.minute = proto.minutes = getSetMinute;
proto.second = proto.seconds = getSetSecond;
proto.millisecond = proto.milliseconds = getSetMillisecond;
proto.utcOffset = getSetOffset;
proto.utc = setOffsetToUTC;
proto.local = setOffsetToLocal;
proto.parseZone = setOffsetToParsedOffset;
proto.hasAlignedHourOffset = hasAlignedHourOffset;
proto.isDST = isDaylightSavingTime;
proto.isLocal = isLocal;
proto.isUtcOffset = isUtcOffset;
proto.isUtc = isUtc;
proto.isUTC = isUtc;
proto.zoneAbbr = getZoneAbbr;
proto.zoneName = getZoneName;
proto.dates = deprecate(
"dates accessor is deprecated. Use date instead.",
getSetDayOfMonth
);
proto.months = deprecate(
"months accessor is deprecated. Use month instead",
getSetMonth
);
proto.years = deprecate(
"years accessor is deprecated. Use year instead",
getSetYear
);
proto.zone = deprecate(
"moment().zone is deprecated, use moment().utcOffset instead. http://momentjs.com/guides/#/warnings/zone/",
getSetZone
);
proto.isDSTShifted = deprecate(
"isDSTShifted is deprecated. See http://momentjs.com/guides/#/warnings/dst-shifted/ for more information",
isDaylightSavingTimeShifted
);
function createUnix(input) {
return createLocal(input * 1e3);
}
function createInZone() {
return createLocal.apply(null, arguments).parseZone();
}
function preParsePostFormat(string) {
return string;
}
var proto$1 = Locale.prototype;
proto$1.calendar = calendar;
proto$1.longDateFormat = longDateFormat;
proto$1.invalidDate = invalidDate;
proto$1.ordinal = ordinal;
proto$1.preparse = preParsePostFormat;
proto$1.postformat = preParsePostFormat;
proto$1.relativeTime = relativeTime;
proto$1.pastFuture = pastFuture;
proto$1.set = set;
proto$1.eras = localeEras;
proto$1.erasParse = localeErasParse;
proto$1.erasConvertYear = localeErasConvertYear;
proto$1.erasAbbrRegex = erasAbbrRegex;
proto$1.erasNameRegex = erasNameRegex;
proto$1.erasNarrowRegex = erasNarrowRegex;
proto$1.months = localeMonths;
proto$1.monthsShort = localeMonthsShort;
proto$1.monthsParse = localeMonthsParse;
proto$1.monthsRegex = monthsRegex;
proto$1.monthsShortRegex = monthsShortRegex;
proto$1.week = localeWeek;
proto$1.firstDayOfYear = localeFirstDayOfYear;
proto$1.firstDayOfWeek = localeFirstDayOfWeek;
proto$1.weekdays = localeWeekdays;
proto$1.weekdaysMin = localeWeekdaysMin;
proto$1.weekdaysShort = localeWeekdaysShort;
proto$1.weekdaysParse = localeWeekdaysParse;
proto$1.weekdaysRegex = weekdaysRegex;
proto$1.weekdaysShortRegex = weekdaysShortRegex;
proto$1.weekdaysMinRegex = weekdaysMinRegex;
proto$1.isPM = localeIsPM;
proto$1.meridiem = localeMeridiem;
function get$1(format2, index, field, setter) {
var locale2 = getLocale(), utc = createUTC().set(setter, index);
return locale2[field](utc, format2);
}
function listMonthsImpl(format2, index, field) {
if (isNumber2(format2)) {
index = format2;
format2 = void 0;
}
format2 = format2 || "";
if (index != null) {
return get$1(format2, index, field, "month");
}
var i, out = [];
for (i = 0; i < 12; i++) {
out[i] = get$1(format2, i, field, "month");
}
return out;
}
function listWeekdaysImpl(localeSorted, format2, index, field) {
if (typeof localeSorted === "boolean") {
if (isNumber2(format2)) {
index = format2;
format2 = void 0;
}
format2 = format2 || "";
} else {
format2 = localeSorted;
index = format2;
localeSorted = false;
if (isNumber2(format2)) {
index = format2;
format2 = void 0;
}
format2 = format2 || "";
}
var locale2 = getLocale(), shift = localeSorted ? locale2._week.dow : 0, i, out = [];
if (index != null) {
return get$1(format2, (index + shift) % 7, field, "day");
}
for (i = 0; i < 7; i++) {
out[i] = get$1(format2, (i + shift) % 7, field, "day");
}
return out;
}
function listMonths(format2, index) {
return listMonthsImpl(format2, index, "months");
}
function listMonthsShort(format2, index) {
return listMonthsImpl(format2, index, "monthsShort");
}
function listWeekdays(localeSorted, format2, index) {
return listWeekdaysImpl(localeSorted, format2, index, "weekdays");
}
function listWeekdaysShort(localeSorted, format2, index) {
return listWeekdaysImpl(localeSorted, format2, index, "weekdaysShort");
}
function listWeekdaysMin(localeSorted, format2, index) {
return listWeekdaysImpl(localeSorted, format2, index, "weekdaysMin");
}
getSetGlobalLocale("en", {
eras: [
{
since: "0001-01-01",
until: Infinity,
offset: 1,
name: "Anno Domini",
narrow: "AD",
abbr: "AD"
},
{
since: "0000-12-31",
until: -Infinity,
offset: 1,
name: "Before Christ",
narrow: "BC",
abbr: "BC"
}
],
dayOfMonthOrdinalParse: /\d{1,2}(th|st|nd|rd)/,
ordinal: function(number) {
var b = number % 10, output = toInt(number % 100 / 10) === 1 ? "th" : b === 1 ? "st" : b === 2 ? "nd" : b === 3 ? "rd" : "th";
return number + output;
}
});
hooks.lang = deprecate(
"moment.lang is deprecated. Use moment.locale instead.",
getSetGlobalLocale
);
hooks.langData = deprecate(
"moment.langData is deprecated. Use moment.localeData instead.",
getLocale
);
var mathAbs = Math.abs;
function abs() {
var data = this._data;
this._milliseconds = mathAbs(this._milliseconds);
this._days = mathAbs(this._days);
this._months = mathAbs(this._months);
data.milliseconds = mathAbs(data.milliseconds);
data.seconds = mathAbs(data.seconds);
data.minutes = mathAbs(data.minutes);
data.hours = mathAbs(data.hours);
data.months = mathAbs(data.months);
data.years = mathAbs(data.years);
return this;
}
function addSubtract$1(duration, input, value, direction) {
var other = createDuration(input, value);
duration._milliseconds += direction * other._milliseconds;
duration._days += direction * other._days;
duration._months += direction * other._months;
return duration._bubble();
}
function add$1(input, value) {
return addSubtract$1(this, input, value, 1);
}
function subtract$1(input, value) {
return addSubtract$1(this, input, value, -1);
}
function absCeil(number) {
if (number < 0) {
return Math.floor(number);
} else {
return Math.ceil(number);
}
}
function bubble() {
var milliseconds2 = this._milliseconds, days2 = this._days, months2 = this._months, data = this._data, seconds2, minutes2, hours2, years2, monthsFromDays;
if (!(milliseconds2 >= 0 && days2 >= 0 && months2 >= 0 || milliseconds2 <= 0 && days2 <= 0 && months2 <= 0)) {
milliseconds2 += absCeil(monthsToDays(months2) + days2) * 864e5;
days2 = 0;
months2 = 0;
}
data.milliseconds = milliseconds2 % 1e3;
seconds2 = absFloor(milliseconds2 / 1e3);
data.seconds = seconds2 % 60;
minutes2 = absFloor(seconds2 / 60);
data.minutes = minutes2 % 60;
hours2 = absFloor(minutes2 / 60);
data.hours = hours2 % 24;
days2 += absFloor(hours2 / 24);
monthsFromDays = absFloor(daysToMonths(days2));
months2 += monthsFromDays;
days2 -= absCeil(monthsToDays(monthsFromDays));
years2 = absFloor(months2 / 12);
months2 %= 12;
data.days = days2;
data.months = months2;
data.years = years2;
return this;
}
function daysToMonths(days2) {
return days2 * 4800 / 146097;
}
function monthsToDays(months2) {
return months2 * 146097 / 4800;
}
function as(units) {
if (!this.isValid()) {
return NaN;
}
var days2, months2, milliseconds2 = this._milliseconds;
units = normalizeUnits(units);
if (units === "month" || units === "quarter" || units === "year") {
days2 = this._days + milliseconds2 / 864e5;
months2 = this._months + daysToMonths(days2);
switch (units) {
case "month":
return months2;
case "quarter":
return months2 / 3;
case "year":
return months2 / 12;
}
} else {
days2 = this._days + Math.round(monthsToDays(this._months));
switch (units) {
case "week":
return days2 / 7 + milliseconds2 / 6048e5;
case "day":
return days2 + milliseconds2 / 864e5;
case "hour":
return days2 * 24 + milliseconds2 / 36e5;
case "minute":
return days2 * 1440 + milliseconds2 / 6e4;
case "second":
return days2 * 86400 + milliseconds2 / 1e3;
case "millisecond":
return Math.floor(days2 * 864e5) + milliseconds2;
default:
throw new Error("Unknown unit " + units);
}
}
}
function valueOf$1() {
if (!this.isValid()) {
return NaN;
}
return this._milliseconds + this._days * 864e5 + this._months % 12 * 2592e6 + toInt(this._months / 12) * 31536e6;
}
function makeAs(alias) {
return function() {
return this.as(alias);
};
}
var asMilliseconds = makeAs("ms"), asSeconds = makeAs("s"), asMinutes = makeAs("m"), asHours = makeAs("h"), asDays = makeAs("d"), asWeeks = makeAs("w"), asMonths = makeAs("M"), asQuarters = makeAs("Q"), asYears = makeAs("y");
function clone$1() {
return createDuration(this);
}
function get$2(units) {
units = normalizeUnits(units);
return this.isValid() ? this[units + "s"]() : NaN;
}
function makeGetter(name) {
return function() {
return this.isValid() ? this._data[name] : NaN;
};
}
var milliseconds = makeGetter("milliseconds"), seconds = makeGetter("seconds"), minutes = makeGetter("minutes"), hours = makeGetter("hours"), days = makeGetter("days"), months = makeGetter("months"), years = makeGetter("years");
function weeks() {
return absFloor(this.days() / 7);
}
var round = Math.round, thresholds = {
ss: 44,
s: 45,
m: 45,
h: 22,
d: 26,
w: null,
M: 11
};
function substituteTimeAgo(string, number, withoutSuffix, isFuture, locale2) {
return locale2.relativeTime(number || 1, !!withoutSuffix, string, isFuture);
}
function relativeTime$1(posNegDuration, withoutSuffix, thresholds2, locale2) {
var duration = createDuration(posNegDuration).abs(), seconds2 = round(duration.as("s")), minutes2 = round(duration.as("m")), hours2 = round(duration.as("h")), days2 = round(duration.as("d")), months2 = round(duration.as("M")), weeks2 = round(duration.as("w")), years2 = round(duration.as("y")), a = seconds2 <= thresholds2.ss && ["s", seconds2] || seconds2 < thresholds2.s && ["ss", seconds2] || minutes2 <= 1 && ["m"] || minutes2 < thresholds2.m && ["mm", minutes2] || hours2 <= 1 && ["h"] || hours2 < thresholds2.h && ["hh", hours2] || days2 <= 1 && ["d"] || days2 < thresholds2.d && ["dd", days2];
if (thresholds2.w != null) {
a = a || weeks2 <= 1 && ["w"] || weeks2 < thresholds2.w && ["ww", weeks2];
}
a = a || months2 <= 1 && ["M"] || months2 < thresholds2.M && ["MM", months2] || years2 <= 1 && ["y"] || ["yy", years2];
a[2] = withoutSuffix;
a[3] = +posNegDuration > 0;
a[4] = locale2;
return substituteTimeAgo.apply(null, a);
}
function getSetRelativeTimeRounding(roundingFunction) {
if (roundingFunction === void 0) {
return round;
}
if (typeof roundingFunction === "function") {
round = roundingFunction;
return true;
}
return false;
}
function getSetRelativeTimeThreshold(threshold, limit) {
if (thresholds[threshold] === void 0) {
return false;
}
if (limit === void 0) {
return thresholds[threshold];
}
thresholds[threshold] = limit;
if (threshold === "s") {
thresholds.ss = limit - 1;
}
return true;
}
function humanize(argWithSuffix, argThresholds) {
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var withSuffix = false, th = thresholds, locale2, output;
if (typeof argWithSuffix === "object") {
argThresholds = argWithSuffix;
argWithSuffix = false;
}
if (typeof argWithSuffix === "boolean") {
withSuffix = argWithSuffix;
}
if (typeof argThresholds === "object") {
th = Object.assign({}, thresholds, argThresholds);
if (argThresholds.s != null && argThresholds.ss == null) {
th.ss = argThresholds.s - 1;
}
}
locale2 = this.localeData();
output = relativeTime$1(this, !withSuffix, th, locale2);
if (withSuffix) {
output = locale2.pastFuture(+this, output);
}
return locale2.postformat(output);
}
var abs$1 = Math.abs;
function sign(x) {
return (x > 0) - (x < 0) || +x;
}
function toISOString$1() {
if (!this.isValid()) {
return this.localeData().invalidDate();
}
var seconds2 = abs$1(this._milliseconds) / 1e3, days2 = abs$1(this._days), months2 = abs$1(this._months), minutes2, hours2, years2, s, total = this.asSeconds(), totalSign, ymSign, daysSign, hmsSign;
if (!total) {
return "P0D";
}
minutes2 = absFloor(seconds2 / 60);
hours2 = absFloor(minutes2 / 60);
seconds2 %= 60;
minutes2 %= 60;
years2 = absFloor(months2 / 12);
months2 %= 12;
s = seconds2 ? seconds2.toFixed(3).replace(/\.?0+$/, "") : "";
totalSign = total < 0 ? "-" : "";
ymSign = sign(this._months) !== sign(total) ? "-" : "";
daysSign = sign(this._days) !== sign(total) ? "-" : "";
hmsSign = sign(this._milliseconds) !== sign(total) ? "-" : "";
return totalSign + "P" + (years2 ? ymSign + years2 + "Y" : "") + (months2 ? ymSign + months2 + "M" : "") + (days2 ? daysSign + days2 + "D" : "") + (hours2 || minutes2 || seconds2 ? "T" : "") + (hours2 ? hmsSign + hours2 + "H" : "") + (minutes2 ? hmsSign + minutes2 + "M" : "") + (seconds2 ? hmsSign + s + "S" : "");
}
var proto$2 = Duration.prototype;
proto$2.isValid = isValid$1;
proto$2.abs = abs;
proto$2.add = add$1;
proto$2.subtract = subtract$1;
proto$2.as = as;
proto$2.asMilliseconds = asMilliseconds;
proto$2.asSeconds = asSeconds;
proto$2.asMinutes = asMinutes;
proto$2.asHours = asHours;
proto$2.asDays = asDays;
proto$2.asWeeks = asWeeks;
proto$2.asMonths = asMonths;
proto$2.asQuarters = asQuarters;
proto$2.asYears = asYears;
proto$2.valueOf = valueOf$1;
proto$2._bubble = bubble;
proto$2.clone = clone$1;
proto$2.get = get$2;
proto$2.milliseconds = milliseconds;
proto$2.seconds = seconds;
proto$2.minutes = minutes;
proto$2.hours = hours;
proto$2.days = days;
proto$2.weeks = weeks;
proto$2.months = months;
proto$2.years = years;
proto$2.humanize = humanize;
proto$2.toISOString = toISOString$1;
proto$2.toString = toISOString$1;
proto$2.toJSON = toISOString$1;
proto$2.locale = locale;
proto$2.localeData = localeData;
proto$2.toIsoString = deprecate(
"toIsoString() is deprecated. Please use toISOString() instead (notice the capitals)",
toISOString$1
);
proto$2.lang = lang;
addFormatToken("X", 0, 0, "unix");
addFormatToken("x", 0, 0, "valueOf");
addRegexToken("x", matchSigned);
addRegexToken("X", matchTimestamp);
addParseToken("X", function(input, array, config) {
config._d = new Date(parseFloat(input) * 1e3);
});
addParseToken("x", function(input, array, config) {
config._d = new Date(toInt(input));
});
hooks.version = "2.29.4";
setHookCallback(createLocal);
hooks.fn = proto;
hooks.min = min;
hooks.max = max;
hooks.now = now;
hooks.utc = createUTC;
hooks.unix = createUnix;
hooks.months = listMonths;
hooks.isDate = isDate;
hooks.locale = getSetGlobalLocale;
hooks.invalid = createInvalid;
hooks.duration = createDuration;
hooks.isMoment = isMoment;
hooks.weekdays = listWeekdays;
hooks.parseZone = createInZone;
hooks.localeData = getLocale;
hooks.isDuration = isDuration;
hooks.monthsShort = listMonthsShort;
hooks.weekdaysMin = listWeekdaysMin;
hooks.defineLocale = defineLocale;
hooks.updateLocale = updateLocale;
hooks.locales = listLocales;
hooks.weekdaysShort = listWeekdaysShort;
hooks.normalizeUnits = normalizeUnits;
hooks.relativeTimeRounding = getSetRelativeTimeRounding;
hooks.relativeTimeThreshold = getSetRelativeTimeThreshold;
hooks.calendarFormat = getCalendarFormat;
hooks.prototype = proto;
hooks.HTML5_FMT = {
DATETIME_LOCAL: "YYYY-MM-DDTHH:mm",
DATETIME_LOCAL_SECONDS: "YYYY-MM-DDTHH:mm:ss",
DATETIME_LOCAL_MS: "YYYY-MM-DDTHH:mm:ss.SSS",
DATE: "YYYY-MM-DD",
TIME: "HH:mm",
TIME_SECONDS: "HH:mm:ss",
TIME_MS: "HH:mm:ss.SSS",
WEEK: "GGGG-[W]WW",
MONTH: "YYYY-MM"
};
return hooks;
});
}
});
// node_modules/rrule/node_modules/tslib/tslib.js
var require_tslib = __commonJS({
"node_modules/rrule/node_modules/tslib/tslib.js"(exports, module2) {
var __extends2;
var __assign2;
var __rest2;
var __decorate2;
var __param2;
var __metadata2;
var __awaiter2;
var __generator2;
var __exportStar2;
var __values2;
var __read2;
var __spread2;
var __spreadArrays2;
var __await2;
var __asyncGenerator2;
var __asyncDelegator2;
var __asyncValues2;
var __makeTemplateObject2;
var __importStar2;
var __importDefault2;
var __classPrivateFieldGet2;
var __classPrivateFieldSet2;
var __createBinding2;
(function(factory) {
var root = typeof global === "object" ? global : typeof self === "object" ? self : typeof this === "object" ? this : {};
if (typeof define === "function" && define.amd) {
define("tslib", ["exports"], function(exports2) {
factory(createExporter(root, createExporter(exports2)));
});
} else if (typeof module2 === "object" && typeof module2.exports === "object") {
factory(createExporter(root, createExporter(module2.exports)));
} else {
factory(createExporter(root));
}
function createExporter(exports2, previous) {
if (exports2 !== root) {
if (typeof Object.create === "function") {
Object.defineProperty(exports2, "__esModule", { value: true });
} else {
exports2.__esModule = true;
}
}
return function(id, v) {
return exports2[id] = previous ? previous(id, v) : v;
};
}
})(function(exporter) {
var extendStatics = Object.setPrototypeOf || { __proto__: [] } instanceof Array && function(d, b) {
d.__proto__ = b;
} || function(d, b) {
for (var p in b)
if (b.hasOwnProperty(p))
d[p] = b[p];
};
__extends2 = function(d, b) {
extendStatics(d, b);
function __() {
this.constructor = d;
}
d.prototype = b === null ? Object.create(b) : (__.prototype = b.prototype, new __());
};
__assign2 = Object.assign || function(t) {
for (var s, i = 1, n = arguments.length; i < n; i++) {
s = arguments[i];
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p))
t[p] = s[p];
}
return t;
};
__rest2 = function(s, e) {
var t = {};
for (var p in s)
if (Object.prototype.hasOwnProperty.call(s, p) && e.indexOf(p) < 0)
t[p] = s[p];
if (s != null && typeof Object.getOwnPropertySymbols === "function")
for (var i = 0, p = Object.getOwnPropertySymbols(s); i < p.length; i++) {
if (e.indexOf(p[i]) < 0 && Object.prototype.propertyIsEnumerable.call(s, p[i]))
t[p[i]] = s[p[i]];
}
return t;
};
__decorate2 = function(decorators, target, key, desc) {
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
if (typeof Reflect === "object" && typeof Reflect.decorate === "function")
r = Reflect.decorate(decorators, target, key, desc);
else
for (var i = decorators.length - 1; i >= 0; i--)
if (d = decorators[i])
r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
return c > 3 && r && Object.defineProperty(target, key, r), r;
};
__param2 = function(paramIndex, decorator) {
return function(target, key) {
decorator(target, key, paramIndex);
};
};
__metadata2 = function(metadataKey, metadataValue) {
if (typeof Reflect === "object" && typeof Reflect.metadata === "function")
return Reflect.metadata(metadataKey, metadataValue);
};
__awaiter2 = function(thisArg, _arguments, P, generator) {
function adopt(value) {
return value instanceof P ? value : new P(function(resolve) {
resolve(value);
});
}
return new (P || (P = Promise))(function(resolve, reject) {
function fulfilled(value) {
try {
step(generator.next(value));
} catch (e) {
reject(e);
}
}
function rejected(value) {
try {
step(generator["throw"](value));
} catch (e) {
reject(e);
}
}
function step(result) {
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
}
step((generator = generator.apply(thisArg, _arguments || [])).next());
});
};
__generator2 = function(thisArg, body) {
var _ = { label: 0, sent: function() {
if (t[0] & 1)
throw t[1];
return t[1];
}, trys: [], ops: [] }, f, y, t, g;
return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() {
return this;
}), g;
function verb(n) {
return function(v) {
return step([n, v]);
};
}
function step(op) {
if (f)
throw new TypeError("Generator is already executing.");
while (_)
try {
if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done)
return t;
if (y = 0, t)
op = [op[0] & 2, t.value];
switch (op[0]) {
case 0:
case 1:
t = op;
break;
case 4:
_.label++;
return { value: op[1], done: false };
case 5:
_.label++;
y = op[1];
op = [0];
continue;
case 7:
op = _.ops.pop();
_.trys.pop();
continue;
default:
if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) {
_ = 0;
continue;
}
if (op[0] === 3 && (!t || op[1] > t[0] && op[1] < t[3])) {
_.label = op[1];
break;
}
if (op[0] === 6 && _.label < t[1]) {
_.label = t[1];
t = op;
break;
}
if (t && _.label < t[2]) {
_.label = t[2];
_.ops.push(op);
break;
}
if (t[2])
_.ops.pop();
_.trys.pop();
continue;
}
op = body.call(thisArg, _);
} catch (e) {
op = [6, e];
y = 0;
} finally {
f = t = 0;
}
if (op[0] & 5)
throw op[1];
return { value: op[0] ? op[1] : void 0, done: true };
}
};
__createBinding2 = function(o, m, k, k2) {
if (k2 === void 0)
k2 = k;
o[k2] = m[k];
};
__exportStar2 = function(m, exports2) {
for (var p in m)
if (p !== "default" && !exports2.hasOwnProperty(p))
exports2[p] = m[p];
};
__values2 = function(o) {
var s = typeof Symbol === "function" && Symbol.iterator, m = s && o[s], i = 0;
if (m)
return m.call(o);
if (o && typeof o.length === "number")
return {
next: function() {
if (o && i >= o.length)
o = void 0;
return { value: o && o[i++], done: !o };
}
};
throw new TypeError(s ? "Object is not iterable." : "Symbol.iterator is not defined.");
};
__read2 = function(o, n) {
var m = typeof Symbol === "function" && o[Symbol.iterator];
if (!m)
return o;
var i = m.call(o), r, ar = [], e;
try {
while ((n === void 0 || n-- > 0) && !(r = i.next()).done)
ar.push(r.value);
} catch (error) {
e = { error };
} finally {
try {
if (r && !r.done && (m = i["return"]))
m.call(i);
} finally {
if (e)
throw e.error;
}
}
return ar;
};
__spread2 = function() {
for (var ar = [], i = 0; i < arguments.length; i++)
ar = ar.concat(__read2(arguments[i]));
return ar;
};
__spreadArrays2 = function() {
for (var s = 0, i = 0, il = arguments.length; i < il; i++)
s += arguments[i].length;
for (var r = Array(s), k = 0, i = 0; i < il; i++)
for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
r[k] = a[j];
return r;
};
__await2 = function(v) {
return this instanceof __await2 ? (this.v = v, this) : new __await2(v);
};
__asyncGenerator2 = function(thisArg, _arguments, generator) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var g = generator.apply(thisArg, _arguments || []), i, q = [];
return i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i;
function verb(n) {
if (g[n])
i[n] = function(v) {
return new Promise(function(a, b) {
q.push([n, v, a, b]) > 1 || resume(n, v);
});
};
}
function resume(n, v) {
try {
step(g[n](v));
} catch (e) {
settle(q[0][3], e);
}
}
function step(r) {
r.value instanceof __await2 ? Promise.resolve(r.value.v).then(fulfill, reject) : settle(q[0][2], r);
}
function fulfill(value) {
resume("next", value);
}
function reject(value) {
resume("throw", value);
}
function settle(f, v) {
if (f(v), q.shift(), q.length)
resume(q[0][0], q[0][1]);
}
};
__asyncDelegator2 = function(o) {
var i, p;
return i = {}, verb("next"), verb("throw", function(e) {
throw e;
}), verb("return"), i[Symbol.iterator] = function() {
return this;
}, i;
function verb(n, f) {
i[n] = o[n] ? function(v) {
return (p = !p) ? { value: __await2(o[n](v)), done: n === "return" } : f ? f(v) : v;
} : f;
}
};
__asyncValues2 = function(o) {
if (!Symbol.asyncIterator)
throw new TypeError("Symbol.asyncIterator is not defined.");
var m = o[Symbol.asyncIterator], i;
return m ? m.call(o) : (o = typeof __values2 === "function" ? __values2(o) : o[Symbol.iterator](), i = {}, verb("next"), verb("throw"), verb("return"), i[Symbol.asyncIterator] = function() {
return this;
}, i);
function verb(n) {
i[n] = o[n] && function(v) {
return new Promise(function(resolve, reject) {
v = o[n](v), settle(resolve, reject, v.done, v.value);
});
};
}
function settle(resolve, reject, d, v) {
Promise.resolve(v).then(function(v2) {
resolve({ value: v2, done: d });
}, reject);
}
};
__makeTemplateObject2 = function(cooked, raw) {
if (Object.defineProperty) {
Object.defineProperty(cooked, "raw", { value: raw });
} else {
cooked.raw = raw;
}
return cooked;
};
__importStar2 = function(mod) {
if (mod && mod.__esModule)
return mod;
var result = {};
if (mod != null) {
for (var k in mod)
if (Object.hasOwnProperty.call(mod, k))
result[k] = mod[k];
}
result["default"] = mod;
return result;
};
__importDefault2 = function(mod) {
return mod && mod.__esModule ? mod : { "default": mod };
};
__classPrivateFieldGet2 = function(receiver, privateMap) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to get private field on non-instance");
}
return privateMap.get(receiver);
};
__classPrivateFieldSet2 = function(receiver, privateMap, value) {
if (!privateMap.has(receiver)) {
throw new TypeError("attempted to set private field on non-instance");
}
privateMap.set(receiver, value);
return value;
};
exporter("__extends", __extends2);
exporter("__assign", __assign2);
exporter("__rest", __rest2);
exporter("__decorate", __decorate2);
exporter("__param", __param2);
exporter("__metadata", __metadata2);
exporter("__awaiter", __awaiter2);
exporter("__generator", __generator2);
exporter("__exportStar", __exportStar2);
exporter("__createBinding", __createBinding2);
exporter("__values", __values2);
exporter("__read", __read2);
exporter("__spread", __spread2);
exporter("__spreadArrays", __spreadArrays2);
exporter("__await", __await2);
exporter("__asyncGenerator", __asyncGenerator2);
exporter("__asyncDelegator", __asyncDelegator2);
exporter("__asyncValues", __asyncValues2);
exporter("__makeTemplateObject", __makeTemplateObject2);
exporter("__importStar", __importStar2);
exporter("__importDefault", __importDefault2);
exporter("__classPrivateFieldGet", __classPrivateFieldGet2);
exporter("__classPrivateFieldSet", __classPrivateFieldSet2);
});
}
});
// node_modules/luxon/build/cjs-browser/luxon.js
var require_luxon = __commonJS({
"node_modules/luxon/build/cjs-browser/luxon.js"(exports) {
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
function _defineProperties(target, props) {
for (var i = 0; i < props.length; i++) {
var descriptor = props[i];
descriptor.enumerable = descriptor.enumerable || false;
descriptor.configurable = true;
if ("value" in descriptor)
descriptor.writable = true;
Object.defineProperty(target, descriptor.key, descriptor);
}
}
function _createClass(Constructor, protoProps, staticProps) {
if (protoProps)
_defineProperties(Constructor.prototype, protoProps);
if (staticProps)
_defineProperties(Constructor, staticProps);
return Constructor;
}
function _inheritsLoose(subClass, superClass) {
subClass.prototype = Object.create(superClass.prototype);
subClass.prototype.constructor = subClass;
subClass.__proto__ = superClass;
}
function _getPrototypeOf(o) {
_getPrototypeOf = Object.setPrototypeOf ? Object.getPrototypeOf : function _getPrototypeOf2(o2) {
return o2.__proto__ || Object.getPrototypeOf(o2);
};
return _getPrototypeOf(o);
}
function _setPrototypeOf(o, p) {
_setPrototypeOf = Object.setPrototypeOf || function _setPrototypeOf2(o2, p2) {
o2.__proto__ = p2;
return o2;
};
return _setPrototypeOf(o, p);
}
function _isNativeReflectConstruct() {
if (typeof Reflect === "undefined" || !Reflect.construct)
return false;
if (Reflect.construct.sham)
return false;
if (typeof Proxy === "function")
return true;
try {
Date.prototype.toString.call(Reflect.construct(Date, [], function() {
}));
return true;
} catch (e) {
return false;
}
}
function _construct(Parent, args, Class) {
if (_isNativeReflectConstruct()) {
_construct = Reflect.construct;
} else {
_construct = function _construct2(Parent2, args2, Class2) {
var a = [null];
a.push.apply(a, args2);
var Constructor = Function.bind.apply(Parent2, a);
var instance8 = new Constructor();
if (Class2)
_setPrototypeOf(instance8, Class2.prototype);
return instance8;
};
}
return _construct.apply(null, arguments);
}
function _isNativeFunction(fn) {
return Function.toString.call(fn).indexOf("[native code]") !== -1;
}
function _wrapNativeSuper(Class) {
var _cache = typeof Map === "function" ? /* @__PURE__ */ new Map() : void 0;
_wrapNativeSuper = function _wrapNativeSuper2(Class2) {
if (Class2 === null || !_isNativeFunction(Class2))
return Class2;
if (typeof Class2 !== "function") {
throw new TypeError("Super expression must either be null or a function");
}
if (typeof _cache !== "undefined") {
if (_cache.has(Class2))
return _cache.get(Class2);
_cache.set(Class2, Wrapper);
}
function Wrapper() {
return _construct(Class2, arguments, _getPrototypeOf(this).constructor);
}
Wrapper.prototype = Object.create(Class2.prototype, {
constructor: {
value: Wrapper,
enumerable: false,
writable: true,
configurable: true
}
});
return _setPrototypeOf(Wrapper, Class2);
};
return _wrapNativeSuper(Class);
}
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;
}
function _unsupportedIterableToArray(o, minLen) {
if (!o)
return;
if (typeof o === "string")
return _arrayLikeToArray(o, minLen);
var n2 = Object.prototype.toString.call(o).slice(8, -1);
if (n2 === "Object" && o.constructor)
n2 = o.constructor.name;
if (n2 === "Map" || n2 === "Set")
return Array.from(n2);
if (n2 === "Arguments" || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(n2))
return _arrayLikeToArray(o, minLen);
}
function _arrayLikeToArray(arr, len) {
if (len == null || len > arr.length)
len = arr.length;
for (var i = 0, arr2 = new Array(len); i < len; i++)
arr2[i] = arr[i];
return arr2;
}
function _createForOfIteratorHelperLoose(o) {
var i = 0;
if (typeof Symbol === "undefined" || o[Symbol.iterator] == null) {
if (Array.isArray(o) || (o = _unsupportedIterableToArray(o)))
return function() {
if (i >= o.length)
return {
done: true
};
return {
done: false,
value: o[i++]
};
};
throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
}
i = o[Symbol.iterator]();
return i.next.bind(i);
}
var LuxonError = /* @__PURE__ */ function(_Error) {
_inheritsLoose(LuxonError2, _Error);
function LuxonError2() {
return _Error.apply(this, arguments) || this;
}
return LuxonError2;
}(/* @__PURE__ */ _wrapNativeSuper(Error));
var InvalidDateTimeError = /* @__PURE__ */ function(_LuxonError) {
_inheritsLoose(InvalidDateTimeError2, _LuxonError);
function InvalidDateTimeError2(reason) {
return _LuxonError.call(this, "Invalid DateTime: " + reason.toMessage()) || this;
}
return InvalidDateTimeError2;
}(LuxonError);
var InvalidIntervalError = /* @__PURE__ */ function(_LuxonError2) {
_inheritsLoose(InvalidIntervalError2, _LuxonError2);
function InvalidIntervalError2(reason) {
return _LuxonError2.call(this, "Invalid Interval: " + reason.toMessage()) || this;
}
return InvalidIntervalError2;
}(LuxonError);
var InvalidDurationError = /* @__PURE__ */ function(_LuxonError3) {
_inheritsLoose(InvalidDurationError2, _LuxonError3);
function InvalidDurationError2(reason) {
return _LuxonError3.call(this, "Invalid Duration: " + reason.toMessage()) || this;
}
return InvalidDurationError2;
}(LuxonError);
var ConflictingSpecificationError = /* @__PURE__ */ function(_LuxonError4) {
_inheritsLoose(ConflictingSpecificationError2, _LuxonError4);
function ConflictingSpecificationError2() {
return _LuxonError4.apply(this, arguments) || this;
}
return ConflictingSpecificationError2;
}(LuxonError);
var InvalidUnitError = /* @__PURE__ */ function(_LuxonError5) {
_inheritsLoose(InvalidUnitError2, _LuxonError5);
function InvalidUnitError2(unit) {
return _LuxonError5.call(this, "Invalid unit " + unit) || this;
}
return InvalidUnitError2;
}(LuxonError);
var InvalidArgumentError = /* @__PURE__ */ function(_LuxonError6) {
_inheritsLoose(InvalidArgumentError2, _LuxonError6);
function InvalidArgumentError2() {
return _LuxonError6.apply(this, arguments) || this;
}
return InvalidArgumentError2;
}(LuxonError);
var ZoneIsAbstractError = /* @__PURE__ */ function(_LuxonError7) {
_inheritsLoose(ZoneIsAbstractError2, _LuxonError7);
function ZoneIsAbstractError2() {
return _LuxonError7.call(this, "Zone is an abstract class") || this;
}
return ZoneIsAbstractError2;
}(LuxonError);
var n = "numeric";
var s = "short";
var l = "long";
var DATE_SHORT = {
year: n,
month: n,
day: n
};
var DATE_MED = {
year: n,
month: s,
day: n
};
var DATE_MED_WITH_WEEKDAY = {
year: n,
month: s,
day: n,
weekday: s
};
var DATE_FULL = {
year: n,
month: l,
day: n
};
var DATE_HUGE = {
year: n,
month: l,
day: n,
weekday: l
};
var TIME_SIMPLE = {
hour: n,
minute: n
};
var TIME_WITH_SECONDS = {
hour: n,
minute: n,
second: n
};
var TIME_WITH_SHORT_OFFSET = {
hour: n,
minute: n,
second: n,
timeZoneName: s
};
var TIME_WITH_LONG_OFFSET = {
hour: n,
minute: n,
second: n,
timeZoneName: l
};
var TIME_24_SIMPLE = {
hour: n,
minute: n,
hour12: false
};
var TIME_24_WITH_SECONDS = {
hour: n,
minute: n,
second: n,
hour12: false
};
var TIME_24_WITH_SHORT_OFFSET = {
hour: n,
minute: n,
second: n,
hour12: false,
timeZoneName: s
};
var TIME_24_WITH_LONG_OFFSET = {
hour: n,
minute: n,
second: n,
hour12: false,
timeZoneName: l
};
var DATETIME_SHORT = {
year: n,
month: n,
day: n,
hour: n,
minute: n
};
var DATETIME_SHORT_WITH_SECONDS = {
year: n,
month: n,
day: n,
hour: n,
minute: n,
second: n
};
var DATETIME_MED = {
year: n,
month: s,
day: n,
hour: n,
minute: n
};
var DATETIME_MED_WITH_SECONDS = {
year: n,
month: s,
day: n,
hour: n,
minute: n,
second: n
};
var DATETIME_MED_WITH_WEEKDAY = {
year: n,
month: s,
day: n,
weekday: s,
hour: n,
minute: n
};
var DATETIME_FULL = {
year: n,
month: l,
day: n,
hour: n,
minute: n,
timeZoneName: s
};
var DATETIME_FULL_WITH_SECONDS = {
year: n,
month: l,
day: n,
hour: n,
minute: n,
second: n,
timeZoneName: s
};
var DATETIME_HUGE = {
year: n,
month: l,
day: n,
weekday: l,
hour: n,
minute: n,
timeZoneName: l
};
var DATETIME_HUGE_WITH_SECONDS = {
year: n,
month: l,
day: n,
weekday: l,
hour: n,
minute: n,
second: n,
timeZoneName: l
};
function isUndefined(o) {
return typeof o === "undefined";
}
function isNumber2(o) {
return typeof o === "number";
}
function isInteger(o) {
return typeof o === "number" && o % 1 === 0;
}
function isString(o) {
return typeof o === "string";
}
function isDate(o) {
return Object.prototype.toString.call(o) === "[object Date]";
}
function hasIntl() {
try {
return typeof Intl !== "undefined" && Intl.DateTimeFormat;
} catch (e) {
return false;
}
}
function hasFormatToParts() {
return !isUndefined(Intl.DateTimeFormat.prototype.formatToParts);
}
function hasRelative() {
try {
return typeof Intl !== "undefined" && !!Intl.RelativeTimeFormat;
} catch (e) {
return false;
}
}
function maybeArray(thing) {
return Array.isArray(thing) ? thing : [thing];
}
function bestBy(arr, by, compare) {
if (arr.length === 0) {
return void 0;
}
return arr.reduce(function(best, next) {
var pair = [by(next), next];
if (!best) {
return pair;
} else if (compare(best[0], pair[0]) === best[0]) {
return best;
} else {
return pair;
}
}, null)[1];
}
function pick(obj, keys) {
return keys.reduce(function(a, k) {
a[k] = obj[k];
return a;
}, {});
}
function hasOwnProperty(obj, prop) {
return Object.prototype.hasOwnProperty.call(obj, prop);
}
function integerBetween(thing, bottom, top) {
return isInteger(thing) && thing >= bottom && thing <= top;
}
function floorMod(x, n2) {
return x - n2 * Math.floor(x / n2);
}
function padStart2(input, n2) {
if (n2 === void 0) {
n2 = 2;
}
var minus = input < 0 ? "-" : "";
var target = minus ? input * -1 : input;
var result;
if (target.toString().length < n2) {
result = ("0".repeat(n2) + target).slice(-n2);
} else {
result = target.toString();
}
return "" + minus + result;
}
function parseInteger(string) {
if (isUndefined(string) || string === null || string === "") {
return void 0;
} else {
return parseInt(string, 10);
}
}
function parseMillis(fraction) {
if (isUndefined(fraction) || fraction === null || fraction === "") {
return void 0;
} else {
var f = parseFloat("0." + fraction) * 1e3;
return Math.floor(f);
}
}
function roundTo(number, digits, towardZero) {
if (towardZero === void 0) {
towardZero = false;
}
var factor = Math.pow(10, digits), rounder = towardZero ? Math.trunc : Math.round;
return rounder(number * factor) / factor;
}
function isLeapYear(year) {
return year % 4 === 0 && (year % 100 !== 0 || year % 400 === 0);
}
function daysInYear(year) {
return isLeapYear(year) ? 366 : 365;
}
function daysInMonth(year, month) {
var modMonth = floorMod(month - 1, 12) + 1, modYear = year + (month - modMonth) / 12;
if (modMonth === 2) {
return isLeapYear(modYear) ? 29 : 28;
} else {
return [31, null, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31][modMonth - 1];
}
}
function objToLocalTS(obj) {
var d = Date.UTC(obj.year, obj.month - 1, obj.day, obj.hour, obj.minute, obj.second, obj.millisecond);
if (obj.year < 100 && obj.year >= 0) {
d = new Date(d);
d.setUTCFullYear(d.getUTCFullYear() - 1900);
}
return +d;
}
function weeksInWeekYear(weekYear) {
var p1 = (weekYear + Math.floor(weekYear / 4) - Math.floor(weekYear / 100) + Math.floor(weekYear / 400)) % 7, last = weekYear - 1, p2 = (last + Math.floor(last / 4) - Math.floor(last / 100) + Math.floor(last / 400)) % 7;
return p1 === 4 || p2 === 3 ? 53 : 52;
}
function untruncateYear(year) {
if (year > 99) {
return year;
} else
return year > 60 ? 1900 + year : 2e3 + year;
}
function parseZoneInfo(ts, offsetFormat, locale, timeZone) {
if (timeZone === void 0) {
timeZone = null;
}
var date = new Date(ts), intlOpts = {
hour12: false,
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit"
};
if (timeZone) {
intlOpts.timeZone = timeZone;
}
var modified = Object.assign({
timeZoneName: offsetFormat
}, intlOpts), intl = hasIntl();
if (intl && hasFormatToParts()) {
var parsed = new Intl.DateTimeFormat(locale, modified).formatToParts(date).find(function(m) {
return m.type.toLowerCase() === "timezonename";
});
return parsed ? parsed.value : null;
} else if (intl) {
var without = new Intl.DateTimeFormat(locale, intlOpts).format(date), included = new Intl.DateTimeFormat(locale, modified).format(date), diffed = included.substring(without.length), trimmed = diffed.replace(/^[, \u200e]+/, "");
return trimmed;
} else {
return null;
}
}
function signedOffset(offHourStr, offMinuteStr) {
var offHour = parseInt(offHourStr, 10);
if (Number.isNaN(offHour)) {
offHour = 0;
}
var offMin = parseInt(offMinuteStr, 10) || 0, offMinSigned = offHour < 0 || Object.is(offHour, -0) ? -offMin : offMin;
return offHour * 60 + offMinSigned;
}
function asNumber(value) {
var numericValue = Number(value);
if (typeof value === "boolean" || value === "" || Number.isNaN(numericValue))
throw new InvalidArgumentError("Invalid unit value " + value);
return numericValue;
}
function normalizeObject(obj, normalizer, nonUnitKeys) {
var normalized = {};
for (var u in obj) {
if (hasOwnProperty(obj, u)) {
if (nonUnitKeys.indexOf(u) >= 0)
continue;
var v = obj[u];
if (v === void 0 || v === null)
continue;
normalized[normalizer(u)] = asNumber(v);
}
}
return normalized;
}
function formatOffset(offset2, format) {
var hours = Math.trunc(Math.abs(offset2 / 60)), minutes = Math.trunc(Math.abs(offset2 % 60)), sign = offset2 >= 0 ? "+" : "-";
switch (format) {
case "short":
return "" + sign + padStart2(hours, 2) + ":" + padStart2(minutes, 2);
case "narrow":
return "" + sign + hours + (minutes > 0 ? ":" + minutes : "");
case "techie":
return "" + sign + padStart2(hours, 2) + padStart2(minutes, 2);
default:
throw new RangeError("Value format " + format + " is out of range for property format");
}
}
function timeObject(obj) {
return pick(obj, ["hour", "minute", "second", "millisecond"]);
}
var ianaRegex = /[A-Za-z_+-]{1,256}(:?\/[A-Za-z_+-]{1,256}(\/[A-Za-z_+-]{1,256})?)?/;
function stringify(obj) {
return JSON.stringify(obj, Object.keys(obj).sort());
}
var monthsLong = ["January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December"];
var monthsShort = ["Jan", "Feb", "Mar", "Apr", "May", "Jun", "Jul", "Aug", "Sep", "Oct", "Nov", "Dec"];
var monthsNarrow = ["J", "F", "M", "A", "M", "J", "J", "A", "S", "O", "N", "D"];
function months(length) {
switch (length) {
case "narrow":
return [].concat(monthsNarrow);
case "short":
return [].concat(monthsShort);
case "long":
return [].concat(monthsLong);
case "numeric":
return ["1", "2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12"];
case "2-digit":
return ["01", "02", "03", "04", "05", "06", "07", "08", "09", "10", "11", "12"];
default:
return null;
}
}
var weekdaysLong = ["Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday", "Sunday"];
var weekdaysShort = ["Mon", "Tue", "Wed", "Thu", "Fri", "Sat", "Sun"];
var weekdaysNarrow = ["M", "T", "W", "T", "F", "S", "S"];
function weekdays(length) {
switch (length) {
case "narrow":
return [].concat(weekdaysNarrow);
case "short":
return [].concat(weekdaysShort);
case "long":
return [].concat(weekdaysLong);
case "numeric":
return ["1", "2", "3", "4", "5", "6", "7"];
default:
return null;
}
}
var meridiems = ["AM", "PM"];
var erasLong = ["Before Christ", "Anno Domini"];
var erasShort = ["BC", "AD"];
var erasNarrow = ["B", "A"];
function eras(length) {
switch (length) {
case "narrow":
return [].concat(erasNarrow);
case "short":
return [].concat(erasShort);
case "long":
return [].concat(erasLong);
default:
return null;
}
}
function meridiemForDateTime(dt) {
return meridiems[dt.hour < 12 ? 0 : 1];
}
function weekdayForDateTime(dt, length) {
return weekdays(length)[dt.weekday - 1];
}
function monthForDateTime(dt, length) {
return months(length)[dt.month - 1];
}
function eraForDateTime(dt, length) {
return eras(length)[dt.year < 0 ? 0 : 1];
}
function formatRelativeTime(unit, count, numeric, narrow) {
if (numeric === void 0) {
numeric = "always";
}
if (narrow === void 0) {
narrow = false;
}
var units = {
years: ["year", "yr."],
quarters: ["quarter", "qtr."],
months: ["month", "mo."],
weeks: ["week", "wk."],
days: ["day", "day", "days"],
hours: ["hour", "hr."],
minutes: ["minute", "min."],
seconds: ["second", "sec."]
};
var lastable = ["hours", "minutes", "seconds"].indexOf(unit) === -1;
if (numeric === "auto" && lastable) {
var isDay = unit === "days";
switch (count) {
case 1:
return isDay ? "tomorrow" : "next " + units[unit][0];
case -1:
return isDay ? "yesterday" : "last " + units[unit][0];
case 0:
return isDay ? "today" : "this " + units[unit][0];
}
}
var isInPast = Object.is(count, -0) || count < 0, fmtValue = Math.abs(count), singular = fmtValue === 1, lilUnits = units[unit], fmtUnit = narrow ? singular ? lilUnits[1] : lilUnits[2] || lilUnits[1] : singular ? units[unit][0] : unit;
return isInPast ? fmtValue + " " + fmtUnit + " ago" : "in " + fmtValue + " " + fmtUnit;
}
function formatString(knownFormat) {
var filtered = pick(knownFormat, ["weekday", "era", "year", "month", "day", "hour", "minute", "second", "timeZoneName", "hour12"]), key = stringify(filtered), dateTimeHuge = "EEEE, LLLL d, yyyy, h:mm a";
switch (key) {
case stringify(DATE_SHORT):
return "M/d/yyyy";
case stringify(DATE_MED):
return "LLL d, yyyy";
case stringify(DATE_MED_WITH_WEEKDAY):
return "EEE, LLL d, yyyy";
case stringify(DATE_FULL):
return "LLLL d, yyyy";
case stringify(DATE_HUGE):
return "EEEE, LLLL d, yyyy";
case stringify(TIME_SIMPLE):
return "h:mm a";
case stringify(TIME_WITH_SECONDS):
return "h:mm:ss a";
case stringify(TIME_WITH_SHORT_OFFSET):
return "h:mm a";
case stringify(TIME_WITH_LONG_OFFSET):
return "h:mm a";
case stringify(TIME_24_SIMPLE):
return "HH:mm";
case stringify(TIME_24_WITH_SECONDS):
return "HH:mm:ss";
case stringify(TIME_24_WITH_SHORT_OFFSET):
return "HH:mm";
case stringify(TIME_24_WITH_LONG_OFFSET):
return "HH:mm";
case stringify(DATETIME_SHORT):
return "M/d/yyyy, h:mm a";
case stringify(DATETIME_MED):
return "LLL d, yyyy, h:mm a";
case stringify(DATETIME_FULL):
return "LLLL d, yyyy, h:mm a";
case stringify(DATETIME_HUGE):
return dateTimeHuge;
case stringify(DATETIME_SHORT_WITH_SECONDS):
return "M/d/yyyy, h:mm:ss a";
case stringify(DATETIME_MED_WITH_SECONDS):
return "LLL d, yyyy, h:mm:ss a";
case stringify(DATETIME_MED_WITH_WEEKDAY):
return "EEE, d LLL yyyy, h:mm a";
case stringify(DATETIME_FULL_WITH_SECONDS):
return "LLLL d, yyyy, h:mm:ss a";
case stringify(DATETIME_HUGE_WITH_SECONDS):
return "EEEE, LLLL d, yyyy, h:mm:ss a";
default:
return dateTimeHuge;
}
}
function stringifyTokens(splits, tokenToString) {
var s2 = "";
for (var _iterator = _createForOfIteratorHelperLoose(splits), _step; !(_step = _iterator()).done; ) {
var token = _step.value;
if (token.literal) {
s2 += token.val;
} else {
s2 += tokenToString(token.val);
}
}
return s2;
}
var _macroTokenToFormatOpts = {
D: DATE_SHORT,
DD: DATE_MED,
DDD: DATE_FULL,
DDDD: DATE_HUGE,
t: TIME_SIMPLE,
tt: TIME_WITH_SECONDS,
ttt: TIME_WITH_SHORT_OFFSET,
tttt: TIME_WITH_LONG_OFFSET,
T: TIME_24_SIMPLE,
TT: TIME_24_WITH_SECONDS,
TTT: TIME_24_WITH_SHORT_OFFSET,
TTTT: TIME_24_WITH_LONG_OFFSET,
f: DATETIME_SHORT,
ff: DATETIME_MED,
fff: DATETIME_FULL,
ffff: DATETIME_HUGE,
F: DATETIME_SHORT_WITH_SECONDS,
FF: DATETIME_MED_WITH_SECONDS,
FFF: DATETIME_FULL_WITH_SECONDS,
FFFF: DATETIME_HUGE_WITH_SECONDS
};
var Formatter = /* @__PURE__ */ function() {
Formatter2.create = function create(locale, opts) {
if (opts === void 0) {
opts = {};
}
return new Formatter2(locale, opts);
};
Formatter2.parseFormat = function parseFormat(fmt) {
var current = null, currentFull = "", bracketed = false;
var splits = [];
for (var i = 0; i < fmt.length; i++) {
var c = fmt.charAt(i);
if (c === "'") {
if (currentFull.length > 0) {
splits.push({
literal: bracketed,
val: currentFull
});
}
current = null;
currentFull = "";
bracketed = !bracketed;
} else if (bracketed) {
currentFull += c;
} else if (c === current) {
currentFull += c;
} else {
if (currentFull.length > 0) {
splits.push({
literal: false,
val: currentFull
});
}
currentFull = c;
current = c;
}
}
if (currentFull.length > 0) {
splits.push({
literal: bracketed,
val: currentFull
});
}
return splits;
};
Formatter2.macroTokenToFormatOpts = function macroTokenToFormatOpts(token) {
return _macroTokenToFormatOpts[token];
};
function Formatter2(locale, formatOpts) {
this.opts = formatOpts;
this.loc = locale;
this.systemLoc = null;
}
var _proto = Formatter2.prototype;
_proto.formatWithSystemDefault = function formatWithSystemDefault(dt, opts) {
if (this.systemLoc === null) {
this.systemLoc = this.loc.redefaultToSystem();
}
var df = this.systemLoc.dtFormatter(dt, Object.assign({}, this.opts, opts));
return df.format();
};
_proto.formatDateTime = function formatDateTime(dt, opts) {
if (opts === void 0) {
opts = {};
}
var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
return df.format();
};
_proto.formatDateTimeParts = function formatDateTimeParts(dt, opts) {
if (opts === void 0) {
opts = {};
}
var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
return df.formatToParts();
};
_proto.resolvedOptions = function resolvedOptions(dt, opts) {
if (opts === void 0) {
opts = {};
}
var df = this.loc.dtFormatter(dt, Object.assign({}, this.opts, opts));
return df.resolvedOptions();
};
_proto.num = function num(n2, p) {
if (p === void 0) {
p = 0;
}
if (this.opts.forceSimple) {
return padStart2(n2, p);
}
var opts = Object.assign({}, this.opts);
if (p > 0) {
opts.padTo = p;
}
return this.loc.numberFormatter(opts).format(n2);
};
_proto.formatDateTimeFromString = function formatDateTimeFromString(dt, fmt) {
var _this = this;
var knownEnglish = this.loc.listingMode() === "en", useDateTimeFormatter = this.loc.outputCalendar && this.loc.outputCalendar !== "gregory" && hasFormatToParts(), string = function string2(opts, extract) {
return _this.loc.extract(dt, opts, extract);
}, formatOffset2 = function formatOffset3(opts) {
if (dt.isOffsetFixed && dt.offset === 0 && opts.allowZ) {
return "Z";
}
return dt.isValid ? dt.zone.formatOffset(dt.ts, opts.format) : "";
}, meridiem = function meridiem2() {
return knownEnglish ? meridiemForDateTime(dt) : string({
hour: "numeric",
hour12: true
}, "dayperiod");
}, month = function month2(length, standalone) {
return knownEnglish ? monthForDateTime(dt, length) : string(standalone ? {
month: length
} : {
month: length,
day: "numeric"
}, "month");
}, weekday = function weekday2(length, standalone) {
return knownEnglish ? weekdayForDateTime(dt, length) : string(standalone ? {
weekday: length
} : {
weekday: length,
month: "long",
day: "numeric"
}, "weekday");
}, maybeMacro = function maybeMacro2(token) {
var formatOpts = Formatter2.macroTokenToFormatOpts(token);
if (formatOpts) {
return _this.formatWithSystemDefault(dt, formatOpts);
} else {
return token;
}
}, era = function era2(length) {
return knownEnglish ? eraForDateTime(dt, length) : string({
era: length
}, "era");
}, tokenToString = function tokenToString2(token) {
switch (token) {
case "S":
return _this.num(dt.millisecond);
case "u":
case "SSS":
return _this.num(dt.millisecond, 3);
case "s":
return _this.num(dt.second);
case "ss":
return _this.num(dt.second, 2);
case "m":
return _this.num(dt.minute);
case "mm":
return _this.num(dt.minute, 2);
case "h":
return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12);
case "hh":
return _this.num(dt.hour % 12 === 0 ? 12 : dt.hour % 12, 2);
case "H":
return _this.num(dt.hour);
case "HH":
return _this.num(dt.hour, 2);
case "Z":
return formatOffset2({
format: "narrow",
allowZ: _this.opts.allowZ
});
case "ZZ":
return formatOffset2({
format: "short",
allowZ: _this.opts.allowZ
});
case "ZZZ":
return formatOffset2({
format: "techie",
allowZ: _this.opts.allowZ
});
case "ZZZZ":
return dt.zone.offsetName(dt.ts, {
format: "short",
locale: _this.loc.locale
});
case "ZZZZZ":
return dt.zone.offsetName(dt.ts, {
format: "long",
locale: _this.loc.locale
});
case "z":
return dt.zoneName;
case "a":
return meridiem();
case "d":
return useDateTimeFormatter ? string({
day: "numeric"
}, "day") : _this.num(dt.day);
case "dd":
return useDateTimeFormatter ? string({
day: "2-digit"
}, "day") : _this.num(dt.day, 2);
case "c":
return _this.num(dt.weekday);
case "ccc":
return weekday("short", true);
case "cccc":
return weekday("long", true);
case "ccccc":
return weekday("narrow", true);
case "E":
return _this.num(dt.weekday);
case "EEE":
return weekday("short", false);
case "EEEE":
return weekday("long", false);
case "EEEEE":
return weekday("narrow", false);
case "L":
return useDateTimeFormatter ? string({
month: "numeric",
day: "numeric"
}, "month") : _this.num(dt.month);
case "LL":
return useDateTimeFormatter ? string({
month: "2-digit",
day: "numeric"
}, "month") : _this.num(dt.month, 2);
case "LLL":
return month("short", true);
case "LLLL":
return month("long", true);
case "LLLLL":
return month("narrow", true);
case "M":
return useDateTimeFormatter ? string({
month: "numeric"
}, "month") : _this.num(dt.month);
case "MM":
return useDateTimeFormatter ? string({
month: "2-digit"
}, "month") : _this.num(dt.month, 2);
case "MMM":
return month("short", false);
case "MMMM":
return month("long", false);
case "MMMMM":
return month("narrow", false);
case "y":
return useDateTimeFormatter ? string({
year: "numeric"
}, "year") : _this.num(dt.year);
case "yy":
return useDateTimeFormatter ? string({
year: "2-digit"
}, "year") : _this.num(dt.year.toString().slice(-2), 2);
case "yyyy":
return useDateTimeFormatter ? string({
year: "numeric"
}, "year") : _this.num(dt.year, 4);
case "yyyyyy":
return useDateTimeFormatter ? string({
year: "numeric"
}, "year") : _this.num(dt.year, 6);
case "G":
return era("short");
case "GG":
return era("long");
case "GGGGG":
return era("narrow");
case "kk":
return _this.num(dt.weekYear.toString().slice(-2), 2);
case "kkkk":
return _this.num(dt.weekYear, 4);
case "W":
return _this.num(dt.weekNumber);
case "WW":
return _this.num(dt.weekNumber, 2);
case "o":
return _this.num(dt.ordinal);
case "ooo":
return _this.num(dt.ordinal, 3);
case "q":
return _this.num(dt.quarter);
case "qq":
return _this.num(dt.quarter, 2);
case "X":
return _this.num(Math.floor(dt.ts / 1e3));
case "x":
return _this.num(dt.ts);
default:
return maybeMacro(token);
}
};
return stringifyTokens(Formatter2.parseFormat(fmt), tokenToString);
};
_proto.formatDurationFromString = function formatDurationFromString(dur, fmt) {
var _this2 = this;
var tokenToField = function tokenToField2(token) {
switch (token[0]) {
case "S":
return "millisecond";
case "s":
return "second";
case "m":
return "minute";
case "h":
return "hour";
case "d":
return "day";
case "M":
return "month";
case "y":
return "year";
default:
return null;
}
}, tokenToString = function tokenToString2(lildur) {
return function(token) {
var mapped = tokenToField(token);
if (mapped) {
return _this2.num(lildur.get(mapped), token.length);
} else {
return token;
}
};
}, tokens = Formatter2.parseFormat(fmt), realTokens = tokens.reduce(function(found, _ref) {
var literal = _ref.literal, val = _ref.val;
return literal ? found : found.concat(val);
}, []), collapsed = dur.shiftTo.apply(dur, realTokens.map(tokenToField).filter(function(t) {
return t;
}));
return stringifyTokens(tokens, tokenToString(collapsed));
};
return Formatter2;
}();
var Invalid = /* @__PURE__ */ function() {
function Invalid2(reason, explanation) {
this.reason = reason;
this.explanation = explanation;
}
var _proto = Invalid2.prototype;
_proto.toMessage = function toMessage() {
if (this.explanation) {
return this.reason + ": " + this.explanation;
} else {
return this.reason;
}
};
return Invalid2;
}();
var Zone = /* @__PURE__ */ function() {
function Zone2() {
}
var _proto = Zone2.prototype;
_proto.offsetName = function offsetName(ts, opts) {
throw new ZoneIsAbstractError();
};
_proto.formatOffset = function formatOffset2(ts, format) {
throw new ZoneIsAbstractError();
};
_proto.offset = function offset2(ts) {
throw new ZoneIsAbstractError();
};
_proto.equals = function equals(otherZone) {
throw new ZoneIsAbstractError();
};
_createClass(Zone2, [{
key: "type",
get: function get() {
throw new ZoneIsAbstractError();
}
}, {
key: "name",
get: function get() {
throw new ZoneIsAbstractError();
}
}, {
key: "universal",
get: function get() {
throw new ZoneIsAbstractError();
}
}, {
key: "isValid",
get: function get() {
throw new ZoneIsAbstractError();
}
}]);
return Zone2;
}();
var singleton = null;
var LocalZone = /* @__PURE__ */ function(_Zone) {
_inheritsLoose(LocalZone2, _Zone);
function LocalZone2() {
return _Zone.apply(this, arguments) || this;
}
var _proto = LocalZone2.prototype;
_proto.offsetName = function offsetName(ts, _ref) {
var format = _ref.format, locale = _ref.locale;
return parseZoneInfo(ts, format, locale);
};
_proto.formatOffset = function formatOffset$1(ts, format) {
return formatOffset(this.offset(ts), format);
};
_proto.offset = function offset2(ts) {
return -new Date(ts).getTimezoneOffset();
};
_proto.equals = function equals(otherZone) {
return otherZone.type === "local";
};
_createClass(LocalZone2, [{
key: "type",
get: function get() {
return "local";
}
}, {
key: "name",
get: function get() {
if (hasIntl()) {
return new Intl.DateTimeFormat().resolvedOptions().timeZone;
} else
return "local";
}
}, {
key: "universal",
get: function get() {
return false;
}
}, {
key: "isValid",
get: function get() {
return true;
}
}], [{
key: "instance",
get: function get() {
if (singleton === null) {
singleton = new LocalZone2();
}
return singleton;
}
}]);
return LocalZone2;
}(Zone);
var matchingRegex = RegExp("^" + ianaRegex.source + "$");
var dtfCache = {};
function makeDTF(zone) {
if (!dtfCache[zone]) {
dtfCache[zone] = new Intl.DateTimeFormat("en-US", {
hour12: false,
timeZone: zone,
year: "numeric",
month: "2-digit",
day: "2-digit",
hour: "2-digit",
minute: "2-digit",
second: "2-digit"
});
}
return dtfCache[zone];
}
var typeToPos = {
year: 0,
month: 1,
day: 2,
hour: 3,
minute: 4,
second: 5
};
function hackyOffset(dtf, date) {
var formatted = dtf.format(date).replace(/\u200E/g, ""), parsed = /(\d+)\/(\d+)\/(\d+),? (\d+):(\d+):(\d+)/.exec(formatted), fMonth = parsed[1], fDay = parsed[2], fYear = parsed[3], fHour = parsed[4], fMinute = parsed[5], fSecond = parsed[6];
return [fYear, fMonth, fDay, fHour, fMinute, fSecond];
}
function partsOffset(dtf, date) {
var formatted = dtf.formatToParts(date), filled = [];
for (var i = 0; i < formatted.length; i++) {
var _formatted$i = formatted[i], type = _formatted$i.type, value = _formatted$i.value, pos = typeToPos[type];
if (!isUndefined(pos)) {
filled[pos] = parseInt(value, 10);
}
}
return filled;
}
var ianaZoneCache = {};
var IANAZone = /* @__PURE__ */ function(_Zone) {
_inheritsLoose(IANAZone2, _Zone);
IANAZone2.create = function create(name) {
if (!ianaZoneCache[name]) {
ianaZoneCache[name] = new IANAZone2(name);
}
return ianaZoneCache[name];
};
IANAZone2.resetCache = function resetCache() {
ianaZoneCache = {};
dtfCache = {};
};
IANAZone2.isValidSpecifier = function isValidSpecifier(s2) {
return !!(s2 && s2.match(matchingRegex));
};
IANAZone2.isValidZone = function isValidZone(zone) {
try {
new Intl.DateTimeFormat("en-US", {
timeZone: zone
}).format();
return true;
} catch (e) {
return false;
}
};
IANAZone2.parseGMTOffset = function parseGMTOffset(specifier) {
if (specifier) {
var match2 = specifier.match(/^Etc\/GMT(0|[+-]\d{1,2})$/i);
if (match2) {
return -60 * parseInt(match2[1]);
}
}
return null;
};
function IANAZone2(name) {
var _this;
_this = _Zone.call(this) || this;
_this.zoneName = name;
_this.valid = IANAZone2.isValidZone(name);
return _this;
}
var _proto = IANAZone2.prototype;
_proto.offsetName = function offsetName(ts, _ref) {
var format = _ref.format, locale = _ref.locale;
return parseZoneInfo(ts, format, locale, this.name);
};
_proto.formatOffset = function formatOffset$1(ts, format) {
return formatOffset(this.offset(ts), format);
};
_proto.offset = function offset2(ts) {
var date = new Date(ts);
if (isNaN(date))
return NaN;
var dtf = makeDTF(this.name), _ref2 = dtf.formatToParts ? partsOffset(dtf, date) : hackyOffset(dtf, date), year = _ref2[0], month = _ref2[1], day = _ref2[2], hour = _ref2[3], minute = _ref2[4], second = _ref2[5], adjustedHour = hour === 24 ? 0 : hour;
var asUTC = objToLocalTS({
year,
month,
day,
hour: adjustedHour,
minute,
second,
millisecond: 0
});
var asTS = +date;
var over = asTS % 1e3;
asTS -= over >= 0 ? over : 1e3 + over;
return (asUTC - asTS) / (60 * 1e3);
};
_proto.equals = function equals(otherZone) {
return otherZone.type === "iana" && otherZone.name === this.name;
};
_createClass(IANAZone2, [{
key: "type",
get: function get() {
return "iana";
}
}, {
key: "name",
get: function get() {
return this.zoneName;
}
}, {
key: "universal",
get: function get() {
return false;
}
}, {
key: "isValid",
get: function get() {
return this.valid;
}
}]);
return IANAZone2;
}(Zone);
var singleton$1 = null;
var FixedOffsetZone = /* @__PURE__ */ function(_Zone) {
_inheritsLoose(FixedOffsetZone2, _Zone);
FixedOffsetZone2.instance = function instance8(offset2) {
return offset2 === 0 ? FixedOffsetZone2.utcInstance : new FixedOffsetZone2(offset2);
};
FixedOffsetZone2.parseSpecifier = function parseSpecifier(s2) {
if (s2) {
var r = s2.match(/^utc(?:([+-]\d{1,2})(?::(\d{2}))?)?$/i);
if (r) {
return new FixedOffsetZone2(signedOffset(r[1], r[2]));
}
}
return null;
};
_createClass(FixedOffsetZone2, null, [{
key: "utcInstance",
get: function get() {
if (singleton$1 === null) {
singleton$1 = new FixedOffsetZone2(0);
}
return singleton$1;
}
}]);
function FixedOffsetZone2(offset2) {
var _this;
_this = _Zone.call(this) || this;
_this.fixed = offset2;
return _this;
}
var _proto = FixedOffsetZone2.prototype;
_proto.offsetName = function offsetName() {
return this.name;
};
_proto.formatOffset = function formatOffset$1(ts, format) {
return formatOffset(this.fixed, format);
};
_proto.offset = function offset2() {
return this.fixed;
};
_proto.equals = function equals(otherZone) {
return otherZone.type === "fixed" && otherZone.fixed === this.fixed;
};
_createClass(FixedOffsetZone2, [{
key: "type",
get: function get() {
return "fixed";
}
}, {
key: "name",
get: function get() {
return this.fixed === 0 ? "UTC" : "UTC" + formatOffset(this.fixed, "narrow");
}
}, {
key: "universal",
get: function get() {
return true;
}
}, {
key: "isValid",
get: function get() {
return true;
}
}]);
return FixedOffsetZone2;
}(Zone);
var InvalidZone = /* @__PURE__ */ function(_Zone) {
_inheritsLoose(InvalidZone2, _Zone);
function InvalidZone2(zoneName) {
var _this;
_this = _Zone.call(this) || this;
_this.zoneName = zoneName;
return _this;
}
var _proto = InvalidZone2.prototype;
_proto.offsetName = function offsetName() {
return null;
};
_proto.formatOffset = function formatOffset2() {
return "";
};
_proto.offset = function offset2() {
return NaN;
};
_proto.equals = function equals() {
return false;
};
_createClass(InvalidZone2, [{
key: "type",
get: function get() {
return "invalid";
}
}, {
key: "name",
get: function get() {
return this.zoneName;
}
}, {
key: "universal",
get: function get() {
return false;
}
}, {
key: "isValid",
get: function get() {
return false;
}
}]);
return InvalidZone2;
}(Zone);
function normalizeZone(input, defaultZone2) {
var offset2;
if (isUndefined(input) || input === null) {
return defaultZone2;
} else if (input instanceof Zone) {
return input;
} else if (isString(input)) {
var lowered = input.toLowerCase();
if (lowered === "local")
return defaultZone2;
else if (lowered === "utc" || lowered === "gmt")
return FixedOffsetZone.utcInstance;
else if ((offset2 = IANAZone.parseGMTOffset(input)) != null) {
return FixedOffsetZone.instance(offset2);
} else if (IANAZone.isValidSpecifier(lowered))
return IANAZone.create(input);
else
return FixedOffsetZone.parseSpecifier(lowered) || new InvalidZone(input);
} else if (isNumber2(input)) {
return FixedOffsetZone.instance(input);
} else if (typeof input === "object" && input.offset && typeof input.offset === "number") {
return input;
} else {
return new InvalidZone(input);
}
}
var now = function now2() {
return Date.now();
};
var defaultZone = null;
var defaultLocale = null;
var defaultNumberingSystem = null;
var defaultOutputCalendar = null;
var throwOnInvalid = false;
var Settings2 = /* @__PURE__ */ function() {
function Settings3() {
}
Settings3.resetCaches = function resetCaches() {
Locale.resetCache();
IANAZone.resetCache();
};
_createClass(Settings3, null, [{
key: "now",
get: function get() {
return now;
},
set: function set(n2) {
now = n2;
}
}, {
key: "defaultZoneName",
get: function get() {
return Settings3.defaultZone.name;
},
set: function set(z) {
if (!z) {
defaultZone = null;
} else {
defaultZone = normalizeZone(z);
}
}
}, {
key: "defaultZone",
get: function get() {
return defaultZone || LocalZone.instance;
}
}, {
key: "defaultLocale",
get: function get() {
return defaultLocale;
},
set: function set(locale) {
defaultLocale = locale;
}
}, {
key: "defaultNumberingSystem",
get: function get() {
return defaultNumberingSystem;
},
set: function set(numberingSystem) {
defaultNumberingSystem = numberingSystem;
}
}, {
key: "defaultOutputCalendar",
get: function get() {
return defaultOutputCalendar;
},
set: function set(outputCalendar) {
defaultOutputCalendar = outputCalendar;
}
}, {
key: "throwOnInvalid",
get: function get() {
return throwOnInvalid;
},
set: function set(t) {
throwOnInvalid = t;
}
}]);
return Settings3;
}();
var intlDTCache = {};
function getCachedDTF(locString, opts) {
if (opts === void 0) {
opts = {};
}
var key = JSON.stringify([locString, opts]);
var dtf = intlDTCache[key];
if (!dtf) {
dtf = new Intl.DateTimeFormat(locString, opts);
intlDTCache[key] = dtf;
}
return dtf;
}
var intlNumCache = {};
function getCachedINF(locString, opts) {
if (opts === void 0) {
opts = {};
}
var key = JSON.stringify([locString, opts]);
var inf = intlNumCache[key];
if (!inf) {
inf = new Intl.NumberFormat(locString, opts);
intlNumCache[key] = inf;
}
return inf;
}
var intlRelCache = {};
function getCachedRTF(locString, opts) {
if (opts === void 0) {
opts = {};
}
var _opts = opts, base = _opts.base, cacheKeyOpts = _objectWithoutPropertiesLoose(_opts, ["base"]);
var key = JSON.stringify([locString, cacheKeyOpts]);
var inf = intlRelCache[key];
if (!inf) {
inf = new Intl.RelativeTimeFormat(locString, opts);
intlRelCache[key] = inf;
}
return inf;
}
var sysLocaleCache = null;
function systemLocale() {
if (sysLocaleCache) {
return sysLocaleCache;
} else if (hasIntl()) {
var computedSys = new Intl.DateTimeFormat().resolvedOptions().locale;
sysLocaleCache = !computedSys || computedSys === "und" ? "en-US" : computedSys;
return sysLocaleCache;
} else {
sysLocaleCache = "en-US";
return sysLocaleCache;
}
}
function parseLocaleString(localeStr) {
var uIndex = localeStr.indexOf("-u-");
if (uIndex === -1) {
return [localeStr];
} else {
var options;
var smaller = localeStr.substring(0, uIndex);
try {
options = getCachedDTF(localeStr).resolvedOptions();
} catch (e) {
options = getCachedDTF(smaller).resolvedOptions();
}
var _options = options, numberingSystem = _options.numberingSystem, calendar = _options.calendar;
return [smaller, numberingSystem, calendar];
}
}
function intlConfigString(localeStr, numberingSystem, outputCalendar) {
if (hasIntl()) {
if (outputCalendar || numberingSystem) {
localeStr += "-u";
if (outputCalendar) {
localeStr += "-ca-" + outputCalendar;
}
if (numberingSystem) {
localeStr += "-nu-" + numberingSystem;
}
return localeStr;
} else {
return localeStr;
}
} else {
return [];
}
}
function mapMonths(f) {
var ms = [];
for (var i = 1; i <= 12; i++) {
var dt = DateTime5.utc(2016, i, 1);
ms.push(f(dt));
}
return ms;
}
function mapWeekdays(f) {
var ms = [];
for (var i = 1; i <= 7; i++) {
var dt = DateTime5.utc(2016, 11, 13 + i);
ms.push(f(dt));
}
return ms;
}
function listStuff(loc, length, defaultOK, englishFn, intlFn) {
var mode = loc.listingMode(defaultOK);
if (mode === "error") {
return null;
} else if (mode === "en") {
return englishFn(length);
} else {
return intlFn(length);
}
}
function supportsFastNumbers(loc) {
if (loc.numberingSystem && loc.numberingSystem !== "latn") {
return false;
} else {
return loc.numberingSystem === "latn" || !loc.locale || loc.locale.startsWith("en") || hasIntl() && new Intl.DateTimeFormat(loc.intl).resolvedOptions().numberingSystem === "latn";
}
}
var PolyNumberFormatter = /* @__PURE__ */ function() {
function PolyNumberFormatter2(intl, forceSimple, opts) {
this.padTo = opts.padTo || 0;
this.floor = opts.floor || false;
if (!forceSimple && hasIntl()) {
var intlOpts = {
useGrouping: false
};
if (opts.padTo > 0)
intlOpts.minimumIntegerDigits = opts.padTo;
this.inf = getCachedINF(intl, intlOpts);
}
}
var _proto = PolyNumberFormatter2.prototype;
_proto.format = function format(i) {
if (this.inf) {
var fixed = this.floor ? Math.floor(i) : i;
return this.inf.format(fixed);
} else {
var _fixed = this.floor ? Math.floor(i) : roundTo(i, 3);
return padStart2(_fixed, this.padTo);
}
};
return PolyNumberFormatter2;
}();
var PolyDateFormatter = /* @__PURE__ */ function() {
function PolyDateFormatter2(dt, intl, opts) {
this.opts = opts;
this.hasIntl = hasIntl();
var z;
if (dt.zone.universal && this.hasIntl) {
var gmtOffset = -1 * (dt.offset / 60);
var offsetZ = gmtOffset >= 0 ? "Etc/GMT+" + gmtOffset : "Etc/GMT" + gmtOffset;
var isOffsetZoneSupported = IANAZone.isValidZone(offsetZ);
if (dt.offset !== 0 && isOffsetZoneSupported) {
z = offsetZ;
this.dt = dt;
} else {
z = "UTC";
if (opts.timeZoneName) {
this.dt = dt;
} else {
this.dt = dt.offset === 0 ? dt : DateTime5.fromMillis(dt.ts + dt.offset * 60 * 1e3);
}
}
} else if (dt.zone.type === "local") {
this.dt = dt;
} else {
this.dt = dt;
z = dt.zone.name;
}
if (this.hasIntl) {
var intlOpts = Object.assign({}, this.opts);
if (z) {
intlOpts.timeZone = z;
}
this.dtf = getCachedDTF(intl, intlOpts);
}
}
var _proto2 = PolyDateFormatter2.prototype;
_proto2.format = function format() {
if (this.hasIntl) {
return this.dtf.format(this.dt.toJSDate());
} else {
var tokenFormat = formatString(this.opts), loc = Locale.create("en-US");
return Formatter.create(loc).formatDateTimeFromString(this.dt, tokenFormat);
}
};
_proto2.formatToParts = function formatToParts() {
if (this.hasIntl && hasFormatToParts()) {
return this.dtf.formatToParts(this.dt.toJSDate());
} else {
return [];
}
};
_proto2.resolvedOptions = function resolvedOptions() {
if (this.hasIntl) {
return this.dtf.resolvedOptions();
} else {
return {
locale: "en-US",
numberingSystem: "latn",
outputCalendar: "gregory"
};
}
};
return PolyDateFormatter2;
}();
var PolyRelFormatter = /* @__PURE__ */ function() {
function PolyRelFormatter2(intl, isEnglish, opts) {
this.opts = Object.assign({
style: "long"
}, opts);
if (!isEnglish && hasRelative()) {
this.rtf = getCachedRTF(intl, opts);
}
}
var _proto3 = PolyRelFormatter2.prototype;
_proto3.format = function format(count, unit) {
if (this.rtf) {
return this.rtf.format(count, unit);
} else {
return formatRelativeTime(unit, count, this.opts.numeric, this.opts.style !== "long");
}
};
_proto3.formatToParts = function formatToParts(count, unit) {
if (this.rtf) {
return this.rtf.formatToParts(count, unit);
} else {
return [];
}
};
return PolyRelFormatter2;
}();
var Locale = /* @__PURE__ */ function() {
Locale2.fromOpts = function fromOpts(opts) {
return Locale2.create(opts.locale, opts.numberingSystem, opts.outputCalendar, opts.defaultToEN);
};
Locale2.create = function create(locale, numberingSystem, outputCalendar, defaultToEN) {
if (defaultToEN === void 0) {
defaultToEN = false;
}
var specifiedLocale = locale || Settings2.defaultLocale, localeR = specifiedLocale || (defaultToEN ? "en-US" : systemLocale()), numberingSystemR = numberingSystem || Settings2.defaultNumberingSystem, outputCalendarR = outputCalendar || Settings2.defaultOutputCalendar;
return new Locale2(localeR, numberingSystemR, outputCalendarR, specifiedLocale);
};
Locale2.resetCache = function resetCache() {
sysLocaleCache = null;
intlDTCache = {};
intlNumCache = {};
intlRelCache = {};
};
Locale2.fromObject = function fromObject(_temp) {
var _ref = _temp === void 0 ? {} : _temp, locale = _ref.locale, numberingSystem = _ref.numberingSystem, outputCalendar = _ref.outputCalendar;
return Locale2.create(locale, numberingSystem, outputCalendar);
};
function Locale2(locale, numbering, outputCalendar, specifiedLocale) {
var _parseLocaleString = parseLocaleString(locale), parsedLocale = _parseLocaleString[0], parsedNumberingSystem = _parseLocaleString[1], parsedOutputCalendar = _parseLocaleString[2];
this.locale = parsedLocale;
this.numberingSystem = numbering || parsedNumberingSystem || null;
this.outputCalendar = outputCalendar || parsedOutputCalendar || null;
this.intl = intlConfigString(this.locale, this.numberingSystem, this.outputCalendar);
this.weekdaysCache = {
format: {},
standalone: {}
};
this.monthsCache = {
format: {},
standalone: {}
};
this.meridiemCache = null;
this.eraCache = {};
this.specifiedLocale = specifiedLocale;
this.fastNumbersCached = null;
}
var _proto4 = Locale2.prototype;
_proto4.listingMode = function listingMode(defaultOK) {
if (defaultOK === void 0) {
defaultOK = true;
}
var intl = hasIntl(), hasFTP = intl && hasFormatToParts(), isActuallyEn = this.isEnglish(), hasNoWeirdness = (this.numberingSystem === null || this.numberingSystem === "latn") && (this.outputCalendar === null || this.outputCalendar === "gregory");
if (!hasFTP && !(isActuallyEn && hasNoWeirdness) && !defaultOK) {
return "error";
} else if (!hasFTP || isActuallyEn && hasNoWeirdness) {
return "en";
} else {
return "intl";
}
};
_proto4.clone = function clone2(alts) {
if (!alts || Object.getOwnPropertyNames(alts).length === 0) {
return this;
} else {
return Locale2.create(alts.locale || this.specifiedLocale, alts.numberingSystem || this.numberingSystem, alts.outputCalendar || this.outputCalendar, alts.defaultToEN || false);
}
};
_proto4.redefaultToEN = function redefaultToEN(alts) {
if (alts === void 0) {
alts = {};
}
return this.clone(Object.assign({}, alts, {
defaultToEN: true
}));
};
_proto4.redefaultToSystem = function redefaultToSystem(alts) {
if (alts === void 0) {
alts = {};
}
return this.clone(Object.assign({}, alts, {
defaultToEN: false
}));
};
_proto4.months = function months$1(length, format, defaultOK) {
var _this = this;
if (format === void 0) {
format = false;
}
if (defaultOK === void 0) {
defaultOK = true;
}
return listStuff(this, length, defaultOK, months, function() {
var intl = format ? {
month: length,
day: "numeric"
} : {
month: length
}, formatStr = format ? "format" : "standalone";
if (!_this.monthsCache[formatStr][length]) {
_this.monthsCache[formatStr][length] = mapMonths(function(dt) {
return _this.extract(dt, intl, "month");
});
}
return _this.monthsCache[formatStr][length];
});
};
_proto4.weekdays = function weekdays$1(length, format, defaultOK) {
var _this2 = this;
if (format === void 0) {
format = false;
}
if (defaultOK === void 0) {
defaultOK = true;
}
return listStuff(this, length, defaultOK, weekdays, function() {
var intl = format ? {
weekday: length,
year: "numeric",
month: "long",
day: "numeric"
} : {
weekday: length
}, formatStr = format ? "format" : "standalone";
if (!_this2.weekdaysCache[formatStr][length]) {
_this2.weekdaysCache[formatStr][length] = mapWeekdays(function(dt) {
return _this2.extract(dt, intl, "weekday");
});
}
return _this2.weekdaysCache[formatStr][length];
});
};
_proto4.meridiems = function meridiems$1(defaultOK) {
var _this3 = this;
if (defaultOK === void 0) {
defaultOK = true;
}
return listStuff(this, void 0, defaultOK, function() {
return meridiems;
}, function() {
if (!_this3.meridiemCache) {
var intl = {
hour: "numeric",
hour12: true
};
_this3.meridiemCache = [DateTime5.utc(2016, 11, 13, 9), DateTime5.utc(2016, 11, 13, 19)].map(function(dt) {
return _this3.extract(dt, intl, "dayperiod");
});
}
return _this3.meridiemCache;
});
};
_proto4.eras = function eras$1(length, defaultOK) {
var _this4 = this;
if (defaultOK === void 0) {
defaultOK = true;
}
return listStuff(this, length, defaultOK, eras, function() {
var intl = {
era: length
};
if (!_this4.eraCache[length]) {
_this4.eraCache[length] = [DateTime5.utc(-40, 1, 1), DateTime5.utc(2017, 1, 1)].map(function(dt) {
return _this4.extract(dt, intl, "era");
});
}
return _this4.eraCache[length];
});
};
_proto4.extract = function extract(dt, intlOpts, field) {
var df = this.dtFormatter(dt, intlOpts), results = df.formatToParts(), matching = results.find(function(m) {
return m.type.toLowerCase() === field;
});
return matching ? matching.value : null;
};
_proto4.numberFormatter = function numberFormatter(opts) {
if (opts === void 0) {
opts = {};
}
return new PolyNumberFormatter(this.intl, opts.forceSimple || this.fastNumbers, opts);
};
_proto4.dtFormatter = function dtFormatter(dt, intlOpts) {
if (intlOpts === void 0) {
intlOpts = {};
}
return new PolyDateFormatter(dt, this.intl, intlOpts);
};
_proto4.relFormatter = function relFormatter(opts) {
if (opts === void 0) {
opts = {};
}
return new PolyRelFormatter(this.intl, this.isEnglish(), opts);
};
_proto4.isEnglish = function isEnglish() {
return this.locale === "en" || this.locale.toLowerCase() === "en-us" || hasIntl() && new Intl.DateTimeFormat(this.intl).resolvedOptions().locale.startsWith("en-us");
};
_proto4.equals = function equals(other) {
return this.locale === other.locale && this.numberingSystem === other.numberingSystem && this.outputCalendar === other.outputCalendar;
};
_createClass(Locale2, [{
key: "fastNumbers",
get: function get() {
if (this.fastNumbersCached == null) {
this.fastNumbersCached = supportsFastNumbers(this);
}
return this.fastNumbersCached;
}
}]);
return Locale2;
}();
function combineRegexes() {
for (var _len = arguments.length, regexes = new Array(_len), _key = 0; _key < _len; _key++) {
regexes[_key] = arguments[_key];
}
var full = regexes.reduce(function(f, r) {
return f + r.source;
}, "");
return RegExp("^" + full + "$");
}
function combineExtractors() {
for (var _len2 = arguments.length, extractors = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
extractors[_key2] = arguments[_key2];
}
return function(m) {
return extractors.reduce(function(_ref, ex) {
var mergedVals = _ref[0], mergedZone = _ref[1], cursor = _ref[2];
var _ex = ex(m, cursor), val = _ex[0], zone = _ex[1], next = _ex[2];
return [Object.assign(mergedVals, val), mergedZone || zone, next];
}, [{}, null, 1]).slice(0, 2);
};
}
function parse(s2) {
if (s2 == null) {
return [null, null];
}
for (var _len3 = arguments.length, patterns = new Array(_len3 > 1 ? _len3 - 1 : 0), _key3 = 1; _key3 < _len3; _key3++) {
patterns[_key3 - 1] = arguments[_key3];
}
for (var _i = 0, _patterns = patterns; _i < _patterns.length; _i++) {
var _patterns$_i = _patterns[_i], regex = _patterns$_i[0], extractor = _patterns$_i[1];
var m = regex.exec(s2);
if (m) {
return extractor(m);
}
}
return [null, null];
}
function simpleParse() {
for (var _len4 = arguments.length, keys = new Array(_len4), _key4 = 0; _key4 < _len4; _key4++) {
keys[_key4] = arguments[_key4];
}
return function(match2, cursor) {
var ret = {};
var i;
for (i = 0; i < keys.length; i++) {
ret[keys[i]] = parseInteger(match2[cursor + i]);
}
return [ret, null, cursor + i];
};
}
var offsetRegex = /(?:(Z)|([+-]\d\d)(?::?(\d\d))?)/;
var isoTimeBaseRegex = /(\d\d)(?::?(\d\d)(?::?(\d\d)(?:[.,](\d{1,30}))?)?)?/;
var isoTimeRegex = RegExp("" + isoTimeBaseRegex.source + offsetRegex.source + "?");
var isoTimeExtensionRegex = RegExp("(?:T" + isoTimeRegex.source + ")?");
var isoYmdRegex = /([+-]\d{6}|\d{4})(?:-?(\d\d)(?:-?(\d\d))?)?/;
var isoWeekRegex = /(\d{4})-?W(\d\d)(?:-?(\d))?/;
var isoOrdinalRegex = /(\d{4})-?(\d{3})/;
var extractISOWeekData = simpleParse("weekYear", "weekNumber", "weekDay");
var extractISOOrdinalData = simpleParse("year", "ordinal");
var sqlYmdRegex = /(\d{4})-(\d\d)-(\d\d)/;
var sqlTimeRegex = RegExp(isoTimeBaseRegex.source + " ?(?:" + offsetRegex.source + "|(" + ianaRegex.source + "))?");
var sqlTimeExtensionRegex = RegExp("(?: " + sqlTimeRegex.source + ")?");
function int(match2, pos, fallback) {
var m = match2[pos];
return isUndefined(m) ? fallback : parseInteger(m);
}
function extractISOYmd(match2, cursor) {
var item = {
year: int(match2, cursor),
month: int(match2, cursor + 1, 1),
day: int(match2, cursor + 2, 1)
};
return [item, null, cursor + 3];
}
function extractISOTime(match2, cursor) {
var item = {
hours: int(match2, cursor, 0),
minutes: int(match2, cursor + 1, 0),
seconds: int(match2, cursor + 2, 0),
milliseconds: parseMillis(match2[cursor + 3])
};
return [item, null, cursor + 4];
}
function extractISOOffset(match2, cursor) {
var local = !match2[cursor] && !match2[cursor + 1], fullOffset = signedOffset(match2[cursor + 1], match2[cursor + 2]), zone = local ? null : FixedOffsetZone.instance(fullOffset);
return [{}, zone, cursor + 3];
}
function extractIANAZone(match2, cursor) {
var zone = match2[cursor] ? IANAZone.create(match2[cursor]) : null;
return [{}, zone, cursor + 1];
}
var isoTimeOnly = RegExp("^T?" + isoTimeBaseRegex.source + "$");
var isoDuration = /^-?P(?:(?:(-?\d{1,9})Y)?(?:(-?\d{1,9})M)?(?:(-?\d{1,9})W)?(?:(-?\d{1,9})D)?(?:T(?:(-?\d{1,9})H)?(?:(-?\d{1,9})M)?(?:(-?\d{1,20})(?:[.,](-?\d{1,9}))?S)?)?)$/;
function extractISODuration(match2) {
var s2 = match2[0], yearStr = match2[1], monthStr = match2[2], weekStr = match2[3], dayStr = match2[4], hourStr = match2[5], minuteStr = match2[6], secondStr = match2[7], millisecondsStr = match2[8];
var hasNegativePrefix = s2[0] === "-";
var negativeSeconds = secondStr && secondStr[0] === "-";
var maybeNegate = function maybeNegate2(num, force) {
if (force === void 0) {
force = false;
}
return num !== void 0 && (force || num && hasNegativePrefix) ? -num : num;
};
return [{
years: maybeNegate(parseInteger(yearStr)),
months: maybeNegate(parseInteger(monthStr)),
weeks: maybeNegate(parseInteger(weekStr)),
days: maybeNegate(parseInteger(dayStr)),
hours: maybeNegate(parseInteger(hourStr)),
minutes: maybeNegate(parseInteger(minuteStr)),
seconds: maybeNegate(parseInteger(secondStr), secondStr === "-0"),
milliseconds: maybeNegate(parseMillis(millisecondsStr), negativeSeconds)
}];
}
var obsOffsets = {
GMT: 0,
EDT: -4 * 60,
EST: -5 * 60,
CDT: -5 * 60,
CST: -6 * 60,
MDT: -6 * 60,
MST: -7 * 60,
PDT: -7 * 60,
PST: -8 * 60
};
function fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr) {
var result = {
year: yearStr.length === 2 ? untruncateYear(parseInteger(yearStr)) : parseInteger(yearStr),
month: monthsShort.indexOf(monthStr) + 1,
day: parseInteger(dayStr),
hour: parseInteger(hourStr),
minute: parseInteger(minuteStr)
};
if (secondStr)
result.second = parseInteger(secondStr);
if (weekdayStr) {
result.weekday = weekdayStr.length > 3 ? weekdaysLong.indexOf(weekdayStr) + 1 : weekdaysShort.indexOf(weekdayStr) + 1;
}
return result;
}
var rfc2822 = /^(?:(Mon|Tue|Wed|Thu|Fri|Sat|Sun),\s)?(\d{1,2})\s(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\s(\d{2,4})\s(\d\d):(\d\d)(?::(\d\d))?\s(?:(UT|GMT|[ECMP][SD]T)|([Zz])|(?:([+-]\d\d)(\d\d)))$/;
function extractRFC2822(match2) {
var weekdayStr = match2[1], dayStr = match2[2], monthStr = match2[3], yearStr = match2[4], hourStr = match2[5], minuteStr = match2[6], secondStr = match2[7], obsOffset = match2[8], milOffset = match2[9], offHourStr = match2[10], offMinuteStr = match2[11], result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
var offset2;
if (obsOffset) {
offset2 = obsOffsets[obsOffset];
} else if (milOffset) {
offset2 = 0;
} else {
offset2 = signedOffset(offHourStr, offMinuteStr);
}
return [result, new FixedOffsetZone(offset2)];
}
function preprocessRFC2822(s2) {
return s2.replace(/\([^)]*\)|[\n\t]/g, " ").replace(/(\s\s+)/g, " ").trim();
}
var rfc1123 = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun), (\d\d) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) (\d{4}) (\d\d):(\d\d):(\d\d) GMT$/;
var rfc850 = /^(Monday|Tuesday|Wedsday|Thursday|Friday|Saturday|Sunday), (\d\d)-(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)-(\d\d) (\d\d):(\d\d):(\d\d) GMT$/;
var ascii = /^(Mon|Tue|Wed|Thu|Fri|Sat|Sun) (Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec) ( \d|\d\d) (\d\d):(\d\d):(\d\d) (\d{4})$/;
function extractRFC1123Or850(match2) {
var weekdayStr = match2[1], dayStr = match2[2], monthStr = match2[3], yearStr = match2[4], hourStr = match2[5], minuteStr = match2[6], secondStr = match2[7], result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
return [result, FixedOffsetZone.utcInstance];
}
function extractASCII(match2) {
var weekdayStr = match2[1], monthStr = match2[2], dayStr = match2[3], hourStr = match2[4], minuteStr = match2[5], secondStr = match2[6], yearStr = match2[7], result = fromStrings(weekdayStr, yearStr, monthStr, dayStr, hourStr, minuteStr, secondStr);
return [result, FixedOffsetZone.utcInstance];
}
var isoYmdWithTimeExtensionRegex = combineRegexes(isoYmdRegex, isoTimeExtensionRegex);
var isoWeekWithTimeExtensionRegex = combineRegexes(isoWeekRegex, isoTimeExtensionRegex);
var isoOrdinalWithTimeExtensionRegex = combineRegexes(isoOrdinalRegex, isoTimeExtensionRegex);
var isoTimeCombinedRegex = combineRegexes(isoTimeRegex);
var extractISOYmdTimeAndOffset = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset);
var extractISOWeekTimeAndOffset = combineExtractors(extractISOWeekData, extractISOTime, extractISOOffset);
var extractISOOrdinalDateAndTime = combineExtractors(extractISOOrdinalData, extractISOTime, extractISOOffset);
var extractISOTimeAndOffset = combineExtractors(extractISOTime, extractISOOffset);
function parseISODate(s2) {
return parse(s2, [isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset], [isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset], [isoOrdinalWithTimeExtensionRegex, extractISOOrdinalDateAndTime], [isoTimeCombinedRegex, extractISOTimeAndOffset]);
}
function parseRFC2822Date(s2) {
return parse(preprocessRFC2822(s2), [rfc2822, extractRFC2822]);
}
function parseHTTPDate(s2) {
return parse(s2, [rfc1123, extractRFC1123Or850], [rfc850, extractRFC1123Or850], [ascii, extractASCII]);
}
function parseISODuration(s2) {
return parse(s2, [isoDuration, extractISODuration]);
}
var extractISOTimeOnly = combineExtractors(extractISOTime);
function parseISOTimeOnly(s2) {
return parse(s2, [isoTimeOnly, extractISOTimeOnly]);
}
var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
var extractISOYmdTimeOffsetAndIANAZone = combineExtractors(extractISOYmd, extractISOTime, extractISOOffset, extractIANAZone);
var extractISOTimeOffsetAndIANAZone = combineExtractors(extractISOTime, extractISOOffset, extractIANAZone);
function parseSQL(s2) {
return parse(s2, [sqlYmdWithTimeExtensionRegex, extractISOYmdTimeOffsetAndIANAZone], [sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]);
}
var INVALID = "Invalid Duration";
var lowOrderMatrix = {
weeks: {
days: 7,
hours: 7 * 24,
minutes: 7 * 24 * 60,
seconds: 7 * 24 * 60 * 60,
milliseconds: 7 * 24 * 60 * 60 * 1e3
},
days: {
hours: 24,
minutes: 24 * 60,
seconds: 24 * 60 * 60,
milliseconds: 24 * 60 * 60 * 1e3
},
hours: {
minutes: 60,
seconds: 60 * 60,
milliseconds: 60 * 60 * 1e3
},
minutes: {
seconds: 60,
milliseconds: 60 * 1e3
},
seconds: {
milliseconds: 1e3
}
};
var casualMatrix = Object.assign({
years: {
quarters: 4,
months: 12,
weeks: 52,
days: 365,
hours: 365 * 24,
minutes: 365 * 24 * 60,
seconds: 365 * 24 * 60 * 60,
milliseconds: 365 * 24 * 60 * 60 * 1e3
},
quarters: {
months: 3,
weeks: 13,
days: 91,
hours: 91 * 24,
minutes: 91 * 24 * 60,
seconds: 91 * 24 * 60 * 60,
milliseconds: 91 * 24 * 60 * 60 * 1e3
},
months: {
weeks: 4,
days: 30,
hours: 30 * 24,
minutes: 30 * 24 * 60,
seconds: 30 * 24 * 60 * 60,
milliseconds: 30 * 24 * 60 * 60 * 1e3
}
}, lowOrderMatrix);
var daysInYearAccurate = 146097 / 400;
var daysInMonthAccurate = 146097 / 4800;
var accurateMatrix = Object.assign({
years: {
quarters: 4,
months: 12,
weeks: daysInYearAccurate / 7,
days: daysInYearAccurate,
hours: daysInYearAccurate * 24,
minutes: daysInYearAccurate * 24 * 60,
seconds: daysInYearAccurate * 24 * 60 * 60,
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1e3
},
quarters: {
months: 3,
weeks: daysInYearAccurate / 28,
days: daysInYearAccurate / 4,
hours: daysInYearAccurate * 24 / 4,
minutes: daysInYearAccurate * 24 * 60 / 4,
seconds: daysInYearAccurate * 24 * 60 * 60 / 4,
milliseconds: daysInYearAccurate * 24 * 60 * 60 * 1e3 / 4
},
months: {
weeks: daysInMonthAccurate / 7,
days: daysInMonthAccurate,
hours: daysInMonthAccurate * 24,
minutes: daysInMonthAccurate * 24 * 60,
seconds: daysInMonthAccurate * 24 * 60 * 60,
milliseconds: daysInMonthAccurate * 24 * 60 * 60 * 1e3
}
}, lowOrderMatrix);
var orderedUnits = ["years", "quarters", "months", "weeks", "days", "hours", "minutes", "seconds", "milliseconds"];
var reverseUnits = orderedUnits.slice(0).reverse();
function clone(dur, alts, clear) {
if (clear === void 0) {
clear = false;
}
var conf = {
values: clear ? alts.values : Object.assign({}, dur.values, alts.values || {}),
loc: dur.loc.clone(alts.loc),
conversionAccuracy: alts.conversionAccuracy || dur.conversionAccuracy
};
return new Duration(conf);
}
function antiTrunc(n2) {
return n2 < 0 ? Math.floor(n2) : Math.ceil(n2);
}
function convert(matrix, fromMap, fromUnit, toMap, toUnit) {
var conv = matrix[toUnit][fromUnit], raw = fromMap[fromUnit] / conv, sameSign = Math.sign(raw) === Math.sign(toMap[toUnit]), added = !sameSign && toMap[toUnit] !== 0 && Math.abs(raw) <= 1 ? antiTrunc(raw) : Math.trunc(raw);
toMap[toUnit] += added;
fromMap[fromUnit] -= added * conv;
}
function normalizeValues(matrix, vals) {
reverseUnits.reduce(function(previous, current) {
if (!isUndefined(vals[current])) {
if (previous) {
convert(matrix, vals, previous, vals, current);
}
return current;
} else {
return previous;
}
}, null);
}
var Duration = /* @__PURE__ */ function() {
function Duration2(config) {
var accurate = config.conversionAccuracy === "longterm" || false;
this.values = config.values;
this.loc = config.loc || Locale.create();
this.conversionAccuracy = accurate ? "longterm" : "casual";
this.invalid = config.invalid || null;
this.matrix = accurate ? accurateMatrix : casualMatrix;
this.isLuxonDuration = true;
}
Duration2.fromMillis = function fromMillis(count, opts) {
return Duration2.fromObject(Object.assign({
milliseconds: count
}, opts));
};
Duration2.fromObject = function fromObject(obj) {
if (obj == null || typeof obj !== "object") {
throw new InvalidArgumentError("Duration.fromObject: argument expected to be an object, got " + (obj === null ? "null" : typeof obj));
}
return new Duration2({
values: normalizeObject(obj, Duration2.normalizeUnit, [
"locale",
"numberingSystem",
"conversionAccuracy",
"zone"
]),
loc: Locale.fromObject(obj),
conversionAccuracy: obj.conversionAccuracy
});
};
Duration2.fromISO = function fromISO(text2, opts) {
var _parseISODuration = parseISODuration(text2), parsed = _parseISODuration[0];
if (parsed) {
var obj = Object.assign(parsed, opts);
return Duration2.fromObject(obj);
} else {
return Duration2.invalid("unparsable", 'the input "' + text2 + `" can't be parsed as ISO 8601`);
}
};
Duration2.fromISOTime = function fromISOTime(text2, opts) {
var _parseISOTimeOnly = parseISOTimeOnly(text2), parsed = _parseISOTimeOnly[0];
if (parsed) {
var obj = Object.assign(parsed, opts);
return Duration2.fromObject(obj);
} else {
return Duration2.invalid("unparsable", 'the input "' + text2 + `" can't be parsed as ISO 8601`);
}
};
Duration2.invalid = function invalid(reason, explanation) {
if (explanation === void 0) {
explanation = null;
}
if (!reason) {
throw new InvalidArgumentError("need to specify a reason the Duration is invalid");
}
var invalid2 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
if (Settings2.throwOnInvalid) {
throw new InvalidDurationError(invalid2);
} else {
return new Duration2({
invalid: invalid2
});
}
};
Duration2.normalizeUnit = function normalizeUnit2(unit) {
var normalized = {
year: "years",
years: "years",
quarter: "quarters",
quarters: "quarters",
month: "months",
months: "months",
week: "weeks",
weeks: "weeks",
day: "days",
days: "days",
hour: "hours",
hours: "hours",
minute: "minutes",
minutes: "minutes",
second: "seconds",
seconds: "seconds",
millisecond: "milliseconds",
milliseconds: "milliseconds"
}[unit ? unit.toLowerCase() : unit];
if (!normalized)
throw new InvalidUnitError(unit);
return normalized;
};
Duration2.isDuration = function isDuration(o) {
return o && o.isLuxonDuration || false;
};
var _proto = Duration2.prototype;
_proto.toFormat = function toFormat(fmt, opts) {
if (opts === void 0) {
opts = {};
}
var fmtOpts = Object.assign({}, opts, {
floor: opts.round !== false && opts.floor !== false
});
return this.isValid ? Formatter.create(this.loc, fmtOpts).formatDurationFromString(this, fmt) : INVALID;
};
_proto.toObject = function toObject(opts) {
if (opts === void 0) {
opts = {};
}
if (!this.isValid)
return {};
var base = Object.assign({}, this.values);
if (opts.includeConfig) {
base.conversionAccuracy = this.conversionAccuracy;
base.numberingSystem = this.loc.numberingSystem;
base.locale = this.loc.locale;
}
return base;
};
_proto.toISO = function toISO() {
if (!this.isValid)
return null;
var s2 = "P";
if (this.years !== 0)
s2 += this.years + "Y";
if (this.months !== 0 || this.quarters !== 0)
s2 += this.months + this.quarters * 3 + "M";
if (this.weeks !== 0)
s2 += this.weeks + "W";
if (this.days !== 0)
s2 += this.days + "D";
if (this.hours !== 0 || this.minutes !== 0 || this.seconds !== 0 || this.milliseconds !== 0)
s2 += "T";
if (this.hours !== 0)
s2 += this.hours + "H";
if (this.minutes !== 0)
s2 += this.minutes + "M";
if (this.seconds !== 0 || this.milliseconds !== 0)
s2 += roundTo(this.seconds + this.milliseconds / 1e3, 3) + "S";
if (s2 === "P")
s2 += "T0S";
return s2;
};
_proto.toISOTime = function toISOTime(opts) {
if (opts === void 0) {
opts = {};
}
if (!this.isValid)
return null;
var millis = this.toMillis();
if (millis < 0 || millis >= 864e5)
return null;
opts = Object.assign({
suppressMilliseconds: false,
suppressSeconds: false,
includePrefix: false,
format: "extended"
}, opts);
var value = this.shiftTo("hours", "minutes", "seconds", "milliseconds");
var fmt = opts.format === "basic" ? "hhmm" : "hh:mm";
if (!opts.suppressSeconds || value.seconds !== 0 || value.milliseconds !== 0) {
fmt += opts.format === "basic" ? "ss" : ":ss";
if (!opts.suppressMilliseconds || value.milliseconds !== 0) {
fmt += ".SSS";
}
}
var str = value.toFormat(fmt);
if (opts.includePrefix) {
str = "T" + str;
}
return str;
};
_proto.toJSON = function toJSON() {
return this.toISO();
};
_proto.toString = function toString() {
return this.toISO();
};
_proto.toMillis = function toMillis() {
return this.as("milliseconds");
};
_proto.valueOf = function valueOf() {
return this.toMillis();
};
_proto.plus = function plus(duration) {
if (!this.isValid)
return this;
var dur = friendlyDuration(duration), result = {};
for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits), _step; !(_step = _iterator()).done; ) {
var k = _step.value;
if (hasOwnProperty(dur.values, k) || hasOwnProperty(this.values, k)) {
result[k] = dur.get(k) + this.get(k);
}
}
return clone(this, {
values: result
}, true);
};
_proto.minus = function minus(duration) {
if (!this.isValid)
return this;
var dur = friendlyDuration(duration);
return this.plus(dur.negate());
};
_proto.mapUnits = function mapUnits(fn) {
if (!this.isValid)
return this;
var result = {};
for (var _i = 0, _Object$keys = Object.keys(this.values); _i < _Object$keys.length; _i++) {
var k = _Object$keys[_i];
result[k] = asNumber(fn(this.values[k], k));
}
return clone(this, {
values: result
}, true);
};
_proto.get = function get(unit) {
return this[Duration2.normalizeUnit(unit)];
};
_proto.set = function set(values) {
if (!this.isValid)
return this;
var mixed = Object.assign(this.values, normalizeObject(values, Duration2.normalizeUnit, []));
return clone(this, {
values: mixed
});
};
_proto.reconfigure = function reconfigure(_temp) {
var _ref = _temp === void 0 ? {} : _temp, locale = _ref.locale, numberingSystem = _ref.numberingSystem, conversionAccuracy = _ref.conversionAccuracy;
var loc = this.loc.clone({
locale,
numberingSystem
}), opts = {
loc
};
if (conversionAccuracy) {
opts.conversionAccuracy = conversionAccuracy;
}
return clone(this, opts);
};
_proto.as = function as(unit) {
return this.isValid ? this.shiftTo(unit).get(unit) : NaN;
};
_proto.normalize = function normalize() {
if (!this.isValid)
return this;
var vals = this.toObject();
normalizeValues(this.matrix, vals);
return clone(this, {
values: vals
}, true);
};
_proto.shiftTo = function shiftTo() {
for (var _len = arguments.length, units = new Array(_len), _key = 0; _key < _len; _key++) {
units[_key] = arguments[_key];
}
if (!this.isValid)
return this;
if (units.length === 0) {
return this;
}
units = units.map(function(u) {
return Duration2.normalizeUnit(u);
});
var built = {}, accumulated = {}, vals = this.toObject();
var lastUnit;
for (var _iterator2 = _createForOfIteratorHelperLoose(orderedUnits), _step2; !(_step2 = _iterator2()).done; ) {
var k = _step2.value;
if (units.indexOf(k) >= 0) {
lastUnit = k;
var own = 0;
for (var ak in accumulated) {
own += this.matrix[ak][k] * accumulated[ak];
accumulated[ak] = 0;
}
if (isNumber2(vals[k])) {
own += vals[k];
}
var i = Math.trunc(own);
built[k] = i;
accumulated[k] = own - i;
for (var down in vals) {
if (orderedUnits.indexOf(down) > orderedUnits.indexOf(k)) {
convert(this.matrix, vals, down, built, k);
}
}
} else if (isNumber2(vals[k])) {
accumulated[k] = vals[k];
}
}
for (var key in accumulated) {
if (accumulated[key] !== 0) {
built[lastUnit] += key === lastUnit ? accumulated[key] : accumulated[key] / this.matrix[lastUnit][key];
}
}
return clone(this, {
values: built
}, true).normalize();
};
_proto.negate = function negate() {
if (!this.isValid)
return this;
var negated = {};
for (var _i2 = 0, _Object$keys2 = Object.keys(this.values); _i2 < _Object$keys2.length; _i2++) {
var k = _Object$keys2[_i2];
negated[k] = -this.values[k];
}
return clone(this, {
values: negated
}, true);
};
_proto.equals = function equals(other) {
if (!this.isValid || !other.isValid) {
return false;
}
if (!this.loc.equals(other.loc)) {
return false;
}
function eq(v1, v2) {
if (v1 === void 0 || v1 === 0)
return v2 === void 0 || v2 === 0;
return v1 === v2;
}
for (var _iterator3 = _createForOfIteratorHelperLoose(orderedUnits), _step3; !(_step3 = _iterator3()).done; ) {
var u = _step3.value;
if (!eq(this.values[u], other.values[u])) {
return false;
}
}
return true;
};
_createClass(Duration2, [{
key: "locale",
get: function get() {
return this.isValid ? this.loc.locale : null;
}
}, {
key: "numberingSystem",
get: function get() {
return this.isValid ? this.loc.numberingSystem : null;
}
}, {
key: "years",
get: function get() {
return this.isValid ? this.values.years || 0 : NaN;
}
}, {
key: "quarters",
get: function get() {
return this.isValid ? this.values.quarters || 0 : NaN;
}
}, {
key: "months",
get: function get() {
return this.isValid ? this.values.months || 0 : NaN;
}
}, {
key: "weeks",
get: function get() {
return this.isValid ? this.values.weeks || 0 : NaN;
}
}, {
key: "days",
get: function get() {
return this.isValid ? this.values.days || 0 : NaN;
}
}, {
key: "hours",
get: function get() {
return this.isValid ? this.values.hours || 0 : NaN;
}
}, {
key: "minutes",
get: function get() {
return this.isValid ? this.values.minutes || 0 : NaN;
}
}, {
key: "seconds",
get: function get() {
return this.isValid ? this.values.seconds || 0 : NaN;
}
}, {
key: "milliseconds",
get: function get() {
return this.isValid ? this.values.milliseconds || 0 : NaN;
}
}, {
key: "isValid",
get: function get() {
return this.invalid === null;
}
}, {
key: "invalidReason",
get: function get() {
return this.invalid ? this.invalid.reason : null;
}
}, {
key: "invalidExplanation",
get: function get() {
return this.invalid ? this.invalid.explanation : null;
}
}]);
return Duration2;
}();
function friendlyDuration(durationish) {
if (isNumber2(durationish)) {
return Duration.fromMillis(durationish);
} else if (Duration.isDuration(durationish)) {
return durationish;
} else if (typeof durationish === "object") {
return Duration.fromObject(durationish);
} else {
throw new InvalidArgumentError("Unknown duration argument " + durationish + " of type " + typeof durationish);
}
}
var INVALID$1 = "Invalid Interval";
function validateStartEnd(start, end) {
if (!start || !start.isValid) {
return Interval.invalid("missing or invalid start");
} else if (!end || !end.isValid) {
return Interval.invalid("missing or invalid end");
} else if (end < start) {
return Interval.invalid("end before start", "The end of an interval must be after its start, but you had start=" + start.toISO() + " and end=" + end.toISO());
} else {
return null;
}
}
var Interval = /* @__PURE__ */ function() {
function Interval2(config) {
this.s = config.start;
this.e = config.end;
this.invalid = config.invalid || null;
this.isLuxonInterval = true;
}
Interval2.invalid = function invalid(reason, explanation) {
if (explanation === void 0) {
explanation = null;
}
if (!reason) {
throw new InvalidArgumentError("need to specify a reason the Interval is invalid");
}
var invalid2 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
if (Settings2.throwOnInvalid) {
throw new InvalidIntervalError(invalid2);
} else {
return new Interval2({
invalid: invalid2
});
}
};
Interval2.fromDateTimes = function fromDateTimes(start, end) {
var builtStart = friendlyDateTime(start), builtEnd = friendlyDateTime(end);
var validateError = validateStartEnd(builtStart, builtEnd);
if (validateError == null) {
return new Interval2({
start: builtStart,
end: builtEnd
});
} else {
return validateError;
}
};
Interval2.after = function after(start, duration) {
var dur = friendlyDuration(duration), dt = friendlyDateTime(start);
return Interval2.fromDateTimes(dt, dt.plus(dur));
};
Interval2.before = function before(end, duration) {
var dur = friendlyDuration(duration), dt = friendlyDateTime(end);
return Interval2.fromDateTimes(dt.minus(dur), dt);
};
Interval2.fromISO = function fromISO(text2, opts) {
var _split = (text2 || "").split("/", 2), s2 = _split[0], e = _split[1];
if (s2 && e) {
var start, startIsValid;
try {
start = DateTime5.fromISO(s2, opts);
startIsValid = start.isValid;
} catch (e2) {
startIsValid = false;
}
var end, endIsValid;
try {
end = DateTime5.fromISO(e, opts);
endIsValid = end.isValid;
} catch (e2) {
endIsValid = false;
}
if (startIsValid && endIsValid) {
return Interval2.fromDateTimes(start, end);
}
if (startIsValid) {
var dur = Duration.fromISO(e, opts);
if (dur.isValid) {
return Interval2.after(start, dur);
}
} else if (endIsValid) {
var _dur = Duration.fromISO(s2, opts);
if (_dur.isValid) {
return Interval2.before(end, _dur);
}
}
}
return Interval2.invalid("unparsable", 'the input "' + text2 + `" can't be parsed as ISO 8601`);
};
Interval2.isInterval = function isInterval(o) {
return o && o.isLuxonInterval || false;
};
var _proto = Interval2.prototype;
_proto.length = function length(unit) {
if (unit === void 0) {
unit = "milliseconds";
}
return this.isValid ? this.toDuration.apply(this, [unit]).get(unit) : NaN;
};
_proto.count = function count(unit) {
if (unit === void 0) {
unit = "milliseconds";
}
if (!this.isValid)
return NaN;
var start = this.start.startOf(unit), end = this.end.startOf(unit);
return Math.floor(end.diff(start, unit).get(unit)) + 1;
};
_proto.hasSame = function hasSame(unit) {
return this.isValid ? this.isEmpty() || this.e.minus(1).hasSame(this.s, unit) : false;
};
_proto.isEmpty = function isEmpty() {
return this.s.valueOf() === this.e.valueOf();
};
_proto.isAfter = function isAfter(dateTime) {
if (!this.isValid)
return false;
return this.s > dateTime;
};
_proto.isBefore = function isBefore(dateTime) {
if (!this.isValid)
return false;
return this.e <= dateTime;
};
_proto.contains = function contains2(dateTime) {
if (!this.isValid)
return false;
return this.s <= dateTime && this.e > dateTime;
};
_proto.set = function set(_temp) {
var _ref = _temp === void 0 ? {} : _temp, start = _ref.start, end = _ref.end;
if (!this.isValid)
return this;
return Interval2.fromDateTimes(start || this.s, end || this.e);
};
_proto.splitAt = function splitAt() {
var _this = this;
if (!this.isValid)
return [];
for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
dateTimes[_key] = arguments[_key];
}
var sorted = dateTimes.map(friendlyDateTime).filter(function(d) {
return _this.contains(d);
}).sort(), results = [];
var s2 = this.s, i = 0;
while (s2 < this.e) {
var added = sorted[i] || this.e, next = +added > +this.e ? this.e : added;
results.push(Interval2.fromDateTimes(s2, next));
s2 = next;
i += 1;
}
return results;
};
_proto.splitBy = function splitBy(duration) {
var dur = friendlyDuration(duration);
if (!this.isValid || !dur.isValid || dur.as("milliseconds") === 0) {
return [];
}
var s2 = this.s, idx = 1, next;
var results = [];
while (s2 < this.e) {
var added = this.start.plus(dur.mapUnits(function(x) {
return x * idx;
}));
next = +added > +this.e ? this.e : added;
results.push(Interval2.fromDateTimes(s2, next));
s2 = next;
idx += 1;
}
return results;
};
_proto.divideEqually = function divideEqually(numberOfParts) {
if (!this.isValid)
return [];
return this.splitBy(this.length() / numberOfParts).slice(0, numberOfParts);
};
_proto.overlaps = function overlaps(other) {
return this.e > other.s && this.s < other.e;
};
_proto.abutsStart = function abutsStart(other) {
if (!this.isValid)
return false;
return +this.e === +other.s;
};
_proto.abutsEnd = function abutsEnd(other) {
if (!this.isValid)
return false;
return +other.e === +this.s;
};
_proto.engulfs = function engulfs(other) {
if (!this.isValid)
return false;
return this.s <= other.s && this.e >= other.e;
};
_proto.equals = function equals(other) {
if (!this.isValid || !other.isValid) {
return false;
}
return this.s.equals(other.s) && this.e.equals(other.e);
};
_proto.intersection = function intersection(other) {
if (!this.isValid)
return this;
var s2 = this.s > other.s ? this.s : other.s, e = this.e < other.e ? this.e : other.e;
if (s2 >= e) {
return null;
} else {
return Interval2.fromDateTimes(s2, e);
}
};
_proto.union = function union(other) {
if (!this.isValid)
return this;
var s2 = this.s < other.s ? this.s : other.s, e = this.e > other.e ? this.e : other.e;
return Interval2.fromDateTimes(s2, e);
};
Interval2.merge = function merge(intervals) {
var _intervals$sort$reduc = intervals.sort(function(a, b) {
return a.s - b.s;
}).reduce(function(_ref2, item) {
var sofar = _ref2[0], current = _ref2[1];
if (!current) {
return [sofar, item];
} else if (current.overlaps(item) || current.abutsStart(item)) {
return [sofar, current.union(item)];
} else {
return [sofar.concat([current]), item];
}
}, [[], null]), found = _intervals$sort$reduc[0], final = _intervals$sort$reduc[1];
if (final) {
found.push(final);
}
return found;
};
Interval2.xor = function xor(intervals) {
var _Array$prototype;
var start = null, currentCount = 0;
var results = [], ends = intervals.map(function(i2) {
return [{
time: i2.s,
type: "s"
}, {
time: i2.e,
type: "e"
}];
}), flattened = (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, ends), arr = flattened.sort(function(a, b) {
return a.time - b.time;
});
for (var _iterator = _createForOfIteratorHelperLoose(arr), _step; !(_step = _iterator()).done; ) {
var i = _step.value;
currentCount += i.type === "s" ? 1 : -1;
if (currentCount === 1) {
start = i.time;
} else {
if (start && +start !== +i.time) {
results.push(Interval2.fromDateTimes(start, i.time));
}
start = null;
}
}
return Interval2.merge(results);
};
_proto.difference = function difference() {
var _this2 = this;
for (var _len2 = arguments.length, intervals = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
intervals[_key2] = arguments[_key2];
}
return Interval2.xor([this].concat(intervals)).map(function(i) {
return _this2.intersection(i);
}).filter(function(i) {
return i && !i.isEmpty();
});
};
_proto.toString = function toString() {
if (!this.isValid)
return INVALID$1;
return "[" + this.s.toISO() + " \u2013 " + this.e.toISO() + ")";
};
_proto.toISO = function toISO(opts) {
if (!this.isValid)
return INVALID$1;
return this.s.toISO(opts) + "/" + this.e.toISO(opts);
};
_proto.toISODate = function toISODate() {
if (!this.isValid)
return INVALID$1;
return this.s.toISODate() + "/" + this.e.toISODate();
};
_proto.toISOTime = function toISOTime(opts) {
if (!this.isValid)
return INVALID$1;
return this.s.toISOTime(opts) + "/" + this.e.toISOTime(opts);
};
_proto.toFormat = function toFormat(dateFormat, _temp2) {
var _ref3 = _temp2 === void 0 ? {} : _temp2, _ref3$separator = _ref3.separator, separator = _ref3$separator === void 0 ? " \u2013 " : _ref3$separator;
if (!this.isValid)
return INVALID$1;
return "" + this.s.toFormat(dateFormat) + separator + this.e.toFormat(dateFormat);
};
_proto.toDuration = function toDuration(unit, opts) {
if (!this.isValid) {
return Duration.invalid(this.invalidReason);
}
return this.e.diff(this.s, unit, opts);
};
_proto.mapEndpoints = function mapEndpoints(mapFn) {
return Interval2.fromDateTimes(mapFn(this.s), mapFn(this.e));
};
_createClass(Interval2, [{
key: "start",
get: function get() {
return this.isValid ? this.s : null;
}
}, {
key: "end",
get: function get() {
return this.isValid ? this.e : null;
}
}, {
key: "isValid",
get: function get() {
return this.invalidReason === null;
}
}, {
key: "invalidReason",
get: function get() {
return this.invalid ? this.invalid.reason : null;
}
}, {
key: "invalidExplanation",
get: function get() {
return this.invalid ? this.invalid.explanation : null;
}
}]);
return Interval2;
}();
var Info = /* @__PURE__ */ function() {
function Info2() {
}
Info2.hasDST = function hasDST(zone) {
if (zone === void 0) {
zone = Settings2.defaultZone;
}
var proto = DateTime5.now().setZone(zone).set({
month: 12
});
return !zone.universal && proto.offset !== proto.set({
month: 6
}).offset;
};
Info2.isValidIANAZone = function isValidIANAZone(zone) {
return IANAZone.isValidSpecifier(zone) && IANAZone.isValidZone(zone);
};
Info2.normalizeZone = function normalizeZone$1(input) {
return normalizeZone(input, Settings2.defaultZone);
};
Info2.months = function months2(length, _temp) {
if (length === void 0) {
length = "long";
}
var _ref = _temp === void 0 ? {} : _temp, _ref$locale = _ref.locale, locale = _ref$locale === void 0 ? null : _ref$locale, _ref$numberingSystem = _ref.numberingSystem, numberingSystem = _ref$numberingSystem === void 0 ? null : _ref$numberingSystem, _ref$locObj = _ref.locObj, locObj = _ref$locObj === void 0 ? null : _ref$locObj, _ref$outputCalendar = _ref.outputCalendar, outputCalendar = _ref$outputCalendar === void 0 ? "gregory" : _ref$outputCalendar;
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length);
};
Info2.monthsFormat = function monthsFormat(length, _temp2) {
if (length === void 0) {
length = "long";
}
var _ref2 = _temp2 === void 0 ? {} : _temp2, _ref2$locale = _ref2.locale, locale = _ref2$locale === void 0 ? null : _ref2$locale, _ref2$numberingSystem = _ref2.numberingSystem, numberingSystem = _ref2$numberingSystem === void 0 ? null : _ref2$numberingSystem, _ref2$locObj = _ref2.locObj, locObj = _ref2$locObj === void 0 ? null : _ref2$locObj, _ref2$outputCalendar = _ref2.outputCalendar, outputCalendar = _ref2$outputCalendar === void 0 ? "gregory" : _ref2$outputCalendar;
return (locObj || Locale.create(locale, numberingSystem, outputCalendar)).months(length, true);
};
Info2.weekdays = function weekdays2(length, _temp3) {
if (length === void 0) {
length = "long";
}
var _ref3 = _temp3 === void 0 ? {} : _temp3, _ref3$locale = _ref3.locale, locale = _ref3$locale === void 0 ? null : _ref3$locale, _ref3$numberingSystem = _ref3.numberingSystem, numberingSystem = _ref3$numberingSystem === void 0 ? null : _ref3$numberingSystem, _ref3$locObj = _ref3.locObj, locObj = _ref3$locObj === void 0 ? null : _ref3$locObj;
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length);
};
Info2.weekdaysFormat = function weekdaysFormat(length, _temp4) {
if (length === void 0) {
length = "long";
}
var _ref4 = _temp4 === void 0 ? {} : _temp4, _ref4$locale = _ref4.locale, locale = _ref4$locale === void 0 ? null : _ref4$locale, _ref4$numberingSystem = _ref4.numberingSystem, numberingSystem = _ref4$numberingSystem === void 0 ? null : _ref4$numberingSystem, _ref4$locObj = _ref4.locObj, locObj = _ref4$locObj === void 0 ? null : _ref4$locObj;
return (locObj || Locale.create(locale, numberingSystem, null)).weekdays(length, true);
};
Info2.meridiems = function meridiems2(_temp5) {
var _ref5 = _temp5 === void 0 ? {} : _temp5, _ref5$locale = _ref5.locale, locale = _ref5$locale === void 0 ? null : _ref5$locale;
return Locale.create(locale).meridiems();
};
Info2.eras = function eras2(length, _temp6) {
if (length === void 0) {
length = "short";
}
var _ref6 = _temp6 === void 0 ? {} : _temp6, _ref6$locale = _ref6.locale, locale = _ref6$locale === void 0 ? null : _ref6$locale;
return Locale.create(locale, null, "gregory").eras(length);
};
Info2.features = function features() {
var intl = false, intlTokens = false, zones = false, relative = false;
if (hasIntl()) {
intl = true;
intlTokens = hasFormatToParts();
relative = hasRelative();
try {
zones = new Intl.DateTimeFormat("en", {
timeZone: "America/New_York"
}).resolvedOptions().timeZone === "America/New_York";
} catch (e) {
zones = false;
}
}
return {
intl,
intlTokens,
zones,
relative
};
};
return Info2;
}();
function dayDiff(earlier, later) {
var utcDayStart = function utcDayStart2(dt) {
return dt.toUTC(0, {
keepLocalTime: true
}).startOf("day").valueOf();
}, ms = utcDayStart(later) - utcDayStart(earlier);
return Math.floor(Duration.fromMillis(ms).as("days"));
}
function highOrderDiffs(cursor, later, units) {
var differs = [["years", function(a, b) {
return b.year - a.year;
}], ["quarters", function(a, b) {
return b.quarter - a.quarter;
}], ["months", function(a, b) {
return b.month - a.month + (b.year - a.year) * 12;
}], ["weeks", function(a, b) {
var days = dayDiff(a, b);
return (days - days % 7) / 7;
}], ["days", dayDiff]];
var results = {};
var lowestOrder, highWater;
for (var _i = 0, _differs = differs; _i < _differs.length; _i++) {
var _differs$_i = _differs[_i], unit = _differs$_i[0], differ = _differs$_i[1];
if (units.indexOf(unit) >= 0) {
var _cursor$plus;
lowestOrder = unit;
var delta = differ(cursor, later);
highWater = cursor.plus((_cursor$plus = {}, _cursor$plus[unit] = delta, _cursor$plus));
if (highWater > later) {
var _cursor$plus2;
cursor = cursor.plus((_cursor$plus2 = {}, _cursor$plus2[unit] = delta - 1, _cursor$plus2));
delta -= 1;
} else {
cursor = highWater;
}
results[unit] = delta;
}
}
return [cursor, results, highWater, lowestOrder];
}
function _diff(earlier, later, units, opts) {
var _highOrderDiffs = highOrderDiffs(earlier, later, units), cursor = _highOrderDiffs[0], results = _highOrderDiffs[1], highWater = _highOrderDiffs[2], lowestOrder = _highOrderDiffs[3];
var remainingMillis = later - cursor;
var lowerOrderUnits = units.filter(function(u) {
return ["hours", "minutes", "seconds", "milliseconds"].indexOf(u) >= 0;
});
if (lowerOrderUnits.length === 0) {
if (highWater < later) {
var _cursor$plus3;
highWater = cursor.plus((_cursor$plus3 = {}, _cursor$plus3[lowestOrder] = 1, _cursor$plus3));
}
if (highWater !== cursor) {
results[lowestOrder] = (results[lowestOrder] || 0) + remainingMillis / (highWater - cursor);
}
}
var duration = Duration.fromObject(Object.assign(results, opts));
if (lowerOrderUnits.length > 0) {
var _Duration$fromMillis;
return (_Duration$fromMillis = Duration.fromMillis(remainingMillis, opts)).shiftTo.apply(_Duration$fromMillis, lowerOrderUnits).plus(duration);
} else {
return duration;
}
}
var numberingSystems = {
arab: "[\u0660-\u0669]",
arabext: "[\u06F0-\u06F9]",
bali: "[\u1B50-\u1B59]",
beng: "[\u09E6-\u09EF]",
deva: "[\u0966-\u096F]",
fullwide: "[\uFF10-\uFF19]",
gujr: "[\u0AE6-\u0AEF]",
hanidec: "[\u3007|\u4E00|\u4E8C|\u4E09|\u56DB|\u4E94|\u516D|\u4E03|\u516B|\u4E5D]",
khmr: "[\u17E0-\u17E9]",
knda: "[\u0CE6-\u0CEF]",
laoo: "[\u0ED0-\u0ED9]",
limb: "[\u1946-\u194F]",
mlym: "[\u0D66-\u0D6F]",
mong: "[\u1810-\u1819]",
mymr: "[\u1040-\u1049]",
orya: "[\u0B66-\u0B6F]",
tamldec: "[\u0BE6-\u0BEF]",
telu: "[\u0C66-\u0C6F]",
thai: "[\u0E50-\u0E59]",
tibt: "[\u0F20-\u0F29]",
latn: "\\d"
};
var numberingSystemsUTF16 = {
arab: [1632, 1641],
arabext: [1776, 1785],
bali: [6992, 7001],
beng: [2534, 2543],
deva: [2406, 2415],
fullwide: [65296, 65303],
gujr: [2790, 2799],
khmr: [6112, 6121],
knda: [3302, 3311],
laoo: [3792, 3801],
limb: [6470, 6479],
mlym: [3430, 3439],
mong: [6160, 6169],
mymr: [4160, 4169],
orya: [2918, 2927],
tamldec: [3046, 3055],
telu: [3174, 3183],
thai: [3664, 3673],
tibt: [3872, 3881]
};
var hanidecChars = numberingSystems.hanidec.replace(/[\[|\]]/g, "").split("");
function parseDigits(str) {
var value = parseInt(str, 10);
if (isNaN(value)) {
value = "";
for (var i = 0; i < str.length; i++) {
var code = str.charCodeAt(i);
if (str[i].search(numberingSystems.hanidec) !== -1) {
value += hanidecChars.indexOf(str[i]);
} else {
for (var key in numberingSystemsUTF16) {
var _numberingSystemsUTF = numberingSystemsUTF16[key], min = _numberingSystemsUTF[0], max = _numberingSystemsUTF[1];
if (code >= min && code <= max) {
value += code - min;
}
}
}
}
return parseInt(value, 10);
} else {
return value;
}
}
function digitRegex(_ref, append2) {
var numberingSystem = _ref.numberingSystem;
if (append2 === void 0) {
append2 = "";
}
return new RegExp("" + numberingSystems[numberingSystem || "latn"] + append2);
}
var MISSING_FTP = "missing Intl.DateTimeFormat.formatToParts support";
function intUnit(regex, post) {
if (post === void 0) {
post = function post2(i) {
return i;
};
}
return {
regex,
deser: function deser(_ref) {
var s2 = _ref[0];
return post(parseDigits(s2));
}
};
}
var NBSP = String.fromCharCode(160);
var spaceOrNBSP = "( |" + NBSP + ")";
var spaceOrNBSPRegExp = new RegExp(spaceOrNBSP, "g");
function fixListRegex(s2) {
return s2.replace(/\./g, "\\.?").replace(spaceOrNBSPRegExp, spaceOrNBSP);
}
function stripInsensitivities(s2) {
return s2.replace(/\./g, "").replace(spaceOrNBSPRegExp, " ").toLowerCase();
}
function oneOf(strings, startIndex) {
if (strings === null) {
return null;
} else {
return {
regex: RegExp(strings.map(fixListRegex).join("|")),
deser: function deser(_ref2) {
var s2 = _ref2[0];
return strings.findIndex(function(i) {
return stripInsensitivities(s2) === stripInsensitivities(i);
}) + startIndex;
}
};
}
}
function offset(regex, groups) {
return {
regex,
deser: function deser(_ref3) {
var h = _ref3[1], m = _ref3[2];
return signedOffset(h, m);
},
groups
};
}
function simple(regex) {
return {
regex,
deser: function deser(_ref4) {
var s2 = _ref4[0];
return s2;
}
};
}
function escapeToken(value) {
return value.replace(/[\-\[\]{}()*+?.,\\\^$|#\s]/g, "\\$&");
}
function unitForToken(token, loc) {
var one = digitRegex(loc), two = digitRegex(loc, "{2}"), three = digitRegex(loc, "{3}"), four = digitRegex(loc, "{4}"), six = digitRegex(loc, "{6}"), oneOrTwo = digitRegex(loc, "{1,2}"), oneToThree = digitRegex(loc, "{1,3}"), oneToSix = digitRegex(loc, "{1,6}"), oneToNine = digitRegex(loc, "{1,9}"), twoToFour = digitRegex(loc, "{2,4}"), fourToSix = digitRegex(loc, "{4,6}"), literal = function literal2(t) {
return {
regex: RegExp(escapeToken(t.val)),
deser: function deser(_ref5) {
var s2 = _ref5[0];
return s2;
},
literal: true
};
}, unitate = function unitate2(t) {
if (token.literal) {
return literal(t);
}
switch (t.val) {
case "G":
return oneOf(loc.eras("short", false), 0);
case "GG":
return oneOf(loc.eras("long", false), 0);
case "y":
return intUnit(oneToSix);
case "yy":
return intUnit(twoToFour, untruncateYear);
case "yyyy":
return intUnit(four);
case "yyyyy":
return intUnit(fourToSix);
case "yyyyyy":
return intUnit(six);
case "M":
return intUnit(oneOrTwo);
case "MM":
return intUnit(two);
case "MMM":
return oneOf(loc.months("short", true, false), 1);
case "MMMM":
return oneOf(loc.months("long", true, false), 1);
case "L":
return intUnit(oneOrTwo);
case "LL":
return intUnit(two);
case "LLL":
return oneOf(loc.months("short", false, false), 1);
case "LLLL":
return oneOf(loc.months("long", false, false), 1);
case "d":
return intUnit(oneOrTwo);
case "dd":
return intUnit(two);
case "o":
return intUnit(oneToThree);
case "ooo":
return intUnit(three);
case "HH":
return intUnit(two);
case "H":
return intUnit(oneOrTwo);
case "hh":
return intUnit(two);
case "h":
return intUnit(oneOrTwo);
case "mm":
return intUnit(two);
case "m":
return intUnit(oneOrTwo);
case "q":
return intUnit(oneOrTwo);
case "qq":
return intUnit(two);
case "s":
return intUnit(oneOrTwo);
case "ss":
return intUnit(two);
case "S":
return intUnit(oneToThree);
case "SSS":
return intUnit(three);
case "u":
return simple(oneToNine);
case "a":
return oneOf(loc.meridiems(), 0);
case "kkkk":
return intUnit(four);
case "kk":
return intUnit(twoToFour, untruncateYear);
case "W":
return intUnit(oneOrTwo);
case "WW":
return intUnit(two);
case "E":
case "c":
return intUnit(one);
case "EEE":
return oneOf(loc.weekdays("short", false, false), 1);
case "EEEE":
return oneOf(loc.weekdays("long", false, false), 1);
case "ccc":
return oneOf(loc.weekdays("short", true, false), 1);
case "cccc":
return oneOf(loc.weekdays("long", true, false), 1);
case "Z":
case "ZZ":
return offset(new RegExp("([+-]" + oneOrTwo.source + ")(?::(" + two.source + "))?"), 2);
case "ZZZ":
return offset(new RegExp("([+-]" + oneOrTwo.source + ")(" + two.source + ")?"), 2);
case "z":
return simple(/[a-z_+-/]{1,256}?/i);
default:
return literal(t);
}
};
var unit = unitate(token) || {
invalidReason: MISSING_FTP
};
unit.token = token;
return unit;
}
var partTypeStyleToTokenVal = {
year: {
"2-digit": "yy",
numeric: "yyyyy"
},
month: {
numeric: "M",
"2-digit": "MM",
short: "MMM",
long: "MMMM"
},
day: {
numeric: "d",
"2-digit": "dd"
},
weekday: {
short: "EEE",
long: "EEEE"
},
dayperiod: "a",
dayPeriod: "a",
hour: {
numeric: "h",
"2-digit": "hh"
},
minute: {
numeric: "m",
"2-digit": "mm"
},
second: {
numeric: "s",
"2-digit": "ss"
}
};
function tokenForPart(part, locale, formatOpts) {
var type = part.type, value = part.value;
if (type === "literal") {
return {
literal: true,
val: value
};
}
var style = formatOpts[type];
var val = partTypeStyleToTokenVal[type];
if (typeof val === "object") {
val = val[style];
}
if (val) {
return {
literal: false,
val
};
}
return void 0;
}
function buildRegex(units) {
var re = units.map(function(u) {
return u.regex;
}).reduce(function(f, r) {
return f + "(" + r.source + ")";
}, "");
return ["^" + re + "$", units];
}
function match(input, regex, handlers) {
var matches = input.match(regex);
if (matches) {
var all = {};
var matchIndex = 1;
for (var i in handlers) {
if (hasOwnProperty(handlers, i)) {
var h = handlers[i], groups = h.groups ? h.groups + 1 : 1;
if (!h.literal && h.token) {
all[h.token.val[0]] = h.deser(matches.slice(matchIndex, matchIndex + groups));
}
matchIndex += groups;
}
}
return [matches, all];
} else {
return [matches, {}];
}
}
function dateTimeFromMatches(matches) {
var toField = function toField2(token) {
switch (token) {
case "S":
return "millisecond";
case "s":
return "second";
case "m":
return "minute";
case "h":
case "H":
return "hour";
case "d":
return "day";
case "o":
return "ordinal";
case "L":
case "M":
return "month";
case "y":
return "year";
case "E":
case "c":
return "weekday";
case "W":
return "weekNumber";
case "k":
return "weekYear";
case "q":
return "quarter";
default:
return null;
}
};
var zone;
if (!isUndefined(matches.Z)) {
zone = new FixedOffsetZone(matches.Z);
} else if (!isUndefined(matches.z)) {
zone = IANAZone.create(matches.z);
} else {
zone = null;
}
if (!isUndefined(matches.q)) {
matches.M = (matches.q - 1) * 3 + 1;
}
if (!isUndefined(matches.h)) {
if (matches.h < 12 && matches.a === 1) {
matches.h += 12;
} else if (matches.h === 12 && matches.a === 0) {
matches.h = 0;
}
}
if (matches.G === 0 && matches.y) {
matches.y = -matches.y;
}
if (!isUndefined(matches.u)) {
matches.S = parseMillis(matches.u);
}
var vals = Object.keys(matches).reduce(function(r, k) {
var f = toField(k);
if (f) {
r[f] = matches[k];
}
return r;
}, {});
return [vals, zone];
}
var dummyDateTimeCache = null;
function getDummyDateTime() {
if (!dummyDateTimeCache) {
dummyDateTimeCache = DateTime5.fromMillis(1555555555555);
}
return dummyDateTimeCache;
}
function maybeExpandMacroToken(token, locale) {
if (token.literal) {
return token;
}
var formatOpts = Formatter.macroTokenToFormatOpts(token.val);
if (!formatOpts) {
return token;
}
var formatter = Formatter.create(locale, formatOpts);
var parts = formatter.formatDateTimeParts(getDummyDateTime());
var tokens = parts.map(function(p) {
return tokenForPart(p, locale, formatOpts);
});
if (tokens.includes(void 0)) {
return token;
}
return tokens;
}
function expandMacroTokens(tokens, locale) {
var _Array$prototype;
return (_Array$prototype = Array.prototype).concat.apply(_Array$prototype, tokens.map(function(t) {
return maybeExpandMacroToken(t, locale);
}));
}
function explainFromTokens(locale, input, format) {
var tokens = expandMacroTokens(Formatter.parseFormat(format), locale), units = tokens.map(function(t) {
return unitForToken(t, locale);
}), disqualifyingUnit = units.find(function(t) {
return t.invalidReason;
});
if (disqualifyingUnit) {
return {
input,
tokens,
invalidReason: disqualifyingUnit.invalidReason
};
} else {
var _buildRegex = buildRegex(units), regexString = _buildRegex[0], handlers = _buildRegex[1], regex = RegExp(regexString, "i"), _match = match(input, regex, handlers), rawMatches = _match[0], matches = _match[1], _ref6 = matches ? dateTimeFromMatches(matches) : [null, null], result = _ref6[0], zone = _ref6[1];
if (hasOwnProperty(matches, "a") && hasOwnProperty(matches, "H")) {
throw new ConflictingSpecificationError("Can't include meridiem when specifying 24-hour format");
}
return {
input,
tokens,
regex,
rawMatches,
matches,
result,
zone
};
}
}
function parseFromTokens(locale, input, format) {
var _explainFromTokens = explainFromTokens(locale, input, format), result = _explainFromTokens.result, zone = _explainFromTokens.zone, invalidReason = _explainFromTokens.invalidReason;
return [result, zone, invalidReason];
}
var nonLeapLadder = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334];
var leapLadder = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335];
function unitOutOfRange(unit, value) {
return new Invalid("unit out of range", "you specified " + value + " (of type " + typeof value + ") as a " + unit + ", which is invalid");
}
function dayOfWeek(year, month, day) {
var js = new Date(Date.UTC(year, month - 1, day)).getUTCDay();
return js === 0 ? 7 : js;
}
function computeOrdinal(year, month, day) {
return day + (isLeapYear(year) ? leapLadder : nonLeapLadder)[month - 1];
}
function uncomputeOrdinal(year, ordinal) {
var table = isLeapYear(year) ? leapLadder : nonLeapLadder, month0 = table.findIndex(function(i) {
return i < ordinal;
}), day = ordinal - table[month0];
return {
month: month0 + 1,
day
};
}
function gregorianToWeek(gregObj) {
var year = gregObj.year, month = gregObj.month, day = gregObj.day, ordinal = computeOrdinal(year, month, day), weekday = dayOfWeek(year, month, day);
var weekNumber = Math.floor((ordinal - weekday + 10) / 7), weekYear;
if (weekNumber < 1) {
weekYear = year - 1;
weekNumber = weeksInWeekYear(weekYear);
} else if (weekNumber > weeksInWeekYear(year)) {
weekYear = year + 1;
weekNumber = 1;
} else {
weekYear = year;
}
return Object.assign({
weekYear,
weekNumber,
weekday
}, timeObject(gregObj));
}
function weekToGregorian(weekData) {
var weekYear = weekData.weekYear, weekNumber = weekData.weekNumber, weekday = weekData.weekday, weekdayOfJan4 = dayOfWeek(weekYear, 1, 4), yearInDays = daysInYear(weekYear);
var ordinal = weekNumber * 7 + weekday - weekdayOfJan4 - 3, year;
if (ordinal < 1) {
year = weekYear - 1;
ordinal += daysInYear(year);
} else if (ordinal > yearInDays) {
year = weekYear + 1;
ordinal -= daysInYear(weekYear);
} else {
year = weekYear;
}
var _uncomputeOrdinal = uncomputeOrdinal(year, ordinal), month = _uncomputeOrdinal.month, day = _uncomputeOrdinal.day;
return Object.assign({
year,
month,
day
}, timeObject(weekData));
}
function gregorianToOrdinal(gregData) {
var year = gregData.year, month = gregData.month, day = gregData.day, ordinal = computeOrdinal(year, month, day);
return Object.assign({
year,
ordinal
}, timeObject(gregData));
}
function ordinalToGregorian(ordinalData) {
var year = ordinalData.year, ordinal = ordinalData.ordinal, _uncomputeOrdinal2 = uncomputeOrdinal(year, ordinal), month = _uncomputeOrdinal2.month, day = _uncomputeOrdinal2.day;
return Object.assign({
year,
month,
day
}, timeObject(ordinalData));
}
function hasInvalidWeekData(obj) {
var validYear = isInteger(obj.weekYear), validWeek = integerBetween(obj.weekNumber, 1, weeksInWeekYear(obj.weekYear)), validWeekday = integerBetween(obj.weekday, 1, 7);
if (!validYear) {
return unitOutOfRange("weekYear", obj.weekYear);
} else if (!validWeek) {
return unitOutOfRange("week", obj.week);
} else if (!validWeekday) {
return unitOutOfRange("weekday", obj.weekday);
} else
return false;
}
function hasInvalidOrdinalData(obj) {
var validYear = isInteger(obj.year), validOrdinal = integerBetween(obj.ordinal, 1, daysInYear(obj.year));
if (!validYear) {
return unitOutOfRange("year", obj.year);
} else if (!validOrdinal) {
return unitOutOfRange("ordinal", obj.ordinal);
} else
return false;
}
function hasInvalidGregorianData(obj) {
var validYear = isInteger(obj.year), validMonth = integerBetween(obj.month, 1, 12), validDay = integerBetween(obj.day, 1, daysInMonth(obj.year, obj.month));
if (!validYear) {
return unitOutOfRange("year", obj.year);
} else if (!validMonth) {
return unitOutOfRange("month", obj.month);
} else if (!validDay) {
return unitOutOfRange("day", obj.day);
} else
return false;
}
function hasInvalidTimeData(obj) {
var hour = obj.hour, minute = obj.minute, second = obj.second, millisecond = obj.millisecond;
var validHour = integerBetween(hour, 0, 23) || hour === 24 && minute === 0 && second === 0 && millisecond === 0, validMinute = integerBetween(minute, 0, 59), validSecond = integerBetween(second, 0, 59), validMillisecond = integerBetween(millisecond, 0, 999);
if (!validHour) {
return unitOutOfRange("hour", hour);
} else if (!validMinute) {
return unitOutOfRange("minute", minute);
} else if (!validSecond) {
return unitOutOfRange("second", second);
} else if (!validMillisecond) {
return unitOutOfRange("millisecond", millisecond);
} else
return false;
}
var INVALID$2 = "Invalid DateTime";
var MAX_DATE = 864e13;
function unsupportedZone(zone) {
return new Invalid("unsupported zone", 'the zone "' + zone.name + '" is not supported');
}
function possiblyCachedWeekData(dt) {
if (dt.weekData === null) {
dt.weekData = gregorianToWeek(dt.c);
}
return dt.weekData;
}
function clone$1(inst, alts) {
var current = {
ts: inst.ts,
zone: inst.zone,
c: inst.c,
o: inst.o,
loc: inst.loc,
invalid: inst.invalid
};
return new DateTime5(Object.assign({}, current, alts, {
old: current
}));
}
function fixOffset(localTS, o, tz) {
var utcGuess = localTS - o * 60 * 1e3;
var o2 = tz.offset(utcGuess);
if (o === o2) {
return [utcGuess, o];
}
utcGuess -= (o2 - o) * 60 * 1e3;
var o3 = tz.offset(utcGuess);
if (o2 === o3) {
return [utcGuess, o2];
}
return [localTS - Math.min(o2, o3) * 60 * 1e3, Math.max(o2, o3)];
}
function tsToObj(ts, offset2) {
ts += offset2 * 60 * 1e3;
var d = new Date(ts);
return {
year: d.getUTCFullYear(),
month: d.getUTCMonth() + 1,
day: d.getUTCDate(),
hour: d.getUTCHours(),
minute: d.getUTCMinutes(),
second: d.getUTCSeconds(),
millisecond: d.getUTCMilliseconds()
};
}
function objToTS(obj, offset2, zone) {
return fixOffset(objToLocalTS(obj), offset2, zone);
}
function adjustTime(inst, dur) {
var oPre = inst.o, year = inst.c.year + Math.trunc(dur.years), month = inst.c.month + Math.trunc(dur.months) + Math.trunc(dur.quarters) * 3, c = Object.assign({}, inst.c, {
year,
month,
day: Math.min(inst.c.day, daysInMonth(year, month)) + Math.trunc(dur.days) + Math.trunc(dur.weeks) * 7
}), millisToAdd = Duration.fromObject({
years: dur.years - Math.trunc(dur.years),
quarters: dur.quarters - Math.trunc(dur.quarters),
months: dur.months - Math.trunc(dur.months),
weeks: dur.weeks - Math.trunc(dur.weeks),
days: dur.days - Math.trunc(dur.days),
hours: dur.hours,
minutes: dur.minutes,
seconds: dur.seconds,
milliseconds: dur.milliseconds
}).as("milliseconds"), localTS = objToLocalTS(c);
var _fixOffset = fixOffset(localTS, oPre, inst.zone), ts = _fixOffset[0], o = _fixOffset[1];
if (millisToAdd !== 0) {
ts += millisToAdd;
o = inst.zone.offset(ts);
}
return {
ts,
o
};
}
function parseDataToDateTime(parsed, parsedZone, opts, format, text2) {
var setZone = opts.setZone, zone = opts.zone;
if (parsed && Object.keys(parsed).length !== 0) {
var interpretationZone = parsedZone || zone, inst = DateTime5.fromObject(Object.assign(parsed, opts, {
zone: interpretationZone,
setZone: void 0
}));
return setZone ? inst : inst.setZone(zone);
} else {
return DateTime5.invalid(new Invalid("unparsable", 'the input "' + text2 + `" can't be parsed as ` + format));
}
}
function toTechFormat(dt, format, allowZ) {
if (allowZ === void 0) {
allowZ = true;
}
return dt.isValid ? Formatter.create(Locale.create("en-US"), {
allowZ,
forceSimple: true
}).formatDateTimeFromString(dt, format) : null;
}
function toTechTimeFormat(dt, _ref) {
var _ref$suppressSeconds = _ref.suppressSeconds, suppressSeconds = _ref$suppressSeconds === void 0 ? false : _ref$suppressSeconds, _ref$suppressMillisec = _ref.suppressMilliseconds, suppressMilliseconds = _ref$suppressMillisec === void 0 ? false : _ref$suppressMillisec, includeOffset = _ref.includeOffset, _ref$includePrefix = _ref.includePrefix, includePrefix = _ref$includePrefix === void 0 ? false : _ref$includePrefix, _ref$includeZone = _ref.includeZone, includeZone = _ref$includeZone === void 0 ? false : _ref$includeZone, _ref$spaceZone = _ref.spaceZone, spaceZone = _ref$spaceZone === void 0 ? false : _ref$spaceZone, _ref$format = _ref.format, format = _ref$format === void 0 ? "extended" : _ref$format;
var fmt = format === "basic" ? "HHmm" : "HH:mm";
if (!suppressSeconds || dt.second !== 0 || dt.millisecond !== 0) {
fmt += format === "basic" ? "ss" : ":ss";
if (!suppressMilliseconds || dt.millisecond !== 0) {
fmt += ".SSS";
}
}
if ((includeZone || includeOffset) && spaceZone) {
fmt += " ";
}
if (includeZone) {
fmt += "z";
} else if (includeOffset) {
fmt += format === "basic" ? "ZZZ" : "ZZ";
}
var str = toTechFormat(dt, fmt);
if (includePrefix) {
str = "T" + str;
}
return str;
}
var defaultUnitValues = {
month: 1,
day: 1,
hour: 0,
minute: 0,
second: 0,
millisecond: 0
};
var defaultWeekUnitValues = {
weekNumber: 1,
weekday: 1,
hour: 0,
minute: 0,
second: 0,
millisecond: 0
};
var defaultOrdinalUnitValues = {
ordinal: 1,
hour: 0,
minute: 0,
second: 0,
millisecond: 0
};
var orderedUnits$1 = ["year", "month", "day", "hour", "minute", "second", "millisecond"];
var orderedWeekUnits = ["weekYear", "weekNumber", "weekday", "hour", "minute", "second", "millisecond"];
var orderedOrdinalUnits = ["year", "ordinal", "hour", "minute", "second", "millisecond"];
function normalizeUnit(unit) {
var normalized = {
year: "year",
years: "year",
month: "month",
months: "month",
day: "day",
days: "day",
hour: "hour",
hours: "hour",
minute: "minute",
minutes: "minute",
quarter: "quarter",
quarters: "quarter",
second: "second",
seconds: "second",
millisecond: "millisecond",
milliseconds: "millisecond",
weekday: "weekday",
weekdays: "weekday",
weeknumber: "weekNumber",
weeksnumber: "weekNumber",
weeknumbers: "weekNumber",
weekyear: "weekYear",
weekyears: "weekYear",
ordinal: "ordinal"
}[unit.toLowerCase()];
if (!normalized)
throw new InvalidUnitError(unit);
return normalized;
}
function quickDT(obj, zone) {
for (var _iterator = _createForOfIteratorHelperLoose(orderedUnits$1), _step; !(_step = _iterator()).done; ) {
var u = _step.value;
if (isUndefined(obj[u])) {
obj[u] = defaultUnitValues[u];
}
}
var invalid = hasInvalidGregorianData(obj) || hasInvalidTimeData(obj);
if (invalid) {
return DateTime5.invalid(invalid);
}
var tsNow = Settings2.now(), offsetProvis = zone.offset(tsNow), _objToTS = objToTS(obj, offsetProvis, zone), ts = _objToTS[0], o = _objToTS[1];
return new DateTime5({
ts,
zone,
o
});
}
function diffRelative(start, end, opts) {
var round = isUndefined(opts.round) ? true : opts.round, format = function format2(c, unit2) {
c = roundTo(c, round || opts.calendary ? 0 : 2, true);
var formatter = end.loc.clone(opts).relFormatter(opts);
return formatter.format(c, unit2);
}, differ = function differ2(unit2) {
if (opts.calendary) {
if (!end.hasSame(start, unit2)) {
return end.startOf(unit2).diff(start.startOf(unit2), unit2).get(unit2);
} else
return 0;
} else {
return end.diff(start, unit2).get(unit2);
}
};
if (opts.unit) {
return format(differ(opts.unit), opts.unit);
}
for (var _iterator2 = _createForOfIteratorHelperLoose(opts.units), _step2; !(_step2 = _iterator2()).done; ) {
var unit = _step2.value;
var count = differ(unit);
if (Math.abs(count) >= 1) {
return format(count, unit);
}
}
return format(start > end ? -0 : 0, opts.units[opts.units.length - 1]);
}
var DateTime5 = /* @__PURE__ */ function() {
function DateTime6(config) {
var zone = config.zone || Settings2.defaultZone;
var invalid = config.invalid || (Number.isNaN(config.ts) ? new Invalid("invalid input") : null) || (!zone.isValid ? unsupportedZone(zone) : null);
this.ts = isUndefined(config.ts) ? Settings2.now() : config.ts;
var c = null, o = null;
if (!invalid) {
var unchanged = config.old && config.old.ts === this.ts && config.old.zone.equals(zone);
if (unchanged) {
var _ref2 = [config.old.c, config.old.o];
c = _ref2[0];
o = _ref2[1];
} else {
var ot = zone.offset(this.ts);
c = tsToObj(this.ts, ot);
invalid = Number.isNaN(c.year) ? new Invalid("invalid input") : null;
c = invalid ? null : c;
o = invalid ? null : ot;
}
}
this._zone = zone;
this.loc = config.loc || Locale.create();
this.invalid = invalid;
this.weekData = null;
this.c = c;
this.o = o;
this.isLuxonDateTime = true;
}
DateTime6.now = function now2() {
return new DateTime6({});
};
DateTime6.local = function local(year, month, day, hour, minute, second, millisecond) {
if (isUndefined(year)) {
return DateTime6.now();
} else {
return quickDT({
year,
month,
day,
hour,
minute,
second,
millisecond
}, Settings2.defaultZone);
}
};
DateTime6.utc = function utc(year, month, day, hour, minute, second, millisecond) {
if (isUndefined(year)) {
return new DateTime6({
ts: Settings2.now(),
zone: FixedOffsetZone.utcInstance
});
} else {
return quickDT({
year,
month,
day,
hour,
minute,
second,
millisecond
}, FixedOffsetZone.utcInstance);
}
};
DateTime6.fromJSDate = function fromJSDate(date, options) {
if (options === void 0) {
options = {};
}
var ts = isDate(date) ? date.valueOf() : NaN;
if (Number.isNaN(ts)) {
return DateTime6.invalid("invalid input");
}
var zoneToUse = normalizeZone(options.zone, Settings2.defaultZone);
if (!zoneToUse.isValid) {
return DateTime6.invalid(unsupportedZone(zoneToUse));
}
return new DateTime6({
ts,
zone: zoneToUse,
loc: Locale.fromObject(options)
});
};
DateTime6.fromMillis = function fromMillis(milliseconds, options) {
if (options === void 0) {
options = {};
}
if (!isNumber2(milliseconds)) {
throw new InvalidArgumentError("fromMillis requires a numerical input, but received a " + typeof milliseconds + " with value " + milliseconds);
} else if (milliseconds < -MAX_DATE || milliseconds > MAX_DATE) {
return DateTime6.invalid("Timestamp out of range");
} else {
return new DateTime6({
ts: milliseconds,
zone: normalizeZone(options.zone, Settings2.defaultZone),
loc: Locale.fromObject(options)
});
}
};
DateTime6.fromSeconds = function fromSeconds(seconds, options) {
if (options === void 0) {
options = {};
}
if (!isNumber2(seconds)) {
throw new InvalidArgumentError("fromSeconds requires a numerical input");
} else {
return new DateTime6({
ts: seconds * 1e3,
zone: normalizeZone(options.zone, Settings2.defaultZone),
loc: Locale.fromObject(options)
});
}
};
DateTime6.fromObject = function fromObject(obj) {
var zoneToUse = normalizeZone(obj.zone, Settings2.defaultZone);
if (!zoneToUse.isValid) {
return DateTime6.invalid(unsupportedZone(zoneToUse));
}
var tsNow = Settings2.now(), offsetProvis = zoneToUse.offset(tsNow), normalized = normalizeObject(obj, normalizeUnit, ["zone", "locale", "outputCalendar", "numberingSystem"]), containsOrdinal = !isUndefined(normalized.ordinal), containsGregorYear = !isUndefined(normalized.year), containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber, loc = Locale.fromObject(obj);
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
}
if (containsGregorMD && containsOrdinal) {
throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
}
var useWeekData = definiteWeekDef || normalized.weekday && !containsGregor;
var units, defaultValues, objNow = tsToObj(tsNow, offsetProvis);
if (useWeekData) {
units = orderedWeekUnits;
defaultValues = defaultWeekUnitValues;
objNow = gregorianToWeek(objNow);
} else if (containsOrdinal) {
units = orderedOrdinalUnits;
defaultValues = defaultOrdinalUnitValues;
objNow = gregorianToOrdinal(objNow);
} else {
units = orderedUnits$1;
defaultValues = defaultUnitValues;
}
var foundFirst = false;
for (var _iterator3 = _createForOfIteratorHelperLoose(units), _step3; !(_step3 = _iterator3()).done; ) {
var u = _step3.value;
var v = normalized[u];
if (!isUndefined(v)) {
foundFirst = true;
} else if (foundFirst) {
normalized[u] = defaultValues[u];
} else {
normalized[u] = objNow[u];
}
}
var higherOrderInvalid = useWeekData ? hasInvalidWeekData(normalized) : containsOrdinal ? hasInvalidOrdinalData(normalized) : hasInvalidGregorianData(normalized), invalid = higherOrderInvalid || hasInvalidTimeData(normalized);
if (invalid) {
return DateTime6.invalid(invalid);
}
var gregorian = useWeekData ? weekToGregorian(normalized) : containsOrdinal ? ordinalToGregorian(normalized) : normalized, _objToTS2 = objToTS(gregorian, offsetProvis, zoneToUse), tsFinal = _objToTS2[0], offsetFinal = _objToTS2[1], inst = new DateTime6({
ts: tsFinal,
zone: zoneToUse,
o: offsetFinal,
loc
});
if (normalized.weekday && containsGregor && obj.weekday !== inst.weekday) {
return DateTime6.invalid("mismatched weekday", "you can't specify both a weekday of " + normalized.weekday + " and a date of " + inst.toISO());
}
return inst;
};
DateTime6.fromISO = function fromISO(text2, opts) {
if (opts === void 0) {
opts = {};
}
var _parseISODate = parseISODate(text2), vals = _parseISODate[0], parsedZone = _parseISODate[1];
return parseDataToDateTime(vals, parsedZone, opts, "ISO 8601", text2);
};
DateTime6.fromRFC2822 = function fromRFC2822(text2, opts) {
if (opts === void 0) {
opts = {};
}
var _parseRFC2822Date = parseRFC2822Date(text2), vals = _parseRFC2822Date[0], parsedZone = _parseRFC2822Date[1];
return parseDataToDateTime(vals, parsedZone, opts, "RFC 2822", text2);
};
DateTime6.fromHTTP = function fromHTTP(text2, opts) {
if (opts === void 0) {
opts = {};
}
var _parseHTTPDate = parseHTTPDate(text2), vals = _parseHTTPDate[0], parsedZone = _parseHTTPDate[1];
return parseDataToDateTime(vals, parsedZone, opts, "HTTP", opts);
};
DateTime6.fromFormat = function fromFormat(text2, fmt, opts) {
if (opts === void 0) {
opts = {};
}
if (isUndefined(text2) || isUndefined(fmt)) {
throw new InvalidArgumentError("fromFormat requires an input string and a format");
}
var _opts = opts, _opts$locale = _opts.locale, locale = _opts$locale === void 0 ? null : _opts$locale, _opts$numberingSystem = _opts.numberingSystem, numberingSystem = _opts$numberingSystem === void 0 ? null : _opts$numberingSystem, localeToUse = Locale.fromOpts({
locale,
numberingSystem,
defaultToEN: true
}), _parseFromTokens = parseFromTokens(localeToUse, text2, fmt), vals = _parseFromTokens[0], parsedZone = _parseFromTokens[1], invalid = _parseFromTokens[2];
if (invalid) {
return DateTime6.invalid(invalid);
} else {
return parseDataToDateTime(vals, parsedZone, opts, "format " + fmt, text2);
}
};
DateTime6.fromString = function fromString(text2, fmt, opts) {
if (opts === void 0) {
opts = {};
}
return DateTime6.fromFormat(text2, fmt, opts);
};
DateTime6.fromSQL = function fromSQL(text2, opts) {
if (opts === void 0) {
opts = {};
}
var _parseSQL = parseSQL(text2), vals = _parseSQL[0], parsedZone = _parseSQL[1];
return parseDataToDateTime(vals, parsedZone, opts, "SQL", text2);
};
DateTime6.invalid = function invalid(reason, explanation) {
if (explanation === void 0) {
explanation = null;
}
if (!reason) {
throw new InvalidArgumentError("need to specify a reason the DateTime is invalid");
}
var invalid2 = reason instanceof Invalid ? reason : new Invalid(reason, explanation);
if (Settings2.throwOnInvalid) {
throw new InvalidDateTimeError(invalid2);
} else {
return new DateTime6({
invalid: invalid2
});
}
};
DateTime6.isDateTime = function isDateTime(o) {
return o && o.isLuxonDateTime || false;
};
var _proto = DateTime6.prototype;
_proto.get = function get(unit) {
return this[unit];
};
_proto.resolvedLocaleOpts = function resolvedLocaleOpts(opts) {
if (opts === void 0) {
opts = {};
}
var _Formatter$create$res = Formatter.create(this.loc.clone(opts), opts).resolvedOptions(this), locale = _Formatter$create$res.locale, numberingSystem = _Formatter$create$res.numberingSystem, calendar = _Formatter$create$res.calendar;
return {
locale,
numberingSystem,
outputCalendar: calendar
};
};
_proto.toUTC = function toUTC(offset2, opts) {
if (offset2 === void 0) {
offset2 = 0;
}
if (opts === void 0) {
opts = {};
}
return this.setZone(FixedOffsetZone.instance(offset2), opts);
};
_proto.toLocal = function toLocal() {
return this.setZone(Settings2.defaultZone);
};
_proto.setZone = function setZone(zone, _temp) {
var _ref3 = _temp === void 0 ? {} : _temp, _ref3$keepLocalTime = _ref3.keepLocalTime, keepLocalTime = _ref3$keepLocalTime === void 0 ? false : _ref3$keepLocalTime, _ref3$keepCalendarTim = _ref3.keepCalendarTime, keepCalendarTime = _ref3$keepCalendarTim === void 0 ? false : _ref3$keepCalendarTim;
zone = normalizeZone(zone, Settings2.defaultZone);
if (zone.equals(this.zone)) {
return this;
} else if (!zone.isValid) {
return DateTime6.invalid(unsupportedZone(zone));
} else {
var newTS = this.ts;
if (keepLocalTime || keepCalendarTime) {
var offsetGuess = zone.offset(this.ts);
var asObj = this.toObject();
var _objToTS3 = objToTS(asObj, offsetGuess, zone);
newTS = _objToTS3[0];
}
return clone$1(this, {
ts: newTS,
zone
});
}
};
_proto.reconfigure = function reconfigure(_temp2) {
var _ref4 = _temp2 === void 0 ? {} : _temp2, locale = _ref4.locale, numberingSystem = _ref4.numberingSystem, outputCalendar = _ref4.outputCalendar;
var loc = this.loc.clone({
locale,
numberingSystem,
outputCalendar
});
return clone$1(this, {
loc
});
};
_proto.setLocale = function setLocale(locale) {
return this.reconfigure({
locale
});
};
_proto.set = function set(values) {
if (!this.isValid)
return this;
var normalized = normalizeObject(values, normalizeUnit, []), settingWeekStuff = !isUndefined(normalized.weekYear) || !isUndefined(normalized.weekNumber) || !isUndefined(normalized.weekday), containsOrdinal = !isUndefined(normalized.ordinal), containsGregorYear = !isUndefined(normalized.year), containsGregorMD = !isUndefined(normalized.month) || !isUndefined(normalized.day), containsGregor = containsGregorYear || containsGregorMD, definiteWeekDef = normalized.weekYear || normalized.weekNumber;
if ((containsGregor || containsOrdinal) && definiteWeekDef) {
throw new ConflictingSpecificationError("Can't mix weekYear/weekNumber units with year/month/day or ordinals");
}
if (containsGregorMD && containsOrdinal) {
throw new ConflictingSpecificationError("Can't mix ordinal dates with month/day");
}
var mixed;
if (settingWeekStuff) {
mixed = weekToGregorian(Object.assign(gregorianToWeek(this.c), normalized));
} else if (!isUndefined(normalized.ordinal)) {
mixed = ordinalToGregorian(Object.assign(gregorianToOrdinal(this.c), normalized));
} else {
mixed = Object.assign(this.toObject(), normalized);
if (isUndefined(normalized.day)) {
mixed.day = Math.min(daysInMonth(mixed.year, mixed.month), mixed.day);
}
}
var _objToTS4 = objToTS(mixed, this.o, this.zone), ts = _objToTS4[0], o = _objToTS4[1];
return clone$1(this, {
ts,
o
});
};
_proto.plus = function plus(duration) {
if (!this.isValid)
return this;
var dur = friendlyDuration(duration);
return clone$1(this, adjustTime(this, dur));
};
_proto.minus = function minus(duration) {
if (!this.isValid)
return this;
var dur = friendlyDuration(duration).negate();
return clone$1(this, adjustTime(this, dur));
};
_proto.startOf = function startOf(unit) {
if (!this.isValid)
return this;
var o = {}, normalizedUnit = Duration.normalizeUnit(unit);
switch (normalizedUnit) {
case "years":
o.month = 1;
case "quarters":
case "months":
o.day = 1;
case "weeks":
case "days":
o.hour = 0;
case "hours":
o.minute = 0;
case "minutes":
o.second = 0;
case "seconds":
o.millisecond = 0;
break;
}
if (normalizedUnit === "weeks") {
o.weekday = 1;
}
if (normalizedUnit === "quarters") {
var q = Math.ceil(this.month / 3);
o.month = (q - 1) * 3 + 1;
}
return this.set(o);
};
_proto.endOf = function endOf(unit) {
var _this$plus;
return this.isValid ? this.plus((_this$plus = {}, _this$plus[unit] = 1, _this$plus)).startOf(unit).minus(1) : this;
};
_proto.toFormat = function toFormat(fmt, opts) {
if (opts === void 0) {
opts = {};
}
return this.isValid ? Formatter.create(this.loc.redefaultToEN(opts)).formatDateTimeFromString(this, fmt) : INVALID$2;
};
_proto.toLocaleString = function toLocaleString(opts) {
if (opts === void 0) {
opts = DATE_SHORT;
}
return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTime(this) : INVALID$2;
};
_proto.toLocaleParts = function toLocaleParts(opts) {
if (opts === void 0) {
opts = {};
}
return this.isValid ? Formatter.create(this.loc.clone(opts), opts).formatDateTimeParts(this) : [];
};
_proto.toISO = function toISO(opts) {
if (opts === void 0) {
opts = {};
}
if (!this.isValid) {
return null;
}
return this.toISODate(opts) + "T" + this.toISOTime(opts);
};
_proto.toISODate = function toISODate(_temp3) {
var _ref5 = _temp3 === void 0 ? {} : _temp3, _ref5$format = _ref5.format, format = _ref5$format === void 0 ? "extended" : _ref5$format;
var fmt = format === "basic" ? "yyyyMMdd" : "yyyy-MM-dd";
if (this.year > 9999) {
fmt = "+" + fmt;
}
return toTechFormat(this, fmt);
};
_proto.toISOWeekDate = function toISOWeekDate() {
return toTechFormat(this, "kkkk-'W'WW-c");
};
_proto.toISOTime = function toISOTime(_temp4) {
var _ref6 = _temp4 === void 0 ? {} : _temp4, _ref6$suppressMillise = _ref6.suppressMilliseconds, suppressMilliseconds = _ref6$suppressMillise === void 0 ? false : _ref6$suppressMillise, _ref6$suppressSeconds = _ref6.suppressSeconds, suppressSeconds = _ref6$suppressSeconds === void 0 ? false : _ref6$suppressSeconds, _ref6$includeOffset = _ref6.includeOffset, includeOffset = _ref6$includeOffset === void 0 ? true : _ref6$includeOffset, _ref6$includePrefix = _ref6.includePrefix, includePrefix = _ref6$includePrefix === void 0 ? false : _ref6$includePrefix, _ref6$format = _ref6.format, format = _ref6$format === void 0 ? "extended" : _ref6$format;
return toTechTimeFormat(this, {
suppressSeconds,
suppressMilliseconds,
includeOffset,
includePrefix,
format
});
};
_proto.toRFC2822 = function toRFC2822() {
return toTechFormat(this, "EEE, dd LLL yyyy HH:mm:ss ZZZ", false);
};
_proto.toHTTP = function toHTTP() {
return toTechFormat(this.toUTC(), "EEE, dd LLL yyyy HH:mm:ss 'GMT'");
};
_proto.toSQLDate = function toSQLDate() {
return toTechFormat(this, "yyyy-MM-dd");
};
_proto.toSQLTime = function toSQLTime(_temp5) {
var _ref7 = _temp5 === void 0 ? {} : _temp5, _ref7$includeOffset = _ref7.includeOffset, includeOffset = _ref7$includeOffset === void 0 ? true : _ref7$includeOffset, _ref7$includeZone = _ref7.includeZone, includeZone = _ref7$includeZone === void 0 ? false : _ref7$includeZone;
return toTechTimeFormat(this, {
includeOffset,
includeZone,
spaceZone: true
});
};
_proto.toSQL = function toSQL(opts) {
if (opts === void 0) {
opts = {};
}
if (!this.isValid) {
return null;
}
return this.toSQLDate() + " " + this.toSQLTime(opts);
};
_proto.toString = function toString() {
return this.isValid ? this.toISO() : INVALID$2;
};
_proto.valueOf = function valueOf() {
return this.toMillis();
};
_proto.toMillis = function toMillis() {
return this.isValid ? this.ts : NaN;
};
_proto.toSeconds = function toSeconds() {
return this.isValid ? this.ts / 1e3 : NaN;
};
_proto.toJSON = function toJSON() {
return this.toISO();
};
_proto.toBSON = function toBSON() {
return this.toJSDate();
};
_proto.toObject = function toObject(opts) {
if (opts === void 0) {
opts = {};
}
if (!this.isValid)
return {};
var base = Object.assign({}, this.c);
if (opts.includeConfig) {
base.outputCalendar = this.outputCalendar;
base.numberingSystem = this.loc.numberingSystem;
base.locale = this.loc.locale;
}
return base;
};
_proto.toJSDate = function toJSDate() {
return new Date(this.isValid ? this.ts : NaN);
};
_proto.diff = function diff(otherDateTime, unit, opts) {
if (unit === void 0) {
unit = "milliseconds";
}
if (opts === void 0) {
opts = {};
}
if (!this.isValid || !otherDateTime.isValid) {
return Duration.invalid(this.invalid || otherDateTime.invalid, "created by diffing an invalid DateTime");
}
var durOpts = Object.assign({
locale: this.locale,
numberingSystem: this.numberingSystem
}, opts);
var units = maybeArray(unit).map(Duration.normalizeUnit), otherIsLater = otherDateTime.valueOf() > this.valueOf(), earlier = otherIsLater ? this : otherDateTime, later = otherIsLater ? otherDateTime : this, diffed = _diff(earlier, later, units, durOpts);
return otherIsLater ? diffed.negate() : diffed;
};
_proto.diffNow = function diffNow(unit, opts) {
if (unit === void 0) {
unit = "milliseconds";
}
if (opts === void 0) {
opts = {};
}
return this.diff(DateTime6.now(), unit, opts);
};
_proto.until = function until(otherDateTime) {
return this.isValid ? Interval.fromDateTimes(this, otherDateTime) : this;
};
_proto.hasSame = function hasSame(otherDateTime, unit) {
if (!this.isValid)
return false;
var inputMs = otherDateTime.valueOf();
var otherZoneDateTime = this.setZone(otherDateTime.zone, {
keepLocalTime: true
});
return otherZoneDateTime.startOf(unit) <= inputMs && inputMs <= otherZoneDateTime.endOf(unit);
};
_proto.equals = function equals(other) {
return this.isValid && other.isValid && this.valueOf() === other.valueOf() && this.zone.equals(other.zone) && this.loc.equals(other.loc);
};
_proto.toRelative = function toRelative(options) {
if (options === void 0) {
options = {};
}
if (!this.isValid)
return null;
var base = options.base || DateTime6.fromObject({
zone: this.zone
}), padding = options.padding ? this < base ? -options.padding : options.padding : 0;
var units = ["years", "months", "days", "hours", "minutes", "seconds"];
var unit = options.unit;
if (Array.isArray(options.unit)) {
units = options.unit;
unit = void 0;
}
return diffRelative(base, this.plus(padding), Object.assign(options, {
numeric: "always",
units,
unit
}));
};
_proto.toRelativeCalendar = function toRelativeCalendar(options) {
if (options === void 0) {
options = {};
}
if (!this.isValid)
return null;
return diffRelative(options.base || DateTime6.fromObject({
zone: this.zone
}), this, Object.assign(options, {
numeric: "auto",
units: ["years", "months", "days"],
calendary: true
}));
};
DateTime6.min = function min() {
for (var _len = arguments.length, dateTimes = new Array(_len), _key = 0; _key < _len; _key++) {
dateTimes[_key] = arguments[_key];
}
if (!dateTimes.every(DateTime6.isDateTime)) {
throw new InvalidArgumentError("min requires all arguments be DateTimes");
}
return bestBy(dateTimes, function(i) {
return i.valueOf();
}, Math.min);
};
DateTime6.max = function max() {
for (var _len2 = arguments.length, dateTimes = new Array(_len2), _key2 = 0; _key2 < _len2; _key2++) {
dateTimes[_key2] = arguments[_key2];
}
if (!dateTimes.every(DateTime6.isDateTime)) {
throw new InvalidArgumentError("max requires all arguments be DateTimes");
}
return bestBy(dateTimes, function(i) {
return i.valueOf();
}, Math.max);
};
DateTime6.fromFormatExplain = function fromFormatExplain(text2, fmt, options) {
if (options === void 0) {
options = {};
}
var _options = options, _options$locale = _options.locale, locale = _options$locale === void 0 ? null : _options$locale, _options$numberingSys = _options.numberingSystem, numberingSystem = _options$numberingSys === void 0 ? null : _options$numberingSys, localeToUse = Locale.fromOpts({
locale,
numberingSystem,
defaultToEN: true
});
return explainFromTokens(localeToUse, text2, fmt);
};
DateTime6.fromStringExplain = function fromStringExplain(text2, fmt, options) {
if (options === void 0) {
options = {};
}
return DateTime6.fromFormatExplain(text2, fmt, options);
};
_createClass(DateTime6, [{
key: "isValid",
get: function get() {
return this.invalid === null;
}
}, {
key: "invalidReason",
get: function get() {
return this.invalid ? this.invalid.reason : null;
}
}, {
key: "invalidExplanation",
get: function get() {
return this.invalid ? this.invalid.explanation : null;
}
}, {
key: "locale",
get: function get() {
return this.isValid ? this.loc.locale : null;
}
}, {
key: "numberingSystem",
get: function get() {
return this.isValid ? this.loc.numberingSystem : null;
}
}, {
key: "outputCalendar",
get: function get() {
return this.isValid ? this.loc.outputCalendar : null;
}
}, {
key: "zone",
get: function get() {
return this._zone;
}
}, {
key: "zoneName",
get: function get() {
return this.isValid ? this.zone.name : null;
}
}, {
key: "year",
get: function get() {
return this.isValid ? this.c.year : NaN;
}
}, {
key: "quarter",
get: function get() {
return this.isValid ? Math.ceil(this.c.month / 3) : NaN;
}
}, {
key: "month",
get: function get() {
return this.isValid ? this.c.month : NaN;
}
}, {
key: "day",
get: function get() {
return this.isValid ? this.c.day : NaN;
}
}, {
key: "hour",
get: function get() {
return this.isValid ? this.c.hour : NaN;
}
}, {
key: "minute",
get: function get() {
return this.isValid ? this.c.minute : NaN;
}
}, {
key: "second",
get: function get() {
return this.isValid ? this.c.second : NaN;
}
}, {
key: "millisecond",
get: function get() {
return this.isValid ? this.c.millisecond : NaN;
}
}, {
key: "weekYear",
get: function get() {
return this.isValid ? possiblyCachedWeekData(this).weekYear : NaN;
}
}, {
key: "weekNumber",
get: function get() {
return this.isValid ? possiblyCachedWeekData(this).weekNumber : NaN;
}
}, {
key: "weekday",
get: function get() {
return this.isValid ? possiblyCachedWeekData(this).weekday : NaN;
}
}, {
key: "ordinal",
get: function get() {
return this.isValid ? gregorianToOrdinal(this.c).ordinal : NaN;
}
}, {
key: "monthShort",
get: function get() {
return this.isValid ? Info.months("short", {
locObj: this.loc
})[this.month - 1] : null;
}
}, {
key: "monthLong",
get: function get() {
return this.isValid ? Info.months("long", {
locObj: this.loc
})[this.month - 1] : null;
}
}, {
key: "weekdayShort",
get: function get() {
return this.isValid ? Info.weekdays("short", {
locObj: this.loc
})[this.weekday - 1] : null;
}
}, {
key: "weekdayLong",
get: function get() {
return this.isValid ? Info.weekdays("long", {
locObj: this.loc
})[this.weekday - 1] : null;
}
}, {
key: "offset",
get: function get() {
return this.isValid ? +this.o : NaN;
}
}, {
key: "offsetNameShort",
get: function get() {
if (this.isValid) {
return this.zone.offsetName(this.ts, {
format: "short",
locale: this.locale
});
} else {
return null;
}
}
}, {
key: "offsetNameLong",
get: function get() {
if (this.isValid) {
return this.zone.offsetName(this.ts, {
format: "long",
locale: this.locale
});
} else {
return null;
}
}
}, {
key: "isOffsetFixed",
get: function get() {
return this.isValid ? this.zone.universal : null;
}
}, {
key: "isInDST",
get: function get() {
if (this.isOffsetFixed) {
return false;
} else {
return this.offset > this.set({
month: 1
}).offset || this.offset > this.set({
month: 5
}).offset;
}
}
}, {
key: "isInLeapYear",
get: function get() {
return isLeapYear(this.year);
}
}, {
key: "daysInMonth",
get: function get() {
return daysInMonth(this.year, this.month);
}
}, {
key: "daysInYear",
get: function get() {
return this.isValid ? daysInYear(this.year) : NaN;
}
}, {
key: "weeksInWeekYear",
get: function get() {
return this.isValid ? weeksInWeekYear(this.weekYear) : NaN;
}
}], [{
key: "DATE_SHORT",
get: function get() {
return DATE_SHORT;
}
}, {
key: "DATE_MED",
get: function get() {
return DATE_MED;
}
}, {
key: "DATE_MED_WITH_WEEKDAY",
get: function get() {
return DATE_MED_WITH_WEEKDAY;
}
}, {
key: "DATE_FULL",
get: function get() {
return DATE_FULL;
}
}, {
key: "DATE_HUGE",
get: function get() {
return DATE_HUGE;
}
}, {
key: "TIME_SIMPLE",
get: function get() {
return TIME_SIMPLE;
}
}, {
key: "TIME_WITH_SECONDS",
get: function get() {
return TIME_WITH_SECONDS;
}
}, {
key: "TIME_WITH_SHORT_OFFSET",
get: function get() {
return TIME_WITH_SHORT_OFFSET;
}
}, {
key: "TIME_WITH_LONG_OFFSET",
get: function get() {
return TIME_WITH_LONG_OFFSET;
}
}, {
key: "TIME_24_SIMPLE",
get: function get() {
return TIME_24_SIMPLE;
}
}, {
key: "TIME_24_WITH_SECONDS",
get: function get() {
return TIME_24_WITH_SECONDS;
}
}, {
key: "TIME_24_WITH_SHORT_OFFSET",
get: function get() {
return TIME_24_WITH_SHORT_OFFSET;
}
}, {
key: "TIME_24_WITH_LONG_OFFSET",
get: function get() {
return TIME_24_WITH_LONG_OFFSET;
}
}, {
key: "DATETIME_SHORT",
get: function get() {
return DATETIME_SHORT;
}
}, {
key: "DATETIME_SHORT_WITH_SECONDS",
get: function get() {
return DATETIME_SHORT_WITH_SECONDS;
}
}, {
key: "DATETIME_MED",
get: function get() {
return DATETIME_MED;
}
}, {
key: "DATETIME_MED_WITH_SECONDS",
get: function get() {
return DATETIME_MED_WITH_SECONDS;
}
}, {
key: "DATETIME_MED_WITH_WEEKDAY",
get: function get() {
return DATETIME_MED_WITH_WEEKDAY;
}
}, {
key: "DATETIME_FULL",
get: function get() {
return DATETIME_FULL;
}
}, {
key: "DATETIME_FULL_WITH_SECONDS",
get: function get() {
return DATETIME_FULL_WITH_SECONDS;
}
}, {
key: "DATETIME_HUGE",
get: function get() {
return DATETIME_HUGE;
}
}, {
key: "DATETIME_HUGE_WITH_SECONDS",
get: function get() {
return DATETIME_HUGE_WITH_SECONDS;
}
}]);
return DateTime6;
}();
function friendlyDateTime(dateTimeish) {
if (DateTime5.isDateTime(dateTimeish)) {
return dateTimeish;
} else if (dateTimeish && dateTimeish.valueOf && isNumber2(dateTimeish.valueOf())) {
return DateTime5.fromJSDate(dateTimeish);
} else if (dateTimeish && typeof dateTimeish === "object") {
return DateTime5.fromObject(dateTimeish);
} else {
throw new InvalidArgumentError("Unknown datetime argument: " + dateTimeish + ", of type " + typeof dateTimeish);
}
}
var VERSION = "1.28.0";
exports.DateTime = DateTime5;
exports.Duration = Duration;
exports.FixedOffsetZone = FixedOffsetZone;
exports.IANAZone = IANAZone;
exports.Info = Info;
exports.Interval = Interval;
exports.InvalidZone = InvalidZone;
exports.LocalZone = LocalZone;
exports.Settings = Settings2;
exports.VERSION = VERSION;
exports.Zone = Zone;
}
});
// src/main.ts
var main_exports = {};
__export(main_exports, {
default: () => ReminderPlugin
});
module.exports = __toCommonJS(main_exports);
// src/controller.ts
var import_obsidian3 = require("obsidian");
// src/model/format/markdown.ts
var _Todo = class {
constructor(lineIndex, prefix, check, suffix, body) {
this.lineIndex = lineIndex;
this.prefix = prefix;
this.check = check;
this.suffix = suffix;
this.body = body;
}
static parse(lineIndex, line) {
const match = _Todo.regexp.exec(line);
if (match) {
return new _Todo(
lineIndex,
match.groups["prefix"],
match.groups["check"],
match.groups["suffix"],
match.groups["body"]
);
}
return null;
}
toMarkdown() {
return `${this.prefix}${this.check}${this.suffix}${this.body}`;
}
isChecked() {
return this.check === "x";
}
setChecked(checked) {
this.check = checked ? "x" : " ";
}
getHeaderLength() {
return this.prefix.length + this.check.length + this.suffix.length;
}
clone() {
return _Todo.parse(this.lineIndex, this.toMarkdown());
}
};
var Todo = _Todo;
Todo.regexp = new RegExp("^(?<prefix>((> ?)*)?\\s*[\\-\\*] \\[)(?<check>.)(?<suffix>\\]\\s+)(?<body>.*)$");
var MarkdownDocument = class {
constructor(file, content) {
this.file = file;
this.lines = [];
this.todos = [];
this.parse(content);
}
parse(content) {
this.lines = content.split("\n");
this.todos = [];
this.lines.forEach((line, lineIndex) => {
const todo = Todo.parse(lineIndex, line);
if (todo) {
this.todos.push(todo);
}
});
}
getTodos() {
return this.todos;
}
insertTodo(lineIndex, todo) {
todo.lineIndex = lineIndex;
this.lines.splice(lineIndex, 0, todo.toMarkdown());
let todoIndex = -1;
for (const i in this.todos) {
const todo2 = this.todos[i];
if (todo2.lineIndex >= lineIndex) {
if (todoIndex < 0) {
todoIndex = parseInt(i);
}
todo2.lineIndex++;
}
}
if (todoIndex <= 0) {
this.todos.splice(0, 0, todo);
} else {
this.todos.splice(todoIndex, 0, todo);
}
}
getTodo(lineIndex) {
const found = this.todos.find((todo) => todo.lineIndex === lineIndex);
if (found == null) {
return null;
}
return found;
}
applyChanges() {
this.todos.forEach((todo) => {
this.lines[todo.lineIndex] = todo.toMarkdown();
});
}
toMarkdown() {
this.applyChanges();
return this.lines.join("\n");
}
};
// src/model/ref.ts
var ConstantReference = class {
constructor(_value) {
this._value = _value;
}
get value() {
return this._value;
}
};
var Reference = class {
constructor(_value) {
this._value = _value;
this.onChangeFunctions = [];
}
onChanged(listener) {
this.onChangeFunctions.push(listener);
}
get value() {
return this._value;
}
set value(value) {
const oldValue = this._value;
this._value = value;
this.onChangeFunctions.forEach((f) => {
f(oldValue, value);
});
}
};
// src/model/time.ts
var import_moment = __toESM(require_moment());
var DateTime = class {
constructor(time, _hasTimePart) {
this.time = time;
this._hasTimePart = _hasTimePart;
}
static now() {
return new DateTime((0, import_moment.default)(), true);
}
static parse(time) {
if (time.length > 10) {
return new DateTime((0, import_moment.default)(time, "YYYY-MM-DD HH:mm"), true);
} else {
return new DateTime((0, import_moment.default)(time, "YYYY-MM-DD"), false);
}
}
static duration(from, to, unit, defaultTime) {
return to.fixedTime(defaultTime).diff(from.fixedTime(defaultTime), unit);
}
getTimeInMillis(defaultTime) {
return this.fixedTime(defaultTime).valueOf();
}
format(format, defaultTime) {
return this.fixedTime(defaultTime).format(format);
}
toYYYYMMMM(defaultTime) {
return this.fixedTime(defaultTime).format("YYYY, MMMM");
}
toYYYYMMDD(defaultTime) {
return this.fixedTime(defaultTime).format("YYYY-MM-DD");
}
add(amount, unit, defaultTime) {
return new DateTime(
this.fixedTime(defaultTime).clone().add(amount, unit),
this._hasTimePart
);
}
fixedTime(defaultTime) {
if (this._hasTimePart) {
return this.time;
}
if (defaultTime === void 0) {
return this.time;
}
return this.time.clone().add(defaultTime.minutes, "minutes");
}
get hasTimePart() {
return this._hasTimePart;
}
moment() {
return this.time;
}
isValid() {
return this.time.isValid();
}
clone(hasTimePart) {
const withTimePart = hasTimePart == null ? this._hasTimePart : hasTimePart;
const clone = this.time.clone();
return new DateTime(clone, withTimePart);
}
toString() {
if (this._hasTimePart) {
return this.format("YYYY-MM-DD HH:mm");
} else {
return this.format("YYYY-MM-DD");
}
}
equals(time) {
return this._hasTimePart === time._hasTimePart && this.time.isSame(time.time);
}
};
var Time = class {
constructor(hour, minute) {
this.hour = hour;
this.minute = minute;
}
static parse(text2) {
if (!text2.match(/^\d{1,2}:\d{1,2}$/)) {
throw `Unexpected format time(${text2}). Time must be HH:mm.`;
}
const s = text2.split(":");
if (s.length !== 2) {
throw `Unexpected format time(${text2}). time must be HH:mm.`;
}
const hour = parseInt(s[0]);
const minute = parseInt(s[1]);
if (hour > 23 || hour < 0) {
throw `hour must be 0~23`;
}
if (minute > 59 || minute < 0) {
throw `minute must be 0~59`;
}
return new Time(hour, minute);
}
get minutes() {
return this.hour * 60 + this.minute;
}
toString() {
const pad = (n) => {
if (n < 10) {
return "0" + n;
}
return "" + n;
};
return `${pad(this.hour)}:${pad(this.minute)}`;
}
};
function add(amount, unit) {
return () => {
return new DateTime((0, import_moment.default)(), true).add(amount, unit);
};
}
function inMinutes(minutes) {
return add(minutes, "minutes");
}
function inHours(hours) {
return add(hours, "hours");
}
function inDays(days) {
return add(days, "days");
}
function inWeeks(weeks) {
return add(weeks, "weeks");
}
function inMonths(months) {
return add(months, "months");
}
function inYears(years) {
return add(years, "years");
}
function nextWeekday(weekday) {
return () => {
const today = (0, import_moment.default)();
if (today.isoWeekday() <= weekday) {
return new DateTime(today.isoWeekday(weekday), false);
} else {
return new DateTime(today.add(1, "weeks").isoWeekday(weekday), false);
}
};
}
function tomorrow() {
return () => {
return new DateTime((0, import_moment.default)().add(1, "days"), false);
};
}
function nextWeek() {
return () => {
return new DateTime((0, import_moment.default)().add(1, "weeks"), false);
};
}
function nextMonth() {
return () => {
return new DateTime((0, import_moment.default)().add(1, "months"), false);
};
}
function nextYear() {
return () => {
return new DateTime((0, import_moment.default)().add(1, "years"), false);
};
}
var Later = class {
constructor(label, later) {
this.label = label;
this.later = later;
}
};
function parseLaters(laters) {
return laters.split("\n").map((l) => parseLater(l.trim()));
}
function parseLater(later) {
later = later.toLowerCase();
if (later.startsWith("in")) {
const tokens = later.split(" ");
if (tokens.length !== 3) {
throw `Unsupported format. Should be 'In N (minutes|hours)'`;
}
const n = tokens[1] === "a" || tokens[1] === "an" ? 1 : parseInt(tokens[1]);
switch (tokens[2]) {
case "minute":
case "minutes": {
const unit = n == 1 ? "minute" : "minutes";
return new Later(`In ${n} ${unit}`, inMinutes(n));
}
case "hour":
case "hours": {
const unit = n == 1 ? "hour" : "hours";
return new Later(`In ${n} ${unit}`, inHours(n));
}
case "day":
case "days": {
const unit = n == 1 ? "day" : "days";
return new Later(`In ${n} ${unit}`, inDays(n));
}
case "week":
case "weeks": {
const unit = n == 1 ? "week" : "weeks";
return new Later(`In ${n} ${unit}`, inWeeks(n));
}
case "month":
case "months": {
const unit = n == 1 ? "month" : "months";
return new Later(`In ${n} ${unit}`, inMonths(n));
}
case "year":
case "years": {
const unit = n == 1 ? "year" : "years";
return new Later(`In ${n} ${unit}`, inYears(n));
}
}
} else if (later.startsWith("next")) {
const weekday = later.substring(5);
switch (weekday) {
case "sunday":
return new Later("Next Sunday", nextWeekday(0));
case "monday":
return new Later("Next Monday", nextWeekday(1));
case "tuesday":
return new Later("Next Tuesday", nextWeekday(2));
case "wednesday":
return new Later("Next Wednesday", nextWeekday(3));
case "thursday":
return new Later("Next Thursday", nextWeekday(4));
case "friday":
return new Later("Next Friday", nextWeekday(5));
case "saturday":
return new Later("Next Saturday", nextWeekday(6));
case "day":
return new Later("Tomorrow", tomorrow());
case "week":
return new Later("Next week", nextWeek());
case "month":
return new Later("Next month", nextMonth());
case "year":
return new Later("Next year", nextYear());
default:
throw `Unsupported weekday: ${weekday}`;
}
} else if (later === "tomorrow") {
return new Later("Tomorrow", tomorrow());
}
throw `Unsupported format: ${later}`;
}
var DEFAULT_LATERS = [
new Later("In 30 minutes", inMinutes(30)),
new Later("In 1 hours", inHours(1)),
new Later("In 3 hours", inHours(3)),
new Later("Tomorrow", tomorrow()),
new Later("Next week", nextWeek())
];
var DateTimeFormatter = class {
constructor() {
this.dateFormat = new ConstantReference("YYYY-MM-DD");
this.dateTimeFormat = new ConstantReference("YYYY-MM-DD HH:mm");
this.strict = new ConstantReference(false);
}
setTimeFormat(dateFormat, dateTimeFormat, strict) {
this.dateFormat = dateFormat;
this.dateTimeFormat = dateTimeFormat;
this.strict = strict;
}
parse(text2) {
const parsed = this.doParse(text2, true);
if (parsed != null) {
return parsed;
}
if (this.strict.value) {
return null;
}
return this.doParse(text2, false);
}
doParse(text2, strict) {
const dateTime = (0, import_moment.default)(text2, this.dateTimeFormat.value, strict);
if (dateTime.isValid()) {
return new DateTime(dateTime, true);
}
const date = (0, import_moment.default)(text2, this.dateFormat.value, strict);
if (date.isValid()) {
return new DateTime(date, false);
}
return null;
}
toString(time) {
if (time.hasTimePart) {
return time.format(this.dateTimeFormat.value);
} else {
return time.format(this.dateFormat.value);
}
}
};
var DATE_TIME_FORMATTER = new DateTimeFormatter();
// src/model/reminder.ts
var Reminder = class {
constructor(file, title, time, rowNumber, done) {
this.file = file;
this.title = title;
this.time = time;
this.rowNumber = rowNumber;
this.done = done;
this.muteNotification = false;
this.beingDisplayed = false;
}
key() {
return this.file + this.title + this.time.toString();
}
equals(reminder) {
return this.rowNumber === reminder.rowNumber && this.title === reminder.title && this.time.equals(reminder.time) && this.file === reminder.file;
}
getFileName() {
const p = this.file.split(/[\/\\]/);
return p[p.length - 1].replace(/^(.*?)(\..+)?$/, "$1");
}
static extractFileName(path) {
const p = path.split(/[\/\\]/);
return p[p.length - 1].replace(/^(.*?)(\..+)?$/, "$1");
}
};
var Reminders = class {
constructor(onChange) {
this.onChange = onChange;
this.fileToReminders = /* @__PURE__ */ new Map();
this.reminders = [];
}
getExpiredReminders(defaultTime) {
const now = new Date().getTime();
const result = [];
for (let i = 0; i < this.reminders.length; i++) {
const reminder = this.reminders[i];
if (reminder.time.getTimeInMillis(defaultTime) <= now) {
result.push(reminder);
} else {
break;
}
}
return result;
}
byDate(date) {
return this.reminders.filter((reminder) => reminder.time.toYYYYMMDD() === date.toYYYYMMDD());
}
removeReminder(reminder) {
console.debug("Remove reminder: %o", reminder);
this.reminders.remove(reminder);
const file = this.fileToReminders.get(reminder.file);
if (file) {
file.remove(reminder);
if (file.length === 0) {
this.fileToReminders.delete(reminder.file);
}
}
this.onChange();
}
clear() {
this.fileToReminders.clear();
this.reminders = [];
this.onChange();
}
removeFile(filePath) {
if (this.fileToReminders.delete(filePath)) {
this.sortReminders();
return true;
}
return false;
}
replaceFile(filePath, reminders) {
const oldReminders = this.fileToReminders.get(filePath);
if (oldReminders) {
if (this.equals(oldReminders, reminders)) {
return false;
}
const reminderToNotificationVisible = /* @__PURE__ */ new Map();
for (const reminder of oldReminders) {
reminderToNotificationVisible.set(reminder.key(), reminder.muteNotification);
}
for (const reminder of reminders) {
const visible = reminderToNotificationVisible.get(reminder.key());
reminderToNotificationVisible.set(reminder.key(), reminder.muteNotification);
if (visible !== void 0) {
reminder.muteNotification = visible;
}
}
}
this.fileToReminders.set(filePath, reminders);
this.sortReminders();
return true;
}
equals(r1, r2) {
if (r1.length !== r2.length) {
return false;
}
this.sort(r1);
this.sort(r2);
for (const i in r1) {
const reminder1 = r1[i];
const reminder2 = r2[i];
if (reminder1 == null && reminder2 != null) {
return false;
}
if (reminder2 == null && reminder1 != null) {
return false;
}
if (reminder1 == null && reminder2 == null) {
continue;
}
if (!reminder1.equals(reminder2)) {
return false;
}
}
return true;
}
sortReminders() {
const reminders = [];
for (const r of this.fileToReminders.values()) {
reminders.push(...r);
}
this.sort(reminders);
this.reminders = reminders;
this.onChange();
}
sort(reminders) {
reminders.sort((a, b) => {
var _a, _b;
const d = a.time.getTimeInMillis((_a = this.reminderTime) == null ? void 0 : _a.value) - b.time.getTimeInMillis((_b = this.reminderTime) == null ? void 0 : _b.value);
return d > 0 ? 1 : d < 0 ? -1 : 0;
});
}
};
function generateGroup(time, now, reminderTime) {
const days = DateTime.duration(now, time, "days", reminderTime);
if (days > 30) {
return new Group(
time.toYYYYMMMM(reminderTime),
(time2) => time2.format("MM/DD", reminderTime)
);
}
if (days >= 7) {
return new Group(
"Over 1 week",
(time2) => time2.format("MM/DD", reminderTime)
);
}
if (time.toYYYYMMDD(reminderTime) === now.toYYYYMMDD(reminderTime)) {
const todaysGroup = new Group(
"Today",
(time2) => time2.format("HH:mm", reminderTime)
);
todaysGroup.isToday = true;
return todaysGroup;
}
if (time.toYYYYMMDD(reminderTime) === now.add(1, "days", reminderTime).toYYYYMMDD()) {
return new Group("Tomorrow", (time2) => time2.format("HH:mm", reminderTime));
}
return new Group(
time.format("M/DD (ddd)", reminderTime),
(time2) => time2.format("HH:mm", reminderTime)
);
}
var Group = class {
constructor(name, timeToStringFunc) {
this.name = name;
this.timeToStringFunc = timeToStringFunc;
this.isToday = false;
this.isOverdue = false;
}
timeToString(time) {
return this.timeToStringFunc(time);
}
};
function groupReminders(sortedReminders, reminderTime) {
const now = DateTime.now();
const result = [];
let currentReminders = [];
const overdueReminders = [];
let previousGroup = generateGroup(now, now, reminderTime);
for (let i = 0; i < sortedReminders.length; i++) {
const r = sortedReminders[i];
if (r.muteNotification) {
overdueReminders.push(r);
continue;
}
const group = generateGroup(r.time, now, reminderTime);
if (group.name !== previousGroup.name) {
if (currentReminders.length > 0 || previousGroup.isToday) {
result.push(new GroupedReminder(previousGroup, currentReminders));
}
currentReminders = [];
}
currentReminders.push(r);
previousGroup = group;
}
if (currentReminders.length > 0) {
result.push(new GroupedReminder(previousGroup, currentReminders));
}
if (overdueReminders.length > 0) {
const overdueGroup = new Group("Overdue", (time) => time.format("HH:mm", reminderTime));
overdueGroup.isOverdue = true;
result.splice(0, 0, new GroupedReminder(overdueGroup, overdueReminders));
console.log(overdueGroup);
console.log(result);
}
return result;
}
var GroupedReminder = class {
constructor(group, reminders) {
this.group = group;
this.reminders = reminders;
}
get name() {
return this.group.name;
}
get isOverdue() {
return this.group.isOverdue;
}
timeToString(time) {
return this.group.timeToString(time);
}
};
// src/model/format/reminder-base.ts
var _ReminderFormatParameterKey = class {
constructor(key, defaultValue) {
this.key = key;
this.defaultValue = defaultValue;
}
};
var ReminderFormatParameterKey = _ReminderFormatParameterKey;
ReminderFormatParameterKey.now = new _ReminderFormatParameterKey("now", DateTime.now());
ReminderFormatParameterKey.useCustomEmojiForTasksPlugin = new _ReminderFormatParameterKey("useCustomEmojiForTasksPlugin", false);
ReminderFormatParameterKey.removeTagsForTasksPlugin = new _ReminderFormatParameterKey("removeTagsForTasksPlugin", false);
ReminderFormatParameterKey.linkDatesToDailyNotes = new _ReminderFormatParameterKey("linkDatesToDailyNotes", false);
ReminderFormatParameterKey.strictDateFormat = new _ReminderFormatParameterKey("strictDateFormat", false);
var ReminderFormatConfig = class {
constructor() {
this.parameters = /* @__PURE__ */ new Map();
}
setParameter(key, value) {
this.parameters.set(key.key, () => value.value);
}
setParameterFunc(key, f) {
this.parameters.set(key.key, f);
}
setParameterValue(key, value) {
this.parameters.set(key.key, () => value);
}
getParameter(key) {
const value = this.parameters.get(key.key);
if (value == null) {
return key.defaultValue;
}
return value();
}
};
var TodoBasedReminderFormat = class {
constructor() {
this.config = new ReminderFormatConfig();
}
setConfig(config) {
this.config = config;
}
parse(doc) {
return doc.getTodos().map((todo) => {
const parsed = this.parseValidReminder(todo);
if (parsed == null) {
return null;
}
const title = parsed.getTitle();
if (title == null) {
return null;
}
const time = parsed.getTime();
if (time == null) {
return null;
}
return new Reminder(doc.file, title, time, todo.lineIndex, todo.isChecked());
}).filter((reminder) => reminder != null);
}
modify(doc, reminder, edit) {
return __async(this, null, function* () {
const todo = doc.getTodo(reminder.rowNumber);
if (todo === null) {
console.warn("Not a todo: reminder=%o", reminder);
return false;
}
const parsed = this.parseValidReminder(todo);
if (parsed === null) {
return false;
}
if (!this.modifyReminder(doc, todo, parsed, edit)) {
return false;
}
todo.body = parsed.toMarkdown();
return true;
});
}
parseValidReminder(todo) {
const parsed = this.parseReminder(todo);
if (parsed === null) {
return null;
}
if (!this.isValidReminder(parsed)) {
return null;
}
return parsed;
}
isValidReminder(reminder) {
return reminder.getTime() !== null;
}
modifyReminder(doc, todo, parsed, edit) {
if (edit.rawTime !== void 0) {
if (!parsed.setRawTime(edit.rawTime)) {
console.warn("The reminder doesn't support raw time: parsed=%o", parsed);
return false;
}
} else if (edit.time !== void 0) {
parsed.setTime(edit.time);
}
if (edit.checked !== void 0) {
todo.setChecked(edit.checked);
}
return true;
}
appendReminder(line, time, insertAt) {
const todo = Todo.parse(0, line);
if (todo == null) {
return null;
}
let parsed = this.parseReminder(todo);
const todoHeaderLength = todo.getHeaderLength();
if (insertAt != null) {
insertAt -= todoHeaderLength;
}
if (parsed != null) {
parsed.setTime(time, insertAt);
} else {
parsed = this.newReminder(todo.body, time, insertAt);
parsed.setTime(time);
}
todo.body = parsed.toMarkdown();
return {
insertedLine: todo.toMarkdown(),
caretPosition: todoHeaderLength + parsed.getEndOfTimeTextIndex()
};
}
isStrictDateFormat() {
return this.config.getParameter(ReminderFormatParameterKey.strictDateFormat);
}
};
var CompositeReminderFormat = class {
constructor() {
this.formats = [];
}
setConfig(config) {
this.config = config;
this.syncConfig();
}
parse(doc) {
const reminders = [];
for (const format of this.formats) {
const parsed = format.parse(doc);
if (parsed == null) {
continue;
}
reminders.push(...parsed);
}
return reminders;
}
modify(doc, reminder, edit) {
return __async(this, null, function* () {
for (const format of this.formats) {
const modified = yield format.modify(doc, reminder, edit);
if (modified) {
return true;
}
}
return false;
});
}
resetFormat(formats) {
this.formats = formats;
this.syncConfig();
}
syncConfig() {
if (this.config == null) {
return;
}
this.formats.forEach((f) => f.setConfig(this.config));
}
appendReminder(line, time) {
if (this.formats[0] == null) {
return null;
}
return this.formats[0].appendReminder(line, time);
}
};
// src/model/format/reminder-default.ts
var _DefaultReminderModel = class {
constructor(linkDatesToDailyNotes, title1, time, title2) {
this.linkDatesToDailyNotes = linkDatesToDailyNotes;
this.title1 = title1;
this.time = time;
this.title2 = title2;
}
static parse(line, linkDatesToDailyNotes) {
if (linkDatesToDailyNotes == null) {
linkDatesToDailyNotes = false;
}
const result = _DefaultReminderModel.regexp.exec(line);
if (result == null) {
return null;
}
const title1 = result.groups["title1"];
let time = result.groups["time"];
if (time == null) {
return null;
}
const title2 = result.groups["title2"];
if (linkDatesToDailyNotes) {
time = time.replace("[[", "");
time = time.replace("]]", "");
}
return new _DefaultReminderModel(linkDatesToDailyNotes, title1, time, title2);
}
getTitle() {
return `${this.title1.trim()} ${this.title2.trim()}`.trim();
}
getTime() {
return DATE_TIME_FORMATTER.parse(this.time);
}
setTime(time) {
this.time = DATE_TIME_FORMATTER.toString(time);
}
setRawTime(rawTime) {
this.time = rawTime;
return true;
}
getEndOfTimeTextIndex() {
return this.toMarkdown().length - this.title2.length;
}
toMarkdown() {
let result = `${this.title1}(@${this.time})${this.title2}`;
if (!this.linkDatesToDailyNotes) {
return result;
}
let time = DATE_TIME_FORMATTER.parse(this.time);
if (!time) {
return result;
}
const date = DATE_TIME_FORMATTER.toString(time.clone(false));
return result.replace(date, `[[${date}]]`);
}
};
var DefaultReminderModel = _DefaultReminderModel;
DefaultReminderModel.regexp = new RegExp("^(?<title1>.*?)\\(@(?<time>.+?)\\)(?<title2>.*)$");
var _DefaultReminderFormat = class extends TodoBasedReminderFormat {
parseReminder(todo) {
return DefaultReminderModel.parse(todo.body, this.linkDatesToDailyNotes());
}
newReminder(title, time, insertAt) {
let title1;
let title2;
if (insertAt != null) {
title1 = title.substring(0, insertAt);
title2 = title.substring(insertAt);
} else {
title1 = title;
title2 = "";
}
return new DefaultReminderModel(this.linkDatesToDailyNotes(), title1, time.toString(), title2);
}
linkDatesToDailyNotes() {
return this.config.getParameter(ReminderFormatParameterKey.linkDatesToDailyNotes);
}
};
var DefaultReminderFormat = _DefaultReminderFormat;
DefaultReminderFormat.instance = new _DefaultReminderFormat();
// src/model/format/reminder-kanban-plugin.ts
var import_moment2 = __toESM(require_moment());
// src/model/format/util.ts
function escapeRegExpChars(text2) {
return text2.replace(/[\\^$.*+?()[\]{}|]/g, "\\$&");
}
// src/model/format/reminder-kanban-plugin.ts
var kanbanSetting = new class KanbanSetting {
get dateTrigger() {
return this.get("date-trigger", "@");
}
get dateFormat() {
return this.get("date-format", "YYYY-MM-DD");
}
get timeTrigger() {
return this.get("time-trigger", "@@");
}
get timeFormat() {
return this.get("time-format", "HH:mm");
}
get linkDateToDailyNote() {
return this.get("link-date-to-daily-note", false);
}
get(key, defaultValue) {
var _a, _b;
if (!window) {
return defaultValue;
}
const plugins = (_b = (_a = window == null ? void 0 : window.app) == null ? void 0 : _a.plugins) == null ? void 0 : _b.plugins;
if (!plugins) {
return defaultValue;
}
const plugin = plugins["obsidian-kanban"];
if (!plugin) {
return defaultValue;
}
const settings = plugin.settings;
if (!settings) {
return defaultValue;
}
const value = plugin.settings[key];
if (value === null || value === void 0) {
return defaultValue;
}
return value;
}
}();
var _KanbanDateTimeFormat = class {
constructor(setting) {
this.setting = setting;
let dateRegExpStr;
if (setting.linkDateToDailyNote) {
dateRegExpStr = `${escapeRegExpChars(this.setting.dateTrigger)}\\[\\[(?<date>.+?)\\]\\]`;
} else {
dateRegExpStr = `${escapeRegExpChars(this.setting.dateTrigger)}\\{(?<date>.+?)\\}`;
}
const timeRegExpStr = `${escapeRegExpChars(this.setting.timeTrigger)}\\{(?<time>.+?)\\}`;
this.dateRegExp = new RegExp(dateRegExpStr);
this.timeRegExp = new RegExp(timeRegExpStr);
}
format(time) {
let datePart;
if (this.setting.linkDateToDailyNote) {
datePart = `${this.setting.dateTrigger}[[${time.format(this.setting.dateFormat)}]]`;
} else {
datePart = `${this.setting.dateTrigger}{${time.format(this.setting.dateFormat)}}`;
}
if (!time.hasTimePart) {
return datePart;
}
return `${datePart} ${this.setting.timeTrigger}{${time.format(this.setting.timeFormat)}}`;
}
split(text2, strictDateFormat) {
const originalText = text2;
let title;
let date;
let time;
const dateMatch = this.dateRegExp.exec(text2);
if (dateMatch) {
date = dateMatch.groups["date"];
text2 = text2.replace(this.dateRegExp, "");
} else {
return { title: originalText };
}
const timeMatch = this.timeRegExp.exec(text2);
if (timeMatch) {
time = timeMatch.groups["time"];
text2 = text2.replace(this.timeRegExp, "");
}
title = text2.trim();
let parsedTime;
const strict = strictDateFormat != null ? strictDateFormat : true;
if (time) {
parsedTime = new DateTime((0, import_moment2.default)(`${date} ${time}`, `${this.setting.dateFormat} ${this.setting.timeFormat}`, strict), true);
} else {
parsedTime = new DateTime((0, import_moment2.default)(date, this.setting.dateFormat, strict), false);
}
if (parsedTime.isValid()) {
return { title, time: parsedTime };
}
return { title: originalText };
}
};
var KanbanDateTimeFormat = _KanbanDateTimeFormat;
KanbanDateTimeFormat.instance = new _KanbanDateTimeFormat(kanbanSetting);
var KanbanReminderModel = class {
constructor(title, time) {
this.title = title;
this.time = time;
}
static parse(line, strictDateFormat) {
const splitted = KanbanDateTimeFormat.instance.split(line, strictDateFormat);
if (splitted.time == null) {
return null;
}
return new KanbanReminderModel(splitted.title, splitted.time);
}
getTitle() {
return this.title.trim();
}
getTime() {
if (this.time) {
return this.time;
}
return null;
}
setTime(time) {
this.time = time;
}
setRawTime() {
return false;
}
getEndOfTimeTextIndex() {
return this.toMarkdown().length;
}
toMarkdown() {
return `${this.title.trim()} ${KanbanDateTimeFormat.instance.format(this.time)}`;
}
};
var _KanbanReminderFormat = class extends TodoBasedReminderFormat {
parseReminder(todo) {
return KanbanReminderModel.parse(todo.body, this.isStrictDateFormat());
}
newReminder(title, time) {
const parsed = new KanbanReminderModel(title, time);
parsed.setTime(time);
return parsed;
}
};
var KanbanReminderFormat = _KanbanReminderFormat;
KanbanReminderFormat.instance = new _KanbanReminderFormat();
// src/model/format/reminder-tasks-plugin.ts
var import_moment3 = __toESM(require_moment());
// node_modules/rrule/dist/esm/src/weekday.js
var ALL_WEEKDAYS = ["MO", "TU", "WE", "TH", "FR", "SA", "SU"];
var Weekday = function() {
function Weekday2(weekday, n) {
if (n === 0)
throw new Error("Can't create weekday with n == 0");
this.weekday = weekday;
this.n = n;
}
Weekday2.fromStr = function(str) {
return new Weekday2(ALL_WEEKDAYS.indexOf(str));
};
Weekday2.prototype.nth = function(n) {
return this.n === n ? this : new Weekday2(this.weekday, n);
};
Weekday2.prototype.equals = function(other) {
return this.weekday === other.weekday && this.n === other.n;
};
Weekday2.prototype.toString = function() {
var s = ALL_WEEKDAYS[this.weekday];
if (this.n)
s = (this.n > 0 ? "+" : "") + String(this.n) + s;
return s;
};
Weekday2.prototype.getJsWeekday = function() {
return this.weekday === 6 ? 0 : this.weekday + 1;
};
return Weekday2;
}();
// node_modules/rrule/dist/esm/src/helpers.js
var isPresent = function(value) {
return value !== null && value !== void 0;
};
var isNumber = function(value) {
return typeof value === "number";
};
var isWeekdayStr = function(value) {
return ALL_WEEKDAYS.indexOf(value) >= 0;
};
var isArray = Array.isArray;
var range = function(start, end) {
if (end === void 0) {
end = start;
}
if (arguments.length === 1) {
end = start;
start = 0;
}
var rang = [];
for (var i = start; i < end; i++)
rang.push(i);
return rang;
};
var repeat = function(value, times) {
var i = 0;
var array = [];
if (isArray(value)) {
for (; i < times; i++)
array[i] = [].concat(value);
} else {
for (; i < times; i++)
array[i] = value;
}
return array;
};
var toArray = function(item) {
if (isArray(item)) {
return item;
}
return [item];
};
function padStart(item, targetLength, padString) {
if (padString === void 0) {
padString = " ";
}
var str = String(item);
targetLength = targetLength >> 0;
if (str.length > targetLength) {
return String(str);
}
targetLength = targetLength - str.length;
if (targetLength > padString.length) {
padString += repeat(padString, targetLength / padString.length);
}
return padString.slice(0, targetLength) + String(str);
}
var split = function(str, sep, num) {
var splits = str.split(sep);
return num ? splits.slice(0, num).concat([splits.slice(num).join(sep)]) : splits;
};
var pymod = function(a, b) {
var r = a % b;
return r * b < 0 ? r + b : r;
};
var divmod = function(a, b) {
return { div: Math.floor(a / b), mod: pymod(a, b) };
};
var empty = function(obj) {
return !isPresent(obj) || obj.length === 0;
};
var notEmpty = function(obj) {
return !empty(obj);
};
var includes = function(arr, val) {
return notEmpty(arr) && arr.indexOf(val) !== -1;
};
// node_modules/rrule/dist/esm/src/dateutil.js
var dateutil;
(function(dateutil2) {
dateutil2.MONTH_DAYS = [31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31];
dateutil2.ONE_DAY = 1e3 * 60 * 60 * 24;
dateutil2.MAXYEAR = 9999;
dateutil2.ORDINAL_BASE = new Date(Date.UTC(1970, 0, 1));
dateutil2.PY_WEEKDAYS = [6, 0, 1, 2, 3, 4, 5];
dateutil2.getYearDay = function(date) {
var dateNoTime = new Date(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate());
return Math.ceil((dateNoTime.valueOf() - new Date(date.getUTCFullYear(), 0, 1).valueOf()) / dateutil2.ONE_DAY) + 1;
};
dateutil2.isLeapYear = function(year) {
return year % 4 === 0 && year % 100 !== 0 || year % 400 === 0;
};
dateutil2.isDate = function(value) {
return value instanceof Date;
};
dateutil2.isValidDate = function(value) {
return dateutil2.isDate(value) && !isNaN(value.getTime());
};
dateutil2.tzOffset = function(date) {
return date.getTimezoneOffset() * 60 * 1e3;
};
dateutil2.daysBetween = function(date1, date2) {
var date1ms = date1.getTime() - dateutil2.tzOffset(date1);
var date2ms = date2.getTime() - dateutil2.tzOffset(date2);
var differencems = date1ms - date2ms;
return Math.round(differencems / dateutil2.ONE_DAY);
};
dateutil2.toOrdinal = function(date) {
return dateutil2.daysBetween(date, dateutil2.ORDINAL_BASE);
};
dateutil2.fromOrdinal = function(ordinal) {
return new Date(dateutil2.ORDINAL_BASE.getTime() + ordinal * dateutil2.ONE_DAY);
};
dateutil2.getMonthDays = function(date) {
var month = date.getUTCMonth();
return month === 1 && dateutil2.isLeapYear(date.getUTCFullYear()) ? 29 : dateutil2.MONTH_DAYS[month];
};
dateutil2.getWeekday = function(date) {
return dateutil2.PY_WEEKDAYS[date.getUTCDay()];
};
dateutil2.monthRange = function(year, month) {
var date = new Date(Date.UTC(year, month, 1));
return [dateutil2.getWeekday(date), dateutil2.getMonthDays(date)];
};
dateutil2.combine = function(date, time) {
time = time || date;
return new Date(Date.UTC(date.getUTCFullYear(), date.getUTCMonth(), date.getUTCDate(), time.getHours(), time.getMinutes(), time.getSeconds(), time.getMilliseconds()));
};
dateutil2.clone = function(date) {
var dolly = new Date(date.getTime());
return dolly;
};
dateutil2.cloneDates = function(dates) {
var clones = [];
for (var i = 0; i < dates.length; i++) {
clones.push(dateutil2.clone(dates[i]));
}
return clones;
};
dateutil2.sort = function(dates) {
dates.sort(function(a, b) {
return a.getTime() - b.getTime();
});
};
dateutil2.timeToUntilString = function(time, utc) {
if (utc === void 0) {
utc = true;
}
var date = new Date(time);
return [
padStart(date.getUTCFullYear().toString(), 4, "0"),
padStart(date.getUTCMonth() + 1, 2, "0"),
padStart(date.getUTCDate(), 2, "0"),
"T",
padStart(date.getUTCHours(), 2, "0"),
padStart(date.getUTCMinutes(), 2, "0"),
padStart(date.getUTCSeconds(), 2, "0"),
utc ? "Z" : ""
].join("");
};
dateutil2.untilStringToDate = function(until) {
var re = /^(\d{4})(\d{2})(\d{2})(T(\d{2})(\d{2})(\d{2})Z?)?$/;
var bits = re.exec(until);
if (!bits)
throw new Error("Invalid UNTIL value: " + until);
return new Date(Date.UTC(parseInt(bits[1], 10), parseInt(bits[2], 10) - 1, parseInt(bits[3], 10), parseInt(bits[5], 10) || 0, parseInt(bits[6], 10) || 0, parseInt(bits[7], 10) || 0));
};
})(dateutil || (dateutil = {}));
var dateutil_default = dateutil;
// node_modules/rrule/dist/esm/src/iterresult.js
var IterResult = function() {
function IterResult2(method, args) {
this.minDate = null;
this.maxDate = null;
this._result = [];
this.total = 0;
this.method = method;
this.args = args;
if (method === "between") {
this.maxDate = args.inc ? args.before : new Date(args.before.getTime() - 1);
this.minDate = args.inc ? args.after : new Date(args.after.getTime() + 1);
} else if (method === "before") {
this.maxDate = args.inc ? args.dt : new Date(args.dt.getTime() - 1);
} else if (method === "after") {
this.minDate = args.inc ? args.dt : new Date(args.dt.getTime() + 1);
}
}
IterResult2.prototype.accept = function(date) {
++this.total;
var tooEarly = this.minDate && date < this.minDate;
var tooLate = this.maxDate && date > this.maxDate;
if (this.method === "between") {
if (tooEarly)
return true;
if (tooLate)
return false;
} else if (this.method === "before") {
if (tooLate)
return false;
} else if (this.method === "after") {
if (tooEarly)
return true;
this.add(date);
return false;
}
return this.add(date);
};
IterResult2.prototype.add = function(date) {
this._result.push(date);
return true;
};
IterResult2.prototype.getValue = function() {
var res = this._result;
switch (this.method) {
case "all":
case "between":
return res;
case "before":
case "after":
default:
return res.length ? res[res.length - 1] : null;
}
};
IterResult2.prototype.clone = function() {
return new IterResult2(this.method, this.args);
};
return IterResult2;
}();
var iterresult_default = IterResult;
// node_modules/rrule/node_modules/tslib/modules/index.js
var import_tslib = __toESM(require_tslib(), 1);
var {
__extends,
__assign,
__rest,
__decorate,
__param,
__metadata,
__awaiter,
__generator,
__exportStar,
__createBinding,
__values,
__read,
__spread,
__spreadArrays,
__await,
__asyncGenerator,
__asyncDelegator,
__asyncValues,
__makeTemplateObject,
__importStar,
__importDefault,
__classPrivateFieldGet,
__classPrivateFieldSet
} = import_tslib.default;
// node_modules/rrule/dist/esm/src/callbackiterresult.js
var CallbackIterResult = function(_super) {
__extends(CallbackIterResult2, _super);
function CallbackIterResult2(method, args, iterator) {
var _this = _super.call(this, method, args) || this;
_this.iterator = iterator;
return _this;
}
CallbackIterResult2.prototype.add = function(date) {
if (this.iterator(date, this._result.length)) {
this._result.push(date);
return true;
}
return false;
};
return CallbackIterResult2;
}(iterresult_default);
var callbackiterresult_default = CallbackIterResult;
// node_modules/rrule/dist/esm/src/nlp/i18n.js
var ENGLISH = {
dayNames: [
"Sunday",
"Monday",
"Tuesday",
"Wednesday",
"Thursday",
"Friday",
"Saturday"
],
monthNames: [
"January",
"February",
"March",
"April",
"May",
"June",
"July",
"August",
"September",
"October",
"November",
"December"
],
tokens: {
"SKIP": /^[ \r\n\t]+|^\.$/,
"number": /^[1-9][0-9]*/,
"numberAsText": /^(one|two|three)/i,
"every": /^every/i,
"day(s)": /^days?/i,
"weekday(s)": /^weekdays?/i,
"week(s)": /^weeks?/i,
"hour(s)": /^hours?/i,
"minute(s)": /^minutes?/i,
"month(s)": /^months?/i,
"year(s)": /^years?/i,
"on": /^(on|in)/i,
"at": /^(at)/i,
"the": /^the/i,
"first": /^first/i,
"second": /^second/i,
"third": /^third/i,
"nth": /^([1-9][0-9]*)(\.|th|nd|rd|st)/i,
"last": /^last/i,
"for": /^for/i,
"time(s)": /^times?/i,
"until": /^(un)?til/i,
"monday": /^mo(n(day)?)?/i,
"tuesday": /^tu(e(s(day)?)?)?/i,
"wednesday": /^we(d(n(esday)?)?)?/i,
"thursday": /^th(u(r(sday)?)?)?/i,
"friday": /^fr(i(day)?)?/i,
"saturday": /^sa(t(urday)?)?/i,
"sunday": /^su(n(day)?)?/i,
"january": /^jan(uary)?/i,
"february": /^feb(ruary)?/i,
"march": /^mar(ch)?/i,
"april": /^apr(il)?/i,
"may": /^may/i,
"june": /^june?/i,
"july": /^july?/i,
"august": /^aug(ust)?/i,
"september": /^sep(t(ember)?)?/i,
"october": /^oct(ober)?/i,
"november": /^nov(ember)?/i,
"december": /^dec(ember)?/i,
"comma": /^(,\s*|(and|or)\s*)+/i
}
};
var i18n_default = ENGLISH;
// node_modules/rrule/dist/esm/src/nlp/totext.js
var contains = function(arr, val) {
return arr.indexOf(val) !== -1;
};
var defaultGetText = function(id) {
return id.toString();
};
var defaultDateFormatter = function(year, month, day) {
return month + " " + day + ", " + year;
};
var ToText = function() {
function ToText2(rrule, gettext, language, dateFormatter) {
if (gettext === void 0) {
gettext = defaultGetText;
}
if (language === void 0) {
language = i18n_default;
}
if (dateFormatter === void 0) {
dateFormatter = defaultDateFormatter;
}
this.text = [];
this.language = language || i18n_default;
this.gettext = gettext;
this.dateFormatter = dateFormatter;
this.rrule = rrule;
this.options = rrule.options;
this.origOptions = rrule.origOptions;
if (this.origOptions.bymonthday) {
var bymonthday = [].concat(this.options.bymonthday);
var bynmonthday = [].concat(this.options.bynmonthday);
bymonthday.sort(function(a, b) {
return a - b;
});
bynmonthday.sort(function(a, b) {
return b - a;
});
this.bymonthday = bymonthday.concat(bynmonthday);
if (!this.bymonthday.length)
this.bymonthday = null;
}
if (isPresent(this.origOptions.byweekday)) {
var byweekday = !isArray(this.origOptions.byweekday) ? [this.origOptions.byweekday] : this.origOptions.byweekday;
var days = String(byweekday);
this.byweekday = {
allWeeks: byweekday.filter(function(weekday) {
return !weekday.n;
}),
someWeeks: byweekday.filter(function(weekday) {
return Boolean(weekday.n);
}),
isWeekdays: days.indexOf("MO") !== -1 && days.indexOf("TU") !== -1 && days.indexOf("WE") !== -1 && days.indexOf("TH") !== -1 && days.indexOf("FR") !== -1 && days.indexOf("SA") === -1 && days.indexOf("SU") === -1,
isEveryDay: days.indexOf("MO") !== -1 && days.indexOf("TU") !== -1 && days.indexOf("WE") !== -1 && days.indexOf("TH") !== -1 && days.indexOf("FR") !== -1 && days.indexOf("SA") !== -1 && days.indexOf("SU") !== -1
};
var sortWeekDays = function(a, b) {
return a.weekday - b.weekday;
};
this.byweekday.allWeeks.sort(sortWeekDays);
this.byweekday.someWeeks.sort(sortWeekDays);
if (!this.byweekday.allWeeks.length)
this.byweekday.allWeeks = null;
if (!this.byweekday.someWeeks.length)
this.byweekday.someWeeks = null;
} else {
this.byweekday = null;
}
}
ToText2.isFullyConvertible = function(rrule) {
var canConvert = true;
if (!(rrule.options.freq in ToText2.IMPLEMENTED))
return false;
if (rrule.origOptions.until && rrule.origOptions.count)
return false;
for (var key in rrule.origOptions) {
if (contains(["dtstart", "wkst", "freq"], key))
return true;
if (!contains(ToText2.IMPLEMENTED[rrule.options.freq], key))
return false;
}
return canConvert;
};
ToText2.prototype.isFullyConvertible = function() {
return ToText2.isFullyConvertible(this.rrule);
};
ToText2.prototype.toString = function() {
var gettext = this.gettext;
if (!(this.options.freq in ToText2.IMPLEMENTED)) {
return gettext("RRule error: Unable to fully convert this rrule to text");
}
this.text = [gettext("every")];
this[src_default.FREQUENCIES[this.options.freq]]();
if (this.options.until) {
this.add(gettext("until"));
var until = this.options.until;
this.add(this.dateFormatter(until.getUTCFullYear(), this.language.monthNames[until.getUTCMonth()], until.getUTCDate()));
} else if (this.options.count) {
this.add(gettext("for")).add(this.options.count.toString()).add(this.plural(this.options.count) ? gettext("times") : gettext("time"));
}
if (!this.isFullyConvertible())
this.add(gettext("(~ approximate)"));
return this.text.join("");
};
ToText2.prototype.HOURLY = function() {
var gettext = this.gettext;
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval) ? gettext("hours") : gettext("hour"));
};
ToText2.prototype.MINUTELY = function() {
var gettext = this.gettext;
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval) ? gettext("minutes") : gettext("minute"));
};
ToText2.prototype.DAILY = function() {
var gettext = this.gettext;
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
if (this.byweekday && this.byweekday.isWeekdays) {
this.add(this.plural(this.options.interval) ? gettext("weekdays") : gettext("weekday"));
} else {
this.add(this.plural(this.options.interval) ? gettext("days") : gettext("day"));
}
if (this.origOptions.bymonth) {
this.add(gettext("in"));
this._bymonth();
}
if (this.bymonthday) {
this._bymonthday();
} else if (this.byweekday) {
this._byweekday();
} else if (this.origOptions.byhour) {
this._byhour();
}
};
ToText2.prototype.WEEKLY = function() {
var gettext = this.gettext;
if (this.options.interval !== 1) {
this.add(this.options.interval.toString()).add(this.plural(this.options.interval) ? gettext("weeks") : gettext("week"));
}
if (this.byweekday && this.byweekday.isWeekdays) {
if (this.options.interval === 1) {
this.add(this.plural(this.options.interval) ? gettext("weekdays") : gettext("weekday"));
} else {
this.add(gettext("on")).add(gettext("weekdays"));
}
} else if (this.byweekday && this.byweekday.isEveryDay) {
this.add(this.plural(this.options.interval) ? gettext("days") : gettext("day"));
} else {
if (this.options.interval === 1)
this.add(gettext("week"));
if (this.origOptions.bymonth) {
this.add(gettext("in"));
this._bymonth();
}
if (this.bymonthday) {
this._bymonthday();
} else if (this.byweekday) {
this._byweekday();
}
}
};
ToText2.prototype.MONTHLY = function() {
var gettext = this.gettext;
if (this.origOptions.bymonth) {
if (this.options.interval !== 1) {
this.add(this.options.interval.toString()).add(gettext("months"));
if (this.plural(this.options.interval))
this.add(gettext("in"));
} else {
}
this._bymonth();
} else {
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval) ? gettext("months") : gettext("month"));
}
if (this.bymonthday) {
this._bymonthday();
} else if (this.byweekday && this.byweekday.isWeekdays) {
this.add(gettext("on")).add(gettext("weekdays"));
} else if (this.byweekday) {
this._byweekday();
}
};
ToText2.prototype.YEARLY = function() {
var gettext = this.gettext;
if (this.origOptions.bymonth) {
if (this.options.interval !== 1) {
this.add(this.options.interval.toString());
this.add(gettext("years"));
} else {
}
this._bymonth();
} else {
if (this.options.interval !== 1)
this.add(this.options.interval.toString());
this.add(this.plural(this.options.interval) ? gettext("years") : gettext("year"));
}
if (this.bymonthday) {
this._bymonthday();
} else if (this.byweekday) {
this._byweekday();
}
if (this.options.byyearday) {
this.add(gettext("on the")).add(this.list(this.options.byyearday, this.nth, gettext("and"))).add(gettext("day"));
}
if (this.options.byweekno) {
this.add(gettext("in")).add(this.plural(this.options.byweekno.length) ? gettext("weeks") : gettext("week")).add(this.list(this.options.byweekno, void 0, gettext("and")));
}
};
ToText2.prototype._bymonthday = function() {
var gettext = this.gettext;
if (this.byweekday && this.byweekday.allWeeks) {
this.add(gettext("on")).add(this.list(this.byweekday.allWeeks, this.weekdaytext, gettext("or"))).add(gettext("the")).add(this.list(this.bymonthday, this.nth, gettext("or")));
} else {
this.add(gettext("on the")).add(this.list(this.bymonthday, this.nth, gettext("and")));
}
};
ToText2.prototype._byweekday = function() {
var gettext = this.gettext;
if (this.byweekday.allWeeks && !this.byweekday.isWeekdays) {
this.add(gettext("on")).add(this.list(this.byweekday.allWeeks, this.weekdaytext));
}
if (this.byweekday.someWeeks) {
if (this.byweekday.allWeeks)
this.add(gettext("and"));
this.add(gettext("on the")).add(this.list(this.byweekday.someWeeks, this.weekdaytext, gettext("and")));
}
};
ToText2.prototype._byhour = function() {
var gettext = this.gettext;
this.add(gettext("at")).add(this.list(this.origOptions.byhour, void 0, gettext("and")));
};
ToText2.prototype._bymonth = function() {
this.add(this.list(this.options.bymonth, this.monthtext, this.gettext("and")));
};
ToText2.prototype.nth = function(n) {
n = parseInt(n.toString(), 10);
var nth;
var npos;
var gettext = this.gettext;
if (n === -1)
return gettext("last");
npos = Math.abs(n);
switch (npos) {
case 1:
case 21:
case 31:
nth = npos + gettext("st");
break;
case 2:
case 22:
nth = npos + gettext("nd");
break;
case 3:
case 23:
nth = npos + gettext("rd");
break;
default:
nth = npos + gettext("th");
}
return n < 0 ? nth + " " + gettext("last") : nth;
};
ToText2.prototype.monthtext = function(m) {
return this.language.monthNames[m - 1];
};
ToText2.prototype.weekdaytext = function(wday) {
var weekday = isNumber(wday) ? (wday + 1) % 7 : wday.getJsWeekday();
return (wday.n ? this.nth(wday.n) + " " : "") + this.language.dayNames[weekday];
};
ToText2.prototype.plural = function(n) {
return n % 100 !== 1;
};
ToText2.prototype.add = function(s) {
this.text.push(" ");
this.text.push(s);
return this;
};
ToText2.prototype.list = function(arr, callback, finalDelim, delim) {
if (delim === void 0) {
delim = ",";
}
if (!isArray(arr)) {
arr = [arr];
}
var delimJoin = function(array, delimiter, finalDelimiter) {
var list = "";
for (var i = 0; i < array.length; i++) {
if (i !== 0) {
if (i === array.length - 1) {
list += " " + finalDelimiter + " ";
} else {
list += delimiter + " ";
}
}
list += array[i];
}
return list;
};
callback = callback || function(o) {
return o.toString();
};
var self2 = this;
var realCallback = function(arg) {
return callback && callback.call(self2, arg);
};
if (finalDelim) {
return delimJoin(arr.map(realCallback), delim, finalDelim);
} else {
return arr.map(realCallback).join(delim + " ");
}
};
return ToText2;
}();
var totext_default = ToText;
// node_modules/rrule/dist/esm/src/nlp/parsetext.js
var Parser = function() {
function Parser2(rules) {
this.done = true;
this.rules = rules;
}
Parser2.prototype.start = function(text2) {
this.text = text2;
this.done = false;
return this.nextSymbol();
};
Parser2.prototype.isDone = function() {
return this.done && this.symbol === null;
};
Parser2.prototype.nextSymbol = function() {
var best;
var bestSymbol;
var p = this;
this.symbol = null;
this.value = null;
do {
if (this.done)
return false;
var rule = void 0;
best = null;
for (var name_1 in this.rules) {
rule = this.rules[name_1];
var match = rule.exec(p.text);
if (match) {
if (best === null || match[0].length > best[0].length) {
best = match;
bestSymbol = name_1;
}
}
}
if (best != null) {
this.text = this.text.substr(best[0].length);
if (this.text === "")
this.done = true;
}
if (best == null) {
this.done = true;
this.symbol = null;
this.value = null;
return;
}
} while (bestSymbol === "SKIP");
this.symbol = bestSymbol;
this.value = best;
return true;
};
Parser2.prototype.accept = function(name) {
if (this.symbol === name) {
if (this.value) {
var v = this.value;
this.nextSymbol();
return v;
}
this.nextSymbol();
return true;
}
return false;
};
Parser2.prototype.acceptNumber = function() {
return this.accept("number");
};
Parser2.prototype.expect = function(name) {
if (this.accept(name))
return true;
throw new Error("expected " + name + " but found " + this.symbol);
};
return Parser2;
}();
function parseText(text2, language) {
if (language === void 0) {
language = i18n_default;
}
var options = {};
var ttr = new Parser(language.tokens);
if (!ttr.start(text2))
return null;
S();
return options;
function S() {
ttr.expect("every");
var n = ttr.acceptNumber();
if (n)
options.interval = parseInt(n[0], 10);
if (ttr.isDone())
throw new Error("Unexpected end");
switch (ttr.symbol) {
case "day(s)":
options.freq = src_default.DAILY;
if (ttr.nextSymbol()) {
AT();
F();
}
break;
case "weekday(s)":
options.freq = src_default.WEEKLY;
options.byweekday = [
src_default.MO,
src_default.TU,
src_default.WE,
src_default.TH,
src_default.FR
];
ttr.nextSymbol();
F();
break;
case "week(s)":
options.freq = src_default.WEEKLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case "hour(s)":
options.freq = src_default.HOURLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case "minute(s)":
options.freq = src_default.MINUTELY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case "month(s)":
options.freq = src_default.MONTHLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case "year(s)":
options.freq = src_default.YEARLY;
if (ttr.nextSymbol()) {
ON();
F();
}
break;
case "monday":
case "tuesday":
case "wednesday":
case "thursday":
case "friday":
case "saturday":
case "sunday":
options.freq = src_default.WEEKLY;
var key = ttr.symbol.substr(0, 2).toUpperCase();
options.byweekday = [src_default[key]];
if (!ttr.nextSymbol())
return;
while (ttr.accept("comma")) {
if (ttr.isDone())
throw new Error("Unexpected end");
var wkd = decodeWKD();
if (!wkd) {
throw new Error("Unexpected symbol " + ttr.symbol + ", expected weekday");
}
options.byweekday.push(src_default[wkd]);
ttr.nextSymbol();
}
MDAYs();
F();
break;
case "january":
case "february":
case "march":
case "april":
case "may":
case "june":
case "july":
case "august":
case "september":
case "october":
case "november":
case "december":
options.freq = src_default.YEARLY;
options.bymonth = [decodeM()];
if (!ttr.nextSymbol())
return;
while (ttr.accept("comma")) {
if (ttr.isDone())
throw new Error("Unexpected end");
var m = decodeM();
if (!m) {
throw new Error("Unexpected symbol " + ttr.symbol + ", expected month");
}
options.bymonth.push(m);
ttr.nextSymbol();
}
ON();
F();
break;
default:
throw new Error("Unknown symbol");
}
}
function ON() {
var on = ttr.accept("on");
var the = ttr.accept("the");
if (!(on || the))
return;
do {
var nth = decodeNTH();
var wkd = decodeWKD();
var m = decodeM();
if (nth) {
if (wkd) {
ttr.nextSymbol();
if (!options.byweekday)
options.byweekday = [];
options.byweekday.push(src_default[wkd].nth(nth));
} else {
if (!options.bymonthday)
options.bymonthday = [];
options.bymonthday.push(nth);
ttr.accept("day(s)");
}
} else if (wkd) {
ttr.nextSymbol();
if (!options.byweekday)
options.byweekday = [];
options.byweekday.push(src_default[wkd]);
} else if (ttr.symbol === "weekday(s)") {
ttr.nextSymbol();
if (!options.byweekday) {
options.byweekday = [
src_default.MO,
src_default.TU,
src_default.WE,
src_default.TH,
src_default.FR
];
}
} else if (ttr.symbol === "week(s)") {
ttr.nextSymbol();
var n = ttr.acceptNumber();
if (!n) {
throw new Error("Unexpected symbol " + ttr.symbol + ", expected week number");
}
options.byweekno = [parseInt(n[0], 10)];
while (ttr.accept("comma")) {
n = ttr.acceptNumber();
if (!n) {
throw new Error("Unexpected symbol " + ttr.symbol + "; expected monthday");
}
options.byweekno.push(parseInt(n[0], 10));
}
} else if (m) {
ttr.nextSymbol();
if (!options.bymonth)
options.bymonth = [];
options.bymonth.push(m);
} else {
return;
}
} while (ttr.accept("comma") || ttr.accept("the") || ttr.accept("on"));
}
function AT() {
var at = ttr.accept("at");
if (!at)
return;
do {
var n = ttr.acceptNumber();
if (!n) {
throw new Error("Unexpected symbol " + ttr.symbol + ", expected hour");
}
options.byhour = [parseInt(n[0], 10)];
while (ttr.accept("comma")) {
n = ttr.acceptNumber();
if (!n) {
throw new Error("Unexpected symbol " + ttr.symbol + "; expected hour");
}
options.byhour.push(parseInt(n[0], 10));
}
} while (ttr.accept("comma") || ttr.accept("at"));
}
function decodeM() {
switch (ttr.symbol) {
case "january":
return 1;
case "february":
return 2;
case "march":
return 3;
case "april":
return 4;
case "may":
return 5;
case "june":
return 6;
case "july":
return 7;
case "august":
return 8;
case "september":
return 9;
case "october":
return 10;
case "november":
return 11;
case "december":
return 12;
default:
return false;
}
}
function decodeWKD() {
switch (ttr.symbol) {
case "monday":
case "tuesday":
case "wednesday":
case "thursday":
case "friday":
case "saturday":
case "sunday":
return ttr.symbol.substr(0, 2).toUpperCase();
default:
return false;
}
}
function decodeNTH() {
switch (ttr.symbol) {
case "last":
ttr.nextSymbol();
return -1;
case "first":
ttr.nextSymbol();
return 1;
case "second":
ttr.nextSymbol();
return ttr.accept("last") ? -2 : 2;
case "third":
ttr.nextSymbol();
return ttr.accept("last") ? -3 : 3;
case "nth":
var v = parseInt(ttr.value[1], 10);
if (v < -366 || v > 366)
throw new Error("Nth out of range: " + v);
ttr.nextSymbol();
return ttr.accept("last") ? -v : v;
default:
return false;
}
}
function MDAYs() {
ttr.accept("on");
ttr.accept("the");
var nth = decodeNTH();
if (!nth)
return;
options.bymonthday = [nth];
ttr.nextSymbol();
while (ttr.accept("comma")) {
nth = decodeNTH();
if (!nth) {
throw new Error("Unexpected symbol " + ttr.symbol + "; expected monthday");
}
options.bymonthday.push(nth);
ttr.nextSymbol();
}
}
function F() {
if (ttr.symbol === "until") {
var date = Date.parse(ttr.text);
if (!date)
throw new Error("Cannot parse until date:" + ttr.text);
options.until = new Date(date);
} else if (ttr.accept("for")) {
options.count = parseInt(ttr.value[0], 10);
ttr.expect("number");
}
}
}
// node_modules/rrule/dist/esm/src/types.js
var Frequency;
(function(Frequency2) {
Frequency2[Frequency2["YEARLY"] = 0] = "YEARLY";
Frequency2[Frequency2["MONTHLY"] = 1] = "MONTHLY";
Frequency2[Frequency2["WEEKLY"] = 2] = "WEEKLY";
Frequency2[Frequency2["DAILY"] = 3] = "DAILY";
Frequency2[Frequency2["HOURLY"] = 4] = "HOURLY";
Frequency2[Frequency2["MINUTELY"] = 5] = "MINUTELY";
Frequency2[Frequency2["SECONDLY"] = 6] = "SECONDLY";
})(Frequency || (Frequency = {}));
function freqIsDailyOrGreater(freq) {
return freq < Frequency.HOURLY;
}
// node_modules/rrule/dist/esm/src/nlp/index.js
var fromText = function(text2, language) {
if (language === void 0) {
language = i18n_default;
}
return new src_default(parseText(text2, language) || void 0);
};
var common = [
"count",
"until",
"interval",
"byweekday",
"bymonthday",
"bymonth"
];
totext_default.IMPLEMENTED = [];
totext_default.IMPLEMENTED[Frequency.HOURLY] = common;
totext_default.IMPLEMENTED[Frequency.MINUTELY] = common;
totext_default.IMPLEMENTED[Frequency.DAILY] = ["byhour"].concat(common);
totext_default.IMPLEMENTED[Frequency.WEEKLY] = common;
totext_default.IMPLEMENTED[Frequency.MONTHLY] = common;
totext_default.IMPLEMENTED[Frequency.YEARLY] = ["byweekno", "byyearday"].concat(common);
var toText = function(rrule, gettext, language, dateFormatter) {
return new totext_default(rrule, gettext, language, dateFormatter).toString();
};
var isFullyConvertible = totext_default.isFullyConvertible;
// node_modules/rrule/dist/esm/src/datetime.js
var Time3 = function() {
function Time5(hour, minute, second, millisecond) {
this.hour = hour;
this.minute = minute;
this.second = second;
this.millisecond = millisecond || 0;
}
Time5.prototype.getHours = function() {
return this.hour;
};
Time5.prototype.getMinutes = function() {
return this.minute;
};
Time5.prototype.getSeconds = function() {
return this.second;
};
Time5.prototype.getMilliseconds = function() {
return this.millisecond;
};
Time5.prototype.getTime = function() {
return (this.hour * 60 * 60 + this.minute * 60 + this.second) * 1e3 + this.millisecond;
};
return Time5;
}();
var DateTime3 = function(_super) {
__extends(DateTime5, _super);
function DateTime5(year, month, day, hour, minute, second, millisecond) {
var _this = _super.call(this, hour, minute, second, millisecond) || this;
_this.year = year;
_this.month = month;
_this.day = day;
return _this;
}
DateTime5.fromDate = function(date) {
return new this(date.getUTCFullYear(), date.getUTCMonth() + 1, date.getUTCDate(), date.getUTCHours(), date.getUTCMinutes(), date.getUTCSeconds(), date.valueOf() % 1e3);
};
DateTime5.prototype.getWeekday = function() {
return dateutil.getWeekday(new Date(this.getTime()));
};
DateTime5.prototype.getTime = function() {
return new Date(Date.UTC(this.year, this.month - 1, this.day, this.hour, this.minute, this.second, this.millisecond)).getTime();
};
DateTime5.prototype.getDay = function() {
return this.day;
};
DateTime5.prototype.getMonth = function() {
return this.month;
};
DateTime5.prototype.getYear = function() {
return this.year;
};
DateTime5.prototype.addYears = function(years) {
this.year += years;
};
DateTime5.prototype.addMonths = function(months) {
this.month += months;
if (this.month > 12) {
var yearDiv = Math.floor(this.month / 12);
var monthMod = pymod(this.month, 12);
this.month = monthMod;
this.year += yearDiv;
if (this.month === 0) {
this.month = 12;
--this.year;
}
}
};
DateTime5.prototype.addWeekly = function(days, wkst) {
if (wkst > this.getWeekday()) {
this.day += -(this.getWeekday() + 1 + (6 - wkst)) + days * 7;
} else {
this.day += -(this.getWeekday() - wkst) + days * 7;
}
this.fixDay();
};
DateTime5.prototype.addDaily = function(days) {
this.day += days;
this.fixDay();
};
DateTime5.prototype.addHours = function(hours, filtered, byhour) {
if (filtered) {
this.hour += Math.floor((23 - this.hour) / hours) * hours;
}
while (true) {
this.hour += hours;
var _a = divmod(this.hour, 24), dayDiv = _a.div, hourMod = _a.mod;
if (dayDiv) {
this.hour = hourMod;
this.addDaily(dayDiv);
}
if (empty(byhour) || includes(byhour, this.hour))
break;
}
};
DateTime5.prototype.addMinutes = function(minutes, filtered, byhour, byminute) {
if (filtered) {
this.minute += Math.floor((1439 - (this.hour * 60 + this.minute)) / minutes) * minutes;
}
while (true) {
this.minute += minutes;
var _a = divmod(this.minute, 60), hourDiv = _a.div, minuteMod = _a.mod;
if (hourDiv) {
this.minute = minuteMod;
this.addHours(hourDiv, false, byhour);
}
if ((empty(byhour) || includes(byhour, this.hour)) && (empty(byminute) || includes(byminute, this.minute))) {
break;
}
}
};
DateTime5.prototype.addSeconds = function(seconds, filtered, byhour, byminute, bysecond) {
if (filtered) {
this.second += Math.floor((86399 - (this.hour * 3600 + this.minute * 60 + this.second)) / seconds) * seconds;
}
while (true) {
this.second += seconds;
var _a = divmod(this.second, 60), minuteDiv = _a.div, secondMod = _a.mod;
if (minuteDiv) {
this.second = secondMod;
this.addMinutes(minuteDiv, false, byhour, byminute);
}
if ((empty(byhour) || includes(byhour, this.hour)) && (empty(byminute) || includes(byminute, this.minute)) && (empty(bysecond) || includes(bysecond, this.second))) {
break;
}
}
};
DateTime5.prototype.fixDay = function() {
if (this.day <= 28) {
return;
}
var daysinmonth = dateutil.monthRange(this.year, this.month - 1)[1];
if (this.day <= daysinmonth) {
return;
}
while (this.day > daysinmonth) {
this.day -= daysinmonth;
++this.month;
if (this.month === 13) {
this.month = 1;
++this.year;
if (this.year > dateutil.MAXYEAR) {
return;
}
}
daysinmonth = dateutil.monthRange(this.year, this.month - 1)[1];
}
};
DateTime5.prototype.add = function(options, filtered) {
var freq = options.freq, interval = options.interval, wkst = options.wkst, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
switch (freq) {
case Frequency.YEARLY:
return this.addYears(interval);
case Frequency.MONTHLY:
return this.addMonths(interval);
case Frequency.WEEKLY:
return this.addWeekly(interval, wkst);
case Frequency.DAILY:
return this.addDaily(interval);
case Frequency.HOURLY:
return this.addHours(interval, filtered, byhour);
case Frequency.MINUTELY:
return this.addMinutes(interval, filtered, byhour, byminute);
case Frequency.SECONDLY:
return this.addSeconds(interval, filtered, byhour, byminute, bysecond);
}
};
return DateTime5;
}(Time3);
// node_modules/rrule/dist/esm/src/parseoptions.js
function initializeOptions(options) {
var invalid = [];
var keys = Object.keys(options);
for (var _i = 0, keys_1 = keys; _i < keys_1.length; _i++) {
var key = keys_1[_i];
if (!includes(defaultKeys, key))
invalid.push(key);
if (dateutil_default.isDate(options[key]) && !dateutil_default.isValidDate(options[key]))
invalid.push(key);
}
if (invalid.length) {
throw new Error("Invalid options: " + invalid.join(", "));
}
return __assign({}, options);
}
function parseOptions(options) {
var opts = __assign(__assign({}, DEFAULT_OPTIONS), initializeOptions(options));
if (isPresent(opts.byeaster))
opts.freq = rrule_default.YEARLY;
if (!(isPresent(opts.freq) && rrule_default.FREQUENCIES[opts.freq])) {
throw new Error("Invalid frequency: " + opts.freq + " " + options.freq);
}
if (!opts.dtstart)
opts.dtstart = new Date(new Date().setMilliseconds(0));
if (!isPresent(opts.wkst)) {
opts.wkst = rrule_default.MO.weekday;
} else if (isNumber(opts.wkst)) {
} else {
opts.wkst = opts.wkst.weekday;
}
if (isPresent(opts.bysetpos)) {
if (isNumber(opts.bysetpos))
opts.bysetpos = [opts.bysetpos];
for (var i = 0; i < opts.bysetpos.length; i++) {
var v = opts.bysetpos[i];
if (v === 0 || !(v >= -366 && v <= 366)) {
throw new Error("bysetpos must be between 1 and 366, or between -366 and -1");
}
}
}
if (!(Boolean(opts.byweekno) || notEmpty(opts.byweekno) || notEmpty(opts.byyearday) || Boolean(opts.bymonthday) || notEmpty(opts.bymonthday) || isPresent(opts.byweekday) || isPresent(opts.byeaster))) {
switch (opts.freq) {
case rrule_default.YEARLY:
if (!opts.bymonth)
opts.bymonth = opts.dtstart.getUTCMonth() + 1;
opts.bymonthday = opts.dtstart.getUTCDate();
break;
case rrule_default.MONTHLY:
opts.bymonthday = opts.dtstart.getUTCDate();
break;
case rrule_default.WEEKLY:
opts.byweekday = [dateutil_default.getWeekday(opts.dtstart)];
break;
}
}
if (isPresent(opts.bymonth) && !isArray(opts.bymonth)) {
opts.bymonth = [opts.bymonth];
}
if (isPresent(opts.byyearday) && !isArray(opts.byyearday) && isNumber(opts.byyearday)) {
opts.byyearday = [opts.byyearday];
}
if (!isPresent(opts.bymonthday)) {
opts.bymonthday = [];
opts.bynmonthday = [];
} else if (isArray(opts.bymonthday)) {
var bymonthday = [];
var bynmonthday = [];
for (var i = 0; i < opts.bymonthday.length; i++) {
var v = opts.bymonthday[i];
if (v > 0) {
bymonthday.push(v);
} else if (v < 0) {
bynmonthday.push(v);
}
}
opts.bymonthday = bymonthday;
opts.bynmonthday = bynmonthday;
} else if (opts.bymonthday < 0) {
opts.bynmonthday = [opts.bymonthday];
opts.bymonthday = [];
} else {
opts.bynmonthday = [];
opts.bymonthday = [opts.bymonthday];
}
if (isPresent(opts.byweekno) && !isArray(opts.byweekno)) {
opts.byweekno = [opts.byweekno];
}
if (!isPresent(opts.byweekday)) {
opts.bynweekday = null;
} else if (isNumber(opts.byweekday)) {
opts.byweekday = [opts.byweekday];
opts.bynweekday = null;
} else if (isWeekdayStr(opts.byweekday)) {
opts.byweekday = [Weekday.fromStr(opts.byweekday).weekday];
opts.bynweekday = null;
} else if (opts.byweekday instanceof Weekday) {
if (!opts.byweekday.n || opts.freq > rrule_default.MONTHLY) {
opts.byweekday = [opts.byweekday.weekday];
opts.bynweekday = null;
} else {
opts.bynweekday = [[opts.byweekday.weekday, opts.byweekday.n]];
opts.byweekday = null;
}
} else {
var byweekday = [];
var bynweekday = [];
for (var i = 0; i < opts.byweekday.length; i++) {
var wday = opts.byweekday[i];
if (isNumber(wday)) {
byweekday.push(wday);
continue;
} else if (isWeekdayStr(wday)) {
byweekday.push(Weekday.fromStr(wday).weekday);
continue;
}
if (!wday.n || opts.freq > rrule_default.MONTHLY) {
byweekday.push(wday.weekday);
} else {
bynweekday.push([wday.weekday, wday.n]);
}
}
opts.byweekday = notEmpty(byweekday) ? byweekday : null;
opts.bynweekday = notEmpty(bynweekday) ? bynweekday : null;
}
if (!isPresent(opts.byhour)) {
opts.byhour = opts.freq < rrule_default.HOURLY ? [opts.dtstart.getUTCHours()] : null;
} else if (isNumber(opts.byhour)) {
opts.byhour = [opts.byhour];
}
if (!isPresent(opts.byminute)) {
opts.byminute = opts.freq < rrule_default.MINUTELY ? [opts.dtstart.getUTCMinutes()] : null;
} else if (isNumber(opts.byminute)) {
opts.byminute = [opts.byminute];
}
if (!isPresent(opts.bysecond)) {
opts.bysecond = opts.freq < rrule_default.SECONDLY ? [opts.dtstart.getUTCSeconds()] : null;
} else if (isNumber(opts.bysecond)) {
opts.bysecond = [opts.bysecond];
}
return { parsedOptions: opts };
}
function buildTimeset(opts) {
var millisecondModulo = opts.dtstart.getTime() % 1e3;
if (!freqIsDailyOrGreater(opts.freq)) {
return [];
}
var timeset = [];
opts.byhour.forEach(function(hour) {
opts.byminute.forEach(function(minute) {
opts.bysecond.forEach(function(second) {
timeset.push(new Time3(hour, minute, second, millisecondModulo));
});
});
});
return timeset;
}
// node_modules/rrule/dist/esm/src/parsestring.js
function parseString(rfcString) {
var options = rfcString.split("\n").map(parseLine).filter(function(x) {
return x !== null;
});
return __assign(__assign({}, options[0]), options[1]);
}
function parseDtstart(line) {
var options = {};
var dtstartWithZone = /DTSTART(?:;TZID=([^:=]+?))?(?::|=)([^;\s]+)/i.exec(line);
if (!dtstartWithZone) {
return options;
}
var _ = dtstartWithZone[0], tzid = dtstartWithZone[1], dtstart = dtstartWithZone[2];
if (tzid) {
options.tzid = tzid;
}
options.dtstart = dateutil_default.untilStringToDate(dtstart);
return options;
}
function parseLine(rfcString) {
rfcString = rfcString.replace(/^\s+|\s+$/, "");
if (!rfcString.length)
return null;
var header = /^([A-Z]+?)[:;]/.exec(rfcString.toUpperCase());
if (!header) {
return parseRrule(rfcString);
}
var _ = header[0], key = header[1];
switch (key.toUpperCase()) {
case "RRULE":
case "EXRULE":
return parseRrule(rfcString);
case "DTSTART":
return parseDtstart(rfcString);
default:
throw new Error("Unsupported RFC prop " + key + " in " + rfcString);
}
}
function parseRrule(line) {
var strippedLine = line.replace(/^RRULE:/i, "");
var options = parseDtstart(strippedLine);
var attrs = line.replace(/^(?:RRULE|EXRULE):/i, "").split(";");
attrs.forEach(function(attr2) {
var _a = attr2.split("="), key = _a[0], value = _a[1];
switch (key.toUpperCase()) {
case "FREQ":
options.freq = Frequency[value.toUpperCase()];
break;
case "WKST":
options.wkst = Days[value.toUpperCase()];
break;
case "COUNT":
case "INTERVAL":
case "BYSETPOS":
case "BYMONTH":
case "BYMONTHDAY":
case "BYYEARDAY":
case "BYWEEKNO":
case "BYHOUR":
case "BYMINUTE":
case "BYSECOND":
var num = parseNumber(value);
var optionKey = key.toLowerCase();
options[optionKey] = num;
break;
case "BYWEEKDAY":
case "BYDAY":
options.byweekday = parseWeekday(value);
break;
case "DTSTART":
case "TZID":
var dtstart = parseDtstart(line);
options.tzid = dtstart.tzid;
options.dtstart = dtstart.dtstart;
break;
case "UNTIL":
options.until = dateutil_default.untilStringToDate(value);
break;
case "BYEASTER":
options.byeaster = Number(value);
break;
default:
throw new Error("Unknown RRULE property '" + key + "'");
}
});
return options;
}
function parseNumber(value) {
if (value.indexOf(",") !== -1) {
var values = value.split(",");
return values.map(parseIndividualNumber);
}
return parseIndividualNumber(value);
}
function parseIndividualNumber(value) {
if (/^[+-]?\d+$/.test(value)) {
return Number(value);
}
return value;
}
function parseWeekday(value) {
var days = value.split(",");
return days.map(function(day) {
if (day.length === 2) {
return Days[day];
}
var parts = day.match(/^([+-]?\d{1,2})([A-Z]{2})$/);
var n = Number(parts[1]);
var wdaypart = parts[2];
var wday = Days[wdaypart].weekday;
return new Weekday(wday, n);
});
}
// node_modules/rrule/dist/esm/src/datewithzone.js
var import_luxon = __toESM(require_luxon());
var DateWithZone = function() {
function DateWithZone2(date, tzid) {
this.date = date;
this.tzid = tzid;
}
Object.defineProperty(DateWithZone2.prototype, "isUTC", {
get: function() {
return !this.tzid || this.tzid.toUpperCase() === "UTC";
},
enumerable: true,
configurable: true
});
DateWithZone2.prototype.toString = function() {
var datestr = dateutil_default.timeToUntilString(this.date.getTime(), this.isUTC);
if (!this.isUTC) {
return ";TZID=" + this.tzid + ":" + datestr;
}
return ":" + datestr;
};
DateWithZone2.prototype.getTime = function() {
return this.date.getTime();
};
DateWithZone2.prototype.rezonedDate = function() {
if (this.isUTC) {
return this.date;
}
try {
var datetime = import_luxon.DateTime.fromJSDate(this.date);
var rezoned = datetime.setZone(this.tzid, { keepLocalTime: true });
return rezoned.toJSDate();
} catch (e) {
if (e instanceof TypeError) {
console.error("Using TZID without Luxon available is unsupported. Returned times are in UTC, not the requested time zone");
}
return this.date;
}
};
return DateWithZone2;
}();
// node_modules/rrule/dist/esm/src/optionstostring.js
function optionsToString(options) {
var rrule = [];
var dtstart = "";
var keys = Object.keys(options);
var defaultKeys2 = Object.keys(DEFAULT_OPTIONS);
for (var i = 0; i < keys.length; i++) {
if (keys[i] === "tzid")
continue;
if (!includes(defaultKeys2, keys[i]))
continue;
var key = keys[i].toUpperCase();
var value = options[keys[i]];
var outValue = "";
if (!isPresent(value) || isArray(value) && !value.length)
continue;
switch (key) {
case "FREQ":
outValue = rrule_default.FREQUENCIES[options.freq];
break;
case "WKST":
if (isNumber(value)) {
outValue = new Weekday(value).toString();
} else {
outValue = value.toString();
}
break;
case "BYWEEKDAY":
key = "BYDAY";
outValue = toArray(value).map(function(wday) {
if (wday instanceof Weekday) {
return wday;
}
if (isArray(wday)) {
return new Weekday(wday[0], wday[1]);
}
return new Weekday(wday);
}).toString();
break;
case "DTSTART":
dtstart = buildDtstart(value, options.tzid);
break;
case "UNTIL":
outValue = dateutil_default.timeToUntilString(value, !options.tzid);
break;
default:
if (isArray(value)) {
var strValues = [];
for (var j = 0; j < value.length; j++) {
strValues[j] = String(value[j]);
}
outValue = strValues.toString();
} else {
outValue = String(value);
}
}
if (outValue) {
rrule.push([key, outValue]);
}
}
var rules = rrule.map(function(_a) {
var key2 = _a[0], value2 = _a[1];
return key2 + "=" + value2.toString();
}).join(";");
var ruleString = "";
if (rules !== "") {
ruleString = "RRULE:" + rules;
}
return [dtstart, ruleString].filter(function(x) {
return !!x;
}).join("\n");
}
function buildDtstart(dtstart, tzid) {
if (!dtstart) {
return "";
}
return "DTSTART" + new DateWithZone(new Date(dtstart), tzid).toString();
}
// node_modules/rrule/dist/esm/src/cache.js
var Cache = function() {
function Cache2() {
this.all = false;
this.before = [];
this.after = [];
this.between = [];
}
Cache2.prototype._cacheAdd = function(what, value, args) {
if (value) {
value = value instanceof Date ? dateutil_default.clone(value) : dateutil_default.cloneDates(value);
}
if (what === "all") {
this.all = value;
} else {
args._value = value;
this[what].push(args);
}
};
Cache2.prototype._cacheGet = function(what, args) {
var cached = false;
var argsKeys = args ? Object.keys(args) : [];
var findCacheDiff = function(item2) {
for (var i2 = 0; i2 < argsKeys.length; i2++) {
var key = argsKeys[i2];
if (String(args[key]) !== String(item2[key])) {
return true;
}
}
return false;
};
var cachedObject = this[what];
if (what === "all") {
cached = this.all;
} else if (isArray(cachedObject)) {
for (var i = 0; i < cachedObject.length; i++) {
var item = cachedObject[i];
if (argsKeys.length && findCacheDiff(item))
continue;
cached = item._value;
break;
}
}
if (!cached && this.all) {
var iterResult = new iterresult_default(what, args);
for (var i = 0; i < this.all.length; i++) {
if (!iterResult.accept(this.all[i]))
break;
}
cached = iterResult.getValue();
this._cacheAdd(what, cached, args);
}
return isArray(cached) ? dateutil_default.cloneDates(cached) : cached instanceof Date ? dateutil_default.clone(cached) : cached;
};
return Cache2;
}();
// node_modules/rrule/dist/esm/src/masks.js
var M365MASK = __spreadArrays(repeat(1, 31), repeat(2, 28), repeat(3, 31), repeat(4, 30), repeat(5, 31), repeat(6, 30), repeat(7, 31), repeat(8, 31), repeat(9, 30), repeat(10, 31), repeat(11, 30), repeat(12, 31), repeat(1, 7));
var M366MASK = __spreadArrays(repeat(1, 31), repeat(2, 29), repeat(3, 31), repeat(4, 30), repeat(5, 31), repeat(6, 30), repeat(7, 31), repeat(8, 31), repeat(9, 30), repeat(10, 31), repeat(11, 30), repeat(12, 31), repeat(1, 7));
var M28 = range(1, 29);
var M29 = range(1, 30);
var M30 = range(1, 31);
var M31 = range(1, 32);
var MDAY366MASK = __spreadArrays(M31, M29, M31, M30, M31, M30, M31, M31, M30, M31, M30, M31, M31.slice(0, 7));
var MDAY365MASK = __spreadArrays(M31, M28, M31, M30, M31, M30, M31, M31, M30, M31, M30, M31, M31.slice(0, 7));
var NM28 = range(-28, 0);
var NM29 = range(-29, 0);
var NM30 = range(-30, 0);
var NM31 = range(-31, 0);
var NMDAY366MASK = __spreadArrays(NM31, NM29, NM31, NM30, NM31, NM30, NM31, NM31, NM30, NM31, NM30, NM31, NM31.slice(0, 7));
var NMDAY365MASK = __spreadArrays(NM31, NM28, NM31, NM30, NM31, NM30, NM31, NM31, NM30, NM31, NM30, NM31, NM31.slice(0, 7));
var M366RANGE = [0, 31, 60, 91, 121, 152, 182, 213, 244, 274, 305, 335, 366];
var M365RANGE = [0, 31, 59, 90, 120, 151, 181, 212, 243, 273, 304, 334, 365];
var WDAYMASK = function() {
var wdaymask = [];
for (var i = 0; i < 55; i++)
wdaymask = wdaymask.concat(range(7));
return wdaymask;
}();
// node_modules/rrule/dist/esm/src/iterinfo/yearinfo.js
function rebuildYear(year, options) {
var firstyday = new Date(Date.UTC(year, 0, 1));
var yearlen = dateutil_default.isLeapYear(year) ? 366 : 365;
var nextyearlen = dateutil_default.isLeapYear(year + 1) ? 366 : 365;
var yearordinal = dateutil_default.toOrdinal(firstyday);
var yearweekday = dateutil_default.getWeekday(firstyday);
var result = __assign(__assign({
yearlen,
nextyearlen,
yearordinal,
yearweekday
}, baseYearMasks(year)), { wnomask: null });
if (empty(options.byweekno)) {
return result;
}
result.wnomask = repeat(0, yearlen + 7);
var firstwkst;
var wyearlen;
var no1wkst = firstwkst = pymod(7 - yearweekday + options.wkst, 7);
if (no1wkst >= 4) {
no1wkst = 0;
wyearlen = result.yearlen + pymod(yearweekday - options.wkst, 7);
} else {
wyearlen = yearlen - no1wkst;
}
var div = Math.floor(wyearlen / 7);
var mod = pymod(wyearlen, 7);
var numweeks = Math.floor(div + mod / 4);
for (var j = 0; j < options.byweekno.length; j++) {
var n = options.byweekno[j];
if (n < 0) {
n += numweeks + 1;
}
if (!(n > 0 && n <= numweeks)) {
continue;
}
var i = void 0;
if (n > 1) {
i = no1wkst + (n - 1) * 7;
if (no1wkst !== firstwkst) {
i -= 7 - firstwkst;
}
} else {
i = no1wkst;
}
for (var k = 0; k < 7; k++) {
result.wnomask[i] = 1;
i++;
if (result.wdaymask[i] === options.wkst)
break;
}
}
if (includes(options.byweekno, 1)) {
var i = no1wkst + numweeks * 7;
if (no1wkst !== firstwkst)
i -= 7 - firstwkst;
if (i < yearlen) {
for (var j = 0; j < 7; j++) {
result.wnomask[i] = 1;
i += 1;
if (result.wdaymask[i] === options.wkst)
break;
}
}
}
if (no1wkst) {
var lnumweeks = void 0;
if (!includes(options.byweekno, -1)) {
var lyearweekday = dateutil_default.getWeekday(new Date(Date.UTC(year - 1, 0, 1)));
var lno1wkst = pymod(7 - lyearweekday.valueOf() + options.wkst, 7);
var lyearlen = dateutil_default.isLeapYear(year - 1) ? 366 : 365;
var weekst = void 0;
if (lno1wkst >= 4) {
lno1wkst = 0;
weekst = lyearlen + pymod(lyearweekday - options.wkst, 7);
} else {
weekst = yearlen - no1wkst;
}
lnumweeks = Math.floor(52 + pymod(weekst, 7) / 4);
} else {
lnumweeks = -1;
}
if (includes(options.byweekno, lnumweeks)) {
for (var i = 0; i < no1wkst; i++)
result.wnomask[i] = 1;
}
}
return result;
}
function baseYearMasks(year) {
var yearlen = dateutil_default.isLeapYear(year) ? 366 : 365;
var firstyday = new Date(Date.UTC(year, 0, 1));
var wday = dateutil_default.getWeekday(firstyday);
if (yearlen === 365) {
return {
mmask: M365MASK,
mdaymask: MDAY365MASK,
nmdaymask: NMDAY365MASK,
wdaymask: WDAYMASK.slice(wday),
mrange: M365RANGE
};
}
return {
mmask: M366MASK,
mdaymask: MDAY366MASK,
nmdaymask: NMDAY366MASK,
wdaymask: WDAYMASK.slice(wday),
mrange: M366RANGE
};
}
// node_modules/rrule/dist/esm/src/iterinfo/monthinfo.js
function rebuildMonth(year, month, yearlen, mrange, wdaymask, options) {
var result = {
lastyear: year,
lastmonth: month,
nwdaymask: []
};
var ranges = [];
if (options.freq === rrule_default.YEARLY) {
if (empty(options.bymonth)) {
ranges = [[0, yearlen]];
} else {
for (var j = 0; j < options.bymonth.length; j++) {
month = options.bymonth[j];
ranges.push(mrange.slice(month - 1, month + 1));
}
}
} else if (options.freq === rrule_default.MONTHLY) {
ranges = [mrange.slice(month - 1, month + 1)];
}
if (empty(ranges)) {
return result;
}
result.nwdaymask = repeat(0, yearlen);
for (var j = 0; j < ranges.length; j++) {
var rang = ranges[j];
var first = rang[0];
var last = rang[1] - 1;
for (var k = 0; k < options.bynweekday.length; k++) {
var i = void 0;
var _a = options.bynweekday[k], wday = _a[0], n = _a[1];
if (n < 0) {
i = last + (n + 1) * 7;
i -= pymod(wdaymask[i] - wday, 7);
} else {
i = first + (n - 1) * 7;
i += pymod(7 - wdaymask[i] + wday, 7);
}
if (first <= i && i <= last)
result.nwdaymask[i] = 1;
}
}
return result;
}
// node_modules/rrule/dist/esm/src/iterinfo/easter.js
function easter(y, offset) {
if (offset === void 0) {
offset = 0;
}
var a = y % 19;
var b = Math.floor(y / 100);
var c = y % 100;
var d = Math.floor(b / 4);
var e = b % 4;
var f = Math.floor((b + 8) / 25);
var g = Math.floor((b - f + 1) / 3);
var h = Math.floor(19 * a + b - d - g + 15) % 30;
var i = Math.floor(c / 4);
var k = c % 4;
var l = Math.floor(32 + 2 * e + 2 * i - h - k) % 7;
var m = Math.floor((a + 11 * h + 22 * l) / 451);
var month = Math.floor((h + l - 7 * m + 114) / 31);
var day = (h + l - 7 * m + 114) % 31 + 1;
var date = Date.UTC(y, month - 1, day + offset);
var yearStart = Date.UTC(y, 0, 1);
return [Math.ceil((date - yearStart) / (1e3 * 60 * 60 * 24))];
}
// node_modules/rrule/dist/esm/src/iterinfo/index.js
var Iterinfo = function() {
function Iterinfo2(options) {
this.options = options;
}
Iterinfo2.prototype.rebuild = function(year, month) {
var options = this.options;
if (year !== this.lastyear) {
this.yearinfo = rebuildYear(year, options);
}
if (notEmpty(options.bynweekday) && (month !== this.lastmonth || year !== this.lastyear)) {
var _a = this.yearinfo, yearlen = _a.yearlen, mrange = _a.mrange, wdaymask = _a.wdaymask;
this.monthinfo = rebuildMonth(year, month, yearlen, mrange, wdaymask, options);
}
if (isPresent(options.byeaster)) {
this.eastermask = easter(year, options.byeaster);
}
};
Object.defineProperty(Iterinfo2.prototype, "lastyear", {
get: function() {
return this.monthinfo ? this.monthinfo.lastyear : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "lastmonth", {
get: function() {
return this.monthinfo ? this.monthinfo.lastmonth : null;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "yearlen", {
get: function() {
return this.yearinfo.yearlen;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "yearordinal", {
get: function() {
return this.yearinfo.yearordinal;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "mrange", {
get: function() {
return this.yearinfo.mrange;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "wdaymask", {
get: function() {
return this.yearinfo.wdaymask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "mmask", {
get: function() {
return this.yearinfo.mmask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "wnomask", {
get: function() {
return this.yearinfo.wnomask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "nwdaymask", {
get: function() {
return this.monthinfo ? this.monthinfo.nwdaymask : [];
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "nextyearlen", {
get: function() {
return this.yearinfo.nextyearlen;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "mdaymask", {
get: function() {
return this.yearinfo.mdaymask;
},
enumerable: true,
configurable: true
});
Object.defineProperty(Iterinfo2.prototype, "nmdaymask", {
get: function() {
return this.yearinfo.nmdaymask;
},
enumerable: true,
configurable: true
});
Iterinfo2.prototype.ydayset = function() {
return [range(this.yearlen), 0, this.yearlen];
};
Iterinfo2.prototype.mdayset = function(_, month, __) {
var start = this.mrange[month - 1];
var end = this.mrange[month];
var set = repeat(null, this.yearlen);
for (var i = start; i < end; i++)
set[i] = i;
return [set, start, end];
};
Iterinfo2.prototype.wdayset = function(year, month, day) {
var set = repeat(null, this.yearlen + 7);
var i = dateutil_default.toOrdinal(new Date(Date.UTC(year, month - 1, day))) - this.yearordinal;
var start = i;
for (var j = 0; j < 7; j++) {
set[i] = i;
++i;
if (this.wdaymask[i] === this.options.wkst)
break;
}
return [set, start, i];
};
Iterinfo2.prototype.ddayset = function(year, month, day) {
var set = repeat(null, this.yearlen);
var i = dateutil_default.toOrdinal(new Date(Date.UTC(year, month - 1, day))) - this.yearordinal;
set[i] = i;
return [set, i, i + 1];
};
Iterinfo2.prototype.htimeset = function(hour, _, second, millisecond) {
var _this = this;
var set = [];
this.options.byminute.forEach(function(minute) {
set = set.concat(_this.mtimeset(hour, minute, second, millisecond));
});
dateutil_default.sort(set);
return set;
};
Iterinfo2.prototype.mtimeset = function(hour, minute, _, millisecond) {
var set = this.options.bysecond.map(function(second) {
return new Time3(hour, minute, second, millisecond);
});
dateutil_default.sort(set);
return set;
};
Iterinfo2.prototype.stimeset = function(hour, minute, second, millisecond) {
return [new Time3(hour, minute, second, millisecond)];
};
Iterinfo2.prototype.getdayset = function(freq) {
switch (freq) {
case Frequency.YEARLY:
return this.ydayset.bind(this);
case Frequency.MONTHLY:
return this.mdayset.bind(this);
case Frequency.WEEKLY:
return this.wdayset.bind(this);
case Frequency.DAILY:
return this.ddayset.bind(this);
default:
return this.ddayset.bind(this);
}
};
Iterinfo2.prototype.gettimeset = function(freq) {
switch (freq) {
case Frequency.HOURLY:
return this.htimeset.bind(this);
case Frequency.MINUTELY:
return this.mtimeset.bind(this);
case Frequency.SECONDLY:
return this.stimeset.bind(this);
}
};
return Iterinfo2;
}();
var iterinfo_default = Iterinfo;
// node_modules/rrule/dist/esm/src/iter/poslist.js
function buildPoslist(bysetpos, timeset, start, end, ii, dayset) {
var poslist = [];
for (var j = 0; j < bysetpos.length; j++) {
var daypos = void 0;
var timepos = void 0;
var pos = bysetpos[j];
if (pos < 0) {
daypos = Math.floor(pos / timeset.length);
timepos = pymod(pos, timeset.length);
} else {
daypos = Math.floor((pos - 1) / timeset.length);
timepos = pymod(pos - 1, timeset.length);
}
var tmp = [];
for (var k = start; k < end; k++) {
var val = dayset[k];
if (!isPresent(val))
continue;
tmp.push(val);
}
var i = void 0;
if (daypos < 0) {
i = tmp.slice(daypos)[0];
} else {
i = tmp[daypos];
}
var time = timeset[timepos];
var date = dateutil_default.fromOrdinal(ii.yearordinal + i);
var res = dateutil_default.combine(date, time);
if (!includes(poslist, res))
poslist.push(res);
}
dateutil_default.sort(poslist);
return poslist;
}
// node_modules/rrule/dist/esm/src/iter/index.js
function iter(iterResult, options) {
var dtstart = options.dtstart, freq = options.freq, interval = options.interval, until = options.until, bysetpos = options.bysetpos;
var count = options.count;
if (count === 0 || interval === 0) {
return emitResult(iterResult);
}
var counterDate = DateTime3.fromDate(dtstart);
var ii = new iterinfo_default(options);
ii.rebuild(counterDate.year, counterDate.month);
var timeset = makeTimeset(ii, counterDate, options);
while (true) {
var _a = ii.getdayset(freq)(counterDate.year, counterDate.month, counterDate.day), dayset = _a[0], start = _a[1], end = _a[2];
var filtered = removeFilteredDays(dayset, start, end, ii, options);
if (notEmpty(bysetpos)) {
var poslist = buildPoslist(bysetpos, timeset, start, end, ii, dayset);
for (var j = 0; j < poslist.length; j++) {
var res = poslist[j];
if (until && res > until) {
return emitResult(iterResult);
}
if (res >= dtstart) {
var rezonedDate = rezoneIfNeeded(res, options);
if (!iterResult.accept(rezonedDate)) {
return emitResult(iterResult);
}
if (count) {
--count;
if (!count) {
return emitResult(iterResult);
}
}
}
}
} else {
for (var j = start; j < end; j++) {
var currentDay = dayset[j];
if (!isPresent(currentDay)) {
continue;
}
var date = dateutil_default.fromOrdinal(ii.yearordinal + currentDay);
for (var k = 0; k < timeset.length; k++) {
var time = timeset[k];
var res = dateutil_default.combine(date, time);
if (until && res > until) {
return emitResult(iterResult);
}
if (res >= dtstart) {
var rezonedDate = rezoneIfNeeded(res, options);
if (!iterResult.accept(rezonedDate)) {
return emitResult(iterResult);
}
if (count) {
--count;
if (!count) {
return emitResult(iterResult);
}
}
}
}
}
}
if (options.interval === 0) {
return emitResult(iterResult);
}
counterDate.add(options, filtered);
if (counterDate.year > dateutil_default.MAXYEAR) {
return emitResult(iterResult);
}
if (!freqIsDailyOrGreater(freq)) {
timeset = ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, 0);
}
ii.rebuild(counterDate.year, counterDate.month);
}
}
function isFiltered(ii, currentDay, options) {
var bymonth = options.bymonth, byweekno = options.byweekno, byweekday = options.byweekday, byeaster = options.byeaster, bymonthday = options.bymonthday, bynmonthday = options.bynmonthday, byyearday = options.byyearday;
return notEmpty(bymonth) && !includes(bymonth, ii.mmask[currentDay]) || notEmpty(byweekno) && !ii.wnomask[currentDay] || notEmpty(byweekday) && !includes(byweekday, ii.wdaymask[currentDay]) || notEmpty(ii.nwdaymask) && !ii.nwdaymask[currentDay] || byeaster !== null && !includes(ii.eastermask, currentDay) || (notEmpty(bymonthday) || notEmpty(bynmonthday)) && !includes(bymonthday, ii.mdaymask[currentDay]) && !includes(bynmonthday, ii.nmdaymask[currentDay]) || notEmpty(byyearday) && (currentDay < ii.yearlen && !includes(byyearday, currentDay + 1) && !includes(byyearday, -ii.yearlen + currentDay) || currentDay >= ii.yearlen && !includes(byyearday, currentDay + 1 - ii.yearlen) && !includes(byyearday, -ii.nextyearlen + currentDay - ii.yearlen));
}
function rezoneIfNeeded(date, options) {
return new DateWithZone(date, options.tzid).rezonedDate();
}
function emitResult(iterResult) {
return iterResult.getValue();
}
function removeFilteredDays(dayset, start, end, ii, options) {
var filtered = false;
for (var dayCounter = start; dayCounter < end; dayCounter++) {
var currentDay = dayset[dayCounter];
filtered = isFiltered(ii, currentDay, options);
if (filtered)
dayset[currentDay] = null;
}
return filtered;
}
function makeTimeset(ii, counterDate, options) {
var freq = options.freq, byhour = options.byhour, byminute = options.byminute, bysecond = options.bysecond;
if (freqIsDailyOrGreater(freq)) {
return buildTimeset(options);
}
if (freq >= rrule_default.HOURLY && notEmpty(byhour) && !includes(byhour, counterDate.hour) || freq >= rrule_default.MINUTELY && notEmpty(byminute) && !includes(byminute, counterDate.minute) || freq >= rrule_default.SECONDLY && notEmpty(bysecond) && !includes(bysecond, counterDate.second)) {
return [];
}
return ii.gettimeset(freq)(counterDate.hour, counterDate.minute, counterDate.second, counterDate.millisecond);
}
// node_modules/rrule/dist/esm/src/rrule.js
var Days = {
MO: new Weekday(0),
TU: new Weekday(1),
WE: new Weekday(2),
TH: new Weekday(3),
FR: new Weekday(4),
SA: new Weekday(5),
SU: new Weekday(6)
};
var DEFAULT_OPTIONS = {
freq: Frequency.YEARLY,
dtstart: null,
interval: 1,
wkst: Days.MO,
count: null,
until: null,
tzid: null,
bysetpos: null,
bymonth: null,
bymonthday: null,
bynmonthday: null,
byyearday: null,
byweekno: null,
byweekday: null,
bynweekday: null,
byhour: null,
byminute: null,
bysecond: null,
byeaster: null
};
var defaultKeys = Object.keys(DEFAULT_OPTIONS);
var RRule = function() {
function RRule2(options, noCache) {
if (options === void 0) {
options = {};
}
if (noCache === void 0) {
noCache = false;
}
this._cache = noCache ? null : new Cache();
this.origOptions = initializeOptions(options);
var parsedOptions = parseOptions(options).parsedOptions;
this.options = parsedOptions;
}
RRule2.parseText = function(text2, language) {
return parseText(text2, language);
};
RRule2.fromText = function(text2, language) {
return fromText(text2, language);
};
RRule2.fromString = function(str) {
return new RRule2(RRule2.parseString(str) || void 0);
};
RRule2.prototype._iter = function(iterResult) {
return iter(iterResult, this.options);
};
RRule2.prototype._cacheGet = function(what, args) {
if (!this._cache)
return false;
return this._cache._cacheGet(what, args);
};
RRule2.prototype._cacheAdd = function(what, value, args) {
if (!this._cache)
return;
return this._cache._cacheAdd(what, value, args);
};
RRule2.prototype.all = function(iterator) {
if (iterator) {
return this._iter(new callbackiterresult_default("all", {}, iterator));
}
var result = this._cacheGet("all");
if (result === false) {
result = this._iter(new iterresult_default("all", {}));
this._cacheAdd("all", result);
}
return result;
};
RRule2.prototype.between = function(after, before, inc, iterator) {
if (inc === void 0) {
inc = false;
}
if (!dateutil_default.isValidDate(after) || !dateutil_default.isValidDate(before))
throw new Error("Invalid date passed in to RRule.between");
var args = {
before,
after,
inc
};
if (iterator) {
return this._iter(new callbackiterresult_default("between", args, iterator));
}
var result = this._cacheGet("between", args);
if (result === false) {
result = this._iter(new iterresult_default("between", args));
this._cacheAdd("between", result, args);
}
return result;
};
RRule2.prototype.before = function(dt, inc) {
if (inc === void 0) {
inc = false;
}
if (!dateutil_default.isValidDate(dt))
throw new Error("Invalid date passed in to RRule.before");
var args = { dt, inc };
var result = this._cacheGet("before", args);
if (result === false) {
result = this._iter(new iterresult_default("before", args));
this._cacheAdd("before", result, args);
}
return result;
};
RRule2.prototype.after = function(dt, inc) {
if (inc === void 0) {
inc = false;
}
if (!dateutil_default.isValidDate(dt))
throw new Error("Invalid date passed in to RRule.after");
var args = { dt, inc };
var result = this._cacheGet("after", args);
if (result === false) {
result = this._iter(new iterresult_default("after", args));
this._cacheAdd("after", result, args);
}
return result;
};
RRule2.prototype.count = function() {
return this.all().length;
};
RRule2.prototype.toString = function() {
return optionsToString(this.origOptions);
};
RRule2.prototype.toText = function(gettext, language, dateFormatter) {
return toText(this, gettext, language, dateFormatter);
};
RRule2.prototype.isFullyConvertibleToText = function() {
return isFullyConvertible(this);
};
RRule2.prototype.clone = function() {
return new RRule2(this.origOptions);
};
RRule2.FREQUENCIES = [
"YEARLY",
"MONTHLY",
"WEEKLY",
"DAILY",
"HOURLY",
"MINUTELY",
"SECONDLY"
];
RRule2.YEARLY = Frequency.YEARLY;
RRule2.MONTHLY = Frequency.MONTHLY;
RRule2.WEEKLY = Frequency.WEEKLY;
RRule2.DAILY = Frequency.DAILY;
RRule2.HOURLY = Frequency.HOURLY;
RRule2.MINUTELY = Frequency.MINUTELY;
RRule2.SECONDLY = Frequency.SECONDLY;
RRule2.MO = Days.MO;
RRule2.TU = Days.TU;
RRule2.WE = Days.WE;
RRule2.TH = Days.TH;
RRule2.FR = Days.FR;
RRule2.SA = Days.SA;
RRule2.SU = Days.SU;
RRule2.parseString = parseString;
RRule2.optionsToString = optionsToString;
return RRule2;
}();
var rrule_default = RRule;
// node_modules/rrule/dist/esm/src/iterset.js
function iterSet(iterResult, _rrule, _exrule, _rdate, _exdate, tzid) {
var _exdateHash = {};
var _accept = iterResult.accept;
function evalExdate(after, before) {
_exrule.forEach(function(rrule) {
rrule.between(after, before, true).forEach(function(date) {
_exdateHash[Number(date)] = true;
});
});
}
_exdate.forEach(function(date) {
var zonedDate2 = new DateWithZone(date, tzid).rezonedDate();
_exdateHash[Number(zonedDate2)] = true;
});
iterResult.accept = function(date) {
var dt = Number(date);
if (isNaN(dt))
return _accept.call(this, date);
if (!_exdateHash[dt]) {
evalExdate(new Date(dt - 1), new Date(dt + 1));
if (!_exdateHash[dt]) {
_exdateHash[dt] = true;
return _accept.call(this, date);
}
}
return true;
};
if (iterResult.method === "between") {
evalExdate(iterResult.args.after, iterResult.args.before);
iterResult.accept = function(date) {
var dt = Number(date);
if (!_exdateHash[dt]) {
_exdateHash[dt] = true;
return _accept.call(this, date);
}
return true;
};
}
for (var i = 0; i < _rdate.length; i++) {
var zonedDate = new DateWithZone(_rdate[i], tzid).rezonedDate();
if (!iterResult.accept(new Date(zonedDate.getTime())))
break;
}
_rrule.forEach(function(rrule) {
iter(iterResult, rrule.options);
});
var res = iterResult._result;
dateutil_default.sort(res);
switch (iterResult.method) {
case "all":
case "between":
return res;
case "before":
return res.length && res[res.length - 1] || null;
case "after":
default:
return res.length && res[0] || null;
}
}
// node_modules/rrule/dist/esm/src/rrulestr.js
var DEFAULT_OPTIONS2 = {
dtstart: null,
cache: false,
unfold: false,
forceset: false,
compatible: false,
tzid: null
};
function parseInput(s, options) {
var rrulevals = [];
var rdatevals = [];
var exrulevals = [];
var exdatevals = [];
var _a = parseDtstart(s), dtstart = _a.dtstart, tzid = _a.tzid;
var lines = splitIntoLines(s, options.unfold);
lines.forEach(function(line) {
if (!line)
return;
var _a2 = breakDownLine(line), name = _a2.name, parms = _a2.parms, value = _a2.value;
switch (name.toUpperCase()) {
case "RRULE":
if (parms.length) {
throw new Error("unsupported RRULE parm: " + parms.join(","));
}
rrulevals.push(parseString(line));
break;
case "RDATE":
var _b = /RDATE(?:;TZID=([^:=]+))?/i.exec(line), _ = _b[0], rdateTzid = _b[1];
if (rdateTzid && !tzid) {
tzid = rdateTzid;
}
rdatevals = rdatevals.concat(parseRDate(value, parms));
break;
case "EXRULE":
if (parms.length) {
throw new Error("unsupported EXRULE parm: " + parms.join(","));
}
exrulevals.push(parseString(value));
break;
case "EXDATE":
exdatevals = exdatevals.concat(parseRDate(value, parms));
break;
case "DTSTART":
break;
default:
throw new Error("unsupported property: " + name);
}
});
return {
dtstart,
tzid,
rrulevals,
rdatevals,
exrulevals,
exdatevals
};
}
function buildRule(s, options) {
var _a = parseInput(s, options), rrulevals = _a.rrulevals, rdatevals = _a.rdatevals, exrulevals = _a.exrulevals, exdatevals = _a.exdatevals, dtstart = _a.dtstart, tzid = _a.tzid;
var noCache = options.cache === false;
if (options.compatible) {
options.forceset = true;
options.unfold = true;
}
if (options.forceset || rrulevals.length > 1 || rdatevals.length || exrulevals.length || exdatevals.length) {
var rset_1 = new rruleset_default(noCache);
rset_1.dtstart(dtstart);
rset_1.tzid(tzid || void 0);
rrulevals.forEach(function(val2) {
rset_1.rrule(new rrule_default(groomRruleOptions(val2, dtstart, tzid), noCache));
});
rdatevals.forEach(function(date) {
rset_1.rdate(date);
});
exrulevals.forEach(function(val2) {
rset_1.exrule(new rrule_default(groomRruleOptions(val2, dtstart, tzid), noCache));
});
exdatevals.forEach(function(date) {
rset_1.exdate(date);
});
if (options.compatible && options.dtstart)
rset_1.rdate(dtstart);
return rset_1;
}
var val = rrulevals[0] || {};
return new rrule_default(groomRruleOptions(val, val.dtstart || options.dtstart || dtstart, val.tzid || options.tzid || tzid), noCache);
}
function rrulestr(s, options) {
if (options === void 0) {
options = {};
}
return buildRule(s, initializeOptions2(options));
}
function groomRruleOptions(val, dtstart, tzid) {
return __assign(__assign({}, val), {
dtstart,
tzid
});
}
function initializeOptions2(options) {
var invalid = [];
var keys = Object.keys(options);
var defaultKeys2 = Object.keys(DEFAULT_OPTIONS2);
keys.forEach(function(key) {
if (!includes(defaultKeys2, key))
invalid.push(key);
});
if (invalid.length) {
throw new Error("Invalid options: " + invalid.join(", "));
}
return __assign(__assign({}, DEFAULT_OPTIONS2), options);
}
function extractName(line) {
if (line.indexOf(":") === -1) {
return {
name: "RRULE",
value: line
};
}
var _a = split(line, ":", 1), name = _a[0], value = _a[1];
return {
name,
value
};
}
function breakDownLine(line) {
var _a = extractName(line), name = _a.name, value = _a.value;
var parms = name.split(";");
if (!parms)
throw new Error("empty property name");
return {
name: parms[0].toUpperCase(),
parms: parms.slice(1),
value
};
}
function splitIntoLines(s, unfold) {
if (unfold === void 0) {
unfold = false;
}
s = s && s.trim();
if (!s)
throw new Error("Invalid empty string");
if (!unfold) {
return s.split(/\s/);
}
var lines = s.split("\n");
var i = 0;
while (i < lines.length) {
var line = lines[i] = lines[i].replace(/\s+$/g, "");
if (!line) {
lines.splice(i, 1);
} else if (i > 0 && line[0] === " ") {
lines[i - 1] += line.slice(1);
lines.splice(i, 1);
} else {
i += 1;
}
}
return lines;
}
function validateDateParm(parms) {
parms.forEach(function(parm) {
if (!/(VALUE=DATE(-TIME)?)|(TZID=)/.test(parm)) {
throw new Error("unsupported RDATE/EXDATE parm: " + parm);
}
});
}
function parseRDate(rdateval, parms) {
validateDateParm(parms);
return rdateval.split(",").map(function(datestr) {
return dateutil_default.untilStringToDate(datestr);
});
}
// node_modules/rrule/dist/esm/src/rruleset.js
function createGetterSetter(fieldName) {
var _this = this;
return function(field) {
if (field !== void 0) {
_this["_" + fieldName] = field;
}
if (_this["_" + fieldName] !== void 0) {
return _this["_" + fieldName];
}
for (var i = 0; i < _this._rrule.length; i++) {
var field_1 = _this._rrule[i].origOptions[fieldName];
if (field_1) {
return field_1;
}
}
};
}
var RRuleSet = function(_super) {
__extends(RRuleSet2, _super);
function RRuleSet2(noCache) {
if (noCache === void 0) {
noCache = false;
}
var _this = _super.call(this, {}, noCache) || this;
_this.dtstart = createGetterSetter.apply(_this, ["dtstart"]);
_this.tzid = createGetterSetter.apply(_this, ["tzid"]);
_this._rrule = [];
_this._rdate = [];
_this._exrule = [];
_this._exdate = [];
return _this;
}
RRuleSet2.prototype._iter = function(iterResult) {
return iterSet(iterResult, this._rrule, this._exrule, this._rdate, this._exdate, this.tzid());
};
RRuleSet2.prototype.rrule = function(rrule) {
_addRule(rrule, this._rrule);
};
RRuleSet2.prototype.exrule = function(rrule) {
_addRule(rrule, this._exrule);
};
RRuleSet2.prototype.rdate = function(date) {
_addDate(date, this._rdate);
};
RRuleSet2.prototype.exdate = function(date) {
_addDate(date, this._exdate);
};
RRuleSet2.prototype.rrules = function() {
return this._rrule.map(function(e) {
return rrulestr(e.toString());
});
};
RRuleSet2.prototype.exrules = function() {
return this._exrule.map(function(e) {
return rrulestr(e.toString());
});
};
RRuleSet2.prototype.rdates = function() {
return this._rdate.map(function(e) {
return new Date(e.getTime());
});
};
RRuleSet2.prototype.exdates = function() {
return this._exdate.map(function(e) {
return new Date(e.getTime());
});
};
RRuleSet2.prototype.valueOf = function() {
var result = [];
if (!this._rrule.length && this._dtstart) {
result = result.concat(optionsToString({ dtstart: this._dtstart }));
}
this._rrule.forEach(function(rrule) {
result = result.concat(rrule.toString().split("\n"));
});
this._exrule.forEach(function(exrule) {
result = result.concat(exrule.toString().split("\n").map(function(line) {
return line.replace(/^RRULE:/, "EXRULE:");
}).filter(function(line) {
return !/^DTSTART/.test(line);
}));
});
if (this._rdate.length) {
result.push(rdatesToString("RDATE", this._rdate, this.tzid()));
}
if (this._exdate.length) {
result.push(rdatesToString("EXDATE", this._exdate, this.tzid()));
}
return result;
};
RRuleSet2.prototype.toString = function() {
return this.valueOf().join("\n");
};
RRuleSet2.prototype.clone = function() {
var rrs = new RRuleSet2(!!this._cache);
this._rrule.forEach(function(rule) {
return rrs.rrule(rule.clone());
});
this._exrule.forEach(function(rule) {
return rrs.exrule(rule.clone());
});
this._rdate.forEach(function(date) {
return rrs.rdate(new Date(date.getTime()));
});
this._exdate.forEach(function(date) {
return rrs.exdate(new Date(date.getTime()));
});
return rrs;
};
return RRuleSet2;
}(rrule_default);
var rruleset_default = RRuleSet;
function _addRule(rrule, collection) {
if (!(rrule instanceof rrule_default)) {
throw new TypeError(String(rrule) + " is not RRule instance");
}
if (!includes(collection.map(String), String(rrule))) {
collection.push(rrule);
}
}
function _addDate(date, collection) {
if (!(date instanceof Date)) {
throw new TypeError(String(date) + " is not Date instance");
}
if (!includes(collection.map(Number), Number(date))) {
collection.push(date);
dateutil_default.sort(collection);
}
}
function rdatesToString(param, rdates, tzid) {
var isUTC = !tzid || tzid.toUpperCase() === "UTC";
var header = isUTC ? param + ":" : param + ";TZID=" + tzid + ":";
var dateString = rdates.map(function(rdate) {
return dateutil_default.timeToUntilString(rdate.valueOf(), isUTC);
}).join(",");
return "" + header + dateString;
}
// node_modules/rrule/dist/esm/src/index.js
var src_default = rrule_default;
// src/model/format/splitter.ts
var Symbol2 = class {
constructor(primary, func) {
this.primary = primary;
this.func = func;
}
static ofChar(ch) {
return new Symbol2(ch, (text2) => {
return text2 === ch;
});
}
static ofChars(ch) {
if (ch.length === 0) {
throw "empty symbol";
}
if (ch[0] == null) {
throw "ch mustn't be null";
}
if (ch.length === 0) {
return this.ofChar(ch[0]);
}
return new Symbol2(ch[0], (text2) => {
return ch.filter((c) => text2 === c).length > 0;
});
}
isSymbol(text2) {
return this.func(text2);
}
};
var Tokens = class {
constructor(tokens) {
this.tokens = tokens;
}
setTokenText(symbol, text2, keepSpace = false, create = false, separateSymbolAndText = false, insertAt) {
let token = this.getToken(symbol);
if (token === null) {
if (!create) {
return null;
}
if (symbol instanceof Symbol2) {
token = { symbol: symbol.primary, text: text2 };
} else {
token = { symbol, text: text2 };
}
if (separateSymbolAndText && token.symbol !== "" && !token.text.startsWith(" ")) {
token.text = " " + token.text;
}
if (this.tokens.length > 0) {
const lastToken = this.tokens[this.tokens.length - 1];
if (!this.isTokenEndsWithSpace(lastToken)) {
lastToken.text += " ";
}
}
if (insertAt == null) {
this.tokens.push(token);
} else {
let index = 0;
let insertTokenIndex = -1;
let tokenIndex = 0;
for (const t of this.tokens) {
const end = index + t.symbol.length + t.text.length;
if (tokenIndex > 0) {
if (end > insertAt) {
insertTokenIndex = tokenIndex;
break;
}
}
index = end;
tokenIndex++;
}
if (insertTokenIndex == -1) {
this.tokens.push(token);
} else {
this.tokens.splice(insertTokenIndex, 0, token);
if (insertTokenIndex < this.tokens.length - 1) {
token.text = token.text + " ";
}
}
}
return token;
}
this.replaceTokenText(token, text2, keepSpace);
return token;
}
length() {
return this.tokens.length;
}
replaceTokenText(token, text2, keepSpace = false) {
if (!keepSpace) {
token.text = text2;
return;
}
token.text = token.text.replace(/^(\s*).*?(\s*)$/, `$1${text2}$2`);
}
isTokenEndsWithSpace(token) {
return token.text.match(/^.*\s$/);
}
getToken(symbol) {
for (let token of this.tokens) {
if (symbol instanceof Symbol2) {
if (symbol.isSymbol(token.symbol)) {
return token;
}
} else {
if (symbol === token.symbol) {
return token;
}
}
}
return null;
}
getTokenText(symbol, removeSpace = false) {
const token = this.getToken(symbol);
if (token === null) {
return null;
}
if (!removeSpace) {
return token.text;
}
return token.text.replace(/^\s*(.*?)\s*$/, `$1`);
}
removeToken(symbol) {
this.tokens = this.tokens.filter((token) => !symbol.isSymbol(token.symbol));
}
forEachTokens(consumer) {
this.tokens.forEach(consumer);
}
rangeOfSymbol(symbol) {
let index = 0;
for (const token of this.tokens) {
const end = index + token.symbol.length + token.text.length;
if (symbol.isSymbol(token.symbol)) {
return {
start: index,
end
};
}
index = end;
}
return;
}
join() {
return this.tokens.map((t) => t.symbol + t.text).join("");
}
};
function splitBySymbol(line, symbols) {
const chars = [...line];
let text2 = "";
let currentToken = null;
const splitted = [];
const fillPreviousToken = () => {
if (currentToken === null) {
splitted.push({ symbol: "", text: text2 });
} else {
currentToken.text = text2;
}
};
chars.forEach((c) => {
let isSymbol = symbols.filter((s) => s.isSymbol(c)).length > 0;
if (isSymbol) {
fillPreviousToken();
currentToken = { symbol: c, text: "" };
splitted.push(currentToken);
text2 = "";
} else {
text2 += c;
}
});
if (text2.length > 0) {
fillPreviousToken();
}
return splitted;
}
// src/model/format/reminder-tasks-plugin.ts
function removeTags(text2) {
return text2.replace(/#\w+/g, "");
}
var _TasksPluginReminderModel = class {
constructor(useCustomEmoji, removeTags2, strictDateFormat, tokens) {
this.useCustomEmoji = useCustomEmoji;
this.removeTags = removeTags2;
this.strictDateFormat = strictDateFormat;
this.tokens = tokens;
}
static parse(line, useCustomEmoji, removeTags2, strictDateFormat) {
return new _TasksPluginReminderModel(
useCustomEmoji != null ? useCustomEmoji : false,
removeTags2 != null ? removeTags2 : false,
strictDateFormat != null ? strictDateFormat : true,
new Tokens(splitBySymbol(line, this.allSymbols))
);
}
getTitle() {
let title = this.tokens.getTokenText("", true);
if (title != null && this.removeTags) {
title = removeTags(title);
}
return title;
}
getTime() {
return this.getDate(this.getReminderSymbol());
}
setTime(time, insertAt) {
if (this.useCustomEmoji) {
this.setDate(this.getReminderSymbol(), time, 1);
} else {
this.setDate(this.getReminderSymbol(), time, insertAt);
}
}
getDueDate() {
return this.getDate(_TasksPluginReminderModel.symbolDueDate);
}
setDueDate(time) {
this.setDate(_TasksPluginReminderModel.symbolDueDate, time);
}
setRawTime(rawTime) {
this.setDate(this.getReminderSymbol(), rawTime);
return true;
}
getReminderSymbol() {
if (this.useCustomEmoji) {
return _TasksPluginReminderModel.symbolReminder;
} else {
return _TasksPluginReminderModel.symbolDueDate;
}
}
getEndOfTimeTextIndex() {
let timeSymbol = _TasksPluginReminderModel.symbolDueDate;
if (this.useCustomEmoji) {
timeSymbol = _TasksPluginReminderModel.symbolReminder;
}
const token = this.tokens.rangeOfSymbol(timeSymbol);
if (token != null) {
return token.end;
}
return this.toMarkdown().length;
}
toMarkdown() {
return this.tokens.join();
}
setTitle(description) {
this.tokens.setTokenText("", description, true, true);
}
getDoneDate() {
return this.getDate(_TasksPluginReminderModel.symbolDoneDate);
}
setDoneDate(time) {
this.setDate(_TasksPluginReminderModel.symbolDoneDate, time);
}
getRecurrence() {
return this.tokens.getTokenText(_TasksPluginReminderModel.symbolRecurrence, true);
}
clone() {
return _TasksPluginReminderModel.parse(this.toMarkdown(), this.useCustomEmoji, this.removeTags, this.strictDateFormat);
}
getDate(symbol) {
const dateText = this.tokens.getTokenText(symbol, true);
if (dateText === null) {
return null;
}
if (symbol === _TasksPluginReminderModel.symbolReminder) {
return DATE_TIME_FORMATTER.parse(dateText);
} else {
const date = (0, import_moment3.default)(dateText, _TasksPluginReminderModel.dateFormat, this.strictDateFormat);
if (!date.isValid()) {
return null;
}
return new DateTime(date, false);
}
}
setDate(symbol, time, insertAt) {
if (time == null) {
this.tokens.removeToken(symbol);
return;
}
let timeStr;
if (time instanceof DateTime) {
if (symbol === _TasksPluginReminderModel.symbolReminder) {
timeStr = DATE_TIME_FORMATTER.toString(time);
} else {
timeStr = time.format(_TasksPluginReminderModel.dateFormat);
}
} else {
timeStr = time;
}
this.tokens.setTokenText(symbol, timeStr, true, true, this.shouldSplitBetweenSymbolAndText(), insertAt);
}
shouldSplitBetweenSymbolAndText() {
let withSpace = 0;
let noSpace = 0;
this.tokens.forEachTokens((token) => {
if (token.symbol === "") {
return;
}
if (token.text.match(/^\s.*$/)) {
withSpace += 1;
} else {
noSpace++;
}
});
if (withSpace > noSpace) {
return true;
} else if (withSpace < noSpace) {
return false;
} else {
return true;
}
}
};
var TasksPluginReminderModel = _TasksPluginReminderModel;
TasksPluginReminderModel.dateFormat = "YYYY-MM-DD";
TasksPluginReminderModel.symbolDueDate = Symbol2.ofChars([..."\u{1F4C5}\u{1F4C6}\u{1F5D3}"]);
TasksPluginReminderModel.symbolDoneDate = Symbol2.ofChar("\u2705");
TasksPluginReminderModel.symbolRecurrence = Symbol2.ofChar("\u{1F501}");
TasksPluginReminderModel.symbolReminder = Symbol2.ofChar("\u23F0");
TasksPluginReminderModel.symbolScheduled = Symbol2.ofChar("\u23F3");
TasksPluginReminderModel.symbolStart = Symbol2.ofChar("\u{1F6EB}");
TasksPluginReminderModel.allSymbols = [
_TasksPluginReminderModel.symbolDueDate,
_TasksPluginReminderModel.symbolDoneDate,
_TasksPluginReminderModel.symbolRecurrence,
_TasksPluginReminderModel.symbolReminder,
_TasksPluginReminderModel.symbolStart,
_TasksPluginReminderModel.symbolScheduled
];
var _TasksPluginFormat = class extends TodoBasedReminderFormat {
parseReminder(todo) {
const parsed = TasksPluginReminderModel.parse(todo.body, this.useCustomEmoji(), this.removeTagsEnabled(), this.isStrictDateFormat());
if (this.useCustomEmoji() && parsed.getDueDate() == null) {
return null;
}
return parsed;
}
removeTagsEnabled() {
return this.config.getParameter(ReminderFormatParameterKey.removeTagsForTasksPlugin);
}
useCustomEmoji() {
return this.config.getParameter(ReminderFormatParameterKey.useCustomEmojiForTasksPlugin);
}
modifyReminder(doc, todo, parsed, edit) {
if (!super.modifyReminder(doc, todo, parsed, edit)) {
return false;
}
if (edit.checked !== void 0) {
if (edit.checked) {
const recurrence = parsed.getRecurrence();
if (recurrence !== null) {
const nextReminderTodo = todo.clone();
const nextReminder = parsed.clone();
const dueDate = parsed.getDueDate();
if (dueDate == null) {
return false;
}
if (this.useCustomEmoji()) {
const time = parsed.getTime();
if (time == null) {
return false;
}
const nextTime = this.nextDate(recurrence, time.moment());
const nextDueDate = this.nextDate(recurrence, dueDate.moment());
if (nextTime == null || nextDueDate == null) {
return false;
}
nextReminder.setTime(new DateTime((0, import_moment3.default)(nextTime), true));
nextReminder.setDueDate(new DateTime((0, import_moment3.default)(nextDueDate), true));
} else {
const next = this.nextDate(recurrence, dueDate.moment());
if (next == null) {
return false;
}
const nextDueDate = new DateTime((0, import_moment3.default)(next), true);
nextReminder.setTime(nextDueDate);
}
nextReminderTodo.body = nextReminder.toMarkdown();
nextReminderTodo.setChecked(false);
doc.insertTodo(todo.lineIndex, nextReminderTodo);
}
parsed.setDoneDate(this.config.getParameter(ReminderFormatParameterKey.now));
} else {
parsed.setDoneDate(void 0);
}
}
return true;
}
nextDate(recurrence, dtStart) {
const rruleOptions = rrule_default.parseText(recurrence);
if (!rruleOptions) {
return void 0;
}
const today = this.config.getParameter(ReminderFormatParameterKey.now).moment();
today.set("hour", dtStart.get("hour"));
today.set("minute", dtStart.get("minute"));
today.set("second", dtStart.get("second"));
today.set("millisecond", dtStart.get("millisecond"));
if (today.isAfter(dtStart)) {
dtStart = today;
}
const base = dtStart.clone();
rruleOptions.dtstart = dtStart.utc(true).toDate();
const rrule = new rrule_default(rruleOptions);
const rdate = rrule.after(dtStart.toDate(), false);
const diff = rdate.getTime() - rruleOptions.dtstart.getTime();
base.add(diff, "millisecond");
return base.toDate();
}
newReminder(title, time, insertAt) {
const parsed = TasksPluginReminderModel.parse(title, this.useCustomEmoji(), this.removeTagsEnabled(), this.isStrictDateFormat());
parsed.setTime(time, insertAt);
if (this.useCustomEmoji() && parsed.getDueDate() == null) {
parsed.setDueDate(time);
}
parsed.setTitle(title);
return parsed;
}
};
var TasksPluginFormat = _TasksPluginFormat;
TasksPluginFormat.instance = new _TasksPluginFormat();
// src/model/format/index.ts
var REMINDER_FORMAT = new CompositeReminderFormat();
REMINDER_FORMAT.resetFormat([DefaultReminderFormat.instance]);
var ReminderFormatType = class {
constructor(name, description, example, format, defaultEnabled) {
this.name = name;
this.description = description;
this.example = example;
this.format = format;
this.defaultEnabled = defaultEnabled;
}
};
function parseReminder(doc) {
return REMINDER_FORMAT.parse(doc);
}
function modifyReminder(doc, reminder, edit) {
return __async(this, null, function* () {
return REMINDER_FORMAT.modify(doc, reminder, edit);
});
}
function changeReminderFormat(formatTypes) {
if (formatTypes.length === 0) {
REMINDER_FORMAT.resetFormat([DefaultReminderFormat.instance]);
} else {
REMINDER_FORMAT.resetFormat(formatTypes.map((f) => f.format));
}
}
function setReminderFormatConfig(config) {
REMINDER_FORMAT.setConfig(config);
}
var reminderPluginReminderFormat = new ReminderFormatType("ReminderPluginReminderFormat", "Reminder plugin format", "(@2021-09-08)", DefaultReminderFormat.instance, true);
var tasksPluginReminderFormat = new ReminderFormatType("TasksPluginReminderFormat", "Tasks plugin format", "\u{1F4C5} 2021-09-08", TasksPluginFormat.instance, false);
var kanbanPluginReminderFormat = new ReminderFormatType("KanbanPluginReminderFormat", "Kanban plugin format", "@{2021-09-08}", KanbanReminderFormat.instance, false);
var ReminderFormatTypes = [
reminderPluginReminderFormat,
tasksPluginReminderFormat,
kanbanPluginReminderFormat
];
// src/model/settings.ts
var import_obsidian = require("obsidian");
var SettingRegistry = class {
constructor() {
this.settingContexts = [];
}
register(settingContext) {
this.settingContexts.push(settingContext);
}
findByKey(key) {
return this.settingContexts.find((c) => c.key === key);
}
forEach(consumer) {
this.settingContexts.forEach(consumer);
}
};
var SettingContext = class {
constructor(_settingRegistry) {
this._settingRegistry = _settingRegistry;
this.tags = [];
}
init(settingModel, setting, containerEl) {
this.settingModel = settingModel;
this._setting = setting;
this.validationEl = containerEl.createDiv("validation", (el) => {
el.style.color = "var(--text-error)";
el.style.marginBottom = "1rem";
el.style.fontSize = "14px";
el.style.display = "none";
});
this.infoEl = containerEl.createDiv("info", (el) => {
el.style.color = "var(--text-faint)";
el.style.marginBottom = "1rem";
el.style.fontSize = "14px";
el.style.display = "none";
});
}
setValidationError(error) {
this.setText(this.validationEl, error);
}
setInfo(info) {
this.setText(this.infoEl, info);
}
setText(el, text2) {
if (!el) {
console.error("element not created");
return;
}
if (text2 === null) {
el.style.display = "none";
} else {
el.style.display = "block";
el.innerHTML = text2;
}
}
get setting() {
return this._setting;
}
get registry() {
return this._settingRegistry;
}
hasTag(tag) {
return this.tags.filter((t) => t === tag).length > 0;
}
update() {
if (!this.anyValueChanged) {
return;
}
this.anyValueChanged(this);
}
setEnabled(enable) {
this.setting.setDisabled(!enable);
}
findContextByKey(key) {
return this._settingRegistry.findByKey(key);
}
booleanValue() {
return this.settingModel.value;
}
isInitialized() {
return this.settingModel && this.validationEl && this.setting;
}
};
var SettingModelBuilder = class {
constructor(registry) {
this.registry = registry;
this.context = new SettingContext(this.registry);
this.registry.register(this.context);
}
key(key) {
this.context.key = key;
return this;
}
name(name) {
this.context.name = name;
return this;
}
desc(desc) {
this.context.desc = desc;
return this;
}
tag(tag) {
this.context.tags.push(tag);
return this;
}
enableWhen(enableWhen) {
this.context.anyValueChanged = enableWhen;
return this;
}
text(initValue) {
return new TextSettingModelBuilder(this.context, false, initValue);
}
textArea(initValue) {
return new TextSettingModelBuilder(this.context, true, initValue);
}
number(initValue) {
return new NumberSettingModelBuilder(this.context, initValue);
}
toggle(initValue) {
return new ToggleSettingModelBuilder(this.context, initValue);
}
dropdown(initValue) {
return new DropdownSettingModelBuilder(this.context, initValue);
}
};
var AbstractSettingModelBuilder = class {
constructor(context, initValue) {
this.context = context;
this.initValue = initValue;
}
onAnyValueChanged(anyValueChanged) {
this.context.anyValueChanged = anyValueChanged;
return this;
}
onValueChange() {
this.context.registry.forEach((c) => {
c.update();
});
}
buildSettingModel(serde, initializer) {
return new SettingModelImpl(this.context, serde, this.initValue, initializer);
}
};
var TextSettingModelBuilder = class extends AbstractSettingModelBuilder {
constructor(context, longText, initValue) {
super(context, initValue);
this.longText = longText;
}
placeHolder(placeHolder) {
this._placeHolder = placeHolder;
return this;
}
build(serde) {
return this.buildSettingModel(serde, ({ setting, rawValue, context }) => {
const initText = (text2) => {
var _a;
text2.setPlaceholder((_a = this._placeHolder) != null ? _a : "").setValue(rawValue.value).onChange((value) => __async(this, null, function* () {
try {
serde.unmarshal(value);
rawValue.value = value;
context.setValidationError(null);
this.onValueChange();
} catch (e) {
if (e instanceof Error) {
context.setValidationError(e.message);
} else if (typeof e === "string") {
context.setValidationError(e);
}
}
}));
};
if (this.longText) {
setting.addTextArea((textarea) => {
initText(textarea);
});
} else {
setting.addText((text2) => {
initText(text2);
});
}
});
}
};
var NumberSettingModelBuilder = class extends AbstractSettingModelBuilder {
constructor(context, initValue) {
super(context, initValue);
}
placeHolder(placeHolder) {
this._placeHolder = placeHolder;
return this;
}
build(serde) {
return this.buildSettingModel(serde, ({ setting, rawValue, context }) => {
const initText = (text2) => {
var _a;
text2.setPlaceholder((_a = this._placeHolder) != null ? _a : "").setValue(rawValue.value.toString()).onChange((value) => __async(this, null, function* () {
try {
const n = parseInt(value);
rawValue.value = n;
context.setValidationError(null);
this.onValueChange();
} catch (e) {
if (e instanceof Error) {
context.setValidationError(e.message);
} else if (typeof e === "string") {
context.setValidationError(e);
}
}
}));
};
setting.addText((textarea) => {
initText(textarea);
});
});
}
};
var ToggleSettingModelBuilder = class extends AbstractSettingModelBuilder {
build(serde) {
return new SettingModelImpl(this.context, serde, this.initValue, ({ setting, rawValue }) => {
setting.addToggle(
(toggle) => toggle.setValue(rawValue.value).onChange((value) => __async(this, null, function* () {
rawValue.value = value;
this.onValueChange();
}))
);
});
}
};
var DropdownOption = class {
constructor(label, value) {
this.label = label;
this.value = value;
}
};
var DropdownSettingModelBuilder = class extends AbstractSettingModelBuilder {
constructor() {
super(...arguments);
this.options = [];
}
addOption(label, value) {
this.options.push(new DropdownOption(label, value));
return this;
}
build(serde) {
return new SettingModelImpl(this.context, serde, this.initValue, ({ setting, rawValue }) => {
setting.addDropdown((d) => {
this.options.forEach((option) => {
d.addOption(option.value, option.label);
});
d.setValue(rawValue.value);
d.onChange((value) => __async(this, null, function* () {
rawValue.value = value;
this.onValueChange();
}));
});
});
}
};
var SettingModelImpl = class {
constructor(context, serde, initRawValue, settingInitializer) {
this.context = context;
this.serde = serde;
this.settingInitializer = settingInitializer;
this.rawValue = new Reference(initRawValue);
if (context.key == null) {
throw new Error("key is required.");
}
}
createSetting(containerEl) {
var _a, _b;
const setting = new import_obsidian.Setting(containerEl).setName((_a = this.context.name) != null ? _a : "").setDesc((_b = this.context.desc) != null ? _b : "");
this.context.init(this, setting, containerEl);
this.settingInitializer({
setting,
rawValue: this.rawValue,
context: this.context
});
return setting;
}
get value() {
return this.serde.unmarshal(this.rawValue.value);
}
get key() {
return this.context.key;
}
load(settings) {
if (settings === void 0) {
return;
}
const newValue = settings[this.key];
if (newValue !== void 0) {
this.rawValue.value = newValue;
}
}
store(settings) {
settings[this.key] = this.rawValue.value;
}
hasTag(tag) {
return this.context.hasTag(tag);
}
};
var SettingGroup = class {
constructor(name) {
this.name = name;
this.settings = [];
}
addSettings(...settingModels) {
this.settings.push(...settingModels);
}
};
var SettingTabModel = class {
constructor() {
this.groups = [];
this.registry = new SettingRegistry();
}
newSettingBuilder() {
return new SettingModelBuilder(this.registry);
}
newGroup(name) {
const group = new SettingGroup(name);
this.groups.push(group);
return group;
}
displayOn(el) {
el.empty();
this.groups.forEach((group) => {
el.createEl("h3", { text: group.name });
group.settings.forEach((settings) => {
settings.createSetting(el);
});
});
this.registry.forEach((context) => context.update());
}
forEach(consumer) {
this.groups.forEach((group) => {
group.settings.forEach((setting) => {
consumer(setting);
});
});
}
};
var TimeSerde = class {
unmarshal(rawValue) {
return Time.parse(rawValue);
}
marshal(value) {
return value.toString();
}
};
var RawSerde = class {
unmarshal(rawValue) {
return rawValue;
}
marshal(value) {
return value;
}
};
var LatersSerde = class {
unmarshal(rawValue) {
return parseLaters(rawValue);
}
marshal(value) {
return value.map((v) => v.label).join("\n");
}
};
var ReminderFormatTypeSerde = class {
unmarshal(rawValue) {
const format = ReminderFormatTypes.find((format2) => format2.name === rawValue);
return format;
}
marshal(value) {
return value.name;
}
};
// src/settings.ts
var import_obsidian2 = require("obsidian");
var TAG_RESCAN = "re-scan";
var Settings = class {
constructor() {
this.settings = new SettingTabModel();
const reminderFormatSettings = new ReminderFormatSettings(this.settings);
this.reminderTime = this.settings.newSettingBuilder().key("reminderTime").name("Reminder Time").desc("Time when a reminder with no time part will show").tag(TAG_RESCAN).text("09:00").placeHolder("Time (hh:mm)").build(new TimeSerde());
this.useSystemNotification = this.settings.newSettingBuilder().key("useSystemNotification").name("Use system notification").desc("Use system notification for reminder notifications").toggle(false).build(new RawSerde());
this.laters = this.settings.newSettingBuilder().key("laters").name("Remind me later").desc("Line-separated list of remind me later items").textArea("In 30 minutes\nIn 1 hour\nIn 3 hours\nTomorrow\nNext week").placeHolder("In 30 minutes\nIn 1 hour\nIn 3 hours\nTomorrow\nNext week").build(new LatersSerde());
this.dateFormat = this.settings.newSettingBuilder().key("dateFormat").name("Date format").desc("moment style date format: https://momentjs.com/docs/#/displaying/format/").tag(TAG_RESCAN).text("YYYY-MM-DD").placeHolder("YYYY-MM-DD").onAnyValueChanged((context) => {
context.setEnabled(reminderFormatSettings.enableReminderPluginReminderFormat.value);
}).build(new RawSerde());
this.strictDateFormat = this.settings.newSettingBuilder().key("strictDateFormat").name("Strict Date format").desc("Strictly parse the date and time").tag(TAG_RESCAN).toggle(false).build(new RawSerde());
this.dateTimeFormat = this.settings.newSettingBuilder().key("dateTimeFormat").name("Date and time format").desc("moment() style date time format: https://momentjs.com/docs/#/displaying/format/").tag(TAG_RESCAN).text("YYYY-MM-DD HH:mm").placeHolder("YYYY-MM-DD HH:mm").onAnyValueChanged((context) => {
context.setEnabled(reminderFormatSettings.enableReminderPluginReminderFormat.value);
}).build(new RawSerde());
this.linkDatesToDailyNotes = this.settings.newSettingBuilder().key("linkDatesToDailyNotes").name("Link dates to daily notes").desc("When toggled, Dates link to daily notes.").tag(TAG_RESCAN).toggle(false).onAnyValueChanged((context) => {
context.setEnabled(reminderFormatSettings.enableReminderPluginReminderFormat.value);
}).build(new RawSerde());
this.autoCompleteTrigger = this.settings.newSettingBuilder().key("autoCompleteTrigger").name("Calendar popup trigger").desc("Trigger text to show calendar popup").text("(@").placeHolder("(@").onAnyValueChanged((context) => {
const value = this.autoCompleteTrigger.value;
context.setInfo(`Popup is ${value.length === 0 ? "disabled" : "enabled"}`);
}).build(new RawSerde());
const primaryFormatBuilder = this.settings.newSettingBuilder().key("primaryReminderFormat").name("Primary reminder format").desc("Reminder format for generated reminder by calendar popup").dropdown(ReminderFormatTypes[0].name);
ReminderFormatTypes.forEach((f) => primaryFormatBuilder.addOption(`${f.description} - ${f.example}`, f.name));
this.primaryFormat = primaryFormatBuilder.build(new ReminderFormatTypeSerde());
this.useCustomEmojiForTasksPlugin = this.settings.newSettingBuilder().key("useCustomEmojiForTasksPlugin").name("Distinguish between reminder date and due date").desc("Use custom emoji \u23F0 instead of \u{1F4C5} and distinguish between reminder date/time and Tasks Plugin's due date.").tag(TAG_RESCAN).toggle(false).onAnyValueChanged((context) => {
context.setEnabled(reminderFormatSettings.enableTasksPluginReminderFormat.value);
}).build(new RawSerde());
this.removeTagsForTasksPlugin = this.settings.newSettingBuilder().key("removeTagsForTasksPlugin").name("Remove tags from reminder title").desc("If checked, tags(#xxx) are removed from the reminder list view and notification.").tag(TAG_RESCAN).toggle(false).onAnyValueChanged((context) => {
context.setEnabled(reminderFormatSettings.enableTasksPluginReminderFormat.value);
}).build(new RawSerde());
this.editDetectionSec = this.settings.newSettingBuilder().key("editDetectionSec").name("Edit Detection Time").desc("The minimum amount of time (in seconds) after a key is typed that it will be identified as notifiable.").number(10).build(new RawSerde());
this.reminderCheckIntervalSec = this.settings.newSettingBuilder().key("reminderCheckIntervalSec").name("Reminder check interval").desc("Interval(in seconds) to periodically check whether or not you should be notified of reminders. You will need to restart Obsidian for this setting to take effect.").number(5).build(new RawSerde());
this.settings.newGroup("Notification Settings").addSettings(
this.reminderTime,
this.laters,
this.useSystemNotification
);
this.settings.newGroup("Editor").addSettings(
this.autoCompleteTrigger,
this.primaryFormat
);
this.settings.newGroup("Reminder Format - Reminder Plugin").addSettings(
reminderFormatSettings.enableReminderPluginReminderFormat,
this.dateFormat,
this.dateTimeFormat,
this.strictDateFormat,
this.linkDatesToDailyNotes
);
this.settings.newGroup("Reminder Format - Tasks Plugin").addSettings(
reminderFormatSettings.enableTasksPluginReminderFormat,
this.useCustomEmojiForTasksPlugin,
this.removeTagsForTasksPlugin
);
this.settings.newGroup("Reminder Format - Kanban Plugin").addSettings(
reminderFormatSettings.enableKanbanPluginReminderFormat
);
this.settings.newGroup("Advanced").addSettings(
this.editDetectionSec,
this.reminderCheckIntervalSec
);
const config = new ReminderFormatConfig();
config.setParameterFunc(ReminderFormatParameterKey.now, () => DateTime.now());
config.setParameter(ReminderFormatParameterKey.useCustomEmojiForTasksPlugin, this.useCustomEmojiForTasksPlugin);
config.setParameter(ReminderFormatParameterKey.linkDatesToDailyNotes, this.linkDatesToDailyNotes);
config.setParameter(ReminderFormatParameterKey.removeTagsForTasksPlugin, this.removeTagsForTasksPlugin);
setReminderFormatConfig(config);
}
forEach(consumer) {
this.settings.forEach(consumer);
}
};
var ReminderFormatSettings = class {
constructor(settings) {
this.settings = settings;
this.settingKeyToFormatName = /* @__PURE__ */ new Map();
this.reminderFormatSettings = [];
this.enableReminderPluginReminderFormat = this.createUseReminderFormatSetting(reminderPluginReminderFormat);
this.enableTasksPluginReminderFormat = this.createUseReminderFormatSetting(tasksPluginReminderFormat);
this.enableKanbanPluginReminderFormat = this.createUseReminderFormatSetting(kanbanPluginReminderFormat);
}
createUseReminderFormatSetting(format) {
const key = `enable${format.name}`;
const setting = this.settings.newSettingBuilder().key(key).name(`Enable ${format.description}`).desc(`Enable ${format.description}`).tag(TAG_RESCAN).toggle(format.defaultEnabled).onAnyValueChanged((context) => {
var _a;
context.setInfo(`Example: ${(_a = format.format.appendReminder("- [ ] Task 1", DateTime.now())) == null ? void 0 : _a.insertedLine}`);
}).build(new RawSerde());
this.settingKeyToFormatName.set(key, format);
this.reminderFormatSettings.push(setting);
setting.rawValue.onChanged(() => {
this.updateReminderFormat(setting);
});
return setting;
}
updateReminderFormat(setting) {
const selectedFormats = this.reminderFormatSettings.filter((s) => s.value).map((s) => this.settingKeyToFormatName.get(s.key)).filter((s) => s !== void 0);
changeReminderFormat(selectedFormats);
}
};
var SETTINGS = new Settings();
var ReminderSettingTab = class extends import_obsidian2.PluginSettingTab {
constructor(app, plugin) {
super(app, plugin);
}
display() {
let { containerEl } = this;
SETTINGS.settings.displayOn(containerEl);
}
};
// src/model/content.ts
var Content = class {
constructor(file, content) {
this.doc = new MarkdownDocument(file, content);
}
getReminders(doneOnly = true) {
const reminders = parseReminder(this.doc);
if (!doneOnly) {
return reminders;
}
return reminders.filter((reminder) => !reminder.done);
}
getTodos() {
return this.doc.getTodos();
}
modifyReminderLines(modifyFunc) {
return __async(this, null, function* () {
for (const reminder of this.getReminders(false)) {
const edit = modifyFunc(reminder);
if (edit === null) {
return;
}
yield this.modifyReminderLine(reminder, edit);
}
});
}
updateReminder(reminder, edit) {
return __async(this, null, function* () {
yield this.modifyReminderLine(reminder, edit);
});
}
modifyReminderLine(reminder, edit) {
return __async(this, null, function* () {
const modified = yield modifyReminder(this.doc, reminder, edit);
if (modified) {
console.info("Reminder was updated: reminder=%o", reminder);
} else {
console.warn("Cannot modify reminder because it's not a reminder todo: reminder=%o", reminder);
}
return modified;
});
}
getContent() {
return this.doc.toMarkdown();
}
};
// src/controller.ts
var RemindersController = class {
constructor(vault, viewProxy, reminders) {
this.vault = vault;
this.viewProxy = viewProxy;
this.reminders = reminders;
}
openReminder(reminder, leaf) {
return __async(this, null, function* () {
console.log("Open reminder: ", reminder);
const file = this.vault.getAbstractFileByPath(reminder.file);
if (!(file instanceof import_obsidian3.TFile)) {
console.error("Cannot open file because it isn't a TFile: %o", file);
return;
}
yield leaf.openFile(file);
if (!(leaf.view instanceof import_obsidian3.MarkdownView)) {
return;
}
const line = leaf.view.editor.getLine(reminder.rowNumber);
leaf.view.editor.setSelection(
{
line: reminder.rowNumber,
ch: 0
},
{
line: reminder.rowNumber,
ch: line.length
}
);
});
}
removeFile(path) {
return __async(this, null, function* () {
console.debug("Remove file: path=%s", path);
const result = this.reminders.removeFile(path);
this.reloadUI();
return result;
});
}
reloadFile(file, reloadUI = false) {
return __async(this, null, function* () {
console.debug(
"Reload file and collect reminders: file=%s, forceReloadUI=%s",
file.path,
reloadUI
);
if (!(file instanceof import_obsidian3.TFile)) {
console.debug("Cannot read file other than TFile: file=%o", file);
return false;
}
if (!this.isMarkdownFile(file)) {
console.debug("Not a markdown file: file=%o", file);
return false;
}
const content = new Content(file.path, yield this.vault.cachedRead(file));
const reminders = content.getReminders();
if (reminders.length > 0) {
if (!this.reminders.replaceFile(file.path, reminders)) {
return false;
}
} else {
if (!this.reminders.removeFile(file.path)) {
return false;
}
}
if (reloadUI) {
this.reloadUI();
}
return true;
});
}
convertDateTimeFormat(dateFormat, dateTimeFormat) {
return __async(this, null, function* () {
let updated = 0;
for (const file of this.vault.getMarkdownFiles()) {
const content = new Content(file.path, yield this.vault.read(file));
let updatedInFile = 0;
yield content.modifyReminderLines((reminder) => {
let converted;
if (reminder.time.hasTimePart) {
converted = reminder.time.format(dateTimeFormat);
} else {
converted = reminder.time.format(dateFormat);
}
updated++;
updatedInFile++;
return {
rawTime: converted
};
});
if (updatedInFile > 0) {
yield this.vault.modify(file, content.getContent());
}
}
SETTINGS.dateFormat.rawValue.value = dateFormat;
SETTINGS.dateTimeFormat.rawValue.value = dateTimeFormat;
if (updated > 0) {
yield this.reloadAllFiles();
}
return updated;
});
}
isMarkdownFile(file) {
return file.extension.toLowerCase() === "md";
}
reloadAllFiles() {
return __async(this, null, function* () {
console.debug("Reload all files and collect reminders");
this.reminders.clear();
for (const file of this.vault.getMarkdownFiles()) {
yield this.reloadFile(file, false);
}
this.reloadUI();
});
}
updateReminder(reminder, checked) {
return __async(this, null, function* () {
const file = this.vault.getAbstractFileByPath(reminder.file);
if (!(file instanceof import_obsidian3.TFile)) {
console.error("file is not instance of TFile: %o", file);
return;
}
const content = new Content(file.path, yield this.vault.read(file));
yield content.updateReminder(reminder, {
checked,
time: reminder.time
});
yield this.vault.modify(file, content.getContent());
});
}
toggleCheck(file, lineNumber) {
return __async(this, null, function* () {
if (!this.isMarkdownFile(file)) {
return;
}
const content = new Content(file.path, yield this.vault.read(file));
const reminder = content.getReminders(false).find((r) => r.rowNumber === lineNumber);
if (reminder) {
yield content.updateReminder(reminder, {
checked: !reminder.done
});
} else {
const todo = content.getTodos().find((t) => t.lineIndex === lineNumber);
console.log(todo);
if (!todo) {
return;
}
todo.setChecked(!todo.isChecked());
}
yield this.vault.modify(file, content.getContent());
});
}
reloadUI() {
console.debug("Reload reminder list view");
if (this.viewProxy === null) {
console.debug("reminder list is null. Skipping UI reload.");
return;
}
this.viewProxy.reload(true);
}
};
// src/data.ts
var PluginDataIO = class {
constructor(plugin, reminders) {
this.plugin = plugin;
this.reminders = reminders;
this.restoring = true;
this.changed = false;
this.scanned = new Reference(false);
this.debug = new Reference(false);
SETTINGS.forEach((setting) => {
setting.rawValue.onChanged(() => {
if (this.restoring) {
return;
}
if (setting.hasTag(TAG_RESCAN)) {
this.scanned.value = false;
}
this.changed = true;
});
});
}
load() {
return __async(this, null, function* () {
console.debug("Load reminder plugin data");
const data = yield this.plugin.loadData();
if (!data) {
this.scanned.value = false;
return;
}
this.scanned.value = data.scanned;
if (data.debug != null) {
this.debug.value = data.debug;
}
const loadedSettings = data.settings;
SETTINGS.forEach((setting) => {
setting.load(loadedSettings);
});
if (data.reminders) {
Object.keys(data.reminders).forEach((filePath) => {
const remindersInFile = data.reminders[filePath];
if (!remindersInFile) {
return;
}
this.reminders.replaceFile(
filePath,
remindersInFile.map(
(d) => new Reminder(
filePath,
d.title,
DateTime.parse(d.time),
d.rowNumber,
false
)
)
);
});
}
this.changed = false;
if (this.restoring) {
this.restoring = false;
}
});
}
save(force = false) {
return __async(this, null, function* () {
if (!force && !this.changed) {
return;
}
console.debug(
"Save reminder plugin data: force=%s, changed=%s",
force,
this.changed
);
const remindersData = {};
this.reminders.fileToReminders.forEach((r, filePath) => {
remindersData[filePath] = r.map((rr) => ({
title: rr.title,
time: rr.time.toString(),
rowNumber: rr.rowNumber
}));
});
const settings = {};
SETTINGS.forEach((setting) => {
setting.store(settings);
});
yield this.plugin.saveData({
scanned: this.scanned.value,
reminders: remindersData,
debug: this.debug.value,
settings
});
this.changed = false;
});
}
};
// src/main.ts
var import_obsidian12 = require("obsidian");
// src/obsidian-hack/obsidian-debug-mobile.ts
var import_obsidian4 = require("obsidian");
function monkeyPatchConsole(plugin) {
if (!import_obsidian4.Platform.isMobile) {
return;
}
const logFile = `${plugin.manifest.dir}/logs.txt`;
const logs = [];
const logMessages = (prefix) => (...messages) => {
logs.push(`
[${prefix}]`);
for (const message of messages) {
logs.push(String(message));
}
plugin.app.vault.adapter.write(logFile, logs.join(" "));
};
console.debug = logMessages("debug");
console.error = logMessages("error");
console.info = logMessages("info");
console.log = logMessages("log");
console.warn = logMessages("warn");
}
// src/ui/autocomplete.ts
var import_obsidian7 = require("obsidian");
// src/ui/date-chooser-modal.ts
var import_obsidian6 = require("obsidian");
// node_modules/svelte/internal/index.mjs
function noop() {
}
function run(fn) {
return fn();
}
function blank_object() {
return /* @__PURE__ */ Object.create(null);
}
function run_all(fns) {
fns.forEach(run);
}
function is_function(thing) {
return typeof thing === "function";
}
function safe_not_equal(a, b) {
return a != a ? b == b : a !== b || (a && typeof a === "object" || typeof a === "function");
}
function is_empty(obj) {
return Object.keys(obj).length === 0;
}
var is_hydrating = false;
function start_hydrating() {
is_hydrating = true;
}
function end_hydrating() {
is_hydrating = false;
}
function append(target, node) {
target.appendChild(node);
}
function insert(target, node, anchor) {
target.insertBefore(node, anchor || null);
}
function detach(node) {
node.parentNode.removeChild(node);
}
function destroy_each(iterations, detaching) {
for (let i = 0; i < iterations.length; i += 1) {
if (iterations[i])
iterations[i].d(detaching);
}
}
function element(name) {
return document.createElement(name);
}
function text(data) {
return document.createTextNode(data);
}
function space() {
return text(" ");
}
function listen(node, event, handler, options) {
node.addEventListener(event, handler, options);
return () => node.removeEventListener(event, handler, options);
}
function attr(node, attribute, value) {
if (value == null)
node.removeAttribute(attribute);
else if (node.getAttribute(attribute) !== value)
node.setAttribute(attribute, value);
}
function children(element2) {
return Array.from(element2.childNodes);
}
function set_data(text2, data) {
data = "" + data;
if (text2.wholeText !== data)
text2.data = data;
}
function select_option(select, value) {
for (let i = 0; i < select.options.length; i += 1) {
const option = select.options[i];
if (option.__value === value) {
option.selected = true;
return;
}
}
select.selectedIndex = -1;
}
function select_value(select) {
const selected_option = select.querySelector(":checked") || select.options[0];
return selected_option && selected_option.__value;
}
function toggle_class(element2, name, toggle) {
element2.classList[toggle ? "add" : "remove"](name);
}
var current_component;
function set_current_component(component) {
current_component = component;
}
function get_current_component() {
if (!current_component)
throw new Error("Function called outside component initialization");
return current_component;
}
function onMount(fn) {
get_current_component().$$.on_mount.push(fn);
}
function afterUpdate(fn) {
get_current_component().$$.after_update.push(fn);
}
var dirty_components = [];
var binding_callbacks = [];
var render_callbacks = [];
var flush_callbacks = [];
var resolved_promise = Promise.resolve();
var update_scheduled = false;
function schedule_update() {
if (!update_scheduled) {
update_scheduled = true;
resolved_promise.then(flush);
}
}
function add_render_callback(fn) {
render_callbacks.push(fn);
}
var seen_callbacks = /* @__PURE__ */ new Set();
var flushidx = 0;
function flush() {
const saved_component = current_component;
do {
while (flushidx < dirty_components.length) {
const component = dirty_components[flushidx];
flushidx++;
set_current_component(component);
update(component.$$);
}
set_current_component(null);
dirty_components.length = 0;
flushidx = 0;
while (binding_callbacks.length)
binding_callbacks.pop()();
for (let i = 0; i < render_callbacks.length; i += 1) {
const callback = render_callbacks[i];
if (!seen_callbacks.has(callback)) {
seen_callbacks.add(callback);
callback();
}
}
render_callbacks.length = 0;
} while (dirty_components.length);
while (flush_callbacks.length) {
flush_callbacks.pop()();
}
update_scheduled = false;
seen_callbacks.clear();
set_current_component(saved_component);
}
function update($$) {
if ($$.fragment !== null) {
$$.update();
run_all($$.before_update);
const dirty = $$.dirty;
$$.dirty = [-1];
$$.fragment && $$.fragment.p($$.ctx, dirty);
$$.after_update.forEach(add_render_callback);
}
}
var outroing = /* @__PURE__ */ new Set();
var outros;
function group_outros() {
outros = {
r: 0,
c: [],
p: outros
};
}
function check_outros() {
if (!outros.r) {
run_all(outros.c);
}
outros = outros.p;
}
function transition_in(block, local) {
if (block && block.i) {
outroing.delete(block);
block.i(local);
}
}
function transition_out(block, local, detach2, callback) {
if (block && block.o) {
if (outroing.has(block))
return;
outroing.add(block);
outros.c.push(() => {
outroing.delete(block);
if (callback) {
if (detach2)
block.d(1);
callback();
}
});
block.o(local);
} else if (callback) {
callback();
}
}
var globals = typeof window !== "undefined" ? window : typeof globalThis !== "undefined" ? globalThis : global;
function create_component(block) {
block && block.c();
}
function mount_component(component, target, anchor, customElement) {
const { fragment, after_update } = component.$$;
fragment && fragment.m(target, anchor);
if (!customElement) {
add_render_callback(() => {
const new_on_destroy = component.$$.on_mount.map(run).filter(is_function);
if (component.$$.on_destroy) {
component.$$.on_destroy.push(...new_on_destroy);
} else {
run_all(new_on_destroy);
}
component.$$.on_mount = [];
});
}
after_update.forEach(add_render_callback);
}
function destroy_component(component, detaching) {
const $$ = component.$$;
if ($$.fragment !== null) {
run_all($$.on_destroy);
$$.fragment && $$.fragment.d(detaching);
$$.on_destroy = $$.fragment = null;
$$.ctx = [];
}
}
function make_dirty(component, i) {
if (component.$$.dirty[0] === -1) {
dirty_components.push(component);
schedule_update();
component.$$.dirty.fill(0);
}
component.$$.dirty[i / 31 | 0] |= 1 << i % 31;
}
function init(component, options, instance8, create_fragment8, not_equal, props, append_styles, dirty = [-1]) {
const parent_component = current_component;
set_current_component(component);
const $$ = component.$$ = {
fragment: null,
ctx: [],
props,
update: noop,
not_equal,
bound: blank_object(),
on_mount: [],
on_destroy: [],
on_disconnect: [],
before_update: [],
after_update: [],
context: new Map(options.context || (parent_component ? parent_component.$$.context : [])),
callbacks: blank_object(),
dirty,
skip_bound: false,
root: options.target || parent_component.$$.root
};
append_styles && append_styles($$.root);
let ready = false;
$$.ctx = instance8 ? instance8(component, options.props || {}, (i, ret, ...rest) => {
const value = rest.length ? rest[0] : ret;
if ($$.ctx && not_equal($$.ctx[i], $$.ctx[i] = value)) {
if (!$$.skip_bound && $$.bound[i])
$$.bound[i](value);
if (ready)
make_dirty(component, i);
}
return ret;
}) : [];
$$.update();
ready = true;
run_all($$.before_update);
$$.fragment = create_fragment8 ? create_fragment8($$.ctx) : false;
if (options.target) {
if (options.hydrate) {
start_hydrating();
const nodes = children(options.target);
$$.fragment && $$.fragment.l(nodes);
nodes.forEach(detach);
} else {
$$.fragment && $$.fragment.c();
}
if (options.intro)
transition_in(component.$$.fragment);
mount_component(component, options.target, options.anchor, options.customElement);
end_hydrating();
flush();
}
set_current_component(parent_component);
}
var SvelteElement;
if (typeof HTMLElement === "function") {
SvelteElement = class extends HTMLElement {
constructor() {
super();
this.attachShadow({ mode: "open" });
}
connectedCallback() {
const { on_mount } = this.$$;
this.$$.on_disconnect = on_mount.map(run).filter(is_function);
for (const key in this.$$.slotted) {
this.appendChild(this.$$.slotted[key]);
}
}
attributeChangedCallback(attr2, _oldValue, newValue) {
this[attr2] = newValue;
}
disconnectedCallback() {
run_all(this.$$.on_disconnect);
}
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
if (!is_function(callback)) {
return noop;
}
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
};
}
var SvelteComponent = class {
$destroy() {
destroy_component(this, 1);
this.$destroy = noop;
}
$on(type, callback) {
if (!is_function(callback)) {
return noop;
}
const callbacks = this.$$.callbacks[type] || (this.$$.callbacks[type] = []);
callbacks.push(callback);
return () => {
const index = callbacks.indexOf(callback);
if (index !== -1)
callbacks.splice(index, 1);
};
}
$set($$props) {
if (this.$$set && !is_empty($$props)) {
this.$$.skip_bound = true;
this.$$set($$props);
this.$$.skip_bound = false;
}
}
};
// src/model/calendar.ts
var import_moment4 = __toESM(require_moment());
var Day = class {
constructor(date) {
this.date = date;
}
isToday(date) {
if (this.date === void 0) {
return false;
}
return this.date.date() === date.date() && this.date.month() === date.month() && this.date.year() === date.year();
}
isHoliday() {
return this.date.weekday() === 0 || this.date.weekday() === 6;
}
};
var Week = class {
constructor(weekStart) {
this.weekStart = weekStart;
this.days = [];
const current = weekStart.clone();
for (let i = 0; i < 7; i++) {
this.days.push(new Day(current.clone()));
current.add(1, "day");
}
}
};
var Month = class {
constructor(monthStart) {
this.monthStart = monthStart;
this.weeks = [];
let current = monthStart.clone().add(-monthStart.weekday(), "day");
for (let i = 0; i < 6; i++) {
if (i > 0 && !this.isThisMonth(current)) {
break;
}
this.weeks.push(new Week(current.clone()));
current.add(1, "week");
}
}
isThisMonth(date) {
return this.monthStart.month() === date.month() && this.monthStart.year() === date.year();
}
};
var Calendar = class {
constructor(today, monthStart) {
if (today) {
this.today = today;
} else {
this.today = (0, import_moment4.default)();
}
if (monthStart) {
this._current = new Month(monthStart.clone().set("date", 1));
} else {
this._current = new Month(this.today.clone().set("date", 1));
}
}
nextMonth() {
return new Calendar(this.today, this._current.monthStart.clone().add(1, "month"));
}
previousMonth() {
return new Calendar(this.today, this._current.monthStart.clone().add(-1, "month"));
}
calendarString() {
let str = `${this._current.monthStart.format("YYYY, MMM")}
Sun Mon Tue Wed Thu Fri Sat
`;
this._current.weeks.forEach((week, weekIndex) => {
let line = " ";
week.days.forEach((slot, slotIndex) => {
let s;
if (slot.date) {
if (this._current.isThisMonth(slot.date)) {
s = slot.date.format("DD");
} else {
s = " ";
}
} else {
s = " ";
}
line = line + s + " ";
});
str = str + line + "\n";
});
return str;
}
get current() {
return this._current;
}
};
// src/ui/components/DateTimeChooser.svelte
var import_moment6 = __toESM(require_moment());
// src/ui/components/Calendar.svelte
var import_moment5 = __toESM(require_moment());
function get_each_context(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[8] = list[i];
child_ctx[10] = i;
return child_ctx;
}
function get_each_context_1(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[11] = list[i];
child_ctx[10] = i;
return child_ctx;
}
function create_each_block_1(ctx) {
let td;
let t_value = ctx[11].date.format("D") + "";
let t;
let mounted;
let dispose;
function click_handler_2() {
return ctx[7](ctx[11]);
}
return {
c() {
td = element("td");
t = text(t_value);
attr(td, "class", "calendar-date svelte-18sic8s");
toggle_class(td, "is-selected", ctx[11].isToday(ctx[1]));
toggle_class(td, "other-month", !ctx[0].current.isThisMonth(ctx[11].date));
toggle_class(td, "is-holiday", ctx[11].isHoliday());
toggle_class(td, "is-past", ctx[11].date.isBefore(ctx[0].today));
},
m(target, anchor) {
insert(target, td, anchor);
append(td, t);
if (!mounted) {
dispose = listen(td, "click", click_handler_2);
mounted = true;
}
},
p(new_ctx, dirty) {
ctx = new_ctx;
if (dirty & 1 && t_value !== (t_value = ctx[11].date.format("D") + ""))
set_data(t, t_value);
if (dirty & 3) {
toggle_class(td, "is-selected", ctx[11].isToday(ctx[1]));
}
if (dirty & 1) {
toggle_class(td, "other-month", !ctx[0].current.isThisMonth(ctx[11].date));
}
if (dirty & 1) {
toggle_class(td, "is-holiday", ctx[11].isHoliday());
}
if (dirty & 1) {
toggle_class(td, "is-past", ctx[11].date.isBefore(ctx[0].today));
}
},
d(detaching) {
if (detaching)
detach(td);
mounted = false;
dispose();
}
};
}
function create_each_block(ctx) {
let tr;
let t;
let each_value_1 = ctx[8].days;
let each_blocks = [];
for (let i = 0; i < each_value_1.length; i += 1) {
each_blocks[i] = create_each_block_1(get_each_context_1(ctx, each_value_1, i));
}
return {
c() {
tr = element("tr");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
t = space();
},
m(target, anchor) {
insert(target, tr, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(tr, null);
}
append(tr, t);
},
p(ctx2, dirty) {
if (dirty & 7) {
each_value_1 = ctx2[8].days;
let i;
for (i = 0; i < each_value_1.length; i += 1) {
const child_ctx = get_each_context_1(ctx2, each_value_1, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block_1(child_ctx);
each_blocks[i].c();
each_blocks[i].m(tr, t);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value_1.length;
}
},
d(detaching) {
if (detaching)
detach(tr);
destroy_each(each_blocks, detaching);
}
};
}
function create_fragment(ctx) {
let div1;
let div0;
let span0;
let t1;
let span1;
let t2_value = ctx[0].current.monthStart.format("MMM") + "";
let t2;
let t3;
let span2;
let t4_value = ctx[0].current.monthStart.format("YYYY") + "";
let t4;
let t5;
let span3;
let t7;
let table;
let thead;
let t21;
let tbody;
let mounted;
let dispose;
let each_value = ctx[0].current.weeks;
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block(get_each_context(ctx, each_value, i));
}
return {
c() {
div1 = element("div");
div0 = element("div");
span0 = element("span");
span0.textContent = "<";
t1 = space();
span1 = element("span");
t2 = text(t2_value);
t3 = space();
span2 = element("span");
t4 = text(t4_value);
t5 = space();
span3 = element("span");
span3.textContent = ">";
t7 = space();
table = element("table");
thead = element("thead");
thead.innerHTML = `<tr><th class="svelte-18sic8s">SUN</th>
<th class="svelte-18sic8s">MON</th>
<th class="svelte-18sic8s">TUE</th>
<th class="svelte-18sic8s">WED</th>
<th class="svelte-18sic8s">THU</th>
<th class="svelte-18sic8s">FRI</th>
<th class="svelte-18sic8s">SAT</th></tr>`;
t21 = space();
tbody = element("tbody");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(span0, "class", "month-nav svelte-18sic8s");
attr(span1, "class", "month svelte-18sic8s");
attr(span2, "class", "year svelte-18sic8s");
attr(span3, "class", "month-nav svelte-18sic8s");
attr(div0, "class", "year-month svelte-18sic8s");
attr(div1, "class", "reminder-calendar svelte-18sic8s");
},
m(target, anchor) {
insert(target, div1, anchor);
append(div1, div0);
append(div0, span0);
append(div0, t1);
append(div0, span1);
append(span1, t2);
append(div0, t3);
append(div0, span2);
append(span2, t4);
append(div0, t5);
append(div0, span3);
append(div1, t7);
append(div1, table);
append(table, thead);
append(table, t21);
append(table, tbody);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(tbody, null);
}
if (!mounted) {
dispose = [
listen(span0, "click", ctx[5]),
listen(span3, "click", ctx[6])
];
mounted = true;
}
},
p(ctx2, [dirty]) {
if (dirty & 1 && t2_value !== (t2_value = ctx2[0].current.monthStart.format("MMM") + ""))
set_data(t2, t2_value);
if (dirty & 1 && t4_value !== (t4_value = ctx2[0].current.monthStart.format("YYYY") + ""))
set_data(t4, t4_value);
if (dirty & 7) {
each_value = ctx2[0].current.weeks;
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context(ctx2, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block(child_ctx);
each_blocks[i].c();
each_blocks[i].m(tbody, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
},
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(div1);
destroy_each(each_blocks, detaching);
mounted = false;
run_all(dispose);
}
};
}
function instance($$self, $$props, $$invalidate) {
let { calendar = new Calendar() } = $$props;
let { selectedDate = (0, import_moment5.default)() } = $$props;
let { onClick = (date) => {
console.log(date);
} } = $$props;
function previousMonth() {
selectedDate.add(-1, "month");
$$invalidate(0, calendar = calendar.previousMonth());
}
function nextMonth2() {
selectedDate.add(1, "month");
$$invalidate(0, calendar = calendar.nextMonth());
}
const click_handler = () => previousMonth();
const click_handler_1 = () => nextMonth2();
const click_handler_2 = (day) => onClick(new DateTime(day.date, false));
$$self.$$set = ($$props2) => {
if ("calendar" in $$props2)
$$invalidate(0, calendar = $$props2.calendar);
if ("selectedDate" in $$props2)
$$invalidate(1, selectedDate = $$props2.selectedDate);
if ("onClick" in $$props2)
$$invalidate(2, onClick = $$props2.onClick);
};
return [
calendar,
selectedDate,
onClick,
previousMonth,
nextMonth2,
click_handler,
click_handler_1,
click_handler_2
];
}
var Calendar_1 = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance, create_fragment, safe_not_equal, { calendar: 0, selectedDate: 1, onClick: 2 });
}
};
var Calendar_default = Calendar_1;
// src/ui/components/Markdown.svelte
var import_obsidian5 = require("obsidian");
function create_fragment2(ctx) {
let span1;
let span0;
return {
c() {
span1 = element("span");
span0 = element("span");
attr(span0, "class", "reminder-markdown");
},
m(target, anchor) {
insert(target, span1, anchor);
append(span1, span0);
ctx[4](span0);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(span1);
ctx[4](null);
}
};
}
function instance2($$self, $$props, $$invalidate) {
let { component } = $$props;
let { sourcePath } = $$props;
let { markdown } = $$props;
let span;
afterUpdate(() => {
span.empty();
import_obsidian5.MarkdownRenderer.renderMarkdown(markdown, span, sourcePath, component);
span.childNodes.forEach((n) => {
if (n instanceof HTMLElement) {
n.style.display = "inline";
}
});
});
function span0_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
span = $$value;
$$invalidate(0, span);
});
}
$$self.$$set = ($$props2) => {
if ("component" in $$props2)
$$invalidate(1, component = $$props2.component);
if ("sourcePath" in $$props2)
$$invalidate(2, sourcePath = $$props2.sourcePath);
if ("markdown" in $$props2)
$$invalidate(3, markdown = $$props2.markdown);
};
return [span, component, sourcePath, markdown, span0_binding];
}
var Markdown = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance2, create_fragment2, safe_not_equal, { component: 1, sourcePath: 2, markdown: 3 });
}
};
var Markdown_default = Markdown;
// src/ui/components/ReminderListByDate.svelte
function get_each_context2(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[7] = list[i];
return child_ctx;
}
function create_else_block(ctx) {
let div;
let current;
let each_value = ctx[0];
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block2(get_each_context2(ctx, each_value, i));
}
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
return {
c() {
div = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
},
m(target, anchor) {
insert(target, div, anchor);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div, null);
}
current = true;
},
p(ctx2, dirty) {
if (dirty & 31) {
each_value = ctx2[0];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context2(ctx2, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block2(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(div, null);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
},
i(local) {
if (current)
return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching)
detach(div);
destroy_each(each_blocks, detaching);
}
};
}
function create_if_block(ctx) {
let div;
return {
c() {
div = element("div");
div.textContent = "No reminders";
attr(div, "class", "reminder-list-item no-reminders svelte-gzdxib");
},
m(target, anchor) {
insert(target, div, anchor);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(div);
}
};
}
function create_each_block2(ctx) {
let div;
let span0;
let t0_value = ctx[3](ctx[7].time) + "";
let t0;
let t1;
let span1;
let markdown;
let t2;
let span2;
let t3;
let t4_value = ctx[7].getFileName() + "";
let t4;
let t5;
let div_aria_label_value;
let current;
let mounted;
let dispose;
markdown = new Markdown_default({
props: {
markdown: ctx[7].title,
sourcePath: ctx[7].file,
component: ctx[1]
}
});
function dragstart_handler(...args) {
return ctx[5](ctx[7], ...args);
}
function click_handler() {
return ctx[6](ctx[7]);
}
return {
c() {
div = element("div");
span0 = element("span");
t0 = text(t0_value);
t1 = space();
span1 = element("span");
create_component(markdown.$$.fragment);
t2 = space();
span2 = element("span");
t3 = text("- ");
t4 = text(t4_value);
t5 = space();
attr(span0, "class", "reminder-time svelte-gzdxib");
attr(span1, "class", "reminder-title");
attr(span2, "class", "reminder-file svelte-gzdxib");
attr(div, "class", "reminder-list-item svelte-gzdxib");
attr(div, "aria-label", div_aria_label_value = `[${ctx[7].time.toString()}] ${ctx[7].title} - ${ctx[7].getFileName()},`);
attr(div, "draggable", "true");
},
m(target, anchor) {
insert(target, div, anchor);
append(div, span0);
append(span0, t0);
append(div, t1);
append(div, span1);
mount_component(markdown, span1, null);
append(div, t2);
append(div, span2);
append(span2, t3);
append(span2, t4);
append(div, t5);
current = true;
if (!mounted) {
dispose = [
listen(div, "dragstart", dragstart_handler),
listen(div, "click", click_handler)
];
mounted = true;
}
},
p(new_ctx, dirty) {
ctx = new_ctx;
if ((!current || dirty & 9) && t0_value !== (t0_value = ctx[3](ctx[7].time) + ""))
set_data(t0, t0_value);
const markdown_changes = {};
if (dirty & 1)
markdown_changes.markdown = ctx[7].title;
if (dirty & 1)
markdown_changes.sourcePath = ctx[7].file;
if (dirty & 2)
markdown_changes.component = ctx[1];
markdown.$set(markdown_changes);
if ((!current || dirty & 1) && t4_value !== (t4_value = ctx[7].getFileName() + ""))
set_data(t4, t4_value);
if (!current || dirty & 1 && div_aria_label_value !== (div_aria_label_value = `[${ctx[7].time.toString()}] ${ctx[7].title} - ${ctx[7].getFileName()},`)) {
attr(div, "aria-label", div_aria_label_value);
}
},
i(local) {
if (current)
return;
transition_in(markdown.$$.fragment, local);
current = true;
},
o(local) {
transition_out(markdown.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching)
detach(div);
destroy_component(markdown);
mounted = false;
run_all(dispose);
}
};
}
function create_fragment3(ctx) {
let div;
let current_block_type_index;
let if_block;
let current;
const if_block_creators = [create_if_block, create_else_block];
const if_blocks = [];
function select_block_type(ctx2, dirty) {
if (ctx2[0].length === 0)
return 0;
return 1;
}
current_block_type_index = select_block_type(ctx, -1);
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx);
return {
c() {
div = element("div");
if_block.c();
attr(div, "class", "reminder-group svelte-gzdxib");
},
m(target, anchor) {
insert(target, div, anchor);
if_blocks[current_block_type_index].m(div, null);
current = true;
},
p(ctx2, [dirty]) {
let previous_block_index = current_block_type_index;
current_block_type_index = select_block_type(ctx2, dirty);
if (current_block_type_index === previous_block_index) {
if_blocks[current_block_type_index].p(ctx2, dirty);
} else {
group_outros();
transition_out(if_blocks[previous_block_index], 1, 1, () => {
if_blocks[previous_block_index] = null;
});
check_outros();
if_block = if_blocks[current_block_type_index];
if (!if_block) {
if_block = if_blocks[current_block_type_index] = if_block_creators[current_block_type_index](ctx2);
if_block.c();
} else {
if_block.p(ctx2, dirty);
}
transition_in(if_block, 1);
if_block.m(div, null);
}
},
i(local) {
if (current)
return;
transition_in(if_block);
current = true;
},
o(local) {
transition_out(if_block);
current = false;
},
d(detaching) {
if (detaching)
detach(div);
if_blocks[current_block_type_index].d();
}
};
}
function instance3($$self, $$props, $$invalidate) {
;
;
;
let { reminders } = $$props;
let { component } = $$props;
let { onOpenReminder = () => {
} } = $$props;
let { timeToString = (time) => time.format("HH:MM") } = $$props;
let { generateLink } = $$props;
const dragstart_handler = (reminder, e) => {
var _a;
(_a = e.dataTransfer) == null ? void 0 : _a.setData("text/plain", generateLink(reminder));
};
const click_handler = (reminder) => {
onOpenReminder(reminder);
};
$$self.$$set = ($$props2) => {
if ("reminders" in $$props2)
$$invalidate(0, reminders = $$props2.reminders);
if ("component" in $$props2)
$$invalidate(1, component = $$props2.component);
if ("onOpenReminder" in $$props2)
$$invalidate(2, onOpenReminder = $$props2.onOpenReminder);
if ("timeToString" in $$props2)
$$invalidate(3, timeToString = $$props2.timeToString);
if ("generateLink" in $$props2)
$$invalidate(4, generateLink = $$props2.generateLink);
};
return [
reminders,
component,
onOpenReminder,
timeToString,
generateLink,
dragstart_handler,
click_handler
];
}
var ReminderListByDate = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance3, create_fragment3, safe_not_equal, {
reminders: 0,
component: 1,
onOpenReminder: 2,
timeToString: 3,
generateLink: 4
});
}
};
var ReminderListByDate_default = ReminderListByDate;
// src/ui/components/DateTimeChooser.svelte
function create_fragment4(ctx) {
let div1;
let calendarview;
let t0;
let hr;
let t1;
let div0;
let reminderlistbydate;
let current;
calendarview = new Calendar_default({
props: {
onClick: ctx[4],
selectedDate: ctx[1],
calendar: ctx[0]
}
});
reminderlistbydate = new ReminderListByDate_default({
props: {
reminders: ctx[3].byDate(new DateTime(ctx[1], false)),
component: ctx[2]
}
});
return {
c() {
div1 = element("div");
create_component(calendarview.$$.fragment);
t0 = space();
hr = element("hr");
t1 = space();
div0 = element("div");
create_component(reminderlistbydate.$$.fragment);
attr(hr, "class", "dtchooser-divider svelte-fjfxbq");
attr(div0, "class", "reminder-list-container svelte-fjfxbq");
attr(div1, "class", "dtchooser svelte-fjfxbq");
},
m(target, anchor) {
insert(target, div1, anchor);
mount_component(calendarview, div1, null);
append(div1, t0);
append(div1, hr);
append(div1, t1);
append(div1, div0);
mount_component(reminderlistbydate, div0, null);
current = true;
},
p(ctx2, [dirty]) {
const calendarview_changes = {};
if (dirty & 16)
calendarview_changes.onClick = ctx2[4];
if (dirty & 2)
calendarview_changes.selectedDate = ctx2[1];
if (dirty & 1)
calendarview_changes.calendar = ctx2[0];
calendarview.$set(calendarview_changes);
const reminderlistbydate_changes = {};
if (dirty & 10)
reminderlistbydate_changes.reminders = ctx2[3].byDate(new DateTime(ctx2[1], false));
if (dirty & 4)
reminderlistbydate_changes.component = ctx2[2];
reminderlistbydate.$set(reminderlistbydate_changes);
},
i(local) {
if (current)
return;
transition_in(calendarview.$$.fragment, local);
transition_in(reminderlistbydate.$$.fragment, local);
current = true;
},
o(local) {
transition_out(calendarview.$$.fragment, local);
transition_out(reminderlistbydate.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching)
detach(div1);
destroy_component(calendarview);
destroy_component(reminderlistbydate);
}
};
}
function instance4($$self, $$props, $$invalidate) {
;
;
let { calendar = new Calendar() } = $$props;
let { component } = $$props;
let { selectedDate = (0, import_moment6.default)() } = $$props;
let { reminders } = $$props;
function selectDate(date) {
$$invalidate(1, selectedDate = date.clone());
$$invalidate(0, calendar = new Calendar((0, import_moment6.default)(), date));
}
function moveUp() {
selectDate(selectedDate.add(-7, "day"));
}
function moveDown() {
selectDate(selectedDate.add(7, "day"));
}
function moveLeft() {
selectDate(selectedDate.add(-1, "day"));
}
function moveRight() {
selectDate(selectedDate.add(1, "day"));
}
function selection() {
return new DateTime(selectedDate, false);
}
let { onClick } = $$props;
$$self.$$set = ($$props2) => {
if ("calendar" in $$props2)
$$invalidate(0, calendar = $$props2.calendar);
if ("component" in $$props2)
$$invalidate(2, component = $$props2.component);
if ("selectedDate" in $$props2)
$$invalidate(1, selectedDate = $$props2.selectedDate);
if ("reminders" in $$props2)
$$invalidate(3, reminders = $$props2.reminders);
if ("onClick" in $$props2)
$$invalidate(4, onClick = $$props2.onClick);
};
return [
calendar,
selectedDate,
component,
reminders,
onClick,
moveUp,
moveDown,
moveLeft,
moveRight,
selection
];
}
var DateTimeChooser = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance4, create_fragment4, safe_not_equal, {
calendar: 0,
component: 2,
selectedDate: 1,
reminders: 3,
moveUp: 5,
moveDown: 6,
moveLeft: 7,
moveRight: 8,
selection: 9,
onClick: 4
});
}
get moveUp() {
return this.$$.ctx[5];
}
get moveDown() {
return this.$$.ctx[6];
}
get moveLeft() {
return this.$$.ctx[7];
}
get moveRight() {
return this.$$.ctx[8];
}
get selection() {
return this.$$.ctx[9];
}
};
var DateTimeChooser_default = DateTimeChooser;
// src/ui/date-chooser-modal.ts
var DateTimeChooserModal = class extends import_obsidian6.Modal {
constructor(app, reminders, onSelect, onCancel) {
super(app);
this.reminders = reminders;
this.onSelect = onSelect;
this.onCancel = onCancel;
this.handlers = [];
}
onOpen() {
let targetElement;
if (import_obsidian6.Platform.isDesktop) {
this.modalEl.style.minWidth = "0px";
this.modalEl.style.minHeight = "0px";
this.modalEl.style.width = "auto";
targetElement = this.contentEl;
} else {
targetElement = this.containerEl;
}
const chooser = new DateTimeChooser_default({
target: targetElement,
props: {
onClick: (time) => {
this.select(time);
},
reminders: this.reminders,
undefined: void 0
}
});
this.registerKeymap(["Ctrl"], "P", () => chooser["moveUp"]());
this.registerKeymap([], "ArrowUp", () => chooser["moveUp"]());
this.registerKeymap(["Ctrl"], "N", () => chooser["moveDown"]());
this.registerKeymap([], "ArrowDown", () => chooser["moveDown"]());
this.registerKeymap(["Ctrl"], "B", () => chooser["moveLeft"]());
this.registerKeymap([], "ArrowLeft", () => chooser["moveLeft"]());
this.registerKeymap(["Ctrl"], "F", () => chooser["moveRight"]());
this.registerKeymap([], "ArrowRight", () => chooser["moveRight"]());
this.registerKeymap([], "Enter", () => this.select(chooser["selection"]()));
this.registerKeymap([], "Escape", () => this.close());
}
registerKeymap(modifier, key, action) {
this.handlers.push(this.scope.register(modifier, key, () => {
action();
return false;
}));
}
select(time) {
this.selected = time;
this.close();
}
onClose() {
this.handlers.forEach((handler) => this.scope.unregister(handler));
if (this.selected != null) {
this.onSelect(this.selected);
} else {
this.onCancel();
}
}
};
function showDateTimeChooserModal(app, reminders) {
return new Promise((resolve, reject) => {
const modal = new DateTimeChooserModal(app, reminders, resolve, reject);
modal.open();
});
}
// src/ui/datetime-chooser.ts
var import_moment7 = __toESM(require_moment());
var DateTimeChooserView = class {
constructor(editor, reminders) {
this.editor = editor;
this.keyMaps = {
"Ctrl-P": () => this.dateTimeChooser["moveUp"](),
"Ctrl-N": () => this.dateTimeChooser["moveDown"](),
"Ctrl-B": () => this.dateTimeChooser["moveLeft"](),
"Ctrl-F": () => this.dateTimeChooser["moveRight"](),
"Enter": () => this.select(),
Up: () => this.dateTimeChooser["moveUp"](),
Down: () => this.dateTimeChooser["moveDown"](),
Right: () => this.dateTimeChooser["moveRight"](),
Left: () => this.dateTimeChooser["moveLeft"](),
Esc: () => this.cancel()
};
this.view = document.createElement("div");
this.view.addClass("date-time-chooser-popup");
this.view.style.position = "fixed";
this.dateTimeChooser = new DateTimeChooser_default({
target: this.view,
props: {
onClick: (time) => {
this.setResult(time);
this.hide();
},
reminders,
undefined: void 0
}
});
}
show() {
this.setResult(null);
this.hide();
this.dateTimeChooser.$set({
selectedDate: (0, import_moment7.default)(),
calendar: new Calendar()
});
const cursor = this.editor.getCursor();
const coords = this.editor.charCoords(cursor);
const parent = document.body;
const parentRect = parent.getBoundingClientRect();
this.view.style.top = `${coords.top - parentRect.top + this.editor.defaultTextHeight()}px`;
this.view.style.left = `${coords.left - parentRect.left}px`;
parent.appendChild(this.view);
this.editor.addKeyMap(this.keyMaps);
return new Promise((resolve, reject) => {
this.resultResolve = resolve;
this.resultReject = reject;
});
}
select() {
this.setResult(this.dateTimeChooser["selection"]());
this.hide();
}
cancel() {
this.setResult(null);
this.hide();
}
setResult(result) {
if (this.resultReject == null || this.resultResolve == null) {
return;
}
if (result === null) {
this.resultReject();
} else {
this.resultResolve(result);
}
this.resultReject = void 0;
this.resultResolve = void 0;
}
hide() {
if (this.view.parentNode) {
this.editor.removeKeyMap(this.keyMaps);
this.view.parentNode.removeChild(this.view);
}
}
};
// src/ui/autocomplete.ts
var AutoComplete = class {
constructor(trigger) {
this.trigger = trigger;
}
isTrigger(cmEditor, changeObj) {
const trigger = this.trigger.value;
if (trigger.length === 0) {
return false;
}
if (changeObj.text.contains(trigger.charAt(trigger.length - 1))) {
const line = cmEditor.getLine(changeObj.from.line).substring(0, changeObj.to.ch) + changeObj.text;
if (!line.match(/^\s*\- \[.\]\s.*/)) {
return false;
}
if (line.endsWith(trigger)) {
return true;
}
}
return false;
}
show(app, editor, reminders) {
let result;
if (import_obsidian7.Platform.isDesktopApp) {
try {
const cm = editor.cm;
if (cm == null) {
console.error("Cannot get codemirror editor.");
return;
}
const v = new DateTimeChooserView(cm, reminders);
result = v.show();
} catch (e) {
result = showDateTimeChooserModal(app, reminders);
}
} else {
result = showDateTimeChooserModal(app, reminders);
}
result.then((value) => {
this.insert(editor, value, true);
}).catch(() => {
});
}
insert(editor, value, triggerFromCommand = false) {
var _a;
const pos = editor.getCursor();
let line = editor.getLine(pos.line);
const endPos = {
line: pos.line,
ch: line.length
};
if (!triggerFromCommand) {
line = line.substring(0, pos.ch - this.trigger.value.length);
}
const format = SETTINGS.primaryFormat.value.format;
try {
const appended = (_a = format.appendReminder(line, value)) == null ? void 0 : _a.insertedLine;
if (appended == null) {
console.error("Cannot append reminder time to the line: line=%s, date=%s", line, value);
return;
}
editor.replaceRange(appended, { line: pos.line, ch: 0 }, endPos);
} catch (ex) {
console.error(ex);
}
}
};
// src/ui/datetime-format-modal.ts
var import_obsidian8 = require("obsidian");
var DateTimeFormatModal = class extends import_obsidian8.FuzzySuggestModal {
constructor(app, suggestions, onChooseSuggestionFunc) {
super(app);
this.suggestions = suggestions;
this.onChooseSuggestionFunc = onChooseSuggestionFunc;
}
getItems() {
return this.suggestions;
}
getItemText(item) {
return item;
}
onChooseItem(item, evt) {
this.onChooseSuggestionFunc(item);
}
};
function openDateTimeFormatChooser(app, onSelectFormat) {
new DateTimeFormatModal(app, ["YYYY-MM-DD", "YYYY/MM/DD", "DD-MM-YYYY", "DD/MM/YYYY"], (dateFormat) => {
new DateTimeFormatModal(app, ["YYYY-MM-DD HH:mm", "YYYY/MM/DD HH:mm", "DD-MM-YYYY HH:mm", "DD/MM/YYYY HH:mm", "YYYY-MM-DDTHH:mm:ss:SSS"], (dateTimeFormat) => {
onSelectFormat(dateFormat, dateTimeFormat);
}).open();
}).open();
}
// src/ui/editor-extension.ts
var import_state = require("@codemirror/state");
var import_view = require("@codemirror/view");
function buildCodeMirrorPlugin(app, reminders) {
return import_view.ViewPlugin.fromClass(
class {
update(update2) {
if (!update2.docChanged) {
return;
}
update2.changes.iterChanges((_fromA, _toA, _fromB, toB, inserted) => {
const doc = update2.state.doc;
const text2 = doc.sliceString(toB - 2, toB);
if (inserted.length === 0) {
return;
}
const trigger = SETTINGS.autoCompleteTrigger.value;
if (trigger === text2) {
showDateTimeChooserModal(app, reminders).then((value) => {
const format = SETTINGS.primaryFormat.value.format;
try {
const line = doc.lineAt(toB);
const triggerStart = line.text.lastIndexOf(trigger);
let triggerEnd = triggerStart + trigger.length;
if (trigger.startsWith("(") && line.text.charAt(triggerEnd) === ")") {
triggerEnd++;
}
const triggerExcludedLine = line.text.substring(0, triggerStart) + line.text.substring(triggerEnd);
const reminderInsertion = format.appendReminder(triggerExcludedLine, value, triggerStart);
if (reminderInsertion == null) {
console.error("Cannot append reminder time to the line: line=%s, date=%s", line.text, value);
return;
}
const updateTextTransaction = update2.view.state.update({
changes: { from: line.from, to: line.to, insert: reminderInsertion.insertedLine },
selection: import_state.EditorSelection.cursor(line.from + reminderInsertion.caretPosition)
});
update2.view.update([updateTextTransaction]);
} catch (ex) {
console.error(ex);
}
});
}
});
}
}
);
}
// src/ui/reminder.ts
var import_obsidian10 = require("obsidian");
// src/ui/components/Icon.svelte
var import_obsidian9 = require("obsidian");
function create_fragment5(ctx) {
let span_1;
return {
c() {
span_1 = element("span");
attr(span_1, "class", "icon svelte-1gcidq0");
},
m(target, anchor) {
insert(target, span_1, anchor);
ctx[3](span_1);
},
p: noop,
i: noop,
o: noop,
d(detaching) {
if (detaching)
detach(span_1);
ctx[3](null);
}
};
}
function instance5($$self, $$props, $$invalidate) {
let { icon = "" } = $$props;
let { size = 16 } = $$props;
let span;
onMount(() => {
(0, import_obsidian9.setIcon)(span, icon, size);
});
function span_1_binding($$value) {
binding_callbacks[$$value ? "unshift" : "push"](() => {
span = $$value;
$$invalidate(0, span);
});
}
$$self.$$set = ($$props2) => {
if ("icon" in $$props2)
$$invalidate(1, icon = $$props2.icon);
if ("size" in $$props2)
$$invalidate(2, size = $$props2.size);
};
return [span, icon, size, span_1_binding];
}
var Icon = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance5, create_fragment5, safe_not_equal, { icon: 1, size: 2 });
}
};
var Icon_default = Icon;
// src/ui/components/Reminder.svelte
function get_each_context3(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[10] = list[i];
child_ctx[12] = i;
return child_ctx;
}
function create_each_block3(ctx) {
let option;
let t_value = ctx[10].label + "";
let t;
let option_value_value;
let option_selected_value;
return {
c() {
option = element("option");
t = text(t_value);
option.__value = option_value_value = ctx[12];
option.value = option.__value;
option.selected = option_selected_value = ctx[6] === ctx[12];
},
m(target, anchor) {
insert(target, option, anchor);
append(option, t);
},
p(ctx2, dirty) {
if (dirty & 32 && t_value !== (t_value = ctx2[10].label + ""))
set_data(t, t_value);
if (dirty & 64 && option_selected_value !== (option_selected_value = ctx2[6] === ctx2[12])) {
option.selected = option_selected_value;
}
},
d(detaching) {
if (detaching)
detach(option);
}
};
}
function create_fragment6(ctx) {
let main;
let h1;
let markdown;
let t0;
let span;
let icon0;
let t1;
let t2_value = ctx[0].file + "";
let t2;
let t3;
let div;
let button0;
let icon1;
let t4;
let t5;
let button1;
let icon2;
let t6;
let t7;
let select;
let option;
let current;
let mounted;
let dispose;
markdown = new Markdown_default({
props: {
markdown: ctx[0].title,
sourcePath: ctx[0].file,
component: ctx[1]
}
});
icon0 = new Icon_default({ props: { icon: "link" } });
icon1 = new Icon_default({ props: { icon: "check-small" } });
icon2 = new Icon_default({ props: { icon: "minus-with-circle" } });
let each_value = ctx[5];
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block3(get_each_context3(ctx, each_value, i));
}
return {
c() {
main = element("main");
h1 = element("h1");
create_component(markdown.$$.fragment);
t0 = space();
span = element("span");
create_component(icon0.$$.fragment);
t1 = space();
t2 = text(t2_value);
t3 = space();
div = element("div");
button0 = element("button");
create_component(icon1.$$.fragment);
t4 = text(" Mark as Done");
t5 = space();
button1 = element("button");
create_component(icon2.$$.fragment);
t6 = text(" Mute");
t7 = space();
select = element("select");
option = element("option");
option.textContent = "Remind Me Later";
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
attr(span, "class", "reminder-file svelte-yfmg28");
attr(button0, "class", "mod-cta");
option.selected = true;
option.disabled = true;
option.hidden = true;
option.__value = "Remind Me Later";
option.value = option.__value;
attr(select, "class", "dropdown later-select svelte-yfmg28");
if (ctx[6] === void 0)
add_render_callback(() => ctx[9].call(select));
attr(div, "class", "reminder-actions svelte-yfmg28");
attr(main, "class", "svelte-yfmg28");
},
m(target, anchor) {
insert(target, main, anchor);
append(main, h1);
mount_component(markdown, h1, null);
append(main, t0);
append(main, span);
mount_component(icon0, span, null);
append(span, t1);
append(span, t2);
append(main, t3);
append(main, div);
append(div, button0);
mount_component(icon1, button0, null);
append(button0, t4);
append(div, t5);
append(div, button1);
mount_component(icon2, button1, null);
append(button1, t6);
append(div, t7);
append(div, select);
append(select, option);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(select, null);
}
select_option(select, ctx[6]);
current = true;
if (!mounted) {
dispose = [
listen(span, "click", function() {
if (is_function(ctx[3]))
ctx[3].apply(this, arguments);
}),
listen(button0, "click", function() {
if (is_function(ctx[2]))
ctx[2].apply(this, arguments);
}),
listen(button1, "click", function() {
if (is_function(ctx[4]))
ctx[4].apply(this, arguments);
}),
listen(select, "change", ctx[9]),
listen(select, "change", ctx[7])
];
mounted = true;
}
},
p(new_ctx, [dirty]) {
ctx = new_ctx;
const markdown_changes = {};
if (dirty & 1)
markdown_changes.markdown = ctx[0].title;
if (dirty & 1)
markdown_changes.sourcePath = ctx[0].file;
if (dirty & 2)
markdown_changes.component = ctx[1];
markdown.$set(markdown_changes);
if ((!current || dirty & 1) && t2_value !== (t2_value = ctx[0].file + ""))
set_data(t2, t2_value);
if (dirty & 96) {
each_value = ctx[5];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context3(ctx, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
} else {
each_blocks[i] = create_each_block3(child_ctx);
each_blocks[i].c();
each_blocks[i].m(select, null);
}
}
for (; i < each_blocks.length; i += 1) {
each_blocks[i].d(1);
}
each_blocks.length = each_value.length;
}
if (dirty & 64) {
select_option(select, ctx[6]);
}
},
i(local) {
if (current)
return;
transition_in(markdown.$$.fragment, local);
transition_in(icon0.$$.fragment, local);
transition_in(icon1.$$.fragment, local);
transition_in(icon2.$$.fragment, local);
current = true;
},
o(local) {
transition_out(markdown.$$.fragment, local);
transition_out(icon0.$$.fragment, local);
transition_out(icon1.$$.fragment, local);
transition_out(icon2.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching)
detach(main);
destroy_component(markdown);
destroy_component(icon0);
destroy_component(icon1);
destroy_component(icon2);
destroy_each(each_blocks, detaching);
mounted = false;
run_all(dispose);
}
};
}
function instance6($$self, $$props, $$invalidate) {
;
;
;
let { reminder } = $$props;
let { component } = $$props;
let { onRemindMeLater } = $$props;
let { onDone } = $$props;
let { onOpenFile } = $$props;
let { onMute } = $$props;
let selectedIndex;
let { laters = [] } = $$props;
function remindMeLater() {
const selected = laters[selectedIndex];
if (selected == null) {
return;
}
onRemindMeLater(selected.later());
}
function select_change_handler() {
selectedIndex = select_value(this);
$$invalidate(6, selectedIndex);
}
$$self.$$set = ($$props2) => {
if ("reminder" in $$props2)
$$invalidate(0, reminder = $$props2.reminder);
if ("component" in $$props2)
$$invalidate(1, component = $$props2.component);
if ("onRemindMeLater" in $$props2)
$$invalidate(8, onRemindMeLater = $$props2.onRemindMeLater);
if ("onDone" in $$props2)
$$invalidate(2, onDone = $$props2.onDone);
if ("onOpenFile" in $$props2)
$$invalidate(3, onOpenFile = $$props2.onOpenFile);
if ("onMute" in $$props2)
$$invalidate(4, onMute = $$props2.onMute);
if ("laters" in $$props2)
$$invalidate(5, laters = $$props2.laters);
};
return [
reminder,
component,
onDone,
onOpenFile,
onMute,
laters,
selectedIndex,
remindMeLater,
onRemindMeLater,
select_change_handler
];
}
var Reminder2 = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance6, create_fragment6, safe_not_equal, {
reminder: 0,
component: 1,
onRemindMeLater: 8,
onDone: 2,
onOpenFile: 3,
onMute: 4,
laters: 5
});
}
};
var Reminder_default = Reminder2;
// src/ui/reminder.ts
var electron = require("electron");
var ReminderModal = class {
constructor(app, useSystemNotification, laters) {
this.app = app;
this.useSystemNotification = useSystemNotification;
this.laters = laters;
}
show(reminder, onRemindMeLater, onDone, onMute, onOpenFile) {
if (!this.isSystemNotification()) {
this.showBuiltinReminder(reminder, onRemindMeLater, onDone, onMute, onOpenFile);
} else {
const Notification = electron.remote.Notification;
const n = new Notification({
title: "Obsidian Reminder",
body: reminder.title
});
n.on("click", () => {
n.close();
this.showBuiltinReminder(reminder, onRemindMeLater, onDone, onMute, onOpenFile);
});
n.on("close", () => {
onMute();
});
{
const laters = SETTINGS.laters.value;
n.on("action", (_, index) => {
if (index === 0) {
onDone();
return;
}
const later = laters[index - 1];
onRemindMeLater(later.later());
});
const actions = [{ type: "button", text: "Mark as Done" }];
laters.forEach((later) => {
actions.push({ type: "button", text: later.label });
});
n.actions = actions;
}
n.show();
}
}
showBuiltinReminder(reminder, onRemindMeLater, onDone, onCancel, onOpenFile) {
new NotificationModal(this.app, this.laters.value, reminder, onRemindMeLater, onDone, onCancel, onOpenFile).open();
}
isSystemNotification() {
if (this.isMobile()) {
return false;
}
return this.useSystemNotification.value;
}
isMobile() {
return electron === void 0;
}
};
var NotificationModal = class extends import_obsidian10.Modal {
constructor(app, laters, reminder, onRemindMeLater, onDone, onCancel, onOpenFile) {
super(app);
this.laters = laters;
this.reminder = reminder;
this.onRemindMeLater = onRemindMeLater;
this.onDone = onDone;
this.onCancel = onCancel;
this.onOpenFile = onOpenFile;
this.canceled = true;
}
onOpen() {
this.reminder.beingDisplayed = true;
let { contentEl } = this;
new Reminder_default({
target: contentEl,
props: {
reminder: this.reminder,
laters: this.laters,
component: this,
onRemindMeLater: (time) => {
this.onRemindMeLater(time);
this.canceled = false;
this.close();
},
onDone: () => {
this.canceled = false;
this.onDone();
this.close();
},
onOpenFile: () => {
this.canceled = true;
this.onOpenFile();
this.close();
},
onMute: () => {
this.canceled = true;
this.close();
}
}
});
}
onClose() {
this.reminder.beingDisplayed = false;
let { contentEl } = this;
contentEl.empty();
if (this.canceled) {
this.onCancel();
}
}
};
// src/ui/reminder-list.ts
var import_obsidian11 = require("obsidian");
// src/constants.ts
var VIEW_TYPE_REMINDER_LIST = "reminder-list";
// src/ui/components/ReminderList.svelte
function get_each_context4(ctx, list, i) {
const child_ctx = ctx.slice();
child_ctx[5] = list[i];
return child_ctx;
}
function create_each_block4(ctx) {
let div;
let t0_value = ctx[5].name + "";
let t0;
let t1;
let reminderlistbydate;
let current;
function func(...args) {
return ctx[4](ctx[5], ...args);
}
reminderlistbydate = new ReminderListByDate_default({
props: {
reminders: ctx[5].reminders,
component: ctx[1],
onOpenReminder: ctx[2],
timeToString: func,
generateLink: ctx[3]
}
});
return {
c() {
div = element("div");
t0 = text(t0_value);
t1 = space();
create_component(reminderlistbydate.$$.fragment);
attr(div, "class", "group-name svelte-2zqui4");
toggle_class(div, "group-name-overdue", ctx[5].isOverdue);
},
m(target, anchor) {
insert(target, div, anchor);
append(div, t0);
insert(target, t1, anchor);
mount_component(reminderlistbydate, target, anchor);
current = true;
},
p(new_ctx, dirty) {
ctx = new_ctx;
if ((!current || dirty & 1) && t0_value !== (t0_value = ctx[5].name + ""))
set_data(t0, t0_value);
if (!current || dirty & 1) {
toggle_class(div, "group-name-overdue", ctx[5].isOverdue);
}
const reminderlistbydate_changes = {};
if (dirty & 1)
reminderlistbydate_changes.reminders = ctx[5].reminders;
if (dirty & 2)
reminderlistbydate_changes.component = ctx[1];
if (dirty & 4)
reminderlistbydate_changes.onOpenReminder = ctx[2];
if (dirty & 1)
reminderlistbydate_changes.timeToString = func;
if (dirty & 8)
reminderlistbydate_changes.generateLink = ctx[3];
reminderlistbydate.$set(reminderlistbydate_changes);
},
i(local) {
if (current)
return;
transition_in(reminderlistbydate.$$.fragment, local);
current = true;
},
o(local) {
transition_out(reminderlistbydate.$$.fragment, local);
current = false;
},
d(detaching) {
if (detaching)
detach(div);
if (detaching)
detach(t1);
destroy_component(reminderlistbydate, detaching);
}
};
}
function create_fragment7(ctx) {
let main;
let div;
let current;
let each_value = ctx[0];
let each_blocks = [];
for (let i = 0; i < each_value.length; i += 1) {
each_blocks[i] = create_each_block4(get_each_context4(ctx, each_value, i));
}
const out = (i) => transition_out(each_blocks[i], 1, 1, () => {
each_blocks[i] = null;
});
return {
c() {
main = element("main");
div = element("div");
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].c();
}
},
m(target, anchor) {
insert(target, main, anchor);
append(main, div);
for (let i = 0; i < each_blocks.length; i += 1) {
each_blocks[i].m(div, null);
}
current = true;
},
p(ctx2, [dirty]) {
if (dirty & 15) {
each_value = ctx2[0];
let i;
for (i = 0; i < each_value.length; i += 1) {
const child_ctx = get_each_context4(ctx2, each_value, i);
if (each_blocks[i]) {
each_blocks[i].p(child_ctx, dirty);
transition_in(each_blocks[i], 1);
} else {
each_blocks[i] = create_each_block4(child_ctx);
each_blocks[i].c();
transition_in(each_blocks[i], 1);
each_blocks[i].m(div, null);
}
}
group_outros();
for (i = each_value.length; i < each_blocks.length; i += 1) {
out(i);
}
check_outros();
}
},
i(local) {
if (current)
return;
for (let i = 0; i < each_value.length; i += 1) {
transition_in(each_blocks[i]);
}
current = true;
},
o(local) {
each_blocks = each_blocks.filter(Boolean);
for (let i = 0; i < each_blocks.length; i += 1) {
transition_out(each_blocks[i]);
}
current = false;
},
d(detaching) {
if (detaching)
detach(main);
destroy_each(each_blocks, detaching);
}
};
}
function instance7($$self, $$props, $$invalidate) {
;
;
let { groups } = $$props;
let { component } = $$props;
let { onOpenReminder } = $$props;
let { generateLink } = $$props;
const func = (group, time) => group.timeToString(time);
$$self.$$set = ($$props2) => {
if ("groups" in $$props2)
$$invalidate(0, groups = $$props2.groups);
if ("component" in $$props2)
$$invalidate(1, component = $$props2.component);
if ("onOpenReminder" in $$props2)
$$invalidate(2, onOpenReminder = $$props2.onOpenReminder);
if ("generateLink" in $$props2)
$$invalidate(3, generateLink = $$props2.generateLink);
};
return [groups, component, onOpenReminder, generateLink, func];
}
var ReminderList = class extends SvelteComponent {
constructor(options) {
super();
init(this, options, instance7, create_fragment7, safe_not_equal, {
groups: 0,
component: 1,
onOpenReminder: 2,
generateLink: 3
});
}
};
var ReminderList_default = ReminderList;
// src/ui/reminder-list.ts
var ReminderListItemView = class extends import_obsidian11.ItemView {
constructor(leaf, reminders, reminderTime, onOpenReminder) {
super(leaf);
this.reminders = reminders;
this.reminderTime = reminderTime;
this.onOpenReminder = onOpenReminder;
}
getViewType() {
return VIEW_TYPE_REMINDER_LIST;
}
getDisplayText() {
return "Reminders";
}
getIcon() {
return "clock";
}
onOpen() {
return __async(this, null, function* () {
this.view = new ReminderList_default({
target: this.contentEl,
props: {
groups: this.remindersForView(),
onOpenReminder: this.onOpenReminder,
component: this,
generateLink: (reminder) => {
const aFile = this.app.vault.getAbstractFileByPath(reminder.file);
const destinationFile = this.app.workspace.getActiveFile();
let linkMd;
if (!(aFile instanceof import_obsidian11.TFile) || destinationFile == null) {
linkMd = `[[${reminder.getFileName()}]]`;
} else {
linkMd = this.app.fileManager.generateMarkdownLink(aFile, destinationFile.path);
}
return `${reminder.title} - ${linkMd}`;
}
}
});
});
}
reload() {
if (this.view == null) {
return;
}
this.view.$set({
groups: this.remindersForView(),
onOpenReminder: this.onOpenReminder
});
}
remindersForView() {
return groupReminders(this.reminders.reminders, this.reminderTime.value);
}
onClose() {
if (this.view) {
this.view.$destroy();
}
return Promise.resolve();
}
};
var ReminderListItemViewProxy = class {
constructor(workspace, reminders, reminderTime, onOpenReminder) {
this.workspace = workspace;
this.reminders = reminders;
this.reminderTime = reminderTime;
this.onOpenReminder = onOpenReminder;
this.valid = false;
}
createView(leaf) {
return new ReminderListItemView(
leaf,
this.reminders,
this.reminderTime,
this.onOpenReminder
);
}
openView() {
if (this.workspace.getLeavesOfType(VIEW_TYPE_REMINDER_LIST).length) {
return;
}
this.workspace.getRightLeaf(false).setViewState({
type: VIEW_TYPE_REMINDER_LIST
});
}
reload(force = false) {
if (force || !this.valid) {
const views = this.getViews();
if (views.length > 0) {
views.forEach((view) => view.reload());
this.valid = true;
} else {
this.valid = false;
console.debug("view is null. Skipping reminder list view reload");
}
}
}
getViews() {
return this.workspace.getLeavesOfType(VIEW_TYPE_REMINDER_LIST).map((leaf) => leaf.view);
}
invalidate() {
this.valid = false;
}
};
// src/ui/util.ts
var electron2 = require("electron");
function showOkCancelDialog(title, message) {
return __async(this, null, function* () {
if (!electron2) {
return 1 /* CANCEL */;
}
const selected = yield electron2.remote.dialog.showMessageBox({
"type": "question",
"title": "Obsidian Reminder",
"message": title,
"detail": message,
buttons: ["OK", "Cancel"],
cancelId: 1
});
if (selected.response === 0) {
return 0 /* OK */;
}
return 1 /* CANCEL */;
});
}
// src/main.ts
var ReminderPlugin = class extends import_obsidian12.Plugin {
constructor(app, manifest) {
super(app, manifest);
this.reminders = new Reminders(() => {
if (this.viewProxy) {
this.viewProxy.invalidate();
}
this.pluginDataIO.changed = true;
});
this.pluginDataIO = new PluginDataIO(this, this.reminders);
this.reminders.reminderTime = SETTINGS.reminderTime;
DATE_TIME_FORMATTER.setTimeFormat(SETTINGS.dateFormat, SETTINGS.dateTimeFormat, SETTINGS.strictDateFormat);
this.editDetector = new EditDetector(SETTINGS.editDetectionSec);
this.viewProxy = new ReminderListItemViewProxy(
app.workspace,
this.reminders,
SETTINGS.reminderTime,
(reminder) => {
if (reminder.muteNotification) {
this.showReminder(reminder);
return;
}
this.openReminderFile(reminder);
}
);
this.remindersController = new RemindersController(
app.vault,
this.viewProxy,
this.reminders
);
this.reminderModal = new ReminderModal(this.app, SETTINGS.useSystemNotification, SETTINGS.laters);
this.autoComplete = new AutoComplete(SETTINGS.autoCompleteTrigger);
}
onload() {
return __async(this, null, function* () {
this.setupUI();
this.setupCommands();
this.app.workspace.onLayoutReady(() => __async(this, null, function* () {
yield this.pluginDataIO.load();
if (this.pluginDataIO.debug.value) {
monkeyPatchConsole(this);
}
this.watchVault();
this.startPeriodicTask();
}));
});
}
setupUI() {
this.registerView(VIEW_TYPE_REMINDER_LIST, (leaf) => {
return this.viewProxy.createView(leaf);
});
this.addSettingTab(
new ReminderSettingTab(this.app, this)
);
this.registerDomEvent(document, "keydown", (evt) => {
this.editDetector.fileChanged();
});
if (import_obsidian12.Platform.isDesktopApp) {
this.registerEditorExtension(buildCodeMirrorPlugin(this.app, this.reminders));
this.registerCodeMirror((cm) => {
const dateTimeChooser = new DateTimeChooserView(cm, this.reminders);
cm.on(
"change",
(cmEditor, changeObj) => {
if (!this.autoComplete.isTrigger(cmEditor, changeObj)) {
dateTimeChooser.cancel();
return;
}
dateTimeChooser.show().then((value) => {
this.autoComplete.insert(cmEditor, value);
}).catch(() => {
});
return;
}
);
});
}
this.app.workspace.onLayoutReady(() => {
this.viewProxy.openView();
});
}
setupCommands() {
this.addCommand({
id: "scan-reminders",
name: "Scan reminders",
checkCallback: (checking) => {
if (checking) {
return true;
}
this.remindersController.reloadAllFiles();
return true;
}
});
this.addCommand({
id: "show-reminders",
name: "Show reminders",
checkCallback: (checking) => {
if (!checking) {
this.showReminderList();
}
return true;
}
});
this.addCommand({
id: "convert-reminder-time-format",
name: "Convert reminder time format",
checkCallback: (checking) => {
if (!checking) {
showOkCancelDialog("Convert reminder time format", "This command rewrite reminder dates in all markdown files. You should make a backup of your vault before you execute this. May I continue to convert?").then((res) => {
if (res !== 0 /* OK */) {
return;
}
openDateTimeFormatChooser(this.app, (dateFormat, dateTimeFormat) => {
this.remindersController.convertDateTimeFormat(dateFormat, dateTimeFormat).catch(() => {
});
});
});
}
return true;
}
});
this.addCommand({
id: "show-date-chooser",
name: "Show calendar popup",
icon: "calendar-with-checkmark",
hotkeys: [
{
modifiers: ["Meta", "Shift"],
key: "2"
}
],
editorCheckCallback: (checking, editor) => {
if (checking) {
return true;
}
this.autoComplete.show(this.app, editor, this.reminders);
}
});
this.addCommand({
id: "toggle-checklist-status",
name: "Toggle checklist status",
hotkeys: [
{
modifiers: ["Meta", "Shift"],
key: "Enter"
}
],
editorCheckCallback: (checking, editor, view) => {
if (checking) {
return true;
}
this.remindersController.toggleCheck(view.file, editor.getCursor().line);
}
});
}
watchVault() {
[
this.app.vault.on("modify", (file) => __async(this, null, function* () {
this.remindersController.reloadFile(file, true);
})),
this.app.vault.on("delete", (file) => {
this.remindersController.removeFile(file.path);
}),
this.app.vault.on("rename", (file, oldPath) => __async(this, null, function* () {
if (yield this.remindersController.removeFile(oldPath)) {
yield this.remindersController.reloadFile(file);
}
}))
].forEach((eventRef) => {
this.registerEvent(eventRef);
});
}
startPeriodicTask() {
let intervalTaskRunning = true;
this.periodicTask().finally(() => {
intervalTaskRunning = false;
});
this.registerInterval(
window.setInterval(() => {
if (intervalTaskRunning) {
console.log(
"Skip reminder interval task because task is already running."
);
return;
}
intervalTaskRunning = true;
this.periodicTask().finally(() => {
intervalTaskRunning = false;
});
}, SETTINGS.reminderCheckIntervalSec.value * 1e3)
);
}
periodicTask() {
return __async(this, null, function* () {
this.viewProxy.reload(false);
if (!this.pluginDataIO.scanned.value) {
this.remindersController.reloadAllFiles().then(() => {
this.pluginDataIO.scanned.value = true;
this.pluginDataIO.save();
});
}
this.pluginDataIO.save(false);
if (this.editDetector.isEditing()) {
return;
}
const expired = this.reminders.getExpiredReminders(
SETTINGS.reminderTime.value
);
let previousReminder = void 0;
for (let reminder of expired) {
if (this.app.workspace.layoutReady) {
if (reminder.muteNotification) {
continue;
}
if (previousReminder) {
while (previousReminder.beingDisplayed) {
yield this.sleep(100);
}
}
this.showReminder(reminder);
previousReminder = reminder;
}
}
});
}
sleep(milliseconds) {
return __async(this, null, function* () {
return new Promise((resolve) => setTimeout(resolve, milliseconds));
});
}
showReminder(reminder) {
reminder.muteNotification = true;
this.reminderModal.show(
reminder,
(time) => {
console.info("Remind me later: time=%o", time);
reminder.time = time;
reminder.muteNotification = false;
this.remindersController.updateReminder(reminder, false);
this.pluginDataIO.save(true);
},
() => {
console.info("done");
reminder.muteNotification = false;
this.remindersController.updateReminder(reminder, true);
this.reminders.removeReminder(reminder);
this.pluginDataIO.save(true);
},
() => {
console.info("Mute");
reminder.muteNotification = true;
this.viewProxy.reload(true);
},
() => {
console.info("Open");
this.openReminderFile(reminder);
}
);
}
openReminderFile(reminder) {
return __async(this, null, function* () {
const leaf = this.app.workspace.getUnpinnedLeaf();
yield this.remindersController.openReminder(reminder, leaf);
});
}
onunload() {
this.app.workspace.getLeavesOfType(VIEW_TYPE_REMINDER_LIST).forEach((leaf) => leaf.detach());
}
showReminderList() {
if (this.app.workspace.getLeavesOfType(VIEW_TYPE_REMINDER_LIST).length) {
return;
}
this.app.workspace.getRightLeaf(false).setViewState({
type: VIEW_TYPE_REMINDER_LIST
});
}
};
var EditDetector = class {
constructor(editDetectionSec) {
this.editDetectionSec = editDetectionSec;
}
fileChanged() {
this.lastModified = new Date();
}
isEditing() {
if (this.editDetectionSec.value <= 0) {
return false;
}
if (this.lastModified == null) {
return false;
}
const elapsedSec = (new Date().getTime() - this.lastModified.getTime()) / 1e3;
return elapsedSec < this.editDetectionSec.value;
}
};
/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
* Based on:
* python-dateutil - Extensions to the standard Python datetime module.
* Copyright (c) 2003-2011 - Gustavo Niemeyer <gustavo@niemeyer.net>
* Copyright (c) 2012 - Tomi Pieviläinen <tomi.pievilainen@iki.fi>
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
*/
/*!
* rrule.js - Library for working with recurrence rules for calendar dates.
* https://github.com/jakubroztocil/rrule
*
* Copyright 2010, Jakub Roztocil and Lars Schoning
* Licenced under the BSD licence.
* https://github.com/jakubroztocil/rrule/blob/master/LICENCE
*
*/
/*! *****************************************************************************
Copyright (c) Microsoft Corporation.
Permission to use, copy, modify, and/or distribute this software for any
purpose with or without fee is hereby granted.
THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH
REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY
AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT,
INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM
LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR
OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
PERFORMANCE OF THIS SOFTWARE.
***************************************************************************** */
//! authors : Tim Wood, Iskren Chernev, Moment.js contributors
//! license : MIT
//! moment.js
//! momentjs.com
//! version : 2.29.4