tods-competition-factory 1.7.8 → 1.7.10

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.7.8';
365
+ return '1.7.10';
366
366
  }
367
367
 
368
368
  /******************************************************************************
@@ -5095,7 +5095,7 @@ function evaluateCollectionResult(_a) {
5095
5095
  if (matchUp.winningSide)
5096
5096
  sideWins[matchUp.winningSide - 1] += 1;
5097
5097
  });
5098
- if (matchUpValue) {
5098
+ if (isConvertableInteger(matchUpValue)) {
5099
5099
  // if tiebreak set count as set value and game value
5100
5100
  collectionMatchUps.forEach(function (matchUp) {
5101
5101
  if (matchUp.winningSide) {
@@ -5103,7 +5103,7 @@ function evaluateCollectionResult(_a) {
5103
5103
  }
5104
5104
  });
5105
5105
  }
5106
- else if (setValue) {
5106
+ else if (isConvertableInteger(setValue)) {
5107
5107
  collectionMatchUps.forEach(function (matchUp) {
5108
5108
  var _a, _b;
5109
5109
  (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
@@ -5112,7 +5112,7 @@ function evaluateCollectionResult(_a) {
5112
5112
  });
5113
5113
  });
5114
5114
  }
5115
- else if (scoreValue) {
5115
+ else if (isConvertableInteger(scoreValue)) {
5116
5116
  collectionMatchUps.forEach(function (matchUp) {
5117
5117
  var _a, _b;
5118
5118
  (_b = (_a = matchUp.score) === null || _a === void 0 ? void 0 : _a.sets) === null || _b === void 0 ? void 0 : _b.forEach(function (set) {
@@ -5141,16 +5141,18 @@ function evaluateCollectionResult(_a) {
5141
5141
  collectionDefinition: collectionDefinition,
5142
5142
  collectionPosition: collectionPosition,
5143
5143
  });
5144
- sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue_1;
5144
+ if (isConvertableInteger(matchUpValue_1)) {
5145
+ sideMatchUpValues[matchUp.winningSide - 1] += matchUpValue_1;
5146
+ }
5145
5147
  }
5146
5148
  });
5147
5149
  }
5148
5150
  // processed separately so that setValue, scoreValue and collecitonValueProfile can be used in conjunction with collectionValue
5149
- if (collectionValue) {
5151
+ if (isConvertableInteger(collectionValue)) {
5150
5152
  var collectionWinningSide = void 0;
5151
5153
  if (winCriteria === null || winCriteria === void 0 ? void 0 : winCriteria.aggregateValue) {
5152
5154
  if (allCollectionMatchUpsCompleted) {
5153
- if ((matchUpValue || setValue || scoreValue) &&
5155
+ if (isConvertableInteger(matchUpValue || setValue || scoreValue) &&
5154
5156
  sideMatchUpValues[0] !== sideMatchUpValues[1]) {
5155
5157
  collectionWinningSide =
5156
5158
  sideMatchUpValues[0] > sideMatchUpValues[1] ? 1 : 2;
@@ -5192,7 +5194,7 @@ function evaluateCollectionResult(_a) {
5192
5194
  }
5193
5195
  }
5194
5196
  if (!belongsToValueGroup) {
5195
- sideCollectionValues.forEach(function (sideCollectionValue, i) { return (sideTieValues[i] += sideCollectionValue); });
5197
+ sideCollectionValues.forEach(function (sideCollectionValue, i) { return (sideTieValues[i] += sideCollectionValue || 0); });
5196
5198
  }
5197
5199
  else {
5198
5200
  groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
@@ -9830,7 +9832,9 @@ function getGroupValueGroups(_a) {
9830
9832
  var _b = _a.collectionGroups, collectionGroups = _b === void 0 ? [] : _b;
9831
9833
  // set up to handle groupValue
9832
9834
  var groupValueGroups = Object.assign.apply(Object, __spreadArray([{}], __read(collectionGroups
9833
- .filter(function (group) { return (group === null || group === void 0 ? void 0 : group.groupValue) && (group === null || group === void 0 ? void 0 : group.groupNumber); })
9835
+ .filter(function (group) {
9836
+ return isConvertableInteger(group === null || group === void 0 ? void 0 : group.groupValue) && (group === null || group === void 0 ? void 0 : group.groupNumber);
9837
+ })
9834
9838
  .map(function (group) {
9835
9839
  var _a;
9836
9840
  return (_a = {},
@@ -9907,7 +9911,7 @@ function generateTieMatchUpScore(params) {
9907
9911
  }, undefined);
9908
9912
  }
9909
9913
  if (groupWinningSide) {
9910
- sideTieValues[groupWinningSide - 1] += groupValue;
9914
+ sideTieValues[groupWinningSide - 1] += groupValue || 0;
9911
9915
  }
9912
9916
  };
9913
9917
  try {
@@ -9924,7 +9928,7 @@ function generateTieMatchUpScore(params) {
9924
9928
  }
9925
9929
  finally { if (e_2) throw e_2.error; }
9926
9930
  }
9927
- var sideScores = sideTieValues.map(function (sideTieValue, i) { return sideTieValue + sideAdjustments[i]; });
9931
+ var sideScores = sideTieValues.map(function (sideTieValue, i) { return (sideTieValue || 0) + sideAdjustments[i]; });
9928
9932
  var set = {
9929
9933
  side1Score: sideScores[0],
9930
9934
  side2Score: sideScores[1],
@@ -16697,7 +16701,7 @@ function calculateWinCriteria(_a) {
16697
16701
  var collectionValueProfiles = collectionDefinition.collectionValueProfiles, collectionGroupNumber = collectionDefinition.collectionGroupNumber, collectionValue = collectionDefinition.collectionValue, matchUpCount = collectionDefinition.matchUpCount, matchUpValue = collectionDefinition.matchUpValue, scoreValue = collectionDefinition.scoreValue, setValue = collectionDefinition.setValue;
16698
16702
  var belongsToValueGroup = collectionGroupNumber &&
16699
16703
  groupValueNumbers.includes(collectionGroupNumber);
16700
- if (setValue || scoreValue) {
16704
+ if (isConvertableInteger(setValue || scoreValue)) {
16701
16705
  // because setValues and scoreValues are unpredictable,
16702
16706
  // any collectionDefintion that has either of these two values without a collectionValue forces the tieFormat to aggregateValue
16703
16707
  aggregateValueImperative = true;
@@ -16705,7 +16709,8 @@ function calculateWinCriteria(_a) {
16705
16709
  else if (belongsToValueGroup) {
16706
16710
  continue;
16707
16711
  }
16708
- else if (collectionValue) {
16712
+ else if (typeof collectionValue === 'number' &&
16713
+ isConvertableInteger(collectionValue)) {
16709
16714
  valueTotal += collectionValue;
16710
16715
  }
16711
16716
  else if (collectionValueProfiles === null || collectionValueProfiles === void 0 ? void 0 : collectionValueProfiles.length) {
@@ -16723,13 +16728,10 @@ function calculateWinCriteria(_a) {
16723
16728
  finally { if (e_2) throw e_2.error; }
16724
16729
  }
16725
16730
  }
16726
- else if (matchUpValue) {
16731
+ else if (typeof matchUpValue === 'number' &&
16732
+ isConvertableInteger(matchUpValue)) {
16727
16733
  valueTotal += (matchUpCount || 0) * matchUpValue;
16728
16734
  }
16729
- else {
16730
- // default is to give each matchUp a value of 1
16731
- valueTotal += matchUpCount || 0;
16732
- }
16733
16735
  }
16734
16736
  }
16735
16737
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -24851,6 +24853,23 @@ function getNumericSeedValue(seedValue) {
24851
24853
  return Infinity;
24852
24854
  }
24853
24855
 
24856
+ function capitalizeFirst(str) {
24857
+ return !isString(str)
24858
+ ? str
24859
+ : str
24860
+ .split(' ')
24861
+ .map(function (name) {
24862
+ return name
24863
+ .split('')
24864
+ .map(function (c, i) { return (i ? c.toLowerCase() : c.toUpperCase()); })
24865
+ .join('');
24866
+ })
24867
+ .join(' ');
24868
+ }
24869
+ function constantToString(str) {
24870
+ return !isString(str) ? str : capitalizeFirst(str.replace(/_/g, ' '));
24871
+ }
24872
+
24854
24873
  var structureTemplate = function (_a) {
24855
24874
  var _b = _a.finishingPosition, finishingPosition = _b === void 0 ? ROUND_OUTCOME : _b, qualifyingRoundNumber = _a.qualifyingRoundNumber, structureAbbreviation = _a.structureAbbreviation, _c = _a.seedAssignments, seedAssignments = _c === void 0 ? [] : _c, _d = _a.stageSequence, stageSequence = _d === void 0 ? 1 : _d, structureOrder = _a.structureOrder, seedingProfile = _a.seedingProfile, matchUpFormat = _a.matchUpFormat, structureType = _a.structureType, structureName = _a.structureName, matchUpType = _a.matchUpType, _e = _a.matchUps, matchUps = _e === void 0 ? [] : _e, structureId = _a.structureId, roundOffset = _a.roundOffset, roundLimit = _a.roundLimit, stageOrder = _a.stageOrder, structures = _a.structures, stage = _a.stage;
24856
24875
  var structure = {
@@ -24906,7 +24925,7 @@ var structureTemplate = function (_a) {
24906
24925
  };
24907
24926
 
24908
24927
  function generateRoundRobin(_a) {
24909
- var _b = _a.structureName, structureName = _b === void 0 ? MAIN : _b, _c = _a.stageSequence, stageSequence = _c === void 0 ? 1 : _c, structureOptions = _a.structureOptions, appliedPolicies = _a.appliedPolicies, seedingProfile = _a.seedingProfile, _d = _a.stage, stage = _d === void 0 ? MAIN : _d, matchUpType = _a.matchUpType, roundTarget = _a.roundTarget, structureId = _a.structureId, drawSize = _a.drawSize, idPrefix = _a.idPrefix, isMock = _a.isMock, uuids = _a.uuids;
24928
+ var _b = _a.structureName, structureName = _b === void 0 ? constantToString(MAIN) : _b, _c = _a.stageSequence, stageSequence = _c === void 0 ? 1 : _c, structureOptions = _a.structureOptions, appliedPolicies = _a.appliedPolicies, seedingProfile = _a.seedingProfile, _d = _a.stage, stage = _d === void 0 ? MAIN : _d, matchUpType = _a.matchUpType, roundTarget = _a.roundTarget, structureId = _a.structureId, drawSize = _a.drawSize, idPrefix = _a.idPrefix, isMock = _a.isMock, uuids = _a.uuids;
24910
24929
  var _e = deriveGroups({
24911
24930
  structureOptions: structureOptions,
24912
24931
  appliedPolicies: appliedPolicies,
@@ -31038,7 +31057,7 @@ function getParticipantEntries(params) {
31038
31057
  // id is the pair, team or individual participant currently being processed
31039
31058
  // whereas participantId is the id of the entry into the draw
31040
31059
  var addDrawEntry = function (id) {
31041
- var _a, _b, _c, _d, _e, _f;
31060
+ var _a, _b, _c, _d, _e;
31042
31061
  if ((_a = participantMap[id].draws) === null || _a === void 0 ? void 0 : _a[drawId])
31043
31062
  return;
31044
31063
  var includeSeeding = withSeeding && seedingPublished;
@@ -31055,13 +31074,17 @@ function getParticipantEntries(params) {
31055
31074
  seedAssignments[MAIN] = mainSeeding;
31056
31075
  if (seedAssignments && qualifyingSeeding)
31057
31076
  seedAssignments[QUALIFYING] = mainSeeding;
31058
- if (withEvents || withRankingProfile) {
31077
+ if ((withEvents || withRankingProfile) &&
31078
+ participantMap[id] &&
31079
+ eventId) {
31080
+ if (!participantMap[id].events[eventId])
31081
+ participantMap[id].events[eventId] = {};
31059
31082
  if (includeSeeding) {
31060
31083
  // overwrite any event seeding with actual draw seeding (which may differ)
31061
31084
  participantMap[id].events[eventId].seedValue =
31062
31085
  mainSeeding || qualifyingSeeding;
31063
31086
  }
31064
- else if ((_f = participantMap[id].events[eventId]) === null || _f === void 0 ? void 0 : _f.seedValue) {
31087
+ else if (participantMap[id].events[eventId].seedValue) {
31065
31088
  // if seeding for specific drawIds is NOT published, remove from event
31066
31089
  participantMap[id].events[eventId].seedValue = undefined;
31067
31090
  }
@@ -42961,8 +42984,8 @@ function firstRoundLoserConsolation(params) {
42961
42984
  ? feedInMatchUps(mainParams)
42962
42985
  : treeMatchUps(mainParams)).matchUps;
42963
42986
  var mainStructure = structureTemplate({
42987
+ structureName: structureName || constantToString(MAIN),
42964
42988
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
42965
- structureName: structureName || MAIN,
42966
42989
  stageSequence: stageSequence,
42967
42990
  matchUpType: matchUpType,
42968
42991
  matchUps: matchUps,
@@ -42979,8 +43002,9 @@ function firstRoundLoserConsolation(params) {
42979
43002
  matchUpType: matchUpType,
42980
43003
  isMock: isMock,
42981
43004
  }).matchUps;
43005
+ var consolation = constantToString(CONSOLATION);
42982
43006
  var consolationStructureName = params.consolationStructureName ||
42983
- (structureName ? "".concat(structureName, " ").concat(CONSOLATION) : CONSOLATION);
43007
+ (structureName ? "".concat(structureName, " ").concat(consolation) : consolation);
42984
43008
  var consolationStructure = structureTemplate({
42985
43009
  structureName: consolationStructureName,
42986
43010
  matchUps: consolationMatchUps,
@@ -43059,7 +43083,7 @@ function feedInLinks(_a) {
43059
43083
  }
43060
43084
 
43061
43085
  function generateCurtisConsolation(params) {
43062
- var finishingPositionOffset = params.finishingPositionOffset, _a = params.structureName, structureName = _a === void 0 ? MAIN : _a, _b = params.stageSequence, stageSequence = _b === void 0 ? 1 : _b, structureNameMap = params.structureNameMap, staggeredEntry = params.staggeredEntry, _c = params.stage, stage = _c === void 0 ? MAIN : _c, matchUpType = params.matchUpType, structureId = params.structureId, drawSize = params.drawSize, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
43086
+ var _a = params.structureName, structureName = _a === void 0 ? constantToString(MAIN) : _a, playoffStructureNameBase = params.playoffStructureNameBase, finishingPositionOffset = params.finishingPositionOffset, _b = params.stageSequence, stageSequence = _b === void 0 ? 1 : _b, structureNameMap = params.structureNameMap, staggeredEntry = params.staggeredEntry, _c = params.stage, stage = _c === void 0 ? MAIN : _c, matchUpType = params.matchUpType, structureId = params.structureId, drawSize = params.drawSize, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
43063
43087
  var mainParams = {
43064
43088
  finishingPositionOffset: finishingPositionOffset,
43065
43089
  matchUpType: matchUpType,
@@ -43088,6 +43112,7 @@ function generateCurtisConsolation(params) {
43088
43112
  var consolationStructure = consolationFeedStructure({
43089
43113
  idPrefix: idPrefix && "".concat(idPrefix, "-c").concat(index),
43090
43114
  structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43115
+ playoffStructureNameBase: playoffStructureNameBase,
43091
43116
  structureNameMap: structureNameMap,
43092
43117
  stageSequence: stageSequence,
43093
43118
  roundOffset: roundOffset,
@@ -43120,12 +43145,17 @@ function generateCurtisConsolation(params) {
43120
43145
  matchUpType: matchUpType,
43121
43146
  isMock: isMock,
43122
43147
  }).matchUps;
43148
+ var defaultName = constantToString(PLAY_OFF);
43149
+ var mappedStructureName = (structureNameMap === null || structureNameMap === void 0 ? void 0 : structureNameMap[defaultName]) || defaultName;
43150
+ var structureName_1 = playoffStructureNameBase
43151
+ ? "".concat(playoffStructureNameBase, " ").concat(mappedStructureName)
43152
+ : mappedStructureName;
43123
43153
  var playoffStructure = structureTemplate({
43124
- structureName: (structureNameMap === null || structureNameMap === void 0 ? void 0 : structureNameMap[PLAY_OFF]) || PLAY_OFF,
43125
43154
  structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43126
43155
  matchUps: playoffMatchUps,
43127
43156
  stageSequence: 2,
43128
43157
  stage: PLAY_OFF,
43158
+ structureName: structureName_1,
43129
43159
  matchUpType: matchUpType,
43130
43160
  });
43131
43161
  var playoffLink = {
@@ -43147,7 +43177,7 @@ function generateCurtisConsolation(params) {
43147
43177
  return __assign({ structures: structures, links: links }, SUCCESS);
43148
43178
  }
43149
43179
  function consolationFeedStructure(_a) {
43150
- var _b = _a.stageSequence, stageSequence = _b === void 0 ? 1 : _b, structureNameMap = _a.structureNameMap, _c = _a.roundOffset, roundOffset = _c === void 0 ? 0 : _c, matchUpType = _a.matchUpType, structureId = _a.structureId, idPrefix = _a.idPrefix, drawSize = _a.drawSize, isMock = _a.isMock, index = _a.index, uuids = _a.uuids;
43180
+ var playoffStructureNameBase = _a.playoffStructureNameBase, _b = _a.stageSequence, stageSequence = _b === void 0 ? 1 : _b, structureNameMap = _a.structureNameMap, _c = _a.roundOffset, roundOffset = _c === void 0 ? 0 : _c, matchUpType = _a.matchUpType, structureId = _a.structureId, idPrefix = _a.idPrefix, drawSize = _a.drawSize, isMock = _a.isMock, index = _a.index, uuids = _a.uuids;
43151
43181
  var consolationDrawPositions = drawSize / (2 * Math.pow(2, roundOffset));
43152
43182
  var _d = feedInMatchUps({
43153
43183
  finishingPositionOffset: consolationDrawPositions,
@@ -43159,8 +43189,11 @@ function consolationFeedStructure(_a) {
43159
43189
  isMock: isMock,
43160
43190
  uuids: uuids,
43161
43191
  }), consolationMatchUps = _d.matchUps, consolationRoundsCount = _d.roundsCount;
43162
- var defaultName = "".concat(CONSOLATION, " ").concat(index + 1);
43163
- var structureName = (structureNameMap === null || structureNameMap === void 0 ? void 0 : structureNameMap[defaultName]) || defaultName;
43192
+ var defaultName = "".concat(constantToString(CONSOLATION), " ").concat(index + 1);
43193
+ var mappedStructureName = (structureNameMap === null || structureNameMap === void 0 ? void 0 : structureNameMap[defaultName]) || defaultName;
43194
+ var structureName = playoffStructureNameBase
43195
+ ? "".concat(playoffStructureNameBase, " ").concat(mappedStructureName)
43196
+ : mappedStructureName;
43164
43197
  var consolationStructure = structureTemplate({
43165
43198
  matchUps: consolationMatchUps,
43166
43199
  stage: CONSOLATION,
@@ -43172,23 +43205,7 @@ function consolationFeedStructure(_a) {
43172
43205
  return { consolationStructure: consolationStructure, consolationRoundsCount: consolationRoundsCount };
43173
43206
  }
43174
43207
 
43175
- /**
43176
- *
43177
- * @param {object} playoffAttributes - mapping of exitProfile to structure names, e.g. 0-1-1 for SOUTH
43178
- * @param {string} playoffStructureNameBase - Root word for default playoff naming, e.g. 'Playoff' for 'Playoff 3-4'
43179
- * @param {string} exitProfile - rounds at which a participant exited each structure, e.g. 0-1-1-1 for losing EAST, WEST, SOUTH
43180
- * @param {boolean} exitProfileLimit - limit playoff rounds generated by the attributes present in playoffAttributes
43181
- * @param {number} finishingPositionOffset - amount by which to offset finishingPositions, e.g. 2 for playing off 3-4
43182
- * @param {number} finishingPositionLimit - highest value of possible finishing Positions to play off
43183
- * @param {object} finishingPositionNaming - map of { [finishingPositionRange]: customName }
43184
- * @param {number} roundOffsetLimit - how many rounds to play off (# of additional matchUps per participant)
43185
- * @param {number} roundOffset - used internally to track generated structures; saved in structure attributes;
43186
- * @param {number} stageSequence - what sequence within stage structures, e.g. WEST is stageSequence 2 in COMPASS
43187
- * @param {string} stage - [QUALIFYING, MAIN, CONSOLATION, PLAY-OFF]
43188
- *
43189
- */
43190
43208
  function generatePlayoffStructures(params) {
43191
- var matchUpType = params.matchUpType;
43192
43209
  var _a = params.finishingPositionOffset, finishingPositionOffset = _a === void 0 ? 0 : _a, addNameBaseToAttributeName = params.addNameBaseToAttributeName, playoffStructureNameBase = params.playoffStructureNameBase, finishingPositionNaming = params.finishingPositionNaming, finishingPositionLimit = params.finishingPositionLimit, playoffAttributes = params.playoffAttributes, _b = params.stageSequence, stageSequence = _b === void 0 ? 1 : _b, _c = params.exitProfile, exitProfile = _c === void 0 ? '0' : _c, exitProfileLimit = params.exitProfileLimit, roundOffsetLimit = params.roundOffsetLimit, _d = params.roundOffset, roundOffset = _d === void 0 ? 0 : _d, drawDefinition = params.drawDefinition, staggeredEntry = params.staggeredEntry, // not propagated to child structurs
43193
43210
  sequenceLimit = params.sequenceLimit, _e = params.stage, stage = _e === void 0 ? MAIN : _e, structureId = params.structureId, drawSize = params.drawSize, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
43194
43211
  var generateStructure = !playoffAttributes || !exitProfileLimit || (playoffAttributes === null || playoffAttributes === void 0 ? void 0 : playoffAttributes[exitProfile]);
@@ -43199,7 +43216,7 @@ function generatePlayoffStructures(params) {
43199
43216
  var allMatchUps = [];
43200
43217
  var structures = [];
43201
43218
  var links = [];
43202
- matchUpType = matchUpType || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType);
43219
+ var matchUpType = params.matchUpType || (drawDefinition === null || drawDefinition === void 0 ? void 0 : drawDefinition.matchUpType);
43203
43220
  var finishingPositionsFrom = finishingPositionOffset + 1;
43204
43221
  var finishingPositionsTo = finishingPositionOffset + drawSize;
43205
43222
  var finishingPositionRange = "".concat(finishingPositionsFrom, "-").concat(finishingPositionsTo);
@@ -43253,7 +43270,8 @@ function generatePlayoffStructures(params) {
43253
43270
  if (playoffDrawPositions < 2)
43254
43271
  return;
43255
43272
  var childFinishingPositionOffset = drawSize / Math.pow(2, roundNumber) + finishingPositionOffset;
43256
- if (childFinishingPositionOffset + 1 > finishingPositionLimit)
43273
+ if (finishingPositionLimit &&
43274
+ childFinishingPositionOffset + 1 > finishingPositionLimit)
43257
43275
  return;
43258
43276
  var _a = generatePlayoffStructures({
43259
43277
  finishingPositionOffset: childFinishingPositionOffset,
@@ -43321,8 +43339,8 @@ function feedInChampionship(params) {
43321
43339
  ? feedInMatchUps(mainParams)
43322
43340
  : treeMatchUps(mainParams)).matchUps;
43323
43341
  var mainStructure = structureTemplate({
43342
+ structureName: structureName || constantToString(MAIN),
43324
43343
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
43325
- structureName: structureName || MAIN,
43326
43344
  stageSequence: stageSequence,
43327
43345
  matchUpType: matchUpType,
43328
43346
  matchUps: matchUps,
@@ -43346,9 +43364,9 @@ function feedInChampionship(params) {
43346
43364
  }), consolationMatchUps = _c.matchUps, roundsCount = _c.roundsCount;
43347
43365
  if (drawSize > 2) {
43348
43366
  var consolationStructure = structureTemplate({
43367
+ structureName: constantToString(CONSOLATION),
43349
43368
  matchUps: consolationMatchUps,
43350
43369
  structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43351
- structureName: CONSOLATION,
43352
43370
  stage: CONSOLATION,
43353
43371
  stageSequence: 1,
43354
43372
  matchUpType: matchUpType,
@@ -43417,20 +43435,18 @@ function processPlayoffGroups(_a) {
43417
43435
  if (positionsPlayedOff) {
43418
43436
  finishingPositionOffset = Math.min.apply(Math, __spreadArray([], __read(positionsPlayedOff), false)) - 1;
43419
43437
  }
43420
- var params = {
43438
+ var playoffGroupParams = {
43439
+ addNameBaseToAttributeName: playoffGroup.addNameBaseToAttributeName,
43440
+ playoffStructureNameBase: playoffGroup.playoffStructureNameBase,
43441
+ finishingPositionNaming: playoffGroup.finishingPositionNaming,
43442
+ finishingPositionLimit: playoffGroup.finishingPositionLimit,
43421
43443
  structureId: (_c = playoffGroup.structureId) !== null && _c !== void 0 ? _c : uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43444
+ playoffAttributes: playoffGroup.playoffAttributes,
43422
43445
  structureNameMap: playoffGroup.structureNameMap,
43423
43446
  structureName: playoffGroup.structureName,
43424
- idPrefix: idPrefix && "".concat(idPrefix, "-po"),
43425
- appliedPolicies: policyDefinitions,
43426
- finishingPositionOffset: finishingPositionOffset,
43427
- stage: PLAY_OFF,
43428
- stageSequence: stageSequence,
43429
- matchUpType: matchUpType,
43430
- drawSize: drawSize,
43431
- isMock: isMock,
43432
- uuids: uuids,
43447
+ sequenceLimit: playoffGroup.sequenceLimit,
43433
43448
  };
43449
+ var params = __assign(__assign({}, playoffGroupParams), { idPrefix: idPrefix && "".concat(idPrefix, "-po"), appliedPolicies: policyDefinitions, finishingPositionOffset: finishingPositionOffset, stage: PLAY_OFF, stageSequence: stageSequence, matchUpType: matchUpType, drawSize: drawSize, isMock: isMock, uuids: uuids });
43434
43450
  var updateStructureAndLinks = function (_a) {
43435
43451
  var playoffStructures = _a.playoffStructures, playoffLinks = _a.playoffLinks;
43436
43452
  var _b = __read(playoffStructures, 1), playoffStructure = _b[0];
@@ -43642,7 +43658,7 @@ function generatePlayoffLink(_a) {
43642
43658
  // groups of finishing drawPositions which playoff
43643
43659
  function generateRoundRobinWithPlayOff(params) {
43644
43660
  var drawDefinition = params.drawDefinition, structureOptions = params.structureOptions, requireSequential = params.requireSequential;
43645
- var mainDrawProperties = __assign(__assign({ structureName: MAIN }, params), { stage: MAIN }); // default structureName
43661
+ var mainDrawProperties = __assign(__assign({ structureName: constantToString(MAIN) }, params), { stage: MAIN }); // default structureName
43646
43662
  var _a = generateRoundRobin(mainDrawProperties), structures = _a.structures, groupCount = _a.groupCount, groupSize = _a.groupSize;
43647
43663
  // TODO: test for and handle this situation
43648
43664
  if (groupCount < 1) {
@@ -43650,7 +43666,7 @@ function generateRoundRobinWithPlayOff(params) {
43650
43666
  }
43651
43667
  // define a default playoff group if none specified
43652
43668
  var playoffGroups = (structureOptions === null || structureOptions === void 0 ? void 0 : structureOptions.playoffGroups) || [
43653
- { finishingPositions: [1], structureName: PLAY_OFF },
43669
+ { finishingPositions: [1], structureName: constantToString(PLAY_OFF) },
43654
43670
  ];
43655
43671
  var _b = __read(structures, 1), mainStructure = _b[0];
43656
43672
  var _c = processPlayoffGroups(__assign({ sourceStructureId: mainStructure.structureId, requireSequential: requireSequential, drawDefinition: drawDefinition, playoffGroups: playoffGroups, groupCount: groupCount, groupSize: groupSize }, params)), playoffStructures = _c.structures, links = _c.links;
@@ -43768,7 +43784,7 @@ function generateDoubleElimination(_a) {
43768
43784
  isMock: isMock,
43769
43785
  }).matchUps;
43770
43786
  var mainStructure = structureTemplate({
43771
- structureName: structureName || MAIN,
43787
+ structureName: structureName || constantToString(MAIN),
43772
43788
  structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43773
43789
  stageSequence: 1,
43774
43790
  stage: MAIN,
@@ -43787,9 +43803,9 @@ function generateDoubleElimination(_a) {
43787
43803
  uuids: uuids,
43788
43804
  }).matchUps;
43789
43805
  var consolationStructure = structureTemplate({
43806
+ structureName: constantToString(BACKDRAW),
43790
43807
  matchUps: consolationMatchUps,
43791
43808
  structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43792
- structureName: BACKDRAW,
43793
43809
  stage: CONSOLATION,
43794
43810
  stageSequence: 2,
43795
43811
  matchUpType: matchUpType,
@@ -43802,9 +43818,9 @@ function generateDoubleElimination(_a) {
43802
43818
  isMock: isMock,
43803
43819
  }).matchUps;
43804
43820
  var deciderStructure = structureTemplate({
43821
+ structureName: constantToString(DECIDER),
43805
43822
  matchUps: deciderMatchUps,
43806
43823
  structureId: uuids === null || uuids === void 0 ? void 0 : uuids.pop(),
43807
- structureName: DECIDER,
43808
43824
  stageSequence: 3,
43809
43825
  stage: PLAY_OFF,
43810
43826
  matchUpType: matchUpType,
@@ -43919,11 +43935,12 @@ function getGenerators(params) {
43919
43935
  params.skipRounds ||
43920
43936
  (drawSize <= 4 && ((feedPolicy === null || feedPolicy === void 0 ? void 0 : feedPolicy.feedMainFinal) ? 0 : 1)) ||
43921
43937
  0;
43938
+ var main = constantToString(MAIN);
43922
43939
  var singleElimination = function () {
43923
43940
  var matchUps = treeMatchUps(params).matchUps;
43924
43941
  var structure = structureTemplate({
43925
- structureName: structureName || MAIN,
43926
43942
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
43943
+ structureName: structureName || main,
43927
43944
  stageSequence: stageSequence,
43928
43945
  matchUpType: matchUpType,
43929
43946
  matchUps: matchUps,
@@ -43934,8 +43951,8 @@ function getGenerators(params) {
43934
43951
  var generators = (_a = {},
43935
43952
  _a[AD_HOC] = function () {
43936
43953
  var structure = structureTemplate({
43937
- structureName: structureName || MAIN,
43938
43954
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
43955
+ structureName: structureName || main,
43939
43956
  finishingPosition: WIN_RATIO,
43940
43957
  stageSequence: stageSequence,
43941
43958
  matchUps: [],
@@ -43947,8 +43964,8 @@ function getGenerators(params) {
43947
43964
  _a[LUCKY_DRAW] = function () {
43948
43965
  var matchUps = luckyDraw(params).matchUps;
43949
43966
  var structure = structureTemplate({
43950
- structureName: structureName || MAIN,
43951
43967
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
43968
+ structureName: structureName || main,
43952
43969
  stageSequence: stageSequence,
43953
43970
  matchUpType: matchUpType,
43954
43971
  matchUps: matchUps,
@@ -43970,8 +43987,8 @@ function getGenerators(params) {
43970
43987
  _a[FEED_IN$1] = function () {
43971
43988
  var matchUps = feedInMatchUps({ drawSize: drawSize, uuids: uuids, matchUpType: matchUpType }).matchUps;
43972
43989
  var structure = structureTemplate({
43973
- structureName: structureName || MAIN,
43974
43990
  structureId: structureId || (uuids === null || uuids === void 0 ? void 0 : uuids.pop()),
43991
+ structureName: structureName || main,
43975
43992
  stageSequence: stageSequence,
43976
43993
  matchUpType: matchUpType,
43977
43994
  stage: MAIN,
@@ -46704,7 +46721,7 @@ function generateAndPopulatePlayoffStructures(params) {
46704
46721
  if (availabilityResult.error) {
46705
46722
  return decorateResult({ result: availabilityResult, stack: stack });
46706
46723
  }
46707
- var sourceStructureId = params.structureId, addNameBaseToAttributeName = params.addNameBaseToAttributeName, playoffStructureNameBase = params.playoffStructureNameBase, playoffAttributes = params.playoffAttributes, playoffPositions = params.playoffPositions, tournamentRecord = params.tournamentRecord, exitProfileLimit = params.exitProfileLimit, roundProfiles = params.roundProfiles, roundNumbers = params.roundNumbers, idPrefix = params.idPrefix, isMock = params.isMock, event = params.event, uuids = params.uuids;
46724
+ var sourceStructureId = params.structureId, addNameBaseToAttributeName = params.addNameBaseToAttributeName, playoffStructureNameBase = params.playoffStructureNameBase, finishingPositionNaming = params.finishingPositionNaming, finishingPositionLimit = params.finishingPositionLimit, playoffAttributes = params.playoffAttributes, playoffPositions = params.playoffPositions, roundOffsetLimit = params.roundOffsetLimit, tournamentRecord = params.tournamentRecord, exitProfileLimit = params.exitProfileLimit, roundProfiles = params.roundProfiles, roundNumbers = params.roundNumbers, idPrefix = params.idPrefix, isMock = params.isMock, event = params.event, uuids = params.uuids;
46708
46725
  // The goal here is to return { structures, links } and not modify existing drawDefinition
46709
46726
  // However, a copy of the drawDefinition needs to have the structures attached in order to
46710
46727
  // populate the newly created structures with participants which should advance into them
@@ -46795,6 +46812,9 @@ function generateAndPopulatePlayoffStructures(params) {
46795
46812
  idPrefix: idPrefix,
46796
46813
  isMock: isMock,
46797
46814
  uuids: uuids,
46815
+ finishingPositionNaming: finishingPositionNaming,
46816
+ finishingPositionLimit: finishingPositionLimit,
46817
+ roundOffsetLimit: roundOffsetLimit,
46798
46818
  });
46799
46819
  if (result.error)
46800
46820
  return { value: decorateResult({ result: result, stack: stack }) };
@@ -46979,8 +46999,8 @@ function addVoluntaryConsolationStage$1(_a) {
46979
46999
 
46980
47000
  function generateVoluntaryConsolation$1(params) {
46981
47001
  var _a, _b;
46982
- var _c, _d, _e, _f, _g;
46983
- var _h = params.drawType, drawType = _h === void 0 ? SINGLE_ELIMINATION : _h, _j = params.attachConsolation, attachConsolation = _j === void 0 ? true : _j, _k = params.applyPositioning, applyPositioning = _k === void 0 ? true : _k, tournamentRecord = params.tournamentRecord, staggeredEntry = params.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
47002
+ var _c, _d, _e, _f, _g, _h, _j;
47003
+ var _k = params.drawType, drawType = _k === void 0 ? SINGLE_ELIMINATION : _k, _l = params.attachConsolation, attachConsolation = _l === void 0 ? true : _l, _m = params.applyPositioning, applyPositioning = _m === void 0 ? true : _m, tournamentRecord = params.tournamentRecord, staggeredEntry = params.staggeredEntry, // optional - specifies main structure FEED_IN for drawTypes CURTIS_CONSOLATION, FEED_IN_CHAMPIONSHIPS, FMLC
46984
47004
  automated = params.automated, placeByes = params.placeByes, isMock = params.isMock, event = params.event;
46985
47005
  var drawDefinition = params === null || params === void 0 ? void 0 : params.drawDefinition;
46986
47006
  if (!drawDefinition)
@@ -47013,8 +47033,8 @@ function generateVoluntaryConsolation$1(params) {
47013
47033
  if (result_1.error)
47014
47034
  return result_1;
47015
47035
  }
47016
- tieFormat = copyTieFormat(tieFormat || ((_d = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _d === void 0 ? void 0 : _d.tieFormat));
47017
- matchUpType = matchUpType || drawDefinition.matchUpType || TypeEnum.Singles;
47036
+ tieFormat = copyTieFormat(tieFormat !== null && tieFormat !== void 0 ? tieFormat : (_d = resolveTieFormat({ drawDefinition: drawDefinition })) === null || _d === void 0 ? void 0 : _d.tieFormat);
47037
+ matchUpType = (_e = matchUpType !== null && matchUpType !== void 0 ? matchUpType : drawDefinition.matchUpType) !== null && _e !== void 0 ? _e : TypeEnum.Singles;
47018
47038
  var stageStructures = getDrawStructures({
47019
47039
  stageSequence: 1,
47020
47040
  drawDefinition: drawDefinition,
@@ -47023,13 +47043,13 @@ function generateVoluntaryConsolation$1(params) {
47023
47043
  // invalid to have more than one existing VOLUNTARY_CONSOLATION structure
47024
47044
  var structureCount = stageStructures.length;
47025
47045
  if (structureCount > 1)
47026
- return { error: INVALID_STRUCTURE };
47046
+ return { error: STAGE_SEQUENCE_LIMIT };
47027
47047
  // invalid to already have matchUps generated for any existing structure
47028
- if ((_f = (_e = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _e === void 0 ? void 0 : _e.matchUps) === null || _f === void 0 ? void 0 : _f.length)
47029
- return { error: INVALID_STRUCTURE };
47030
- var structureId = (_g = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _g === void 0 ? void 0 : _g.structureId;
47048
+ if ((_g = (_f = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _f === void 0 ? void 0 : _f.matchUps) === null || _g === void 0 ? void 0 : _g.length)
47049
+ return { error: EXISTING_STRUCTURE };
47050
+ var structureId = (_h = stageStructures === null || stageStructures === void 0 ? void 0 : stageStructures[0]) === null || _h === void 0 ? void 0 : _h.structureId;
47031
47051
  Object.assign(params, definedAttributes({
47032
- structureName: params.structureName || VOLUNTARY_CONSOLATION,
47052
+ structureName: (_j = params.structureName) !== null && _j !== void 0 ? _j : constantToString(VOLUNTARY_CONSOLATION),
47033
47053
  structureId: structureId,
47034
47054
  matchUpType: matchUpType,
47035
47055
  tieFormat: tieFormat,
@@ -55024,17 +55044,6 @@ function formatPersonName(_a) {
55024
55044
  if (!person)
55025
55045
  return;
55026
55046
  var spacer = hasSpacing(personFormat) ? ' ' : '';
55027
- var capitalizeFirst = function (str) {
55028
- return str
55029
- .split(' ')
55030
- .map(function (name) {
55031
- return name
55032
- .split('')
55033
- .map(function (c, i) { return (i ? c.toLowerCase() : c.toUpperCase()); })
55034
- .join('');
55035
- })
55036
- .join(' ');
55037
- };
55038
55047
  var firstName = capitalizeFirst((_b = person === null || person === void 0 ? void 0 : person.standardGivenName) !== null && _b !== void 0 ? _b : '');
55039
55048
  var lastName = capitalizeFirst((_c = person === null || person === void 0 ? void 0 : person.standardFamilyName) !== null && _c !== void 0 ? _c : '');
55040
55049
  if (!personFormat)
@@ -63017,7 +63026,7 @@ function generateDrawDefinition(params) {
63017
63026
  }
63018
63027
  else if (structureId && generateQualifyingPlaceholder) {
63019
63028
  var qualifyingStructure = structureTemplate({
63020
- structureName: QUALIFYING,
63029
+ structureName: constantToString(QUALIFYING),
63021
63030
  stage: QUALIFYING,
63022
63031
  });
63023
63032
  var link = generateQualifyingLink({
@@ -68923,6 +68932,7 @@ var utilities = {
68923
68932
  structureSort: structureSort,
68924
68933
  matchUpSort: matchUpSort,
68925
68934
  tidyScore: tidyScore,
68935
+ createMap: createMap,
68926
68936
  generateScoreString: generateScoreString,
68927
68937
  calculateWinCriteria: calculateWinCriteria,
68928
68938
  compareTieFormats: compareTieFormats,