tods-competition-factory 0.72.2 → 0.75.0

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.
@@ -249,7 +249,7 @@ const matchUpFormatCode = {
249
249
  };
250
250
 
251
251
  function factoryVersion() {
252
- return '0.72.2';
252
+ return '0.75.0';
253
253
  }
254
254
 
255
255
  const FORMAT_STANDARD = 'SET3-S:6/TB7'; // Best of 3 Tiebreak Sets to 6
@@ -718,6 +718,7 @@ const MISSING_DRAW_DEFINITION = 'Missing drawDefinition';
718
718
  const EXISTING_DRAW_DEFINITIONS = 'Existing drawDefinition(s)';
719
719
  const DRAW_DEFINITION_NOT_FOUND = 'drawDefinition not found';
720
720
  const INVALID_STRUCTURE = 'Invalid structure';
721
+ const INCOMPLETE_SOURCE_STRUCTURE = 'Incomplete source structure';
721
722
  const INVALID_DRAW_POSITION_FOR_SEEDING = 'Invalid drawPosition for seedAssignment';
722
723
  const DRAW_POSITION_ASSIGNED = 'drawPosition already assigned';
723
724
  const DRAW_POSITION_NOT_CLEARED = 'drawPosition not cleared';
@@ -892,6 +893,7 @@ const errorConditionConstants = {
892
893
  EXISTING_PROFILE,
893
894
  EXISTING_ROUND,
894
895
  INCOMPATIBLE_MATCHUP_STATUS,
896
+ INCOMPLETE_SOURCE_STRUCTURE,
895
897
  INVALID_BOOKINGS,
896
898
  INVALID_CONFIGURATION,
897
899
  INVALID_DATE_AVAILABILITY,
@@ -1021,26 +1023,35 @@ const errorConditionConstants = {
1021
1023
  };
1022
1024
 
1023
1025
  const syncGlobalState = {
1026
+ disableNotifications: false,
1024
1027
  tournamentId: undefined,
1025
1028
  tournamentRecords: {},
1026
1029
  subscriptions: {},
1027
1030
  notices: []
1028
1031
  };
1029
1032
  var syncGlobalState$1 = {
1030
- setSubscriptions: setSubscriptions$1,
1031
1033
  addNotice: addNotice$1,
1032
- getNotices: getNotices$1,
1034
+ callListener: callListener$1,
1033
1035
  deleteNotices: deleteNotices$1,
1036
+ disableNotifications: disableNotifications$1,
1037
+ enableNotifications: enableNotifications$1,
1038
+ getNotices: getNotices$1,
1034
1039
  getTopics: getTopics$1,
1035
- callListener: callListener$1,
1036
1040
  getTournamentId: getTournamentId$1,
1037
1041
  getTournamentRecord: getTournamentRecord$1,
1038
1042
  getTournamentRecords: getTournamentRecords$1,
1043
+ removeTournamentRecord: removeTournamentRecord$1,
1044
+ setSubscriptions: setSubscriptions$1,
1039
1045
  setTournamentId: setTournamentId$1,
1040
1046
  setTournamentRecord: setTournamentRecord$2,
1041
- setTournamentRecords: setTournamentRecords$1,
1042
- removeTournamentRecord: removeTournamentRecord$1
1047
+ setTournamentRecords: setTournamentRecords$1
1043
1048
  };
1049
+ function disableNotifications$1() {
1050
+ syncGlobalState.disableNotifications = true;
1051
+ }
1052
+ function enableNotifications$1() {
1053
+ syncGlobalState.disableNotifications = false;
1054
+ }
1044
1055
  function getTournamentId$1() {
1045
1056
  return syncGlobalState.tournamentId;
1046
1057
  }
@@ -1127,7 +1138,7 @@ function addNotice$1({
1127
1138
  return;
1128
1139
  }
1129
1140
 
1130
- if (!syncGlobalState.subscriptions[topic]) return;
1141
+ if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic]) return;
1131
1142
 
