tods-competition-factory 2.0.5 → 2.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/dist/tods-competition-factory.d.ts +91 -71
- package/dist/tods-competition-factory.development.cjs.js +1153 -969
- 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 +3 -3
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
Object.defineProperty(exports, '__esModule', { value: true });
|
|
4
4
|
|
|
5
5
|
function factoryVersion() {
|
|
6
|
-
return '2.0.
|
|
6
|
+
return '2.0.7';
|
|
7
7
|
}
|
|
8
8
|
|
|
9
9
|
/******************************************************************************
|
|
@@ -3377,7 +3377,7 @@ var getMatchUpIds = function (o) {
|
|
|
3377
3377
|
if (o === void 0) { o = []; }
|
|
3378
3378
|
return o.map(getMatchUpId).filter(Boolean);
|
|
3379
3379
|
};
|
|
3380
|
-
var getParticipantIds = function (o) {
|
|
3380
|
+
var getParticipantIds$1 = function (o) {
|
|
3381
3381
|
if (o === void 0) { o = []; }
|
|
3382
3382
|
return o.map(getParticipantId).filter(Boolean);
|
|
3383
3383
|
};
|
|
@@ -3400,7 +3400,7 @@ function setDrawParticipantRepresentativeIds(_a) {
|
|
|
3400
3400
|
return { error: DRAW_DEFINITION_NOT_FOUND };
|
|
3401
3401
|
if (!Array.isArray(representativeParticipantIds))
|
|
3402
3402
|
return { error: INVALID_VALUES };
|
|
3403
|
-
var enteredParticipantIds = getParticipantIds((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) || []);
|
|
3403
|
+
var enteredParticipantIds = getParticipantIds$1((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) || []);
|
|
3404
3404
|
// An empty array is valid; if ids provided...
|
|
3405
3405
|
// check that all representativeParticipantIds are enteredParticipantIds
|
|
3406
3406
|
if (representativeParticipantIds.length &&
|
|
@@ -5096,8 +5096,8 @@ function addUpcomingMatchUps(_a) {
|
|
|
5096
5096
|
var firstMatchUp = (loserTargetLink === null || loserTargetLink === void 0 ? void 0 : loserTargetLink.linkCondition) === FIRST_MATCHUP;
|
|
5097
5097
|
var participants = getMatchUpParticipants(inContextMatchUp);
|
|
5098
5098
|
if (participants.length) {
|
|
5099
|
-
var winnerParticipantIds_1 = getParticipantIds(winnerMatchUp_1 === null || winnerMatchUp_1 === void 0 ? void 0 : winnerMatchUp_1.sides);
|
|
5100
|
-
var loserParticipantIds_1 = getParticipantIds(loserMatchUp_1 === null || loserMatchUp_1 === void 0 ? void 0 : loserMatchUp_1.sides);
|
|
5099
|
+
var winnerParticipantIds_1 = getParticipantIds$1(winnerMatchUp_1 === null || winnerMatchUp_1 === void 0 ? void 0 : winnerMatchUp_1.sides);
|
|
5100
|
+
var loserParticipantIds_1 = getParticipantIds$1(loserMatchUp_1 === null || loserMatchUp_1 === void 0 ? void 0 : loserMatchUp_1.sides);
|
|
5101
5101
|
var winnerDetermined = participants.find(function (_a) {
|
|
5102
5102
|
var participantId = _a.participantId;
|
|
5103
5103
|
return winnerParticipantIds_1.includes(participantId);
|
|
@@ -5637,7 +5637,7 @@ function getStageEntryTypeCount(_a) {
|
|
|
5637
5637
|
var stage = _a.stage, drawDefinition = _a.drawDefinition, entryStatus = _a.entryStatus;
|
|
5638
5638
|
return drawDefinition.entries.reduce(function (p, c) { return (c.entryStage === stage && c.entryStatus === entryStatus ? p + 1 : p); }, 0);
|
|
5639
5639
|
}
|
|
5640
|
-
function getStageEntries$
|
|
5640
|
+
function getStageEntries$2(_a) {
|
|
5641
5641
|
var _b, _c;
|
|
5642
5642
|
var provisionalPositioning = _a.provisionalPositioning, placementGroup = _a.placementGroup, drawDefinition = _a.drawDefinition, stageSequence = _a.stageSequence, entryStatuses = _a.entryStatuses, structureId = _a.structureId, roundTarget = _a.roundTarget, stages = _a.stages, stage = _a.stage;
|
|
5643
5643
|
var entries = (_c = (_b = drawDefinition.entries) === null || _b === void 0 ? void 0 : _b.reduce(function (entries, entry) {
|
|
@@ -5770,7 +5770,7 @@ function getStructureSeedAssignments(_a) {
|
|
|
5770
5770
|
var isPlayoffStructure = stage === PLAY_OFF;
|
|
5771
5771
|
var entries = isPlayoffStructure &&
|
|
5772
5772
|
drawDefinition &&
|
|
5773
|
-
getStageEntries$
|
|
5773
|
+
getStageEntries$2({
|
|
5774
5774
|
provisionalPositioning: provisionalPositioning,
|
|
5775
5775
|
drawDefinition: drawDefinition,
|
|
5776
5776
|
stageSequence: stageSequence,
|
|
@@ -15372,7 +15372,7 @@ function deleteParticipants(params) {
|
|
|
15372
15372
|
return participantsRemovedCount ? __assign(__assign({}, SUCCESS), { participantsRemovedCount: participantsRemovedCount }) : { error: CANNOT_REMOVE_PARTICIPANTS };
|
|
15373
15373
|
}
|
|
15374
15374
|
|
|
15375
|
-
function getStageEntries(_a) {
|
|
15375
|
+
function getStageEntries$1(_a) {
|
|
15376
15376
|
var _b, _c;
|
|
15377
15377
|
var _d = _a.selected, selected = _d === void 0 ? true : _d, drawDefinition = _a.drawDefinition, entryStatuses = _a.entryStatuses, drawId = _a.drawId, event = _a.event, stage = _a.stage;
|
|
15378
15378
|
var entries = (_b = event.entries) !== null && _b !== void 0 ? _b : [];
|
|
@@ -15426,7 +15426,7 @@ function destroyGroupEntry(_a) {
|
|
|
15426
15426
|
var entry = eventEntries.find(function (entry) { return entry.participantId === participantId; });
|
|
15427
15427
|
if (!entry)
|
|
15428
15428
|
return { error: PARTICIPANT_ENTRY_NOT_FOUND };
|
|
15429
|
-
var stageEntries = getStageEntries({
|
|
15429
|
+
var stageEntries = getStageEntries$1({
|
|
15430
15430
|
selected: false,
|
|
15431
15431
|
drawDefinition: drawDefinition,
|
|
15432
15432
|
drawId: drawId,
|
|
@@ -19049,7 +19049,7 @@ function positionUnseededParticipants(_a) {
|
|
|
19049
19049
|
var stage = structure.stage, stageSequence = structure.stageSequence;
|
|
19050
19050
|
var roundTarget = stage === QUALIFYING ? (_c = (_b = findExtension({ element: structure, name: ROUND_TARGET })) === null || _b === void 0 ? void 0 : _b.extension) === null || _c === void 0 ? void 0 : _c.value : undefined;
|
|
19051
19051
|
var entryStatuses = DIRECT_ENTRY_STATUSES;
|
|
19052
|
-
var entries = getStageEntries$
|
|
19052
|
+
var entries = getStageEntries$2({
|
|
19053
19053
|
provisionalPositioning: provisionalPositioning,
|
|
19054
19054
|
drawDefinition: drawDefinition,
|
|
19055
19055
|
stageSequence: stageSequence,
|
|
@@ -19294,7 +19294,7 @@ function getByesData(_a) {
|
|
|
19294
19294
|
: matchUps.length;
|
|
19295
19295
|
// get stage/stageSequence Entries and qualifiers
|
|
19296
19296
|
var structureId = structure.structureId, stage = structure.stage, stageSequence = structure.stageSequence;
|
|
19297
|
-
var entries = getStageEntries$
|
|
19297
|
+
var entries = getStageEntries$2({
|
|
19298
19298
|
entryStatuses: STRUCTURE_SELECTED_STATUSES,
|
|
19299
19299
|
provisionalPositioning: provisionalPositioning,
|
|
19300
19300
|
drawDefinition: drawDefinition,
|
|
@@ -19918,7 +19918,7 @@ function automatedPositioning(_a) {
|
|
|
19918
19918
|
structureId: structureId,
|
|
19919
19919
|
}).qualifiersCount;
|
|
19920
19920
|
var entryStatuses = DIRECT_ENTRY_STATUSES;
|
|
19921
|
-
var entries = getStageEntries$
|
|
19921
|
+
var entries = getStageEntries$2({
|
|
19922
19922
|
stageSequence: structure.stageSequence,
|
|
19923
19923
|
provisionalPositioning: provisionalPositioning,
|
|
19924
19924
|
stage: structure.stage,
|
|
@@ -26909,7 +26909,7 @@ function getEntriesAndSeedsCount(_a) {
|
|
|
26909
26909
|
var policyDefinitions = _a.policyDefinitions, drawDefinition = _a.drawDefinition, drawSize = _a.drawSize, drawId = _a.drawId, event = _a.event, stage = _a.stage;
|
|
26910
26910
|
if (!event)
|
|
26911
26911
|
return { error: MISSING_EVENT };
|
|
26912
|
-
var _b = getStageEntries({
|
|
26912
|
+
var _b = getStageEntries$1({
|
|
26913
26913
|
drawDefinition: drawDefinition,
|
|
26914
26914
|
drawId: drawId,
|
|
26915
26915
|
stage: stage,
|
|
@@ -27100,7 +27100,7 @@ function getEligibleVoluntaryConsolationParticipants(_a) {
|
|
|
27100
27100
|
inContext: true,
|
|
27101
27101
|
drawDefinition: drawDefinition,
|
|
27102
27102
|
})) === null || _e === void 0 ? void 0 : _e.matchUps) !== null && _f !== void 0 ? _f : [];
|
|
27103
|
-
var voluntaryConsolationEntries = getStageEntries$
|
|
27103
|
+
var voluntaryConsolationEntries = getStageEntries$2({
|
|
27104
27104
|
stage: VOLUNTARY_CONSOLATION,
|
|
27105
27105
|
drawDefinition: drawDefinition,
|
|
27106
27106
|
});
|
|
@@ -28878,7 +28878,7 @@ function positionActions(params) {
|
|
|
28878
28878
|
stages.push(MAIN);
|
|
28879
28879
|
if (stage === MAIN)
|
|
28880
28880
|
stages.push(CONSOLATION);
|
|
28881
|
-
var stageEntries = getStageEntries$
|
|
28881
|
+
var stageEntries = getStageEntries$2({
|
|
28882
28882
|
entryStatuses: DIRECT_ENTRY_STATUSES,
|
|
28883
28883
|
provisionalPositioning: provisionalPositioning,
|
|
28884
28884
|
drawDefinition: drawDefinition,
|
|
@@ -30139,7 +30139,7 @@ function generateVoluntaryConsolation(params) {
|
|
|
30139
30139
|
if (!drawDefinition)
|
|
30140
30140
|
return { error: MISSING_DRAW_DEFINITION };
|
|
30141
30141
|
var stage = VOLUNTARY_CONSOLATION;
|
|
30142
|
-
var entries = getStageEntries$
|
|
30142
|
+
var entries = getStageEntries$2({
|
|
30143
30143
|
stageSequence: 1,
|
|
30144
30144
|
drawDefinition: drawDefinition,
|
|
30145
30145
|
stage: stage,
|
|
@@ -30701,9 +30701,9 @@ var ENCOUNTER_VALUE = 100;
|
|
|
30701
30701
|
var SAME_TEAM_VALUE = 100;
|
|
30702
30702
|
var MAX_ITERATIONS = 4000;
|
|
30703
30703
|
function generateDrawMaticRound(_a) {
|
|
30704
|
-
var
|
|
30705
|
-
var _e, _f
|
|
30706
|
-
|
|
30704
|
+
var _b, _c;
|
|
30705
|
+
var _d = _a.encounterValue, encounterValue = _d === void 0 ? ENCOUNTER_VALUE : _d, _e = _a.sameTeamValue, sameTeamValue = _e === void 0 ? SAME_TEAM_VALUE : _e, _f = _a.maxIterations, maxIterations = _f === void 0 ? MAX_ITERATIONS : _f, _g = _a.generateMatchUps, generateMatchUps = _g === void 0 ? true : _g, ignoreLastRoundNumber = _a.ignoreLastRoundNumber, iterationMatchUps = _a.iterationMatchUps, // necessary when called iteratively and matchUps are not yet added to structure
|
|
30706
|
+
tournamentRecord = _a.tournamentRecord, participantIds = _a.participantIds, drawDefinition = _a.drawDefinition, adHocRatings = _a.adHocRatings, _h = _a.salted, salted = _h === void 0 ? 0.5 : _h, roundNumber = _a.roundNumber, structureId = _a.structureId, matchUpIds = _a.matchUpIds, eventType = _a.eventType, structure = _a.structure, scaleName = _a.scaleName, idPrefix = _a.idPrefix, isMock = _a.isMock, event = _a.event;
|
|
30707
30707
|
if (!drawDefinition)
|
|
30708
30708
|
return { error: MISSING_DRAW_DEFINITION };
|
|
30709
30709
|
if (!structure && !structureId)
|
|
@@ -30717,74 +30717,24 @@ function generateDrawMaticRound(_a) {
|
|
|
30717
30717
|
return { error: MISSING_PARTICIPANT_IDS };
|
|
30718
30718
|
}
|
|
30719
30719
|
// create valueObject for each previous encounter within the structure
|
|
30720
|
-
var
|
|
30721
|
-
|
|
30722
|
-
|
|
30723
|
-
|
|
30724
|
-
|
|
30725
|
-
|
|
30726
|
-
|
|
30727
|
-
|
|
30728
|
-
|
|
30729
|
-
for (var encounters_1 = __values(encounters), encounters_1_1 = encounters_1.next(); !encounters_1_1.done; encounters_1_1 = encounters_1.next()) {
|
|
30730
|
-
var pairing = encounters_1_1.value;
|
|
30731
|
-
if (!valueObjects[pairing])
|
|
30732
|
-
valueObjects[pairing] = 0;
|
|
30733
|
-
valueObjects[pairing] += encounterValue;
|
|
30734
|
-
}
|
|
30735
|
-
}
|
|
30736
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
30737
|
-
finally {
|
|
30738
|
-
try {
|
|
30739
|
-
if (encounters_1_1 && !encounters_1_1.done && (_b = encounters_1.return)) _b.call(encounters_1);
|
|
30740
|
-
}
|
|
30741
|
-
finally { if (e_1) throw e_1.error; }
|
|
30742
|
-
}
|
|
30743
|
-
var teamParticipants = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.filter(function (_a) {
|
|
30744
|
-
var participantType = _a.participantType;
|
|
30745
|
-
return participantType === TEAM;
|
|
30746
|
-
});
|
|
30747
|
-
if (teamParticipants) {
|
|
30748
|
-
try {
|
|
30749
|
-
// add SAME_TEAM_VALUE for participants who appear on the same team
|
|
30750
|
-
for (var teamParticipants_1 = __values(teamParticipants), teamParticipants_1_1 = teamParticipants_1.next(); !teamParticipants_1_1.done; teamParticipants_1_1 = teamParticipants_1.next()) {
|
|
30751
|
-
var teamParticipant = teamParticipants_1_1.value;
|
|
30752
|
-
var participantIds_1 = (_f = teamParticipant.individualParticipantIds) !== null && _f !== void 0 ? _f : [];
|
|
30753
|
-
var uniquePairings_2 = getPairingsData({ participantIds: participantIds_1 }).uniquePairings;
|
|
30754
|
-
try {
|
|
30755
|
-
for (var uniquePairings_1 = (e_3 = void 0, __values(uniquePairings_2)), uniquePairings_1_1 = uniquePairings_1.next(); !uniquePairings_1_1.done; uniquePairings_1_1 = uniquePairings_1.next()) {
|
|
30756
|
-
var pairing = uniquePairings_1_1.value;
|
|
30757
|
-
if (!valueObjects[pairing])
|
|
30758
|
-
valueObjects[pairing] = 0;
|
|
30759
|
-
valueObjects[pairing] += sameTeamValue;
|
|
30760
|
-
}
|
|
30761
|
-
}
|
|
30762
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
30763
|
-
finally {
|
|
30764
|
-
try {
|
|
30765
|
-
if (uniquePairings_1_1 && !uniquePairings_1_1.done && (_d = uniquePairings_1.return)) _d.call(uniquePairings_1);
|
|
30766
|
-
}
|
|
30767
|
-
finally { if (e_3) throw e_3.error; }
|
|
30768
|
-
}
|
|
30769
|
-
}
|
|
30770
|
-
}
|
|
30771
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
30772
|
-
finally {
|
|
30773
|
-
try {
|
|
30774
|
-
if (teamParticipants_1_1 && !teamParticipants_1_1.done && (_c = teamParticipants_1.return)) _c.call(teamParticipants_1);
|
|
30775
|
-
}
|
|
30776
|
-
finally { if (e_2) throw e_2.error; }
|
|
30777
|
-
}
|
|
30778
|
-
}
|
|
30720
|
+
var consideredMatchUps = __spreadArray(__spreadArray([], __read((iterationMatchUps !== null && iterationMatchUps !== void 0 ? iterationMatchUps : [])), false), __read(((_b = structure === null || structure === void 0 ? void 0 : structure.matchUps) !== null && _b !== void 0 ? _b : [])), false);
|
|
30721
|
+
var encounters = getEncounters({ matchUps: consideredMatchUps }).encounters;
|
|
30722
|
+
var tournamentParticipants = (_c = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) !== null && _c !== void 0 ? _c : [];
|
|
30723
|
+
var valueObjects = getValueObjects({
|
|
30724
|
+
tournamentParticipants: tournamentParticipants,
|
|
30725
|
+
encounterValue: encounterValue,
|
|
30726
|
+
sameTeamValue: sameTeamValue,
|
|
30727
|
+
encounters: encounters,
|
|
30728
|
+
}).valueObjects;
|
|
30779
30729
|
// deltaObjects contain the difference in ratings between two participants
|
|
30780
30730
|
// {
|
|
30781
30731
|
// 'P-I-0|P-I-1': 0,
|
|
30782
30732
|
// 'P-I-0|P-I-2': 0,
|
|
30783
30733
|
// 'P-I-0|P-I-3': 0
|
|
30784
30734
|
// }
|
|
30785
|
-
var
|
|
30735
|
+
var _j = getPairingsData({
|
|
30786
30736
|
participantIds: participantIds,
|
|
30787
|
-
}), uniquePairings =
|
|
30737
|
+
}), uniquePairings = _j.uniquePairings, possiblePairings = _j.possiblePairings, deltaObjects = _j.deltaObjects;
|
|
30788
30738
|
var params = {
|
|
30789
30739
|
tournamentParticipants: tournamentParticipants,
|
|
30790
30740
|
possiblePairings: possiblePairings,
|
|
@@ -30800,7 +30750,7 @@ function generateDrawMaticRound(_a) {
|
|
|
30800
30750
|
structure: structure,
|
|
30801
30751
|
salted: salted,
|
|
30802
30752
|
};
|
|
30803
|
-
var
|
|
30753
|
+
var _k = getPairings(params), candidatesCount = _k.candidatesCount, participantIdPairings = _k.participantIdPairings, iterations = _k.iterations, candidate = _k.candidate;
|
|
30804
30754
|
if (!candidatesCount)
|
|
30805
30755
|
return { error: NO_CANDIDATES };
|
|
30806
30756
|
var generatedRoundNumber;
|
|
@@ -30826,88 +30776,69 @@ function generateDrawMaticRound(_a) {
|
|
|
30826
30776
|
var maxDelta = candidate.maxDelta, maxDiff = candidate.maxDiff;
|
|
30827
30777
|
return __assign(__assign({ roundNumber: generatedRoundNumber, participantIdPairings: participantIdPairings, candidatesCount: candidatesCount }, SUCCESS), { iterations: iterations, matchUps: matchUps, maxDelta: maxDelta, maxDiff: maxDiff });
|
|
30828
30778
|
}
|
|
30829
|
-
|
|
30830
|
-
//
|
|
30831
|
-
|
|
30832
|
-
|
|
30833
|
-
|
|
30834
|
-
|
|
30835
|
-
|
|
30836
|
-
|
|
30837
|
-
|
|
30838
|
-
|
|
30839
|
-
|
|
30840
|
-
|
|
30841
|
-
|
|
30842
|
-
|
|
30843
|
-
|
|
30844
|
-
|
|
30845
|
-
|
|
30846
|
-
|
|
30847
|
-
});
|
|
30848
|
-
if (result.error)
|
|
30849
|
-
return result;
|
|
30850
|
-
if (!result.matchUp)
|
|
30851
|
-
return { error: MATCHUP_NOT_FOUND };
|
|
30852
|
-
var matchUp = result.matchUp;
|
|
30853
|
-
if ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpType) === TEAM$2)
|
|
30854
|
-
return {
|
|
30855
|
-
error: INVALID_MATCHUP,
|
|
30856
|
-
info: 'Cannot set matchUpFormat when { matchUpType: TEAM }',
|
|
30857
|
-
};
|
|
30858
|
-
matchUp.matchUpFormat = matchUpFormat;
|
|
30859
|
-
modifyMatchUpNotice({
|
|
30860
|
-
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
30861
|
-
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
30862
|
-
context: stack,
|
|
30863
|
-
drawDefinition: drawDefinition,
|
|
30864
|
-
matchUp: matchUp,
|
|
30865
|
-
});
|
|
30779
|
+
function getValueObjects(_a) {
|
|
30780
|
+
// valueObjects provide "weighting" to each possible pairing of participants
|
|
30781
|
+
// {
|
|
30782
|
+
// 'P-I-0|P-I-1': 1,
|
|
30783
|
+
// 'P-I-0|P-I-2': 1,
|
|
30784
|
+
// 'P-I-0|P-I-3': 1
|
|
30785
|
+
// }
|
|
30786
|
+
var e_1, _b, e_2, _c, e_3, _d;
|
|
30787
|
+
var _e;
|
|
30788
|
+
var encounters = _a.encounters, tournamentParticipants = _a.tournamentParticipants, encounterValue = _a.encounterValue, sameTeamValue = _a.sameTeamValue;
|
|
30789
|
+
var valueObjects = {};
|
|
30790
|
+
try {
|
|
30791
|
+
for (var encounters_1 = __values(encounters), encounters_1_1 = encounters_1.next(); !encounters_1_1.done; encounters_1_1 = encounters_1.next()) {
|
|
30792
|
+
var pairing = encounters_1_1.value;
|
|
30793
|
+
if (!valueObjects[pairing])
|
|
30794
|
+
valueObjects[pairing] = 0;
|
|
30795
|
+
valueObjects[pairing] += encounterValue;
|
|
30796
|
+
}
|
|
30866
30797
|
}
|
|
30867
|
-
|
|
30868
|
-
|
|
30869
|
-
return { error: INVALID_EVENT_TYPE };
|
|
30798
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
30799
|
+
finally {
|
|
30870
30800
|
try {
|
|
30871
|
-
|
|
30872
|
-
|
|
30873
|
-
|
|
30874
|
-
|
|
30875
|
-
|
|
30876
|
-
|
|
30877
|
-
|
|
30801
|
+
if (encounters_1_1 && !encounters_1_1.done && (_b = encounters_1.return)) _b.call(encounters_1);
|
|
30802
|
+
}
|
|
30803
|
+
finally { if (e_1) throw e_1.error; }
|
|
30804
|
+
}
|
|
30805
|
+
var teamParticipants = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.filter(function (_a) {
|
|
30806
|
+
var participantType = _a.participantType;
|
|
30807
|
+
return participantType === TEAM;
|
|
30808
|
+
});
|
|
30809
|
+
if (teamParticipants) {
|
|
30810
|
+
try {
|
|
30811
|
+
// add SAME_TEAM_VALUE for participants who appear on the same team
|
|
30812
|
+
for (var teamParticipants_1 = __values(teamParticipants), teamParticipants_1_1 = teamParticipants_1.next(); !teamParticipants_1_1.done; teamParticipants_1_1 = teamParticipants_1.next()) {
|
|
30813
|
+
var teamParticipant = teamParticipants_1_1.value;
|
|
30814
|
+
var participantIds = (_e = teamParticipant.individualParticipantIds) !== null && _e !== void 0 ? _e : [];
|
|
30815
|
+
var uniquePairings = getPairingsData({ participantIds: participantIds }).uniquePairings;
|
|
30816
|
+
try {
|
|
30817
|
+
for (var uniquePairings_1 = (e_3 = void 0, __values(uniquePairings)), uniquePairings_1_1 = uniquePairings_1.next(); !uniquePairings_1_1.done; uniquePairings_1_1 = uniquePairings_1.next()) {
|
|
30818
|
+
var pairing = uniquePairings_1_1.value;
|
|
30819
|
+
if (!valueObjects[pairing])
|
|
30820
|
+
valueObjects[pairing] = 0;
|
|
30821
|
+
valueObjects[pairing] += sameTeamValue;
|
|
30822
|
+
}
|
|
30878
30823
|
}
|
|
30879
|
-
|
|
30880
|
-
|
|
30824
|
+
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
30825
|
+
finally {
|
|
30826
|
+
try {
|
|
30827
|
+
if (uniquePairings_1_1 && !uniquePairings_1_1.done && (_d = uniquePairings_1.return)) _d.call(uniquePairings_1);
|
|
30828
|
+
}
|
|
30829
|
+
finally { if (e_3) throw e_3.error; }
|
|
30881
30830
|
}
|
|
30882
30831
|
}
|
|
30883
30832
|
}
|
|
30884
|
-
catch (
|
|
30833
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
30885
30834
|
finally {
|
|
30886
30835
|
try {
|
|
30887
|
-
if (
|
|
30836
|
+
if (teamParticipants_1_1 && !teamParticipants_1_1.done && (_c = teamParticipants_1.return)) _c.call(teamParticipants_1);
|
|
30888
30837
|
}
|
|
30889
|
-
finally { if (
|
|
30890
|
-
}
|
|
30891
|
-
}
|
|
30892
|
-
else if (structureId) {
|
|
30893
|
-
if ((event === null || event === void 0 ? void 0 : event.eventType) === TEAM$2)
|
|
30894
|
-
return { error: INVALID_EVENT_TYPE };
|
|
30895
|
-
var result = findStructure({ drawDefinition: drawDefinition, structureId: structureId });
|
|
30896
|
-
if (result.error)
|
|
30897
|
-
return result;
|
|
30898
|
-
if (!result.structure) {
|
|
30899
|
-
return { error: STRUCTURE_NOT_FOUND };
|
|
30900
|
-
}
|
|
30901
|
-
else {
|
|
30902
|
-
result.structure.matchUpFormat = matchUpFormat;
|
|
30838
|
+
finally { if (e_2) throw e_2.error; }
|
|
30903
30839
|
}
|
|
30904
30840
|
}
|
|
30905
|
-
|
|
30906
|
-
drawDefinition.matchUpFormat = matchUpFormat;
|
|
30907
|
-
}
|
|
30908
|
-
structureIds = structureIds !== null && structureIds !== void 0 ? structureIds : (structureId ? [structureId] : undefined);
|
|
30909
|
-
modifyDrawNotice({ drawDefinition: drawDefinition, structureIds: structureIds });
|
|
30910
|
-
return __assign({}, SUCCESS);
|
|
30841
|
+
return { valueObjects: valueObjects };
|
|
30911
30842
|
}
|
|
30912
30843
|
|
|
30913
30844
|
function credits() {
|
|
@@ -35913,7 +35844,7 @@ function validateAndDeriveDrawValues(params) {
|
|
|
35913
35844
|
});
|
|
35914
35845
|
}
|
|
35915
35846
|
var seedingPolicy = (_a = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING]) !== null && _a !== void 0 ? _a : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING];
|
|
35916
|
-
var seedingProfile = (_e = (_b = params.seedingProfile) !== null && _b !== void 0 ? _b : (_d = (_c = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _c === void 0 ? void 0 : _c.drawTypes) === null || _d === void 0 ? void 0 : _d[drawType]) !== null && _e !== void 0 ? _e : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
|
|
35847
|
+
var seedingProfile = (_e = (_b = params.seedingProfile) !== null && _b !== void 0 ? _b : (_d = (_c = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _c === void 0 ? void 0 : _c.drawTypes) === null || _d === void 0 ? void 0 : _d[drawType !== null && drawType !== void 0 ? drawType : '']) !== null && _e !== void 0 ? _e : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
|
|
35917
35848
|
// extend policyDefinitions only if a seedingProfile was specified in params
|
|
35918
35849
|
if (params.seedingProfile) {
|
|
35919
35850
|
if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
|
|
@@ -36007,110 +35938,233 @@ function checkDrawTypeIsAllowed(params) {
|
|
|
36007
35938
|
return __assign({}, SUCCESS);
|
|
36008
35939
|
}
|
|
36009
35940
|
|
|
36010
|
-
|
|
36011
|
-
|
|
36012
|
-
var
|
|
36013
|
-
var
|
|
36014
|
-
var
|
|
36015
|
-
|
|
36016
|
-
|
|
35941
|
+
function processExistingDrawDefinition(params) {
|
|
35942
|
+
var _a, _b, _c, _d, _e;
|
|
35943
|
+
var drawDefinition = params.drawDefinition;
|
|
35944
|
+
var existingQualifyingPlaceholderStructureId = params.existingQualifyingPlaceholderStructureId, drawEntries = params.drawEntries, appliedPolicies = params.appliedPolicies, structureId = params.structureId, idPrefix = params.idPrefix, isMock = params.isMock;
|
|
35945
|
+
var qualifyingProfiles = params.qualifyingProfiles;
|
|
35946
|
+
var qualifyingResult = (qualifyingProfiles === null || qualifyingProfiles === void 0 ? void 0 : qualifyingProfiles.length)
|
|
35947
|
+
? generateQualifyingStructures({
|
|
35948
|
+
uuids: params.uuids,
|
|
35949
|
+
qualifyingProfiles: qualifyingProfiles,
|
|
35950
|
+
appliedPolicies: appliedPolicies,
|
|
35951
|
+
idPrefix: idPrefix,
|
|
35952
|
+
isMock: isMock,
|
|
35953
|
+
})
|
|
35954
|
+
: undefined;
|
|
35955
|
+
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
|
|
35956
|
+
return qualifyingResult;
|
|
35957
|
+
}
|
|
35958
|
+
drawDefinition.structures = (_a = drawDefinition.structures) === null || _a === void 0 ? void 0 : _a.filter(function (_a) {
|
|
35959
|
+
var structureId = _a.structureId;
|
|
35960
|
+
return structureId !== existingQualifyingPlaceholderStructureId;
|
|
35961
|
+
});
|
|
35962
|
+
drawDefinition.links = (_b = drawDefinition.links) === null || _b === void 0 ? void 0 : _b.filter(function (_a) {
|
|
35963
|
+
var source = _a.source;
|
|
35964
|
+
return source.structureId !== existingQualifyingPlaceholderStructureId;
|
|
35965
|
+
});
|
|
35966
|
+
var _f = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _f.qualifiersCount, qualifyingDrawPositionsCount = _f.qualifyingDrawPositionsCount, qualifyingDetails = _f.qualifyingDetails;
|
|
35967
|
+
if (qualifyingDrawPositionsCount) {
|
|
35968
|
+
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
|
|
35969
|
+
(_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c.push.apply(_c, __spreadArray([], __read(qualifyingResult.structures), false));
|
|
35970
|
+
}
|
|
35971
|
+
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
|
|
35972
|
+
(_d = drawDefinition.links) === null || _d === void 0 ? void 0 : _d.push.apply(_d, __spreadArray([], __read(qualifyingResult.links), false));
|
|
35973
|
+
}
|
|
35974
|
+
}
|
|
35975
|
+
var mainStructure = (_e = drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (_a) {
|
|
35976
|
+
var stage = _a.stage, stageSequence = _a.stageSequence;
|
|
35977
|
+
return stage === MAIN && stageSequence === 1;
|
|
35978
|
+
});
|
|
35979
|
+
var existingQualifiersCount = getQualifiersCount({
|
|
35980
|
+
stageSequence: 1,
|
|
35981
|
+
drawDefinition: drawDefinition,
|
|
35982
|
+
structureId: structureId,
|
|
35983
|
+
stage: MAIN,
|
|
35984
|
+
}).qualifiersCount;
|
|
35985
|
+
var derivedQualifiersCount = Math.max(qualifiersCount !== null && qualifiersCount !== void 0 ? qualifiersCount : 0, existingQualifiersCount !== null && existingQualifiersCount !== void 0 ? existingQualifiersCount : 0);
|
|
35986
|
+
var result = setStageQualifiersCount({
|
|
35987
|
+
qualifiersCount: derivedQualifiersCount,
|
|
35988
|
+
drawDefinition: drawDefinition,
|
|
35989
|
+
stage: MAIN,
|
|
36017
35990
|
});
|
|
36018
35991
|
if (result.error)
|
|
36019
35992
|
return result;
|
|
35993
|
+
result = setStageDrawSize({
|
|
35994
|
+
drawSize: qualifyingDrawPositionsCount,
|
|
35995
|
+
stage: QUALIFYING,
|
|
35996
|
+
drawDefinition: drawDefinition,
|
|
35997
|
+
});
|
|
35998
|
+
if (result.error)
|
|
35999
|
+
return result;
|
|
36000
|
+
addEntries$1({ drawDefinition: drawDefinition, drawEntries: drawEntries });
|
|
36001
|
+
var qResult = processQualifyingDetails({ mainStructure: mainStructure, qualifyingDetails: qualifyingDetails, drawDefinition: drawDefinition });
|
|
36002
|
+
if (qResult.error)
|
|
36003
|
+
return qResult;
|
|
36004
|
+
return { drawDefinition: drawDefinition, structureId: structureId };
|
|
36005
|
+
}
|
|
36006
|
+
function addEntries$1(_a) {
|
|
36007
|
+
var e_1, _b;
|
|
36008
|
+
var _c;
|
|
36009
|
+
var drawDefinition = _a.drawDefinition, drawEntries = _a.drawEntries;
|
|
36020
36010
|
try {
|
|
36021
|
-
for (var
|
|
36022
|
-
var
|
|
36023
|
-
|
|
36024
|
-
|
|
36011
|
+
for (var _d = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
|
|
36012
|
+
var entryStage = _a.entryStage;
|
|
36013
|
+
return entryStage === QUALIFYING;
|
|
36014
|
+
})), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
36015
|
+
var entry = _e.value;
|
|
36016
|
+
var entryData = __assign(__assign({}, entry), { entryStage: (_c = entry.entryStage) !== null && _c !== void 0 ? _c : MAIN, drawDefinition: drawDefinition });
|
|
36017
|
+
// ignore errors (EXITING_PARTICIPANT)
|
|
36018
|
+
addDrawEntry(entryData);
|
|
36025
36019
|
}
|
|
36026
36020
|
}
|
|
36027
36021
|
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36028
36022
|
finally {
|
|
36029
36023
|
try {
|
|
36030
|
-
if (
|
|
36024
|
+
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
36031
36025
|
}
|
|
36032
36026
|
finally { if (e_1) throw e_1.error; }
|
|
36033
36027
|
}
|
|
36034
|
-
return { tieFormat: tieFormat };
|
|
36035
36028
|
}
|
|
36036
|
-
|
|
36037
|
-
var
|
|
36038
|
-
|
|
36039
|
-
|
|
36040
|
-
|
|
36041
|
-
|
|
36042
|
-
|
|
36043
|
-
|
|
36044
|
-
|
|
36045
|
-
|
|
36046
|
-
|
|
36047
|
-
|
|
36048
|
-
|
|
36049
|
-
|
|
36050
|
-
|
|
36051
|
-
|
|
36052
|
-
|
|
36053
|
-
|
|
36054
|
-
|
|
36055
|
-
|
|
36056
|
-
|
|
36057
|
-
|
|
36058
|
-
|
|
36059
|
-
|
|
36060
|
-
|
|
36061
|
-
idPrefix = params.idPrefix, salted = params.salted, event = params.event;
|
|
36062
|
-
if (roundsCount && typeof roundsCount !== 'number') {
|
|
36063
|
-
return { error: INVALID_VALUES, info: 'roundsCount must be a number' };
|
|
36064
|
-
}
|
|
36065
|
-
if (typeof drawDefinition !== 'object' || (drawDefinition.drawType && drawDefinition.drawType !== AD_HOC)) {
|
|
36066
|
-
return { error: INVALID_DRAW_DEFINITION };
|
|
36029
|
+
function processQualifyingDetails(_a) {
|
|
36030
|
+
var e_2, _b;
|
|
36031
|
+
var _c;
|
|
36032
|
+
var mainStructure = _a.mainStructure, qualifyingDetails = _a.qualifyingDetails, drawDefinition = _a.drawDefinition;
|
|
36033
|
+
try {
|
|
36034
|
+
for (var _d = __values(qualifyingDetails || []), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
36035
|
+
var qualifyingDetail = _e.value;
|
|
36036
|
+
var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
|
|
36037
|
+
var link = mainStructure &&
|
|
36038
|
+
((_c = generateQualifyingLink({
|
|
36039
|
+
targetStructureId: mainStructure.structureId,
|
|
36040
|
+
sourceStructureId: qualifyingStructureId,
|
|
36041
|
+
sourceRoundNumber: qualifyingRoundNumber,
|
|
36042
|
+
finishingPositions: finishingPositions,
|
|
36043
|
+
targetEntryRound: targetEntryRound,
|
|
36044
|
+
linkType: linkType,
|
|
36045
|
+
})) === null || _c === void 0 ? void 0 : _c.link);
|
|
36046
|
+
if (link === null || link === void 0 ? void 0 : link.error)
|
|
36047
|
+
return link;
|
|
36048
|
+
if (link) {
|
|
36049
|
+
if (!drawDefinition.links)
|
|
36050
|
+
drawDefinition.links = [];
|
|
36051
|
+
drawDefinition.links.push(link);
|
|
36052
|
+
}
|
|
36053
|
+
}
|
|
36067
36054
|
}
|
|
36068
|
-
|
|
36069
|
-
|
|
36070
|
-
|
|
36071
|
-
|
|
36055
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
36056
|
+
finally {
|
|
36057
|
+
try {
|
|
36058
|
+
if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
|
|
36059
|
+
}
|
|
36060
|
+
finally { if (e_2) throw e_2.error; }
|
|
36072
36061
|
}
|
|
36073
|
-
|
|
36074
|
-
|
|
36075
|
-
|
|
36076
|
-
|
|
36077
|
-
|
|
36078
|
-
|
|
36079
|
-
|
|
36080
|
-
|
|
36081
|
-
|
|
36082
|
-
|
|
36083
|
-
|
|
36084
|
-
|
|
36062
|
+
return { error: undefined };
|
|
36063
|
+
}
|
|
36064
|
+
|
|
36065
|
+
function generateAdHocRounds(_a) {
|
|
36066
|
+
var e_1, _b;
|
|
36067
|
+
var _c, _d;
|
|
36068
|
+
var _e = _a.roundsCount, roundsCount = _e === void 0 ? 1 : _e, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, structureId = _a.structureId, idPrefix = _a.idPrefix, isMock = _a.isMock, event = _a.event;
|
|
36069
|
+
var matchUps = [];
|
|
36070
|
+
var roundNumber;
|
|
36071
|
+
try {
|
|
36072
|
+
for (var _f = __values(generateRange(1, roundsCount + 1)), _g = _f.next(); !_g.done; _g = _f.next()) {
|
|
36073
|
+
var iteration = _g.value;
|
|
36074
|
+
// on the first iteration roundNumber is undefined and generateAdHocMatchUps will infer the roundNumber from existing matchUps
|
|
36075
|
+
// on subsequent iterations roundNumber will be incremented and ignoreLastRoundNumber will be true to avoid inference error
|
|
36076
|
+
var genResult = generateAdHocMatchUps({
|
|
36077
|
+
ignoreLastRoundNumber: !!roundNumber,
|
|
36078
|
+
newRound: !roundNumber,
|
|
36079
|
+
drawDefinition: drawDefinition,
|
|
36080
|
+
matchUpsCount: matchUpsCount,
|
|
36081
|
+
structureId: structureId,
|
|
36082
|
+
roundNumber: roundNumber,
|
|
36083
|
+
idPrefix: idPrefix,
|
|
36084
|
+
isMock: isMock,
|
|
36085
|
+
event: event,
|
|
36085
36086
|
});
|
|
36087
|
+
if (genResult.error)
|
|
36088
|
+
return decorateResult({ result: genResult, info: { iteration: iteration } });
|
|
36089
|
+
if ((_c = genResult.matchUps) === null || _c === void 0 ? void 0 : _c.length)
|
|
36090
|
+
matchUps.push.apply(matchUps, __spreadArray([], __read(genResult.matchUps), false));
|
|
36091
|
+
roundNumber = ((_d = genResult === null || genResult === void 0 ? void 0 : genResult.roundNumber) !== null && _d !== void 0 ? _d : 1) + 1;
|
|
36092
|
+
}
|
|
36086
36093
|
}
|
|
36087
|
-
|
|
36088
|
-
|
|
36094
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36095
|
+
finally {
|
|
36096
|
+
try {
|
|
36097
|
+
if (_g && !_g.done && (_b = _f.return)) _b.call(_f);
|
|
36098
|
+
}
|
|
36099
|
+
finally { if (e_1) throw e_1.error; }
|
|
36089
36100
|
}
|
|
36090
|
-
|
|
36091
|
-
|
|
36092
|
-
|
|
36093
|
-
|
|
36101
|
+
return { matchUps: matchUps };
|
|
36102
|
+
}
|
|
36103
|
+
|
|
36104
|
+
function drawMatic(params) {
|
|
36105
|
+
var e_1, _a;
|
|
36106
|
+
var _b, _c, _d, _e, _f, _g;
|
|
36107
|
+
var paramsCheck = checkParams(params);
|
|
36108
|
+
if (paramsCheck === null || paramsCheck === void 0 ? void 0 : paramsCheck.error)
|
|
36109
|
+
return paramsCheck;
|
|
36110
|
+
var idsResult = getParticipantIds(params);
|
|
36111
|
+
if (idsResult.error)
|
|
36112
|
+
return idsResult;
|
|
36113
|
+
var structureResult = getStructure(params);
|
|
36114
|
+
if (structureResult.error)
|
|
36115
|
+
return structureResult;
|
|
36116
|
+
var adHocRatings = getAdHocRatings(params);
|
|
36117
|
+
// TODO: update dynamic ratings based on matchUps present from last played round
|
|
36118
|
+
// use scaleEngine.generateDynamicRatings(); see dynamicCalculations.test.ts
|
|
36119
|
+
var isMock = (_c = (_b = params.tournamentRecord) === null || _b === void 0 ? void 0 : _b.isMock) !== null && _c !== void 0 ? _c : params.isMock;
|
|
36120
|
+
var eventType = (_d = params.eventType) !== null && _d !== void 0 ? _d : (_e = params.event) === null || _e === void 0 ? void 0 : _e.eventType;
|
|
36121
|
+
var matchUps = [];
|
|
36122
|
+
var roundResults = [];
|
|
36123
|
+
var roundNumber;
|
|
36124
|
+
try {
|
|
36125
|
+
for (var _h = __values(generateRange(1, ((_f = params.roundsCount) !== null && _f !== void 0 ? _f : 1) + 1)), _j = _h.next(); !_j.done; _j = _h.next()) {
|
|
36126
|
+
var iteration = _j.value;
|
|
36127
|
+
var result = generateDrawMaticRound(__assign(__assign({}, params), { participantIds: idsResult.participantIds, structure: structureResult.structure, ignoreLastRoundNumber: true, iterationMatchUps: matchUps, adHocRatings: adHocRatings, roundNumber: roundNumber, eventType: eventType, isMock: isMock }));
|
|
36128
|
+
if (result.error)
|
|
36129
|
+
return result;
|
|
36130
|
+
var roundMatchUps = result.matchUps, roundResult = __rest(result, ["matchUps"]);
|
|
36131
|
+
roundResults.push(__assign(__assign({}, roundResult), { iteration: iteration, matchUpsCount: roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps.length }));
|
|
36132
|
+
roundNumber = ((_g = roundResult === null || roundResult === void 0 ? void 0 : roundResult.roundNumber) !== null && _g !== void 0 ? _g : 1) + 1;
|
|
36133
|
+
if (roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps.length) {
|
|
36134
|
+
matchUps.push.apply(matchUps, __spreadArray([], __read(roundMatchUps), false));
|
|
36135
|
+
}
|
|
36136
|
+
}
|
|
36094
36137
|
}
|
|
36095
|
-
|
|
36096
|
-
|
|
36097
|
-
|
|
36098
|
-
|
|
36099
|
-
|
|
36100
|
-
|
|
36101
|
-
? structure
|
|
36102
|
-
: targetStructure;
|
|
36103
|
-
}, undefined);
|
|
36104
|
-
structureId = targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.structureId;
|
|
36138
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36139
|
+
finally {
|
|
36140
|
+
try {
|
|
36141
|
+
if (_j && !_j.done && (_a = _h.return)) _a.call(_h);
|
|
36142
|
+
}
|
|
36143
|
+
finally { if (e_1) throw e_1.error; }
|
|
36105
36144
|
}
|
|
36106
|
-
|
|
36107
|
-
|
|
36108
|
-
|
|
36109
|
-
|
|
36110
|
-
var
|
|
36111
|
-
|
|
36112
|
-
|
|
36113
|
-
|
|
36145
|
+
return __assign(__assign({}, SUCCESS), { matchUps: matchUps, roundResults: roundResults });
|
|
36146
|
+
}
|
|
36147
|
+
function getScaleValue(_a) {
|
|
36148
|
+
var _b;
|
|
36149
|
+
var _c = _a.scaleType, scaleType = _c === void 0 ? RATING$1 : _c, scaleAccessor = _a.scaleAccessor, participant = _a.participant, scaleName = _a.scaleName, eventType = _a.eventType;
|
|
36150
|
+
var scaleAttributes = {
|
|
36151
|
+
eventType: eventType !== null && eventType !== void 0 ? eventType : SINGLES_EVENT,
|
|
36152
|
+
scaleType: scaleType,
|
|
36153
|
+
scaleName: scaleName,
|
|
36154
|
+
};
|
|
36155
|
+
var result = participant &&
|
|
36156
|
+
participantScaleItem({
|
|
36157
|
+
scaleAttributes: scaleAttributes,
|
|
36158
|
+
participant: participant,
|
|
36159
|
+
});
|
|
36160
|
+
var scaleValue = (_b = result === null || result === void 0 ? void 0 : result.scaleItem) === null || _b === void 0 ? void 0 : _b.scaleValue;
|
|
36161
|
+
return scaleAccessor && isObject(scaleValue) ? scaleValue[scaleAccessor] : scaleValue;
|
|
36162
|
+
}
|
|
36163
|
+
function getAdHocRatings(params) {
|
|
36164
|
+
var e_2, _a;
|
|
36165
|
+
var _b;
|
|
36166
|
+
var tournamentRecord = params.tournamentRecord, participantIds = params.participantIds, scaleAccessor = params.scaleAccessor, scaleName = params.scaleName, eventType = params.eventType, _c = params.adHocRatings, adHocRatings = _c === void 0 ? {} : _c;
|
|
36167
|
+
var tournamentParticipants = (_b = tournamentRecord.participants) !== null && _b !== void 0 ? _b : [];
|
|
36114
36168
|
var _loop_1 = function (participantId) {
|
|
36115
36169
|
var participant = tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.find(function (participant) { return participant.participantId === participantId; });
|
|
36116
36170
|
// first see if there is already a dynamic value
|
|
@@ -36133,79 +36187,135 @@ function drawMatic(params) {
|
|
|
36133
36187
|
adHocRatings[participantId] = scaleValue;
|
|
36134
36188
|
};
|
|
36135
36189
|
try {
|
|
36136
|
-
for (var
|
|
36137
|
-
var participantId =
|
|
36190
|
+
for (var _d = __values(participantIds !== null && participantIds !== void 0 ? participantIds : []), _e = _d.next(); !_e.done; _e = _d.next()) {
|
|
36191
|
+
var participantId = _e.value;
|
|
36138
36192
|
_loop_1(participantId);
|
|
36139
36193
|
}
|
|
36140
36194
|
}
|
|
36141
|
-
catch (
|
|
36195
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
36142
36196
|
finally {
|
|
36143
36197
|
try {
|
|
36144
|
-
if (
|
|
36198
|
+
if (_e && !_e.done && (_a = _d.return)) _a.call(_d);
|
|
36145
36199
|
}
|
|
36146
|
-
finally { if (
|
|
36200
|
+
finally { if (e_2) throw e_2.error; }
|
|
36147
36201
|
}
|
|
36148
|
-
|
|
36149
|
-
|
|
36150
|
-
|
|
36151
|
-
var
|
|
36152
|
-
|
|
36153
|
-
|
|
36154
|
-
|
|
36155
|
-
|
|
36156
|
-
|
|
36157
|
-
|
|
36158
|
-
|
|
36159
|
-
|
|
36160
|
-
|
|
36161
|
-
|
|
36162
|
-
|
|
36202
|
+
return adHocRatings;
|
|
36203
|
+
}
|
|
36204
|
+
function getStructure(params) {
|
|
36205
|
+
var _a, _b, _c;
|
|
36206
|
+
if (params.structureId)
|
|
36207
|
+
return params.structureId;
|
|
36208
|
+
var drawDefinition = params.drawDefinition;
|
|
36209
|
+
// if no structureId is specified find the latest AD_HOC stage which has matchUps
|
|
36210
|
+
var targetStructure = (_b = (_a = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _a === void 0 ? void 0 : _a.filter(function (structure) { return structure.stageSequence === 1; })) === null || _b === void 0 ? void 0 : _b.reduce(function (targetStructure, structure) {
|
|
36211
|
+
var orderNumber = structure.stage && stageOrder$1[structure.stage];
|
|
36212
|
+
var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
|
|
36213
|
+
return structureIsAdHoc && orderNumber > (stageOrder$1[targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.stage] || 1) ? structure : targetStructure;
|
|
36214
|
+
}, undefined);
|
|
36215
|
+
var structure = (_c = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _c === void 0 ? void 0 : _c.find(function (structure) { return structure.structureId === (targetStructure === null || targetStructure === void 0 ? void 0 : targetStructure.structureId); });
|
|
36216
|
+
if (!structure)
|
|
36217
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
36218
|
+
// an AD_HOC structure is one that has no child structures and in which no matchUps have roundPosition
|
|
36219
|
+
var structureIsAdHoc = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
|
|
36220
|
+
if (!structureIsAdHoc)
|
|
36221
|
+
return { error: INVALID_DRAW_DEFINITION };
|
|
36222
|
+
return { structure: structure };
|
|
36223
|
+
}
|
|
36224
|
+
function getParticipantIds(params) {
|
|
36225
|
+
var _a, _b, _c;
|
|
36226
|
+
var participantIds = params.participantIds;
|
|
36227
|
+
var enteredParticipantIds = (_c = (_b = (_a = params.drawDefinition) === null || _a === void 0 ? void 0 : _a.entries) === null || _b === void 0 ? void 0 : _b.filter(function (entry) {
|
|
36228
|
+
var entryStatus = entry.entryStatus;
|
|
36229
|
+
return !params.restrictEntryStatus || STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
36230
|
+
}).map(getParticipantId)) !== null && _c !== void 0 ? _c : [];
|
|
36231
|
+
if (participantIds) {
|
|
36232
|
+
// ensure all participantIds are in drawDefinition.entries
|
|
36233
|
+
var invalidParticipantIds = participantIds.filter(function (participantId) { return !(enteredParticipantIds === null || enteredParticipantIds === void 0 ? void 0 : enteredParticipantIds.includes(participantId)); });
|
|
36234
|
+
if (invalidParticipantIds === null || invalidParticipantIds === void 0 ? void 0 : invalidParticipantIds.length)
|
|
36235
|
+
return decorateResult({
|
|
36236
|
+
result: { error: INVALID_PARTICIPANT_ID },
|
|
36237
|
+
info: { invalidParticipantIds: invalidParticipantIds },
|
|
36238
|
+
});
|
|
36239
|
+
}
|
|
36240
|
+
else {
|
|
36241
|
+
participantIds = enteredParticipantIds;
|
|
36242
|
+
}
|
|
36243
|
+
if (params.roundsCount &&
|
|
36244
|
+
params.roundsCount > participantIds.length - 1 &&
|
|
36245
|
+
(!params.enableDoubleRobin || params.roundsCount > (participantIds.length - 1) * 2)) {
|
|
36246
|
+
return { error: INVALID_VALUES, info: 'Not enough participants for roundsCount' };
|
|
36247
|
+
}
|
|
36248
|
+
return { participantIds: participantIds };
|
|
36249
|
+
}
|
|
36250
|
+
function checkParams(params) {
|
|
36251
|
+
var _a;
|
|
36252
|
+
if (params.roundsCount && typeof params.roundsCount !== 'number') {
|
|
36253
|
+
return { error: INVALID_VALUES, info: 'roundsCount must be a number' };
|
|
36254
|
+
}
|
|
36255
|
+
if (typeof params.drawDefinition !== 'object' ||
|
|
36256
|
+
(params.drawDefinition.drawType && params.drawDefinition.drawType !== AD_HOC)) {
|
|
36257
|
+
return { error: INVALID_DRAW_DEFINITION };
|
|
36258
|
+
}
|
|
36259
|
+
if (!Array.isArray((_a = params.drawDefinition) === null || _a === void 0 ? void 0 : _a.entries) &&
|
|
36260
|
+
params.participantIds &&
|
|
36261
|
+
!Array.isArray(params.participantIds)) {
|
|
36262
|
+
return { error: INVALID_VALUES, info: 'Missing Entries' };
|
|
36263
|
+
}
|
|
36264
|
+
return { error: undefined };
|
|
36265
|
+
}
|
|
36266
|
+
|
|
36267
|
+
function generateAdHoc(params) {
|
|
36268
|
+
var _a, _b;
|
|
36269
|
+
var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, structureId = params.structureId, idPrefix = params.idPrefix, isMock = params.isMock, event = params.event;
|
|
36270
|
+
var entries = (_a = event === null || event === void 0 ? void 0 : event.entries) === null || _a === void 0 ? void 0 : _a.filter(function (_a) {
|
|
36271
|
+
var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
|
|
36272
|
+
return (!entryStage || entryStage === MAIN) && entryStatus && STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
36273
|
+
});
|
|
36274
|
+
var participantIds = entries === null || entries === void 0 ? void 0 : entries.map(getParticipantId);
|
|
36275
|
+
var matchUpsCount = entries ? Math.floor(entries.length / 2) : 0;
|
|
36276
|
+
if (params.automated) {
|
|
36277
|
+
return automateAdHoc(__assign(__assign({}, params), { participantIds: participantIds }));
|
|
36278
|
+
}
|
|
36279
|
+
else {
|
|
36280
|
+
var genResult = generateAdHocRounds({
|
|
36281
|
+
roundsCount: params.roundsCount,
|
|
36282
|
+
drawDefinition: drawDefinition,
|
|
36283
|
+
matchUpsCount: matchUpsCount,
|
|
36284
|
+
idPrefix: idPrefix,
|
|
36285
|
+
isMock: isMock,
|
|
36286
|
+
event: event,
|
|
36287
|
+
});
|
|
36288
|
+
if (genResult.error)
|
|
36289
|
+
return genResult;
|
|
36290
|
+
if ((_b = genResult.matchUps) === null || _b === void 0 ? void 0 : _b.length) {
|
|
36291
|
+
addAdHocMatchUps({
|
|
36292
|
+
matchUps: genResult.matchUps,
|
|
36293
|
+
suppressNotifications: true,
|
|
36294
|
+
tournamentRecord: tournamentRecord,
|
|
36163
36295
|
drawDefinition: drawDefinition,
|
|
36164
|
-
|
|
36165
|
-
adHocRatings: adHocRatings,
|
|
36166
|
-
roundNumber: roundNumber,
|
|
36167
|
-
matchUpIds: matchUpIds,
|
|
36168
|
-
structure: structure,
|
|
36169
|
-
eventType: eventType,
|
|
36170
|
-
idPrefix: idPrefix,
|
|
36171
|
-
salted: salted,
|
|
36172
|
-
isMock: isMock,
|
|
36296
|
+
structureId: structureId,
|
|
36173
36297
|
event: event,
|
|
36174
36298
|
});
|
|
36175
|
-
if (result.error)
|
|
36176
|
-
return result;
|
|
36177
|
-
var roundMatchUps = result.matchUps, roundResult = __rest(result, ["matchUps"]);
|
|
36178
|
-
roundResults.push(__assign(__assign({}, roundResult), { iteration: iteration, matchUpsCount: roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps.length }));
|
|
36179
|
-
roundNumber = ((_l = roundResult === null || roundResult === void 0 ? void 0 : roundResult.roundNumber) !== null && _l !== void 0 ? _l : 1) + 1;
|
|
36180
|
-
if (roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps.length) {
|
|
36181
|
-
matchUps.push.apply(matchUps, __spreadArray([], __read(roundMatchUps), false));
|
|
36182
|
-
}
|
|
36183
|
-
}
|
|
36184
|
-
}
|
|
36185
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
36186
|
-
finally {
|
|
36187
|
-
try {
|
|
36188
|
-
if (_r && !_r.done && (_b = _q.return)) _b.call(_q);
|
|
36189
36299
|
}
|
|
36190
|
-
finally { if (e_2) throw e_2.error; }
|
|
36191
36300
|
}
|
|
36192
|
-
return __assign(
|
|
36301
|
+
return __assign({}, SUCCESS);
|
|
36193
36302
|
}
|
|
36194
|
-
function
|
|
36195
|
-
var _b;
|
|
36196
|
-
var
|
|
36197
|
-
var
|
|
36198
|
-
|
|
36199
|
-
|
|
36200
|
-
|
|
36201
|
-
|
|
36202
|
-
|
|
36203
|
-
|
|
36204
|
-
|
|
36205
|
-
|
|
36303
|
+
function automateAdHoc(params) {
|
|
36304
|
+
var _a, _b, _c, _d;
|
|
36305
|
+
var _e = (_a = params.drawMatic) !== null && _a !== void 0 ? _a : {}, restrictEntryStatus = _e.restrictEntryStatus, generateMatchUps = _e.generateMatchUps, structureId = _e.structureId, matchUpIds = _e.matchUpIds, scaleName = _e.scaleName;
|
|
36306
|
+
var result = drawMatic(__assign(__assign({}, params), { eventType: (_c = (_b = params.drawMatic) === null || _b === void 0 ? void 0 : _b.eventType) !== null && _c !== void 0 ? _c : params.matchUpType, generateMatchUps: generateMatchUps !== null && generateMatchUps !== void 0 ? generateMatchUps : true, participantIds: params.participantIds, roundsCount: params.roundsCount, restrictEntryStatus: restrictEntryStatus, structureId: structureId, matchUpIds: matchUpIds, scaleName: scaleName }));
|
|
36307
|
+
if (result.error)
|
|
36308
|
+
return result;
|
|
36309
|
+
((_d = result === null || result === void 0 ? void 0 : result.matchUps) === null || _d === void 0 ? void 0 : _d.length) &&
|
|
36310
|
+
addAdHocMatchUps({
|
|
36311
|
+
tournamentRecord: params.tournamentRecord,
|
|
36312
|
+
drawDefinition: params.drawDefinition,
|
|
36313
|
+
suppressNotifications: true,
|
|
36314
|
+
matchUps: result.matchUps,
|
|
36315
|
+
event: params.event,
|
|
36316
|
+
structureId: structureId,
|
|
36206
36317
|
});
|
|
36207
|
-
|
|
36208
|
-
return scaleAccessor && isObject(scaleValue) ? scaleValue[scaleAccessor] : scaleValue;
|
|
36318
|
+
return __assign({}, SUCCESS);
|
|
36209
36319
|
}
|
|
36210
36320
|
|
|
36211
36321
|
function initializeStructureSeedAssignments(_a) {
|
|
@@ -36254,41 +36364,15 @@ function initializeStructureSeedAssignments(_a) {
|
|
|
36254
36364
|
}
|
|
36255
36365
|
|
|
36256
36366
|
function prepareStage(params) {
|
|
36257
|
-
var _a;
|
|
36258
36367
|
var stack = 'prepareStage';
|
|
36259
|
-
var
|
|
36260
|
-
var preparedStructureIds = params.preparedStructureIds || [];
|
|
36261
|
-
var provisionalPositioning = params.provisionalPositioning, inContextDrawMatchUps = params.inContextDrawMatchUps, tournamentRecord = params.tournamentRecord, appliedPolicies = params.appliedPolicies, qualifyingOnly = params.qualifyingOnly, drawDefinition = params.drawDefinition, seedingProfile = params.seedingProfile, matchUpsMap = params.matchUpsMap, automated = params.automated, placeByes = params.placeByes, drawType = params.drawType, drawSize = params.drawSize, entries = params.entries, event = params.event, _b = params.enforcePolicyLimits, enforcePolicyLimits = _b === void 0 ? true : _b, seedAssignmentProfile = params.seedAssignmentProfile, // mainly used by mocksEngine for scenario testing
|
|
36262
|
-
_c = params.seedByRanking, // mainly used by mocksEngine for scenario testing
|
|
36263
|
-
seedByRanking = _c === void 0 ? true : _c, seededParticipants = params.seededParticipants, assignSeedsCount = params.assignSeedsCount, // used for testing bye placement next to seeds
|
|
36264
|
-
seedingScaleName = params.seedingScaleName, _d = params.stageSequence, stageSequence = _d === void 0 ? 1 : _d, roundTarget = params.roundTarget, stage = params.stage;
|
|
36265
|
-
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
36266
|
-
var stageEntries = entries.filter(function (entry) {
|
|
36267
|
-
var _a, _b;
|
|
36268
|
-
var entryRoundTarget = (_b = (_a = findExtension({
|
|
36269
|
-
name: ROUND_TARGET,
|
|
36270
|
-
element: entry,
|
|
36271
|
-
})) === null || _a === void 0 ? void 0 : _a.extension) === null || _b === void 0 ? void 0 : _b.value;
|
|
36272
|
-
return ((!entry.entryStage || entry.entryStage === stage) &&
|
|
36273
|
-
(!stageSequence ||
|
|
36274
|
-
!entry.entryStageSequence ||
|
|
36275
|
-
entry.entryStageSequence === stageSequence) &&
|
|
36276
|
-
(!roundTarget || !entryRoundTarget || entryRoundTarget === roundTarget) &&
|
|
36277
|
-
DIRECT_ENTRY_STATUSES.includes(entry.entryStatus));
|
|
36278
|
-
});
|
|
36279
|
-
if (seededParticipants)
|
|
36280
|
-
seedsCount = seededParticipants.length;
|
|
36281
|
-
if (seedsCount > drawSize)
|
|
36282
|
-
seedsCount = drawSize;
|
|
36283
|
-
if (seedsCount > stageEntries.length)
|
|
36284
|
-
seedsCount = stageEntries.length;
|
|
36368
|
+
var drawDefinition = params.drawDefinition;
|
|
36285
36369
|
var structures = getDrawStructures({
|
|
36370
|
+
stageSequence: params.stageSequence || 1,
|
|
36371
|
+
roundTarget: params.roundTarget,
|
|
36372
|
+
stage: params.stage,
|
|
36286
36373
|
drawDefinition: drawDefinition,
|
|
36287
|
-
stageSequence: stageSequence,
|
|
36288
|
-
roundTarget: roundTarget,
|
|
36289
|
-
stage: stage,
|
|
36290
36374
|
}).structures;
|
|
36291
|
-
var
|
|
36375
|
+
var preparedStructureIds = params.preparedStructureIds || [];
|
|
36292
36376
|
var structure = structures === null || structures === void 0 ? void 0 : structures.find(function (_a) {
|
|
36293
36377
|
var structureId = _a.structureId;
|
|
36294
36378
|
return !preparedStructureIds.includes(structureId);
|
|
@@ -36296,6 +36380,54 @@ function prepareStage(params) {
|
|
|
36296
36380
|
if (!structure)
|
|
36297
36381
|
return decorateResult({ result: { error: STRUCTURE_NOT_FOUND }, stack: stack });
|
|
36298
36382
|
var structureId = structure === null || structure === void 0 ? void 0 : structure.structureId;
|
|
36383
|
+
var _a = getSeedsCountAndStageEntries(__assign(__assign({}, params), { structureId: structureId })), seedsCount = _a.seedsCount, stageEntries = _a.stageEntries, seedLimit = _a.seedLimit;
|
|
36384
|
+
if (params.seededParticipants || params.event || params.seedingScaleName) {
|
|
36385
|
+
seeding(__assign(__assign({}, params), { seedsCount: seedsCount, structure: structure, structureId: structureId }));
|
|
36386
|
+
}
|
|
36387
|
+
var doPositioning = params.automated !== false && params.drawType !== AD_HOC && !(params.qualifyingOnly && params.stage !== QUALIFYING);
|
|
36388
|
+
var multipleStructures = ((structures === null || structures === void 0 ? void 0 : structures.length) || 0) > 1;
|
|
36389
|
+
var positioningResult = doPositioning ? positioning(__assign(__assign({}, params), { multipleStructures: multipleStructures, seedLimit: seedLimit, structureId: structureId })) : {};
|
|
36390
|
+
if (positioningResult === null || positioningResult === void 0 ? void 0 : positioningResult.error)
|
|
36391
|
+
return decorateResult({ result: positioningResult, stack: stack });
|
|
36392
|
+
return __assign(__assign({}, positioningResult), { stageEntries: stageEntries, structureId: structureId, seedsCount: seedsCount });
|
|
36393
|
+
}
|
|
36394
|
+
function getStageEntries(_a) {
|
|
36395
|
+
var entries = _a.entries, stage = _a.stage, stageSequence = _a.stageSequence, roundTarget = _a.roundTarget;
|
|
36396
|
+
return entries.filter(function (entry) {
|
|
36397
|
+
var _a, _b;
|
|
36398
|
+
var entryRoundTarget = (_b = (_a = findExtension({
|
|
36399
|
+
name: ROUND_TARGET,
|
|
36400
|
+
element: entry,
|
|
36401
|
+
})) === null || _a === void 0 ? void 0 : _a.extension) === null || _b === void 0 ? void 0 : _b.value;
|
|
36402
|
+
return ((!entry.entryStage || entry.entryStage === stage) &&
|
|
36403
|
+
(!stageSequence || !entry.entryStageSequence || entry.entryStageSequence === stageSequence) &&
|
|
36404
|
+
(!roundTarget || !entryRoundTarget || entryRoundTarget === roundTarget) &&
|
|
36405
|
+
DIRECT_ENTRY_STATUSES.includes(entry.entryStatus));
|
|
36406
|
+
});
|
|
36407
|
+
}
|
|
36408
|
+
function positioning(params) {
|
|
36409
|
+
var seedsOnly = typeof params.automated === 'object' && params.automated.seedsOnly;
|
|
36410
|
+
// if { seedsOnly: true } then only seeds and an Byes releated to seeded positions are placed
|
|
36411
|
+
var result = automatedPositioning(__assign(__assign({}, params), { seedsOnly: seedsOnly }));
|
|
36412
|
+
if (result.error)
|
|
36413
|
+
return result;
|
|
36414
|
+
var positionAssignments = result === null || result === void 0 ? void 0 : result.positionAssignments;
|
|
36415
|
+
var positioningReport = result === null || result === void 0 ? void 0 : result.positioningReport;
|
|
36416
|
+
return { conflicts: result.conflicts, positionAssignments: positionAssignments, positioningReport: positioningReport };
|
|
36417
|
+
}
|
|
36418
|
+
function seeding(params) {
|
|
36419
|
+
var seededParticipants = params.seededParticipants, seedingScaleName = params.seedingScaleName, entries = params.entries, event = params.event;
|
|
36420
|
+
var enteredParticipantIds = entries.map(getParticipantId);
|
|
36421
|
+
if (seededParticipants) {
|
|
36422
|
+
processSeededParticipants(__assign(__assign({}, params), { enteredParticipantIds: enteredParticipantIds }));
|
|
36423
|
+
}
|
|
36424
|
+
else if (event || seedingScaleName) {
|
|
36425
|
+
// if no seededParticipants have been defined, seed by seeding scale or ranking scale, if present
|
|
36426
|
+
scaledEntriesSeeding(__assign(__assign({}, params), { enteredParticipantIds: enteredParticipantIds }));
|
|
36427
|
+
}
|
|
36428
|
+
}
|
|
36429
|
+
function processSeededParticipants(params) {
|
|
36430
|
+
var provisionalPositioning = params.provisionalPositioning, enteredParticipantIds = params.enteredParticipantIds, seededParticipants = params.seededParticipants, tournamentRecord = params.tournamentRecord, appliedPolicies = params.appliedPolicies, drawDefinition = params.drawDefinition, seedingProfile = params.seedingProfile, structureId = params.structureId, structure = params.structure, event = params.event;
|
|
36299
36431
|
var seedBlockInfo = structure
|
|
36300
36432
|
? getValidSeedBlocks({
|
|
36301
36433
|
provisionalPositioning: provisionalPositioning,
|
|
@@ -36305,145 +36437,660 @@ function prepareStage(params) {
|
|
|
36305
36437
|
structure: structure,
|
|
36306
36438
|
})
|
|
36307
36439
|
: undefined;
|
|
36440
|
+
seededParticipants
|
|
36441
|
+
.filter(function (_a) {
|
|
36442
|
+
var participantId = _a.participantId;
|
|
36443
|
+
return enteredParticipantIds.includes(participantId);
|
|
36444
|
+
})
|
|
36445
|
+
.filter(function (seededParticipant) { return !seededParticipant.seedNumber || seededParticipant.seedNumber <= seededParticipants.length; })
|
|
36446
|
+
.sort(function (a, b) {
|
|
36447
|
+
if (a.seedNumber < b.seedNumber)
|
|
36448
|
+
return -1;
|
|
36449
|
+
if (a.seedNumber < b.seedNumber)
|
|
36450
|
+
return 1;
|
|
36451
|
+
return 0;
|
|
36452
|
+
})
|
|
36453
|
+
.forEach(function (seededParticipant) {
|
|
36454
|
+
var participantId = seededParticipant.participantId, seedNumber = seededParticipant.seedNumber, seedValue = seededParticipant.seedValue;
|
|
36455
|
+
assignSeed({
|
|
36456
|
+
provisionalPositioning: provisionalPositioning,
|
|
36457
|
+
tournamentRecord: tournamentRecord,
|
|
36458
|
+
drawDefinition: drawDefinition,
|
|
36459
|
+
seedingProfile: seedingProfile,
|
|
36460
|
+
participantId: participantId,
|
|
36461
|
+
seedBlockInfo: seedBlockInfo,
|
|
36462
|
+
structureId: structureId,
|
|
36463
|
+
seedNumber: seedNumber,
|
|
36464
|
+
seedValue: seedValue,
|
|
36465
|
+
event: event,
|
|
36466
|
+
});
|
|
36467
|
+
});
|
|
36468
|
+
}
|
|
36469
|
+
function scaledEntriesSeeding(params) {
|
|
36470
|
+
var _a;
|
|
36471
|
+
var seedsCount = params.seedsCount;
|
|
36472
|
+
var provisionalPositioning = params.provisionalPositioning, enteredParticipantIds = params.enteredParticipantIds, seedAssignmentProfile = params.seedAssignmentProfile, // mainly used by mocksEngine for scenario testing
|
|
36473
|
+
assignSeedsCount = params.assignSeedsCount, // used for testing bye placement next to seeds
|
|
36474
|
+
tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, seedByRanking = params.seedByRanking, seedingProfile = params.seedingProfile, structureId = params.structureId, event = params.event;
|
|
36475
|
+
var _b = (event === null || event === void 0 ? void 0 : event.category) || {}, categoryName = _b.categoryName, ageCategoryCode = _b.ageCategoryCode;
|
|
36476
|
+
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
36477
|
+
var scaledEntries = getSeedingScaleEntries(__assign(__assign({}, params), { ageCategoryCode: ageCategoryCode, categoryName: categoryName, eventType: eventType })) ||
|
|
36478
|
+
(seedByRanking && getRankingScaleEntries(__assign(__assign({}, params), { ageCategoryCode: ageCategoryCode, categoryName: categoryName, eventType: eventType })));
|
|
36479
|
+
var scaledEntriesCount = (_a = scaledEntries === null || scaledEntries === void 0 ? void 0 : scaledEntries.length) !== null && _a !== void 0 ? _a : 0;
|
|
36480
|
+
if (scaledEntriesCount < seedsCount)
|
|
36481
|
+
seedsCount = scaledEntriesCount;
|
|
36482
|
+
scaledEntries === null || scaledEntries === void 0 ? void 0 : scaledEntries.filter(function (_a) {
|
|
36483
|
+
var participantId = _a.participantId;
|
|
36484
|
+
return enteredParticipantIds.includes(participantId);
|
|
36485
|
+
}).slice(0, assignSeedsCount || seedsCount).forEach(function (scaledEntry, index) {
|
|
36486
|
+
var seedNumber = index + 1;
|
|
36487
|
+
var participantId = scaledEntry.participantId, scaleValue = scaledEntry.scaleValue;
|
|
36488
|
+
var seedValue = (seedAssignmentProfile === null || seedAssignmentProfile === void 0 ? void 0 : seedAssignmentProfile[seedNumber]) || scaleValue || seedNumber;
|
|
36489
|
+
assignSeed({
|
|
36490
|
+
provisionalPositioning: provisionalPositioning,
|
|
36491
|
+
tournamentRecord: tournamentRecord,
|
|
36492
|
+
drawDefinition: drawDefinition,
|
|
36493
|
+
seedingProfile: seedingProfile,
|
|
36494
|
+
participantId: participantId,
|
|
36495
|
+
structureId: structureId,
|
|
36496
|
+
seedNumber: seedNumber,
|
|
36497
|
+
seedValue: seedValue,
|
|
36498
|
+
event: event,
|
|
36499
|
+
});
|
|
36500
|
+
});
|
|
36501
|
+
}
|
|
36502
|
+
function getSeedingScaleEntries(params) {
|
|
36503
|
+
var tournamentRecord = params.tournamentRecord, seedingScaleName = params.seedingScaleName, stageSequence = params.stageSequence, entries = params.entries, stage = params.stage, event = params.event;
|
|
36504
|
+
var _a = (event === null || event === void 0 ? void 0 : event.category) || {}, categoryName = _a.categoryName, ageCategoryCode = _a.ageCategoryCode;
|
|
36505
|
+
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
36506
|
+
var seedingScaleAttributes = {
|
|
36507
|
+
scaleName: seedingScaleName || categoryName || ageCategoryCode || event.eventId,
|
|
36508
|
+
scaleType: SEEDING$1,
|
|
36509
|
+
eventType: eventType,
|
|
36510
|
+
};
|
|
36511
|
+
return getScaledEntries({
|
|
36512
|
+
scaleAttributes: seedingScaleAttributes,
|
|
36513
|
+
tournamentRecord: tournamentRecord,
|
|
36514
|
+
stageSequence: stageSequence,
|
|
36515
|
+
entries: entries,
|
|
36516
|
+
stage: stage,
|
|
36517
|
+
}).scaledEntries;
|
|
36518
|
+
}
|
|
36519
|
+
function getRankingScaleEntries(params) {
|
|
36520
|
+
var tournamentRecord = params.tournamentRecord, stageSequence = params.stageSequence, event = params.event, entries = params.entries, stage = params.stage;
|
|
36521
|
+
var _a = (event === null || event === void 0 ? void 0 : event.category) || {}, categoryName = _a.categoryName, ageCategoryCode = _a.ageCategoryCode;
|
|
36522
|
+
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
36523
|
+
var rankingScaleAttributes = {
|
|
36524
|
+
scaleName: categoryName || ageCategoryCode,
|
|
36525
|
+
scaleType: RANKING$1,
|
|
36526
|
+
eventType: eventType,
|
|
36527
|
+
};
|
|
36528
|
+
return getScaledEntries({
|
|
36529
|
+
scaleAttributes: rankingScaleAttributes,
|
|
36530
|
+
tournamentRecord: tournamentRecord,
|
|
36531
|
+
stageSequence: stageSequence,
|
|
36532
|
+
entries: entries,
|
|
36533
|
+
stage: stage,
|
|
36534
|
+
}).scaledEntries;
|
|
36535
|
+
}
|
|
36536
|
+
function getSeedsCountAndStageEntries(params) {
|
|
36537
|
+
var _a;
|
|
36538
|
+
var seedsCount = params.seedsCount;
|
|
36539
|
+
if (params.seededParticipants)
|
|
36540
|
+
seedsCount = params.seededParticipants.length;
|
|
36541
|
+
if (seedsCount > params.drawSize)
|
|
36542
|
+
seedsCount = params.drawSize;
|
|
36543
|
+
var stageEntries = getStageEntries(params);
|
|
36544
|
+
if (seedsCount > stageEntries.length)
|
|
36545
|
+
seedsCount = stageEntries.length;
|
|
36308
36546
|
var seedLimit = initializeStructureSeedAssignments({
|
|
36547
|
+
enforcePolicyLimits: (_a = params.enforcePolicyLimits) !== null && _a !== void 0 ? _a : true,
|
|
36548
|
+
appliedPolicies: params.appliedPolicies,
|
|
36309
36549
|
participantsCount: stageEntries.length,
|
|
36310
|
-
|
|
36311
|
-
|
|
36312
|
-
|
|
36313
|
-
seedingProfile: seedingProfile,
|
|
36314
|
-
structureId: structureId,
|
|
36550
|
+
seedingProfile: params.seedingProfile,
|
|
36551
|
+
drawDefinition: params.drawDefinition,
|
|
36552
|
+
structureId: params.structureId,
|
|
36315
36553
|
seedsCount: seedsCount,
|
|
36316
36554
|
}).seedLimit;
|
|
36317
36555
|
if (seedLimit && seedLimit < seedsCount)
|
|
36318
36556
|
seedsCount = seedLimit;
|
|
36319
|
-
|
|
36320
|
-
|
|
36321
|
-
|
|
36322
|
-
|
|
36323
|
-
|
|
36324
|
-
|
|
36325
|
-
|
|
36326
|
-
|
|
36327
|
-
|
|
36328
|
-
|
|
36329
|
-
|
|
36330
|
-
|
|
36331
|
-
|
|
36332
|
-
|
|
36333
|
-
|
|
36334
|
-
|
|
36335
|
-
|
|
36336
|
-
|
|
36337
|
-
|
|
36338
|
-
|
|
36339
|
-
|
|
36340
|
-
|
|
36341
|
-
|
|
36342
|
-
|
|
36343
|
-
|
|
36344
|
-
|
|
36345
|
-
|
|
36346
|
-
|
|
36347
|
-
|
|
36348
|
-
seedValue: seedValue,
|
|
36349
|
-
event: event,
|
|
36350
|
-
});
|
|
36351
|
-
});
|
|
36557
|
+
return { seedsCount: seedsCount, stageEntries: stageEntries, seedLimit: seedLimit };
|
|
36558
|
+
}
|
|
36559
|
+
|
|
36560
|
+
function generateNewDrawDefinition(params) {
|
|
36561
|
+
var _a;
|
|
36562
|
+
var _b, _c;
|
|
36563
|
+
var drawTypeResult = generateDrawTypeAndModifyDrawDefinition(__assign(__assign({}, params), { modifyOriginal: false }));
|
|
36564
|
+
if (drawTypeResult.error)
|
|
36565
|
+
return drawTypeResult;
|
|
36566
|
+
var drawDefinition = drawTypeResult.drawDefinition;
|
|
36567
|
+
var ignoreStageSpace = params.ignoreStageSpace, appliedPolicies = params.appliedPolicies, qualifyingOnly = params.qualifyingOnly, seedingProfile = params.seedingProfile, participants = params.participants, drawEntries = params.drawEntries, placeByes = params.placeByes, drawSize = params.drawSize, drawType = params.drawType, entries = params.entries;
|
|
36568
|
+
var positioningReports = [];
|
|
36569
|
+
var conflicts = [];
|
|
36570
|
+
var addResult = addEntries({ ignoreStageSpace: ignoreStageSpace, drawDefinition: drawDefinition, drawEntries: drawEntries, drawType: drawType, entries: entries });
|
|
36571
|
+
if (addResult.error)
|
|
36572
|
+
return addResult;
|
|
36573
|
+
// temporary until seeding is supported in LUCKY_DRAW
|
|
36574
|
+
var seedsCount = drawType === LUCKY_DRAW ? 0 : ensureInt((_b = params.seedsCount) !== null && _b !== void 0 ? _b : 0);
|
|
36575
|
+
var structureResult = prepareStage(__assign(__assign({}, params), { qualifyingOnly: !drawSize || qualifyingOnly, // ooo!! If there is no drawSize then MAIN is not being generated
|
|
36576
|
+
appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, seedingProfile: seedingProfile, participants: participants, stage: MAIN, seedsCount: seedsCount, placeByes: placeByes, drawSize: drawSize, entries: entries }));
|
|
36577
|
+
if (structureResult.error && !structureResult.conflicts)
|
|
36578
|
+
return structureResult;
|
|
36579
|
+
if ((_c = structureResult.positioningReport) === null || _c === void 0 ? void 0 : _c.length)
|
|
36580
|
+
positioningReports.push((_a = {}, _a[MAIN] = structureResult.positioningReport, _a));
|
|
36581
|
+
var structureId = structureResult.structureId;
|
|
36582
|
+
if (structureResult.conflicts)
|
|
36583
|
+
conflicts = structureResult.conflicts;
|
|
36584
|
+
if (drawType === AD_HOC && params.roundsCount) {
|
|
36585
|
+
generateAdHoc(__assign(__assign({}, params), { drawDefinition: drawDefinition, structureId: structureId }));
|
|
36352
36586
|
}
|
|
36353
|
-
|
|
36354
|
-
|
|
36355
|
-
|
|
36356
|
-
|
|
36357
|
-
|
|
36358
|
-
|
|
36359
|
-
|
|
36360
|
-
|
|
36361
|
-
var
|
|
36362
|
-
|
|
36363
|
-
|
|
36364
|
-
|
|
36365
|
-
|
|
36366
|
-
|
|
36367
|
-
|
|
36368
|
-
|
|
36369
|
-
|
|
36370
|
-
|
|
36371
|
-
|
|
36372
|
-
|
|
36587
|
+
return { drawDefinition: drawDefinition, positioningReports: positioningReports, conflicts: conflicts, structureId: structureId };
|
|
36588
|
+
}
|
|
36589
|
+
function addEntries(params) {
|
|
36590
|
+
var e_1, _a;
|
|
36591
|
+
var _b;
|
|
36592
|
+
var ignoreStageSpace = params.ignoreStageSpace, drawDefinition = params.drawDefinition, drawEntries = params.drawEntries, drawType = params.drawType, entries = params.entries;
|
|
36593
|
+
try {
|
|
36594
|
+
// add all entries to the draw
|
|
36595
|
+
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
36596
|
+
var entry = entries_1_1.value;
|
|
36597
|
+
// if drawEntries and entryStage !== stage ignore
|
|
36598
|
+
if (drawEntries && entry.entryStage && entry.entryStage !== MAIN)
|
|
36599
|
+
continue;
|
|
36600
|
+
var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_b = entry.entryStage) !== null && _b !== void 0 ? _b : MAIN, drawDefinition: drawDefinition, drawType: drawType });
|
|
36601
|
+
var result = addDrawEntry(entryData);
|
|
36602
|
+
if (drawEntries && result.error) {
|
|
36603
|
+
// only report errors with drawEntries
|
|
36604
|
+
// if entries are taken from event.entries assume stageSpace is not available
|
|
36605
|
+
return result;
|
|
36606
|
+
}
|
|
36607
|
+
}
|
|
36608
|
+
}
|
|
36609
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36610
|
+
finally {
|
|
36611
|
+
try {
|
|
36612
|
+
if (entries_1_1 && !entries_1_1.done && (_a = entries_1.return)) _a.call(entries_1);
|
|
36613
|
+
}
|
|
36614
|
+
finally { if (e_1) throw e_1.error; }
|
|
36615
|
+
}
|
|
36616
|
+
return { error: undefined };
|
|
36617
|
+
}
|
|
36618
|
+
|
|
36619
|
+
// internal use only; set matchUpFormat for a matchUp or structure
|
|
36620
|
+
function setMatchUpMatchUpFormat(params) {
|
|
36621
|
+
var e_1, _a;
|
|
36622
|
+
var structureIds = params.structureIds;
|
|
36623
|
+
var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, matchUpFormat = params.matchUpFormat, structureId = params.structureId, matchUpId = params.matchUpId, event = params.event;
|
|
36624
|
+
if (!drawDefinition)
|
|
36625
|
+
return { error: MISSING_DRAW_DEFINITION };
|
|
36626
|
+
if (!matchUpFormat)
|
|
36627
|
+
return { error: MISSING_MATCHUP_FORMAT };
|
|
36628
|
+
if (!isValidMatchUpFormat({ matchUpFormat: matchUpFormat }))
|
|
36629
|
+
return { error: UNRECOGNIZED_MATCHUP_FORMAT };
|
|
36630
|
+
var stack = 'setMatchUpFormat';
|
|
36631
|
+
if (matchUpId) {
|
|
36632
|
+
var result = findDrawMatchUp({
|
|
36633
|
+
drawDefinition: drawDefinition,
|
|
36634
|
+
matchUpId: matchUpId,
|
|
36635
|
+
event: event,
|
|
36636
|
+
});
|
|
36637
|
+
if (result.error)
|
|
36638
|
+
return result;
|
|
36639
|
+
if (!result.matchUp)
|
|
36640
|
+
return { error: MATCHUP_NOT_FOUND };
|
|
36641
|
+
var matchUp = result.matchUp;
|
|
36642
|
+
if ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpType) === TEAM$2)
|
|
36643
|
+
return {
|
|
36644
|
+
error: INVALID_MATCHUP,
|
|
36645
|
+
info: 'Cannot set matchUpFormat when { matchUpType: TEAM }',
|
|
36373
36646
|
};
|
|
36374
|
-
|
|
36375
|
-
|
|
36376
|
-
|
|
36377
|
-
|
|
36378
|
-
|
|
36379
|
-
|
|
36380
|
-
|
|
36647
|
+
matchUp.matchUpFormat = matchUpFormat;
|
|
36648
|
+
modifyMatchUpNotice({
|
|
36649
|
+
tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
|
|
36650
|
+
eventId: event === null || event === void 0 ? void 0 : event.eventId,
|
|
36651
|
+
context: stack,
|
|
36652
|
+
drawDefinition: drawDefinition,
|
|
36653
|
+
matchUp: matchUp,
|
|
36654
|
+
});
|
|
36655
|
+
}
|
|
36656
|
+
else if (Array.isArray(structureIds)) {
|
|
36657
|
+
if ((event === null || event === void 0 ? void 0 : event.eventType) === TEAM$2)
|
|
36658
|
+
return { error: INVALID_EVENT_TYPE };
|
|
36659
|
+
try {
|
|
36660
|
+
for (var structureIds_1 = __values(structureIds), structureIds_1_1 = structureIds_1.next(); !structureIds_1_1.done; structureIds_1_1 = structureIds_1.next()) {
|
|
36661
|
+
var structureId_1 = structureIds_1_1.value;
|
|
36662
|
+
var result = findStructure({ drawDefinition: drawDefinition, structureId: structureId_1 });
|
|
36663
|
+
if (result.error)
|
|
36664
|
+
return result;
|
|
36665
|
+
if (!result.structure) {
|
|
36666
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
36667
|
+
}
|
|
36668
|
+
else {
|
|
36669
|
+
result.structure.matchUpFormat = matchUpFormat;
|
|
36670
|
+
}
|
|
36671
|
+
}
|
|
36381
36672
|
}
|
|
36382
|
-
|
|
36383
|
-
|
|
36384
|
-
|
|
36385
|
-
|
|
36386
|
-
|
|
36387
|
-
|
|
36388
|
-
}
|
|
36389
|
-
|
|
36390
|
-
|
|
36391
|
-
|
|
36392
|
-
|
|
36393
|
-
|
|
36394
|
-
|
|
36395
|
-
|
|
36396
|
-
|
|
36397
|
-
|
|
36398
|
-
|
|
36399
|
-
|
|
36400
|
-
|
|
36401
|
-
|
|
36402
|
-
|
|
36673
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36674
|
+
finally {
|
|
36675
|
+
try {
|
|
36676
|
+
if (structureIds_1_1 && !structureIds_1_1.done && (_a = structureIds_1.return)) _a.call(structureIds_1);
|
|
36677
|
+
}
|
|
36678
|
+
finally { if (e_1) throw e_1.error; }
|
|
36679
|
+
}
|
|
36680
|
+
}
|
|
36681
|
+
else if (structureId) {
|
|
36682
|
+
if ((event === null || event === void 0 ? void 0 : event.eventType) === TEAM$2)
|
|
36683
|
+
return { error: INVALID_EVENT_TYPE };
|
|
36684
|
+
var result = findStructure({ drawDefinition: drawDefinition, structureId: structureId });
|
|
36685
|
+
if (result.error)
|
|
36686
|
+
return result;
|
|
36687
|
+
if (!result.structure) {
|
|
36688
|
+
return { error: STRUCTURE_NOT_FOUND };
|
|
36689
|
+
}
|
|
36690
|
+
else {
|
|
36691
|
+
result.structure.matchUpFormat = matchUpFormat;
|
|
36692
|
+
}
|
|
36693
|
+
}
|
|
36694
|
+
else if (drawDefinition) {
|
|
36695
|
+
drawDefinition.matchUpFormat = matchUpFormat;
|
|
36696
|
+
}
|
|
36697
|
+
structureIds = structureIds !== null && structureIds !== void 0 ? structureIds : (structureId ? [structureId] : undefined);
|
|
36698
|
+
modifyDrawNotice({ drawDefinition: drawDefinition, structureIds: structureIds });
|
|
36699
|
+
return __assign({}, SUCCESS);
|
|
36700
|
+
}
|
|
36701
|
+
|
|
36702
|
+
// add collectionIds if missing
|
|
36703
|
+
function checkTieFormat(_a) {
|
|
36704
|
+
var e_1, _b;
|
|
36705
|
+
var tieFormat = _a.tieFormat;
|
|
36706
|
+
var result = validateTieFormat({
|
|
36707
|
+
checkCollectionIds: false,
|
|
36708
|
+
tieFormat: tieFormat,
|
|
36709
|
+
});
|
|
36710
|
+
if (result.error)
|
|
36711
|
+
return result;
|
|
36712
|
+
try {
|
|
36713
|
+
for (var _c = __values(tieFormat.collectionDefinitions), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
36714
|
+
var collectionDefinition = _d.value;
|
|
36715
|
+
if (!collectionDefinition.collectionId)
|
|
36716
|
+
collectionDefinition.collectionId = UUID();
|
|
36717
|
+
}
|
|
36718
|
+
}
|
|
36719
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36720
|
+
finally {
|
|
36721
|
+
try {
|
|
36722
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
36723
|
+
}
|
|
36724
|
+
finally { if (e_1) throw e_1.error; }
|
|
36725
|
+
}
|
|
36726
|
+
return { tieFormat: tieFormat };
|
|
36727
|
+
}
|
|
36728
|
+
|
|
36729
|
+
function checkFormatScopeEquivalence(_a) {
|
|
36730
|
+
var _b;
|
|
36731
|
+
var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpFormat = _a.matchUpFormat, matchUpType = _a.matchUpType, tieFormat = _a.tieFormat, event = _a.event;
|
|
36732
|
+
// if there is a defined matchUpFormat/tieFormat only attach to drawDefinition...
|
|
36733
|
+
// ...when there is not an equivalent definition on the parent event
|
|
36734
|
+
if (matchUpFormat || tieFormat) {
|
|
36735
|
+
var equivalentInScope = (matchUpFormat && (event === null || event === void 0 ? void 0 : event.matchUpFormat) === matchUpFormat) ||
|
|
36736
|
+
((event === null || event === void 0 ? void 0 : event.tieFormat) && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat));
|
|
36737
|
+
// if an equivalent matchUpFormat or tieFormat is attached to the event
|
|
36738
|
+
// there is no need to attach to the drawDefinition
|
|
36739
|
+
if (!equivalentInScope) {
|
|
36740
|
+
if (tieFormat) {
|
|
36741
|
+
var result = checkTieFormat({ tieFormat: tieFormat });
|
|
36742
|
+
if (result.error)
|
|
36743
|
+
return result;
|
|
36744
|
+
drawDefinition.tieFormat = (_b = result.tieFormat) !== null && _b !== void 0 ? _b : tieFormat;
|
|
36745
|
+
}
|
|
36746
|
+
else if (matchUpFormat) {
|
|
36747
|
+
var result = setMatchUpMatchUpFormat({
|
|
36748
|
+
tournamentRecord: tournamentRecord,
|
|
36749
|
+
drawDefinition: drawDefinition,
|
|
36750
|
+
matchUpFormat: matchUpFormat,
|
|
36751
|
+
event: event,
|
|
36752
|
+
});
|
|
36753
|
+
if (result.error) {
|
|
36754
|
+
return {
|
|
36755
|
+
info: 'matchUpFormat or tieFormat error',
|
|
36756
|
+
error: result.error,
|
|
36757
|
+
};
|
|
36758
|
+
}
|
|
36759
|
+
}
|
|
36760
|
+
if (matchUpType)
|
|
36761
|
+
drawDefinition.matchUpType = matchUpType;
|
|
36762
|
+
}
|
|
36763
|
+
}
|
|
36764
|
+
return { error: undefined };
|
|
36765
|
+
}
|
|
36766
|
+
|
|
36767
|
+
function removePolicy(params) {
|
|
36768
|
+
var _a, _b, e_1, _c;
|
|
36769
|
+
var _d, _e;
|
|
36770
|
+
var checkParams = checkRequiredParameters(params, [
|
|
36771
|
+
(_a = {},
|
|
36772
|
+
_a[POLICY_TYPE] = true,
|
|
36773
|
+
_a._anyOf = (_b = {},
|
|
36774
|
+
_b[TOURNAMENT_RECORDS] = false,
|
|
36775
|
+
_b[TOURNAMENT_RECORD] = false,
|
|
36776
|
+
_b[DRAW_DEFINITION] = false,
|
|
36777
|
+
_b[EVENT] = false,
|
|
36778
|
+
_b),
|
|
36779
|
+
_a),
|
|
36780
|
+
]);
|
|
36781
|
+
if (checkParams.error)
|
|
36782
|
+
return checkParams;
|
|
36783
|
+
var policyRemoved;
|
|
36784
|
+
var element = (_e = (_d = params.drawDefinition) !== null && _d !== void 0 ? _d : params.event) !== null && _e !== void 0 ? _e : ((params.tournamentId || !params.tournamentRecords) && params.tournamentRecord);
|
|
36785
|
+
if (element) {
|
|
36786
|
+
return policyDeletion(params, element);
|
|
36787
|
+
}
|
|
36788
|
+
else if (params.tournamentRecords) {
|
|
36789
|
+
var tournamentIds = Object.keys(params.tournamentRecords);
|
|
36790
|
+
if (!tournamentIds.length)
|
|
36791
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
36792
|
+
try {
|
|
36793
|
+
for (var tournamentIds_1 = __values(tournamentIds), tournamentIds_1_1 = tournamentIds_1.next(); !tournamentIds_1_1.done; tournamentIds_1_1 = tournamentIds_1.next()) {
|
|
36794
|
+
var tournamentId = tournamentIds_1_1.value;
|
|
36795
|
+
var tournamentRecord = params.tournamentRecords[tournamentId];
|
|
36796
|
+
var result = policyDeletion(params, tournamentRecord);
|
|
36797
|
+
if (result.error)
|
|
36798
|
+
return result;
|
|
36799
|
+
policyRemoved = true;
|
|
36800
|
+
}
|
|
36801
|
+
}
|
|
36802
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36803
|
+
finally {
|
|
36804
|
+
try {
|
|
36805
|
+
if (tournamentIds_1_1 && !tournamentIds_1_1.done && (_c = tournamentIds_1.return)) _c.call(tournamentIds_1);
|
|
36806
|
+
}
|
|
36807
|
+
finally { if (e_1) throw e_1.error; }
|
|
36808
|
+
}
|
|
36809
|
+
}
|
|
36810
|
+
else {
|
|
36811
|
+
return { error: MISSING_TOURNAMENT_RECORD };
|
|
36812
|
+
}
|
|
36813
|
+
return policyRemoved ? __assign({}, SUCCESS) : { error: POLICY_NOT_FOUND };
|
|
36814
|
+
}
|
|
36815
|
+
function policyDeletion(params, element) {
|
|
36816
|
+
var _a;
|
|
36817
|
+
var appliedPolicies = (_a = getAppliedPolicies(params).appliedPolicies) !== null && _a !== void 0 ? _a : {};
|
|
36818
|
+
if (appliedPolicies[params.policyType]) {
|
|
36819
|
+
delete appliedPolicies[params.policyType];
|
|
36820
|
+
if (Object.keys(appliedPolicies).length) {
|
|
36821
|
+
var extension = { name: APPLIED_POLICIES, value: appliedPolicies };
|
|
36822
|
+
addExtension({ element: element, extension: extension });
|
|
36823
|
+
}
|
|
36824
|
+
else {
|
|
36825
|
+
removeExtension({ element: element, name: APPLIED_POLICIES });
|
|
36826
|
+
}
|
|
36827
|
+
return __assign({}, SUCCESS);
|
|
36828
|
+
}
|
|
36829
|
+
return { error: POLICY_NOT_FOUND };
|
|
36830
|
+
}
|
|
36831
|
+
|
|
36832
|
+
var mutate$a = {
|
|
36833
|
+
__proto__: null,
|
|
36834
|
+
attachPolicies: attachPolicies,
|
|
36835
|
+
removePolicy: removePolicy
|
|
36836
|
+
};
|
|
36837
|
+
|
|
36838
|
+
var query$1 = {
|
|
36839
|
+
__proto__: null,
|
|
36840
|
+
findPolicy: findPolicy,
|
|
36841
|
+
getAppliedPolicies: getAppliedPolicies,
|
|
36842
|
+
getPolicyDefinitions: getPolicyDefinitions
|
|
36843
|
+
};
|
|
36844
|
+
|
|
36845
|
+
var index$e = {
|
|
36846
|
+
__proto__: null,
|
|
36847
|
+
attachPolicies: attachPolicies,
|
|
36848
|
+
findPolicy: findPolicy,
|
|
36849
|
+
getAppliedPolicies: getAppliedPolicies,
|
|
36850
|
+
getPolicyDefinitions: getPolicyDefinitions,
|
|
36851
|
+
mutate: mutate$a,
|
|
36852
|
+
query: query$1,
|
|
36853
|
+
removePolicy: removePolicy
|
|
36854
|
+
};
|
|
36855
|
+
|
|
36856
|
+
function policyAttachment(_a) {
|
|
36857
|
+
// ---------------------------------------------------------------------------
|
|
36858
|
+
// Attach policies to the drawDefinition
|
|
36859
|
+
// if there is an avoidance policy on the event, it must be preserved in the drawDefinition
|
|
36860
|
+
// if there is an avoidance policy in policyDefinitions, it will override
|
|
36861
|
+
// avoidance policies on the event can be changed (if location used for UI)
|
|
36862
|
+
var _b;
|
|
36863
|
+
var appliedPolicies = _a.appliedPolicies, policyDefinitions = _a.policyDefinitions, drawDefinition = _a.drawDefinition, stack = _a.stack;
|
|
36864
|
+
if (policyDefinitions && typeof policyDefinitions !== 'object')
|
|
36865
|
+
return decorateResult({
|
|
36866
|
+
info: 'policyDefinitions must be an object',
|
|
36867
|
+
result: { error: INVALID_VALUES },
|
|
36868
|
+
stack: stack,
|
|
36403
36869
|
});
|
|
36870
|
+
var policiesToAttach = (_b = {},
|
|
36871
|
+
_b[POLICY_TYPE_AVOIDANCE] = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_AVOIDANCE],
|
|
36872
|
+
_b);
|
|
36873
|
+
if (policyDefinitions) {
|
|
36874
|
+
existingPolicyDefinitions({ policyDefinitions: policyDefinitions, appliedPolicies: appliedPolicies, policiesToAttach: policiesToAttach, drawDefinition: drawDefinition });
|
|
36404
36875
|
}
|
|
36405
|
-
|
|
36406
|
-
|
|
36407
|
-
|
|
36408
|
-
if (
|
|
36409
|
-
|
|
36410
|
-
|
|
36411
|
-
var seedsOnly = typeof automated === 'object' && automated.seedsOnly;
|
|
36412
|
-
// if { seedsOnly: true } then only seeds and an Byes releated to seeded positions are placed
|
|
36413
|
-
var result = automatedPositioning({
|
|
36414
|
-
inContextDrawMatchUps: inContextDrawMatchUps,
|
|
36415
|
-
multipleStructures: multipleStructures,
|
|
36416
|
-
tournamentRecord: tournamentRecord,
|
|
36417
|
-
appliedPolicies: appliedPolicies,
|
|
36876
|
+
else if (policiesToAttach.avoidance) {
|
|
36877
|
+
attachPolicies({ drawDefinition: drawDefinition, policyDefinitions: policiesToAttach });
|
|
36878
|
+
}
|
|
36879
|
+
if (!(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING]) && !(policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING])) {
|
|
36880
|
+
attachPolicies({
|
|
36881
|
+
policyDefinitions: POLICY_SEEDING_DEFAULT,
|
|
36418
36882
|
drawDefinition: drawDefinition,
|
|
36419
|
-
seedingProfile: seedingProfile,
|
|
36420
|
-
structureId: structureId,
|
|
36421
|
-
matchUpsMap: matchUpsMap,
|
|
36422
|
-
placeByes: placeByes,
|
|
36423
|
-
seedLimit: seedLimit,
|
|
36424
|
-
seedsOnly: seedsOnly,
|
|
36425
|
-
drawSize: drawSize,
|
|
36426
|
-
drawType: drawType,
|
|
36427
|
-
event: event,
|
|
36428
36883
|
});
|
|
36429
|
-
if (
|
|
36430
|
-
|
|
36431
|
-
|
|
36432
|
-
|
|
36433
|
-
|
|
36434
|
-
|
|
36884
|
+
if (appliedPolicies)
|
|
36885
|
+
Object.assign(appliedPolicies, POLICY_SEEDING_DEFAULT);
|
|
36886
|
+
}
|
|
36887
|
+
return { error: undefined };
|
|
36888
|
+
}
|
|
36889
|
+
function existingPolicyDefinitions(_a) {
|
|
36890
|
+
var e_1, _b;
|
|
36891
|
+
var policyDefinitions = _a.policyDefinitions, appliedPolicies = _a.appliedPolicies, policiesToAttach = _a.policiesToAttach, drawDefinition = _a.drawDefinition;
|
|
36892
|
+
try {
|
|
36893
|
+
for (var _c = __values(Object.keys(policyDefinitions)), _d = _c.next(); !_d.done; _d = _c.next()) {
|
|
36894
|
+
var key = _d.value;
|
|
36895
|
+
if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !== JSON.stringify(policyDefinitions[key])) {
|
|
36896
|
+
policiesToAttach[key] = policyDefinitions[key];
|
|
36897
|
+
}
|
|
36435
36898
|
}
|
|
36436
36899
|
}
|
|
36900
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
36901
|
+
finally {
|
|
36902
|
+
try {
|
|
36903
|
+
if (_d && !_d.done && (_b = _c.return)) _b.call(_c);
|
|
36904
|
+
}
|
|
36905
|
+
finally { if (e_1) throw e_1.error; }
|
|
36906
|
+
}
|
|
36907
|
+
if (Object.keys(policiesToAttach).length) {
|
|
36908
|
+
// attach any policyDefinitions which have been provided and are not already present
|
|
36909
|
+
attachPolicies({
|
|
36910
|
+
policyDefinitions: policiesToAttach,
|
|
36911
|
+
drawDefinition: drawDefinition,
|
|
36912
|
+
});
|
|
36913
|
+
if (appliedPolicies)
|
|
36914
|
+
Object.assign(appliedPolicies, policiesToAttach);
|
|
36915
|
+
}
|
|
36916
|
+
}
|
|
36917
|
+
|
|
36918
|
+
var definitionTemplate = function () { return ({
|
|
36919
|
+
matchUpType: undefined,
|
|
36920
|
+
drawName: undefined,
|
|
36921
|
+
drawId: undefined,
|
|
36922
|
+
structures: [],
|
|
36923
|
+
entries: [],
|
|
36924
|
+
links: [],
|
|
36925
|
+
}); };
|
|
36926
|
+
|
|
36927
|
+
function newDrawDefinition(params) {
|
|
36928
|
+
var _a = params !== null && params !== void 0 ? params : {}, _b = _a.drawId, drawId = _b === void 0 ? UUID() : _b, processCodes = _a.processCodes, matchUpType = _a.matchUpType, drawType = _a.drawType;
|
|
36929
|
+
var drawDefinition = definitionTemplate();
|
|
36930
|
+
return Object.assign(drawDefinition, {
|
|
36931
|
+
processCodes: processCodes,
|
|
36932
|
+
matchUpType: matchUpType,
|
|
36933
|
+
drawType: drawType,
|
|
36934
|
+
drawId: drawId,
|
|
36935
|
+
});
|
|
36936
|
+
}
|
|
36937
|
+
|
|
36938
|
+
function setUpDrawGeneration(params) {
|
|
36939
|
+
var _a, _b, _c, _d, _e;
|
|
36940
|
+
var tournamentRecord = params.tournamentRecord, matchUpFormat = params.matchUpFormat, appliedPolicies = params.appliedPolicies, policyDefinitions = params.policyDefinitions, matchUpType = params.matchUpType, tieFormat = params.tieFormat, drawType = params.drawType, stack = params.stack, event = params.event;
|
|
36941
|
+
var existingDrawDefinition = params.drawId
|
|
36942
|
+
? (_a = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _a === void 0 ? void 0 : _a.find(function (d) { return d.drawId === params.drawId; })
|
|
36943
|
+
: undefined;
|
|
36944
|
+
if (existingDrawDefinition && drawType !== existingDrawDefinition.drawType)
|
|
36945
|
+
existingDrawDefinition.drawType = drawType;
|
|
36946
|
+
var drawDefinition = existingDrawDefinition !== null && existingDrawDefinition !== void 0 ? existingDrawDefinition : newDrawDefinition({
|
|
36947
|
+
processCodes: params.processCodes,
|
|
36948
|
+
drawId: params.drawId,
|
|
36949
|
+
drawType: drawType,
|
|
36950
|
+
});
|
|
36951
|
+
var equivalenceResult = checkFormatScopeEquivalence({
|
|
36952
|
+
tournamentRecord: tournamentRecord,
|
|
36953
|
+
drawDefinition: drawDefinition,
|
|
36954
|
+
matchUpFormat: matchUpFormat,
|
|
36955
|
+
matchUpType: matchUpType,
|
|
36956
|
+
tieFormat: tieFormat,
|
|
36957
|
+
event: event,
|
|
36958
|
+
});
|
|
36959
|
+
if (equivalenceResult.error)
|
|
36960
|
+
return decorateResult({ result: equivalenceResult, stack: stack });
|
|
36961
|
+
var attachmentResult = policyAttachment({ appliedPolicies: appliedPolicies, policyDefinitions: policyDefinitions, drawDefinition: drawDefinition, stack: stack });
|
|
36962
|
+
if (attachmentResult.error)
|
|
36963
|
+
return attachmentResult;
|
|
36964
|
+
// find existing MAIN structureId if existingDrawDefinition
|
|
36965
|
+
var structureId = (_c = (_b = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _b === void 0 ? void 0 : _b.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _c === void 0 ? void 0 : _c.structureId;
|
|
36966
|
+
var existingQualifyingStructures = existingDrawDefinition
|
|
36967
|
+
? (_d = existingDrawDefinition.structures) === null || _d === void 0 ? void 0 : _d.filter(function (structure) { return structure.stage === QUALIFYING; })
|
|
36968
|
+
: [];
|
|
36969
|
+
var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
|
|
36970
|
+
!((_e = existingQualifyingStructures[0].matchUps) === null || _e === void 0 ? void 0 : _e.length) &&
|
|
36971
|
+
existingQualifyingStructures[0].structureId;
|
|
36972
|
+
return { drawDefinition: drawDefinition, structureId: structureId, existingDrawDefinition: existingDrawDefinition, existingQualifyingPlaceholderStructureId: existingQualifyingPlaceholderStructureId };
|
|
36973
|
+
}
|
|
36974
|
+
|
|
36975
|
+
function generateOrGetExisting(params) {
|
|
36976
|
+
var _a, _b, _c, _d, _e, _f, _g;
|
|
36977
|
+
var stack = 'generateOrGetExisting';
|
|
36978
|
+
var positioningReports = [];
|
|
36979
|
+
var conflicts = [];
|
|
36980
|
+
var setUpResult = setUpDrawGeneration(params);
|
|
36981
|
+
if (setUpResult.error)
|
|
36982
|
+
return decorateResult({ result: setUpResult, stack: stack });
|
|
36983
|
+
var existingDrawDefinition = setUpResult.existingDrawDefinition;
|
|
36984
|
+
var drawDefinition = (_a = setUpResult.drawDefinition) !== null && _a !== void 0 ? _a : {};
|
|
36985
|
+
var structureId = setUpResult.structureId;
|
|
36986
|
+
var entries = (_c = (_b = params.drawEntries) !== null && _b !== void 0 ? _b : params.eventEntries) !== null && _c !== void 0 ? _c : [];
|
|
36987
|
+
var genResult = (setUpResult.existingQualifyingPlaceholderStructureId &&
|
|
36988
|
+
processExistingDrawDefinition(__assign(__assign({}, params), setUpResult))) ||
|
|
36989
|
+
generateNewDrawDefinition(__assign(__assign(__assign({}, params), setUpResult), { entries: entries }));
|
|
36990
|
+
if (genResult.error)
|
|
36991
|
+
return decorateResult({ result: genResult, stack: stack });
|
|
36992
|
+
if ((_d = genResult.positioningReports) === null || _d === void 0 ? void 0 : _d.length)
|
|
36993
|
+
positioningReports.push.apply(positioningReports, __spreadArray([], __read(((_e = genResult.positioningReports) !== null && _e !== void 0 ? _e : [])), false));
|
|
36994
|
+
if ((_f = genResult.conflicts) === null || _f === void 0 ? void 0 : _f.length)
|
|
36995
|
+
conflicts.push.apply(conflicts, __spreadArray([], __read(((_g = genResult.conflicts) !== null && _g !== void 0 ? _g : [])), false));
|
|
36996
|
+
drawDefinition = genResult.drawDefinition;
|
|
36997
|
+
structureId = genResult.structureId;
|
|
36437
36998
|
return {
|
|
36438
|
-
|
|
36439
|
-
|
|
36440
|
-
|
|
36999
|
+
existingDrawDefinition: existingDrawDefinition,
|
|
37000
|
+
positioningReports: positioningReports,
|
|
37001
|
+
drawDefinition: drawDefinition,
|
|
36441
37002
|
structureId: structureId,
|
|
36442
|
-
seedsCount: seedsCount,
|
|
36443
37003
|
conflicts: conflicts,
|
|
37004
|
+
entries: entries,
|
|
36444
37005
|
};
|
|
36445
37006
|
}
|
|
36446
37007
|
|
|
37008
|
+
function qualifyingGeneration(params) {
|
|
37009
|
+
var e_1, _a, e_2, _b, _c;
|
|
37010
|
+
var _d, _e, _f, _g;
|
|
37011
|
+
var qualifyingPlaceholder = params.qualifyingPlaceholder, qualifyingProfiles = params.qualifyingProfiles, existingDrawDefinition = params.existingDrawDefinition, positioningReports = params.positioningReports, appliedPolicies = params.appliedPolicies, qualifyingOnly = params.qualifyingOnly, drawDefinition = params.drawDefinition, seedingProfile = params.seedingProfile, participants = params.participants, structureId = params.structureId, entries = params.entries, stack = params.stack;
|
|
37012
|
+
// generate qualifying structures
|
|
37013
|
+
var generateQualifyingPlaceholder = qualifyingPlaceholder && !(qualifyingProfiles === null || qualifyingProfiles === void 0 ? void 0 : qualifyingProfiles.length) && !existingDrawDefinition;
|
|
37014
|
+
var qualifyingConflicts = [];
|
|
37015
|
+
if (qualifyingProfiles) {
|
|
37016
|
+
var sequenceSort = function (a, b) { return a.stageSequence - b.stageSequence; };
|
|
37017
|
+
var roundTargetSort = function (a, b) { return a.roundTarget - b.roundTarget; };
|
|
37018
|
+
// keep track of structures already prepared in case of multiple matching structures
|
|
37019
|
+
var preparedStructureIds = [];
|
|
37020
|
+
var roundTarget = 1;
|
|
37021
|
+
qualifyingProfiles.sort(roundTargetSort);
|
|
37022
|
+
try {
|
|
37023
|
+
for (var qualifyingProfiles_1 = __values(qualifyingProfiles), qualifyingProfiles_1_1 = qualifyingProfiles_1.next(); !qualifyingProfiles_1_1.done; qualifyingProfiles_1_1 = qualifyingProfiles_1.next()) {
|
|
37024
|
+
var roundTargetProfile = qualifyingProfiles_1_1.value;
|
|
37025
|
+
if (!Array.isArray(roundTargetProfile.structureProfiles))
|
|
37026
|
+
return decorateResult({
|
|
37027
|
+
info: mustBeAnArray('structureProfiles'),
|
|
37028
|
+
result: { error: MISSING_VALUE },
|
|
37029
|
+
stack: stack,
|
|
37030
|
+
});
|
|
37031
|
+
roundTarget = roundTargetProfile.roundTarget || roundTarget;
|
|
37032
|
+
var sortedStructureProfiles = ((_d = roundTargetProfile.structureProfiles) === null || _d === void 0 ? void 0 : _d.sort(sequenceSort)) || [];
|
|
37033
|
+
var sequence = 1;
|
|
37034
|
+
try {
|
|
37035
|
+
for (var sortedStructureProfiles_1 = (e_2 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
|
|
37036
|
+
var structureProfile = sortedStructureProfiles_1_1.value;
|
|
37037
|
+
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _h = structureProfile.seedsCount, seedsCount = _h === void 0 ? 0 : _h, seedByRanking = structureProfile.seedByRanking, placeByes = structureProfile.placeByes, drawSize = structureProfile.drawSize;
|
|
37038
|
+
var qualifyingStageResult = prepareStage(__assign(__assign({}, params), { seedingProfile: (_e = structureProfile.seedingProfile) !== null && _e !== void 0 ? _e : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount, placeByes: placeByes, drawSize: drawSize, entries: entries }));
|
|
37039
|
+
if (qualifyingStageResult.error) {
|
|
37040
|
+
return qualifyingStageResult;
|
|
37041
|
+
}
|
|
37042
|
+
if (qualifyingStageResult.structureId) {
|
|
37043
|
+
preparedStructureIds.push(qualifyingStageResult.structureId);
|
|
37044
|
+
}
|
|
37045
|
+
sequence += 1;
|
|
37046
|
+
if ((_f = qualifyingStageResult.conflicts) === null || _f === void 0 ? void 0 : _f.length)
|
|
37047
|
+
qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
|
|
37048
|
+
if ((_g = qualifyingStageResult.positioningReport) === null || _g === void 0 ? void 0 : _g.length)
|
|
37049
|
+
positioningReports.push((_c = {},
|
|
37050
|
+
_c[QUALIFYING] = qualifyingStageResult.positioningReport,
|
|
37051
|
+
_c));
|
|
37052
|
+
}
|
|
37053
|
+
}
|
|
37054
|
+
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
37055
|
+
finally {
|
|
37056
|
+
try {
|
|
37057
|
+
if (sortedStructureProfiles_1_1 && !sortedStructureProfiles_1_1.done && (_b = sortedStructureProfiles_1.return)) _b.call(sortedStructureProfiles_1);
|
|
37058
|
+
}
|
|
37059
|
+
finally { if (e_2) throw e_2.error; }
|
|
37060
|
+
}
|
|
37061
|
+
roundTarget += 1;
|
|
37062
|
+
}
|
|
37063
|
+
}
|
|
37064
|
+
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
37065
|
+
finally {
|
|
37066
|
+
try {
|
|
37067
|
+
if (qualifyingProfiles_1_1 && !qualifyingProfiles_1_1.done && (_a = qualifyingProfiles_1.return)) _a.call(qualifyingProfiles_1);
|
|
37068
|
+
}
|
|
37069
|
+
finally { if (e_1) throw e_1.error; }
|
|
37070
|
+
}
|
|
37071
|
+
}
|
|
37072
|
+
else if (structureId && generateQualifyingPlaceholder) {
|
|
37073
|
+
var qualifyingStructure = structureTemplate({
|
|
37074
|
+
structureName: constantToString(QUALIFYING),
|
|
37075
|
+
stage: QUALIFYING,
|
|
37076
|
+
});
|
|
37077
|
+
var link = generateQualifyingLink({
|
|
37078
|
+
sourceStructureId: qualifyingStructure.structureId,
|
|
37079
|
+
targetStructureId: structureId,
|
|
37080
|
+
sourceRoundNumber: 0,
|
|
37081
|
+
linkType: POSITION,
|
|
37082
|
+
}).link;
|
|
37083
|
+
if (!drawDefinition.structures)
|
|
37084
|
+
drawDefinition.structures = [];
|
|
37085
|
+
drawDefinition.structures.push(qualifyingStructure);
|
|
37086
|
+
if (!drawDefinition.links)
|
|
37087
|
+
drawDefinition.links = [];
|
|
37088
|
+
drawDefinition.links.push(link);
|
|
37089
|
+
}
|
|
37090
|
+
// complete qualifying generation
|
|
37091
|
+
return { qualifyingConflicts: qualifyingConflicts, error: undefined };
|
|
37092
|
+
}
|
|
37093
|
+
|
|
36447
37094
|
function generateScoreString(params) {
|
|
36448
37095
|
var _a = params.winnerFirst, winnerFirst = _a === void 0 ? true : _a, addOutcomeString = params.addOutcomeString, _b = params.reversed, reversed = _b === void 0 ? false : _b, matchUpStatus = params.matchUpStatus, matchUpFormat = params.matchUpFormat, autoComplete = params.autoComplete, winningSide = params.winningSide, sets = params.sets;
|
|
36449
37096
|
if (!sets)
|
|
@@ -41259,31 +41906,25 @@ function getDrawFormat(params) {
|
|
|
41259
41906
|
}
|
|
41260
41907
|
|
|
41261
41908
|
function generateDrawDefinition(params) {
|
|
41262
|
-
var _a,
|
|
41263
|
-
var
|
|
41909
|
+
var _a, _b, _c, _d, _e;
|
|
41910
|
+
var voluntaryConsolation = params.voluntaryConsolation, tournamentRecord = params.tournamentRecord, event = params.event;
|
|
41264
41911
|
var stack = 'generateDrawDefinition';
|
|
41265
|
-
var voluntaryConsolation = params.voluntaryConsolation, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, drawEntries = params.drawEntries, placeByes = params.placeByes, event = params.event;
|
|
41266
|
-
var isMock = (_k = params.isMock) !== null && _k !== void 0 ? _k : true;
|
|
41267
|
-
var idPrefix = params.idPrefix;
|
|
41268
41912
|
// get participants both for entry validation and for automated placement
|
|
41269
41913
|
// automated placement requires them to be "inContext" for avoidance policies to work
|
|
41270
|
-
var
|
|
41914
|
+
var _f = getParticipants({
|
|
41271
41915
|
withIndividualParticipants: true,
|
|
41272
41916
|
convertExtensions: true,
|
|
41273
41917
|
internalUse: true,
|
|
41274
41918
|
tournamentRecord: tournamentRecord,
|
|
41275
|
-
}), participants =
|
|
41276
|
-
var eventEntries = (
|
|
41919
|
+
}), participants = _f.participants, participantMap = _f.participantMap;
|
|
41920
|
+
var eventEntries = (_b = (_a = event === null || event === void 0 ? void 0 : event.entries) === null || _a === void 0 ? void 0 : _a.filter(function (entry) { return entry.entryStatus && __spreadArray(__spreadArray([], __read(STRUCTURE_SELECTED_STATUSES), false), [QUALIFIER], false).includes(entry.entryStatus); })) !== null && _b !== void 0 ? _b : [];
|
|
41277
41921
|
var validDerivedResult = validateAndDeriveDrawValues(__assign(__assign({}, params), { // order is important here
|
|
41278
41922
|
participantMap: participantMap, participants: participants, eventEntries: eventEntries }));
|
|
41279
41923
|
if (validDerivedResult.error)
|
|
41280
41924
|
return decorateResult({ result: validDerivedResult, stack: stack });
|
|
41281
41925
|
var appliedPolicies = validDerivedResult.appliedPolicies, policyDefinitions = validDerivedResult.policyDefinitions, drawSize = validDerivedResult.drawSize, drawType = validDerivedResult.drawType, enforceGender = validDerivedResult.enforceGender, seedingProfile = validDerivedResult.seedingProfile;
|
|
41282
41926
|
var eventType = event === null || event === void 0 ? void 0 : event.eventType;
|
|
41283
|
-
var matchUpType = (
|
|
41284
|
-
var existingDrawDefinition = params.drawId
|
|
41285
|
-
? (_p = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _p === void 0 ? void 0 : _p.find(function (d) { return d.drawId === params.drawId; })
|
|
41286
|
-
: undefined;
|
|
41927
|
+
var matchUpType = (_c = params.matchUpType) !== null && _c !== void 0 ? _c : eventType;
|
|
41287
41928
|
var drawFormatResult = getDrawFormat(__assign(__assign({}, params), { enforceGender: enforceGender, eventType: eventType, matchUpType: matchUpType }));
|
|
41288
41929
|
if (drawFormatResult.error)
|
|
41289
41930
|
return decorateResult({ result: drawFormatResult, stack: stack });
|
|
@@ -41291,402 +41932,25 @@ function generateDrawDefinition(params) {
|
|
|
41291
41932
|
var invalidDrawId = params.drawId && typeof params.drawId !== 'string';
|
|
41292
41933
|
if (invalidDrawId)
|
|
41293
41934
|
return decorateResult({ result: { error: INVALID_VALUES }, stack: stack });
|
|
41294
|
-
|
|
41295
|
-
|
|
41296
|
-
|
|
41297
|
-
|
|
41298
|
-
|
|
41299
|
-
|
|
41300
|
-
|
|
41301
|
-
|
|
41302
|
-
|
|
41303
|
-
|
|
41304
|
-
|
|
41305
|
-
|
|
41306
|
-
var equivalentInScope = (matchUpFormat && (event === null || event === void 0 ? void 0 : event.matchUpFormat) === matchUpFormat) ||
|
|
41307
|
-
((event === null || event === void 0 ? void 0 : event.tieFormat) && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat));
|
|
41308
|
-
// if an equivalent matchUpFormat or tieFormat is attached to the event
|
|
41309
|
-
// there is no need to attach to the drawDefinition
|
|
41310
|
-
if (!equivalentInScope) {
|
|
41311
|
-
if (tieFormat) {
|
|
41312
|
-
var result = checkTieFormat({ tieFormat: tieFormat });
|
|
41313
|
-
if (result.error)
|
|
41314
|
-
return decorateResult({ result: result, stack: stack });
|
|
41315
|
-
drawDefinition.tieFormat = (_q = result.tieFormat) !== null && _q !== void 0 ? _q : tieFormat;
|
|
41316
|
-
}
|
|
41317
|
-
else if (matchUpFormat) {
|
|
41318
|
-
var result = setMatchUpMatchUpFormat({
|
|
41319
|
-
tournamentRecord: tournamentRecord,
|
|
41320
|
-
drawDefinition: drawDefinition,
|
|
41321
|
-
matchUpFormat: matchUpFormat,
|
|
41322
|
-
event: event,
|
|
41323
|
-
});
|
|
41324
|
-
if (result.error) {
|
|
41325
|
-
return {
|
|
41326
|
-
error: result.error,
|
|
41327
|
-
info: 'matchUpFormat or tieFormat error',
|
|
41328
|
-
};
|
|
41329
|
-
}
|
|
41330
|
-
}
|
|
41331
|
-
if (matchUpType)
|
|
41332
|
-
drawDefinition.matchUpType = matchUpType;
|
|
41333
|
-
}
|
|
41334
|
-
}
|
|
41335
|
-
// ---------------------------------------------------------------------------
|
|
41336
|
-
// Attach policies to the drawDefinition
|
|
41337
|
-
// if there is an avoidance policy on the event, it must be preserved in the drawDefinition
|
|
41338
|
-
// if there is an avoidance policy in policyDefinitions, it will override
|
|
41339
|
-
// avoidance policies on the event can be changed (if location used for UI)
|
|
41340
|
-
var policiesToAttach = (_a = {},
|
|
41341
|
-
_a[POLICY_TYPE_AVOIDANCE] = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_AVOIDANCE],
|
|
41342
|
-
_a);
|
|
41343
|
-
if (policyDefinitions) {
|
|
41344
|
-
if (typeof policyDefinitions !== 'object') {
|
|
41345
|
-
return decorateResult({
|
|
41346
|
-
info: 'policyDefinitions must be an object',
|
|
41347
|
-
result: { error: INVALID_VALUES },
|
|
41348
|
-
stack: stack,
|
|
41349
|
-
});
|
|
41350
|
-
}
|
|
41351
|
-
else {
|
|
41352
|
-
try {
|
|
41353
|
-
for (var _17 = __values(Object.keys(policyDefinitions)), _18 = _17.next(); !_18.done; _18 = _17.next()) {
|
|
41354
|
-
var key = _18.value;
|
|
41355
|
-
if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !== JSON.stringify(policyDefinitions[key])) {
|
|
41356
|
-
policiesToAttach[key] = policyDefinitions[key];
|
|
41357
|
-
}
|
|
41358
|
-
}
|
|
41359
|
-
}
|
|
41360
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
41361
|
-
finally {
|
|
41362
|
-
try {
|
|
41363
|
-
if (_18 && !_18.done && (_b = _17.return)) _b.call(_17);
|
|
41364
|
-
}
|
|
41365
|
-
finally { if (e_1) throw e_1.error; }
|
|
41366
|
-
}
|
|
41367
|
-
if (Object.keys(policiesToAttach).length) {
|
|
41368
|
-
// attach any policyDefinitions which have been provided and are not already present
|
|
41369
|
-
attachPolicies({
|
|
41370
|
-
policyDefinitions: policiesToAttach,
|
|
41371
|
-
drawDefinition: drawDefinition,
|
|
41372
|
-
});
|
|
41373
|
-
if (appliedPolicies)
|
|
41374
|
-
Object.assign(appliedPolicies, policiesToAttach);
|
|
41375
|
-
}
|
|
41376
|
-
}
|
|
41377
|
-
}
|
|
41378
|
-
else if (policiesToAttach.avoidance) {
|
|
41379
|
-
attachPolicies({ drawDefinition: drawDefinition, policyDefinitions: policiesToAttach });
|
|
41380
|
-
}
|
|
41381
|
-
if (!(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING]) && !(policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING])) {
|
|
41382
|
-
attachPolicies({
|
|
41383
|
-
policyDefinitions: POLICY_SEEDING_DEFAULT,
|
|
41384
|
-
drawDefinition: drawDefinition,
|
|
41385
|
-
});
|
|
41386
|
-
if (appliedPolicies)
|
|
41387
|
-
Object.assign(appliedPolicies, POLICY_SEEDING_DEFAULT);
|
|
41388
|
-
}
|
|
41389
|
-
// ---------------------------------------------------------------------------
|
|
41390
|
-
// find existing MAIN structureId if existingDrawDefinition
|
|
41391
|
-
var structureId = (_s = (_r = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _r === void 0 ? void 0 : _r.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _s === void 0 ? void 0 : _s.structureId;
|
|
41392
|
-
var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
|
|
41393
|
-
var positioningReports = [];
|
|
41394
|
-
var drawTypeResult;
|
|
41395
|
-
var conflicts = [];
|
|
41396
|
-
var generateQualifyingPlaceholder = params.qualifyingPlaceholder && !((_t = params.qualifyingProfiles) === null || _t === void 0 ? void 0 : _t.length) && !existingDrawDefinition;
|
|
41397
|
-
var existingQualifyingStructures = existingDrawDefinition
|
|
41398
|
-
? (_u = existingDrawDefinition.structures) === null || _u === void 0 ? void 0 : _u.filter(function (structure) { return structure.stage === QUALIFYING; })
|
|
41399
|
-
: [];
|
|
41400
|
-
var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
|
|
41401
|
-
!((_v = existingQualifyingStructures[0].matchUps) === null || _v === void 0 ? void 0 : _v.length) &&
|
|
41402
|
-
existingQualifyingStructures[0].structureId;
|
|
41403
|
-
if (existingQualifyingPlaceholderStructureId) {
|
|
41404
|
-
var qualifyingProfiles = params.qualifyingProfiles;
|
|
41405
|
-
var qualifyingResult = (qualifyingProfiles === null || qualifyingProfiles === void 0 ? void 0 : qualifyingProfiles.length)
|
|
41406
|
-
? generateQualifyingStructures({
|
|
41407
|
-
uuids: params.uuids,
|
|
41408
|
-
qualifyingProfiles: qualifyingProfiles,
|
|
41409
|
-
appliedPolicies: appliedPolicies,
|
|
41410
|
-
idPrefix: idPrefix,
|
|
41411
|
-
isMock: isMock,
|
|
41412
|
-
})
|
|
41413
|
-
: undefined;
|
|
41414
|
-
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
|
|
41415
|
-
return qualifyingResult;
|
|
41416
|
-
}
|
|
41417
|
-
drawDefinition.structures = (_w = drawDefinition.structures) === null || _w === void 0 ? void 0 : _w.filter(function (_a) {
|
|
41418
|
-
var structureId = _a.structureId;
|
|
41419
|
-
return structureId !== existingQualifyingPlaceholderStructureId;
|
|
41420
|
-
});
|
|
41421
|
-
drawDefinition.links = (_x = drawDefinition.links) === null || _x === void 0 ? void 0 : _x.filter(function (_a) {
|
|
41422
|
-
var source = _a.source;
|
|
41423
|
-
return source.structureId !== existingQualifyingPlaceholderStructureId;
|
|
41424
|
-
});
|
|
41425
|
-
var _19 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _19.qualifiersCount, qualifyingDrawPositionsCount = _19.qualifyingDrawPositionsCount, qualifyingDetails = _19.qualifyingDetails;
|
|
41426
|
-
if (qualifyingDrawPositionsCount) {
|
|
41427
|
-
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
|
|
41428
|
-
(_y = drawDefinition.structures) === null || _y === void 0 ? void 0 : _y.push.apply(_y, __spreadArray([], __read(qualifyingResult.structures), false));
|
|
41429
|
-
}
|
|
41430
|
-
if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
|
|
41431
|
-
(_z = drawDefinition.links) === null || _z === void 0 ? void 0 : _z.push.apply(_z, __spreadArray([], __read(qualifyingResult.links), false));
|
|
41432
|
-
}
|
|
41433
|
-
}
|
|
41434
|
-
var mainStructure = (_0 = drawDefinition.structures) === null || _0 === void 0 ? void 0 : _0.find(function (_a) {
|
|
41435
|
-
var stage = _a.stage, stageSequence = _a.stageSequence;
|
|
41436
|
-
return stage === MAIN && stageSequence === 1;
|
|
41437
|
-
});
|
|
41438
|
-
var existingQualifiersCount = getQualifiersCount({
|
|
41439
|
-
stageSequence: 1,
|
|
41440
|
-
drawDefinition: drawDefinition,
|
|
41441
|
-
structureId: structureId,
|
|
41442
|
-
stage: MAIN,
|
|
41443
|
-
}).qualifiersCount;
|
|
41444
|
-
var derivedQualifiersCount = Math.max(qualifiersCount !== null && qualifiersCount !== void 0 ? qualifiersCount : 0, existingQualifiersCount !== null && existingQualifiersCount !== void 0 ? existingQualifiersCount : 0);
|
|
41445
|
-
var result = setStageQualifiersCount({
|
|
41446
|
-
qualifiersCount: derivedQualifiersCount,
|
|
41447
|
-
drawDefinition: drawDefinition,
|
|
41448
|
-
stage: MAIN,
|
|
41449
|
-
});
|
|
41450
|
-
if (result.error)
|
|
41451
|
-
return result;
|
|
41452
|
-
result = setStageDrawSize({
|
|
41453
|
-
drawSize: qualifyingDrawPositionsCount,
|
|
41454
|
-
stage: QUALIFYING,
|
|
41455
|
-
drawDefinition: drawDefinition,
|
|
41456
|
-
});
|
|
41457
|
-
if (result.error)
|
|
41458
|
-
return result;
|
|
41459
|
-
try {
|
|
41460
|
-
for (var _20 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
|
|
41461
|
-
var entryStage = _a.entryStage;
|
|
41462
|
-
return entryStage === QUALIFYING;
|
|
41463
|
-
})), _21 = _20.next(); !_21.done; _21 = _20.next()) {
|
|
41464
|
-
var entry = _21.value;
|
|
41465
|
-
var entryData = __assign(__assign({}, entry), { entryStage: (_1 = entry.entryStage) !== null && _1 !== void 0 ? _1 : MAIN, drawDefinition: drawDefinition });
|
|
41466
|
-
// ignore errors (EXITING_PARTICIPANT)
|
|
41467
|
-
addDrawEntry(entryData);
|
|
41468
|
-
}
|
|
41469
|
-
}
|
|
41470
|
-
catch (e_2_1) { e_2 = { error: e_2_1 }; }
|
|
41471
|
-
finally {
|
|
41472
|
-
try {
|
|
41473
|
-
if (_21 && !_21.done && (_c = _20.return)) _c.call(_20);
|
|
41474
|
-
}
|
|
41475
|
-
finally { if (e_2) throw e_2.error; }
|
|
41476
|
-
}
|
|
41477
|
-
try {
|
|
41478
|
-
for (var _22 = __values(qualifyingDetails || []), _23 = _22.next(); !_23.done; _23 = _22.next()) {
|
|
41479
|
-
var qualifyingDetail = _23.value;
|
|
41480
|
-
var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
|
|
41481
|
-
var link = mainStructure &&
|
|
41482
|
-
((_2 = generateQualifyingLink({
|
|
41483
|
-
targetStructureId: mainStructure.structureId,
|
|
41484
|
-
sourceStructureId: qualifyingStructureId,
|
|
41485
|
-
sourceRoundNumber: qualifyingRoundNumber,
|
|
41486
|
-
finishingPositions: finishingPositions,
|
|
41487
|
-
targetEntryRound: targetEntryRound,
|
|
41488
|
-
linkType: linkType,
|
|
41489
|
-
})) === null || _2 === void 0 ? void 0 : _2.link);
|
|
41490
|
-
if (link === null || link === void 0 ? void 0 : link.error)
|
|
41491
|
-
return link;
|
|
41492
|
-
if (link) {
|
|
41493
|
-
if (!drawDefinition.links)
|
|
41494
|
-
drawDefinition.links = [];
|
|
41495
|
-
drawDefinition.links.push(link);
|
|
41496
|
-
}
|
|
41497
|
-
}
|
|
41498
|
-
}
|
|
41499
|
-
catch (e_3_1) { e_3 = { error: e_3_1 }; }
|
|
41500
|
-
finally {
|
|
41501
|
-
try {
|
|
41502
|
-
if (_23 && !_23.done && (_d = _22.return)) _d.call(_22);
|
|
41503
|
-
}
|
|
41504
|
-
finally { if (e_3) throw e_3.error; }
|
|
41505
|
-
}
|
|
41506
|
-
drawTypeResult = { drawDefinition: drawDefinition };
|
|
41507
|
-
}
|
|
41508
|
-
else {
|
|
41509
|
-
drawTypeResult = generateDrawTypeAndModifyDrawDefinition(__assign(__assign({}, params), { modifyOriginal: false, tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpFormat: matchUpFormat, matchUpType: matchUpType, tieFormat: tieFormat, drawSize: drawSize, isMock: isMock }));
|
|
41510
|
-
if (drawTypeResult.error) {
|
|
41511
|
-
return decorateResult({ result: drawTypeResult, stack: stack });
|
|
41512
|
-
}
|
|
41513
|
-
drawDefinition = drawTypeResult.drawDefinition;
|
|
41514
|
-
try {
|
|
41515
|
-
// add all entries to the draw
|
|
41516
|
-
for (var entries_1 = __values(entries), entries_1_1 = entries_1.next(); !entries_1_1.done; entries_1_1 = entries_1.next()) {
|
|
41517
|
-
var entry = entries_1_1.value;
|
|
41518
|
-
// if drawEntries and entryStage !== stage ignore
|
|
41519
|
-
if (drawEntries && entry.entryStage && entry.entryStage !== MAIN)
|
|
41520
|
-
continue;
|
|
41521
|
-
var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_3 = entry.entryStage) !== null && _3 !== void 0 ? _3 : MAIN, drawDefinition: drawDefinition, drawType: drawType });
|
|
41522
|
-
var result = addDrawEntry(entryData);
|
|
41523
|
-
if (drawEntries && result.error) {
|
|
41524
|
-
// only report errors with drawEntries
|
|
41525
|
-
// if entries are taken from event.entries assume stageSpace is not available
|
|
41526
|
-
return decorateResult({ result: result, stack: stack });
|
|
41527
|
-
}
|
|
41528
|
-
}
|
|
41529
|
-
}
|
|
41530
|
-
catch (e_4_1) { e_4 = { error: e_4_1 }; }
|
|
41531
|
-
finally {
|
|
41532
|
-
try {
|
|
41533
|
-
if (entries_1_1 && !entries_1_1.done && (_e = entries_1.return)) _e.call(entries_1);
|
|
41534
|
-
}
|
|
41535
|
-
finally { if (e_4) throw e_4.error; }
|
|
41536
|
-
}
|
|
41537
|
-
// temporary until seeding is supported in LUCKY_DRAW
|
|
41538
|
-
var seedsCount = drawType === LUCKY_DRAW ? 0 : ensureInt((_4 = params.seedsCount) !== null && _4 !== void 0 ? _4 : 0);
|
|
41539
|
-
var structureResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { qualifyingOnly: !drawSize || qualifyingOnly, // ooo!! If there is no drawSize then MAIN is not being generated
|
|
41540
|
-
appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, seedingProfile: seedingProfile, participants: participants, stage: MAIN, seedsCount: seedsCount, placeByes: placeByes, drawSize: drawSize, entries: entries }));
|
|
41541
|
-
if (structureResult.error && !structureResult.conflicts) {
|
|
41542
|
-
return structureResult;
|
|
41543
|
-
}
|
|
41544
|
-
if ((_5 = structureResult.positioningReport) === null || _5 === void 0 ? void 0 : _5.length)
|
|
41545
|
-
positioningReports.push((_f = {}, _f[MAIN] = structureResult.positioningReport, _f));
|
|
41546
|
-
structureId = structureResult.structureId;
|
|
41547
|
-
if (structureResult.conflicts)
|
|
41548
|
-
conflicts = structureResult.conflicts;
|
|
41549
|
-
if (drawType === AD_HOC && params.roundsCount) {
|
|
41550
|
-
var entries_2 = (_6 = event === null || event === void 0 ? void 0 : event.entries) === null || _6 === void 0 ? void 0 : _6.filter(function (_a) {
|
|
41551
|
-
var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
|
|
41552
|
-
return (!entryStage || entryStage === MAIN) && entryStatus && STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
|
|
41553
|
-
});
|
|
41554
|
-
var participantIds = entries_2 === null || entries_2 === void 0 ? void 0 : entries_2.map(getParticipantId);
|
|
41555
|
-
var matchUpsCount_1 = entries_2 ? Math.floor(entries_2.length / 2) : 0;
|
|
41556
|
-
if (params.automated) {
|
|
41557
|
-
var _24 = (_7 = params.drawMatic) !== null && _7 !== void 0 ? _7 : {}, restrictEntryStatus = _24.restrictEntryStatus, generateMatchUps = _24.generateMatchUps, structureId_1 = _24.structureId, matchUpIds = _24.matchUpIds, scaleName = _24.scaleName;
|
|
41558
|
-
var result = drawMatic({
|
|
41559
|
-
eventType: (_9 = (_8 = params.drawMatic) === null || _8 === void 0 ? void 0 : _8.eventType) !== null && _9 !== void 0 ? _9 : matchUpType,
|
|
41560
|
-
generateMatchUps: generateMatchUps !== null && generateMatchUps !== void 0 ? generateMatchUps : true,
|
|
41561
|
-
roundsCount: params.roundsCount,
|
|
41562
|
-
restrictEntryStatus: restrictEntryStatus,
|
|
41563
|
-
tournamentRecord: tournamentRecord,
|
|
41564
|
-
participantIds: participantIds,
|
|
41565
|
-
drawDefinition: drawDefinition,
|
|
41566
|
-
structureId: structureId_1,
|
|
41567
|
-
matchUpIds: matchUpIds,
|
|
41568
|
-
scaleName: scaleName, // custom rating name to seed dynamic ratings
|
|
41569
|
-
idPrefix: idPrefix,
|
|
41570
|
-
isMock: isMock,
|
|
41571
|
-
event: event,
|
|
41572
|
-
});
|
|
41573
|
-
((_10 = result === null || result === void 0 ? void 0 : result.matchUps) === null || _10 === void 0 ? void 0 : _10.length) &&
|
|
41574
|
-
addAdHocMatchUps({
|
|
41575
|
-
suppressNotifications: true,
|
|
41576
|
-
matchUps: result.matchUps,
|
|
41577
|
-
tournamentRecord: tournamentRecord,
|
|
41578
|
-
drawDefinition: drawDefinition,
|
|
41579
|
-
structureId: structureId_1,
|
|
41580
|
-
event: event,
|
|
41581
|
-
});
|
|
41582
|
-
}
|
|
41583
|
-
else {
|
|
41584
|
-
generateRange(1, params.roundsCount + 1).forEach(function () {
|
|
41585
|
-
var matchUps = generateAdHocMatchUps({
|
|
41586
|
-
newRound: true,
|
|
41587
|
-
drawDefinition: drawDefinition,
|
|
41588
|
-
matchUpsCount: matchUpsCount_1,
|
|
41589
|
-
idPrefix: idPrefix,
|
|
41590
|
-
isMock: isMock,
|
|
41591
|
-
event: event,
|
|
41592
|
-
}).matchUps;
|
|
41593
|
-
(matchUps === null || matchUps === void 0 ? void 0 : matchUps.length) &&
|
|
41594
|
-
addAdHocMatchUps({
|
|
41595
|
-
suppressNotifications: true,
|
|
41596
|
-
tournamentRecord: tournamentRecord,
|
|
41597
|
-
drawDefinition: drawDefinition,
|
|
41598
|
-
structureId: structureId,
|
|
41599
|
-
matchUps: matchUps,
|
|
41600
|
-
event: event,
|
|
41601
|
-
});
|
|
41602
|
-
});
|
|
41603
|
-
}
|
|
41604
|
-
}
|
|
41605
|
-
}
|
|
41606
|
-
var qualifyingConflicts = [];
|
|
41607
|
-
if (params.qualifyingProfiles) {
|
|
41608
|
-
var sequenceSort = function (a, b) { return a.stageSequence - b.stageSequence; };
|
|
41609
|
-
var roundTargetSort = function (a, b) { return a.roundTarget - b.roundTarget; };
|
|
41610
|
-
// keep track of structures already prepared in case of multiple matching structures
|
|
41611
|
-
var preparedStructureIds = [];
|
|
41612
|
-
var roundTarget = 1;
|
|
41613
|
-
params.qualifyingProfiles.sort(roundTargetSort);
|
|
41614
|
-
try {
|
|
41615
|
-
for (var _25 = __values(params.qualifyingProfiles), _26 = _25.next(); !_26.done; _26 = _25.next()) {
|
|
41616
|
-
var roundTargetProfile = _26.value;
|
|
41617
|
-
if (!Array.isArray(roundTargetProfile.structureProfiles))
|
|
41618
|
-
return decorateResult({
|
|
41619
|
-
info: mustBeAnArray('structureProfiles'),
|
|
41620
|
-
result: { error: MISSING_VALUE },
|
|
41621
|
-
stack: stack,
|
|
41622
|
-
});
|
|
41623
|
-
roundTarget = roundTargetProfile.roundTarget || roundTarget;
|
|
41624
|
-
var sortedStructureProfiles = ((_11 = roundTargetProfile.structureProfiles) === null || _11 === void 0 ? void 0 : _11.sort(sequenceSort)) || [];
|
|
41625
|
-
var sequence = 1;
|
|
41626
|
-
try {
|
|
41627
|
-
for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
|
|
41628
|
-
var structureProfile = sortedStructureProfiles_1_1.value;
|
|
41629
|
-
var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _27 = structureProfile.seedsCount, seedsCount = _27 === void 0 ? 0 : _27, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
|
|
41630
|
-
var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_12 = structureProfile.seedingProfile) !== null && _12 !== void 0 ? _12 : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
|
|
41631
|
-
if (qualifyingStageResult.error) {
|
|
41632
|
-
return qualifyingStageResult;
|
|
41633
|
-
}
|
|
41634
|
-
if (qualifyingStageResult.structureId) {
|
|
41635
|
-
preparedStructureIds.push(qualifyingStageResult.structureId);
|
|
41636
|
-
}
|
|
41637
|
-
sequence += 1;
|
|
41638
|
-
if ((_13 = qualifyingStageResult.conflicts) === null || _13 === void 0 ? void 0 : _13.length)
|
|
41639
|
-
qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
|
|
41640
|
-
if ((_14 = qualifyingStageResult.positioningReport) === null || _14 === void 0 ? void 0 : _14.length)
|
|
41641
|
-
positioningReports.push((_j = {},
|
|
41642
|
-
_j[QUALIFYING] = qualifyingStageResult.positioningReport,
|
|
41643
|
-
_j));
|
|
41644
|
-
}
|
|
41645
|
-
}
|
|
41646
|
-
catch (e_6_1) { e_6 = { error: e_6_1 }; }
|
|
41647
|
-
finally {
|
|
41648
|
-
try {
|
|
41649
|
-
if (sortedStructureProfiles_1_1 && !sortedStructureProfiles_1_1.done && (_h = sortedStructureProfiles_1.return)) _h.call(sortedStructureProfiles_1);
|
|
41650
|
-
}
|
|
41651
|
-
finally { if (e_6) throw e_6.error; }
|
|
41652
|
-
}
|
|
41653
|
-
roundTarget += 1;
|
|
41654
|
-
}
|
|
41655
|
-
}
|
|
41656
|
-
catch (e_5_1) { e_5 = { error: e_5_1 }; }
|
|
41657
|
-
finally {
|
|
41658
|
-
try {
|
|
41659
|
-
if (_26 && !_26.done && (_g = _25.return)) _g.call(_25);
|
|
41660
|
-
}
|
|
41661
|
-
finally { if (e_5) throw e_5.error; }
|
|
41662
|
-
}
|
|
41663
|
-
}
|
|
41664
|
-
else if (structureId && generateQualifyingPlaceholder) {
|
|
41665
|
-
var qualifyingStructure = structureTemplate({
|
|
41666
|
-
structureName: constantToString(QUALIFYING),
|
|
41667
|
-
stage: QUALIFYING,
|
|
41668
|
-
});
|
|
41669
|
-
var link = generateQualifyingLink({
|
|
41670
|
-
sourceStructureId: qualifyingStructure.structureId,
|
|
41671
|
-
targetStructureId: structureId,
|
|
41672
|
-
sourceRoundNumber: 0,
|
|
41673
|
-
linkType: POSITION,
|
|
41674
|
-
}).link;
|
|
41675
|
-
if (!drawDefinition.structures)
|
|
41676
|
-
drawDefinition.structures = [];
|
|
41677
|
-
drawDefinition.structures.push(qualifyingStructure);
|
|
41678
|
-
if (!drawDefinition.links)
|
|
41679
|
-
drawDefinition.links = [];
|
|
41680
|
-
drawDefinition.links.push(link);
|
|
41681
|
-
}
|
|
41682
|
-
drawDefinition.drawName = (_15 = params.drawName) !== null && _15 !== void 0 ? _15 : (drawType && constantToString(drawType));
|
|
41935
|
+
var genResult = generateOrGetExisting(__assign(__assign({}, params), { isMock: (_d = params.isMock) !== null && _d !== void 0 ? _d : true, policyDefinitions: policyDefinitions, tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, matchUpFormat: matchUpFormat, seedingProfile: seedingProfile, participants: participants, eventEntries: eventEntries, matchUpType: matchUpType, tieFormat: tieFormat, drawSize: drawSize, drawType: drawType, event: event }));
|
|
41936
|
+
if (genResult.error)
|
|
41937
|
+
return decorateResult({ result: genResult, stack: stack });
|
|
41938
|
+
var existingDrawDefinition = genResult.existingDrawDefinition, positioningReports = genResult.positioningReports, drawDefinition = genResult.drawDefinition, structureId = genResult.structureId, conflicts = genResult.conflicts, entries = genResult.entries;
|
|
41939
|
+
if (!drawDefinition)
|
|
41940
|
+
return decorateResult({ result: { error: INVALID_VALUES }, stack: stack });
|
|
41941
|
+
// generate qualifying structures
|
|
41942
|
+
var qGenResult = qualifyingGeneration(__assign(__assign({}, params), { existingDrawDefinition: existingDrawDefinition, positioningReports: positioningReports, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, seedingProfile: seedingProfile, participants: participants, structureId: structureId, entries: entries, params: params, stack: stack }));
|
|
41943
|
+
if (qGenResult.error)
|
|
41944
|
+
return qGenResult;
|
|
41945
|
+
var qualifyingConflicts = qGenResult.qualifyingConflicts;
|
|
41946
|
+
drawDefinition.drawName = (_e = params.drawName) !== null && _e !== void 0 ? _e : (drawType && constantToString(drawType));
|
|
41683
41947
|
if (drawSize && typeof voluntaryConsolation === 'object' && drawSize >= 4) {
|
|
41684
41948
|
addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { drawDefinition: drawDefinition, matchUpType: matchUpType }));
|
|
41685
41949
|
}
|
|
41686
41950
|
return __assign(__assign({ existingDrawDefinition: !!existingDrawDefinition, qualifyingConflicts: qualifyingConflicts, positioningReports: positioningReports, drawDefinition: drawDefinition, structureId: structureId }, SUCCESS), { conflicts: conflicts });
|
|
41687
41951
|
}
|
|
41688
41952
|
|
|
41689
|
-
var index$
|
|
41953
|
+
var index$d = {
|
|
41690
41954
|
__proto__: null,
|
|
41691
41955
|
addAdHocMatchUps: addAdHocMatchUps,
|
|
41692
41956
|
addDrawDefinitionTimeItem: addDrawDefinitionTimeItem,
|
|
@@ -41710,6 +41974,7 @@ var index$e = {
|
|
|
41710
41974
|
drawMatic: drawMatic,
|
|
41711
41975
|
findDrawDefinition: publicFindDrawDefinition,
|
|
41712
41976
|
generateAdHocMatchUps: generateAdHocMatchUps,
|
|
41977
|
+
generateAdHocRounds: generateAdHocRounds,
|
|
41713
41978
|
generateAndPopulatePlayoffStructures: generateAndPopulatePlayoffStructures,
|
|
41714
41979
|
generateDrawDefinition: generateDrawDefinition,
|
|
41715
41980
|
generateDrawMaticRound: generateDrawMaticRound,
|
|
@@ -42399,7 +42664,7 @@ function modifyEventEntries(_a) {
|
|
|
42399
42664
|
return __assign({}, SUCCESS);
|
|
42400
42665
|
}
|
|
42401
42666
|
|
|
42402
|
-
var mutate$
|
|
42667
|
+
var mutate$9 = {
|
|
42403
42668
|
__proto__: null,
|
|
42404
42669
|
addDrawEntries: addDrawEntries,
|
|
42405
42670
|
addEventEntries: addEventEntries,
|
|
@@ -42416,7 +42681,7 @@ var mutate$a = {
|
|
|
42416
42681
|
setEntryPositions: setEntryPositions
|
|
42417
42682
|
};
|
|
42418
42683
|
|
|
42419
|
-
var index$
|
|
42684
|
+
var index$c = {
|
|
42420
42685
|
__proto__: null,
|
|
42421
42686
|
addDrawEntries: addDrawEntries,
|
|
42422
42687
|
addEventEntries: addEventEntries,
|
|
@@ -42427,7 +42692,7 @@ var index$d = {
|
|
|
42427
42692
|
getMaxEntryPosition: getMaxEntryPosition,
|
|
42428
42693
|
modifyEntriesStatus: modifyEntriesStatus,
|
|
42429
42694
|
modifyEventEntries: modifyEventEntries,
|
|
42430
|
-
mutate: mutate$
|
|
42695
|
+
mutate: mutate$9,
|
|
42431
42696
|
promoteAlternate: promoteAlternate,
|
|
42432
42697
|
promoteAlternates: promoteAlternates,
|
|
42433
42698
|
query: query$5,
|
|
@@ -44577,7 +44842,7 @@ function addEvent(_a) {
|
|
|
44577
44842
|
}
|
|
44578
44843
|
}
|
|
44579
44844
|
|
|
44580
|
-
var mutate$
|
|
44845
|
+
var mutate$8 = {
|
|
44581
44846
|
__proto__: null,
|
|
44582
44847
|
addDrawDefinition: addDrawDefinition,
|
|
44583
44848
|
addEvent: addEvent,
|
|
@@ -44603,7 +44868,7 @@ var mutate$9 = {
|
|
|
44603
44868
|
validateCategory: validateCategory
|
|
44604
44869
|
};
|
|
44605
44870
|
|
|
44606
|
-
var index$
|
|
44871
|
+
var index$b = {
|
|
44607
44872
|
__proto__: null,
|
|
44608
44873
|
addDrawDefinition: addDrawDefinition,
|
|
44609
44874
|
addEvent: addEvent,
|
|
@@ -44627,7 +44892,7 @@ var index$c = {
|
|
|
44627
44892
|
modifyEvent: modifyEvent,
|
|
44628
44893
|
modifyEventMatchUpFormatTiming: modifyEventMatchUpFormatTiming,
|
|
44629
44894
|
modifyPairAssignment: modifyPairAssignment,
|
|
44630
|
-
mutate: mutate$
|
|
44895
|
+
mutate: mutate$8,
|
|
44631
44896
|
query: query$2,
|
|
44632
44897
|
refreshEventDrawOrder: refreshEventDrawOrder,
|
|
44633
44898
|
removeEventMatchUpFormatTiming: removeEventMatchUpFormatTiming,
|
|
@@ -45376,11 +45641,12 @@ var garman$1 = {
|
|
|
45376
45641
|
garman: garman
|
|
45377
45642
|
};
|
|
45378
45643
|
|
|
45379
|
-
var index$
|
|
45644
|
+
var index$a = {
|
|
45380
45645
|
__proto__: null,
|
|
45381
45646
|
drawMatic: drawMatic,
|
|
45382
45647
|
garman: garman$1,
|
|
45383
45648
|
generateAdHocMatchUps: generateAdHocMatchUps,
|
|
45649
|
+
generateAdHocRounds: generateAdHocRounds,
|
|
45384
45650
|
generateAndPopulatePlayoffStructures: generateAndPopulatePlayoffStructures,
|
|
45385
45651
|
generateCourts: generateCourts,
|
|
45386
45652
|
generateDrawDefinition: generateDrawDefinition,
|
|
@@ -45395,7 +45661,7 @@ var index$b = {
|
|
|
45395
45661
|
roundRobinGroups: roundRobinGroups
|
|
45396
45662
|
};
|
|
45397
45663
|
|
|
45398
|
-
var index$
|
|
45664
|
+
var index$9 = {
|
|
45399
45665
|
__proto__: null,
|
|
45400
45666
|
isValid: isValidMatchUpFormat,
|
|
45401
45667
|
isValidMatchUpFormat: isValidMatchUpFormat,
|
|
@@ -50534,7 +50800,7 @@ function resetScorecard(params) {
|
|
|
50534
50800
|
return __assign({}, SUCCESS);
|
|
50535
50801
|
}
|
|
50536
50802
|
|
|
50537
|
-
var mutate$
|
|
50803
|
+
var mutate$7 = {
|
|
50538
50804
|
__proto__: null,
|
|
50539
50805
|
applyLineUps: applyLineUps,
|
|
50540
50806
|
assignMatchUpSideParticipant: assignMatchUpSideParticipant,
|
|
@@ -50561,7 +50827,7 @@ var mutate$8 = {
|
|
|
50561
50827
|
updateTieMatchUpScore: updateTieMatchUpScore
|
|
50562
50828
|
};
|
|
50563
50829
|
|
|
50564
|
-
var index$
|
|
50830
|
+
var index$8 = {
|
|
50565
50831
|
__proto__: null,
|
|
50566
50832
|
allCompetitionMatchUps: allCompetitionMatchUps,
|
|
50567
50833
|
allDrawMatchUps: allDrawMatchUps,
|
|
@@ -50603,7 +50869,7 @@ var index$9 = {
|
|
|
50603
50869
|
getRounds: getRounds,
|
|
50604
50870
|
isValidMatchUpFormat: isValidMatchUpFormat,
|
|
50605
50871
|
matchUpActions: matchUpActions,
|
|
50606
|
-
mutate: mutate$
|
|
50872
|
+
mutate: mutate$7,
|
|
50607
50873
|
participantScheduledMatchUps: participantScheduledMatchUps,
|
|
50608
50874
|
query: query$4,
|
|
50609
50875
|
removeDelegatedOutcome: removeDelegatedOutcome,
|
|
@@ -53240,6 +53506,7 @@ var lastNames = [
|
|
|
53240
53506
|
"Le Guin",
|
|
53241
53507
|
"Lem",
|
|
53242
53508
|
"Lovelace",
|
|
53509
|
+
"Mander",
|
|
53243
53510
|
"Midgely",
|
|
53244
53511
|
"Mond",
|
|
53245
53512
|
"Montoya",
|
|
@@ -53386,6 +53653,7 @@ var firstMale = [
|
|
|
53386
53653
|
"Ivan",
|
|
53387
53654
|
"James",
|
|
53388
53655
|
"Jared",
|
|
53656
|
+
"Jerry",
|
|
53389
53657
|
"Joe",
|
|
53390
53658
|
"Johann",
|
|
53391
53659
|
"Julian",
|
|
@@ -56511,6 +56779,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
56511
56779
|
tournamentRecord.tournamentId = newTournamentId;
|
|
56512
56780
|
tournamentRecord.createdAt = new Date().toISOString();
|
|
56513
56781
|
tournamentRecord.tournamentName = tournamentName || "Anonymized: ".concat(formatDate(new Date()));
|
|
56782
|
+
tournamentRecord.isMock = true;
|
|
56514
56783
|
delete tournamentRecord.parentOrganisation;
|
|
56515
56784
|
try {
|
|
56516
56785
|
for (var _x = __values(tournamentRecord.participants || []), _y = _x.next(); !_y.done; _y = _x.next()) {
|
|
@@ -56552,6 +56821,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
56552
56821
|
venue.venueAbbreviation = "V".concat(venueIndex);
|
|
56553
56822
|
var newVenueId = UUID();
|
|
56554
56823
|
idMap[venue.venueId] = newVenueId;
|
|
56824
|
+
venue.isMock = true;
|
|
56555
56825
|
venueIndex += 1;
|
|
56556
56826
|
// venue.eventId = UUID(); eventIds can't be anonymized without updating schedulingProfiles
|
|
56557
56827
|
}
|
|
@@ -56568,6 +56838,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
56568
56838
|
for (var _3 = __values(tournamentRecord.events || []), _4 = _3.next(); !_4.done; _4 = _3.next()) {
|
|
56569
56839
|
var event_1 = _4.value;
|
|
56570
56840
|
event_1.extensions = filterExtensions(event_1);
|
|
56841
|
+
event_1.isMock = true;
|
|
56571
56842
|
var newEventId = UUID();
|
|
56572
56843
|
idMap[event_1.eventId] = newEventId;
|
|
56573
56844
|
event_1.eventId = newEventId;
|
|
@@ -56596,6 +56867,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
56596
56867
|
var newDrawId = UUID();
|
|
56597
56868
|
idMap[drawDefinition.drawId] = newDrawId;
|
|
56598
56869
|
drawDefinition.drawId = newDrawId;
|
|
56870
|
+
drawDefinition.isMock = true;
|
|
56599
56871
|
// update all drawDefinition entries
|
|
56600
56872
|
if (Array.isArray(drawDefinition.entries)) {
|
|
56601
56873
|
try {
|
|
@@ -56652,6 +56924,7 @@ function anonymizeTournamentRecord(_a) {
|
|
|
56652
56924
|
// update lineUps in each matchUp
|
|
56653
56925
|
for (var _j = (e_13 = void 0, __values(structure.matchUps || [])), _k = _j.next(); !_k.done; _k = _j.next()) {
|
|
56654
56926
|
var matchUp = _k.value;
|
|
56927
|
+
matchUp.isMock = true;
|
|
56655
56928
|
try {
|
|
56656
56929
|
for (var _l = (e_14 = void 0, __values(matchUp.sides || [])), _m = _l.next(); !_m.done; _m = _l.next()) {
|
|
56657
56930
|
var side = _m.value;
|
|
@@ -57153,7 +57426,7 @@ function modifyTournamentRecord(params) {
|
|
|
57153
57426
|
return __assign(__assign({ totalParticipantsCount: totalParticipantsCount, scheduledRounds: scheduledRounds, schedulerResult: schedulerResult }, SUCCESS), { eventIds: eventIds, venueIds: venueIds, drawIds: drawIds });
|
|
57154
57427
|
}
|
|
57155
57428
|
|
|
57156
|
-
var mutate$
|
|
57429
|
+
var mutate$6 = {
|
|
57157
57430
|
__proto__: null,
|
|
57158
57431
|
anonymizeTournamentRecord: anonymizeTournamentRecord,
|
|
57159
57432
|
modifyTournamentRecord: modifyTournamentRecord
|
|
@@ -57169,7 +57442,7 @@ var mocksGovernor = {
|
|
|
57169
57442
|
generateParticipants: generateParticipants,
|
|
57170
57443
|
generateTournamentRecord: generateTournamentRecord,
|
|
57171
57444
|
modifyTournamentRecord: modifyTournamentRecord,
|
|
57172
|
-
mutate: mutate$
|
|
57445
|
+
mutate: mutate$6
|
|
57173
57446
|
};
|
|
57174
57447
|
|
|
57175
57448
|
// check whether there is a request for the date with overlapping times
|
|
@@ -58459,7 +58732,7 @@ function addPersons(_a) {
|
|
|
58459
58732
|
return __assign(__assign({}, SUCCESS), { addedCount: addedCount, newPersonIds: newPersonIds });
|
|
58460
58733
|
}
|
|
58461
58734
|
|
|
58462
|
-
var mutate$
|
|
58735
|
+
var mutate$5 = {
|
|
58463
58736
|
__proto__: null,
|
|
58464
58737
|
addIndividualParticipantIds: addIndividualParticipantIds,
|
|
58465
58738
|
addParticipant: addParticipant,
|
|
@@ -58489,7 +58762,7 @@ var mutate$6 = {
|
|
|
58489
58762
|
setParticipantScaleItems: setParticipantScaleItems
|
|
58490
58763
|
};
|
|
58491
58764
|
|
|
58492
|
-
var index$
|
|
58765
|
+
var index$7 = {
|
|
58493
58766
|
__proto__: null,
|
|
58494
58767
|
addIndividualParticipantIds: addIndividualParticipantIds,
|
|
58495
58768
|
addParticipant: addParticipant,
|
|
@@ -58520,7 +58793,7 @@ var index$8 = {
|
|
|
58520
58793
|
modifyParticipantsSignInStatus: modifyParticipantsSignInStatus,
|
|
58521
58794
|
modifyPenalty: modifyPenalty,
|
|
58522
58795
|
modifyPersonRequests: modifyPersonRequests,
|
|
58523
|
-
mutate: mutate$
|
|
58796
|
+
mutate: mutate$5,
|
|
58524
58797
|
participantScaleItem: participantScaleItem,
|
|
58525
58798
|
query: query$9,
|
|
58526
58799
|
regenerateParticipantNames: regenerateParticipantNames,
|
|
@@ -58534,95 +58807,6 @@ var index$8 = {
|
|
|
58534
58807
|
validateLineUp: validateLineUp
|
|
58535
58808
|
};
|
|
58536
58809
|
|
|
58537
|
-
function removePolicy(params) {
|
|
58538
|
-
var _a, _b, e_1, _c;
|
|
58539
|
-
var _d, _e;
|
|
58540
|
-
var checkParams = checkRequiredParameters(params, [
|
|
58541
|
-
(_a = {},
|
|
58542
|
-
_a[POLICY_TYPE] = true,
|
|
58543
|
-
_a._anyOf = (_b = {},
|
|
58544
|
-
_b[TOURNAMENT_RECORDS] = false,
|
|
58545
|
-
_b[TOURNAMENT_RECORD] = false,
|
|
58546
|
-
_b[DRAW_DEFINITION] = false,
|
|
58547
|
-
_b[EVENT] = false,
|
|
58548
|
-
_b),
|
|
58549
|
-
_a),
|
|
58550
|
-
]);
|
|
58551
|
-
if (checkParams.error)
|
|
58552
|
-
return checkParams;
|
|
58553
|
-
var policyRemoved;
|
|
58554
|
-
var element = (_e = (_d = params.drawDefinition) !== null && _d !== void 0 ? _d : params.event) !== null && _e !== void 0 ? _e : ((params.tournamentId || !params.tournamentRecords) && params.tournamentRecord);
|
|
58555
|
-
if (element) {
|
|
58556
|
-
return policyDeletion(params, element);
|
|
58557
|
-
}
|
|
58558
|
-
else if (params.tournamentRecords) {
|
|
58559
|
-
var tournamentIds = Object.keys(params.tournamentRecords);
|
|
58560
|
-
if (!tournamentIds.length)
|
|
58561
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
58562
|
-
try {
|
|
58563
|
-
for (var tournamentIds_1 = __values(tournamentIds), tournamentIds_1_1 = tournamentIds_1.next(); !tournamentIds_1_1.done; tournamentIds_1_1 = tournamentIds_1.next()) {
|
|
58564
|
-
var tournamentId = tournamentIds_1_1.value;
|
|
58565
|
-
var tournamentRecord = params.tournamentRecords[tournamentId];
|
|
58566
|
-
var result = policyDeletion(params, tournamentRecord);
|
|
58567
|
-
if (result.error)
|
|
58568
|
-
return result;
|
|
58569
|
-
policyRemoved = true;
|
|
58570
|
-
}
|
|
58571
|
-
}
|
|
58572
|
-
catch (e_1_1) { e_1 = { error: e_1_1 }; }
|
|
58573
|
-
finally {
|
|
58574
|
-
try {
|
|
58575
|
-
if (tournamentIds_1_1 && !tournamentIds_1_1.done && (_c = tournamentIds_1.return)) _c.call(tournamentIds_1);
|
|
58576
|
-
}
|
|
58577
|
-
finally { if (e_1) throw e_1.error; }
|
|
58578
|
-
}
|
|
58579
|
-
}
|
|
58580
|
-
else {
|
|
58581
|
-
return { error: MISSING_TOURNAMENT_RECORD };
|
|
58582
|
-
}
|
|
58583
|
-
return policyRemoved ? __assign({}, SUCCESS) : { error: POLICY_NOT_FOUND };
|
|
58584
|
-
}
|
|
58585
|
-
function policyDeletion(params, element) {
|
|
58586
|
-
var _a;
|
|
58587
|
-
var appliedPolicies = (_a = getAppliedPolicies(params).appliedPolicies) !== null && _a !== void 0 ? _a : {};
|
|
58588
|
-
if (appliedPolicies[params.policyType]) {
|
|
58589
|
-
delete appliedPolicies[params.policyType];
|
|
58590
|
-
if (Object.keys(appliedPolicies).length) {
|
|
58591
|
-
var extension = { name: APPLIED_POLICIES, value: appliedPolicies };
|
|
58592
|
-
addExtension({ element: element, extension: extension });
|
|
58593
|
-
}
|
|
58594
|
-
else {
|
|
58595
|
-
removeExtension({ element: element, name: APPLIED_POLICIES });
|
|
58596
|
-
}
|
|
58597
|
-
return __assign({}, SUCCESS);
|
|
58598
|
-
}
|
|
58599
|
-
return { error: POLICY_NOT_FOUND };
|
|
58600
|
-
}
|
|
58601
|
-
|
|
58602
|
-
var mutate$5 = {
|
|
58603
|
-
__proto__: null,
|
|
58604
|
-
attachPolicies: attachPolicies,
|
|
58605
|
-
removePolicy: removePolicy
|
|
58606
|
-
};
|
|
58607
|
-
|
|
58608
|
-
var query$1 = {
|
|
58609
|
-
__proto__: null,
|
|
58610
|
-
findPolicy: findPolicy,
|
|
58611
|
-
getAppliedPolicies: getAppliedPolicies,
|
|
58612
|
-
getPolicyDefinitions: getPolicyDefinitions
|
|
58613
|
-
};
|
|
58614
|
-
|
|
58615
|
-
var index$7 = {
|
|
58616
|
-
__proto__: null,
|
|
58617
|
-
attachPolicies: attachPolicies,
|
|
58618
|
-
findPolicy: findPolicy,
|
|
58619
|
-
getAppliedPolicies: getAppliedPolicies,
|
|
58620
|
-
getPolicyDefinitions: getPolicyDefinitions,
|
|
58621
|
-
mutate: mutate$5,
|
|
58622
|
-
query: query$1,
|
|
58623
|
-
removePolicy: removePolicy
|
|
58624
|
-
};
|
|
58625
|
-
|
|
58626
58810
|
function publishEventSeeding(_a) {
|
|
58627
58811
|
var _b, _c, _d, _e;
|
|
58628
58812
|
var _f = _a.removePriorValues, removePriorValues = _f === void 0 ? true : _f, stageSeedingScaleNames = _a.stageSeedingScaleNames, seedingScaleNames = _a.seedingScaleNames, tournamentRecord = _a.tournamentRecord, _g = _a.status, status = _g === void 0 ? PUBLIC : _g, _h = _a.drawIds, drawIds = _h === void 0 ? [] : _h, event = _a.event;
|
|
@@ -64702,15 +64886,15 @@ var index$1 = {
|
|
|
64702
64886
|
var governors = {
|
|
64703
64887
|
__proto__: null,
|
|
64704
64888
|
competitionGovernor: index$h,
|
|
64705
|
-
drawsGovernor: index$
|
|
64706
|
-
entriesGovernor: index$
|
|
64707
|
-
eventGovernor: index$
|
|
64708
|
-
generationGovernor: index$
|
|
64709
|
-
matchUpFormatGovernor: index$
|
|
64710
|
-
matchUpGovernor: index$
|
|
64889
|
+
drawsGovernor: index$d,
|
|
64890
|
+
entriesGovernor: index$c,
|
|
64891
|
+
eventGovernor: index$b,
|
|
64892
|
+
generationGovernor: index$a,
|
|
64893
|
+
matchUpFormatGovernor: index$9,
|
|
64894
|
+
matchUpGovernor: index$8,
|
|
64711
64895
|
mocksGovernor: mocksGovernor,
|
|
64712
|
-
participantGovernor: index$
|
|
64713
|
-
policyGovernor: index$
|
|
64896
|
+
participantGovernor: index$7,
|
|
64897
|
+
policyGovernor: index$e,
|
|
64714
64898
|
publishingGovernor: index$6,
|
|
64715
64899
|
queryGovernor: index$g,
|
|
64716
64900
|
reportGovernor: index$5,
|
|
@@ -66735,27 +66919,27 @@ exports.competitionGovernor = index$h;
|
|
|
66735
66919
|
exports.completedMatchUpStatuses = completedMatchUpStatuses;
|
|
66736
66920
|
exports.directingMatchUpStatuses = directingMatchUpStatuses;
|
|
66737
66921
|
exports.drawDefinitionConstants = drawDefinitionConstants;
|
|
66738
|
-
exports.drawsGovernor = index$
|
|
66739
|
-
exports.entriesGovernor = index$
|
|
66922
|
+
exports.drawsGovernor = index$d;
|
|
66923
|
+
exports.entriesGovernor = index$c;
|
|
66740
66924
|
exports.entryStatusConstants = entryStatusConstants;
|
|
66741
66925
|
exports.errorConditionConstants = errorConditionConstants;
|
|
66742
66926
|
exports.eventConstants = eventConstants;
|
|
66743
|
-
exports.eventGovernor = index$
|
|
66927
|
+
exports.eventGovernor = index$b;
|
|
66744
66928
|
exports.extensionConstants = extensionConstants;
|
|
66745
66929
|
exports.factoryConstants = index;
|
|
66746
66930
|
exports.fixtures = fixtures;
|
|
66747
66931
|
exports.flightConstants = flightConstants;
|
|
66748
66932
|
exports.forge = forge;
|
|
66749
66933
|
exports.genderConstants = genderConstants;
|
|
66750
|
-
exports.generationGovernor = index$
|
|
66934
|
+
exports.generationGovernor = index$a;
|
|
66751
66935
|
exports.globalState = globalState$1;
|
|
66752
66936
|
exports.governors = governors;
|
|
66753
66937
|
exports.keyValueConstants = keyValueConstants;
|
|
66754
66938
|
exports.matchUpActionConstants = matchUpActionConstants;
|
|
66755
66939
|
exports.matchUpEngine = matchUpEngine;
|
|
66756
|
-
exports.matchUpFormatCode = index$
|
|
66757
|
-
exports.matchUpFormatGovernor = index$
|
|
66758
|
-
exports.matchUpGovernor = index$
|
|
66940
|
+
exports.matchUpFormatCode = index$9;
|
|
66941
|
+
exports.matchUpFormatGovernor = index$9;
|
|
66942
|
+
exports.matchUpGovernor = index$8;
|
|
66759
66943
|
exports.matchUpStatusConstants = matchUpStatusConstants;
|
|
66760
66944
|
exports.matchUpTypes = matchUpTypes;
|
|
66761
66945
|
exports.mocksEngine = mocksEngine;
|
|
@@ -66763,12 +66947,12 @@ exports.mocksGovernor = mocksGovernor;
|
|
|
66763
66947
|
exports.nonDirectingMatchUpStatuses = nonDirectingMatchUpStatuses;
|
|
66764
66948
|
exports.particicipantsRequiredMatchUpStatuses = particicipantsRequiredMatchUpStatuses;
|
|
66765
66949
|
exports.participantConstants = participantConstants;
|
|
66766
|
-
exports.participantGovernor = index$
|
|
66950
|
+
exports.participantGovernor = index$7;
|
|
66767
66951
|
exports.participantRoles = participantRoles;
|
|
66768
66952
|
exports.participantTypes = participantTypes;
|
|
66769
66953
|
exports.penaltyConstants = penaltyConstants;
|
|
66770
66954
|
exports.policyConstants = policyConstants;
|
|
66771
|
-
exports.policyGovernor = index$
|
|
66955
|
+
exports.policyGovernor = index$e;
|
|
66772
66956
|
exports.positionActionConstants = positionActionConstants;
|
|
66773
66957
|
exports.publishingGovernor = index$6;
|
|
66774
66958
|
exports.queryGovernor = index$g;
|