tods-competition-factory 0.63.1 → 0.64.2
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/tods-competition-factory.development.cjs.js +321 -407
- package/dist/tods-competition-factory.development.cjs.js.map +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js +1 -1
- package/dist/tods-competition-factory.production.cjs.min.js.map +1 -1
- package/dist/tods-competition-factory.production.esm.min.js +1 -1
- package/dist/tods-competition-factory.production.esm.min.js.map +1 -1
- package/package.json +2 -2
|
@@ -1238,6 +1238,7 @@ function setDeepCopy(value, attributes) {
|
|
|
1238
1238
|
if (Array.isArray(attributes.ignore)) globalState.deepCopyAttributes.ignore = attributes.ignore;
|
|
1239
1239
|
if (Array.isArray(attributes.toJSON)) globalState.deepCopyAttributes.toJSON = attributes.toJSON;
|
|
1240
1240
|
if (Array.isArray(attributes.stringify)) globalState.deepCopyAttributes.stringify = attributes.stringify;
|
|
1241
|
+
if (attributes.threshold) globalState.deepCopyAttributes.threshold = attributes.threshold;
|
|
1241
1242
|
}
|
|
1242
1243
|
}
|
|
1243
1244
|
function deepCopyEnabled() {
|
|
@@ -16321,7 +16322,7 @@ function updateTieMatchUpScore({
|
|
|
16321
16322
|
});
|
|
16322
16323
|
if (result.error) return result;
|
|
16323
16324
|
const matchUp = result.matchUp;
|
|
16324
|
-
const tieFormat = matchUp.tieFormat || (structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
16325
|
+
const tieFormat = matchUp.tieFormat || (structure === null || structure === void 0 ? void 0 : structure.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat) || undefined;
|
|
16325
16326
|
const {
|
|
16326
16327
|
winningSide,
|
|
16327
16328
|
set,
|
|
@@ -19899,7 +19900,7 @@ function setMatchUpStatus$2(params) {
|
|
|
19899
19900
|
matchUpsMap,
|
|
19900
19901
|
event
|
|
19901
19902
|
});
|
|
19902
|
-
const tieFormat = dualMatchUp.tieFormat || drawDefinition.tieFormat;
|
|
19903
|
+
const tieFormat = (dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.tieFormat) || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.tieFormat) || (event === null || event === void 0 ? void 0 : event.tieFormat) || undefined;
|
|
19903
19904
|
const {
|
|
19904
19905
|
projectedWinningSide
|
|
19905
19906
|
} = getProjectedDualWinningSide({
|
|
@@ -27549,9 +27550,6 @@ function bulkRescheduleMatchUps({
|
|
|
27549
27550
|
matchUpIds,
|
|
27550
27551
|
dryRun
|
|
27551
27552
|
}) {
|
|
27552
|
-
if (!tournamentRecords) return {
|
|
27553
|
-
error: MISSING_TOURNAMENT_RECORDS
|
|
27554
|
-
};
|
|
27555
27553
|
if (!matchUpIds || !Array.isArray(matchUpIds)) return {
|
|
27556
27554
|
error: MISSING_MATCHUP_IDS
|
|
27557
27555
|
};
|
|
@@ -28042,7 +28040,7 @@ const scheduleGovernor$1 = {
|
|
|
28042
28040
|
};
|
|
28043
28041
|
|
|
28044
28042
|
function factoryVersion() {
|
|
28045
|
-
return '0.
|
|
28043
|
+
return '0.64.2';
|
|
28046
28044
|
}
|
|
28047
28045
|
|
|
28048
28046
|
function attachPolicies$2({
|
|
@@ -32759,7 +32757,7 @@ function addPlayoffStructures$1(params) {
|
|
|
32759
32757
|
}) => addedMatchUpIds.includes(matchUpId));
|
|
32760
32758
|
|
|
32761
32759
|
if (addedMatchUps.length) {
|
|
32762
|
-
const tieFormat = drawDefinition.tieFormat || (event === null || event === void 0 ? void 0 : event.tieFormat);
|
|
32760
|
+
const tieFormat = drawDefinition.tieFormat || (event === null || event === void 0 ? void 0 : event.tieFormat) || undefined;
|
|
32763
32761
|
|
|
32764
32762
|
if (tieFormat) {
|
|
32765
32763
|
addedMatchUps.forEach(matchUp => {
|
|
@@ -33881,17 +33879,17 @@ function generateDrawType(params = {}) {
|
|
|
33881
33879
|
tieFormat,
|
|
33882
33880
|
matchUpType
|
|
33883
33881
|
} = params;
|
|
33884
|
-
tieFormat = tieFormat || drawDefinition.tieFormat;
|
|
33882
|
+
tieFormat = tieFormat || drawDefinition.tieFormat || undefined;
|
|
33885
33883
|
matchUpType = matchUpType || drawDefinition.matchUpType || SINGLES$1;
|
|
33886
33884
|
const drawSize = getStageDrawPositionsCount({
|
|
33887
33885
|
stage,
|
|
33888
33886
|
drawDefinition
|
|
33889
33887
|
});
|
|
33890
|
-
Object.assign(params, {
|
|
33888
|
+
Object.assign(params, definedAttributes({
|
|
33891
33889
|
drawSize,
|
|
33892
33890
|
matchUpType,
|
|
33893
33891
|
tieFormat
|
|
33894
|
-
});
|
|
33892
|
+
}));
|
|
33895
33893
|
const validDoubleEliminationSize = isPowerOf2(drawSize * 2 / 3); // check that drawSize is a valid value
|
|
33896
33894
|
|
|
33897
33895
|
const invalidDrawSize = drawSize < 2 || !staggeredEntry && ![FEED_IN$1, AD_HOC].includes(drawType) && (drawType === ROUND_ROBIN && drawSize < 3 || drawType === DOUBLE_ELIMINATION && !validDoubleEliminationSize || ![ROUND_ROBIN, DOUBLE_ELIMINATION, ROUND_ROBIN_WITH_PLAYOFF].includes(drawType) && !isPowerOf2(drawSize));
|
|
@@ -42664,7 +42662,7 @@ function getTieMatchUpContext({
|
|
|
42664
42662
|
drawDefinition,
|
|
42665
42663
|
matchUpsMap
|
|
42666
42664
|
});
|
|
42667
|
-
const tieFormat = dualMatchUp.tieFormat || structure.tieFormat || drawDefinition.tieFormat || event.tieFormat;
|
|
42665
|
+
const tieFormat = dualMatchUp.tieFormat || structure.tieFormat || drawDefinition.tieFormat || event.tieFormat || undefined;
|
|
42668
42666
|
return {
|
|
42669
42667
|
relevantAssignments,
|
|
42670
42668
|
collectionPosition,
|
|
@@ -45704,7 +45702,7 @@ function getTieFormat({
|
|
|
45704
45702
|
const structureDefaultTieFormat = (_structure = structure) === null || _structure === void 0 ? void 0 : _structure.tieFormat;
|
|
45705
45703
|
const drawDefaultTieFormat = (_drawDefinition = drawDefinition) === null || _drawDefinition === void 0 ? void 0 : _drawDefinition.tieFormat;
|
|
45706
45704
|
const eventDefaultTieFormat = event === null || event === void 0 ? void 0 : event.tieFormat;
|
|
45707
|
-
const tieFormat = (matchUpResult === null || matchUpResult === void 0 ? void 0 : (_matchUpResult$matchU = matchUpResult.matchUp) === null || _matchUpResult$matchU === void 0 ? void 0 : _matchUpResult$matchU.tieFormat) || structureDefaultTieFormat || drawDefaultTieFormat || eventDefaultTieFormat;
|
|
45705
|
+
const tieFormat = (matchUpResult === null || matchUpResult === void 0 ? void 0 : (_matchUpResult$matchU = matchUpResult.matchUp) === null || _matchUpResult$matchU === void 0 ? void 0 : _matchUpResult$matchU.tieFormat) || structureDefaultTieFormat || drawDefaultTieFormat || eventDefaultTieFormat || undefined;
|
|
45708
45706
|
return {
|
|
45709
45707
|
structureDefaultTieFormat,
|
|
45710
45708
|
eventDefaultTieFormat,
|
|
@@ -49826,10 +49824,12 @@ function completeDrawMatchUps({
|
|
|
49826
49824
|
completeAllMatchUps,
|
|
49827
49825
|
randomWinningSide,
|
|
49828
49826
|
drawDefinition,
|
|
49827
|
+
completionGoal,
|
|
49829
49828
|
matchUpFormat,
|
|
49830
49829
|
event
|
|
49831
49830
|
}) {
|
|
49832
|
-
const sortedStructures = drawDefinition.structures.slice().sort(structureSort);
|
|
49831
|
+
const sortedStructures = drawDefinition.structures.slice().sort(structureSort);
|
|
49832
|
+
let completedCount = 0; // to support legacy tests it is possible to use completeAllMatchUps
|
|
49833
49833
|
// to pass a score string that will be applied to all matchUps
|
|
49834
49834
|
|
|
49835
49835
|
const scoreString = typeof completeAllMatchUps === 'string' && completeAllMatchUps;
|
|
@@ -49853,6 +49853,7 @@ function completeDrawMatchUps({
|
|
|
49853
49853
|
}) => !winningSide).sort(matchUpSort).map(getMatchUpId$1);
|
|
49854
49854
|
|
|
49855
49855
|
for (const matchUpId of sortedMatchUpIds) {
|
|
49856
|
+
if (!isNaN(completionGoal) && completedCount >= completionGoal) break;
|
|
49856
49857
|
const {
|
|
49857
49858
|
matchUps
|
|
49858
49859
|
} = getAllStructureMatchUps({
|
|
@@ -49876,11 +49877,13 @@ function completeDrawMatchUps({
|
|
|
49876
49877
|
scoreString
|
|
49877
49878
|
});
|
|
49878
49879
|
if (result.error) return result;
|
|
49880
|
+
completedCount += 1;
|
|
49879
49881
|
}
|
|
49880
49882
|
}
|
|
49881
49883
|
}
|
|
49882
49884
|
|
|
49883
|
-
return { ...SUCCESS
|
|
49885
|
+
return { ...SUCCESS,
|
|
49886
|
+
completedCount
|
|
49884
49887
|
};
|
|
49885
49888
|
}
|
|
49886
49889
|
function completeDrawMatchUp({
|
|
@@ -50060,18 +50063,21 @@ function generateFlightDrawDefinitions({
|
|
|
50060
50063
|
} // TODO: enable { outcomes: [] } in eventProfile: { drawProfiles }
|
|
50061
50064
|
|
|
50062
50065
|
|
|
50066
|
+
const completionGoal = drawProfile === null || drawProfile === void 0 ? void 0 : drawProfile.completionGoal;
|
|
50063
50067
|
const manual = (drawProfile === null || drawProfile === void 0 ? void 0 : drawProfile.automated) === false;
|
|
50064
50068
|
|
|
50065
|
-
if (!manual && completeAllMatchUps) {
|
|
50069
|
+
if (!manual && (completeAllMatchUps || completionGoal)) {
|
|
50066
50070
|
const matchUpFormat = drawProfile === null || drawProfile === void 0 ? void 0 : drawProfile.matchUpFormat;
|
|
50067
50071
|
const result = completeDrawMatchUps({
|
|
50068
50072
|
matchUpStatusProfile,
|
|
50069
|
-
completeAllMatchUps,
|
|
50073
|
+
completeAllMatchUps: !completionGoal && completeAllMatchUps,
|
|
50070
50074
|
randomWinningSide,
|
|
50075
|
+
completionGoal,
|
|
50071
50076
|
drawDefinition,
|
|
50072
50077
|
matchUpFormat
|
|
50073
50078
|
});
|
|
50074
50079
|
if (result.error) return result;
|
|
50080
|
+
const completedCount = result.completedCount;
|
|
50075
50081
|
|
|
50076
50082
|
if ((drawProfile === null || drawProfile === void 0 ? void 0 : drawProfile.drawType) === ROUND_ROBIN_WITH_PLAYOFF) {
|
|
50077
50083
|
const mainStructure = drawDefinition.structures.find(structure => structure.stage === MAIN);
|
|
@@ -50082,12 +50088,14 @@ function generateFlightDrawDefinitions({
|
|
|
50082
50088
|
event
|
|
50083
50089
|
});
|
|
50084
50090
|
if (result.error) return result;
|
|
50091
|
+
const playoffCompletionGoal = completionGoal ? completionGoal - completedCount : undefined;
|
|
50085
50092
|
result = completeDrawMatchUps({
|
|
50086
|
-
completeAllMatchUps,
|
|
50093
|
+
completeAllMatchUps: !completionGoal && completeAllMatchUps,
|
|
50094
|
+
completionGoal: completionGoal ? playoffCompletionGoal : undefined,
|
|
50087
50095
|
matchUpStatusProfile,
|
|
50088
50096
|
randomWinningSide,
|
|
50089
|
-
|
|
50090
|
-
|
|
50097
|
+
drawDefinition,
|
|
50098
|
+
matchUpFormat
|
|
50091
50099
|
});
|
|
50092
50100
|
if (result.error) return result;
|
|
50093
50101
|
}
|
|
@@ -50394,6 +50402,258 @@ function addScaleItem({
|
|
|
50394
50402
|
}
|
|
50395
50403
|
}
|
|
50396
50404
|
|
|
50405
|
+
function processTieFormat({
|
|
50406
|
+
tieFormat,
|
|
50407
|
+
tieFormatName,
|
|
50408
|
+
drawSize,
|
|
50409
|
+
alternatesCount = 0
|
|
50410
|
+
}) {
|
|
50411
|
+
var _tieFormat, _tieFormat$collection;
|
|
50412
|
+
|
|
50413
|
+
let maxDoublesCount = 0,
|
|
50414
|
+
maxSinglesCount = 0;
|
|
50415
|
+
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
50416
|
+
namedFormat: tieFormatName
|
|
50417
|
+
});
|
|
50418
|
+
(_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : (_tieFormat$collection = _tieFormat.collectionDefinitions) === null || _tieFormat$collection === void 0 ? void 0 : _tieFormat$collection.forEach(collectionDefinition => {
|
|
50419
|
+
// ensure every collectionDefinition has a collectionId
|
|
50420
|
+
if (!collectionDefinition.collectionId) collectionDefinition.collectionId = UUID();
|
|
50421
|
+
|
|
50422
|
+
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === DOUBLES$1) {
|
|
50423
|
+
const doublesCount = collectionDefinition.matchUpCount;
|
|
50424
|
+
maxDoublesCount = Math.max(maxDoublesCount, doublesCount);
|
|
50425
|
+
}
|
|
50426
|
+
|
|
50427
|
+
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === SINGLES$1) {
|
|
50428
|
+
const singlescount = collectionDefinition.matchUpCount;
|
|
50429
|
+
maxSinglesCount = Math.max(maxSinglesCount, singlescount);
|
|
50430
|
+
}
|
|
50431
|
+
});
|
|
50432
|
+
const teamSize = Math.max(maxSinglesCount, maxDoublesCount * 2);
|
|
50433
|
+
const maxDoublesDraw = maxDoublesCount * (drawSize + alternatesCount);
|
|
50434
|
+
const maxSinglesDraw = maxSinglesCount * (drawSize + alternatesCount);
|
|
50435
|
+
return {
|
|
50436
|
+
maxDoublesDraw,
|
|
50437
|
+
maxSinglesDraw,
|
|
50438
|
+
teamSize
|
|
50439
|
+
};
|
|
50440
|
+
}
|
|
50441
|
+
|
|
50442
|
+
function getParticipantsCount({
|
|
50443
|
+
participantsProfile,
|
|
50444
|
+
eventProfiles,
|
|
50445
|
+
drawProfiles
|
|
50446
|
+
}) {
|
|
50447
|
+
let {
|
|
50448
|
+
participantsCount,
|
|
50449
|
+
participantType = INDIVIDUAL$1
|
|
50450
|
+
} = participantsProfile || {};
|
|
50451
|
+
const specifiedParicipantsCount = participantsCount || 0; // capture this to ensure calculated participantsCount is not below
|
|
50452
|
+
|
|
50453
|
+
let largestDoublesDraw = 0,
|
|
50454
|
+
largestSinglesDraw = 0,
|
|
50455
|
+
largestTeamSize = 0,
|
|
50456
|
+
largestTeamDraw = 0,
|
|
50457
|
+
uniqueParticipantsCount = 0;
|
|
50458
|
+
|
|
50459
|
+
const processDrawProfile = ({
|
|
50460
|
+
alternatesCount = 0,
|
|
50461
|
+
uniqueParticipants,
|
|
50462
|
+
tieFormatName,
|
|
50463
|
+
drawSize = 0,
|
|
50464
|
+
eventType,
|
|
50465
|
+
tieFormat,
|
|
50466
|
+
category,
|
|
50467
|
+
gender,
|
|
50468
|
+
stage
|
|
50469
|
+
}) => {
|
|
50470
|
+
const isDoubles = eventType === DOUBLES;
|
|
50471
|
+
const isTeam = eventType === TEAM$2;
|
|
50472
|
+
const requiresUniqueParticipants = uniqueParticipants || stage === QUALIFYING || category || gender;
|
|
50473
|
+
|
|
50474
|
+
if (requiresUniqueParticipants) {
|
|
50475
|
+
if (isDoubles) {
|
|
50476
|
+
uniqueParticipantsCount += (drawSize + alternatesCount) * 2;
|
|
50477
|
+
} else {
|
|
50478
|
+
uniqueParticipantsCount += drawSize + alternatesCount;
|
|
50479
|
+
}
|
|
50480
|
+
} else {
|
|
50481
|
+
if (isTeam) {
|
|
50482
|
+
largestTeamDraw = Math.max(largestTeamDraw, drawSize + alternatesCount);
|
|
50483
|
+
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
50484
|
+
namedFormat: tieFormatName
|
|
50485
|
+
});
|
|
50486
|
+
const {
|
|
50487
|
+
teamSize,
|
|
50488
|
+
maxDoublesDraw,
|
|
50489
|
+
maxSinglesDraw
|
|
50490
|
+
} = processTieFormat({
|
|
50491
|
+
alternatesCount,
|
|
50492
|
+
tieFormatName,
|
|
50493
|
+
tieFormat,
|
|
50494
|
+
drawSize
|
|
50495
|
+
});
|
|
50496
|
+
largestTeamSize = Math.max(largestTeamSize, teamSize);
|
|
50497
|
+
largestDoublesDraw = Math.max(largestDoublesDraw, maxDoublesDraw);
|
|
50498
|
+
largestSinglesDraw = Math.max(largestSinglesDraw, maxSinglesDraw);
|
|
50499
|
+
}
|
|
50500
|
+
|
|
50501
|
+
if (isDoubles && drawSize + alternatesCount && drawSize + alternatesCount > largestDoublesDraw) {
|
|
50502
|
+
largestDoublesDraw = drawSize + alternatesCount;
|
|
50503
|
+
}
|
|
50504
|
+
|
|
50505
|
+
if (!isDoubles && !isTeam && drawSize && drawSize > largestSinglesDraw) {
|
|
50506
|
+
largestSinglesDraw = drawSize + alternatesCount;
|
|
50507
|
+
}
|
|
50508
|
+
}
|
|
50509
|
+
};
|
|
50510
|
+
|
|
50511
|
+
eventProfiles === null || eventProfiles === void 0 ? void 0 : eventProfiles.forEach(eventProfile => {
|
|
50512
|
+
const {
|
|
50513
|
+
tieFormatName: eventTieFormatName,
|
|
50514
|
+
tieFormat: eventTieFormat,
|
|
50515
|
+
drawProfiles,
|
|
50516
|
+
eventType,
|
|
50517
|
+
category,
|
|
50518
|
+
gender
|
|
50519
|
+
} = eventProfile;
|
|
50520
|
+
|
|
50521
|
+
if (drawProfiles) {
|
|
50522
|
+
for (const drawProfile of drawProfiles) {
|
|
50523
|
+
const {
|
|
50524
|
+
tieFormatName,
|
|
50525
|
+
tieFormat
|
|
50526
|
+
} = drawProfile;
|
|
50527
|
+
processDrawProfile({ ...drawProfile,
|
|
50528
|
+
tieFormatName: tieFormatName || eventTieFormatName,
|
|
50529
|
+
tieFormat: tieFormat || eventTieFormat,
|
|
50530
|
+
eventType,
|
|
50531
|
+
category,
|
|
50532
|
+
gender
|
|
50533
|
+
});
|
|
50534
|
+
}
|
|
50535
|
+
}
|
|
50536
|
+
});
|
|
50537
|
+
|
|
50538
|
+
if (drawProfiles) {
|
|
50539
|
+
for (const drawProfile of drawProfiles) {
|
|
50540
|
+
processDrawProfile(drawProfile);
|
|
50541
|
+
}
|
|
50542
|
+
}
|
|
50543
|
+
|
|
50544
|
+
const individualCompetitorsCount = Math.max(largestTeamDraw * largestTeamSize, largestDoublesDraw * 2, largestSinglesDraw);
|
|
50545
|
+
if (largestDoublesDraw) participantType = PAIR$1;
|
|
50546
|
+
if ((participantsCount || specifiedParicipantsCount) < individualCompetitorsCount) participantsCount = individualCompetitorsCount;
|
|
50547
|
+
|
|
50548
|
+
if (participantsCount && largestDoublesDraw && [PAIR$1, TEAM$2].includes(participantType)) {
|
|
50549
|
+
// if we are generating PAIRs or TEAMs...
|
|
50550
|
+
if (largestSinglesDraw && Math.floor(largestSinglesDraw / 2) > largestDoublesDraw) {
|
|
50551
|
+
// if the half the singles draw is still larger than doubles draw
|
|
50552
|
+
participantsCount = Math.floor(largestSinglesDraw / 2);
|
|
50553
|
+
} else if (!largestSinglesDraw || largestDoublesDraw * 2 >= largestSinglesDraw) {
|
|
50554
|
+
// otherwise participantsCount can be cut in half
|
|
50555
|
+
participantsCount = Math.ceil(participantsCount / 2);
|
|
50556
|
+
}
|
|
50557
|
+
} // if (participantsCount === undefined) participantsCount = 32;
|
|
50558
|
+
|
|
50559
|
+
|
|
50560
|
+
if (participantsCount === undefined) {
|
|
50561
|
+
participantsCount = !(eventProfiles !== null && eventProfiles !== void 0 && eventProfiles.length) && !(drawProfiles !== null && drawProfiles !== void 0 && drawProfiles.length) ? 32 : 0;
|
|
50562
|
+
}
|
|
50563
|
+
|
|
50564
|
+
if (participantsCount < specifiedParicipantsCount) participantsCount = specifiedParicipantsCount;
|
|
50565
|
+
return {
|
|
50566
|
+
largestTeamDraw,
|
|
50567
|
+
largestTeamSize,
|
|
50568
|
+
participantsCount,
|
|
50569
|
+
participantType,
|
|
50570
|
+
uniqueParticipantsCount
|
|
50571
|
+
};
|
|
50572
|
+
}
|
|
50573
|
+
|
|
50574
|
+
function addTournamentParticipants({
|
|
50575
|
+
participantsProfile,
|
|
50576
|
+
tournamentRecord,
|
|
50577
|
+
eventProfiles,
|
|
50578
|
+
drawProfiles,
|
|
50579
|
+
startDate,
|
|
50580
|
+
uuids
|
|
50581
|
+
}) {
|
|
50582
|
+
const {
|
|
50583
|
+
participantsCount,
|
|
50584
|
+
participantType,
|
|
50585
|
+
largestTeamDraw,
|
|
50586
|
+
largestTeamSize
|
|
50587
|
+
} = getParticipantsCount({
|
|
50588
|
+
participantsProfile,
|
|
50589
|
+
eventProfiles,
|
|
50590
|
+
drawProfiles
|
|
50591
|
+
});
|
|
50592
|
+
const {
|
|
50593
|
+
nationalityCodesCount,
|
|
50594
|
+
nationalityCodeType,
|
|
50595
|
+
valuesInstanceLimit,
|
|
50596
|
+
nationalityCodes,
|
|
50597
|
+
personExtensions,
|
|
50598
|
+
addressProps,
|
|
50599
|
+
personData,
|
|
50600
|
+
personIds,
|
|
50601
|
+
inContext,
|
|
50602
|
+
teamKey,
|
|
50603
|
+
sex
|
|
50604
|
+
} = participantsProfile || {};
|
|
50605
|
+
const {
|
|
50606
|
+
participants
|
|
50607
|
+
} = generateParticipants({
|
|
50608
|
+
consideredDate: startDate,
|
|
50609
|
+
valuesInstanceLimit,
|
|
50610
|
+
nationalityCodesCount,
|
|
50611
|
+
nationalityCodeType,
|
|
50612
|
+
nationalityCodes,
|
|
50613
|
+
personExtensions,
|
|
50614
|
+
addressProps,
|
|
50615
|
+
personData,
|
|
50616
|
+
sex,
|
|
50617
|
+
participantsCount,
|
|
50618
|
+
participantType,
|
|
50619
|
+
personIds,
|
|
50620
|
+
uuids,
|
|
50621
|
+
inContext
|
|
50622
|
+
});
|
|
50623
|
+
let result = addParticipants({
|
|
50624
|
+
tournamentRecord,
|
|
50625
|
+
participants
|
|
50626
|
+
});
|
|
50627
|
+
if (!result.success) return result;
|
|
50628
|
+
|
|
50629
|
+
if (teamKey) {
|
|
50630
|
+
const result = generateTeamsFromParticipantAttribute({
|
|
50631
|
+
tournamentRecord,
|
|
50632
|
+
...teamKey
|
|
50633
|
+
});
|
|
50634
|
+
if (result.error) return result;
|
|
50635
|
+
} // generate Team participants
|
|
50636
|
+
|
|
50637
|
+
|
|
50638
|
+
const allIndividualParticipantIds = participants.filter(({
|
|
50639
|
+
participantType
|
|
50640
|
+
}) => participantType === INDIVIDUAL$1).map(getParticipantId);
|
|
50641
|
+
const teamParticipants = generateRange(0, largestTeamDraw).map(teamIndex => {
|
|
50642
|
+
const individualParticipantIds = allIndividualParticipantIds.slice(teamIndex * largestTeamSize, (teamIndex + 1) * largestTeamSize);
|
|
50643
|
+
return {
|
|
50644
|
+
participantName: `Team ${teamIndex + 1}`,
|
|
50645
|
+
participantRole: COMPETITOR,
|
|
50646
|
+
participantType: TEAM$1,
|
|
50647
|
+
participantId: UUID(),
|
|
50648
|
+
individualParticipantIds
|
|
50649
|
+
};
|
|
50650
|
+
});
|
|
50651
|
+
return addParticipants({
|
|
50652
|
+
tournamentRecord,
|
|
50653
|
+
participants: teamParticipants
|
|
50654
|
+
});
|
|
50655
|
+
}
|
|
50656
|
+
|
|
50397
50657
|
function generateEventParticipants({
|
|
50398
50658
|
uniqueParticipantsCount,
|
|
50399
50659
|
participantsProfile,
|
|
@@ -50421,6 +50681,7 @@ function generateEventParticipants({
|
|
|
50421
50681
|
const mainParticipantsCount = uniqueParticipantsCount[MAIN] || 0;
|
|
50422
50682
|
const qualifyingParticipantsCount = uniqueParticipantsCount[QUALIFYING] || 0;
|
|
50423
50683
|
const participantsCount = mainParticipantsCount + qualifyingParticipantsCount;
|
|
50684
|
+
const sex = [MALE, FEMALE].includes(gender) ? gender : undefined;
|
|
50424
50685
|
const {
|
|
50425
50686
|
participants: uniqueFlightParticipants
|
|
50426
50687
|
} = generateParticipants({
|
|
@@ -50435,11 +50696,11 @@ function generateEventParticipants({
|
|
|
50435
50696
|
ratingsParameters,
|
|
50436
50697
|
nationalityCodes,
|
|
50437
50698
|
addressProps,
|
|
50438
|
-
sex: gender,
|
|
50439
50699
|
personIds,
|
|
50440
50700
|
inContext,
|
|
50441
50701
|
category,
|
|
50442
|
-
uuids
|
|
50702
|
+
uuids,
|
|
50703
|
+
sex
|
|
50443
50704
|
});
|
|
50444
50705
|
let result = addParticipants({
|
|
50445
50706
|
participants: uniqueFlightParticipants,
|
|
@@ -50622,63 +50883,29 @@ function modifyTournamentRecord({
|
|
|
50622
50883
|
};
|
|
50623
50884
|
const allUniqueParticipantIds = [];
|
|
50624
50885
|
const drawIds = [];
|
|
50886
|
+
eventProfiles === null || eventProfiles === void 0 ? void 0 : eventProfiles.forEach(eventProfile => {
|
|
50887
|
+
const event = tournamentRecord.events.find((event, index) => eventProfile.eventIndex !== undefined && index === eventProfile.eventIndex || eventProfile.eventName && event.eventName === eventProfile.eventName || eventProfile.eventId && event.eventId === eventProfile.eventId);
|
|
50625
50888
|
|
|
50626
|
-
|
|
50627
|
-
|
|
50628
|
-
nationalityCodesCount,
|
|
50629
|
-
nationalityCodeType,
|
|
50630
|
-
valuesInstanceLimit,
|
|
50631
|
-
participantsCount,
|
|
50632
|
-
nationalityCodes,
|
|
50633
|
-
personExtensions,
|
|
50634
|
-
participantType,
|
|
50635
|
-
addressProps,
|
|
50636
|
-
personData,
|
|
50637
|
-
personIds,
|
|
50638
|
-
inContext,
|
|
50639
|
-
teamKey,
|
|
50640
|
-
uuids,
|
|
50641
|
-
sex
|
|
50642
|
-
} = participantsProfile || {};
|
|
50643
|
-
const {
|
|
50644
|
-
participants
|
|
50645
|
-
} = generateParticipants({
|
|
50646
|
-
consideredDate: tournamentRecord.startDate,
|
|
50647
|
-
valuesInstanceLimit,
|
|
50648
|
-
nationalityCodesCount,
|
|
50649
|
-
nationalityCodeType,
|
|
50650
|
-
nationalityCodes,
|
|
50651
|
-
personExtensions,
|
|
50652
|
-
addressProps,
|
|
50653
|
-
personData,
|
|
50654
|
-
sex,
|
|
50655
|
-
participantsCount,
|
|
50656
|
-
participantType,
|
|
50657
|
-
personIds,
|
|
50658
|
-
uuids,
|
|
50659
|
-
inContext
|
|
50660
|
-
});
|
|
50661
|
-
let result = addParticipants({
|
|
50662
|
-
tournamentRecord,
|
|
50663
|
-
participants
|
|
50664
|
-
});
|
|
50665
|
-
if (result.error) return result;
|
|
50666
|
-
|
|
50667
|
-
if (teamKey) {
|
|
50668
|
-
const result = generateTeamsFromParticipantAttribute({
|
|
50669
|
-
tournamentRecord,
|
|
50670
|
-
...teamKey
|
|
50671
|
-
});
|
|
50672
|
-
if (result.error) return result;
|
|
50889
|
+
if (event !== null && event !== void 0 && event.gender) {
|
|
50890
|
+
eventProfile.gender = event.gender;
|
|
50673
50891
|
}
|
|
50674
|
-
}
|
|
50892
|
+
});
|
|
50893
|
+
const result = addTournamentParticipants({
|
|
50894
|
+
startDate: tournamentRecord.startDate,
|
|
50895
|
+
participantsProfile,
|
|
50896
|
+
tournamentRecord,
|
|
50897
|
+
eventProfiles,
|
|
50898
|
+
// drawProfiles,
|
|
50899
|
+
uuids
|
|
50900
|
+
});
|
|
50901
|
+
if (!result.success) return result;
|
|
50675
50902
|
|
|
50676
50903
|
if (eventProfiles) {
|
|
50677
50904
|
for (const eventProfile of eventProfiles) {
|
|
50678
50905
|
let {
|
|
50679
50906
|
ratingsParameters
|
|
50680
50907
|
} = eventProfile;
|
|
50681
|
-
const event = tournamentRecord.events.find(event => eventProfile.eventName && event.eventName === eventProfile.eventName || eventProfile.eventId && event.eventId === eventProfile.eventId);
|
|
50908
|
+
const event = tournamentRecord.events.find((event, index) => eventProfile.eventIndex !== undefined && index === eventProfile.eventIndex || eventProfile.eventName && event.eventName === eventProfile.eventName || eventProfile.eventId && event.eventId === eventProfile.eventId);
|
|
50682
50909
|
if (!event) return {
|
|
50683
50910
|
error: EVENT_NOT_FOUND
|
|
50684
50911
|
};
|
|
@@ -50857,12 +51084,6 @@ function generateSchedulingProfile({
|
|
|
50857
51084
|
};
|
|
50858
51085
|
}
|
|
50859
51086
|
|
|
50860
|
-
// import { addDrawDefinition } from '../../tournamentEngine/governors/eventGovernor/drawDefinitions/addDrawDefinition';
|
|
50861
|
-
// import {
|
|
50862
|
-
// MAIN,
|
|
50863
|
-
// ROUND_ROBIN_WITH_PLAYOFF,
|
|
50864
|
-
// } from '../../constants/drawDefinitionConstants';
|
|
50865
|
-
|
|
50866
51087
|
function generateEventWithFlights({
|
|
50867
51088
|
allUniqueParticipantIds,
|
|
50868
51089
|
matchUpStatusProfile,
|
|
@@ -50873,7 +51094,6 @@ function generateEventWithFlights({
|
|
|
50873
51094
|
ratingsParameters,
|
|
50874
51095
|
tournamentRecord,
|
|
50875
51096
|
eventProfile,
|
|
50876
|
-
// startDate,
|
|
50877
51097
|
uuids
|
|
50878
51098
|
}) {
|
|
50879
51099
|
let gender = eventProfile.gender;
|
|
@@ -51002,120 +51222,6 @@ function generateEventWithFlights({
|
|
|
51002
51222
|
});
|
|
51003
51223
|
if (result.error) return result;
|
|
51004
51224
|
const drawIds = result.drawIds;
|
|
51005
|
-
/*
|
|
51006
|
-
const drawIds = [];
|
|
51007
|
-
const { flightProfile } = getFlightProfile({ event });
|
|
51008
|
-
if (Array.isArray(flightProfile?.flights)) {
|
|
51009
|
-
for (const [index, flight] of flightProfile.flights.entries()) {
|
|
51010
|
-
const { drawId, stage, drawName, drawEntries } = flight;
|
|
51011
|
-
drawIds.push(flight.drawId);
|
|
51012
|
-
const drawProfile = drawProfiles[index];
|
|
51013
|
-
const { seedsCount, generate = true } = drawProfile || {};
|
|
51014
|
-
if (generate) {
|
|
51015
|
-
const drawParticipantIds = drawEntries
|
|
51016
|
-
.filter(hasParticipantId)
|
|
51017
|
-
.map(getParticipantId);
|
|
51018
|
-
const seedingScaleName = categoryName || eventName;
|
|
51019
|
-
if (
|
|
51020
|
-
tournamentRecord &&
|
|
51021
|
-
seedsCount &&
|
|
51022
|
-
seedsCount <= drawParticipantIds.length
|
|
51023
|
-
) {
|
|
51024
|
-
const scaleValues = generateRange(1, seedsCount + 1);
|
|
51025
|
-
scaleValues.forEach((scaleValue, index) => {
|
|
51026
|
-
let scaleItem = {
|
|
51027
|
-
scaleValue,
|
|
51028
|
-
scaleName: seedingScaleName,
|
|
51029
|
-
scaleType: SEEDING,
|
|
51030
|
-
eventType,
|
|
51031
|
-
scaleDate: startDate,
|
|
51032
|
-
};
|
|
51033
|
-
const participantId = drawParticipantIds[index];
|
|
51034
|
-
setParticipantScaleItem({
|
|
51035
|
-
tournamentRecord,
|
|
51036
|
-
participantId,
|
|
51037
|
-
scaleItem,
|
|
51038
|
-
});
|
|
51039
|
-
});
|
|
51040
|
-
}
|
|
51041
|
-
let result = generateDrawDefinition({
|
|
51042
|
-
...drawProfile,
|
|
51043
|
-
matchUpType: eventType,
|
|
51044
|
-
seedingScaleName,
|
|
51045
|
-
tournamentRecord,
|
|
51046
|
-
isMock: true,
|
|
51047
|
-
drawEntries,
|
|
51048
|
-
drawName,
|
|
51049
|
-
drawId,
|
|
51050
|
-
event,
|
|
51051
|
-
stage,
|
|
51052
|
-
});
|
|
51053
|
-
const { drawDefinition, error } = result;
|
|
51054
|
-
if (error) return { error };
|
|
51055
|
-
const drawExtensions = drawProfiles[index]?.drawExtensions;
|
|
51056
|
-
if (Array.isArray(drawExtensions)) {
|
|
51057
|
-
drawExtensions
|
|
51058
|
-
.filter(isValidExtension)
|
|
51059
|
-
.forEach((extension) =>
|
|
51060
|
-
addExtension({ element: drawDefinition, extension })
|
|
51061
|
-
);
|
|
51062
|
-
}
|
|
51063
|
-
result = addDrawDefinition({
|
|
51064
|
-
drawDefinition,
|
|
51065
|
-
event,
|
|
51066
|
-
});
|
|
51067
|
-
if (result.error) return result;
|
|
51068
|
-
if (drawProfile?.withPlayoffs) {
|
|
51069
|
-
const structureId = drawDefinition.structures[0].structureId;
|
|
51070
|
-
const result = addPlayoffStructures({
|
|
51071
|
-
idPrefix: drawProfile.idPrefix,
|
|
51072
|
-
...drawProfile.withPlayoffs,
|
|
51073
|
-
tournamentRecord,
|
|
51074
|
-
drawDefinition,
|
|
51075
|
-
isMock: true,
|
|
51076
|
-
structureId,
|
|
51077
|
-
event,
|
|
51078
|
-
});
|
|
51079
|
-
if (result?.error) return result;
|
|
51080
|
-
}
|
|
51081
|
-
// TODO: enable { outcomes: [] } in eventProfile: { drawProfiles }
|
|
51082
|
-
const manual = drawProfile?.automated === false;
|
|
51083
|
-
if (!manual && completeAllMatchUps) {
|
|
51084
|
-
const matchUpFormat = drawProfile?.matchUpFormat;
|
|
51085
|
-
const result = completeDrawMatchUps({
|
|
51086
|
-
matchUpStatusProfile,
|
|
51087
|
-
completeAllMatchUps,
|
|
51088
|
-
randomWinningSide,
|
|
51089
|
-
drawDefinition,
|
|
51090
|
-
matchUpFormat,
|
|
51091
|
-
});
|
|
51092
|
-
if (result.error) return result;
|
|
51093
|
-
if (drawProfile?.drawType === ROUND_ROBIN_WITH_PLAYOFF) {
|
|
51094
|
-
const mainStructure = drawDefinition.structures.find(
|
|
51095
|
-
(structure) => structure.stage === MAIN
|
|
51096
|
-
);
|
|
51097
|
-
let result = automatedPlayoffPositioning({
|
|
51098
|
-
structureId: mainStructure.structureId,
|
|
51099
|
-
tournamentRecord,
|
|
51100
|
-
drawDefinition,
|
|
51101
|
-
event,
|
|
51102
|
-
});
|
|
51103
|
-
if (result.error) return result;
|
|
51104
|
-
result = completeDrawMatchUps({
|
|
51105
|
-
completeAllMatchUps,
|
|
51106
|
-
matchUpStatusProfile,
|
|
51107
|
-
randomWinningSide,
|
|
51108
|
-
matchUpFormat,
|
|
51109
|
-
drawDefinition,
|
|
51110
|
-
});
|
|
51111
|
-
if (result.error) return result;
|
|
51112
|
-
}
|
|
51113
|
-
}
|
|
51114
|
-
}
|
|
51115
|
-
}
|
|
51116
|
-
}
|
|
51117
|
-
*/
|
|
51118
|
-
|
|
51119
51225
|
return {
|
|
51120
51226
|
drawIds,
|
|
51121
51227
|
eventId,
|
|
@@ -51123,43 +51229,6 @@ function generateEventWithFlights({
|
|
|
51123
51229
|
};
|
|
51124
51230
|
}
|
|
51125
51231
|
|
|
51126
|
-
function processTieFormat({
|
|
51127
|
-
tieFormat,
|
|
51128
|
-
tieFormatName,
|
|
51129
|
-
drawSize,
|
|
51130
|
-
alternatesCount = 0
|
|
51131
|
-
}) {
|
|
51132
|
-
var _tieFormat, _tieFormat$collection;
|
|
51133
|
-
|
|
51134
|
-
let maxDoublesCount = 0,
|
|
51135
|
-
maxSinglesCount = 0;
|
|
51136
|
-
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
51137
|
-
namedFormat: tieFormatName
|
|
51138
|
-
});
|
|
51139
|
-
(_tieFormat = tieFormat) === null || _tieFormat === void 0 ? void 0 : (_tieFormat$collection = _tieFormat.collectionDefinitions) === null || _tieFormat$collection === void 0 ? void 0 : _tieFormat$collection.forEach(collectionDefinition => {
|
|
51140
|
-
// ensure every collectionDefinition has a collectionId
|
|
51141
|
-
if (!collectionDefinition.collectionId) collectionDefinition.collectionId = UUID();
|
|
51142
|
-
|
|
51143
|
-
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === DOUBLES$1) {
|
|
51144
|
-
const doublesCount = collectionDefinition.matchUpCount;
|
|
51145
|
-
maxDoublesCount = Math.max(maxDoublesCount, doublesCount);
|
|
51146
|
-
}
|
|
51147
|
-
|
|
51148
|
-
if ((collectionDefinition === null || collectionDefinition === void 0 ? void 0 : collectionDefinition.matchUpType) === SINGLES$1) {
|
|
51149
|
-
const singlescount = collectionDefinition.matchUpCount;
|
|
51150
|
-
maxSinglesCount = Math.max(maxSinglesCount, singlescount);
|
|
51151
|
-
}
|
|
51152
|
-
});
|
|
51153
|
-
const teamSize = Math.max(maxSinglesCount, maxDoublesCount * 2);
|
|
51154
|
-
const maxDoublesDraw = maxDoublesCount * (drawSize + alternatesCount);
|
|
51155
|
-
const maxSinglesDraw = maxSinglesCount * (drawSize + alternatesCount);
|
|
51156
|
-
return {
|
|
51157
|
-
maxDoublesDraw,
|
|
51158
|
-
maxSinglesDraw,
|
|
51159
|
-
teamSize
|
|
51160
|
-
};
|
|
51161
|
-
}
|
|
51162
|
-
|
|
51163
51232
|
function generateEventWithDraw({
|
|
51164
51233
|
allUniqueParticipantIds = [],
|
|
51165
51234
|
matchUpStatusProfile,
|
|
@@ -51271,7 +51340,7 @@ function generateEventWithDraw({
|
|
|
51271
51340
|
});
|
|
51272
51341
|
|
|
51273
51342
|
if (tournamentRecord) {
|
|
51274
|
-
|
|
51343
|
+
const result = addParticipants({
|
|
51275
51344
|
tournamentRecord,
|
|
51276
51345
|
participants: unique
|
|
51277
51346
|
});
|
|
@@ -51331,22 +51400,26 @@ function generateEventWithDraw({
|
|
|
51331
51400
|
participantId
|
|
51332
51401
|
}) => !allUniqueParticipantIds.includes(participantId));
|
|
51333
51402
|
const participantIds = consideredParticipants.slice(0, participantsCount).map(p => p.participantId);
|
|
51334
|
-
|
|
51335
|
-
|
|
51336
|
-
|
|
51337
|
-
|
|
51338
|
-
|
|
51339
|
-
|
|
51340
|
-
|
|
51341
|
-
|
|
51403
|
+
|
|
51404
|
+
if (participantIds !== null && participantIds !== void 0 && participantIds.length) {
|
|
51405
|
+
const result = addEventEntries({
|
|
51406
|
+
autoEntryPositions,
|
|
51407
|
+
entryStage: stage,
|
|
51408
|
+
tournamentRecord,
|
|
51409
|
+
participantIds,
|
|
51410
|
+
event
|
|
51411
|
+
});
|
|
51412
|
+
if (result.error) return result;
|
|
51413
|
+
} // alternates can still be taken from existing participants
|
|
51342
51414
|
// when unique participants are used for DIRECT_ACCEPTANCE entries
|
|
51343
51415
|
|
|
51416
|
+
|
|
51344
51417
|
const alternatesParticipantIds = excessParticipantAlternates && (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : (_tournamentRecord$par = tournamentRecord.participants) === null || _tournamentRecord$par === void 0 ? void 0 : _tournamentRecord$par.filter(({
|
|
51345
51418
|
participantId
|
|
51346
51419
|
}) => !participantIds.includes(participantId)).filter(isEventParticipantType).filter(isEventGender).slice(0, alternatesCount || drawSize - participantsCount).map(p => p.participantId));
|
|
51347
51420
|
|
|
51348
51421
|
if (alternatesParticipantIds !== null && alternatesParticipantIds !== void 0 && alternatesParticipantIds.length) {
|
|
51349
|
-
result = addEventEntries({
|
|
51422
|
+
const result = addEventEntries({
|
|
51350
51423
|
participantIds: alternatesParticipantIds,
|
|
51351
51424
|
autoEntryPositions: false,
|
|
51352
51425
|
entryStatus: ALTERNATE,
|
|
@@ -51518,9 +51591,6 @@ function generateEventWithDraw({
|
|
|
51518
51591
|
}
|
|
51519
51592
|
}
|
|
51520
51593
|
|
|
51521
|
-
if (result.error) return {
|
|
51522
|
-
error: result.error
|
|
51523
|
-
};
|
|
51524
51594
|
return { ...SUCCESS,
|
|
51525
51595
|
event: definedAttributes(event),
|
|
51526
51596
|
uniqueParticipantIds,
|
|
@@ -51623,12 +51693,6 @@ function generateTournamentRecord({
|
|
|
51623
51693
|
goesTo,
|
|
51624
51694
|
uuids
|
|
51625
51695
|
} = {}) {
|
|
51626
|
-
let {
|
|
51627
|
-
participantsCount,
|
|
51628
|
-
participantType = INDIVIDUAL$1
|
|
51629
|
-
} = participantsProfile || {};
|
|
51630
|
-
const specifiedParicipantsCount = participantsCount || 0; // capture this to ensure calculated participantsCount is not below
|
|
51631
|
-
|
|
51632
51696
|
if (startDate && !isValidDateString(startDate) || endDate && !isValidDateString(endDate)) return {
|
|
51633
51697
|
error: INVALID_DATE
|
|
51634
51698
|
};
|
|
@@ -51670,165 +51734,13 @@ function generateTournamentRecord({
|
|
|
51670
51734
|
}
|
|
51671
51735
|
}
|
|
51672
51736
|
|
|
51673
|
-
|
|
51674
|
-
|
|
51675
|
-
largestTeamSize = 0,
|
|
51676
|
-
largestTeamDraw = 0;
|
|
51677
|
-
|
|
51678
|
-
const processDrawProfile = ({
|
|
51679
|
-
alternatesCount = 0,
|
|
51680
|
-
uniqueParticipants,
|
|
51681
|
-
tieFormatName,
|
|
51682
|
-
drawSize = 0,
|
|
51683
|
-
eventType,
|
|
51684
|
-
tieFormat,
|
|
51685
|
-
category,
|
|
51686
|
-
gender,
|
|
51687
|
-
stage
|
|
51688
|
-
}) => {
|
|
51689
|
-
const isDoubles = eventType === DOUBLES;
|
|
51690
|
-
const isTeam = eventType === TEAM$2;
|
|
51691
|
-
const requiresUniqueParticipants = uniqueParticipants || stage === QUALIFYING || category || gender;
|
|
51692
|
-
|
|
51693
|
-
if (isTeam && !requiresUniqueParticipants) {
|
|
51694
|
-
largestTeamDraw = Math.max(largestTeamDraw, drawSize + alternatesCount);
|
|
51695
|
-
tieFormat = typeof tieFormat === 'object' ? tieFormat : tieFormatDefaults({
|
|
51696
|
-
namedFormat: tieFormatName
|
|
51697
|
-
});
|
|
51698
|
-
const {
|
|
51699
|
-
teamSize,
|
|
51700
|
-
maxDoublesDraw,
|
|
51701
|
-
maxSinglesDraw
|
|
51702
|
-
} = processTieFormat({
|
|
51703
|
-
alternatesCount,
|
|
51704
|
-
tieFormatName,
|
|
51705
|
-
tieFormat,
|
|
51706
|
-
drawSize
|
|
51707
|
-
});
|
|
51708
|
-
largestTeamSize = Math.max(largestTeamSize, teamSize);
|
|
51709
|
-
largestDoublesDraw = Math.max(largestDoublesDraw, maxDoublesDraw);
|
|
51710
|
-
largestSinglesDraw = Math.max(largestSinglesDraw, maxSinglesDraw);
|
|
51711
|
-
}
|
|
51712
|
-
|
|
51713
|
-
if (isDoubles && drawSize + alternatesCount && drawSize + alternatesCount > largestDoublesDraw) {
|
|
51714
|
-
largestDoublesDraw = drawSize + alternatesCount;
|
|
51715
|
-
}
|
|
51716
|
-
|
|
51717
|
-
if (!isDoubles && !isTeam && drawSize && drawSize > largestSinglesDraw) {
|
|
51718
|
-
largestSinglesDraw = drawSize + alternatesCount;
|
|
51719
|
-
}
|
|
51720
|
-
};
|
|
51721
|
-
|
|
51722
|
-
eventProfiles === null || eventProfiles === void 0 ? void 0 : eventProfiles.forEach(eventProfile => {
|
|
51723
|
-
const {
|
|
51724
|
-
tieFormatName: eventTieFormatName,
|
|
51725
|
-
tieFormat: eventTieFormat,
|
|
51726
|
-
drawProfiles,
|
|
51727
|
-
eventType,
|
|
51728
|
-
category
|
|
51729
|
-
} = eventProfile;
|
|
51730
|
-
|
|
51731
|
-
if (drawProfiles) {
|
|
51732
|
-
for (const drawProfile of drawProfiles) {
|
|
51733
|
-
const {
|
|
51734
|
-
tieFormatName,
|
|
51735
|
-
tieFormat
|
|
51736
|
-
} = drawProfile;
|
|
51737
|
-
processDrawProfile({ ...drawProfile,
|
|
51738
|
-
tieFormatName: tieFormatName || eventTieFormatName,
|
|
51739
|
-
tieFormat: tieFormat || eventTieFormat,
|
|
51740
|
-
eventType,
|
|
51741
|
-
category
|
|
51742
|
-
});
|
|
51743
|
-
}
|
|
51744
|
-
}
|
|
51745
|
-
});
|
|
51746
|
-
|
|
51747
|
-
if (drawProfiles) {
|
|
51748
|
-
for (const drawProfile of drawProfiles) {
|
|
51749
|
-
processDrawProfile(drawProfile);
|
|
51750
|
-
}
|
|
51751
|
-
}
|
|
51752
|
-
|
|
51753
|
-
const individualCompetitorsCount = Math.max(largestTeamDraw * largestTeamSize, largestDoublesDraw * 2, largestSinglesDraw);
|
|
51754
|
-
if (largestDoublesDraw) participantType = PAIR$1;
|
|
51755
|
-
if ((participantsCount || specifiedParicipantsCount) < individualCompetitorsCount) participantsCount = individualCompetitorsCount;
|
|
51756
|
-
|
|
51757
|
-
if (participantsCount && largestDoublesDraw && [PAIR$1, TEAM$2].includes(participantType)) {
|
|
51758
|
-
// if we are generating PAIRs or TEAMs...
|
|
51759
|
-
if (largestSinglesDraw && Math.floor(largestSinglesDraw / 2) > largestDoublesDraw) {
|
|
51760
|
-
// if the half the singles draw is still larger than doubles draw
|
|
51761
|
-
participantsCount = Math.floor(largestSinglesDraw / 2);
|
|
51762
|
-
} else if (!largestSinglesDraw || largestDoublesDraw * 2 >= largestSinglesDraw) {
|
|
51763
|
-
// otherwise participantsCount can be cut in half
|
|
51764
|
-
participantsCount = Math.ceil(participantsCount / 2);
|
|
51765
|
-
}
|
|
51766
|
-
}
|
|
51767
|
-
|
|
51768
|
-
if (participantsCount === undefined) participantsCount = 32;
|
|
51769
|
-
if (participantsCount < specifiedParicipantsCount) participantsCount = specifiedParicipantsCount;
|
|
51770
|
-
const {
|
|
51771
|
-
nationalityCodesCount,
|
|
51772
|
-
nationalityCodeType,
|
|
51773
|
-
valuesInstanceLimit,
|
|
51774
|
-
nationalityCodes,
|
|
51775
|
-
personExtensions,
|
|
51776
|
-
addressProps,
|
|
51777
|
-
personData,
|
|
51778
|
-
personIds,
|
|
51779
|
-
inContext,
|
|
51780
|
-
teamKey,
|
|
51781
|
-
sex
|
|
51782
|
-
} = participantsProfile || {};
|
|
51783
|
-
const {
|
|
51784
|
-
participants
|
|
51785
|
-
} = generateParticipants({
|
|
51786
|
-
consideredDate: startDate,
|
|
51787
|
-
valuesInstanceLimit,
|
|
51788
|
-
nationalityCodesCount,
|
|
51789
|
-
nationalityCodeType,
|
|
51790
|
-
nationalityCodes,
|
|
51791
|
-
personExtensions,
|
|
51792
|
-
addressProps,
|
|
51793
|
-
personData,
|
|
51794
|
-
sex,
|
|
51795
|
-
participantsCount,
|
|
51796
|
-
participantType,
|
|
51797
|
-
personIds,
|
|
51798
|
-
uuids,
|
|
51799
|
-
inContext
|
|
51800
|
-
});
|
|
51801
|
-
let result = addParticipants({
|
|
51802
|
-
tournamentRecord,
|
|
51803
|
-
participants
|
|
51804
|
-
});
|
|
51805
|
-
if (!result.success) return result;
|
|
51806
|
-
|
|
51807
|
-
if (teamKey) {
|
|
51808
|
-
const result = generateTeamsFromParticipantAttribute({
|
|
51809
|
-
tournamentRecord,
|
|
51810
|
-
...teamKey
|
|
51811
|
-
});
|
|
51812
|
-
if (result.error) return result;
|
|
51813
|
-
} // generate Team participants
|
|
51814
|
-
|
|
51815
|
-
|
|
51816
|
-
const allIndividualParticipantIds = participants.filter(({
|
|
51817
|
-
participantType
|
|
51818
|
-
}) => participantType === INDIVIDUAL$1).map(getParticipantId);
|
|
51819
|
-
const teamParticipants = generateRange(0, largestTeamDraw).map(teamIndex => {
|
|
51820
|
-
const individualParticipantIds = allIndividualParticipantIds.slice(teamIndex * largestTeamSize, (teamIndex + 1) * largestTeamSize);
|
|
51821
|
-
return {
|
|
51822
|
-
participantName: `Team ${teamIndex + 1}`,
|
|
51823
|
-
participantRole: COMPETITOR,
|
|
51824
|
-
participantType: TEAM$2,
|
|
51825
|
-
participantId: UUID(),
|
|
51826
|
-
individualParticipantIds
|
|
51827
|
-
};
|
|
51828
|
-
});
|
|
51829
|
-
result = addParticipants({
|
|
51737
|
+
const result = addTournamentParticipants({
|
|
51738
|
+
participantsProfile,
|
|
51830
51739
|
tournamentRecord,
|
|
51831
|
-
|
|
51740
|
+
eventProfiles,
|
|
51741
|
+
drawProfiles,
|
|
51742
|
+
startDate,
|
|
51743
|
+
uuids
|
|
51832
51744
|
});
|
|
51833
51745
|
if (!result.success) return result;
|
|
51834
51746
|
const drawIds = [],
|
|
@@ -51854,7 +51766,8 @@ function generateTournamentRecord({
|
|
|
51854
51766
|
tournamentRecord,
|
|
51855
51767
|
drawProfile,
|
|
51856
51768
|
startDate,
|
|
51857
|
-
goesTo
|
|
51769
|
+
goesTo,
|
|
51770
|
+
uuids
|
|
51858
51771
|
});
|
|
51859
51772
|
if (error) return {
|
|
51860
51773
|
error
|
|
@@ -51887,7 +51800,8 @@ function generateTournamentRecord({
|
|
|
51887
51800
|
ratingsParameters: ratingsParameters$1,
|
|
51888
51801
|
tournamentRecord,
|
|
51889
51802
|
eventProfile,
|
|
51890
|
-
startDate
|
|
51803
|
+
startDate,
|
|
51804
|
+
uuids
|
|
51891
51805
|
});
|
|
51892
51806
|
if (error) return {
|
|
51893
51807
|
error
|