tods-competition-factory 1.8.3 → 1.8.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.
- package/dist/forge/generate.mjs +322 -51
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.d.ts +2 -1
- package/dist/forge/query.mjs +42 -23
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +282 -28
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/forge/utilities.mjs +175 -0
- package/dist/forge/utilities.mjs.map +1 -1
- package/dist/index.mjs +553 -379
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +633 -444
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/package.json +5 -5
|
@@ -15,9 +15,8 @@ var setTypes$1 = {
|
|
|
15
15
|
function stringify(matchUpFormatObject, preserveRedundant) {
|
|
16
16
|
if (typeof matchUpFormatObject !== 'object')
|
|
17
17
|
return;
|
|
18
|
-
if (matchUpFormatObject.
|
|
19
|
-
|
|
20
|
-
if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
|
|
18
|
+
if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) &&
|
|
19
|
+
matchUpFormatObject.setFormat)
|
|
21
20
|
return getSetFormat(matchUpFormatObject, preserveRedundant);
|
|
22
21
|
return undefined;
|
|
23
22
|
}
|
|
@@ -34,25 +33,27 @@ function timedSetFormat(matchUpFormatObject) {
|
|
|
34
33
|
}
|
|
35
34
|
function getSetFormat(matchUpFormatObject, preserveRedundant) {
|
|
36
35
|
var _a;
|
|
37
|
-
var bestOfValue = getNumber$1(matchUpFormatObject.bestOf);
|
|
36
|
+
var bestOfValue = getNumber$1(matchUpFormatObject.bestOf) || undefined;
|
|
37
|
+
var exactly = getNumber$1(matchUpFormatObject.exactly) || undefined;
|
|
38
|
+
var setLimit = bestOfValue || exactly;
|
|
38
39
|
if (((_a = matchUpFormatObject.setFormat) === null || _a === void 0 ? void 0 : _a.timed) &&
|
|
39
40
|
matchUpFormatObject.simplified &&
|
|
40
|
-
|
|
41
|
+
setLimit === 1) {
|
|
41
42
|
return timedSetFormat(matchUpFormatObject.setFormat);
|
|
42
43
|
}
|
|
43
|
-
var
|
|
44
|
+
var setLimitCode = (setLimit && "".concat(SET).concat(setLimit)) || '';
|
|
44
45
|
var setCountValue = stringifySet(matchUpFormatObject.setFormat, preserveRedundant);
|
|
45
46
|
var setCode = (setCountValue && "S:".concat(setCountValue)) || '';
|
|
46
47
|
var finalSetCountValue = stringifySet(matchUpFormatObject.finalSetFormat, preserveRedundant);
|
|
47
|
-
var finalSetCode = (
|
|
48
|
-
|
|
48
|
+
var finalSetCode = (setLimit &&
|
|
49
|
+
setLimit > 1 &&
|
|
49
50
|
finalSetCountValue &&
|
|
50
51
|
setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
|
|
51
52
|
"F:".concat(finalSetCountValue)) ||
|
|
52
53
|
'';
|
|
53
|
-
var valid =
|
|
54
|
+
var valid = setLimitCode && setCountValue;
|
|
54
55
|
if (valid) {
|
|
55
|
-
return [
|
|
56
|
+
return [setLimitCode, setCode, finalSetCode].filter(function (f) { return f; }).join('-');
|
|
56
57
|
}
|
|
57
58
|
return undefined;
|
|
58
59
|
}
|
|
@@ -190,181 +191,6 @@ function skewedDistribution(min, max, skew, step, significantDecimals) {
|
|
|
190
191
|
return parseFloat(num.toFixed(significantDecimals));
|
|
191
192
|
}
|
|
192
193
|
|
|
193
|
-
function parse(matchUpFormatCode) {
|
|
194
|
-
if (typeof matchUpFormatCode === 'string') {
|
|
195
|
-
var type = (matchUpFormatCode.startsWith('T') && TIMED) ||
|
|
196
|
-
(matchUpFormatCode.startsWith(SET) && SET) ||
|
|
197
|
-
'';
|
|
198
|
-
if (type === TIMED) {
|
|
199
|
-
var setFormat = parseTimedSet(matchUpFormatCode);
|
|
200
|
-
var parsedFormat = {
|
|
201
|
-
simplified: true,
|
|
202
|
-
setFormat: setFormat,
|
|
203
|
-
bestOf: 1,
|
|
204
|
-
};
|
|
205
|
-
if (parsedFormat.setFormat)
|
|
206
|
-
return parsedFormat;
|
|
207
|
-
}
|
|
208
|
-
if (type === SET)
|
|
209
|
-
return setsMatch(matchUpFormatCode);
|
|
210
|
-
}
|
|
211
|
-
return undefined;
|
|
212
|
-
}
|
|
213
|
-
function setsMatch(formatstring) {
|
|
214
|
-
var parts = formatstring.split('-');
|
|
215
|
-
var bestOf = getNumber(parts[0].slice(3));
|
|
216
|
-
var setFormat = parts && parseSetFormat(parts[1]);
|
|
217
|
-
var finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
218
|
-
var validBestOf = bestOf && bestOf < 6;
|
|
219
|
-
var validFinalSet = !parts[2] || finalSetFormat;
|
|
220
|
-
var validSetsFormat = setFormat;
|
|
221
|
-
var result = { bestOf: bestOf, setFormat: setFormat };
|
|
222
|
-
if (finalSetFormat)
|
|
223
|
-
result.finalSetFormat = finalSetFormat;
|
|
224
|
-
if (validBestOf && validSetsFormat && validFinalSet)
|
|
225
|
-
return result;
|
|
226
|
-
}
|
|
227
|
-
function parseSetFormat(formatstring) {
|
|
228
|
-
if ((formatstring === null || formatstring === void 0 ? void 0 : formatstring[1]) === ':') {
|
|
229
|
-
var parts = formatstring.split(':');
|
|
230
|
-
var setType = setTypes$1[parts[0]];
|
|
231
|
-
var setFormatString = parts[1];
|
|
232
|
-
if (setType && setFormatString) {
|
|
233
|
-
var isTiebreakSet = setFormatString.indexOf('TB') === 0;
|
|
234
|
-
if (isTiebreakSet) {
|
|
235
|
-
var tiebreakSet = parseTiebreakFormat(setFormatString);
|
|
236
|
-
if (tiebreakSet === false)
|
|
237
|
-
return false;
|
|
238
|
-
return typeof tiebreakSet === 'object' ? { tiebreakSet: tiebreakSet } : undefined;
|
|
239
|
-
}
|
|
240
|
-
var timedSet = setFormatString.indexOf('T') === 0;
|
|
241
|
-
if (timedSet)
|
|
242
|
-
return parseTimedSet(setFormatString);
|
|
243
|
-
var parts_1 = formatstring.match(/^[FS]:(\d+)([A-Za-z]*)/);
|
|
244
|
-
var NoAD = (parts_1 && isNoAD(parts_1[2])) || false;
|
|
245
|
-
var validNoAD = !(parts_1 === null || parts_1 === void 0 ? void 0 : parts_1[2]) || NoAD;
|
|
246
|
-
var setTo = parts_1 ? getNumber(parts_1[1]) : undefined;
|
|
247
|
-
var tiebreakAtValue = parseTiebreakAt(setFormatString);
|
|
248
|
-
var validTiebreakAt = tiebreakAtValue !== false;
|
|
249
|
-
var tiebreakAt = (validTiebreakAt && tiebreakAtValue) || setTo;
|
|
250
|
-
var tiebreakFormat = parseTiebreakFormat(setFormatString.split('/')[1]);
|
|
251
|
-
var validTiebreak = tiebreakFormat !== false;
|
|
252
|
-
var result = { setTo: setTo };
|
|
253
|
-
if (NoAD)
|
|
254
|
-
result.NoAD = true;
|
|
255
|
-
if (tiebreakFormat) {
|
|
256
|
-
result.tiebreakFormat = tiebreakFormat;
|
|
257
|
-
result.tiebreakAt = tiebreakAt;
|
|
258
|
-
}
|
|
259
|
-
else {
|
|
260
|
-
result.noTiebreak = true;
|
|
261
|
-
}
|
|
262
|
-
return ((setTo && validNoAD && validTiebreak && validTiebreakAt && result) ||
|
|
263
|
-
false);
|
|
264
|
-
}
|
|
265
|
-
}
|
|
266
|
-
return undefined;
|
|
267
|
-
}
|
|
268
|
-
function parseTiebreakAt(setFormatString, expectNumber) {
|
|
269
|
-
if (expectNumber === void 0) { expectNumber = true; }
|
|
270
|
-
var tiebreakAtValue = (setFormatString === null || setFormatString === void 0 ? void 0 : setFormatString.indexOf('@')) > 0 && setFormatString.split('@');
|
|
271
|
-
if (tiebreakAtValue) {
|
|
272
|
-
var tiebreakAt = expectNumber
|
|
273
|
-
? getNumber(tiebreakAtValue[1])
|
|
274
|
-
: tiebreakAtValue[1];
|
|
275
|
-
return tiebreakAt || false;
|
|
276
|
-
}
|
|
277
|
-
return undefined;
|
|
278
|
-
}
|
|
279
|
-
function parseTiebreakFormat(formatstring) {
|
|
280
|
-
if (formatstring) {
|
|
281
|
-
if (formatstring.startsWith('TB')) {
|
|
282
|
-
var modifier = parseTiebreakAt(formatstring, false);
|
|
283
|
-
var parts = formatstring.match(/^TB(\d+)([A-Za-z]*)/);
|
|
284
|
-
var tiebreakToString = parts === null || parts === void 0 ? void 0 : parts[1];
|
|
285
|
-
var NoAD = parts && isNoAD(parts[2]);
|
|
286
|
-
var validNoAD = !(parts === null || parts === void 0 ? void 0 : parts[2]) || NoAD;
|
|
287
|
-
var tiebreakTo = getNumber(tiebreakToString);
|
|
288
|
-
if (tiebreakTo && validNoAD) {
|
|
289
|
-
var result = { tiebreakTo: tiebreakTo };
|
|
290
|
-
// modifiers cannot be numeric
|
|
291
|
-
if (modifier &&
|
|
292
|
-
typeof modifier === 'string' &&
|
|
293
|
-
!isConvertableInteger(modifier)) {
|
|
294
|
-
result.modifier = modifier;
|
|
295
|
-
}
|
|
296
|
-
if (NoAD)
|
|
297
|
-
result.NoAD = true;
|
|
298
|
-
return result;
|
|
299
|
-
}
|
|
300
|
-
else {
|
|
301
|
-
return false;
|
|
302
|
-
}
|
|
303
|
-
}
|
|
304
|
-
else {
|
|
305
|
-
return false;
|
|
306
|
-
}
|
|
307
|
-
}
|
|
308
|
-
return undefined;
|
|
309
|
-
}
|
|
310
|
-
function parseTimedSet(formatstring) {
|
|
311
|
-
var _a;
|
|
312
|
-
var timestring = formatstring.slice(1);
|
|
313
|
-
var parts = timestring.match(/^(\d+)(@?[A-Za-z]*)/);
|
|
314
|
-
var minutes = getNumber(parts === null || parts === void 0 ? void 0 : parts[1]);
|
|
315
|
-
if (!minutes)
|
|
316
|
-
return;
|
|
317
|
-
var setFormat = { timed: true, minutes: minutes };
|
|
318
|
-
var based = parts === null || parts === void 0 ? void 0 : parts[2];
|
|
319
|
-
var validModifier = [undefined, 'P', 'G'].includes(based);
|
|
320
|
-
if (based && !validModifier) {
|
|
321
|
-
var modifier = (_a = timestring.match(/^(\d+)(@)([A-Za-z]+)$/)) === null || _a === void 0 ? void 0 : _a[3];
|
|
322
|
-
if (modifier) {
|
|
323
|
-
setFormat.modifier = modifier;
|
|
324
|
-
return setFormat;
|
|
325
|
-
}
|
|
326
|
-
return;
|
|
327
|
-
}
|
|
328
|
-
if (based)
|
|
329
|
-
setFormat.based = parts[2];
|
|
330
|
-
return setFormat;
|
|
331
|
-
}
|
|
332
|
-
function isNoAD(formatstring) {
|
|
333
|
-
return formatstring && formatstring.indexOf(NOAD) >= 0;
|
|
334
|
-
}
|
|
335
|
-
function getNumber(formatstring) {
|
|
336
|
-
return !isNaN(Number(formatstring)) ? Number(formatstring) : 0;
|
|
337
|
-
}
|
|
338
|
-
|
|
339
|
-
function isValid(matchUpFormat) {
|
|
340
|
-
if (typeof matchUpFormat !== 'string')
|
|
341
|
-
return false;
|
|
342
|
-
var parsedFormat = parse(matchUpFormat);
|
|
343
|
-
var setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
344
|
-
var setsTo = setParts === null || setParts === void 0 ? void 0 : setParts[1];
|
|
345
|
-
var tiebreakTo = setParts === null || setParts === void 0 ? void 0 : setParts[2];
|
|
346
|
-
var tiebreakAt = setParts === null || setParts === void 0 ? void 0 : setParts[3];
|
|
347
|
-
var finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
348
|
-
var finalSetTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[1];
|
|
349
|
-
var finalSetTiebreakTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[2];
|
|
350
|
-
var finalTiebreakAt = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[3];
|
|
351
|
-
var preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
|
|
352
|
-
(finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
|
|
353
|
-
var stringified = stringify(parsedFormat, preserveRedundant);
|
|
354
|
-
return stringified === matchUpFormat;
|
|
355
|
-
}
|
|
356
|
-
|
|
357
|
-
var matchUpFormatCode = {
|
|
358
|
-
isValidMatchUpFormat: isValid,
|
|
359
|
-
stringify: stringify,
|
|
360
|
-
isValid: isValid,
|
|
361
|
-
parse: parse,
|
|
362
|
-
};
|
|
363
|
-
|
|
364
|
-
function factoryVersion() {
|
|
365
|
-
return '1.8.3';
|
|
366
|
-
}
|
|
367
|
-
|
|
368
194
|
/******************************************************************************
|
|
369
195
|
Copyright (c) Microsoft Corporation.
|
|
370
196
|
|
|
@@ -566,69 +392,6 @@ typeof SuppressedError === "function" ? SuppressedError : function (error, suppr
|
|
|
566
392
|
return e.name = "SuppressedError", e.error = error, e.suppressed = suppressed, e;
|
|
567
393
|
};
|
|
568
394
|
|
|
569
|
-
function getObjectTieFormat(obj) {
|
|
570
|
-
if (!obj)
|
|
571
|
-
return;
|
|
572
|
-
var tieFormatId = obj.tieFormatId, tieFormats = obj.tieFormats;
|
|
573
|
-
if (obj.tieFormat) {
|
|
574
|
-
return obj.tieFormat;
|
|
575
|
-
}
|
|
576
|
-
else if (tieFormatId && Array.isArray(tieFormats)) {
|
|
577
|
-
return tieFormats.find(function (tf) { return tf.tieFormatId === tieFormatId; });
|
|
578
|
-
}
|
|
579
|
-
}
|
|
580
|
-
|
|
581
|
-
function getItemTieFormat(_a) {
|
|
582
|
-
var _b, _c, _d;
|
|
583
|
-
var item = _a.item, drawDefinition = _a.drawDefinition, structure = _a.structure, event = _a.event;
|
|
584
|
-
if (!item)
|
|
585
|
-
return;
|
|
586
|
-
if (item.tieFormat)
|
|
587
|
-
return item.tieFormat;
|
|
588
|
-
// if there is a tieFormatId, only possible to look for referenced tieFormat in tieFormats on drawDefinition and event
|
|
589
|
-
if (item.tieFormatId) {
|
|
590
|
-
if (drawDefinition.tieFormat)
|
|
591
|
-
return drawDefinition.tieFormat;
|
|
592
|
-
var tieFormat = (_b = drawDefinition.tieFormats) === null || _b === void 0 ? void 0 : _b.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
593
|
-
if (tieFormat)
|
|
594
|
-
return tieFormat;
|
|
595
|
-
if (event.tieFormat)
|
|
596
|
-
return event.tieFormat;
|
|
597
|
-
return (_c = event.tieFormats) === null || _c === void 0 ? void 0 : _c.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
598
|
-
}
|
|
599
|
-
if (structure.tieFormat)
|
|
600
|
-
return structure.tieFormat;
|
|
601
|
-
if (structure.tieFormatId) {
|
|
602
|
-
var structureTieFormat = (_d = drawDefinition.tieFormats) === null || _d === void 0 ? void 0 : _d.find(function (tf) { return structure.tieFormatId === tf.tieFormatId; });
|
|
603
|
-
if (structureTieFormat)
|
|
604
|
-
return structureTieFormat;
|
|
605
|
-
}
|
|
606
|
-
}
|
|
607
|
-
|
|
608
|
-
function resolveTieFormat(_a) {
|
|
609
|
-
var drawDefinition = _a.drawDefinition, structure = _a.structure, matchUp = _a.matchUp, event = _a.event;
|
|
610
|
-
return {
|
|
611
|
-
tieFormat: getItemTieFormat({
|
|
612
|
-
item: matchUp,
|
|
613
|
-
drawDefinition: drawDefinition,
|
|
614
|
-
structure: structure,
|
|
615
|
-
event: event,
|
|
616
|
-
}) ||
|
|
617
|
-
getItemTieFormat({
|
|
618
|
-
item: structure,
|
|
619
|
-
drawDefinition: drawDefinition,
|
|
620
|
-
structure: structure,
|
|
621
|
-
event: event,
|
|
622
|
-
}) ||
|
|
623
|
-
getObjectTieFormat(drawDefinition) ||
|
|
624
|
-
getObjectTieFormat(event),
|
|
625
|
-
};
|
|
626
|
-
}
|
|
627
|
-
|
|
628
|
-
function mustBeAnArray(value) {
|
|
629
|
-
return "".concat(value, " must be an array");
|
|
630
|
-
}
|
|
631
|
-
|
|
632
395
|
// returns only unique values within an array
|
|
633
396
|
function unique(arr) {
|
|
634
397
|
return arr.filter(function (item, i, s) { return s.lastIndexOf(item) === i; });
|
|
@@ -1446,10 +1209,18 @@ var INVALID_CONFIGURATION = {
|
|
|
1446
1209
|
message: 'Invalid configuration',
|
|
1447
1210
|
code: 'ERR_INVALID_CONFIG',
|
|
1448
1211
|
};
|
|
1212
|
+
var INVALID_COLLECTION_DEFINITION = {
|
|
1213
|
+
message: 'Invalid collectionDefinition',
|
|
1214
|
+
code: 'ERR_INVALID_COLLECTION_DEFINITION',
|
|
1215
|
+
};
|
|
1449
1216
|
var INVALID_OBJECT = {
|
|
1450
1217
|
message: 'Invalid object',
|
|
1451
1218
|
code: 'ERR_INVALID_OBJECT',
|
|
1452
1219
|
};
|
|
1220
|
+
var INVALID_CATEGORY = {
|
|
1221
|
+
message: 'Invalid category',
|
|
1222
|
+
code: 'ERR_INVALID_CATEGORY',
|
|
1223
|
+
};
|
|
1453
1224
|
var INVALID_VALUES = {
|
|
1454
1225
|
message: 'Invalid values',
|
|
1455
1226
|
code: 'ERR_INVALID_VALUES',
|
|
@@ -1550,6 +1321,8 @@ var errorConditionConstants = {
|
|
|
1550
1321
|
INVALID_ACTION: INVALID_ACTION,
|
|
1551
1322
|
INVALID_ASSIGNMENT: INVALID_ASSIGNMENT,
|
|
1552
1323
|
INVALID_BOOKINGS: INVALID_BOOKINGS,
|
|
1324
|
+
INVALID_CATEGORY: INVALID_CATEGORY,
|
|
1325
|
+
INVALID_COLLECTION_DEFINITION: INVALID_COLLECTION_DEFINITION,
|
|
1553
1326
|
INVALID_CONFIGURATION: INVALID_CONFIGURATION,
|
|
1554
1327
|
INVALID_DATE_AVAILABILITY: INVALID_DATE_AVAILABILITY,
|
|
1555
1328
|
INVALID_DATE: INVALID_DATE,
|
|
@@ -2004,6 +1777,9 @@ function setTournamentId(tournamentId) {
|
|
|
2004
1777
|
function removeTournamentRecord(tournamentId) {
|
|
2005
1778
|
return _globalStateProvider.removeTournamentRecord(tournamentId);
|
|
2006
1779
|
}
|
|
1780
|
+
function getProvider() {
|
|
1781
|
+
return _globalStateProvider;
|
|
1782
|
+
}
|
|
2007
1783
|
function handleCaughtError(_a) {
|
|
2008
1784
|
var engineName = _a.engineName, methodName = _a.methodName, params = _a.params, err = _a.err;
|
|
2009
1785
|
var caughtErrorHandler = (typeof _globalStateProvider.handleCaughtError === 'function' &&
|
|
@@ -2371,6 +2147,8 @@ iteration // escape hatch - check against iteration threshold
|
|
|
2371
2147
|
) {
|
|
2372
2148
|
var e_1, _a;
|
|
2373
2149
|
if (iteration === void 0) { iteration = 0; }
|
|
2150
|
+
if (getProvider().makeDeepCopy)
|
|
2151
|
+
return getProvider().makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtensions);
|
|
2374
2152
|
var deepCopy = deepCopyEnabled();
|
|
2375
2153
|
var _b = deepCopy || {}, stringify = _b.stringify, toJSON = _b.toJSON, ignore = _b.ignore, modulate = _b.modulate;
|
|
2376
2154
|
if ((!(deepCopy === null || deepCopy === void 0 ? void 0 : deepCopy.enabled) && !internalUse) ||
|
|
@@ -2941,6 +2719,490 @@ function UUID() {
|
|
|
2941
2719
|
lut[(d3 >> 24) & 0xff]);
|
|
2942
2720
|
}
|
|
2943
2721
|
|
|
2722
|
+
function parse(matchUpFormatCode) {
|
|
2723
|
+
if (typeof matchUpFormatCode === 'string') {
|
|
2724
|
+
var type = (matchUpFormatCode.startsWith('T') && TIMED) ||
|
|
2725
|
+
(matchUpFormatCode.startsWith(SET) && SET) ||
|
|
2726
|
+
'';
|
|
2727
|
+
if (type === TIMED) {
|
|
2728
|
+
var setFormat = parseTimedSet(matchUpFormatCode);
|
|
2729
|
+
var parsedFormat = {
|
|
2730
|
+
simplified: true,
|
|
2731
|
+
setFormat: setFormat,
|
|
2732
|
+
bestOf: 1,
|
|
2733
|
+
};
|
|
2734
|
+
if (setFormat)
|
|
2735
|
+
return parsedFormat;
|
|
2736
|
+
}
|
|
2737
|
+
if (type === SET)
|
|
2738
|
+
return setsMatch(matchUpFormatCode);
|
|
2739
|
+
}
|
|
2740
|
+
return undefined;
|
|
2741
|
+
}
|
|
2742
|
+
function setsMatch(formatstring) {
|
|
2743
|
+
var parts = formatstring.split('-');
|
|
2744
|
+
var setsCount = getNumber(parts[0].slice(3));
|
|
2745
|
+
var bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : undefined;
|
|
2746
|
+
var exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : undefined;
|
|
2747
|
+
var setFormat = parts && parseSetFormat(parts[1]);
|
|
2748
|
+
var finalSetFormat = parts && parseSetFormat(parts[2]);
|
|
2749
|
+
var timed = (setFormat && setFormat.timed) || (finalSetFormat && finalSetFormat.timed);
|
|
2750
|
+
var validSetsCount = (bestOf && bestOf < 6) || (timed && exactly);
|
|
2751
|
+
var validFinalSet = !parts[2] || finalSetFormat;
|
|
2752
|
+
var validSetsFormat = setFormat;
|
|
2753
|
+
var result = definedAttributes({
|
|
2754
|
+
setFormat: setFormat,
|
|
2755
|
+
exactly: exactly,
|
|
2756
|
+
bestOf: bestOf,
|
|
2757
|
+
});
|
|
2758
|
+
if (finalSetFormat)
|
|
2759
|
+
result.finalSetFormat = finalSetFormat;
|
|
2760
|
+
if (validSetsCount && validSetsFormat && validFinalSet)
|
|
2761
|
+
return result;
|
|
2762
|
+
}
|
|
2763
|
+
function parseSetFormat(formatstring) {
|
|
2764
|
+
if ((formatstring === null || formatstring === void 0 ? void 0 : formatstring[1]) === ':') {
|
|
2765
|
+
var parts = formatstring.split(':');
|
|
2766
|
+
var setType = setTypes$1[parts[0]];
|
|
2767
|
+
var setFormatString = parts[1];
|
|
2768
|
+
if (setType && setFormatString) {
|
|
2769
|
+
var isTiebreakSet = setFormatString.indexOf('TB') === 0;
|
|
2770
|
+
if (isTiebreakSet) {
|
|
2771
|
+
var tiebreakSet = parseTiebreakFormat(setFormatString);
|
|
2772
|
+
if (tiebreakSet === false)
|
|
2773
|
+
return false;
|
|
2774
|
+
return typeof tiebreakSet === 'object' ? { tiebreakSet: tiebreakSet } : undefined;
|
|
2775
|
+
}
|
|
2776
|
+
var timedSet = setFormatString.indexOf('T') === 0;
|
|
2777
|
+
if (timedSet)
|
|
2778
|
+
return parseTimedSet(setFormatString);
|
|
2779
|
+
var parts_1 = formatstring.match(/^[FS]:(\d+)([A-Za-z]*)/);
|
|
2780
|
+
var NoAD = (parts_1 && isNoAD(parts_1[2])) || false;
|
|
2781
|
+
var validNoAD = !(parts_1 === null || parts_1 === void 0 ? void 0 : parts_1[2]) || NoAD;
|
|
2782
|
+
var setTo = parts_1 ? getNumber(parts_1[1]) : undefined;
|
|
2783
|
+
var tiebreakAtValue = parseTiebreakAt(setFormatString);
|
|
2784
|
+
var validTiebreakAt = tiebreakAtValue !== false;
|
|
2785
|
+
var tiebreakAt = (validTiebreakAt && tiebreakAtValue) || setTo;
|
|
2786
|
+
var tiebreakFormat = parseTiebreakFormat(setFormatString.split('/')[1]);
|
|
2787
|
+
var validTiebreak = tiebreakFormat !== false;
|
|
2788
|
+
var result = { setTo: setTo };
|
|
2789
|
+
if (NoAD)
|
|
2790
|
+
result.NoAD = true;
|
|
2791
|
+
if (tiebreakFormat) {
|
|
2792
|
+
result.tiebreakFormat = tiebreakFormat;
|
|
2793
|
+
result.tiebreakAt = tiebreakAt;
|
|
2794
|
+
}
|
|
2795
|
+
else {
|
|
2796
|
+
result.noTiebreak = true;
|
|
2797
|
+
}
|
|
2798
|
+
return ((setTo && validNoAD && validTiebreak && validTiebreakAt && result) ||
|
|
2799
|
+
false);
|
|
2800
|
+
}
|
|
2801
|
+
}
|
|
2802
|
+
return undefined;
|
|
2803
|
+
}
|
|
2804
|
+
function parseTiebreakAt(setFormatString, expectNumber) {
|
|
2805
|
+
if (expectNumber === void 0) { expectNumber = true; }
|
|
2806
|
+
var tiebreakAtValue = (setFormatString === null || setFormatString === void 0 ? void 0 : setFormatString.indexOf('@')) > 0 && setFormatString.split('@');
|
|
2807
|
+
if (tiebreakAtValue) {
|
|
2808
|
+
var tiebreakAt = expectNumber
|
|
2809
|
+
? getNumber(tiebreakAtValue[1])
|
|
2810
|
+
: tiebreakAtValue[1];
|
|
2811
|
+
return tiebreakAt || false;
|
|
2812
|
+
}
|
|
2813
|
+
return undefined;
|
|
2814
|
+
}
|
|
2815
|
+
function parseTiebreakFormat(formatstring) {
|
|
2816
|
+
if (formatstring) {
|
|
2817
|
+
if (formatstring.startsWith('TB')) {
|
|
2818
|
+
var modifier = parseTiebreakAt(formatstring, false);
|
|
2819
|
+
var parts = formatstring.match(/^TB(\d+)([A-Za-z]*)/);
|
|
2820
|
+
var tiebreakToString = parts === null || parts === void 0 ? void 0 : parts[1];
|
|
2821
|
+
var NoAD = parts && isNoAD(parts[2]);
|
|
2822
|
+
var validNoAD = !(parts === null || parts === void 0 ? void 0 : parts[2]) || NoAD;
|
|
2823
|
+
var tiebreakTo = getNumber(tiebreakToString);
|
|
2824
|
+
if (tiebreakTo && validNoAD) {
|
|
2825
|
+
var result = { tiebreakTo: tiebreakTo };
|
|
2826
|
+
// modifiers cannot be numeric
|
|
2827
|
+
if (modifier &&
|
|
2828
|
+
typeof modifier === 'string' &&
|
|
2829
|
+
!isConvertableInteger(modifier)) {
|
|
2830
|
+
result.modifier = modifier;
|
|
2831
|
+
}
|
|
2832
|
+
if (NoAD)
|
|
2833
|
+
result.NoAD = true;
|
|
2834
|
+
return result;
|
|
2835
|
+
}
|
|
2836
|
+
else {
|
|
2837
|
+
return false;
|
|
2838
|
+
}
|
|
2839
|
+
}
|
|
2840
|
+
else {
|
|
2841
|
+
return false;
|
|
2842
|
+
}
|
|
2843
|
+
}
|
|
2844
|
+
return undefined;
|
|
2845
|
+
}
|
|
2846
|
+
function parseTimedSet(formatstring) {
|
|
2847
|
+
var _a;
|
|
2848
|
+
var timestring = formatstring.slice(1);
|
|
2849
|
+
var parts = timestring.match(/^(\d+)(@?[A-Za-z]*)/);
|
|
2850
|
+
var minutes = getNumber(parts === null || parts === void 0 ? void 0 : parts[1]);
|
|
2851
|
+
if (!minutes)
|
|
2852
|
+
return;
|
|
2853
|
+
var setFormat = { timed: true, minutes: minutes };
|
|
2854
|
+
var based = parts === null || parts === void 0 ? void 0 : parts[2];
|
|
2855
|
+
var validModifier = [undefined, 'P', 'G'].includes(based);
|
|
2856
|
+
if (based && !validModifier) {
|
|
2857
|
+
var modifier = (_a = timestring.match(/^(\d+)(@)([A-Za-z]+)$/)) === null || _a === void 0 ? void 0 : _a[3];
|
|
2858
|
+
if (modifier) {
|
|
2859
|
+
setFormat.modifier = modifier;
|
|
2860
|
+
return setFormat;
|
|
2861
|
+
}
|
|
2862
|
+
return;
|
|
2863
|
+
}
|
|
2864
|
+
if (based)
|
|
2865
|
+
setFormat.based = parts[2];
|
|
2866
|
+
return setFormat;
|
|
2867
|
+
}
|
|
2868
|
+
function isNoAD(formatstring) {
|
|
2869
|
+
return formatstring && formatstring.indexOf(NOAD) >= 0;
|
|
2870
|
+
}
|
|
2871
|
+
function getNumber(formatstring) {
|
|
2872
|
+
return !isNaN(Number(formatstring)) ? Number(formatstring) : 0;
|
|
2873
|
+
}
|
|
2874
|
+
|
|
2875
|
+
function isValid(matchUpFormat) {
|
|
2876
|
+
if (typeof matchUpFormat !== 'string')
|
|
2877
|
+
return false;
|
|
2878
|
+
var parsedFormat = parse(matchUpFormat);
|
|
2879
|
+
var setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
2880
|
+
var setsTo = setParts === null || setParts === void 0 ? void 0 : setParts[1];
|
|
2881
|
+
var tiebreakTo = setParts === null || setParts === void 0 ? void 0 : setParts[2];
|
|
2882
|
+
var tiebreakAt = setParts === null || setParts === void 0 ? void 0 : setParts[3];
|
|
2883
|
+
var finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
|
|
2884
|
+
var finalSetTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[1];
|
|
2885
|
+
var finalSetTiebreakTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[2];
|
|
2886
|
+
var finalTiebreakAt = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[3];
|
|
2887
|
+
var preserveRedundant = !!((setParts && tiebreakTo && setsTo === tiebreakAt) ||
|
|
2888
|
+
(finalSetParts && finalSetTiebreakTo && finalSetTo === finalTiebreakAt));
|
|
2889
|
+
var stringified = stringify(parsedFormat, preserveRedundant);
|
|
2890
|
+
return stringified === matchUpFormat;
|
|
2891
|
+
}
|
|
2892
|
+
|
|
2893
|
+
var matchUpFormatCode = {
|
|
2894
|
+
isValidMatchUpFormat: isValid,
|
|
2895
|
+
stringify: stringify,
|
|
2896
|
+
isValid: isValid,
|
|
2897
|
+
parse: parse,
|
|
2898
|
+
};
|
|
2899
|
+
|
|
2900
|
+
function factoryVersion() {
|
|
2901
|
+
return '1.8.5';
|
|
2902
|
+
}
|
|
2903
|
+
|
|
2904
|
+
function getObjectTieFormat(obj) {
|
|
2905
|
+
if (!obj)
|
|
2906
|
+
return;
|
|
2907
|
+
var tieFormatId = obj.tieFormatId, tieFormats = obj.tieFormats;
|
|
2908
|
+
if (obj.tieFormat) {
|
|
2909
|
+
return obj.tieFormat;
|
|
2910
|
+
}
|
|
2911
|
+
else if (tieFormatId && Array.isArray(tieFormats)) {
|
|
2912
|
+
return tieFormats.find(function (tf) { return tf.tieFormatId === tieFormatId; });
|
|
2913
|
+
}
|
|
2914
|
+
}
|
|
2915
|
+
|
|
2916
|
+
function getItemTieFormat(_a) {
|
|
2917
|
+
var _b, _c, _d;
|
|
2918
|
+
var item = _a.item, drawDefinition = _a.drawDefinition, structure = _a.structure, event = _a.event;
|
|
2919
|
+
if (!item)
|
|
2920
|
+
return;
|
|
2921
|
+
if (item.tieFormat)
|
|
2922
|
+
return item.tieFormat;
|
|
2923
|
+
// if there is a tieFormatId, only possible to look for referenced tieFormat in tieFormats on drawDefinition and event
|
|
2924
|
+
if (item.tieFormatId) {
|
|
2925
|
+
if (drawDefinition.tieFormat)
|
|
2926
|
+
return drawDefinition.tieFormat;
|
|
2927
|
+
var tieFormat = (_b = drawDefinition.tieFormats) === null || _b === void 0 ? void 0 : _b.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
2928
|
+
if (tieFormat)
|
|
2929
|
+
return tieFormat;
|
|
2930
|
+
if (event.tieFormat)
|
|
2931
|
+
return event.tieFormat;
|
|
2932
|
+
return (_c = event.tieFormats) === null || _c === void 0 ? void 0 : _c.find(function (tf) { return item.tieFormatId === tf.tieFormatId; });
|
|
2933
|
+
}
|
|
2934
|
+
if (structure.tieFormat)
|
|
2935
|
+
return structure.tieFormat;
|
|
2936
|
+
if (structure.tieFormatId) {
|
|
2937
|
+
var structureTieFormat = (_d = drawDefinition.tieFormats) === null || _d === void 0 ? void 0 : _d.find(function (tf) { return structure.tieFormatId === tf.tieFormatId; });
|
|
2938
|
+
if (structureTieFormat)
|
|
2939
|
+
return structureTieFormat;
|
|
2940
|
+
}
|
|
2941
|
+
}
|
|
2942
|
+
|
|
2943
|
+
function resolveTieFormat(_a) {
|
|
2944
|
+
var drawDefinition = _a.drawDefinition, structure = _a.structure, matchUp = _a.matchUp, event = _a.event;
|
|
2945
|
+
return {
|
|
2946
|
+
tieFormat: getItemTieFormat({
|
|
2947
|
+
item: matchUp,
|
|
2948
|
+
drawDefinition: drawDefinition,
|
|
2949
|
+
structure: structure,
|
|
2950
|
+
event: event,
|
|
2951
|
+
}) ||
|
|
2952
|
+
getItemTieFormat({
|
|
2953
|
+
item: structure,
|
|
2954
|
+
drawDefinition: drawDefinition,
|
|
2955
|
+
structure: structure,
|
|
2956
|
+
event: event,
|
|
2957
|
+
}) ||
|
|
2958
|
+
getObjectTieFormat(drawDefinition) ||
|
|
2959
|
+
getObjectTieFormat(event),
|
|
2960
|
+
};
|
|
2961
|
+
}
|
|
2962
|
+
|
|
2963
|
+
var typeMatch = function (arr, type) {
|
|
2964
|
+
return arr.filter(Boolean).every(function (i) { return typeof i === type; });
|
|
2965
|
+
};
|
|
2966
|
+
var allNumeric = function (arr) { return arr.filter(Boolean).every(isNumeric); };
|
|
2967
|
+
function getCategoryAgeDetails(params) {
|
|
2968
|
+
var _a, _b;
|
|
2969
|
+
var category = params.category;
|
|
2970
|
+
if (typeof category !== 'object')
|
|
2971
|
+
return { error: INVALID_CATEGORY };
|
|
2972
|
+
var ageCategoryCode = category.ageCategoryCode, ageMaxDate = category.ageMaxDate, ageMinDate = category.ageMinDate, ageMax = category.ageMax, ageMin = category.ageMin;
|
|
2973
|
+
var categoryName = category.categoryName;
|
|
2974
|
+
var combinedAge;
|
|
2975
|
+
if (!typeMatch([ageCategoryCode, ageMaxDate, ageMinDate, categoryName], 'string') ||
|
|
2976
|
+
!allNumeric([ageMax, ageMin] ||
|
|
2977
|
+
![ageMaxDate, ageMinDate].filter(Boolean).every(isValidDateString)))
|
|
2978
|
+
return { error: INVALID_CATEGORY };
|
|
2979
|
+
var consideredDate = (_a = params.consideredDate) !== null && _a !== void 0 ? _a : extractDate(new Date().toLocaleDateString('sv'));
|
|
2980
|
+
if (!isValidDateString(consideredDate))
|
|
2981
|
+
return { error: INVALID_DATE };
|
|
2982
|
+
// const [consideredYear, month, day] = consideredDate
|
|
2983
|
+
var _c = __read(consideredDate
|
|
2984
|
+
.split('-')
|
|
2985
|
+
.slice(0, 3)
|
|
2986
|
+
.map(function (n) { return parseInt(n); }), 1), consideredYear = _c[0];
|
|
2987
|
+
// const monthDay = `${zeroPad(month)}-${zeroPad(day)}`;
|
|
2988
|
+
var previousDayDate = dateStringDaysChange(consideredDate, -1);
|
|
2989
|
+
var _d = __read(previousDayDate
|
|
2990
|
+
.split('-')
|
|
2991
|
+
.slice(1, 3)
|
|
2992
|
+
.map(function (n) { return parseInt(n); }), 2), previousDayMonth = _d[0], previousDay = _d[1];
|
|
2993
|
+
var previousMonthDay = "".concat(zeroPad(previousDayMonth), "-").concat(zeroPad(previousDay));
|
|
2994
|
+
var nextDayDate = dateStringDaysChange(consideredDate, 1);
|
|
2995
|
+
var _e = __read(nextDayDate
|
|
2996
|
+
.split('-')
|
|
2997
|
+
.slice(1, 3)
|
|
2998
|
+
.map(function (n) { return parseInt(n); }), 2), nextDayMonth = _e[0], nextDay = _e[1];
|
|
2999
|
+
var nextMonthDay = "".concat(zeroPad(nextDayMonth), "-").concat(zeroPad(nextDay));
|
|
3000
|
+
var calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
|
|
3001
|
+
var calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
|
|
3002
|
+
// collect errors; e.g. provided ageMin does not equal calculated ageMin
|
|
3003
|
+
var errors = [];
|
|
3004
|
+
var addError = function (errorString) {
|
|
3005
|
+
return !errors.includes(errorString) && errors.push(errorString);
|
|
3006
|
+
};
|
|
3007
|
+
ageCategoryCode = ageCategoryCode !== null && ageCategoryCode !== void 0 ? ageCategoryCode : categoryName;
|
|
3008
|
+
var prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
|
|
3009
|
+
var extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
|
|
3010
|
+
var isBetween = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.includes('-');
|
|
3011
|
+
var isCombined = isBetween && (ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined));
|
|
3012
|
+
var isCoded = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(prePost);
|
|
3013
|
+
// construct min or max date with or without year
|
|
3014
|
+
//const isYYMM = (datePart) => datePart.match(/^\d{2}-\d{2}$/);
|
|
3015
|
+
var constructedDate = function (y, df) { return "".concat(y, "-").concat(df); };
|
|
3016
|
+
var uPre = function (ageInt) {
|
|
3017
|
+
var ageMinYear = consideredYear - ageInt;
|
|
3018
|
+
var newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3019
|
+
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
3020
|
+
addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
|
|
3021
|
+
ageMinDate = newMinDate;
|
|
3022
|
+
if (ageCategoryCode) {
|
|
3023
|
+
if (category.ageMax && category.ageMax !== ageInt - 1) {
|
|
3024
|
+
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3025
|
+
calculatedAgeMinDate = undefined;
|
|
3026
|
+
}
|
|
3027
|
+
ageMax = ageInt - 1;
|
|
3028
|
+
}
|
|
3029
|
+
};
|
|
3030
|
+
var uPost = function (ageInt) {
|
|
3031
|
+
var ageMinYear = consideredYear - ageInt - 1;
|
|
3032
|
+
var newMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3033
|
+
if (category.ageMin && category.ageMin > ageInt) {
|
|
3034
|
+
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3035
|
+
}
|
|
3036
|
+
if (category.ageMax && category.ageMax > ageInt) {
|
|
3037
|
+
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3038
|
+
}
|
|
3039
|
+
if (category.ageMinDate && category.ageMinDate !== newMinDate)
|
|
3040
|
+
addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
|
|
3041
|
+
ageMinDate = newMinDate;
|
|
3042
|
+
if (ageCategoryCode) {
|
|
3043
|
+
if (category.ageMax && category.ageMax !== ageInt) {
|
|
3044
|
+
addError("Invalid submitted ageMax: ".concat(ageMax));
|
|
3045
|
+
calculatedAgeMaxDate = undefined;
|
|
3046
|
+
}
|
|
3047
|
+
ageMax = ageInt;
|
|
3048
|
+
}
|
|
3049
|
+
};
|
|
3050
|
+
var oPre = function (ageInt) {
|
|
3051
|
+
var ageMaxYear = consideredYear - ageInt;
|
|
3052
|
+
var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3053
|
+
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
3054
|
+
addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
|
|
3055
|
+
ageMaxDate = newMaxDate;
|
|
3056
|
+
if (ageCategoryCode) {
|
|
3057
|
+
if (category.ageMin && category.ageMin !== ageInt + 1) {
|
|
3058
|
+
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3059
|
+
calculatedAgeMaxDate = undefined;
|
|
3060
|
+
}
|
|
3061
|
+
ageMin = ageInt + 1;
|
|
3062
|
+
}
|
|
3063
|
+
};
|
|
3064
|
+
var oPost = function (ageInt) {
|
|
3065
|
+
var ageMaxYear = consideredYear - ageInt - 1;
|
|
3066
|
+
var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3067
|
+
if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
|
|
3068
|
+
addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
|
|
3069
|
+
ageMaxDate = newMaxDate;
|
|
3070
|
+
if (ageCategoryCode) {
|
|
3071
|
+
if (category.ageMin && category.ageMin !== ageInt) {
|
|
3072
|
+
addError("Invalid submitted ageMin: ".concat(ageMin));
|
|
3073
|
+
calculatedAgeMaxDate = undefined;
|
|
3074
|
+
}
|
|
3075
|
+
ageMin = ageInt;
|
|
3076
|
+
}
|
|
3077
|
+
};
|
|
3078
|
+
var processCode = function (code) {
|
|
3079
|
+
var _a = __read((code.match(prePost) || []).slice(1), 3), pre = _a[0], age = _a[1], post = _a[2];
|
|
3080
|
+
var ageInt = parseInt(age);
|
|
3081
|
+
if (pre === 'U') {
|
|
3082
|
+
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
3083
|
+
addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
|
|
3084
|
+
}
|
|
3085
|
+
uPre(ageInt);
|
|
3086
|
+
}
|
|
3087
|
+
else if (pre === 'O') {
|
|
3088
|
+
oPre(ageInt);
|
|
3089
|
+
}
|
|
3090
|
+
if (post === 'U') {
|
|
3091
|
+
if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
|
|
3092
|
+
addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
|
|
3093
|
+
}
|
|
3094
|
+
uPost(ageInt);
|
|
3095
|
+
}
|
|
3096
|
+
else if (post === 'O') {
|
|
3097
|
+
oPost(ageInt);
|
|
3098
|
+
}
|
|
3099
|
+
ageMaxDate = ageMaxDate !== null && ageMaxDate !== void 0 ? ageMaxDate : calculatedAgeMaxDate;
|
|
3100
|
+
ageMinDate = ageMinDate !== null && ageMinDate !== void 0 ? ageMinDate : calculatedAgeMinDate;
|
|
3101
|
+
};
|
|
3102
|
+
if (isCombined) {
|
|
3103
|
+
// min and max birthdates are not relevant
|
|
3104
|
+
// TODO: utility function to calculate combined age given two birthdates?
|
|
3105
|
+
ageMaxDate = undefined;
|
|
3106
|
+
ageMinDate = undefined;
|
|
3107
|
+
ageMax = undefined;
|
|
3108
|
+
ageMin = undefined;
|
|
3109
|
+
if (category.ageMin) {
|
|
3110
|
+
// calculate ageMaxDate
|
|
3111
|
+
var ageMaxYear = consideredYear - category.ageMin;
|
|
3112
|
+
ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
|
|
3113
|
+
}
|
|
3114
|
+
if (category.ageMax) {
|
|
3115
|
+
// calculate ageMinDate
|
|
3116
|
+
var ageMinYear = consideredYear - category.ageMax - 1;
|
|
3117
|
+
ageMinDate = constructedDate(ageMinYear, nextMonthDay);
|
|
3118
|
+
}
|
|
3119
|
+
var _f = __read(((_b = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined)) !== null && _b !== void 0 ? _b : [])
|
|
3120
|
+
.slice(1)
|
|
3121
|
+
.map(function (n) { return parseInt(n); }), 2), lowAge = _f[0], highAge = _f[1];
|
|
3122
|
+
if (lowAge <= highAge) {
|
|
3123
|
+
ageMin = lowAge;
|
|
3124
|
+
ageMax = highAge;
|
|
3125
|
+
combinedAge = true;
|
|
3126
|
+
}
|
|
3127
|
+
else {
|
|
3128
|
+
addError("Invalid combined age range ".concat(ageCategoryCode));
|
|
3129
|
+
}
|
|
3130
|
+
}
|
|
3131
|
+
else if (isBetween) {
|
|
3132
|
+
ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.split('-').forEach(processCode);
|
|
3133
|
+
}
|
|
3134
|
+
else if (isCoded) {
|
|
3135
|
+
processCode(ageCategoryCode);
|
|
3136
|
+
}
|
|
3137
|
+
else {
|
|
3138
|
+
if (ageMin)
|
|
3139
|
+
oPre(ageMin);
|
|
3140
|
+
if (ageMax)
|
|
3141
|
+
uPost(ageMax);
|
|
3142
|
+
}
|
|
3143
|
+
if (ageMax && category.ageMin && category.ageMin > ageMax) {
|
|
3144
|
+
addError("Invalid submitted ageMin: ".concat(category.ageMin));
|
|
3145
|
+
ageMin = undefined;
|
|
3146
|
+
}
|
|
3147
|
+
var result = definedAttributes({
|
|
3148
|
+
consideredDate: consideredDate,
|
|
3149
|
+
combinedAge: combinedAge,
|
|
3150
|
+
ageMaxDate: ageMaxDate,
|
|
3151
|
+
ageMinDate: ageMinDate,
|
|
3152
|
+
ageMax: ageMax,
|
|
3153
|
+
ageMin: ageMin,
|
|
3154
|
+
});
|
|
3155
|
+
if (errors.length)
|
|
3156
|
+
result.errors = errors;
|
|
3157
|
+
return result;
|
|
3158
|
+
}
|
|
3159
|
+
|
|
3160
|
+
function categoryCanContain(_a) {
|
|
3161
|
+
var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
|
|
3162
|
+
var categoryDetails = getCategoryAgeDetails({ category: category });
|
|
3163
|
+
var childCategoryDetails = getCategoryAgeDetails({
|
|
3164
|
+
category: childCategory,
|
|
3165
|
+
});
|
|
3166
|
+
var invalidAgeMin = childCategoryDetails.ageMin &&
|
|
3167
|
+
((categoryDetails.ageMin &&
|
|
3168
|
+
childCategoryDetails.ageMin < categoryDetails.ageMin) ||
|
|
3169
|
+
(categoryDetails.ageMax &&
|
|
3170
|
+
childCategoryDetails.ageMin > categoryDetails.ageMax));
|
|
3171
|
+
var invalidAgeMax = childCategoryDetails.ageMax &&
|
|
3172
|
+
((categoryDetails.ageMax &&
|
|
3173
|
+
childCategoryDetails.ageMax > categoryDetails.ageMax) ||
|
|
3174
|
+
(categoryDetails.ageMin &&
|
|
3175
|
+
childCategoryDetails.ageMax < categoryDetails.ageMin));
|
|
3176
|
+
var invalidAgeMinDate = childCategoryDetails.ageMinDate &&
|
|
3177
|
+
categoryDetails.ageMaxDate &&
|
|
3178
|
+
new Date(childCategoryDetails.ageMinDate) >
|
|
3179
|
+
new Date(categoryDetails.ageMaxDate);
|
|
3180
|
+
var invalidAgeMaxDate = childCategoryDetails.ageMaxDate &&
|
|
3181
|
+
categoryDetails.ageMinDate &&
|
|
3182
|
+
new Date(childCategoryDetails.ageMaxDate) <
|
|
3183
|
+
new Date(categoryDetails.ageMinDate);
|
|
3184
|
+
var valid = !invalidAgeMax &&
|
|
3185
|
+
!invalidAgeMin &&
|
|
3186
|
+
!invalidAgeMinDate &&
|
|
3187
|
+
!invalidAgeMaxDate;
|
|
3188
|
+
var ignoreFalse = true;
|
|
3189
|
+
var result = definedAttributes({
|
|
3190
|
+
valid: valid,
|
|
3191
|
+
invalidAgeMax: invalidAgeMax,
|
|
3192
|
+
invalidAgeMin: invalidAgeMin,
|
|
3193
|
+
invalidAgeMinDate: invalidAgeMinDate,
|
|
3194
|
+
invalidAgeMaxDate: invalidAgeMaxDate,
|
|
3195
|
+
}, ignoreFalse);
|
|
3196
|
+
if (withDetails) {
|
|
3197
|
+
Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
|
|
3198
|
+
}
|
|
3199
|
+
return result;
|
|
3200
|
+
}
|
|
3201
|
+
|
|
3202
|
+
function mustBeAnArray(value) {
|
|
3203
|
+
return "".concat(value, " must be an array");
|
|
3204
|
+
}
|
|
3205
|
+
|
|
2944
3206
|
function decorateResult(_a) {
|
|
2945
3207
|
var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
|
|
2946
3208
|
if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
|
|
@@ -3522,6 +3784,7 @@ var SexEnum;
|
|
|
3522
3784
|
|
|
3523
3785
|
function validateTieFormat(params) {
|
|
3524
3786
|
var _a, _b, _c, _d;
|
|
3787
|
+
var checkCategory = !!((params === null || params === void 0 ? void 0 : params.enforceCategory) !== false && (params === null || params === void 0 ? void 0 : params.category));
|
|
3525
3788
|
var checkGender = !!((params === null || params === void 0 ? void 0 : params.enforceGender) !== false && (params === null || params === void 0 ? void 0 : params.gender));
|
|
3526
3789
|
var checkCollectionIds = params === null || params === void 0 ? void 0 : params.checkCollectionIds;
|
|
3527
3790
|
var tieFormat = params === null || params === void 0 ? void 0 : params.tieFormat;
|
|
@@ -3557,9 +3820,11 @@ function validateTieFormat(params) {
|
|
|
3557
3820
|
if ((setValue || scoreValue) && !collectionValue)
|
|
3558
3821
|
aggregateValueImperative = true;
|
|
3559
3822
|
var _a = validateCollectionDefinition({
|
|
3823
|
+
referenceCategory: params.category,
|
|
3560
3824
|
referenceGender: params.gender,
|
|
3561
3825
|
collectionDefinition: collectionDefinition,
|
|
3562
3826
|
checkCollectionIds: checkCollectionIds,
|
|
3827
|
+
checkCategory: checkCategory,
|
|
3563
3828
|
checkGender: checkGender,
|
|
3564
3829
|
}), valid = _a.valid, collectionDefinitionErrors = _a.errors;
|
|
3565
3830
|
if (valid) {
|
|
@@ -3605,14 +3870,15 @@ function validateTieFormat(params) {
|
|
|
3605
3870
|
return result;
|
|
3606
3871
|
}
|
|
3607
3872
|
function validateCollectionDefinition(_a) {
|
|
3608
|
-
var collectionDefinition = _a.collectionDefinition, checkCollectionIds = _a.checkCollectionIds,
|
|
3873
|
+
var _b = _a.checkCategory, checkCategory = _b === void 0 ? true : _b, collectionDefinition = _a.collectionDefinition, checkCollectionIds = _a.checkCollectionIds, _c = _a.checkGender, checkGender = _c === void 0 ? true : _c, referenceCategory = _a.referenceCategory, referenceGender = _a.referenceGender, event = _a.event;
|
|
3609
3874
|
referenceGender = referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender;
|
|
3875
|
+
var stack = 'validateCollectionDefinition';
|
|
3610
3876
|
var errors = [];
|
|
3611
3877
|
if (typeof collectionDefinition !== 'object') {
|
|
3612
3878
|
errors.push("collectionDefinition must be an object: ".concat(collectionDefinition));
|
|
3613
|
-
return { errors: errors, error: INVALID_OBJECT };
|
|
3879
|
+
return decorateResult({ result: { errors: errors, error: INVALID_OBJECT }, stack: stack });
|
|
3614
3880
|
}
|
|
3615
|
-
var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, collectionId = collectionDefinition.collectionId, matchUpCount = collectionDefinition.matchUpCount, matchUpFormat = collectionDefinition.matchUpFormat, matchUpValue = collectionDefinition.matchUpValue, matchUpType = collectionDefinition.matchUpType, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue, gender = collectionDefinition.gender;
|
|
3881
|
+
var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, collectionId = collectionDefinition.collectionId, matchUpCount = collectionDefinition.matchUpCount, matchUpFormat = collectionDefinition.matchUpFormat, matchUpValue = collectionDefinition.matchUpValue, matchUpType = collectionDefinition.matchUpType, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue, category = collectionDefinition.category, gender = collectionDefinition.gender;
|
|
3616
3882
|
if (checkCollectionIds && typeof collectionId !== 'string') {
|
|
3617
3883
|
errors.push("collectionId is not type string: ".concat(collectionId));
|
|
3618
3884
|
}
|
|
@@ -3657,8 +3923,23 @@ function validateCollectionDefinition(_a) {
|
|
|
3657
3923
|
referenceGender !== gender) {
|
|
3658
3924
|
errors.push("Invalid gender: ".concat(gender));
|
|
3659
3925
|
}
|
|
3926
|
+
if (checkCategory && referenceCategory && category) {
|
|
3927
|
+
var result = categoryCanContain({
|
|
3928
|
+
category: referenceCategory,
|
|
3929
|
+
childCategory: category,
|
|
3930
|
+
});
|
|
3931
|
+
if (!result.valid)
|
|
3932
|
+
return decorateResult({
|
|
3933
|
+
result: { error: INVALID_CATEGORY },
|
|
3934
|
+
context: result,
|
|
3935
|
+
stack: stack,
|
|
3936
|
+
});
|
|
3937
|
+
}
|
|
3660
3938
|
if (errors.length)
|
|
3661
|
-
return {
|
|
3939
|
+
return decorateResult({
|
|
3940
|
+
result: { errors: errors, error: INVALID_COLLECTION_DEFINITION },
|
|
3941
|
+
stack: stack,
|
|
3942
|
+
});
|
|
3662
3943
|
return { valid: true };
|
|
3663
3944
|
}
|
|
3664
3945
|
// add collectionIds if missing
|
|
@@ -8647,6 +8928,7 @@ function structureAssignedDrawPositions(_a) {
|
|
|
8647
8928
|
}
|
|
8648
8929
|
|
|
8649
8930
|
function getOrderedDrawPositions(_a) {
|
|
8931
|
+
var _b;
|
|
8650
8932
|
var drawPositions = _a.drawPositions, roundProfile = _a.roundProfile, roundNumber = _a.roundNumber;
|
|
8651
8933
|
var unassignedDrawPositions = [undefined, undefined];
|
|
8652
8934
|
if (noNumeric(drawPositions)) {
|
|
@@ -8657,9 +8939,9 @@ function getOrderedDrawPositions(_a) {
|
|
|
8657
8939
|
}
|
|
8658
8940
|
var targetRoundProfile = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber];
|
|
8659
8941
|
var pairedDrawPositions = targetRoundProfile === null || targetRoundProfile === void 0 ? void 0 : targetRoundProfile.pairedDrawPositions;
|
|
8660
|
-
var displayOrder = (pairedDrawPositions === null || pairedDrawPositions === void 0 ? void 0 : pairedDrawPositions.find(function (pair) {
|
|
8942
|
+
var displayOrder = (_b = pairedDrawPositions === null || pairedDrawPositions === void 0 ? void 0 : pairedDrawPositions.find(function (pair) {
|
|
8661
8943
|
return overlap(pair || [], drawPositions.filter(Boolean));
|
|
8662
|
-
}))
|
|
8944
|
+
})) !== null && _b !== void 0 ? _b : unassignedDrawPositions;
|
|
8663
8945
|
// ############# IMPORTANT DO NOT CHANGE #################
|
|
8664
8946
|
// when both present, drawPositions are always sorted numerically
|
|
8665
8947
|
// this holds true even when fed positions encounter each other in later rounds
|
|
@@ -8669,7 +8951,7 @@ function getOrderedDrawPositions(_a) {
|
|
|
8669
8951
|
// previous round lookback is provided by the roundProfile
|
|
8670
8952
|
var isFeedRound = targetRoundProfile === null || targetRoundProfile === void 0 ? void 0 : targetRoundProfile.feedRound;
|
|
8671
8953
|
if (allNumeric$1(drawPositions)) {
|
|
8672
|
-
var orderedDrawPositions = drawPositions.sort(numericSort);
|
|
8954
|
+
var orderedDrawPositions = __spreadArray([], __read(drawPositions), false).sort(numericSort);
|
|
8673
8955
|
return {
|
|
8674
8956
|
orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
|
|
8675
8957
|
displayOrder: isFeedRound ? orderedDrawPositions : displayOrder,
|
|
@@ -9450,9 +9732,9 @@ function getAllStructureMatchUps(_a) {
|
|
|
9450
9732
|
}
|
|
9451
9733
|
return { matchUps: matchUps, roundMatchUps: roundMatchUps, roundProfile: roundProfile, collectionPositionMatchUps: collectionPositionMatchUps };
|
|
9452
9734
|
function addMatchUpContext(_a) {
|
|
9453
|
-
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
|
|
9735
|
+
var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
9454
9736
|
var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, sourceDrawPositionRanges = _a.sourceDrawPositionRanges, drawPositionsRanges = _a.drawPositionsRanges, initialRoundOfPlay = _a.initialRoundOfPlay, additionalContext = _a.additionalContext, roundNamingProfile = _a.roundNamingProfile, tieDrawPositions = _a.tieDrawPositions, appliedPolicies = _a.appliedPolicies, isCollectionBye = _a.isCollectionBye, matchUpTieId = _a.matchUpTieId, isRoundRobin = _a.isRoundRobin, roundProfile = _a.roundProfile, sideLineUps = _a.sideLineUps, matchUp = _a.matchUp, event = _a.event;
|
|
9455
|
-
additionalContext = additionalContext
|
|
9737
|
+
additionalContext = additionalContext !== null && additionalContext !== void 0 ? additionalContext : {};
|
|
9456
9738
|
var tieFormat = (_b = resolveTieFormat({
|
|
9457
9739
|
drawDefinition: drawDefinition,
|
|
9458
9740
|
structure: structure,
|
|
@@ -9464,17 +9746,14 @@ function getAllStructureMatchUps(_a) {
|
|
|
9464
9746
|
(collectionDefinitions === null || collectionDefinitions === void 0 ? void 0 : collectionDefinitions.find(function (definition) { return definition.collectionId === matchUp.collectionId; }));
|
|
9465
9747
|
var matchUpFormat = matchUp.collectionId
|
|
9466
9748
|
? collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpFormat
|
|
9467
|
-
: matchUp.matchUpFormat ||
|
|
9468
|
-
(structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) ||
|
|
9469
|
-
(drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) ||
|
|
9470
|
-
(event === null || event === void 0 ? void 0 : event.matchUpFormat);
|
|
9749
|
+
: (_e = (_d = (_c = matchUp.matchUpFormat) !== null && _c !== void 0 ? _c : structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) !== null && _d !== void 0 ? _d : drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) !== null && _e !== void 0 ? _e : event === null || event === void 0 ? void 0 : event.matchUpFormat;
|
|
9471
9750
|
var matchUpType = matchUp.matchUpType ||
|
|
9472
9751
|
(collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) ||
|
|
9473
9752
|
(structure === null || structure === void 0 ? void 0 : structure.matchUpType) ||
|
|
9474
9753
|
(drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType) ||
|
|
9475
9754
|
((event === null || event === void 0 ? void 0 : event.eventType) !== TEAM$1 && (event === null || event === void 0 ? void 0 : event.eventType));
|
|
9476
9755
|
var matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
|
|
9477
|
-
var
|
|
9756
|
+
var _z = getMatchUpScheduleDetails({
|
|
9478
9757
|
scheduleVisibilityFilters: scheduleVisibilityFilters,
|
|
9479
9758
|
afterRecoveryTimes: afterRecoveryTimes,
|
|
9480
9759
|
tournamentRecord: tournamentRecord,
|
|
@@ -9483,10 +9762,10 @@ function getAllStructureMatchUps(_a) {
|
|
|
9483
9762
|
matchUpType: matchUpType,
|
|
9484
9763
|
matchUp: matchUp,
|
|
9485
9764
|
event: event,
|
|
9486
|
-
}), schedule =
|
|
9487
|
-
var drawPositions = (
|
|
9765
|
+
}), schedule = _z.schedule, endDate = _z.endDate;
|
|
9766
|
+
var drawPositions = (_f = tieDrawPositions !== null && tieDrawPositions !== void 0 ? tieDrawPositions : matchUp.drawPositions) !== null && _f !== void 0 ? _f : [];
|
|
9488
9767
|
var collectionPosition = matchUp.collectionPosition, collectionId = matchUp.collectionId, roundPosition = matchUp.roundPosition;
|
|
9489
|
-
var roundNumber = matchUp.roundNumber
|
|
9768
|
+
var roundNumber = (_g = matchUp.roundNumber) !== null && _g !== void 0 ? _g : additionalContext.roundNumber;
|
|
9490
9769
|
var drawPositionCollectionAssignment = collectionId
|
|
9491
9770
|
? getDrawPositionCollectionAssignment({
|
|
9492
9771
|
tournamentParticipants: tournamentParticipants,
|
|
@@ -9500,13 +9779,13 @@ function getAllStructureMatchUps(_a) {
|
|
|
9500
9779
|
matchUpType: matchUpType,
|
|
9501
9780
|
})
|
|
9502
9781
|
: undefined;
|
|
9503
|
-
var roundName = ((
|
|
9782
|
+
var roundName = ((_h = roundNamingProfile === null || roundNamingProfile === void 0 ? void 0 : roundNamingProfile[roundNumber]) === null || _h === void 0 ? void 0 : _h.roundName) ||
|
|
9504
9783
|
additionalContext.roundName;
|
|
9505
|
-
var abbreviatedRoundName = ((
|
|
9784
|
+
var abbreviatedRoundName = ((_j = roundNamingProfile === null || roundNamingProfile === void 0 ? void 0 : roundNamingProfile[roundNumber]) === null || _j === void 0 ? void 0 : _j.abbreviatedRoundName) ||
|
|
9506
9785
|
additionalContext.abbreviatedRoundName;
|
|
9507
|
-
var feedRound = (
|
|
9508
|
-
var preFeedRound = (
|
|
9509
|
-
var roundFactor = (
|
|
9786
|
+
var feedRound = (_k = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _k === void 0 ? void 0 : _k.feedRound;
|
|
9787
|
+
var preFeedRound = (_l = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _l === void 0 ? void 0 : _l.preFeedRound;
|
|
9788
|
+
var roundFactor = (_m = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _m === void 0 ? void 0 : _m.roundFactor;
|
|
9510
9789
|
var drawPositionsRoundRanges = drawPositionsRanges === null || drawPositionsRanges === void 0 ? void 0 : drawPositionsRanges[roundNumber];
|
|
9511
9790
|
var drawPositionsRange = roundPosition
|
|
9512
9791
|
? drawPositionsRoundRanges === null || drawPositionsRoundRanges === void 0 ? void 0 : drawPositionsRoundRanges[roundPosition]
|
|
@@ -9515,18 +9794,17 @@ function getAllStructureMatchUps(_a) {
|
|
|
9515
9794
|
// if part of a tie matchUp and collectionDefinition has a category definition, prioritize
|
|
9516
9795
|
var matchUpCategory = (collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.category)
|
|
9517
9796
|
? __assign(__assign({}, ((context === null || context === void 0 ? void 0 : context.category) || {})), collectionDefinition.category) : context === null || context === void 0 ? void 0 : context.category;
|
|
9518
|
-
var processCodes = (((
|
|
9519
|
-
(((
|
|
9797
|
+
var processCodes = (((_o = matchUp.processCodes) === null || _o === void 0 ? void 0 : _o.length) && matchUp.processCodes) ||
|
|
9798
|
+
(((_p = collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.processCodes) === null || _p === void 0 ? void 0 : _p.length) &&
|
|
9520
9799
|
(collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.processCodes)) ||
|
|
9521
|
-
(((
|
|
9522
|
-
(((
|
|
9523
|
-
(((
|
|
9800
|
+
(((_q = structure === null || structure === void 0 ? void 0 : structure.processCodes) === null || _q === void 0 ? void 0 : _q.length) && (structure === null || structure === void 0 ? void 0 : structure.processCodes)) ||
|
|
9801
|
+
(((_r = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.processCodes) === null || _r === void 0 ? void 0 : _r.length) && (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.processCodes)) ||
|
|
9802
|
+
(((_s = event === null || event === void 0 ? void 0 : event.processCodes) === null || _s === void 0 ? void 0 : _s.length) && (event === null || event === void 0 ? void 0 : event.processCodes)) ||
|
|
9524
9803
|
(tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.processCodes);
|
|
9525
9804
|
var competitiveProfile = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.withCompetitiveness) &&
|
|
9526
9805
|
getMatchUpCompetitiveProfile(__assign(__assign({}, contextContent), { matchUp: matchUp }));
|
|
9527
9806
|
// necessry for SINGLES/DOUBLES matchUps that are part of TEAM tournaments
|
|
9528
|
-
var finishingPositionRange = matchUp.finishingPositionRange
|
|
9529
|
-
additionalContext.finishingPositionRange;
|
|
9807
|
+
var finishingPositionRange = (_t = matchUp.finishingPositionRange) !== null && _t !== void 0 ? _t : additionalContext.finishingPositionRange;
|
|
9530
9808
|
// order is important here as Round Robin matchUps already have inContext structureId
|
|
9531
9809
|
var onlyDefined = function (obj) { return definedAttributes(obj, undefined, true); };
|
|
9532
9810
|
var matchUpWithContext = __assign(__assign(__assign({}, onlyDefined(context)), onlyDefined({
|
|
@@ -9535,7 +9813,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9535
9813
|
roundOfPlay: stage !== QUALIFYING &&
|
|
9536
9814
|
isConvertableInteger(initialRoundOfPlay) &&
|
|
9537
9815
|
initialRoundOfPlay + (roundNumber || 0),
|
|
9538
|
-
endDate: matchUp.endDate
|
|
9816
|
+
endDate: (_u = matchUp.endDate) !== null && _u !== void 0 ? _u : endDate,
|
|
9539
9817
|
gender: collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.gender,
|
|
9540
9818
|
discipline: event === null || event === void 0 ? void 0 : event.discipline,
|
|
9541
9819
|
category: matchUpCategory,
|
|
@@ -9564,9 +9842,9 @@ function getAllStructureMatchUps(_a) {
|
|
|
9564
9842
|
drawId: drawId,
|
|
9565
9843
|
stage: stage,
|
|
9566
9844
|
})), makeDeepCopy(onlyDefined(matchUp), true, true));
|
|
9567
|
-
if (matchUpFormat && ((
|
|
9845
|
+
if (matchUpFormat && ((_v = matchUp.score) === null || _v === void 0 ? void 0 : _v.scoreStringSide1)) {
|
|
9568
9846
|
var parsedFormat = parse(matchUpFormat);
|
|
9569
|
-
var
|
|
9847
|
+
var _0 = parsedFormat !== null && parsedFormat !== void 0 ? parsedFormat : {}, bestOf_1 = _0.bestOf, finalSetFormat_1 = _0.finalSetFormat, setFormat_1 = _0.setFormat;
|
|
9570
9848
|
if ((finalSetFormat_1 === null || finalSetFormat_1 === void 0 ? void 0 : finalSetFormat_1.tiebreakSet) ||
|
|
9571
9849
|
(setFormat_1 === null || setFormat_1 === void 0 ? void 0 : setFormat_1.tiebreakSet) ||
|
|
9572
9850
|
(setFormat_1 === null || setFormat_1 === void 0 ? void 0 : setFormat_1.timed)) {
|
|
@@ -9586,12 +9864,12 @@ function getAllStructureMatchUps(_a) {
|
|
|
9586
9864
|
}
|
|
9587
9865
|
}
|
|
9588
9866
|
if (Array.isArray(drawPositions)) {
|
|
9589
|
-
var
|
|
9867
|
+
var _1 = getOrderedDrawPositions({
|
|
9590
9868
|
drawPositions: drawPositions,
|
|
9591
9869
|
roundProfile: roundProfile,
|
|
9592
9870
|
roundNumber: roundNumber,
|
|
9593
|
-
}), orderedDrawPositions =
|
|
9594
|
-
var isFeedRound_1 = (
|
|
9871
|
+
}), orderedDrawPositions = _1.orderedDrawPositions, displayOrder = _1.displayOrder;
|
|
9872
|
+
var isFeedRound_1 = (_w = roundProfile === null || roundProfile === void 0 ? void 0 : roundProfile[roundNumber]) === null || _w === void 0 ? void 0 : _w.feedRound;
|
|
9595
9873
|
var reversedDisplayOrder_1 = displayOrder[0] !== orderedDrawPositions[0];
|
|
9596
9874
|
// ensure there are two sides generated
|
|
9597
9875
|
var sideDrawPositions = orderedDrawPositions
|
|
@@ -9684,7 +9962,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9684
9962
|
}
|
|
9685
9963
|
var inferGender = (contextProfile === null || contextProfile === void 0 ? void 0 : contextProfile.inferGender) &&
|
|
9686
9964
|
(!matchUpWithContext.gender || matchUpWithContext.gender === MIXED) &&
|
|
9687
|
-
((
|
|
9965
|
+
((_x = matchUpWithContext.sides) === null || _x === void 0 ? void 0 : _x.length) === 2 &&
|
|
9688
9966
|
matchUpWithContext.matchUpType !== TEAM$1;
|
|
9689
9967
|
if (inferGender) {
|
|
9690
9968
|
var sideGenders = matchUpWithContext.sides.map(function (side) {
|
|
@@ -9706,7 +9984,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9706
9984
|
}
|
|
9707
9985
|
if (matchUpWithContext.tieMatchUps) {
|
|
9708
9986
|
var isCollectionBye_1 = matchUpWithContext.matchUpStatus === BYE;
|
|
9709
|
-
var lineUps_1 = (
|
|
9987
|
+
var lineUps_1 = (_y = matchUpWithContext.sides) === null || _y === void 0 ? void 0 : _y.map(function (_a) {
|
|
9710
9988
|
var participant = _a.participant, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber, lineUp = _a.lineUp;
|
|
9711
9989
|
var teamParticipant = (participant === null || participant === void 0 ? void 0 : participant.participantType) === TEAM$1 && participant;
|
|
9712
9990
|
var teamParticipantValues = teamParticipant &&
|
|
@@ -9759,7 +10037,7 @@ function getAllStructureMatchUps(_a) {
|
|
|
9759
10037
|
var readyToScore = scoringActive && hasParticipants && hasNoWinner;
|
|
9760
10038
|
Object.assign(matchUpWithContext, { readyToScore: readyToScore, hasContext: true });
|
|
9761
10039
|
if (hasParticipants) {
|
|
9762
|
-
var
|
|
10040
|
+
var _2 = getCheckedInParticipantIds({ matchUp: matchUpWithContext }), allParticipantsCheckedIn = _2.allParticipantsCheckedIn, checkedInParticipantIds = _2.checkedInParticipantIds;
|
|
9763
10041
|
Object.assign(matchUpWithContext, {
|
|
9764
10042
|
allParticipantsCheckedIn: allParticipantsCheckedIn,
|
|
9765
10043
|
checkedInParticipantIds: checkedInParticipantIds,
|
|
@@ -10782,17 +11060,18 @@ function addUpcomingMatchUps(_a) {
|
|
|
10782
11060
|
var drawDefinition = _a.drawDefinition, inContextDrawMatchUps = _a.inContextDrawMatchUps;
|
|
10783
11061
|
var scheduleConflictMatchUpIds = {};
|
|
10784
11062
|
inContextDrawMatchUps.forEach(function (inContextMatchUp) {
|
|
10785
|
-
var _a, _b, _c, _d, _e;
|
|
10786
|
-
var matchUpId = inContextMatchUp.matchUpId, structureId = inContextMatchUp.structureId,
|
|
11063
|
+
var _a, _b, _c, _d, _e, _f;
|
|
11064
|
+
var matchUpId = inContextMatchUp.matchUpId, structureId = inContextMatchUp.structureId, _g = inContextMatchUp.drawPositions, drawPositions = _g === void 0 ? [] : _g;
|
|
10787
11065
|
var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
|
|
10788
11066
|
if ((structure === null || structure === void 0 ? void 0 : structure.finishingPosition) === WIN_RATIO) {
|
|
10789
11067
|
var roundNumber = inContextMatchUp.roundNumber;
|
|
10790
11068
|
var nextRoundNumber_1 = roundNumber && ensureInt(roundNumber) + 1;
|
|
10791
|
-
var matchUps = structure.matchUps
|
|
11069
|
+
var matchUps = (_a = structure.matchUps) !== null && _a !== void 0 ? _a : [];
|
|
10792
11070
|
var roundMatchUps_1 = getRoundMatchUps$1({ matchUps: matchUps }).roundMatchUps;
|
|
10793
11071
|
// if this is a round robin then we have sidesTo information, not winnerTo and loserTo
|
|
10794
11072
|
if (nextRoundNumber_1 && (roundMatchUps_1 === null || roundMatchUps_1 === void 0 ? void 0 : roundMatchUps_1[nextRoundNumber_1])) {
|
|
10795
|
-
var sidesTo =
|
|
11073
|
+
var sidesTo = __spreadArray([], __read(drawPositions), false).sort(numericSort)
|
|
11074
|
+
.map(function (drawPosition, index) {
|
|
10796
11075
|
var nextRoundMatchUp = roundMatchUps_1[nextRoundNumber_1].find(function (matchUp) { var _a; return (_a = matchUp.drawPositions) === null || _a === void 0 ? void 0 : _a.includes(drawPosition); });
|
|
10797
11076
|
return {
|
|
10798
11077
|
matchUpId: nextRoundMatchUp === null || nextRoundMatchUp === void 0 ? void 0 : nextRoundMatchUp.matchUpId,
|
|
@@ -10835,9 +11114,9 @@ function addUpcomingMatchUps(_a) {
|
|
|
10835
11114
|
loserTo;
|
|
10836
11115
|
}
|
|
10837
11116
|
// scheduleConflict in the following only applies to conflicts between subsequent matchUps WITHIN the same draw
|
|
10838
|
-
var timeAfterRecovery = (
|
|
11117
|
+
var timeAfterRecovery = (_b = inContextMatchUp.schedule) === null || _b === void 0 ? void 0 : _b.timeAfterRecovery;
|
|
10839
11118
|
if (timeAfterRecovery) {
|
|
10840
|
-
if ((
|
|
11119
|
+
if ((_c = winnerTo === null || winnerTo === void 0 ? void 0 : winnerTo.schedule) === null || _c === void 0 ? void 0 : _c.scheduledTime) {
|
|
10841
11120
|
var scheduleConflict = timeStringMinutes(winnerTo.schedule.scheduledTime) <
|
|
10842
11121
|
timeStringMinutes(timeAfterRecovery);
|
|
10843
11122
|
if (scheduleConflict) {
|
|
@@ -10846,7 +11125,7 @@ function addUpcomingMatchUps(_a) {
|
|
|
10846
11125
|
winnerTo.schedule.scheduleConflict = inContextMatchUp.matchUpId;
|
|
10847
11126
|
}
|
|
10848
11127
|
}
|
|
10849
|
-
if ((
|
|
11128
|
+
if ((_d = loserTo === null || loserTo === void 0 ? void 0 : loserTo.schedule) === null || _d === void 0 ? void 0 : _d.scheduledTime) {
|
|
10850
11129
|
var scheduleConflict = timeStringMinutes(loserTo.schedule.scheduledTime) <
|
|
10851
11130
|
timeStringMinutes(timeAfterRecovery);
|
|
10852
11131
|
if (scheduleConflict) {
|
|
@@ -10857,8 +11136,8 @@ function addUpcomingMatchUps(_a) {
|
|
|
10857
11136
|
}
|
|
10858
11137
|
}
|
|
10859
11138
|
Object.assign(inContextMatchUp, { winnerTo: winnerTo, loserTo: loserTo });
|
|
10860
|
-
if ((
|
|
10861
|
-
var loserTargetLink = (
|
|
11139
|
+
if ((_e = inContextMatchUp.drawPositions) === null || _e === void 0 ? void 0 : _e.filter(Boolean).length) {
|
|
11140
|
+
var loserTargetLink = (_f = targetData.targetLinks) === null || _f === void 0 ? void 0 : _f.loserTargetLink;
|
|
10862
11141
|
var firstMatchUp = (loserTargetLink === null || loserTargetLink === void 0 ? void 0 : loserTargetLink.linkCondition) === FIRST_MATCHUP;
|
|
10863
11142
|
var participants = getMatchUpParticipants(inContextMatchUp);
|
|
10864
11143
|
if (participants.length) {
|
|
@@ -12503,7 +12782,7 @@ function getScoreAnalysis(_a) {
|
|
|
12503
12782
|
var setFormat = (isDecidingSet && (matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.finalSetFormat)) ||
|
|
12504
12783
|
(matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.setFormat) ||
|
|
12505
12784
|
{};
|
|
12506
|
-
var isTimedSet =
|
|
12785
|
+
var isTimedSet = setFormat === null || setFormat === void 0 ? void 0 : setFormat.timed;
|
|
12507
12786
|
var finalSet = isDecidingSet && sets[(matchUpScoringFormat === null || matchUpScoringFormat === void 0 ? void 0 : matchUpScoringFormat.bestOf) - 1];
|
|
12508
12787
|
var finalSetIsComplete = finalSet === null || finalSet === void 0 ? void 0 : finalSet.winningSide;
|
|
12509
12788
|
var isSetTiebreakEntry = testTiebreakEntry({
|
|
@@ -19123,117 +19402,6 @@ var garman = {
|
|
|
19123
19402
|
courtGenerator: courtGenerator,
|
|
19124
19403
|
};
|
|
19125
19404
|
|
|
19126
|
-
var typeMatch = function (arr, type) {
|
|
19127
|
-
return arr.filter(Boolean).every(function (i) { return typeof i === type; });
|
|
19128
|
-
};
|
|
19129
|
-
var allNumeric = function (arr) { return arr.filter(Boolean).every(isNumeric); };
|
|
19130
|
-
function parseAgeCategoryCode(_a) {
|
|
19131
|
-
var _b;
|
|
19132
|
-
var _c = _a === void 0 ? { consideredDate: '' } : _a, consideredDate = _c.consideredDate, category = _c.category;
|
|
19133
|
-
var invalid = { error: INVALID_VALUES, ageMin: 8, ageMax: 99 };
|
|
19134
|
-
if (typeof category !== 'object' || !isValidDateString(consideredDate))
|
|
19135
|
-
return invalid;
|
|
19136
|
-
var consideredYear = parseInt(consideredDate.split('-')[0]);
|
|
19137
|
-
// collect errors; e.g. provided ageMin does not equal calculated ageMin
|
|
19138
|
-
var errors = [];
|
|
19139
|
-
var ageCategoryCode = category.ageCategoryCode, ageMaxDate = category.ageMaxDate, ageMinDate = category.ageMinDate, ageMax = category.ageMax, ageMin = category.ageMin;
|
|
19140
|
-
var categoryName = category.categoryName;
|
|
19141
|
-
var combinedAge;
|
|
19142
|
-
if (!typeMatch([ageCategoryCode, ageMaxDate, ageMinDate, categoryName], 'string') ||
|
|
19143
|
-
!allNumeric([ageMax, ageMin]))
|
|
19144
|
-
return invalid;
|
|
19145
|
-
ageCategoryCode = ageCategoryCode !== null && ageCategoryCode !== void 0 ? ageCategoryCode : categoryName;
|
|
19146
|
-
var prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
|
|
19147
|
-
var extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
|
|
19148
|
-
var isBetween = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.includes('-');
|
|
19149
|
-
var isCombined = isBetween && (ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined));
|
|
19150
|
-
var isCoded = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(prePost);
|
|
19151
|
-
// construct min or max date with or without year
|
|
19152
|
-
var isYYMM = function (datePart) { return datePart.match(/^\d{2}-\d{2}$/); };
|
|
19153
|
-
var constructedDate = function (y, d, df) {
|
|
19154
|
-
return (isValidDateString(d) && d) ||
|
|
19155
|
-
(d && isYYMM(d) && "".concat(y, "-").concat(d)) ||
|
|
19156
|
-
"".concat(y, "-").concat(df);
|
|
19157
|
-
};
|
|
19158
|
-
var uPre = function (ageInt) {
|
|
19159
|
-
var ageMinYear = consideredYear - ageInt;
|
|
19160
|
-
ageMinDate = constructedDate(ageMinYear, ageMinDate, '01-01');
|
|
19161
|
-
if (ageMax && ageMax !== ageInt - 1)
|
|
19162
|
-
errors.push("Invalid ageMax: ".concat(ageMax));
|
|
19163
|
-
if (!ageMax)
|
|
19164
|
-
ageMax = ageInt - 1;
|
|
19165
|
-
return { ageMinDate: ageMinDate, ageMax: ageMax };
|
|
19166
|
-
};
|
|
19167
|
-
var uPost = function (ageInt) {
|
|
19168
|
-
var ageMinYear = consideredYear - ageInt - 1;
|
|
19169
|
-
ageMinDate = constructedDate(ageMinYear, ageMinDate, '01-01');
|
|
19170
|
-
if (ageMax && ageMax !== ageInt)
|
|
19171
|
-
errors.push("Invalid ageMax: ".concat(ageMax));
|
|
19172
|
-
if (!ageMax)
|
|
19173
|
-
ageMax = ageInt;
|
|
19174
|
-
return { ageMinDate: ageMinDate, ageMax: ageMax };
|
|
19175
|
-
};
|
|
19176
|
-
var oPre = function (ageInt) {
|
|
19177
|
-
var ageMaxYear = consideredYear - ageInt - 2;
|
|
19178
|
-
ageMaxDate = constructedDate(ageMaxYear, ageMaxDate, '12-31');
|
|
19179
|
-
if (ageMin && ageMin !== ageInt + 1)
|
|
19180
|
-
errors.push("Invalid ageMin: ".concat(ageMin));
|
|
19181
|
-
if (!ageMin)
|
|
19182
|
-
ageMin = ageInt + 1;
|
|
19183
|
-
return { ageMaxDate: ageMaxDate, ageMin: ageMin };
|
|
19184
|
-
};
|
|
19185
|
-
var oPost = function (ageInt) {
|
|
19186
|
-
var ageMaxYear = consideredYear - ageInt - 1;
|
|
19187
|
-
ageMaxDate = constructedDate(ageMaxYear, ageMaxDate, '12-31');
|
|
19188
|
-
if (ageMin && ageMin !== ageInt)
|
|
19189
|
-
errors.push("Invalid ageMin: ".concat(ageMin));
|
|
19190
|
-
if (!ageMin)
|
|
19191
|
-
ageMin = ageInt;
|
|
19192
|
-
return { ageMaxDate: ageMaxDate, ageMin: ageMin };
|
|
19193
|
-
};
|
|
19194
|
-
var processCode = function (code) {
|
|
19195
|
-
var _a, _b, _c, _d;
|
|
19196
|
-
var _e = __read((code.match(prePost) || []).slice(1), 3), pre = _e[0], age = _e[1], post = _e[2];
|
|
19197
|
-
var ageInt = parseInt(age);
|
|
19198
|
-
if (pre === 'U')
|
|
19199
|
-
(_a = uPre(ageInt), ageMinDate = _a.ageMinDate, ageMax = _a.ageMax);
|
|
19200
|
-
if (post === 'U')
|
|
19201
|
-
(_b = uPost(ageInt), ageMinDate = _b.ageMinDate, ageMax = _b.ageMax);
|
|
19202
|
-
if (pre === 'O')
|
|
19203
|
-
(_c = oPre(ageInt), ageMaxDate = _c.ageMaxDate, ageMin = _c.ageMin);
|
|
19204
|
-
if (post === 'O')
|
|
19205
|
-
(_d = oPost(ageInt), ageMaxDate = _d.ageMaxDate, ageMin = _d.ageMin);
|
|
19206
|
-
};
|
|
19207
|
-
if (isCombined) {
|
|
19208
|
-
var _d = __read(((_b = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined)) !== null && _b !== void 0 ? _b : [])
|
|
19209
|
-
.slice(1)
|
|
19210
|
-
.map(function (n) { return parseInt(n); }), 2), lowAge = _d[0], highAge = _d[1];
|
|
19211
|
-
if (lowAge <= highAge) {
|
|
19212
|
-
ageMin = ageMin !== null && ageMin !== void 0 ? ageMin : lowAge;
|
|
19213
|
-
ageMax = ageMax !== null && ageMax !== void 0 ? ageMax : highAge;
|
|
19214
|
-
combinedAge = true;
|
|
19215
|
-
}
|
|
19216
|
-
else {
|
|
19217
|
-
errors.push("Invalid combined age range ".concat(ageCategoryCode));
|
|
19218
|
-
}
|
|
19219
|
-
}
|
|
19220
|
-
else if (isBetween) {
|
|
19221
|
-
ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.split('-').forEach(processCode);
|
|
19222
|
-
}
|
|
19223
|
-
else if (isCoded) {
|
|
19224
|
-
processCode(ageCategoryCode);
|
|
19225
|
-
}
|
|
19226
|
-
if (errors.length)
|
|
19227
|
-
return { error: errors, ageMin: 8, ageMax: 99 };
|
|
19228
|
-
return definedAttributes({
|
|
19229
|
-
combinedAge: combinedAge,
|
|
19230
|
-
ageMaxDate: ageMaxDate,
|
|
19231
|
-
ageMinDate: ageMinDate,
|
|
19232
|
-
ageMax: ageMax,
|
|
19233
|
-
ageMin: ageMin,
|
|
19234
|
-
});
|
|
19235
|
-
}
|
|
19236
|
-
|
|
19237
19405
|
// utility function just to allow testing with string score entry
|
|
19238
19406
|
function parseScoreString(_a) {
|
|
19239
19407
|
var _b = _a.tiebreakTo, tiebreakTo = _b === void 0 ? 7 : _b, scoreString = _a.scoreString;
|
|
@@ -19296,7 +19464,7 @@ function getRoundRobinGroupMatchUps(_a) {
|
|
|
19296
19464
|
return { groupMatchUps: groupMatchUps, uniqueMatchUpGroupings: uniqueMatchUpGroupings };
|
|
19297
19465
|
}
|
|
19298
19466
|
function drawPositionsHash(drawPositions) {
|
|
19299
|
-
return drawPositions.sort(numericSort).join('|');
|
|
19467
|
+
return __spreadArray([], __read(drawPositions), false).sort(numericSort).join('|');
|
|
19300
19468
|
}
|
|
19301
19469
|
function groupRounds(_a) {
|
|
19302
19470
|
var groupSize = _a.groupSize, drawPositionOffset = _a.drawPositionOffset;
|
|
@@ -19321,8 +19489,7 @@ function groupRounds(_a) {
|
|
|
19321
19489
|
aRow = __spreadArray([aHead, bUp], __read(aRow), false).filter(Boolean);
|
|
19322
19490
|
bRow = __spreadArray(__spreadArray([], __read(bRow), false), [aDown], false).filter(Boolean);
|
|
19323
19491
|
var sum = function (x) { return x[0].reduce(function (a, b) { return a + b; }); };
|
|
19324
|
-
return rounds
|
|
19325
|
-
.reverse()
|
|
19492
|
+
return __spreadArray([], __read(rounds), false).reverse()
|
|
19326
19493
|
.sort(function (a, b) { return sum(a) - sum(b); })
|
|
19327
19494
|
.map(function (round) {
|
|
19328
19495
|
return round
|
|
@@ -25199,16 +25366,19 @@ var structureTemplate = function (_a) {
|
|
|
25199
25366
|
return structure;
|
|
25200
25367
|
};
|
|
25201
25368
|
|
|
25202
|
-
function generateRoundRobin(
|
|
25203
|
-
var
|
|
25204
|
-
var _f =
|
|
25369
|
+
function generateRoundRobin(params) {
|
|
25370
|
+
var _a, _b, _c;
|
|
25371
|
+
var _d = params.groupNameBase, groupNameBase = _d === void 0 ? 'Group' : _d, playoffAttributes = params.playoffAttributes, _e = params.stageSequence, stageSequence = _e === void 0 ? 1 : _e, structureOptions = params.structureOptions, appliedPolicies = params.appliedPolicies, seedingProfile = params.seedingProfile, _f = params.stage, stage = _f === void 0 ? MAIN : _f, matchUpType = params.matchUpType, roundTarget = params.roundTarget, structureId = params.structureId, groupNames = params.groupNames, drawSize = params.drawSize, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
|
|
25372
|
+
var structureName = (_c = (_a = params.structureName) !== null && _a !== void 0 ? _a : (_b = playoffAttributes === null || playoffAttributes === void 0 ? void 0 : playoffAttributes['0']) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : constantToString(MAIN);
|
|
25373
|
+
var _g = deriveGroups({
|
|
25205
25374
|
structureOptions: structureOptions,
|
|
25206
25375
|
appliedPolicies: appliedPolicies,
|
|
25207
25376
|
drawSize: drawSize,
|
|
25208
|
-
}), groupCount =
|
|
25377
|
+
}), groupCount = _g.groupCount, groupSize = _g.groupSize;
|
|
25209
25378
|
var finishingPosition = WIN_RATIO;
|
|
25210
25379
|
var maxRoundNumber;
|
|
25211
25380
|
var structures = generateRange(1, groupCount + 1).map(function (structureOrder) {
|
|
25381
|
+
var _a;
|
|
25212
25382
|
var matchUps = roundRobinMatchUps({
|
|
25213
25383
|
groupSize: groupSize,
|
|
25214
25384
|
structureOrder: structureOrder,
|
|
@@ -25221,12 +25391,13 @@ function generateRoundRobin(_a) {
|
|
|
25221
25391
|
var roundNumber = _a.roundNumber;
|
|
25222
25392
|
return roundNumber;
|
|
25223
25393
|
})), false));
|
|
25394
|
+
var structureName = (_a = groupNames === null || groupNames === void 0 ? void 0 : groupNames[structureOrder - 1]) !== null && _a !== void 0 ? _a : "".concat(groupNameBase, " ").concat(structureOrder);
|
|
25224
25395
|
return structureTemplate({
|
|
25225
|
-
structureName: "".concat(groupNameBase, " ").concat(structureOrder),
|
|
25226
25396
|
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
25227
25397
|
structureType: ITEM,
|
|
25228
25398
|
finishingPosition: finishingPosition,
|
|
25229
25399
|
structureOrder: structureOrder,
|
|
25400
|
+
structureName: structureName,
|
|
25230
25401
|
matchUps: matchUps,
|
|
25231
25402
|
});
|
|
25232
25403
|
});
|
|
@@ -32864,24 +33035,32 @@ function removeCollectionDefinition(params) {
|
|
|
32864
33035
|
function addCollectionDefinition$1(_a) {
|
|
32865
33036
|
var e_1, _b, e_2, _c, _d, e_3, _e;
|
|
32866
33037
|
var _f, _g, _h, _j, _k, _l, _m, _o;
|
|
32867
|
-
var _p = _a.updateInProgressMatchUps, updateInProgressMatchUps = _p === void 0 ? true : _p, collectionDefinition = _a.collectionDefinition, tournamentRecord = _a.tournamentRecord, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
|
|
33038
|
+
var _p = _a.updateInProgressMatchUps, updateInProgressMatchUps = _p === void 0 ? true : _p, collectionDefinition = _a.collectionDefinition, referenceCategory = _a.referenceCategory, tournamentRecord = _a.tournamentRecord, enforceCategory = _a.enforceCategory, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
|
|
32868
33039
|
var stack = 'addCollectionDefinition';
|
|
32869
33040
|
var appliedPolicies = (_f = getAppliedPolicies({
|
|
32870
33041
|
tournamentRecord: tournamentRecord,
|
|
32871
33042
|
drawDefinition: drawDefinition,
|
|
32872
33043
|
event: event,
|
|
32873
33044
|
}).appliedPolicies) !== null && _f !== void 0 ? _f : {};
|
|
33045
|
+
var matchUpActionsPolicy = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS];
|
|
33046
|
+
enforceCategory =
|
|
33047
|
+
enforceCategory !== null && enforceCategory !== void 0 ? enforceCategory : (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _g === void 0 ? void 0 : _g.enforceCategory;
|
|
32874
33048
|
enforceGender =
|
|
32875
|
-
enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_h =
|
|
32876
|
-
var
|
|
32877
|
-
|
|
33049
|
+
enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceGender;
|
|
33050
|
+
var checkCategory = !!((referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category) &&
|
|
33051
|
+
enforceCategory !== false);
|
|
33052
|
+
var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) &&
|
|
33053
|
+
enforceGender !== false);
|
|
33054
|
+
var validationResult = validateCollectionDefinition({
|
|
33055
|
+
referenceCategory: referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category,
|
|
32878
33056
|
collectionDefinition: collectionDefinition,
|
|
32879
33057
|
referenceGender: referenceGender,
|
|
33058
|
+
checkCategory: checkCategory,
|
|
32880
33059
|
checkGender: checkGender,
|
|
32881
33060
|
event: event,
|
|
32882
|
-
})
|
|
32883
|
-
if (
|
|
32884
|
-
return decorateResult({ result:
|
|
33061
|
+
});
|
|
33062
|
+
if (validationResult.error) {
|
|
33063
|
+
return decorateResult({ result: validationResult, stack: stack });
|
|
32885
33064
|
}
|
|
32886
33065
|
var result = !(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat)
|
|
32887
33066
|
? getTieFormat$1({
|
|
@@ -32924,7 +33103,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
32924
33103
|
});
|
|
32925
33104
|
// calculate new winCriteria for tieFormat
|
|
32926
33105
|
// if existing winCriteria is aggregateValue, retain
|
|
32927
|
-
var
|
|
33106
|
+
var _q = calculateWinCriteria(tieFormat), aggregateValue = _q.aggregateValue, valueGoal = _q.valueGoal;
|
|
32928
33107
|
tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
|
|
32929
33108
|
// if valueGoal has changed, force renaming of the tieFormat
|
|
32930
33109
|
var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
|
|
@@ -32950,13 +33129,13 @@ function addCollectionDefinition$1(_a) {
|
|
|
32950
33129
|
event.tieFormat = prunedTieFormat;
|
|
32951
33130
|
try {
|
|
32952
33131
|
// all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
|
|
32953
|
-
for (var
|
|
32954
|
-
var drawDefinition_1 =
|
|
33132
|
+
for (var _r = __values((_k = event.drawDefinitions) !== null && _k !== void 0 ? _k : []), _s = _r.next(); !_s.done; _s = _r.next()) {
|
|
33133
|
+
var drawDefinition_1 = _s.value;
|
|
32955
33134
|
if (drawDefinition_1.tieFormat)
|
|
32956
33135
|
continue;
|
|
32957
33136
|
try {
|
|
32958
|
-
for (var
|
|
32959
|
-
var structure_1 =
|
|
33137
|
+
for (var _t = (e_2 = void 0, __values((_l = drawDefinition_1.structures) !== null && _l !== void 0 ? _l : [])), _u = _t.next(); !_u.done; _u = _t.next()) {
|
|
33138
|
+
var structure_1 = _u.value;
|
|
32960
33139
|
if (structure_1.tieFormat)
|
|
32961
33140
|
continue;
|
|
32962
33141
|
var result_1 = updateStructureMatchUps({
|
|
@@ -32973,7 +33152,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
32973
33152
|
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
32974
33153
|
finally {
|
|
32975
33154
|
try {
|
|
32976
|
-
if (
|
|
33155
|
+
if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
|
|
32977
33156
|
}
|
|
32978
33157
|
finally { if (e_2) throw e_2.error; }
|
|
32979
33158
|
}
|
|
@@ -32982,7 +33161,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
32982
33161
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
32983
33162
|
finally {
|
|
32984
33163
|
try {
|
|
32985
|
-
if (
|
|
33164
|
+
if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
|
|
32986
33165
|
}
|
|
32987
33166
|
finally { if (e_1) throw e_1.error; }
|
|
32988
33167
|
}
|
|
@@ -33045,8 +33224,8 @@ function addCollectionDefinition$1(_a) {
|
|
|
33045
33224
|
// all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
|
|
33046
33225
|
drawDefinition.tieFormat = prunedTieFormat;
|
|
33047
33226
|
try {
|
|
33048
|
-
for (var
|
|
33049
|
-
var structure_2 =
|
|
33227
|
+
for (var _v = __values((_m = drawDefinition.structures) !== null && _m !== void 0 ? _m : []), _w = _v.next(); !_w.done; _w = _v.next()) {
|
|
33228
|
+
var structure_2 = _w.value;
|
|
33050
33229
|
var result_3 = updateStructureMatchUps({
|
|
33051
33230
|
updateInProgressMatchUps: updateInProgressMatchUps,
|
|
33052
33231
|
collectionDefinition: collectionDefinition,
|
|
@@ -33061,7 +33240,7 @@ function addCollectionDefinition$1(_a) {
|
|
|
33061
33240
|
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
33062
33241
|
finally {
|
|
33063
33242
|
try {
|
|
33064
|
-
if (
|
|
33243
|
+
if (_w && !_w.done && (_e = _v.return)) _e.call(_v);
|
|
33065
33244
|
}
|
|
33066
33245
|
finally { if (e_3) throw e_3.error; }
|
|
33067
33246
|
}
|
|
@@ -38870,10 +39049,11 @@ function bulkRescheduleMatchUps$1(_a) {
|
|
|
38870
39049
|
doNotReschedule = newTime < 0 || newTime > dayTotalMinutes;
|
|
38871
39050
|
if (!doNotReschedule) {
|
|
38872
39051
|
var timeString = addMinutesToTimeString(scheduledTime, minutesChange);
|
|
38873
|
-
|
|
38874
|
-
scheduledTimeDate &&
|
|
38875
|
-
|
|
38876
|
-
|
|
39052
|
+
var timeStringDate = (scheduledTimeDate && newScheduledDate) ||
|
|
39053
|
+
(scheduledDate === scheduledTimeDate && scheduledTimeDate);
|
|
39054
|
+
newScheduledTime = timeStringDate
|
|
39055
|
+
? "".concat(timeStringDate, "T").concat(timeString)
|
|
39056
|
+
: timeString;
|
|
38877
39057
|
}
|
|
38878
39058
|
}
|
|
38879
39059
|
if (doNotReschedule) {
|
|
@@ -39966,6 +40146,7 @@ var POLICY_MATCHUP_ACTIONS_DEFAULT = (_a$2 = {},
|
|
|
39966
40146
|
},
|
|
39967
40147
|
],
|
|
39968
40148
|
participants: {
|
|
40149
|
+
enforceCategory: true,
|
|
39969
40150
|
enforceGender: true, // disallow placing FEMALEs in MALE events and vice versa
|
|
39970
40151
|
},
|
|
39971
40152
|
processCodes: {
|
|
@@ -43767,7 +43948,8 @@ function generatePlayoffStructures(params) {
|
|
|
43767
43948
|
var attributeProfile = playoffAttributes === null || playoffAttributes === void 0 ? void 0 : playoffAttributes[exitProfile];
|
|
43768
43949
|
var base = (playoffStructureNameBase && "".concat(playoffStructureNameBase, " ")) || '';
|
|
43769
43950
|
var customNaming = (_a = playoffAttributes === null || playoffAttributes === void 0 ? void 0 : playoffAttributes[finishingPositionRange]) !== null && _a !== void 0 ? _a : finishingPositionNaming === null || finishingPositionNaming === void 0 ? void 0 : finishingPositionNaming[finishingPositionRange];
|
|
43770
|
-
var structureName =
|
|
43951
|
+
var structureName = params.structureName ||
|
|
43952
|
+
(customNaming === null || customNaming === void 0 ? void 0 : customNaming.name) ||
|
|
43771
43953
|
((attributeProfile === null || attributeProfile === void 0 ? void 0 : attributeProfile.name) &&
|
|
43772
43954
|
(addNameBaseToAttributeName
|
|
43773
43955
|
? "".concat(base).concat(attributeProfile === null || attributeProfile === void 0 ? void 0 : attributeProfile.name)
|
|
@@ -43908,12 +44090,16 @@ function feedInChampionship(params) {
|
|
|
43908
44090
|
fmlc: fmlc,
|
|
43909
44091
|
}), consolationMatchUps = _f.matchUps, roundsCount = _f.roundsCount;
|
|
43910
44092
|
if (drawSize > 2) {
|
|
44093
|
+
var name_1 = (_c = (_b = playoffAttributes === null || playoffAttributes === void 0 ? void 0 : playoffAttributes['0-1']) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : constantToString(CONSOLATION);
|
|
44094
|
+
var structureName_1 = params.playoffStructureNameBase
|
|
44095
|
+
? "".concat(params.playoffStructureNameBase, " ").concat(name_1)
|
|
44096
|
+
: name_1;
|
|
43911
44097
|
var consolationStructure = structureTemplate({
|
|
43912
|
-
structureName: (_c = (_b = playoffAttributes === null || playoffAttributes === void 0 ? void 0 : playoffAttributes['0-1']) === null || _b === void 0 ? void 0 : _b.name) !== null && _c !== void 0 ? _c : constantToString(CONSOLATION),
|
|
43913
44098
|
matchUps: consolationMatchUps,
|
|
43914
44099
|
structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
43915
44100
|
stage: CONSOLATION,
|
|
43916
44101
|
stageSequence: 1,
|
|
44102
|
+
structureName: structureName_1,
|
|
43917
44103
|
matchUpType: matchUpType,
|
|
43918
44104
|
});
|
|
43919
44105
|
structures.push(consolationStructure);
|
|
@@ -44051,8 +44237,9 @@ function processPlayoffGroups(_a) {
|
|
|
44051
44237
|
else if ([COMPASS, OLYMPIC, PLAY_OFF].includes(playoffDrawType)) {
|
|
44052
44238
|
var params_1 = {
|
|
44053
44239
|
playoffAttributes: (_j = playoffGroup.playoffAttributes) !== null && _j !== void 0 ? _j : playoffAttributes,
|
|
44240
|
+
playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
|
|
44054
44241
|
structureId: (_k = playoffGroup.structureId) !== null && _k !== void 0 ? _k : uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
44055
|
-
|
|
44242
|
+
structureName: playoffGroup.structureName,
|
|
44056
44243
|
idPrefix: idPrefix && "".concat(idPrefix, "-po"),
|
|
44057
44244
|
addNameBaseToAttributeName: true,
|
|
44058
44245
|
finishingPositionOffset: finishingPositionOffset,
|
|
@@ -44108,7 +44295,9 @@ function processPlayoffGroups(_a) {
|
|
|
44108
44295
|
].includes(playoffDrawType)) {
|
|
44109
44296
|
var uuidsFMLC = [uuids === null || uuids === void 0 ? void 0 : uuids.pop(), uuids === null || uuids === void 0 ? void 0 : uuids.pop()];
|
|
44110
44297
|
var params_2 = {
|
|
44298
|
+
playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
|
|
44111
44299
|
structureId: (_s = playoffGroup.structureId) !== null && _s !== void 0 ? _s : uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
|
|
44300
|
+
playoffAttributes: playoffGroup.playoffAttributes,
|
|
44112
44301
|
idPrefix: idPrefix && "".concat(idPrefix, "-po"),
|
|
44113
44302
|
finishingPositionOffset: finishingPositionOffset,
|
|
44114
44303
|
uuids: uuidsFMLC,
|
|
@@ -44211,9 +44400,8 @@ function generateRoundRobinWithPlayOff(params) {
|
|
|
44211
44400
|
var drawDefinition = params.drawDefinition, structureOptions = params.structureOptions, requireSequential = params.requireSequential;
|
|
44212
44401
|
var mainDrawProperties = __assign(__assign({ structureName: constantToString(MAIN) }, params), { stage: MAIN }); // default structureName
|
|
44213
44402
|
var _a = generateRoundRobin(mainDrawProperties), structures = _a.structures, groupCount = _a.groupCount, groupSize = _a.groupSize;
|
|
44214
|
-
// TODO: test for and handle this situation
|
|
44215
44403
|
if (groupCount < 1) {
|
|
44216
|
-
|
|
44404
|
+
return { error: INVALID_CONFIGURATION };
|
|
44217
44405
|
}
|
|
44218
44406
|
// define a default playoff group if none specified
|
|
44219
44407
|
var playoffGroups = (structureOptions === null || structureOptions === void 0 ? void 0 : structureOptions.playoffGroups) || [
|
|
@@ -63067,8 +63255,8 @@ function prepareStage(params) {
|
|
|
63067
63255
|
}).scaledEntries;
|
|
63068
63256
|
if (!(scaledEntries === null || scaledEntries === void 0 ? void 0 : scaledEntries.length) && seedByRanking) {
|
|
63069
63257
|
var rankingScaleAttributes = {
|
|
63070
|
-
scaleType: RANKING$1,
|
|
63071
63258
|
scaleName: categoryName || ageCategoryCode,
|
|
63259
|
+
scaleType: RANKING$1,
|
|
63072
63260
|
eventType: eventType,
|
|
63073
63261
|
};
|
|
63074
63262
|
(scaledEntries = getScaledEntries({
|
|
@@ -66567,7 +66755,7 @@ function generatePersons(params) {
|
|
|
66567
66755
|
shuffledPersons.push(person);
|
|
66568
66756
|
});
|
|
66569
66757
|
}
|
|
66570
|
-
var _d =
|
|
66758
|
+
var _d = getCategoryAgeDetails({
|
|
66571
66759
|
consideredDate: consideredDate,
|
|
66572
66760
|
category: category,
|
|
66573
66761
|
}), ageMinDate = _d.ageMinDate, ageMaxDate = _d.ageMaxDate;
|
|
@@ -69645,7 +69833,8 @@ var utilities = {
|
|
|
69645
69833
|
nextPowerOf2: nextPowerOf2,
|
|
69646
69834
|
numericSort: numericSort,
|
|
69647
69835
|
overlap: overlap,
|
|
69648
|
-
|
|
69836
|
+
getCategoryAgeDetails: getCategoryAgeDetails,
|
|
69837
|
+
categoryCanContain: categoryCanContain,
|
|
69649
69838
|
randomMember: randomMember,
|
|
69650
69839
|
randomPop: randomPop,
|
|
69651
69840
|
shuffleArray: shuffleArray,
|