tods-competition-factory 1.8.4 → 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.
@@ -1634,8 +1634,9 @@ declare function isValid(matchUpFormat: string): boolean;
1634
1634
  type ParsedFormat = {
1635
1635
  finalSetFormat?: any;
1636
1636
  simplified?: boolean;
1637
+ exactly?: number;
1637
1638
  setFormat?: any;
1638
- bestOf: number;
1639
+ bestOf?: number;
1639
1640
  };
1640
1641
  declare function parse(matchUpFormatCode: string): ParsedFormat | undefined;
1641
1642
 
@@ -4558,10 +4558,10 @@ function addUpcomingMatchUps({ drawDefinition, inContextDrawMatchUps }) {
4558
4558
  if (structure?.finishingPosition === WIN_RATIO$1) {
4559
4559
  const { roundNumber } = inContextMatchUp;
4560
4560
  const nextRoundNumber = roundNumber && ensureInt(roundNumber) + 1;
4561
- const matchUps = structure.matchUps || [];
4561
+ const matchUps = structure.matchUps ?? [];
4562
4562
  const { roundMatchUps } = getRoundMatchUps({ matchUps });
4563
4563
  if (nextRoundNumber && roundMatchUps?.[nextRoundNumber]) {
4564
- const sidesTo = drawPositions.sort().map((drawPosition, index) => {
4564
+ const sidesTo = [...drawPositions].sort(numericSort).map((drawPosition, index) => {
4565
4565
  const nextRoundMatchUp = roundMatchUps[nextRoundNumber].find(
4566
4566
  (matchUp) => matchUp.drawPositions?.includes(drawPosition)
4567
4567
  );
@@ -6137,7 +6137,7 @@ function parse(matchUpFormatCode) {
6137
6137
  setFormat,
6138
6138
  bestOf: 1
6139
6139
  };
6140
- if (parsedFormat.setFormat)
6140
+ if (setFormat)
6141
6141
  return parsedFormat;
6142
6142
  }
6143
6143
  if (type === SET)
@@ -6147,16 +6147,23 @@ function parse(matchUpFormatCode) {
6147
6147
  }
6148
6148
  function setsMatch(formatstring) {
6149
6149
  const parts = formatstring.split("-");
6150
- const bestOf = getNumber$1(parts[0].slice(3));
6150
+ const setsCount = getNumber$1(parts[0].slice(3));
6151
+ const bestOf = setsCount === 1 || setsCount % 2 !== 0 ? setsCount : void 0;
6152
+ const exactly = setsCount !== 1 && setsCount % 2 === 0 ? setsCount : void 0;
6151
6153
  const setFormat = parts && parseSetFormat(parts[1]);
6152
6154
  const finalSetFormat = parts && parseSetFormat(parts[2]);
6153
- const validBestOf = bestOf && bestOf < 6;
6155
+ const timed = setFormat && setFormat.timed || finalSetFormat && finalSetFormat.timed;
6156
+ const validSetsCount = bestOf && bestOf < 6 || timed && exactly;
6154
6157
  const validFinalSet = !parts[2] || finalSetFormat;
6155
6158
  const validSetsFormat = setFormat;
6156
- const result = { bestOf, setFormat };
6159
+ const result = definedAttributes({
6160
+ setFormat,
6161
+ exactly,
6162
+ bestOf
6163
+ });
6157
6164
  if (finalSetFormat)
6158
6165
  result.finalSetFormat = finalSetFormat;
6159
- if (validBestOf && validSetsFormat && validFinalSet)
6166
+ if (validSetsCount && validSetsFormat && validFinalSet)
6160
6167
  return result;
6161
6168
  }
6162
6169
  function parseSetFormat(formatstring) {
@@ -6446,10 +6453,10 @@ function getOrderedDrawPositions({
6446
6453
  const pairedDrawPositions = targetRoundProfile?.pairedDrawPositions;
6447
6454
  const displayOrder = pairedDrawPositions?.find(
6448
6455
  (pair) => overlap(pair || [], drawPositions.filter(Boolean))
6449
- ) || unassignedDrawPositions;
6456
+ ) ?? unassignedDrawPositions;
6450
6457
  const isFeedRound = targetRoundProfile?.feedRound;
6451
6458
  if (allNumeric(drawPositions)) {
6452
- const orderedDrawPositions = drawPositions.sort(numericSort);
6459
+ const orderedDrawPositions = [...drawPositions].sort(numericSort);
6453
6460
  return {
6454
6461
  orderedDrawPositions: orderedDrawPositions.length === 2 ? orderedDrawPositions : displayOrder,
6455
6462
  displayOrder: isFeedRound ? orderedDrawPositions : displayOrder
@@ -7173,7 +7180,7 @@ function getAllStructureMatchUps({
7173
7180
  matchUp,
7174
7181
  event: event2
7175
7182
  }) {
7176
- additionalContext = additionalContext || {};
7183
+ additionalContext = additionalContext ?? {};
7177
7184
  const tieFormat = resolveTieFormat({
7178
7185
  drawDefinition,
7179
7186
  structure,
@@ -7184,7 +7191,7 @@ function getAllStructureMatchUps({
7184
7191
  const collectionDefinition = matchUp.collectionId && collectionDefinitions?.find(
7185
7192
  (definition) => definition.collectionId === matchUp.collectionId
7186
7193
  );
7187
- const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat || structure?.matchUpFormat || drawDefinition?.matchUpFormat || event2?.matchUpFormat;
7194
+ const matchUpFormat = matchUp.collectionId ? collectionDefinition?.matchUpFormat : matchUp.matchUpFormat ?? structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event2?.matchUpFormat;
7188
7195
  const matchUpType = matchUp.matchUpType || collectionDefinition?.matchUpType || structure?.matchUpType || drawDefinition?.matchUpType || event2?.eventType !== TEAM && event2?.eventType;
7189
7196
  const matchUpStatus = isCollectionBye ? BYE : matchUp.matchUpStatus;
7190
7197
  const { schedule, endDate } = getMatchUpScheduleDetails({
@@ -7199,7 +7206,7 @@ function getAllStructureMatchUps({
7199
7206
  });
7200
7207
  const drawPositions = tieDrawPositions ?? matchUp.drawPositions ?? [];
7201
7208
  const { collectionPosition, collectionId, roundPosition } = matchUp;
7202
- const roundNumber = matchUp.roundNumber || additionalContext.roundNumber;
7209
+ const roundNumber = matchUp.roundNumber ?? additionalContext.roundNumber;
7203
7210
  const drawPositionCollectionAssignment = collectionId ? getDrawPositionCollectionAssignment({
7204
7211
  tournamentParticipants,
7205
7212
  positionAssignments,
@@ -7225,7 +7232,7 @@ function getAllStructureMatchUps({
7225
7232
  } : context?.category;
7226
7233
  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;
7227
7234
  const competitiveProfile = contextProfile?.withCompetitiveness && getMatchUpCompetitiveProfile({ ...contextContent, matchUp });
7228
- const finishingPositionRange = matchUp.finishingPositionRange || additionalContext.finishingPositionRange;
7235
+ const finishingPositionRange = matchUp.finishingPositionRange ?? additionalContext.finishingPositionRange;
7229
7236
  const onlyDefined = (obj) => definedAttributes(obj, void 0, true);
7230
7237
  const matchUpWithContext = {
7231
7238
  ...onlyDefined(context),
@@ -7233,7 +7240,7 @@ function getAllStructureMatchUps({
7233
7240
  matchUpFormat: matchUp.matchUpType === TEAM ? void 0 : matchUpFormat,
7234
7241
  tieFormat: matchUp.matchUpType !== TEAM ? void 0 : tieFormat,
7235
7242
  roundOfPlay: stage !== QUALIFYING && isConvertableInteger(initialRoundOfPlay2) && initialRoundOfPlay2 + (roundNumber || 0),
7236
- endDate: matchUp.endDate || endDate,
7243
+ endDate: matchUp.endDate ?? endDate,
7237
7244
  gender: collectionDefinition?.gender,
7238
7245
  discipline: event2?.discipline,
7239
7246
  category: matchUpCategory,
@@ -8338,9 +8345,7 @@ function getEligibleVoluntaryConsolationParticipants({
8338
8345
  function stringify(matchUpFormatObject, preserveRedundant) {
8339
8346
  if (typeof matchUpFormatObject !== "object")
8340
8347
  return;
8341
- if (matchUpFormatObject.timed && !isNaN(matchUpFormatObject.minutes))
8342
- return timedSetFormat(matchUpFormatObject);
8343
- if (matchUpFormatObject.bestOf && matchUpFormatObject.setFormat)
8348
+ if ((matchUpFormatObject.bestOf || matchUpFormatObject.exactly) && matchUpFormatObject.setFormat)
8344
8349
  return getSetFormat(matchUpFormatObject, preserveRedundant);
8345
8350
  return void 0;
8346
8351
  }
@@ -8356,11 +8361,13 @@ function timedSetFormat(matchUpFormatObject) {
8356
8361
  return value;
8357
8362
  }
8358
8363
  function getSetFormat(matchUpFormatObject, preserveRedundant) {
8359
- const bestOfValue = getNumber(matchUpFormatObject.bestOf);
8360
- if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && bestOfValue === 1) {
8364
+ const bestOfValue = getNumber(matchUpFormatObject.bestOf) || void 0;
8365
+ const exactly = getNumber(matchUpFormatObject.exactly) || void 0;
8366
+ const setLimit = bestOfValue || exactly;
8367
+ if (matchUpFormatObject.setFormat?.timed && matchUpFormatObject.simplified && setLimit === 1) {
8361
8368
  return timedSetFormat(matchUpFormatObject.setFormat);
8362
8369
  }
8363
- const bestOfCode = bestOfValue && `${SET}${bestOfValue}` || "";
8370
+ const setLimitCode = setLimit && `${SET}${setLimit}` || "";
8364
8371
  const setCountValue = stringifySet(
8365
8372
  matchUpFormatObject.setFormat,
8366
8373
  preserveRedundant
@@ -8370,11 +8377,11 @@ function getSetFormat(matchUpFormatObject, preserveRedundant) {
8370
8377
  matchUpFormatObject.finalSetFormat,
8371
8378
  preserveRedundant
8372
8379
  );
8373
- const finalSetCode = bestOfValue && bestOfValue > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
8380
+ const finalSetCode = setLimit && setLimit > 1 && finalSetCountValue && setCountValue !== finalSetCountValue && // don't include final set code if equivalent to other sets
8374
8381
  `F:${finalSetCountValue}` || "";
8375
- const valid = bestOfCode && setCountValue;
8382
+ const valid = setLimitCode && setCountValue;
8376
8383
  if (valid) {
8377
- return [bestOfCode, setCode, finalSetCode].filter((f) => f).join("-");
8384
+ return [setLimitCode, setCode, finalSetCode].filter((f) => f).join("-");
8378
8385
  }
8379
8386
  return void 0;
8380
8387
  }