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.
@@ -72,7 +72,7 @@ function groupConsecutiveNumbers(arr) {
72
72
  return result;
73
73
  }, []);
74
74
  }
75
- function allNumeric(arr) {
75
+ function allNumeric$1(arr) {
76
76
  return arr.reduce((numeric, item) => !isNaN(parseInt(item)) && numeric, true);
77
77
  }
78
78
  function noNumeric(arr) {
@@ -365,10 +365,18 @@ const MISSING_CONTEXT = {
365
365
  message: "Missing context",
366
366
  code: "ERR_MISSING_CONTEXT"
367
367
  };
368
+ const INVALID_COLLECTION_DEFINITION = {
369
+ message: "Invalid collectionDefinition",
370
+ code: "ERR_INVALID_COLLECTION_DEFINITION"
371
+ };
368
372
  const INVALID_OBJECT = {
369
373
  message: "Invalid object",
370
374
  code: "ERR_INVALID_OBJECT"
371
375
  };
376
+ const INVALID_CATEGORY = {
377
+ message: "Invalid category",
378
+ code: "ERR_INVALID_CATEGORY"
379
+ };
372
380
  const INVALID_VALUES = {
373
381
  message: "Invalid values",
374
382
  code: "ERR_INVALID_VALUES"
@@ -574,7 +582,11 @@ function addNotice(notice) {
574
582
  function getTopics() {
575
583
  return _globalStateProvider.getTopics();
576
584
  }
585
+ function getProvider() {
586
+ return _globalStateProvider;
587
+ }
577
588
 
589
+ const validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
578
590
  const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
579
591
  const 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?$/;
580
592
  const 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?$/;
@@ -605,6 +617,9 @@ function validTimeValue(value) {
605
617
  return false;
606
618
  return !!(!value || timeValidation.test(convertTime(value, true, true)));
607
619
  }
620
+ function isValidDateString(scheduleDate) {
621
+ return isISODateString(scheduleDate) || validDateString.test(scheduleDate);
622
+ }
608
623
  const getUTCdateString = (date) => {
609
624
  const dateDate = isDate(date) || isISODateString(date) ? new Date(date) : /* @__PURE__ */ new Date();
610
625
  const monthNumber = dateDate.getUTCMonth() + 1;
@@ -762,6 +777,13 @@ function sameDay(date1, date2) {
762
777
  }
763
778
 
764
779
  function makeDeepCopy(sourceObject, convertExtensions, internalUse, removeExtensions, iteration = 0) {
780
+ if (getProvider().makeDeepCopy)
781
+ return getProvider().makeDeepCopy(
782
+ sourceObject,
783
+ convertExtensions,
784
+ internalUse,
785
+ removeExtensions
786
+ );
765
787
  const deepCopy = deepCopyEnabled();
766
788
  const { stringify, toJSON, ignore, modulate } = deepCopy || {};
767
789
  if (!deepCopy?.enabled && !internalUse || typeof sourceObject !== "object" || typeof sourceObject === "function" || sourceObject === null || typeof deepCopy?.threshold === "number" && iteration >= deepCopy.threshold) {
@@ -1411,6 +1433,208 @@ function removeTournamentExtension(params) {
1411
1433
  });
1412
1434
  }
1413
1435
 
1436
+ const typeMatch = (arr, type) => arr.filter(Boolean).every((i) => typeof i === type);
1437
+ const allNumeric = (arr) => arr.filter(Boolean).every(isNumeric);
1438
+ function getCategoryAgeDetails(params) {
1439
+ const category = params.category;
1440
+ if (typeof category !== "object")
1441
+ return { error: INVALID_CATEGORY };
1442
+ let { ageCategoryCode, ageMaxDate, ageMinDate, ageMax, ageMin } = category;
1443
+ const categoryName = category.categoryName;
1444
+ let combinedAge;
1445
+ if (!typeMatch(
1446
+ [ageCategoryCode, ageMaxDate, ageMinDate, categoryName],
1447
+ "string"
1448
+ ) || !allNumeric(
1449
+ [ageMax, ageMin]
1450
+ ))
1451
+ return { error: INVALID_CATEGORY };
1452
+ const consideredDate = params.consideredDate ?? extractDate((/* @__PURE__ */ new Date()).toLocaleDateString("sv"));
1453
+ if (!isValidDateString(consideredDate))
1454
+ return { error: INVALID_DATE };
1455
+ const [consideredYear] = consideredDate.split("-").slice(0, 3).map((n) => parseInt(n));
1456
+ const previousDayDate = dateStringDaysChange(consideredDate, -1);
1457
+ const [previousDayMonth, previousDay] = previousDayDate.split("-").slice(1, 3).map((n) => parseInt(n));
1458
+ const previousMonthDay = `${zeroPad(previousDayMonth)}-${zeroPad(
1459
+ previousDay
1460
+ )}`;
1461
+ const nextDayDate = dateStringDaysChange(consideredDate, 1);
1462
+ const [nextDayMonth, nextDay] = nextDayDate.split("-").slice(1, 3).map((n) => parseInt(n));
1463
+ const nextMonthDay = `${zeroPad(nextDayMonth)}-${zeroPad(nextDay)}`;
1464
+ let calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
1465
+ let calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
1466
+ const errors = [];
1467
+ const addError = (errorString) => !errors.includes(errorString) && errors.push(errorString);
1468
+ ageCategoryCode = ageCategoryCode ?? categoryName;
1469
+ const prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
1470
+ const extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
1471
+ const isBetween = ageCategoryCode?.includes("-");
1472
+ const isCombined = isBetween && ageCategoryCode?.match(extractCombined);
1473
+ const isCoded = ageCategoryCode?.match(prePost);
1474
+ const constructedDate = (y, df) => `${y}-${df}`;
1475
+ const uPre = (ageInt) => {
1476
+ const ageMinYear = consideredYear - ageInt;
1477
+ const newMinDate = constructedDate(ageMinYear, nextMonthDay);
1478
+ if (category.ageMinDate && category.ageMinDate !== newMinDate)
1479
+ addError(`Invalid submitted ageMinDate: ${ageMinDate}`);
1480
+ ageMinDate = newMinDate;
1481
+ if (ageCategoryCode) {
1482
+ if (category.ageMax && category.ageMax !== ageInt - 1) {
1483
+ addError(`Invalid submitted ageMax: ${ageMax}`);
1484
+ calculatedAgeMinDate = void 0;
1485
+ }
1486
+ ageMax = ageInt - 1;
1487
+ }
1488
+ };
1489
+ const uPost = (ageInt) => {
1490
+ const ageMinYear = consideredYear - ageInt - 1;
1491
+ const newMinDate = constructedDate(ageMinYear, nextMonthDay);
1492
+ if (category.ageMin && category.ageMin > ageInt) {
1493
+ addError(`Invalid submitted ageMin: ${ageMin}`);
1494
+ }
1495
+ if (category.ageMax && category.ageMax > ageInt) {
1496
+ addError(`Invalid submitted ageMax: ${ageMax}`);
1497
+ }
1498
+ if (category.ageMinDate && category.ageMinDate !== newMinDate)
1499
+ addError(`Invalid submitted ageMinDate: ${ageMinDate}`);
1500
+ ageMinDate = newMinDate;
1501
+ if (ageCategoryCode) {
1502
+ if (category.ageMax && category.ageMax !== ageInt) {
1503
+ addError(`Invalid submitted ageMax: ${ageMax}`);
1504
+ calculatedAgeMaxDate = void 0;
1505
+ }
1506
+ ageMax = ageInt;
1507
+ }
1508
+ };
1509
+ const oPre = (ageInt) => {
1510
+ const ageMaxYear = consideredYear - ageInt;
1511
+ const newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
1512
+ if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
1513
+ addError(`Invalid submitted ageMaxDate: ${ageMaxDate}`);
1514
+ ageMaxDate = newMaxDate;
1515
+ if (ageCategoryCode) {
1516
+ if (category.ageMin && category.ageMin !== ageInt + 1) {
1517
+ addError(`Invalid submitted ageMin: ${ageMin}`);
1518
+ calculatedAgeMaxDate = void 0;
1519
+ }
1520
+ ageMin = ageInt + 1;
1521
+ }
1522
+ };
1523
+ const oPost = (ageInt) => {
1524
+ const ageMaxYear = consideredYear - ageInt - 1;
1525
+ const newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
1526
+ if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
1527
+ addError(`Invalid submitted ageMaxDate: ${ageMaxDate}`);
1528
+ ageMaxDate = newMaxDate;
1529
+ if (ageCategoryCode) {
1530
+ if (category.ageMin && category.ageMin !== ageInt) {
1531
+ addError(`Invalid submitted ageMin: ${ageMin}`);
1532
+ calculatedAgeMaxDate = void 0;
1533
+ }
1534
+ ageMin = ageInt;
1535
+ }
1536
+ };
1537
+ const processCode = (code) => {
1538
+ const [pre, age, post] = (code.match(prePost) || []).slice(1);
1539
+ const ageInt = parseInt(age);
1540
+ if (pre === "U") {
1541
+ if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
1542
+ addError(`Invalid submitted ageMaxDate: ${category.ageMaxDate}`);
1543
+ }
1544
+ uPre(ageInt);
1545
+ } else if (pre === "O") {
1546
+ oPre(ageInt);
1547
+ }
1548
+ if (post === "U") {
1549
+ if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
1550
+ addError(`Invalid submitted ageMaxDate: ${category.ageMaxDate}`);
1551
+ }
1552
+ uPost(ageInt);
1553
+ } else if (post === "O") {
1554
+ oPost(ageInt);
1555
+ }
1556
+ ageMaxDate = ageMaxDate ?? calculatedAgeMaxDate;
1557
+ ageMinDate = ageMinDate ?? calculatedAgeMinDate;
1558
+ };
1559
+ if (isCombined) {
1560
+ ageMaxDate = void 0;
1561
+ ageMinDate = void 0;
1562
+ ageMax = void 0;
1563
+ ageMin = void 0;
1564
+ if (category.ageMin) {
1565
+ const ageMaxYear = consideredYear - category.ageMin;
1566
+ ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
1567
+ }
1568
+ if (category.ageMax) {
1569
+ const ageMinYear = consideredYear - category.ageMax - 1;
1570
+ ageMinDate = constructedDate(ageMinYear, nextMonthDay);
1571
+ }
1572
+ const [lowAge, highAge] = (ageCategoryCode?.match(extractCombined) ?? []).slice(1).map((n) => parseInt(n));
1573
+ if (lowAge <= highAge) {
1574
+ ageMin = lowAge;
1575
+ ageMax = highAge;
1576
+ combinedAge = true;
1577
+ } else {
1578
+ addError(`Invalid combined age range ${ageCategoryCode}`);
1579
+ }
1580
+ } else if (isBetween) {
1581
+ ageCategoryCode?.split("-").forEach(processCode);
1582
+ } else if (isCoded) {
1583
+ processCode(ageCategoryCode);
1584
+ } else {
1585
+ if (ageMin)
1586
+ oPre(ageMin);
1587
+ if (ageMax)
1588
+ uPost(ageMax);
1589
+ }
1590
+ if (ageMax && category.ageMin && category.ageMin > ageMax) {
1591
+ addError(`Invalid submitted ageMin: ${category.ageMin}`);
1592
+ ageMin = void 0;
1593
+ }
1594
+ const result = definedAttributes({
1595
+ consideredDate,
1596
+ combinedAge,
1597
+ ageMaxDate,
1598
+ ageMinDate,
1599
+ ageMax,
1600
+ ageMin
1601
+ });
1602
+ if (errors.length)
1603
+ result.errors = errors;
1604
+ return result;
1605
+ }
1606
+
1607
+ function categoryCanContain({
1608
+ childCategory,
1609
+ withDetails,
1610
+ category
1611
+ }) {
1612
+ const categoryDetails = getCategoryAgeDetails({ category });
1613
+ const childCategoryDetails = getCategoryAgeDetails({
1614
+ category: childCategory
1615
+ });
1616
+ const invalidAgeMin = childCategoryDetails.ageMin && (categoryDetails.ageMin && childCategoryDetails.ageMin < categoryDetails.ageMin || categoryDetails.ageMax && childCategoryDetails.ageMin > categoryDetails.ageMax);
1617
+ const invalidAgeMax = childCategoryDetails.ageMax && (categoryDetails.ageMax && childCategoryDetails.ageMax > categoryDetails.ageMax || categoryDetails.ageMin && childCategoryDetails.ageMax < categoryDetails.ageMin);
1618
+ const invalidAgeMinDate = childCategoryDetails.ageMinDate && categoryDetails.ageMaxDate && new Date(childCategoryDetails.ageMinDate) > new Date(categoryDetails.ageMaxDate);
1619
+ const invalidAgeMaxDate = childCategoryDetails.ageMaxDate && categoryDetails.ageMinDate && new Date(childCategoryDetails.ageMaxDate) < new Date(categoryDetails.ageMinDate);
1620
+ const valid = !invalidAgeMax && !invalidAgeMin && !invalidAgeMinDate && !invalidAgeMaxDate;
1621
+ const ignoreFalse = true;
1622
+ const result = definedAttributes(
1623
+ {
1624
+ valid,
1625
+ invalidAgeMax,
1626
+ invalidAgeMin,
1627
+ invalidAgeMinDate,
1628
+ invalidAgeMaxDate
1629
+ },
1630
+ ignoreFalse
1631
+ );
1632
+ if (withDetails) {
1633
+ Object.assign(result, { categoryDetails, childCategoryDetails });
1634
+ }
1635
+ return result;
1636
+ }
1637
+
1414
1638
  const NORMAL = "normal";
1415
1639
  const TIMED = "timed";
1416
1640
  const FINAL = "final";
@@ -1424,9 +1648,7 @@ const setTypes = {
1424
1648
  function stringify(matchUpFormatObject, preserveRedundant) {
1425
1649
  if (typeof matchUpFormatObject !== "object")
1426
1650
  return;
1427
- if (matchUpFormatObject.timed && !isNaN(matchUpFormatObject.minutes))
1428
- return timedSetFormat(matchUpFormatObject);
1429
- if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
1651
+ if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) && matchUpFormatObject.setFormat)
1430
1652
  return getSetFormat(matchUpFormatObject, preserveRedundant);
1431
1653
  return void 0;
1432
1654
  }
@@ -1442,11 +1664,13 @@ function timedSetFormat(matchUpFormatObject) {
1442
1664
  return value;
1443
1665
  }
1444
1666
  function getSetFormat(matchUpFormatObject, preserveRedundant) {
1445
- const bestOfValue = getNumber$1(matchUpFormatObject.bestOf);
1446
- if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && bestOfValue === 1) {
1667
+ const bestOfValue = getNumber$1(matchUpFormatObject.bestOf) || void 0;
1668
+ const exactly = getNumber$1(matchUpFormatObject.exactly) || void 0;
1669
+ const setLimit = bestOfValue || exactly;
1670
+ if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
1447
1671
  return timedSetFormat(matchUpFormatObject.setFormat);
1448
1672
  }
1449
- const bestOfCode = bestOfValue && `${SET}${bestOfValue}` || "";
1673
+ const setLimitCode = setLimit && `${SET}${setLimit}` || "";
1450
1674
  const setCountValue = stringifySet(
1451
1675
  matchUpFormatObject.setFormat,
1452
1676
  preserveRedundant
@@ -1456,11 +1680,11 @@ function getSetFormat(matchUpFormatObject, preserveRedundant) {
1456
1680
  matchUpFormatObject.finalSetFormat,
1457
1681
  preserveRedundant
1458
1682
  );
1459
- const finalSetCode = bestOfValue && bestOfValue > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
1683
+ const finalSetCode = setLimit && setLimit > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
1460
1684
  `F:${finalSetCountValue}` || "";
1461
- const valid = bestOfCode && setCountValue;
1685
+ const valid = setLimitCode && setCountValue;
1462
1686
  if (valid) {
1463
- return [bestOfCode, setCode, finalSetCode].filter((f) => f).join("-");
1687
+ return [setLimitCode, setCode, finalSetCode].filter((f) => f).join("-");
1464
1688
  }
1465
1689
  return void 0;
1466
1690
  }
@@ -1510,7 +1734,7 @@ function parse(matchUpFormatCode) {
1510
1734
  setFormat,
1511
1735
  bestOf: 1
1512
1736
  };
1513
- if (parsedFormat.setFormat)
1737
+ if (setFormat)
1514
1738
  return parsedFormat;
1515
1739
  }
1516
1740
  if (type === SET)
@@ -1520,16 +1744,23 @@ function parse(matchUpFormatCode) {
1520
1744
  }
1521
1745
  function setsMatch(formatstring) {
1522
1746
  const parts = formatstring.split("-");
1523
- const bestOf = getNumber(parts[0].slice(3));
1747
+ const setsCount = getNumber(parts[0].slice(3));
1748
+ const bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : void 0;
1749
+ const exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : void 0;
1524
1750
  const setFormat = parts && parseSetFormat(parts[1]);
1525
1751
  const finalSetFormat = parts && parseSetFormat(parts[2]);
1526
- const validBestOf = bestOf && bestOf < 6;
1752
+ const timed = setFormat && setFormat.timed || finalSetFormat && finalSetFormat.timed;
1753
+ const validSetsCount = bestOf && bestOf < 6 || timed && exactly;
1527
1754
  const validFinalSet = !parts[2] || finalSetFormat;
1528
1755
  const validSetsFormat = setFormat;
1529
- const result = { bestOf, setFormat };
1756
+ const result = definedAttributes({
1757
+ setFormat,
1758
+ exactly,
1759
+ bestOf
1760
+ });
1530
1761
  if (finalSetFormat)
1531
1762
  result.finalSetFormat = finalSetFormat;
1532
- if (validBestOf && validSetsFormat && validFinalSet)
1763
+ if (validSetsCount && validSetsFormat && validFinalSet)
1533
1764
  return result;
1534
1765
  }
1535
1766
  function parseSetFormat(formatstring) {
@@ -1719,6 +1950,7 @@ var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
1719
1950
  })(ParticipantTypeEnum || {});
