tods-competition-factory 1.7.0 → 1.7.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -340,11 +340,11 @@ function isValid(matchUpFormat) {
340
340
  if (typeof matchUpFormat !== 'string')
341
341
  return false;
342
342
  var parsedFormat = parse(matchUpFormat);
343
- var setParts = matchUpFormat.match(/-S:(\d+)+\/TB(\d+)@?(\d*)*/);
343
+ var setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
344
344
  var setsTo = setParts === null || setParts === void 0 ? void 0 : setParts[1];
345
345
  var tiebreakTo = setParts === null || setParts === void 0 ? void 0 : setParts[2];
346
346
  var tiebreakAt = setParts === null || setParts === void 0 ? void 0 : setParts[3];
347
- var finalSetParts = matchUpFormat.match(/-F:(\d+)+\/TB(\d+)@?(\d*)*/);
347
+ var finalSetParts = matchUpFormat.match(/-F:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
348
348
  var finalSetTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[1];
349
349
  var finalSetTiebreakTo = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[2];
350
350
  var finalTiebreakAt = finalSetParts === null || finalSetParts === void 0 ? void 0 : finalSetParts[3];
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
362
362
  };
363
363
 
364
364
  function factoryVersion() {
365
- return '1.7.0';
365
+ return '1.7.2';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -3533,11 +3533,12 @@ function validateTieFormat(params) {
3533
3533
  return result;
3534
3534
  }
3535
3535
  function validateCollectionDefinition(_a) {
3536
- var collectionDefinition = _a.collectionDefinition, checkCollectionIds = _a.checkCollectionIds, referenceGender = _a.referenceGender, checkGender = _a.checkGender;
3536
+ var collectionDefinition = _a.collectionDefinition, checkCollectionIds = _a.checkCollectionIds, _b = _a.checkGender, checkGender = _b === void 0 ? true : _b, referenceGender = _a.referenceGender, event = _a.event;
3537
+ referenceGender = referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender;
3537
3538
  var errors = [];
3538
3539
  if (typeof collectionDefinition !== 'object') {
3539
3540
  errors.push("collectionDefinition must be an object: ".concat(collectionDefinition));
3540
- return { errors: errors };
3541
+ return { errors: errors, error: INVALID_OBJECT };
3541
3542
  }
3542
3543
  var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, collectionId = collectionDefinition.collectionId, matchUpCount = collectionDefinition.matchUpCount, matchUpFormat = collectionDefinition.matchUpFormat, matchUpValue = collectionDefinition.matchUpValue, matchUpType = collectionDefinition.matchUpType, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue, gender = collectionDefinition.gender;
3543
3544
  if (checkCollectionIds && typeof collectionId !== 'string') {
@@ -3585,7 +3586,7 @@ function validateCollectionDefinition(_a) {
3585
3586
  errors.push("Invalid gender: ".concat(gender));
3586
3587
  }
3587
3588
  if (errors.length)
3588
- return { errors: errors };
3589
+ return { errors: errors, error: INVALID_OBJECT };
3589
3590
  return { valid: true };
3590
3591
  }
3591
3592
  // add collectionIds if missing
@@ -23782,7 +23783,7 @@ function getExitWinningSide(_a) {
23782
23783
  }
23783
23784
 
23784
23785
  function assignMatchUpDrawPosition(_a) {
23785
- var _b, _c, _d;
23786
+ var _b, _c, _d, _e, _f, _g, _h;
23786
23787
  var inContextDrawMatchUps = _a.inContextDrawMatchUps, sourceMatchUpStatus = _a.sourceMatchUpStatus, tournamentRecord = _a.tournamentRecord, sourceMatchUpId = _a.sourceMatchUpId, drawDefinition = _a.drawDefinition, matchUpStatus = _a.matchUpStatus, drawPosition = _a.drawPosition, matchUpsMap = _a.matchUpsMap, matchUpId = _a.matchUpId, event = _a.event;
23787
23788
  var stack = 'assignMatchUpDrawPosition';
23788
23789
  if (!matchUpsMap) {
@@ -23790,20 +23791,20 @@ function assignMatchUpDrawPosition(_a) {
23790
23791
  }
23791
23792
  if (!inContextDrawMatchUps) {
23792
23793
  inContextDrawMatchUps =
23793
- getAllDrawMatchUps({
23794
+ (_b = getAllDrawMatchUps({
23794
23795
  inContext: true,
23795
23796
  drawDefinition: drawDefinition,
23796
23797
  matchUpsMap: matchUpsMap,
23797
- }).matchUps || [];
23798
+ }).matchUps) !== null && _b !== void 0 ? _b : [];
23798
23799
  }
23799
23800
  var inContextMatchUp = inContextDrawMatchUps.find(function (m) { return m.matchUpId === matchUpId; });
23800
23801
  var structureId = inContextMatchUp === null || inContextMatchUp === void 0 ? void 0 : inContextMatchUp.structureId;
23801
- var structure = (_b = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.find(function (structure) { return structure.structureId === structureId; });
23802
+ 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 === structureId; });
23802
23803
  if (!structure)
23803
23804
  return { error: STRUCTURE_NOT_FOUND };
23804
- var matchUp = (_c = matchUpsMap === null || matchUpsMap === void 0 ? void 0 : matchUpsMap.drawMatchUps) === null || _c === void 0 ? void 0 : _c.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
23805
- var drawPositions = (matchUp === null || matchUp === void 0 ? void 0 : matchUp.drawPositions) || [];
23806
- var _e = getUpdatedDrawPositions({ drawPosition: drawPosition, drawPositions: drawPositions }), positionAdded = _e.positionAdded, positionAssigned = _e.positionAssigned, updatedDrawPositions = _e.updatedDrawPositions;
23805
+ var matchUp = (_d = matchUpsMap === null || matchUpsMap === void 0 ? void 0 : matchUpsMap.drawMatchUps) === null || _d === void 0 ? void 0 : _d.find(function (matchUp) { return matchUp.matchUpId === matchUpId; });
23806
+ var drawPositions = (_e = matchUp === null || matchUp === void 0 ? void 0 : matchUp.drawPositions) !== null && _e !== void 0 ? _e : [];
23807
+ var _j = getUpdatedDrawPositions({ drawPosition: drawPosition, drawPositions: drawPositions }), positionAdded = _j.positionAdded, positionAssigned = _j.positionAssigned, updatedDrawPositions = _j.updatedDrawPositions;
23807
23808
  var positionAssignments = getPositionAssignments$1({
23808
23809
  drawDefinition: drawDefinition,
23809
23810
  structure: structure,
@@ -23829,11 +23830,11 @@ function assignMatchUpDrawPosition(_a) {
23829
23830
  if (matchUp && positionAdded) {
23830
23831
  // necessary to update inContextDrawMatchUps
23831
23832
  inContextDrawMatchUps =
23832
- getAllDrawMatchUps({
23833
+ (_f = getAllDrawMatchUps({
23833
23834
  inContext: true,
23834
23835
  drawDefinition: drawDefinition,
23835
23836
  matchUpsMap: matchUpsMap,
23836
- }).matchUps || [];
23837
+ }).matchUps) !== null && _f !== void 0 ? _f : [];
23837
23838
  var exitWinningSide = (isDoubleExitExit &&
23838
23839
  getExitWinningSide({
23839
23840
  inContextDrawMatchUps: inContextDrawMatchUps,
@@ -23870,7 +23871,7 @@ function assignMatchUpDrawPosition(_a) {
23870
23871
  drawDefinition: drawDefinition,
23871
23872
  matchUpId: matchUpId,
23872
23873
  });
23873
- var _f = targetData.targetMatchUps, winnerMatchUp = _f.winnerMatchUp, loserMatchUp = _f.loserMatchUp, loserTargetDrawPosition = _f.loserTargetDrawPosition, loserTargetLink = targetData.targetLinks.loserTargetLink;
23874
+ var _k = targetData.targetMatchUps, winnerMatchUp = _k.winnerMatchUp, loserMatchUp = _k.loserMatchUp, loserTargetDrawPosition = _k.loserTargetDrawPosition, loserTargetLink = targetData.targetLinks.loserTargetLink;
23874
23875
  var structureMatchUps = getMappedStructureMatchUps({
23875
23876
  structureId: structure.structureId,
23876
23877
  matchUpsMap: matchUpsMap,
@@ -23923,9 +23924,9 @@ function assignMatchUpDrawPosition(_a) {
23923
23924
  var matchUpId = _a.matchUpId;
23924
23925
  return matchUpId === matchUp.matchUpId;
23925
23926
  });
23926
- var sides = (inContextTargetMatchUp === null || inContextTargetMatchUp === void 0 ? void 0 : inContextTargetMatchUp.sides) || [];
23927
+ var sides = (_g = inContextTargetMatchUp === null || inContextTargetMatchUp === void 0 ? void 0 : inContextTargetMatchUp.sides) !== null && _g !== void 0 ? _g : [];
23927
23928
  var drawPositionSideIndex = sides.reduce(function (index, side, i) { return (side.drawPosition === drawPosition ? i : index); }, undefined);
23928
- var teamParticipantId = (_d = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.find(function (assignment) { return assignment.drawPosition === drawPosition; })) === null || _d === void 0 ? void 0 : _d.participantId;
23929
+ var teamParticipantId = (_h = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.find(function (assignment) { return assignment.drawPosition === drawPosition; })) === null || _h === void 0 ? void 0 : _h.participantId;
23929
23930
  if (teamParticipantId && drawPositionSideIndex !== undefined) {
23930
23931
  updateSideLineUp({
23931
23932
  inContextTargetMatchUp: inContextTargetMatchUp,
@@ -32852,19 +32853,24 @@ function generateCollectionMatchUps(_a) {
32852
32853
  });
32853
32854
  }
32854
32855
 
32855
- /*
32856
- * collectionDefinition will be added to an event tieFormat (if present)
32857
- * if a matchUpId is provided, will be added to matchUp.tieFormat
32858
- * if a structureId is provided, will be added to structure.tieFormat
32859
- * TODO: determine whether all contained instances of tieFormat should be updated
32860
- */
32861
32856
  function addCollectionDefinition$1(_a) {
32862
32857
  var e_1, _b, e_2, _c, _d, e_3, _e;
32863
- var _f;
32864
- var _g = _a.updateInProgressMatchUps, updateInProgressMatchUps = _g === void 0 ? true : _g, collectionDefinition = _a.collectionDefinition, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
32865
- var _h = validateCollectionDefinition({
32858
+ var _f, _g, _h, _j, _k, _l, _m;
32859
+ var _o = _a.updateInProgressMatchUps, updateInProgressMatchUps = _o === void 0 ? true : _o, collectionDefinition = _a.collectionDefinition, tournamentRecord = _a.tournamentRecord, referenceGender = _a.referenceGender, drawDefinition = _a.drawDefinition, tieFormatName = _a.tieFormatName, enforceGender = _a.enforceGender, structureId = _a.structureId, matchUpId = _a.matchUpId, matchUp = _a.matchUp, eventId = _a.eventId, uuids = _a.uuids, event = _a.event;
32860
+ var appliedPolicies = (_f = getAppliedPolicies({
32861
+ tournamentRecord: tournamentRecord,
32862
+ drawDefinition: drawDefinition,
32863
+ event: event,
32864
+ }).appliedPolicies) !== null && _f !== void 0 ? _f : {};
32865
+ enforceGender =
32866
+ enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_h = (_g = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _g === void 0 ? void 0 : _g.participants) === null || _h === void 0 ? void 0 : _h.enforceGender;
32867
+ var checkGender = !!(enforceGender !== false && (event === null || event === void 0 ? void 0 : event.gender));
32868
+ var _p = validateCollectionDefinition({
32866
32869
  collectionDefinition: collectionDefinition,
32867
- }), valid = _h.valid, errors = _h.errors;
32870
+ referenceGender: referenceGender,
32871
+ checkGender: checkGender,
32872
+ event: event,
32873
+ }), valid = _p.valid, errors = _p.errors;
32868
32874
  if (!valid)
32869
32875
  return { error: INVALID_VALUES, errors: errors };
32870
32876
  var stack = 'addCollectionDefinition';
@@ -32880,7 +32886,7 @@ function addCollectionDefinition$1(_a) {
32880
32886
  if (result === null || result === void 0 ? void 0 : result.error)
32881
32887
  return { error: result.error };
32882
32888
  var structure = result === null || result === void 0 ? void 0 : result.structure;
32883
- matchUp = matchUp || (result === null || result === void 0 ? void 0 : result.matchUp);
32889
+ matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
32884
32890
  var existingTieFormat = result === null || result === void 0 ? void 0 : result.tieFormat;
32885
32891
  var tieFormat = copyTieFormat(existingTieFormat);
32886
32892
  result = validateTieFormat({ tieFormat: tieFormat });
@@ -32908,7 +32914,7 @@ function addCollectionDefinition$1(_a) {
32908
32914
  });
32909
32915
  // calculate new winCriteria for tieFormat
32910
32916
  // if existing winCriteria is aggregateValue, retain
32911
- var _j = calculateWinCriteria(tieFormat), aggregateValue = _j.aggregateValue, valueGoal = _j.valueGoal;
32917
+ var _q = calculateWinCriteria(tieFormat), aggregateValue = _q.aggregateValue, valueGoal = _q.valueGoal;
32912
32918
  tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
32913
32919
  // if valueGoal has changed, force renaming of the tieFormat
32914
32920
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
@@ -32929,17 +32935,17 @@ function addCollectionDefinition$1(_a) {
32929
32935
  result = validateTieFormat({ tieFormat: prunedTieFormat });
32930
32936
  if (result === null || result === void 0 ? void 0 : result.error)
32931
32937
  return { error: result.error };
32932
- if (eventId) {
32938
+ if (eventId && event) {
32933
32939
  event.tieFormat = prunedTieFormat;
32934
32940
  try {
32935
32941
  // all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
32936
- for (var _k = __values(event.drawDefinitions || []), _l = _k.next(); !_l.done; _l = _k.next()) {
32937
- var drawDefinition_1 = _l.value;
32942
+ for (var _r = __values((_j = event.drawDefinitions) !== null && _j !== void 0 ? _j : []), _s = _r.next(); !_s.done; _s = _r.next()) {
32943
+ var drawDefinition_1 = _s.value;
32938
32944
  if (drawDefinition_1.tieFormat)
32939
32945
  continue;
32940
32946
  try {
32941
- for (var _m = (e_2 = void 0, __values(drawDefinition_1.structures || [])), _o = _m.next(); !_o.done; _o = _m.next()) {
32942
- var structure_1 = _o.value;
32947
+ for (var _t = (e_2 = void 0, __values((_k = drawDefinition_1.structures) !== null && _k !== void 0 ? _k : [])), _u = _t.next(); !_u.done; _u = _t.next()) {
32948
+ var structure_1 = _u.value;
32943
32949
  if (structure_1.tieFormat)
32944
32950
  continue;
32945
32951
  var result_1 = updateStructureMatchUps({
@@ -32956,7 +32962,7 @@ function addCollectionDefinition$1(_a) {
32956
32962
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
32957
32963
  finally {
32958
32964
  try {
32959
- if (_o && !_o.done && (_c = _m.return)) _c.call(_m);
32965
+ if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
32960
32966
  }
32961
32967
  finally { if (e_2) throw e_2.error; }
32962
32968
  }
@@ -32965,7 +32971,7 @@ function addCollectionDefinition$1(_a) {
32965
32971
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
32966
32972
  finally {
32967
32973
  try {
32968
- if (_l && !_l.done && (_b = _k.return)) _b.call(_k);
32974
+ if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
32969
32975
  }
32970
32976
  finally { if (e_1) throw e_1.error; }
32971
32977
  }
@@ -33025,8 +33031,8 @@ function addCollectionDefinition$1(_a) {
33025
33031
  // all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
33026
33032
  drawDefinition.tieFormat = prunedTieFormat;
33027
33033
  try {
33028
- for (var _p = __values(drawDefinition.structures || []), _q = _p.next(); !_q.done; _q = _p.next()) {
33029
- var structure_2 = _q.value;
33034
+ for (var _v = __values((_l = drawDefinition.structures) !== null && _l !== void 0 ? _l : []), _w = _v.next(); !_w.done; _w = _v.next()) {
33035
+ var structure_2 = _w.value;
33030
33036
  var result_3 = updateStructureMatchUps({
33031
33037
  updateInProgressMatchUps: updateInProgressMatchUps,
33032
33038
  collectionDefinition: collectionDefinition,
@@ -33041,7 +33047,7 @@ function addCollectionDefinition$1(_a) {
33041
33047
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
33042
33048
  finally {
33043
33049
  try {
33044
- if (_q && !_q.done && (_e = _p.return)) _e.call(_p);
33050
+ if (_w && !_w.done && (_e = _v.return)) _e.call(_v);
33045
33051
  }
33046
33052
  finally { if (e_3) throw e_3.error; }
33047
33053
  }
@@ -33057,8 +33063,7 @@ function addCollectionDefinition$1(_a) {
33057
33063
  else {
33058
33064
  return { error: MISSING_DRAW_DEFINITION };
33059
33065
  }
33060
- var appliedPolicies = getAppliedPolicies({ tournamentRecord: tournamentRecord }).appliedPolicies;
33061
- if ((_f = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _f === void 0 ? void 0 : _f[TIE_FORMAT_MODIFICATIONS]) {
33066
+ if ((_m = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _m === void 0 ? void 0 : _m[TIE_FORMAT_MODIFICATIONS]) {
33062
33067
  var auditData = definedAttributes({
33063
33068
  drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
33064
33069
  collectionDefinition: collectionDefinition,
@@ -47604,8 +47609,8 @@ function addPlayoffStructures$1(params) {
47604
47609
 
47605
47610
  function deleteAdHocMatchUps$1(_a) {
47606
47611
  var e_1, _b;
47607
- var _c, _d, _e;
47608
- var tournamentRecord = _a.tournamentRecord, _f = _a.matchUpIds, matchUpIds = _f === void 0 ? [] : _f, drawDefinition = _a.drawDefinition, structureId = _a.structureId, event = _a.event;
47612
+ var _c, _d, _e, _f, _g;
47613
+ var tournamentRecord = _a.tournamentRecord, _h = _a.matchUpIds, matchUpIds = _h === void 0 ? [] : _h, drawDefinition = _a.drawDefinition, structureId = _a.structureId, event = _a.event;
47609
47614
  if (typeof drawDefinition !== 'object')
47610
47615
  return { error: MISSING_DRAW_DEFINITION };
47611
47616
  if (typeof structureId !== 'string')
@@ -47622,8 +47627,11 @@ function deleteAdHocMatchUps$1(_a) {
47622
47627
  structure.finishingPosition === ROUND_OUTCOME) {
47623
47628
  return { error: INVALID_STRUCTURE };
47624
47629
  }
47630
+ var matchUpIdsWithScoreValue = [];
47625
47631
  var matchUpsToDelete = (_d = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.filter(function (_a) {
47626
- var matchUpId = _a.matchUpId;
47632
+ var matchUpId = _a.matchUpId, score = _a.score;
47633
+ if (scoreHasValue({ score: score }))
47634
+ matchUpIdsWithScoreValue.push(matchUpId);
47627
47635
  return matchUpIds.includes(matchUpId);
47628
47636
  })) !== null && _d !== void 0 ? _d : [];
47629
47637
  var matchUpIdsToDelete = matchUpsToDelete.map(extractAttributes('matchUpId'));
@@ -47642,28 +47650,51 @@ function deleteAdHocMatchUps$1(_a) {
47642
47650
  var roundNumbers = unique(structure.matchUps.map(extractAttributes('roundNumber')));
47643
47651
  var missingRoundNumbers = getMissingSequenceNumbers(roundNumbers);
47644
47652
  if (missingRoundNumbers.length) {
47645
- var roundNumbersToConsider = missingRoundNumbers.reverse();
47653
+ missingRoundNumbers.reverse();
47646
47654
  var _loop_1 = function (roundNumber) {
47647
47655
  structure.matchUps.forEach(function (matchUp) {
47648
47656
  if (matchUp.roundNumber && matchUp.roundNumber > roundNumber) {
47649
47657
  matchUp.roundNumber -= 1;
47658
+ modifyMatchUpNotice({
47659
+ tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
47660
+ context: ['adHoc round deletion'],
47661
+ eventId: event === null || event === void 0 ? void 0 : event.eventId,
47662
+ drawDefinition: drawDefinition,
47663
+ matchUp: matchUp,
47664
+ });
47650
47665
  }
47651
47666
  });
47652
47667
  };
47653
47668
  try {
47654
- for (var roundNumbersToConsider_1 = __values(roundNumbersToConsider), roundNumbersToConsider_1_1 = roundNumbersToConsider_1.next(); !roundNumbersToConsider_1_1.done; roundNumbersToConsider_1_1 = roundNumbersToConsider_1.next()) {
47655
- var roundNumber = roundNumbersToConsider_1_1.value;
47669
+ for (var missingRoundNumbers_1 = __values(missingRoundNumbers), missingRoundNumbers_1_1 = missingRoundNumbers_1.next(); !missingRoundNumbers_1_1.done; missingRoundNumbers_1_1 = missingRoundNumbers_1.next()) {
47670
+ var roundNumber = missingRoundNumbers_1_1.value;
47656
47671
  _loop_1(roundNumber);
47657
47672
  }
47658
47673
  }
47659
47674
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
47660
47675
  finally {
47661
47676
  try {
47662
- if (roundNumbersToConsider_1_1 && !roundNumbersToConsider_1_1.done && (_b = roundNumbersToConsider_1.return)) _b.call(roundNumbersToConsider_1);
47677
+ if (missingRoundNumbers_1_1 && !missingRoundNumbers_1_1.done && (_b = missingRoundNumbers_1.return)) _b.call(missingRoundNumbers_1);
47663
47678
  }
47664
47679
  finally { if (e_1) throw e_1.error; }
47665
47680
  }
47666
47681
  }
47682
+ if (matchUpIdsWithScoreValue.length) {
47683
+ structure.positionAssignments = unique(structure.matchUps
47684
+ .flatMap(function (matchUp) { var _a; return ((_a = matchUp.sides) !== null && _a !== void 0 ? _a : []).map(function (side) { return side.participantId; }); })
47685
+ .filter(Boolean)).map(function (participantId) { return ({ participantId: participantId }); });
47686
+ var matchUpFormat = (_g = (_f = structure === null || structure === void 0 ? void 0 : structure.matchUpFormat) !== null && _f !== void 0 ? _f : drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpFormat) !== null && _g !== void 0 ? _g : event === null || event === void 0 ? void 0 : event.matchUpFormat;
47687
+ var result = updateAssignmentParticipantResults({
47688
+ positionAssignments: structure.positionAssignments,
47689
+ matchUps: structure.matchUps,
47690
+ tournamentRecord: tournamentRecord,
47691
+ drawDefinition: drawDefinition,
47692
+ matchUpFormat: matchUpFormat,
47693
+ event: event,
47694
+ });
47695
+ if (result.error)
47696
+ console.log(result);
47697
+ }
47667
47698
  modifyDrawNotice({
47668
47699
  structureIds: [structureId],
47669
47700
  eventId: event === null || event === void 0 ? void 0 : event.eventId,
@@ -47847,14 +47878,21 @@ function removeStructure(_a) {
47847
47878
  }
47848
47879
 
47849
47880
  function generateAdHocMatchUps$1(_a) {
47850
- var _b, _c, _d, _e;
47851
- var participantIdPairings = _a.participantIdPairings, _f = _a.addToStructure, addToStructure = _f === void 0 ? true : _f, tournamentRecord = _a.tournamentRecord, _g = _a.matchUpIds, matchUpIds = _g === void 0 ? [] : _g, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, roundNumber = _a.roundNumber, structureId = _a.structureId, newRound = _a.newRound;
47881
+ var _b, _c, _d, _e, _f, _g;
47882
+ var participantIdPairings = _a.participantIdPairings, _h = _a.addToStructure, addToStructure = _h === void 0 ? true : _h, tournamentRecord = _a.tournamentRecord, _j = _a.matchUpIds, matchUpIds = _j === void 0 ? [] : _j, drawDefinition = _a.drawDefinition, matchUpsCount = _a.matchUpsCount, roundNumber = _a.roundNumber, structureId = _a.structureId, newRound = _a.newRound;
47852
47883
  if (typeof drawDefinition !== 'object')
47853
47884
  return { error: MISSING_DRAW_DEFINITION };
47854
47885
  if (!structureId && ((_b = drawDefinition.structures) === null || _b === void 0 ? void 0 : _b.length) === 1)
47855
47886
  structureId = (_d = (_c = drawDefinition.structures) === null || _c === void 0 ? void 0 : _c[0]) === null || _d === void 0 ? void 0 : _d.structureId;
47856
47887
  if (typeof structureId !== 'string')
47857
47888
  return { error: MISSING_STRUCTURE_ID };
47889
+ if (newRound && !matchUpsCount) {
47890
+ var selectedEntries = (_f = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.entries) === null || _e === void 0 ? void 0 : _e.filter(function (entry) {
47891
+ var entryStatus = entry.entryStatus;
47892
+ return STRUCTURE_SELECTED_STATUSES.includes(entryStatus);
47893
+ })) !== null && _f !== void 0 ? _f : [];
47894
+ matchUpsCount = Math.floor((selectedEntries === null || selectedEntries === void 0 ? void 0 : selectedEntries.length) / 2) || 1;
47895
+ }
47858
47896
  if ((participantIdPairings && !Array.isArray(participantIdPairings)) ||
47859
47897
  (matchUpsCount && !isConvertableInteger(matchUpsCount)) ||
47860
47898
  (matchUpIds && !Array.isArray(matchUpIds)) ||
@@ -47862,7 +47900,7 @@ function generateAdHocMatchUps$1(_a) {
47862
47900
  return { error: INVALID_VALUES, info: 'matchUpsCount or pairings error' };
47863
47901
  }
47864
47902
  // if drawDefinition and structureId are provided it is possible to infer roundNumber
47865
- var structure = (_e = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _e === void 0 ? void 0 : _e.find(function (structure) { return structure.structureId === structureId; });
47903
+ var structure = (_g = drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.structures) === null || _g === void 0 ? void 0 : _g.find(function (structure) { return structure.structureId === structureId; });
47866
47904
  var structureHasRoundPositions;
47867
47905
  var existingMatchUps = structure === null || structure === void 0 ? void 0 : structure.matchUps;
47868
47906
  var lastRoundNumber = existingMatchUps === null || existingMatchUps === void 0 ? void 0 : existingMatchUps.reduce(function (roundNumber, matchUp) {
@@ -62873,6 +62911,7 @@ var eventGovernor = {
62873
62911
  renameStructures: renameStructures,
62874
62912
  disableTieAutoCalc: disableTieAutoCalc,
62875
62913
  enableTieAutoCalc: enableTieAutoCalc,
62914
+ validateCollectionDefinition: validateCollectionDefinition,
62876
62915
  modifyCollectionDefinition: modifyCollectionDefinition$1,
62877
62916
  orderCollectionDefinitions: orderCollectionDefinitions$1,
62878
62917
  removeCollectionDefinition: removeCollectionDefinition$1,