tods-competition-factory 1.9.3 → 1.9.5

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1828,587 +1828,6 @@ function globalLog$1(engine, log) {
1828
1828
  }
1829
1829
  }
1830
1830
 
1831
- var validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
1832
- var validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
1833
- var dateValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
1834
- var timeValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))?([ T]?(0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
1835
-
1836
- function getIsoDateString(schedule) {
1837
- var scheduledDate = schedule.scheduledDate;
1838
- if (!scheduledDate && schedule.scheduledTime)
1839
- scheduledDate = extractDate(schedule.scheduledTime);
1840
- if (!scheduledDate)
1841
- return;
1842
- var extractedTime = extractTime(schedule.scheduledTime);
1843
- var isoDateString = extractDate(scheduledDate);
1844
- if (isoDateString && extractedTime)
1845
- isoDateString += "T".concat(extractedTime);
1846
- return isoDateString;
1847
- }
1848
- function isDateObject(value) {
1849
- if (typeof value !== 'object' || Array.isArray(value)) {
1850
- return false;
1851
- }
1852
- else {
1853
- var datePrototype = Object.prototype.toString.call(value);
1854
- return datePrototype === '[object Date]';
1855
- }
1856
- }
1857
- function validTimeValue(value) {
1858
- var spaceSplit = typeof value === 'string' ? value === null || value === void 0 ? void 0 : value.split(' ') : [];
1859
- if (value &&
1860
- (spaceSplit === null || spaceSplit === void 0 ? void 0 : spaceSplit.length) > 1 &&
1861
- !['AM', 'PM'].includes(spaceSplit[1].toUpperCase()))
1862
- return false;
1863
- return !!(!value || timeValidation.test(convertTime(value, true, true)));
1864
- }
1865
- function isValidDateString(scheduleDate) {
1866
- return isISODateString(scheduleDate) || validDateString.test(scheduleDate);
1867
- }
1868
- function DateHHMM(date) {
1869
- var dt = new Date(date);
1870
- var secs = dt.getSeconds() + 60 * dt.getMinutes() + 60 * 60 * dt.getHours();
1871
- return HHMMSS(secs, { displaySeconds: false });
1872
- }
1873
- function HHMMSS(s, format) {
1874
- var secondNumber = parseInt(s, 10); // don't forget the second param
1875
- var hours = Math.floor(secondNumber / 3600);
1876
- var minutes = Math.floor((secondNumber - hours * 3600) / 60);
1877
- var seconds = secondNumber - hours * 3600 - minutes * 60;
1878
- var displaySeconds = !format || (format === null || format === void 0 ? void 0 : format.displaySeconds);
1879
- var timeString = displaySeconds
1880
- ? hours + ':' + minutes + ':' + seconds
1881
- : hours + ':' + minutes;
1882
- return timeString.split(':').map(zeroPad).join(':');
1883
- }
1884
- var getUTCdateString = function (date) {
1885
- var dateDate = isDate(date) || isISODateString(date) ? new Date(date) : new Date();
1886
- var monthNumber = dateDate.getUTCMonth() + 1;
1887
- var utcMonth = monthNumber < 10 ? "0".concat(monthNumber) : "".concat(monthNumber);
1888
- return "".concat(dateDate.getUTCFullYear(), "-").concat(zeroPad(utcMonth), "-").concat(zeroPad(dateDate.getUTCDate()));
1889
- };
1890
- function timeUTC(date) {
1891
- var dateDate = isDate(date) || isISODateString(date) ? new Date(date) : new Date();
1892
- return Date.UTC(dateDate.getFullYear(), dateDate.getMonth(), dateDate.getDate());
1893
- }
1894
- function formatDate(date, separator, format) {
1895
- if (separator === void 0) { separator = '-'; }
1896
- if (format === void 0) { format = 'YMD'; }
1897
- if (!date)
1898
- return '';
1899
- if (typeof date === 'string' && date.indexOf('T') < 0)
1900
- date = date + 'T00:00';
1901
- var d = new Date(date);
1902
- var month = '' + (d.getMonth() + 1);
1903
- var day = '' + d.getDate();
1904
- var year = d.getFullYear();
1905
- if (month.length < 2)
1906
- month = '0' + month;
1907
- if (day.length < 2)
1908
- day = '0' + day;
1909
- if (format === 'DMY')
1910
- return [day, month, year].join(separator);
1911
- if (format === 'MDY')
1912
- return [month, day, year].join(separator);
1913
- if (format === 'YDM')
1914
- return [year, day, month].join(separator);
1915
- if (format === 'DYM')
1916
- return [day, year, month].join(separator);
1917
- if (format === 'MYD')
1918
- return [month, year, day].join(separator);
1919
- return [year, month, day].join(separator);
1920
- }
1921
- function offsetDate(date) {
1922
- var targetTime = date ? new Date(date) : new Date();
1923
- var tzDifference = targetTime.getTimezoneOffset();
1924
- return new Date(targetTime.getTime() - tzDifference * 60 * 1000);
1925
- }
1926
- function offsetTime(date) {
1927
- return offsetDate(date).getTime();
1928
- }
1929
- // only returns true for valid date objects
1930
- // dateArg = new Date('xxx') produces 'Invalid Date', which return false
1931
- function isDate(dateArg) {
1932
- if (typeof dateArg == 'boolean')
1933
- return false;
1934
- var t = (dateArg instanceof Date && dateArg) ||
1935
- (!isNaN(dateArg) && new Date(dateArg)) ||
1936
- false;
1937
- return t && !isNaN(t.valueOf());
1938
- }
1939
- function dateRange(startDt, endDt) {
1940
- if (!isValidDateString(startDt) || !isValidDateString(endDt))
1941
- return [];
1942
- var startDateString = extractDate(startDt) + 'T00:00';
1943
- var endDateString = extractDate(endDt) + 'T00:00';
1944
- var startDate = new Date(startDateString);
1945
- var endDate = new Date(endDateString);
1946
- var process = isDate(endDate) &&
1947
- isDate(startDate) &&
1948
- isValidDateRange(startDate, endDate);
1949
- var between = [];
1950
- var iterations = 0;
1951
- if (process) {
1952
- var currentDate = startDate;
1953
- var dateSecs = currentDate.getTime();
1954
- while (dateSecs <= endDate.getTime() && iterations < 300) {
1955
- iterations += 1;
1956
- // must be a *new* Date otherwise it is an array of the same object
1957
- between.push(new Date(currentDate));
1958
- dateSecs = currentDate.setDate(currentDate.getDate() + 1);
1959
- }
1960
- }
1961
- return between.map(function (date) { return formatDate(date); });
1962
- function isValidDateRange(minDate, maxDate) {
1963
- return minDate <= maxDate;
1964
- }
1965
- }
1966
- // matches valid ISO date string
1967
- var re = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
1968
- function isISODateString(dateString) {
1969
- if (typeof dateString !== 'string')
1970
- return false;
1971
- return re.test(dateString);
1972
- }
1973
- function isTimeString(timeString) {
1974
- if (typeof timeString !== 'string')
1975
- return false;
1976
- var noZ = timeString.split('Z')[0];
1977
- var parts = noZ.split(':');
1978
- var isNumeric = parts.every(function (part) { return !isNaN(parseInt(part)); });
1979
- var invalid = parts.length < 2 ||
1980
- !isNumeric ||
1981
- parseInt(parts[0]) > 23 ||
1982
- parseInt(parts[1]) > 60;
1983
- return !invalid;
1984
- }
1985
- function timeStringMinutes(timeString) {
1986
- var validTimeString = extractTime(timeString);
1987
- if (!validTimeString)
1988
- return 0;
1989
- var _a = __read(validTimeString
1990
- .split(':')
1991
- .map(function (value) { return parseInt(value); }), 2), hours = _a[0], minutes = _a[1];
1992
- return hours * 60 + minutes;
1993
- }
1994
- function dayMinutesToTimeString(totalMinutes) {
1995
- var hours = Math.floor(totalMinutes / 60);
1996
- var minutes = totalMinutes - hours * 60;
1997
- if (hours > 23)
1998
- hours = hours % 24;
1999
- return [zeroPad(hours), zeroPad(minutes)].join(':');
2000
- }
2001
- function tidyTime(timeString) {
2002
- return isTimeString(timeString)
2003
- ? timeString.split(':').slice(0, 2).map(zeroPad).join(':')
2004
- : undefined;
2005
- }
2006
- function extractTime(dateString) {
2007
- return isISODateString(dateString) && dateString.indexOf('T') > 0
2008
- ? tidyTime(dateString.split('T').reverse()[0])
2009
- : tidyTime(dateString);
2010
- }
2011
- function extractDate(dateString) {
2012
- return isISODateString(dateString) || dateValidation.test(dateString)
2013
- ? dateString.split('T')[0]
2014
- : undefined;
2015
- }
2016
- function dateStringDaysChange(dateString, daysChange) {
2017
- var date = new Date(dateString);
2018
- date.setDate(date.getDate() + daysChange);
2019
- return extractDate(date.toISOString());
2020
- }
2021
- function splitTime(value) {
2022
- var _a, _b;
2023
- value = typeof value !== 'string' ? '00:00' : value;
2024
- var o = {}, time = {};
2025
- (_a = value.split(' ') || [], o.time = _a[0], o.ampm = _a[1]);
2026
- (_b = o.time.split(':') || [], time.hours = _b[0], time.minutes = _b[1]);
2027
- time.ampm = o.ampm;
2028
- if (isNaN(time.hours) ||
2029
- isNaN(time.minutes) ||
2030
- (time.ampm && !['AM', 'PM'].includes(time.ampm.toUpperCase())))
2031
- return {};
2032
- return time;
2033
- }
2034
- function militaryTime(value) {
2035
- var time = splitTime(value);
2036
- if (time.ampm && time.hours) {
2037
- if (time.ampm.toLowerCase() === 'pm' && parseInt(time.hours) < 12)
2038
- time.hours = ((time.hours && parseInt(time.hours)) || 0) + 12;
2039
- if (time.ampm.toLowerCase() === 'am' && time.hours === '12')
2040
- time.hours = '00';
2041
- }
2042
- var timeString = "".concat(time.hours || '12', ":").concat(time.minutes || '00');
2043
- return timeString.split(':').map(zeroPad).join(':');
2044
- }
2045
- function regularTime(value) {
2046
- var _a;
2047
- var time = splitTime(value);
2048
- if (typeof time === 'object' && !Object.keys(time).length)
2049
- return undefined;
2050
- if (time.ampm)
2051
- return value;
2052
- if (time.hours > 12) {
2053
- time.hours -= 12;
2054
- time.ampm = 'PM';
2055
- }
2056
- else if (time.hours === '12') {
2057
- time.ampm = 'PM';
2058
- }
2059
- else if (time.hours === '00') {
2060
- time.hours = '12';
2061
- time.ampm = 'AM';
2062
- }
2063
- else {
2064
- time.ampm = 'AM';
2065
- }
2066
- if (((_a = time.hours) === null || _a === void 0 ? void 0 : _a[0]) === '0') {
2067
- time.hours = time.hours.slice(1);
2068
- }
2069
- return "".concat(time.hours || '12', ":").concat(time.minutes || '00', " ").concat(time.ampm);
2070
- }
2071
- function convertTime(value, time24, keepDate) {
2072
- var hasDate = extractDate(value);
2073
- var timeString = extractTime(value);
2074
- var timeValue = hasDate ? timeString : value;
2075
- return !value
2076
- ? undefined
2077
- : (time24 && ((hasDate && keepDate && value) || militaryTime(timeValue))) ||
2078
- regularTime(timeValue);
2079
- }
2080
- function timeSort(a, b) {
2081
- var as = splitTime(a);
2082
- var bs = splitTime(b);
2083
- if (parseInt(as.hours) < parseInt(bs.hours))
2084
- return -1;
2085
- if (parseInt(as.hours) > parseInt(bs.hours))
2086
- return 1;
2087
- if (as.hours === bs.hours) {
2088
- if (parseInt(as.minutes) < parseInt(bs.minutes))
2089
- return -1;
2090
- if (parseInt(as.minutes) > parseInt(bs.minutes))
2091
- return 1;
2092
- }
2093
- return 0;
2094
- }
2095
- function addDays(date, days) {
2096
- if (days === void 0) { days = 7; }
2097
- var universalDate = extractDate(date) + 'T00:00';
2098
- var now = new Date(universalDate);
2099
- var adjustedDate = new Date(now.setDate(now.getDate() + days));
2100
- return formatDate(adjustedDate);
2101
- }
2102
- function addWeek(date) {
2103
- return addDays(date);
2104
- }
2105
- function getDateByWeek(week, year, dateFormat, sunday) {
2106
- if (sunday === void 0) { sunday = false; }
2107
- var date = new Date(year, 0, 1 + (week - 1) * 7);
2108
- var startValue = sunday ? 0 : 1;
2109
- date.setDate(date.getDate() + (startValue - date.getDay()));
2110
- return formatDate(date, dateFormat);
2111
- }
2112
- function dateFromDay(year, day, dateFormat) {
2113
- var date = new Date(year, 0); // initialize a date in `year-01-01`
2114
- return formatDate(new Date(date.setDate(day)), dateFormat); // add the number of days
2115
- }
2116
- function timeToDate(timeString, date) {
2117
- if (date === void 0) { date = undefined; }
2118
- var _a = __read((timeString || '00:00').split(':').map(zeroPad), 2), hours = _a[0], minutes = _a[1];
2119
- var milliseconds = offsetDate(date).setHours(hours, minutes, 0, 0);
2120
- return offsetDate(milliseconds);
2121
- }
2122
- function minutesDifference(date1, date2, absolute) {
2123
- if (absolute === void 0) { absolute = true; }
2124
- var dt1 = new Date(date1);
2125
- var dt2 = new Date(date2);
2126
- var diff = (dt2.getTime() - dt1.getTime()) / 1000 / 60;
2127
- return absolute ? Math.abs(Math.round(diff)) : Math.round(diff);
2128
- }
2129
- function addMinutesToTimeString(timeString, minutes) {
2130
- var validTimeString = extractTime(timeString);
2131
- if (!validTimeString)
2132
- return '00:00';
2133
- var minutesToAdd = isNaN(minutes) ? 0 : minutes;
2134
- return extractTime(addMinutes(timeToDate(validTimeString), minutesToAdd).toISOString());
2135
- }
2136
- function addMinutes(startDate, minutes) {
2137
- var date = new Date(startDate);
2138
- return new Date(date.getTime() + minutes * 60000);
2139
- }
2140
- function zeroPad(number) {
2141
- return number.toString()[1] ? number : '0' + number;
2142
- }
2143
- function sameDay(date1, date2) {
2144
- var d1 = new Date(date1);
2145
- var d2 = new Date(date2);
2146
- return (d1.getFullYear() === d2.getFullYear() &&
2147
- d1.getMonth() === d2.getMonth() &&
2148
- d1.getDate() === d2.getDate());
2149
- }
2150
- var dateTime = {
2151
- addDays: addDays,
2152
- addWeek: addWeek,
2153
- addMinutesToTimeString: addMinutesToTimeString,
2154
- convertTime: convertTime,
2155
- getIsoDateString: getIsoDateString,
2156
- getUTCdateString: getUTCdateString,
2157
- DateHHMM: DateHHMM,
2158
- extractDate: extractDate,
2159
- extractTime: extractTime,
2160
- formatDate: formatDate,
2161
- getDateByWeek: getDateByWeek,
2162
- isISODateString: isISODateString,
2163
- isDate: isDate,
2164
- isTimeString: isTimeString,
2165
- offsetDate: offsetDate,
2166
- offsetTime: offsetTime,
2167
- sameDay: sameDay,
2168
- timeStringMinutes: timeStringMinutes,
2169
- timeToDate: timeToDate,
2170
- timeUTC: timeUTC,
2171
- validTimeValue: validTimeValue,
2172
- validDateString: validDateString,
2173
- timeValidation: timeValidation,
2174
- dateValidation: dateValidation,
2175
- };
2176
-
2177
- function makeDeepCopy(sourceObject, // arbitrary JSON object; functions will be stripped.
2178
- convertExtensions, // optional - all extension objects converted to attributes ._key
2179
- internalUse, // disregard deepCopy being disabled within the engine - necessary for query results
2180
- removeExtensions, // optional - strip all extension attributes
2181
- iteration // escape hatch - check against iteration threshold
2182
- ) {
2183
- var e_1, _a;
2184
- if (iteration === void 0) { iteration = 0; }
2185
- if (getProvider().makeDeepCopy)
2186
- return getProvider().makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtensions);
2187
- var deepCopy = deepCopyEnabled();
2188
- var _b = deepCopy || {}, stringify = _b.stringify, toJSON = _b.toJSON, ignore = _b.ignore, modulate = _b.modulate;
2189
- if ((!(deepCopy === null || deepCopy === void 0 ? void 0 : deepCopy.enabled) && !internalUse) ||
2190
- typeof sourceObject !== 'object' ||
2191
- typeof sourceObject === 'function' ||
2192
- sourceObject === null ||
2193
- (typeof (deepCopy === null || deepCopy === void 0 ? void 0 : deepCopy.threshold) === 'number' && iteration >= deepCopy.threshold)) {
2194
- return sourceObject;
2195
- }
2196
- var targetObject = Array.isArray(sourceObject) ? [] : {};
2197
- var sourceObjectKeys = Object.keys(sourceObject).filter(function (key) {
2198
- return !internalUse ||
2199
- !ignore ||
2200
- (Array.isArray(ignore) && !ignore.includes(key)) ||
2201
- (typeof ignore === 'function' && !ignore(key));
2202
- });
2203
- var stringifyValue = function (key, value) {
2204
- targetObject[key] =
2205
- typeof (value === null || value === void 0 ? void 0 : value.toString) === 'function'
2206
- ? value.toString()
2207
- : JSON.stringify(value);
2208
- };
2209
- try {
2210
- for (var sourceObjectKeys_1 = __values(sourceObjectKeys), sourceObjectKeys_1_1 = sourceObjectKeys_1.next(); !sourceObjectKeys_1_1.done; sourceObjectKeys_1_1 = sourceObjectKeys_1.next()) {
2211
- var key = sourceObjectKeys_1_1.value;
2212
- var value = sourceObject[key];
2213
- var modulated = typeof modulate === 'function' ? modulate(value) : undefined;
2214
- if (modulated !== undefined) {
2215
- targetObject[key] = modulated;
2216
- }
2217
- else if (convertExtensions &&
2218
- key === 'extensions' &&
2219
- Array.isArray(value)) {
2220
- var extensionConversions = extensionsToAttributes(value);
2221
- Object.assign.apply(Object, __spreadArray([targetObject], __read(extensionConversions), false));
2222
- }
2223
- else if (removeExtensions && key === 'extensions') {
2224
- targetObject[key] = [];
2225
- }
2226
- else if (Array.isArray(stringify) && stringify.includes(key)) {
2227
- stringifyValue(key, value);
2228
- }
2229
- else if (Array.isArray(toJSON) &&
2230
- toJSON.includes(key) &&
2231
- typeof (value === null || value === void 0 ? void 0 : value.toJSON) === 'function') {
2232
- targetObject[key] = value.toJSON();
2233
- }
2234
- else if (value === null) {
2235
- targetObject[key] = undefined;
2236
- }
2237
- else if (isDateObject(value)) {
2238
- targetObject[key] = new Date(value).toISOString();
2239
- }
2240
- else {
2241
- targetObject[key] = makeDeepCopy(value, convertExtensions, internalUse, removeExtensions, iteration + 1);
2242
- }
2243
- }
2244
- }
2245
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2246
- finally {
2247
- try {
2248
- if (sourceObjectKeys_1_1 && !sourceObjectKeys_1_1.done && (_a = sourceObjectKeys_1.return)) _a.call(sourceObjectKeys_1);
2249
- }
2250
- finally { if (e_1) throw e_1.error; }
2251
- }
2252
- return targetObject;
2253
- }
2254
- function extensionsToAttributes(extensions) {
2255
- return extensions === null || extensions === void 0 ? void 0 : extensions.map(function (extension) {
2256
- var _a;
2257
- var name = extension.name, value = extension.value;
2258
- return name && value && (_a = {}, _a["_".concat(name)] = value, _a);
2259
- }).filter(Boolean);
2260
- }
2261
-
2262
- function getAccessorValue(_a) {
2263
- var element = _a.element, accessor = _a.accessor;
2264
- if (typeof accessor !== 'string')
2265
- return { values: [] };
2266
- var targetElement = makeDeepCopy(element);
2267
- var attributes = accessor.split('.');
2268
- var values = [];
2269
- var value;
2270
- processKeys({ targetElement: targetElement, attributes: attributes });
2271
- var result = { value: value };
2272
- if (values.length)
2273
- result.values = values;
2274
- return result;
2275
- function processKeys(_a) {
2276
- var e_1, _b;
2277
- var targetElement = _a.targetElement, _c = _a.attributes, attributes = _c === void 0 ? [] : _c, significantCharacters = _a.significantCharacters;
2278
- var _loop_1 = function (index, attribute) {
2279
- if (targetElement === null || targetElement === void 0 ? void 0 : targetElement[attribute]) {
2280
- var remainingKeys_1 = attributes.slice(index + 1);
2281
- if (!remainingKeys_1.length) {
2282
- if (!value)
2283
- value = targetElement[attribute];
2284
- if (!values.includes(targetElement[attribute])) {
2285
- values.push(targetElement[attribute]);
2286
- }
2287
- }
2288
- else if (Array.isArray(targetElement[attribute])) {
2289
- var values_1 = targetElement[attribute];
2290
- values_1.forEach(function (nestedTarget) {
2291
- return processKeys({
2292
- targetElement: nestedTarget,
2293
- attributes: remainingKeys_1,
2294
- });
2295
- });
2296
- }
2297
- else {
2298
- targetElement = targetElement[attribute];
2299
- checkValue({ targetElement: targetElement, index: index });
2300
- }
2301
- }
2302
- };
2303
- try {
2304
- for (var _d = __values(attributes.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
2305
- var _f = __read(_e.value, 2), index = _f[0], attribute = _f[1];
2306
- _loop_1(index, attribute);
2307
- }
2308
- }
2309
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2310
- finally {
2311
- try {
2312
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
2313
- }
2314
- finally { if (e_1) throw e_1.error; }
2315
- }
2316
- function checkValue(_a) {
2317
- var targetElement = _a.targetElement, index = _a.index;
2318
- if (targetElement &&
2319
- index === attributes.length - 1 &&
2320
- ['string', 'number'].includes(typeof targetElement)) {
2321
- var extractedValue = significantCharacters
2322
- ? targetElement.slice(0, significantCharacters)
2323
- : targetElement;
2324
- if (value) {
2325
- if (!values.includes(extractedValue)) {
2326
- values.push(extractedValue);
2327
- }
2328
- }
2329
- else {
2330
- value = extractedValue;
2331
- values.push(extractedValue);
2332
- }
2333
- }
2334
- }
2335
- }
2336
- }
2337
-
2338
- function isString(obj) {
2339
- return typeof obj === 'string';
2340
- }
2341
- function isObject(obj) {
2342
- return obj !== null && typeof obj === 'object';
2343
- }
2344
- function objShallowEqual(o1, o2) {
2345
- var e_1, _a;
2346
- if (!isObject(o1) || !isObject(o2))
2347
- return false;
2348
- var keys1 = Object.keys(o1);
2349
- var keys2 = Object.keys(o2);
2350
- if (keys1.length !== keys2.length) {
2351
- return false;
2352
- }
2353
- try {
2354
- for (var keys1_1 = __values(keys1), keys1_1_1 = keys1_1.next(); !keys1_1_1.done; keys1_1_1 = keys1_1.next()) {
2355
- var key = keys1_1_1.value;
2356
- if (o1[key] !== o2[key]) {
2357
- return false;
2358
- }
2359
- }
2360
- }
2361
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2362
- finally {
2363
- try {
2364
- if (keys1_1_1 && !keys1_1_1.done && (_a = keys1_1.return)) _a.call(keys1_1);
2365
- }
2366
- finally { if (e_1) throw e_1.error; }
2367
- }
2368
- return true;
2369
- }
2370
- function createMap(objectArray, attribute) {
2371
- if (!Array.isArray(objectArray))
2372
- return {};
2373
- return Object.assign.apply(Object, __spreadArray([{}], __read((objectArray !== null && objectArray !== void 0 ? objectArray : [])
2374
- .filter(isObject)
2375
- .map(function (obj) {
2376
- var _a;
2377
- return (obj[attribute] && (_a = {},
2378
- _a[obj[attribute]] = obj,
2379
- _a));
2380
- })
2381
- .filter(Boolean)), false));
2382
- }
2383
- // e.g. result.find(hav({ attr: value })) -or- result.filter(hav({ attr: value }))
2384
- var hasAttributeValues = function (a) { return function (o) {
2385
- return Object.keys(a).every(function (key) { return o[key] === a[key]; });
2386
- }; };
2387
- // extracts targeted attributes
2388
- // e.g. const byeAssignments = positionAssignments.filter(xa('bye')).map(xa('drawPosition'));
2389
- // supports xa('string'), xa(['string', 'string']), xa({ attr1: true, attr2: true })
2390
- var extractAttributes = function (accessor) { return function (element) {
2391
- var _a;
2392
- return !accessor || typeof element !== 'object'
2393
- ? undefined
2394
- : (Array.isArray(accessor) &&
2395
- accessor.map(function (a) {
2396
- var _a;
2397
- var _b;
2398
- return (_a = {},
2399
- _a[a] = (_b = getAccessorValue({ element: element, accessor: a })) === null || _b === void 0 ? void 0 : _b.value,
2400
- _a);
2401
- })) ||
2402
- (typeof accessor === 'object' &&
2403
- Object.keys(accessor).map(function (key) {
2404
- var _a;
2405
- var _b;
2406
- return (_a = {},
2407
- _a[key] = (_b = getAccessorValue({ element: element, accessor: key })) === null || _b === void 0 ? void 0 : _b.value,
2408
- _a);
2409
- })) ||
2410
- ((_a = (typeof accessor === 'string' && getAccessorValue({ element: element, accessor: accessor }))) === null || _a === void 0 ? void 0 : _a.value);
2411
- }; };
2412
1831
  function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
2413
1832
  return Object.keys(obj).filter(function (key) {
2414
1833
  return !ignoreValues.includes(obj[key]) &&
@@ -2435,337 +1854,6 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2435
1854
  _a) : (_b = {}, _b[key] = shallow ? obj[key] : definedAttributes(obj[key]), _b);
2436
1855
  })), false));