1132
1143
  if (key) {
1133
1144
  syncGlobalState.notices = syncGlobalState.notices.filter(notice => !(notice.topic === topic && notice.key === key));
@@ -1166,19 +1177,19 @@ function callListener$1({
1166
1177
  }
1167
1178
 
1168
1179
  const globalState = {
1169
- devContext: undefined,
1170
1180
  timers: {
1171
1181
  default: {
1172
1182
  elapsedTime: 0
1173
1183
  }
1174
1184
  },
1175
- deepCopy: true,
1185
+ devContext: undefined,
1176
1186
  deepCopyAttributes: {
1177
1187
  threshold: undefined,
1178
1188
  stringify: [],
1179
1189
  ignore: [],
1180
1190
  toJSON: []
1181
- }
1191
+ },
1192
+ deepCopy: true
1182
1193
  };
1183
1194
  let _globalStateProvider = syncGlobalState$1;
1184
1195
  const requiredStateProviderMethods = ['addNotice', 'callListener', 'deleteNotices', 'getNotices', 'getTopics', 'getTournamentId', 'getTournamentRecord', 'getTournamentRecords', 'removeTournamentRecord', 'setSubscriptions', 'setTournamentId', 'setTournamentRecord', 'setTournamentRecords'];
@@ -1234,6 +1245,12 @@ function getDevContext(contextCriteria) {
1234
1245
  function setDevContext(value) {
1235
1246
  globalState.devContext = value;
1236
1247
  }
1248
+ function disableNotifications() {
1249
+ _globalStateProvider.disableNotifications();
1250
+ }
1251
+ function enableNotifications() {
1252
+ _globalStateProvider.enableNotifications();
1253
+ }
1237
1254
  function setDeepCopy(value, attributes) {
1238
1255
  if (typeof value === 'boolean') {
1239
1256
  globalState.deepCopy = value;
@@ -2051,7 +2068,7 @@ The algorithm relies on the values avaialble in the calculated `participantResul
2051
2068
  • participantResults scoped to the members of a group and recalculated when `{ idsFilter: true }`
2052
2069
  */
2053
2070
 
2054
- const defaultTallyDirectives = [{
2071
+ const headToHeadTallyDirectives = [{
2055
2072
  attribute: 'matchUpsRatio',
2056
2073
  idsFilter: false
2057
2074
  }, {
@@ -2092,6 +2109,12 @@ const defaultTallyDirectives = [{
2092
2109
  attribute: 'pointsRatio',
2093
2110
  idsFilter: true
2094
2111
  }];
2112
+ const GEMScoreValueMap = {
2113
+ matchUpsRatio: 16,
2114
+ setsRatio: 12,
2115
+ gamesRatio: 8,
2116
+ pointsRatio: 4
2117
+ };
2095
2118
  /**
2096
2119
  *
2097
2120
  * @param {object[]} participantResults - calculated results for each participant
@@ -2104,15 +2127,17 @@ const defaultTallyDirectives = [{
2104
2127
  function getGroupOrder(params) {
2105
2128
  const {
2106
2129
  participantResults,
2107
- subOrderMap
2130
+ subOrderMap,
2131
+ tallyPolicy
2108
2132
  } = params; // if not all opponents have completed their matchUps, no orders are assigned
2109
2133
 
2110
2134
  if (!isComplete(params)) return;
2111
- const matchUpsWonGroups = getGroups({
2112
- attribute: 'matchUpsWon',
2113
- participantResults
2135
+ const attribute = ['matchUpsWon', 'pointsWon', 'gamesWon', 'setsWon', 'gamesRatio', 'setsRatio', 'pointsRatio', 'matchUpsRatio'].includes(tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.groupOrderKey) ? tallyPolicy.groupOrderKey : 'matchUpsWon';
2136
+ const orderedTallyGroups = getGroups({
2137
+ participantResults,
2138
+ attribute
2114
2139
  });
2115
- const groupOrder = Object.keys(matchUpsWonGroups).map(key => parseFloat(key)).sort((a, b) => b - a).map(key => matchUpsWonGroups[key]).map(participantIds => groupSubSort({
2140
+ const groupOrder = Object.keys(orderedTallyGroups).map(key => parseFloat(key)).sort((a, b) => b - a).map(key => orderedTallyGroups[key]).map(participantIds => groupSubSort({
2116
2141
  participantIds,
2117
2142
  ...params
2118
2143
  })).flat(Infinity);
@@ -2162,11 +2187,11 @@ function getGroupOrder(params) {
2162
2187
  result.GEMscore = getRatioHash(result);
2163
2188
  });
2164
2189
  return groupOrder;
2165
- }
2166
2190
 
2167
- function getRatioHash(result) {
2168
- const rh = result.matchUpsRatio * Math.pow(10, 16) + result.setsRatio * Math.pow(10, 12) + result.gamesRatio * Math.pow(10, 8) + result.pointsRatio * Math.pow(10, 3);
2169
- return rh;
2191
+ function getRatioHash(result) {
2192
+ const attributes = Array.isArray(tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.GEMscore) ? Object.keys(GEMScoreValueMap).filter(attribute => tallyPolicy.GEMscore.includes(attribute)) : Object.keys(GEMScoreValueMap);
2193
+ return attributes.map(attribute => (result[attribute] || 0) * Math.pow(10, GEMScoreValueMap[attribute])).reduce((a, b) => a + b, 0);
2194
+ }
2170
2195
  }
2171
2196
 
2172
2197
  function isComplete({
@@ -2244,7 +2269,7 @@ function groupSubSort({
2244
2269
  }
2245
2270
 
2246
2271
  let result;
2247
- ((tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.tallyDirectives) || defaultTallyDirectives).every(({
2272
+ ((tallyPolicy === null || tallyPolicy === void 0 ? void 0 : tallyPolicy.tallyDirectives) || headToHeadTallyDirectives).every(({
2248
2273
  attribute,
2249
2274
  reversed,
2250
2275
  idsFilter,
@@ -3288,6 +3313,211 @@ const eventConstants = {
3288
3313
  BOTH
3289
3314
  };
3290
3315
 
3316
+ function getVenuesAndCourts$1({
3317
+ tournamentRecord
3318
+ }) {
3319
+ if (!tournamentRecord) return {
3320
+ error: MISSING_TOURNAMENT_RECORD
3321
+ };
3322
+ const venues = makeDeepCopy(tournamentRecord.venues || []);
3323
+ const courts = venues.reduce((courts, venue) => {
3324
+ var _venue$courts;
3325
+
3326
+ return venue !== null && venue !== void 0 && (_venue$courts = venue.courts) !== null && _venue$courts !== void 0 && _venue$courts.length ? courts.concat(venue.courts) : courts;
3327
+ }, []);
3328
+ return {
3329
+ venues,
3330
+ courts
3331
+ };
3332
+ }
3333
+ function findVenue({
3334
+ tournamentRecord,
3335
+ venueId
3336
+ }) {
3337
+ if (!tournamentRecord) return {
3338
+ error: MISSING_TOURNAMENT_RECORD
3339
+ };
3340
+ if (!venueId) return {
3341
+ error: MISSING_VENUE_ID
3342
+ };
3343
+ const venues = tournamentRecord.venues || [];
3344
+ const venue = venues.reduce((venue, venueRecord) => {
3345
+ return venueRecord.venueId === venueId ? venueRecord : venue;
3346
+ }, undefined);
3347
+ return venue && {
3348
+ venue
3349
+ } || {
3350
+ error: VENUE_NOT_FOUND
3351
+ };
3352
+ }
3353
+ function publicFindVenue(params) {
3354
+ return makeDeepCopy(findVenue(params), false, true);
3355
+ }
3356
+
3357
+ function findCourt({
3358
+ tournamentRecord,
3359
+ courtId
3360
+ }) {
3361
+ if (!tournamentRecord) return {
3362
+ error: MISSING_TOURNAMENT_RECORD
3363
+ };
3364
+ if (!courtId) return {
3365
+ error: MISSING_COURT_ID
3366
+ };
3367
+ let court, venue;
3368
+ (tournamentRecord.venues || []).forEach(venueRecord => {
3369
+ (venueRecord.courts || []).forEach(courtRecord => {
3370
+ if (courtRecord.courtId === courtId) {
3371
+ court = courtRecord;
3372
+ venue = venueRecord;
3373
+ }
3374
+ });
3375
+ });
3376
+ return court && {
3377
+ court,
3378
+ venue
3379
+ } || {
3380
+ error: COURT_NOT_FOUND
3381
+ };
3382
+ }
3383
+ function publicFindCourt(params) {
3384
+ return makeDeepCopy(findCourt(params), false, true);
3385
+ }
3386
+ /**
3387
+ *
3388
+ * @param {string} venueId - optional -
3389
+ * @param {string[]} venueIds - optional -
3390
+ */
3391
+
3392
+ function getCourts({
3393
+ tournamentRecord,
3394
+ venueId,
3395
+ venueIds
3396
+ }) {
3397
+ if (!tournamentRecord) return {
3398
+ error: MISSING_TOURNAMENT_RECORD
3399
+ };
3400
+ const courts = (tournamentRecord.venues || []).filter(venue => {
3401
+ if (venueId) return venue.venueId === venueId;
3402
+ if (venueIds) return venueIds.includes(venue.venueId);
3403
+ if (!venueId && !venueIds) return true;
3404
+ return false;
3405
+ }).map(venue => {
3406
+ const {
3407
+ venueId
3408
+ } = venue;
3409
+ const venueCourts = makeDeepCopy(venue.courts || []);
3410
+ venueCourts.forEach(court => Object.assign(court, {
3411
+ venueId
3412
+ }));
3413
+ return venueCourts;
3414
+ }).flat();
3415
+ return {
3416
+ courts
3417
+ };
3418
+ }
3419
+
3420
+ function getCourtInfo({
3421
+ tournamentRecord,
3422
+ courtId
3423
+ }) {
3424
+ if (!tournamentRecord) return {
3425
+ error: MISSING_TOURNAMENT_RECORD
3426
+ };
3427
+ if (!courtId) return {
3428
+ error: MISSING_COURT_ID
3429
+ };
3430
+ const {
3431
+ court,
3432
+ error
3433
+ } = findCourt({
3434
+ tournamentRecord,
3435
+ courtId
3436
+ });
3437
+ if (error) return {
3438
+ error
3439
+ };
3440
+
3441
+ const courtInfo = (({
3442
+ altitude,
3443
+ courtId,
3444
+ courtName,
3445
+ courtDimensions,
3446
+ latitude,
3447
+ longitude,
3448
+ surfaceCategory,
3449
+ surfaceType,
3450
+ surfaceDate,
3451
+ pace,
3452
+ notes
3453
+ }) => ({
3454
+ altitude,
3455
+ courtId,
3456
+ courtName,
3457
+ courtDimensions,
3458
+ latitude,
3459
+ longitude,
3460
+ surfaceCategory,
3461
+ surfaceType,
3462
+ surfaceDate,
3463
+ pace,
3464
+ notes
3465
+ }))(court);
3466
+
3467
+ return { ...SUCCESS,
3468
+ courtInfo: makeDeepCopy(courtInfo)
3469
+ };
3470
+ }
3471
+
3472
+ // e.g. dataAvailability objects are not returned.
3473
+
3474
+ function getVenueData({
3475
+ tournamentRecord,
3476
+ venueId
3477
+ }) {
3478
+ if (!tournamentRecord) return {
3479
+ error: MISSING_TOURNAMENT_RECORD
3480
+ };
3481
+ if (!venueId) return {
3482
+ error: MISSING_VENUE_ID
3483
+ };
3484
+ const {
3485
+ venue,
3486
+ error
3487
+ } = findVenue({
3488
+ tournamentRecord,
3489
+ venueId
3490
+ });
3491
+ if (error) return {
3492
+ error
3493
+ };
3494
+ const courts = venue.courts || [];
3495
+ const courtsInfo = courts.map(court => (({
3496
+ courtInfo
3497
+ }) => ({ ...courtInfo
3498
+ }))(getCourtInfo({
3499
+ tournamentRecord,
3500
+ courtId: court.courtId
3501
+ })));
3502
+
3503
+ const venueInfo = (({
3504
+ venueId,
3505
+ venueName,
3506
+ venueAbbreviation
3507
+ }) => ({
3508
+ venueId,
3509
+ venueName,
3510
+ venueAbbreviation
3511
+ }))(venue);
3512
+
3513
+ const venueData = { ...venueInfo,
3514
+ courtsInfo
3515
+ };
3516
+ return { ...SUCCESS,
3517
+ venueData: makeDeepCopy(venueData)
3518
+ };
3519
+ }
3520
+
3291
3521
  function getMatchUpScheduleDetails({
3292
3522
  scheduleVisibilityFilters,
3293
3523
  afterRecoveryTimes = true,
@@ -3347,6 +3577,8 @@ function getMatchUpScheduleDetails({
3347
3577
  } = scheduleVisibilityFilters || {};
3348
3578
 
3349
3579
  if ((!eventIds || eventIds.includes(matchUp.eventId)) && (!drawIds || drawIds.includes(matchUp.drawId))) {
3580
+ var _ref;
3581
+
3350
3582
  const scheduleSource = {
3351
3583
  matchUp,
3352
3584
  visibilityThreshold
@@ -3389,13 +3621,31 @@ function getMatchUpScheduleDetails({
3389
3621
  }
3390
3622
 
3391
3623
  if (!scheduledDate && scheduledTime) scheduledDate = extractDate(scheduledTime);
3624
+ const extractedTime = extractTime(scheduledTime);
3625
+ let isoDateString = extractDate(scheduledDate);
3626
+ if (isoDateString && extractedTime) isoDateString += `T${extractedTime}`;
3627
+ const venueData = ((_ref = tournamentRecord && venueId && getVenueData({
3628
+ tournamentRecord,
3629
+ venueId
3630
+ })) === null || _ref === void 0 ? void 0 : _ref.venueData) || {};
3631
+ const {
3632
+ venueName,
3633
+ venueAbbreviation,
3634
+ courtsInfo
3635
+ } = venueData;
3636
+ const courtInfo = courtId && (courtsInfo === null || courtsInfo === void 0 ? void 0 : courtsInfo.find(courtInfo => courtInfo.courtId === courtId));
3637
+ const courtName = courtInfo === null || courtInfo === void 0 ? void 0 : courtInfo.courtName;
3392
3638
  schedule = definedAttributes({
3393
- venueId,
3394
- courtId,
3395
3639
  typeChangeTimeAfterRecovery,
3396
3640
  timeAfterRecovery,
3397
3641
  scheduledDate,
3398
3642
  scheduledTime,
3643
+ isoDateString,
3644
+ venueAbbreviation,
3645
+ venueName,
3646
+ venueId,
3647
+ courtName,
3648
+ courtId,
3399
3649
  typeChangeRecoveryMinutes,
3400
3650
  recoveryMinutes,
3401
3651
  averageMinutes,
@@ -10564,9 +10814,9 @@ function getAllPositionedParticipantIds({
10564
10814
  }).flat();
10565
10815
  }
10566
10816
  function getPositionAssignments$1({
10567
- structure,
10568
10817
  drawDefinition,
10569
- structureId
10818
+ structureId,
10819
+ structure
10570
10820
  }) {
10571
10821
  let error,
10572
10822
  positionAssignments = [];
@@ -10617,9 +10867,9 @@ function structureAssignedDrawPositions({
10617
10867
  const {
10618
10868
  positionAssignments
10619
10869
  } = getPositionAssignments$1({
10620
- structure,
10621
10870
  drawDefinition,
10622
- structureId
10871
+ structureId,
10872
+ structure
10623
10873
  });
10624
10874
  const assignedPositions = positionAssignments.filter(drawPosition => {
10625
10875
  return drawPosition.participantId || drawPosition.bye || drawPosition.qualifier;
@@ -11235,6 +11485,7 @@ function getAllStructureMatchUps({
11235
11485
  tournamentAppliedPolicies,
11236
11486
  tournamentParticipants,
11237
11487
  policyDefinitions,
11488
+ tournamentRecord,
11238
11489
  seedAssignments,
11239
11490
  drawDefinition,
11240
11491
  contextFilters,
@@ -11324,7 +11575,7 @@ function getAllStructureMatchUps({
11324
11575
  drawId,
11325
11576
  drawName
11326
11577
  } = drawDefinition || {};
11327
- const isRoundRobin = structure.structures;
11578
+ const isRoundRobin = !!structure.structures;
11328
11579
  let matchUps = getMappedStructureMatchUps({
11329
11580
  matchUpsMap,
11330
11581
  structureId,
@@ -11456,6 +11707,7 @@ function getAllStructureMatchUps({
11456
11707
  endDate
11457
11708
  } = getMatchUpScheduleDetails({
11458
11709
  scheduleVisibilityFilters,
11710
+ tournamentRecord,
11459
11711
  scheduleTiming,
11460
11712
  matchUpFormat,
11461
11713
  matchUpType,
@@ -11571,6 +11823,11 @@ function getAllStructureMatchUps({
11571
11823
  });
11572
11824
 
11573
11825
  if (participant) {
11826
+ if (drawDefinition !== null && drawDefinition !== void 0 && drawDefinition.entries) {
11827
+ const entry = drawDefinition.entries.find(entry => entry.participantId === side.participantId);
11828
+ if (entry !== null && entry !== void 0 && entry.entryStatus) participant.entryStatus = entry.entryStatus || ALTERNATE;
11829
+ }
11830
+
11574
11831
  Object.assign(side, {
11575
11832
  participant
11576
11833
  });
@@ -11601,17 +11858,6 @@ function getAllStructureMatchUps({
11601
11858
  matchUpType
11602
11859
  });
11603
11860
  }
11604
-
11605
- if (drawDefinition !== null && drawDefinition !== void 0 && drawDefinition.entries) {
11606
- matchUpWithContext.sides.filter(Boolean).forEach(side => {
11607
- if (side.participantId) {
11608
- const entry = drawDefinition.entries.find(entry => entry.participantId === side.participantId);
11609
- if (entry !== null && entry !== void 0 && entry.entryStatus) Object.assign(side, {
11610
- entryStatus: entry.entryStatus || ALTERNATE
11611
- });
11612
- }
11613
- });
11614
- }
11615
11861
  }
11616
11862
 
11617
11863
  if (matchUpWithContext.tieMatchUps) {
@@ -11825,47 +12071,6 @@ function resetMatchUpTimeItems({
11825
12071
  };
11826
12072
  }
11827
12073
 
11828
- function getVenuesAndCourts$1({
11829
- tournamentRecord
11830
- }) {
11831
- if (!tournamentRecord) return {
11832
- error: MISSING_TOURNAMENT_RECORD
11833
- };
11834
- const venues = makeDeepCopy(tournamentRecord.venues || []);
11835
- const courts = venues.reduce((courts, venue) => {
11836
- var _venue$courts;
11837
-
11838
- return venue !== null && venue !== void 0 && (_venue$courts = venue.courts) !== null && _venue$courts !== void 0 && _venue$courts.length ? courts.concat(venue.courts) : courts;
11839
- }, []);
11840
- return {
11841
- venues,
11842
- courts
11843
- };
11844
- }
11845
- function findVenue({
11846
- tournamentRecord,
11847
- venueId
11848
- }) {
11849
- if (!tournamentRecord) return {
11850
- error: MISSING_TOURNAMENT_RECORD
11851
- };
11852
- if (!venueId) return {
11853
- error: MISSING_VENUE_ID
11854
- };
11855
- const venues = tournamentRecord.venues || [];
11856
- const venue = venues.reduce((venue, venueRecord) => {
11857
- return venueRecord.venueId === venueId ? venueRecord : venue;
11858
- }, undefined);
11859
- return venue && {
11860
- venue
11861
- } || {
11862
- error: VENUE_NOT_FOUND
11863
- };
11864
- }
11865
- function publicFindVenue(params) {
11866
- return makeDeepCopy(findVenue(params), false, true);
11867
- }
11868
-
11869
12074
  function assignMatchUpVenue$1({
11870
12075
  tournamentRecord,
11871
12076
  drawDefinition,
@@ -11905,69 +12110,6 @@ function assignMatchUpVenue$1({
11905
12110
  });
11906
12111
  }
11907
12112
 
11908
- function findCourt({
11909
- tournamentRecord,
11910
- courtId
11911
- }) {
11912
- if (!tournamentRecord) return {
11913
- error: MISSING_TOURNAMENT_RECORD
11914
- };
11915
- if (!courtId) return {
11916
- error: MISSING_COURT_ID
11917
- };
11918
- let court, venue;
11919
- (tournamentRecord.venues || []).forEach(venueRecord => {
11920
- (venueRecord.courts || []).forEach(courtRecord => {
11921
- if (courtRecord.courtId === courtId) {
11922
- court = courtRecord;
11923
- venue = venueRecord;
11924
- }
11925
- });
11926
- });
11927
- return court && {
11928
- court,
11929
- venue
11930
- } || {
11931
- error: COURT_NOT_FOUND
11932
- };
11933
- }
11934
- function publicFindCourt(params) {
11935
- return makeDeepCopy(findCourt(params), false, true);
11936
- }
11937
- /**
11938
- *
11939
- * @param {string} venueId - optional -
11940
- * @param {string[]} venueIds - optional -
11941
- */
11942
-
11943
- function getCourts({
11944
- tournamentRecord,
11945
- venueId,
11946
- venueIds
11947
- }) {
11948
- if (!tournamentRecord) return {
11949
- error: MISSING_TOURNAMENT_RECORD
11950
- };
11951
- const courts = (tournamentRecord.venues || []).filter(venue => {
11952
- if (venueId) return venue.venueId === venueId;
11953
- if (venueIds) return venueIds.includes(venue.venueId);
11954
- if (!venueId && !venueIds) return true;
11955
- return false;
11956
- }).map(venue => {
11957
- const {
11958
- venueId
11959
- } = venue;
11960
- const venueCourts = makeDeepCopy(venue.courts || []);
11961
- venueCourts.forEach(court => Object.assign(court, {
11962
- venueId
11963
- }));
11964
- return venueCourts;
11965
- }).flat();
11966
- return {
11967
- courts
11968
- };
11969
- }
11970
-
11971
12113
  function assignMatchUpCourt$1({
11972
12114
  tournamentRecord,
11973
12115
  drawDefinition,
@@ -13274,6 +13416,7 @@ function getStructureMatchUps({
13274
13416
  tournamentAppliedPolicies,
13275
13417
  tournamentParticipants,
13276
13418
  policyDefinitions,
13419
+ tournamentRecord,
13277
13420
  drawDefinition,
13278
13421
  matchUpFilters,
13279
13422
  contextFilters,
@@ -13304,6 +13447,7 @@ function getStructureMatchUps({
13304
13447
  scheduleVisibilityFilters,
13305
13448
  tournamentParticipants,
13306
13449
  policyDefinitions,
13450
+ tournamentRecord,
13307
13451
  drawDefinition,
13308
13452
  matchUpFilters,
13309
13453
  contextFilters,
@@ -13462,6 +13606,7 @@ function getDrawMatchUps({
13462
13606
  requireParticipants,
13463
13607
  includeByeMatchUps,
13464
13608
  policyDefinitions,
13609
+ tournamentRecord,
13465
13610
  drawDefinition,
13466
13611
  matchUpFilters,
13467
13612
  //
@@ -16925,22 +17070,26 @@ function assignDrawPositionBye$1({
16925
17070
  drawDefinition,
16926
17071
  drawPosition,
16927
17072
  matchUpsMap,
16928
- structureId
17073
+ structureId,
17074
+ structure
16929
17075
  }) {
16930
17076
  var _matchUp$drawPosition;
16931
17077
 
16932
17078
  if (!drawDefinition) return {
16933
17079
  error: MISSING_DRAW_DEFINITION
16934
17080
  };
16935
- const {
17081
+ if (!structure) ({
16936
17082
  structure
16937
17083
  } = findStructure({
16938
17084
  drawDefinition,
16939
17085
  structureId
16940
- });
17086
+ }));
16941
17087
  if (!structure) return {
16942
17088
  error: STRUCTURE_NOT_FOUND
16943
17089
  };
17090
+ if (!structureId) ({
17091
+ structureId
17092
+ } = structure);
16944
17093
 
16945
17094
  if (!matchUpsMap) {
16946
17095
  matchUpsMap = getMatchUpsMap({
@@ -17148,10 +17297,10 @@ function advanceDrawPosition({
17148
17297
  loserTargetDrawPosition
17149
17298
  }
17150
17299
  } = positionTargets({
17151
- matchUpId,
17152
- structure,
17300
+ inContextDrawMatchUps,
17153
17301
  drawDefinition,
17154
- inContextDrawMatchUps
17302
+ matchUpId,
17303
+ structure
17155
17304
  }); // only handling situation where winningMatchUp is in same structure
17156
17305
 
17157
17306
  if (winnerMatchUp && winnerMatchUp.structureId === structure.structureId) {
@@ -17182,10 +17331,10 @@ function advanceDrawPosition({
17182
17331
  if (result.error) return result;
17183
17332
  } else {
17184
17333
  assignFedDrawPositionBye({
17334
+ loserTargetDrawPosition,
17335
+ loserTargetLink,
17185
17336
  drawDefinition,
17186
17337
  loserMatchUp,
17187
- loserTargetLink,
17188
- loserTargetDrawPosition,
17189
17338
  matchUpsMap
17190
17339
  });
17191
17340
  }
@@ -21094,6 +21243,7 @@ function addCourt({
21094
21243
  disableNotice,
21095
21244
  returnDetails,
21096
21245
  venueId,
21246
+ courtId,
21097
21247
  court
21098
21248
  }) {
21099
21249
  const {
@@ -21107,7 +21257,8 @@ function addCourt({
21107
21257
  };
21108
21258
  if (!venue.courts) venue.courts = [];
21109
21259
  const courtRecord = { ...courtTemplate(),
21110
- venueId
21260
+ venueId,
21261
+ courtId
21111
21262
  };
21112
21263
 
21113
21264
  if (!courtRecord.courtId) {
@@ -21198,6 +21349,7 @@ function addCourts$1({
21198
21349
  tournamentRecord,
21199
21350
  courtNames = [],
21200
21351
  courtsCount,
21352
+ courtIds,
21201
21353
  venueId
21202
21354
  }) {
21203
21355
  if (!venueId) return {
@@ -21214,13 +21366,17 @@ function addCourts$1({
21214
21366
  };
21215
21367
  return court;
21216
21368
  });
21217
- const result = courts.map(court => addCourt({
21218
- tournamentRecord,
21219
- venueId,
21220
- court,
21221
- disableNotice: true,
21222
- returnDetails: true
21223
- }));
21369
+ const result = courts.map(court => {
21370
+ const courtId = courtIds === null || courtIds === void 0 ? void 0 : courtIds.pop();
21371
+ return addCourt({
21372
+ disableNotice: true,
21373
+ returnDetails: true,
21374
+ tournamentRecord,
21375
+ courtId,
21376
+ venueId,
21377
+ court
21378
+ });
21379
+ });
21224
21380
  const courtRecords = result.map(outcome => outcome.court).filter(Boolean);
21225
21381
 
21226
21382
  if (courtRecords.length === courtsCount) {
@@ -24624,9 +24780,10 @@ function findMatchUpFormatTiming({
24624
24780
  */
24625
24781
 
24626
24782
  function getScheduledRoundsDetails({
24627
- tournamentRecords,
24783
+ scheduleCompletedMatchUps,
24628
24784
  containedStructureIds,
24629
24785
  // optional to support calling method outside of scheduleProfileRounds
24786
+ tournamentRecords,
24630
24787
  periodLength = 30,
24631
24788
  matchUps,
24632
24789
  // optional to support calling method outside of scheduleProfileRounds
@@ -24733,8 +24890,8 @@ function getScheduledRoundsDetails({
24733
24890
  };
24734
24891
  const matchUpIds = roundMatchUps.filter(({
24735
24892
  matchUpStatus
24736
- }) => // don't attempt to scheduled completed matchUpstatuses
24737
- !completedMatchUpStatuses.includes(matchUpStatus) && matchUpStatus !== BYE).map(getMatchUpId);
24893
+ }) => // don't attempt to scheduled completed matchUpstatuses unless explicit override
24894
+ (scheduleCompletedMatchUps || !completedMatchUpStatuses.includes(matchUpStatus)) && matchUpStatus !== BYE).map(getMatchUpId);
24738
24895
  matchUpIds.forEach(matchUpId => {
24739
24896
  minutesMap[matchUpId] = {
24740
24897
  typeChangeRecoveryMinutes,
@@ -26077,6 +26234,8 @@ function generateScheduleTimes({
26077
26234
  function jinnScheduler({
26078
26235
  checkPotentialRequestConflicts = true,
26079
26236
  // passed to checkRequestConflicts
26237
+ scheduleCompletedMatchUps,
26238
+ // override which can be used by mocksEngine
26080
26239
  clearScheduleDates,
26081
26240
  scheduleDates = [],
26082
26241
  tournamentRecords,
@@ -26196,9 +26355,9 @@ function jinnScheduler({
26196
26355
 
26197
26356
  if ((_matchUp$schedule = matchUp.schedule) !== null && _matchUp$schedule !== void 0 && _matchUp$schedule.scheduledDate && sameDay(scheduleDate, extractDate(matchUp.schedule.scheduledDate))) {
26198
26357
  processNextMatchUps({
26199
- matchUp,
26358
+ matchUpPotentialParticipantIds,
26200
26359
  matchUpNotBeforeTimes,
26201
- matchUpPotentialParticipantIds
26360
+ matchUp
26202
26361
  });
26203
26362
  }
26204
26363
  }); // checking that matchUpDependencies is scoped to only those matchUps that are already or are to be scheduled on the same date
@@ -26218,6 +26377,7 @@ function jinnScheduler({
26218
26377
  orderedMatchUpIds,
26219
26378
  minutesMap
26220
26379
  } = getScheduledRoundsDetails({
26380
+ scheduleCompletedMatchUps,
26221
26381
  containedStructureIds,
26222
26382
  tournamentRecords,
26223
26383
  periodLength,
@@ -26291,7 +26451,8 @@ function jinnScheduler({
26291
26451
  let matchUpsToSchedule = orderedMatchUpIds.map(matchUpId => matchUps.find(matchUp => matchUp.matchUpId === matchUpId)).filter(Boolean).filter(matchUp => {
26292
26452
  const alreadyScheduled = !clearDate && dateScheduledMatchUpIds.includes(matchUp.matchUpId);
26293
26453
  const doNotSchedule = [BYE, DEFAULTED, COMPLETED, ABANDONED, RETIRED, WALKOVER$1].includes(matchUp === null || matchUp === void 0 ? void 0 : matchUp.matchUpStatus);
26294
- return !alreadyScheduled && !matchUp.winningSide && !doNotSchedule;
26454
+ return scheduleCompletedMatchUps || // override for mocksEngine
26455
+ !alreadyScheduled && !matchUp.winningSide && !doNotSchedule;
26295
26456
  }); // for optimization, build up an object for each tournament and an array for each draw with target matchUps
26296
26457
  // keep track of matchUps counts per participant and don't add matchUps for participants beyond those limits
26297
26458
 
@@ -26603,6 +26764,7 @@ function jinnScheduler({
26603
26764
  schedulingProfileModifications,
26604
26765
  schedulingProfileIssues,
26605
26766
  scheduleTimesRemaining,
26767
+ dateSchedulingProfiles,
26606
26768
  skippedScheduleTimes,
26607
26769
  recoveryTimeDeferredMatchUpIds,
26608
26770
  dependencyDeferredMatchUpIds,
@@ -26617,6 +26779,7 @@ function jinnScheduler({
26617
26779
 
26618
26780
  function scheduleProfileRounds({
26619
26781
  checkPotentialRequestConflicts = true,
26782
+ scheduleCompletedMatchUps,
26620
26783
  clearScheduleDates,
26621
26784
  scheduleDates = [],
26622
26785
  tournamentRecords,
@@ -26625,6 +26788,7 @@ function scheduleProfileRounds({
26625
26788
  }) {
26626
26789
  return jinnScheduler({
26627
26790
  checkPotentialRequestConflicts,
26791
+ scheduleCompletedMatchUps,
26628
26792
  clearScheduleDates,
26629
26793
  tournamentRecords,
26630
26794
  scheduleDates,
@@ -30917,9 +31081,10 @@ function positionByes({
30917
31081
  for (const drawPosition of byeDrawPositions) {
30918
31082
  const result = assignDrawPositionBye$1({
30919
31083
  drawDefinition,
30920
- structureId,
30921
31084
  drawPosition,
30922
- matchUpsMap
31085
+ matchUpsMap,
31086
+ structureId,
31087
+ structure
30923
31088
  });
30924
31089
  if (result !== null && result !== void 0 && result.error) return result;
30925
31090
  }
@@ -30966,6 +31131,8 @@ function positionQualifiers(params) {
30966
31131
  positionAssignments.forEach(assignment => {
30967
31132
  if (assignment.drawPosition === drawPosition) {
30968
31133
  assignment.qualifier = true;
31134
+ delete assignment.participantId;
31135
+ delete assignment.bye;
30969
31136
  }
30970
31137
  });
30971
31138
  });
@@ -30997,27 +31164,27 @@ function getQualifiersData({
30997
31164
  } = structure;
30998
31165
  const qualifiersCount = getStageQualifiersCount({
30999
31166
  drawDefinition,
31000
- stage,
31001
- stageSequence
31167
+ stageSequence,
31168
+ stage
31002
31169
  });
31003
31170
  const unplacedQualifiersCount = qualifiersCount - assignedQualifierPositions.length;
31004
31171
  const placedQualifiersCount = assignedQualifierPositions.length;
31005
31172
  return {
31006
- positionAssignments,
31007
- qualifiersCount,
31173
+ unplacedQualifiersCount,
31008
31174
  placedQualifiersCount,
31009
- unplacedQualifiersCount
31175
+ positionAssignments,
31176
+ qualifiersCount
31010
31177
  };
31011
31178
  }
31012
31179
 
31013
31180
  function positionSeedBlocks({
31181
+ inContextDrawMatchUps,
31014
31182
  drawDefinition,
31015
31183
  participants,
31016
31184
  groupsCount,
31017
31185
  structureId,
31018
- structure,
31019
31186
  matchUpsMap,
31020
- inContextDrawMatchUps
31187
+ structure
31021
31188
  }) {
31022
31189
  const errors = [];
31023
31190
  let placedSeedBlocks = 0;
@@ -31048,11 +31215,11 @@ function positionSeedBlocks({
31048
31215
  generateRange(0, groupsCount).forEach(() => {
31049
31216
  if (placedSeedBlocks < groupsCount) {
31050
31217
  const result = positionSeedBlock({
31218
+ inContextDrawMatchUps,
31051
31219
  drawDefinition,
31052
31220
  participants,
31053
31221
  structureId,
31054
- matchUpsMap,
31055
- inContextDrawMatchUps
31222
+ matchUpsMap
31056
31223
  });
31057
31224
  if (result && result.success) placedSeedBlocks++;
31058
31225
 
@@ -31100,13 +31267,13 @@ function positionSeedBlock({
31100
31267
  error: MISSING_DRAW_POSITION
31101
31268
  };
31102
31269
  const result = assignDrawPosition$1({
31270
+ automaticPlacement: true,
31271
+ inContextDrawMatchUps,
31103
31272
  drawDefinition,
31104
- structureId,
31105
- drawPosition,
31106
31273
  participantId,
31107
- automaticPlacement: true,
31274
+ drawPosition,
31108
31275
  matchUpsMap,
31109
- inContextDrawMatchUps
31276
+ structureId
31110
31277
  });
31111
31278
  if (!result.success) return result;
31112
31279
  }
@@ -31115,6 +31282,7 @@ function positionSeedBlock({
31115
31282
  }
31116
31283
 
31117
31284
  function automatedPositioning$1({
31285
+ applyPositioning = true,
31118
31286
  inContextDrawMatchUps,
31119
31287
  drawDefinition,
31120
31288
  candidatesCount,
@@ -31125,6 +31293,24 @@ function automatedPositioning$1({
31125
31293
  drawType,
31126
31294
  event
31127
31295
  }) {
31296
+ //-----------------------------------------------------------
31297
+ // handle notification state for all exit conditions
31298
+ if (!applyPositioning) {
31299
+ disableNotifications();
31300
+ drawDefinition = makeDeepCopy(drawDefinition, false, true);
31301
+ }
31302
+
31303
+ const handleErrorCondition = result => {
31304
+ if (!applyPositioning) enableNotifications();
31305
+ return result;
31306
+ };
31307
+
31308
+ const handleSuccessCondition = result => {
31309
+ if (!applyPositioning) enableNotifications();
31310
+ return result;
31311
+ }; //-----------------------------------------------------------
31312
+
31313
+
31128
31314
  const {
31129
31315
  structure,
31130
31316
  error
@@ -31132,9 +31318,9 @@ function automatedPositioning$1({
31132
31318
  drawDefinition,
31133
31319
  structureId
31134
31320
  });
31135
- if (error) return {
31321
+ if (error) return handleErrorCondition({
31136
31322
  error
31137
- };
31323
+ });
31138
31324
  const entryStatuses = [DIRECT_ACCEPTANCE, WILDCARD];
31139
31325
  const entries = getStageEntries$1({
31140
31326
  stageSequence: structure.stageSequence,
@@ -31143,7 +31329,8 @@ function automatedPositioning$1({
31143
31329
  entryStatuses,
31144
31330
  structureId
31145
31331
  });
31146
- if (!(entries !== null && entries !== void 0 && entries.length)) return SUCCESS;
31332
+ if (!(entries !== null && entries !== void 0 && entries.length)) return handleSuccessCondition({ ...SUCCESS
31333
+ });
31147
31334
  const {
31148
31335
  seedingProfile
31149
31336
  } = structure;
@@ -31172,7 +31359,7 @@ function automatedPositioning$1({
31172
31359
  seedsOnly,
31173
31360
  event
31174
31361
  });
31175
- if (result.error) return result;
31362
+ if (result.error) return handleErrorCondition(result);
31176
31363
  result = positionSeedBlocks({
31177
31364
  inContextDrawMatchUps,
31178
31365
  drawDefinition,
@@ -31180,7 +31367,7 @@ function automatedPositioning$1({
31180
31367
  matchUpsMap,
31181
31368
  structure
31182
31369
  });
31183
- if (result.error) return result;
31370
+ if (result.error) return handleErrorCondition(result);
31184
31371
  } else {
31185
31372
  // otherwise... seeds need to be placed first so that BYEs
31186
31373
  // can follow the seedValues of placed seeds
@@ -31192,7 +31379,7 @@ function automatedPositioning$1({
31192
31379
  matchUpsMap,
31193
31380
  structure
31194
31381
  });
31195
- if (result.error) return result;
31382
+ if (result.error) return handleErrorCondition(result);
31196
31383
  }
31197
31384
 
31198
31385
  const result = positionByes({
@@ -31203,7 +31390,7 @@ function automatedPositioning$1({
31203
31390
  seedsOnly,
31204
31391
  event
31205
31392
  });
31206
- if (result.error) return result;
31393
+ if (result.error) return handleErrorCondition(result);
31207
31394
  }
31208
31395
 
31209
31396
  const conflicts = {};
@@ -31217,25 +31404,37 @@ function automatedPositioning$1({
31217
31404
  matchUpsMap,
31218
31405
  structure
31219
31406
  });
31220
- if (result.error) return result;
31407
+ if (result.error) return handleErrorCondition(result);
31221
31408
  if (result.conflicts) conflicts.unseededConflicts = result.conflicts;
31222
31409
  result = positionQualifiers({
31410
+ inContextDrawMatchUps,
31223
31411
  drawDefinition,
31224
31412
  participants,
31225
- structure,
31226
31413
  matchUpsMap,
31227
- inContextDrawMatchUps
31414
+ structure
31228
31415
  });
31229
- if (result.error) return result;
31416
+ if (result.error) return handleErrorCondition(result);
31230
31417
  if (result.conflicts) conflicts.qualifierConflicts = result.conflicts;
31231
31418
  }
31232
31419
 
31420
+ const {
31421
+ positionAssignments
31422
+ } = getPositionAssignments$1({
31423
+ drawDefinition,
31424
+ structure
31425
+ });
31233
31426
  modifyDrawNotice({
31234
31427
  drawDefinition,
31235
31428
  structureIds: [structureId]
31236
- });
31429
+ }); //-----------------------------------------------------------
31430
+ // re-enable notifications, if they have been disabled
31431
+
31432
+ if (!applyPositioning) enableNotifications(); //-----------------------------------------------------------
31433
+
31237
31434
  return {
31238
- conflicts
31435
+ positionAssignments,
31436
+ conflicts,
31437
+ ...SUCCESS
31239
31438
  };
31240
31439
  }
31241
31440
 
@@ -31985,8 +32184,8 @@ function addVoluntaryConsolationStage$1({
31985
32184
 
31986
32185
  function getStructureQualifiersCount({
31987
32186
  drawDefinition,
31988
- structure,
31989
- structureId
32187
+ structureId,
32188
+ structure
31990
32189
  }) {
31991
32190
  let error, qualifiersCount;
31992
32191
 
@@ -34816,15 +35015,15 @@ function getSeedsCount({
34816
35015
  }
34817
35016
 
34818
35017
  function initializeStructureSeedAssignments({
34819
- tournamentRecord,
34820
- drawDefinition,
34821
- event,
34822
35018
  requireParticipantCount = true,
34823
35019
  enforcePolicyLimits = true,
34824
35020
  drawSizeProgression,
35021
+ tournamentRecord,
34825
35022
  participantCount,
35023
+ drawDefinition,
34826
35024
  structureId,
34827
- seedsCount
35025
+ seedsCount,
35026
+ event
34828
35027
  }) {
34829
35028
  const {
34830
35029
  structure,
@@ -35173,6 +35372,110 @@ function alternateDrawPositionAssignment$1({
35173
35372
  });
35174
35373
  }
35175
35374
 
35375
+ function setPositionAssignments$1({
35376
+ structurePositionAssignments,
35377
+ drawDefinition
35378
+ }) {
35379
+ if (!drawDefinition) return {
35380
+ error: MISSING_DRAW_DEFINITION
35381
+ };
35382
+ if (!Array.isArray(structurePositionAssignments)) return {
35383
+ error: INVALID_VALUES
35384
+ };
35385
+
35386
+ for (const structureAssignments of structurePositionAssignments) {
35387
+ var _structure$positionAs;
35388
+
35389
+ const {
35390
+ structureId,
35391
+ positionAssignments
35392
+ } = structureAssignments;
35393
+ const result = findStructure({
35394
+ drawDefinition,
35395
+ structureId
35396
+ });
35397
+ if (result.error) return result;
35398
+ const structure = result.structure;
35399
+ if (!structure) return {
35400
+ error: STRUCTURE_NOT_FOUND
35401
+ };
35402
+ if (structure.structures) return {
35403
+ error: INVALID_STRUCTURE,
35404
+ message: 'cannot be Round Robin group container'
35405
+ };
35406
+ const structureDrawPositions = (_structure$positionAs = structure.positionAssignments) === null || _structure$positionAs === void 0 ? void 0 : _structure$positionAs.map(({
35407
+ drawPosition
35408
+ }) => drawPosition);
35409
+ const submittedDrawPositions = positionAssignments.map(({
35410
+ drawPosition
35411
+ }) => drawPosition);
35412
+ if (intersection(structureDrawPositions, submittedDrawPositions).length !== structureDrawPositions.length) return {
35413
+ error: INVALID_VALUES,
35414
+ message: 'drawPositions do not match'
35415
+ };
35416
+ const matchUpsMap = getMatchUpsMap({
35417
+ drawDefinition
35418
+ });
35419
+ const {
35420
+ matchUps: inContextDrawMatchUps
35421
+ } = getAllDrawMatchUps({
35422
+ includeByeMatchUps: true,
35423
+ inContext: true,
35424
+ drawDefinition,
35425
+ matchUpsMap
35426
+ });
35427
+
35428
+ for (const assignment of positionAssignments) {
35429
+ const {
35430
+ drawPosition,
35431
+ participantId,
35432
+ bye,
35433
+ qualifier
35434
+ } = assignment;
35435
+
35436
+ if (bye) {
35437
+ const result = assignDrawPositionBye$1({
35438
+ drawDefinition,
35439
+ drawPosition,
35440
+ matchUpsMap,
35441
+ structureId,
35442
+ structure
35443
+ });
35444
+ if (result !== null && result !== void 0 && result.error) return result;
35445
+ } else if (qualifier) {
35446
+ positionAssignments.forEach(assignment => {
35447
+ if (assignment.drawPosition === drawPosition) {
35448
+ assignment.qualifier = true;
35449
+ delete assignment.participantId;
35450
+ delete assignment.bye;
35451
+ }
35452
+ });
35453
+ } else if (participantId) {
35454
+ const result = assignDrawPosition$1({
35455
+ automaticPlacement: true,
35456
+ inContextDrawMatchUps,
35457
+ drawDefinition,
35458
+ participantId,
35459
+ drawPosition,
35460
+ matchUpsMap,
35461
+ structureId
35462
+ });
35463
+ if (result !== null && result !== void 0 && result.error) return result;
35464
+ }
35465
+ }
35466
+ }
35467
+
35468
+ const structureIds = structurePositionAssignments.map(({
35469
+ structureId
35470
+ }) => structureId);
35471
+ modifyDrawNotice({
35472
+ drawDefinition,
35473
+ structureIds
35474
+ });
35475
+ return { ...SUCCESS
35476
+ };
35477
+ }
35478
+
35176
35479
  // optionally filter to included only specified stages
35177
35480
 
35178
35481
  function getAssignedParticipantIds({
@@ -36725,12 +37028,11 @@ function setSubOrder({
36725
37028
  };
36726
37029
  }
36727
37030
 
36728
- // import { assignCollectionPosition, assignDrawPosition } from './positionAssignment';
36729
37031
  const positionGovernor = {
36730
37032
  setSubOrder,
36731
37033
  clearDrawPosition,
36732
37034
  assignDrawPosition: assignDrawPosition$1,
36733
- // assignCollectionPosition,
37035
+ setPositionAssignments: setPositionAssignments$1,
36734
37036
  automatedPositioning: automatedPositioning$1,
36735
37037
  assignDrawPositionBye: assignDrawPositionBye$1,
36736
37038
  swapDrawPositionAssignments: swapDrawPositionAssignments$1,
@@ -38852,7 +39154,7 @@ function modifySeedAssignment$1({
38852
39154
  if (!structure) return {
38853
39155
  error: STRUCTURE_NOT_FOUND
38854
39156
  };
38855
- const validValue = !validation || isNumeric(seedValue) || typeof seedValue === 'string' && seedValue.split('-').every(isNumeric);
39157
+ const validValue = !validation || isNumeric(seedValue) || [undefined, ''].includes(seedValue) || typeof seedValue === 'string' && seedValue.split('-').every(v => isNumeric(v) && v > 0);
38856
39158
  if (!validValue) return {
38857
39159
  error: INVALID_VALUES
38858
39160
  };
@@ -38866,7 +39168,8 @@ function modifySeedAssignment$1({
38866
39168
  const existingAssginment = seedAssignments.find(assignment => assignment.participantId === participantId);
38867
39169
 
38868
39170
  if (existingAssginment) {
38869
- existingAssginment.seedValue = seedValue;
39171
+ const newValue = typeof seedValue === 'string' ? seedValue.includes('-') ? seedValue.split('-').map(v => parseInt(v)).join('-') : seedValue > 0 ? parseInt(seedValue) : '' : seedValue > 0 ? parseInt(seedValue) : '';
39172
+ existingAssginment.seedValue = newValue;
38870
39173
  } else {
38871
39174
  const seedNumber = Math.max(0, ...seedNumbers) + 1;
38872
39175
  structure.seedAssignments.push({
@@ -41392,61 +41695,10 @@ const participantGovernor = {
41392
41695
  getTournamentPersons
41393
41696
  };
41394
41697
 
41395
- function getCourtInfo({
41396
- tournamentRecord,
41397
- courtId
41398
- }) {
41399
- if (!tournamentRecord) return {
41400
- error: MISSING_TOURNAMENT_RECORD
41401
- };
41402
- if (!courtId) return {
41403
- error: MISSING_COURT_ID
41404
- };
41405
- const {
41406
- court,
41407
- error
41408
- } = findCourt({
41409
- tournamentRecord,
41410
- courtId
41411
- });
41412
- if (error) return {
41413
- error
41414
- };
41415
-
41416
- const courtInfo = (({
41417
- altitude,
41418
- courtId,
41419
- courtName,
41420
- courtDimensions,
41421
- latitude,
41422
- longitude,
41423
- surfaceCategory,
41424
- surfaceType,
41425
- surfaceDate,
41426
- pace,
41427
- notes
41428
- }) => ({
41429
- altitude,
41430
- courtId,
41431
- courtName,
41432
- courtDimensions,
41433
- latitude,
41434
- longitude,
41435
- surfaceCategory,
41436
- surfaceType,
41437
- surfaceDate,
41438
- pace,
41439
- notes
41440
- }))(court);
41441
-
41442
- return { ...SUCCESS,
41443
- courtInfo: makeDeepCopy(courtInfo)
41444
- };
41445
- }
41446
-
41447
41698
  function getDrawData({
41448
41699
  tournamentParticipants = [],
41449
41700
  policyDefinitions,
41701
+ tournamentRecord,
41450
41702
  inContext = true,
41451
41703
  drawDefinition,
41452
41704
  context,
@@ -41525,6 +41777,7 @@ function getDrawData({
41525
41777
  },
41526
41778
  tournamentParticipants,
41527
41779
  policyDefinitions,
41780
+ tournamentRecord,
41528
41781
  seedAssignments,
41529
41782
  drawDefinition,
41530
41783
  structure,
@@ -41670,55 +41923,6 @@ function getStructureGroups({
41670
41923
  };
41671
41924
  }
41672
41925
 
41673
- // e.g. dataAvailability objects are not returned.
41674
-
41675
- function getVenueData({
41676
- tournamentRecord,
41677
- venueId
41678
- }) {
41679
- if (!tournamentRecord) return {
41680
- error: MISSING_TOURNAMENT_RECORD
41681
- };
41682
- if (!venueId) return {
41683
- error: MISSING_VENUE_ID
41684
- };
41685
- const {
41686
- venue,
41687
- error
41688
- } = findVenue({
41689
- tournamentRecord,
41690
- venueId
41691
- });
41692
- if (error) return {
41693
- error
41694
- };
41695
- const courts = venue.courts || [];
41696
- const courtsInfo = courts.map(court => (({
41697
- courtInfo
41698
- }) => ({ ...courtInfo
41699
- }))(getCourtInfo({
41700
- tournamentRecord,
41701
- courtId: court.courtId
41702
- })));
41703
-
41704
- const venueInfo = (({
41705
- venueId,
41706
- venueName,
41707
- venueAbbreviation
41708
- }) => ({
41709
- venueId,
41710
- venueName,
41711
- venueAbbreviation
41712
- }))(venue);
41713
-
41714
- const venueData = { ...venueInfo,
41715
- courtsInfo
41716
- };
41717
- return { ...SUCCESS,
41718
- venueData: makeDeepCopy(venueData)
41719
- };
41720
- }
41721
-
41722
41926
  function getEventData({
41723
41927
  participantsProfile,
41724
41928
  policyDefinitions,
@@ -41756,14 +41960,15 @@ function getEventData({
41756
41960
  }) => ({ ...drawInfo,
41757
41961
  structures
41758
41962
  }))(getDrawData({
41759
- tournamentParticipants,
41760
- policyDefinitions,
41761
- drawDefinition,
41762
41963
  context: {
41763
41964
  eventId,
41764
41965
  tournamentId,
41765
41966
  endDate
41766
41967
  },
41968
+ tournamentParticipants,
41969
+ policyDefinitions,
41970
+ tournamentRecord,
41971
+ drawDefinition,
41767
41972
  event
41768
41973
  })));
41769
41974
  const {
@@ -43210,14 +43415,13 @@ function addEvent({
43210
43415
  */
43211
43416
 
43212
43417
  function automatedPositioning({
43418
+ applyPositioning = true,
43213
43419
  tournamentRecord,
43214
43420
  drawDefinition,
43215
43421
  structureId,
43216
43422
  seedsOnly,
43217
43423
  event
43218
43424
  }) {
43219
- var _result$errors;
43220
-
43221
43425
  if (!event) return {
43222
43426
  error: EVENT_NOT_FOUND
43223
43427
  };
@@ -43225,17 +43429,16 @@ function automatedPositioning({
43225
43429
  error: DRAW_DEFINITION_NOT_FOUND
43226
43430
  };
43227
43431
  const participants = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
43228
- const result = automatedPositioning$1({
43432
+ return automatedPositioning$1({
43433
+ applyPositioning,
43229
43434
  drawDefinition,
43230
43435
  participants,
43231
43436
  structureId,
43232
43437
  seedsOnly
43233
43438
  });
43234
- return result.error ? result : result !== null && result !== void 0 && (_result$errors = result.errors) !== null && _result$errors !== void 0 && _result$errors.length ? {
43235
- error: result.errors
43236
- } : SUCCESS;
43237
43439
  }
43238
43440
  function automatedPlayoffPositioning({
43441
+ applyPositioning = true,
43239
43442
  candidatesCount = 1,
43240
43443
  tournamentRecord,
43241
43444
  drawDefinition,
@@ -43249,13 +43452,21 @@ function automatedPlayoffPositioning({
43249
43452
  if (!drawDefinition) return {
43250
43453
  error: DRAW_DEFINITION_NOT_FOUND
43251
43454
  };
43252
- const participants = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
43455
+ const structureIsComplete = isCompletedStructure({
43456
+ drawDefinition,
43457
+ structureId
43458
+ });
43459
+ if (!structureIsComplete) return {
43460
+ error: INCOMPLETE_SOURCE_STRUCTURE
43461
+ };
43253
43462
  const {
43254
43463
  playoffStructures
43255
43464
  } = getPlayoffStructures({
43256
43465
  drawDefinition,
43257
43466
  structureId
43258
43467
  });
43468
+ const structurePositionAssignments = [];
43469
+ const participants = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
43259
43470
 
43260
43471
  if (playoffStructures) {
43261
43472
  for (const structure of playoffStructures) {
@@ -43264,16 +43475,22 @@ function automatedPlayoffPositioning({
43264
43475
  } = structure;
43265
43476
  const result = automatedPositioning$1({
43266
43477
  structureId: playoffStructureId,
43478
+ applyPositioning,
43267
43479
  candidatesCount,
43268
43480
  drawDefinition,
43269
43481
  participants,
43270
43482
  seedsOnly
43271
43483
  });
43272
43484
  if (result.error) return result;
43485
+ structurePositionAssignments.push({
43486
+ positionAssignments: result.positionAssignments,
43487
+ structureId: playoffStructureId
43488
+ });
43273
43489
  }
43274
43490
  }
43275
43491
 
43276
- return { ...SUCCESS
43492
+ return { ...SUCCESS,
43493
+ structurePositionAssignments
43277
43494
  };
43278
43495
  }
43279
43496
 
@@ -45123,6 +45340,10 @@ function setEntryPositions({
45123
45340
  };
45124
45341
  }
45125
45342
 
45343
+ function setPositionAssignments(params) {
45344
+ return setPositionAssignments$1(params);
45345
+ }
45346
+
45126
45347
  function addDrawDefinitionTimeItem({
45127
45348
  drawDefinition,
45128
45349
  timeItem
@@ -46368,6 +46589,7 @@ const eventGovernor = {
46368
46589
  setDrawParticipantRepresentativeIds,
46369
46590
  getDrawParticipantRepresentativeIds,
46370
46591
  luckyLoserDrawPositionAssignment,
46592
+ setPositionAssignments,
46371
46593
  automatedPositioning,
46372
46594
  automatedPlayoffPositioning,
46373
46595
  checkInParticipant,
@@ -52256,7 +52478,8 @@ function generateEventWithDraw({
52256
52478
  tournamentRecord,
52257
52479
  drawDefinition,
52258
52480
  event
52259
- });
52481
+ }); // ignore when positioning cannot occur because of incomplete source structure
52482
+
52260
52483
  const playoffCompletionGoal = completionGoal ? completionGoal - completedCount : undefined;
52261
52484
  result = completeDrawMatchUps({
52262
52485
  completionGoal: completionGoal ? playoffCompletionGoal : undefined,
@@ -52302,16 +52525,20 @@ function generateVenues({
52302
52525
 
52303
52526
  for (const [index, venueProfile] of venueProfiles.entries()) {
52304
52527
  let {
52528
+ venueAbbreviation,
52305
52529
  venueId = UUID(),
52306
- venueName,
52307
- courtsCount,
52308
52530
  dateAvailability,
52309
52531
  startTime = '07:00',
52310
- endTime = '19:00'
52532
+ endTime = '19:00',
52533
+ courtsCount,
52534
+ courtNames,
52535
+ venueName,
52536
+ courtIds
52311
52537
  } = venueProfile;
52312
52538
  const newVenue = {
52313
- venueId,
52314
- venueName: venueName || `Venue ${index + 1}`
52539
+ venueName: venueName || `Venue ${index + 1}`,
52540
+ venueAbbreviation,
52541
+ venueId
52315
52542
  };
52316
52543
  let result = addVenue$1({
52317
52544
  tournamentRecord,
@@ -52327,9 +52554,11 @@ function generateVenues({
52327
52554
  })) || dateAvailability;
52328
52555
  result = addCourts$1({
52329
52556
  tournamentRecord,
52330
- venueId,
52557
+ dateAvailability,
52331
52558
  courtsCount,
52332
- dateAvailability
52559
+ courtNames,
52560
+ courtIds,
52561
+ venueId
52333
52562
  });
52334
52563
  if (result.error) return result;
52335
52564
  }
@@ -52643,30 +52872,30 @@ function generateSchedulingProfile({
52643
52872
  let structureId = targetMatchUp.structureId;
52644
52873
 
52645
52874
  if (roundNumber && !winnerFinishingPositionRange) {
52646
- structureId = Object.keys(containedStructures).find(containingStructureId => containedStructures[containingStructureId].includes(structureId));
52875
+ structureId = Object.keys(containedStructures).find(containingStructureId => containedStructures[containingStructureId].includes(structureId)) || structureId;
52647
52876
  }
52648
52877
 
52649
52878
  const roundToSchedule = {
52650
52879
  tournamentId,
52651
- eventId,
52652
- drawId,
52653
52880
  structureId,
52654
52881
  roundNumber,
52655
- roundSegment
52882
+ roundSegment,
52883
+ eventId,
52884
+ drawId
52656
52885
  };
52657
52886
  let result = addSchedulingProfileRound({
52658
52887
  tournamentRecords: {
52659
52888
  [tournamentId]: tournamentRecord
52660
52889
  },
52890
+ round: roundToSchedule,
52661
52891
  scheduleDate,
52662
- venueId,
52663
- round: roundToSchedule
52892
+ venueId
52664
52893
  });
52665
52894
  if (result.error) return result;
52666
52895
  scheduledRounds.push({
52667
- drawName,
52668
52896
  structureName,
52669
52897
  roundName,
52898
+ drawName,
52670
52899
  ...roundToSchedule
52671
52900
  });
52672
52901
  }
@@ -52704,6 +52933,8 @@ function generateSchedulingProfile({
52704
52933
  */
52705
52934
 
52706
52935
  function generateTournamentRecord({
52936
+ scheduleCompletedMatchUps,
52937
+ // explicit override for scheduler
52707
52938
  ratingsParameters: ratingsParameters$1 = ratingsParameters,
52708
52939
  tournamentName = 'Mock Tournament',
52709
52940
  tournamentExtensions,
@@ -52856,7 +53087,8 @@ function generateTournamentRecord({
52856
53087
 
52857
53088
  const venueIds = venueProfiles !== null && venueProfiles !== void 0 && venueProfiles.length ? generateVenues({
52858
53089
  tournamentRecord,
52859
- venueProfiles
53090
+ venueProfiles,
53091
+ uuids
52860
53092
  }) : [];
52861
53093
  let scheduledRounds;
52862
53094
  let schedulerResult = {};
@@ -52877,6 +53109,7 @@ function generateTournamentRecord({
52877
53109
  [tournamentId]: tournamentRecord
52878
53110
  };
52879
53111
  schedulerResult = scheduleProfileRounds({
53112
+ scheduleCompletedMatchUps,
52880
53113
  tournamentRecords
52881
53114
  });
52882
53115
  }