tods-competition-factory 2.3.0 → 2.3.1

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.3.0';
6
+ return '2.3.1';
7
7
  }
8
8
 
9
9
  const SINGLES_MATCHUP = 'SINGLES';
@@ -2289,7 +2289,8 @@ function validTimeValue(value) {
2289
2289
  const spaceSplit = typeof value === 'string' ? value?.split(' ') : [];
2290
2290
  if (value && spaceSplit?.length > 1 && !['AM', 'PM'].includes(spaceSplit[1].toUpperCase()))
2291
2291
  return false;
2292
- return !!(!value || timeValidation.test(convertTime(value, true, true)));
2292
+ const converted = convertTime(value, true, true);
2293
+ return !!(!value || (converted && timeValidation.test(converted)));
2293
2294
  }
2294
2295
  function isValidDateString(scheduleDate) {
2295
2296
  return isISODateString(scheduleDate) || validDateString.test(scheduleDate);
@@ -2300,7 +2301,7 @@ function DateHHMM(date) {
2300
2301
  return HHMMSS(secs, { displaySeconds: false });
2301
2302
  }
2302
2303
  function HHMMSS(s, format) {
2303
- const secondNumber = parseInt(s, 10);
2304
+ const secondNumber = Number.parseInt(s, 10);
2304
2305
  const hours = Math.floor(secondNumber / 3600);
2305
2306
  const minutes = Math.floor((secondNumber - hours * 3600) / 60);
2306
2307
  const seconds = secondNumber - hours * 3600 - minutes * 60;
@@ -2321,7 +2322,7 @@ function timeUTC(date) {
2321
2322
  function formatDate(date, separator = '-', format = 'YMD') {
2322
2323
  if (!date)
2323
2324
  return '';
2324
- if (typeof date === 'string' && date.indexOf('T') < 0)
2325
+ if (typeof date === 'string' && !date.includes('T'))
2325
2326
  date = date + 'T00:00';
2326
2327
  const d = new Date(date);
2327
2328
  let month = '' + (d.getMonth() + 1);
@@ -2354,8 +2355,11 @@ function offsetTime(date) {
2354
2355
  function isDate(dateArg) {
2355
2356
  if (typeof dateArg == 'boolean')
2356
2357
  return false;
2357
- const t = (dateArg instanceof Date && dateArg) || (!isNaN(dateArg) && new Date(dateArg)) || false;
2358
- return t && !isNaN(t.valueOf());
2358
+ const t = (dateArg instanceof Date && dateArg) || (!Number.isNaN(Number(dateArg)) && new Date(dateArg)) || false;
2359
+ return t && !Number.isNaN(Number(t.valueOf()));
2360
+ }
2361
+ function isValidDateRange(minDate, maxDate) {
2362
+ return minDate <= maxDate;
2359
2363
  }
2360
2364
  function generateDateRange(startDt, endDt) {
2361
2365
  if (!isValidDateString(startDt) || !isValidDateString(endDt))
@@ -2377,9 +2381,6 @@ function generateDateRange(startDt, endDt) {
2377
2381
  }
2378
2382
  }
2379
2383
  return between.map((date) => formatDate(date));
2380
- function isValidDateRange(minDate, maxDate) {
2381
- return minDate <= maxDate;
2382
- }
2383
2384
  }
2384
2385
  const re = /^([+-]?\d{4}(?!\d{2}\b))((-?)((0[1-9]|1[0-2])(\3([12]\d|0[1-9]|3[01]))?|W([0-4]\d|5[0-2])(-?[1-7])?|(00[1-9]|0[1-9]\d|[12]\d{2}|3([0-5]\d|6[1-6])))([T\s]((([01]\d|2[0-3])((:?)[0-5]\d)?|24:?00)([.,]\d+(?!:))?)?(\17[0-5]\d([.,]\d+)?)?([zZ]|([+-])([01]\d|2[0-3]):?([0-5]\d)?)?)?)?$/;
2385
2386
  function isISODateString(dateString) {
@@ -2392,15 +2393,15 @@ function isTimeString(timeString) {
2392
2393
  return false;
2393
2394
  const noZ = timeString.split('Z')[0];
2394
2395
  const parts = noZ.split(':');
2395
- const isNumeric = parts.every((part) => !isNaN(parseInt(part)));
2396
- const invalid = parts.length < 2 || !isNumeric || parseInt(parts[0]) > 23 || parseInt(parts[1]) > 60;
2396
+ const isNumeric = parts.every((part) => !Number.isNaN(Number.parseInt(part)));
2397
+ const invalid = parts.length < 2 || !isNumeric || Number.parseInt(parts[0]) > 23 || Number.parseInt(parts[1]) > 60;
2397
2398
  return !invalid;
2398
2399
  }
2399
2400
  function timeStringMinutes$1(timeString) {
2400
2401
  const validTimeString = extractTime$1(timeString);
2401
2402
  if (!validTimeString)
2402
2403
  return 0;
2403
- const [hours, minutes] = validTimeString.split(':').map((value) => parseInt(value));
2404
+ const [hours, minutes] = validTimeString.split(':').map((value) => Number.parseInt(value));
2404
2405
  return hours * 60 + minutes;
2405
2406
  }
2406
2407
  function dayMinutesToTimeString(totalMinutes) {
@@ -2419,7 +2420,7 @@ function extractTime$1(dateString) {
2419
2420
  : tidyTime(dateString);
2420
2421
  }
2421
2422
  function extractDate(dateString) {
2422
- return isISODateString(dateString) || dateValidation.test(dateString) ? dateString.split('T')[0] : undefined;
2423
+ return isISODateString(dateString) || dateValidation.test(dateString) ? dateString.split('T')[0] : '';
2423
2424
  }
2424
2425
  function dateStringDaysChange(dateString, daysChange) {
2425
2426
  const date = new Date(dateString);
@@ -2427,20 +2428,22 @@ function dateStringDaysChange(dateString, daysChange) {
2427
2428
  return extractDate(date.toISOString());
2428
2429
  }
2429
2430
  function splitTime(value) {
2430
- value = typeof value !== 'string' ? '00:00' : value;
2431
+ value = typeof value === 'string' ? value : '00:00';
2431
2432
  const o = {}, time = {};
2432
2433
  ({ 0: o.time, 1: o.ampm } = value.split(' ') || []);
2433
2434
  ({ 0: time.hours, 1: time.minutes } = o.time.split(':') || []);
2434
2435
  time.ampm = o.ampm;
2435
- if (isNaN(time.hours) || isNaN(time.minutes) || (time.ampm && !['AM', 'PM'].includes(time.ampm.toUpperCase())))
2436
+ if (Number.isNaN(Number.parseInt(time.hours)) ||
2437
+ Number.isNaN(Number.parseInt(time.minutes)) ||
2438
+ (time.ampm && !['AM', 'PM'].includes(time.ampm.toUpperCase())))
2436
2439
  return {};
2437
2440
  return time;
2438
2441
  }
2439
2442
  function militaryTime(value) {
2440
2443
  const time = splitTime(value);
2441
2444
  if (time.ampm && time.hours) {
2442
- if (time.ampm.toLowerCase() === 'pm' && parseInt(time.hours) < 12)
2443
- time.hours = ((time.hours && parseInt(time.hours)) || 0) + 12;
2445
+ if (time.ampm.toLowerCase() === 'pm' && Number.parseInt(time.hours) < 12)
2446
+ time.hours = ((time.hours && Number.parseInt(time.hours)) || 0) + 12;
2444
2447
  if (time.ampm.toLowerCase() === 'am' && time.hours === '12')
2445
2448
  time.hours = '00';
2446
2449
  }
@@ -2476,21 +2479,21 @@ function convertTime(value, time24, keepDate) {
2476
2479
  const hasDate = extractDate(value);
2477
2480
  const timeString = extractTime$1(value);
2478
2481
  const timeValue = hasDate ? timeString : value;
2479
- return !value
2480
- ? undefined
2481
- : (time24 && ((hasDate && keepDate && value) || militaryTime(timeValue))) || regularTime(timeValue);
2482
+ return value
2483
+ ? (time24 && ((hasDate && keepDate && value) || militaryTime(timeValue))) || regularTime(timeValue)
2484
+ : undefined;
2482
2485
  }
2483
2486
  function timeSort(a, b) {
2484
2487
  const as = splitTime(a);
2485
2488
  const bs = splitTime(b);
2486
- if (parseInt(as.hours) < parseInt(bs.hours))
2489
+ if (Number.parseInt(as.hours) < Number.parseInt(bs.hours))
2487
2490
  return -1;
2488
- if (parseInt(as.hours) > parseInt(bs.hours))
2491
+ if (Number.parseInt(as.hours) > Number.parseInt(bs.hours))
2489
2492
  return 1;
2490
2493
  if (as.hours === bs.hours) {
2491
- if (parseInt(as.minutes) < parseInt(bs.minutes))
2494
+ if (Number.parseInt(as.minutes) < Number.parseInt(bs.minutes))
2492
2495
  return -1;
2493
- if (parseInt(as.minutes) > parseInt(bs.minutes))
2496
+ if (Number.parseInt(as.minutes) > Number.parseInt(bs.minutes))
2494
2497
  return 1;
2495
2498
  }
2496
2499
  return 0;
@@ -2529,8 +2532,8 @@ function addMinutesToTimeString(timeString, minutes) {
2529
2532
  const validTimeString = extractTime$1(timeString);
2530
2533
  if (!validTimeString)
2531
2534
  return '00:00';
2532
- const minutesToAdd = isNaN(minutes) ? 0 : minutes;
2533
- return extractTime$1(addMinutes(timeToDate(validTimeString), minutesToAdd).toISOString());
2535
+ const minutesToAdd = Number.isNaN(minutes) ? 0 : minutes;
2536
+ return extractTime$1(addMinutes(timeToDate(validTimeString), minutesToAdd).toISOString()) || '00:00';
2534
2537
  }
2535
2538
  function addMinutes(startDate, minutes) {
2536
2539
  const date = new Date(startDate);
@@ -2586,23 +2589,27 @@ function getCategoryAgeDetails(params) {
2586
2589
  if (!isValidCategory)
2587
2590
  return { error: INVALID_CATEGORY };
2588
2591
  const consideredDate = params.consideredDate ?? extractDate(new Date().toLocaleDateString('sv'));
2589
- if (!isValidDateString(consideredDate))
2592
+ if (!consideredDate || !isValidDateString(consideredDate))
2590
2593
  return { error: INVALID_DATE };
2591
2594
  const [consideredYear] = consideredDate
2592
2595
  .split('-')
2593
2596
  .slice(0, 3)
2594
- .map((n) => parseInt(n));
2597
+ .map((n) => Number.parseInt(n));
2595
2598
  const previousDayDate = dateStringDaysChange(consideredDate, -1);
2599
+ if (!previousDayDate)
2600
+ return { error: INVALID_DATE };
2596
2601
  const [previousDayMonth, previousDay] = previousDayDate
2597
2602
  .split('-')
2598
2603
  .slice(1, 3)
2599
- .map((n) => parseInt(n));
2604
+ .map((n) => Number.parseInt(n));
2600
2605
  const previousMonthDay = `${zeroPad(previousDayMonth)}-${zeroPad(previousDay)}`;
2601
2606
  const nextDayDate = dateStringDaysChange(consideredDate, 1);
2607
+ if (!nextDayDate)
2608
+ return { error: INVALID_DATE };
2602
2609
  const [nextDayMonth, nextDay] = nextDayDate
2603
2610
  .split('-')
2604
2611
  .slice(1, 3)
2605
- .map((n) => parseInt(n));
2612
+ .map((n) => Number.parseInt(n));
2606
2613
  const nextMonthDay = `${zeroPad(nextDayMonth)}-${zeroPad(nextDay)}`;
2607
2614
  let calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
2608
2615
  let calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
@@ -2679,7 +2686,7 @@ function getCategoryAgeDetails(params) {
2679
2686
  };
2680
2687
  const processCode = (code) => {
2681
2688
  const [pre, age, post] = (code.match(prePost) || []).slice(1);
2682
- const ageInt = parseInt(age);
2689
+ const ageInt = Number.parseInt(age);
2683
2690
  if (pre === 'U') {
2684
2691
  if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
2685
2692
  addError(`Invalid submitted ageMaxDate: ${category.ageMaxDate}`);
@@ -2698,8 +2705,8 @@ function getCategoryAgeDetails(params) {
2698
2705
  else if (post === 'O') {
2699
2706
  oPost(ageInt);
2700
2707
  }
2701
- ageMaxDate = ageMaxDate ?? calculatedAgeMaxDate;
2702
- ageMinDate = ageMinDate ?? calculatedAgeMinDate;
2708
+ ageMaxDate = (ageMaxDate ?? calculatedAgeMaxDate) || undefined;
2709
+ ageMinDate = (ageMinDate ?? calculatedAgeMinDate) || undefined;
2703
2710
  };
2704
2711
  if (isCombined) {
2705
2712
  ageMaxDate = undefined;
@@ -2714,7 +2721,7 @@ function getCategoryAgeDetails(params) {
2714
2721
  const ageMinYear = consideredYear - category.ageMax - 1;
2715
2722
  ageMinDate = constructedDate(ageMinYear, nextMonthDay);
2716
2723
  }
2717
- const [lowAge, highAge] = (ageCategoryCode?.match(extractCombined) ?? []).slice(1).map((n) => parseInt(n));
2724
+ const [lowAge, highAge] = (ageCategoryCode?.match(extractCombined) ?? []).slice(1).map((n) => Number.parseInt(n));
2718
2725
  if (lowAge <= highAge) {
2719
2726
  ageMin = lowAge;
2720
2727
  ageMax = highAge;
@@ -8675,7 +8682,7 @@ function getRoundMatchUps({ matchUps = [], interpolate }) {
8675
8682
  if (interpolate) {
8676
8683
  const maxRoundNumber = Math.max(...Object.keys(roundMatchUps)
8677
8684
  .map((key) => ensureInt(key))
8678
- .filter((f) => !isNaN(f)));
8685
+ .filter((f) => !Number.isNaN(f)));
8679
8686
  const maxRoundMatchUpsCount = roundMatchUps[maxRoundNumber]?.length;
8680
8687
  if (maxRoundMatchUpsCount > 1 && isPowerOf2(maxRoundMatchUpsCount)) {
8681
8688
  const nextRound = maxRoundNumber + 1;
@@ -8698,10 +8705,10 @@ function getRoundMatchUps({ matchUps = [], interpolate }) {
8698
8705
  let feedRoundIndex = 0;
8699
8706
  const roundNumbers = Object.keys(roundMatchUps)
8700
8707
  .map((key) => ensureInt(key))
8701
- .filter((f) => !isNaN(f));
8708
+ .filter((f) => !Number.isNaN(f));
8702
8709
  roundNumbers.forEach((roundNumber) => {
8703
8710
  const currentRoundMatchUps = roundMatchUps[roundNumber].sort((a, b) => a.roundPosition - b.roundPosition);
8704
- const currentRoundDrawPositions = currentRoundMatchUps.map((matchUp) => matchUp?.drawPositions || []).flat();
8711
+ const currentRoundDrawPositions = currentRoundMatchUps.flatMap((matchUp) => matchUp?.drawPositions || []);
8705
8712
  roundProfile[roundNumber].roundNumber = roundNumber;
8706
8713
  roundProfile[roundNumber].roundFactor = roundProfile[roundNumber].matchUpsCount
8707
8714
  ? maxMatchUpsCount / roundProfile[roundNumber].matchUpsCount
@@ -8762,7 +8769,7 @@ function getRoundMatchUps({ matchUps = [], interpolate }) {
8762
8769
  roundIndex += 1;
8763
8770
  }
8764
8771
  });
8765
- const roundsNotPowerOf2 = !!Object.values(roundProfile).find(({ matchUpsCount }) => !isPowerOf2(matchUpsCount));
8772
+ const roundsNotPowerOf2 = !!Object.values(roundProfile).some(({ matchUpsCount }) => !isPowerOf2(matchUpsCount));
8766
8773
  const hasNoRoundPositions = matchUps.some((matchUp) => !matchUp.roundPosition);
8767
8774
  return {
8768
8775
  hasNoRoundPositions,
@@ -9115,7 +9122,7 @@ function getRoundContextProfile({ roundNamingPolicy, drawDefinition, structure,
9115
9122
  const add = (a, b) => (a || 0) + (b || 0);
9116
9123
  function getBand(spread, bandProfiles) {
9117
9124
  const spreadValue = Array.isArray(spread) ? spread[0] : spread;
9118
- return ((isNaN(spreadValue) && WALKOVER$1) ||
9125
+ return ((Number.isNaN(spreadValue) && WALKOVER$1) ||
9119
9126
  (spreadValue <= bandProfiles[DECISIVE] && DECISIVE) ||
9120
9127
  (spreadValue <= bandProfiles[ROUTINE] && ROUTINE) ||
9121
9128
  COMPETITIVE);
@@ -9285,7 +9292,7 @@ function getCheckedInParticipantIds({ matchUp }) {
9285
9292
  return { error: MISSING_MATCHUP };
9286
9293
  if (!matchUp.hasContext)
9287
9294
  return { error: MISSING_CONTEXT };
9288
- if (!matchUp.sides || matchUp.sides.filter(Boolean).length !== 2) {
9295
+ if (!matchUp.sides || matchUp?.sides.filter(Boolean).length !== 2) {
9289
9296
  return { error: INVALID_MATCHUP };
9290
9297
  }
9291
9298
  const { nestedIndividualParticipantIds, allRelevantParticipantIds, sideParticipantIds } = getMatchUpParticipantIds({
@@ -15782,6 +15789,84 @@ function addVoluntaryConsolationStructure({ structureName = constantToString(VOL
15782
15789
  return { ...SUCCESS };
15783
15790
  }
15784
15791
 
15792
+ function getDivisions({ size }) {
15793
+ const divisions = [size];
15794
+ let division = size;
15795
+ while (division / 2 === Math.floor(division / 2)) {
15796
+ division = division / 2;
15797
+ divisions.push(division);
15798
+ }
15799
+ if (!divisions.includes(1))
15800
+ divisions.push(1);
15801
+ divisions.sort(numericSort);
15802
+ divisions.reverse();
15803
+ return divisions;
15804
+ }
15805
+ function getSubBlock({ blockPattern, index }) {
15806
+ let i = 0;
15807
+ for (const subBlock of blockPattern) {
15808
+ if (i === index)
15809
+ return subBlock;
15810
+ let j = 0;
15811
+ while (j < subBlock.length) {
15812
+ if (i === index)
15813
+ return subBlock;
15814
+ i += 1;
15815
+ j++;
15816
+ }
15817
+ }
15818
+ }
15819
+ function generateBlockPattern({ positioning, size }) {
15820
+ const divisions = getDivisions({ size });
15821
+ const divisionGroupings = [];
15822
+ const selected = [];
15823
+ const firstMember = (arr) => arr[0];
15824
+ const lastMember = (arr) => arr[arr.length - 1];
15825
+ const getMember = (arr, i) => (positioning && [CLUSTER, ADJACENT, WATERFALL].includes(positioning) && i % 2
15826
+ ? lastMember(arr)
15827
+ : firstMember(arr)) || firstMember(arr);
15828
+ const noneSelected = (chunk, i) => {
15829
+ if (chunk.every((member) => !selected.includes(member))) {
15830
+ const member = getMember(chunk, i);
15831
+ selected.push(member);
15832
+ return member;
15833
+ }
15834
+ };
15835
+ const notSelected = (chunk) => {
15836
+ const notSelected = chunk.filter((member) => !selected.includes(member));
15837
+ if (notSelected.length) {
15838
+ selected.push(...notSelected);
15839
+ return notSelected;
15840
+ }
15841
+ };
15842
+ const select = (chunk, i) => {
15843
+ const member = getMember(chunk, i);
15844
+ if (!selected.includes(member)) {
15845
+ selected.push(member);
15846
+ return member;
15847
+ }
15848
+ };
15849
+ const range = generateRange(1, size + 1);
15850
+ for (const division of divisions) {
15851
+ if (division === 1) {
15852
+ const chunks = chunkArray(range, 2);
15853
+ const positions = chunks.map(noneSelected).filter(Boolean);
15854
+ if (positions.length)
15855
+ divisionGroupings.push(positions);
15856
+ const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
15857
+ if (lastPositions.length)
15858
+ divisionGroupings.push(lastPositions);
15859
+ }
15860
+ else {
15861
+ const chunks = chunkArray(range, division);
15862
+ const positions = chunks.map(select).filter(Boolean);
15863
+ if (positions.length)
15864
+ divisionGroupings.push(positions);
15865
+ }
15866
+ }
15867
+ return { divisions, divisionGroupings };
15868
+ }
15869
+
15785
15870
  function getRoundRobinGroupMatchUps({ drawPositions }) {
15786
15871
  if (!drawPositions?.length)
15787
15872
  return { error: MISSING_DRAW_POSITIONS };
@@ -16132,84 +16217,6 @@ function getNumericSeedValue(seedValue) {
16132
16217
  return Infinity;
16133
16218
  }
16134
16219
 
16135
- function getDivisions({ size }) {
16136
- const divisions = [size];
16137
- let division = size;
16138
- while (division / 2 === Math.floor(division / 2)) {
16139
- division = division / 2;
16140
- divisions.push(division);
16141
- }
16142
- if (!divisions.includes(1))
16143
- divisions.push(1);
16144
- divisions.sort(numericSort);
16145
- divisions.reverse();
16146
- return divisions;
16147
- }
16148
- function getSubBlock({ blockPattern, index }) {
16149
- let i = 0;
16150
- for (const subBlock of blockPattern) {
16151
- if (i === index)
16152
- return subBlock;
16153
- let j = 0;
16154
- while (j < subBlock.length) {
16155
- if (i === index)
16156
- return subBlock;
16157
- i += 1;
16158
- j++;
16159
- }
16160
- }
16161
- }
16162
- function generateBlockPattern({ positioning, size }) {
16163
- const divisions = getDivisions({ size });
16164
- const divisionGroupings = [];
16165
- const selected = [];
16166
- const firstMember = (arr) => arr[0];
16167
- const lastMember = (arr) => arr[arr.length - 1];
16168
- const getMember = (arr, i) => (positioning && [CLUSTER, ADJACENT, WATERFALL].includes(positioning) && i % 2
16169
- ? lastMember(arr)
16170
- : firstMember(arr)) || firstMember(arr);
16171
- const noneSelected = (chunk, i) => {
16172
- if (chunk.every((member) => !selected.includes(member))) {
16173
- const member = getMember(chunk, i);
16174
- selected.push(member);
16175
- return member;
16176
- }
16177
- };
16178
- const notSelected = (chunk) => {
16179
- const notSelected = chunk.filter((member) => !selected.includes(member));
16180
- if (notSelected.length) {
16181
- selected.push(...notSelected);
16182
- return notSelected;
16183
- }
16184
- };
16185
- const select = (chunk, i) => {
16186
- const member = getMember(chunk, i);
16187
- if (!selected.includes(member)) {
16188
- selected.push(member);
16189
- return member;
16190
- }
16191
- };
16192
- const range = generateRange(1, size + 1);
16193
- for (const division of divisions) {
16194
- if (division === 1) {
16195
- const chunks = chunkArray(range, 2);
16196
- const positions = chunks.map(noneSelected).filter(Boolean);
16197
- if (positions.length)
16198
- divisionGroupings.push(positions);
16199
- const lastPositions = chunks.flatMap(notSelected).filter(Boolean);
16200
- if (lastPositions.length)
16201
- divisionGroupings.push(lastPositions);
16202
- }
16203
- else {
16204
- const chunks = chunkArray(range, division);
16205
- const positions = chunks.map(select).filter(Boolean);
16206
- if (positions.length)
16207
- divisionGroupings.push(positions);
16208
- }
16209
- }
16210
- return { divisions, divisionGroupings };
16211
- }
16212
-
16213
16220
  function getValidSeedBlocks({ provisionalPositioning, returnAllProxies, appliedPolicies, seedingProfile, drawDefinition, allPositions, structure, }) {
16214
16221
  let validSeedBlocks = [];
16215
16222
  if (!structure)
@@ -16399,7 +16406,7 @@ function constructPower2Blocks(params) {
16399
16406
  let count = 1;
16400
16407
  const blocks = [];
16401
16408
  const { seedBlocks } = getSeedBlocks({
16402
- cluster: getSeedPattern(seedingProfile) === CLUSTER,
16409
+ cluster: [CLUSTER, ADJACENT].includes(getSeedPattern(seedingProfile)),
16403
16410
  participantsCount: baseDrawSize,
16404
16411
  roundRobinGroupsCount,
16405
16412
  });
@@ -18855,7 +18862,7 @@ function getUnseededByePositions({ provisionalPositioning, seedOrderByePositions
18855
18862
  if (isFeedIn) {
18856
18863
  const baseDrawSize = relevantDrawPositions.length;
18857
18864
  const { seedBlocks } = getSeedBlocks({
18858
- cluster: getSeedPattern(seedingProfile) === CLUSTER,
18865
+ cluster: [CLUSTER, ADJACENT].includes(getSeedPattern(seedingProfile)),
18859
18866
  participantsCount: baseDrawSize,
18860
18867
  });
18861
18868
  const blockDrawPositions = seedBlocks.map((seedBlock) => seedBlock.map((drawPosition) => drawPosition + drawPositionOffset));
@@ -21671,8 +21678,7 @@ function processPlayoffGroups({ requireSequential = true, playoffMatchUpFormat,
21671
21678
  finishingPositions,
21672
21679
  sourceStructureId,
21673
21680
  });
21674
- links.push(playoffLink);
21675
- links.push(...playoffLinks);
21681
+ links.push(playoffLink, ...playoffLinks);
21676
21682
  structures.push(...playoffStructures);
21677
21683
  finishingPositionTargets.push({
21678
21684
  structureId: playoffStructure.structureId,
@@ -21799,8 +21805,7 @@ function processPlayoffGroups({ requireSequential = true, playoffMatchUpFormat,
21799
21805
  finishingPositions,
21800
21806
  sourceStructureId,
21801
21807
  });
21802
- links.push(playoffLink);
21803
- links.push(...feedInLinks);
21808
+ links.push(playoffLink, ...feedInLinks);
21804
21809
  structures.push(...champitionShipStructures);
21805
21810
  finishingPositionTargets.push({
21806
21811
  structureId: playoffStructure.structureId,
@@ -22015,7 +22020,7 @@ function getRatingConvertedFromELO({ targetRatingType, sourceRating }) {
22015
22020
  sourceRange: eloRatingRange,
22016
22021
  value: sourceRating,
22017
22022
  });
22018
- const convertedRating = parseFloat(result.toFixed(decimalPlaces));
22023
+ const convertedRating = Number.parseFloat(result.toFixed(decimalPlaces));
22019
22024
  return invertedScale ? maxTargetRatingRange - convertedRating : convertedRating;
22020
22025
  }
22021
22026
 
@@ -22066,8 +22071,8 @@ function calculatePressureRatings({ participantResults, sides, score }) {
22066
22071
  }
22067
22072
  }
22068
22073
  function getSideValues$1({ side1ConvertedRating, side2ConvertedRating, score }) {
22069
- const highRating = side1ConvertedRating > side2ConvertedRating ? side1ConvertedRating : side2ConvertedRating;
22070
- const lowRating = side1ConvertedRating > side2ConvertedRating ? side2ConvertedRating : side1ConvertedRating;
22074
+ const highRating = Math.max(side1ConvertedRating, side2ConvertedRating);
22075
+ const lowRating = Math.min(side1ConvertedRating, side2ConvertedRating);
22071
22076
  const ratingsDifference = Math.abs(side1ConvertedRating - side2ConvertedRating);
22072
22077
  const eloRatingRange = ratingsParameters[ELO].range;
22073
22078
  const rangeMax = Math.max(...eloRatingRange);
@@ -22232,19 +22237,19 @@ function calculatePercentages({ participantResults, groupingTotal, matchUpFormat
22232
22237
  ? totalSets
22233
22238
  : perPlayer * (bracketSetsToWin) || setsWon + setsLost;
22234
22239
  let setsPct = Math.round((setsWon / setsTotal) * precision) / precision;
22235
- if (setsPct === Infinity || isNaN(setsPct))
22240
+ if (setsPct === Infinity || Number.isNaN(setsPct))
22236
22241
  setsPct = setsTotal;
22237
22242
  const tieMatchUpsWon = participantResults[participantId].tieMatchUpsWon;
22238
22243
  const tieMatchUpsLost = participantResults[participantId].tieMatchUpsLost;
22239
22244
  const tieMatchUpsTotal = tieMatchUpsWon + tieMatchUpsLost;
22240
22245
  let tieMatchUpsPct = Math.round((tieMatchUpsWon / tieMatchUpsTotal) * precision) / precision;
22241
- if (tieMatchUpsPct === Infinity || isNaN(tieMatchUpsPct))
22246
+ if (tieMatchUpsPct === Infinity || Number.isNaN(tieMatchUpsPct))
22242
22247
  tieMatchUpsPct = tieMatchUpsWon;
22243
22248
  const matchUpsWon = participantResults[participantId].matchUpsWon;
22244
22249
  const matchUpsLost = participantResults[participantId].matchUpsLost;
22245
22250
  const matchUpsTotal = matchUpsWon + matchUpsLost;
22246
22251
  let matchUpsPct = Math.round((matchUpsWon / matchUpsTotal) * precision) / precision;
22247
- if (matchUpsPct === Infinity || isNaN(matchUpsPct))
22252
+ if (matchUpsPct === Infinity || Number.isNaN(matchUpsPct))
22248
22253
  matchUpsPct = matchUpsWon;
22249
22254
  const gamesWon = participantResults[participantId].gamesWon || 0;
22250
22255
  const gamesLost = participantResults[participantId].gamesLost || 0;
@@ -22253,11 +22258,11 @@ function calculatePercentages({ participantResults, groupingTotal, matchUpFormat
22253
22258
  ? totalGames
22254
22259
  : Math.max(minimumExpectedGames, gamesWon + gamesLost);
22255
22260
  let gamesPct = Math.round((gamesWon / gamesTotal) * precision) / precision;
22256
- if (gamesPct === Infinity || isNaN(gamesPct))
22261
+ if (gamesPct === Infinity || Number.isNaN(gamesPct))
22257
22262
  gamesPct = 0;
22258
22263
  const pointsTotal = participantResults[participantId].pointsWon + participantResults[participantId].pointsLost;
22259
22264
  let pointsPct = Math.round((participantResults[participantId].pointsWon / pointsTotal) * precision) / precision;
22260
- if (pointsPct === Infinity || isNaN(pointsPct))
22265
+ if (pointsPct === Infinity || Number.isNaN(pointsPct))
22261
22266
  pointsPct = 0;
22262
22267
  participantResults[participantId].setsWon = setsWon;
22263
22268
  participantResults[participantId].setsLost = setsLost;
@@ -23476,16 +23481,16 @@ function evaluateCollectionResult({ collectionDefinition, groupValueNumbers, gro
23476
23481
  else {
23477
23482
  sideCollectionValues = sideMatchUpValues;
23478
23483
  }
23479
- if (!belongsToValueGroup) {
23480
- sideCollectionValues.forEach((sideCollectionValue, i) => (sideTieValues[i] += sideCollectionValue || 0));
23481
- }
23482
- else {
23484
+ if (belongsToValueGroup) {
23483
23485
  groupValueGroups[collectionGroupNumber].sideWins[0] += sideWins[0] || 0;
23484
23486
  groupValueGroups[collectionGroupNumber].sideWins[1] += sideWins[1] || 0;
23485
23487
  groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted =
23486
23488
  groupValueGroups[collectionGroupNumber].allGroupMatchUpsCompleted && allCollectionMatchUpsCompleted;
23487
23489
  groupValueGroups[collectionGroupNumber].matchUpsCount += collectionMatchUps.length;
23488
23490
  }
23491
+ else {
23492
+ sideCollectionValues.forEach((sideCollectionValue, i) => (sideTieValues[i] += sideCollectionValue || 0));
23493
+ }
23489
23494
  }
23490
23495
  function getCollectionPositionValue({ collectionDefinition, collectionPosition }) {
23491
23496
  const collectionValueProfiles = collectionDefinition.collectionValueProfiles || [];
@@ -23497,7 +23502,7 @@ function generateTieMatchUpScore(params) {
23497
23502
  const { sideAdjustments = [0, 0], separator = '-', drawDefinition, matchUpsMap, structure, matchUp, event, } = params;
23498
23503
  if (!Array.isArray(sideAdjustments) ||
23499
23504
  sideAdjustments.length !== 2 ||
23500
- isNaN(sideAdjustments.reduce((a, b) => a + b))) {
23505
+ Number.isNaN(sideAdjustments.reduce((a, b) => a + b))) {
23501
23506
  return { error: INVALID_VALUES };
23502
23507
  }
23503
23508
  if (!matchUp)
@@ -24902,7 +24907,7 @@ function analyzeDraws({ tournamentRecord }) {
24902
24907
  };
24903
24908
  const eventsMap = {};
24904
24909
  const eventDraws = tournamentRecord.events
24905
- ?.map((event) => {
24910
+ ?.flatMap((event) => {
24906
24911
  const eventId = event.eventId;
24907
24912
  eventsMap[eventId] = event;
24908
24913
  return (event?.drawDefinitions || []).map((drawDefinition) => ({
@@ -24910,7 +24915,6 @@ function analyzeDraws({ tournamentRecord }) {
24910
24915
  eventId,
24911
24916
  }));
24912
24917
  })
24913
- .flat()
24914
24918
  .filter(Boolean);
24915
24919
  eventDraws.forEach(({ drawDefinition, eventId }) => {
24916
24920
  let positionsAssignedCount = 0;
@@ -24944,11 +24948,11 @@ function analyzeDraws({ tournamentRecord }) {
24944
24948
  const activeRounds = roundProfile &&
24945
24949
  Object.keys(roundProfile)
24946
24950
  .filter((roundNumber) => !roundProfile[roundNumber].inactiveRound)
24947
- .map((roundNumber) => parseInt(roundNumber));
24951
+ .map((roundNumber) => Number.parseInt(roundNumber));
24948
24952
  const inactiveRounds = roundProfile &&
24949
24953
  Object.keys(roundProfile)
24950
24954
  .filter((roundNumber) => roundProfile[roundNumber].inactiveRound)
24951
- .map((roundNumber) => parseInt(roundNumber));
24955
+ .map((roundNumber) => Number.parseInt(roundNumber));
24952
24956
  const inactiveStructure = roundProfile && Object.values(roundProfile).every((profile) => profile.inactiveRound);
24953
24957
  return {
24954
24958
  positionsAssignedCount: positionsAssigned?.length ?? 0,
@@ -28379,7 +28383,7 @@ const k538 = (countables = 0) => 250 / Math.pow(countables + 5, 0.4);
28379
28383
  const kDefault = () => 1;
28380
28384
  function kSet(maxCountables = 3, counted = 2) {
28381
28385
  const kset = maxCountables / counted;
28382
- return isNaN(kset) ? eloConfig.kDefault() : kset;
28386
+ return Number.isNaN(kset) ? eloConfig.kDefault() : kset;
28383
28387
  }
28384
28388
  const eloConfig = {
28385
28389
  nSpread: 400,
@@ -28400,7 +28404,7 @@ function calculateNewRatings(params) {
28400
28404
  const invertedScale = ratingRange[0] > ratingRange[1];
28401
28405
  const decimalPlaces = ratingParameters.decimalsCount || 0;
28402
28406
  const consideredRange = invertedScale ? ratingRange.slice().reverse() : ratingRange;
28403
- const inRange = (range, value) => parseFloat(value) >= Math.min(...range) && parseFloat(value) <= Math.max(...range);
28407
+ const inRange = (range, value) => Number.parseFloat(value) >= Math.min(...range) && Number.parseFloat(value) <= Math.max(...range);
28404
28408
  if (!inRange(ratingRange, winnerRating) || !inRange(ratingRange, loserRating)) {
28405
28409
  if (!inRange(ratingRange, winnerRating))
28406
28410
  winnerRating = ratingParameters.defaultInitialization;
@@ -28438,9 +28442,9 @@ function calculateNewRatings(params) {
28438
28442
  const updatedWinnerRating = invertedScale
28439
28443
  ? ratingRange[0] - convertedUpdatedWinnerRating
28440
28444
  : convertedUpdatedWinnerRating;
28441
- let newWinnerRating = parseFloat(updatedWinnerRating.toFixed(decimalPlaces));
28445
+ let newWinnerRating = Number.parseFloat(updatedWinnerRating.toFixed(decimalPlaces));
28442
28446
  const updatedLoserRating = invertedScale ? ratingRange[0] - convertedUpdatedLoserRating : convertedUpdatedLoserRating;
28443
- let newLoserRating = parseFloat(updatedLoserRating.toFixed(decimalPlaces));
28447
+ let newLoserRating = Number.parseFloat(updatedLoserRating.toFixed(decimalPlaces));
28444
28448
  const percentageDifference = Math.max(...ratingRange)
28445
28449
  ? Math.abs(winnerRating - loserRating) / Math.max(...ratingRange)
28446
28450
  : 0;
@@ -30447,7 +30451,7 @@ function keyValueScore(params) {
30447
30451
  const { tiebreakTo, NoAD } = tiebreakFormat || {};
30448
30452
  const leadingSide = getLeadingSide({ set });
30449
30453
  if (!analysis.isTiebreakSet) {
30450
- const lowTiebreakScore = parseInt(scoreString.split(open).reverse()[0]);
30454
+ const lowTiebreakScore = Number.parseInt(scoreString.split(open).reverse()[0]);
30451
30455
  const highTiebreakScore = getHighTiebreakValue$1({
30452
30456
  lowValue: lowTiebreakScore,
30453
30457
  tiebreakTo,
@@ -34591,11 +34595,13 @@ function getCompetitionDateRange({ tournamentRecords }) {
34591
34595
  const dateRange = tournamentIds.reduce((dateRange, tournamentId) => {
34592
34596
  const tournamentRecord = tournamentRecords[tournamentId];
34593
34597
  const { tournamentInfo: { startDate, endDate }, } = getTournamentInfo({ tournamentRecord });
34594
- const dateOfStart = startDate && new Date(extractDate(startDate));
34598
+ const extractedStart = startDate && extractDate(startDate);
34599
+ const dateOfStart = extractedStart && new Date(extractedStart);
34595
34600
  if (!dateRange.startDate || (dateOfStart && dateOfStart < dateRange.startDate)) {
34596
34601
  dateRange.startDate = dateOfStart;
34597
34602
  }
34598
- const dateOfEnd = endDate && new Date(extractDate(endDate));
34603
+ const extractedEnd = endDate && extractDate(endDate);
34604
+ const dateOfEnd = extractedEnd && new Date(extractedEnd);
34599
34605
  if (!dateRange.endDate || (dateOfEnd && dateOfEnd > dateRange.endDate)) {
34600
34606
  dateRange.endDate = dateOfEnd;
34601
34607
  }
@@ -38497,7 +38503,7 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38497
38503
  withScaleValues: true,
38498
38504
  tournamentRecord,
38499
38505
  }).participantMap;
38500
- const sum = (values) => values.reduce((total, value) => total + parseFloat(value), 0);
38506
+ const sum = (values) => values.reduce((total, value) => total + Number.parseFloat(value), 0);
38501
38507
  for (const event of eventCopies) {
38502
38508
  const eventType = scaleEventType ?? event.eventType;
38503
38509
  const eventId = event.eventId;
@@ -38518,7 +38524,7 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38518
38524
  eventsMap[eventId].ratings[scaleName] = [];
38519
38525
  const accessor = ratingsParameters[scaleName]?.accessor;
38520
38526
  if (accessor) {
38521
- const value = parseFloat(rating.scaleValue?.[accessor]);
38527
+ const value = Number.parseFloat(rating.scaleValue?.[accessor]);
38522
38528
  if (value)
38523
38529
  eventsMap[eventId].ratings[scaleName].push(value);
38524
38530
  }
@@ -38536,15 +38542,15 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38536
38542
  };
38537
38543
  for (const participantId of participantIds) {
38538
38544
  const participant = participantMap?.[participantId]?.participant;
38539
- if (participant?.participantType !== INDIVIDUAL) {
38545
+ if (participant?.participantType === INDIVIDUAL) {
38546
+ processParticipant(participant);
38547
+ }
38548
+ else {
38540
38549
  for (const individualParticipantId of participant?.individualParticipantIds ?? []) {
38541
38550
  const individualParticipant = participantMap?.[individualParticipantId]?.participant;
38542
38551
  processParticipant(individualParticipant);
38543
38552
  }
38544
38553
  }
38545
- else {
38546
- processParticipant(participant);
38547
- }
38548
38554
  }
38549
38555
  const ratings = eventsMap[eventId].ratings;
38550
38556
  for (const scaleName of Object.keys(ratings)) {
@@ -38553,8 +38559,8 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38553
38559
  continue;
38554
38560
  const med = median(scaleRating)?.toFixed(2);
38555
38561
  eventsMap[eventId].ratingsStats[scaleName] = {
38556
- avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
38557
- median: med ? parseFloat(med) : undefined,
38562
+ avg: Number.parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
38563
+ median: med ? Number.parseFloat(med) : undefined,
38558
38564
  max: Math.max(...scaleRating),
38559
38565
  min: Math.min(...scaleRating),
38560
38566
  };
@@ -38568,7 +38574,7 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38568
38574
  eventsMap[eventId].draws[drawId].ratings[scaleName] = [];
38569
38575
  const accessor = ratingsParameters[scaleName]?.accessor;
38570
38576
  if (accessor) {
38571
- const value = parseFloat(rating.scaleValue?.[accessor]);
38577
+ const value = Number.parseFloat(rating.scaleValue?.[accessor]);
38572
38578
  if (value) {
38573
38579
  eventsMap[eventId].draws[drawId].ratings[scaleName].push(value);
38574
38580
  }
@@ -38589,15 +38595,15 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38589
38595
  };
38590
38596
  for (const participantId of participantIds.filter(Boolean)) {
38591
38597
  const participant = participantMap?.[participantId]?.participant;
38592
- if (participant?.participantType !== INDIVIDUAL) {
38598
+ if (participant?.participantType === INDIVIDUAL) {
38599
+ processParticipant(participant);
38600
+ }
38601
+ else {
38593
38602
  for (const individualParticipantId of participant?.individualParticipantIds ?? []) {
38594
38603
  const individualParticipant = participantMap?.[individualParticipantId]?.participant;
38595
38604
  processParticipant(individualParticipant);
38596
38605
  }
38597
38606
  }
38598
- else {
38599
- processParticipant(participant);
38600
- }
38601
38607
  }
38602
38608
  };
38603
38609
  const processedDrawIds = [];
@@ -38634,8 +38640,8 @@ function getEvents({ tournamentRecord, withScaleValues, scaleEventType, inContex
38634
38640
  continue;
38635
38641
  const med = median(scaleRating)?.toFixed(2);
38636
38642
  eventsMap[eventId].draws[drawId].ratingsStats[scaleName] = {
38637
- avg: parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
38638
- median: med ? parseFloat(med) : undefined,
38643
+ avg: Number.parseFloat((sum(scaleRating) / scaleRating.length).toFixed(2)),
38644
+ median: med ? Number.parseFloat(med) : undefined,
38639
38645
  max: Math.max(...scaleRating),
38640
38646
  min: Math.min(...scaleRating),
38641
38647
  };
@@ -42100,7 +42106,7 @@ function generateTimeSlots(params) {
42100
42106
  let startTime = timeToDate(courtDate.startTime);
42101
42107
  (courtDate.bookings || [])
42102
42108
  .filter((booking) => !booking.bookingType || !includeBookingTypes.includes(booking.bookingType))
42103
- .sort((a, b) => tidyTime(a.startTime).localeCompare(tidyTime(b.startTime)))
42109
+ .sort((a, b) => (tidyTime(a.startTime) || '').localeCompare(tidyTime(b.startTime) || ''))
42104
42110
  .forEach((booking) => {
42105
42111
  const timeSlot = {
42106
42112
  startTime: extractTime$1(startTime.toISOString()),
@@ -42195,11 +42201,11 @@ function generateVirtualCourts(params) {
42195
42201
  const { courtBookings, unassignedBookings } = bookings.reduce((accumulator, booking) => {
42196
42202
  const { courtId } = booking;
42197
42203
  if (courtId) {
42198
- if (!accumulator.courtBookings[courtId]) {
42199
- accumulator.courtBookings[courtId] = [booking];
42204
+ if (accumulator.courtBookings[courtId]) {
42205
+ accumulator.courtBookings[courtId].push(booking);
42200
42206
  }
42201
42207
  else {
42202
- accumulator.courtBookings[courtId].push(booking);
42208
+ accumulator.courtBookings[courtId] = [booking];
42203
42209
  }
42204
42210
  }
42205
42211
  else {
@@ -42233,8 +42239,7 @@ function generateVirtualCourts(params) {
42233
42239
  };
42234
42240
  });
42235
42241
  unassignedBookings.sort((a, b) => timeStringMinutes$1(a.startTime) - timeStringMinutes$1(b.startTime));
42236
- const getCourtTimeSlots = () => inProcessCourts
42237
- .map((court) => {
42242
+ const getCourtTimeSlots = () => inProcessCourts.flatMap((court) => {
42238
42243
  const courtDate = court.dateAvailability;
42239
42244
  const { timeSlots = [] } = generateTimeSlots({ courtDate });
42240
42245
  return {
@@ -42242,8 +42247,7 @@ function generateVirtualCourts(params) {
42242
42247
  courtId: court.courtId,
42243
42248
  timeSlots,
42244
42249
  };
42245
- })
42246
- .flat();
42250
+ });
42247
42251
  const assignedBookings = [];
42248
42252
  for (const unassignedBooking of unassignedBookings) {
42249
42253
  const { startTime, endTime, averageMinutes, recoveryMinutes, matchUpId } = unassignedBooking;
@@ -42340,7 +42344,7 @@ function getFirstTimeSlotStartTime({ averageMinutes, startTime, endTime, courts,
42340
42344
  const available = timeSlotMinutes >= averageMinutes;
42341
42345
  if (available) {
42342
42346
  const timeString = extractTime$1(timeSlotStartTime.toISOString());
42343
- if (!firstTimeSlotStartTime || timeString < firstTimeSlotStartTime) {
42347
+ if (timeString && (!firstTimeSlotStartTime || timeString < firstTimeSlotStartTime)) {
42344
42348
  firstTimeSlotStartTime = timeString;
42345
42349
  }
42346
42350
  }
@@ -45282,15 +45286,15 @@ function addMatchUpScheduleItems(params) {
45282
45286
  let { matchUpDependencies, inContextMatchUps } = params;
45283
45287
  const { errorOnAnachronism = false, checkChronology = true, removePriorValues, tournamentRecords, tournamentRecord, drawDefinition, disableNotice, drawMatchUps, matchUpId, schedule, event, } = params;
45284
45288
  let matchUp, warning;
45285
- if (!drawMatchUps) {
45289
+ if (drawMatchUps) {
45290
+ matchUp = drawMatchUps.find((drawMatchUp) => drawMatchUp.matchUpId === matchUpId);
45291
+ }
45292
+ else {
45286
45293
  const result = findDrawMatchUp({ drawDefinition, event, matchUpId });
45287
45294
  if (result.error)
45288
45295
  return result;
45289
45296
  matchUp = result.matchUp;
45290
45297
  }
45291
- else {
45292
- matchUp = drawMatchUps.find((drawMatchUp) => drawMatchUp.matchUpId === matchUpId);
45293
- }
45294
45298
  const { endTime, courtId, courtIds, courtOrder, resumeTime, homeParticipantId, scheduledDate, scheduledTime, startTime, stopTime, timeModifiers, venueId, } = schedule;
45295
45299
  if (checkChronology && (!matchUpDependencies || !inContextMatchUps)) {
45296
45300
  ({ matchUpDependencies, matchUps: inContextMatchUps } = getMatchUpDependencies({
@@ -45304,11 +45308,11 @@ function addMatchUpScheduleItems(params) {
45304
45308
  priorMatchUpIds.includes(matchUp.matchUpId))
45305
45309
  .map(({ schedule }) => {
45306
45310
  const isoDateString = getIsoDateString(schedule);
45307
- return new Date(isoDateString).getTime();
45311
+ return new Date(isoDateString ?? '').getTime();
45308
45312
  });
45309
45313
  if (priorMatchUpTimes?.length) {
45310
45314
  const isoDateString = getIsoDateString(schedule);
45311
- const matchUpTime = new Date(isoDateString).getTime();
45315
+ const matchUpTime = new Date(isoDateString ?? '').getTime();
45312
45316
  const maxPriorMatchUpTime = Math.max(...priorMatchUpTimes);
45313
45317
  if (maxPriorMatchUpTime >= matchUpTime) {
45314
45318
  if (errorOnAnachronism) {
@@ -45618,8 +45622,8 @@ function addMatchUpStopTime({ removePriorValues, tournamentRecord, drawDefinitio
45618
45622
  const relevantTimeItems = timeItems
45619
45623
  .filter((timeItem) => [START_TIME, RESUME_TIME, STOP_TIME].includes(timeItem?.itemType))
45620
45624
  .sort((a, b) => timeDate(a.itemValue, scheduledDate) - timeDate(b.itemValue, scheduledDate));
45621
- const lastRelevantTimeItem = relevantTimeItems[relevantTimeItems.length - 1];
45622
- const lastRelevantTimeItemIsStop = lastRelevantTimeItem && lastRelevantTimeItem.itemType === STOP_TIME;
45625
+ const lastRelevantTimeItem = relevantTimeItems.at(-1);
45626
+ const lastRelevantTimeItemIsStop = lastRelevantTimeItem?.itemType === STOP_TIME;
45623
45627
  const latestRelevantTimeValue = relevantTimeItems
45624
45628
  .filter((timeItem) => !lastRelevantTimeItemIsStop || timeItem.createdAt !== lastRelevantTimeItem.createdAt)
45625
45629
  .map((timeItem) => timeDate(timeItem.itemValue, scheduledDate))
@@ -45664,8 +45668,8 @@ function addMatchUpResumeTime({ removePriorValues, tournamentRecord, drawDefinit
45664
45668
  const relevantTimeItems = timeItems
45665
45669
  .filter((timeItem) => [START_TIME, RESUME_TIME, STOP_TIME].includes(timeItem?.itemType))
45666
45670
  .sort((a, b) => timeDate(a.itemValue, scheduledDate) - timeDate(b.itemValue, scheduledDate));
45667
- const lastRelevantTimeItem = relevantTimeItems[relevantTimeItems.length - 1];
45668
- const lastRelevantTimeItemIsResume = lastRelevantTimeItem && lastRelevantTimeItem.itemType === RESUME_TIME;
45671
+ const lastRelevantTimeItem = relevantTimeItems.at(-1);
45672
+ const lastRelevantTimeItemIsResume = lastRelevantTimeItem?.itemType === RESUME_TIME;
45669
45673
  const latestRelevantTimeValue = relevantTimeItems
45670
45674
  .filter((timeItem) => !lastRelevantTimeItemIsResume || timeItem.createdAt !== lastRelevantTimeItem.createdAt)
45671
45675
  .map((timeItem) => timeDate(timeItem.itemValue, scheduledDate))
@@ -47432,7 +47436,9 @@ function updateTimeAfterRecovery({ matchUpPotentialParticipantIds, individualPar
47432
47436
  participantId,
47433
47437
  });
47434
47438
  const matchUpTypeChange = individualParticipantProfiles[participantId].priorMatchUpType !== matchUp.matchUpType;
47435
- const recoveryValue = matchUpTypeChange ? typeChangeTimeAfterRecovery || timeAfterRecovery : timeAfterRecovery;
47439
+ const recoveryValue = matchUpTypeChange
47440
+ ? typeChangeTimeAfterRecovery || timeAfterRecovery
47441
+ : timeAfterRecovery;
47436
47442
  if (potentialIndividualParticipantIds.includes(participantId)) {
47437
47443
  addParticipantPotentialRecovery({
47438
47444
  individualParticipantProfiles,
@@ -47521,22 +47527,23 @@ function checkRequestConflicts({ averageMatchUpMinutes = 90, requestConflicts =
47521
47527
  const averageEnd = extractTime$1(addMinutes(scheduleStart, averageMatchUpMinutes).toISOString());
47522
47528
  for (const request of relevantPersonRequests) {
47523
47529
  const { requestId, startTime, endTime } = request;
47524
- const conflict = (scheduleTime > startTime && scheduleTime < endTime) || (averageEnd > startTime && averageEnd < endTime);
47530
+ const conflict = (scheduleTime > startTime && scheduleTime < endTime) ||
47531
+ (averageEnd && averageEnd > startTime && averageEnd < endTime);
47525
47532
  if (conflict) {
47526
47533
  conflicts.push({ matchUpId, request, scheduleTime });
47527
- if (!requestConflicts[requestId]) {
47534
+ if (requestConflicts[requestId]) {
47535
+ if (!requestConflicts[requestId].scheduleTimes.includes(scheduleTime))
47536
+ requestConflicts[requestId].scheduleTimes.push(scheduleTime);
47537
+ if (!requestConflicts[requestId].matchUpIds.includes(matchUpId))
47538
+ requestConflicts[requestId].matchUpIds.push(matchUpId);
47539
+ }
47540
+ else {
47528
47541
  requestConflicts[requestId] = {
47529
47542
  request,
47530
47543
  scheduleTimes: [scheduleTime],
47531
47544
  matchUpIds: [matchUpId],
47532
47545
  };
47533
47546
  }
47534
- else {
47535
- if (!requestConflicts[requestId].scheduleTimes.includes(scheduleTime))
47536
- requestConflicts[requestId].scheduleTimes.push(scheduleTime);
47537
- if (!requestConflicts[requestId].matchUpIds.includes(matchUpId))
47538
- requestConflicts[requestId].matchUpIds.push(matchUpId);
47539
- }
47540
47547
  }
47541
47548
  }
47542
47549
  return { conflicts };
@@ -48421,7 +48428,7 @@ function getEarliestCourtTime({ averageMinutes, startTime, endTime, court, date
48421
48428
  const available = timeSlotMinutes >= averageMinutes;
48422
48429
  if (available) {
48423
48430
  const timeString = extractTime$1(consideredStartTime.toISOString());
48424
- if (!first || timeString < first)
48431
+ if (timeString && (!first || timeString < first))
48425
48432
  first = timeString;
48426
48433
  }
48427
48434
  return first;
@@ -49662,7 +49669,7 @@ function generatePersonData(params) {
49662
49669
  function generatePersons(params) {
49663
49670
  let count = params?.count || 1;
49664
49671
  const { personExtensions, consideredDate, isMock = true, gendersCount, personData, category, sex } = params || {};
49665
- if (isNaN(count))
49672
+ if (Number.isNaN(Number(count)))
49666
49673
  return { error: INVALID_VALUES };
49667
49674
  const maleCount = gendersCount?.[MALE] || (isMale(sex) && count) || 0;
49668
49675
  const femaleCount = gendersCount?.[FEMALE] || (isFemale(sex) && count) || 0;
@@ -49702,7 +49709,7 @@ function generatePersons(params) {
49702
49709
  if (person.nationalityCode &&
49703
49710
  (typeof person.nationalityCode !== 'string' ||
49704
49711
  person.nationalityCode.length > 3 ||
49705
- !countries.find(({ iso, ioc }) => [iso, ioc].includes(person.nationalityCode))))
49712
+ !countries.some(({ iso, ioc }) => [iso, ioc].includes(person.nationalityCode))))
49706
49713
  return false;
49707
49714
  if (person.nationalityCode)
49708
49715
  nationalityCodes.push(person.nationalityCode);
@@ -50410,7 +50417,9 @@ function generateOutcome(params) {
50410
50417
  return { error: INVALID_VALUES };
50411
50418
  if (defaultWithScorePercent > 100)
50412
50419
  defaultWithScorePercent = 100;
50413
- if (isNaN(defaultWithScorePercent) || isNaN(pointsPerMinute) || isNaN(sideWeight))
50420
+ if (Number.isNaN(Number(defaultWithScorePercent)) ||
50421
+ Number.isNaN(Number(pointsPerMinute)) ||
50422
+ Number.isNaN(Number(sideWeight)))
50414
50423
  return { error: INVALID_VALUES };
50415
50424
  const matchUpStatuses = Object.keys(matchUpStatusProfile).filter((matchUpStatus) => Object.keys(matchUpStatusConstants).includes(matchUpStatus) && matchUpStatus !== COMPLETED$1);
50416
50425
  const matchUpStatusTotals = Object.keys(matchUpStatuses).reduce((total, key) => total + matchUpStatusProfile[key], 0);
@@ -50531,9 +50540,7 @@ function generateSet({ weightedRange = [0, 1], pointsPerMinute, matchUpStatus, i
50531
50540
  return { set, incomplete, winningSideNumber };
50532
50541
  }
50533
50542
  else {
50534
- const range = generateRange(1, setTo + 1)
50535
- .map((value) => generateRange(0, setTo + 2 - value).map(() => value))
50536
- .flat();
50543
+ const range = generateRange(1, setTo + 1).flatMap((value) => generateRange(0, setTo + 2 - value).map(() => value));
50537
50544
  const lowValue = range[randomInt(0, range.length - 1)];
50538
50545
  const scores = setTo &&
50539
50546
  getSetComplement({
@@ -50563,9 +50570,7 @@ function generateSet({ weightedRange = [0, 1], pointsPerMinute, matchUpStatus, i
50563
50570
  let tiebreakWinningSide;
50564
50571
  if (setAnalysis.hasTiebreakCondition || isTiebreakSet) {
50565
50572
  const { NoAD: tiebreakNoAd, tiebreakTo } = tiebreakFormat || tiebreakSet || {};
50566
- const range = generateRange(1, tiebreakTo + 1)
50567
- .map((value) => generateRange(0, tiebreakTo + 2 - value).map(() => value))
50568
- .flat();
50573
+ const range = generateRange(1, tiebreakTo + 1).flatMap((value) => generateRange(0, tiebreakTo + 2 - value).map(() => value));
50569
50574
  const lowValue = range[randomInt(0, range.length - 1)];
50570
50575
  const scores = getTiebreakComplement({
50571
50576
  isSide1: true,