2437
1856
  }
2438
- function countKeys(o) {
2439
- if (Array.isArray(o)) {
2440
- return o.length + o.map(countKeys).reduce(function (a, b) { return a + b; }, 0);
2441
- }
2442
- else if (typeof o === 'object' && o !== null) {
2443
- return (Object.keys(o).length +
2444
- Object.keys(o)
2445
- .map(function (k) { return countKeys(o[k]); })
2446
- .reduce(function (a, b) { return a + b; }, 0));
2447
- }
2448
- return 0;
2449
- }
2450
- function generateHashCode(o) {
2451
- if (o === null || typeof o !== 'object')
2452
- return undefined;
2453
- var str = JSON.stringify(o);
2454
- var keyCount = countKeys(o);
2455
- var charSum = str.split('').reduce(function (a, b) { return a + b.charCodeAt(0); }, 0);
2456
- return [str.length, keyCount, charSum].map(function (e) { return e.toString(36); }).join('');
2457
- }
2458
-
2459
- // NOTE: type really does need to be any!
2460
- function attributeFilter(params) {
2461
- if (params === null)
2462
- return {};
2463
- var _a = params || {}, source = _a.source, template = _a.template;
2464
- if (!template)
2465
- return source;
2466
- var target = {};
2467
- attributeCopy(source, template, target);
2468
- return target;
2469
- function attributeCopy(valuesObject, templateObject, outputObject) {
2470
- var e_1, _a;
2471
- if (!valuesObject || !templateObject)
2472
- return undefined;
2473
- var vKeys = Object.keys(valuesObject);
2474
- var oKeys = Object.keys(templateObject);
2475
- // the orMap allows spcification of { 'a||b': boolean } so that filter templates can apply to multiple attributes
2476
- var orMap = Object.assign.apply(Object, __spreadArray([{}], __read(oKeys
2477
- .filter(function (key) { return key.indexOf('||'); })
2478
- .map(function (key) { return key.split('||').map(function (or) {
2479
- var _a;
2480
- return (_a = {}, _a[or] = key, _a);
2481
- }); })
2482
- .flat()), false));
2483
- var allKeys = oKeys.concat.apply(oKeys, __spreadArray([], __read(Object.keys(orMap)), false));
2484
- var wildcard = allKeys.includes('*');
2485
- var _loop_1 = function (vKey) {
2486
- if (allKeys.indexOf(vKey) >= 0 || wildcard) {
2487
- var templateKey = orMap[vKey] || vKey;
2488
- var tobj_1 = templateObject[templateKey] || wildcard;
2489
- var vobj = valuesObject[vKey];
2490
- if (typeof tobj_1 === 'object' &&
2491
- typeof vobj !== 'function' &&
2492
- !Array.isArray(tobj_1)) {
2493
- if (Array.isArray(vobj)) {
2494
- var mappedElements = vobj
2495
- .map(function (arrayMember) {
2496
- var target = {};
2497
- var result = attributeCopy(arrayMember, tobj_1, target);
2498
- return result !== false ? target : undefined;
2499
- })
2500
- .filter(Boolean);
2501
- outputObject[vKey] = mappedElements;
2502
- }
2503
- else if (vobj) {
2504
- outputObject[vKey] = {};
2505
- attributeCopy(vobj, tobj_1, outputObject[vKey]);
2506
- }
2507
- }
2508
- else {
2509
- var value = valuesObject[vKey];
2510
- var exclude = Array.isArray(tobj_1) && !tobj_1.includes(value);
2511
- if (exclude)
2512
- return { value: false };
2513
- if (templateObject[vKey] ||
2514
- (wildcard && templateObject[vKey] !== false)) {
2515
- outputObject[vKey] = value;
2516
- }
2517
- }
2518
- }
2519
- };
2520
- try {
2521
- for (var vKeys_1 = __values(vKeys), vKeys_1_1 = vKeys_1.next(); !vKeys_1_1.done; vKeys_1_1 = vKeys_1.next()) {
2522
- var vKey = vKeys_1_1.value;
2523
- var state_1 = _loop_1(vKey);
2524
- if (typeof state_1 === "object")
2525
- return state_1.value;
2526
- }
2527
- }
2528
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
2529
- finally {
2530
- try {
2531
- if (vKeys_1_1 && !vKeys_1_1.done && (_a = vKeys_1.return)) _a.call(vKeys_1);
2532
- }
2533
- finally { if (e_1) throw e_1.error; }
2534
- }
2535
- return undefined;
2536
- }
2537
- }
2538
-
2539
- function generateTimeCode(index) {
2540
- if (index === void 0) { index = 0; }
2541
- var uidate = new Date();
2542
- uidate.setHours(uidate.getHours() + index);
2543
- return uidate.getTime().toString(36).slice(-6).toUpperCase();
2544
- }
2545
-
2546
- /**
2547
- *
2548
- * @param {object[]} arrayOfJSON - JSON objects array
2549
- * @param {object} config - object which configures processing (see below)
2550
- * @returns {string} - joined by '\r\n' or specified line separator
2551
- *
2552
- * config {
2553
- * {boolean} includeTransformAccessors, // transform accessors are included with columnAccessors
2554
- * {string[]} columnAccessors, // [ 'includeThis', 'andThis' ]
2555
- * {object} columnTransform, // e.g. { 'newColumnName': ['oldColumn1', 'oldColumn2' ]}
2556
- * {object} columnMap, // e.g. { 'columnName': 'newColumnName' }
2557
- * {object} valuesMap, // e.g. { 'columnName': { 'value1': 'mappedValue' }} // useful for mapping IDs
2558
- * {array} sortOrder // e.g. ['columnName1', 'columnName2'] // determine order of csv columns
2559
- * {object} context, // attributes which are to be added to all rows { 'columnName': 'value }
2560
- * {string} delimiter, // defaults to '"'
2561
- * {string} columnJoiner, // defaults to ',' // defines how CSV columns are joined
2562
- * {string} rowJoiner, // defaults to '\r\n' // defines how CSV lines are joined
2563
- * {string} keyJoiner, // defaults to '.' // defines how flattened column names are constructed
2564
- * }
2565
- *
2566
- * NOTE: `columnTransform` mapped array elements are sensitive to order and will resolve to the first matching value
2567
- * NOTE: `columnMap` should not contain new columnName(s) that are `columnTransform` keys
2568
- */
2569
- function JSON2CSV(arrayOfJSON, config) {
2570
- if (config && typeof config !== 'object')
2571
- return INVALID_VALUES;
2572
- var _a = (config || {}).columnTransform, columnTransform = _a === void 0 ? {} : _a;
2573
- var _b = config || {}, includeTransformAccessors = _b.includeTransformAccessors, _c = _b.includeHeaderRow, includeHeaderRow = _c === void 0 ? true : _c, returnTransformedJSON = _b.returnTransformedJSON, removeEmptyColumns = _b.removeEmptyColumns, onlyHeaderRow = _b.onlyHeaderRow, _d = _b.columnAccessors, columnAccessors = _d === void 0 ? [] : _d, _e = _b.functionMap, functionMap = _e === void 0 ? {} : _e, _f = _b.columnMap, columnMap = _f === void 0 ? {} : _f, _g = _b.valuesMap, valuesMap = _g === void 0 ? {} : _g, _h = _b.context, context = _h === void 0 ? {} : _h, _j = _b.delimiter, delimiter = _j === void 0 ? '"' : _j, _k = _b.columnJoiner, columnJoiner = _k === void 0 ? ',' : _k, _l = _b.rowJoiner, rowJoiner = _l === void 0 ? '\r\n' : _l, _m = _b.keyJoiner, keyJoiner = _m === void 0 ? '.' : _m;
2574
- if (!Array.isArray(arrayOfJSON) ||
2575
- !Array.isArray(columnAccessors) ||
2576
- typeof context !== 'object' ||
2577
- typeof columnMap !== 'object' ||
2578
- typeof columnTransform !== 'object' ||
2579
- typeof functionMap !== 'object' ||
2580
- typeof valuesMap !== 'object' ||
2581
- typeof columnJoiner !== 'string' ||
2582
- typeof rowJoiner !== 'string' ||
2583
- typeof keyJoiner !== 'string' ||
2584
- typeof delimiter !== 'string')
2585
- return INVALID_VALUES;
2586
- // ensure all column transformers are arrays
2587
- columnTransform = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
2588
- .reverse() // reverse so that exported CSV columns are in the order as defined
2589
- .map(function (key) {
2590
- var _a;
2591
- return (_a = {},
2592
- _a[key] = Array.isArray(columnTransform[key])
2593
- ? columnTransform[key]
2594
- : [
2595
- // ensure transform attributes are strings
2596
- typeof columnTransform[key] === 'string' && columnTransform[key],
2597
- ].filter(Boolean),
2598
- _a);
2599
- })), false));
2600
- var flattened = arrayOfJSON
2601
- .filter(Boolean)
2602
- .map(function (obj) { return flattenJSON(obj, keyJoiner); });
2603
- var transformColumns = Object.values(columnTransform).flat();
2604
- if (includeTransformAccessors)
2605
- columnAccessors.push.apply(columnAccessors, __spreadArray([], __read(transformColumns), false));
2606
- var headerRow = flattened
2607
- .reduce(function (aggregator, row) {
2608
- return Object.keys(row).every(function (key) { return (!aggregator.includes(key) && aggregator.push(key)) || true; }) && aggregator;
2609
- }, [])
2610
- .filter(function (key) { return !(columnAccessors === null || columnAccessors === void 0 ? void 0 : columnAccessors.length) || columnAccessors.includes(key); });
2611
- var accessorMap = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
2612
- .reverse() // so that original order is preserved when later pushed
2613
- .map(function (transform) {
2614
- return columnTransform[transform]
2615
- .map(function (value) {
2616
- var _a;
2617
- return (_a = {}, _a[value] = transform, _a);
2618
- })
2619
- .flat();
2620
- })
2621
- .flat()), false));
2622
- var sortColumns = function (a, b) {
2623
- return !(config === null || config === void 0 ? void 0 : config.sortOrder)
2624
- ? 0
2625
- : (config.sortOrder.includes(a) &&
2626
- config.sortOrder.includes(b) &&
2627
- config.sortOrder.indexOf(a) - config.sortOrder.indexOf(b)) ||
2628
- (!config.sortOrder.includes(b) && -1);
2629
- };
2630
- var tranformedHeaderRow = headerRow
2631
- .reduce(function (def, key) {
2632
- var transform = accessorMap[key];
2633
- if (transform) {
2634
- if (!def.includes(transform))
2635
- def.push(transform);
2636
- }
2637
- else {
2638
- def.push(key);
2639
- }
2640
- return def;
2641
- }, [])
2642
- .sort(sortColumns);
2643
- Object.keys(columnMap).forEach(function (columnName) {
2644
- return !tranformedHeaderRow.includes(columnName) &&
2645
- tranformedHeaderRow.unshift(columnName);
2646
- });
2647
- Object.keys(columnTransform).forEach(function (columnName) {
2648
- return !tranformedHeaderRow.includes(columnName) &&
2649
- tranformedHeaderRow.unshift(columnName);
2650
- });
2651
- typeof context === 'object' &&
2652
- Object.keys(context).forEach(function (columnName) {
2653
- return !tranformedHeaderRow.includes(columnName) &&
2654
- tranformedHeaderRow.unshift(columnName);
2655
- });
2656
- var mappedHeaderRow = tranformedHeaderRow.map(function (key) { return columnMap[key] || key; });
2657
- if (onlyHeaderRow)
2658
- return [mappedHeaderRow];
2659
- var withDelimiter = function (value) { return "".concat(delimiter).concat(value).concat(delimiter); };
2660
- var columnValueCounts = [];
2661
- var processRow = function (row) {
2662
- return Object.values(tranformedHeaderRow.reduce(function (columnsMap, columnName, columnIndex) {
2663
- var _a;
2664
- var accessors = columnTransform[columnName];
2665
- var value = ((accessors === null || accessors === void 0 ? void 0 : accessors.length)
2666
- ? row[accessors.find(function (accessor) { return row[accessor]; })]
2667
- : row[columnName]) ||
2668
- (context === null || context === void 0 ? void 0 : context[columnName]) ||
2669
- '';
2670
- var mappedValue = ((_a = valuesMap[columnName]) === null || _a === void 0 ? void 0 : _a[value]) || value;
2671
- var fxValue = typeof functionMap[columnName] === 'function'
2672
- ? functionMap[columnName](mappedValue)
2673
- : mappedValue;
2674
- columnsMap[columnName] = withDelimiter(fxValue);
2675
- if (fxValue) {
2676
- columnValueCounts[columnIndex] =
2677
- (columnValueCounts[columnIndex] || 0) + 1;
2678
- }
2679
- return columnsMap;
2680
- }, {}));
2681
- };
2682
- var flattenedRows = flattened.map(processRow);
2683
- var indicesToRemove = removeEmptyColumns &&
2684
- __spreadArray([], __read(columnValueCounts), false).map(function (count, index) { return !count && index; })
2685
- .filter(isNumeric)
2686
- .reverse();
2687
- if (indicesToRemove) {
2688
- var purge = function (row) {
2689
- return row.filter(function (_, index) { return !indicesToRemove.includes(index); });
2690
- };
2691
- flattenedRows = flattenedRows.map(purge);
2692
- mappedHeaderRow = purge(mappedHeaderRow);
2693
- }
2694
- var rows = flattenedRows.map(function (row) { return row.join(columnJoiner); });
2695
- if (returnTransformedJSON) {
2696
- return rows.map(function (row) {
2697
- var columnValues = row.split(columnJoiner);
2698
- return Object.assign.apply(Object, __spreadArray([{}], __read(columnValues.map(function (v, i) {
2699
- var _a;
2700
- return (_a = {}, _a[mappedHeaderRow[i]] = v, _a);
2701
- })), false));
2702
- });
2703
- }
2704
- return includeHeaderRow
2705
- ? __spreadArray([mappedHeaderRow.map(withDelimiter).join(columnJoiner)], __read(rows), false).join(rowJoiner)
2706
- : rows.join(rowJoiner);
2707
- }
2708
- function flattenJSON(obj, keyJoiner, path) {
2709
- if (keyJoiner === void 0) { keyJoiner = '.'; }
2710
- if (path === void 0) { path = []; }
2711
- return (typeof obj === 'object' &&
2712
- Object.keys(obj).reduce(function (result, key) {
2713
- if (typeof obj[key] !== 'object') {
2714
- result[path.concat(key).join(keyJoiner)] = obj[key];
2715
- return result;
2716
- }
2717
- return Object.assign(result, flattenJSON(obj[key], keyJoiner, path.concat(key)));
2718
- }, {}));
2719
- }
2720
-
2721
- /*
2722
- based on an answer provided by Jeff Ward on StackOverflow; November 2019
2723
- https://stackoverflow.com/users/1026023/jeff-ward
2724
- https://stackoverflow.com/questions/105034/how-to-create-guid-uuid?rq=1
2725
- */
2726
- /**
2727
- * generate a given number of UUIDs
2728
- *
2729
- * @param {number} count - number of UUIDs to generate
2730
- */
2731
- function UUIDS(count) {
2732
- if (count === void 0) { count = 1; }
2733
- return generateRange(0, count).map(UUID);
2734
- }
2735
- function UUID() {
2736
- var lut = [];
2737
- for (var i = 0; i < 256; i++) {
2738
- lut[i] = (i < 16 ? '0' : '') + i.toString(16);
2739
- }
2740
- var d0 = (Math.random() * 0xffffffff) | 0;
2741
- var d1 = (Math.random() * 0xffffffff) | 0;
2742
- var d2 = (Math.random() * 0xffffffff) | 0;
2743
- var d3 = (Math.random() * 0xffffffff) | 0;
2744
- // eslint-disable-next-line no-mixed-operators
2745
- return (lut[d0 & 0xff] +
2746
- lut[(d0 >> 8) & 0xff] +
2747
- lut[(d0 >> 16) & 0xff] +
2748
- lut[(d0 >> 24) & 0xff] +
2749
- '-' +
2750
- // eslint-disable-next-line no-mixed-operators
2751
- lut[d1 & 0xff] +
2752
- lut[(d1 >> 8) & 0xff] +
2753
- '-' +
2754
- lut[((d1 >> 16) & 0x0f) | 0x40] +
2755
- lut[(d1 >> 24) & 0xff] +
2756
- '-' +
2757
- // eslint-disable-next-line no-mixed-operators
2758
- lut[(d2 & 0x3f) | 0x80] +
2759
- lut[(d2 >> 8) & 0xff] +
2760
- '-' +
2761
- lut[(d2 >> 16) & 0xff] +
2762
- lut[(d2 >> 24) & 0xff] +
2763
- // eslint-disable-next-line no-mixed-operators
2764
- lut[d3 & 0xff] +
2765
- lut[(d3 >> 8) & 0xff] +
2766
- lut[(d3 >> 16) & 0xff] +
2767
- lut[(d3 >> 24) & 0xff]);
2768
- }
2769
1857
 
