tods-competition-factory 2.1.17 → 2.1.19

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.1.17';
6
+ return '2.1.19';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -24779,12 +24779,19 @@ function deleteAdHocMatchUps(params) {
24779
24779
  .flatMap((matchUp) => (matchUp.sides ?? []).map((side) => side.participantId))
24780
24780
  .filter(Boolean)).map((participantId) => ({ participantId }));
24781
24781
  const matchUpFormat = structure?.matchUpFormat ?? drawDefinition?.matchUpFormat ?? event?.matchUpFormat;
24782
+ const isDualMatchUp = structureResult.existingMatchUps.some((matchUp) => matchUp.matchUpType === TEAM_MATCHUP);
24783
+ const matchUpFilters = isDualMatchUp ? { matchUpTypes: [TEAM_MATCHUP] } : undefined;
24782
24784
  const { matchUps } = getAllStructureMatchUps({
24783
24785
  afterRecoveryTimes: false,
24784
24786
  inContext: true,
24787
+ matchUpFilters,
24785
24788
  structure,
24786
24789
  event,
24787
24790
  });
24791
+ const isAdHocStructure = isAdHoc({ structure });
24792
+ if (isAdHocStructure) {
24793
+ structure.positionAssignments = unique(matchUps.flatMap((matchUp) => (matchUp.sides ?? []).map((side) => side.participantId)).filter(Boolean)).map((participantId) => ({ participantId }));
24794
+ }
24788
24795
  const result = updateAssignmentParticipantResults({
24789
24796
  positionAssignments: structure.positionAssignments,
24790
24797
  tournamentRecord,
@@ -34818,9 +34825,8 @@ function getDrawData(params) {
34818
34825
  if (structure.stage && [MAIN, CONSOLATION, PLAY_OFF].includes(structure.stage)) {
34819
34826
  seedAssignments = mainStageSeedAssignments;
34820
34827
  }
34821
- if (structure?.stage === QUALIFYING) {
34828
+ if (structure?.stage === QUALIFYING)
34822
34829
  seedAssignments = qualificationStageSeedAssignments;
34823
- }
34824
34830
  const { matchUps, roundMatchUps, roundProfile } = getAllStructureMatchUps({
34825
34831
  seedAssignments: !structure?.seedAssignments?.length ? seedAssignments : undefined,
34826
34832
  context: { drawId: drawInfo.drawId, ...context },
@@ -34834,9 +34840,7 @@ function getDrawData(params) {
34834
34840
  structure,
34835
34841
  event,
34836
34842
  });
34837
- const { positionAssignments } = getPositionAssignments$1({
34838
- structure,
34839
- });
34843
+ const { positionAssignments } = getPositionAssignments$1({ structure });
34840
34844
  let participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
34841
34845
  const participantResult = findExtension({ element: assignment, name: TALLY })?.extension?.value;
34842
34846
  const { drawPosition, participantId } = assignment;
@@ -34851,12 +34855,16 @@ function getDrawData(params) {
34851
34855
  ((!participantResults?.length && params.allParticipantResults) ||
34852
34856
  (refreshResults && !structure.structures))) {
34853
34857
  const { subOrderMap } = createSubOrderMap({ positionAssignments });
34858
+ const hasTeamMatchUps = matchUps.some((matchUp) => matchUp.matchUpType === TEAM_MATCHUP);
34859
+ const consideredMatchUps = hasTeamMatchUps
34860
+ ? matchUps.filter((matchUp) => matchUp.matchUpType === TEAM_MATCHUP)
34861
+ : matchUps;
34854
34862
  const result = tallyParticipantResults({
34855
34863
  matchUpFormat: structure.matchUpFormat,
34864
+ matchUps: consideredMatchUps,
34856
34865
  policyDefinitions,
34857
34866
  pressureRating,
34858
34867
  subOrderMap,
34859
- matchUps,
34860
34868
  });
34861
34869
  participantResults = positionAssignments?.filter(xa(PARTICIPANT_ID)).map((assignment) => {
34862
34870
  const { drawPosition, participantId } = assignment;
@@ -40446,7 +40454,9 @@ function modifyEvent(params) {
40446
40454
  const enteredParticipants = getEnteredParticipants(params);
40447
40455
  const participantsProfile = getParticipantsProfile({ enteredParticipants });
40448
40456
  const { enteredParticipantGenders, enteredParticipantTypes } = participantsProfile;
40449
- const genderResult = checkGenderUpdates({ enteredParticipantGenders, eventUpdates, stack });
40457
+ const flights = getFlightProfile({ event })?.flightProfile?.flights;
40458
+ const noFlightsNoDraws = !event.drawDefinitions?.length && !flights?.length;
40459
+ const genderResult = checkGenderUpdates({ noFlightsNoDraws, enteredParticipantGenders, eventUpdates, stack });
40450
40460
  if (genderResult.error)
40451
40461
  return genderResult;
40452
40462
  const eventTypeResult = checkEventType({ enteredParticipantTypes, eventUpdates, stack });
@@ -40561,10 +40571,12 @@ function getParticipantsProfile({ enteredParticipants }) {
40561
40571
  const enteredParticipantGenders = unique(genderAccumulator);
40562
40572
  return { enteredParticipantTypes, enteredParticipantGenders };
40563
40573
  }
40564
- function checkGenderUpdates({ enteredParticipantGenders, eventUpdates, stack }) {
40574
+ function checkGenderUpdates({ noFlightsNoDraws, enteredParticipantGenders, eventUpdates, stack }) {
40565
40575
  const validGender = !enteredParticipantGenders.length ||
40566
- [MIXED, ANY].includes(eventUpdates.gender ?? '') ||
40567
- (enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender);
40576
+ !eventUpdates.gender ||
40577
+ eventUpdates.gender === ANY ||
40578
+ (enteredParticipantGenders.length === 1 && enteredParticipantGenders[0] === eventUpdates.gender) ||
40579
+ (noFlightsNoDraws && eventUpdates.gender === MIXED);
40568
40580
  return eventUpdates.gender && !validGender
40569
40581
  ? decorateResult({
40570
40582
  context: { gender: eventUpdates.gender, validGender },
@@ -45029,18 +45041,20 @@ function setMatchUpState(params) {
45029
45041
  });
45030
45042
  const existingDualMatchUpWinningSide = dualMatchUp.winningSide;
45031
45043
  dualWinningSideChange = projectedWinningSide !== existingDualMatchUpWinningSide;
45044
+ const autoCalcDisabled = dualMatchUp._disableAutoCalc;
45032
45045
  Object.assign(params, {
45033
45046
  isCollectionMatchUp: true,
45034
45047
  dualWinningSideChange,
45035
45048
  projectedWinningSide,
45049
+ autoCalcDisabled,
45036
45050
  matchUpTieId,
45037
45051
  dualMatchUp,
45038
45052
  tieFormat,
45039
45053
  });
45040
45054
  }
45041
45055
  }
45042
- const activeDownstream = isActiveDownstream(params);
45043
45056
  const directingMatchUpStatus = isDirectingMatchUpStatus({ matchUpStatus });
45057
+ const activeDownstream = isActiveDownstream(params);
45044
45058
  if (!matchUpTieId) {
45045
45059
  if (activeDownstream &&
45046
45060
  !winningSide &&
@@ -45088,7 +45102,7 @@ function setMatchUpState(params) {
45088
45102
  method: stack,
45089
45103
  winningSide,
45090
45104
  });
45091
- const result = (!activeDownstream && noDownstreamDependencies(params)) ||
45105
+ const result = ((!activeDownstream || params.autoCalcDisabled) && noDownstreamDependencies(params)) ||
45092
45106
  (matchUpWinner && winningSideWithDownstreamDependencies(params)) ||
45093
45107
  (directingMatchUpStatus && applyMatchUpValues(params)) || {
45094
45108
  error: NO_VALID_ACTIONS,