tods-competition-factory 1.8.30 → 1.8.32

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/index.mjs CHANGED
@@ -2404,7 +2404,7 @@ const matchUpFormatCode = {
2404
2404
  };
2405
2405
 
2406
2406
  function factoryVersion() {
2407
- return "1.8.30";
2407
+ return "1.8.32";
2408
2408
  }
2409
2409
 
2410
2410
  function getObjectTieFormat(obj) {
@@ -9240,13 +9240,12 @@ function updateAssignmentParticipantResults({
9240
9240
 
9241
9241
  function addParticipantGroupings({
9242
9242
  participantsProfile,
9243
- participants = []
9243
+ participants = [],
9244
+ deepCopy
9245
+ // will skip deepCopy only if false
9244
9246
  }) {
9245
- const participantsWithGroupings = makeDeepCopy(
9246
- participants,
9247
- participantsProfile?.convertExtensions,
9248
- true
9249
- );
9247
+ const groupMap = /* @__PURE__ */ new Map();
9248
+ const participantsWithGroupings = deepCopy !== false ? makeDeepCopy(participants, participantsProfile?.convertExtensions, true) : participants;
9250
9249
  const teamParticipants = participantsWithGroupings.filter(
9251
9250
  (participant) => participant.participantType === TEAM
9252
9251
  );
@@ -9269,6 +9268,11 @@ function addParticipantGroupings({
9269
9268
  (individualParticipantId) => {
9270
9269
  if (individualParticipantId === participantId && !participant.teamParticipantIds?.includes(team.participantId)) {
9271
9270
  participant.teamParticipantIds.push(team.participantId);
9271
+ if (!groupMap.get(team.participantId))
9272
+ groupMap.set(team.participantId, {
9273
+ participantName: team.participantName,
9274
+ participantId: team.participantId
9275
+ });
9272
9276
  participant.teams.push({
9273
9277
  participantRoleResponsibilities: team.participantRoleResponsibilities,
9274
9278
  participantOtherName: team.participantOtherName,
@@ -9306,7 +9310,7 @@ function addParticipantGroupings({
9306
9310
  });
9307
9311
  }
9308
9312
  });
9309
- return participantsWithGroupings;
9313
+ return { participantsWithGroupings, groupInfo: Object.fromEntries(groupMap) };
9310
9314
  }
9311
9315
 
9312
9316
  const extractor = (object) => (attr) => object[attr];
@@ -10002,13 +10006,14 @@ function getDrawMatchUps(params) {
10002
10006
  event
10003
10007
  });
10004
10008
  }
10009
+ let groupInfo;
10005
10010
  if (!tournamentParticipants?.length && tournamentRecord) {
10006
10011
  tournamentParticipants = tournamentRecord?.participants;
10007
10012
  if ((inContext || participantsProfile?.withGroupings) && tournamentParticipants?.length) {
10008
- tournamentParticipants = addParticipantGroupings({
10013
+ ({ participantsWithGroupings: tournamentParticipants, groupInfo } = addParticipantGroupings({
10009
10014
  participants: tournamentParticipants,
10010
10015
  participantsProfile
10011
- });
10016
+ }));
10012
10017
  }
10013
10018
  }
10014
10019
  const { structures } = getDrawStructures({ drawDefinition });
@@ -10069,14 +10074,15 @@ function getDrawMatchUps(params) {
10069
10074
  }
10070
10075
  return matchUps;
10071
10076
  };
10072
- const matchUpGroups = {
10077
+ const drawMatchUpsResult = {
10073
10078
  abandonedMatchUps: applyFilter(allAbandonedMatchUps),
10074
10079
  completedMatchUps: applyFilter(allCompletedMatchUps),
10075
10080
  upcomingMatchUps: applyFilter(allUpcomingMatchUps),
10076
10081
  pendingMatchUps: applyFilter(allPendingMatchUps),
10077
10082
  byeMatchUps: applyFilter(allByeMatchUps),
10078
10083
  matchUpsMap,
10079
- ...SUCCESS
10084
+ ...SUCCESS,
10085
+ groupInfo
10080
10086
  };
10081
10087
  if (nextMatchUps) {
10082
10088
  const nextFilter = typeof nextMatchUps === "object" || {
@@ -10099,7 +10105,7 @@ function getDrawMatchUps(params) {
10099
10105
  drawDefinition
10100
10106
  });
10101
10107
  }
10102
- return matchUpGroups;
10108
+ return drawMatchUpsResult;
10103
10109
  }
10104
10110
 
10105
10111
  const toBePlayed = {
@@ -16068,11 +16074,13 @@ function hydrateParticipants({
16068
16074
  participants.forEach(
16069
16075
  (participant) => addNationalityCode({ participant, ...participantsProfile })
16070
16076
  );
16077
+ let groupInfo;
16071
16078
  if ((inContext || participantsProfile?.withGroupings) && participants?.length) {
16072
- participants = addParticipantGroupings({
16079
+ ({ participantsWithGroupings: participants, groupInfo } = addParticipantGroupings({
16073
16080
  participantsProfile,
16081
+ deepCopy: false,
16074
16082
  participants
16075
- });
16083
+ }));
16076
16084
  }
16077
16085
  if (participantsProfile?.withScaleValues && participants?.length) {
16078
16086
  for (const participant of participants) {
@@ -16081,7 +16089,7 @@ function hydrateParticipants({
16081
16089
  participant.ratings = ratings;
16082
16090
  }
16083
16091
  }
16084
- return { participants };
16092
+ return { participants, groupInfo };
16085
16093
  }
16086
16094
 
16087
16095
  function allTournamentMatchUps(params) {
@@ -16189,8 +16197,13 @@ function allDrawMatchUps$1(params) {
16189
16197
  surfaceCategory: event?.surfaceCategory ?? tournamentRecord?.surfaceCategory,
16190
16198
  endDate: event?.endDate
16191
16199
  };
16200
+ let groupInfo;
16192
16201
  if (!tournamentParticipants?.length && !participantMap && tournamentRecord) {
16193
- ({ participants: tournamentParticipants = [], participantMap } = hydrateParticipants({
16202
+ ({
16203
+ participants: tournamentParticipants = [],
16204
+ participantMap,
16205
+ groupInfo
16206
+ } = hydrateParticipants({
16194
16207
  participantsProfile,
16195
16208
  useParticipantMap,
16196
16209
  policyDefinitions,
@@ -16208,7 +16221,7 @@ function allDrawMatchUps$1(params) {
16208
16221
  event
16209
16222
  });
16210
16223
  }
16211
- return getAllDrawMatchUps({
16224
+ const allDrawMatchUpsResult = getAllDrawMatchUps({
16212
16225
  context: additionalContext,
16213
16226
  tournamentAppliedPolicies,
16214
16227
  scheduleVisibilityFilters,
@@ -16227,6 +16240,7 @@ function allDrawMatchUps$1(params) {
16227
16240
  inContext,
16228
16241
  event
16229
16242
  });
16243
+ return { ...allDrawMatchUpsResult, groupInfo };
16230
16244
  }
16231
16245
  function allEventMatchUps(params) {
16232
16246
  let { participants = [], contextContent, participantMap } = params;
@@ -16273,6 +16287,7 @@ function allEventMatchUps(params) {
16273
16287
  event
16274
16288
  });
16275
16289
  }
16290
+ let groupInfo;
16276
16291
  if (!participants?.length && !participantMap && tournamentRecord) {
16277
16292
  const hydratedParticipantResult = hydrateParticipants({
16278
16293
  participantsProfile,
@@ -16284,6 +16299,7 @@ function allEventMatchUps(params) {
16284
16299
  });
16285
16300
  participantMap = hydratedParticipantResult.participantMap;
16286
16301
  participants = hydratedParticipantResult.participants ?? [];
16302
+ groupInfo = hydratedParticipantResult.groupInfo;
16287
16303
  }
16288
16304
  const drawDefinitions = event.drawDefinitions ?? [];
16289
16305
  const scheduleTiming = getScheduleTiming({
@@ -16315,7 +16331,7 @@ function allEventMatchUps(params) {
16315
16331
  return matchUps2 ?? [];
16316
16332
  }
16317
16333
  );
16318
- return { matchUps };
16334
+ return { matchUps, groupInfo };
16319
16335
  }
16320
16336
  function tournamentMatchUps(params) {
16321
16337
  if (!params?.tournamentRecord)
@@ -16337,7 +16353,7 @@ function tournamentMatchUps(params) {
16337
16353
  } = params;
16338
16354
  const tournamentId = params.tournamentId ?? tournamentRecord.tournamentId;
16339
16355
  const events = tournamentRecord?.events ?? [];
16340
- const { participants, participantMap } = hydrateParticipants({
16356
+ const { participants, participantMap, groupInfo } = hydrateParticipants({
16341
16357
  participantsProfile,
16342
16358
  policyDefinitions,
16343
16359
  useParticipantMap,
@@ -16381,21 +16397,24 @@ function tournamentMatchUps(params) {
16381
16397
  event
16382
16398
  });
16383
16399
  });
16384
- return eventsDrawsMatchUps.reduce(
16400
+ const eventsDrawMatchUpsResult = eventsDrawsMatchUps.reduce(
16385
16401
  (matchUps, eventMatchUps2) => {
16386
16402
  const keys = eventMatchUps2 && Object.keys(eventMatchUps2).filter(
16387
16403
  (key) => !["success", "matchUpsMap"].includes(key)
16388
16404
  );
16389
16405
  keys?.forEach((key) => {
16390
- if (!matchUps[key])
16391
- matchUps[key] = [];
16392
- matchUps[key] = matchUps[key].concat(eventMatchUps2[key]);
16393
- matchUps.matchUpsCount += eventMatchUps2[key].length;
16406
+ if (Array.isArray(eventMatchUps2[key])) {
16407
+ if (!matchUps[key])
16408
+ matchUps[key] = [];
16409
+ matchUps[key] = matchUps[key].concat(eventMatchUps2[key]);
16410
+ matchUps.matchUpsCount += eventMatchUps2[key].length;
16411
+ }
16394
16412
  });
16395
16413
  return matchUps;
16396
16414
  },
16397
16415
  { matchUpsCount: 0 }
16398
16416
  );
16417
+ return { ...eventsDrawMatchUpsResult, groupInfo };
16399
16418
  }
16400
16419
  function eventMatchUps(params) {
16401
16420
  let {
@@ -16434,8 +16453,13 @@ function eventMatchUps(params) {
16434
16453
  surfaceCategory: event.surfaceCategory ?? tournamentRecord?.surfaceCategory
16435
16454
  })
16436
16455
  };
16456
+ let groupInfo;
16437
16457
  if (!tournamentParticipants && tournamentRecord) {
16438
- ({ participants: tournamentParticipants, participantMap } = hydrateParticipants({
16458
+ ({
16459
+ participants: tournamentParticipants,
16460
+ participantMap,
16461
+ groupInfo
16462
+ } = hydrateParticipants({
16439
16463
  participantsProfile,
16440
16464
  policyDefinitions,
16441
16465
  useParticipantMap,
@@ -16452,8 +16476,8 @@ function eventMatchUps(params) {
16452
16476
  event
16453
16477
  });
16454
16478
  const drawDefinitions = event.drawDefinitions ?? [];
16455
- return drawDefinitions.reduce((matchUps, drawDefinition) => {
16456
- const drawMatchUps2 = getDrawMatchUps({
16479
+ const eventResult = drawDefinitions.reduce((results, drawDefinition) => {
16480
+ const drawMatchUpsResult = getDrawMatchUps({
16457
16481
  context: additionalContext,
16458
16482
  tournamentAppliedPolicies,
16459
16483
  scheduleVisibilityFilters,
@@ -16472,14 +16496,17 @@ function eventMatchUps(params) {
16472
16496
  inContext,
16473
16497
  event
16474
16498
  });
16475
- const keys = Object.keys(drawMatchUps2);
16499
+ const keys = Object.keys(drawMatchUpsResult);
16476
16500
  keys?.forEach((key) => {
16477
- if (!matchUps[key])
16478
- matchUps[key] = [];
16479
- matchUps[key] = matchUps[key].concat(drawMatchUps2[key]);
16501
+ if (Array.isArray(drawMatchUpsResult[key])) {
16502
+ if (!results[key])
16503
+ results[key] = [];
16504
+ results[key] = results[key].concat(drawMatchUpsResult[key]);
16505
+ }
16480
16506
  });
16481
- return matchUps;
16507
+ return results;
16482
16508
  }, {});
16509
+ return { ...eventResult, ...SUCCESS, groupInfo };
16483
16510
  }
16484
16511
  function drawMatchUps$1({
16485
16512
  participants: tournamentParticipants,
@@ -16514,8 +16541,13 @@ function drawMatchUps$1({
16514
16541
  surfaceCategory: event?.surfaceCategory ?? tournamentRecord?.surfaceCategory
16515
16542
  })
16516
16543
  };
16544
+ let groupInfo;
16517
16545
  if (!tournamentParticipants?.length && tournamentRecord) {
16518
- ({ participants: tournamentParticipants, participantMap } = hydrateParticipants({
16546
+ ({
16547
+ participants: tournamentParticipants,
16548
+ participantMap,
16549
+ groupInfo
16550
+ } = hydrateParticipants({
16519
16551
  participantsProfile,
16520
16552
  policyDefinitions,
16521
16553
  useParticipantMap,
@@ -16532,7 +16564,7 @@ function drawMatchUps$1({
16532
16564
  drawDefinition,
16533
16565
  event
16534
16566
  });
16535
- return getDrawMatchUps({
16567
+ const drawMatchUpsResult = getDrawMatchUps({
16536
16568
  context: additionalContext,
16537
16569
  tournamentAppliedPolicies,
16538
16570
  scheduleVisibilityFilters,
@@ -16551,6 +16583,7 @@ function drawMatchUps$1({
16551
16583
  inContext,
16552
16584
  event
16553
16585
  });
16586
+ return { ...drawMatchUpsResult, groupInfo };
16554
16587
  }
16555
16588
 
16556
16589
  function addFinishingRounds({
@@ -16758,15 +16791,25 @@ function competitionMatchUps({
16758
16791
  inContext
16759
16792
  });
16760
16793
  });
16761
- return tournamentsMatchUps.reduce((groupings, matchUpGroupings) => {
16762
- const keys = Object.keys(matchUpGroupings);
16763
- keys.forEach((key) => {
16764
- if (!groupings[key])
16765
- groupings[key] = [];
16766
- groupings[key] = groupings[key].concat(matchUpGroupings[key]);
16767
- });
16768
- return groupings;
16769
- }, {});
16794
+ const groupInfo = {};
16795
+ const competitionMatchUpsResult = tournamentsMatchUps.reduce(
16796
+ (groupings, matchUpGroupings) => {
16797
+ const keys = Object.keys(matchUpGroupings);
16798
+ keys.forEach((key) => {
16799
+ if (Array.isArray(matchUpGroupings[key])) {
16800
+ if (!groupings[key])
16801
+ groupings[key] = [];
16802
+ groupings[key] = groupings[key].concat(matchUpGroupings[key]);
16803
+ }
16804
+ if (key === "groupInfo") {
16805
+ Object.assign(groupInfo, matchUpGroupings[key]);
16806
+ }
16807
+ });
16808
+ return groupings;
16809
+ },
16810
+ {}
16811
+ );
16812
+ return { ...competitionMatchUpsResult, groupInfo };
16770
16813
  }
16771
16814
 
16772
16815
  function matchUpSort(a, b) {
@@ -23819,10 +23862,89 @@ function getSeedingThresholds({
23819
23862
  return { ...SUCCESS, seedingThresholds };
23820
23863
  }
23821
23864
 
23865
+ function getDivisions({ size }) {
23866
+ const divisions = [size];
23867
+ let division = size;
23868
+ while (division / 2 === Math.floor(division / 2)) {
23869
+ division = division / 2;
23870
+ divisions.push(division);
23871
+ }
23872
+ if (!divisions.includes(1))
23873
+ divisions.push(1);
23874
+ divisions.sort(numericSort);
23875
+ divisions.reverse();
23876
+ return divisions;
23877
+ }
23878
+ function getSubBlock({ blockPattern, index }) {
23879
+ let i = 0;
23880
+ for (const subBlock of blockPattern) {
23881
+ if (i === index)
23882
+ return subBlock;
23883
+ let j = 0;
23884
+ while (j < subBlock.length) {
23885
+ if (i === index)
23886
+ return subBlock;
23887
+ i += 1;
23888
+ j++;
23889
+ }
23890
+ }
23891
+ }
23892
+ function generateBlockPattern({
23893
+ positioning,
23894
+ size
23895
+ }) {
23896
+ const divisions = getDivisions({ size });
23897
+ const divisionGroupings = [];
23898
+ const selected = [];
23899
+ const firstMember = (arr) => arr[0];
23900
+ const lastMember = (arr) => arr[arr.length - 1];
23901
+ const getMember = (arr, i) => (positioning === CLUSTER && i % 2 ? lastMember(arr) : firstMember(arr)) || firstMember(arr);
23902
+ const noneSelected = (chunk, i) => {
23903
+ if (chunk.every((member) => !selected.includes(member))) {
23904
+ const member = getMember(chunk, i);
23905
+ selected.push(member);
23906
+ return member;
23907
+ }
23908
+ };
23909
+ const notSelected = (chunk) => {
23910
+ const notSelected2 = chunk.filter((member) => !selected.includes(member));
23911
+ if (notSelected2.length) {
23912
+ selected.push(...notSelected2);
23913
+ return notSelected2;
23914
+ }
23915
+ };
23916
+ const select = (chunk, i) => {
23917
+ const member = getMember(chunk, i);
23918
+ if (!selected.includes(member)) {
23919
+ selected.push(member);
23920
+ return member;
23921
+ }
23922
+ };
23923
+ const range = generateRange(1, size + 1);
23924
+ for (const division of divisions) {
23925
+ if (division === 1) {
23926
+ const chunks = chunkArray(range, 2);
23927
+ const positions = chunks.map(noneSelected).filter(Boolean);
23928
+ if (positions.length)
23929
+ divisionGroupings.push(positions);
23930
+ const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
23931
+ if (lastPositions.length)
23932
+ divisionGroupings.push(lastPositions);
23933
+ } else {
23934
+ const chunks = chunkArray(range, division);
23935
+ const positions = chunks.map(select).filter(Boolean);
23936
+ if (positions.length)
23937
+ divisionGroupings.push(positions);
23938
+ }
23939
+ }
23940
+ return { divisions, divisionGroupings };
23941
+ }
23942
+
23822
23943
  function getValidSeedBlocks({
23823
23944
  provisionalPositioning,
23824
23945
  returnAllProxies,
23825
23946
  appliedPolicies,
23947
+ seedingProfile,
23826
23948
  drawDefinition,
23827
23949
  allPositions,
23828
23950
  structure
@@ -23856,7 +23978,7 @@ function getValidSeedBlocks({
23856
23978
  }).filter((f) => f.length).reverse();
23857
23979
  const firstRoundDrawPositions = uniqueDrawPositionsByRound.pop();
23858
23980
  const firstRoundDrawPositionOffset = firstRoundDrawPositions && Math.min(...firstRoundDrawPositions) - 1 || 0;
23859
- const seedingProfile = appliedPolicies?.seeding?.seedingProfile;
23981
+ seedingProfile = seedingProfile ?? appliedPolicies?.seeding?.seedingProfile;
23860
23982
  const baseDrawSize = firstRoundDrawPositions?.length || 0;
23861
23983
  const seedRangeDrawPositionBlocks = uniqueDrawPositionsByRound.filter(
23862
23984
  (block) => block.filter((drawPosition) => drawPosition <= seedsCount).length
@@ -23895,12 +24017,14 @@ function getValidSeedBlocks({
23895
24017
  );
23896
24018
  ({ validSeedBlocks } = getSeedBlockPattern({
23897
24019
  drawPositionBlocks: drawPositionChunks,
24020
+ nonRandom: seedingProfile?.nonRandom,
23898
24021
  positioning,
23899
24022
  seedGroups
23900
24023
  }));
23901
24024
  }
23902
24025
  } else if (isContainer) {
23903
24026
  const result = getContainerBlocks({
24027
+ nonRandom: seedingProfile?.nonRandom,
23904
24028
  seedingProfile,
23905
24029
  structure
23906
24030
  });
@@ -23950,7 +24074,7 @@ function getValidSeedBlocks({
23950
24074
  isFeedIn
23951
24075
  };
23952
24076
  }
23953
- function getContainerBlocks({ seedingProfile, structure }) {
24077
+ function getContainerBlocks({ seedingProfile, structure, nonRandom }) {
23954
24078
  const containedStructures = structure.structures || [];
23955
24079
  const roundRobinGroupsCount = containedStructures.length;
23956
24080
  const positionAssignments = getPositionAssignments$1({
@@ -23970,26 +24094,48 @@ function getContainerBlocks({ seedingProfile, structure }) {
23970
24094
  return getSeedBlockPattern({
23971
24095
  drawPositionBlocks,
23972
24096
  positioning,
23973
- seedGroups
24097
+ seedGroups,
24098
+ nonRandom
23974
24099
  });
23975
24100
  }
23976
- function getSeedBlockPattern({ positioning, seedGroups, drawPositionBlocks }) {
24101
+ function getSeedBlockPattern({
24102
+ drawPositionBlocks,
24103
+ positioning,
24104
+ seedGroups,
24105
+ nonRandom
24106
+ }) {
23977
24107
  const validSeedBlocks = [];
23978
- const topDown = (a, b) => a - b;
23979
- const bottomUp = (a, b) => b - a;
24108
+ const { divisionGroupings } = generateBlockPattern({
24109
+ size: seedGroups.length,
24110
+ positioning
24111
+ });
23980
24112
  const assignedPositions = [];
23981
24113
  seedGroups.forEach((seedGroup, i) => {
23982
- if (i && positioning !== WATERFALL) {
23983
- shuffleArray(seedGroup);
23984
- }
24114
+ const relativePositions = getSubBlock({
24115
+ blockPattern: divisionGroupings,
24116
+ index: i
24117
+ });
23985
24118
  seedGroup.forEach((seedNumber, j) => {
23986
24119
  const blockIndex = i % 2 ? drawPositionBlocks.length - j - 1 : j;
23987
- const drawPosition = drawPositionBlocks[blockIndex].sort(i % 2 ? bottomUp : topDown).find((drawPosition2) => !assignedPositions.includes(drawPosition2));
23988
- assignedPositions.push(drawPosition);
23989
- validSeedBlocks.push({
23990
- seedNumbers: [seedNumber],
23991
- drawPositions: [drawPosition]
23992
- });
24120
+ const block = drawPositionBlocks[blockIndex].slice();
24121
+ let consideredDrawPositions = block.filter(
24122
+ (drawPosition2, i2) => relativePositions.includes(i2 + 1) && drawPosition2
24123
+ );
24124
+ if (positioning !== WATERFALL) {
24125
+ consideredDrawPositions = nonRandom ? consideredDrawPositions : shuffleArray(consideredDrawPositions);
24126
+ } else if (i % 2) {
24127
+ consideredDrawPositions.reverse();
24128
+ }
24129
+ const drawPosition = consideredDrawPositions.find(
24130
+ (drawPosition2) => !assignedPositions.includes(drawPosition2)
24131
+ );
24132
+ if (drawPosition) {
24133
+ assignedPositions.push(drawPosition);
24134
+ validSeedBlocks.push({
24135
+ seedNumbers: [seedNumber],
24136
+ drawPositions: [drawPosition]
24137
+ });
24138
+ }
23993
24139
  });
23994
24140
  });
23995
24141
  return { validSeedBlocks };
@@ -24066,6 +24212,7 @@ function getNextSeedBlock(params) {
24066
24212
  const {
24067
24213
  provisionalPositioning,
24068
24214
  drawDefinition,
24215
+ seedingProfile,
24069
24216
  seedBlockInfo,
24070
24217
  structureId,
24071
24218
  randomize
@@ -24088,6 +24235,7 @@ function getNextSeedBlock(params) {
24088
24235
  provisionalPositioning,
24089
24236
  appliedPolicies,
24090
24237
  drawDefinition,
24238
+ seedingProfile,
24091
24239
  structure
24092
24240
  })?.validSeedBlocks;
24093
24241
  const unfilledSeedBlocks = (validSeedBlocks || []).filter((seedBlock) => {
@@ -30319,10 +30467,10 @@ function findMatchUp({
30319
30467
  return { error: MISSING_TOURNAMENT_RECORD };
30320
30468
  if (typeof matchUpId !== "string")
30321
30469
  return { error: MISSING_MATCHUP_ID };
30322
- if (!drawDefinition || !event || nextMatchUps) {
30470
+ if (!drawDefinition || !event) {
30323
30471
  const matchUps = allTournamentMatchUps({ tournamentRecord, nextMatchUps }).matchUps ?? [];
30324
30472
  const inContextMatchUp = matchUps.find(
30325
- (matchUp2) => matchUp2.matchUpId === matchUpId
30473
+ (matchUp) => matchUp.matchUpId === matchUpId
30326
30474
  );
30327
30475
  if (!inContextMatchUp)
30328
30476
  return { error: MATCHUP_NOT_FOUND };
@@ -30351,18 +30499,41 @@ function findMatchUp({
30351
30499
  contextProfile,
30352
30500
  inContext
30353
30501
  });
30354
- const { matchUp, structure } = findDrawMatchUp({
30355
- context: inContext ? additionalContext : void 0,
30356
- tournamentParticipants,
30357
- afterRecoveryTimes,
30358
- contextContent,
30359
- drawDefinition,
30360
- contextProfile,
30361
- matchUpId,
30362
- inContext,
30363
- event
30364
- });
30365
- return { matchUp, structure, drawDefinition };
30502
+ if (nextMatchUps) {
30503
+ const matchUps = allDrawMatchUps$1({
30504
+ context: inContext ? additionalContext : void 0,
30505
+ participants: tournamentParticipants,
30506
+ afterRecoveryTimes,
30507
+ contextContent,
30508
+ contextProfile,
30509
+ drawDefinition,
30510
+ nextMatchUps,
30511
+ inContext,
30512
+ event
30513
+ }).matchUps ?? [];
30514
+ const inContextMatchUp = matchUps.find(
30515
+ (matchUp) => matchUp.matchUpId === matchUpId
30516
+ );
30517
+ if (!inContextMatchUp)
30518
+ return { error: MATCHUP_NOT_FOUND };
30519
+ const structure = drawDefinition?.structures?.find(
30520
+ (structure2) => structure2.structureId === inContextMatchUp.structureId
30521
+ );
30522
+ return { drawDefinition, structure, matchUp: inContextMatchUp };
30523
+ } else {
30524
+ const { matchUp, structure } = findDrawMatchUp({
30525
+ context: inContext ? additionalContext : void 0,
30526
+ tournamentParticipants,
30527
+ afterRecoveryTimes,
30528
+ contextContent,
30529
+ drawDefinition,
30530
+ contextProfile,
30531
+ matchUpId,
30532
+ inContext,
30533
+ event
30534
+ });
30535
+ return { matchUp, structure, drawDefinition };
30536
+ }
30366
30537
  }
30367
30538
 
30368
30539
  function resetTieFormat$1({
@@ -31869,7 +32040,7 @@ function competitionScheduleMatchUps(params) {
31869
32040
  params.matchUpFilters.excludeMatchUpStatuses = [COMPLETED$1];
31870
32041
  }
31871
32042
  }
31872
- const { completedMatchUps, upcomingMatchUps, pendingMatchUps } = competitionMatchUps({
32043
+ const { completedMatchUps, upcomingMatchUps, pendingMatchUps, groupInfo } = competitionMatchUps({
31873
32044
  ...params,
31874
32045
  matchUpFilters: params.matchUpFilters,
31875
32046
  contextFilters: params.contextFilters
@@ -31893,6 +32064,7 @@ function competitionScheduleMatchUps(params) {
31893
32064
  // completed matchUps for the filter date
31894
32065
  dateMatchUps,
31895
32066
  // all incomplete matchUps for the filter date
32067
+ groupInfo,
31896
32068
  venues
31897
32069
  };
31898
32070
  if (withCourtGridRows) {
@@ -31903,7 +32075,7 @@ function competitionScheduleMatchUps(params) {
31903
32075
  result.courtPrefix = courtPrefix;
31904
32076
  result.rows = rows;
31905
32077
  }
31906
- return result;
32078
+ return { ...result, ...SUCCESS };
31907
32079
  function getCourtMatchUps({ courtId }) {
31908
32080
  const matchUpsToConsider = courtCompletedMatchUps ? dateMatchUps.concat(completedMatchUps ?? []) : dateMatchUps;
31909
32081
  const courtMatchUps = matchUpsToConsider.filter(
@@ -41691,8 +41863,9 @@ function randomUnseededSeparation({
41691
41863
  const { positionAssignments } = structureAssignedDrawPositions({ structure });
41692
41864
  const participantsWithGroupings = addParticipantGroupings({
41693
41865
  participantsProfile: { convertExtensions: true },
41866
+ deepCopy: false,
41694
41867
  participants
41695
- });
41868
+ }).participantsWithGroupings;
41696
41869
  const unassignedPositions = positionAssignments?.filter(
41697
41870
  (assignment) => !assignment.participantId
41698
41871
  );
@@ -42090,6 +42263,7 @@ function getSeedOrderByePositions({
42090
42263
  relevantMatchUps,
42091
42264
  appliedPolicies,
42092
42265
  drawDefinition,
42266
+ seedingProfile,
42093
42267
  seedBlockInfo,
42094
42268
  byesToPlace,
42095
42269
  structure
@@ -42099,6 +42273,7 @@ function getSeedOrderByePositions({
42099
42273
  provisionalPositioning,
42100
42274
  appliedPolicies,
42101
42275
  drawDefinition,
42276
+ seedingProfile,
42102
42277
  structure
42103
42278
  });
42104
42279
  }
@@ -42374,6 +42549,7 @@ function positionByes({
42374
42549
  appliedPolicies,
42375
42550
  drawDefinition,
42376
42551
  seedBlockInfo,
42552
+ seedingProfile,
42377
42553
  matchUpsMap,
42378
42554
  structureId,
42379
42555
  structure,
@@ -42406,6 +42582,7 @@ function positionByes({
42406
42582
  relevantMatchUps,
42407
42583
  appliedPolicies,
42408
42584
  drawDefinition,
42585
+ seedingProfile,
42409
42586
  seedBlockInfo,
42410
42587
  byesToPlace,
42411
42588
  structure
@@ -42581,6 +42758,7 @@ function positionSeedBlocks({
42581
42758
  provisionalPositioning,
42582
42759
  appliedPolicies,
42583
42760
  drawDefinition,
42761
+ seedingProfile,
42584
42762
  structure
42585
42763
  });
42586
42764
  if (result?.error)
@@ -42631,6 +42809,7 @@ function positionSeedBlock({
42631
42809
  provisionalPositioning,
42632
42810
  randomize: true,
42633
42811
  drawDefinition,
42812
+ seedingProfile,
42634
42813
  seedBlockInfo,
42635
42814
  structureId,
42636
42815
  event
@@ -42743,6 +42922,7 @@ function automatedPositioning$1({
42743
42922
  provisionalPositioning,
42744
42923
  appliedPolicies,
42745
42924
  drawDefinition,
42925
+ seedingProfile,
42746
42926
  structure
42747
42927
  });
42748
42928
  if (seedBlockInfo.error)
@@ -47724,6 +47904,7 @@ function getNextUnfilledDrawPositions({
47724
47904
  provisionalPositioning,
47725
47905
  drawDefinition,
47726
47906
  seedBlockInfo,
47907
+ seedingProfile,
47727
47908
  structureId,
47728
47909
  event
47729
47910
  }) {
@@ -47745,6 +47926,7 @@ function getNextUnfilledDrawPositions({
47745
47926
  provisionalPositioning,
47746
47927
  randomize: true,
47747
47928
  drawDefinition,
47929
+ seedingProfile,
47748
47930
  seedBlockInfo,
47749
47931
  structureId,
47750
47932
  event
@@ -48024,6 +48206,7 @@ function getValidAssignmentActions({
48024
48206
  returnParticipants,
48025
48207
  appliedPolicies,
48026
48208
  drawDefinition,
48209
+ seedingProfile,
48027
48210
  isByePosition,
48028
48211
  drawPosition,
48029
48212
  structureId,
@@ -48039,6 +48222,7 @@ function getValidAssignmentActions({
48039
48222
  returnAllProxies: true,
48040
48223
  randomize: true,
48041
48224
  drawDefinition,
48225
+ seedingProfile,
48042
48226
  structureId,
48043
48227
  event
48044
48228
  });
@@ -59042,6 +59226,7 @@ function prepareStage(params) {
59042
59226
  provisionalPositioning,
59043
59227
  appliedPolicies,
59044
59228
  drawDefinition,
59229
+ seedingProfile,
59045
59230
  structure
59046
59231
  }) : void 0;
59047
59232
  const { seedLimit } = initializeStructureSeedAssignments({
@@ -59184,6 +59369,7 @@ function generateDrawDefinition(params) {
59184
59369
  ignoreStageSpace,
59185
59370
  tournamentRecord,
59186
59371
  qualifyingOnly,
59372
+ seedingProfile,
59187
59373
  tieFormatName,
59188
59374
  drawEntries,
59189
59375
  addToEvent,
@@ -59473,6 +59659,7 @@ function generateDrawDefinition(params) {
59473
59659
  // ooo!! If there is no drawSize then MAIN is not being generated
59474
59660
  appliedPolicies,
59475
59661
  drawDefinition,
59662
+ seedingProfile,
59476
59663
  participants,
59477
59664
  stage: MAIN,
59478
59665
  seedsCount,
@@ -59555,7 +59742,6 @@ function generateDrawDefinition(params) {
59555
59742
  seededParticipants,
59556
59743
  seedingScaleName,
59557
59744
  seedsCount: seedsCount2 = 0,
59558
- seedingProfile,
59559
59745
  seedByRanking,
59560
59746
  placeByes: placeByes2,
59561
59747
  drawSize: drawSize2
@@ -59563,6 +59749,7 @@ function generateDrawDefinition(params) {
59563
59749
  const qualifyingStageResult = prepareStage({
59564
59750
  ...drawTypeResult,
59565
59751
  ...params,
59752
+ seedingProfile: structureProfile.seedingProfile ?? seedingProfile,
59566
59753
  stageSequence: sequence,
59567
59754
  qualifyingRoundNumber,
59568
59755
  preparedStructureIds,
@@ -59573,7 +59760,6 @@ function generateDrawDefinition(params) {
59573
59760
  appliedPolicies,
59574
59761
  drawDefinition,
59575
59762
  qualifyingOnly,
59576
- seedingProfile,
59577
59763
  seedByRanking,
59578
59764
  participants,
59579
59765
  roundTarget,