tods-competition-factory 1.7.13 → 1.7.14

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.
package/dist/index.mjs CHANGED
@@ -333,7 +333,7 @@ const matchUpFormatCode = {
333
333
  };
334
334
 
335
335
  function factoryVersion() {
336
- return "1.7.13";
336
+ return "1.7.14";
337
337
  }
338
338
 
339
339
  function getObjectTieFormat(obj) {
@@ -2426,8 +2426,9 @@ function decorateResult({
2426
2426
  if (result && Array.isArray(result?.stack) && typeof stack === "string") {
2427
2427
  result.stack.push(stack);
2428
2428
  }
2429
- if (info && result?.error)
2430
- result.error.info = info;
2429
+ if (result && info) {
2430
+ result.info = info;
2431
+ }
2431
2432
  if (result && typeof context === "object" && Object.keys(context).length) {
2432
2433
  Object.assign(result, definedAttributes(context));
2433
2434
  }
@@ -2557,7 +2558,7 @@ function validateTieFormat(params) {
2557
2558
  const tieFormat = params?.tieFormat;
2558
2559
  const stack = "validateTieFormat";
2559
2560
  const errors = [];
2560
- if (typeof tieFormat !== "object") {
2561
+ if (!params || !tieFormat || typeof tieFormat !== "object") {
2561
2562
  errors.push("tieFormat must be an object");
2562
2563
  return decorateResult({
2563
2564
  result: {
@@ -2695,7 +2696,7 @@ function validateCollectionDefinition({
2695
2696
  errors.push(`collectionValue is not type number: ${collectionValue}`);
2696
2697
  }
2697
2698
  if (collectionValueProfiles) {
2698
- const result = validateCollectionValueProfile({
2699
+ const result = validateCollectionValueProfiles({
2699
2700
  collectionValueProfiles,
2700
2701
  matchUpCount
2701
2702
  });
@@ -2726,7 +2727,7 @@ function checkTieFormat(tieFormat) {
2726
2727
  }
2727
2728
  return { tieFormat };
2728
2729
  }
2729
- function validateCollectionValueProfile({
2730
+ function validateCollectionValueProfiles({
2730
2731
  collectionValueProfiles,
2731
2732
  matchUpCount
2732
2733
  }) {
@@ -16570,6 +16571,10 @@ function proConflicts({
16570
16571
  return { courtIssues, rowIssues };
16571
16572
  }
16572
16573
 
16574
+ function stringSort(a, b) {
16575
+ return (a || "").localeCompare(b || "");
16576
+ }
16577
+
16573
16578
  function getTieFormatDesc(tieFormat) {
16574
16579
  if (!tieFormat)
16575
16580
  return {};
@@ -16652,7 +16657,30 @@ function compareTieFormats({
16652
16657
  ancestorDifferences.groupsCount = descendantDifferences.groupsCount ? -1 * descendantDifferences.groupsCount : 0;
16653
16658
  const valueDifference = descendantDifferences.collectionsValue.totalValue - ancestorDifferences.collectionsValue.totalValue;
16654
16659
  const matchUpCountDifference = descendantDifferences.collectionsValue.totalMatchUps - ancestorDifferences.collectionsValue.totalMatchUps;
16655
- const different = nameDifference || orderDifference || ancestorDesc !== descendantDesc || valueDifference !== 0;
16660
+ const assignmentValuesCountDifference = ancestorDifferences.collectionsValue.assignmentValues.length !== descendantDifferences.collectionsValue.assignmentValues.length;
16661
+ const assignmentValuesDifference = ancestorDifferences.collectionsValue.assignmentValues.some(
16662
+ (assignment, i) => {
16663
+ const comparisonAssignment = descendantDifferences.collectionsValue.assignmentValues[i];
16664
+ if (!comparisonAssignment)
16665
+ return true;
16666
+ if (assignment.valueKey !== comparisonAssignment.valueKey)
16667
+ return true;
16668
+ if (assignment.value !== comparisonAssignment.value)
16669
+ return true;
16670
+ if (Array.isArray(assignment.value)) {
16671
+ return assignment.value.every(
16672
+ (value, i2) => comparisonAssignment.value[i2] === value
16673
+ );
16674
+ }
16675
+ return false;
16676
+ }
16677
+ );
16678
+ const different = nameDifference || orderDifference || ancestorDesc !== descendantDesc || assignmentValuesCountDifference || assignmentValuesDifference || valueDifference !== 0;
16679
+ const invalidValues = [
16680
+ ...ancestorDifferences.collectionsValue.invalidValues,
16681
+ ...descendantDifferences.collectionsValue.invalidValues
16682
+ ];
16683
+ const invalid = invalidValues.length && invalidValues;
16656
16684
  return {
16657
16685
  matchUpFormatDifferences,
16658
16686
  matchUpCountDifference,
@@ -16664,12 +16692,15 @@ function compareTieFormats({
16664
16692
  descendantDesc,
16665
16693
  ancestorDesc,
16666
16694
  ...SUCCESS,
16667
- different
16695
+ different,
16696
+ invalid
16668
16697
  };
16669
16698
  }
16670
16699
  function getCollectionsValue(definitions) {
16700
+ const invalidValues = [];
16701
+ const assignmentValues = [];
16671
16702
  let totalMatchUps = 0;
16672
- const collectionIds = Object.keys(definitions);
16703
+ const collectionIds = Object.keys(definitions).sort(stringSort);
16673
16704
  const totalValue = collectionIds.reduce((total, collectionId) => {
16674
16705
  const collectionDefinition = definitions[collectionId];
16675
16706
  const {
@@ -16680,6 +16711,24 @@ function getCollectionsValue(definitions) {
16680
16711
  scoreValue,
16681
16712
  setValue
16682
16713
  } = collectionDefinition;
16714
+ const valueAssignments = {
16715
+ collectionValueProfiles,
16716
+ collectionValue,
16717
+ matchUpValue,
16718
+ scoreValue,
16719
+ setValue
16720
+ };
16721
+ const valueKeys = Object.keys(valueAssignments).filter(
16722
+ (key) => ![void 0, null].includes(valueAssignments[key])
16723
+ );
16724
+ if (valueKeys.length !== 1) {
16725
+ invalidValues.push({ collectionId });
16726
+ }
16727
+ const valueKey = valueKeys[0];
16728
+ if (valueKey) {
16729
+ const value = valueKey === "collectionValueProfiles" ? Object.values(collectionValueProfiles) : valueAssignments[valueKey];
16730
+ assignmentValues.push({ valueKey, value });
16731
+ }
16683
16732
  totalMatchUps += matchUpCount;
16684
16733
  if (collectionValueProfiles)
16685
16734
  return total + collectionValueProfiles.reduce(
@@ -16697,7 +16746,7 @@ function getCollectionsValue(definitions) {
16697
16746
  }
16698
16747
  return total;
16699
16748
  }, 0);
16700
- return { totalValue, totalMatchUps };
16749
+ return { totalValue, totalMatchUps, invalidValues, assignmentValues };
16701
16750
  }
16702
16751
 
16703
16752
  function dehydrateMatchUps({ tournamentRecord }) {
@@ -29622,7 +29671,12 @@ function getTieFormat$1({
29622
29671
  }
29623
29672
  if (!tieFormat)
29624
29673
  return decorateResult({ result: { error: MISSING_TIE_FORMAT }, stack });
29625
- return { ...SUCCESS, tieFormat, matchUp, structure };
29674
+ return {
29675
+ ...SUCCESS,
29676
+ structure,
29677
+ tieFormat,
29678
+ matchUp
29679
+ };
29626
29680
  }
29627
29681
 
29628
29682
  function tieFormatTelemetry({ drawDefinition, auditData }) {
@@ -29637,13 +29691,59 @@ function tieFormatTelemetry({ drawDefinition, auditData }) {
29637
29691
  addExtension$1({ element: drawDefinition, extension: updatedExtension });
29638
29692
  }
29639
29693
 
29694
+ function generateTieMatchUps({
29695
+ tieFormat,
29696
+ isMock,
29697
+ uuids
29698
+ }) {
29699
+ const { collectionDefinitions } = tieFormat ?? {};
29700
+ const tieMatchUps = (collectionDefinitions ?? []).map(
29701
+ (collectionDefinition) => generateCollectionMatchUps({ collectionDefinition, uuids, isMock })
29702
+ ).filter(Boolean).flat();
29703
+ return { tieMatchUps };
29704
+ }
29705
+ function generateCollectionMatchUps({
29706
+ collectionPositionOffset = 0,
29707
+ collectionDefinition,
29708
+ matchUpsLimit,
29709
+ // internal use allows generation of missing matchUps on "reset"
29710
+ isMock,
29711
+ uuids
29712
+ }) {
29713
+ const { matchUpCount, matchUpType, collectionId, processCodes } = collectionDefinition || {};
29714
+ const numberToGenerate = matchUpsLimit ?? matchUpCount ?? 0;
29715
+ return generateRange(0, numberToGenerate).map((index) => {
29716
+ const collectionPosition = collectionPositionOffset + index + 1;
29717
+ return {
29718
+ sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
29719
+ matchUpId: uuids?.pop() || UUID(),
29720
+ matchUpStatus: MatchUpStatusEnum.ToBePlayed,
29721
+ collectionPosition,
29722
+ collectionId,
29723
+ processCodes,
29724
+ matchUpType,
29725
+ isMock
29726
+ };
29727
+ });
29728
+ }
29729
+
29640
29730
  function validUpdate({ matchUp, updateInProgressMatchUps }) {
29641
29731
  return !matchUp.winningSide && ![completedMatchUpStatuses].includes(matchUp.matchUpStatus) && (updateInProgressMatchUps || matchUp.matchUpStatus !== IN_PROGRESS$1 && !scoreHasValue(matchUp));
29642
29732
  }
29643
29733
 
29644
- function mapsCheck(map1, map2) {
29645
- const referenceKeys = Object.keys(map1);
29646
- return intersection(referenceKeys, Object.keys(map2)).length === referenceKeys.length;
29734
+ function checkStructureMatchUpCounts({ from, to }) {
29735
+ const referenceKeys = Object.keys(from);
29736
+ const sameKeys = intersection(referenceKeys, Object.keys(to)).length === referenceKeys.length;
29737
+ const differentMatchUpsCount = referenceKeys.filter(
29738
+ (collectionId) => from[collectionId] !== to[collectionId]
29739
+ );
29740
+ const matchUpsCountChanges = differentMatchUpsCount.map((collectionId) => ({
29741
+ countChange: to[collectionId] - from[collectionId],
29742
+ collectionId
29743
+ }));
29744
+ const sameMatchUpsCount = referenceKeys.every((key) => from[key] === to[key]);
29745
+ const equivalent = sameKeys && sameMatchUpsCount;
29746
+ return { equivalent, matchUpsCountChanges };
29647
29747
  }
29648
29748
  function updateTieFormat({
29649
29749
  updateInProgressMatchUps,
@@ -29653,10 +29753,14 @@ function updateTieFormat({
29653
29753
  tieFormat,
29654
29754
  eventId,
29655
29755
  matchUp,
29656
- event
29756
+ event,
29757
+ uuids
29657
29758
  }) {
29658
29759
  const stack = "updateTieFormat";
29760
+ const tournamentId = tournamentRecord?.tournamentId;
29659
29761
  let modifiedStructuresCount = 0;
29762
+ let modifiedMatchUpsCount = 0;
29763
+ let addedMatchUpsCount = 0;
29660
29764
  let modifiedCount = 0;
29661
29765
  const collectionMap = tieFormat?.collectionDefinitions.reduce(
29662
29766
  (instanceMap, def) => {
@@ -29670,7 +29774,7 @@ function updateTieFormat({
29670
29774
  instanceMap[def.collectionId] = (instanceMap[def.collectionId] || 0) + def.matchUpCount;
29671
29775
  return instanceMap;
29672
29776
  }, {});
29673
- return mapsCheck(collectionMap, cMap);
29777
+ return checkStructureMatchUpCounts({ from: cMap, to: collectionMap }).equivalent;
29674
29778
  };
29675
29779
  const drawDefaultTieFormat = getTieFormat$1({ drawDefinition })?.tieFormat;
29676
29780
  const eventDefaultTieFormat = getTieFormat$1({ event })?.tieFormat;
@@ -29678,7 +29782,7 @@ function updateTieFormat({
29678
29782
  for (const drawDefinition2 of event.drawDefinitions ?? []) {
29679
29783
  processDrawDefinition({ drawDefinition: drawDefinition2 });
29680
29784
  }
29681
- event.tieFormat = tieFormat;
29785
+ event.tieFormat = copyTieFormat(tieFormat);
29682
29786
  modifiedCount += 1;
29683
29787
  } else if (matchUp) {
29684
29788
  if (!matchUp.tieMatchUps) {
@@ -29687,9 +29791,17 @@ function updateTieFormat({
29687
29791
  const matchUpMap = instanceCount(
29688
29792
  matchUp.tieMatchUps?.map(({ collectionId }) => collectionId)
29689
29793
  );
29690
- if (mapsCheck(collectionMap, matchUpMap)) {
29794
+ const check = checkStructureMatchUpCounts({
29795
+ to: collectionMap,
29796
+ from: matchUpMap
29797
+ });
29798
+ const { changes, changesArePossible, cannotChangeReaon } = getMatchUpChangesArePossible({
29799
+ matchUp,
29800
+ check
29801
+ });
29802
+ if (check.equivalent) {
29691
29803
  if (validUpdate({ matchUp, updateInProgressMatchUps })) {
29692
- matchUp.tieFormat = tieFormat;
29804
+ matchUp.tieFormat = copyTieFormat(tieFormat);
29693
29805
  modifiedCount += 1;
29694
29806
  } else {
29695
29807
  return decorateResult({
@@ -29697,44 +29809,64 @@ function updateTieFormat({
29697
29809
  info: "matchUp is IN_PROGRESS or COMPLETE"
29698
29810
  });
29699
29811
  }
29812
+ } else if (changesArePossible) {
29813
+ makeChanges({ tieFormat, matchUp, changes, uuids });
29700
29814
  } else {
29701
29815
  return decorateResult({
29702
29816
  context: { collectionMap, matchUpMap },
29703
29817
  result: { error: INVALID_TIE_FORMAT },
29704
- info: "on matchUp",
29818
+ info: cannotChangeReaon || "specified changes not possible",
29705
29819
  stack
29706
29820
  });
29707
29821
  }
29822
+ modifiedMatchUpsCount += 1;
29708
29823
  modifyMatchUpNotice({
29709
- tournamentId: tournamentRecord?.tournamentId,
29710
29824
  eventId: event?.eventId,
29711
29825
  context: stack,
29712
29826
  drawDefinition,
29827
+ tournamentId,
29713
29828
  matchUp
29714
29829
  });
29715
29830
  } else if (structure) {
29716
- const inheritedTieFormat = drawDefaultTieFormat || eventDefaultTieFormat;
29831
+ const inheritedTieFormat = drawDefaultTieFormat ?? eventDefaultTieFormat;
29717
29832
  const modified = processStructure({
29718
29833
  inheritedTieFormat,
29719
29834
  structure
29720
- })?.modifiedCount;
29721
- if (modified)
29722
- modifiedStructuresCount += modified;
29723
- structure.tieFormat = tieFormat;
29724
- modifiedCount += 1;
29725
- modifyDrawNotice({
29835
+ })?.modifiedMatchUpsCount;
29836
+ if (modified) {
29837
+ modifiedMatchUpsCount += modified;
29838
+ modifiedStructuresCount += 1;
29839
+ modifiedCount += 1;
29840
+ }
29841
+ const different = !structure.tieFormat || compareTieFormats({
29842
+ ancestor: structure.tieFormat,
29843
+ descendant: tieFormat
29844
+ }).different;
29845
+ if (different) {
29846
+ structure.tieFormat = copyTieFormat(tieFormat);
29847
+ modifiedStructuresCount += 1;
29848
+ modifiedCount += 1;
29849
+ }
29850
+ (modified || different) && drawDefinition && modifyDrawNotice({
29726
29851
  structureIds: [structure.structureId],
29727
29852
  eventId: event?.eventId,
29728
29853
  drawDefinition
29729
29854
  });
29730
29855
  } else if (drawDefinition) {
29731
29856
  processDrawDefinition({ drawDefinition });
29732
- drawDefinition.tieFormat = tieFormat;
29857
+ drawDefinition.tieFormat = copyTieFormat(tieFormat);
29733
29858
  modifiedCount += 1;
29734
29859
  } else {
29735
29860
  return { error: MISSING_DRAW_DEFINITION };
29736
29861
  }
29737
- return { ...SUCCESS, modifiedCount, modifiedStructuresCount, tieFormat };
29862
+ return {
29863
+ modifiedStructuresCount,
29864
+ modifiedMatchUpsCount,
29865
+ addedMatchUpsCount,
29866
+ modifiedCount,
29867
+ ...SUCCESS,
29868
+ tieFormat
29869
+ };
29738
29870
  function processDrawDefinition({ drawDefinition: drawDefinition2 }) {
29739
29871
  const structures = drawDefinition2.structures || [];
29740
29872
  const modifiedStructureIds = [];
@@ -29745,9 +29877,10 @@ function updateTieFormat({
29745
29877
  const modifiedCount2 = processStructure({
29746
29878
  inheritedTieFormat,
29747
29879
  structure: structure2
29748
- })?.modifiedCount;
29880
+ })?.modifiedMatchUpsCount;
29749
29881
  if (modifiedCount2) {
29750
- modifiedStructuresCount += modifiedCount2;
29882
+ modifiedStructuresCount += 1;
29883
+ modifiedMatchUpsCount += modifiedCount2;
29751
29884
  const structureId = structure2.structureId;
29752
29885
  modifiedStructureIds.push(structureId);
29753
29886
  }
@@ -29760,32 +29893,49 @@ function updateTieFormat({
29760
29893
  return modifiedStructureIds.length;
29761
29894
  }
29762
29895
  function processStructure({ inheritedTieFormat, structure: structure2 }) {
29763
- let modifiedCount2 = 0;
29896
+ let modifiedMatchUpsCount2 = 0;
29764
29897
  const structureMatchUps = getAllStructureMatchUps({
29765
29898
  matchUpFilters: { matchUpTypes: [TEAM$2] },
29766
29899
  structure: structure2
29767
29900
  })?.matchUps || [];
29768
29901
  for (const matchUp2 of structureMatchUps) {
29902
+ const validToUpdate = validUpdate({ matchUp: matchUp2, updateInProgressMatchUps });
29769
29903
  let modified = false;
29770
29904
  const tieMatchUpsMap = instanceCount(
29771
29905
  matchUp2.tieMatchUps?.map(({ collectionId }) => collectionId)
29772
29906
  );
29773
- if (!mapsCheck(collectionMap, tieMatchUpsMap)) {
29774
- if (inheritedTieFormat) {
29775
- matchUp2.tieFormat = inheritedTieFormat;
29776
- modified = true;
29907
+ const check = checkStructureMatchUpCounts({
29908
+ from: tieMatchUpsMap,
29909
+ to: collectionMap
29910
+ });
29911
+ if (!check.equivalent) {
29912
+ const { changes, changesArePossible } = getMatchUpChangesArePossible({
29913
+ matchUp: matchUp2,
29914
+ check
29915
+ });
29916
+ if (changesArePossible && !matchUp2.tieFormat) {
29917
+ makeChanges({ changes, matchUp: matchUp2, tieFormat, uuids });
29918
+ } else if (inheritedTieFormat) {
29919
+ const different = !matchUp2.tieFormat || compareTieFormats({
29920
+ ancestor: inheritedTieFormat,
29921
+ descendant: matchUp2.tieFormat
29922
+ }).different;
29923
+ if (different) {
29924
+ matchUp2.tieFormat = inheritedTieFormat;
29925
+ modified = true;
29926
+ }
29777
29927
  } else {
29778
29928
  return decorateResult({
29779
29929
  result: { error: MISSING_TIE_FORMAT },
29780
29930
  stack
29781
29931
  });
29782
29932
  }
29783
- } else if (matchUp2.tieFormat && matchingCollections(matchUp2) && validUpdate({ matchUp: matchUp2, updateInProgressMatchUps })) {
29933
+ } else if (matchUp2.tieFormat && matchingCollections(matchUp2) && validToUpdate) {
29784
29934
  matchUp2.tieFormat = copyTieFormat(tieFormat);
29785
29935
  modified = true;
29786
29936
  }
29787
29937
  if (modified) {
29788
- modifiedCount2 += 1;
29938
+ modifiedMatchUpsCount2 += 1;
29789
29939
  modifyMatchUpNotice({
29790
29940
  tournamentId: tournamentRecord?.tournamentId,
29791
29941
  drawDefinition,
@@ -29795,8 +29945,80 @@ function updateTieFormat({
29795
29945
  });
29796
29946
  }
29797
29947
  }
29798
- return { modifiedCount: modifiedCount2 };
29948
+ return { modifiedMatchUpsCount: modifiedMatchUpsCount2 };
29799
29949
  }
29950
+ function makeChanges({ uuids: uuids2, matchUp: matchUp2, tieFormat: tieFormat2, changes }) {
29951
+ matchUp2.tieFormat = copyTieFormat(tieFormat2);
29952
+ const matchUpIdsRemoved = [];
29953
+ const matchUpsAdded = [];
29954
+ changes.forEach((change) => {
29955
+ if (change.countChange > 0) {
29956
+ const collectionPositionOffset = Math.max(
29957
+ 0,
29958
+ ...matchUp2.tieMatchUps.filter(
29959
+ (tieMatchUp) => tieMatchUp.collectionId === change.collectionId
29960
+ ).map(extractAttributes("collectionPosition"))
29961
+ );
29962
+ const collectionDefinition = tieFormat2.collectionDefinitions.find(
29963
+ (def) => def.collectionId === change.collectionId
29964
+ );
29965
+ const newMatchUps = generateCollectionMatchUps({
29966
+ matchUpsLimit: change.countChange,
29967
+ collectionPositionOffset,
29968
+ collectionDefinition,
29969
+ uuids: uuids2
29970
+ });
29971
+ matchUpsAdded.push(...makeDeepCopy(newMatchUps, false, true));
29972
+ addedMatchUpsCount += matchUpsAdded.length;
29973
+ matchUp2.tieMatchUps.push(...newMatchUps);
29974
+ } else {
29975
+ const tieMatchUpIdsToRemove = change.toBePlayedTieMatchUpIds.slice(
29976
+ 0,
29977
+ Math.abs(change.countChange)
29978
+ );
29979
+ console.log("remove", tieMatchUpIdsToRemove.length);
29980
+ matchUpIdsRemoved.push(...tieMatchUpIdsToRemove);
29981
+ matchUp2.tieMatchUps = matchUp2.tieMatchUps.filter(
29982
+ ({ matchUpId }) => !tieMatchUpIdsToRemove.includes(matchUpId)
29983
+ );
29984
+ }
29985
+ });
29986
+ matchUpsAdded.length && addMatchUpsNotice({
29987
+ matchUps: matchUpsAdded,
29988
+ drawDefinition,
29989
+ tournamentId,
29990
+ eventId
29991
+ });
29992
+ matchUpIdsRemoved.length && deleteMatchUpsNotice({
29993
+ matchUpIds: matchUpIdsRemoved,
29994
+ action: "updateTieFormat",
29995
+ drawDefinition,
29996
+ tournamentId,
29997
+ eventId
29998
+ });
29999
+ return { matchUpIdsRemoved, matchUpsAdded };
30000
+ }
30001
+ }
30002
+ function getMatchUpChangesArePossible({ check, matchUp }) {
30003
+ let cannotChangeReaon = "";
30004
+ const changes = [];
30005
+ const changesArePossible = check.matchUpsCountChanges.every(
30006
+ ({ collectionId, countChange }) => {
30007
+ const toBePlayedTieMatchUpIds = matchUp.tieMatchUps.filter(
30008
+ (tieMatchUp) => tieMatchUp.collectionId === collectionId && tieMatchUp.matchUpStatus === TO_BE_PLAYED
30009
+ ).map(extractAttributes("matchUpId"));
30010
+ const possibleToChange = toBePlayedTieMatchUpIds.length + countChange >= 0 || countChange > 0;
30011
+ if (!possibleToChange && countChange < 0)
30012
+ cannotChangeReaon = "Insufficient TO_BE_PLAYED matchUps";
30013
+ changes.push({
30014
+ toBePlayedTieMatchUpIds,
30015
+ collectionId,
30016
+ countChange
30017
+ });
30018
+ return possibleToChange;
30019
+ }
30020
+ );
30021
+ return { changesArePossible, changes, cannotChangeReaon };
29800
30022
  }
29801
30023
 
29802
30024
  function modifyCollectionDefinition$1({
@@ -29859,7 +30081,7 @@ function modifyCollectionDefinition$1({
29859
30081
  scoreValue,
29860
30082
  setValue
29861
30083
  };
29862
- if (!Object.values(valueAssignments).filter(Boolean).length && !collectionOrder && !collectionName && !matchUpCount && !matchUpFormat)
30084
+ if (!Object.values(valueAssignments).filter(Boolean).length && !collectionOrder && !collectionName && !matchUpFormat && !matchUpCount && !matchUpType)
29863
30085
  return decorateResult({ result: { error: MISSING_VALUE }, stack });
29864
30086
  if (Object.values(valueAssignments).filter(Boolean).length > 1)
29865
30087
  return decorateResult({
@@ -29886,11 +30108,16 @@ function modifyCollectionDefinition$1({
29886
30108
  (collectionDefinition) => collectionDefinition.collectionId === collectionId
29887
30109
  );
29888
30110
  if (!sourceCollectionDefinition)
29889
- return decorateResult({ result: { error: NOT_FOUND }, stack });
30111
+ return decorateResult({
30112
+ info: "source collectionDefinition",
30113
+ result: { error: NOT_FOUND },
30114
+ context: { collectionId },
30115
+ stack
30116
+ });
29890
30117
  const value = collectionValue ?? matchUpValue ?? scoreValue ?? setValue;
29891
30118
  if (collectionValueProfiles) {
29892
- const result2 = validateCollectionValueProfile({
29893
- matchUpCount: matchUpCount || sourceCollectionDefinition?.matchUpCount,
30119
+ const result2 = validateCollectionValueProfiles({
30120
+ matchUpCount: matchUpCount ?? sourceCollectionDefinition?.matchUpCount,
29894
30121
  collectionValueProfiles
29895
30122
  });
29896
30123
  if (result2.errors) {
@@ -29966,11 +30193,8 @@ function modifyCollectionDefinition$1({
29966
30193
  modifications.push({ collectionId, matchUpFormat });
29967
30194
  }
29968
30195
  if (isConvertableInteger(matchUpCount) && sourceCollectionDefinition.matchUpCount !== matchUpCount) {
29969
- return decorateResult({
29970
- result: { error: NOT_IMPLEMENTED },
29971
- context: { matchUpCount },
29972
- stack
29973
- });
30196
+ targetCollectionDefinition.matchUpCount = matchUpCount;
30197
+ modifications.push({ collectionId, matchUpCount });
29974
30198
  }
29975
30199
  if (matchUpType && sourceCollectionDefinition.matchUpType !== matchUpType) {
29976
30200
  return decorateResult({
@@ -29987,8 +30211,8 @@ function modifyCollectionDefinition$1({
29987
30211
  targetCollectionDefinition.gender = gender;
29988
30212
  modifications.push({ collectionId, gender });
29989
30213
  }
29990
- const prunedTieFormat = definedAttributes(tieFormat);
29991
- result = validateTieFormat({ tieFormat: prunedTieFormat });
30214
+ const modifiedTieFormat = definedAttributes(tieFormat);
30215
+ result = validateTieFormat({ tieFormat: modifiedTieFormat });
29992
30216
  if (result.error) {
29993
30217
  return decorateResult({ result, stack });
29994
30218
  }
@@ -29997,16 +30221,16 @@ function modifyCollectionDefinition$1({
29997
30221
  }
29998
30222
  const changedTieFormatName = existingTieFormat?.tieFormatName !== tieFormatName;
29999
30223
  if (changedTieFormatName) {
30000
- prunedTieFormat.tieFormatName = tieFormatName;
30224
+ modifiedTieFormat.tieFormatName = tieFormatName;
30001
30225
  modifications.push({ tieFormatName });
30002
30226
  } else if (modifications.length) {
30003
- delete prunedTieFormat.tieFormatName;
30227
+ delete modifiedTieFormat.tieFormatName;
30004
30228
  modifications.push(
30005
30229
  "tieFormatName removed: modifications without new tieFormatName"
30006
30230
  );
30007
30231
  }
30008
30232
  result = updateTieFormat({
30009
- tieFormat: prunedTieFormat,
30233
+ tieFormat: modifiedTieFormat,
30010
30234
  updateInProgressMatchUps,
30011
30235
  tournamentRecord,
30012
30236
  drawDefinition,
@@ -30299,17 +30523,17 @@ function removeCollectionDefinition$1({
30299
30523
  matchUps = getAllStructureMatchUps({
30300
30524
  matchUpFilters: { matchUpTypes: [TEAM$2] },
30301
30525
  structure
30302
- })?.matchUps || [];
30526
+ })?.matchUps ?? [];
30303
30527
  } else if (drawDefinition) {
30304
30528
  matchUps = allDrawMatchUps$1({
30305
30529
  matchUpFilters: { matchUpTypes: [TEAM$2] },
30306
30530
  drawDefinition
30307
- })?.matchUps || [];
30531
+ })?.matchUps ?? [];
30308
30532
  } else if (event) {
30309
30533
  matchUps = allEventMatchUps({
30310
30534
  matchUpFilters: { matchUpTypes: [TEAM$2] },
30311
30535
  drawDefinition
30312
- })?.matchUps || [];
30536
+ })?.matchUps ?? [];
30313
30537
  }
30314
30538
  const targetMatchUps = (matchUps || []).filter((matchUp2) => {
30315
30539
  const collectionMatchUps = matchUp2.tieMatchUps?.filter(
@@ -30435,41 +30659,6 @@ function removeCollectionDefinition(params) {
30435
30659
  return resolveTournamentRecord({ ...params, method: removeCollectionDefinition$1 });
30436
30660
  }
30437
30661
 
30438
- function generateTieMatchUps({
30439
- tieFormat,
30440
- isMock,
30441
- uuids
30442
- }) {
30443
- const { collectionDefinitions } = tieFormat || {};
30444
- const tieMatchUps = (collectionDefinitions || []).map(
30445
- (collectionDefinition) => generateCollectionMatchUps({ collectionDefinition, uuids, isMock })
30446
- ).filter(Boolean).flat();
30447
- return { tieMatchUps };
30448
- }
30449
- function generateCollectionMatchUps({
30450
- collectionDefinition,
30451
- matchUpsLimit,
30452
- // internal use allows generation of missing matchUps on "reset"
30453
- isMock,
30454
- uuids
30455
- }) {
30456
- const { matchUpCount, matchUpType, collectionId, processCodes } = collectionDefinition || {};
30457
- const numberToGenerate = matchUpsLimit || matchUpCount || 0;
30458
- return generateRange(0, numberToGenerate).map((index) => {
30459
- const collectionPosition = index + 1;
30460
- return {
30461
- sides: [{ sideNumber: 1 }, { sideNumber: 2 }],
30462
- matchUpId: uuids?.pop() || UUID(),
30463
- matchUpStatus: MatchUpStatusEnum.ToBePlayed,
30464
- collectionPosition,
30465
- collectionId,
30466
- processCodes,
30467
- matchUpType,
30468
- isMock
30469
- };
30470
- });
30471
- }
30472
-
30473
30662
  function addCollectionDefinition$1({
30474
30663
  updateInProgressMatchUps = true,
30475
30664
  collectionDefinition,
@@ -30631,7 +30820,7 @@ function addCollectionDefinition$1({
30631
30820
  structure: structure2,
30632
30821
  uuids
30633
30822
  });
30634
- modifiedStructureIds.push(structureId);
30823
+ modifiedStructureIds.push(structure2.structureId);
30635
30824
  addedMatchUps.push(...result2.newMatchUps);
30636
30825
  targetMatchUps.push(...result2.targetMatchUps);
30637
30826
  }
@@ -30725,146 +30914,6 @@ function addCollectionDefinition(params) {
30725
30914
  return resolveTournamentRecord({ ...params, method: addCollectionDefinition$1 });
30726
30915
  }
30727
30916
 
30728
- function publicFindMatchUp(params) {
30729
- Object.assign(params, { inContext: true });
30730
- const { matchUp, error } = findMatchUp(params);
30731
- return { matchUp: makeDeepCopy(matchUp, true, true), error };
30732
- }
30733
- function findMatchUp({
30734
- participantsProfile,
30735
- afterRecoveryTimes,
30736
- tournamentRecord,
30737
- contextContent,
30738
- contextProfile,
30739
- drawDefinition,
30740
- matchUpId,
30741
- inContext,
30742
- eventId,
30743
- drawId,
30744
- event
30745
- }) {
30746
- if (!tournamentRecord)
30747
- return { error: MISSING_TOURNAMENT_RECORD };
30748
- if (typeof matchUpId !== "string")
30749
- return { error: MISSING_MATCHUP_ID };
30750
- if (!drawDefinition || !event) {
30751
- const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps || [];
30752
- const inContextMatchUp = matchUps.find(
30753
- (matchUp2) => matchUp2.matchUpId === matchUpId
30754
- );
30755
- if (!inContextMatchUp)
30756
- return { error: MATCHUP_NOT_FOUND };
30757
- ({ eventId, drawId } = inContextMatchUp);
30758
- ({ event, drawDefinition } = findEvent({
30759
- tournamentRecord,
30760
- eventId,
30761
- drawId
30762
- }));
30763
- }
30764
- if (!drawDefinition)
30765
- return { error: DRAW_DEFINITION_NOT_FOUND };
30766
- if (contextProfile && !contextContent)
30767
- contextContent = getContextContent({ tournamentRecord, contextProfile });
30768
- const additionalContext = {
30769
- surfaceCategory: event?.surfaceCategory || tournamentRecord.surfaceCategory,
30770
- indoorOutDoor: event?.indoorOutdoor || tournamentRecord.indoorOutdoor,
30771
- endDate: event?.endDate || tournamentRecord.endDate,
30772
- tournamentId: tournamentRecord.tournamentId,
30773
- eventId: eventId || event?.eventId,
30774
- drawId
30775
- };
30776
- const { participants: tournamentParticipants = [] } = hydrateParticipants({
30777
- participantsProfile,
30778
- tournamentRecord,
30779
- contextProfile,
30780
- inContext
30781
- });
30782
- const { matchUp, structure } = findMatchUp$1({
30783
- context: inContext ? additionalContext : void 0,
30784
- tournamentParticipants,
30785
- afterRecoveryTimes,
30786
- contextContent,
30787
- drawDefinition,
30788
- contextProfile,
30789
- matchUpId,
30790
- inContext,
30791
- event
30792
- });
30793
- return { matchUp, structure, drawDefinition };
30794
- }
30795
-
30796
- function getTieFormat({
30797
- tournamentRecord,
30798
- // passed in automatically by tournamentEngine
30799
- drawDefinition,
30800
- // passed in automatically by tournamentEngine when drawId provided
30801
- structureId,
30802
- // optional - if only the default matchUpFormat for a structure is required
30803
- matchUpId,
30804
- // id of matchUp for which the scoped matchUpFormat(s) are desired
30805
- structure,
30806
- // optional optimization - when structure already known
30807
- eventId,
30808
- // optional - if only the default matchUpFormat for an event is required
30809
- drawId,
30810
- // avoid brute force search for matchUp
30811
- event
30812
- // passed in automatically by tournamentEngine when drawId or eventId provided
30813
- }) {
30814
- if (!tournamentRecord)
30815
- return { error: MISSING_TOURNAMENT_RECORD };
30816
- if (!drawId && !event && !structureId && !matchUpId)
30817
- return decorateResult({
30818
- result: { error: MISSING_VALUE },
30819
- stack: "getTieFormat"
30820
- });
30821
- if (eventId && !event) {
30822
- event = tournamentRecord.events?.find((event2) => event2.eventId === eventId);
30823
- }
30824
- const matchUpResult = findMatchUp({
30825
- tournamentRecord,
30826
- drawDefinition,
30827
- matchUpId,
30828
- drawId,
30829
- event
30830
- });
30831
- if (matchUpId && matchUpResult?.error) {
30832
- return matchUpResult;
30833
- } else if (!drawDefinition && matchUpResult?.drawDefinition) {
30834
- drawDefinition = matchUpResult?.drawDefinition;
30835
- }
30836
- structure = structure ?? matchUpResult?.structure;
30837
- if (!structure && structureId && !matchUpId) {
30838
- if (!drawDefinition)
30839
- return { error: MISSING_DRAW_ID };
30840
- const structureResult = findStructure({ drawDefinition, structureId });
30841
- if (structureResult.error)
30842
- return structureResult;
30843
- structure = structureResult.structure;
30844
- }
30845
- const structureDefaultTieFormat = (structure?.tieFormat || structure?.tieFormatId) && resolveTieFormat({ structure, drawDefinition, event })?.tieFormat;
30846
- const drawDefaultTieFormat = (drawDefinition?.tieFormat || drawDefinition?.tieFormatId) && resolveTieFormat({
30847
- drawDefinition,
30848
- event
30849
- })?.tieFormat;
30850
- const eventDefaultTieFormat = resolveTieFormat({ event })?.tieFormat;
30851
- const tieFormat = resolveTieFormat({
30852
- matchUp: matchUpResult?.matchUp,
30853
- drawDefinition,
30854
- structure,
30855
- event
30856
- })?.tieFormat;
30857
- return {
30858
- ...SUCCESS,
30859
- matchUp: matchUpResult?.matchUp,
30860
- structureDefaultTieFormat,
30861
- eventDefaultTieFormat,
30862
- drawDefaultTieFormat,
30863
- tieFormat,
30864
- structure
30865
- };
30866
- }
30867
-
30868
30917
  function updateTargetTeamMatchUps({
30869
30918
  updateInProgressMatchUps,
30870
30919
  tournamentRecord,
@@ -31010,8 +31059,7 @@ function removeCollectionGroup$1({
31010
31059
  if (isNaN(collectionGroupNumber))
31011
31060
  return { error: INVALID_VALUES };
31012
31061
  const stack = "removeCollectionGroup";
31013
- let result = !matchUp ? getTieFormat({
31014
- tournamentRecord,
31062
+ let result = !matchUp ? getTieFormat$1({
31015
31063
  drawDefinition,
31016
31064
  structureId,
31017
31065
  matchUpId,
@@ -31179,8 +31227,13 @@ function modifyTieFormat$1({
31179
31227
  event
31180
31228
  }) {
31181
31229
  const stack = "updateTieFormat";
31182
- if (!validateTieFormat(modifiedTieFormat))
31183
- return { error: INVALID_TIE_FORMAT };
31230
+ if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
31231
+ return decorateResult({
31232
+ result: { error: INVALID_TIE_FORMAT },
31233
+ info: "falied validation",
31234
+ stack
31235
+ });
31236
+ }
31184
31237
  const result = getTieFormat$1({
31185
31238
  drawDefinition,
31186
31239
  structureId,
@@ -31192,8 +31245,18 @@ function modifyTieFormat$1({
31192
31245
  return decorateResult({ result, stack });
31193
31246
  const { matchUp, tieFormat: existingTieFormat } = result;
31194
31247
  const tieFormat = copyTieFormat(existingTieFormat);
31195
- if (!compareTieFormats({ ancestor: tieFormat, descendant: modifiedTieFormat })?.different) {
31196
- return { ...SUCCESS };
31248
+ const comparison = compareTieFormats({
31249
+ descendant: modifiedTieFormat,
31250
+ ancestor: tieFormat
31251
+ });
31252
+ if (comparison.invalid) {
31253
+ return decorateResult({
31254
+ context: { invalid: comparison.invalid },
31255
+ result: { error: INVALID_TIE_FORMAT }
31256
+ });
31257
+ }
31258
+ if (!comparison?.different) {
31259
+ return decorateResult({ result: { ...SUCCESS }, info: "Nothing to do" });
31197
31260
  }
31198
31261
  const existingCollectionIds = tieFormat.collectionDefinitions.map(
31199
31262
  ({ collectionId }) => collectionId
@@ -31207,13 +31270,18 @@ function modifyTieFormat$1({
31207
31270
  const addedCollectionDefinitions = modifiedTieFormat.collectionDefinitions.filter(
31208
31271
  ({ collectionId }) => !existingCollectionIds.includes(collectionId)
31209
31272
  );
31273
+ const addedCollectionIds = addedCollectionDefinitions.map(extractAttributes("collectionId"));
31210
31274
  const modifications = [];
31211
31275
  let processedTieFormat;
31276
+ const tieFormatName = modifiedTieFormat.tieFormatName;
31212
31277
  for (const collectionDefinition of modifiedTieFormat.collectionDefinitions) {
31278
+ if (addedCollectionIds.includes(collectionDefinition.collectionId))
31279
+ continue;
31213
31280
  const result2 = modifyCollectionDefinition$1({
31214
31281
  updateInProgressMatchUps,
31215
31282
  ...collectionDefinition,
31216
31283
  tournamentRecord,
31284
+ tieFormatName,
31217
31285
  drawDefinition,
31218
31286
  structureId,
31219
31287
  matchUpId,
@@ -31227,7 +31295,6 @@ function modifyTieFormat$1({
31227
31295
  if (result2.tieFormat)
31228
31296
  processedTieFormat = result2.tieFormat;
31229
31297
  }
31230
- const tieFormatName = modifiedTieFormat.tieFormatName;
31231
31298
  for (const collectionDefinition of addedCollectionDefinitions) {
31232
31299
  const result2 = addCollectionDefinition$1({
31233
31300
  updateInProgressMatchUps,
@@ -31270,7 +31337,7 @@ function modifyTieFormat$1({
31270
31337
  if (changedTieFormatName) {
31271
31338
  processedTieFormat.tieFormatName = tieFormatName;
31272
31339
  modifications.push({ tieFormatName });
31273
- } else if (modifications.length) {
31340
+ } else if (modifications.length || addedCollectionIds.length || removedCollectionIds.length) {
31274
31341
  delete processedTieFormat.tieFormatName;
31275
31342
  modifications.push(
31276
31343
  "tieFormatName removed: modifications without new tieFormatName"
@@ -31279,13 +31346,85 @@ function modifyTieFormat$1({
31279
31346
  processedTieFormat.collectionDefinitions = processedTieFormat.collectionDefinitions.sort(
31280
31347
  (a, b) => numericSortValue(a.collectionOrder) - numericSortValue(b.collectionOrder)
31281
31348
  ).map((def, i) => ({ ...def, collectionOrder: i + 1 }));
31282
- return { ...SUCCESS, processedTieFormat, modifications };
31349
+ return {
31350
+ processedTieFormat: copyTieFormat(processedTieFormat),
31351
+ modifications,
31352
+ ...SUCCESS
31353
+ };
31283
31354
  }
31284
31355
 
31285
31356
  function modifyTieFormat(params) {
31286
31357
  return resolveTournamentRecord({ ...params, method: modifyTieFormat$1 });
31287
31358
  }
31288
31359
 
31360
+ function publicFindMatchUp(params) {
31361
+ Object.assign(params, { inContext: true });
31362
+ const { matchUp, error } = findMatchUp(params);
31363
+ return { matchUp: makeDeepCopy(matchUp, true, true), error };
31364
+ }
31365
+ function findMatchUp({
31366
+ participantsProfile,
31367
+ afterRecoveryTimes,
31368
+ tournamentRecord,
31369
+ contextContent,
31370
+ contextProfile,
31371
+ drawDefinition,
31372
+ matchUpId,
31373
+ inContext,
31374
+ eventId,
31375
+ drawId,
31376
+ event
31377
+ }) {
31378
+ if (!tournamentRecord)
31379
+ return { error: MISSING_TOURNAMENT_RECORD };
31380
+ if (typeof matchUpId !== "string")
31381
+ return { error: MISSING_MATCHUP_ID };
31382
+ if (!drawDefinition || !event) {
31383
+ const matchUps = allTournamentMatchUps({ tournamentRecord }).matchUps ?? [];
31384
+ const inContextMatchUp = matchUps.find(
31385
+ (matchUp2) => matchUp2.matchUpId === matchUpId
31386
+ );
31387
+ if (!inContextMatchUp)
31388
+ return { error: MATCHUP_NOT_FOUND };
31389
+ ({ eventId, drawId } = inContextMatchUp);
31390
+ ({ event, drawDefinition } = findEvent({
31391
+ tournamentRecord,
31392
+ eventId,
31393
+ drawId
31394
+ }));
31395
+ }
31396
+ if (!drawDefinition)
31397
+ return { error: DRAW_DEFINITION_NOT_FOUND };
31398
+ if (contextProfile && !contextContent)
31399
+ contextContent = getContextContent({ tournamentRecord, contextProfile });
31400
+ const additionalContext = {
31401
+ surfaceCategory: event?.surfaceCategory ?? tournamentRecord.surfaceCategory,
31402
+ indoorOutDoor: event?.indoorOutdoor ?? tournamentRecord.indoorOutdoor,
31403
+ endDate: event?.endDate ?? tournamentRecord.endDate,
31404
+ tournamentId: tournamentRecord.tournamentId,
31405
+ eventId: eventId ?? event?.eventId,
31406
+ drawId
31407
+ };
31408
+ const { participants: tournamentParticipants = [] } = hydrateParticipants({
31409
+ participantsProfile,
31410
+ tournamentRecord,
31411
+ contextProfile,
31412
+ inContext
31413
+ });
31414
+ const { matchUp, structure } = findMatchUp$1({
31415
+ context: inContext ? additionalContext : void 0,
31416
+ tournamentParticipants,
31417
+ afterRecoveryTimes,
31418
+ contextContent,
31419
+ drawDefinition,
31420
+ contextProfile,
31421
+ matchUpId,
31422
+ inContext,
31423
+ event
31424
+ });
31425
+ return { matchUp, structure, drawDefinition };
31426
+ }
31427
+
31289
31428
  function resetTieFormat$1({
31290
31429
  tournamentRecord,
31291
31430
  drawDefinition,
@@ -46891,10 +47030,6 @@ function removeDelegatedOutcome$1({ drawDefinition, event, matchUpId }) {
46891
47030
  });
46892
47031
  }
46893
47032
 
46894
- function stringSort(a, b) {
46895
- return (a || "").localeCompare(b || "");
46896
- }
46897
-
46898
47033
  function generateCandidate({
46899
47034
  maxIterations = 4e3,
46900
47035
  // cap the processing intensity of the candidate generator
@@ -59052,6 +59187,78 @@ function getParticipantSignInStatus({
59052
59187
  return timeItem && timeItem.itemValue === SIGNED_IN && SIGNED_IN;
59053
59188
  }
59054
59189
 
59190
+ function getTieFormat({
59191
+ tournamentRecord,
59192
+ // passed in automatically by tournamentEngine
59193
+ drawDefinition,
59194
+ // passed in automatically by tournamentEngine when drawId provided
59195
+ structureId,
59196
+ // optional - if only the default matchUpFormat for a structure is required
59197
+ matchUpId,
59198
+ // id of matchUp for which the scoped matchUpFormat(s) are desired
59199
+ structure,
59200
+ // optional optimization - when structure already known
59201
+ eventId,
59202
+ // optional - if only the default matchUpFormat for an event is required
59203
+ drawId,
59204
+ // avoid brute force search for matchUp
59205
+ event
59206
+ // passed in automatically by tournamentEngine when drawId or eventId provided
59207
+ }) {
59208
+ if (!tournamentRecord)
59209
+ return { error: MISSING_TOURNAMENT_RECORD };
59210
+ if (!drawId && !event && !structureId && !matchUpId)
59211
+ return decorateResult({
59212
+ result: { error: MISSING_VALUE },
59213
+ stack: "getTieFormat"
59214
+ });
59215
+ if (eventId && !event) {
59216
+ event = tournamentRecord.events?.find((event2) => event2.eventId === eventId);
59217
+ }
59218
+ const matchUpResult = publicFindMatchUp({
59219
+ tournamentRecord,
59220
+ drawDefinition,
59221
+ matchUpId,
59222
+ drawId,
59223
+ event
59224
+ });
59225
+ if (matchUpId && matchUpResult?.error) {
59226
+ return matchUpResult;
59227
+ } else if (!drawDefinition && matchUpResult?.drawDefinition) {
59228
+ drawDefinition = matchUpResult?.drawDefinition;
59229
+ }
59230
+ structure = structure ?? matchUpResult?.structure;
59231
+ if (!structure && structureId && !matchUpId) {
59232
+ if (!drawDefinition)
59233
+ return { error: MISSING_DRAW_ID };
59234
+ const structureResult = findStructure({ drawDefinition, structureId });
59235
+ if (structureResult.error)
59236
+ return structureResult;
59237
+ structure = structureResult.structure;
59238
+ }
59239
+ const structureDefaultTieFormat = (structure?.tieFormat || structure?.tieFormatId) && resolveTieFormat({ structure, drawDefinition, event })?.tieFormat;
59240
+ const drawDefaultTieFormat = (drawDefinition?.tieFormat || drawDefinition?.tieFormatId) && resolveTieFormat({
59241
+ drawDefinition,
59242
+ event
59243
+ })?.tieFormat;
59244
+ const eventDefaultTieFormat = resolveTieFormat({ event })?.tieFormat;
59245
+ const tieFormat = resolveTieFormat({
59246
+ matchUp: matchUpResult?.matchUp,
59247
+ drawDefinition,
59248
+ structure,
59249
+ event
59250
+ })?.tieFormat;
59251
+ return {
59252
+ ...SUCCESS,
59253
+ matchUp: matchUpResult?.matchUp,
59254
+ structureDefaultTieFormat: copyTieFormat(structureDefaultTieFormat),
59255
+ eventDefaultTieFormat: copyTieFormat(eventDefaultTieFormat),
59256
+ drawDefaultTieFormat: copyTieFormat(drawDefaultTieFormat),
59257
+ tieFormat: copyTieFormat(tieFormat),
59258
+ structure
59259
+ };
59260
+ }
59261
+
59055
59262
  function getEventProperties({ tournamentRecord, event }) {
59056
59263
  if (!tournamentRecord)
59057
59264
  return { error: MISSING_TOURNAMENT_RECORD };