tods-competition-factory 1.8.21 → 1.8.23
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/forge/generate.mjs +34 -23
- package/dist/forge/generate.mjs.map +1 -1
- package/dist/forge/query.mjs +21 -17
- package/dist/forge/query.mjs.map +1 -1
- package/dist/forge/transform.mjs +11 -6
- package/dist/forge/transform.mjs.map +1 -1
- package/dist/index.mjs +217 -208
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.development.cjs.js +482 -465
- 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/package.json +5 -5
package/dist/index.mjs
CHANGED
|
@@ -2382,7 +2382,7 @@ const matchUpFormatCode = {
|
|
|
2382
2382
|
};
|
|
2383
2383
|
|
|
2384
2384
|
function factoryVersion() {
|
|
2385
|
-
return "1.8.
|
|
2385
|
+
return "1.8.23";
|
|
2386
2386
|
}
|
|
2387
2387
|
|
|
2388
2388
|
function getObjectTieFormat(obj) {
|
|
@@ -4857,7 +4857,7 @@ function getMatchUpFormatTiming({
|
|
|
4857
4857
|
}) {
|
|
4858
4858
|
if (!tournamentRecord)
|
|
4859
4859
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
4860
|
-
eventType = eventType
|
|
4860
|
+
eventType = eventType ?? event?.eventType ?? TypeEnum.Singles;
|
|
4861
4861
|
const defaultTiming = {
|
|
4862
4862
|
averageTimes: [{ minutes: { default: defaultAverageMinutes } }],
|
|
4863
4863
|
recoveryTimes: [{ minutes: { default: defaultRecoveryMinutes } }]
|
|
@@ -5507,7 +5507,7 @@ function findVenue({
|
|
|
5507
5507
|
if (!venue && tournamentRecords) {
|
|
5508
5508
|
const linkedTournamentIds = getLinkedTournamentIds({
|
|
5509
5509
|
tournamentRecords
|
|
5510
|
-
}).linkedTournamentIds
|
|
5510
|
+
}).linkedTournamentIds ?? [];
|
|
5511
5511
|
const relevantIds = linkedTournamentIds[tournamentRecord.tournamentId];
|
|
5512
5512
|
for (const tournamentId of relevantIds) {
|
|
5513
5513
|
const record = tournamentRecords[tournamentId];
|
|
@@ -6185,7 +6185,7 @@ function getPairedParticipant({
|
|
|
6185
6185
|
result: { error: MISSING_PARTICIPANT_IDS },
|
|
6186
6186
|
stack
|
|
6187
6187
|
});
|
|
6188
|
-
tournamentParticipants = tournamentParticipants
|
|
6188
|
+
tournamentParticipants = tournamentParticipants ?? tournamentRecord?.participants ?? [];
|
|
6189
6189
|
const existingPairedParticipants = tournamentParticipants.filter(
|
|
6190
6190
|
(participant) => participant.participantType === PAIR && intersection(participantIds, participant.individualParticipantIds).length === participantIds.length && participant.individualParticipantIds.length === participantIds.length
|
|
6191
6191
|
);
|
|
@@ -6778,7 +6778,6 @@ const DIRECT_ENTRY_STATUSES = [
|
|
|
6778
6778
|
const STRUCTURE_SELECTED_STATUSES = [
|
|
6779
6779
|
CONFIRMED,
|
|
6780
6780
|
DIRECT_ACCEPTANCE,
|
|
6781
|
-
FEED_IN,
|
|
6782
6781
|
JUNIOR_EXEMPT,
|
|
6783
6782
|
LUCKY_LOSER,
|
|
6784
6783
|
QUALIFIER,
|
|
@@ -7825,7 +7824,7 @@ function getRoundContextProfile({
|
|
|
7825
7824
|
...(drawDefinition?.structures ?? []).filter((structure2) => structure2.stage === QUALIFYING).map(({ stageSequence }) => stageSequence ?? 1),
|
|
7826
7825
|
0
|
|
7827
7826
|
) : 0;
|
|
7828
|
-
const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence
|
|
7827
|
+
const preQualifyingSequence = qualifyingStageSequences ? qualifyingStageSequences - (structure.stageSequence ?? 1) || "" : "";
|
|
7829
7828
|
const preQualifyingAffix = preQualifyingSequence ? roundNamingPolicy?.affixes?.preQualifying || defaultRoundNamingPolicy.affixes.preQualifying || "" : "";
|
|
7830
7829
|
const roundNamingMap = roundNamingPolicy?.roundNamingMap || defaultRoundNamingPolicy.roundNamingMap || {};
|
|
7831
7830
|
const abbreviatedRoundNamingMap = roundNamingPolicy?.abbreviatedRoundNamingMap || defaultRoundNamingPolicy.abbreviatedRoundNamingMap || {};
|
|
@@ -8134,7 +8133,13 @@ function getAllStructureMatchUps({
|
|
|
8134
8133
|
matchUps
|
|
8135
8134
|
}));
|
|
8136
8135
|
}
|
|
8137
|
-
return {
|
|
8136
|
+
return {
|
|
8137
|
+
collectionPositionMatchUps,
|
|
8138
|
+
roundMatchUps,
|
|
8139
|
+
roundProfile,
|
|
8140
|
+
matchUpsMap,
|
|
8141
|
+
matchUps
|
|
8142
|
+
};
|
|
8138
8143
|
function addMatchUpContext({
|
|
8139
8144
|
scheduleVisibilityFilters: scheduleVisibilityFilters2,
|
|
8140
8145
|
sourceDrawPositionRanges,
|
|
@@ -17812,7 +17817,7 @@ function parseScoreString({
|
|
|
17812
17817
|
isSide1: winningSide === 2,
|
|
17813
17818
|
tiebreakTo
|
|
17814
17819
|
});
|
|
17815
|
-
const setTiebreak = side1TiebreakPerspective
|
|
17820
|
+
const setTiebreak = side1TiebreakPerspective ?? [];
|
|
17816
17821
|
const [side1Score, side2Score] = setScores || [];
|
|
17817
17822
|
const [side1TiebreakScore, side2TiebreakScore] = matchTiebreak || setTiebreak || [];
|
|
17818
17823
|
return {
|
|
@@ -18002,7 +18007,9 @@ function getSuper(values, index) {
|
|
|
18002
18007
|
values.slice(index, index + 2),
|
|
18003
18008
|
index ? values.slice(0, 1) : values.slice(2)
|
|
18004
18009
|
].map((n) => parseInt(n.join("")));
|
|
18005
|
-
|
|
18010
|
+
if (index)
|
|
18011
|
+
parts.reverse();
|
|
18012
|
+
const scores = parts;
|
|
18006
18013
|
const diff = Math.abs(scores.reduce((a, b) => +a - +b));
|
|
18007
18014
|
if (diff >= 2)
|
|
18008
18015
|
return scores.join("-");
|
|
@@ -19013,7 +19020,7 @@ function handleNumeric(params) {
|
|
|
19013
19020
|
if (superParse && score !== superParse) {
|
|
19014
19021
|
applied.push("parsedSuperPattern");
|
|
19015
19022
|
}
|
|
19016
|
-
score = superParse
|
|
19023
|
+
score = superParse ?? score;
|
|
19017
19024
|
}
|
|
19018
19025
|
}
|
|
19019
19026
|
return { score, applied, matchUpStatus };
|
|
@@ -19054,7 +19061,9 @@ function sensibleSets({ score, matchUpStatus, attributes }) {
|
|
|
19054
19061
|
const maxSetScore = Math.max(...sideScores);
|
|
19055
19062
|
const maxIndex = setScores.indexOf(maxSetScore);
|
|
19056
19063
|
const sensibleSetScores = [maxSetScore, maxSetScore - 1];
|
|
19057
|
-
|
|
19064
|
+
if (maxIndex)
|
|
19065
|
+
sensibleSetScores.reverse();
|
|
19066
|
+
const sensibleSetScore = sensibleSetScores.join("-");
|
|
19058
19067
|
return sensibleSetScore + tiebreak;
|
|
19059
19068
|
}
|
|
19060
19069
|
} else if (set.length === 2 && isNumeric(set)) {
|
|
@@ -19073,7 +19082,7 @@ function sensibleSets({ score, matchUpStatus, attributes }) {
|
|
|
19073
19082
|
const splitMax = max.toString().split("");
|
|
19074
19083
|
const reasonable = splitMax.find(
|
|
19075
19084
|
(value) => parseInt(value) > min || index && parseInt(value) <= maxSetValue
|
|
19076
|
-
)
|
|
19085
|
+
) ?? splitMax[0];
|
|
19077
19086
|
if (reasonable) {
|
|
19078
19087
|
set = minIndex ? [reasonable, min].join("-") : [min, reasonable].join("-");
|
|
19079
19088
|
}
|
|
@@ -19537,7 +19546,6 @@ function getVenuesAndCourts({
|
|
|
19537
19546
|
tournamentIds.forEach((tournamentId) => {
|
|
19538
19547
|
const tournamentRecord = tournamentRecords[tournamentId];
|
|
19539
19548
|
for (const venue of tournamentRecord.venues || []) {
|
|
19540
|
-
tournamentRecord.venues;
|
|
19541
19549
|
if (venueIds.length && !venueIds.includes(venue.venueId))
|
|
19542
19550
|
continue;
|
|
19543
19551
|
if (ignoreDisabled) {
|
|
@@ -21008,7 +21016,7 @@ function getContainedStructures({
|
|
|
21008
21016
|
const containerStructures = {};
|
|
21009
21017
|
const structureContainers = drawDefinitions.map((dd) => dd?.structures?.filter((structure) => structure?.structures)).flat().filter(Boolean);
|
|
21010
21018
|
for (const structureContainer of structureContainers) {
|
|
21011
|
-
const { structures, structureId } = structureContainer
|
|
21019
|
+
const { structures, structureId } = structureContainer ?? {};
|
|
21012
21020
|
structures && structureId && (containedStructures[structureId] = structures?.map(
|
|
21013
21021
|
(structure) => structure.structureId
|
|
21014
21022
|
)) && structures.forEach(
|
|
@@ -27876,7 +27884,7 @@ function filterParticipants({
|
|
|
27876
27884
|
);
|
|
27877
27885
|
if (event.eventType === SINGLES)
|
|
27878
27886
|
return enteredParticipantIds;
|
|
27879
|
-
const individualParticipantIds = (tournamentRecord?.participants
|
|
27887
|
+
const individualParticipantIds = (tournamentRecord?.participants ?? []).filter(
|
|
27880
27888
|
(participant) => enteredParticipantIds.includes(participant.participantId)
|
|
27881
27889
|
).map((participant) => participant.individualParticipantIds).flat(1);
|
|
27882
27890
|
return enteredParticipantIds.concat(...individualParticipantIds);
|
|
@@ -28243,7 +28251,7 @@ function addPenalty$1({
|
|
|
28243
28251
|
return { error: MISSING_PARTICIPANT_ID };
|
|
28244
28252
|
if (!penaltyType)
|
|
28245
28253
|
return { error: MISSING_PENALTY_TYPE };
|
|
28246
|
-
const participants = tournamentRecord?.participants
|
|
28254
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28247
28255
|
const relevantParticipants = participants.filter(
|
|
28248
28256
|
(participant) => participantIds.includes(participant.participantId)
|
|
28249
28257
|
);
|
|
@@ -28286,13 +28294,13 @@ function removePenalty$1({
|
|
|
28286
28294
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
28287
28295
|
if (!penaltyId)
|
|
28288
28296
|
return { error: MISSING_PENALTY_ID };
|
|
28289
|
-
const participants = tournamentRecord?.participants
|
|
28297
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28290
28298
|
const modifiedParticipants = [];
|
|
28291
28299
|
let penaltyRemoved = false;
|
|
28292
28300
|
let removedPenalty;
|
|
28293
28301
|
participants.forEach((participant) => {
|
|
28294
28302
|
let participantModified = false;
|
|
28295
|
-
participant.penalties = (participant.penalties
|
|
28303
|
+
participant.penalties = (participant.penalties ?? []).filter((penalty) => {
|
|
28296
28304
|
if (penalty.penaltyId === penaltyId) {
|
|
28297
28305
|
participantModified = true;
|
|
28298
28306
|
if (!penaltyRemoved) {
|
|
@@ -28321,10 +28329,10 @@ function getTournamentPenalties({
|
|
|
28321
28329
|
}) {
|
|
28322
28330
|
if (!tournamentRecord)
|
|
28323
28331
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
28324
|
-
const participants = tournamentRecord?.participants
|
|
28332
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28325
28333
|
const allPenalties = participants.reduce((penalties, participant) => {
|
|
28326
28334
|
const { participantId } = participant;
|
|
28327
|
-
(participant.penalties
|
|
28335
|
+
(participant.penalties ?? []).forEach((penalty) => {
|
|
28328
28336
|
const { penaltyId } = penalty || {};
|
|
28329
28337
|
if (penalties[penaltyId]) {
|
|
28330
28338
|
penalties[penaltyId].participants.push(participantId);
|
|
@@ -28350,7 +28358,7 @@ function modifyPenalty$1({
|
|
|
28350
28358
|
return { error: INVALID_VALUES, modifications };
|
|
28351
28359
|
if (!penaltyId)
|
|
28352
28360
|
return { error: MISSING_PENALTY_ID };
|
|
28353
|
-
const participants = tournamentRecord?.participants
|
|
28361
|
+
const participants = tournamentRecord?.participants ?? [];
|
|
28354
28362
|
const validAttributes = Object.keys(penaltyTemplate()).filter(
|
|
28355
28363
|
(attribute) => attribute !== "penaltyId"
|
|
28356
28364
|
);
|
|
@@ -28363,7 +28371,7 @@ function modifyPenalty$1({
|
|
|
28363
28371
|
const modifiedParticipants = [];
|
|
28364
28372
|
participants.forEach((participant) => {
|
|
28365
28373
|
let participantModified = false;
|
|
28366
|
-
participant.penalties = (participant.penalties
|
|
28374
|
+
participant.penalties = (participant.penalties ?? []).map((penalty) => {
|
|
28367
28375
|
if (penalty.penaltyId === penaltyId) {
|
|
28368
28376
|
participantModified = true;
|
|
28369
28377
|
validModificationAttributes.forEach(
|
|
@@ -28400,7 +28408,7 @@ function addPenalty(params) {
|
|
|
28400
28408
|
if (tournamentParticipantIds.length) {
|
|
28401
28409
|
const result = addPenalty$1({
|
|
28402
28410
|
...params,
|
|
28403
|
-
penaltyId: params.penaltyId
|
|
28411
|
+
penaltyId: params.penaltyId ?? penaltyId,
|
|
28404
28412
|
tournamentRecord,
|
|
28405
28413
|
participantIds: tournamentParticipantIds
|
|
28406
28414
|
});
|
|
@@ -28439,7 +28447,7 @@ function getCompetitionPenalties({
|
|
|
28439
28447
|
const allPenalties = [];
|
|
28440
28448
|
for (const tournamentRecord of Object.values(tournamentRecords)) {
|
|
28441
28449
|
const { penalties } = getTournamentPenalties({ tournamentRecord });
|
|
28442
|
-
allPenalties.push(...penalties
|
|
28450
|
+
allPenalties.push(...penalties ?? []);
|
|
28443
28451
|
}
|
|
28444
28452
|
return { penalties: allPenalties };
|
|
28445
28453
|
}
|
|
@@ -33749,18 +33757,18 @@ function clearScheduledMatchUps$1({
|
|
|
33749
33757
|
const inContextMatchUps = allTournamentMatchUps({
|
|
33750
33758
|
matchUpFilters: { scheduledDates },
|
|
33751
33759
|
tournamentRecord
|
|
33752
|
-
}).matchUps
|
|
33760
|
+
}).matchUps ?? [];
|
|
33753
33761
|
const relevantMatchUpIds = inContextMatchUps.filter(
|
|
33754
33762
|
(matchUp) => matchUp.matchUpStatus && !ignoreMatchUpStatuses.includes(matchUp.matchUpStatus) && hasSchedule({ schedule: matchUp.schedule, scheduleAttributes }) && (!venueIds?.length || venueIds.includes(matchUp.schedule.venueId))
|
|
33755
33763
|
).map(getMatchUpId);
|
|
33756
33764
|
const matchUps = allTournamentMatchUps({
|
|
33757
33765
|
tournamentRecord,
|
|
33758
33766
|
inContext: false
|
|
33759
|
-
}).matchUps
|
|
33767
|
+
}).matchUps ?? [];
|
|
33760
33768
|
let clearedScheduleCount = 0;
|
|
33761
33769
|
for (const matchUp of matchUps) {
|
|
33762
33770
|
if (relevantMatchUpIds.includes(matchUp.matchUpId)) {
|
|
33763
|
-
matchUp.timeItems = (matchUp.timeItems
|
|
33771
|
+
matchUp.timeItems = (matchUp.timeItems ?? []).filter(
|
|
33764
33772
|
(timeItem) => timeItem?.itemType && ![
|
|
33765
33773
|
ALLOCATE_COURTS,
|
|
33766
33774
|
ASSIGN_COURT,
|
|
@@ -36713,12 +36721,12 @@ function matchUpActions$1({
|
|
|
36713
36721
|
if (!tournamentRecord)
|
|
36714
36722
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
36715
36723
|
if (!drawId) {
|
|
36716
|
-
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps
|
|
36724
|
+
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps ?? [];
|
|
36717
36725
|
drawId = matchUps.reduce((drawId2, candidate) => {
|
|
36718
36726
|
return candidate.matchUpId === matchUpId ? candidate.drawId : drawId2;
|
|
36719
36727
|
}, void 0);
|
|
36720
|
-
const events = tournamentRecord.events
|
|
36721
|
-
const drawDefinitions = events.map((event2) => event2.drawDefinitions
|
|
36728
|
+
const events = tournamentRecord.events ?? [];
|
|
36729
|
+
const drawDefinitions = events.map((event2) => event2.drawDefinitions ?? []).flat();
|
|
36722
36730
|
drawDefinition = drawDefinitions.reduce(
|
|
36723
36731
|
(drawDefinition2, candidate) => {
|
|
36724
36732
|
return candidate.drawId === drawId ? candidate : drawDefinition2;
|
|
@@ -36732,7 +36740,7 @@ function matchUpActions$1({
|
|
|
36732
36740
|
drawDefinition,
|
|
36733
36741
|
event
|
|
36734
36742
|
});
|
|
36735
|
-
policyDefinitions = policyDefinitions
|
|
36743
|
+
policyDefinitions = policyDefinitions ?? attachedPolicy;
|
|
36736
36744
|
if (drawDefinition) {
|
|
36737
36745
|
return matchUpActions$2({
|
|
36738
36746
|
tournamentParticipants: tournamentRecord.participants,
|
|
@@ -37108,7 +37116,7 @@ function deleteVenue$1({
|
|
|
37108
37116
|
const matchUpsToUnschedule = allTournamentMatchUps({
|
|
37109
37117
|
tournamentRecord,
|
|
37110
37118
|
contextFilters
|
|
37111
|
-
}).matchUps
|
|
37119
|
+
}).matchUps ?? [];
|
|
37112
37120
|
if (!matchUpsToUnschedule.length || force) {
|
|
37113
37121
|
for (const matchUp of matchUpsToUnschedule) {
|
|
37114
37122
|
const result = removeCourtAssignment({
|
|
@@ -37123,7 +37131,7 @@ function deleteVenue$1({
|
|
|
37123
37131
|
return deletionMessage({ matchUpsCount: matchUpsToUnschedule.length });
|
|
37124
37132
|
}
|
|
37125
37133
|
let deleted;
|
|
37126
|
-
tournamentRecord.venues = (tournamentRecord.venues
|
|
37134
|
+
tournamentRecord.venues = (tournamentRecord.venues ?? []).filter(
|
|
37127
37135
|
(venue) => {
|
|
37128
37136
|
if (venue?.venueId !== venueId)
|
|
37129
37137
|
return true;
|
|
@@ -37335,7 +37343,7 @@ function deleteCourt$1({
|
|
|
37335
37343
|
courtId
|
|
37336
37344
|
});
|
|
37337
37345
|
if (!matchUps?.length || force) {
|
|
37338
|
-
for (const matchUp of matchUps
|
|
37346
|
+
for (const matchUp of matchUps ?? []) {
|
|
37339
37347
|
const result2 = removeCourtAssignment({
|
|
37340
37348
|
matchUpId: matchUp.matchUpId,
|
|
37341
37349
|
drawId: matchUp.drawId,
|
|
@@ -37346,7 +37354,7 @@ function deleteCourt$1({
|
|
|
37346
37354
|
return result2;
|
|
37347
37355
|
}
|
|
37348
37356
|
if (venue) {
|
|
37349
|
-
venue.courts = (venue.courts
|
|
37357
|
+
venue.courts = (venue.courts ?? []).filter((courtRecord) => {
|
|
37350
37358
|
return courtRecord.courtId !== courtId;
|
|
37351
37359
|
});
|
|
37352
37360
|
if (!disableNotice)
|
|
@@ -38609,7 +38617,7 @@ function treeMatchUps({
|
|
|
38609
38617
|
uuids
|
|
38610
38618
|
}));
|
|
38611
38619
|
roundNumber++;
|
|
38612
|
-
roundLimit = roundLimit
|
|
38620
|
+
roundLimit = roundLimit ?? qualifyingRoundNumber;
|
|
38613
38621
|
while (roundNodes.length > 1) {
|
|
38614
38622
|
if (qualifyingPositions && roundNodes.length === qualifyingPositions) {
|
|
38615
38623
|
roundLimit = roundNumber - 1;
|
|
@@ -38637,7 +38645,7 @@ function treeMatchUps({
|
|
|
38637
38645
|
roundLimit = roundNumber - 1;
|
|
38638
38646
|
} else {
|
|
38639
38647
|
matchUps = matchUps.filter(
|
|
38640
|
-
(matchUp) => roundLimit && (matchUp.roundNumber
|
|
38648
|
+
(matchUp) => roundLimit && (matchUp.roundNumber ?? 0) <= roundLimit
|
|
38641
38649
|
);
|
|
38642
38650
|
}
|
|
38643
38651
|
return { drawSize, matchUps, roundsCount, roundLimit };
|
|
@@ -38770,7 +38778,6 @@ function generateQualifyingStructures({
|
|
|
38770
38778
|
roundTarget,
|
|
38771
38779
|
linkType
|
|
38772
38780
|
});
|
|
38773
|
-
targetRoundQualifiersCount = 0;
|
|
38774
38781
|
roundTarget += 1;
|
|
38775
38782
|
}
|
|
38776
38783
|
return {
|
|
@@ -38785,6 +38792,7 @@ function generateQualifyingStructures({
|
|
|
38785
38792
|
|
|
38786
38793
|
function getStructureRoundProfile({
|
|
38787
38794
|
drawDefinition,
|
|
38795
|
+
matchUpsMap,
|
|
38788
38796
|
structureId
|
|
38789
38797
|
}) {
|
|
38790
38798
|
const result = findStructure({
|
|
@@ -38792,9 +38800,12 @@ function getStructureRoundProfile({
|
|
|
38792
38800
|
structureId
|
|
38793
38801
|
});
|
|
38794
38802
|
if (result.error)
|
|
38795
|
-
return result;
|
|
38796
|
-
const { matchUps } = getAllStructureMatchUps({
|
|
38797
|
-
|
|
38803
|
+
return decorateResult({ result });
|
|
38804
|
+
const { matchUps } = getAllStructureMatchUps({
|
|
38805
|
+
structure: result.structure,
|
|
38806
|
+
matchUpsMap
|
|
38807
|
+
});
|
|
38808
|
+
return { ...getRoundMatchUps$1({ matchUps }), matchUps, matchUpsMap };
|
|
38798
38809
|
}
|
|
38799
38810
|
|
|
38800
38811
|
function getFinishingPositionSourceRoundsMap({
|
|
@@ -38845,16 +38856,18 @@ function roundValueRanges(values) {
|
|
|
38845
38856
|
|
|
38846
38857
|
function getPositionsPlayedOff({
|
|
38847
38858
|
drawDefinition,
|
|
38848
|
-
structureIds
|
|
38859
|
+
structureIds,
|
|
38860
|
+
matchUpsMap
|
|
38849
38861
|
}) {
|
|
38850
38862
|
if (structureIds && !Array.isArray(structureIds))
|
|
38851
38863
|
return { error: INVALID_VALUES, context: { structureIds } };
|
|
38852
38864
|
if (!drawDefinition)
|
|
38853
38865
|
return { error: MISSING_DRAW_DEFINITION };
|
|
38854
|
-
structureIds = structureIds
|
|
38866
|
+
structureIds = structureIds ?? (drawDefinition.structures ?? []).filter((structure) => structure.stage !== QUALIFYING).map(({ structureId }) => structureId);
|
|
38855
38867
|
const allFinishingPositionRanges = structureIds.map((structureId) => {
|
|
38856
38868
|
const { roundProfile } = getStructureRoundProfile({
|
|
38857
38869
|
drawDefinition,
|
|
38870
|
+
matchUpsMap,
|
|
38858
38871
|
structureId
|
|
38859
38872
|
});
|
|
38860
38873
|
const values = roundProfile && Object.values(roundProfile);
|
|
@@ -38949,18 +38962,19 @@ function getPlayoffRoundsRanges({ playoffSourceRounds, roundProfile }) {
|
|
|
38949
38962
|
function getAvailablePlayoffProfiles$1({ drawDefinition, structureId }) {
|
|
38950
38963
|
if (!drawDefinition)
|
|
38951
38964
|
return { error: MISSING_DRAW_DEFINITION };
|
|
38952
|
-
const {
|
|
38965
|
+
const { matchUps, matchUpsMap } = allDrawMatchUps$1({
|
|
38966
|
+
inContext: true,
|
|
38953
38967
|
drawDefinition
|
|
38954
38968
|
});
|
|
38969
|
+
const { positionsNotPlayedOff, positionsPlayedOff } = getPositionsPlayedOff({
|
|
38970
|
+
drawDefinition,
|
|
38971
|
+
matchUpsMap
|
|
38972
|
+
});
|
|
38955
38973
|
const { structures } = getDrawStructures({ drawDefinition });
|
|
38956
38974
|
const filteredStructures = structures.filter(
|
|
38957
38975
|
(structure) => !structureId && structure.stage !== VOLUNTARY_CONSOLATION || structure.structureId === structureId
|
|
38958
38976
|
);
|
|
38959
38977
|
const available = {};
|
|
38960
|
-
const matchUps = allDrawMatchUps$1({
|
|
38961
|
-
inContext: true,
|
|
38962
|
-
drawDefinition
|
|
38963
|
-
}).matchUps;
|
|
38964
38978
|
for (const structure of filteredStructures) {
|
|
38965
38979
|
const structureId2 = structure?.structureId;
|
|
38966
38980
|
const result = availablePlayoffProfiles({
|
|
@@ -43383,7 +43397,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43383
43397
|
if (!params.drawDefinition)
|
|
43384
43398
|
return { error: MISSING_DRAW_DEFINITION };
|
|
43385
43399
|
const stack = "generateQualifyingStructure";
|
|
43386
|
-
let drawSize = params.drawSize
|
|
43400
|
+
let drawSize = params.drawSize ?? coerceEven(params.participantsCount);
|
|
43387
43401
|
const {
|
|
43388
43402
|
qualifyingRoundNumber,
|
|
43389
43403
|
qualifyingPositions,
|
|
@@ -43391,6 +43405,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43391
43405
|
structureOptions,
|
|
43392
43406
|
appliedPolicies,
|
|
43393
43407
|
drawDefinition,
|
|
43408
|
+
matchUpFormat,
|
|
43394
43409
|
structureName,
|
|
43395
43410
|
structureId,
|
|
43396
43411
|
roundTarget,
|
|
@@ -43429,6 +43444,7 @@ function generateQualifyingStructure$1(params) {
|
|
|
43429
43444
|
let nextStageSequence = 2;
|
|
43430
43445
|
let chainModified;
|
|
43431
43446
|
while (!chainModified && nextStructureId) {
|
|
43447
|
+
console.log("check getRoundContextProfile preqQualifyingStageSequence");
|
|
43432
43448
|
targetStructure.stageSequence = nextStageSequence;
|
|
43433
43449
|
const targetTargetStructureId = drawDefinition.links?.find(
|
|
43434
43450
|
(link2) => link2.source.structureId === nextStructureId
|
|
@@ -43459,11 +43475,11 @@ function generateQualifyingStructure$1(params) {
|
|
|
43459
43475
|
}
|
|
43460
43476
|
const roundTargetName = roundTarget ? `${roundTarget}-` : "";
|
|
43461
43477
|
const stageSequenceName = `${stageSequence}`;
|
|
43462
|
-
const qualifyingStructureName = structureName
|
|
43478
|
+
const qualifyingStructureName = structureName ?? (roundTargetName || stageSequenceName ? `${constantToString(QUALIFYING)} ${roundTargetName}${stageSequenceName}` : constantToString(QUALIFYING));
|
|
43463
43479
|
if (drawType === ROUND_ROBIN) {
|
|
43464
43480
|
const { maxRoundNumber, structures, groupCount } = generateRoundRobin({
|
|
43465
|
-
structureName: structureName
|
|
43466
|
-
structureId: structureId
|
|
43481
|
+
structureName: structureName ?? qualifyingStructureName,
|
|
43482
|
+
structureId: structureId ?? uuids?.pop(),
|
|
43467
43483
|
stage: QUALIFYING,
|
|
43468
43484
|
structureOptions,
|
|
43469
43485
|
appliedPolicies,
|
|
@@ -43492,10 +43508,11 @@ function generateQualifyingStructure$1(params) {
|
|
|
43492
43508
|
if (!roundLimit)
|
|
43493
43509
|
roundLimit = roundsCount;
|
|
43494
43510
|
structure = structureTemplate({
|
|
43495
|
-
structureName: structureName
|
|
43496
|
-
structureId: structureId
|
|
43511
|
+
structureName: structureName ?? qualifyingStructureName,
|
|
43512
|
+
structureId: structureId ?? uuids?.pop(),
|
|
43497
43513
|
qualifyingRoundNumber: roundLimit,
|
|
43498
43514
|
stage: QUALIFYING,
|
|
43515
|
+
matchUpFormat,
|
|
43499
43516
|
stageSequence,
|
|
43500
43517
|
matchUpType,
|
|
43501
43518
|
roundLimit,
|
|
@@ -44079,21 +44096,26 @@ function removeStructure({
|
|
|
44079
44096
|
({ stage, stageSequence }) => stage === MAIN && stageSequence === 1
|
|
44080
44097
|
);
|
|
44081
44098
|
const isMainStageSequence1 = structureId === mainStageSequence1.structureId;
|
|
44082
|
-
const
|
|
44083
|
-
if (isMainStageSequence1 && !
|
|
44099
|
+
const qualifyingStructureIds = structures.filter(({ stage }) => stage === QUALIFYING).map(extractAttributes("structureId"));
|
|
44100
|
+
if (isMainStageSequence1 && !qualifyingStructureIds.length) {
|
|
44084
44101
|
return { error: CANNOT_REMOVE_MAIN_STRUCTURE };
|
|
44085
44102
|
}
|
|
44103
|
+
const structureIds = structures.map(extractAttributes("structureId"));
|
|
44086
44104
|
const removedMatchUpIds = [];
|
|
44087
44105
|
const idsToRemove = [structureId];
|
|
44088
44106
|
const getTargetedStructureIds = (structureId2) => drawDefinition.links?.map(
|
|
44089
44107
|
(link) => link.source.structureId === structureId2 && link.target.structureId !== mainStageSequence1.structureId && link.target.structureId
|
|
44090
44108
|
).filter(Boolean);
|
|
44091
|
-
const
|
|
44092
|
-
|
|
44093
|
-
|
|
44094
|
-
|
|
44095
|
-
|
|
44096
|
-
|
|
44109
|
+
const getQualifyingSourceStructureIds = (structureId2) => drawDefinition.links?.map(
|
|
44110
|
+
(link) => qualifyingStructureIds.includes(link.source.structureId) && link.target.structureId === structureId2 && link.source.structureId
|
|
44111
|
+
).filter(Boolean);
|
|
44112
|
+
const isQualifyingStructure = qualifyingStructureIds.includes(structureId);
|
|
44113
|
+
const relatedStructureIdsMap = /* @__PURE__ */ new Map();
|
|
44114
|
+
structureIds.forEach(
|
|
44115
|
+
(id) => relatedStructureIdsMap.set(
|
|
44116
|
+
id,
|
|
44117
|
+
isQualifyingStructure ? getQualifyingSourceStructureIds(id) : getTargetedStructureIds(id)
|
|
44118
|
+
)
|
|
44097
44119
|
);
|
|
44098
44120
|
while (idsToRemove.length) {
|
|
44099
44121
|
const idBeingRemoved = idsToRemove.pop();
|
|
@@ -44116,7 +44138,8 @@ function removeStructure({
|
|
|
44116
44138
|
}
|
|
44117
44139
|
);
|
|
44118
44140
|
}
|
|
44119
|
-
const targetedStructureIds = idBeingRemoved && targetedStructureIdsMap[idBeingRemoved].filter(
|
|
44141
|
+
const targetedStructureIds = idBeingRemoved && // targetedStructureIdsMap[idBeingRemoved].filter(
|
|
44142
|
+
relatedStructureIdsMap.get(idBeingRemoved)?.filter(
|
|
44120
44143
|
(id) => (
|
|
44121
44144
|
// IMPORTANT: only delete MAIN stageSequence: 1 if specified to protect against DOUBLE_ELIMINATION scenario
|
|
44122
44145
|
id !== mainStageSequence1.structureId || structureId === mainStageSequence1.structureId
|
|
@@ -44913,7 +44936,7 @@ function modifyEntriesStatus({
|
|
|
44913
44936
|
}).assignedParticipantIds ?? [];
|
|
44914
44937
|
assignedParticipantIds.push(...participantIds2);
|
|
44915
44938
|
});
|
|
44916
|
-
const tournamentParticipants = tournamentRecord?.participants
|
|
44939
|
+
const tournamentParticipants = tournamentRecord?.participants ?? [];
|
|
44917
44940
|
const validEntryStatusForAllParticipantIds = participantIds.every(
|
|
44918
44941
|
(participantId) => {
|
|
44919
44942
|
const participantType = findParticipant({
|
|
@@ -44961,7 +44984,7 @@ function modifyEntriesStatus({
|
|
|
44961
44984
|
const autoPosition = ({ flight: flight2, drawDefinition: drawDefinition2 }) => {
|
|
44962
44985
|
if (event) {
|
|
44963
44986
|
event.entries = refreshEntryPositions({
|
|
44964
|
-
entries: event.entries
|
|
44987
|
+
entries: event.entries ?? []
|
|
44965
44988
|
});
|
|
44966
44989
|
}
|
|
44967
44990
|
if (flight2) {
|
|
@@ -44992,7 +45015,7 @@ function modifyEntriesStatus({
|
|
|
44992
45015
|
}
|
|
44993
45016
|
return { ...SUCCESS };
|
|
44994
45017
|
};
|
|
44995
|
-
const entryPositionsExist = event?.entries?.find(({ entryPosition }) => entryPosition)
|
|
45018
|
+
const entryPositionsExist = event?.entries?.find(({ entryPosition }) => entryPosition) ?? (flight?.drawEntries?.find(({ entryPosition }) => entryPosition) || drawDefinition?.entries?.find(({ entryPosition }) => entryPosition));
|
|
44996
45019
|
if (autoEntryPositions && !entryPositionsExist)
|
|
44997
45020
|
autoPosition({ flight, drawDefinition });
|
|
44998
45021
|
if (flight || drawDefinition) {
|
|
@@ -45000,7 +45023,7 @@ function modifyEntriesStatus({
|
|
|
45000
45023
|
if (result.error)
|
|
45001
45024
|
return decorateResult({ result, stack });
|
|
45002
45025
|
}
|
|
45003
|
-
const generatedDrawIds = event?.drawDefinitions?.map(({ drawId: drawId2 }) => drawId2)
|
|
45026
|
+
const generatedDrawIds = event?.drawDefinitions?.map(({ drawId: drawId2 }) => drawId2) ?? [];
|
|
45004
45027
|
const flightsNoDraw = flightProfile?.flights?.filter(
|
|
45005
45028
|
(flight2) => !generatedDrawIds.includes(flight2.drawId)
|
|
45006
45029
|
) || [];
|
|
@@ -45009,7 +45032,7 @@ function modifyEntriesStatus({
|
|
|
45009
45032
|
if (result?.error)
|
|
45010
45033
|
return decorateResult({ result, stack });
|
|
45011
45034
|
}
|
|
45012
|
-
const singleDraw = flightProfile?.flights?.length === 1 && (event?.drawDefinitions?.length
|
|
45035
|
+
const singleDraw = flightProfile?.flights?.length === 1 && (event?.drawDefinitions?.length ?? 0) <= flightProfile?.flights?.length;
|
|
45013
45036
|
if (!flight && !drawDefinition && entryStatus && DRAW_SPECIFIC_STATUSES.includes(entryStatus)) {
|
|
45014
45037
|
return { error: ENTRY_STATUS_NOT_ALLOWED_FOR_EVENT };
|
|
45015
45038
|
}
|
|
@@ -45047,7 +45070,7 @@ function modifyEntriesStatus({
|
|
|
45047
45070
|
}
|
|
45048
45071
|
if (autoEntryPositions)
|
|
45049
45072
|
autoPosition({ flight, drawDefinition });
|
|
45050
|
-
for (const drawDefinition2 of event?.drawDefinitions
|
|
45073
|
+
for (const drawDefinition2 of event?.drawDefinitions ?? []) {
|
|
45051
45074
|
if (modifiedDrawIds.length && !modifiedDrawIds.includes(drawDefinition2.drawId))
|
|
45052
45075
|
continue;
|
|
45053
45076
|
modifyDrawNotice({
|
|
@@ -45413,7 +45436,7 @@ function removeEventEntries({
|
|
|
45413
45436
|
if (!participantIds?.length)
|
|
45414
45437
|
return { ...SUCCESS, participantIdsRemoved: [] };
|
|
45415
45438
|
const participantIdsRemoved = [];
|
|
45416
|
-
event.entries = (event.entries
|
|
45439
|
+
event.entries = (event.entries ?? []).filter((entry) => {
|
|
45417
45440
|
const keepEntry = !participantIds.includes(entry?.participantId);
|
|
45418
45441
|
if (!keepEntry)
|
|
45419
45442
|
participantIdsRemoved.push(entry.participantId);
|
|
@@ -45431,7 +45454,7 @@ function removeEventEntries({
|
|
|
45431
45454
|
);
|
|
45432
45455
|
});
|
|
45433
45456
|
event.drawDefinitions?.forEach((drawDefinition) => {
|
|
45434
|
-
drawDefinition.entries = (drawDefinition.entries
|
|
45457
|
+
drawDefinition.entries = (drawDefinition.entries ?? []).filter(
|
|
45435
45458
|
(entry) => !participantIds.includes(entry.participantId)
|
|
45436
45459
|
);
|
|
45437
45460
|
});
|
|
@@ -45612,7 +45635,7 @@ function removeIndividualParticipantIds({
|
|
|
45612
45635
|
});
|
|
45613
45636
|
if (!groupingParticipantId || !individualParticipantIds)
|
|
45614
45637
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
45615
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
45638
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
45616
45639
|
const groupingParticipant = tournamentParticipants.find(
|
|
45617
45640
|
(participant) => {
|
|
45618
45641
|
return participant.participantId === groupingParticipantId;
|
|
@@ -45639,8 +45662,8 @@ function removeIndividualParticipantIds({
|
|
|
45639
45662
|
if (error)
|
|
45640
45663
|
return decorateResult({ result, stack });
|
|
45641
45664
|
if (addIndividualParticipantsToEvents) {
|
|
45642
|
-
for (const event of tournamentRecord.events
|
|
45643
|
-
const enteredIds = (event.entries
|
|
45665
|
+
for (const event of tournamentRecord.events ?? []) {
|
|
45666
|
+
const enteredIds = (event.entries ?? []).map(({ participantId }) => participantId).filter(Boolean);
|
|
45644
45667
|
if (enteredIds.includes(groupingParticipantId)) {
|
|
45645
45668
|
const participantIdsToEnter = removed?.filter(
|
|
45646
45669
|
(participantId) => !enteredIds.includes(participantId)
|
|
@@ -45691,7 +45714,7 @@ function removeParticipantIdsFromGroupingParticipant({
|
|
|
45691
45714
|
const groupingParticipantEventIds = inContextGroupingParticipant?.events?.map(
|
|
45692
45715
|
({ eventId }) => eventId
|
|
45693
45716
|
);
|
|
45694
|
-
const updatedIndividualParticipantIds = (groupingParticipant.individualParticipantIds
|
|
45717
|
+
const updatedIndividualParticipantIds = (groupingParticipant.individualParticipantIds ?? []).filter((participantId) => {
|
|
45695
45718
|
const targetParticipant = individualParticipantIds?.includes(participantId);
|
|
45696
45719
|
const scoredParticipantGroupingMatchUps = targetParticipant && participants?.find((participant) => participant.participantId === participantId)?.matchUps.filter(
|
|
45697
45720
|
({ eventId }) => groupingParticipantEventIds.includes(eventId)
|
|
@@ -45704,25 +45727,25 @@ function removeParticipantIdsFromGroupingParticipant({
|
|
|
45704
45727
|
}
|
|
45705
45728
|
if (removeParticipant) {
|
|
45706
45729
|
removed.push(participantId);
|
|
45707
|
-
for (const event of tournamentRecord.events
|
|
45708
|
-
for (const drawDefinition of event.drawDefinitions
|
|
45730
|
+
for (const event of tournamentRecord.events ?? []) {
|
|
45731
|
+
for (const drawDefinition of event.drawDefinitions ?? []) {
|
|
45709
45732
|
const { extension } = findExtension$2({
|
|
45710
45733
|
element: drawDefinition,
|
|
45711
45734
|
name: LINEUPS
|
|
45712
45735
|
});
|
|
45713
|
-
|
|
45736
|
+
const lineUp = extension?.value[groupingParticipant.participantId];
|
|
45714
45737
|
if (extension && lineUp) {
|
|
45715
|
-
|
|
45738
|
+
extension.value[groupingParticipant.participantId] = lineUp.filter(
|
|
45716
45739
|
(assignment) => assignment.participantId !== participantId
|
|
45717
45740
|
);
|
|
45718
45741
|
addExtension$1({ element: drawDefinition, extension });
|
|
45719
45742
|
addDrawNotice({ drawDefinition });
|
|
45720
45743
|
}
|
|
45721
|
-
const matchUps = allDrawMatchUps$1({ drawDefinition, inContext: false }).matchUps
|
|
45744
|
+
const matchUps = allDrawMatchUps$1({ drawDefinition, inContext: false }).matchUps ?? [];
|
|
45722
45745
|
for (const matchUp of matchUps) {
|
|
45723
|
-
const sides = matchUp.sides
|
|
45746
|
+
const sides = matchUp.sides ?? [];
|
|
45724
45747
|
for (const side of sides) {
|
|
45725
|
-
const lineUp2 = side.lineUp
|
|
45748
|
+
const lineUp2 = side.lineUp ?? [];
|
|
45726
45749
|
const containsParticipant = lineUp2.find(
|
|
45727
45750
|
(assignment) => assignment.participantId === participantId
|
|
45728
45751
|
);
|
|
@@ -45766,7 +45789,7 @@ function removeParticipantIdsFromAllTeams({
|
|
|
45766
45789
|
}) {
|
|
45767
45790
|
if (!tournamentRecord)
|
|
45768
45791
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
45769
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
45792
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
45770
45793
|
const { participants, mappedMatchUps } = getParticipants$1({
|
|
45771
45794
|
withMatchUps: true,
|
|
45772
45795
|
tournamentRecord,
|
|
@@ -45812,7 +45835,7 @@ function deleteParticipants(params) {
|
|
|
45812
45835
|
const matchUps = allTournamentMatchUps({
|
|
45813
45836
|
matchUpFilters: { drawIds: teamDrawIds, matchUpTypes: [DOUBLES$1] },
|
|
45814
45837
|
tournamentRecord
|
|
45815
|
-
}).matchUps
|
|
45838
|
+
}).matchUps ?? [];
|
|
45816
45839
|
const placedPairParticipantIds2 = matchUps.map(({ sides }) => sides?.map(({ participantId }) => participantId)).flat().filter(Boolean);
|
|
45817
45840
|
return intersection(placedPairParticipantIds2, participantIds);
|
|
45818
45841
|
};
|
|
@@ -45935,7 +45958,7 @@ function destroyGroupEntry({
|
|
|
45935
45958
|
if (!event.eventType || ![TypeEnum.Doubles, TypeEnum.Team].includes(event.eventType)) {
|
|
45936
45959
|
return decorateResult({ result: { error: INVALID_EVENT_TYPE }, stack });
|
|
45937
45960
|
}
|
|
45938
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
45961
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
45939
45962
|
const participant = tournamentParticipants.find(
|
|
45940
45963
|
(participant2) => participant2.participantId === participantId
|
|
45941
45964
|
);
|
|
@@ -45947,7 +45970,7 @@ function destroyGroupEntry({
|
|
|
45947
45970
|
) || participant.participantType === TEAM$1 && event.eventType !== TEAM$1 || participant.participantType === PAIR && event.eventType !== DOUBLES) {
|
|
45948
45971
|
return { error: INVALID_PARTICIPANT_TYPE };
|
|
45949
45972
|
}
|
|
45950
|
-
const eventEntries = event.entries
|
|
45973
|
+
const eventEntries = event.entries ?? [];
|
|
45951
45974
|
const entry = eventEntries.find(
|
|
45952
45975
|
(entry2) => entry2.participantId === participantId
|
|
45953
45976
|
);
|
|
@@ -46053,7 +46076,7 @@ function removeDrawPositionAssignment(params) {
|
|
|
46053
46076
|
tournamentRecord: tournamentRecord2,
|
|
46054
46077
|
participantId
|
|
46055
46078
|
});
|
|
46056
|
-
const { participantType, individualParticipantIds } = participant
|
|
46079
|
+
const { participantType, individualParticipantIds } = participant ?? {};
|
|
46057
46080
|
if (destroyPair && participantType === PAIR) {
|
|
46058
46081
|
const result2 = destroyPairEntry({
|
|
46059
46082
|
tournamentRecord: tournamentRecord2,
|
|
@@ -49588,12 +49611,12 @@ function getParticipantEventDetails({
|
|
|
49588
49611
|
if (!participantId)
|
|
49589
49612
|
return { error: MISSING_PARTICIPANT_ID };
|
|
49590
49613
|
const relevantParticipantIds = [participantId].concat(
|
|
49591
|
-
(tournamentRecord.participants
|
|
49614
|
+
(tournamentRecord.participants ?? []).filter(
|
|
49592
49615
|
(participant) => participant?.participantType && [TEAM, PAIR].includes(participant.participantType) && participant.individualParticipantIds?.includes(participantId)
|
|
49593
49616
|
).map((participant) => participant.participantId)
|
|
49594
49617
|
);
|
|
49595
|
-
const relevantEvents = (tournamentRecord.events
|
|
49596
|
-
const enteredParticipantIds = (event?.entries
|
|
49618
|
+
const relevantEvents = (tournamentRecord.events ?? []).filter((event) => {
|
|
49619
|
+
const enteredParticipantIds = (event?.entries ?? []).map(
|
|
49597
49620
|
(entry) => entry.participantId
|
|
49598
49621
|
);
|
|
49599
49622
|
return overlap(enteredParticipantIds, relevantParticipantIds);
|
|
@@ -49634,7 +49657,7 @@ function getRelevantParticipantIdsMap({
|
|
|
49634
49657
|
}) {
|
|
49635
49658
|
if (typeof tournamentRecord !== "object" && typeof tournamentRecords !== "object")
|
|
49636
49659
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
49637
|
-
const allParticipants = tournamentRecords ? Object.values(tournamentRecords).map((tournamentRecord2) => tournamentRecord2?.participants || []).flat() : tournamentRecord?.participants
|
|
49660
|
+
const allParticipants = tournamentRecords ? Object.values(tournamentRecords).map((tournamentRecord2) => tournamentRecord2?.participants || []).flat() : tournamentRecord?.participants ?? [];
|
|
49638
49661
|
const relevantParticipantIdsMap = Object.assign(
|
|
49639
49662
|
{},
|
|
49640
49663
|
...allParticipants.map(
|
|
@@ -49902,7 +49925,7 @@ function annotateParticipant(params) {
|
|
|
49902
49925
|
);
|
|
49903
49926
|
const scheduledMatchUps = participantScheduledMatchUps({
|
|
49904
49927
|
matchUps: allParticipantMatchUps
|
|
49905
|
-
})?.scheduledMatchUps
|
|
49928
|
+
})?.scheduledMatchUps ?? [];
|
|
49906
49929
|
const { scheduledMinutesDifference } = scheduleAnalysis || {};
|
|
49907
49930
|
const dates = Object.keys(scheduledMatchUps);
|
|
49908
49931
|
dates.forEach((date) => {
|
|
@@ -50707,7 +50730,7 @@ function getParticipantMembership({
|
|
|
50707
50730
|
participantFilters: { participantTypes: [TEAM, PAIR, GROUP] },
|
|
50708
50731
|
tournamentRecord
|
|
50709
50732
|
});
|
|
50710
|
-
const memberOf = (participants
|
|
50733
|
+
const memberOf = (participants ?? []).filter((participant) => {
|
|
50711
50734
|
return participant.individualParticipantIds?.includes(participantId);
|
|
50712
50735
|
});
|
|
50713
50736
|
return memberOf.reduce((groupingTypesMap, participant) => {
|
|
@@ -50733,7 +50756,7 @@ function getParticipantSchedules({
|
|
|
50733
50756
|
const matchUps = allTournamentMatchUps({
|
|
50734
50757
|
tournamentRecord,
|
|
50735
50758
|
contextFilters
|
|
50736
|
-
}).matchUps
|
|
50759
|
+
}).matchUps ?? [];
|
|
50737
50760
|
const matchUpsMap = Object.assign(
|
|
50738
50761
|
{},
|
|
50739
50762
|
...matchUps.map((matchUp) => ({ [matchUp.matchUpId]: matchUp }))
|
|
@@ -50744,7 +50767,7 @@ function getParticipantSchedules({
|
|
|
50744
50767
|
const sourceMatchUpIds = getMatchUpDependencies({
|
|
50745
50768
|
tournamentRecord,
|
|
50746
50769
|
matchUps
|
|
50747
|
-
}).sourceMatchUpIds
|
|
50770
|
+
}).sourceMatchUpIds ?? [];
|
|
50748
50771
|
const participantAggregator = {};
|
|
50749
50772
|
for (const matchUp of scheduledMatchUps) {
|
|
50750
50773
|
const { sides } = matchUp;
|
|
@@ -50754,13 +50777,11 @@ function getParticipantSchedules({
|
|
|
50754
50777
|
return [side.participant].concat(
|
|
50755
50778
|
...side.participant.individualParticipants || []
|
|
50756
50779
|
);
|
|
50757
|
-
} else {
|
|
50758
|
-
|
|
50759
|
-
relevantSourceMatchUps = (sourceMatchUpIds[matchUp.matchUpId] || []).map((matchUpId) => matchUpsMap[matchUpId]).filter(({ winningSide, bye }) => !winningSide && !bye);
|
|
50760
|
-
}
|
|
50780
|
+
} else if (sourceMatchUpIds[matchUp.matchUpId] && !relevantSourceMatchUps) {
|
|
50781
|
+
relevantSourceMatchUps = (sourceMatchUpIds[matchUp.matchUpId] || []).map((matchUpId) => matchUpsMap[matchUpId]).filter(({ winningSide, bye }) => !winningSide && !bye);
|
|
50761
50782
|
}
|
|
50762
50783
|
return void 0;
|
|
50763
|
-
}).filter(Boolean).flat()
|
|
50784
|
+
}).filter(Boolean).flat() ?? [];
|
|
50764
50785
|
for (const participant of participants) {
|
|
50765
50786
|
const { participantId } = participant;
|
|
50766
50787
|
if (!participantAggregator[participantId]) {
|
|
@@ -50891,7 +50912,7 @@ function addPersons({
|
|
|
50891
50912
|
const tournamentParticipants = getParticipants$1({
|
|
50892
50913
|
participantFilters: { participantTypes: [INDIVIDUAL] },
|
|
50893
50914
|
tournamentRecord
|
|
50894
|
-
})?.participants
|
|
50915
|
+
})?.participants ?? [];
|
|
50895
50916
|
if (participantRole === COMPETITOR) {
|
|
50896
50917
|
persons.filter(({ pairedPersons }) => pairedPersons).forEach(({ personId, pairedPersons }) => {
|
|
50897
50918
|
Array.isArray(pairedPersons) && pairedPersons.forEach((pairing) => {
|
|
@@ -50966,7 +50987,7 @@ function addIndividualParticipantIds({
|
|
|
50966
50987
|
});
|
|
50967
50988
|
if (!groupingParticipantId || !individualParticipantIds)
|
|
50968
50989
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
50969
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
50990
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
50970
50991
|
const groupingParticipant = tournamentParticipants.find(
|
|
50971
50992
|
(participant) => participant.participantId === groupingParticipantId
|
|
50972
50993
|
);
|
|
@@ -51127,7 +51148,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
51127
51148
|
if (!tournamentRecord)
|
|
51128
51149
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
51129
51150
|
const teams = {};
|
|
51130
|
-
const individualParticipants = (tournamentRecord.participants
|
|
51151
|
+
const individualParticipants = (tournamentRecord.participants ?? []).filter(
|
|
51131
51152
|
({ participantType, participantRole }) => participantType === INDIVIDUAL && participantRole === COMPETITOR
|
|
51132
51153
|
);
|
|
51133
51154
|
let teamIndex = 0;
|
|
@@ -51140,15 +51161,15 @@ function generateTeamsFromParticipantAttribute({
|
|
|
51140
51161
|
if (attributeValue) {
|
|
51141
51162
|
if (!Object.keys(teams).includes(attributeValue)) {
|
|
51142
51163
|
teams[attributeValue] = {
|
|
51143
|
-
participantName: teamNames?.[teamIndex]
|
|
51144
|
-
participantId: uuids?.pop()
|
|
51164
|
+
participantName: teamNames?.[teamIndex] ?? attributeValue,
|
|
51165
|
+
participantId: uuids?.pop() ?? UUID(),
|
|
51145
51166
|
individualParticipantIds: [],
|
|
51146
51167
|
participantRole: COMPETITOR,
|
|
51147
51168
|
participantType: TEAM
|
|
51148
51169
|
};
|
|
51149
51170
|
const extension = {
|
|
51150
|
-
|
|
51151
|
-
|
|
51171
|
+
value: personAttribute ?? participantAttribute,
|
|
51172
|
+
name: GROUPING_ATTRIBUTE
|
|
51152
51173
|
};
|
|
51153
51174
|
addExtension$1({ element: teams[attributeValue], extension });
|
|
51154
51175
|
teamIndex += 1;
|
|
@@ -51159,7 +51180,7 @@ function generateTeamsFromParticipantAttribute({
|
|
|
51159
51180
|
}
|
|
51160
51181
|
}
|
|
51161
51182
|
const groupingAttributes = Object.keys(teams);
|
|
51162
|
-
const overlappingTeamParticipantIds = (tournamentRecord.participants
|
|
51183
|
+
const overlappingTeamParticipantIds = (tournamentRecord.participants ?? []).map((participant) => {
|
|
51163
51184
|
if (participant.participantType !== TEAM)
|
|
51164
51185
|
return void 0;
|
|
51165
51186
|
if (participant.participantRole !== COMPETITOR)
|
|
@@ -51304,16 +51325,16 @@ function scaledTeamAssignment({
|
|
|
51304
51325
|
error: MISSING_VALUE
|
|
51305
51326
|
};
|
|
51306
51327
|
}
|
|
51307
|
-
let participantIdsToAssign = individualParticipantIds
|
|
51328
|
+
let participantIdsToAssign = individualParticipantIds ?? scaledParticipants.map(({ participantId }) => participantId);
|
|
51308
51329
|
if (reverseAssignmentOrder) {
|
|
51309
51330
|
teamParticipantIds?.reverse();
|
|
51310
51331
|
initialTeamIndex += 1;
|
|
51311
51332
|
}
|
|
51312
51333
|
if (initialTeamIndex > (teamParticipantIds?.length || 0) - 1)
|
|
51313
51334
|
initialTeamIndex = 0;
|
|
51314
|
-
const orderedTeamParticipantIds = teamParticipantIds?.slice(initialTeamIndex).concat(...teamParticipantIds.slice(0, initialTeamIndex))
|
|
51335
|
+
const orderedTeamParticipantIds = teamParticipantIds?.slice(initialTeamIndex).concat(...teamParticipantIds.slice(0, initialTeamIndex)) ?? [];
|
|
51315
51336
|
const relevantTeams = [];
|
|
51316
|
-
for (const participant of tournamentRecord.participants
|
|
51337
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
51317
51338
|
const { participantId, participantType } = participant;
|
|
51318
51339
|
if (!orderedTeamParticipantIds.includes(participantId))
|
|
51319
51340
|
continue;
|
|
@@ -51323,7 +51344,7 @@ function scaledTeamAssignment({
|
|
|
51323
51344
|
}
|
|
51324
51345
|
if (teamsCount && relevantTeams.length < teamsCount) {
|
|
51325
51346
|
const addCount = teamsCount - (relevantTeams?.length || 0);
|
|
51326
|
-
const nameBase = teamNameBase
|
|
51347
|
+
const nameBase = teamNameBase ?? "Team";
|
|
51327
51348
|
const teamParticipants = generateRange(0, addCount).map((i) => ({
|
|
51328
51349
|
participantName: `${nameBase} ${i + 1}`,
|
|
51329
51350
|
participantType: TEAM_PARTICIPANT,
|
|
@@ -51362,7 +51383,7 @@ function scaledTeamAssignment({
|
|
|
51362
51383
|
return { error: NO_CANDIDATES, info: "Nothing to be done" };
|
|
51363
51384
|
}
|
|
51364
51385
|
if (!scaledParticipants.length) {
|
|
51365
|
-
for (const participant of tournamentRecord.participants
|
|
51386
|
+
for (const participant of tournamentRecord.participants ?? []) {
|
|
51366
51387
|
const { participantId, participantType } = participant;
|
|
51367
51388
|
if (!participantIdsToAssign.includes(participantId))
|
|
51368
51389
|
continue;
|
|
@@ -51400,10 +51421,10 @@ function scaledTeamAssignment({
|
|
|
51400
51421
|
relevantTeams.reverse();
|
|
51401
51422
|
}
|
|
51402
51423
|
const relevantTeamParticipantIds = relevantTeams.map(getParticipantId);
|
|
51403
|
-
for (const event2 of tournamentRecord.events
|
|
51424
|
+
for (const event2 of tournamentRecord.events ?? []) {
|
|
51404
51425
|
if (event2.eventType !== TEAM_EVENT)
|
|
51405
51426
|
continue;
|
|
51406
|
-
const relevantTeamEntries = (event2.entries
|
|
51427
|
+
const relevantTeamEntries = (event2.entries ?? []).filter(
|
|
51407
51428
|
(entry) => relevantTeamParticipantIds.includes(entry.participantId)
|
|
51408
51429
|
);
|
|
51409
51430
|
for (const relevantEntry of relevantTeamEntries) {
|
|
@@ -51412,11 +51433,11 @@ function scaledTeamAssignment({
|
|
|
51412
51433
|
(teamParticipant) => teamParticipant.participantId === relevantTeamParticipantId
|
|
51413
51434
|
);
|
|
51414
51435
|
const individualParticipantIds2 = relevantTeam?.individualParticipantIds;
|
|
51415
|
-
event2.entries = (event2.entries
|
|
51436
|
+
event2.entries = (event2.entries ?? []).filter(
|
|
51416
51437
|
(entry) => !individualParticipantIds2.includes(entry.participantId)
|
|
51417
51438
|
);
|
|
51418
|
-
(event2.drawDefinitions
|
|
51419
|
-
drawDefinition.entries = (drawDefinition.entries
|
|
51439
|
+
(event2.drawDefinitions ?? []).forEach((drawDefinition) => {
|
|
51440
|
+
drawDefinition.entries = (drawDefinition.entries ?? []).filter(
|
|
51420
51441
|
(entry) => !individualParticipantIds2.includes(entry.participantId)
|
|
51421
51442
|
);
|
|
51422
51443
|
});
|
|
@@ -52683,7 +52704,7 @@ function publishEvent(params) {
|
|
|
52683
52704
|
policyDefinitions = appliedPolicies;
|
|
52684
52705
|
}
|
|
52685
52706
|
const itemType = `${PUBLISH}.${STATUS$1}`;
|
|
52686
|
-
const eventDrawIds = event.drawDefinitions?.map(({ drawId }) => drawId)
|
|
52707
|
+
const eventDrawIds = event.drawDefinitions?.map(({ drawId }) => drawId) ?? [];
|
|
52687
52708
|
const { timeItem } = getEventTimeItem({
|
|
52688
52709
|
itemType,
|
|
52689
52710
|
event
|
|
@@ -52693,7 +52714,7 @@ function publishEvent(params) {
|
|
|
52693
52714
|
} else if (!drawIds && (drawIdsToAdd?.length || drawIdsToRemove?.length)) {
|
|
52694
52715
|
drawIds = timeItem?.itemValue?.PUBLIC?.drawIds || [];
|
|
52695
52716
|
}
|
|
52696
|
-
drawIds = (drawIds
|
|
52717
|
+
drawIds = (drawIds ?? []).filter(
|
|
52697
52718
|
(drawId) => !drawIdsToRemove?.length || !drawIdsToRemove.includes(drawId)
|
|
52698
52719
|
);
|
|
52699
52720
|
if (drawIdsToAdd?.length) {
|
|
@@ -52706,7 +52727,7 @@ function publishEvent(params) {
|
|
|
52706
52727
|
if (!structureIds && (structureIdsToAdd?.length || structureIdsToRemove?.length)) {
|
|
52707
52728
|
structureIds = timeItem?.itemValue?.PUBLIC?.structureIds || [];
|
|
52708
52729
|
}
|
|
52709
|
-
structureIds = (structureIds
|
|
52730
|
+
structureIds = (structureIds ?? []).filter(
|
|
52710
52731
|
(structureId) => !structureIdsToRemove?.length || !structureIdsToRemove.includes(structureId)
|
|
52711
52732
|
);
|
|
52712
52733
|
if (structureIdsToAdd?.length) {
|
|
@@ -52715,7 +52736,7 @@ function publishEvent(params) {
|
|
|
52715
52736
|
if (!stages && (stagesToAdd?.length || stagesToRemove?.length)) {
|
|
52716
52737
|
stages = timeItem?.itemValue?.PUBLIC?.stages || [];
|
|
52717
52738
|
}
|
|
52718
|
-
stages = (stages
|
|
52739
|
+
stages = (stages ?? []).filter(
|
|
52719
52740
|
(stage) => !stagesToRemove?.length || !stagesToRemove.includes(stage)
|
|
52720
52741
|
);
|
|
52721
52742
|
if (stagesToAdd?.length) {
|
|
@@ -54034,14 +54055,14 @@ function analyzeDraws({ tournamentRecord }) {
|
|
|
54034
54055
|
const positionsAssigned = positionAssignments?.filter(
|
|
54035
54056
|
({ participantId }) => participantId
|
|
54036
54057
|
);
|
|
54037
|
-
positionsAssignedCount += positionsAssigned?.length
|
|
54038
|
-
const unassignedPositionsCount = (positionAssignments?.length
|
|
54058
|
+
positionsAssignedCount += positionsAssigned?.length ?? 0;
|
|
54059
|
+
const unassignedPositionsCount = (positionAssignments?.length ?? 0) - (positionsAssigned?.length ?? 0);
|
|
54039
54060
|
const { roundMatchUps, roundProfile, roundNumbers, maxMatchUpsCount } = getRoundMatchUps$1({ matchUps: inContextStructureMatchUps });
|
|
54040
54061
|
const activeRounds = roundProfile && Object.keys(roundProfile).filter((roundNumber) => !roundProfile[roundNumber].inactiveRound).map((roundNumber) => parseInt(roundNumber));
|
|
54041
54062
|
const inactiveRounds = roundProfile && Object.keys(roundProfile).filter((roundNumber) => roundProfile[roundNumber].inactiveRound).map((roundNumber) => parseInt(roundNumber));
|
|
54042
54063
|
const inactiveStructure = roundProfile && Object.values(roundProfile).every((profile) => profile.inactiveRound);
|
|
54043
54064
|
return {
|
|
54044
|
-
positionsAssignedCount: positionsAssigned?.length
|
|
54065
|
+
positionsAssignedCount: positionsAssigned?.length ?? 0,
|
|
54045
54066
|
maxWinningSideFirstRoundPosition,
|
|
54046
54067
|
unassignedPositionsCount,
|
|
54047
54068
|
inactiveStructure,
|
|
@@ -54167,7 +54188,7 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
54167
54188
|
courts.push(...venue.courts);
|
|
54168
54189
|
}
|
|
54169
54190
|
for (const court of courts) {
|
|
54170
|
-
const { startTime, endTime } = (court.dateAvailability
|
|
54191
|
+
const { startTime, endTime } = (court.dateAvailability ?? []).reduce(
|
|
54171
54192
|
(extents, availability) => {
|
|
54172
54193
|
const startMinutes = timeStringMinutes(extents.startTime);
|
|
54173
54194
|
const endMinutes = timeStringMinutes(extents.endTime);
|
|
@@ -54183,7 +54204,7 @@ function updateCourtAvailability({ tournamentRecord }) {
|
|
|
54183
54204
|
const existing = court.dateAvailability?.find(
|
|
54184
54205
|
(availability) => availability.date === date
|
|
54185
54206
|
);
|
|
54186
|
-
return existing
|
|
54207
|
+
return existing ?? { date, startTime, endTime };
|
|
54187
54208
|
});
|
|
54188
54209
|
const defaultAvailability = court.dateAvailability?.find(
|
|
54189
54210
|
(availability) => !availability.date
|
|
@@ -54400,7 +54421,7 @@ function clearMatchUpSchedule({
|
|
|
54400
54421
|
}).matchUps?.[0];
|
|
54401
54422
|
if (!matchUp)
|
|
54402
54423
|
return { error: MATCHUP_NOT_FOUND };
|
|
54403
|
-
const newTimeItems = (matchUp.timeItems
|
|
54424
|
+
const newTimeItems = (matchUp.timeItems ?? []).filter(
|
|
54404
54425
|
(timeItem) => timeItem?.itemType && !scheduleAttributes.includes(timeItem?.itemType)
|
|
54405
54426
|
);
|
|
54406
54427
|
matchUp.timeItems = newTimeItems;
|
|
@@ -55304,7 +55325,7 @@ function assignMatchUpSideParticipant({
|
|
|
55304
55325
|
matchUp.sides = [1, 2].map((currentSideNumber) => {
|
|
55305
55326
|
const existingSide = matchUp.sides?.find(
|
|
55306
55327
|
(side) => side.sideNumber === currentSideNumber
|
|
55307
|
-
)
|
|
55328
|
+
) ?? { sideNumber: currentSideNumber };
|
|
55308
55329
|
return sideNumber === currentSideNumber ? { ...existingSide, participantId } : existingSide;
|
|
55309
55330
|
});
|
|
55310
55331
|
if (noSideNumberProvided) {
|
|
@@ -55704,7 +55725,7 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55704
55725
|
const tieMatchUpSide = inContextTieMatchUp?.sides?.find(
|
|
55705
55726
|
(side2) => side2.sideNumber === dualMatchUpSide?.sideNumber
|
|
55706
55727
|
);
|
|
55707
|
-
const { participantId: pairParticipantId } = tieMatchUpSide
|
|
55728
|
+
const { participantId: pairParticipantId } = tieMatchUpSide ?? {};
|
|
55708
55729
|
const pairParticipant = pairParticipantId && getParticipants$1({
|
|
55709
55730
|
participantFilters: { participantIds: [pairParticipantId] },
|
|
55710
55731
|
tournamentRecord,
|
|
@@ -55740,26 +55761,24 @@ function removeTieMatchUpParticipantId(params) {
|
|
|
55740
55761
|
if (result.error)
|
|
55741
55762
|
console.log("cleanup", { result });
|
|
55742
55763
|
}
|
|
55743
|
-
} else {
|
|
55744
|
-
|
|
55745
|
-
|
|
55746
|
-
|
|
55764
|
+
} else if (individualParticipantIds.length === 1) {
|
|
55765
|
+
const { participant: existingParticipant } = getPairedParticipant({
|
|
55766
|
+
participantIds: individualParticipantIds,
|
|
55767
|
+
tournamentRecord
|
|
55768
|
+
});
|
|
55769
|
+
if (!existingParticipant) {
|
|
55770
|
+
const newPairParticipant = {
|
|
55771
|
+
participantRole: COMPETITOR,
|
|
55772
|
+
individualParticipantIds,
|
|
55773
|
+
participantType: PAIR
|
|
55774
|
+
};
|
|
55775
|
+
const result = addParticipant$1({
|
|
55776
|
+
participant: newPairParticipant,
|
|
55777
|
+
pairOverride: true,
|
|
55747
55778
|
tournamentRecord
|
|
55748
55779
|
});
|
|
55749
|
-
if (
|
|
55750
|
-
|
|
55751
|
-
participantRole: COMPETITOR,
|
|
55752
|
-
individualParticipantIds,
|
|
55753
|
-
participantType: PAIR
|
|
55754
|
-
};
|
|
55755
|
-
const result = addParticipant$1({
|
|
55756
|
-
participant: newPairParticipant,
|
|
55757
|
-
pairOverride: true,
|
|
55758
|
-
tournamentRecord
|
|
55759
|
-
});
|
|
55760
|
-
if (result.error)
|
|
55761
|
-
return decorateResult({ result, stack });
|
|
55762
|
-
}
|
|
55780
|
+
if (result.error)
|
|
55781
|
+
return decorateResult({ result, stack });
|
|
55763
55782
|
}
|
|
55764
55783
|
}
|
|
55765
55784
|
} else {
|
|
@@ -55821,9 +55840,9 @@ function getPositionAssignments({
|
|
|
55821
55840
|
structure
|
|
55822
55841
|
});
|
|
55823
55842
|
return {
|
|
55824
|
-
|
|
55825
|
-
|
|
55826
|
-
|
|
55843
|
+
positionAssignments: assignments ?? [],
|
|
55844
|
+
structureId: structure?.structureId,
|
|
55845
|
+
error
|
|
55827
55846
|
};
|
|
55828
55847
|
}
|
|
55829
55848
|
|
|
@@ -56169,7 +56188,7 @@ function addEventEntryPairs({
|
|
|
56169
56188
|
return { error: MISSING_EVENT };
|
|
56170
56189
|
if (event.eventType !== DOUBLES$1)
|
|
56171
56190
|
return { error: INVALID_EVENT_TYPE };
|
|
56172
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
56191
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
56173
56192
|
const individualParticipantIds = tournamentParticipants.filter((participant) => participant.participantType === INDIVIDUAL).map((participant) => participant.participantId);
|
|
56174
56193
|
const invalidParticipantIds = individualParticipantIds.filter(
|
|
56175
56194
|
(participantId) => !individualParticipantIds.includes(participantId)
|
|
@@ -56184,7 +56203,7 @@ function addEventEntryPairs({
|
|
|
56184
56203
|
const existingParticipantIdPairs = tournamentParticipants.filter((participant) => participant.participantType === PAIR).map((participant) => participant.individualParticipantIds);
|
|
56185
56204
|
const provisionalParticipants = participantIdPairs.map(
|
|
56186
56205
|
(individualParticipantIds2) => ({
|
|
56187
|
-
participantId: uuids?.pop()
|
|
56206
|
+
participantId: uuids?.pop() ?? UUID(),
|
|
56188
56207
|
participantRole: COMPETITOR,
|
|
56189
56208
|
individualParticipantIds: individualParticipantIds2,
|
|
56190
56209
|
participantType: PAIR
|
|
@@ -56326,7 +56345,7 @@ function assignSeedPositions(params) {
|
|
|
56326
56345
|
const { seedAssignments, seedLimit } = result;
|
|
56327
56346
|
const mergeObject = Object.assign(
|
|
56328
56347
|
{},
|
|
56329
|
-
...(seedAssignments
|
|
56348
|
+
...(seedAssignments ?? []).filter((assignment) => assignment.seedNumber).map((assignment) => ({ [assignment.seedNumber]: assignment }))
|
|
56330
56349
|
);
|
|
56331
56350
|
assignments.forEach((newAssignment) => {
|
|
56332
56351
|
const { seedNumber } = newAssignment;
|
|
@@ -56607,17 +56626,14 @@ function addEvent({
|
|
|
56607
56626
|
context
|
|
56608
56627
|
};
|
|
56609
56628
|
}
|
|
56610
|
-
const eventRecord =
|
|
56611
|
-
|
|
56612
|
-
|
|
56613
|
-
|
|
56614
|
-
|
|
56615
|
-
|
|
56616
|
-
|
|
56617
|
-
|
|
56618
|
-
},
|
|
56619
|
-
event
|
|
56620
|
-
);
|
|
56629
|
+
const eventRecord = {
|
|
56630
|
+
drawDefinitions: [],
|
|
56631
|
+
eventType: TypeEnum.Singles,
|
|
56632
|
+
entries: [],
|
|
56633
|
+
startDate,
|
|
56634
|
+
endDate,
|
|
56635
|
+
...event
|
|
56636
|
+
};
|
|
56621
56637
|
if (event.eventType === TypeEnum.Team) {
|
|
56622
56638
|
if (event.tieFormat) {
|
|
56623
56639
|
const result = validateTieFormat({ tieFormat: event.tieFormat });
|
|
@@ -56647,7 +56663,7 @@ function addEvent({
|
|
|
56647
56663
|
if (!suppressNotifications) {
|
|
56648
56664
|
const { topics } = getTopics();
|
|
56649
56665
|
if (topics.includes(ADD_MATCHUPS)) {
|
|
56650
|
-
const matchUps = allEventMatchUps({ event }).matchUps
|
|
56666
|
+
const matchUps = allEventMatchUps({ event }).matchUps ?? [];
|
|
56651
56667
|
addMatchUpsNotice({
|
|
56652
56668
|
tournamentId: tournamentRecord?.tournamentId,
|
|
56653
56669
|
eventId: event.eventId,
|
|
@@ -57264,11 +57280,9 @@ function setMatchUpFormat({
|
|
|
57264
57280
|
drawDefinition: drawDefinition2
|
|
57265
57281
|
});
|
|
57266
57282
|
}
|
|
57267
|
-
} else {
|
|
57268
|
-
|
|
57269
|
-
|
|
57270
|
-
modificationsCount += 1;
|
|
57271
|
-
}
|
|
57283
|
+
} else if (event2.matchUpFormat !== matchUpFormat) {
|
|
57284
|
+
event2.matchUpFormat = matchUpFormat;
|
|
57285
|
+
modificationsCount += 1;
|
|
57272
57286
|
}
|
|
57273
57287
|
}
|
|
57274
57288
|
if (!modificationsCount)
|
|
@@ -57489,7 +57503,7 @@ function getScaledEntries({
|
|
|
57489
57503
|
}) {
|
|
57490
57504
|
if (!tournamentRecord)
|
|
57491
57505
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
57492
|
-
entries = entries
|
|
57506
|
+
entries = entries ?? event?.entries ?? [];
|
|
57493
57507
|
const stageEntries = entries.filter(
|
|
57494
57508
|
(entry) => (!stage || !entry.entryStage || entry.entryStage === stage) && (!stageSequence || !entry.entryStageSequence || entry.entryStageSequence === stageSequence) && STRUCTURE_SELECTED_STATUSES.includes(entry.entryStatus)
|
|
57495
57509
|
);
|
|
@@ -57808,7 +57822,7 @@ function generateFlightProfile(params) {
|
|
|
57808
57822
|
} = params;
|
|
57809
57823
|
if (!event)
|
|
57810
57824
|
return { error: MISSING_EVENT };
|
|
57811
|
-
const eventEntries = event.entries
|
|
57825
|
+
const eventEntries = event.entries ?? [];
|
|
57812
57826
|
const { flightProfile } = getFlightProfile({ event });
|
|
57813
57827
|
if (flightProfile && attachFlightProfile$1 && !deleteExisting) {
|
|
57814
57828
|
return { error: EXISTING_PROFILE };
|
|
@@ -57857,7 +57871,7 @@ function generateFlightProfile(params) {
|
|
|
57857
57871
|
const flightNumber = index + 1;
|
|
57858
57872
|
return {
|
|
57859
57873
|
flightNumber,
|
|
57860
|
-
drawId: uuids?.pop()
|
|
57874
|
+
drawId: uuids?.pop() ?? UUID(),
|
|
57861
57875
|
drawEntries: getDrawEntries(splitEntries[index]),
|
|
57862
57876
|
drawName: drawNames?.length && drawNames[index] || `${drawNameRoot} ${flightNumber}`
|
|
57863
57877
|
};
|
|
@@ -58153,7 +58167,7 @@ function pruneDrawDefinition({
|
|
|
58153
58167
|
const structureData = drawAnalysis.structuresData.find(
|
|
58154
58168
|
({ structureId }) => mainStructure.structureId === structureId
|
|
58155
58169
|
);
|
|
58156
|
-
const matchUps = mainStructure.matchUps
|
|
58170
|
+
const matchUps = mainStructure.matchUps ?? [];
|
|
58157
58171
|
relevantMatchUps = matchUps.sort((a, b) => a.roundPosition - b.roundPosition).filter(
|
|
58158
58172
|
({ roundNumber }) => !structureData.inactiveRounds.includes(roundNumber)
|
|
58159
58173
|
);
|
|
@@ -58168,7 +58182,7 @@ function pruneDrawDefinition({
|
|
|
58168
58182
|
(matchUpId) => !matchPlayMatchUpIds.includes(matchUpId)
|
|
58169
58183
|
);
|
|
58170
58184
|
deletedMatchUpIds.push(...matchUpIdsToDelete);
|
|
58171
|
-
const existingDrawPositionPairings = matchPlayMatchUps.flatMap((matchUp) => matchUp.drawPositions
|
|
58185
|
+
const existingDrawPositionPairings = matchPlayMatchUps.flatMap((matchUp) => matchUp.drawPositions ?? []).filter(Boolean);
|
|
58172
58186
|
const existingDrawPositions = existingDrawPositionPairings.flat();
|
|
58173
58187
|
const drawPositionsMap = Object.assign(
|
|
58174
58188
|
{},
|
|
@@ -58225,7 +58239,7 @@ function modifyEventEntries({
|
|
|
58225
58239
|
return { error: MISSING_TOURNAMENT_RECORD };
|
|
58226
58240
|
if (!event)
|
|
58227
58241
|
return { error: MISSING_EVENT };
|
|
58228
|
-
const tournamentParticipants = tournamentRecord.participants
|
|
58242
|
+
const tournamentParticipants = tournamentRecord.participants ?? [];
|
|
58229
58243
|
const individualParticipantIds = tournamentParticipants.filter((participant) => participant.participantType === INDIVIDUAL).map((participant) => participant.participantId);
|
|
58230
58244
|
const incomingIndividualParticipantIds = unpairedParticipantIds.concat(...participantIdPairs).flat(Infinity);
|
|
58231
58245
|
const invalidParticipantIds = incomingIndividualParticipantIds.filter(
|
|
@@ -58275,7 +58289,7 @@ function modifyEventEntries({
|
|
|
58275
58289
|
entryStage
|
|
58276
58290
|
})
|
|
58277
58291
|
);
|
|
58278
|
-
event.entries = (event.entries
|
|
58292
|
+
event.entries = (event.entries ?? []).filter(
|
|
58279
58293
|
(entry) => entry.entryStage === entryStage
|
|
58280
58294
|
);
|
|
58281
58295
|
event.entries = event.entries.concat(
|
|
@@ -58306,7 +58320,7 @@ function addFlight({
|
|
|
58306
58320
|
if (!drawName)
|
|
58307
58321
|
return decorateResult({ result: { error: MISSING_VALUE }, stack });
|
|
58308
58322
|
if (drawEntries?.length) {
|
|
58309
|
-
const enteredParticipantIds = (event.entries
|
|
58323
|
+
const enteredParticipantIds = (event.entries ?? []).map(
|
|
58310
58324
|
extractAttributes("participantId")
|
|
58311
58325
|
);
|
|
58312
58326
|
const flightParticipantIds = drawEntries.map(
|
|
@@ -59430,10 +59444,7 @@ function isValidForQualifying({ structureId, drawDefinition }) {
|
|
|
59430
59444
|
if (result.error)
|
|
59431
59445
|
return result;
|
|
59432
59446
|
const targetFeedProfiles = result.links.target.flatMap((t) => t.target.feedProfile).filter(Boolean);
|
|
59433
|
-
const valid =
|
|
59434
|
-
[BOTTOM_UP, TOP_DOWN, RANDOM],
|
|
59435
|
-
targetFeedProfiles
|
|
59436
|
-
).length;
|
|
59447
|
+
const valid = !intersection([BOTTOM_UP, TOP_DOWN, RANDOM], targetFeedProfiles).length;
|
|
59437
59448
|
return { ...SUCCESS, valid };
|
|
59438
59449
|
}
|
|
59439
59450
|
|
|
@@ -59790,7 +59801,7 @@ function getPredictiveAccuracy(params) {
|
|
|
59790
59801
|
const ascending = scaleProfile?.ascending ?? params.ascending ?? false;
|
|
59791
59802
|
const valueAccessor = scaleProfile?.accessor ?? params.valueAccessor;
|
|
59792
59803
|
const ratingsRangeDifference = Array.isArray(scaleProfile?.range) ? Math.abs(scaleProfile.range[0] - scaleProfile.range[1]) : 0;
|
|
59793
|
-
const zoneMargin = isConvertableInteger(zonePct) && ratingsRangeDifference ? (zonePct
|
|
59804
|
+
const zoneMargin = isConvertableInteger(zonePct) && ratingsRangeDifference ? (zonePct ?? 0 / 100) * ratingsRangeDifference : params.zoneMargin ?? ratingsRangeDifference;
|
|
59794
59805
|
const contextProfile = { withScaleValues: true, withCompetitiveness: true };
|
|
59795
59806
|
const contextFilters = {
|
|
59796
59807
|
matchUpTypes: matchUpType ? [matchUpType] : [SINGLES$1, DOUBLES$1]
|
|
@@ -59828,7 +59839,7 @@ function getPredictiveAccuracy(params) {
|
|
|
59828
59839
|
}
|
|
59829
59840
|
const relevantMatchUps = matchUps.filter(
|
|
59830
59841
|
({ winningSide, score, sides, matchUpStatus }) => ![RETIRED$1, DEFAULTED, WALKOVER$2, DEAD_RUBBER, ABANDONED$1].includes(
|
|
59831
|
-
matchUpStatus
|
|
59842
|
+
matchUpStatus ?? ""
|
|
59832
59843
|
) && scoreHasValue({ score }) && sides?.length === 2 && winningSide
|
|
59833
59844
|
);
|
|
59834
59845
|
const accuracy = getGroupingAccuracy({
|
|
@@ -61105,7 +61116,7 @@ function getTournamentPoints({
|
|
|
61105
61116
|
policyTypes: [POLICY_TYPE_RANKING_POINTS],
|
|
61106
61117
|
tournamentRecord
|
|
61107
61118
|
});
|
|
61108
|
-
const pointsPolicy = policyDefinitions?.[POLICY_TYPE_RANKING_POINTS]
|
|
61119
|
+
const pointsPolicy = policyDefinitions?.[POLICY_TYPE_RANKING_POINTS] ?? attachedPolicies?.[POLICY_TYPE_RANKING_POINTS];
|
|
61109
61120
|
if (!pointsPolicy)
|
|
61110
61121
|
return { error: MISSING_POLICY_DEFINITION };
|
|
61111
61122
|
const awardProfiles = pointsPolicy.awardProfiles;
|
|
@@ -61120,7 +61131,7 @@ function getTournamentPoints({
|
|
|
61120
61131
|
const personPoints = {};
|
|
61121
61132
|
const teamPoints = {};
|
|
61122
61133
|
const pairPoints = {};
|
|
61123
|
-
for (const participant of participantsWithOutcomes
|
|
61134
|
+
for (const participant of participantsWithOutcomes ?? []) {
|
|
61124
61135
|
const { participantType, participantId, person, draws } = participant;
|
|
61125
61136
|
for (const draw of draws) {
|
|
61126
61137
|
const { drawId, structureParticipation, eventId } = draw;
|
|
@@ -61428,8 +61439,9 @@ function generateDynamicRatings({
|
|
|
61428
61439
|
matchUpFilters: { matchUpIds, matchUpStatuses: completedMatchUpStatuses },
|
|
61429
61440
|
tournamentRecord,
|
|
61430
61441
|
inContext: true
|
|
61431
|
-
}).matchUps
|
|
61432
|
-
|
|
61442
|
+
}).matchUps ?? [];
|
|
61443
|
+
matchUps.sort(matchUpSort);
|
|
61444
|
+
for (const matchUp of matchUps) {
|
|
61433
61445
|
const { endDate, matchUpFormat, score, sides, winningSide } = matchUp;
|
|
61434
61446
|
const matchUpType = matchUp.matchUpType;
|
|
61435
61447
|
const scaleAttributes = {
|
|
@@ -61445,12 +61457,12 @@ function generateDynamicRatings({
|
|
|
61445
61457
|
};
|
|
61446
61458
|
const sideParticipantIds = Object.assign(
|
|
61447
61459
|
{},
|
|
61448
|
-
...(sides
|
|
61460
|
+
...(sides ?? []).map((side) => {
|
|
61449
61461
|
const { sideNumber, participant } = side;
|
|
61450
61462
|
return sideNumber && {
|
|
61451
61463
|
[sideNumber]: [
|
|
61452
61464
|
participant?.participantId,
|
|
61453
|
-
...participant?.individualParticipantIds
|
|
61465
|
+
...participant?.individualParticipantIds ?? []
|
|
61454
61466
|
].filter(Boolean).flat()
|
|
61455
61467
|
};
|
|
61456
61468
|
})
|
|
@@ -62987,11 +62999,10 @@ function generateParticipants(params) {
|
|
|
62987
62999
|
}
|
|
62988
63000
|
if (ratingType && ratingsParameters$1[ratingType]) {
|
|
62989
63001
|
const { ratingMax, ratingMin, ratingAttributes } = category;
|
|
62990
|
-
const ratingParameters =
|
|
62991
|
-
|
|
62992
|
-
|
|
62993
|
-
|
|
62994
|
-
);
|
|
63002
|
+
const ratingParameters = {
|
|
63003
|
+
...ratingsParameters$1[ratingType],
|
|
63004
|
+
...ratingAttributes || {}
|
|
63005
|
+
};
|
|
62995
63006
|
const {
|
|
62996
63007
|
attributes = {},
|
|
62997
63008
|
decimalsCount,
|
|
@@ -63330,15 +63341,13 @@ function getParticipantsCount({
|
|
|
63330
63341
|
} else if (drawSize + alternatesCount && drawSize + alternatesCount > largestDoublesDraw) {
|
|
63331
63342
|
largestDoublesDraw = drawSize + alternatesCount;
|
|
63332
63343
|
}
|
|
63333
|
-
} else {
|
|
63334
|
-
|
|
63335
|
-
|
|
63336
|
-
|
|
63337
|
-
|
|
63338
|
-
|
|
63339
|
-
|
|
63340
|
-
largestSinglesDraw = drawSize + alternatesCount;
|
|
63341
|
-
}
|
|
63344
|
+
} else if (requiresUniqueParticipants) {
|
|
63345
|
+
const additionalParticipantsCount = drawSize + alternatesCount;
|
|
63346
|
+
if (gender)
|
|
63347
|
+
gendersCount[gender] += additionalParticipantsCount;
|
|
63348
|
+
uniqueParticipantsCount += additionalParticipantsCount;
|
|
63349
|
+
} else if (drawSize && drawSize > largestSinglesDraw) {
|
|
63350
|
+
largestSinglesDraw = drawSize + alternatesCount;
|
|
63342
63351
|
}
|
|
63343
63352
|
};
|
|
63344
63353
|
eventProfiles?.forEach((eventProfile) => {
|
|
@@ -64274,7 +64283,7 @@ function generateVenues({
|
|
|
64274
64283
|
for (const [index, venueProfile] of venueProfiles.entries()) {
|
|
64275
64284
|
const {
|
|
64276
64285
|
venueAbbreviation,
|
|
64277
|
-
venueId = uuids?.pop()
|
|
64286
|
+
venueId = uuids?.pop() ?? UUID(),
|
|
64278
64287
|
dateAvailability,
|
|
64279
64288
|
startTime = "07:00",
|
|
64280
64289
|
endTime = "19:00",
|
|
@@ -64537,7 +64546,7 @@ function generateScheduledRounds({
|
|
|
64537
64546
|
const containedStructures = getContainedStructures({
|
|
64538
64547
|
tournamentRecord
|
|
64539
64548
|
}).containedStructures;
|
|
64540
|
-
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps
|
|
64549
|
+
const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps ?? [];
|
|
64541
64550
|
const { tournamentId } = tournamentRecord;
|
|
64542
64551
|
const scheduledRounds = [];
|
|
64543
64552
|
for (const dateProfile of schedulingProfile) {
|
|
@@ -64558,7 +64567,7 @@ function generateScheduledRounds({
|
|
|
64558
64567
|
if (roundNumber && !winnerFinishingPositionRange) {
|
|
64559
64568
|
structureId = Object.keys(containedStructures).find(
|
|
64560
64569
|
(containingStructureId) => containedStructures[containingStructureId].includes(structureId)
|
|
64561
|
-
)
|
|
64570
|
+
) ?? structureId;
|
|
64562
64571
|
}
|
|
64563
64572
|
const roundToSchedule = {
|
|
64564
64573
|
tournamentId,
|