tods-competition-factory 1.9.2 → 1.9.3

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.
@@ -2946,7 +2946,7 @@ var matchUpFormatCode = {
2946
2946
  };
2947
2947
 
2948
2948
  function factoryVersion() {
2949
- return '1.9.2';
2949
+ return '1.9.3';
2950
2950
  }
2951
2951
 
2952
2952
  function getObjectTieFormat(obj) {
@@ -16764,8 +16764,51 @@ var positionActionConstants = {
16764
16764
  };
16765
16765
 
16766
16766
  var _a$e;
16767
- var POLICY_POSITION_ACTIONS_DEFAULT = (_a$e = {},
16767
+ var POLICY_POSITION_ACTIONS_UNRESTRICTED = (_a$e = {},
16768
16768
  _a$e[POLICY_TYPE_POSITION_ACTIONS] = {
16769
+ policyName: 'positionActionsUnrestricted',
16770
+ // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [], structureTypes: [] }
16771
+ // enabledStructures: [] => all structures are enabled
16772
+ enabledStructures: [],
16773
+ // enables entries in other flights to be accessed as alternates
16774
+ otherFlightEntries: true,
16775
+ // enables entries with multiple qualifying roundTargets to be placed in any round
16776
+ disableRoundRestrictions: true,
16777
+ // enable specific actions even when there are active positions
16778
+ activePositionOverrides: [SEED_VALUE, REMOVE_SEED],
16779
+ },
16780
+ _a$e);
16781
+
16782
+ var _a$d;
16783
+ var POLICY_POSITION_ACTIONS_NO_MOVEMENT = (_a$d = {},
16784
+ _a$d[POLICY_TYPE_POSITION_ACTIONS] = {
16785
+ policyName: 'positionActionsNoMovement',
16786
+ // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
16787
+ // enabledStructures: [] => all structures are enabled
16788
+ enabledStructures: [
16789
+ {
16790
+ stages: [], // stages: [] => applies to all stages
16791
+ stageSequences: [], // stageSequences: [] => applies to all stageSequences
16792
+ enabledActions: [SEED_VALUE, ADD_NICKNAME, ADD_PENALTY],
16793
+ disabledActions: [], // disabledActions: [] => no actions are disabled
16794
+ },
16795
+ ],
16796
+ },
16797
+ _a$d);
16798
+
16799
+ var _a$c;
16800
+ var POLICY_POSITION_ACTIONS_DISABLED = (_a$c = {},
16801
+ _a$c[POLICY_TYPE_POSITION_ACTIONS] = {
16802
+ policyName: 'positionActionsDisabled',
16803
+ // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [], structureTypes: [] }
16804
+ // enabledStructures: [] => all structures are enabled
16805
+ enabledStructures: false,
16806
+ },
16807
+ _a$c);
16808
+
16809
+ var _a$b;
16810
+ var POLICY_POSITION_ACTIONS_DEFAULT = (_a$b = {},
16811
+ _a$b[POLICY_TYPE_POSITION_ACTIONS] = {
16769
16812
  policyName: 'positionActionsDefault',
16770
16813
  // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
16771
16814
  // enabledStructures: [] => all structures are enabled
@@ -16796,137 +16839,15 @@ var POLICY_POSITION_ACTIONS_DEFAULT = (_a$e = {},
16796
16839
  // enable specific actions even when there are active positions
16797
16840
  activePositionOverrides: [],
16798
16841
  },
16799
- _a$e);
16800
-
16801
- var _a$d;
16802
- var POLICY_POSITION_ACTIONS_DISABLED = (_a$d = {},
16803
- _a$d[POLICY_TYPE_POSITION_ACTIONS] = {
16804
- policyName: 'positionActionsDisabled',
16805
- // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [], structureTypes: [] }
16806
- // enabledStructures: [] => all structures are enabled
16807
- enabledStructures: false,
16808
- },
16809
- _a$d);
16810
-
16811
- var _a$c;
16812
- var POLICY_POSITION_ACTIONS_NO_MOVEMENT = (_a$c = {},
16813
- _a$c[POLICY_TYPE_POSITION_ACTIONS] = {
16814
- policyName: 'positionActionsNoMovement',
16815
- // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [] }
16816
- // enabledStructures: [] => all structures are enabled
16817
- enabledStructures: [
16818
- {
16819
- stages: [], // stages: [] => applies to all stages
16820
- stageSequences: [], // stageSequences: [] => applies to all stageSequences
16821
- enabledActions: [SEED_VALUE, ADD_NICKNAME, ADD_PENALTY],
16822
- disabledActions: [], // disabledActions: [] => no actions are disabled
16823
- },
16824
- ],
16825
- },
16826
- _a$c);
16827
-
16828
- var _a$b;
16829
- var POLICY_POSITION_ACTIONS_UNRESTRICTED = (_a$b = {},
16830
- _a$b[POLICY_TYPE_POSITION_ACTIONS] = {
16831
- policyName: 'positionActionsUnrestricted',
16832
- // positionActions will be selectively enabled for structures matching { stages: [], stageSequences: [], structureTypes: [] }
16833
- // enabledStructures: [] => all structures are enabled
16834
- enabledStructures: [],
16835
- // enables entries in other flights to be accessed as alternates
16836
- otherFlightEntries: true,
16837
- // enables entries with multiple qualifying roundTargets to be placed in any round
16838
- disableRoundRestrictions: true,
16839
- // enable specific actions even when there are active positions
16840
- activePositionOverrides: [SEED_VALUE, REMOVE_SEED],
16841
- },
16842
16842
  _a$b);
16843
16843
 
16844
- var _a$a;
16845
- var POLICY_PRIVACY_DEFAULT = (_a$a = {},
16846
- _a$a[POLICY_TYPE_PARTICIPANT] = {
16847
- policyName: 'Participant Privacy Policy',
16848
- participant: {
16849
- contacts: false,
16850
- individualParticipants: {
16851
- onlineResources: false,
16852
- participantName: true,
16853
- participantOtherName: true,
16854
- participantId: true,
16855
- participantRole: true,
16856
- participantStatus: true,
16857
- penalties: false,
16858
- representing: true,
16859
- participantRoleResponsibilities: false,
16860
- participantType: true,
16861
- person: {
16862
- addresses: false,
16863
- biographicalInformation: false,
16864
- birthDate: false,
16865
- contacts: false,
16866
- nationalityCode: true,
16867
- nativeFamilyName: false,
16868
- nativeGivenName: false,
16869
- onlineResources: false,
16870
- otherNames: true,
16871
- parentOrganisationId: false,
16872
- passportFamilyName: false,
16873
- passportGivenName: false,
16874
- personId: false,
16875
- personOtherIds: false,
16876
- previousNames: false,
16877
- sex: false,
16878
- standardFamilyName: true,
16879
- standardGivenName: true,
16880
- status: false,
16881
- tennisId: false,
16882
- wheelchair: true,
16883
- },
16884
- },
16885
- individualParticipantIds: true,
16886
- onlineResources: false,
16887
- participantName: true,
16888
- participantOtherName: true,
16889
- participantId: true,
16890
- participantRole: true,
16891
- participantStatus: true,
16892
- penalties: false,
16893
- representing: true,
16894
- participantRoleResponsibilities: false,
16895
- participantType: true,
16896
- person: {
16897
- addresses: false,
16898
- biographicalInformation: false,
16899
- birthDate: false,
16900
- contacts: false,
16901
- nationalityCode: true,
16902
- nativeFamilyName: false,
16903
- nativeGivenName: false,
16904
- onlineResources: false,
16905
- otherNames: true,
16906
- parentOrganisationId: false,
16907
- passportFamilyName: false,
16908
- passportGivenName: false,
16909
- personId: false,
16910
- personOtherIds: false,
16911
- previousNames: false,
16912
- sex: false,
16913
- standardFamilyName: true,
16914
- standardGivenName: true,
16915
- status: false,
16916
- tennisId: false,
16917
- wheelchair: true,
16918
- },
16919
- },
16920
- },
16921
- _a$a);
16922
-
16923
- var _a$9, _b$4, _c, _d, _e;
16844
+ var _a$a, _b$4, _c, _d, _e;
16924
16845
  // categoryTypes
16925
16846
  var ADULT = 'ADULT';
16926
16847
  var JUNIOR = 'JUNIOR';
16927
16848
  var WHEELCHAIR = 'WHEELCHAIR';
16928
- var POLICY_SCHEDULING_DEFAULT = (_a$9 = {},
16929
- _a$9[POLICY_TYPE_SCHEDULING] = {
16849
+ var POLICY_SCHEDULING_DEFAULT = (_a$a = {},
16850
+ _a$a[POLICY_TYPE_SCHEDULING] = {
16930
16851
  allowModificationWhenMatchUpsScheduled: {
16931
16852
  courts: false,
16932
16853
  venues: false,
@@ -17100,12 +17021,103 @@ var POLICY_SCHEDULING_DEFAULT = (_a$9 = {},
17100
17021
  ],
17101
17022
  matchUpDailyLimits: [],
17102
17023
  },
17024
+ _a$a);
17025
+
17026
+ var _a$9;
17027
+ var POLICY_PRIVACY_DEFAULT = (_a$9 = {},
17028
+ _a$9[POLICY_TYPE_PARTICIPANT] = {
17029
+ policyName: 'Participant Privacy Policy',
17030
+ participant: {
17031
+ contacts: false,
17032
+ individualParticipants: {
17033
+ onlineResources: false,
17034
+ participantName: true,
17035
+ participantOtherName: true,
17036
+ participantId: true,
17037
+ participantRole: true,
17038
+ participantStatus: true,
17039
+ penalties: false,
17040
+ representing: true,
17041
+ participantRoleResponsibilities: false,
17042
+ participantType: true,
17043
+ person: {
17044
+ addresses: false,
17045
+ biographicalInformation: false,
17046
+ birthDate: false,
17047
+ contacts: false,
17048
+ nationalityCode: true,
17049
+ nativeFamilyName: false,
17050
+ nativeGivenName: false,
17051
+ onlineResources: false,
17052
+ otherNames: true,
17053
+ parentOrganisationId: false,
17054
+ passportFamilyName: false,
17055
+ passportGivenName: false,
17056
+ personId: false,
17057
+ personOtherIds: false,
17058
+ previousNames: false,
17059
+ sex: false,
17060
+ standardFamilyName: true,
17061
+ standardGivenName: true,
17062
+ status: false,
17063
+ tennisId: false,
17064
+ wheelchair: true,
17065
+ },
17066
+ },
17067
+ individualParticipantIds: true,
17068
+ onlineResources: false,
17069
+ participantName: true,
17070
+ participantOtherName: true,
17071
+ participantId: true,
17072
+ participantRole: true,
17073
+ participantStatus: true,
17074
+ penalties: false,
17075
+ representing: true,
17076
+ participantRoleResponsibilities: false,
17077
+ participantType: true,
17078
+ person: {
17079
+ addresses: false,
17080
+ biographicalInformation: false,
17081
+ birthDate: false,
17082
+ contacts: false,
17083
+ nationalityCode: true,
17084
+ nativeFamilyName: false,
17085
+ nativeGivenName: false,
17086
+ onlineResources: false,
17087
+ otherNames: true,
17088
+ parentOrganisationId: false,
17089
+ passportFamilyName: false,
17090
+ passportGivenName: false,
17091
+ personId: false,
17092
+ personOtherIds: false,
17093
+ previousNames: false,
17094
+ sex: false,
17095
+ standardFamilyName: true,
17096
+ standardGivenName: true,
17097
+ status: false,
17098
+ tennisId: false,
17099
+ wheelchair: true,
17100
+ },
17101
+ },
17102
+ },
17103
17103
  _a$9);
17104
17104
 
17105
17105
  var _a$8, _b$3;
17106
- var POLICY_SCORING_USTA = (_a$8 = {},
17106
+ /**
17107
+ * without a SCORING_POLICY which sets { requireAllPositionsAssigned: false }, all stage:MAIN, stageSequence:1 drawPositions must be assigned **BEFORE** scoring is enabled,
17108
+ * scoring is enabled in consolation and compass/playoff structures when not all drawPositions have been filled
17109
+ */
17110
+ var POLICY_SCORING_DEFAULT = (_a$8 = {},
17107
17111
  _a$8[POLICY_TYPE_SCORING] = {
17112
+ defaultMatchUpFormat: FORMAT_STANDARD,
17113
+ allowDeletionWithScoresPresent: {
17114
+ drawDefinitions: false,
17115
+ structures: false,
17116
+ },
17108
17117
  requireAllPositionsAssigned: false,
17118
+ processCodes: {
17119
+ incompleteAssignmentsOnDefault: ['RANKING.IGNORE'],
17120
+ },
17109
17121
  stage: (_b$3 = {},
17110
17122
  _b$3[MAIN] = {
17111
17123
  stageSequence: {
@@ -17115,6 +17127,22 @@ var POLICY_SCORING_USTA = (_a$8 = {},
17115
17127
  },
17116
17128
  },
17117
17129
  _b$3),
17130
+ },
17131
+ _a$8);
17132
+
17133
+ var _a$7, _b$2;
17134
+ var POLICY_SCORING_USTA = (_a$7 = {},
17135
+ _a$7[POLICY_TYPE_SCORING] = {
17136
+ requireAllPositionsAssigned: false,
17137
+ stage: (_b$2 = {},
17138
+ _b$2[MAIN] = {
17139
+ stageSequence: {
17140
+ 1: {
17141
+ requireAllPositionsAssigned: true,
17142
+ },
17143
+ },
17144
+ },
17145
+ _b$2),
17118
17146
  defaultMatchUpFormat: FORMAT_STANDARD,
17119
17147
  matchUpFormats: [
17120
17148
  {
@@ -17197,75 +17225,47 @@ var POLICY_SCORING_USTA = (_a$8 = {},
17197
17225
  },
17198
17226
  ],
17199
17227
  },
17200
- _a$8);
17201
-
17202
- var _a$7, _b$2;
17203
- /**
17204
- * without a SCORING_POLICY which sets { requireAllPositionsAssigned: false }, all stage:MAIN, stageSequence:1 drawPositions must be assigned **BEFORE** scoring is enabled,
17205
- * scoring is enabled in consolation and compass/playoff structures when not all drawPositions have been filled
17206
- */
17207
- var POLICY_SCORING_DEFAULT = (_a$7 = {},
17208
- _a$7[POLICY_TYPE_SCORING] = {
17209
- defaultMatchUpFormat: FORMAT_STANDARD,
17210
- allowDeletionWithScoresPresent: {
17211
- drawDefinitions: false,
17212
- structures: false,
17213
- },
17214
- requireAllPositionsAssigned: false,
17215
- processCodes: {
17216
- incompleteAssignmentsOnDefault: ['RANKING.IGNORE'],
17217
- },
17218
- stage: (_b$2 = {},
17219
- _b$2[MAIN] = {
17220
- stageSequence: {
17221
- 1: {
17222
- requireAllPositionsAssigned: true,
17223
- },
17224
- },
17225
- },
17226
- _b$2),
17227
- },
17228
17228
  _a$7);
17229
17229
 
17230
- var _a$6;
17231
- var POLICY_SEEDING_ITF = (_a$6 = {},
17230
+ var _a$6, _b$1;
17231
+ var POLICY_SEEDING_DEFAULT = (_a$6 = {},
17232
17232
  _a$6[POLICY_TYPE_SEEDING] = {
17233
- seedingProfile: { positioning: CLUSTER },
17234
17233
  validSeedPositions: { ignore: true },
17235
17234
  duplicateSeedNumbers: true,
17236
17235
  drawSizeProgression: true,
17237
- policyName: 'ITF SEEDING',
17236
+ seedingProfile: {
17237
+ drawTypes: (_b$1 = {},
17238
+ _b$1[ROUND_ROBIN_WITH_PLAYOFF] = { positioning: WATERFALL },
17239
+ _b$1[ROUND_ROBIN] = { positioning: WATERFALL },
17240
+ _b$1),
17241
+ positioning: SEPARATE,
17242
+ },
17243
+ policyName: 'USTA SEEDING',
17238
17244
  seedsCountThresholds: [
17239
17245
  { drawSize: 4, minimumParticipantCount: 3, seedsCount: 2 },
17240
17246
  { drawSize: 16, minimumParticipantCount: 12, seedsCount: 4 },
17241
17247
  { drawSize: 32, minimumParticipantCount: 24, seedsCount: 8 },
17242
17248
  { drawSize: 64, minimumParticipantCount: 48, seedsCount: 16 },
17243
- { drawSize: 128, minimumParticipantCount: 97, seedsCount: 32 },
17249
+ { drawSize: 128, minimumParticipantCount: 96, seedsCount: 32 },
17244
17250
  { drawSize: 256, minimumParticipantCount: 192, seedsCount: 64 },
17245
17251
  ],
17246
17252
  },
17247
17253
  _a$6);
17248
17254
 
17249
- var _a$5, _b$1;
17250
- var POLICY_SEEDING_USTA = (_a$5 = {},
17255
+ var _a$5;
17256
+ var POLICY_SEEDING_ITF = (_a$5 = {},
17251
17257
  _a$5[POLICY_TYPE_SEEDING] = {
17258
+ seedingProfile: { positioning: CLUSTER },
17252
17259
  validSeedPositions: { ignore: true },
17253
17260
  duplicateSeedNumbers: true,
17254
17261
  drawSizeProgression: true,
17255
- seedingProfile: {
17256
- drawTypes: (_b$1 = {},
17257
- _b$1[ROUND_ROBIN_WITH_PLAYOFF] = { positioning: WATERFALL },
17258
- _b$1[ROUND_ROBIN] = { positioning: WATERFALL },
17259
- _b$1),
17260
- positioning: SEPARATE,
17261
- },
17262
- policyName: 'USTA SEEDING',
17262
+ policyName: 'ITF SEEDING',
17263
17263
  seedsCountThresholds: [
17264
17264
  { drawSize: 4, minimumParticipantCount: 3, seedsCount: 2 },
17265
17265
  { drawSize: 16, minimumParticipantCount: 12, seedsCount: 4 },
17266
17266
  { drawSize: 32, minimumParticipantCount: 24, seedsCount: 8 },
17267
17267
  { drawSize: 64, minimumParticipantCount: 48, seedsCount: 16 },
17268
- { drawSize: 128, minimumParticipantCount: 96, seedsCount: 32 },
17268
+ { drawSize: 128, minimumParticipantCount: 97, seedsCount: 32 },
17269
17269
  { drawSize: 256, minimumParticipantCount: 192, seedsCount: 64 },
17270
17270
  ],
17271
17271
  },
@@ -17283,7 +17283,7 @@ var policies = {
17283
17283
  POLICY_SCORING_DEFAULT: POLICY_SCORING_DEFAULT,
17284
17284
  POLICY_SCORING_USTA: POLICY_SCORING_USTA,
17285
17285
  POLICY_SEEDING_ITF: POLICY_SEEDING_ITF,
17286
- POLICY_SEEDING_USTA: POLICY_SEEDING_USTA,
17286
+ POLICY_SEEDING_DEFAULT: POLICY_SEEDING_DEFAULT,
17287
17287
  };
17288
17288
 
17289
17289
  var fixtures = {
@@ -47074,17 +47074,6 @@ function getUnplacedParticipantIds(_a) {
47074
47074
  return participantIds.filter(function (participantId) { return !assignedParticipantIds.includes(participantId); });
47075
47075
  }
47076
47076
 
47077
- /**
47078
- *
47079
- * @param {string[]} targetParticipantIds - participantIds to be processed
47080
- * @param {string} groupKey - OPTIONAL - specify default grouping
47081
- *
47082
- * @param {boolean=} useSpecifiedGroupKey - defaults to false; use specified group key, if present
47083
- * @param {boolean=} largestFirst - defaults to true; return participantId from groupings with largest number of participantIds
47084
- *
47085
- * Creates groupings of participantIds based on policyAttributes
47086
- * Returns a participantId at random from either the specified group, the largest group, or a randomly selected group
47087
- */
47088
47077
  function getNextParticipantId(_a) {
47089
47078
  var _b;
47090
47079
  var _c = _a.useSpecifiedGroupKey, useSpecifiedGroupKey = _c === void 0 ? false : _c, targetParticipantIds = _a.targetParticipantIds, _d = _a.largestFirst, largestFirst = _d === void 0 ? true : _d, allGroups = _a.allGroups, groupKey = _a.groupKey;
@@ -47456,11 +47445,12 @@ function randomUnseededSeparation(_a) {
47456
47445
  idCollections: idCollections,
47457
47446
  participants: participants,
47458
47447
  });
47448
+ if (allGroups.error) {
47449
+ return decorateResult({ result: allGroups, stack: stack });
47450
+ }
47459
47451
  var participantIdGroups = Object.assign.apply(Object, __spreadArray([{}], __read(unseededParticipantIds.map(function (participantId) {
47460
47452
  var _a;
47461
- var groups = Object.keys(allGroups).filter(function (key) {
47462
- return allGroups[key].includes(participantId);
47463
- });
47453
+ var groups = Object.keys(allGroups).filter(function (key) { var _a; return ((_a = allGroups[key]) !== null && _a !== void 0 ? _a : []).includes(participantId); });
47464
47454
  return _a = {}, _a[participantId] = groups, _a;
47465
47455
  })), false));
47466
47456
  var unplacedParticipantIds = getUnplacedParticipantIds({
@@ -47631,7 +47621,7 @@ function positionUnseededParticipants(_a) {
47631
47621
  drawDefinition: drawDefinition,
47632
47622
  event: event,
47633
47623
  }).appliedPolicies;
47634
- var avoidance = (appliedPolicies !== null && appliedPolicies !== void 0 ? appliedPolicies : {})[POLICY_TYPE_AVOIDANCE];
47624
+ var avoidance = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_AVOIDANCE];
47635
47625
  if (structure.stage === PLAY_OFF) {
47636
47626
  // generate avoidance policies automatically for Playoffs from Round Robin Groups
47637
47627
  var groupings = entries.reduce(function (groupings, entry) {
@@ -53504,7 +53494,7 @@ var matchUpGovernor = {
53504
53494
 
53505
53495
  function attachPolicies(_a) {
53506
53496
  var _b, _c;
53507
- var drawDefinition = _a.drawDefinition, policyDefinitions = _a.policyDefinitions;
53497
+ var policyDefinitions = _a.policyDefinitions, drawDefinition = _a.drawDefinition;
53508
53498
  if (!drawDefinition) {
53509
53499
  return { error: MISSING_DRAW_DEFINITION };
53510
53500
  }
@@ -65011,54 +65001,56 @@ function prepareStage(params) {
65011
65001
  }
65012
65002
 
65013
65003
  function generateDrawDefinition(params) {
65014
- var e_1, _a, e_2, _b, e_3, _c, e_4, _d, _e, e_5, _f, e_6, _g, _h;
65015
- var _j, _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33;
65004
+ var _a, e_1, _b, e_2, _c, e_3, _d, e_4, _e, _f, e_5, _g, e_6, _h, _j;
65005
+ var _k, _l, _m, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y, _z, _0, _1, _2, _3, _4, _5, _6, _7, _8, _9, _10, _11, _12, _13, _14, _15, _16, _17, _18, _19, _20, _21, _22, _23, _24, _25, _26, _27, _28, _29, _30, _31, _32, _33, _34;
65016
65006
  var stack = 'generateDrawDefinition';
65017
- var _34 = params.considerEventEntries, considerEventEntries = _34 === void 0 ? true : _34, // in the absence of drawSize and drawEntries, look to event.entries
65007
+ var _35 = params.considerEventEntries, considerEventEntries = _35 === void 0 ? true : _35, // in the absence of drawSize and drawEntries, look to event.entries
65018
65008
  ignoreAllowedDrawTypes = params.ignoreAllowedDrawTypes, voluntaryConsolation = params.voluntaryConsolation, hydrateCollections = params.hydrateCollections, ignoreStageSpace = params.ignoreStageSpace, tournamentRecord = params.tournamentRecord, qualifyingOnly = params.qualifyingOnly, tieFormatName = params.tieFormatName, drawEntries = params.drawEntries, addToEvent = params.addToEvent, placeByes = params.placeByes, event = params.event;
65019
- var appliedPolicies = (_j = getAppliedPolicies({
65009
+ var appliedPolicies = (_k = getAppliedPolicies({
65020
65010
  tournamentRecord: tournamentRecord,
65021
65011
  event: event,
65022
- }).appliedPolicies) !== null && _j !== void 0 ? _j : {};
65023
- var policyDefinitions = makeDeepCopy((_k = params.policyDefinitions) !== null && _k !== void 0 ? _k : {}, false, true);
65024
- var drawTypeCoercion = (_q = (_o = (_l = params.drawTypeCoercion) !== null && _l !== void 0 ? _l : (_m = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_DRAWS]) === null || _m === void 0 ? void 0 : _m.drawTypeCoercion) !== null && _o !== void 0 ? _o : (_p = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_DRAWS]) === null || _p === void 0 ? void 0 : _p.drawTypeCoercion) !== null && _q !== void 0 ? _q : true;
65012
+ }).appliedPolicies) !== null && _k !== void 0 ? _k : {};
65013
+ var policyDefinitions = makeDeepCopy((_l = params.policyDefinitions) !== null && _l !== void 0 ? _l : {}, false, true);
65014
+ var drawTypeCoercion = (_r = (_p = (_m = params.drawTypeCoercion) !== null && _m !== void 0 ? _m : (_o = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_DRAWS]) === null || _o === void 0 ? void 0 : _o.drawTypeCoercion) !== null && _p !== void 0 ? _p : (_q = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_DRAWS]) === null || _q === void 0 ? void 0 : _q.drawTypeCoercion) !== null && _r !== void 0 ? _r : true;
65025
65015
  var drawType = (drawTypeCoercion &&
65026
65016
  params.drawSize === 2 &&
65027
65017
  DrawTypeEnum.SingleElimination) ||
65028
65018
  params.drawType ||
65029
65019
  DrawTypeEnum.SingleElimination;
65030
- var seedingPolicy = (_r = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING]) !== null && _r !== void 0 ? _r : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING];
65031
- var seedingProfile = (_v = (_s = params.seedingProfile) !== null && _s !== void 0 ? _s : (_u = (_t = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _t === void 0 ? void 0 : _t.drawTypes) === null || _u === void 0 ? void 0 : _u[drawType]) !== null && _v !== void 0 ? _v : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
65020
+ var seedingPolicy = (_s = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_SEEDING]) !== null && _s !== void 0 ? _s : appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_SEEDING];
65021
+ var seedingProfile = (_w = (_t = params.seedingProfile) !== null && _t !== void 0 ? _t : (_v = (_u = seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile) === null || _u === void 0 ? void 0 : _u.drawTypes) === null || _v === void 0 ? void 0 : _v[drawType]) !== null && _w !== void 0 ? _w : seedingPolicy === null || seedingPolicy === void 0 ? void 0 : seedingPolicy.seedingProfile;
65032
65022
  // extend policyDefinitions only if a seedingProfile was specified in params
65033
65023
  if (params.seedingProfile) {
65034
65024
  if (!policyDefinitions[POLICY_TYPE_SEEDING]) {
65035
- policyDefinitions[POLICY_TYPE_SEEDING] = __assign({}, POLICY_SEEDING_USTA[POLICY_TYPE_SEEDING]);
65025
+ policyDefinitions[POLICY_TYPE_SEEDING] = __assign({}, POLICY_SEEDING_DEFAULT[POLICY_TYPE_SEEDING]);
65036
65026
  }
65037
65027
  policyDefinitions[POLICY_TYPE_SEEDING].seedingProfile = seedingProfile;
65038
65028
  }
65039
65029
  // get participants both for entry validation and for automated placement
65040
65030
  // automated placement requires them to be "inContext" for avoidance policies to work
65041
- var _35 = getParticipants$1({
65031
+ var _36 = getParticipants$1({
65042
65032
  withIndividualParticipants: true,
65033
+ convertExtensions: true,
65034
+ internalUse: true,
65043
65035
  tournamentRecord: tournamentRecord,
65044
- }), participants = _35.participants, participantMap = _35.participantMap;
65045
- var enforceGender = (_z = (_w = params.enforceGender) !== null && _w !== void 0 ? _w : (_y = (_x = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _x === void 0 ? void 0 : _x.participants) === null || _y === void 0 ? void 0 : _y.enforceGender) !== null && _z !== void 0 ? _z : (_1 = (_0 = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _0 === void 0 ? void 0 : _0.participants) === null || _1 === void 0 ? void 0 : _1.enforceGender;
65036
+ }), participants = _36.participants, participantMap = _36.participantMap;
65037
+ var enforceGender = (_0 = (_x = params.enforceGender) !== null && _x !== void 0 ? _x : (_z = (_y = policyDefinitions === null || policyDefinitions === void 0 ? void 0 : policyDefinitions[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _y === void 0 ? void 0 : _y.participants) === null || _z === void 0 ? void 0 : _z.enforceGender) !== null && _0 !== void 0 ? _0 : (_2 = (_1 = appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[POLICY_TYPE_MATCHUP_ACTIONS]) === null || _1 === void 0 ? void 0 : _1.participants) === null || _2 === void 0 ? void 0 : _2.enforceGender;
65046
65038
  // if tournamentRecord is provided, and unless instructed to ignore valid types,
65047
65039
  // check for restrictions on allowed drawTypes
65048
65040
  var allowedDrawTypes = !ignoreAllowedDrawTypes &&
65049
65041
  tournamentRecord &&
65050
65042
  getAllowedDrawTypes({
65051
65043
  tournamentRecord: tournamentRecord,
65052
- categoryType: (_2 = event === null || event === void 0 ? void 0 : event.category) === null || _2 === void 0 ? void 0 : _2.categoryType,
65053
- categoryName: (_3 = event === null || event === void 0 ? void 0 : event.category) === null || _3 === void 0 ? void 0 : _3.categoryName,
65044
+ categoryType: (_3 = event === null || event === void 0 ? void 0 : event.category) === null || _3 === void 0 ? void 0 : _3.categoryType,
65045
+ categoryName: (_4 = event === null || event === void 0 ? void 0 : event.category) === null || _4 === void 0 ? void 0 : _4.categoryName,
65054
65046
  });
65055
65047
  if ((allowedDrawTypes === null || allowedDrawTypes === void 0 ? void 0 : allowedDrawTypes.length) && !allowedDrawTypes.includes(drawType)) {
65056
65048
  return decorateResult({ result: { error: INVALID_DRAW_TYPE }, stack: stack });
65057
65049
  }
65058
- var eventEntries = (_5 = (_4 = event === null || event === void 0 ? void 0 : event.entries) === null || _4 === void 0 ? void 0 : _4.filter(function (entry) {
65050
+ var eventEntries = (_6 = (_5 = event === null || event === void 0 ? void 0 : event.entries) === null || _5 === void 0 ? void 0 : _5.filter(function (entry) {
65059
65051
  return entry.entryStatus &&
65060
65052
  __spreadArray(__spreadArray([], __read(STRUCTURE_ENTERED_TYPES), false), [QUALIFIER], false).includes(entry.entryStatus);
65061
- })) !== null && _5 !== void 0 ? _5 : [];
65053
+ })) !== null && _6 !== void 0 ? _6 : [];
65062
65054
  var consideredEntries = ((qualifyingOnly && []) ||
65063
65055
  drawEntries ||
65064
65056
  (considerEventEntries ? eventEntries : [])).filter(function (_a) {
@@ -65102,12 +65094,12 @@ function generateDrawDefinition(params) {
65102
65094
  });
65103
65095
  }
65104
65096
  var seedsCount = typeof params.seedsCount !== 'number'
65105
- ? ensureInt((_6 = params.seedsCount) !== null && _6 !== void 0 ? _6 : 0)
65106
- : (_7 = params.seedsCount) !== null && _7 !== void 0 ? _7 : 0;
65097
+ ? ensureInt((_7 = params.seedsCount) !== null && _7 !== void 0 ? _7 : 0)
65098
+ : (_8 = params.seedsCount) !== null && _8 !== void 0 ? _8 : 0;
65107
65099
  var eventType = event === null || event === void 0 ? void 0 : event.eventType;
65108
- var matchUpType = (_8 = params.matchUpType) !== null && _8 !== void 0 ? _8 : eventType;
65100
+ var matchUpType = (_9 = params.matchUpType) !== null && _9 !== void 0 ? _9 : eventType;
65109
65101
  var existingDrawDefinition = params.drawId
65110
- ? (_9 = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _9 === void 0 ? void 0 : _9.find(function (d) { return d.drawId === params.drawId; })
65102
+ ? (_10 = event === null || event === void 0 ? void 0 : event.drawDefinitions) === null || _10 === void 0 ? void 0 : _10.find(function (d) { return d.drawId === params.drawId; })
65111
65103
  : undefined;
65112
65104
  // drawDefinition cannot have both tieFormat and matchUpFormat
65113
65105
  var tieFormat = params.tieFormat, matchUpFormat = params.matchUpFormat;
@@ -65115,16 +65107,16 @@ function generateDrawDefinition(params) {
65115
65107
  if (matchUpType === TEAM$2 && eventType === TEAM$2) {
65116
65108
  // if there is an existingDrawDefinition which has a tieFormat on MAIN structure
65117
65109
  // use this tieFormat ONLY when no tieFormat is specified in params
65118
- var existingMainTieFormat = (_11 = (_10 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _10 === void 0 ? void 0 : _10.find(function (_a) {
65110
+ var existingMainTieFormat = (_12 = (_11 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _11 === void 0 ? void 0 : _11.find(function (_a) {
65119
65111
  var stage = _a.stage;
65120
65112
  return stage === MAIN;
65121
- })) === null || _11 === void 0 ? void 0 : _11.tieFormat;
65113
+ })) === null || _12 === void 0 ? void 0 : _12.tieFormat;
65122
65114
  tieFormat =
65123
65115
  tieFormat ||
65124
65116
  existingMainTieFormat ||
65125
65117
  // if tieFormatName is provided and it matches the name of the tieFormat attached to parent event...
65126
65118
  (tieFormatName &&
65127
- ((_12 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _12 === void 0 ? void 0 : _12.tieFormatName) === tieFormatName &&
65119
+ ((_13 = event === null || event === void 0 ? void 0 : event.tieFormat) === null || _13 === void 0 ? void 0 : _13.tieFormatName) === tieFormatName &&
65128
65120
  event.tieFormat) ||
65129
65121
  // if the tieFormatName is not found in the factory then will use default
65130
65122
  (tieFormatName &&
@@ -65180,7 +65172,7 @@ function generateDrawDefinition(params) {
65180
65172
  var result = checkTieFormat({ tieFormat: tieFormat });
65181
65173
  if (result.error)
65182
65174
  return decorateResult({ result: result, stack: stack });
65183
- drawDefinition.tieFormat = (_13 = result.tieFormat) !== null && _13 !== void 0 ? _13 : tieFormat;
65175
+ drawDefinition.tieFormat = (_14 = result.tieFormat) !== null && _14 !== void 0 ? _14 : tieFormat;
65184
65176
  }
65185
65177
  else if (matchUpFormat) {
65186
65178
  var result = setMatchUpFormat$1({
@@ -65200,6 +65192,12 @@ function generateDrawDefinition(params) {
65200
65192
  drawDefinition.matchUpType = matchUpType;
65201
65193
  }
65202
65194
  }
65195
+ // ---------------------------------------------------------------------------
65196
+ // Attach policies to the drawDefinition
65197
+ // if there is an avoidance policy on the event, it must be preserved in the drawDefinition
65198
+ // if there is an avoidance policy in policyDefinitions, it will override
65199
+ // avoidance policies on the event can be changed (if location used for UI)
65200
+ var policiesToAttach = __assign((_a = {}, _a[POLICY_TYPE_AVOIDANCE] = appliedPolicies[POLICY_TYPE_AVOIDANCE], _a), POLICY_SEEDING_DEFAULT);
65203
65201
  if (policyDefinitions) {
65204
65202
  if (typeof policyDefinitions !== 'object') {
65205
65203
  return decorateResult({
@@ -65209,10 +65207,9 @@ function generateDrawDefinition(params) {
65209
65207
  });
65210
65208
  }
65211
65209
  else {
65212
- var policiesToAttach = {};
65213
65210
  try {
65214
- for (var _36 = __values(Object.keys(policyDefinitions)), _37 = _36.next(); !_37.done; _37 = _36.next()) {
65215
- var key = _37.value;
65211
+ for (var _37 = __values(Object.keys(policyDefinitions)), _38 = _37.next(); !_38.done; _38 = _37.next()) {
65212
+ var key = _38.value;
65216
65213
  if (JSON.stringify(appliedPolicies === null || appliedPolicies === void 0 ? void 0 : appliedPolicies[key]) !==
65217
65214
  JSON.stringify(policyDefinitions[key])) {
65218
65215
  policiesToAttach[key] = policyDefinitions[key];
@@ -65222,7 +65219,7 @@ function generateDrawDefinition(params) {
65222
65219
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
65223
65220
  finally {
65224
65221
  try {
65225
- if (_37 && !_37.done && (_a = _36.return)) _a.call(_36);
65222
+ if (_38 && !_38.done && (_b = _37.return)) _b.call(_37);
65226
65223
  }
65227
65224
  finally { if (e_1) throw e_1.error; }
65228
65225
  }
@@ -65233,25 +65230,28 @@ function generateDrawDefinition(params) {
65233
65230
  }
65234
65231
  }
65235
65232
  }
65233
+ else if (policiesToAttach.avoidance) {
65234
+ attachPolicies({ drawDefinition: drawDefinition, policyDefinitions: policiesToAttach });
65235
+ }
65236
65236
  if (!appliedPolicies[POLICY_TYPE_SEEDING] &&
65237
65237
  !policyDefinitions[POLICY_TYPE_SEEDING]) {
65238
- attachPolicies({ drawDefinition: drawDefinition, policyDefinitions: POLICY_SEEDING_USTA });
65239
- Object.assign(appliedPolicies, POLICY_SEEDING_USTA);
65238
+ Object.assign(appliedPolicies, POLICY_SEEDING_DEFAULT);
65240
65239
  }
65240
+ // ---------------------------------------------------------------------------
65241
65241
  // find existing MAIN structureId if existingDrawDefinition
65242
- var structureId = (_15 = (_14 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _14 === void 0 ? void 0 : _14.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _15 === void 0 ? void 0 : _15.structureId;
65242
+ var structureId = (_16 = (_15 = existingDrawDefinition === null || existingDrawDefinition === void 0 ? void 0 : existingDrawDefinition.structures) === null || _15 === void 0 ? void 0 : _15.find(function (structure) { return structure.stage === MAIN && structure.stageSequence === 1; })) === null || _16 === void 0 ? void 0 : _16.structureId;
65243
65243
  var entries = drawEntries !== null && drawEntries !== void 0 ? drawEntries : eventEntries;
65244
65244
  var positioningReports = [];
65245
65245
  var drawTypeResult;
65246
65246
  var conflicts = [];
65247
65247
  var generateQualifyingPlaceholder = params.qualifyingPlaceholder &&
65248
- !((_16 = params.qualifyingProfiles) === null || _16 === void 0 ? void 0 : _16.length) &&
65248
+ !((_17 = params.qualifyingProfiles) === null || _17 === void 0 ? void 0 : _17.length) &&
65249
65249
  !existingDrawDefinition;
65250
65250
  var existingQualifyingStructures = existingDrawDefinition
65251
- ? (_17 = existingDrawDefinition.structures) === null || _17 === void 0 ? void 0 : _17.filter(function (structure) { return structure.stage === QUALIFYING; })
65251
+ ? (_18 = existingDrawDefinition.structures) === null || _18 === void 0 ? void 0 : _18.filter(function (structure) { return structure.stage === QUALIFYING; })
65252
65252
  : [];
65253
65253
  var existingQualifyingPlaceholderStructureId = (existingQualifyingStructures === null || existingQualifyingStructures === void 0 ? void 0 : existingQualifyingStructures.length) === 1 &&
65254
- !((_18 = existingQualifyingStructures[0].matchUps) === null || _18 === void 0 ? void 0 : _18.length) &&
65254
+ !((_19 = existingQualifyingStructures[0].matchUps) === null || _19 === void 0 ? void 0 : _19.length) &&
65255
65255
  existingQualifyingStructures[0].structureId;
65256
65256
  if (existingQualifyingPlaceholderStructureId) {
65257
65257
  var qualifyingProfiles = params.qualifyingProfiles;
@@ -65267,24 +65267,24 @@ function generateDrawDefinition(params) {
65267
65267
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.error) {
65268
65268
  return qualifyingResult;
65269
65269
  }
65270
- drawDefinition.structures = (_19 = drawDefinition.structures) === null || _19 === void 0 ? void 0 : _19.filter(function (_a) {
65270
+ drawDefinition.structures = (_20 = drawDefinition.structures) === null || _20 === void 0 ? void 0 : _20.filter(function (_a) {
65271
65271
  var structureId = _a.structureId;
65272
65272
  return structureId !== existingQualifyingPlaceholderStructureId;
65273
65273
  });
65274
- drawDefinition.links = (_20 = drawDefinition.links) === null || _20 === void 0 ? void 0 : _20.filter(function (_a) {
65274
+ drawDefinition.links = (_21 = drawDefinition.links) === null || _21 === void 0 ? void 0 : _21.filter(function (_a) {
65275
65275
  var source = _a.source;
65276
65276
  return source.structureId !== existingQualifyingPlaceholderStructureId;
65277
65277
  });
65278
- var _38 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _38.qualifiersCount, qualifyingDrawPositionsCount = _38.qualifyingDrawPositionsCount, qualifyingDetails = _38.qualifyingDetails;
65278
+ var _39 = qualifyingResult !== null && qualifyingResult !== void 0 ? qualifyingResult : {}, qualifiersCount = _39.qualifiersCount, qualifyingDrawPositionsCount = _39.qualifyingDrawPositionsCount, qualifyingDetails = _39.qualifyingDetails;
65279
65279
  if (qualifyingDrawPositionsCount) {
65280
65280
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.structures) {
65281
- (_21 = drawDefinition.structures) === null || _21 === void 0 ? void 0 : _21.push.apply(_21, __spreadArray([], __read(qualifyingResult.structures), false));
65281
+ (_22 = drawDefinition.structures) === null || _22 === void 0 ? void 0 : _22.push.apply(_22, __spreadArray([], __read(qualifyingResult.structures), false));
65282
65282
  }
65283
65283
  if (qualifyingResult === null || qualifyingResult === void 0 ? void 0 : qualifyingResult.links) {
65284
- (_22 = drawDefinition.links) === null || _22 === void 0 ? void 0 : _22.push.apply(_22, __spreadArray([], __read(qualifyingResult.links), false));
65284
+ (_23 = drawDefinition.links) === null || _23 === void 0 ? void 0 : _23.push.apply(_23, __spreadArray([], __read(qualifyingResult.links), false));
65285
65285
  }
65286
65286
  }
65287
- var mainStructure = (_23 = drawDefinition.structures) === null || _23 === void 0 ? void 0 : _23.find(function (_a) {
65287
+ var mainStructure = (_24 = drawDefinition.structures) === null || _24 === void 0 ? void 0 : _24.find(function (_a) {
65288
65288
  var stage = _a.stage, stageSequence = _a.stageSequence;
65289
65289
  return stage === MAIN && stageSequence === 1;
65290
65290
  });
@@ -65310,12 +65310,12 @@ function generateDrawDefinition(params) {
65310
65310
  if (result.error)
65311
65311
  return result;
65312
65312
  try {
65313
- for (var _39 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
65313
+ for (var _40 = __values((drawEntries !== null && drawEntries !== void 0 ? drawEntries : []).filter(function (_a) {
65314
65314
  var entryStage = _a.entryStage;
65315
65315
  return entryStage === StageTypeEnum.Qualifying;
65316
- })), _40 = _39.next(); !_40.done; _40 = _39.next()) {
65317
- var entry = _40.value;
65318
- var entryData = __assign(__assign({}, entry), { entryStage: (_24 = entry.entryStage) !== null && _24 !== void 0 ? _24 : StageTypeEnum.Main, drawDefinition: drawDefinition });
65316
+ })), _41 = _40.next(); !_41.done; _41 = _40.next()) {
65317
+ var entry = _41.value;
65318
+ var entryData = __assign(__assign({}, entry), { entryStage: (_25 = entry.entryStage) !== null && _25 !== void 0 ? _25 : StageTypeEnum.Main, drawDefinition: drawDefinition });
65319
65319
  // ignore errors (EXITING_PARTICIPANT)
65320
65320
  addDrawEntry(entryData);
65321
65321
  }
@@ -65323,23 +65323,23 @@ function generateDrawDefinition(params) {
65323
65323
  catch (e_2_1) { e_2 = { error: e_2_1 }; }
65324
65324
  finally {
65325
65325
  try {
65326
- if (_40 && !_40.done && (_b = _39.return)) _b.call(_39);
65326
+ if (_41 && !_41.done && (_c = _40.return)) _c.call(_40);
65327
65327
  }
65328
65328
  finally { if (e_2) throw e_2.error; }
65329
65329
  }
65330
65330
  try {
65331
- for (var _41 = __values(qualifyingDetails || []), _42 = _41.next(); !_42.done; _42 = _41.next()) {
65332
- var qualifyingDetail = _42.value;
65331
+ for (var _42 = __values(qualifyingDetails || []), _43 = _42.next(); !_43.done; _43 = _42.next()) {
65332
+ var qualifyingDetail = _43.value;
65333
65333
  var qualifyingRoundNumber = qualifyingDetail.finalQualifyingRoundNumber, qualifyingStructureId = qualifyingDetail.finalQualifyingStructureId, targetEntryRound = qualifyingDetail.roundTarget, finishingPositions = qualifyingDetail.finishingPositions, linkType = qualifyingDetail.linkType;
65334
65334
  var link = mainStructure &&
65335
- ((_25 = generateQualifyingLink({
65335
+ ((_26 = generateQualifyingLink({
65336
65336
  targetStructureId: mainStructure.structureId,
65337
65337
  sourceStructureId: qualifyingStructureId,
65338
65338
  sourceRoundNumber: qualifyingRoundNumber,
65339
65339
  finishingPositions: finishingPositions,
65340
65340
  targetEntryRound: targetEntryRound,
65341
65341
  linkType: linkType,
65342
- })) === null || _25 === void 0 ? void 0 : _25.link);
65342
+ })) === null || _26 === void 0 ? void 0 : _26.link);
65343
65343
  if (link === null || link === void 0 ? void 0 : link.error)
65344
65344
  return link;
65345
65345
  if (link) {
@@ -65352,7 +65352,7 @@ function generateDrawDefinition(params) {
65352
65352
  catch (e_3_1) { e_3 = { error: e_3_1 }; }
65353
65353
  finally {
65354
65354
  try {
65355
- if (_42 && !_42.done && (_c = _41.return)) _c.call(_41);
65355
+ if (_43 && !_43.done && (_d = _42.return)) _d.call(_42);
65356
65356
  }
65357
65357
  finally { if (e_3) throw e_3.error; }
65358
65358
  }
@@ -65373,7 +65373,7 @@ function generateDrawDefinition(params) {
65373
65373
  entry.entryStage &&
65374
65374
  entry.entryStage !== StageTypeEnum.Main)
65375
65375
  continue;
65376
- var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_26 = entry.entryStage) !== null && _26 !== void 0 ? _26 : StageTypeEnum.Main, drawDefinition: drawDefinition, drawType: drawType });
65376
+ var entryData = __assign(__assign({}, entry), { ignoreStageSpace: ignoreStageSpace !== null && ignoreStageSpace !== void 0 ? ignoreStageSpace : drawType === AD_HOC, entryStage: (_27 = entry.entryStage) !== null && _27 !== void 0 ? _27 : StageTypeEnum.Main, drawDefinition: drawDefinition, drawType: drawType });
65377
65377
  var result = addDrawEntry(entryData);
65378
65378
  if (drawEntries && result.error) {
65379
65379
  // only report errors with drawEntries
@@ -65385,7 +65385,7 @@ function generateDrawDefinition(params) {
65385
65385
  catch (e_4_1) { e_4 = { error: e_4_1 }; }
65386
65386
  finally {
65387
65387
  try {
65388
- if (entries_1_1 && !entries_1_1.done && (_d = entries_1.return)) _d.call(entries_1);
65388
+ if (entries_1_1 && !entries_1_1.done && (_e = entries_1.return)) _e.call(entries_1);
65389
65389
  }
65390
65390
  finally { if (e_4) throw e_4.error; }
65391
65391
  }
@@ -65397,13 +65397,13 @@ function generateDrawDefinition(params) {
65397
65397
  if (structureResult.error && !structureResult.conflicts) {
65398
65398
  return structureResult;
65399
65399
  }
65400
- if ((_27 = structureResult.positioningReport) === null || _27 === void 0 ? void 0 : _27.length)
65401
- positioningReports.push((_e = {}, _e[MAIN] = structureResult.positioningReport, _e));
65400
+ if ((_28 = structureResult.positioningReport) === null || _28 === void 0 ? void 0 : _28.length)
65401
+ positioningReports.push((_f = {}, _f[MAIN] = structureResult.positioningReport, _f));
65402
65402
  structureId = structureResult.structureId;
65403
65403
  if (structureResult.conflicts)
65404
65404
  conflicts = structureResult.conflicts;
65405
65405
  if (drawType === AD_HOC && params.roundsCount) {
65406
- var entries_2 = (_28 = event === null || event === void 0 ? void 0 : event.entries) === null || _28 === void 0 ? void 0 : _28.filter(function (_a) {
65406
+ var entries_2 = (_29 = event === null || event === void 0 ? void 0 : event.entries) === null || _29 === void 0 ? void 0 : _29.filter(function (_a) {
65407
65407
  var entryStage = _a.entryStage, entryStatus = _a.entryStatus;
65408
65408
  return (!entryStage || entryStage === MAIN) &&
65409
65409
  entryStatus &&
@@ -65450,8 +65450,8 @@ function generateDrawDefinition(params) {
65450
65450
  var roundTarget = 1;
65451
65451
  params.qualifyingProfiles.sort(roundTargetSort);
65452
65452
  try {
65453
- for (var _43 = __values(params.qualifyingProfiles), _44 = _43.next(); !_44.done; _44 = _43.next()) {
65454
- var roundTargetProfile = _44.value;
65453
+ for (var _44 = __values(params.qualifyingProfiles), _45 = _44.next(); !_45.done; _45 = _44.next()) {
65454
+ var roundTargetProfile = _45.value;
65455
65455
  if (!Array.isArray(roundTargetProfile.structureProfiles))
65456
65456
  return decorateResult({
65457
65457
  info: mustBeAnArray('structureProfiles'),
@@ -65459,13 +65459,13 @@ function generateDrawDefinition(params) {
65459
65459
  stack: stack,
65460
65460
  });
65461
65461
  roundTarget = roundTargetProfile.roundTarget || roundTarget;
65462
- var sortedStructureProfiles = ((_29 = roundTargetProfile.structureProfiles) === null || _29 === void 0 ? void 0 : _29.sort(sequenceSort)) || [];
65462
+ var sortedStructureProfiles = ((_30 = roundTargetProfile.structureProfiles) === null || _30 === void 0 ? void 0 : _30.sort(sequenceSort)) || [];
65463
65463
  var sequence = 1;
65464
65464
  try {
65465
65465
  for (var sortedStructureProfiles_1 = (e_6 = void 0, __values(sortedStructureProfiles)), sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next(); !sortedStructureProfiles_1_1.done; sortedStructureProfiles_1_1 = sortedStructureProfiles_1.next()) {
65466
65466
  var structureProfile = sortedStructureProfiles_1_1.value;
65467
- var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _45 = structureProfile.seedsCount, seedsCount_1 = _45 === void 0 ? 0 : _45, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
65468
- var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_30 = structureProfile.seedingProfile) !== null && _30 !== void 0 ? _30 : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
65467
+ var qualifyingRoundNumber = structureProfile.qualifyingRoundNumber, qualifyingPositions = structureProfile.qualifyingPositions, seededParticipants = structureProfile.seededParticipants, seedingScaleName = structureProfile.seedingScaleName, _46 = structureProfile.seedsCount, seedsCount_1 = _46 === void 0 ? 0 : _46, seedByRanking = structureProfile.seedByRanking, placeByes_1 = structureProfile.placeByes, drawSize_1 = structureProfile.drawSize;
65468
+ var qualifyingStageResult = prepareStage(__assign(__assign(__assign({}, drawTypeResult), params), { seedingProfile: (_31 = structureProfile.seedingProfile) !== null && _31 !== void 0 ? _31 : seedingProfile, stageSequence: sequence, qualifyingRoundNumber: qualifyingRoundNumber, preparedStructureIds: preparedStructureIds, qualifyingPositions: qualifyingPositions, seededParticipants: seededParticipants, stage: QUALIFYING, seedingScaleName: seedingScaleName, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, qualifyingOnly: qualifyingOnly, seedByRanking: seedByRanking, participants: participants, roundTarget: roundTarget, seedsCount: seedsCount_1, placeByes: placeByes_1, drawSize: drawSize_1, entries: entries }));
65469
65469
  if (qualifyingStageResult.error) {
65470
65470
  return qualifyingStageResult;
65471
65471
  }
@@ -65473,18 +65473,18 @@ function generateDrawDefinition(params) {
65473
65473
  preparedStructureIds.push(qualifyingStageResult.structureId);
65474
65474
  }
65475
65475
  sequence += 1;
65476
- if ((_31 = qualifyingStageResult.conflicts) === null || _31 === void 0 ? void 0 : _31.length)
65476
+ if ((_32 = qualifyingStageResult.conflicts) === null || _32 === void 0 ? void 0 : _32.length)
65477
65477
  qualifyingConflicts.push.apply(qualifyingConflicts, __spreadArray([], __read(qualifyingStageResult.conflicts), false));
65478
- if ((_32 = qualifyingStageResult.positioningReport) === null || _32 === void 0 ? void 0 : _32.length)
65479
- positioningReports.push((_h = {},
65480
- _h[QUALIFYING] = qualifyingStageResult.positioningReport,
65481
- _h));
65478
+ if ((_33 = qualifyingStageResult.positioningReport) === null || _33 === void 0 ? void 0 : _33.length)
65479
+ positioningReports.push((_j = {},
65480
+ _j[QUALIFYING] = qualifyingStageResult.positioningReport,
65481
+ _j));
65482
65482
  }
65483
65483
  }
65484
65484
  catch (e_6_1) { e_6 = { error: e_6_1 }; }
65485
65485
  finally {
65486
65486
  try {
65487
- if (sortedStructureProfiles_1_1 && !sortedStructureProfiles_1_1.done && (_g = sortedStructureProfiles_1.return)) _g.call(sortedStructureProfiles_1);
65487
+ if (sortedStructureProfiles_1_1 && !sortedStructureProfiles_1_1.done && (_h = sortedStructureProfiles_1.return)) _h.call(sortedStructureProfiles_1);
65488
65488
  }
65489
65489
  finally { if (e_6) throw e_6.error; }
65490
65490
  }
@@ -65494,7 +65494,7 @@ function generateDrawDefinition(params) {
65494
65494
  catch (e_5_1) { e_5 = { error: e_5_1 }; }
65495
65495
  finally {
65496
65496
  try {
65497
- if (_44 && !_44.done && (_f = _43.return)) _f.call(_43);
65497
+ if (_45 && !_45.done && (_g = _44.return)) _g.call(_44);
65498
65498
  }
65499
65499
  finally { if (e_5) throw e_5.error; }
65500
65500
  }
@@ -65518,7 +65518,7 @@ function generateDrawDefinition(params) {
65518
65518
  drawDefinition.links.push(link);
65519
65519
  }
65520
65520
  drawDefinition.drawName =
65521
- (_33 = params.drawName) !== null && _33 !== void 0 ? _33 : (drawType && constantToString(drawType));
65521
+ (_34 = params.drawName) !== null && _34 !== void 0 ? _34 : (drawType && constantToString(drawType));
65522
65522
  if (typeof voluntaryConsolation === 'object' && drawSize >= 4) {
65523
65523
  addVoluntaryConsolationStructure(__assign(__assign({}, voluntaryConsolation), { tournamentRecord: tournamentRecord, appliedPolicies: appliedPolicies, drawDefinition: drawDefinition, matchUpType: matchUpType }));
65524
65524
  }