tods-competition-factory 1.8.31 → 1.8.33

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.31";
2407
+ return "1.8.33";
2408
2408
  }
2409
2409
 
2410
2410
  function getObjectTieFormat(obj) {
@@ -23862,10 +23862,89 @@ function getSeedingThresholds({
23862
23862
  return { ...SUCCESS, seedingThresholds };
23863
23863
  }
23864
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
+
23865
23943
  function getValidSeedBlocks({
23866
23944
  provisionalPositioning,
23867
23945
  returnAllProxies,
23868
23946
  appliedPolicies,
23947
+ seedingProfile,
23869
23948
  drawDefinition,
23870
23949
  allPositions,
23871
23950
  structure
@@ -23899,7 +23978,7 @@ function getValidSeedBlocks({
23899
23978
  }).filter((f) => f.length).reverse();
23900
23979
  const firstRoundDrawPositions = uniqueDrawPositionsByRound.pop();
23901
23980
  const firstRoundDrawPositionOffset = firstRoundDrawPositions && Math.min(...firstRoundDrawPositions) - 1 || 0;
23902
- const seedingProfile = appliedPolicies?.seeding?.seedingProfile;
23981
+ seedingProfile = seedingProfile ?? appliedPolicies?.seeding?.seedingProfile;
23903
23982
  const baseDrawSize = firstRoundDrawPositions?.length || 0;
23904
23983
  const seedRangeDrawPositionBlocks = uniqueDrawPositionsByRound.filter(
23905
23984
  (block) => block.filter((drawPosition) => drawPosition <= seedsCount).length
@@ -23938,12 +24017,14 @@ function getValidSeedBlocks({
23938
24017
  );
23939
24018
  ({ validSeedBlocks } = getSeedBlockPattern({
23940
24019
  drawPositionBlocks: drawPositionChunks,
24020
+ nonRandom: seedingProfile?.nonRandom,
23941
24021
  positioning,
23942
24022
  seedGroups
23943
24023
  }));
23944
24024
  }
23945
24025
  } else if (isContainer) {
23946
24026
  const result = getContainerBlocks({
24027
+ nonRandom: seedingProfile?.nonRandom,
23947
24028
  seedingProfile,
23948
24029
  structure
23949
24030
  });
@@ -23993,7 +24074,7 @@ function getValidSeedBlocks({
23993
24074
  isFeedIn
23994
24075
  };
23995
24076
  }
23996
- function getContainerBlocks({ seedingProfile, structure }) {
24077
+ function getContainerBlocks({ seedingProfile, structure, nonRandom }) {
23997
24078
  const containedStructures = structure.structures || [];
23998
24079
  const roundRobinGroupsCount = containedStructures.length;
23999
24080
  const positionAssignments = getPositionAssignments$1({
@@ -24013,26 +24094,48 @@ function getContainerBlocks({ seedingProfile, structure }) {
24013
24094
  return getSeedBlockPattern({
24014
24095
  drawPositionBlocks,
24015
24096
  positioning,
24016
- seedGroups
24097
+ seedGroups,
24098
+ nonRandom
24017
24099
  });
24018
24100
  }
24019
- function getSeedBlockPattern({ positioning, seedGroups, drawPositionBlocks }) {
24101
+ function getSeedBlockPattern({
24102
+ drawPositionBlocks,
24103
+ positioning,
24104
+ seedGroups,
24105
+ nonRandom
24106
+ }) {
24020
24107
  const validSeedBlocks = [];
24021
- const topDown = (a, b) => a - b;
24022
- const bottomUp = (a, b) => b - a;
24108
+ const { divisionGroupings } = generateBlockPattern({
24109
+ size: seedGroups.length,
24110
+ positioning
24111
+ });
24023
24112
  const assignedPositions = [];
24024
24113
  seedGroups.forEach((seedGroup, i) => {
24025
- if (i && positioning !== WATERFALL) {
24026
- shuffleArray(seedGroup);
24027
- }
24114
+ const relativePositions = getSubBlock({
24115
+ blockPattern: divisionGroupings,
24116
+ index: i
24117
+ });
24028
24118
  seedGroup.forEach((seedNumber, j) => {
24029
24119
  const blockIndex = i % 2 ? drawPositionBlocks.length - j - 1 : j;
24030
- const drawPosition = drawPositionBlocks[blockIndex].sort(i % 2 ? bottomUp : topDown).find((drawPosition2) => !assignedPositions.includes(drawPosition2));
24031
- assignedPositions.push(drawPosition);
24032
- validSeedBlocks.push({
24033
- seedNumbers: [seedNumber],
24034
- drawPositions: [drawPosition]
24035
- });
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
+ }
24036
24139
  });
24037
24140
  });
24038
24141
  return { validSeedBlocks };
@@ -24109,6 +24212,7 @@ function getNextSeedBlock(params) {
24109
24212
  const {
24110
24213
  provisionalPositioning,
24111
24214
  drawDefinition,
24215
+ seedingProfile,
24112
24216
  seedBlockInfo,
24113
24217
  structureId,
24114
24218
  randomize
@@ -24131,6 +24235,7 @@ function getNextSeedBlock(params) {
24131
24235
  provisionalPositioning,
24132
24236
  appliedPolicies,
24133
24237
  drawDefinition,
24238
+ seedingProfile,
24134
24239
  structure
24135
24240
  })?.validSeedBlocks;
24136
24241
  const unfilledSeedBlocks = (validSeedBlocks || []).filter((seedBlock) => {
@@ -27901,7 +28006,7 @@ function getParticipantEntries(params) {
27901
28006
  const minutesDifference = Math.abs(
27902
28007
  consideredMinutes - scheduledMinutes
27903
28008
  );
27904
- const itemIsPrior = consideredMinutes > scheduledMinutes;
28009
+ const itemIsPrior = consideredMinutes >= scheduledMinutes;
27905
28010
  const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
27906
28011
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
27907
28012
  participantAggregator.scheduleConflicts.push({
@@ -42158,6 +42263,7 @@ function getSeedOrderByePositions({
42158
42263
  relevantMatchUps,
42159
42264
  appliedPolicies,
42160
42265
  drawDefinition,
42266
+ seedingProfile,
42161
42267
  seedBlockInfo,
42162
42268
  byesToPlace,
42163
42269
  structure
@@ -42167,6 +42273,7 @@ function getSeedOrderByePositions({
42167
42273
  provisionalPositioning,
42168
42274
  appliedPolicies,
42169
42275
  drawDefinition,
42276
+ seedingProfile,
42170
42277
  structure
42171
42278
  });
42172
42279
  }
@@ -42442,6 +42549,7 @@ function positionByes({
42442
42549
  appliedPolicies,
42443
42550
  drawDefinition,
42444
42551
  seedBlockInfo,
42552
+ seedingProfile,
42445
42553
  matchUpsMap,
42446
42554
  structureId,
42447
42555
  structure,
@@ -42474,6 +42582,7 @@ function positionByes({
42474
42582
  relevantMatchUps,
42475
42583
  appliedPolicies,
42476
42584
  drawDefinition,
42585
+ seedingProfile,
42477
42586
  seedBlockInfo,
42478
42587
  byesToPlace,
42479
42588
  structure
@@ -42649,6 +42758,7 @@ function positionSeedBlocks({
42649
42758
  provisionalPositioning,
42650
42759
  appliedPolicies,
42651
42760
  drawDefinition,
42761
+ seedingProfile,
42652
42762
  structure
42653
42763
  });
42654
42764
  if (result?.error)
@@ -42699,6 +42809,7 @@ function positionSeedBlock({
42699
42809
  provisionalPositioning,
42700
42810
  randomize: true,
42701
42811
  drawDefinition,
42812
+ seedingProfile,
42702
42813
  seedBlockInfo,
42703
42814
  structureId,
42704
42815
  event
@@ -42811,6 +42922,7 @@ function automatedPositioning$1({
42811
42922
  provisionalPositioning,
42812
42923
  appliedPolicies,
42813
42924
  drawDefinition,
42925
+ seedingProfile,
42814
42926
  structure
42815
42927
  });
42816
42928
  if (seedBlockInfo.error)
@@ -47792,6 +47904,7 @@ function getNextUnfilledDrawPositions({
47792
47904
  provisionalPositioning,
47793
47905
  drawDefinition,
47794
47906
  seedBlockInfo,
47907
+ seedingProfile,
47795
47908
  structureId,
47796
47909
  event
47797
47910
  }) {
@@ -47813,6 +47926,7 @@ function getNextUnfilledDrawPositions({
47813
47926
  provisionalPositioning,
47814
47927
  randomize: true,
47815
47928
  drawDefinition,
47929
+ seedingProfile,
47816
47930
  seedBlockInfo,
47817
47931
  structureId,
47818
47932
  event
@@ -48092,6 +48206,7 @@ function getValidAssignmentActions({
48092
48206
  returnParticipants,
48093
48207
  appliedPolicies,
48094
48208
  drawDefinition,
48209
+ seedingProfile,
48095
48210
  isByePosition,
48096
48211
  drawPosition,
48097
48212
  structureId,
@@ -48107,6 +48222,7 @@ function getValidAssignmentActions({
48107
48222
  returnAllProxies: true,
48108
48223
  randomize: true,
48109
48224
  drawDefinition,
48225
+ seedingProfile,
48110
48226
  structureId,
48111
48227
  event
48112
48228
  });
@@ -59110,6 +59226,7 @@ function prepareStage(params) {
59110
59226
  provisionalPositioning,
59111
59227
  appliedPolicies,
59112
59228
  drawDefinition,
59229
+ seedingProfile,
59113
59230
  structure
59114
59231
  }) : void 0;
59115
59232
  const { seedLimit } = initializeStructureSeedAssignments({
@@ -59252,6 +59369,7 @@ function generateDrawDefinition(params) {
59252
59369
  ignoreStageSpace,
59253
59370
  tournamentRecord,
59254
59371
  qualifyingOnly,
59372
+ seedingProfile,
59255
59373
  tieFormatName,
59256
59374
  drawEntries,
59257
59375
  addToEvent,
@@ -59541,6 +59659,7 @@ function generateDrawDefinition(params) {
59541
59659
  // ooo!! If there is no drawSize then MAIN is not being generated
59542
59660
  appliedPolicies,
59543
59661
  drawDefinition,
59662
+ seedingProfile,
59544
59663
  participants,
59545
59664
  stage: MAIN,
59546
59665
  seedsCount,
@@ -59623,7 +59742,6 @@ function generateDrawDefinition(params) {
59623
59742
  seededParticipants,
59624
59743
  seedingScaleName,
59625
59744
  seedsCount: seedsCount2 = 0,
59626
- seedingProfile,
59627
59745
  seedByRanking,
59628
59746
  placeByes: placeByes2,
59629
59747
  drawSize: drawSize2
@@ -59631,6 +59749,7 @@ function generateDrawDefinition(params) {
59631
59749
  const qualifyingStageResult = prepareStage({
59632
59750
  ...drawTypeResult,
59633
59751
  ...params,
59752
+ seedingProfile: structureProfile.seedingProfile ?? seedingProfile,
59634
59753
  stageSequence: sequence,
59635
59754
  qualifyingRoundNumber,
59636
59755
  preparedStructureIds,
@@ -59641,7 +59760,6 @@ function generateDrawDefinition(params) {
59641
59760
  appliedPolicies,
59642
59761
  drawDefinition,
59643
59762
  qualifyingOnly,
59644
- seedingProfile,
59645
59763
  seedByRanking,
59646
59764
  participants,
59647
59765
  roundTarget,