1720
1951
 
1721
1952
  function validateTieFormat(params) {
1953
+ const checkCategory = !!(params?.enforceCategory !== false && params?.category);
1722
1954
  const checkGender = !!(params?.enforceGender !== false && params?.gender);
1723
1955
  const checkCollectionIds = params?.checkCollectionIds;
1724
1956
  const tieFormat = params?.tieFormat;
@@ -1755,9 +1987,11 @@ function validateTieFormat(params) {
1755
1987
  if ((setValue || scoreValue) && !collectionValue)
1756
1988
  aggregateValueImperative = true;
1757
1989
  const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
1990
+ referenceCategory: params.category,
1758
1991
  referenceGender: params.gender,
1759
1992
  collectionDefinition,
1760
1993
  checkCollectionIds,
1994
+ checkCategory,
1761
1995
  checkGender
1762
1996
  });
1763
1997
  if (valid2) {
@@ -1799,19 +2033,22 @@ function validateTieFormat(params) {
1799
2033
  return result;
1800
2034
  }
1801
2035
  function validateCollectionDefinition({
2036
+ checkCategory = true,
1802
2037
  collectionDefinition,
1803
2038
  checkCollectionIds,
1804
2039
  checkGender = true,
2040
+ referenceCategory,
1805
2041
  referenceGender,
1806
2042
  event
1807
2043
  }) {
1808
2044
  referenceGender = referenceGender ?? event?.gender;
2045
+ const stack = "validateCollectionDefinition";
1809
2046
  const errors = [];
1810
2047
  if (typeof collectionDefinition !== "object") {
1811
2048
  errors.push(
1812
2049
  `collectionDefinition must be an object: ${collectionDefinition}`
1813
2050
  );
1814
- return { errors, error: INVALID_OBJECT };
2051
+ return decorateResult({ result: { errors, error: INVALID_OBJECT }, stack });
1815
2052
  }
1816
2053
  const {
1817
2054
  collectionValueProfiles,
@@ -1824,6 +2061,7 @@ function validateCollectionDefinition({
1824
2061
  matchUpType,
1825
2062
  scoreValue,
1826
2063
  setValue,
2064
+ category,
1827
2065
  gender
1828
2066
  } = collectionDefinition;
1829
2067
  if (checkCollectionIds && typeof collectionId !== "string") {
@@ -1869,8 +2107,23 @@ function validateCollectionDefinition({
1869
2107
  if (checkGender && referenceGender && gender && [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) && referenceGender !== gender) {
1870
2108
  errors.push(`Invalid gender: ${gender}`);
1871
2109
  }
2110
+ if (checkCategory && referenceCategory && category) {
2111
+ const result = categoryCanContain({
2112
+ category: referenceCategory,
2113
+ childCategory: category
2114
+ });
2115
+ if (!result.valid)
2116
+ return decorateResult({
2117
+ result: { error: INVALID_CATEGORY },
2118
+ context: result,
2119
+ stack
2120
+ });
2121
+ }
1872
2122
  if (errors.length)
1873
- return { errors, error: INVALID_OBJECT };
2123
+ return decorateResult({
2124
+ result: { errors, error: INVALID_COLLECTION_DEFINITION },
2125
+ stack
2126
+ });
1874
2127
  return { valid: true };
1875
2128
  }
1876
2129
  function validateCollectionValueProfiles({
@@ -5236,10 +5489,10 @@ function getOrderedDrawPositions({
5236
5489
  const pairedDrawPositions = targetRoundProfile?.pairedDrawPositions;
5237
5490
  const displayOrder = pairedDrawPositions?.find(
5238
5491
  (pair) => overlap(pair || [], drawPositions.filter(Boolean))
5239
- ) || unassignedDrawPositions;
5492
+ ) ?? unassignedDrawPositions;
5240
5493
  const isFeedRound = targetRoundProfile?.feedRound;
5241
- if (allNumeric(drawPositions)) {
5242
- const orderedDrawPositions = drawPositions.sort(numericSort);
5494
+ if (allNumeric$1(drawPositions)) {
5495
+ const orderedDrawPositions = [...drawPositions].sort(numericSort);
5243
5496
  return {
5244
5497
  orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
5245
5498
  displayOrder: isFeedRound ? orderedDrawPositions : displayOrder
@@ -5962,7 +6215,7 @@ function getAllStructureMatchUps({
5962
6215
  matchUp,
5963
6216
  event: event2
5964
6217
  }) {
5965
- additionalContext = additionalContext || {};
6218
+ additionalContext = additionalContext ?? {};
5966
6219
  const tieFormat = resolveTieFormat({
5967
6220
  drawDefinition,
5968
6221
  structure,
@@ -5973,7 +6226,7 @@ function getAllStructureMatchUps({
5973
6226
  const collectionDefinition = matchUp.collectionId && collectionDefinitions?.find(
5974
6227
  (definition) => definition.collectionId === matchUp.collectionId
5975
6228
  );
5976
- const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat || structure?.matchUpFormat || drawDefinition?.matchUpFormat || event2?.matchUpFormat;
6229
+ const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event2?.matchUpFormat;
5977
6230
  const matchUpType = matchUp.matchUpType || collectionDefinition?.matchUpType || structure?.matchUpType || drawDefinition?.matchUpType || event2?.eventType !== TEAM$1 && event2?.eventType;
5978
6231
  const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
5979
6232
  const { schedule, endDate } = getMatchUpScheduleDetails({
@@ -5988,7 +6241,7 @@ function getAllStructureMatchUps({
5988
6241
  });
5989
6242
  const drawPositions = tieDrawPositions ?? matchUp.drawPositions ?? [];
5990
6243
  const { collectionPosition, collectionId, roundPosition } = matchUp;
5991
- const roundNumber = matchUp.roundNumber || additionalContext.roundNumber;
6244
+ const roundNumber = matchUp.roundNumber ?? additionalContext.roundNumber;
5992
6245
  const drawPositionCollectionAssignment = collectionId ? getDrawPositionCollectionAssignment({
5993
6246
  tournamentParticipants,
5994
6247
  positionAssignments,
@@ -6014,7 +6267,7 @@ function getAllStructureMatchUps({
6014
6267
  } : context?.category;
6015
6268
  const processCodes = matchUp.processCodes?.length && matchUp.processCodes || collectionDefinition?.processCodes?.length && collectionDefinition?.processCodes || structure?.processCodes?.length && structure?.processCodes || drawDefinition?.processCodes?.length && drawDefinition?.processCodes || event2?.processCodes?.length && event2?.processCodes || tournamentRecord?.processCodes;
6016
6269
  const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
6017
- const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
6270
+ const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
6018
6271
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
6019
6272
  const matchUpWithContext = {
6020
6273
  ...onlyDefined(context),
@@ -6022,7 +6275,7 @@ function getAllStructureMatchUps({
6022
6275
  matchUpFormat: matchUp.matchUpType === TEAM$1 ? void 0 : matchUpFormat,
6023
6276
  tieFormat: matchUp.matchUpType !== TEAM$1 ? void 0 : tieFormat,
6024
6277
  roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
6025
- endDate: matchUp.endDate || endDate,
6278
+ endDate: matchUp.endDate ?? endDate,
6026
6279
  gender: collectionDefinition?.gender,
6027
6280
  discipline: event2?.discipline,
6028
6281
  category: matchUpCategory,
@@ -6931,10 +7184,10 @@ function addUpcomingMatchUps({ drawDefinition, inContextDrawMatchUps }) {
6931
7184
  if (structure?.finishingPosition === WIN_RATIO) {
6932
7185
  const { roundNumber } = inContextMatchUp;
6933
7186
  const nextRoundNumber = roundNumber && ensureInt(roundNumber) + 1;
6934
- const matchUps = structure.matchUps || [];
7187
+ const matchUps = structure.matchUps ?? [];
6935
7188
  const { roundMatchUps } = getRoundMatchUps({ matchUps });
6936
7189
  if (nextRoundNumber && roundMatchUps?.[nextRoundNumber]) {
6937
- const sidesTo = drawPositions.sort().map((drawPosition, index) => {
7190
+ const sidesTo = [...drawPositions].sort(numericSort).map((drawPosition, index) => {
6938
7191
  const nextRoundMatchUp = roundMatchUps[nextRoundNumber].find(
6939
7192
  (matchUp) => matchUp.drawPositions?.includes(drawPosition)
6940
7193
  );
@@ -16895,7 +17148,8 @@ function bulkRescheduleMatchUps$1({
16895
17148
  scheduledTime,
16896
17149
  minutesChange
16897
17150
  );
16898
- newScheduledTime = scheduledTimeDate && newScheduledDate ? `${newScheduledDate}T${timeString}` : timeString;
17151
+ const timeStringDate = scheduledTimeDate && newScheduledDate || scheduledDate === scheduledTimeDate && scheduledTimeDate;
17152
+ newScheduledTime = timeStringDate ? `${timeStringDate}T${timeString}` : timeString;
16899
17153
  }
16900
17154
  }
16901
17155
  if (doNotReschedule) {