2770
1858
  function parse(matchUpFormatCode) {
2771
1859
  if (typeof matchUpFormatCode === 'string') {
@@ -2946,7 +2034,7 @@ var matchUpFormatCode = {
2946
2034
  };
2947
2035
 
2948
2036
  function factoryVersion() {
2949
- return '1.9.3';
2037
+ return '1.9.5';
2950
2038
  }
2951
2039
 
2952
2040
  function getObjectTieFormat(obj) {
@@ -3622,16 +2710,362 @@ function tieFormatGenderValidityCheck(params) {
3622
2710
  stack: stack,
3623
2711
  });
3624
2712
  }
3625
- if (referenceGender === ANY &&
3626
- gender === MIXED &&
3627
- matchUpType !== TypeEnum.Doubles)
3628
- return decorateResult({
3629
- result: { error: INVALID_GENDER, valid: false },
3630
- info: anyMixedError,
3631
- stack: stack,
3632
- });
3633
- return { valid: true };
2713
+ if (referenceGender === ANY &&
2714
+ gender === MIXED &&
2715
+ matchUpType !== TypeEnum.Doubles)
2716
+ return decorateResult({
2717
+ result: { error: INVALID_GENDER, valid: false },
2718
+ info: anyMixedError,
2719
+ stack: stack,
2720
+ });
2721
+ return { valid: true };
2722
+ }
2723
+
2724
+ var validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
2725
+ var validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
2726
+ var dateValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
2727
+ var timeValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))?([ T]?(0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
2728
+
2729
+ function getIsoDateString(schedule) {
2730
+ var scheduledDate = schedule.scheduledDate;
2731
+ if (!scheduledDate && schedule.scheduledTime)
2732
+ scheduledDate = extractDate(schedule.scheduledTime);
2733
+ if (!scheduledDate)
2734
+ return;
2735
+ var extractedTime = extractTime(schedule.scheduledTime);
2736
+ var isoDateString = extractDate(scheduledDate);
2737
+ if (isoDateString && extractedTime)
2738
+ isoDateString += "T".concat(extractedTime);
2739
+ return isoDateString;
2740
+ }
2741
+ function isDateObject(value) {
2742
+ if (typeof value !== 'object' || Array.isArray(value)) {
2743
+ return false;
2744
+ }
2745
+ else {
2746
+ var datePrototype = Object.prototype.toString.call(value);
2747
+ return datePrototype === '[object Date]';
2748
+ }
2749
+ }
2750
+ function validTimeValue(value) {
2751
+ var spaceSplit = typeof value === 'string' ? value === null || value === void 0 ? void 0 : value.split(' ') : [];
2752
+ if (value &&
2753
+ (spaceSplit === null || spaceSplit === void 0 ? void 0 : spaceSplit.length) > 1 &&
2754
+ !['AM', 'PM'].includes(spaceSplit[1].toUpperCase()))
2755
+ return false;
2756
+ return !!(!value || timeValidation.test(convertTime(value, true, true)));
2757
+ }
2758
+ function isValidDateString(scheduleDate) {
2759
+ return isISODateString(scheduleDate) || validDateString.test(scheduleDate);
2760
+ }
2761
+ function DateHHMM(date) {
2762
+ var dt = new Date(date);
2763
+ var secs = dt.getSeconds() + 60 * dt.getMinutes() + 60 * 60 * dt.getHours();
2764
+ return HHMMSS(secs, { displaySeconds: false });
2765
+ }
2766
+ function HHMMSS(s, format) {
2767
+ var secondNumber = parseInt(s, 10); // don't forget the second param
2768
+ var hours = Math.floor(secondNumber / 3600);
2769
+ var minutes = Math.floor((secondNumber - hours * 3600) / 60);
2770
+ var seconds = secondNumber - hours * 3600 - minutes * 60;
2771
+ var displaySeconds = !format || (format === null || format === void 0 ? void 0 : format.displaySeconds);
2772
+ var timeString = displaySeconds
2773
+ ? hours + ':' + minutes + ':' + seconds
2774
+ : hours + ':' + minutes;
2775
+ return timeString.split(':').map(zeroPad).join(':');
2776
+ }
2777
+ var getUTCdateString = function (date) {
2778
+ var dateDate = isDate(date) || isISODateString(date) ? new Date(date) : new Date();
2779
+ var monthNumber = dateDate.getUTCMonth() + 1;
2780
+ var utcMonth = monthNumber < 10 ? "0".concat(monthNumber) : "".concat(monthNumber);
2781
+ return "".concat(dateDate.getUTCFullYear(), "-").concat(zeroPad(utcMonth), "-").concat(zeroPad(dateDate.getUTCDate()));
2782
+ };
2783
+ function timeUTC(date) {
2784
+ var dateDate = isDate(date) || isISODateString(date) ? new Date(date) : new Date();
2785
+ return Date.UTC(dateDate.getFullYear(), dateDate.getMonth(), dateDate.getDate());
2786
+ }
2787
+ function formatDate(date, separator, format) {
2788
+ if (separator === void 0) { separator = '-'; }
2789
+ if (format === void 0) { format = 'YMD'; }
2790
+ if (!date)
2791
+ return '';
2792
+ if (typeof date === 'string' && date.indexOf('T') < 0)
2793
+ date = date + 'T00:00';
2794
+ var d = new Date(date);
2795
+ var month = '' + (d.getMonth() + 1);
2796
+ var day = '' + d.getDate();
2797
+ var year = d.getFullYear();
2798
+ if (month.length < 2)
2799
+ month = '0' + month;
2800
+ if (day.length < 2)
2801
+ day = '0' + day;
2802
+ if (format === 'DMY')
2803
+ return [day, month, year].join(separator);
2804
+ if (format === 'MDY')
2805
+ return [month, day, year].join(separator);
2806
+ if (format === 'YDM')
2807
+ return [year, day, month].join(separator);
2808
+ if (format === 'DYM')
2809
+ return [day, year, month].join(separator);
2810
+ if (format === 'MYD')
2811
+ return [month, year, day].join(separator);
2812
+ return [year, month, day].join(separator);
2813
+ }
2814
+ function offsetDate(date) {
2815
+ var targetTime = date ? new Date(date) : new Date();
2816
+ var tzDifference = targetTime.getTimezoneOffset();
2817
+ return new Date(targetTime.getTime() - tzDifference * 60 * 1000);
2818
+ }
2819
+ function offsetTime(date) {
2820
+ return offsetDate(date).getTime();
2821
+ }
2822
+ // only returns true for valid date objects
2823
+ // dateArg = new Date('xxx') produces 'Invalid Date', which return false
2824
+ function isDate(dateArg) {
2825
+ if (typeof dateArg == 'boolean')
2826
+ return false;
2827
+ var t = (dateArg instanceof Date && dateArg) ||
2828
+ (!isNaN(dateArg) && new Date(dateArg)) ||
2829
+ false;
2830
+ return t && !isNaN(t.valueOf());
2831
+ }
2832
+ function dateRange(startDt, endDt) {
2833
+ if (!isValidDateString(startDt) || !isValidDateString(endDt))
2834
+ return [];
2835
+ var startDateString = extractDate(startDt) + 'T00:00';
2836
+ var endDateString = extractDate(endDt) + 'T00:00';
2837
+ var startDate = new Date(startDateString);
2838
+ var endDate = new Date(endDateString);
2839
+ var process = isDate(endDate) &&
2840
+ isDate(startDate) &&
2841
+ isValidDateRange(startDate, endDate);
2842
+ var between = [];
2843
+ var iterations = 0;
2844
+ if (process) {
2845
+ var currentDate = startDate;
2846
+ var dateSecs = currentDate.getTime();
2847
+ while (dateSecs <= endDate.getTime() && iterations < 300) {
2848
+ iterations += 1;
2849
+ // must be a *new* Date otherwise it is an array of the same object
2850
+ between.push(new Date(currentDate));
2851
+ dateSecs = currentDate.setDate(currentDate.getDate() + 1);
2852
+ }
2853
+ }
2854
+ return between.map(function (date) { return formatDate(date); });
2855
+ function isValidDateRange(minDate, maxDate) {
2856
+ return minDate <= maxDate;
2857
+ }
2858
+ }
2859
+ // matches valid ISO date string
2860
+ var re = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
2861
+ function isISODateString(dateString) {
2862
+ if (typeof dateString !== 'string')
2863
+ return false;
2864
+ return re.test(dateString);
2865
+ }
2866
+ function isTimeString(timeString) {
2867
+ if (typeof timeString !== 'string')
2868
+ return false;
2869
+ var noZ = timeString.split('Z')[0];
2870
+ var parts = noZ.split(':');
2871
+ var isNumeric = parts.every(function (part) { return !isNaN(parseInt(part)); });
2872
+ var invalid = parts.length < 2 ||
2873
+ !isNumeric ||
2874
+ parseInt(parts[0]) > 23 ||
2875
+ parseInt(parts[1]) > 60;
2876
+ return !invalid;
2877
+ }
2878
+ function timeStringMinutes(timeString) {
2879
+ var validTimeString = extractTime(timeString);
2880
+ if (!validTimeString)
2881
+ return 0;
2882
+ var _a = __read(validTimeString
2883
+ .split(':')
2884
+ .map(function (value) { return parseInt(value); }), 2), hours = _a[0], minutes = _a[1];
2885
+ return hours * 60 + minutes;
2886
+ }
2887
+ function dayMinutesToTimeString(totalMinutes) {
2888
+ var hours = Math.floor(totalMinutes / 60);
2889
+ var minutes = totalMinutes - hours * 60;
2890
+ if (hours > 23)
2891
+ hours = hours % 24;
2892
+ return [zeroPad(hours), zeroPad(minutes)].join(':');
2893
+ }
2894
+ function tidyTime(timeString) {
2895
+ return isTimeString(timeString)
2896
+ ? timeString.split(':').slice(0, 2).map(zeroPad).join(':')
2897
+ : undefined;
2898
+ }
2899
+ function extractTime(dateString) {
2900
+ return isISODateString(dateString) && dateString.indexOf('T') > 0
2901
+ ? tidyTime(dateString.split('T').reverse()[0])
2902
+ : tidyTime(dateString);
2903
+ }
2904
+ function extractDate(dateString) {
2905
+ return isISODateString(dateString) || dateValidation.test(dateString)
2906
+ ? dateString.split('T')[0]
2907
+ : undefined;
2908
+ }
2909
+ function dateStringDaysChange(dateString, daysChange) {
2910
+ var date = new Date(dateString);
2911
+ date.setDate(date.getDate() + daysChange);
2912
+ return extractDate(date.toISOString());
2913
+ }
2914
+ function splitTime(value) {
2915
+ var _a, _b;
2916
+ value = typeof value !== 'string' ? '00:00' : value;
2917
+ var o = {}, time = {};
2918
+ (_a = value.split(' ') || [], o.time = _a[0], o.ampm = _a[1]);
2919
+ (_b = o.time.split(':') || [], time.hours = _b[0], time.minutes = _b[1]);
2920
+ time.ampm = o.ampm;
2921
+ if (isNaN(time.hours) ||
2922
+ isNaN(time.minutes) ||
2923
+ (time.ampm && !['AM', 'PM'].includes(time.ampm.toUpperCase())))
2924
+ return {};
2925
+ return time;
2926
+ }
2927
+ function militaryTime(value) {
2928
+ var time = splitTime(value);
2929
+ if (time.ampm && time.hours) {
2930
+ if (time.ampm.toLowerCase() === 'pm' && parseInt(time.hours) < 12)
2931
+ time.hours = ((time.hours && parseInt(time.hours)) || 0) + 12;
2932
+ if (time.ampm.toLowerCase() === 'am' && time.hours === '12')
2933
+ time.hours = '00';
2934
+ }
2935
+ var timeString = "".concat(time.hours || '12', ":").concat(time.minutes || '00');
2936
+ return timeString.split(':').map(zeroPad).join(':');
2937
+ }
2938
+ function regularTime(value) {
2939
+ var _a;
2940
+ var time = splitTime(value);
2941
+ if (typeof time === 'object' && !Object.keys(time).length)
2942
+ return undefined;
2943
+ if (time.ampm)
2944
+ return value;
2945
+ if (time.hours > 12) {
2946
+ time.hours -= 12;
2947
+ time.ampm = 'PM';
2948
+ }
2949
+ else if (time.hours === '12') {
2950
+ time.ampm = 'PM';
2951
+ }
2952
+ else if (time.hours === '00') {
2953
+ time.hours = '12';
2954
+ time.ampm = 'AM';
2955
+ }
2956
+ else {
2957
+ time.ampm = 'AM';
2958
+ }
2959
+ if (((_a = time.hours) === null || _a === void 0 ? void 0 : _a[0]) === '0') {
2960
+ time.hours = time.hours.slice(1);
2961
+ }
2962
+ return "".concat(time.hours || '12', ":").concat(time.minutes || '00', " ").concat(time.ampm);
2963
+ }
2964
+ function convertTime(value, time24, keepDate) {
2965
+ var hasDate = extractDate(value);
2966
+ var timeString = extractTime(value);
2967
+ var timeValue = hasDate ? timeString : value;
2968
+ return !value
2969
+ ? undefined
2970
+ : (time24 && ((hasDate && keepDate && value) || militaryTime(timeValue))) ||
2971
+ regularTime(timeValue);
2972
+ }
2973
+ function timeSort(a, b) {
2974
+ var as = splitTime(a);
2975
+ var bs = splitTime(b);
2976
+ if (parseInt(as.hours) < parseInt(bs.hours))
2977
+ return -1;
2978
+ if (parseInt(as.hours) > parseInt(bs.hours))
2979
+ return 1;
2980
+ if (as.hours === bs.hours) {
2981
+ if (parseInt(as.minutes) < parseInt(bs.minutes))
2982
+ return -1;
2983
+ if (parseInt(as.minutes) > parseInt(bs.minutes))
2984
+ return 1;
2985
+ }
2986
+ return 0;
2987
+ }
2988
+ function addDays(date, days) {
2989
+ if (days === void 0) { days = 7; }
2990
+ var universalDate = extractDate(date) + 'T00:00';
2991
+ var now = new Date(universalDate);
2992
+ var adjustedDate = new Date(now.setDate(now.getDate() + days));
2993
+ return formatDate(adjustedDate);
2994
+ }
2995
+ function addWeek(date) {
2996
+ return addDays(date);
2997
+ }
2998
+ function getDateByWeek(week, year, dateFormat, sunday) {
2999
+ if (sunday === void 0) { sunday = false; }
3000
+ var date = new Date(year, 0, 1 + (week - 1) * 7);
3001
+ var startValue = sunday ? 0 : 1;
3002
+ date.setDate(date.getDate() + (startValue - date.getDay()));
3003
+ return formatDate(date, dateFormat);
3634
3004
  }
3005
+ function dateFromDay(year, day, dateFormat) {
3006
+ var date = new Date(year, 0); // initialize a date in `year-01-01`
3007
+ return formatDate(new Date(date.setDate(day)), dateFormat); // add the number of days
3008
+ }
3009
+ function timeToDate(timeString, date) {
3010
+ if (date === void 0) { date = undefined; }
3011
+ var _a = __read((timeString || '00:00').split(':').map(zeroPad), 2), hours = _a[0], minutes = _a[1];
3012
+ var milliseconds = offsetDate(date).setHours(hours, minutes, 0, 0);
3013
+ return offsetDate(milliseconds);
3014
+ }
3015
+ function minutesDifference(date1, date2, absolute) {
3016
+ if (absolute === void 0) { absolute = true; }
3017
+ var dt1 = new Date(date1);
3018
+ var dt2 = new Date(date2);
3019
+ var diff = (dt2.getTime() - dt1.getTime()) / 1000 / 60;
3020
+ return absolute ? Math.abs(Math.round(diff)) : Math.round(diff);
3021
+ }
3022
+ function addMinutesToTimeString(timeString, minutes) {
3023
+ var validTimeString = extractTime(timeString);
3024
+ if (!validTimeString)
3025
+ return '00:00';
3026
+ var minutesToAdd = isNaN(minutes) ? 0 : minutes;
3027
+ return extractTime(addMinutes(timeToDate(validTimeString), minutesToAdd).toISOString());
3028
+ }
3029
+ function addMinutes(startDate, minutes) {
3030
+ var date = new Date(startDate);
3031
+ return new Date(date.getTime() + minutes * 60000);
3032
+ }
3033
+ function zeroPad(number) {
3034
+ return number.toString()[1] ? number : '0' + number;
3035
+ }
3036
+ function sameDay(date1, date2) {
3037
+ var d1 = new Date(date1);
3038
+ var d2 = new Date(date2);
3039
+ return (d1.getFullYear() === d2.getFullYear() &&
3040
+ d1.getMonth() === d2.getMonth() &&
3041
+ d1.getDate() === d2.getDate());
3042
+ }
3043
+ var dateTime = {
3044
+ addDays: addDays,
3045
+ addWeek: addWeek,
3046
+ addMinutesToTimeString: addMinutesToTimeString,
3047
+ convertTime: convertTime,
3048
+ getIsoDateString: getIsoDateString,
3049
+ getUTCdateString: getUTCdateString,
3050
+ DateHHMM: DateHHMM,
3051
+ extractDate: extractDate,
3052
+ extractTime: extractTime,
3053
+ formatDate: formatDate,
3054
+ getDateByWeek: getDateByWeek,
3055
+ isISODateString: isISODateString,
3056
+ isDate: isDate,
3057
+ isTimeString: isTimeString,
3058
+ offsetDate: offsetDate,
3059
+ offsetTime: offsetTime,
3060
+ sameDay: sameDay,
3061
+ timeStringMinutes: timeStringMinutes,
3062
+ timeToDate: timeToDate,
3063
+ timeUTC: timeUTC,
3064
+ validTimeValue: validTimeValue,
3065
+ validDateString: validDateString,
3066
+ timeValidation: timeValidation,
3067
+ dateValidation: dateValidation,
3068
+ };
3635
3069
 
3636
3070
  var typeMatch = function (arr, type) {
3637
3071
  return arr.filter(Boolean).every(function (i) { return typeof i === type; });
@@ -3830,6 +3264,262 @@ function getCategoryAgeDetails(params) {
3830
3264
  return result;
3831
3265
  }
3832
3266
 
3267
+ function makeDeepCopy(sourceObject, // arbitrary JSON object; functions will be stripped.
3268
+ convertExtensions, // optional - all extension objects converted to attributes ._key
3269
+ internalUse, // disregard deepCopy being disabled within the engine - necessary for query results
3270
+ removeExtensions, // optional - strip all extension attributes
3271
+ iteration // escape hatch - check against iteration threshold
3272
+ ) {
3273
+ var e_1, _a;
3274
+ if (iteration === void 0) { iteration = 0; }
3275
+ if (getProvider().makeDeepCopy)
3276
+ return getProvider().makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtensions);
3277
+ var deepCopy = deepCopyEnabled();
3278
+ var _b = deepCopy || {}, stringify = _b.stringify, toJSON = _b.toJSON, ignore = _b.ignore, modulate = _b.modulate;
3279
+ if ((!(deepCopy === null || deepCopy === void 0 ? void 0 : deepCopy.enabled) && !internalUse) ||
3280
+ typeof sourceObject !== 'object' ||
3281
+ typeof sourceObject === 'function' ||
3282
+ sourceObject === null ||
3283
+ (typeof (deepCopy === null || deepCopy === void 0 ? void 0 : deepCopy.threshold) === 'number' && iteration >= deepCopy.threshold)) {
3284
+ return sourceObject;
3285
+ }
3286
+ var targetObject = Array.isArray(sourceObject) ? [] : {};
3287
+ var sourceObjectKeys = Object.keys(sourceObject).filter(function (key) {
3288
+ return !internalUse ||
3289
+ !ignore ||
3290
+ (Array.isArray(ignore) && !ignore.includes(key)) ||
3291
+ (typeof ignore === 'function' && !ignore(key));
3292
+ });
3293
+ var stringifyValue = function (key, value) {
3294
+ targetObject[key] =
3295
+ typeof (value === null || value === void 0 ? void 0 : value.toString) === 'function'
3296
+ ? value.toString()
3297
+ : JSON.stringify(value);
3298
+ };
3299
+ try {
3300
+ for (var sourceObjectKeys_1 = __values(sourceObjectKeys), sourceObjectKeys_1_1 = sourceObjectKeys_1.next(); !sourceObjectKeys_1_1.done; sourceObjectKeys_1_1 = sourceObjectKeys_1.next()) {
3301
+ var key = sourceObjectKeys_1_1.value;
3302
+ var value = sourceObject[key];
3303
+ var modulated = typeof modulate === 'function' ? modulate(value) : undefined;
3304
+ if (modulated !== undefined) {
3305
+ targetObject[key] = modulated;
3306
+ }
3307
+ else if (convertExtensions &&
3308
+ key === 'extensions' &&
3309
+ Array.isArray(value)) {
3310
+ var extensionConversions = extensionsToAttributes(value);
3311
+ Object.assign.apply(Object, __spreadArray([targetObject], __read(extensionConversions), false));
3312
+ }
3313
+ else if (removeExtensions && key === 'extensions') {
3314
+ targetObject[key] = [];
3315
+ }
3316
+ else if (Array.isArray(stringify) && stringify.includes(key)) {
3317
+ stringifyValue(key, value);
3318
+ }
3319
+ else if (Array.isArray(toJSON) &&
3320
+ toJSON.includes(key) &&
3321
+ typeof (value === null || value === void 0 ? void 0 : value.toJSON) === 'function') {
3322
+ targetObject[key] = value.toJSON();
3323
+ }
3324
+ else if (value === null) {
3325
+ targetObject[key] = undefined;
3326
+ }
3327
+ else if (isDateObject(value)) {
3328
+ targetObject[key] = new Date(value).toISOString();
3329
+ }
3330
+ else {
3331
+ targetObject[key] = makeDeepCopy(value, convertExtensions, internalUse, removeExtensions, iteration + 1);
3332
+ }
3333
+ }
3334
+ }
3335
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3336
+ finally {
3337
+ try {
3338
+ if (sourceObjectKeys_1_1 && !sourceObjectKeys_1_1.done && (_a = sourceObjectKeys_1.return)) _a.call(sourceObjectKeys_1);
3339
+ }
3340
+ finally { if (e_1) throw e_1.error; }
3341
+ }
3342
+ return targetObject;
3343
+ }
3344
+ function extensionsToAttributes(extensions) {
3345
+ return extensions === null || extensions === void 0 ? void 0 : extensions.map(function (extension) {
3346
+ var _a;
3347
+ var name = extension.name, value = extension.value;
3348
+ return name && value && (_a = {}, _a["_".concat(name)] = value, _a);
3349
+ }).filter(Boolean);
3350
+ }
3351
+
3352
+ function getAccessorValue(_a) {
3353
+ var element = _a.element, accessor = _a.accessor;
3354
+ if (typeof accessor !== 'string')
3355
+ return { values: [] };
3356
+ var targetElement = makeDeepCopy(element);
3357
+ var attributes = accessor.split('.');
3358
+ var values = [];
3359
+ var value;
3360
+ processKeys({ targetElement: targetElement, attributes: attributes });
3361
+ var result = { value: value };
3362
+ if (values.length)
3363
+ result.values = values;
3364
+ return result;
3365
+ function processKeys(_a) {
3366
+ var e_1, _b;
3367
+ var targetElement = _a.targetElement, _c = _a.attributes, attributes = _c === void 0 ? [] : _c, significantCharacters = _a.significantCharacters;
3368
+ var _loop_1 = function (index, attribute) {
3369
+ if (targetElement === null || targetElement === void 0 ? void 0 : targetElement[attribute]) {
3370
+ var remainingKeys_1 = attributes.slice(index + 1);
3371
+ if (!remainingKeys_1.length) {
3372
+ if (!value)
3373
+ value = targetElement[attribute];
3374
+ if (!values.includes(targetElement[attribute])) {
3375
+ values.push(targetElement[attribute]);
3376
+ }
3377
+ }
3378
+ else if (Array.isArray(targetElement[attribute])) {
3379
+ var values_1 = targetElement[attribute];
3380
+ values_1.forEach(function (nestedTarget) {
3381
+ return processKeys({
3382
+ targetElement: nestedTarget,
3383
+ attributes: remainingKeys_1,
3384
+ });
3385
+ });
3386
+ }
3387
+ else {
3388
+ targetElement = targetElement[attribute];
3389
+ checkValue({ targetElement: targetElement, index: index });
3390
+ }
3391
+ }
3392
+ };
3393
+ try {
3394
+ for (var _d = __values(attributes.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
3395
+ var _f = __read(_e.value, 2), index = _f[0], attribute = _f[1];
3396
+ _loop_1(index, attribute);
3397
+ }
3398
+ }
3399
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3400
+ finally {
3401
+ try {
3402
+ if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
3403
+ }
3404
+ finally { if (e_1) throw e_1.error; }
3405
+ }
3406
+ function checkValue(_a) {
3407
+ var targetElement = _a.targetElement, index = _a.index;
3408
+ if (targetElement &&
3409
+ index === attributes.length - 1 &&
3410
+ ['string', 'number'].includes(typeof targetElement)) {
3411
+ var extractedValue = significantCharacters
3412
+ ? targetElement.slice(0, significantCharacters)
3413
+ : targetElement;
3414
+ if (value) {
3415
+ if (!values.includes(extractedValue)) {
3416
+ values.push(extractedValue);
3417
+ }
3418
+ }
3419
+ else {
3420
+ value = extractedValue;
3421
+ values.push(extractedValue);
3422
+ }
3423
+ }
3424
+ }
3425
+ }
3426
+ }
3427
+
3428
+ function isString(obj) {
3429
+ return typeof obj === 'string';
3430
+ }
3431
+ function isObject(obj) {
3432
+ return obj !== null && typeof obj === 'object';
3433
+ }
3434
+ function objShallowEqual(o1, o2) {
3435
+ var e_1, _a;
3436
+ if (!isObject(o1) || !isObject(o2))
3437
+ return false;
3438
+ var keys1 = Object.keys(o1);
3439
+ var keys2 = Object.keys(o2);
3440
+ if (keys1.length !== keys2.length) {
3441
+ return false;
3442
+ }
3443
+ try {
3444
+ for (var keys1_1 = __values(keys1), keys1_1_1 = keys1_1.next(); !keys1_1_1.done; keys1_1_1 = keys1_1.next()) {
3445
+ var key = keys1_1_1.value;
3446
+ if (o1[key] !== o2[key]) {
3447
+ return false;
3448
+ }
3449
+ }
3450
+ }
3451
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3452
+ finally {
3453
+ try {
3454
+ if (keys1_1_1 && !keys1_1_1.done && (_a = keys1_1.return)) _a.call(keys1_1);
3455
+ }
3456
+ finally { if (e_1) throw e_1.error; }
3457
+ }
3458
+ return true;
3459
+ }
3460
+ function createMap(objectArray, attribute) {
3461
+ if (!Array.isArray(objectArray))
3462
+ return {};
3463
+ return Object.assign.apply(Object, __spreadArray([{}], __read((objectArray !== null && objectArray !== void 0 ? objectArray : [])
3464
+ .filter(isObject)
3465
+ .map(function (obj) {
3466
+ var _a;
3467
+ return (obj[attribute] && (_a = {},
3468
+ _a[obj[attribute]] = obj,
3469
+ _a));
3470
+ })
3471
+ .filter(Boolean)), false));
3472
+ }
3473
+ // e.g. result.find(hav({ attr: value })) -or- result.filter(hav({ attr: value }))
3474
+ var hasAttributeValues = function (a) { return function (o) {
3475
+ return Object.keys(a).every(function (key) { return o[key] === a[key]; });
3476
+ }; };
3477
+ // extracts targeted attributes
3478
+ // e.g. const byeAssignments = positionAssignments.filter(xa('bye')).map(xa('drawPosition'));
3479
+ // supports xa('string'), xa(['string', 'string']), xa({ attr1: true, attr2: true })
3480
+ var extractAttributes = function (accessor) { return function (element) {
3481
+ var _a;
3482
+ return !accessor || typeof element !== 'object'
3483
+ ? undefined
3484
+ : (Array.isArray(accessor) &&
3485
+ accessor.map(function (a) {
3486
+ var _a;
3487
+ var _b;
3488
+ return (_a = {},
3489
+ _a[a] = (_b = getAccessorValue({ element: element, accessor: a })) === null || _b === void 0 ? void 0 : _b.value,
3490
+ _a);
3491
+ })) ||
3492
+ (typeof accessor === 'object' &&
3493
+ Object.keys(accessor).map(function (key) {
3494
+ var _a;
3495
+ var _b;
3496
+ return (_a = {},
3497
+ _a[key] = (_b = getAccessorValue({ element: element, accessor: key })) === null || _b === void 0 ? void 0 : _b.value,
3498
+ _a);
3499
+ })) ||
3500
+ ((_a = (typeof accessor === 'string' && getAccessorValue({ element: element, accessor: accessor }))) === null || _a === void 0 ? void 0 : _a.value);
3501
+ }; };
3502
+ function countKeys(o) {
3503
+ if (Array.isArray(o)) {
3504
+ return o.length + o.map(countKeys).reduce(function (a, b) { return a + b; }, 0);
3505
+ }
3506
+ else if (typeof o === 'object' && o !== null) {
3507
+ return (Object.keys(o).length +
3508
+ Object.keys(o)
3509
+ .map(function (k) { return countKeys(o[k]); })
3510
+ .reduce(function (a, b) { return a + b; }, 0));
3511
+ }
3512
+ return 0;
3513
+ }
3514
+ function generateHashCode(o) {
3515
+ if (o === null || typeof o !== 'object')
3516
+ return undefined;
3517
+ var str = JSON.stringify(o);
3518
+ var keyCount = countKeys(o);
3519
+ var charSum = str.split('').reduce(function (a, b) { return a + b.charCodeAt(0); }, 0);
3520
+ return [str.length, keyCount, charSum].map(function (e) { return e.toString(36); }).join('');
3521
+ }
3522
+
3833
3523
  function validateCategory(_a) {
3834
3524
  var category = _a.category;
3835
3525
  if (!isObject(category))
@@ -3920,6 +3610,317 @@ function mustBeAnArray(value) {
3920
3610
  return "".concat(value, " must be an array");
3921
3611
  }
3922
3612
 
3613
+ // NOTE: type really does need to be any!
3614
+ function attributeFilter(params) {
3615
+ if (params === null)
3616
+ return {};
3617
+ var _a = params || {}, source = _a.source, template = _a.template;
3618
+ if (!template)
3619
+ return source;
3620
+ var target = {};
3621
+ attributeCopy(source, template, target);
3622
+ return target;
3623
+ function attributeCopy(valuesObject, templateObject, outputObject) {
3624
+ var e_1, _a;
3625
+ if (!valuesObject || !templateObject)
3626
+ return undefined;
3627
+ var vKeys = Object.keys(valuesObject);
3628
+ var oKeys = Object.keys(templateObject);
3629
+ // the orMap allows spcification of { 'a||b': boolean } so that filter templates can apply to multiple attributes
3630
+ var orMap = Object.assign.apply(Object, __spreadArray([{}], __read(oKeys
3631
+ .filter(function (key) { return key.indexOf('||'); })
3632
+ .map(function (key) { return key.split('||').map(function (or) {
3633
+ var _a;
3634
+ return (_a = {}, _a[or] = key, _a);
3635
+ }); })
3636
+ .flat()), false));
3637
+ var allKeys = oKeys.concat.apply(oKeys, __spreadArray([], __read(Object.keys(orMap)), false));
3638
+ var wildcard = allKeys.includes('*');
3639
+ var _loop_1 = function (vKey) {
3640
+ if (allKeys.indexOf(vKey) >= 0 || wildcard) {
3641
+ var templateKey = orMap[vKey] || vKey;
3642
+ var tobj_1 = templateObject[templateKey] || wildcard;
3643
+ var vobj = valuesObject[vKey];
3644
+ if (typeof tobj_1 === 'object' &&
3645
+ typeof vobj !== 'function' &&
3646
+ !Array.isArray(tobj_1)) {
3647
+ if (Array.isArray(vobj)) {
3648
+ var mappedElements = vobj
3649
+ .map(function (arrayMember) {
3650
+ var target = {};
3651
+ var result = attributeCopy(arrayMember, tobj_1, target);
3652
+ return result !== false ? target : undefined;
3653
+ })
3654
+ .filter(Boolean);
3655
+ outputObject[vKey] = mappedElements;
3656
+ }
3657
+ else if (vobj) {
3658
+ outputObject[vKey] = {};
3659
+ attributeCopy(vobj, tobj_1, outputObject[vKey]);
3660
+ }
3661
+ }
3662
+ else {
3663
+ var value = valuesObject[vKey];
3664
+ var exclude = Array.isArray(tobj_1) && !tobj_1.includes(value);
3665
+ if (exclude)
3666
+ return { value: false };
3667
+ if (templateObject[vKey] ||
3668
+ (wildcard && templateObject[vKey] !== false)) {
3669
+ outputObject[vKey] = value;
3670
+ }
3671
+ }
3672
+ }
3673
+ };
3674
+ try {
3675
+ for (var vKeys_1 = __values(vKeys), vKeys_1_1 = vKeys_1.next(); !vKeys_1_1.done; vKeys_1_1 = vKeys_1.next()) {
3676
+ var vKey = vKeys_1_1.value;
3677
+ var state_1 = _loop_1(vKey);
3678
+ if (typeof state_1 === "object")
3679
+ return state_1.value;
3680
+ }
3681
+ }
3682
+ catch (e_1_1) { e_1 = { error: e_1_1 }; }
3683
+ finally {
3684
+ try {
3685
+ if (vKeys_1_1 && !vKeys_1_1.done && (_a = vKeys_1.return)) _a.call(vKeys_1);
3686
+ }
3687
+ finally { if (e_1) throw e_1.error; }
3688
+ }
3689
+ return undefined;
3690
+ }
3691
+ }
3692
+
3693
+ function generateTimeCode(index) {
3694
+ if (index === void 0) { index = 0; }
3695
+ var uidate = new Date();
3696
+ uidate.setHours(uidate.getHours() + index);
3697
+ return uidate.getTime().toString(36).slice(-6).toUpperCase();
3698
+ }
3699
+
3700
+ /**
3701
+ *
3702
+ * @param {object[]} arrayOfJSON - JSON objects array
3703
+ * @param {object} config - object which configures processing (see below)
3704
+ * @returns {string} - joined by '\r\n' or specified line separator
3705
+ *
3706
+ * config {
3707
+ * {boolean} includeTransformAccessors, // transform accessors are included with columnAccessors
3708
+ * {string[]} columnAccessors, // [ 'includeThis', 'andThis' ]
3709
+ * {object} columnTransform, // e.g. { 'newColumnName': ['oldColumn1', 'oldColumn2' ]}
3710
+ * {object} columnMap, // e.g. { 'columnName': 'newColumnName' }
3711
+ * {object} valuesMap, // e.g. { 'columnName': { 'value1': 'mappedValue' }} // useful for mapping IDs
3712
+ * {array} sortOrder // e.g. ['columnName1', 'columnName2'] // determine order of csv columns
3713
+ * {object} context, // attributes which are to be added to all rows { 'columnName': 'value }
3714
+ * {string} delimiter, // defaults to '"'
3715
+ * {string} columnJoiner, // defaults to ',' // defines how CSV columns are joined
3716
+ * {string} rowJoiner, // defaults to '\r\n' // defines how CSV lines are joined
3717
+ * {string} keyJoiner, // defaults to '.' // defines how flattened column names are constructed
3718
+ * }
3719
+ *
3720
+ * NOTE: `columnTransform` mapped array elements are sensitive to order and will resolve to the first matching value
3721
+ * NOTE: `columnMap` should not contain new columnName(s) that are `columnTransform` keys
3722
+ */
3723
+ function JSON2CSV(arrayOfJSON, config) {
3724
+ if (config && typeof config !== 'object')
3725
+ return INVALID_VALUES;
3726
+ var _a = (config || {}).columnTransform, columnTransform = _a === void 0 ? {} : _a;
3727
+ var _b = config || {}, includeTransformAccessors = _b.includeTransformAccessors, _c = _b.includeHeaderRow, includeHeaderRow = _c === void 0 ? true : _c, returnTransformedJSON = _b.returnTransformedJSON, removeEmptyColumns = _b.removeEmptyColumns, onlyHeaderRow = _b.onlyHeaderRow, _d = _b.columnAccessors, columnAccessors = _d === void 0 ? [] : _d, _e = _b.functionMap, functionMap = _e === void 0 ? {} : _e, _f = _b.columnMap, columnMap = _f === void 0 ? {} : _f, _g = _b.valuesMap, valuesMap = _g === void 0 ? {} : _g, _h = _b.context, context = _h === void 0 ? {} : _h, _j = _b.delimiter, delimiter = _j === void 0 ? '"' : _j, _k = _b.columnJoiner, columnJoiner = _k === void 0 ? ',' : _k, _l = _b.rowJoiner, rowJoiner = _l === void 0 ? '\r\n' : _l, _m = _b.keyJoiner, keyJoiner = _m === void 0 ? '.' : _m;
3728
+ if (!Array.isArray(arrayOfJSON) ||
3729
+ !Array.isArray(columnAccessors) ||
3730
+ typeof context !== 'object' ||
3731
+ typeof columnMap !== 'object' ||
3732
+ typeof columnTransform !== 'object' ||
3733
+ typeof functionMap !== 'object' ||
3734
+ typeof valuesMap !== 'object' ||
3735
+ typeof columnJoiner !== 'string' ||
3736
+ typeof rowJoiner !== 'string' ||
3737
+ typeof keyJoiner !== 'string' ||
3738
+ typeof delimiter !== 'string')
3739
+ return INVALID_VALUES;
3740
+ // ensure all column transformers are arrays
3741
+ columnTransform = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
3742
+ .reverse() // reverse so that exported CSV columns are in the order as defined
3743
+ .map(function (key) {
3744
+ var _a;
3745
+ return (_a = {},
3746
+ _a[key] = Array.isArray(columnTransform[key])
3747
+ ? columnTransform[key]
3748
+ : [
3749
+ // ensure transform attributes are strings
3750
+ typeof columnTransform[key] === 'string' && columnTransform[key],
3751
+ ].filter(Boolean),
3752
+ _a);
3753
+ })), false));
3754
+ var flattened = arrayOfJSON
3755
+ .filter(Boolean)
3756
+ .map(function (obj) { return flattenJSON(obj, keyJoiner); });
3757
+ var transformColumns = Object.values(columnTransform).flat();
3758
+ if (includeTransformAccessors)
3759
+ columnAccessors.push.apply(columnAccessors, __spreadArray([], __read(transformColumns), false));
3760
+ var headerRow = flattened
3761
+ .reduce(function (aggregator, row) {
3762
+ return Object.keys(row).every(function (key) { return (!aggregator.includes(key) && aggregator.push(key)) || true; }) && aggregator;
3763
+ }, [])
3764
+ .filter(function (key) { return !(columnAccessors === null || columnAccessors === void 0 ? void 0 : columnAccessors.length) || columnAccessors.includes(key); });
3765
+ var accessorMap = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(columnTransform)
3766
+ .reverse() // so that original order is preserved when later pushed
3767
+ .map(function (transform) {
3768
+ return columnTransform[transform]
3769
+ .map(function (value) {
3770
+ var _a;
3771
+ return (_a = {}, _a[value] = transform, _a);
3772
+ })
3773
+ .flat();
3774
+ })
3775
+ .flat()), false));
3776
+ var sortColumns = function (a, b) {
3777
+ return !(config === null || config === void 0 ? void 0 : config.sortOrder)
3778
+ ? 0
3779
+ : (config.sortOrder.includes(a) &&
3780
+ config.sortOrder.includes(b) &&
3781
+ config.sortOrder.indexOf(a) - config.sortOrder.indexOf(b)) ||
3782
+ (!config.sortOrder.includes(b) && -1);
3783
+ };
3784
+ var tranformedHeaderRow = headerRow
3785
+ .reduce(function (def, key) {
3786
+ var transform = accessorMap[key];
3787
+ if (transform) {
3788
+ if (!def.includes(transform))
3789
+ def.push(transform);
3790
+ }
3791
+ else {
3792
+ def.push(key);
3793
+ }
3794
+ return def;
3795
+ }, [])
3796
+ .sort(sortColumns);
3797
+ Object.keys(columnMap).forEach(function (columnName) {
3798
+ return !tranformedHeaderRow.includes(columnName) &&
3799
+ tranformedHeaderRow.unshift(columnName);
3800
+ });
3801
+ Object.keys(columnTransform).forEach(function (columnName) {
3802
+ return !tranformedHeaderRow.includes(columnName) &&
3803
+ tranformedHeaderRow.unshift(columnName);
3804
+ });
3805
+ typeof context === 'object' &&
3806
+ Object.keys(context).forEach(function (columnName) {
3807
+ return !tranformedHeaderRow.includes(columnName) &&
3808
+ tranformedHeaderRow.unshift(columnName);
3809
+ });
3810
+ var mappedHeaderRow = tranformedHeaderRow.map(function (key) { return columnMap[key] || key; });
3811
+ if (onlyHeaderRow)
3812
+ return [mappedHeaderRow];
3813
+ var withDelimiter = function (value) { return "".concat(delimiter).concat(value).concat(delimiter); };
3814
+ var columnValueCounts = [];
3815
+ var processRow = function (row) {
3816
+ return Object.values(tranformedHeaderRow.reduce(function (columnsMap, columnName, columnIndex) {
3817
+ var _a;
3818
+ var accessors = columnTransform[columnName];
3819
+ var value = ((accessors === null || accessors === void 0 ? void 0 : accessors.length)
3820
+ ? row[accessors.find(function (accessor) { return row[accessor]; })]
3821
+ : row[columnName]) ||
3822
+ (context === null || context === void 0 ? void 0 : context[columnName]) ||
3823
+ '';
3824
+ var mappedValue = ((_a = valuesMap[columnName]) === null || _a === void 0 ? void 0 : _a[value]) || value;
3825
+ var fxValue = typeof functionMap[columnName] === 'function'
3826
+ ? functionMap[columnName](mappedValue)
3827
+ : mappedValue;
3828
+ columnsMap[columnName] = withDelimiter(fxValue);
3829
+ if (fxValue) {
3830
+ columnValueCounts[columnIndex] =
3831
+ (columnValueCounts[columnIndex] || 0) + 1;
3832
+ }
3833
+ return columnsMap;
3834
+ }, {}));
3835
+ };
3836
+ var flattenedRows = flattened.map(processRow);
3837
+ var indicesToRemove = removeEmptyColumns &&
3838
+ __spreadArray([], __read(columnValueCounts), false).map(function (count, index) { return !count && index; })
3839
+ .filter(isNumeric)
3840
+ .reverse();
3841
+ if (indicesToRemove) {
3842
+ var purge = function (row) {
3843
+ return row.filter(function (_, index) { return !indicesToRemove.includes(index); });
3844
+ };
3845
+ flattenedRows = flattenedRows.map(purge);
3846
+ mappedHeaderRow = purge(mappedHeaderRow);
3847
+ }
3848
+ var rows = flattenedRows.map(function (row) { return row.join(columnJoiner); });
3849
+ if (returnTransformedJSON) {
3850
+ return rows.map(function (row) {
3851
+ var columnValues = row.split(columnJoiner);
3852
+ return Object.assign.apply(Object, __spreadArray([{}], __read(columnValues.map(function (v, i) {
3853
+ var _a;
3854
+ return (_a = {}, _a[mappedHeaderRow[i]] = v, _a);
3855
+ })), false));
3856
+ });
3857
+ }
3858
+ return includeHeaderRow
3859
+ ? __spreadArray([mappedHeaderRow.map(withDelimiter).join(columnJoiner)], __read(rows), false).join(rowJoiner)
3860
+ : rows.join(rowJoiner);
3861
+ }
3862
+ function flattenJSON(obj, keyJoiner, path) {
3863
+ if (keyJoiner === void 0) { keyJoiner = '.'; }
3864
+ if (path === void 0) { path = []; }
3865
+ return (typeof obj === 'object' &&
3866
+ Object.keys(obj).reduce(function (result, key) {
3867
+ if (typeof obj[key] !== 'object') {
3868
+ result[path.concat(key).join(keyJoiner)] = obj[key];
3869
+ return result;
3870
+ }
3871
+ return Object.assign(result, flattenJSON(obj[key], keyJoiner, path.concat(key)));
3872
+ }, {}));
3873
+ }
3874
+
3875
+ /*
3876
+ based on an answer provided by Jeff Ward on StackOverflow; November 2019
3877
+ https://stackoverflow.com/users/1026023/jeff-ward
3878
+ https://stackoverflow.com/questions/105034/how-to-create-guid-uuid?rq=1
3879
+ */
3880
+ /**
3881
+ * generate a given number of UUIDs
3882
+ *
3883
+ * @param {number} count - number of UUIDs to generate
3884
+ */
3885
+ function UUIDS(count) {
3886
+ if (count === void 0) { count = 1; }
3887
+ return generateRange(0, count).map(UUID);
3888
+ }
3889
+ function UUID() {
3890
+ var lut = [];
3891
+ for (var i = 0; i < 256; i++) {
3892
+ lut[i] = (i < 16 ? '0' : '') + i.toString(16);
3893
+ }
3894
+ var d0 = (Math.random() * 0xffffffff) | 0;
3895
+ var d1 = (Math.random() * 0xffffffff) | 0;
3896
+ var d2 = (Math.random() * 0xffffffff) | 0;
3897
+ var d3 = (Math.random() * 0xffffffff) | 0;
3898
+ // eslint-disable-next-line no-mixed-operators
3899
+ return (lut[d0 & 0xff] +
3900
+ lut[(d0 >> 8) & 0xff] +
3901
+ lut[(d0 >> 16) & 0xff] +
3902
+ lut[(d0 >> 24) & 0xff] +
3903
+ '-' +
3904
+ // eslint-disable-next-line no-mixed-operators
3905
+ lut[d1 & 0xff] +
3906
+ lut[(d1 >> 8) & 0xff] +
3907
+ '-' +
3908
+ lut[((d1 >> 16) & 0x0f) | 0x40] +
3909
+ lut[(d1 >> 24) & 0xff] +
3910
+ '-' +
3911
+ // eslint-disable-next-line no-mixed-operators
3912
+ lut[(d2 & 0x3f) | 0x80] +
3913
+ lut[(d2 >> 8) & 0xff] +
3914
+ '-' +
3915
+ lut[(d2 >> 16) & 0xff] +
3916
+ lut[(d2 >> 24) & 0xff] +
3917
+ // eslint-disable-next-line no-mixed-operators
3918
+ lut[d3 & 0xff] +
3919
+ lut[(d3 >> 8) & 0xff] +
3920
+ lut[(d3 >> 16) & 0xff] +
3921
+ lut[(d3 >> 24) & 0xff]);
3922
+ }
3923
+
3923
3924
  function validateTieFormat(params) {
3924
3925
  var _a, _b, _c, _d;
3925
3926
  var checkCategory = !!((params === null || params === void 0 ? void 0 : params.enforceCategory) !== false && (params === null || params === void 0 ? void 0 : params.category));
@@ -65197,7 +65198,9 @@ function generateDrawDefinition(params) {
65197
65198
  // if there is an avoidance policy on the event, it must be preserved in the drawDefinition
65198
65199
  // if there is an avoidance policy in policyDefinitions, it will override
65199
65200
  // avoidance policies on the event can be changed (if location used for UI)
65200
- var policiesToAttach = __assign((_a = {}, _a[POLICY_TYPE_AVOIDANCE] = appliedPolicies[POLICY_TYPE_AVOIDANCE], _a), POLICY_SEEDING_DEFAULT);
65201
+ var policiesToAttach = (_a = {},
65202
+ _a[POLICY_TYPE_AVOIDANCE] = appliedPolicies[POLICY_TYPE_AVOIDANCE],
65203
+ _a);
65201
65204
  if (policyDefinitions) {
65202
65205
  if (typeof policyDefinitions !== 'object') {
65203
65206
  return decorateResult({
@@ -65235,6 +65238,10 @@ function generateDrawDefinition(params) {
65235
65238
  }
65236
65239
  if (!appliedPolicies[POLICY_TYPE_SEEDING] &&
65237
65240
  !policyDefinitions[POLICY_TYPE_SEEDING]) {
65241
+ attachPolicies({
65242
+ drawDefinition: drawDefinition,
65243
+ policyDefinitions: POLICY_SEEDING_DEFAULT,
65244
+ });
65238
65245
  Object.assign(appliedPolicies, POLICY_SEEDING_DEFAULT);
65239
65246
  }
65240
65247
  // ---------------------------------------------------------------------------