tods-competition-factory 2.0.34 → 2.0.36

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.
@@ -3,7 +3,7 @@
3
3
  Object.defineProperty(exports, '__esModule', { value: true });
4
4
 
5
5
  function factoryVersion() {
6
- return '2.0.34';
6
+ return '2.0.36';
7
7
  }
8
8
 
9
9
  function isFunction(obj) {
@@ -1873,7 +1873,7 @@ function checkRequiredParameters(params, requiredParams, stack) {
1873
1873
  if (!paramError)
1874
1874
  return { valid: true };
1875
1875
  const error = params?.[errorParam] === undefined
1876
- ? errors[errorParam] || INVALID_VALUES
1876
+ ? errors[errorParam] || paramError[ERROR] || INVALID_VALUES
1877
1877
  : (paramError[VALIDATE] && paramError[INVALID]) || INVALID_VALUES;
1878
1878
  const param = errorParam ?? (paramError[ONE_OF] && Object.keys(paramError[ONE_OF]).join(', '));
1879
1879
  return decorateResult({
@@ -1917,10 +1917,10 @@ function findParamError(params, requiredParams) {
1917
1917
  const booleanParams = Object.keys(attrs).filter((key) => typeof attrs[key] === 'boolean');
1918
1918
  const invalidParam = booleanParams.find((param) => {
1919
1919
  const invalidValidationFunction = _validate && !isFunction(_validate);
1920
- const faliedTypeCheck = params[param] && !_validate && invalidType(params, param, _ofType);
1921
- const paramNotPresent = attrs[param] && !params[param];
1920
+ const faliedTypeCheck = params[param] !== undefined && !_validate && invalidType(params, param, _ofType);
1921
+ const paramNotPresent = attrs[param] && [undefined, null].includes(params[param]);
1922
1922
  const invalid = invalidValidationFunction || faliedTypeCheck || paramNotPresent;
1923
- const hasError = invalid || (_validate && params[param] && !checkValidation(params[param], _validate));
1923
+ const hasError = invalid || (_validate && params[param] !== undefined && !checkValidation(params[param], _validate));
1924
1924
  if (hasError) {
1925
1925
  errorParam = param;
1926
1926
  paramInfo = _info;
@@ -7166,7 +7166,11 @@ function findEvent(params) {
7166
7166
  };
7167
7167
  }
7168
7168
 
7169
- function getHomeParticipantId({ visibilityThreshold, timeStamp, schedule, matchUp }) {
7169
+ function getHomeParticipantId(params) {
7170
+ const { visibilityThreshold, timeStamp, schedule, matchUp } = params;
7171
+ const paramsCheck = checkRequiredParameters(params, [{ [MATCHUP]: true }]);
7172
+ if (paramsCheck.error)
7173
+ return paramsCheck;
7170
7174
  const { itemValue: homeParticipantId, timeStamp: itemTimeStamp } = latestVisibleTimeItemValue({
7171
7175
  timeItems: matchUp?.timeItems || [],
7172
7176
  itemType: HOME_PARTICIPANT_ID,
@@ -15376,13 +15380,7 @@ function checkRoundsArgs(params, additionalChecks) {
15376
15380
  }
15377
15381
 
15378
15382
  function shiftAdHocRounds(params) {
15379
- const check = checkRoundsArgs(params, [
15380
- {
15381
- targetRoundNumber: true,
15382
- roundNumber: true,
15383
- [OF_TYPE]: NUMBER,
15384
- },
15385
- ]);
15383
+ const check = checkRoundsArgs(params, [{ targetRoundNumber: true, roundNumber: true, [OF_TYPE]: NUMBER }]);
15386
15384
  if (check.error)
15387
15385
  return check;
15388
15386
  const { structure, roundMatchUps, roundNumbers } = check;
@@ -19909,7 +19907,109 @@ function calculatePercentages({ participantResults, matchUpFormat, tallyPolicy,
19909
19907
  });
19910
19908
  }
19911
19909
 
19912
- function getParticipantResults({ participantIds, matchUpFormat, tallyPolicy, perPlayer, matchUps, }) {
19910
+ const ELO = 'ELO';
19911
+ const NTRP = 'NTRP';
19912
+ const TRN = 'TRN';
19913
+ const UTR = 'UTR';
19914
+ const WTN = 'WTN';
19915
+ const ratingConstants = {
19916
+ ELO,
19917
+ NTRP,
19918
+ TRN,
19919
+ UTR,
19920
+ WTN,
19921
+ };
19922
+
19923
+ const ratingsParameters = {
19924
+ [ELO]: {
19925
+ defaultInitialization: 1500,
19926
+ decimalsCount: 0,
19927
+ range: [0, 3000],
19928
+ ascending: true,
19929
+ },
19930
+ [NTRP]: {
19931
+ accessors: ['ntrpRating', 'dntrpRatingHundredths'],
19932
+ attributes: { ustaRatingType: '' },
19933
+ accessor: 'dntrpRatingHundredths',
19934
+ defaultInitialization: 3,
19935
+ decimalsCount: 1,
19936
+ ascending: true,
19937
+ range: [1, 7],
19938
+ },
19939
+ [UTR]: {
19940
+ defaultInitialization: 6,
19941
+ accessors: ['utrRating'],
19942
+ accessor: 'utrRating',
19943
+ decimalsCount: 2,
19944
+ ascending: true,
19945
+ range: [1, 16],
19946
+ },
19947
+ [WTN]: {
19948
+ attributes: { confidence: { generator: true, range: [60, 100] } },
19949
+ accessors: ['wtnRating', 'confidence'],
19950
+ defaultInitialization: 23,
19951
+ accessor: 'wtnRating',
19952
+ ascending: false,
19953
+ decimalsCount: 2,
19954
+ range: [40, 1],
19955
+ },
19956
+ };
19957
+
19958
+ function convertRange({ value, sourceRange, targetRange }) {
19959
+ return (((value - sourceRange[0]) * (targetRange[1] - targetRange[0])) / (sourceRange[1] - sourceRange[0]) + targetRange[0]);
19960
+ }
19961
+
19962
+ function getRatingConvertedToELO({ sourceRatingType, sourceRating }) {
19963
+ const sourceRatingRange = ratingsParameters[sourceRatingType].range;
19964
+ const invertedScale = sourceRatingRange[0] > sourceRatingRange[1];
19965
+ const eloRatingRange = ratingsParameters[ELO].range;
19966
+ return convertRange({
19967
+ value: invertedScale ? sourceRatingRange[0] - sourceRating : sourceRating,
19968
+ sourceRange: sourceRatingRange,
19969
+ targetRange: eloRatingRange,
19970
+ });
19971
+ }
19972
+ function getRatingConvertedFromELO({ targetRatingType, sourceRating }) {
19973
+ const decimalPlaces = ratingsParameters[targetRatingType].decimalsCount || 0;
19974
+ const targetRatingRange = ratingsParameters[targetRatingType].range;
19975
+ const invertedScale = targetRatingRange[0] > targetRatingRange[1];
19976
+ const eloRatingRange = ratingsParameters[ELO].range;
19977
+ const result = convertRange({
19978
+ targetRange: targetRatingRange,
19979
+ sourceRange: eloRatingRange,
19980
+ value: sourceRating,
19981
+ });
19982
+ const convertedRating = parseFloat(parseFloat(result).toFixed(decimalPlaces));
19983
+ return invertedScale ? targetRatingRange[0] - convertedRating : convertedRating;
19984
+ }
19985
+
19986
+ function getConvertedRating(params) {
19987
+ const paramsCheck = checkRequiredParameters(params, [{ ratings: true, [OF_TYPE]: OBJECT }]);
19988
+ if (paramsCheck.error)
19989
+ return paramsCheck;
19990
+ const matchUpType = params.matchUpType && [SINGLES, DOUBLES].includes(params.matchUpType) ? params.matchUpType : SINGLES;
19991
+ const ratingTypes = Object.keys(ratingsParameters);
19992
+ const targetRatingType = params.targetRatingType && ratingTypes.includes(params.targetRatingType) ? params.targetRatingType : ELO;
19993
+ const sourceRatings = params.ratings[matchUpType]
19994
+ ? params.ratings[matchUpType].reduce((sr, rating) => (sr.includes(rating.scaleName) ? sr : sr.concat(rating.scaleName)), [])
19995
+ : [];
19996
+ if (!sourceRatings)
19997
+ return { error: NOT_FOUND };
19998
+ const sourceRatingObject = params.ratings[matchUpType]?.find((rating) => rating.scaleName === targetRatingType) ??
19999
+ params.ratings[matchUpType][0];
20000
+ if (sourceRatings[0] === targetRatingType)
20001
+ return sourceRatingObject;
20002
+ const accessor = ratingsParameters[sourceRatingObject.scaleName].accessor;
20003
+ const value = accessor ? sourceRatingObject.scaleValue[accessor] : sourceRatingObject.scaleValue;
20004
+ const eloValue = getRatingConvertedToELO({ sourceRatingType: sourceRatingObject.scaleName, sourceRating: value });
20005
+ const convertedRating = getRatingConvertedFromELO({
20006
+ targetRatingType: targetRatingType,
20007
+ sourceRating: eloValue,
20008
+ });
20009
+ return { convertedRating };
20010
+ }
20011
+
20012
+ function getParticipantResults({ participantIds, pressureRating, matchUpFormat, tallyPolicy, perPlayer, matchUps, }) {
19913
20013
  const participantResults = {};
19914
20014
  const excludeMatchUpStatuses = tallyPolicy?.excludeMatchUpStatuses || [];
19915
20015
  const filteredMatchUps = matchUps?.filter((matchUp) => {
@@ -20029,11 +20129,13 @@ function getParticipantResults({ participantIds, matchUpFormat, tallyPolicy, per
20029
20129
  matchUpFormat: tieMatchUp.matchUpFormat,
20030
20130
  matchUpStatus: tieMatchUp.matchUpStatus,
20031
20131
  score: tieMatchUp.score,
20132
+ sides: tieMatchUp.sides,
20032
20133
  winningParticipantId,
20033
20134
  losingParticipantId,
20135
+ manualGamesOverride,
20034
20136
  participantResults,
20035
20137
  isTieMatchUp: true,
20036
- manualGamesOverride,
20138
+ pressureRating,
20037
20139
  tallyPolicy,
20038
20140
  winningSide,
20039
20141
  });
@@ -20053,20 +20155,22 @@ function getParticipantResults({ participantIds, matchUpFormat, tallyPolicy, per
20053
20155
  manualGamesOverride,
20054
20156
  losingParticipantId,
20055
20157
  participantResults,
20158
+ pressureRating,
20056
20159
  matchUpStatus,
20057
20160
  tallyPolicy,
20058
20161
  winningSide,
20059
20162
  score,
20163
+ sides,
20060
20164
  });
20061
20165
  }
20062
20166
  }
20167
+ const gamesWonSide1 = score?.sets?.reduce((total, set) => total + (set?.side1Score ?? 0), 0);
20168
+ const gamesWonSide2 = score?.sets?.reduce((total, set) => total + (set.side2Score ?? 0), 0);
20063
20169
  if (manualGamesOverride) {
20064
20170
  const side1participantId = sides?.find(({ sideNumber }) => sideNumber === 1)?.participantId;
20065
20171
  const side2participantId = sides?.find(({ sideNumber }) => sideNumber === 2)?.participantId;
20066
20172
  checkInitializeParticipant(participantResults, side1participantId);
20067
20173
  checkInitializeParticipant(participantResults, side2participantId);
20068
- const gamesWonSide1 = score?.sets?.reduce((total, set) => total + (set?.side1Score ?? 0), 0);
20069
- const gamesWonSide2 = score?.sets?.reduce((total, set) => total + (set.side2Score ?? 0), 0);
20070
20174
  if (side1participantId) {
20071
20175
  participantResults[side1participantId].gamesWon += gamesWonSide1;
20072
20176
  participantResults[side1participantId].gamesLost += gamesWonSide2;
@@ -20119,6 +20223,7 @@ function checkInitializeParticipant(participantResults, participantId) {
20119
20223
  matchUpsWon: 0,
20120
20224
  pointsLost: 0,
20121
20225
  pointsWon: 0,
20226
+ pressureScores: [],
20122
20227
  retirements: 0,
20123
20228
  setsLost: 0,
20124
20229
  setsWon: 0,
@@ -20157,9 +20262,22 @@ function processScore({ manualGamesOverride, participantResults, score, sides })
20157
20262
  }
20158
20263
  });
20159
20264
  }
20160
- function processMatchUp({ winningParticipantId, losingParticipantId, participantResults, manualGamesOverride, matchUpFormat, matchUpStatus, isTieMatchUp, tallyPolicy, winningSide, score, }) {
20265
+ function processMatchUp({ winningParticipantId, manualGamesOverride, losingParticipantId, participantResults, pressureRating, matchUpFormat, matchUpStatus, isTieMatchUp, tallyPolicy, winningSide, score, sides, }) {
20161
20266
  const winningSideIndex = winningSide && winningSide - 1;
20162
20267
  const losingSideIndex = 1 - winningSideIndex;
20268
+ if (pressureRating) {
20269
+ const fixed2 = (value) => parseFloat(Number(Math.round(value * 1000) / 1000).toFixed(2));
20270
+ const gamesWonSide1 = score?.sets?.reduce((total, set) => total + (set?.side1Score ?? 0), 0);
20271
+ const gamesWonSide2 = score?.sets?.reduce((total, set) => total + (set.side2Score ?? 0), 0);
20272
+ const side1 = sides.find(({ sideNumber }) => sideNumber === 1);
20273
+ const side2 = sides.find(({ sideNumber }) => sideNumber === 2);
20274
+ const side1ConvertedRating = getConvertedRating({ ratings: side1?.participant?.ratings }).convertedRating;
20275
+ const side2ConvertedRating = getConvertedRating({ ratings: side2?.participant?.ratings }).convertedRating;
20276
+ const side1Value = gamesWonSide1 * side2ConvertedRating;
20277
+ const side2Value = gamesWonSide2 * side1ConvertedRating;
20278
+ participantResults[side1?.participantId].pressureScores.push(fixed2(side1Value / (side1Value + side2Value)));
20279
+ participantResults[side2?.participantId].pressureScores.push(fixed2(side1Value / (side1Value + side2Value)));
20280
+ }
20163
20281
  if (!isTieMatchUp) {
20164
20282
  processOutcome$1({
20165
20283
  winningParticipantId,
@@ -20515,7 +20633,7 @@ function headToHeadWinner({ participantIds, participantResults }) {
20515
20633
  }
20516
20634
  }
20517
20635
 
20518
- function tallyParticipantResults({ policyDefinitions, generateReport, matchUpFormat, matchUps = [], subOrderMap, perPlayer, }) {
20636
+ function tallyParticipantResults({ policyDefinitions, generateReport, pressureRating, matchUpFormat, matchUps = [], subOrderMap, perPlayer, }) {
20519
20637
  if (!matchUps?.length || !validMatchUps(matchUps))
20520
20638
  return { error: MISSING_MATCHUPS };
20521
20639
  const structureIds = unique(matchUps.map(({ structureId }) => structureId));
@@ -20536,6 +20654,7 @@ function tallyParticipantResults({ policyDefinitions, generateReport, matchUpFor
20536
20654
  const consideredMatchUps = matchUps.filter((matchUp) => checkMatchUpIsComplete({ matchUp }) || matchUp.matchUpType === TEAM$1);
20537
20655
  const { participantResults } = getParticipantResults({
20538
20656
  matchUps: consideredMatchUps,
20657
+ pressureRating,
20539
20658
  matchUpFormat,
20540
20659
  tallyPolicy,
20541
20660
  perPlayer,
@@ -21209,7 +21328,7 @@ function tiebreakFormat(tieobject) {
21209
21328
  }
21210
21329
 
21211
21330
  function isValidMatchUpFormat({ matchUpFormat }) {
21212
- if (typeof matchUpFormat !== 'string')
21331
+ if (!isString(matchUpFormat) || matchUpFormat === '')
21213
21332
  return false;
21214
21333
  const parsedFormat = parse(matchUpFormat);
21215
21334
  const setParts = matchUpFormat.match(/-S:([1-9])+\/TB([0-9]{1,2})@?([1-9]?)*/);
@@ -26350,55 +26469,7 @@ function addParticipantScaleItem({ removePriorValues, participant, scaleItem })
26350
26469
  return { ...SUCCESS, valueChanged, newValue: scaleItem.scaleValue };
26351
26470
  }
26352
26471
 
26353
- const ELO = 'ELO';
26354
- const NTRP = 'NTRP';
26355
- const TRN = 'TRN';
26356
- const UTR = 'UTR';
26357
- const WTN = 'WTN';
26358
- const ratingConstants = {
26359
- ELO,
26360
- NTRP,
26361
- TRN,
26362
- UTR,
26363
- WTN,
26364
- };
26365
-
26366
- const ratingsParameters = {
26367
- [ELO]: {
26368
- defaultInitialization: 1500,
26369
- decimalsCount: 0,
26370
- range: [0, 3000],
26371
- ascending: true,
26372
- },
26373
- [NTRP]: {
26374
- accessors: ['ntrpRating', 'dntrpRatingHundredths'],
26375
- attributes: { ustaRatingType: '' },
26376
- accessor: 'dntrpRatingHundredths',
26377
- defaultInitialization: 3,
26378
- decimalsCount: 1,
26379
- ascending: true,
26380
- range: [1, 7],
26381
- },
26382
- [UTR]: {
26383
- defaultInitialization: 6,
26384
- accessors: ['utrRating'],
26385
- accessor: 'utrRating',
26386
- decimalsCount: 2,
26387
- ascending: true,
26388
- range: [1, 16],
26389
- },
26390
- [WTN]: {
26391
- attributes: { confidence: { generator: true, range: [60, 100] } },
26392
- accessors: ['wtnRating', 'confidence'],
26393
- defaultInitialization: 23,
26394
- accessor: 'wtnRating',
26395
- ascending: false,
26396
- decimalsCount: 2,
26397
- range: [40, 1],
26398
- },
26399
- };
26400
-
26401
- const k538 = (countables) => 250 / Math.pow(countables + 5, 0.4);
26472
+ const k538 = (countables = 0) => 250 / Math.pow(countables + 5, 0.4);
26402
26473
  const kDefault = () => 1;
26403
26474
  function kSet(maxCountables = 3, counted = 2) {
26404
26475
  const kset = maxCountables / counted;
@@ -26412,12 +26483,12 @@ const eloConfig = {
26412
26483
  kDefault,
26413
26484
  };
26414
26485
  function calculateNewRatings(params) {
26415
- let { winnerRating, loserRating, ratingRange } = params;
26486
+ let { winnerRating, loserRating } = params;
26416
26487
  const { ratings = ratingsParameters, winnerCountables = 1, loserCountables = 0, ratingType = ELO, maxCountables, countables, } = params || {};
26417
26488
  const ratingParameters = ratings?.[ratingType];
26418
26489
  if (!ratingParameters)
26419
26490
  return { error: MISSING_VALUE };
26420
- ratingRange = ratingParameters.range || ratingRange;
26491
+ const ratingRange = ratingParameters.range || params.ratingRange;
26421
26492
  winnerRating = winnerRating || ratingParameters.defaultInitialization;
26422
26493
  loserRating = loserRating || ratingParameters.defaultInitialization;
26423
26494
  const invertedScale = ratingRange[0] > ratingRange[1];
@@ -26430,7 +26501,6 @@ function calculateNewRatings(params) {
26430
26501
  if (!inRange(ratingRange, loserRating))
26431
26502
  loserRating = ratingParameters.defaultInitialization;
26432
26503
  }
26433
- const convertRange = ({ value, sourceRange, targetRange }) => ((value - sourceRange[0]) * (targetRange[1] - targetRange[0])) / (sourceRange[1] - sourceRange[0]) + targetRange[0];
26434
26504
  const convertedWinnerRating = convertRange({
26435
26505
  targetRange: ratingsParameters[ELO].range,
26436
26506
  sourceRange: consideredRange,
@@ -33566,17 +33636,17 @@ function getCollectionsValue(definitions) {
33566
33636
  scoreValue,
33567
33637
  setValue,
33568
33638
  };
33569
- const valueKeys = Object.keys(valueAssignments).filter((key) => ![undefined, null].includes(valueAssignments[key]));
33570
- if (valueKeys.length !== 1) {
33639
+ const valueKeys = Object.keys(valueAssignments).filter((key) => ![undefined, null].includes(valueAssignments[key]) &&
33640
+ (!Array.isArray(valueAssignments[key]) || valueAssignments[key].length > 0));
33641
+ if (valueKeys.length !== 1)
33571
33642
  invalidValues.push({ collectionId });
33572
- }
33573
33643
  const valueKey = valueKeys[0];
33574
33644
  if (valueKey) {
33575
33645
  const value = valueKey === 'collectionValueProfiles' ? Object.values(collectionValueProfiles) : valueAssignments[valueKey];
33576
33646
  assignmentValues.push({ valueKey, value });
33577
33647
  }
33578
33648
  totalMatchUps += matchUpCount;
33579
- if (collectionValueProfiles)
33649
+ if (collectionValueProfiles?.length)
33580
33650
  return total + collectionValueProfiles.reduce((total, profile) => total + profile.value, 0);
33581
33651
  if (matchUpCount) {
33582
33652
  if (isConvertableInteger(matchUpValue))
@@ -33992,7 +34062,7 @@ function getDrawIsPublished({ publishStatus, drawId }) {
33992
34062
  }
33993
34063
 
33994
34064
  function getDrawData(params) {
33995
- const { tournamentParticipants = [], includePositionAssignments, policyDefinitions, tournamentRecord, inContext = true, usePublishState, status = PUBLIC, drawDefinition, noDeepCopy, sortConfig, context, event, } = params;
34065
+ const { tournamentParticipants = [], includePositionAssignments, policyDefinitions, tournamentRecord, inContext = true, usePublishState, status = PUBLIC, pressureRating, refreshResults, drawDefinition, noDeepCopy, sortConfig, context, event, } = params;
33996
34066
  if (!drawDefinition)
33997
34067
  return { error: MISSING_DRAW_DEFINITION };
33998
34068
  const drawInfo = (({ matchUpFormat, updatedAt, drawType, drawName, drawId }) => ({
@@ -34070,11 +34140,12 @@ function getDrawData(params) {
34070
34140
  drawPosition,
34071
34141
  };
34072
34142
  });
34073
- if (!participantResults?.length && matchUps.length && params.allParticipantResults) {
34143
+ if (matchUps.length && ((!participantResults?.length && params.allParticipantResults) || refreshResults)) {
34074
34144
  const { subOrderMap } = createSubOrderMap({ positionAssignments });
34075
34145
  const result = tallyParticipantResults({
34076
34146
  matchUpFormat: structure.matchUpFormat,
34077
34147
  policyDefinitions,
34148
+ pressureRating,
34078
34149
  subOrderMap,
34079
34150
  matchUps,
34080
34151
  });
@@ -34102,14 +34173,14 @@ function getDrawData(params) {
34102
34173
  structureInfo.positionAssignments = positionAssignments;
34103
34174
  structureInfo.structureActive = matchUps.reduce((active, matchUp) => {
34104
34175
  const activeMatchUpStatus = [
34176
+ DOUBLE_WALKOVER,
34177
+ DOUBLE_DEFAULT,
34178
+ IN_PROGRESS$1,
34105
34179
  COMPLETED$1,
34106
34180
  CANCELLED$1,
34107
34181
  DEFAULTED,
34108
34182
  RETIRED$1,
34109
34183
  WALKOVER$2,
34110
- IN_PROGRESS$1,
34111
- DOUBLE_DEFAULT,
34112
- DOUBLE_WALKOVER,
34113
34184
  ].includes(matchUp.matchUpStatus);
34114
34185
  return active || activeMatchUpStatus || !!matchUp.winningSide || !!matchUp.score?.scoreStringSide1;
34115
34186
  }, false);
@@ -34231,6 +34302,8 @@ function getEventData(params) {
34231
34302
  }))(getDrawData({
34232
34303
  allParticipantResults: params.allParticipantResults,
34233
34304
  context: { eventId, tournamentId, endDate },
34305
+ pressureRating: params.pressureRating,
34306
+ refreshResults: params.refreshResults,
34234
34307
  includePositionAssignments,
34235
34308
  tournamentParticipants,
34236
34309
  noDeepCopy: true,
@@ -36161,7 +36234,7 @@ function calculateWinCriteria({ collectionDefinitions = [], collectionGroups = [
36161
36234
  else if (typeof collectionValue === 'number' && isConvertableInteger(collectionValue)) {
36162
36235
  valueTotal += collectionValue;
36163
36236
  }
36164
- else if (collectionValueProfiles?.length) {
36237
+ else if (Array.isArray(collectionValueProfiles) && collectionValueProfiles?.length) {
36165
36238
  for (const collectionValueProfile of collectionValueProfiles) {
36166
36239
  valueTotal += collectionValueProfile.matchUpValue;
36167
36240
  }
@@ -36624,6 +36697,7 @@ var query$2 = {
36624
36697
  getCheckedInParticipantIds: getCheckedInParticipantIds,
36625
36698
  getCompetitionMatchUps: getCompetitionMatchUps,
36626
36699
  getEventMatchUpFormatTiming: getEventMatchUpFormatTiming,
36700
+ getHomeParticipantId: getHomeParticipantId,
36627
36701
  getMatchUpCompetitiveProfile: getMatchUpCompetitiveProfile,
36628
36702
  getMatchUpContextIds: getMatchUpContextIds,
36629
36703
  getMatchUpDailyLimits: getMatchUpDailyLimits,
@@ -36979,6 +37053,7 @@ var index$f = {
36979
37053
  getEventTimeItem: getEventTimeItem,
36980
37054
  getEvents: getEvents,
36981
37055
  getFlightProfile: getFlightProfile,
37056
+ getHomeParticipantId: getHomeParticipantId,
36982
37057
  getLinkedTournamentIds: getLinkedTournamentIds,
36983
37058
  getMatchUpCompetitiveProfile: getMatchUpCompetitiveProfile,
36984
37059
  getMatchUpContextIds: getMatchUpContextIds,
@@ -42662,10 +42737,22 @@ function scoreModification(params) {
42662
42737
  }
42663
42738
 
42664
42739
  function setMatchUpHomeParticipantId(params) {
42740
+ const paramsCheck = checkRequiredParameters(params, [
42741
+ { [TOURNAMENT_RECORD]: true, [DRAW_DEFINITION]: true, [MATCHUP_ID]: true },
42742
+ { homeParticipantId: true, [ERROR]: MISSING_PARTICIPANT_ID },
42743
+ ]);
42744
+ if (paramsCheck.error)
42745
+ return paramsCheck;
42746
+ const resolutions = resolveFromParameters(params, [{ [PARAM]: MATCHUP, attr: { [IN_CONTEXT]: true } }]);
42747
+ if (resolutions.error)
42748
+ return resolutions;
42749
+ const participantIds = resolutions?.matchUp?.matchUp?.sides?.map((side) => side?.participantId);
42750
+ if (params.homeParticipantId && !participantIds?.includes(params.homeParticipantId))
42751
+ return { error: INVALID_PARTICIPANT_ID };
42665
42752
  const { disableNotice = true, homeParticipantId, removePriorValues, tournamentRecord, drawDefinition, matchUpId, } = params;
42666
42753
  const timeItem = {
42667
- itemValue: homeParticipantId,
42668
42754
  itemType: HOME_PARTICIPANT_ID,
42755
+ itemValue: homeParticipantId,
42669
42756
  };
42670
42757
  return addMatchUpTimeItem({
42671
42758
  duplicateValues: false,
@@ -44761,6 +44848,7 @@ var index$9 = {
44761
44848
  getCheckedInParticipantIds: getCheckedInParticipantIds,
44762
44849
  getCompetitionMatchUps: getCompetitionMatchUps,
44763
44850
  getEventMatchUpFormatTiming: getEventMatchUpFormatTiming,
44851
+ getHomeParticipantId: getHomeParticipantId,
44764
44852
  getMatchUpCompetitiveProfile: getMatchUpCompetitiveProfile,
44765
44853
  getMatchUpContextIds: getMatchUpContextIds,
44766
44854
  getMatchUpDailyLimits: getMatchUpDailyLimits,
@@ -46955,6 +47043,7 @@ var lastNames = [
46955
47043
  "Lem",
46956
47044
  "Lovelace",
46957
47045
  "Mander",
47046
+ "McLuhan",
46958
47047
  "Midgely",
46959
47048
  "Mond",
46960
47049
  "Montoya",
@@ -47113,6 +47202,7 @@ var firstMale = [
47113
47202
  "Lief",
47114
47203
  "Malachi",
47115
47204
  "Mark",
47205
+ "Marhsall",
47116
47206
  "Masanobu",
47117
47207
  "Maurits",
47118
47208
  "Michael",
@@ -53865,7 +53955,7 @@ function modifyCollectionDefinition({ updateInProgressMatchUps = false, tourname
53865
53955
  stack,
53866
53956
  });
53867
53957
  const value = collectionValue ?? matchUpValue ?? scoreValue ?? setValue;
53868
- if (collectionValueProfiles) {
53958
+ if (collectionValueProfiles?.length) {
53869
53959
  const result = validateCollectionValueProfiles({
53870
53960
  matchUpCount: matchUpCount ?? sourceCollectionDefinition?.matchUpCount ?? 0,
53871
53961
  collectionValueProfiles,
@@ -54194,7 +54284,7 @@ function getOrderedTieFormat({ tieFormat, orderMap }) {
54194
54284
  if (collectionOrder)
54195
54285
  collectionDefinition.collectionOrder = collectionOrder;
54196
54286
  });
54197
- orderedTieFormat.collectionDefinitions.sort((a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder));
54287
+ orderedTieFormat.collectionDefinitions?.sort((a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder));
54198
54288
  return orderedTieFormat;
54199
54289
  }
54200
54290
  function orderCollectionDefinitions({ tournamentRecord, drawDefinition, structureId, matchUpId, orderMap, eventId, matchUp, event, }) {
@@ -54835,7 +54925,7 @@ function queueNoficiations({ modifiedStructureIds, tournamentRecord, modifiedMat
54835
54925
  });
54836
54926
  }
54837
54927
 
54838
- function modifyTieFormat({ updateInProgressMatchUps = false, tieFormatComparison, modifiedTieFormat, tournamentRecord, drawDefinition, structureId, matchUpId, eventId, uuids, event, }) {
54928
+ function modifyTieFormat({ updateInProgressMatchUps = false, tieFormatComparison, modifiedTieFormat, tournamentRecord, considerations, drawDefinition, structureId, matchUpId, eventId, uuids, event, }) {
54839
54929
  const stack = 'modifyTieFormat';
54840
54930
  if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
54841
54931
  return decorateResult({
@@ -54858,6 +54948,7 @@ function modifyTieFormat({ updateInProgressMatchUps = false, tieFormatComparison
54858
54948
  const comparison = compareTieFormats({
54859
54949
  descendant: modifiedTieFormat,
54860
54950
  ancestor: tieFormat,
54951
+ considerations,
54861
54952
  });
54862
54953
  if (comparison.invalid) {
54863
54954
  return decorateResult({
@@ -57607,6 +57698,15 @@ const POLICY_SCORING_DEFAULT = {
57607
57698
  },
57608
57699
  },
57609
57700
  },
57701
+ matchUpFormats: [],
57702
+ matchUpStatusCodes: {
57703
+ [ABANDONED$1]: [],
57704
+ [CANCELLED$1]: [],
57705
+ [DEFAULTED]: [],
57706
+ [INCOMPLETE]: [],
57707
+ [RETIRED$1]: [],
57708
+ [WALKOVER$2]: [],
57709
+ },
57610
57710
  },
57611
57711
  };
57612
57712
 
@@ -57703,6 +57803,182 @@ const POLICY_SCORING_USTA = {
57703
57803
  matchUpFormat: 'SET1-S:T20',
57704
57804
  },
57705
57805
  ],
57806
+ matchUpStatusCodes: {
57807
+ [ABANDONED$1]: [
57808
+ {
57809
+ matchUpStatusCodeDisplay: 'Abandoned',
57810
+ label: 'Abandoned match',
57811
+ matchUpStatusCode: 'OA',
57812
+ },
57813
+ ],
57814
+ [CANCELLED$1]: [
57815
+ {
57816
+ matchUpStatusCodeDisplay: 'Unplayed or Cancelled',
57817
+ label: 'Cancelled match',
57818
+ matchUpStatusCode: 'OC',
57819
+ },
57820
+ ],
57821
+ [INCOMPLETE]: [
57822
+ {
57823
+ matchUpStatusCodeDisplay: 'Incomplete',
57824
+ label: 'Incomplete match',
57825
+ matchUpStatusCode: 'OI',
57826
+ },
57827
+ ],
57828
+ [DEFAULTED]: [
57829
+ {
57830
+ description: 'Disqualification for cause or ineligibility',
57831
+ label: 'Disqualification (ineligibility)',
57832
+ matchUpStatusCodeDisplay: 'Def [dq]',
57833
+ matchUpStatusCode: 'DQ',
57834
+ },
57835
+ {
57836
+ description: 'Misconduct before or between matches',
57837
+ label: 'Misconduct',
57838
+ matchUpStatusCodeDisplay: 'Def [cond]',
57839
+ matchUpStatusCode: 'DM',
57840
+ },
57841
+ {
57842
+ description: 'Failure to start match because of adult discipline',
57843
+ label: 'Fail. (adult discipline)',
57844
+ matchUpStatusCodeDisplay: 'Def [ad]',
57845
+ matchUpStatusCode: 'D5',
57846
+ },
57847
+ {
57848
+ description: 'Refusal to start match for reason other than adult discipline, injury, illness, or personal circumstance. ' +
57849
+ '(After the Referee has conclusively confirmed that a player refuses to play a match, the Referee need not ' +
57850
+ 'wait until the scheduled time of the match to records the result.)',
57851
+ label: 'Refusal to start match',
57852
+ matchUpStatusCodeDisplay: 'Def [refsl]',
57853
+ matchUpStatusCode: 'D4',
57854
+ },
57855
+ {
57856
+ label: 'Not showing up',
57857
+ matchUpStatusCodeDisplay: 'Def [ns]',
57858
+ matchUpStatusCode: 'D6',
57859
+ },
57860
+ {
57861
+ description: 'Lateness for match including, but not limited to, intending to play but mistakenly arriving at the ' +
57862
+ 'wrong time, location, or without proper equipment',
57863
+ label: 'Lateness for match',
57864
+ matchUpStatusCodeDisplay: 'Score + Def [late]',
57865
+ matchUpStatusCode: 'D7',
57866
+ },
57867
+ {
57868
+ label: 'Double default',
57869
+ matchUpStatusCodeDisplay: 'Def/Def',
57870
+ matchUpStatusCode: 'DD',
57871
+ },
57872
+ {
57873
+ description: 'Refusal to continue playing a match for reason other than injury, illness, personal circumstance, or ' +
57874
+ 'adult discipline',
57875
+ label: 'Refusal to continue match',
57876
+ matchUpStatusCodeDisplay: 'Def [refsl]',
57877
+ matchUpStatusCode: 'D9',
57878
+ },
57879
+ {
57880
+ description: 'Default for receiving an injection, IV, or supplemental oxygen',
57881
+ label: 'Default (PEDs)',
57882
+ matchUpStatusCodeDisplay: 'Def [med]',
57883
+ matchUpStatusCode: 'DI',
57884
+ },
57885
+ {
57886
+ description: 'Default under Point Penalty System',
57887
+ label: 'Default (Point Penalty System)',
57888
+ matchUpStatusCodeDisplay: 'Def [pps]',
57889
+ matchUpStatusCode: 'DP',
57890
+ },
57891
+ ],
57892
+ [WALKOVER$2]: [
57893
+ {
57894
+ matchUpStatusCodeDisplay: 'Wo [inj]',
57895
+ matchUpStatusCode: 'W1',
57896
+ label: 'Injury',
57897
+ },
57898
+ {
57899
+ matchUpStatusCodeDisplay: 'Wo [ill]',
57900
+ matchUpStatusCode: 'W2',
57901
+ label: 'Illness',
57902
+ },
57903
+ {
57904
+ matchUpStatusCodeDisplay: 'Wo [pc]',
57905
+ label: 'Personal circumstance',
57906
+ matchUpStatusCode: 'W3',
57907
+ },
57908
+ {
57909
+ matchUpStatusCodeDisplay: 'Wo/Wo',
57910
+ matchUpStatusCode: 'WOWO',
57911
+ label: 'Double walkover',
57912
+ },
57913
+ {
57914
+ matchUpStatusCodeDisplay: 'Wo [Tae]',
57915
+ label: 'Tournament Administrative Error',
57916
+ matchUpStatusCode: 'W4',
57917
+ },
57918
+ {
57919
+ matchUpStatusCodeDisplay: 'Wo/Withdrawn',
57920
+ matchUpStatusCode: 'W5',
57921
+ label: 'Withdrawn',
57922
+ },
57923
+ ],
57924
+ [RETIRED$1]: [
57925
+ {
57926
+ matchUpStatusCodeDisplay: 'Ret [inj]',
57927
+ matchUpStatusCode: 'RJ',
57928
+ label: 'Injury',
57929
+ },
57930
+ {
57931
+ matchUpStatusCodeDisplay: 'Ret [ill]',
57932
+ matchUpStatusCode: 'RI',
57933
+ label: 'Illness',
57934
+ },
57935
+ {
57936
+ matchUpStatusCodeDisplay: 'Ret [pc]',
57937
+ label: 'Personal circumstance',
57938
+ matchUpStatusCode: 'RC',
57939
+ },
57940
+ {
57941
+ description: 'Retirement because of adult discipline',
57942
+ label: 'Ret. (adult discipline)',
57943
+ matchUpStatusCodeDisplay: 'Ret [ad]',
57944
+ matchUpStatusCode: 'RD',
57945
+ },
57946
+ {
57947
+ description: 'A player who retires from a match remains eligible for consolations, place playoffs, doubles and ' +
57948
+ 'subsequent round robin matches',
57949
+ matchUpStatusCodeDisplay: 'Ret [elg]',
57950
+ label: 'Ret. (eligible)',
57951
+ matchUpStatusCode: 'RU',
57952
+ },
57953
+ ],
57954
+ [WITHDRAWN]: [
57955
+ {
57956
+ matchUpStatusCodeDisplay: 'Wd [inj]',
57957
+ matchUpStatusCode: 'WD.INJ',
57958
+ label: 'Injury',
57959
+ },
57960
+ {
57961
+ matchUpStatusCodeDisplay: 'Wd [ill]',
57962
+ matchUpStatusCode: 'WD.ILL',
57963
+ label: 'Illness',
57964
+ },
57965
+ {
57966
+ matchUpStatusCodeDisplay: 'Wd [pc]',
57967
+ label: 'Personal circumstance',
57968
+ matchUpStatusCode: 'WD.PC',
57969
+ },
57970
+ {
57971
+ matchUpStatusCodeDisplay: 'Wd/Wd',
57972
+ matchUpStatusCode: 'WD.WD',
57973
+ label: 'Double withdrawal',
57974
+ },
57975
+ {
57976
+ label: 'Tournament Administrative Error',
57977
+ matchUpStatusCodeDisplay: 'Wd [Tae]',
57978
+ matchUpStatusCode: 'WD.TAE',
57979
+ },
57980
+ ],
57981
+ },
57706
57982
  },
57707
57983
  };
57708
57984