tods-competition-factory 1.8.18 → 1.8.20

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.
@@ -2905,7 +2905,7 @@ var matchUpFormatCode = {
2905
2905
  };
2906
2906
 
2907
2907
  function factoryVersion() {
2908
- return '1.8.18';
2908
+ return '1.8.20';
2909
2909
  }
2910
2910
 
2911
2911
  function getObjectTieFormat(obj) {
@@ -3164,10 +3164,50 @@ function getCategoryAgeDetails(params) {
3164
3164
  return result;
3165
3165
  }
3166
3166
 
3167
+ function decorateResult(_a) {
3168
+ var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3169
+ if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3170
+ result.stack = [];
3171
+ if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3172
+ result.stack.push(stack);
3173
+ }
3174
+ if (result && info) {
3175
+ result.info = info;
3176
+ }
3177
+ if (result && typeof context === 'object' && Object.keys(context).length) {
3178
+ Object.assign(result, definedAttributes(context));
3179
+ }
3180
+ if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3181
+ Object.assign(result, __assign({}, SUCCESS));
3182
+ }
3183
+ return result !== null && result !== void 0 ? result : { success: true };
3184
+ }
3185
+
3186
+ function validateCategory(_a) {
3187
+ var category = _a.category;
3188
+ if (!isObject(category))
3189
+ return { error: INVALID_VALUES };
3190
+ var categoryDetails = getCategoryAgeDetails({ category: category });
3191
+ if (categoryDetails.error)
3192
+ return { error: categoryDetails };
3193
+ var ratingMax = category.ratingMax, ratingMin = category.ratingMin;
3194
+ if (ratingMax && !isNumeric(ratingMax))
3195
+ return decorateResult({
3196
+ result: { error: INVALID_VALUES },
3197
+ context: { ratingMax: ratingMax },
3198
+ });
3199
+ if (ratingMin && !isNumeric(ratingMin))
3200
+ return decorateResult({
3201
+ result: { error: INVALID_VALUES },
3202
+ context: { ratingMin: ratingMin },
3203
+ });
3204
+ return __assign({}, categoryDetails);
3205
+ }
3206
+
3167
3207
  function categoryCanContain(_a) {
3168
3208
  var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
3169
- var categoryDetails = getCategoryAgeDetails({ category: category });
3170
- var childCategoryDetails = getCategoryAgeDetails({
3209
+ var categoryDetails = validateCategory({ category: category });
3210
+ var childCategoryDetails = validateCategory({
3171
3211
  category: childCategory,
3172
3212
  });
3173
3213
  var invalidAgeMin = childCategoryDetails.ageMin &&
@@ -3188,17 +3228,40 @@ function categoryCanContain(_a) {
3188
3228
  categoryDetails.ageMinDate &&
3189
3229
  new Date(childCategoryDetails.ageMaxDate) <
3190
3230
  new Date(categoryDetails.ageMinDate);
3191
- var valid = !invalidAgeMax &&
3192
- !invalidAgeMin &&
3231
+ var ratingComparison = category.ratingType &&
3232
+ childCategory.ratingType &&
3233
+ category.ratingType === childCategory.ratingType;
3234
+ var invalidRatingRange = ratingComparison &&
3235
+ ((category.ratingMin &&
3236
+ childCategory.ratingMin &&
3237
+ childCategory.ratingMin < category.ratingMin) ||
3238
+ (category.ratingMax &&
3239
+ childCategory.ratingMax &&
3240
+ childCategory.ratingMax > category.ratingMax) ||
3241
+ (category.ratingMin &&
3242
+ childCategory.ratingMax &&
3243
+ childCategory.ratingMax < category.ratingMin) ||
3244
+ (category.ratingMax &&
3245
+ childCategory.ratingMin &&
3246
+ childCategory.ratingMin > category.ratingMax));
3247
+ var invalidBallType = category.ballType &&
3248
+ childCategory.ballType &&
3249
+ category.ballType !== childCategory.ballType;
3250
+ var valid = !invalidRatingRange &&
3193
3251
  !invalidAgeMinDate &&
3194
- !invalidAgeMaxDate;
3252
+ !invalidAgeMaxDate &&
3253
+ !invalidBallType &&
3254
+ !invalidAgeMax &&
3255
+ !invalidAgeMin;
3195
3256
  var ignoreFalse = true;
3196
3257
  var result = definedAttributes({
3197
- valid: valid,
3198
- invalidAgeMax: invalidAgeMax,
3199
- invalidAgeMin: invalidAgeMin,
3258
+ invalidRatingRange: invalidRatingRange,
3200
3259
  invalidAgeMinDate: invalidAgeMinDate,
3201
3260
  invalidAgeMaxDate: invalidAgeMaxDate,
3261
+ invalidBallType: invalidBallType,
3262
+ invalidAgeMax: invalidAgeMax,
3263
+ invalidAgeMin: invalidAgeMin,
3264
+ valid: valid,
3202
3265
  }, ignoreFalse);
3203
3266
  if (withDetails) {
3204
3267
  Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
@@ -3210,25 +3273,6 @@ function mustBeAnArray(value) {
3210
3273
  return "".concat(value, " must be an array");
3211
3274
  }
3212
3275
 
3213
- function decorateResult(_a) {
3214
- var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3215
- if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3216
- result.stack = [];
3217
- if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3218
- result.stack.push(stack);
3219
- }
3220
- if (result && info) {
3221
- result.info = info;
3222
- }
3223
- if (result && typeof context === 'object' && Object.keys(context).length) {
3224
- Object.assign(result, definedAttributes(context));
3225
- }
3226
- if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3227
- Object.assign(result, __assign({}, SUCCESS));
3228
- }
3229
- return result !== null && result !== void 0 ? result : { success: true };
3230
- }
3231
-
3232
3276
  var DrawTypeEnum;
3233
3277
  (function (DrawTypeEnum) {
3234
3278
  DrawTypeEnum["AdHoc"] = "AD_HOC";
@@ -3930,8 +3974,8 @@ function validateCollectionDefinition(_a) {
3930
3974
  referenceGender !== gender) {
3931
3975
  errors.push("Invalid gender: ".concat(gender));
3932
3976
  return decorateResult({
3977
+ result: { error: INVALID_GENDER, errors: errors },
3933
3978
  context: { referenceGender: referenceGender, gender: gender },
3934
- result: { error: INVALID_GENDER },
3935
3979
  stack: stack,
3936
3980
  });
3937
3981
  }
@@ -5359,142 +5403,6 @@ function tallyParticipantResults(_a) {
5359
5403
  return result;
5360
5404
  }
5361
5405
 
5362
- function evaluateCollectionResult(_a) {
5363
- var collectionDefinition = _a.collectionDefinition, groupValueNumbers = _a.groupValueNumbers, groupValueGroups = _a.groupValueGroups, sideTieValues = _a.sideTieValues, tieMatchUps = _a.tieMatchUps;
5364
- var collectionMatchUps = tieMatchUps.filter(function (matchUp) { return matchUp.collectionId === collectionDefinition.collectionId; });
5365
- // keep track of the values derived from matchUps
5366
- var sideMatchUpValues = [0, 0];
5367
- // will be equivalent to sideMatchUpValues unless there is a collectionValue,
5368
- // in which case the sideMatchUpValues are used in comparision with winCriteria
5369
- var sideCollectionValues = [0, 0];
5370
- var allCollectionMatchUpsCompleted = collectionMatchUps.every(function (matchUp) {
5371
- return completedMatchUpStatuses.includes(matchUp.matchUpStatus);
5372
- });
5373
- var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, matchUpValue = collectionDefinition.matchUpValue, winCriteria = collectionDefinition.winCriteria, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
5374
- var belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
5375
- var sideWins = [0, 0];
5376
- collectionMatchUps.forEach(function (matchUp) {
5377
- if (matchUp.winningSide)
5378
- sideWins[matchUp.winningSide - 1] += 1;
5379
- });
5380
- if (isConvertableInteger(matchUpValue)) {
5381
- // if tiebreak set count as set value and game value
5382
- collectionMatchUps.forEach(function (matchUp) {
5383
- if (matchUp.winningSide) {
5384
- sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
5385
- }
5386
- });
5387
- }
5388
- else if (isConvertableInteger(setValue)) {
5389
- collectionMatchUps.forEach(function (matchUp) {
5390
- var _a, _b;
5391
- (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
5392
- if (set.winningSide)
5393
- sideMatchUpValues[set.winningSide - 1] += setValue;
5394
- });
5395
- });
5396
- }
5397
- else if (isConvertableInteger(scoreValue)) {
5398
- collectionMatchUps.forEach(function (matchUp) {
5399
- var _a, _b;
5400
- (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
5401
- var _a = set.side1TiebreakScore, side1TiebreakScore = _a === void 0 ? 0 : _a, _b = set.side2TiebreakScore, side2TiebreakScore = _b === void 0 ? 0 : _b, _c = set.side1Score, side1Score = _c === void 0 ? 0 : _c, _d = set.side2Score, side2Score = _d === void 0 ? 0 : _d;
5402
- if (matchUp.matchUpStatus === COMPLETED$1 ||
5403
- matchUp.winningSide ||
5404
- set.winningSide) {
5405
- if (side1Score || side2Score) {
5406
- sideMatchUpValues[0] += side1Score;
5407
- sideMatchUpValues[1] += side2Score;
5408
- }
5409
- else if ((side1TiebreakScore || side2TiebreakScore) &&
5410
- set.winningSide) {
5411
- sideMatchUpValues[set.winningSide - 1] += 1;
5412
- }
5413
- }
5414
- });
5415
- });
5416
- }
5417
- else if (Array.isArray(collectionValueProfiles)) {
5418
- // this must come last because it will be true for []
5419
- collectionMatchUps.forEach(function (matchUp) {
5420
- if (matchUp.winningSide) {
5421
- var collectionPosition = matchUp.collectionPosition;
5422
- var matchUpValue_1 = getCollectionPositionValue({
5423
- collectionDefinition: collectionDefinition,
5424
- collectionPosition: collectionPosition,
5425
- });
5426
- if (isConvertableInteger(matchUpValue_1)) {
5427
- sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue_1;
5428
- }
5429
- }
5430
- });
5431
- }
5432
- // processed separately so that setValue, scoreValue and collecitonValueProfile can be used in conjunction with collectionValue
5433
- if (isConvertableInteger(collectionValue)) {
5434
- var collectionWinningSide = void 0;
5435
- if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.aggregateValue) {
5436
- if (allCollectionMatchUpsCompleted) {
5437
- if (isConvertableInteger(matchUpValue || setValue || scoreValue) &&
5438
- sideMatchUpValues[0] !== sideMatchUpValues[1]) {
5439
- collectionWinningSide =
5440
- sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
5441
- }
5442
- else if (sideWins[0] !== sideWins[1]) {
5443
- collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
5444
- }
5445
- }
5446
- }
5447
- else if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.valueGoal) {
5448
- collectionWinningSide = sideMatchUpValues.reduce(function (winningSide, side, i) {
5449
- return side >= winCriteria.valueGoal ? i + 1 : winningSide;
5450
- }, 0);
5451
- }
5452
- else {
5453
- var winGoal_1 = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
5454
- collectionWinningSide = sideWins.reduce(function (winningSide, side, i) {
5455
- return side >= winGoal_1 ? i + 1 : winningSide;
5456
- }, 0);
5457
- }
5458
- if (collectionWinningSide) {
5459
- if (belongsToValueGroup) {
5460
- groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
5461
- }
5462
- else {
5463
- sideCollectionValues[collectionWinningSide - 1] += collectionValue;
5464
- }
5465
- }
5466
- }
5467
- else {
5468
- if (belongsToValueGroup) {
5469
- groupValueGroups[collectionGroupNumber].values[0] +=
5470
- sideMatchUpValues[0] || 0;
5471
- groupValueGroups[collectionGroupNumber].values[1] +=
5472
- sideMatchUpValues[1] || 0;
5473
- }
5474
- else {
5475
- sideCollectionValues = sideMatchUpValues;
5476
- }
5477
- }
5478
- if (!belongsToValueGroup) {
5479
- sideCollectionValues.forEach(function (sideCollectionValue, i) { return (sideTieValues[i] += sideCollectionValue || 0); });
5480
- }
5481
- else {
5482
- groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
5483
- groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
5484
- groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted =
5485
- groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted &&
5486
- allCollectionMatchUpsCompleted;
5487
- groupValueGroups[collectionGroupNumber].matchUpsCount +=
5488
- collectionMatchUps.length;
5489
- }
5490
- }
5491
- function getCollectionPositionValue(_a) {
5492
- var collectionDefinition = _a.collectionDefinition, collectionPosition = _a.collectionPosition;
5493
- var collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
5494
- var profile = collectionValueProfiles === null || collectionValueProfiles === void 0 ? void 0 : collectionValueProfiles.find(function (profile) { return profile.collectionPosition === collectionPosition; });
5495
- return profile === null || profile === void 0 ? void 0 : profile.matchUpValue;
5496
- }
5497
-
5498
5406
  var APPLIED_POLICIES = 'appliedPolicies';
5499
5407
  var AUDIT_POSITION_ACTIONS = 'positionActions';
5500
5408
  var CONTEXT = 'context';
@@ -10007,11 +9915,13 @@ function getAllStructureMatchUps(_a) {
10007
9915
  /*
10008
9916
  public version of findMatchUp
10009
9917
  */
10010
- function publicFindMatchUp$1(params) {
9918
+ function publicFindDrawMatchUp(params) {
10011
9919
  Object.assign(params, { inContext: true });
10012
- return { matchUp: makeDeepCopy(findMatchUp$1(params).matchUp, false, true) };
9920
+ return {
9921
+ matchUp: makeDeepCopy(findDrawMatchUp(params).matchUp, false, true),
9922
+ };
10013
9923
  }
10014
- function findMatchUp$1(_a) {
9924
+ function findDrawMatchUp(_a) {
10015
9925
  var e_1, _b;
10016
9926
  var tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, contextContent = _a.contextContent, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, matchUpsMap = _a.matchUpsMap, matchUpId = _a.matchUpId, inContext = _a.inContext, context = _a.context, event = _a.event;
10017
9927
  if (!drawDefinition)
@@ -10053,6 +9963,142 @@ function findMatchUp$1(_a) {
10053
9963
  return { error: MATCHUP_NOT_FOUND };
10054
9964
  }
10055
9965
 
9966
+ function evaluateCollectionResult(_a) {
9967
+ var collectionDefinition = _a.collectionDefinition, groupValueNumbers = _a.groupValueNumbers, groupValueGroups = _a.groupValueGroups, sideTieValues = _a.sideTieValues, tieMatchUps = _a.tieMatchUps;
9968
+ var collectionMatchUps = tieMatchUps.filter(function (matchUp) { return matchUp.collectionId === collectionDefinition.collectionId; });
9969
+ // keep track of the values derived from matchUps
9970
+ var sideMatchUpValues = [0, 0];
9971
+ // will be equivalent to sideMatchUpValues unless there is a collectionValue,
9972
+ // in which case the sideMatchUpValues are used in comparision with winCriteria
9973
+ var sideCollectionValues = [0, 0];
9974
+ var allCollectionMatchUpsCompleted = collectionMatchUps.every(function (matchUp) {
9975
+ return completedMatchUpStatuses.includes(matchUp.matchUpStatus);
9976
+ });
9977
+ var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, matchUpValue = collectionDefinition.matchUpValue, winCriteria = collectionDefinition.winCriteria, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
9978
+ var belongsToValueGroup = collectionGroupNumber && groupValueNumbers.includes(collectionGroupNumber);
9979
+ var sideWins = [0, 0];
9980
+ collectionMatchUps.forEach(function (matchUp) {
9981
+ if (matchUp.winningSide)
9982
+ sideWins[matchUp.winningSide - 1] += 1;
9983
+ });
9984
+ if (isConvertableInteger(matchUpValue)) {
9985
+ // if tiebreak set count as set value and game value
9986
+ collectionMatchUps.forEach(function (matchUp) {
9987
+ if (matchUp.winningSide) {
9988
+ sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue;
9989
+ }
9990
+ });
9991
+ }
9992
+ else if (isConvertableInteger(setValue)) {
9993
+ collectionMatchUps.forEach(function (matchUp) {
9994
+ var _a, _b;
9995
+ (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
9996
+ if (set.winningSide)
9997
+ sideMatchUpValues[set.winningSide - 1] += setValue;
9998
+ });
9999
+ });
10000
+ }
10001
+ else if (isConvertableInteger(scoreValue)) {
10002
+ collectionMatchUps.forEach(function (matchUp) {
10003
+ var _a, _b;
10004
+ (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
10005
+ var _a = set.side1TiebreakScore, side1TiebreakScore = _a === void 0 ? 0 : _a, _b = set.side2TiebreakScore, side2TiebreakScore = _b === void 0 ? 0 : _b, _c = set.side1Score, side1Score = _c === void 0 ? 0 : _c, _d = set.side2Score, side2Score = _d === void 0 ? 0 : _d;
10006
+ if (matchUp.matchUpStatus === COMPLETED$1 ||
10007
+ matchUp.winningSide ||
10008
+ set.winningSide) {
10009
+ if (side1Score || side2Score) {
10010
+ sideMatchUpValues[0] += side1Score;
10011
+ sideMatchUpValues[1] += side2Score;
10012
+ }
10013
+ else if ((side1TiebreakScore || side2TiebreakScore) &&
10014
+ set.winningSide) {
10015
+ sideMatchUpValues[set.winningSide - 1] += 1;
10016
+ }
10017
+ }
10018
+ });
10019
+ });
10020
+ }
10021
+ else if (Array.isArray(collectionValueProfiles)) {
10022
+ // this must come last because it will be true for []
10023
+ collectionMatchUps.forEach(function (matchUp) {
10024
+ if (matchUp.winningSide) {
10025
+ var collectionPosition = matchUp.collectionPosition;
10026
+ var matchUpValue_1 = getCollectionPositionValue({
10027
+ collectionDefinition: collectionDefinition,
10028
+ collectionPosition: collectionPosition,
10029
+ });
10030
+ if (isConvertableInteger(matchUpValue_1)) {
10031
+ sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue_1;
10032
+ }
10033
+ }
10034
+ });
10035
+ }
10036
+ // processed separately so that setValue, scoreValue and collecitonValueProfile can be used in conjunction with collectionValue
10037
+ if (isConvertableInteger(collectionValue)) {
10038
+ var collectionWinningSide = void 0;
10039
+ if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.aggregateValue) {
10040
+ if (allCollectionMatchUpsCompleted) {
10041
+ if (isConvertableInteger(matchUpValue || setValue || scoreValue) &&
10042
+ sideMatchUpValues[0] !== sideMatchUpValues[1]) {
10043
+ collectionWinningSide =
10044
+ sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
10045
+ }
10046
+ else if (sideWins[0] !== sideWins[1]) {
10047
+ collectionWinningSide = sideWins[0] > sideWins[1] ? 1 : 2;
10048
+ }
10049
+ }
10050
+ }
10051
+ else if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.valueGoal) {
10052
+ collectionWinningSide = sideMatchUpValues.reduce(function (winningSide, side, i) {
10053
+ return side >= winCriteria.valueGoal ? i + 1 : winningSide;
10054
+ }, 0);
10055
+ }
10056
+ else {
10057
+ var winGoal_1 = Math.floor(collectionDefinition.matchUpCount / 2) + 1;
10058
+ collectionWinningSide = sideWins.reduce(function (winningSide, side, i) {
10059
+ return side >= winGoal_1 ? i + 1 : winningSide;
10060
+ }, 0);
10061
+ }
10062
+ if (collectionWinningSide) {
10063
+ if (belongsToValueGroup) {
10064
+ groupValueGroups[collectionGroupNumber].values[collectionWinningSide - 1] += collectionValue;
10065
+ }
10066
+ else {
10067
+ sideCollectionValues[collectionWinningSide - 1] += collectionValue;
10068
+ }
10069
+ }
10070
+ }
10071
+ else {
10072
+ if (belongsToValueGroup) {
10073
+ groupValueGroups[collectionGroupNumber].values[0] +=
10074
+ sideMatchUpValues[0] || 0;
10075
+ groupValueGroups[collectionGroupNumber].values[1] +=
10076
+ sideMatchUpValues[1] || 0;
10077
+ }
10078
+ else {
10079
+ sideCollectionValues = sideMatchUpValues;
10080
+ }
10081
+ }
10082
+ if (!belongsToValueGroup) {
10083
+ sideCollectionValues.forEach(function (sideCollectionValue, i) { return (sideTieValues[i] += sideCollectionValue || 0); });
10084
+ }
10085
+ else {
10086
+ groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
10087
+ groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
10088
+ groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted =
10089
+ groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted &&
10090
+ allCollectionMatchUpsCompleted;
10091
+ groupValueGroups[collectionGroupNumber].matchUpsCount +=
10092
+ collectionMatchUps.length;
10093
+ }
10094
+ }
10095
+ function getCollectionPositionValue(_a) {
10096
+ var collectionDefinition = _a.collectionDefinition, collectionPosition = _a.collectionPosition;
10097
+ var collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
10098
+ var profile = collectionValueProfiles === null || collectionValueProfiles === void 0 ? void 0 : collectionValueProfiles.find(function (profile) { return profile.collectionPosition === collectionPosition; });
10099
+ return profile === null || profile === void 0 ? void 0 : profile.matchUpValue;
10100
+ }
10101
+
10056
10102
  function getGroupValueGroups(_a) {
10057
10103
  var _b = _a.collectionGroups, collectionGroups = _b === void 0 ? [] : _b;
10058
10104
  // set up to handle groupValue
@@ -10190,7 +10236,7 @@ function generateTieMatchUpScore(params) {
10190
10236
  ? matchUp
10191
10237
  : ((_d = matchUpsMap === null || matchUpsMap === void 0 ? void 0 : matchUpsMap.drawMatchUps) === null || _d === void 0 ? void 0 : _d[matchUpId]) ||
10192
10238
  (drawDefinition &&
10193
- ((_e = findMatchUp$1({
10239
+ ((_e = findDrawMatchUp({
10194
10240
  inContext: true,
10195
10241
  drawDefinition: drawDefinition,
10196
10242
  matchUpId: matchUpId,
@@ -10219,83 +10265,6 @@ function generateTieMatchUpScore(params) {
10219
10265
  };
10220
10266
  }
10221
10267
 
10222
- function copyTieFormat(tieFormat) {
10223
- if (!tieFormat)
10224
- return undefined;
10225
- return makeDeepCopy(tieFormat, false, true);
10226
- }
10227
-
10228
- function scoreHasValue(params) {
10229
- var _a, _b;
10230
- var matchUp = params === null || params === void 0 ? void 0 : params.matchUp;
10231
- var score = (params === null || params === void 0 ? void 0 : params.score) || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.score);
10232
- var firstSet = (_a = score === null || score === void 0 ? void 0 : score.sets) === null || _a === void 0 ? void 0 : _a[0];
10233
- var _c = firstSet || {}, side1Score = _c.side1Score, side2Score = _c.side2Score, side1TiebreakScore = _c.side1TiebreakScore, side2TiebreakScore = _c.side2TiebreakScore, side1PointScore = _c.side1PointScore, side2PointScore = _c.side2PointScore;
10234
- var firstSetScore = side1Score ||
10235
- side2Score ||
10236
- side1TiebreakScore ||
10237
- side2TiebreakScore ||
10238
- side1PointScore ||
10239
- side2PointScore;
10240
- var hasValue = ((_b = score === null || score === void 0 ? void 0 : score.sets) === null || _b === void 0 ? void 0 : _b.length) > 1 || firstSetScore;
10241
- return !!hasValue;
10242
- }
10243
-
10244
- function isDirectingMatchUpStatus(_a) {
10245
- var matchUpStatus = _a.matchUpStatus;
10246
- return directingMatchUpStatuses.includes(matchUpStatus);
10247
- }
10248
- function isActiveMatchUpStatus(_a) {
10249
- var matchUpStatus = _a.matchUpStatus;
10250
- return activeMatchUpStatuses.includes(matchUpStatus);
10251
- }
10252
- function isNonDirectingMatchUpStatus(_a) {
10253
- var matchUpStatus = _a.matchUpStatus;
10254
- return nonDirectingMatchUpStatuses.includes(matchUpStatus);
10255
- }
10256
-
10257
- function isActiveMatchUp(_a) {
10258
- var _b;
10259
- var matchUpStatus = _a.matchUpStatus, winningSide = _a.winningSide, tieMatchUps = _a.tieMatchUps, sides = _a.sides, score = _a.score;
10260
- var participantAssigned = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
10261
- var participantId = _a.participantId;
10262
- return participantId;
10263
- });
10264
- var activeTieMatchUps = (_b = tieMatchUps === null || tieMatchUps === void 0 ? void 0 : tieMatchUps.filter(isActiveMatchUp)) === null || _b === void 0 ? void 0 : _b.length;
10265
- var scoreExists = scoreHasValue({ score: score });
10266
- return (scoreExists ||
10267
- activeTieMatchUps ||
10268
- (winningSide && participantAssigned) || // if winningSide and no participant assigned => "produced" WALKOVER
10269
- // must exclude IN_PROGRESS as this is automatically set by updateTieMatchUpScore
10270
- // must exclude WALKOVER and DEFAULTED as "produced" scenarios do not imply a winningSide
10271
- (matchUpStatus &&
10272
- isActiveMatchUpStatus({ matchUpStatus: matchUpStatus }) &&
10273
- ![DEFAULTED, WALKOVER$2, IN_PROGRESS$1].includes(matchUpStatus)));
10274
- }
10275
-
10276
- function addNotes(params) {
10277
- var _a;
10278
- if (typeof params !== 'object')
10279
- return { error: MISSING_VALUE };
10280
- if (typeof params.element !== 'object')
10281
- return { error: INVALID_VALUES };
10282
- if (!params.notes)
10283
- return { error: MISSING_VALUE };
10284
- if (typeof params.notes !== 'string' && !((_a = params.notes) === null || _a === void 0 ? void 0 : _a.testing))
10285
- return { error: INVALID_VALUES };
10286
- Object.assign(params.element, { notes: params.notes });
10287
- return __assign({}, SUCCESS);
10288
- }
10289
- function removeNotes(params) {
10290
- if (typeof params !== 'object')
10291
- return { error: MISSING_VALUE };
10292
- if (typeof params.element !== 'object')
10293
- return { error: INVALID_VALUES };
10294
- if (params.element.notes)
10295
- delete params.element.notes;
10296
- return __assign({}, SUCCESS);
10297
- }
10298
-
10299
10268
  function drawUpdatedAt(drawDefinition, structureIds) {
10300
10269
  var _a;
10301
10270
  if (!drawDefinition)
@@ -10382,8 +10351,8 @@ function updateInContextMatchUp(_a) {
10382
10351
  return { error: MISSING_MATCHUP };
10383
10352
  }
10384
10353
  addNotice({
10385
- topic: UPDATE_INCONTEXT_MATCHUP,
10386
10354
  payload: { inContextMatchUp: inContextMatchUp, tournamentId: tournamentId },
10355
+ topic: UPDATE_INCONTEXT_MATCHUP,
10387
10356
  key: inContextMatchUp.matchUpId,
10388
10357
  });
10389
10358
  return __assign({}, SUCCESS);
@@ -10477,6 +10446,117 @@ function modifyPositionAssignmentsNotice(_a) {
10477
10446
  return __assign({}, SUCCESS);
10478
10447
  }
10479
10448
 
10449
+ function ensureSideLineUps(_a) {
10450
+ var _b, _c, _d;
10451
+ var inContextDualMatchUp = _a.inContextDualMatchUp, drawDefinition = _a.drawDefinition, tournamentId = _a.tournamentId, dualMatchUp = _a.dualMatchUp, eventId = _a.eventId;
10452
+ if (dualMatchUp && !((_b = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _b === void 0 ? void 0 : _b.length)) {
10453
+ if (!inContextDualMatchUp) {
10454
+ inContextDualMatchUp = (_c = findDrawMatchUp({
10455
+ matchUpId: dualMatchUp.matchUpId,
10456
+ inContext: true,
10457
+ drawDefinition: drawDefinition,
10458
+ })) === null || _c === void 0 ? void 0 : _c.matchUp;
10459
+ }
10460
+ var extension = findExtension$2({
10461
+ element: drawDefinition,
10462
+ name: LINEUPS,
10463
+ }).extension;
10464
+ var lineUps_1 = makeDeepCopy((extension === null || extension === void 0 ? void 0 : extension.value) || {}, false, true);
10465
+ var extractSideDetail_1 = function (_a) {
10466
+ var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
10467
+ return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
10468
+ };
10469
+ dualMatchUp.sides = (_d = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _d === void 0 ? void 0 : _d.map(function (side) {
10470
+ var participantId = side.participantId;
10471
+ return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps_1[participantId]) || [] });
10472
+ });
10473
+ modifyMatchUpNotice({
10474
+ context: 'ensureSidLineUps',
10475
+ matchUp: dualMatchUp,
10476
+ drawDefinition: drawDefinition,
10477
+ tournamentId: tournamentId,
10478
+ eventId: eventId,
10479
+ });
10480
+ }
10481
+ }
10482
+
10483
+ function copyTieFormat(tieFormat) {
10484
+ if (!tieFormat)
10485
+ return undefined;
10486
+ return makeDeepCopy(tieFormat, false, true);
10487
+ }
10488
+
10489
+ function scoreHasValue(params) {
10490
+ var _a, _b;
10491
+ var matchUp = params === null || params === void 0 ? void 0 : params.matchUp;
10492
+ var score = (params === null || params === void 0 ? void 0 : params.score) || (matchUp === null || matchUp === void 0 ? void 0 : matchUp.score);
10493
+ var firstSet = (_a = score === null || score === void 0 ? void 0 : score.sets) === null || _a === void 0 ? void 0 : _a[0];
10494
+ var _c = firstSet || {}, side1Score = _c.side1Score, side2Score = _c.side2Score, side1TiebreakScore = _c.side1TiebreakScore, side2TiebreakScore = _c.side2TiebreakScore, side1PointScore = _c.side1PointScore, side2PointScore = _c.side2PointScore;
10495
+ var firstSetScore = side1Score ||
10496
+ side2Score ||
10497
+ side1TiebreakScore ||
10498
+ side2TiebreakScore ||
10499
+ side1PointScore ||
10500
+ side2PointScore;
10501
+ var hasValue = ((_b = score === null || score === void 0 ? void 0 : score.sets) === null || _b === void 0 ? void 0 : _b.length) > 1 || firstSetScore;
10502
+ return !!hasValue;
10503
+ }
10504
+
10505
+ function isDirectingMatchUpStatus(_a) {
10506
+ var matchUpStatus = _a.matchUpStatus;
10507
+ return directingMatchUpStatuses.includes(matchUpStatus);
10508
+ }
10509
+ function isActiveMatchUpStatus(_a) {
10510
+ var matchUpStatus = _a.matchUpStatus;
10511
+ return activeMatchUpStatuses.includes(matchUpStatus);
10512
+ }
10513
+ function isNonDirectingMatchUpStatus(_a) {
10514
+ var matchUpStatus = _a.matchUpStatus;
10515
+ return nonDirectingMatchUpStatuses.includes(matchUpStatus);
10516
+ }
10517
+
10518
+ function isActiveMatchUp(_a) {
10519
+ var _b;
10520
+ var matchUpStatus = _a.matchUpStatus, winningSide = _a.winningSide, tieMatchUps = _a.tieMatchUps, sides = _a.sides, score = _a.score;
10521
+ var participantAssigned = sides === null || sides === void 0 ? void 0 : sides.find(function (_a) {
10522
+ var participantId = _a.participantId;
10523
+ return participantId;
10524
+ });
10525
+ var activeTieMatchUps = (_b = tieMatchUps === null || tieMatchUps === void 0 ? void 0 : tieMatchUps.filter(isActiveMatchUp)) === null || _b === void 0 ? void 0 : _b.length;
10526
+ var scoreExists = scoreHasValue({ score: score });
10527
+ return (scoreExists ||
10528
+ activeTieMatchUps ||
10529
+ (winningSide && participantAssigned) || // if winningSide and no participant assigned => "produced" WALKOVER
10530
+ // must exclude IN_PROGRESS as this is automatically set by updateTieMatchUpScore
10531
+ // must exclude WALKOVER and DEFAULTED as "produced" scenarios do not imply a winningSide
10532
+ (matchUpStatus &&
10533
+ isActiveMatchUpStatus({ matchUpStatus: matchUpStatus }) &&
10534
+ ![DEFAULTED, WALKOVER$2, IN_PROGRESS$1].includes(matchUpStatus)));
10535
+ }
10536
+
10537
+ function addNotes(params) {
10538
+ var _a;
10539
+ if (typeof params !== 'object')
10540
+ return { error: MISSING_VALUE };
10541
+ if (typeof params.element !== 'object')
10542
+ return { error: INVALID_VALUES };
10543
+ if (!params.notes)
10544
+ return { error: MISSING_VALUE };
10545
+ if (typeof params.notes !== 'string' && !((_a = params.notes) === null || _a === void 0 ? void 0 : _a.testing))
10546
+ return { error: INVALID_VALUES };
10547
+ Object.assign(params.element, { notes: params.notes });
10548
+ return __assign({}, SUCCESS);
10549
+ }
10550
+ function removeNotes(params) {
10551
+ if (typeof params !== 'object')
10552
+ return { error: MISSING_VALUE };
10553
+ if (typeof params.element !== 'object')
10554
+ return { error: INVALID_VALUES };
10555
+ if (params.element.notes)
10556
+ delete params.element.notes;
10557
+ return __assign({}, SUCCESS);
10558
+ }
10559
+
10480
10560
  var hasParticipantId = function (o) { return o === null || o === void 0 ? void 0 : o.participantId; };
10481
10561
 
10482
10562
  function createSubOrderMap(_a) {
@@ -11433,7 +11513,7 @@ function modifyMatchUpScore(_a) {
11433
11513
  if (isDualMatchUp && drawDefinition) {
11434
11514
  if (matchUpId && matchUp.matchUpId !== matchUpId) {
11435
11515
  // the modification is to be applied to a tieMatchUp
11436
- var findResult = findMatchUp$1({
11516
+ var findResult = findDrawMatchUp({
11437
11517
  drawDefinition: drawDefinition,
11438
11518
  matchUpId: matchUpId,
11439
11519
  event: event,
@@ -11467,7 +11547,7 @@ function modifyMatchUpScore(_a) {
11467
11547
  if (removeWinningSide)
11468
11548
  matchUp.winningSide = undefined;
11469
11549
  if (!structure && drawDefinition) {
11470
- (structure = findMatchUp$1({
11550
+ (structure = findDrawMatchUp({
11471
11551
  drawDefinition: drawDefinition,
11472
11552
  matchUpId: matchUpId,
11473
11553
  event: event,
@@ -11606,7 +11686,7 @@ function modifyMatchUpScore(_a) {
11606
11686
  function updateTieMatchUpScore$1(_a) {
11607
11687
  var _b, _c;
11608
11688
  var tournamentRecord = _a.tournamentRecord, exitWhenNoValues = _a.exitWhenNoValues, drawDefinition = _a.drawDefinition, matchUpStatus = _a.matchUpStatus, removeScore = _a.removeScore, matchUpsMap = _a.matchUpsMap, matchUpId = _a.matchUpId, event = _a.event;
11609
- var result = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
11689
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
11610
11690
  if (result.error)
11611
11691
  return result;
11612
11692
  if (!result.matchUp)
@@ -11614,6 +11694,12 @@ function updateTieMatchUpScore$1(_a) {
11614
11694
  var matchUp = result.matchUp, structure = result.structure;
11615
11695
  if (!matchUp.tieMatchUps)
11616
11696
  return { error: INVALID_MATCHUP };
11697
+ ensureSideLineUps({
11698
+ tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
11699
+ eventId: event === null || event === void 0 ? void 0 : event.eventId,
11700
+ dualMatchUp: matchUp,
11701
+ drawDefinition: drawDefinition,
11702
+ });
11617
11703
  var extension = findExtension({
11618
11704
  name: DISABLE_AUTO_CALC,
11619
11705
  element: matchUp,
@@ -21744,7 +21830,7 @@ function addEventTimeItem(params) {
21744
21830
 
21745
21831
  function addMatchUpTimeItem(_a) {
21746
21832
  var removePriorValues = _a.removePriorValues, tournamentRecord = _a.tournamentRecord, duplicateValues = _a.duplicateValues, drawDefinition = _a.drawDefinition, disableNotice = _a.disableNotice, matchUpId = _a.matchUpId, timeItem = _a.timeItem, event = _a.event;
21747
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21833
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21748
21834
  if (!matchUp)
21749
21835
  return { error: MATCHUP_NOT_FOUND };
21750
21836
  var result = addTimeItem({
@@ -21766,7 +21852,7 @@ function addMatchUpTimeItem(_a) {
21766
21852
  }
21767
21853
  function resetMatchUpTimeItems(_a) {
21768
21854
  var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
21769
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21855
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
21770
21856
  if (!matchUp)
21771
21857
  return { error: MATCHUP_NOT_FOUND };
21772
21858
  matchUp.timeItems = [];
@@ -21788,7 +21874,7 @@ function allocateTeamMatchUpCourts$1(_a) {
21788
21874
  return { error: MISSING_TOURNAMENT_RECORD };
21789
21875
  if (!matchUpId)
21790
21876
  return { error: MISSING_MATCHUP_ID };
21791
- var result = findMatchUp$1({
21877
+ var result = findDrawMatchUp({
21792
21878
  drawDefinition: drawDefinition,
21793
21879
  matchUpId: matchUpId,
21794
21880
  });
@@ -21931,7 +22017,7 @@ function addMatchUpScheduledTime$2(params) {
21931
22017
  if (!validTimeValue(scheduledTime))
21932
22018
  return decorateResult({ result: { error: INVALID_TIME }, stack: stack });
21933
22019
  if (!matchUp) {
21934
- var result = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId });
22020
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
21935
22021
  if (result.error)
21936
22022
  return decorateResult({ result: result, stack: stack });
21937
22023
  matchUp = result.matchUp;
@@ -21982,7 +22068,7 @@ function addMatchUpTimeModifiers(_a) {
21982
22068
  stack: stack,
21983
22069
  });
21984
22070
  if (!matchUp) {
21985
- var result = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId });
22071
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
21986
22072
  if (result.error)
21987
22073
  return decorateResult({ result: result, stack: stack });
21988
22074
  matchUp = result.matchUp;
@@ -22047,7 +22133,7 @@ function addMatchUpScheduleItems$2(_a) {
22047
22133
  var stack = 'drawEngine.addMatchUpScheduleItems';
22048
22134
  var matchUp, warning;
22049
22135
  if (!drawMatchUps) {
22050
- var result = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
22136
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
22051
22137
  if (result.error)
22052
22138
  return result;
22053
22139
  matchUp = result.matchUp;
@@ -22313,7 +22399,7 @@ function addMatchUpStartTime$2(_a) {
22313
22399
  return { error: MISSING_MATCHUP_ID };
22314
22400
  if (!validTimeValue(startTime))
22315
22401
  return { error: INVALID_TIME };
22316
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22402
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22317
22403
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22318
22404
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22319
22405
  var earliestRelevantTimeValue = timeItems
@@ -22354,7 +22440,7 @@ function addMatchUpEndTime$2(_a) {
22354
22440
  return { error: MISSING_MATCHUP_ID };
22355
22441
  if (!validTimeValue(endTime))
22356
22442
  return { error: INVALID_TIME };
22357
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22443
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22358
22444
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22359
22445
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22360
22446
  var latestRelevantTimeValue = timeItems
@@ -22397,7 +22483,7 @@ function addMatchUpStopTime$2(_a) {
22397
22483
  return { error: MISSING_MATCHUP_ID };
22398
22484
  if (!validTimeValue(stopTime))
22399
22485
  return { error: INVALID_TIME };
22400
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22486
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22401
22487
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22402
22488
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22403
22489
  // can't add a STOP_TIME if the matchUp is not STARTED or RESUMED, or has START_TIME
@@ -22458,7 +22544,7 @@ function addMatchUpResumeTime$2(_a) {
22458
22544
  return { error: MISSING_MATCHUP_ID };
22459
22545
  if (!validTimeValue(resumeTime))
22460
22546
  return { error: INVALID_TIME };
22461
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22547
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
22462
22548
  var scheduledDate = scheduledMatchUpDate({ matchUp: matchUp }).scheduledDate;
22463
22549
  var timeItems = (_b = matchUp === null || matchUp === void 0 ? void 0 : matchUp.timeItems) !== null && _b !== void 0 ? _b : [];
22464
22550
  // can't add a RESUME_TIME if the matchUp is not STOPPED, or if it has ENDED
@@ -24293,8 +24379,8 @@ function updateSideLineUp(_a) {
24293
24379
  element: drawDefinition,
24294
24380
  name: LINEUPS,
24295
24381
  }).extension;
24296
- var value = (existingExtension === null || existingExtension === void 0 ? void 0 : existingExtension.value) || {};
24297
- var lineUp = value[teamParticipantId];
24382
+ var lineUps = (existingExtension === null || existingExtension === void 0 ? void 0 : existingExtension.value) || {};
24383
+ var lineUp = makeDeepCopy(lineUps[teamParticipantId], false, true);
24298
24384
  if (sideExists) {
24299
24385
  (_e = matchUp === null || matchUp === void 0 ? void 0 : matchUp.sides) === null || _e === void 0 ? void 0 : _e.forEach(function (side) {
24300
24386
  if (side.sideNumber === drawPositionSideNumber) {
@@ -24309,13 +24395,12 @@ function updateSideLineUp(_a) {
24309
24395
  return __assign(__assign({}, existingSide), { sideNumber: sideNumber });
24310
24396
  });
24311
24397
  var targetSide = matchUp.sides.find(function (side) { return side.sideNumber === drawPositionSideNumber; });
24312
- if (targetSide) {
24398
+ if (targetSide)
24313
24399
  targetSide.lineUp = lineUp;
24314
- }
24315
24400
  }
24316
24401
  modifyMatchUpNotice({
24317
24402
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
24318
- context: 'updateSidLineUps',
24403
+ context: 'updateSidLineUp',
24319
24404
  eventId: event === null || event === void 0 ? void 0 : event.eventId,
24320
24405
  drawDefinition: drawDefinition,
24321
24406
  matchUp: matchUp,
@@ -25290,13 +25375,15 @@ function removeLineUpSubstitutions(_a) {
25290
25375
  if (!Array.isArray(lineUp))
25291
25376
  return;
25292
25377
  var participantAssignments = {};
25293
- var permutations = unique(lineUp.flatMap(function (_a) {
25378
+ var permutations = unique(lineUp
25379
+ .flatMap(function (_a) {
25294
25380
  var collectionAssignments = _a.collectionAssignments;
25295
- return collectionAssignments.map(function (_a) {
25381
+ return collectionAssignments === null || collectionAssignments === void 0 ? void 0 : collectionAssignments.map(function (_a) {
25296
25382
  var collectionId = _a.collectionId, collectionPosition = _a.collectionPosition;
25297
25383
  return [collectionId, collectionPosition].join('|');
25298
25384
  });
25299
- }));
25385
+ })
25386
+ .filter(Boolean));
25300
25387
  permutations.forEach(function (permutation) {
25301
25388
  var _a = __read(permutation.split('|'), 2), collectionId = _a[0], position = _a[1];
25302
25389
  var collectionPosition = parseInt(position);
@@ -27925,7 +28012,7 @@ function setMatchUpStatus$2(params) {
27925
28012
  matchUp: matchUp,
27926
28013
  });
27927
28014
  if (matchUpTieId) {
27928
- var dualMatchUp = findMatchUp$1({
28015
+ var dualMatchUp = findDrawMatchUp({
27929
28016
  matchUpId: matchUpTieId,
27930
28017
  inContext: true,
27931
28018
  drawDefinition: drawDefinition,
@@ -28089,7 +28176,7 @@ function setMatchUpFormat$1(params) {
28089
28176
  return { error: UNRECOGNIZED_MATCHUP_FORMAT };
28090
28177
  var stack = 'setMatchUpFormat';
28091
28178
  if (matchUpId) {
28092
- var result = findMatchUp$1({
28179
+ var result = findDrawMatchUp({
28093
28180
  drawDefinition: drawDefinition,
28094
28181
  matchUpId: matchUpId,
28095
28182
  event: event,
@@ -30722,7 +30809,7 @@ function getTieFormat$1(_a) {
30722
30809
  else if (matchUpId) {
30723
30810
  // if matchUpId is present, structure and drawDefinition are always required
30724
30811
  if (drawDefinition && (!matchUp || !structure)) {
30725
- var result = findMatchUp$1({
30812
+ var result = findDrawMatchUp({
30726
30813
  drawDefinition: drawDefinition,
30727
30814
  matchUpId: matchUpId,
30728
30815
  });
@@ -31460,7 +31547,7 @@ function orderCollectionDefinitions$1(_a) {
31460
31547
  }
31461
31548
  else if (matchUpId) {
31462
31549
  var result = drawDefinition &&
31463
- findMatchUp$1({
31550
+ findDrawMatchUp({
31464
31551
  drawDefinition: drawDefinition,
31465
31552
  matchUpId: matchUpId,
31466
31553
  });
@@ -31765,7 +31852,7 @@ function removeCollectionDefinition$1(_a) {
31765
31852
  });
31766
31853
  if (result_1.error)
31767
31854
  return result_1;
31768
- result_1 = findMatchUp$1({
31855
+ result_1 = findDrawMatchUp({
31769
31856
  drawDefinition: drawDefinition,
31770
31857
  matchUpId: matchUpId,
31771
31858
  });
@@ -31898,23 +31985,22 @@ function removeCollectionDefinition(params) {
31898
31985
 
31899
31986
  function addCollectionDefinition$1(_a) {
31900
31987
  var e_1, _b, e_2, _c, _d, e_3, _e;
31901
- var _f, _g, _h, _j, _k, _l, _m, _o;
31902
- var _p = _a.updateInProgressMatchUps, updateInProgressMatchUps = _p === void 0 ? true : _p, collectionDefinition = _a.collectionDefinition, referenceCategory = _a.referenceCategory, tournamentRecord = _a.tournamentRecord, enforceCategory = _a.enforceCategory, 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;
31988
+ var _f, _g, _h, _j, _k, _l, _m, _o, _p;
31989
+ var _q = _a.updateInProgressMatchUps, updateInProgressMatchUps = _q === void 0 ? true : _q, collectionDefinition = _a.collectionDefinition, referenceCategory = _a.referenceCategory, tournamentRecord = _a.tournamentRecord, policyDefinitions = _a.policyDefinitions, enforceCategory = _a.enforceCategory, 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;
31903
31990
  var stack = 'addCollectionDefinition';
31904
31991
  var appliedPolicies = (_f = getAppliedPolicies({
31905
31992
  tournamentRecord: tournamentRecord,
31906
31993
  drawDefinition: drawDefinition,
31907
31994
  event: event,
31908
31995
  }).appliedPolicies) !== null && _f !== void 0 ? _f : {};
31909
- var matchUpActionsPolicy = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS];
31996
+ var matchUpActionsPolicy = (_g = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _g !== void 0 ? _g : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS];
31910
31997
  enforceCategory =
31911
- enforceCategory !== null && enforceCategory !== void 0 ? enforceCategory : (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _g === void 0 ? void 0 : _g.enforceCategory;
31912
- enforceGender =
31913
- enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceGender;
31998
+ enforceCategory !== null && enforceCategory !== void 0 ? enforceCategory : (_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceCategory;
31999
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_j = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _j === void 0 ? void 0 : _j.enforceGender) !==
32000
+ false;
31914
32001
  var checkCategory = !!((referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category) &&
31915
32002
  enforceCategory !== false);
31916
- var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) &&
31917
- enforceGender !== false);
32003
+ var checkGender = !!((referenceGender !== null && referenceGender !== void 0 ? referenceGender : event === null || event === void 0 ? void 0 : event.gender) && genderEnforced);
31918
32004
  var validationResult = validateCollectionDefinition({
31919
32005
  referenceCategory: referenceCategory !== null && referenceCategory !== void 0 ? referenceCategory : event === null || event === void 0 ? void 0 : event.category,
31920
32006
  collectionDefinition: collectionDefinition,
@@ -31939,7 +32025,7 @@ function addCollectionDefinition$1(_a) {
31939
32025
  return decorateResult({ result: { error: result.error }, stack: stack });
31940
32026
  var structure = result === null || result === void 0 ? void 0 : result.structure;
31941
32027
  matchUp = matchUp !== null && matchUp !== void 0 ? matchUp : result === null || result === void 0 ? void 0 : result.matchUp;
31942
- var existingTieFormat = (_j = matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) !== null && _j !== void 0 ? _j : result === null || result === void 0 ? void 0 : result.tieFormat;
32028
+ var existingTieFormat = (_k = matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieFormat) !== null && _k !== void 0 ? _k : result === null || result === void 0 ? void 0 : result.tieFormat;
31943
32029
  var tieFormat = copyTieFormat(existingTieFormat);
31944
32030
  result = validateTieFormat({ tieFormat: tieFormat });
31945
32031
  if (result === null || result === void 0 ? void 0 : result.error) {
@@ -31967,7 +32053,7 @@ function addCollectionDefinition$1(_a) {
31967
32053
  });
31968
32054
  // calculate new winCriteria for tieFormat
31969
32055
  // if existing winCriteria is aggregateValue, retain
31970
- var _q = calculateWinCriteria(tieFormat), aggregateValue = _q.aggregateValue, valueGoal = _q.valueGoal;
32056
+ var _r = calculateWinCriteria(tieFormat), aggregateValue = _r.aggregateValue, valueGoal = _r.valueGoal;
31971
32057
  tieFormat.winCriteria = definedAttributes({ aggregateValue: aggregateValue, valueGoal: valueGoal });
31972
32058
  // if valueGoal has changed, force renaming of the tieFormat
31973
32059
  var originalValueGoal = existingTieFormat === null || existingTieFormat === void 0 ? void 0 : existingTieFormat.winCriteria.valueGoal;
@@ -31993,13 +32079,13 @@ function addCollectionDefinition$1(_a) {
31993
32079
  event.tieFormat = prunedTieFormat;
31994
32080
  try {
31995
32081
  // all team matchUps in the event which do not have tieFormats and where draws/strucures do not have tieFormats should have matchUps added
31996
- for (var _r = __values((_k = event.drawDefinitions) !== null && _k !== void 0 ? _k : []), _s = _r.next(); !_s.done; _s = _r.next()) {
31997
- var drawDefinition_1 = _s.value;
32082
+ for (var _s = __values((_l = event.drawDefinitions) !== null && _l !== void 0 ? _l : []), _t = _s.next(); !_t.done; _t = _s.next()) {
32083
+ var drawDefinition_1 = _t.value;
31998
32084
  if (drawDefinition_1.tieFormat)
31999
32085
  continue;
32000
32086
  try {
32001
- for (var _t = (e_2 = void 0, __values((_l = drawDefinition_1.structures) !== null && _l !== void 0 ? _l : [])), _u = _t.next(); !_u.done; _u = _t.next()) {
32002
- var structure_1 = _u.value;
32087
+ for (var _u = (e_2 = void 0, __values((_m = drawDefinition_1.structures) !== null && _m !== void 0 ? _m : [])), _v = _u.next(); !_v.done; _v = _u.next()) {
32088
+ var structure_1 = _v.value;
32003
32089
  if (structure_1.tieFormat)
32004
32090
  continue;
32005
32091
  var result_1 = updateStructureMatchUps({
@@ -32016,7 +32102,7 @@ function addCollectionDefinition$1(_a) {
32016
32102
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
32017
32103
  finally {
32018
32104
  try {
32019
- if (_u && !_u.done && (_c = _t.return)) _c.call(_t);
32105
+ if (_v && !_v.done && (_c = _u.return)) _c.call(_u);
32020
32106
  }
32021
32107
  finally { if (e_2) throw e_2.error; }
32022
32108
  }
@@ -32025,7 +32111,7 @@ function addCollectionDefinition$1(_a) {
32025
32111
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
32026
32112
  finally {
32027
32113
  try {
32028
- if (_s && !_s.done && (_b = _r.return)) _b.call(_r);
32114
+ if (_t && !_t.done && (_b = _s.return)) _b.call(_s);
32029
32115
  }
32030
32116
  finally { if (e_1) throw e_1.error; }
32031
32117
  }
@@ -32088,8 +32174,8 @@ function addCollectionDefinition$1(_a) {
32088
32174
  // all team matchUps in the drawDefinition which do not have tieFormats and where strucures do not have tieFormats should have matchUps added
32089
32175
  drawDefinition.tieFormat = prunedTieFormat;
32090
32176
  try {
32091
- for (var _v = __values((_m = drawDefinition.structures) !== null && _m !== void 0 ? _m : []), _w = _v.next(); !_w.done; _w = _v.next()) {
32092
- var structure_2 = _w.value;
32177
+ for (var _w = __values((_o = drawDefinition.structures) !== null && _o !== void 0 ? _o : []), _x = _w.next(); !_x.done; _x = _w.next()) {
32178
+ var structure_2 = _x.value;
32093
32179
  var result_3 = updateStructureMatchUps({
32094
32180
  updateInProgressMatchUps: updateInProgressMatchUps,
32095
32181
  collectionDefinition: collectionDefinition,
@@ -32104,7 +32190,7 @@ function addCollectionDefinition$1(_a) {
32104
32190
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
32105
32191
  finally {
32106
32192
  try {
32107
- if (_w && !_w.done && (_e = _v.return)) _e.call(_v);
32193
+ if (_x && !_x.done && (_e = _w.return)) _e.call(_w);
32108
32194
  }
32109
32195
  finally { if (e_3) throw e_3.error; }
32110
32196
  }
@@ -32120,7 +32206,7 @@ function addCollectionDefinition$1(_a) {
32120
32206
  else {
32121
32207
  return { error: MISSING_DRAW_DEFINITION };
32122
32208
  }
32123
- if ((_o = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _o === void 0 ? void 0 : _o[TIE_FORMAT_MODIFICATIONS]) {
32209
+ if ((_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.audit) === null || _p === void 0 ? void 0 : _p[TIE_FORMAT_MODIFICATIONS]) {
32124
32210
  var auditData = definedAttributes({
32125
32211
  drawId: drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawId,
32126
32212
  collectionDefinition: collectionDefinition,
@@ -32705,7 +32791,7 @@ function findMatchUp(_a) {
32705
32791
  contextProfile: contextProfile,
32706
32792
  inContext: inContext,
32707
32793
  }).participants, tournamentParticipants = _g === void 0 ? [] : _g;
32708
- var _h = findMatchUp$1({
32794
+ var _h = findDrawMatchUp({
32709
32795
  context: inContext ? additionalContext : undefined,
32710
32796
  tournamentParticipants: tournamentParticipants,
32711
32797
  afterRecoveryTimes: afterRecoveryTimes,
@@ -36813,7 +36899,7 @@ function checkInParticipant$1(_a) {
36813
36899
  tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
36814
36900
  if (tournamentParticipants === null || tournamentParticipants === void 0 ? void 0 : tournamentParticipants.length) {
36815
36901
  if (!matchUp && drawDefinition) {
36816
- var result_1 = findMatchUp$1({
36902
+ var result_1 = findDrawMatchUp({
36817
36903
  tournamentParticipants: tournamentParticipants,
36818
36904
  inContext: true,
36819
36905
  drawDefinition: drawDefinition,
@@ -36856,7 +36942,7 @@ function checkOutParticipant$1(_a) {
36856
36942
  tournamentParticipants =
36857
36943
  tournamentParticipants !== null && tournamentParticipants !== void 0 ? tournamentParticipants : tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
36858
36944
  if (!matchUp) {
36859
- var result = findMatchUp$1({
36945
+ var result = findDrawMatchUp({
36860
36946
  tournamentParticipants: tournamentParticipants,
36861
36947
  inContext: true,
36862
36948
  drawDefinition: drawDefinition,
@@ -36975,7 +37061,7 @@ function removeMatchUpCourtAssignment$1(params) {
36975
37061
  }), drawDefinition = _c.drawDefinition, event = _c.event;
36976
37062
  if (!drawDefinition)
36977
37063
  return { error: MISSING_DRAW_DEFINITION };
36978
- var result = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
37064
+ var result = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId });
36979
37065
  if (result.error)
36980
37066
  return result;
36981
37067
  if (((_a = result === null || result === void 0 ? void 0 : result.matchUp) === null || _a === void 0 ? void 0 : _a.matchUpType) === TEAM_MATCHUP) {
@@ -39174,7 +39260,7 @@ var matchUpActionConstants = {
39174
39260
  function matchUpActions$2(_a) {
39175
39261
  var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9;
39176
39262
  var _10 = _a.restrictAdHocRoundParticipants, restrictAdHocRoundParticipants = _10 === void 0 ? true : _10, // disallow the same participant being in the same round multiple times
39177
- specifiedPolicyDefinitions = _a.policyDefinitions, _11 = _a.tournamentParticipants, tournamentParticipants = _11 === void 0 ? [] : _11, inContextDrawMatchUps = _a.inContextDrawMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, participantId = _a.participantId, matchUpsMap = _a.matchUpsMap, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, event = _a.event;
39263
+ specifiedPolicyDefinitions = _a.policyDefinitions, _11 = _a.tournamentParticipants, tournamentParticipants = _11 === void 0 ? [] : _11, inContextDrawMatchUps = _a.inContextDrawMatchUps, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, enforceGender = _a.enforceGender, participantId = _a.participantId, matchUpsMap = _a.matchUpsMap, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, event = _a.event;
39178
39264
  if (!drawDefinition)
39179
39265
  return { error: MISSING_DRAW_DEFINITION };
39180
39266
  if (!matchUpId)
@@ -39186,7 +39272,7 @@ function matchUpActions$2(_a) {
39186
39272
  });
39187
39273
  var otherFlightEntries = (_b = specifiedPolicyDefinitions === null || specifiedPolicyDefinitions === void 0 ? void 0 : specifiedPolicyDefinitions[POLICY_TYPE_POSITION_ACTIONS]) === null || _b === void 0 ? void 0 : _b.otherFlightEntries;
39188
39274
  var drawId = drawDefinition.drawId;
39189
- var _12 = findMatchUp$1({
39275
+ var _12 = findDrawMatchUp({
39190
39276
  drawDefinition: drawDefinition,
39191
39277
  matchUpId: matchUpId,
39192
39278
  event: event,
@@ -39200,8 +39286,8 @@ function matchUpActions$2(_a) {
39200
39286
  event: event,
39201
39287
  }).appliedPolicies) !== null && _c !== void 0 ? _c : {};
39202
39288
  Object.assign(appliedPolicies, specifiedPolicyDefinitions !== null && specifiedPolicyDefinitions !== void 0 ? specifiedPolicyDefinitions : {});
39203
- var isAdHocMatchUp = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
39204
39289
  var matchUpActionsPolicy = (_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _d !== void 0 ? _d : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
39290
+ var isAdHocMatchUp = isAdHoc({ drawDefinition: drawDefinition, structure: structure });
39205
39291
  var enabledStructures = getEnabledStructures({
39206
39292
  actionType: MATCHUP_ACTION,
39207
39293
  appliedPolicies: appliedPolicies,
@@ -39440,9 +39526,9 @@ function matchUpActions$2(_a) {
39440
39526
  ((_v = inContextMatchUp.sides) === null || _v === void 0 ? void 0 : _v.filter(function (side) { return side.particiapntId; }).length) === 1 &&
39441
39527
  ((_x = (_w = firstFoundSide === null || firstFoundSide === void 0 ? void 0 : firstFoundSide.participant) === null || _w === void 0 ? void 0 : _w.person) === null || _x === void 0 ? void 0 : _x.sex);
39442
39528
  var matchUpType = inContextMatchUp.matchUpType;
39443
- var gender_1 = ((_y = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _y === void 0 ? void 0 : _y.enforceGender)
39444
- ? inContextMatchUp.gender
39445
- : undefined;
39529
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_y = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _y === void 0 ? void 0 : _y.enforceGender) !==
39530
+ false;
39531
+ var gender_1 = genderEnforced ? inContextMatchUp.gender : undefined;
39446
39532
  var allParticipants = (_z = inContextMatchUp.sides) === null || _z === void 0 ? void 0 : _z.flatMap(function (side) { var _a; return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipants) || side.participant; }).filter(Boolean);
39447
39533
  var allParticipantIds_1 = allParticipants === null || allParticipants === void 0 ? void 0 : allParticipants.map(getParticipantId);
39448
39534
  var existingParticipants = (_0 = inContextMatchUp.sides) === null || _0 === void 0 ? void 0 : _0.filter(function (side) { return !sideNumber || side.sideNumber === sideNumber; }).flatMap(function (side) { var _a; return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipants) || side.participant; }).filter(Boolean);
@@ -39611,7 +39697,7 @@ function getEventAlternateParticipantIds(_a) {
39611
39697
  }
39612
39698
 
39613
39699
  function matchUpActions$1(_a) {
39614
- var policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, participantId = _a.participantId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, drawId = _a.drawId, event = _a.event;
39700
+ var policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, enforceGender = _a.enforceGender, participantId = _a.participantId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, drawId = _a.drawId, event = _a.event;
39615
39701
  if (!tournamentRecord)
39616
39702
  return { error: MISSING_TOURNAMENT_RECORD };
39617
39703
  if (!drawId) {
@@ -39640,6 +39726,7 @@ function matchUpActions$1(_a) {
39640
39726
  tournamentParticipants: tournamentRecord.participants,
39641
39727
  policyDefinitions: policyDefinitions,
39642
39728
  drawDefinition: drawDefinition,
39729
+ enforceGender: enforceGender,
39643
39730
  participantId: participantId,
39644
39731
  sideNumber: sideNumber,
39645
39732
  matchUpId: matchUpId,
@@ -39652,7 +39739,7 @@ function matchUpActions$1(_a) {
39652
39739
  }
39653
39740
 
39654
39741
  function matchUpActions(params) {
39655
- var _a = params !== null && params !== void 0 ? params : {}, tournamentRecords = _a.tournamentRecords, participantId = _a.participantId, tournamentId = _a.tournamentId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, eventId = _a.eventId, drawId = _a.drawId;
39742
+ var _a = params !== null && params !== void 0 ? params : {}, tournamentRecords = _a.tournamentRecords, policyDefinitions = _a.policyDefinitions, enforceGender = _a.enforceGender, participantId = _a.participantId, tournamentId = _a.tournamentId, sideNumber = _a.sideNumber, matchUpId = _a.matchUpId, eventId = _a.eventId, drawId = _a.drawId;
39656
39743
  if (typeof tournamentRecords !== 'object' ||
39657
39744
  typeof tournamentId !== 'string' ||
39658
39745
  typeof matchUpId !== 'string' ||
@@ -39670,7 +39757,9 @@ function matchUpActions(params) {
39670
39757
  return result;
39671
39758
  return matchUpActions$1({
39672
39759
  drawDefinition: result.drawDefinition,
39760
+ policyDefinitions: policyDefinitions,
39673
39761
  tournamentRecord: tournamentRecord,
39762
+ enforceGender: enforceGender,
39674
39763
  participantId: participantId,
39675
39764
  sideNumber: sideNumber,
39676
39765
  matchUpId: matchUpId,
@@ -40076,7 +40165,7 @@ function removeCourtAssignment(_a) {
40076
40165
  (drawDefinition = findEvent({ tournamentRecord: tournamentRecord, drawId: drawId }).drawDefinition);
40077
40166
  }
40078
40167
  if (drawDefinition) {
40079
- (matchUp = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId }).matchUp);
40168
+ (matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId }).matchUp);
40080
40169
  }
40081
40170
  else {
40082
40171
  if (!tournamentRecord)
@@ -48980,20 +49069,11 @@ function removeEventEntries(_a) {
48980
49069
  }
48981
49070
 
48982
49071
  /**
48983
- *
48984
49072
  * Add entries into an event; optionally add to specified drawDefinition/flightProfile, if possible.
48985
- *
48986
- * @param {object} tournamentRecord - passed in automatically by tournamentEngine
48987
- * @param {string} eventId - tournamentEngine automatically retrieves event
48988
- * @param {string} drawId - optional - also add to drawDefinition.entries & flightProfile.drawEntries (if possible)
48989
- * @param {string[]} participantIds - ids of all participants to add to event
48990
- * @param {string} enryStatus - entryStatus enum
48991
- * @param {string} entryStage - entryStage enum
48992
- *
48993
49073
  */
48994
49074
  function addEventEntries(params) {
48995
- var _a;
48996
- var _b = params.entryStatus, entryStatus = _b === void 0 ? DIRECT_ACCEPTANCE : _b, _c = params.autoEntryPositions, autoEntryPositions = _c === void 0 ? true : _c, _d = params.participantIds, participantIds = _d === void 0 ? [] : _d, entryStageSequence = params.entryStageSequence, ignoreEventGender = params.ignoreEventGender, _e = params.entryStage, entryStage = _e === void 0 ? MAIN : _e, tournamentRecord = params.tournamentRecord, ignoreStageSpace = params.ignoreStageSpace, drawDefinition = params.drawDefinition, roundTarget = params.roundTarget, extensions = params.extensions, extension = params.extension, drawId = params.drawId, event = params.event;
49075
+ var _a, _b, _c, _d, _e;
49076
+ var _f = params.entryStatus, entryStatus = _f === void 0 ? DIRECT_ACCEPTANCE : _f, _g = params.autoEntryPositions, autoEntryPositions = _g === void 0 ? true : _g, _h = params.enforceGender, enforceGender = _h === void 0 ? true : _h, _j = params.participantIds, participantIds = _j === void 0 ? [] : _j, entryStageSequence = params.entryStageSequence, policyDefinitions = params.policyDefinitions, _k = params.entryStage, entryStage = _k === void 0 ? MAIN : _k, tournamentRecord = params.tournamentRecord, ignoreStageSpace = params.ignoreStageSpace, drawDefinition = params.drawDefinition, roundTarget = params.roundTarget, extensions = params.extensions, extension = params.extension, drawId = params.drawId, event = params.event;
48997
49077
  var stack = 'addEventEntries';
48998
49078
  if (!event)
48999
49079
  return { error: MISSING_EVENT };
@@ -49005,6 +49085,10 @@ function addEventEntries(params) {
49005
49085
  }
49006
49086
  if (!(event === null || event === void 0 ? void 0 : event.eventId))
49007
49087
  return { error: EVENT_NOT_FOUND };
49088
+ var appliedPolicies = (_a = getAppliedPolicies({ tournamentRecord: tournamentRecord, event: event }).appliedPolicies) !== null && _a !== void 0 ? _a : {};
49089
+ var matchUpActionsPolicy = (_c = (_b = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _b !== void 0 ? _b : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _c !== void 0 ? _c : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
49090
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_d = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _d === void 0 ? void 0 : _d.enforceGender) !==
49091
+ false;
49008
49092
  var addedParticipantIdEntries = [];
49009
49093
  var removedEntries = [];
49010
49094
  if ((extensions &&
@@ -49018,9 +49102,9 @@ function addEventEntries(params) {
49018
49102
  });
49019
49103
  }
49020
49104
  var checkTypedParticipants = !!tournamentRecord;
49021
- var misMatchedGender = [];
49105
+ var mismatchedGender = [];
49022
49106
  var info;
49023
- var typedParticipantIds = ((_a = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) === null || _a === void 0 ? void 0 : _a.filter(function (participant) {
49107
+ var typedParticipantIds = ((_e = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants) === null || _e === void 0 ? void 0 : _e.filter(function (participant) {
49024
49108
  var _a, _b, _c;
49025
49109
  if (!participantIds.includes(participant.participantId))
49026
49110
  return false;
@@ -49030,7 +49114,7 @@ function addEventEntries(params) {
49030
49114
  var validDoubles = event.eventType === DOUBLES$1 && participant.participantType === PAIR;
49031
49115
  if (validSingles &&
49032
49116
  (!event.gender ||
49033
- ignoreEventGender ||
49117
+ !genderEnforced ||
49034
49118
  [MIXED, ANY].includes(event.gender) ||
49035
49119
  event.gender === ((_a = participant.person) === null || _a === void 0 ? void 0 : _a.sex))) {
49036
49120
  return true;
@@ -49045,10 +49129,10 @@ function addEventEntries(params) {
49045
49129
  }
49046
49130
  if (validSingles &&
49047
49131
  event.gender &&
49048
- !ignoreEventGender &&
49132
+ genderEnforced &&
49049
49133
  ![MIXED, ANY].includes(event.gender) &&
49050
49134
  event.gender !== ((_b = participant.person) === null || _b === void 0 ? void 0 : _b.sex)) {
49051
- misMatchedGender.push({
49135
+ mismatchedGender.push({
49052
49136
  participantId: participant.participantId,
49053
49137
  sex: (_c = participant.person) === null || _c === void 0 ? void 0 : _c.sex,
49054
49138
  });
@@ -49137,7 +49221,7 @@ function addEventEntries(params) {
49137
49221
  var invalidParticipantIds = validParticipantIds.length !== participantIds.length;
49138
49222
  if (invalidParticipantIds)
49139
49223
  return decorateResult({
49140
- context: { misMatchedGender: misMatchedGender, gender: event.gender },
49224
+ context: { mismatchedGender: mismatchedGender, gender: event.gender },
49141
49225
  result: { error: INVALID_PARTICIPANT_IDS },
49142
49226
  stack: stack,
49143
49227
  });
@@ -50099,13 +50183,13 @@ function resetMatchUpLineUps$1(_a) {
50099
50183
  var _d = _a.inheritance, inheritance = _d === void 0 ? true : _d, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
50100
50184
  if (!drawDefinition)
50101
50185
  return { error: MISSING_DRAW_DEFINITION };
50102
- var matchUp = (_b = findMatchUp$1({
50186
+ var matchUp = (_b = findDrawMatchUp({
50103
50187
  drawDefinition: drawDefinition,
50104
50188
  matchUpId: matchUpId,
50105
50189
  })) === null || _b === void 0 ? void 0 : _b.matchUp;
50106
50190
  if (!(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps))
50107
50191
  return { error: INVALID_MATCHUP };
50108
- var inContextMatchUp = (_c = findMatchUp$1({
50192
+ var inContextMatchUp = (_c = findDrawMatchUp({
50109
50193
  inContext: true,
50110
50194
  drawDefinition: drawDefinition,
50111
50195
  matchUpId: matchUpId,
@@ -50215,7 +50299,7 @@ function removeDelegatedOutcome$1(_a) {
50215
50299
  return { error: MISSING_DRAW_DEFINITION };
50216
50300
  if (!matchUpId)
50217
50301
  return { error: MISSING_MATCHUP_ID };
50218
- var matchUp = findMatchUp$1({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
50302
+ var matchUp = findDrawMatchUp({ drawDefinition: drawDefinition, event: event, matchUpId: matchUpId }).matchUp;
50219
50303
  if (!matchUp)
50220
50304
  return { error: MATCHUP_NOT_FOUND };
50221
50305
  return removeExtension$1({
@@ -50785,7 +50869,7 @@ function setDelegatedOutcome$1(_a) {
50785
50869
  if (!matchUp && !matchUpId)
50786
50870
  return { error: MISSING_MATCHUP };
50787
50871
  if (!matchUp) {
50788
- var result = findMatchUp$1({
50872
+ var result = findDrawMatchUp({
50789
50873
  drawDefinition: drawDefinition,
50790
50874
  matchUpId: matchUpId,
50791
50875
  });
@@ -50838,7 +50922,7 @@ function disableTieAutoCalc$1(_a) {
50838
50922
  var drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
50839
50923
  if (!drawDefinition)
50840
50924
  return { error: MISSING_DRAW_DEFINITION };
50841
- var matchUp = findMatchUp$1({
50925
+ var matchUp = findDrawMatchUp({
50842
50926
  drawDefinition: drawDefinition,
50843
50927
  matchUpId: matchUpId,
50844
50928
  event: event,
@@ -50853,7 +50937,7 @@ function enableTieAutoCalc$1(_a) {
50853
50937
  var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
50854
50938
  if (!drawDefinition)
50855
50939
  return { error: MISSING_DRAW_DEFINITION };
50856
- var matchUp = findMatchUp$1({
50940
+ var matchUp = findDrawMatchUp({
50857
50941
  drawDefinition: drawDefinition,
50858
50942
  matchUpId: matchUpId,
50859
50943
  event: event,
@@ -51034,7 +51118,7 @@ var matchUpGovernor = {
51034
51118
  removeDelegatedOutcome: removeDelegatedOutcome$1,
51035
51119
  drawMatic: drawMatic$1,
51036
51120
  addMatchUpOfficial: addMatchUpOfficial$2,
51037
- findMatchUp: publicFindMatchUp$1,
51121
+ findMatchUp: publicFindDrawMatchUp,
51038
51122
  getRoundMatchUps: getRoundMatchUps$1,
51039
51123
  validDrawPositions: validDrawPositions,
51040
51124
  validateScore: validateScore,
@@ -57112,14 +57196,14 @@ function getTieMatchUpContext(_a) {
57112
57196
  return { error: EVENT_NOT_FOUND };
57113
57197
  var matchUpsMap = getMatchUpsMap({ drawDefinition: drawDefinition });
57114
57198
  // tieMatchUp is matchUpType: SINGLES or DOUBLES
57115
- var tieMatchUp = findMatchUp$1({
57199
+ var tieMatchUp = findDrawMatchUp({
57116
57200
  matchUpId: tieMatchUpId,
57117
57201
  drawDefinition: drawDefinition,
57118
57202
  matchUpsMap: matchUpsMap,
57119
57203
  }).matchUp;
57120
57204
  if (!tieMatchUp)
57121
57205
  return { error: MATCHUP_NOT_FOUND };
57122
- var _c = findMatchUp$1({
57206
+ var _c = findDrawMatchUp({
57123
57207
  tournamentParticipants: tournamentRecord.participants,
57124
57208
  matchUpId: tieMatchUpId,
57125
57209
  inContext: true,
@@ -57142,12 +57226,12 @@ function getTieMatchUpContext(_a) {
57142
57226
  participantIds: participantIds,
57143
57227
  },
57144
57228
  }).participants;
57145
- var dualMatchUp = findMatchUp$1({
57229
+ var dualMatchUp = findDrawMatchUp({
57146
57230
  matchUpId: matchUpTieId,
57147
57231
  drawDefinition: drawDefinition,
57148
57232
  matchUpsMap: matchUpsMap,
57149
57233
  }).matchUp;
57150
- var inContextDualMatchUp = findMatchUp$1({
57234
+ var inContextDualMatchUp = findDrawMatchUp({
57151
57235
  matchUpId: matchUpTieId,
57152
57236
  inContext: true,
57153
57237
  drawDefinition: drawDefinition,
@@ -57164,7 +57248,7 @@ function getTieMatchUpContext(_a) {
57164
57248
 
57165
57249
  function assignTieMatchUpParticipantId(params) {
57166
57250
  var e_1, _a;
57167
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s;
57251
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u;
57168
57252
  var matchUpContext = getTieMatchUpContext(params);
57169
57253
  if (matchUpContext.error)
57170
57254
  return matchUpContext;
@@ -57188,9 +57272,9 @@ function assignTieMatchUpParticipantId(params) {
57188
57272
  return decorateResult({ result: __assign({}, SUCCESS), stack: stack });
57189
57273
  }
57190
57274
  teamParticipantId =
57191
- teamParticipantId ||
57192
- (params.sideNumber &&
57193
- ((_d = (_c = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) { return side.sideNumber === params.sideNumber; })) === null || _d === void 0 ? void 0 : _d.participantId));
57275
+ teamParticipantId !== null && teamParticipantId !== void 0 ? teamParticipantId : (params.sideNumber
57276
+ ? (_d = (_c = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) { return side.sideNumber === params.sideNumber; })) === null || _d === void 0 ? void 0 : _d.participantId
57277
+ : undefined);
57194
57278
  var participantToAssign = (_f = (_e = getParticipants$1({
57195
57279
  participantFilters: { participantIds: [participantId] },
57196
57280
  tournamentRecord: tournamentRecord,
@@ -57203,12 +57287,11 @@ function assignTieMatchUpParticipantId(params) {
57203
57287
  drawDefinition: drawDefinition,
57204
57288
  event: event,
57205
57289
  }).appliedPolicies;
57206
- var matchUpActionsPolicy = ((_g = params.policyDefinitions) === null || _g === void 0 ? void 0 : _g[POLICY_TYPE_MATCHUP_ACTIONS]) ||
57207
- (appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) ||
57208
- POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
57209
- if (((_h = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _h === void 0 ? void 0 : _h.enforceGender) &&
57290
+ var matchUpActionsPolicy = (_j = (_h = (_g = params.policyDefinitions) === null || _g === void 0 ? void 0 : _g[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _h !== void 0 ? _h : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _j !== void 0 ? _j : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
57291
+ var genderEnforced = ((_k = params.enforceGender) !== null && _k !== void 0 ? _k : (_l = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _l === void 0 ? void 0 : _l.enforceGender) !== false;
57292
+ if (genderEnforced &&
57210
57293
  [MALE, FEMALE].includes(inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) &&
57211
- (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_j = participantToAssign.person) === null || _j === void 0 ? void 0 : _j.sex)) {
57294
+ (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_m = participantToAssign.person) === null || _m === void 0 ? void 0 : _m.sex)) {
57212
57295
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
57213
57296
  }
57214
57297
  var individualParticipantIds = participantToAssign.individualParticipantIds, participantType = participantToAssign.participantType;
@@ -57235,37 +57318,27 @@ function assignTieMatchUpParticipantId(params) {
57235
57318
  return { error: PARTICIPANT_NOT_FOUND };
57236
57319
  var teamAssignment = relevantAssignments === null || relevantAssignments === void 0 ? void 0 : relevantAssignments.find(function (assignment) { return assignment.participantId === (participantTeam === null || participantTeam === void 0 ? void 0 : participantTeam.participantId); });
57237
57320
  var teamDrawPosition = teamAssignment === null || teamAssignment === void 0 ? void 0 : teamAssignment.drawPosition;
57238
- var teamSide = (_k = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (side) { return side.drawPosition === teamDrawPosition; });
57239
- var sideNumber = params.sideNumber || (teamSide === null || teamSide === void 0 ? void 0 : teamSide.sideNumber);
57321
+ var teamSide = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.find(function (side) { return side.drawPosition === teamDrawPosition; });
57322
+ var sideNumber = (_p = params.sideNumber) !== null && _p !== void 0 ? _p : teamSide === null || teamSide === void 0 ? void 0 : teamSide.sideNumber;
57240
57323
  if (!tieFormat) {
57241
57324
  return { error: MISSING_TIE_FORMAT };
57242
57325
  }
57243
- var collectionDefinition = (_l = tieFormat.collectionDefinitions) === null || _l === void 0 ? void 0 : _l.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57326
+ var collectionDefinition = (_q = tieFormat.collectionDefinitions) === null || _q === void 0 ? void 0 : _q.find(function (collectionDefinition) { return collectionDefinition.collectionId === collectionId; });
57244
57327
  if (!collectionDefinition)
57245
57328
  return { error: MISSING_COLLECTION_DEFINITION };
57246
- if (!((_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.length)) {
57247
- var extension = findExtension$2({
57248
- element: drawDefinition,
57249
- name: LINEUPS,
57250
- }).extension;
57251
- var lineUps_1 = makeDeepCopy((extension === null || extension === void 0 ? void 0 : extension.value) || {}, false, true);
57252
- var extractSideDetail_1 = function (_a) {
57253
- var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
57254
- return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
57255
- };
57256
- if (dualMatchUp) {
57257
- dualMatchUp.sides = (_o = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.map(function (side) {
57258
- var participantId = side.participantId;
57259
- return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps_1[participantId]) || [] });
57260
- });
57261
- }
57262
- }
57263
- var dualMatchUpSide = (_p = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) { return side.sideNumber === sideNumber; });
57264
- var tieMatchUpSide = (_q = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _q === void 0 ? void 0 : _q.find(function (side) { return side.sideNumber === sideNumber; });
57265
- var lineUp = (_r = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _r !== void 0 ? _r : (_s = getTeamLineUp({
57329
+ ensureSideLineUps({
57330
+ tournamentId: tournamentRecord.tournamentId,
57331
+ eventId: event.eventId,
57332
+ inContextDualMatchUp: inContextDualMatchUp,
57333
+ drawDefinition: drawDefinition,
57334
+ dualMatchUp: dualMatchUp,
57335
+ });
57336
+ var dualMatchUpSide = (_r = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _r === void 0 ? void 0 : _r.find(function (side) { return side.sideNumber === sideNumber; });
57337
+ var tieMatchUpSide = (_s = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _s === void 0 ? void 0 : _s.find(function (side) { return side.sideNumber === sideNumber; });
57338
+ var lineUp = (_t = dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.lineUp) !== null && _t !== void 0 ? _t : (_u = getTeamLineUp({
57266
57339
  participantId: teamParticipantId,
57267
57340
  drawDefinition: drawDefinition,
57268
- })) === null || _s === void 0 ? void 0 : _s.lineUp;
57341
+ })) === null || _u === void 0 ? void 0 : _u.lineUp;
57269
57342
  var targetAssignments = lineUp === null || lineUp === void 0 ? void 0 : lineUp.filter(function (participantAssignment) {
57270
57343
  var _a;
57271
57344
  return (_a = participantAssignment.collectionAssignments) === null || _a === void 0 ? void 0 : _a.find(function (assignment) {
@@ -57292,7 +57365,7 @@ function assignTieMatchUpParticipantId(params) {
57292
57365
  if (removeResult.error)
57293
57366
  return decorateResult({ result: removeResult, stack: stack });
57294
57367
  var modifiedLineUp = removeResult.modifiedLineUp;
57295
- var deleteParticipantId;
57368
+ var deletedParticipantId;
57296
57369
  if (matchUpType === DOUBLES$1) {
57297
57370
  if (participantType !== PAIR) {
57298
57371
  var result = updateLineUp({
@@ -57311,7 +57384,7 @@ function assignTieMatchUpParticipantId(params) {
57311
57384
  });
57312
57385
  if (result.error)
57313
57386
  return result;
57314
- deleteParticipantId = result.deleteParticipantId;
57387
+ deletedParticipantId = result.deletedParticipantId;
57315
57388
  if (dualMatchUpSide)
57316
57389
  dualMatchUpSide.lineUp = modifiedLineUp;
57317
57390
  if (dualMatchUp) {
@@ -57369,9 +57442,9 @@ function assignTieMatchUpParticipantId(params) {
57369
57442
  context: stack,
57370
57443
  drawDefinition: drawDefinition,
57371
57444
  });
57372
- if (deleteParticipantId) {
57445
+ if (deletedParticipantId) {
57373
57446
  var error = deleteParticipants({
57374
- participantIds: [deleteParticipantId],
57447
+ participantIds: [deletedParticipantId],
57375
57448
  tournamentRecord: tournamentRecord,
57376
57449
  }).error;
57377
57450
  if (error)
@@ -57380,7 +57453,7 @@ function assignTieMatchUpParticipantId(params) {
57380
57453
  return __assign(__assign({}, SUCCESS), { modifiedLineUp: modifiedLineUp });
57381
57454
  function addParticipantId2Pair(_a) {
57382
57455
  var side = _a.side;
57383
- var deleteParticipantId;
57456
+ var deletedParticipantId;
57384
57457
  if (!side.participant) {
57385
57458
  var newPairParticipant = {
57386
57459
  individualParticipantIds: [participantId],
@@ -57421,11 +57494,11 @@ function assignTieMatchUpParticipantId(params) {
57421
57494
  else {
57422
57495
  // check if there is a pairParticipant that includes both individualParticipantIds
57423
57496
  // if there is, use that and delete the PAIR participant with only one [individualParticipantId]
57424
- deleteParticipantId = participant === null || participant === void 0 ? void 0 : participant.participantId;
57497
+ deletedParticipantId = participant === null || participant === void 0 ? void 0 : participant.participantId;
57425
57498
  }
57426
57499
  }
57427
57500
  }
57428
- return __assign(__assign({}, SUCCESS), { deleteParticipantId: deleteParticipantId });
57501
+ return __assign(__assign({}, SUCCESS), { deletedParticipantId: deletedParticipantId });
57429
57502
  }
57430
57503
  }
57431
57504
  function updateLineUp(_a) {
@@ -58028,14 +58101,15 @@ function completeDrawMatchUps(params) {
58028
58101
  });
58029
58102
  if (teamParticipant) {
58030
58103
  var individualParticipantId = (_a = teamParticipant.individualParticipantIds) === null || _a === void 0 ? void 0 : _a[i];
58031
- assignTieMatchUpParticipantId({
58032
- teamParticipantId: teamParticipant.participantId,
58033
- participantId: individualParticipantId,
58034
- tournamentRecord: tournamentRecord,
58035
- drawDefinition: drawDefinition,
58036
- tieMatchUpId: tieMatchUpId,
58037
- event: event,
58038
- });
58104
+ individualParticipantId &&
58105
+ assignTieMatchUpParticipantId({
58106
+ teamParticipantId: teamParticipant.participantId,
58107
+ participantId: individualParticipantId,
58108
+ tournamentRecord: tournamentRecord,
58109
+ drawDefinition: drawDefinition,
58110
+ tieMatchUpId: tieMatchUpId,
58111
+ event: event,
58112
+ });
58039
58113
  }
58040
58114
  });
58041
58115
  });
@@ -59936,8 +60010,10 @@ function assignMatchUpSideParticipant(_a) {
59936
60010
  if (noSideNumberProvided)
59937
60011
  sideNumber = 1;
59938
60012
  if (![1, 2].includes(sideNumber))
59939
- return { error: INVALID_VALUES, sideNumber: sideNumber };
59940
- var _e = findMatchUp$1({
60013
+ return decorateResult({
60014
+ result: { error: INVALID_VALUES, context: { sideNumber: sideNumber } },
60015
+ });
60016
+ var _e = findDrawMatchUp({
59941
60017
  drawDefinition: drawDefinition,
59942
60018
  matchUpId: matchUpId,
59943
60019
  event: event,
@@ -60011,7 +60087,7 @@ function removeMatchUpSideParticipant(_a) {
60011
60087
  // TODO: move to drawEngine and passthrough
60012
60088
  if (![1, 2].includes(sideNumber))
60013
60089
  return { error: INVALID_VALUES, sideNumber: sideNumber };
60014
- var _d = findMatchUp$1({
60090
+ var _d = findDrawMatchUp({
60015
60091
  drawDefinition: drawDefinition,
60016
60092
  matchUpId: matchUpId,
60017
60093
  event: event,
@@ -60041,7 +60117,7 @@ function removeMatchUpSideParticipant(_a) {
60041
60117
 
60042
60118
  function replaceTieMatchUpParticipantId(params) {
60043
60119
  var e_1, _a;
60044
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t;
60120
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x;
60045
60121
  var matchUpContext = getTieMatchUpContext(params);
60046
60122
  if (matchUpContext.error)
60047
60123
  return matchUpContext;
@@ -60079,36 +60155,26 @@ function replaceTieMatchUpParticipantId(params) {
60079
60155
  drawDefinition: drawDefinition,
60080
60156
  event: event,
60081
60157
  }).appliedPolicies;
60082
- var matchUpActionsPolicy = (appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) ||
60083
- POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60158
+ var matchUpActionsPolicy = (_g = (_f = (_e = params.policyDefinitions) === null || _e === void 0 ? void 0 : _e[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _f !== void 0 ? _f : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _g !== void 0 ? _g : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60084
60159
  var newParticipant = targetParticipants.find(function (_a) {
60085
60160
  var participantId = _a.participantId;
60086
60161
  return participantId === newParticipantId;
60087
60162
  });
60088
- if (((_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _e === void 0 ? void 0 : _e.enforceGender) &&
60163
+ var genderEnforced = ((_h = params.enforceGender) !== null && _h !== void 0 ? _h : (_j = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _j === void 0 ? void 0 : _j.enforceGender) !== false;
60164
+ if (genderEnforced &&
60089
60165
  [MALE, FEMALE].includes(inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) &&
60090
- (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_f = newParticipant === null || newParticipant === void 0 ? void 0 : newParticipant.person) === null || _f === void 0 ? void 0 : _f.sex)) {
60166
+ (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.gender) !== ((_k = newParticipant === null || newParticipant === void 0 ? void 0 : newParticipant.person) === null || _k === void 0 ? void 0 : _k.sex)) {
60091
60167
  return { error: INVALID_PARTICIPANT, info: 'Gender mismatch' };
60092
60168
  }
60093
- var substitutionProcessCodes = (_g = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _g === void 0 ? void 0 : _g.substitution;
60094
- var extension = findExtension$2({
60095
- element: drawDefinition,
60096
- name: LINEUPS,
60097
- }).extension;
60098
- var lineUps = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
60099
- if (!((_h = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.length)) {
60100
- var extractSideDetail_1 = function (_a) {
60101
- var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
60102
- return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
60103
- };
60104
- if (dualMatchUp) {
60105
- dualMatchUp.sides = (_j = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.map(function (side) {
60106
- var participantId = side.participantId;
60107
- return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps[participantId]) || [] });
60108
- });
60109
- }
60110
- }
60111
- var dualMatchUpSide = (_k = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.find(function (_a) {
60169
+ var substitutionProcessCodes = (_l = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _l === void 0 ? void 0 : _l.substitution;
60170
+ ensureSideLineUps({
60171
+ tournamentId: tournamentRecord.tournamentId,
60172
+ eventId: event.eventId,
60173
+ inContextDualMatchUp: inContextDualMatchUp,
60174
+ drawDefinition: drawDefinition,
60175
+ dualMatchUp: dualMatchUp,
60176
+ });
60177
+ var dualMatchUpSide = (_m = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60112
60178
  var sideNumber = _a.sideNumber;
60113
60179
  return sideNumber === side.sideNumber;
60114
60180
  });
@@ -60122,7 +60188,7 @@ function replaceTieMatchUpParticipantId(params) {
60122
60188
  stack: stack,
60123
60189
  });
60124
60190
  }
60125
- var allTieIndividualParticipantIds = (_l = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _l === void 0 ? void 0 : _l.flatMap(function (side) {
60191
+ var allTieIndividualParticipantIds = (_o = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _o === void 0 ? void 0 : _o.flatMap(function (side) {
60126
60192
  var _a, _b;
60127
60193
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds) ||
60128
60194
  ((_b = side.participant) === null || _b === void 0 ? void 0 : _b.participantId) ||
@@ -60131,10 +60197,10 @@ function replaceTieMatchUpParticipantId(params) {
60131
60197
  if (allTieIndividualParticipantIds === null || allTieIndividualParticipantIds === void 0 ? void 0 : allTieIndividualParticipantIds.includes(newParticipantId)) {
60132
60198
  return decorateResult({ result: { error: EXISTING_PARTICIPANT }, stack: stack });
60133
60199
  }
60134
- var teamParticipantId = (_o = (_m = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60200
+ var teamParticipantId = (_q = (_p = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (_a) {
60135
60201
  var sideNumber = _a.sideNumber;
60136
60202
  return sideNumber === side.sideNumber;
60137
- })) === null || _o === void 0 ? void 0 : _o.participantId;
60203
+ })) === null || _q === void 0 ? void 0 : _q.participantId;
60138
60204
  var teamLineUp = dualMatchUpSide.lineUp;
60139
60205
  var newParticipantIdInLineUp = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.find(function (_a) {
60140
60206
  var participantId = _a.participantId;
@@ -60145,7 +60211,7 @@ function replaceTieMatchUpParticipantId(params) {
60145
60211
  ? teamCompetitor.substitutionOrder
60146
60212
  : order;
60147
60213
  }, 0);
60148
- var modifiedLineUp = (teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.map(function (teamCompetitor) {
60214
+ var modifiedLineUp = (_r = teamLineUp === null || teamLineUp === void 0 ? void 0 : teamLineUp.map(function (teamCompetitor) {
60149
60215
  var _a;
60150
60216
  var modifiedCompetitor = makeDeepCopy(teamCompetitor, false, true);
60151
60217
  // if the current competitor is not either id, return as is
@@ -60180,16 +60246,16 @@ function replaceTieMatchUpParticipantId(params) {
60180
60246
  var assignment = { collectionId: collectionId, collectionPosition: collectionPosition };
60181
60247
  if (substitution) {
60182
60248
  assignment.previousParticipantId = existingParticipantId;
60183
- assignment.substitutionOrder = (substitutionOrder || 0) + 1;
60249
+ assignment.substitutionOrder = (substitutionOrder !== null && substitutionOrder !== void 0 ? substitutionOrder : 0) + 1;
60184
60250
  }
60185
60251
  modifiedCompetitor.collectionAssignments.push(assignment);
60186
60252
  }
60187
60253
  return modifiedCompetitor;
60188
- })) || [];
60254
+ })) !== null && _r !== void 0 ? _r : [];
60189
60255
  if (!newParticipantIdInLineUp) {
60190
60256
  var collectionAssignment = { collectionId: collectionId, collectionPosition: collectionPosition };
60191
60257
  if (substitution) {
60192
- collectionAssignment.substitutionOrder = (substitutionOrder || 0) + 1;
60258
+ collectionAssignment.substitutionOrder = (substitutionOrder !== null && substitutionOrder !== void 0 ? substitutionOrder : 0) + 1;
60193
60259
  collectionAssignment.previousParticipantId = existingParticipantId;
60194
60260
  }
60195
60261
  var assignment = {
@@ -60245,14 +60311,14 @@ function replaceTieMatchUpParticipantId(params) {
60245
60311
  });
60246
60312
  if (result_1.error)
60247
60313
  return decorateResult({ result: result_1, stack: stack });
60248
- participantAdded = (_p = result_1.participant) === null || _p === void 0 ? void 0 : _p.participantId;
60314
+ participantAdded = (_s = result_1.participant) === null || _s === void 0 ? void 0 : _s.participantId;
60249
60315
  }
60250
60316
  // now attempt to cleanup/delete previous pairParticipant
60251
60317
  result = getPairedParticipant({
60252
60318
  participantIds: existingIndividualParticipantIds,
60253
60319
  tournamentRecord: tournamentRecord_1,
60254
60320
  });
60255
- var existingPairParticipantId = (_q = result.participant) === null || _q === void 0 ? void 0 : _q.participantId;
60321
+ var existingPairParticipantId = (_t = result.participant) === null || _t === void 0 ? void 0 : _t.participantId;
60256
60322
  if (existingPairParticipantId) {
60257
60323
  var result_2 = deleteParticipants({
60258
60324
  participantIds: [existingPairParticipantId],
@@ -60262,9 +60328,9 @@ function replaceTieMatchUpParticipantId(params) {
60262
60328
  participantRemoved = existingPairParticipantId;
60263
60329
  }
60264
60330
  }
60265
- if (substitution || ((_r = side.substitutions) === null || _r === void 0 ? void 0 : _r.length) === 1) {
60331
+ if (substitution || ((_u = side.substitutions) === null || _u === void 0 ? void 0 : _u.length) === 1) {
60266
60332
  if (substitution) {
60267
- var processCodes = (tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) || [];
60333
+ var processCodes = (_v = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) !== null && _v !== void 0 ? _v : [];
60268
60334
  if (substitutionProcessCodes)
60269
60335
  processCodes.push.apply(processCodes, __spreadArray([], __read(substitutionProcessCodes), false));
60270
60336
  if (tieMatchUp)
@@ -60273,18 +60339,18 @@ function replaceTieMatchUpParticipantId(params) {
60273
60339
  else {
60274
60340
  try {
60275
60341
  // if there was only one substitution, remove processCode(s)
60276
- for (var _u = __values(substitutionProcessCodes || []), _v = _u.next(); !_v.done; _v = _u.next()) {
60277
- var substitutionProcessCode = _v.value;
60278
- var codeIndex = (_s = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _s === void 0 ? void 0 : _s.lastIndexOf(substitutionProcessCode);
60342
+ for (var _y = __values(substitutionProcessCodes || []), _z = _y.next(); !_z.done; _z = _y.next()) {
60343
+ var substitutionProcessCode = _z.value;
60344
+ var codeIndex = (_w = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _w === void 0 ? void 0 : _w.lastIndexOf(substitutionProcessCode);
60279
60345
  // remove only one instance of substitutionProcessCode
60280
60346
  codeIndex !== undefined &&
60281
- ((_t = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _t === void 0 ? void 0 : _t.splice(codeIndex, 1));
60347
+ ((_x = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _x === void 0 ? void 0 : _x.splice(codeIndex, 1));
60282
60348
  }
60283
60349
  }
60284
60350
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60285
60351
  finally {
60286
60352
  try {
60287
- if (_v && !_v.done && (_a = _u.return)) _a.call(_u);
60353
+ if (_z && !_z.done && (_a = _y.return)) _a.call(_y);
60288
60354
  }
60289
60355
  finally { if (e_1) throw e_1.error; }
60290
60356
  }
@@ -60311,7 +60377,7 @@ function replaceTieMatchUpParticipantId(params) {
60311
60377
 
60312
60378
  function removeTieMatchUpParticipantId(params) {
60313
60379
  var e_1, _a;
60314
- var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
60380
+ var _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z;
60315
60381
  var tournamentRecord = params.tournamentRecord, drawDefinition = params.drawDefinition, participantId = params.participantId, event = params.event;
60316
60382
  var stack = 'removeTieMatchUpParticiapantId';
60317
60383
  if (!participantId)
@@ -60324,33 +60390,32 @@ function removeTieMatchUpParticipantId(params) {
60324
60390
  drawDefinition: drawDefinition,
60325
60391
  event: event,
60326
60392
  }).appliedPolicies;
60327
- var matchUpActionsPolicy = (appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) ||
60328
- POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60329
- var substitutionProcessCodes = (_b = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _b === void 0 ? void 0 : _b.substitution;
60393
+ var matchUpActionsPolicy = (_d = (_c = (_b = params.policyDefinitions) === null || _b === void 0 ? void 0 : _b[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _c !== void 0 ? _c : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _d !== void 0 ? _d : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
60394
+ var substitutionProcessCodes = (_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.processCodes) === null || _e === void 0 ? void 0 : _e.substitution;
60330
60395
  var inContextDualMatchUp = matchUpContext.inContextDualMatchUp, inContextTieMatchUp = matchUpContext.inContextTieMatchUp, relevantAssignments = matchUpContext.relevantAssignments, collectionPosition = matchUpContext.collectionPosition, teamParticipants = matchUpContext.teamParticipants, collectionId = matchUpContext.collectionId, matchUpType = matchUpContext.matchUpType, dualMatchUp = matchUpContext.dualMatchUp, tieMatchUp = matchUpContext.tieMatchUp, tieFormat = matchUpContext.tieFormat;
60331
60396
  if (!dualMatchUp)
60332
60397
  return decorateResult({ result: { error: MISSING_MATCHUP }, stack: stack });
60333
- var side = (_c = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _c === void 0 ? void 0 : _c.find(function (side) {
60398
+ var side = (_f = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _f === void 0 ? void 0 : _f.find(function (side) {
60334
60399
  var _a, _b, _c;
60335
60400
  return ((_a = side.participant) === null || _a === void 0 ? void 0 : _a.participantId) === participantId ||
60336
60401
  ((_c = (_b = side.participant) === null || _b === void 0 ? void 0 : _b.individualParticipantIds) === null || _c === void 0 ? void 0 : _c.includes(participantId));
60337
60402
  });
60338
60403
  if (!side)
60339
60404
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60340
- if (!((_d = side.substitutions) === null || _d === void 0 ? void 0 : _d.length) &&
60405
+ if (!((_g = side.substitutions) === null || _g === void 0 ? void 0 : _g.length) &&
60341
60406
  (scoreHasValue({ score: inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.score }) ||
60342
60407
  (inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.winningSide)))
60343
60408
  return decorateResult({ result: { error: EXISTING_OUTCOME }, stack: stack });
60344
- var teamParticipantId = (_f = (_e = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _e === void 0 ? void 0 : _e.find(function (_a) {
60409
+ var teamParticipantId = (_j = (_h = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _h === void 0 ? void 0 : _h.find(function (_a) {
60345
60410
  var sideNumber = _a.sideNumber;
60346
60411
  return sideNumber === side.sideNumber;
60347
- })) === null || _f === void 0 ? void 0 : _f.participantId;
60412
+ })) === null || _j === void 0 ? void 0 : _j.participantId;
60348
60413
  if (!teamParticipantId)
60349
60414
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60350
- var participantToRemove = (_h = (_g = getParticipants$1({
60415
+ var participantToRemove = (_l = (_k = getParticipants$1({
60351
60416
  participantFilters: { participantIds: [participantId] },
60352
60417
  tournamentRecord: tournamentRecord,
60353
- })) === null || _g === void 0 ? void 0 : _g.participants) === null || _h === void 0 ? void 0 : _h[0];
60418
+ })) === null || _k === void 0 ? void 0 : _k.participants) === null || _l === void 0 ? void 0 : _l[0];
60354
60419
  if (!participantToRemove) {
60355
60420
  return decorateResult({ result: { error: PARTICIPANT_NOT_FOUND }, stack: stack });
60356
60421
  }
@@ -60360,27 +60425,19 @@ function removeTieMatchUpParticipantId(params) {
60360
60425
  var participantIds = participantToRemove.participantType === INDIVIDUAL
60361
60426
  ? [participantId]
60362
60427
  : participantToRemove.individualParticipantIds;
60363
- if (!((_j = dualMatchUp === null || dualMatchUp === void 0 ? void 0 : dualMatchUp.sides) === null || _j === void 0 ? void 0 : _j.length)) {
60364
- var extension = findExtension$2({
60365
- element: drawDefinition,
60366
- name: LINEUPS,
60367
- }).extension;
60368
- var lineUps_1 = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
60369
- var extractSideDetail_1 = function (_a) {
60370
- var displaySideNumber = _a.displaySideNumber, drawPosition = _a.drawPosition, sideNumber = _a.sideNumber;
60371
- return ({ drawPosition: drawPosition, sideNumber: sideNumber, displaySideNumber: displaySideNumber });
60372
- };
60373
- dualMatchUp.sides = (_k = inContextDualMatchUp === null || inContextDualMatchUp === void 0 ? void 0 : inContextDualMatchUp.sides) === null || _k === void 0 ? void 0 : _k.map(function (side) {
60374
- var participantId = side.participantId;
60375
- return __assign(__assign({}, extractSideDetail_1(side)), { lineUp: (participantId && lineUps_1[participantId]) || [] });
60376
- });
60377
- }
60378
- var dualMatchUpSide = (_l = dualMatchUp.sides) === null || _l === void 0 ? void 0 : _l.find(function (_a) {
60428
+ ensureSideLineUps({
60429
+ tournamentId: tournamentRecord.tournamentId,
60430
+ eventId: event.eventId,
60431
+ inContextDualMatchUp: inContextDualMatchUp,
60432
+ drawDefinition: drawDefinition,
60433
+ dualMatchUp: dualMatchUp,
60434
+ });
60435
+ var dualMatchUpSide = (_m = dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.find(function (_a) {
60379
60436
  var sideNumber = _a.sideNumber;
60380
60437
  return sideNumber === side.sideNumber;
60381
60438
  });
60382
60439
  if (!dualMatchUpSide &&
60383
- (((_m = dualMatchUp.sides) === null || _m === void 0 ? void 0 : _m.filter(function (_a) {
60440
+ (((_o = dualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.filter(function (_a) {
60384
60441
  var lineUp = _a.lineUp;
60385
60442
  return !lineUp;
60386
60443
  }).length) || 0) < 2) {
@@ -60392,7 +60449,7 @@ function removeTieMatchUpParticipantId(params) {
60392
60449
  teamParticipantId: teamParticipantId,
60393
60450
  });
60394
60451
  });
60395
- dualMatchUpSide = (_o = dualMatchUp.sides) === null || _o === void 0 ? void 0 : _o.find(function (side) {
60452
+ dualMatchUpSide = (_p = dualMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) {
60396
60453
  var _a;
60397
60454
  return ((_a = drawPositionMap_1 === null || drawPositionMap_1 === void 0 ? void 0 : drawPositionMap_1.find(function (_a) {
60398
60455
  var drawPosition = _a.drawPosition;
@@ -60401,17 +60458,18 @@ function removeTieMatchUpParticipantId(params) {
60401
60458
  });
60402
60459
  }
60403
60460
  if (!dualMatchUpSide) {
60404
- console.log({ teamParticipantId: teamParticipantId, teamParticipants: teamParticipants });
60405
- return { error: PARTICIPANT_NOT_FOUND, participantId: participantId };
60461
+ return decorateResult({
60462
+ result: { error: PARTICIPANT_NOT_FOUND, context: { participantId: participantId } },
60463
+ });
60406
60464
  }
60407
- var _z = removeCollectionAssignments({
60465
+ var _0 = removeCollectionAssignments({
60408
60466
  collectionPosition: collectionPosition,
60409
60467
  teamParticipantId: teamParticipantId,
60410
60468
  dualMatchUpSide: dualMatchUpSide,
60411
60469
  participantIds: participantIds,
60412
60470
  drawDefinition: drawDefinition,
60413
60471
  collectionId: collectionId,
60414
- }), modifiedLineUp = _z.modifiedLineUp, previousParticipantIds = _z.previousParticipantIds;
60472
+ }), modifiedLineUp = _0.modifiedLineUp, previousParticipantIds = _0.previousParticipantIds;
60415
60473
  dualMatchUpSide.lineUp = modifiedLineUp;
60416
60474
  teamParticipantId &&
60417
60475
  tieFormat &&
@@ -60425,16 +60483,16 @@ function removeTieMatchUpParticipantId(params) {
60425
60483
  // ...then the PAIR participant may need to be modified
60426
60484
  if (matchUpType === DOUBLES$1 &&
60427
60485
  participantToRemove.participantType === INDIVIDUAL) {
60428
- var tieMatchUpSide = (_p = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _p === void 0 ? void 0 : _p.find(function (side) { return side.sideNumber === (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.sideNumber); });
60486
+ var tieMatchUpSide = (_q = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _q === void 0 ? void 0 : _q.find(function (side) { return side.sideNumber === (dualMatchUpSide === null || dualMatchUpSide === void 0 ? void 0 : dualMatchUpSide.sideNumber); });
60429
60487
  var pairParticipantId = (tieMatchUpSide || {}).participantId;
60430
60488
  var pairParticipant = pairParticipantId &&
60431
- ((_r = (_q = getParticipants$1({
60489
+ ((_s = (_r = getParticipants$1({
60432
60490
  participantFilters: { participantIds: [pairParticipantId] },
60433
60491
  tournamentRecord: tournamentRecord,
60434
60492
  withDraws: true,
60435
- })) === null || _q === void 0 ? void 0 : _q.participants) === null || _r === void 0 ? void 0 : _r[0]);
60493
+ })) === null || _r === void 0 ? void 0 : _r.participants) === null || _s === void 0 ? void 0 : _s[0]);
60436
60494
  if (pairParticipant) {
60437
- var individualParticipantIds = (_t = (_s = pairParticipant === null || pairParticipant === void 0 ? void 0 : pairParticipant.individualParticipantIds) === null || _s === void 0 ? void 0 : _s.filter(function (currentId) { return currentId !== participantId; })) !== null && _t !== void 0 ? _t : [];
60495
+ var individualParticipantIds = (_u = (_t = pairParticipant === null || pairParticipant === void 0 ? void 0 : pairParticipant.individualParticipantIds) === null || _t === void 0 ? void 0 : _t.filter(function (currentId) { return currentId !== participantId; })) !== null && _u !== void 0 ? _u : [];
60438
60496
  if (previousParticipantIds)
60439
60497
  individualParticipantIds.push.apply(individualParticipantIds, __spreadArray([], __read(previousParticipantIds), false));
60440
60498
  if (individualParticipantIds.length > 2) {
@@ -60444,7 +60502,7 @@ function removeTieMatchUpParticipantId(params) {
60444
60502
  });
60445
60503
  }
60446
60504
  // don't modify pair participant that is part of other events/draws
60447
- if (!((_u = pairParticipant.draws) === null || _u === void 0 ? void 0 : _u.length)) {
60505
+ if (!((_v = pairParticipant.draws) === null || _v === void 0 ? void 0 : _v.length)) {
60448
60506
  if (individualParticipantIds.length) {
60449
60507
  pairParticipant.individualParticipantIds = individualParticipantIds;
60450
60508
  var result = modifyParticipant({
@@ -60495,13 +60553,13 @@ function removeTieMatchUpParticipantId(params) {
60495
60553
  }
60496
60554
  }
60497
60555
  // if there was only one subsitution on target side and there are no substiutions on other side
60498
- if (((_v = side.substitutions) === null || _v === void 0 ? void 0 : _v.length) === 1) {
60499
- var otherSide = (_w = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _w === void 0 ? void 0 : _w.find(function (s) { return s.sideNumber !== side.sideNumber; });
60500
- if (!((_x = otherSide === null || otherSide === void 0 ? void 0 : otherSide.substitutions) === null || _x === void 0 ? void 0 : _x.length) && ((_y = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _y === void 0 ? void 0 : _y.length)) {
60556
+ if (((_w = side.substitutions) === null || _w === void 0 ? void 0 : _w.length) === 1) {
60557
+ var otherSide = (_x = inContextTieMatchUp === null || inContextTieMatchUp === void 0 ? void 0 : inContextTieMatchUp.sides) === null || _x === void 0 ? void 0 : _x.find(function (s) { return s.sideNumber !== side.sideNumber; });
60558
+ if (!((_y = otherSide === null || otherSide === void 0 ? void 0 : otherSide.substitutions) === null || _y === void 0 ? void 0 : _y.length) && ((_z = tieMatchUp === null || tieMatchUp === void 0 ? void 0 : tieMatchUp.processCodes) === null || _z === void 0 ? void 0 : _z.length)) {
60501
60559
  try {
60502
60560
  // remove processCode(s)
60503
- for (var _0 = __values(substitutionProcessCodes || []), _1 = _0.next(); !_1.done; _1 = _0.next()) {
60504
- var substitutionProcessCode = _1.value;
60561
+ for (var _1 = __values(substitutionProcessCodes || []), _2 = _1.next(); !_2.done; _2 = _1.next()) {
60562
+ var substitutionProcessCode = _2.value;
60505
60563
  var codeIndex = tieMatchUp.processCodes.lastIndexOf(substitutionProcessCode);
60506
60564
  // remove only one instance of substitutionProcessCode
60507
60565
  tieMatchUp.processCodes.splice(codeIndex, 1);
@@ -60510,7 +60568,7 @@ function removeTieMatchUpParticipantId(params) {
60510
60568
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
60511
60569
  finally {
60512
60570
  try {
60513
- if (_1 && !_1.done && (_a = _0.return)) _a.call(_0);
60571
+ if (_2 && !_2.done && (_a = _1.return)) _a.call(_1);
60514
60572
  }
60515
60573
  finally { if (e_1) throw e_1.error; }
60516
60574
  }
@@ -60964,19 +61022,27 @@ function addEventEntryPairs(_a) {
60964
61022
  }
60965
61023
 
60966
61024
  function checkValidEntries(_a) {
60967
- var _b = _a.enforceGender, enforceGender = _b === void 0 ? true : _b, consideredEntries = _a.consideredEntries, tournamentRecord = _a.tournamentRecord, participants = _a.participants, event = _a.event;
60968
- participants = participants || (tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants);
61025
+ var _b;
61026
+ var _c, _d, _e, _f;
61027
+ var consideredEntries = _a.consideredEntries, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, appliedPolicies = _a.appliedPolicies, participantMap = _a.participantMap, enforceGender = _a.enforceGender, participants = _a.participants, event = _a.event;
61028
+ if ((!participants || !participantMap) && tournamentRecord) {
61029
+ (_b = getParticipants$1({
61030
+ tournamentRecord: tournamentRecord,
61031
+ }), participants = _b.participants, participantMap = _b.participantMap);
61032
+ }
60969
61033
  if (!participants)
60970
61034
  return { error: MISSING_PARTICIPANTS };
60971
61035
  if (!Array.isArray(participants))
60972
61036
  return { error: INVALID_VALUES };
60973
61037
  if (!event)
60974
61038
  return { error: MISSING_EVENT };
61039
+ var matchUpActionsPolicy = (_d = (_c = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _c !== void 0 ? _c : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) !== null && _d !== void 0 ? _d : POLICY_MATCHUP_ACTIONS_DEFAULT[POLICY_TYPE_MATCHUP_ACTIONS];
61040
+ var genderEnforced = (enforceGender !== null && enforceGender !== void 0 ? enforceGender : (_e = matchUpActionsPolicy === null || matchUpActionsPolicy === void 0 ? void 0 : matchUpActionsPolicy.participants) === null || _e === void 0 ? void 0 : _e.enforceGender) !==
61041
+ false;
60975
61042
  var eventType = event.eventType, eventGender = event.gender;
60976
- var participantType = (eventType === TEAM_EVENT && TEAM) ||
60977
- (eventType === DOUBLES_EVENT && PAIR) ||
60978
- INDIVIDUAL;
60979
- var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read((consideredEntries || event.entries || []).map(function (entry) {
61043
+ var isDoubles = eventType === DOUBLES_EVENT;
61044
+ var participantType = (eventType === TEAM_EVENT && TEAM) || (isDoubles && PAIR) || INDIVIDUAL;
61045
+ var entryStatusMap = Object.assign.apply(Object, __spreadArray([{}], __read(((_f = consideredEntries !== null && consideredEntries !== void 0 ? consideredEntries : event.entries) !== null && _f !== void 0 ? _f : []).map(function (entry) {
60980
61046
  var _a;
60981
61047
  return (_a = {},
60982
61048
  _a[entry.participantId] = entry.entryStatus,
@@ -60987,27 +61053,39 @@ function checkValidEntries(_a) {
60987
61053
  return enteredParticipantIds.includes(participant.participantId);
60988
61054
  });
60989
61055
  var invalidEntries = enteredParticipants.filter(function (participant) {
60990
- var _a;
61056
+ var _a, _b, _c, _d;
60991
61057
  var entryStatus = entryStatusMap[participant.participantId];
60992
61058
  var ungroupedParticipant = eventType &&
60993
61059
  [TypeEnum.Doubles, TypeEnum.Team].includes(eventType) &&
60994
61060
  participant.participantType === INDIVIDUAL &&
60995
61061
  (isUngrouped(entryStatus) || entryStatus === WITHDRAWN);
60996
61062
  var mismatch = participant.participantType !== participantType && !ungroupedParticipant;
60997
- // TODO: implement gender checking for teams & pairs
60998
- var personGender = (_a = participant === null || participant === void 0 ? void 0 : participant.person) === null || _a === void 0 ? void 0 : _a.sex;
60999
- var wrongGender = enforceGender &&
61000
- eventGender &&
61001
- eventType === TypeEnum.Singles &&
61002
- [GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61003
- personGender !== eventGender;
61004
- return mismatch || wrongGender;
61063
+ var pairGender = !mismatch &&
61064
+ isDoubles &&
61065
+ unique((_b = (_a = participant === null || participant === void 0 ? void 0 : participant.individualParticipantIds) === null || _a === void 0 ? void 0 : _a.map(function (id) { var _a, _b, _c; return (_c = (_b = (_a = participantMap === null || participantMap === void 0 ? void 0 : participantMap[id]) === null || _a === void 0 ? void 0 : _a.participant) === null || _b === void 0 ? void 0 : _b.person) === null || _c === void 0 ? void 0 : _c.sex; }).filter(Boolean)) !== null && _b !== void 0 ? _b : []);
61066
+ var validPairGender = !eventGender ||
61067
+ !(pairGender === null || pairGender === void 0 ? void 0 : pairGender.length) ||
61068
+ GenderEnum.Any === eventGender ||
61069
+ ([GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61070
+ pairGender[0] === eventGender) ||
61071
+ (GenderEnum.Mixed === eventGender &&
61072
+ ((pairGender.length == 1 &&
61073
+ ((_c = participant.individualParticipantIds) === null || _c === void 0 ? void 0 : _c.length) === 1) ||
61074
+ pairGender.length === 2));
61075
+ var personGender = (_d = participant === null || participant === void 0 ? void 0 : participant.person) === null || _d === void 0 ? void 0 : _d.sex;
61076
+ var validPersonGender = !(participant === null || participant === void 0 ? void 0 : participant.person) ||
61077
+ !eventGender ||
61078
+ [GenderEnum.Any, GenderEnum.Mixed].includes(eventGender) ||
61079
+ ([GenderEnum.Male, GenderEnum.Female].includes(eventGender) &&
61080
+ personGender === eventGender);
61081
+ var validGender = !genderEnforced || (validPairGender && validPersonGender);
61082
+ return mismatch || !validGender;
61005
61083
  });
61006
61084
  if (invalidEntries.length) {
61007
61085
  var invalidParticipantIds = invalidEntries.map(function (participant) { return participant.participantId; });
61008
61086
  return { error: INVALID_ENTRIES, invalidParticipantIds: invalidParticipantIds };
61009
61087
  }
61010
- return __assign({}, SUCCESS);
61088
+ return __assign(__assign({}, SUCCESS), { valid: true });
61011
61089
  }
61012
61090
 
61013
61091
  function assignSeedPositions(params) {
@@ -62744,7 +62822,7 @@ function substituteParticipant$1(_a) {
62744
62822
  return { error: MISSING_MATCHUP_ID };
62745
62823
  if (!existingParticipantId || !substituteParticipantId)
62746
62824
  return decorateResult({ result: { error: MISSING_PARTICIPANT_ID }, stack: stack });
62747
- var matchUp = findMatchUp$1({
62825
+ var matchUp = findDrawMatchUp({
62748
62826
  drawDefinition: drawDefinition,
62749
62827
  matchUpId: matchUpId,
62750
62828
  event: event,
@@ -63384,7 +63462,7 @@ function applyLineUps(_a) {
63384
63462
  return { error: INVALID_VALUES, lineUps: lineUps };
63385
63463
  var stack = 'applyLineUps';
63386
63464
  var tournamentParticipants = tournamentRecord.participants || [];
63387
- var result = findMatchUp$1({
63465
+ var result = findDrawMatchUp({
63388
63466
  tournamentParticipants: tournamentParticipants,
63389
63467
  inContext: true,
63390
63468
  drawDefinition: drawDefinition,
@@ -63549,7 +63627,7 @@ function applyLineUps(_a) {
63549
63627
  }
63550
63628
  if (!Object.keys(sideAssignments).length)
63551
63629
  return { error: VALUE_UNCHANGED };
63552
- result = findMatchUp$1({ drawDefinition: drawDefinition, matchUpId: matchUpId });
63630
+ result = findDrawMatchUp({ drawDefinition: drawDefinition, matchUpId: matchUpId });
63553
63631
  if (result.error)
63554
63632
  return result;
63555
63633
  if (!result.matchUp)
@@ -63881,10 +63959,10 @@ function generateDrawDefinition(params) {
63881
63959
  DrawTypeEnum.SingleElimination;
63882
63960
  // get participants both for entry validation and for automated placement
63883
63961
  // automated placement requires them to be "inContext" for avoidance policies to work
63884
- var participants = getParticipants$1({
63962
+ var _26 = getParticipants$1({
63885
63963
  withIndividualParticipants: true,
63886
63964
  tournamentRecord: tournamentRecord,
63887
- }).participants;
63965
+ }), participants = _26.participants, participantMap = _26.participantMap;
63888
63966
  var enforceGender = (_r = (_o = params.enforceGender) !== null && _o !== void 0 ? _o : (_q = (_p = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _p === void 0 ? void 0 : _p.participants) === null || _q === void 0 ? void 0 : _q.enforceGender) !== null && _r !== void 0 ? _r : (_t = (_s = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _s === void 0 ? void 0 : _s.participants) === null || _t === void 0 ? void 0 : _t.enforceGender;
63889
63967
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
63890
63968
  // check for restrictions on allowed drawTypes
@@ -63914,6 +63992,8 @@ function generateDrawDefinition(params) {
63914
63992
  participants &&
63915
63993
  checkValidEntries({
63916
63994
  consideredEntries: consideredEntries,
63995
+ appliedPolicies: appliedPolicies,
63996
+ participantMap: participantMap,
63917
63997
  enforceGender: enforceGender,
63918
63998
  participants: participants,
63919
63999
  event: event,
@@ -64052,8 +64132,8 @@ function generateDrawDefinition(params) {
64052
64132
  else {
64053
64133
  var policiesToAttach = {};
64054
64134
  try {
64055
- for (var _26 = __values(Object.keys(policyDefinitions)), _27 = _26.next(); !_27.done; _27 = _26.next()) {
64056
- var key = _27.value;
64135
+ for (var _27 = __values(Object.keys(policyDefinitions)), _28 = _27.next(); !_28.done; _28 = _27.next()) {
64136
+ var key = _28.value;
64057
64137
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
64058
64138
  JSON.stringify(policyDefinitions[key])) {
64059
64139
  policiesToAttach[key] = policyDefinitions[key];
@@ -64063,7 +64143,7 @@ function generateDrawDefinition(params) {
64063
64143
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
64064
64144
  finally {
64065
64145
  try {
64066
- if (_27 && !_27.done && (_a = _26.return)) _a.call(_26);
64146
+ if (_28 && !_28.done && (_a = _27.return)) _a.call(_27);
64067
64147
  }
64068
64148
  finally { if (e_1) throw e_1.error; }
64069
64149
  }
@@ -64115,7 +64195,7 @@ function generateDrawDefinition(params) {
64115
64195
  var source = _a.source;
64116
64196
  return source.structureId !== existingQualifyingPlaceholderStructureId;
64117
64197
  });
64118
- var _28 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _28.qualifiersCount, qualifyingDrawPositionsCount = _28.qualifyingDrawPositionsCount, qualifyingDetails = _28.qualifyingDetails;
64198
+ var _29 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _29.qualifiersCount, qualifyingDrawPositionsCount = _29.qualifyingDrawPositionsCount, qualifyingDetails = _29.qualifyingDetails;
64119
64199
  if (qualifyingDrawPositionsCount) {
64120
64200
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
64121
64201
  (_13 = drawDefinition.structures) === null || _13 === void 0 ? void 0 : _13.push.apply(_13, __spreadArray([], __read(qualifyingResult.structures), false));
@@ -64150,11 +64230,11 @@ function generateDrawDefinition(params) {
64150
64230
  if (result.error)
64151
64231
  return result;
64152
64232
  try {
64153
- for (var _29 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64233
+ for (var _30 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
64154
64234
  var entryStage = _a.entryStage;
64155
64235
  return entryStage === StageTypeEnum.Qualifying;
64156
- })), _30 = _29.next(); !_30.done; _30 = _29.next()) {
64157
- var entry = _30.value;
64236
+ })), _31 = _30.next(); !_31.done; _31 = _30.next()) {
64237
+ var entry = _31.value;
64158
64238
  var entryData = __assign(__assign({}, entry), { entryStage: (_16 = entry.entryStage) !== null && _16 !== void 0 ? _16 : StageTypeEnum.Main, drawDefinition: drawDefinition });
64159
64239
  // ignore errors (EXITING_PARTICIPANT)
64160
64240
  addDrawEntry(entryData);
@@ -64163,13 +64243,13 @@ function generateDrawDefinition(params) {
64163
64243
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
64164
64244
  finally {
64165
64245
  try {
64166
- if (_30 && !_30.done && (_b = _29.return)) _b.call(_29);
64246
+ if (_31 && !_31.done && (_b = _30.return)) _b.call(_30);
64167
64247
  }
64168
64248
  finally { if (e_2) throw e_2.error; }
64169
64249
  }
64170
64250
  try {
64171
- for (var _31 = __values(qualifyingDetails || []), _32 = _31.next(); !_32.done; _32 = _31.next()) {
64172
- var qualifyingDetail = _32.value;
64251
+ for (var _32 = __values(qualifyingDetails || []), _33 = _32.next(); !_33.done; _33 = _32.next()) {
64252
+ var qualifyingDetail = _33.value;
64173
64253
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
64174
64254
  var link = mainStructure &&
64175
64255
  ((_17 = generateQualifyingLink({
@@ -64192,7 +64272,7 @@ function generateDrawDefinition(params) {
64192
64272
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
64193
64273
  finally {
64194
64274
  try {
64195
- if (_32 && !_32.done && (_c = _31.return)) _c.call(_31);
64275
+ if (_33 && !_33.done && (_c = _32.return)) _c.call(_32);
64196
64276
  }
64197
64277
  finally { if (e_3) throw e_3.error; }
64198
64278
  }
@@ -64290,8 +64370,8 @@ function generateDrawDefinition(params) {
64290
64370
  var roundTarget = 1;
64291
64371
  params.qualifyingProfiles.sort(roundTargetSort);
64292
64372
  try {
64293
- for (var _33 = __values(params.qualifyingProfiles), _34 = _33.next(); !_34.done; _34 = _33.next()) {
64294
- var roundTargetProfile = _34.value;
64373
+ for (var _34 = __values(params.qualifyingProfiles), _35 = _34.next(); !_35.done; _35 = _34.next()) {
64374
+ var roundTargetProfile = _35.value;
64295
64375
  if (!Array.isArray(roundTargetProfile.structureProfiles))
64296
64376
  return decorateResult({
64297
64377
  info: mustBeAnArray('structureProfiles'),
@@ -64304,7 +64384,7 @@ function generateDrawDefinition(params) {
64304
64384
  try {
64305
64385
  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()) {
64306
64386
  var structureProfile = sortedStructureProfiles_1_1.value;
64307
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _35 = structureProfile.seedsCount, seedsCount_1 = _35 === void 0 ? 0 : _35, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
64387
+ var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _36 = structureProfile.seedsCount, seedsCount_1 = _36 === void 0 ? 0 : _36, seedingProfile = structureProfile.seedingProfile, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
64308
64388
  var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedingProfile: seedingProfile, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
64309
64389
  if (qualifyingStageResult.error) {
64310
64390
  return qualifyingStageResult;
@@ -64334,7 +64414,7 @@ function generateDrawDefinition(params) {
64334
64414
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
64335
64415
  finally {
64336
64416
  try {
64337
- if (_34 && !_34.done && (_f = _33.return)) _f.call(_33);
64417
+ if (_35 && !_35.done && (_f = _34.return)) _f.call(_34);
64338
64418
  }
64339
64419
  finally { if (e_5) throw e_5.error; }
64340
64420
  }
@@ -70675,6 +70755,7 @@ var utilities = {
70675
70755
  unique: unique,
70676
70756
  UUID: UUID,
70677
70757
  UUIDS: UUIDS,
70758
+ validateCategory: validateCategory,
70678
70759
  validateTieFormat: validateTieFormat,
70679
70760
  visualizeScheduledMatchUps: visualizeScheduledMatchUps,
70680
70761
  };