tods-competition-factory 1.6.18 → 1.6.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.
@@ -362,7 +362,7 @@ var matchUpFormatCode = {
362
362
  };
363
363
 
364
364
  function factoryVersion() {
365
- return '1.6.18';
365
+ return '1.6.20';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -7455,14 +7455,14 @@ function getRoundMatchUps$1(_a) {
7455
7455
  roundIndex += 1;
7456
7456
  }
7457
7457
  });
7458
- var isNotEliminationStructure = !!Object.values(roundProfile).find(function (_a) {
7458
+ var roundsNotPowerOf2 = !!Object.values(roundProfile).find(function (_a) {
7459
7459
  var matchUpsCount = _a.matchUpsCount;
7460
7460
  return !isPowerOf2(matchUpsCount);
7461
7461
  });
7462
7462
  var hasNoRoundPositions = matchUps.some(function (matchUp) { return !matchUp.roundPosition; });
7463
7463
  return {
7464
- isNotEliminationStructure: isNotEliminationStructure,
7465
7464
  hasNoRoundPositions: hasNoRoundPositions,
7465
+ roundsNotPowerOf2: roundsNotPowerOf2,
7466
7466
  maxMatchUpsCount: maxMatchUpsCount,
7467
7467
  roundMatchUps: roundMatchUps,
7468
7468
  roundNumbers: roundNumbers,
@@ -8934,42 +8934,38 @@ function filterMatchUps(params) {
8934
8934
  }
8935
8935
 
8936
8936
  function isLucky(_a) {
8937
- var _b;
8938
- var _c, _d, _e;
8939
- var isNotEliminationStructure = _a.isNotEliminationStructure, drawDefinition = _a.drawDefinition, roundMatchUps = _a.roundMatchUps, structure = _a.structure;
8937
+ var _b, _c;
8938
+ var roundsNotPowerOf2 = _a.roundsNotPowerOf2, drawDefinition = _a.drawDefinition, structure = _a.structure, matchUps = _a.matchUps;
8940
8939
  if (!structure)
8941
8940
  return false;
8942
- if (!roundMatchUps) {
8943
- (_b = getRoundMatchUps$1({
8944
- matchUps: (_c = structure.matchUps) !== null && _c !== void 0 ? _c : [],
8945
- }), isNotEliminationStructure = _b.isNotEliminationStructure, roundMatchUps = _b.roundMatchUps);
8946
- }
8947
- var hasFirstRoundDrawPositions = !!((_d = roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps[1]) === null || _d === void 0 ? void 0 : _d.find(function (_a) {
8948
- var drawPositions = _a.drawPositions;
8949
- return drawPositions;
8950
- }));
8951
- var noSecondRoundDrawPositions = !((_e = roundMatchUps === null || roundMatchUps === void 0 ? void 0 : roundMatchUps[2]) === null || _e === void 0 ? void 0 : _e.find(function (_a) {
8952
- var drawPositions = _a.drawPositions;
8953
- return drawPositions;
8954
- }));
8955
- return (isNotEliminationStructure &&
8941
+ matchUps = (_b = matchUps !== null && matchUps !== void 0 ? matchUps : structure.matchUps) !== null && _b !== void 0 ? _b : [];
8942
+ roundsNotPowerOf2 =
8943
+ roundsNotPowerOf2 !== null && roundsNotPowerOf2 !== void 0 ? roundsNotPowerOf2 : getRoundMatchUps$1({ matchUps: matchUps }).roundsNotPowerOf2;
8944
+ var hasDrawPositions = !!((_c = structure.positionAssignments) === null || _c === void 0 ? void 0 : _c.find(function (_a) {
8945
+ var drawPosition = _a.drawPosition;
8946
+ return drawPosition;
8947
+ })) ||
8948
+ !!(matchUps === null || matchUps === void 0 ? void 0 : matchUps.find(function (_a) {
8949
+ var drawPositions = _a.drawPositions;
8950
+ return drawPositions === null || drawPositions === void 0 ? void 0 : drawPositions.length;
8951
+ }));
8952
+ return ((!(drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawType) || drawDefinition.drawType !== LUCKY_DRAW) &&
8956
8953
  !(structure === null || structure === void 0 ? void 0 : structure.structures) &&
8957
- hasFirstRoundDrawPositions &&
8958
- noSecondRoundDrawPositions &&
8959
- !((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawType) && drawDefinition.drawType !== LUCKY_DRAW));
8954
+ roundsNotPowerOf2 &&
8955
+ hasDrawPositions);
8960
8956
  }
8961
8957
 
8962
8958
  function isAdHoc(_a) {
8963
- var _b;
8959
+ var _b, _c;
8964
8960
  var drawDefinition = _a.drawDefinition, structure = _a.structure;
8965
8961
  if (!structure)
8966
8962
  return false;
8963
+ var hasRoundPosition = (_b = structure === null || structure === void 0 ? void 0 : structure.matchUps) === null || _b === void 0 ? void 0 : _b.find(function (matchUp) { return matchUp === null || matchUp === void 0 ? void 0 : matchUp.roundPosition; });
8964
+ var hasDrawPosition = (_c = structure === null || structure === void 0 ? void 0 : structure.matchUps) === null || _c === void 0 ? void 0 : _c.find(function (matchUp) { var _a; return (_a = matchUp === null || matchUp === void 0 ? void 0 : matchUp.drawPositions) === null || _a === void 0 ? void 0 : _a.length; });
8967
8965
  return (!(structure === null || structure === void 0 ? void 0 : structure.structures) &&
8968
8966
  !((drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.drawType) && drawDefinition.drawType !== AD_HOC) &&
8969
- !((_b = structure === null || structure === void 0 ? void 0 : structure.matchUps) === null || _b === void 0 ? void 0 : _b.find(function (_a) {
8970
- var roundPosition = _a.roundPosition;
8971
- return !!roundPosition;
8972
- })));
8967
+ !hasRoundPosition &&
8968
+ !hasDrawPosition);
8973
8969
  }
8974
8970
 
8975
8971
  var _a$h, _b$4;
@@ -9002,14 +8998,10 @@ var POLICY_ROUND_NAMING_DEFAULT = (_a$h = {},
9002
8998
 
9003
8999
  function getRoundContextProfile(_a) {
9004
9000
  var roundNamingPolicy = _a.roundNamingPolicy, structure = _a.structure, matchUps = _a.matchUps;
9005
- var _b = getRoundMatchUps$1({ matchUps: matchUps }), isNotEliminationStructure = _b.isNotEliminationStructure, roundProfile = _b.roundProfile, roundMatchUps = _b.roundMatchUps;
9001
+ var _b = getRoundMatchUps$1({ matchUps: matchUps }), roundProfile = _b.roundProfile, roundMatchUps = _b.roundMatchUps;
9006
9002
  var structureAbbreviation = structure.structureAbbreviation, stage = structure.stage;
9007
9003
  var isAdHocStructure = isAdHoc({ structure: structure });
9008
- var isLuckyStructure = isLucky({
9009
- isNotEliminationStructure: isNotEliminationStructure,
9010
- roundMatchUps: roundMatchUps,
9011
- structure: structure,
9012
- });
9004
+ var isLuckyStructure = isLucky({ structure: structure });
9013
9005
  var isRoundRobin = structure.structures;
9014
9006
  var roundNamingProfile = {};
9015
9007
  var defaultRoundNamingPolicy = POLICY_ROUND_NAMING_DEFAULT[POLICY_TYPE_ROUND_NAMING];
@@ -25060,11 +25052,11 @@ function getValidSeedBlocks(_a) {
25060
25052
  var validSeedBlocks = [];
25061
25053
  if (!structure)
25062
25054
  return { error: MISSING_STRUCTURE };
25063
- var roundMatchUps = getAllStructureMatchUps({
25055
+ var _d = getAllStructureMatchUps({
25064
25056
  matchUpFilters: { roundNumbers: [1] },
25065
25057
  provisionalPositioning: provisionalPositioning,
25066
25058
  structure: structure,
25067
- }).roundMatchUps;
25059
+ }), matchUps = _d.matchUps, roundMatchUps = _d.roundMatchUps;
25068
25060
  var seedAssignments = getStructureSeedAssignments({
25069
25061
  provisionalPositioning: provisionalPositioning,
25070
25062
  drawDefinition: drawDefinition,
@@ -25099,14 +25091,16 @@ function getValidSeedBlocks(_a) {
25099
25091
  var stage = structure.stage, structureType = structure.structureType, roundLimit = structure.roundLimit;
25100
25092
  var isContainer = structureType === CONTAINER;
25101
25093
  var isFeedIn = !isContainer && (uniqueDrawPositionsByRound === null || uniqueDrawPositionsByRound === void 0 ? void 0 : uniqueDrawPositionsByRound.length);
25102
- // if there are first round draw positions it is not AdHoc
25103
- // if the baseDrawSize is not a power of 2 then it isLucky
25104
- var isLucky = (firstRoundDrawPositions === null || firstRoundDrawPositions === void 0 ? void 0 : firstRoundDrawPositions.length) && !isPowerOf2(baseDrawSize);
25105
25094
  var qualifyingBlocks = !isContainer && stage === QUALIFYING && roundLimit;
25106
25095
  var fedSeedBlockPositions = seedRangeDrawPositionBlocks.flat(Infinity);
25107
25096
  var fedSeedNumberOffset = isFeedIn ? fedSeedBlockPositions === null || fedSeedBlockPositions === void 0 ? void 0 : fedSeedBlockPositions.length : 0;
25108
25097
  var countLimit = allPositions ? positionsCount : seedsCount;
25109
- var firstRoundSeedsCount = isLucky
25098
+ var isLuckyStructure = isLucky({
25099
+ drawDefinition: drawDefinition,
25100
+ structure: structure,
25101
+ matchUps: matchUps,
25102
+ });
25103
+ var firstRoundSeedsCount = isLuckyStructure
25110
25104
  ? 0
25111
25105
  : (!isFeedIn && countLimit) ||
25112
25106
  (countLimit &&
@@ -25153,17 +25147,14 @@ function getValidSeedBlocks(_a) {
25153
25147
  return { seedNumbers: block, drawPositions: block };
25154
25148
  });
25155
25149
  }
25156
- else if (isLucky) {
25157
- // if there are first round draw positions it is not AdHoc
25158
- // if the baseDrawSize is not a power of 2 then it isLucky
25159
- // firstRoundSeedsCount = 0;
25150
+ else if (isLuckyStructure) {
25160
25151
  var blocks = chunkArray(firstRoundDrawPositions, 2).map(function (block, i) { return ({
25161
25152
  drawPositions: [block[0]],
25162
25153
  seedNumbers: [i + 1],
25163
25154
  }); });
25164
25155
  blocks.forEach(function (block) { return validSeedBlocks.push(block); });
25165
25156
  }
25166
- if (!isContainer && !isLucky && !qualifyingBlocks) {
25157
+ if (!isContainer && !isLuckyStructure && !qualifyingBlocks) {
25167
25158
  var blocks = constructPower2Blocks({
25168
25159
  drawPositionOffset: firstRoundDrawPositionOffset,
25169
25160
  seedNumberOffset: fedSeedNumberOffset,
@@ -25177,7 +25168,7 @@ function getValidSeedBlocks(_a) {
25177
25168
  var validSeedPositions = seedDrawPositions.reduce(function (result, drawPosition) {
25178
25169
  return (firstRoundDrawPositions === null || firstRoundDrawPositions === void 0 ? void 0 : firstRoundDrawPositions.includes(drawPosition)) && result;
25179
25170
  }, true);
25180
- if (!isLucky && !isFeedIn && !isContainer && !validSeedPositions) {
25171
+ if (!isLuckyStructure && !isFeedIn && !isContainer && !validSeedPositions) {
25181
25172
  return {
25182
25173
  error: INVALID_SEED_POSITION,
25183
25174
  validSeedBlocks: [],
@@ -25186,10 +25177,10 @@ function getValidSeedBlocks(_a) {
25186
25177
  };
25187
25178
  }
25188
25179
  return {
25180
+ isLuckyStructure: isLuckyStructure,
25189
25181
  validSeedBlocks: validSeedBlocks,
25190
25182
  isContainer: isContainer,
25191
25183
  isFeedIn: isFeedIn,
25192
- isLucky: isLucky,
25193
25184
  };
25194
25185
  }
25195
25186
  function getContainerBlocks(_a) {
@@ -25511,6 +25502,72 @@ function getTargetMatchUps(_a) {
25511
25502
  return { drawPositions: drawPositions, matchUps: matchUps, targetMatchUps: targetMatchUps };
25512
25503
  }
25513
25504
 
25505
+ function validateLineUp(_a) {
25506
+ var lineUp = _a.lineUp; _a.tieFormat;
25507
+ var errors = [];
25508
+ if (!Array.isArray(lineUp)) {
25509
+ errors.push(mustBeAnArray('lineUp'));
25510
+ return { valid: false, errors: errors, error: INVALID_VALUES };
25511
+ }
25512
+ var validItems = lineUp.every(function (item) {
25513
+ if (typeof item !== 'object') {
25514
+ errors.push("lineUp entries must be objects");
25515
+ return false;
25516
+ }
25517
+ var participantId = item.participantId, collectionAssignments = item.collectionAssignments;
25518
+ if (!participantId) {
25519
+ errors.push('Missing participantId');
25520
+ return false;
25521
+ }
25522
+ if (typeof participantId !== 'string') {
25523
+ errors.push('participantIds must be strings');
25524
+ return false;
25525
+ }
25526
+ if (!Array.isArray(collectionAssignments)) {
25527
+ errors.push(mustBeAnArray('collectionAssignments'));
25528
+ return false;
25529
+ }
25530
+ return collectionAssignments.every(function (collectionAssignment) {
25531
+ if (typeof collectionAssignment !== 'object') {
25532
+ errors.push('collectionAssignments must be objects');
25533
+ return false;
25534
+ }
25535
+ var collectionPosition = collectionAssignment.collectionPosition;
25536
+ if (typeof collectionPosition !== 'number') {
25537
+ errors.push('collectionPosition must be a number');
25538
+ return false;
25539
+ }
25540
+ return true;
25541
+ });
25542
+ });
25543
+ var noDuplicates = unique(lineUp.map(getParticipantId)).length === lineUp.length;
25544
+ if (!noDuplicates)
25545
+ errors.push('Duplicated participantId(s)');
25546
+ var valid = validItems && noDuplicates;
25547
+ return { valid: valid, errors: errors, error: errors.length ? INVALID_VALUES : undefined };
25548
+ }
25549
+
25550
+ function updateTeamLineUp(_a) {
25551
+ var drawDefinition = _a.drawDefinition, participantId = _a.participantId, tieFormat = _a.tieFormat, lineUp = _a.lineUp;
25552
+ if (typeof drawDefinition !== 'object')
25553
+ return { error: MISSING_DRAW_DEFINITION };
25554
+ if (typeof participantId !== 'string')
25555
+ return { error: MISSING_PARTICIPANT_ID };
25556
+ var validation = validateLineUp({ lineUp: lineUp, tieFormat: tieFormat });
25557
+ if (!validation.valid)
25558
+ return validation;
25559
+ var existingExtension = findExtension({
25560
+ element: drawDefinition,
25561
+ name: LINEUPS,
25562
+ }).extension;
25563
+ var value = (existingExtension === null || existingExtension === void 0 ? void 0 : existingExtension.value) || {};
25564
+ value[participantId] = removeLineUpSubstitutions({ lineUp: lineUp });
25565
+ var extension = { name: LINEUPS, value: value };
25566
+ addExtension$1({ element: drawDefinition, extension: extension });
25567
+ addDrawNotice({ drawDefinition: drawDefinition });
25568
+ return __assign({}, SUCCESS);
25569
+ }
25570
+
25514
25571
  function resetLineUps(_a) {
25515
25572
  var e_1, _b;
25516
25573
  var inContextDrawMatchUps = _a.inContextDrawMatchUps, _c = _a.inheritance, inheritance = _c === void 0 ? true : _c, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpsMap = _a.matchUpsMap, assignments = _a.assignments, structure = _a.structure, event = _a.event;
@@ -25533,11 +25590,19 @@ function resetLineUps(_a) {
25533
25590
  return matchUpId === inContextMatchUp.matchUpId;
25534
25591
  });
25535
25592
  if ((_a = matchUp === null || matchUp === void 0 ? void 0 : matchUp.sides) === null || _a === void 0 ? void 0 : _a[sideIndex]) {
25536
- if (inheritance) {
25537
- delete matchUp.sides[sideIndex].lineUp;
25538
- }
25539
- else {
25540
- matchUp.sides[sideIndex].lineUp = [];
25593
+ delete matchUp.sides[sideIndex].lineUp;
25594
+ if (inheritance === false) {
25595
+ // remove lineup for team participantId from drawDefinition LINE_UP extension
25596
+ var tieFormat = inContextMatchUp.tieFormat;
25597
+ var participantId = side.participantId;
25598
+ if (tieFormat && participantId) {
25599
+ updateTeamLineUp({
25600
+ drawDefinition: drawDefinition,
25601
+ participantId: participantId,
25602
+ lineUp: [],
25603
+ tieFormat: tieFormat,
25604
+ });
25605
+ }
25541
25606
  }
25542
25607
  modifyMatchUpNotice({
25543
25608
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
@@ -43547,7 +43612,7 @@ function getSeedOrderByePositions(_a) {
43547
43612
  structure: structure,
43548
43613
  });
43549
43614
  }
43550
- var isFeedIn = seedBlockInfo.isFeedIn, isLucky = seedBlockInfo.isLucky, isContainer = seedBlockInfo.isContainer;
43615
+ var isFeedIn = seedBlockInfo.isFeedIn, isLuckyStructure = seedBlockInfo.isLuckyStructure, isContainer = seedBlockInfo.isContainer;
43551
43616
  var validSeedBlocks = seedBlockInfo.validSeedBlocks;
43552
43617
  if ((_b = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.seeding) === null || _b === void 0 ? void 0 : _b.containerByesIgnoreSeeding)
43553
43618
  validSeedBlocks = [];
@@ -43593,10 +43658,10 @@ function getSeedOrderByePositions(_a) {
43593
43658
  return {
43594
43659
  strictSeedOrderByePositions: strictSeedOrderByePositions,
43595
43660
  blockSeedOrderByePositions: blockSeedOrderByePositions,
43661
+ isLuckyStructure: isLuckyStructure,
43596
43662
  positionedSeeds: positionedSeeds,
43597
43663
  isContainer: isContainer,
43598
43664
  isFeedIn: isFeedIn,
43599
- isLucky: isLucky,
43600
43665
  };
43601
43666
  }
43602
43667
  function getOrderedByePositions(_a) {
@@ -43627,7 +43692,7 @@ function getOrderedByePositions(_a) {
43627
43692
 
43628
43693
  function getUnseededByePositions(_a) {
43629
43694
  var _b, _c;
43630
- var provisionalPositioning = _a.provisionalPositioning, seedOrderByePositions = _a.seedOrderByePositions, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedLimit = _a.seedLimit, structure = _a.structure, isFeedIn = _a.isFeedIn; _a.isLucky;
43695
+ var provisionalPositioning = _a.provisionalPositioning, seedOrderByePositions = _a.seedOrderByePositions; _a.isLuckyStructure; var appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, seedLimit = _a.seedLimit, structure = _a.structure, isFeedIn = _a.isFeedIn;
43631
43696
  var seedingProfile = (_b = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.seeding) === null || _b === void 0 ? void 0 : _b.seedingProfile;
43632
43697
  var isQualifying = structure.stage === QUALIFYING;
43633
43698
  var positionAssignments = structureAssignedDrawPositions({ structure: structure }).positionAssignments;
@@ -43861,7 +43926,7 @@ function positionByes(_a) {
43861
43926
  seedBlockInfo: seedBlockInfo,
43862
43927
  byesToPlace: byesToPlace,
43863
43928
  structure: structure,
43864
- }), strictSeedOrderByePositions = _f.strictSeedOrderByePositions, blockSeedOrderByePositions = _f.blockSeedOrderByePositions, isFeedIn = _f.isFeedIn, isLucky = _f.isLucky;
43929
+ }), strictSeedOrderByePositions = _f.strictSeedOrderByePositions, blockSeedOrderByePositions = _f.blockSeedOrderByePositions, isLuckyStructure = _f.isLuckyStructure, isFeedIn = _f.isFeedIn;
43865
43930
  var ignoreSeededByes = (structure === null || structure === void 0 ? void 0 : structure.structureType) &&
43866
43931
  [CONTAINER, ITEM].includes(structure.structureType) &&
43867
43932
  ((_d = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies.seeding) === null || _d === void 0 ? void 0 : _d.containerByesIgnoreSeeding);
@@ -43871,12 +43936,12 @@ function positionByes(_a) {
43871
43936
  var unseededByePositions = getUnseededByePositions({
43872
43937
  provisionalPositioning: provisionalPositioning,
43873
43938
  seedOrderByePositions: seedOrderByePositions,
43939
+ isLuckyStructure: isLuckyStructure,
43874
43940
  appliedPolicies: appliedPolicies,
43875
43941
  drawDefinition: drawDefinition,
43876
43942
  seedLimit: seedLimit,
43877
43943
  structure: structure,
43878
43944
  isFeedIn: isFeedIn,
43879
- isLucky: isLucky,
43880
43945
  }).unseededByePositions;
43881
43946
  var isOdd = function (x) { return x % 2; };
43882
43947
  // method determines whether candidate c is paired to elements in an array
@@ -48220,24 +48285,37 @@ function roundRobinSwap(_a) {
48220
48285
 
48221
48286
  function resetMatchUpLineUps$1(_a) {
48222
48287
  var _b;
48223
- var tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, inheritance = _a.inheritance, matchUpId = _a.matchUpId, event = _a.event;
48288
+ var _c = _a.inheritance, inheritance = _c === void 0 ? true : _c, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, matchUpId = _a.matchUpId, event = _a.event;
48224
48289
  if (!drawDefinition)
48225
48290
  return { error: MISSING_DRAW_DEFINITION };
48226
48291
  var matchUp = (_b = findMatchUp$1({
48227
- inContext: true,
48228
48292
  drawDefinition: drawDefinition,
48229
48293
  matchUpId: matchUpId,
48230
48294
  })) === null || _b === void 0 ? void 0 : _b.matchUp;
48231
- if ((matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpType) !== TEAM_MATCHUP)
48295
+ if (!(matchUp === null || matchUp === void 0 ? void 0 : matchUp.tieMatchUps))
48232
48296
  return { error: INVALID_MATCHUP };
48233
48297
  var modificationsCount = 0;
48234
48298
  (matchUp.sides || []).forEach(function (side) {
48299
+ var _a;
48235
48300
  modificationsCount += 1;
48236
- if (inheritance) {
48237
- delete side.lineUp;
48238
- }
48239
- else {
48240
- side.lineUp = [];
48301
+ delete side.lineUp;
48302
+ if (inheritance === false) {
48303
+ // remove lineup for team participantId from drawDefinition LINE_UP extension
48304
+ var inContextMatchUp = (_a = findMatchUp$1({
48305
+ inContext: true,
48306
+ drawDefinition: drawDefinition,
48307
+ matchUpId: matchUpId,
48308
+ })) === null || _a === void 0 ? void 0 : _a.matchUp;
48309
+ var tieFormat = inContextMatchUp === null || inContextMatchUp === void 0 ? void 0 : inContextMatchUp.tieFormat;
48310
+ var participantId = side.participantId;
48311
+ if (tieFormat && participantId) {
48312
+ updateTeamLineUp({
48313
+ drawDefinition: drawDefinition,
48314
+ participantId: participantId,
48315
+ lineUp: [],
48316
+ tieFormat: tieFormat,
48317
+ });
48318
+ }
48241
48319
  }
48242
48320
  modifyMatchUpNotice({
48243
48321
  tournamentId: tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.tournamentId,
@@ -55751,72 +55829,6 @@ function removeCollectionAssignments(_a) {
55751
55829
  return { modifiedLineUp: modifiedLineUp, assignmentsRemoved: assignmentsRemoved, previousParticipantIds: previousParticipantIds };
55752
55830
  }
55753
55831
 
55754
- function validateLineUp(_a) {
55755
- var lineUp = _a.lineUp; _a.tieFormat;
55756
- var errors = [];
55757
- if (!Array.isArray(lineUp)) {
55758
- errors.push(mustBeAnArray('lineUp'));
55759
- return { valid: false, errors: errors, error: INVALID_VALUES };
55760
- }
55761
- var validItems = lineUp.every(function (item) {
55762
- if (typeof item !== 'object') {
55763
- errors.push("lineUp entries must be objects");
55764
- return false;
55765
- }
55766
- var participantId = item.participantId, collectionAssignments = item.collectionAssignments;
55767
- if (!participantId) {
55768
- errors.push('Missing participantId');
55769
- return false;
55770
- }
55771
- if (typeof participantId !== 'string') {
55772
- errors.push('participantIds must be strings');
55773
- return false;
55774
- }
55775
- if (!Array.isArray(collectionAssignments)) {
55776
- errors.push(mustBeAnArray('collectionAssignments'));
55777
- return false;
55778
- }
55779
- return collectionAssignments.every(function (collectionAssignment) {
55780
- if (typeof collectionAssignment !== 'object') {
55781
- errors.push('collectionAssignments must be objects');
55782
- return false;
55783
- }
55784
- var collectionPosition = collectionAssignment.collectionPosition;
55785
- if (typeof collectionPosition !== 'number') {
55786
- errors.push('collectionPosition must be a number');
55787
- return false;
55788
- }
55789
- return true;
55790
- });
55791
- });
55792
- var noDuplicates = unique(lineUp.map(getParticipantId)).length === lineUp.length;
55793
- if (!noDuplicates)
55794
- errors.push('Duplicated participantId(s)');
55795
- var valid = validItems && noDuplicates;
55796
- return { valid: valid, errors: errors, error: errors.length ? INVALID_VALUES : undefined };
55797
- }
55798
-
55799
- function updateTeamLineUp(_a) {
55800
- var drawDefinition = _a.drawDefinition, participantId = _a.participantId, tieFormat = _a.tieFormat, lineUp = _a.lineUp;
55801
- if (typeof drawDefinition !== 'object')
55802
- return { error: MISSING_DRAW_DEFINITION };
55803
- if (typeof participantId !== 'string')
55804
- return { error: MISSING_PARTICIPANT_ID };
55805
- var validation = validateLineUp({ lineUp: lineUp, tieFormat: tieFormat });
55806
- if (!validation.valid)
55807
- return validation;
55808
- var existingExtension = findExtension({
55809
- element: drawDefinition,
55810
- name: LINEUPS,
55811
- }).extension;
55812
- var value = (existingExtension === null || existingExtension === void 0 ? void 0 : existingExtension.value) || {};
55813
- value[participantId] = removeLineUpSubstitutions({ lineUp: lineUp });
55814
- var extension = { name: LINEUPS, value: value };
55815
- addExtension$1({ element: drawDefinition, extension: extension });
55816
- addDrawNotice({ drawDefinition: drawDefinition });
55817
- return __assign({}, SUCCESS);
55818
- }
55819
-
55820
55832
  // for a given tieMatchUpId (SINGLES or DOUBLES) return:
55821
55833
  // the tieMatchUp, the dualMatchUp within which it occurs, an inContext copy of the dualMatchUp
55822
55834
  // the tieFormat, collectionId and collectionPosition & etc.