tods-competition-factory 2.2.31 → 2.2.32-beta.0

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.2.31';
6
+ return '2.2.32-beta.0';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -1880,38 +1880,85 @@ function decorateResult({ context, result, stack, info }) {
1880
1880
  return result ?? { success: true };
1881
1881
  }
1882
1882
 
1883
- const ANY = 'ANY';
1884
- const MALE = 'MALE';
1885
- const MIXED = 'MIXED';
1886
- const OTHER$3 = 'OTHER';
1883
+ const FEMALE_ABBR = 'F';
1884
+ const OTHER_ABBR = 'O';
1885
+ const MIXED_ABBR = 'X';
1886
+ const MALE_ABBR = 'M';
1887
+ const ANY_ABBR = 'A';
1887
1888
  const FEMALE = 'FEMALE';
1889
+ const OTHER$3 = 'OTHER';
1890
+ const MIXED = 'MIXED';
1891
+ const MALE = 'MALE';
1892
+ const ANY = 'ANY';
1888
1893
  const genderConstants = {
1889
- ANY,
1890
- MALE,
1894
+ FEMALE_ABBR,
1895
+ OTHER_ABBR,
1896
+ MIXED_ABBR,
1897
+ MALE_ABBR,
1898
+ ANY_ABBR,
1891
1899
  FEMALE,
1892
1900
  MIXED,
1893
1901
  OTHER: OTHER$3,
1902
+ MALE,
1903
+ ANY,
1894
1904
  };
1895
1905
 
1906
+ function isFemale(gender) {
1907
+ return [FEMALE, FEMALE_ABBR].includes(gender);
1908
+ }
1909
+
1910
+ function isMale(gender) {
1911
+ return [MALE, MALE_ABBR].includes(gender);
1912
+ }
1913
+
1914
+ function isMixed(gender) {
1915
+ return [MIXED, MIXED_ABBR].includes(gender);
1916
+ }
1917
+
1918
+ function isAny(gender) {
1919
+ return [ANY, ANY_ABBR].includes(gender);
1920
+ }
1921
+
1922
+ function coercedGender(gender) {
1923
+ if (gender) {
1924
+ if (isFemale(gender))
1925
+ return FEMALE;
1926
+ if (isMixed(gender))
1927
+ return MIXED;
1928
+ if (isMale(gender))
1929
+ return MALE;
1930
+ if (isAny(gender))
1931
+ return ANY;
1932
+ }
1933
+ return OTHER$3;
1934
+ }
1935
+
1936
+ function isGendered(gender) {
1937
+ return isFemale(gender) || isMale(gender);
1938
+ }
1939
+
1896
1940
  const mixedGenderError = 'MIXED events can not contain mixed singles or { gender: ANY } collections';
1897
1941
  const anyMixedError = 'events with { gender: ANY } can not contain MIXED singles collections';
1898
1942
  function tieFormatGenderValidityCheck(params) {
1899
1943
  const stack = 'tieFormatGenderValidityCheck';
1900
1944
  const { referenceGender, matchUpType, gender } = params;
1901
- if (referenceGender && gender && [MALE, FEMALE].includes(referenceGender) && referenceGender !== gender)
1945
+ if (referenceGender &&
1946
+ gender &&
1947
+ isGendered(referenceGender) &&
1948
+ coercedGender(referenceGender) !== coercedGender(gender))
1902
1949
  return decorateResult({
1903
1950
  result: { valid: false, error: INVALID_GENDER },
1904
1951
  context: { gender },
1905
1952
  stack,
1906
1953
  });
1907
- if (referenceGender === MIXED && (gender === ANY || (gender === MIXED && matchUpType !== DOUBLES$1))) {
1954
+ if (isMixed(referenceGender) && (isAny(gender) || (isMixed(gender) && matchUpType !== DOUBLES$1))) {
1908
1955
  return decorateResult({
1909
1956
  result: { error: INVALID_GENDER, valid: false },
1910
1957
  info: mixedGenderError,
1911
1958
  stack,
1912
1959
  });
1913
1960
  }
1914
- if (referenceGender === ANY && gender === MIXED && matchUpType !== DOUBLES$1)
1961
+ if (isAny(referenceGender) && isMixed(gender) && matchUpType !== DOUBLES$1)
1915
1962
  return decorateResult({
1916
1963
  result: { error: INVALID_GENDER, valid: false },
1917
1964
  info: anyMixedError,
@@ -12237,7 +12284,63 @@ function getInitialRoundNumber({ drawPosition, matchUps = [] }) {
12237
12284
  return { initialRoundNumber };
12238
12285
  }
12239
12286
 
12240
- function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tournamentRecord, drawDefinition, drawPosition, matchUpsMap, structureId, structure, event, }) {
12287
+ const logColors = {
12288
+ reset: '\x1b[0m',
12289
+ bright: '\x1b[1m',
12290
+ dim: '\x1b[2m',
12291
+ red: '\x1b[31m',
12292
+ brightred: '\x1b[91m',
12293
+ green: '\x1b[32m',
12294
+ brightgreen: '\x1b[92m',
12295
+ yellow: '\x1b[33m',
12296
+ brightyellow: '\x1b[93m',
12297
+ blue: '\x1b[34m',
12298
+ brightblue: '\x1b[94m',
12299
+ lightblue: '\x1b[105m',
12300
+ magenta: '\x1b[35m',
12301
+ brightmagenta: '\x1b[95m',
12302
+ cyan: '\x1b[36m',
12303
+ brightcyan: '\x1b[96m',
12304
+ white: '\x1b[37m',
12305
+ brightwhite: '\x1b[97m',
12306
+ };
12307
+
12308
+ const globalLog = [];
12309
+ function pushGlobalLog(value, devContextOverride) {
12310
+ if (isString(value))
12311
+ value = { method: value };
12312
+ if (devContextOverride || getDevContext())
12313
+ globalLog.push(value);
12314
+ }
12315
+ function getGlobalLog(purge) {
12316
+ const globalLogCopy = globalLog.slice();
12317
+ return globalLogCopy;
12318
+ }
12319
+ function printGlobalLog(purge) {
12320
+ const globalLogCopy = getGlobalLog();
12321
+ const modifiedText = globalLogCopy.map((line) => {
12322
+ const { color, keyColors, method, newline } = line;
12323
+ const methodColor = Object.keys(logColors).includes(color) ? logColors[color] : logColors.cyan;
12324
+ const bodyKeys = Object.keys(line).filter((key) => !['color', 'keyColors', 'method', 'newline'].includes(key));
12325
+ const body = bodyKeys
12326
+ .map((key) => {
12327
+ const keyColor = keyColors && Object.keys(keyColors).includes(key) && logColors[keyColors[key]]
12328
+ ? logColors[keyColors[key]]
12329
+ : logColors.brightwhite;
12330
+ return `${logColors.white}${key}: ${keyColor}${line[key]}`;
12331
+ })
12332
+ .join(', ');
12333
+ const tabs = method?.length < 15 ? `\t\t` : '\t';
12334
+ return [newline ? '\n' : '', methodColor, method, tabs, logColors.white, body, logColors.reset, '\n'].join('');
12335
+ });
12336
+ if (modifiedText?.length)
12337
+ console.log(...modifiedText);
12338
+ }
12339
+ function purgeGlobalLog() {
12340
+ globalLog.length = 0;
12341
+ }
12342
+
12343
+ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tournamentRecord, drawDefinition, drawPosition, loserMatchUp, matchUpsMap, structureId, structure, event, }) {
12241
12344
  if (!drawDefinition)
12242
12345
  return { error: MISSING_DRAW_DEFINITION };
12243
12346
  if (!structure)
@@ -12247,6 +12350,7 @@ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tourn
12247
12350
  if (!structureId)
12248
12351
  ({ structureId } = structure);
12249
12352
  const stack = 'assignDrawPositionBye';
12353
+ pushGlobalLog({ method: stack, color: 'cyan', drawPosition });
12250
12354
  if (!matchUpsMap) {
12251
12355
  matchUpsMap = getMatchUpsMap({ drawDefinition });
12252
12356
  }
@@ -12259,8 +12363,9 @@ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tourn
12259
12363
  if (currentAssignment?.bye) {
12260
12364
  return { ...SUCCESS };
12261
12365
  }
12366
+ const hasPropagatedStatus = !!(loserMatchUp && matchUpsMap.drawMatchUps.find((m) => m.loserMatchUpId === loserMatchUp?.matchUpId && [DEFAULTED, WALKOVER$2].includes(m.matchUpStatus)));
12262
12367
  const drawPositionIsActive = activeDrawPositions?.includes(drawPosition);
12263
- if (drawPositionIsActive) {
12368
+ if (drawPositionIsActive && !hasPropagatedStatus) {
12264
12369
  return { error: DRAW_POSITION_ACTIVE };
12265
12370
  }
12266
12371
  const positionAssignment = positionAssignments?.find((assignment) => assignment.drawPosition === drawPosition);
@@ -12269,7 +12374,7 @@ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tourn
12269
12374
  const { filled, containsBye, assignedParticipantId } = drawPositionFilled(positionAssignment);
12270
12375
  if (containsBye)
12271
12376
  return { ...SUCCESS };
12272
- if (filled && !containsBye) {
12377
+ if (filled && !containsBye && !hasPropagatedStatus) {
12273
12378
  return decorateResult({ result: { error: DRAW_POSITION_ASSIGNED }, stack });
12274
12379
  }
12275
12380
  const appliedPolicies = getAppliedPolicies({
@@ -12293,6 +12398,9 @@ function assignDrawPositionBye({ provisionalPositioning, isPositionAction, tourn
12293
12398
  positionAssignments?.forEach((assignment) => {
12294
12399
  if (assignment.drawPosition === drawPosition) {
12295
12400
  assignment.bye = true;
12401
+ if (hasPropagatedStatus) {
12402
+ assignment.participantId = undefined;
12403
+ }
12296
12404
  }
12297
12405
  });
12298
12406
  if (structure.structureType === CONTAINER) {
@@ -12406,6 +12514,8 @@ function assignRoundRobinBYE({ tournamentRecord, drawDefinition, drawPosition, m
12406
12514
  });
12407
12515
  }
12408
12516
  function advanceDrawPosition({ drawPositionToAdvance, inContextDrawMatchUps, sourceDrawPositions, tournamentRecord, drawDefinition, matchUpsMap, matchUpId, event, }) {
12517
+ const stack = 'advanceDrawPosition';
12518
+ pushGlobalLog({ method: stack, color: 'cyan', drawPositionToAdvance });
12409
12519
  const matchUp = matchUpsMap.drawMatchUps.find((matchUp) => matchUp.matchUpId === matchUpId);
12410
12520
  const inContextMatchUp = inContextDrawMatchUps.find((matchUp) => matchUp.matchUpId === matchUpId);
12411
12521
  const structureId = inContextMatchUp?.structureId;
@@ -12518,6 +12628,14 @@ function advanceWinner({ drawPositionToAdvance, inContextDrawMatchUps, sourceDra
12518
12628
  winningSide: undefined,
12519
12629
  drawPositions,
12520
12630
  });
12631
+ const changedDrawPosition = noContextWinnerMatchUp.drawPositions.find((position) => !twoDrawPositions.includes(position));
12632
+ pushGlobalLog({
12633
+ method: stack,
12634
+ color: 'brightyellow',
12635
+ changedDrawPosition,
12636
+ pairedDrawPositionIsBye,
12637
+ drawPositionIsBye,
12638
+ });
12521
12639
  modifyMatchUpNotice({
12522
12640
  tournamentId: tournamentRecord?.tournamentId,
12523
12641
  matchUp: noContextWinnerMatchUp,
@@ -12572,6 +12690,8 @@ function advanceWinner({ drawPositionToAdvance, inContextDrawMatchUps, sourceDra
12572
12690
  }
12573
12691
  function assignFedDrawPositionBye({ loserTargetDrawPosition, tournamentRecord, loserTargetLink, drawDefinition, loserMatchUp, matchUpsMap, event, }) {
12574
12692
  const { roundNumber } = loserMatchUp;
12693
+ const stack = 'assignFedDrawPositionBye';
12694
+ pushGlobalLog({ method: stack, color: 'cyan', loserTargetDrawPosition });
12575
12695
  const mappedMatchUps = matchUpsMap?.mappedMatchUps || {};
12576
12696
  const loserStructureMatchUps = mappedMatchUps[loserMatchUp.structureId].matchUps;
12577
12697
  const { initialRoundNumber } = getInitialRoundNumber({
@@ -12615,65 +12735,6 @@ function modifyRoundRobinMatchUpsStatus({ positionAssignments, tournamentRecord,
12615
12735
  });
12616
12736
  }
12617
12737
 
12618
- const logColors = {
12619
- reset: '\x1b[0m',
12620
- bright: '\x1b[1m',
12621
- dim: '\x1b[2m',
12622
- red: '\x1b[31m',
12623
- brightred: '\x1b[91m',
12624
- green: '\x1b[32m',
12625
- brightgreen: '\x1b[92m',
12626
- yellow: '\x1b[33m',
12627
- brightyellow: '\x1b[93m',
12628
- blue: '\x1b[34m',
12629
- brightblue: '\x1b[94m',
12630
- pinkbackground: '\x1b[105m',
12631
- magenta: '\x1b[35m',
12632
- brightmagenta: '\x1b[95m',
12633
- cyan: '\x1b[36m',
12634
- brightcyan: '\x1b[96m',
12635
- white: '\x1b[37m',
12636
- brightwhite: '\x1b[97m',
12637
- };
12638
-
12639
- const globalLog = [];
12640
- function pushGlobalLog(value, devContextOverride) {
12641
- if (isString(value))
12642
- value = { method: value };
12643
- if (devContextOverride || getDevContext())
12644
- globalLog.push(value);
12645
- }
12646
- function getGlobalLog(purge) {
12647
- const globalLogCopy = globalLog.slice();
12648
- return globalLogCopy;
12649
- }
12650
- function printGlobalLog(purge) {
12651
- const globalLogCopy = getGlobalLog();
12652
- const modifiedText = globalLogCopy.map((line) => {
12653
- const { color, keyColors, method, newline } = line;
12654
- const methodColor = Object.keys(logColors).includes(color) ? logColors[color] : logColors.cyan;
12655
- const bodyKeys = Object.keys(line).filter((key) => !['color', 'keyColors', 'method', 'newline'].includes(key));
12656
- const body = bodyKeys
12657
- .map((key) => {
12658
- const keyColor = (line[key] === undefined && logColors.red) ||
12659
- (keyColors &&
12660
- Object.keys(keyColors).includes(key) &&
12661
- logColors[keyColors[key]] &&
12662
- logColors[keyColors[key]]) ||
12663
- logColors.brightwhite;
12664
- return `${logColors.white}${key}: ${keyColor}${line[key]}`;
12665
- })
12666
- .join(', ');
12667
- const tabs = (method?.length <= 12 && '\t\t\t') || (method?.length <= 20 && `\t\t`) || '\t';
12668
- return [newline ? '\n' : '', methodColor, method, tabs, logColors.white, body, logColors.reset, '\n'].join('');
12669
- });
12670
- if (modifiedText?.length)
12671
- console.log(...modifiedText);
12672
- }
12673
- function purgeGlobalLog() {
12674
- globalLog.length = 0;
12675
- }
12676
-
12677
12738
  function clearDrawPosition(params) {
12678
12739
  let { inContextDrawMatchUps, participantId, drawPosition } = params;
12679
12740
  const { tournamentRecord, drawDefinition, structureId, matchUpsMap, event } = params;
@@ -14974,21 +15035,32 @@ function addEventEntries(params) {
14974
15035
  if (validSingles &&
14975
15036
  (!event.gender ||
14976
15037
  !genderEnforced ||
14977
- [MIXED, ANY].includes(event.gender) ||
14978
- event.gender === participant.person?.sex)) {
15038
+ isMixed(event.gender) ||
15039
+ isAny(event.gender) ||
15040
+ coercedGender(event.gender) === coercedGender(participant.person?.sex))) {
14979
15041
  return true;
14980
15042
  }
14981
15043
  if (validDoubles && !isUngrouped(entryStatus)) {
14982
15044
  return true;
14983
15045
  }
14984
15046
  if (event.eventType === DOUBLES$1 && participant.participantType === INDIVIDUAL && isUngrouped(entryStatus)) {
15047
+ if (event.gender &&
15048
+ genderEnforced &&
15049
+ !(isMixed(event.gender) || isAny(event.gender)) &&
15050
+ coercedGender(event.gender) !== coercedGender(participant.person?.sex)) {
15051
+ mismatchedGender.push({
15052
+ participantId: participant.participantId,
15053
+ sex: participant.person?.sex,
15054
+ });
15055
+ return false;
15056
+ }
14985
15057
  return true;
14986
15058
  }
14987
15059
  if (validSingles &&
14988
15060
  event.gender &&
14989
15061
  genderEnforced &&
14990
- ![MIXED, ANY].includes(event.gender) &&
14991
- event.gender !== participant.person?.sex) {
15062
+ !(isMixed(event.gender) || isAny(event.gender)) &&
15063
+ coercedGender(event.gender) !== coercedGender(participant.person?.sex)) {
14992
15064
  mismatchedGender.push({
14993
15065
  participantId: participant.participantId,
14994
15066
  sex: participant.person?.sex,
@@ -23200,7 +23272,7 @@ function modifyMatchUpScore(params) {
23200
23272
  }
23201
23273
 
23202
23274
  function attemptToModifyScore(params) {
23203
- const { matchUpStatusCodes, matchUpStatus, structure, matchUp, dualMatchUp, inContextMatchUp, autoCalcDisabled, propagateExitStatus, } = params;
23275
+ const { propagateExitStatus, matchUpStatusCodes, autoCalcDisabled, inContextMatchUp, matchUpStatus, dualMatchUp, structure, matchUp, } = params;
23204
23276
  const matchUpStatusIsValid = isDirectingMatchUpStatus({ matchUpStatus }) ||
23205
23277
  ([CANCELLED$1, ABANDONED$1].includes(matchUpStatus) && dualMatchUp) ||
23206
23278
  autoCalcDisabled;
@@ -23935,7 +24007,7 @@ function directLoser(params) {
23935
24007
  }
23936
24008
  }
23937
24009
  }
23938
- return { ...SUCCESS, stack, context };
24010
+ return decorateResult({ result: { ...SUCCESS }, stack, context });
23939
24011
  function loserLinkFedFMLC() {
23940
24012
  const stack = 'loserLinkFedFMLC';
23941
24013
  if (validForConsolation) {
@@ -25632,7 +25704,7 @@ function getValidModifyAssignedPairAction({ tournamentParticipants, returnPartic
25632
25704
  }
25633
25705
 
25634
25706
  function isActiveDownstream(params) {
25635
- const { inContextDrawMatchUps, targetData, drawDefinition, relevantLink, matchUpStatus, score, winningSide } = params;
25707
+ const { inContextDrawMatchUps, targetData, drawDefinition, relevantLink, matchUpStatus, score, winningSide, matchUpsMap } = params;
25636
25708
  const fmlcBYE = relevantLink?.linkCondition === FIRST_MATCHUP && targetData?.matchUp?.matchUpStatus === BYE;
25637
25709
  if (fmlcBYE)
25638
25710
  return false;
@@ -25647,15 +25719,15 @@ function isActiveDownstream(params) {
25647
25719
  const loserIndex = loserTargetData?.targetMatchUps?.loserMatchUpDrawPositionIndex;
25648
25720
  const propagatedLoserParticipant = loserExitPropagation?.sides[loserIndex]?.participant;
25649
25721
  const loserMatchUpExit = [DEFAULTED, WALKOVER$2].includes(loserMatchUp?.matchUpStatus) && !propagatedLoserParticipant;
25722
+ const isLoserMatchUpWO = [DEFAULTED, WALKOVER$2].includes(loserMatchUp?.matchUpStatus);
25723
+ const hasLoserMatchUpUpstreamWOMatches = !!matchUpsMap?.drawMatchUps.find((m) => m.loserMatchUpId === loserMatchUp?.matchUpId && [DEFAULTED, WALKOVER$2, WITHDRAWN].includes(m.matchUpStatus));
25650
25724
  const loserMatchUpParticipantsCount = loserMatchUp?.sides?.reduce((acc, current) => (current?.participant ? ++acc : acc), 0) ?? 0;
25651
- const isLoserMatchUpAPropagatedExitStatus = loserMatchUp?.winningSide &&
25652
- [DEFAULTED, WALKOVER$2].includes(loserMatchUp?.matchUpStatus) &&
25653
- propagatedLoserParticipant &&
25654
- loserMatchUpParticipantsCount === 1;
25725
+ const isLoserMatchUpWalkoverWithOnePlayer = loserMatchUp?.winningSide && isLoserMatchUpWO && loserMatchUpParticipantsCount === 1;
25655
25726
  const isClearScore = matchUpStatus === TO_BE_PLAYED && score?.scoreStringSide1 === '' && score?.scoreStringSide2 === '' && !winningSide;
25656
25727
  const winnerDrawPositionsCount = winnerMatchUp?.drawPositions?.filter(Boolean).length || 0;
25657
- if ((isLoserMatchUpAPropagatedExitStatus && isClearScore) ||
25658
- (!isLoserMatchUpAPropagatedExitStatus &&
25728
+ if ((hasLoserMatchUpUpstreamWOMatches && loserMatchUp?.matchUpStatus === DOUBLE_WALKOVER && isClearScore) ||
25729
+ (hasLoserMatchUpUpstreamWOMatches && isLoserMatchUpWO && isClearScore) ||
25730
+ (!isLoserMatchUpWalkoverWithOnePlayer &&
25659
25731
  ((loserMatchUp?.winningSide && !loserMatchUpExit) ||
25660
25732
  (winnerMatchUp?.winningSide &&
25661
25733
  winnerDrawPositionsCount === 2 &&
@@ -25803,7 +25875,7 @@ const matchUpActionConstants = {
25803
25875
  function collectionMatchUpActions({ specifiedPolicyDefinitions, inContextDrawMatchUps, matchUpParticipantIds, matchUpActionsPolicy, inContextMatchUp, policyActions, enforceGender, participantId, sideNumber, matchUpId, matchUp, drawId, side, }) {
25804
25876
  const validActions = [];
25805
25877
  const firstFoundSide = inContextMatchUp.sides?.find((side) => side.participant);
25806
- const assignedGender = inContextMatchUp.gender === MIXED &&
25878
+ const assignedGender = isMixed(inContextMatchUp.gender) &&
25807
25879
  inContextMatchUp.sideNumber &&
25808
25880
  inContextMatchUp.sides?.filter((side) => side.particiapntId).length === 1 &&
25809
25881
  firstFoundSide?.participant?.person?.sex;
@@ -25822,9 +25894,9 @@ function collectionMatchUpActions({ specifiedPolicyDefinitions, inContextDrawMat
25822
25894
  const inContextDualMatchUp = inContextDrawMatchUps?.find((drawMatchUp) => drawMatchUp.matchUpId === inContextMatchUp.matchUpTieId);
25823
25895
  const availableIndividualParticipants = inContextDualMatchUp?.sides?.map((side) => side?.participant?.individualParticipants?.filter(({ participantId, person }) => !existingParticipantIds?.includes(participantId) &&
25824
25896
  (!gender ||
25825
- gender === ANY ||
25897
+ isAny(gender) ||
25826
25898
  person.sex === gender ||
25827
- (gender === MIXED && !assignedGender) ||
25899
+ (isMixed(gender) && !assignedGender) ||
25828
25900
  (assignedGender && person.sex !== assignedGender))));
25829
25901
  const availableParticipants = sideNumber
25830
25902
  ? availableIndividualParticipants?.[sideNumber - 1]
@@ -27219,15 +27291,16 @@ function getValidGender(params) {
27219
27291
  [];
27220
27292
  const validPairGender = !eventGender ||
27221
27293
  !pairGender?.length ||
27222
- ANY === eventGender ||
27223
- ([MALE, FEMALE].includes(eventGender) && pairGender[0] === eventGender) ||
27224
- (MIXED === eventGender &&
27294
+ isAny(eventGender) ||
27295
+ (isGendered(eventGender) && coercedGender(pairGender[0]) === coercedGender(eventGender)) ||
27296
+ (isMixed(eventGender) &&
27225
27297
  ((pairGender.length === 1 && participant.individualParticipantIds?.length === 1) || pairGender.length === 2));
27226
27298
  const personGender = participant?.person?.sex;
27227
27299
  const validPersonGender = !participant?.person ||
27228
27300
  !eventGender ||
27229
- [ANY, MIXED].includes(eventGender) ||
27230
- ([MALE, FEMALE].includes(eventGender) && personGender === eventGender);
27301
+ isMixed(eventGender) ||
27302
+ isAny(eventGender) ||
27303
+ (isGendered(eventGender) && coercedGender(personGender) === coercedGender(eventGender));
27231
27304
  return !genderEnforced || (validPairGender && validPersonGender);
27232
27305
  }
27233
27306
 
@@ -39055,16 +39128,16 @@ function addEventEntryPairs(params) {
39055
39128
  const invalidParticipantIdPairs = participantIdPairs.filter((pair) => {
39056
39129
  if (pair.length !== 2)
39057
39130
  return true;
39058
- if (!event.gender || event.gender === ANY)
39131
+ if (!event.gender || isAny(event.gender))
39059
39132
  return false;
39060
39133
  if (!genderMap.has(pair[0]) || !genderMap.has(pair[1]))
39061
39134
  return true;
39062
39135
  const participantGenders = pair.map((id) => genderMap.get(id));
39063
- let invalidParticiapntGenders = (event.gender === MALE && (participantGenders[0] !== MALE || participantGenders[1] !== MALE)) ||
39064
- (event.gender === FEMALE && (participantGenders[0] !== FEMALE || participantGenders[1] !== FEMALE));
39065
- if (event.gender === MIXED) {
39136
+ let invalidParticiapntGenders = (isMale(event.gender) && (!isMale(participantGenders[0]) || !isMale(participantGenders[1]))) ||
39137
+ (isFemale(event.gender) && (!isFemale(participantGenders[0]) || !isFemale(participantGenders[1])));
39138
+ if (isMixed(event.gender)) {
39066
39139
  participantGenders.sort(stringSort);
39067
- if (participantGenders[0] !== FEMALE || participantGenders[1] !== MALE)
39140
+ if (!isFemale(participantGenders[0]) || !isMale(participantGenders[1]))
39068
39141
  invalidParticiapntGenders = true;
39069
39142
  }
39070
39143
  return invalidParticiapntGenders;
@@ -39426,8 +39499,10 @@ function generateEventsFromTieFormat(params) {
39426
39499
  for (const participant of params.tournamentRecord.participants ?? []) {
39427
39500
  if (individualParticipantIds?.includes(participant.participantId)) {
39428
39501
  const gender = participant.person?.sex;
39429
- if (gender && [MALE, FEMALE].includes(gender)) {
39430
- genderedParticipants[gender].push(participant.participantId);
39502
+ if (gender && isGendered(gender)) {
39503
+ const coerced = coercedGender(gender);
39504
+ if (coerced)
39505
+ genderedParticipants[coerced].push(participant.participantId);
39431
39506
  }
39432
39507
  }
39433
39508
  }
@@ -39447,9 +39522,9 @@ function generateEventsFromTieFormat(params) {
39447
39522
  };
39448
39523
  if (params.addEntriesFromTeams) {
39449
39524
  const entryStatus = eventType === DOUBLES_EVENT ? UNGROUPED : params.entryStatus || DIRECT_ACCEPTANCE;
39450
- const participantIds = eventGender === MIXED
39525
+ const participantIds = isMixed(eventGender)
39451
39526
  ? [...genderedParticipants[MALE], ...genderedParticipants[FEMALE]]
39452
- : (genderedParticipants[eventGender] ?? []);
39527
+ : (genderedParticipants[coercedGender(eventGender) || OTHER$3] ?? []);
39453
39528
  if (participantIds.length) {
39454
39529
  const result = addEventEntries({
39455
39530
  participantIds,
@@ -40916,9 +40991,9 @@ function getParticipantsProfile({ enteredParticipants }) {
40916
40991
  function checkGenderUpdates({ noFlightsNoDraws, enteredParticipantGenders, eventUpdates, stack }) {
40917
40992
  const validGender = !enteredParticipantGenders.length ||
40918
40993
  !eventUpdates.gender ||
40919
- eventUpdates.gender === ANY ||
40994
+ isAny(eventUpdates.gender) ||
40920
40995
  (enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender) ||
40921
- (noFlightsNoDraws && eventUpdates.gender === MIXED);
40996
+ (noFlightsNoDraws && isMixed(eventUpdates.gender));
40922
40997
  return eventUpdates.gender && !validGender
40923
40998
  ? decorateResult({
40924
40999
  context: { gender: eventUpdates.gender, validGender },
@@ -41440,7 +41515,8 @@ function generateLineUps(params) {
41440
41515
  const participantIds = [];
41441
41516
  generateRange(0, singlesMatchUp ? 1 : 2).forEach((i) => {
41442
41517
  const nextParticipantId = typeSort?.find((participant) => {
41443
- const targetGender = gender && (([MALE, FEMALE].includes(gender) && gender) || (gender === MIXED && [MALE, FEMALE][i]));
41518
+ const coerced = coercedGender(gender);
41519
+ const targetGender = coerced && ((isGendered(gender) && coerced) || (isMixed(gender) && [MALE, FEMALE][i]));
41444
41520
  return ((!targetGender || targetGender === participant.person?.sex) &&
41445
41521
  !collectionParticipantIds.includes(participant.participantId));
41446
41522
  })?.participantId;
@@ -42243,8 +42319,8 @@ function replaceTieMatchUpParticipantId(params) {
42243
42319
  const newParticipant = targetParticipants.find(({ participantId }) => participantId === newParticipantId);
42244
42320
  const genderEnforced = (params.enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
42245
42321
  if (genderEnforced &&
42246
- [MALE, FEMALE].includes(inContextTieMatchUp?.gender) &&
42247
- inContextTieMatchUp?.gender !== newParticipant?.person?.sex) {
42322
+ isGendered(inContextTieMatchUp?.gender) &&
42323
+ coercedGender(inContextTieMatchUp?.gender) !== coercedGender(newParticipant?.person?.sex)) {
42248
42324
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
42249
42325
  }
42250
42326
  const substitutionProcessCodes = matchUpActionsPolicy?.processCodes?.substitution;
@@ -42704,8 +42780,8 @@ function assignTieMatchUpParticipantId(params) {
42704
42780
  POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
42705
42781
  const genderEnforced = (params.enforceGender ?? matchUpActionsPolicy?.participants?.enforceGender) !== false;
42706
42782
  if (genderEnforced &&
42707
- [MALE, FEMALE].includes(inContextTieMatchUp?.gender) &&
42708
- inContextTieMatchUp?.gender !== participantToAssign.person?.sex) {
42783
+ isGendered(inContextTieMatchUp?.gender) &&
42784
+ coercedGender(inContextTieMatchUp?.gender) !== coercedGender(participantToAssign.person?.sex)) {
42709
42785
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
42710
42786
  }
42711
42787
  const { individualParticipantIds, participantType } = participantToAssign;
@@ -43402,6 +43478,10 @@ function removeDirectedLoser({ sourceMatchUpStatus, loserParticipantId, tourname
43402
43478
  delete assignment.participantId;
43403
43479
  }
43404
43480
  });
43481
+ if (sourceMatchUpId && sourceMatchUpStatus) {
43482
+ const targetMatchUp = matchUpsMap?.drawMatchUps?.find(({ matchUpId }) => matchUpId === loserMatchUp.matchUpId);
43483
+ targetMatchUp.matchUpStatusCodes = sourceMatchUpStatus === DOUBLE_WALKOVER ? ['WO', 'WO'] : [];
43484
+ }
43405
43485
  structure.seedAssignments = (structure.seedAssignments ?? []).filter((assignment) => assignment.participantId !== loserParticipantId);
43406
43486
  if (dualMatchUp) {
43407
43487
  const drawPositionSideIndex = loserMatchUp?.sides.reduce((sideIndex, side, i) => (side.drawPosition === relevantDrawPosition ? i : sideIndex), undefined);
@@ -43423,6 +43503,11 @@ function removeDirectedLoser({ sourceMatchUpStatus, loserParticipantId, tourname
43423
43503
  function removeDirectedBye({ inContextDrawMatchUps, tournamentRecord, drawDefinition, drawPosition, matchUpsMap, targetLink, event, }) {
43424
43504
  const structureId = targetLink.target.structureId;
43425
43505
  const stack = 'removeDirectedBye';
43506
+ pushGlobalLog({
43507
+ color: 'brightyellow',
43508
+ method: stack,
43509
+ drawPosition,
43510
+ });
43426
43511
  const result = clearDrawPosition({
43427
43512
  inContextDrawMatchUps,
43428
43513
  tournamentRecord,
@@ -43490,6 +43575,7 @@ function doubleExitAdvancement(params) {
43490
43575
  const { loserMatchUp, winnerMatchUp, loserTargetDrawPosition } = targetMatchUps;
43491
43576
  const loserMatchUpIsEmptyExit = [WALKOVER$2, DEFAULTED].includes(loserMatchUp?.matchUpStatus) &&
43492
43577
  !loserMatchUp.sides?.map((side) => side.participantId ?? side.participant).filter(Boolean).length;
43578
+ const loserMatchUpIsDoubleExit = loserMatchUp?.matchUpStatus === DOUBLE_WALKOVER;
43493
43579
  if (loserMatchUp && loserMatchUp.matchUpStatus !== BYE) {
43494
43580
  const { loserTargetLink } = targetLinks;
43495
43581
  if (appliedPolicies?.progression?.doubleExitPropagateBye ||
@@ -43499,15 +43585,17 @@ function doubleExitAdvancement(params) {
43499
43585
  tournamentRecord,
43500
43586
  loserTargetLink,
43501
43587
  drawDefinition,
43588
+ loserMatchUp,
43502
43589
  matchUpsMap,
43503
43590
  event,
43504
43591
  });
43505
43592
  if (result.error)
43506
43593
  return decorateResult({ result, stack });
43507
43594
  }
43508
- else if (!loserMatchUpIsEmptyExit) {
43595
+ else if (!loserMatchUpIsDoubleExit) {
43509
43596
  const { feedRound, drawPositions, matchUpId } = loserMatchUp;
43510
- const walkoverWinningSide = feedRound ? 2 : 2 - drawPositions.indexOf(loserTargetDrawPosition);
43597
+ let walkoverWinningSide = feedRound ? 2 : 2 - drawPositions.indexOf(loserTargetDrawPosition);
43598
+ walkoverWinningSide = loserMatchUpIsEmptyExit ? loserMatchUp.winningSide : walkoverWinningSide;
43511
43599
  const result = conditionallyAdvanceDrawPosition({
43512
43600
  ...params,
43513
43601
  targetMatchUp: loserMatchUp,
@@ -43562,6 +43650,7 @@ function conditionallyAdvanceDrawPosition(params) {
43562
43650
  const { loserTargetLink } = targetLinks;
43563
43651
  const result = advanceByeToLoserMatchUp({
43564
43652
  loserTargetDrawPosition: nextLoserTargetDrawPosition,
43653
+ loserMatchUp: nextLoserMatchUp,
43565
43654
  tournamentRecord,
43566
43655
  loserTargetLink,
43567
43656
  drawDefinition,
@@ -43757,7 +43846,7 @@ function conditionallyAdvanceDrawPosition(params) {
43757
43846
  return decorateResult({ result: { ...SUCCESS }, stack });
43758
43847
  }
43759
43848
  function advanceByeToLoserMatchUp(params) {
43760
- const { loserTargetDrawPosition, tournamentRecord, loserTargetLink, drawDefinition, matchUpsMap, event } = params;
43849
+ const { loserTargetDrawPosition, tournamentRecord, loserTargetLink, drawDefinition, matchUpsMap, event, loserMatchUp, } = params;
43761
43850
  const structureId = loserTargetLink?.target?.structureId;
43762
43851
  const { structure } = findStructure({ drawDefinition, structureId });
43763
43852
  if (!structure)
@@ -43768,6 +43857,7 @@ function advanceByeToLoserMatchUp(params) {
43768
43857
  drawDefinition,
43769
43858
  structureId,
43770
43859
  matchUpsMap,
43860
+ loserMatchUp,
43771
43861
  event,
43772
43862
  });
43773
43863
  }
@@ -44071,13 +44161,36 @@ function attemptToSetWinningSide(params) {
44071
44161
  });
44072
44162
  }
44073
44163
 
44164
+ const keyColors = {
44165
+ drawPositionToRemove: 'green',
44166
+ iteration: 'brightred',
44167
+ winner: 'green',
44168
+ loser: 'brightred',
44169
+ };
44074
44170
  function removeDoubleExit(params) {
44075
44171
  const { inContextDrawMatchUps, appliedPolicies, drawDefinition, matchUpsMap, targetData, matchUp } = params;
44172
+ const { matchUpId } = matchUp;
44076
44173
  let { iteration = 0 } = params;
44077
44174
  iteration += 1;
44078
44175
  const stack = 'removeDoubleExit';
44176
+ pushGlobalLog({
44177
+ color: 'brightyellow',
44178
+ method: stack,
44179
+ matchUpId,
44180
+ iteration,
44181
+ keyColors,
44182
+ });
44079
44183
  const { targetMatchUps: { loserMatchUp, winnerMatchUp, loserTargetDrawPosition }, targetLinks: { loserTargetLink }, } = targetData;
44080
44184
  if (winnerMatchUp && winnerMatchUp.matchUpStatus !== BYE) {
44185
+ const { stage, roundNumber, roundPosition, structureName } = winnerMatchUp;
44186
+ pushGlobalLog({
44187
+ winner: 'winner',
44188
+ roundPosition,
44189
+ structureName,
44190
+ roundNumber,
44191
+ keyColors,
44192
+ stage,
44193
+ });
44081
44194
  conditionallyRemoveDrawPosition({
44082
44195
  ...params,
44083
44196
  targetMatchUp: winnerMatchUp,
@@ -44105,6 +44218,16 @@ function removeDoubleExit(params) {
44105
44218
  drawDefinition,
44106
44219
  structureId: inContextLoserMatchUp.structureId,
44107
44220
  });
44221
+ const { stage, roundNumber, roundPosition, feedRound, structureName } = loserMatchUp;
44222
+ pushGlobalLog({
44223
+ loser: 'loser',
44224
+ roundPosition,
44225
+ structureName,
44226
+ roundNumber,
44227
+ keyColors,
44228
+ feedRound,
44229
+ stage,
44230
+ });
44108
44231
  if (appliedPolicies?.progression?.doubleExitPropagateBye || byePropagatedToLoserMatchUp) {
44109
44232
  removeDirectedBye({
44110
44233
  drawPosition: loserTargetDrawPosition,
@@ -44130,6 +44253,7 @@ function removeDoubleExit(params) {
44130
44253
  function conditionallyRemoveDrawPosition(params) {
44131
44254
  const { inContextDrawMatchUps, appliedPolicies, drawDefinition, sourceMatchUp, targetMatchUp, matchUpsMap, structure, iteration, } = params;
44132
44255
  const stack = 'conditionallyRemoveDrawPosition';
44256
+ pushGlobalLog({ method: stack, structureName: structure?.structureName, iteration });
44133
44257
  const nextTargetData = positionTargets({
44134
44258
  matchUpId: targetMatchUp.matchUpId,
44135
44259
  inContextDrawMatchUps,
@@ -44169,6 +44293,17 @@ function conditionallyRemoveDrawPosition(params) {
44169
44293
  }
44170
44294
  }
44171
44295
  if (nextWinnerMatchUp && drawPositionToRemove) {
44296
+ const { stage, roundNumber, roundPosition, structureName } = nextWinnerMatchUp;
44297
+ pushGlobalLog({
44298
+ method: 'removeDirectedWinner',
44299
+ drawPositionToRemove,
44300
+ color: 'brightgreen',
44301
+ roundPosition,
44302
+ structureName,
44303
+ roundNumber,
44304
+ keyColors,
44305
+ stage,
44306
+ });
44172
44307
  removeDirectedWinner({
44173
44308
  winningDrawPosition: drawPositionToRemove,
44174
44309
  winnerMatchUp: nextWinnerMatchUp,
@@ -45155,7 +45290,7 @@ function swapWinnerLoser(params) {
45155
45290
  }
45156
45291
 
45157
45292
  function setMatchUpState(params) {
45158
- const stack = 'setMatchUpState';
45293
+ const stack = 'setMatchUpStatus';
45159
45294
  if (params.matchUpStatus && [WALKOVER$2, DOUBLE_WALKOVER].includes(params.matchUpStatus))
45160
45295
  params.score = undefined;
45161
45296
  const { allowChangePropagation, disableScoreValidation, propagateExitStatus, tournamentRecords, tournamentRecord, disableAutoCalc, enableAutoCalc, drawDefinition, matchUpStatus, winningSide, matchUpId, event, score, } = params;
@@ -45401,6 +45536,12 @@ function setMatchUpState(params) {
45401
45536
  return swapWinnerLoser(params);
45402
45537
  }
45403
45538
  const matchUpWinner = (winningSide && !matchUpTieId) || params.projectedWinningSide;
45539
+ pushGlobalLog({
45540
+ activeDownstream,
45541
+ matchUpWinner,
45542
+ method: stack,
45543
+ winningSide,
45544
+ });
45404
45545
  const result = (!activeDownstream && noDownstreamDependencies(params)) ||
45405
45546
  (matchUpWinner && winningSideWithDownstreamDependencies(params)) ||
45406
45547
  ((directingMatchUpStatus || params.autoCalcDisabled) && applyMatchUpValues(params)) || {
@@ -45481,7 +45622,7 @@ function checkParticipants({ assignedDrawPositions, propagateExitStatus, inConte
45481
45622
  if (matchUpStatus && particicipantsRequiredMatchUpStatuses.includes(matchUpStatus) && !requiredParticipants) {
45482
45623
  return decorateResult({
45483
45624
  info: 'matchUpStatus requires assigned participants',
45484
- context: { matchUpStatus, requiredParticipants, propagateExitStatus: propagateExitStatus, participantsCount },
45625
+ context: { matchUpStatus, requiredParticipants },
45485
45626
  result: { error: INVALID_MATCHUP_STATUS },
45486
45627
  });
45487
45628
  }
@@ -45785,6 +45926,12 @@ function matchUpScore(params) {
45785
45926
 
45786
45927
  function progressExitStatus({ sourceMatchUpStatusCodes, propagateExitStatus, sourceMatchUpStatus, loserParticipantId, tournamentRecord, drawDefinition, loserMatchUp, matchUpsMap, event, }) {
45787
45928
  const stack = 'progressExitStatus';
45929
+ pushGlobalLog({
45930
+ matchUpId: loserMatchUp?.matchUpId,
45931
+ matchUpStatus: sourceMatchUpStatus,
45932
+ color: 'magenta',
45933
+ method: stack,
45934
+ });
45788
45935
  const carryOverMatchUpStatus = ([WALKOVER$2, DEFAULTED].includes(sourceMatchUpStatus) && sourceMatchUpStatus) || WALKOVER$2;
45789
45936
  const inContextMatchUps = getAllDrawMatchUps({
45790
45937
  inContext: true,
@@ -45795,7 +45942,7 @@ function progressExitStatus({ sourceMatchUpStatusCodes, propagateExitStatus, sou
45795
45942
  const updatedLoserMatchUp = inContextMatchUps?.find((m) => m.matchUpId === loserMatchUp?.matchUpId);
45796
45943
  if (updatedLoserMatchUp?.matchUpId && loserMatchUpStatus) {
45797
45944
  let winningSide = undefined;
45798
- const statusCodes = updatedLoserMatchUp.matchUpStatusCodes?.map((sc) => (typeof sc === 'string' ? sc : 'WO')) ?? [];
45945
+ const statusCodes = updatedLoserMatchUp.matchUpStatusCodes?.map((sc) => (typeof sc === 'string' ? sc : OUTCOME_WALKOVER)) ?? [];
45799
45946
  const loserParticipantSide = updatedLoserMatchUp.sides?.find((s) => s.participantId === loserParticipantId);
45800
45947
  if (loserParticipantSide?.sideNumber) {
45801
45948
  const participantsCount = updatedLoserMatchUp?.sides?.reduce((count, current) => {
@@ -45852,7 +45999,7 @@ function setMatchUpStatus(params) {
45852
45999
  tournamentRecord,
45853
46000
  });
45854
46001
  if (result.error)
45855
- return decorateResult({ stack, result });
46002
+ return result;
45856
46003
  if (result.drawDefinition)
45857
46004
  params.drawDefinition = result.drawDefinition;
45858
46005
  params.event = result.event;
@@ -45869,7 +46016,7 @@ function setMatchUpStatus(params) {
45869
46016
  undefined;
45870
46017
  const { outcome, setTBlast } = params;
45871
46018
  if (outcome?.winningSide && ![1, 2].includes(outcome.winningSide)) {
45872
- return decorateResult({ result: { error: INVALID_WINNING_SIDE }, stack });
46019
+ return { error: INVALID_WINNING_SIDE };
45873
46020
  }
45874
46021
  if (matchUpFormat) {
45875
46022
  const result = setMatchUpMatchUpFormat({
@@ -45880,7 +46027,7 @@ function setMatchUpStatus(params) {
45880
46027
  event,
45881
46028
  });
45882
46029
  if (result.error)
45883
- return decorateResult({ stack, result });
46030
+ return result;
45884
46031
  }
45885
46032
  if (outcome?.score?.sets && !outcome.score.scoreStringSide1) {
45886
46033
  const { score: scoreObject } = matchUpScore({ ...outcome, setTBlast });
@@ -48924,7 +49071,7 @@ var namesData$1 = {
48924
49071
 
48925
49072
  function generatePersonData(params) {
48926
49073
  const { count = 100, sex } = params || {};
48927
- if (!count || (sex && ![MALE, FEMALE].includes(sex)))
49074
+ if (!count || (sex && !isGendered(sex)))
48928
49075
  return { personData: [], error: INVALID_VALUES };
48929
49076
  const buffer = Math.ceil(count * 1.3);
48930
49077
  const { lastNames, firstFemale, firstMale } = namesData$1;
@@ -48966,8 +49113,8 @@ function generatePersons(params) {
48966
49113
  const { personExtensions, consideredDate, isMock = true, gendersCount, personData, category, sex } = params || {};
48967
49114
  if (isNaN(count))
48968
49115
  return { error: INVALID_VALUES };
48969
- const maleCount = gendersCount?.[MALE] || (sex === MALE && count) || 0;
48970
- const femaleCount = gendersCount?.[FEMALE] || (sex === FEMALE && count) || 0;
49116
+ const maleCount = gendersCount?.[MALE] || (isMale(sex) && count) || 0;
49117
+ const femaleCount = gendersCount?.[FEMALE] || (isFemale(sex) && count) || 0;
48971
49118
  count = Math.max(count, maleCount + femaleCount);
48972
49119
  const defaultCount = count - (maleCount + femaleCount);
48973
49120
  const defaultMalePersonData = (maleCount &&
@@ -49450,12 +49597,13 @@ function processTieFormat(params) {
49450
49597
  const tieFormat = isObject(params.tieFormat) ? params.tieFormat : tieFormatDefaults({ namedFormat: tieFormatName });
49451
49598
  tieFormat?.collectionDefinitions?.filter(Boolean).forEach((collectionDefinition) => {
49452
49599
  const { category, collectionId, matchUpType, matchUpCount, gender } = collectionDefinition;
49453
- if ([MALE, FEMALE].includes(gender)) {
49600
+ if (isGendered(gender)) {
49601
+ const coerced = coercedGender(gender);
49454
49602
  const required = matchUpCount * (matchUpType === DOUBLES$1 ? 2 : 1);
49455
- if (genders[gender] < required)
49456
- genders[gender] = required;
49603
+ if (coerced && genders[coerced] < required)
49604
+ genders[coerced] = required;
49457
49605
  }
49458
- else if (gender === MIXED) {
49606
+ else if (isMixed(gender)) {
49459
49607
  if (genders[MALE] < matchUpCount)
49460
49608
  genders[MALE] = matchUpCount;
49461
49609
  if (genders[FEMALE] < matchUpCount)
@@ -50254,7 +50402,7 @@ function generateEventParticipants(params) {
50254
50402
  const participantsCount = eventProfile.drawProfiles?.length
50255
50403
  ? mainParticipantsCount + qualifyingParticipantsCount
50256
50404
  : (eventProfile.participantsProfile?.participantsCount ?? 0);
50257
- const sex = [MALE, FEMALE].includes(gender) ? gender : undefined;
50405
+ const sex = isGendered(gender) ? gender : undefined;
50258
50406
  const idPrefix = participantsProfile?.idPrefix ? `E-${eventIndex}-${participantsProfile?.idPrefix}` : undefined;
50259
50407
  const { participants: uniqueFlightParticipants } = generateParticipants({
50260
50408
  uuids: eventProfile.uuids || uuids,
@@ -50653,8 +50801,9 @@ function generateEventWithDraw(params) {
50653
50801
  drawSize,
50654
50802
  }));
50655
50803
  Object.keys(genders).forEach((key) => {
50656
- if ([MALE, FEMALE].includes(key) && genders[key]) {
50657
- gendersCount[key] = drawSize * genders[key];
50804
+ const coerced = coercedGender(key);
50805
+ if (coerced && isGendered(key) && genders[coerced]) {
50806
+ gendersCount[coerced] = drawSize * genders[coerced];
50658
50807
  }
50659
50808
  });
50660
50809
  individualParticipantCount = teamSize * ((drawSize || 0) + qualifyingParticipantsCount);
@@ -50695,7 +50844,7 @@ function generateEventWithDraw(params) {
50695
50844
  : [];
50696
50845
  const femaleIndividualParticipantIds = genders[FEMALE]
50697
50846
  ? unique
50698
- .filter(({ participantType, person }) => participantType === INDIVIDUAL && person?.sex === FEMALE)
50847
+ .filter(({ participantType, person }) => participantType === INDIVIDUAL && isFemale(person?.sex))
50699
50848
  .map(getParticipantId)
50700
50849
  : [];
50701
50850
  const remainingParticipantIds = unique
@@ -51729,8 +51878,9 @@ function anonymizeTournamentRecord({ keepExtensions = [], anonymizeParticipantNa
51729
51878
  const individualParticipants = (tournamentRecord.participants || []).filter(({ participantType }) => participantType === INDIVIDUAL);
51730
51879
  const gendersCount = individualParticipants.reduce((counts, participant) => {
51731
51880
  const gender = participant.person?.sex;
51732
- if ([MALE, FEMALE].includes(gender)) {
51733
- counts[gender] += 1;
51881
+ const coerced = coercedGender(gender);
51882
+ if (coerced && isGendered(gender)) {
51883
+ counts[coerced] += 1;
51734
51884
  }
51735
51885
  else {
51736
51886
  counts[OTHER$3] += 1;