tods-competition-factory 1.8.46 → 1.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1980,7 +1980,22 @@ function isString(obj) {
1980
1980
  return typeof obj === "string";
1981
1981
  }
1982
1982
  function isObject(obj) {
1983
- return typeof obj === "object";
1983
+ return obj !== null && typeof obj === "object";
1984
+ }
1985
+ function objShallowEqual(o1, o2) {
1986
+ if (!isObject(o1) || !isObject(o2))
1987
+ return false;
1988
+ const keys1 = Object.keys(o1);
1989
+ const keys2 = Object.keys(o2);
1990
+ if (keys1.length !== keys2.length) {
1991
+ return false;
1992
+ }
1993
+ for (const key of keys1) {
1994
+ if (o1[key] !== o2[key]) {
1995
+ return false;
1996
+ }
1997
+ }
1998
+ return true;
1984
1999
  }
1985
2000
  function createMap(objectArray, attribute) {
1986
2001
  if (!Array.isArray(objectArray))
@@ -2000,6 +2015,11 @@ const extractAttributes = (accessor) => (element) => !accessor || typeof element
2000
2015
  })) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
2001
2016
  [key]: getAccessorValue({ element, accessor: key })?.value
2002
2017
  })) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
2018
+ function getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays) {
2019
+ return Object.keys(obj).filter(
2020
+ (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
2021
+ );
2022
+ }
2003
2023
  function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2004
2024
  if (typeof obj !== "object" || obj === null)
2005
2025
  return obj;
@@ -2009,9 +2029,7 @@ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
2009
2029
  const ignoreValues = ["", void 0, null];
2010
2030
  if (ignoreFalse)
2011
2031
  ignoreValues.push(false);
2012
- const definedKeys = Object.keys(obj).filter(
2013
- (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
2014
- );
2032
+ const definedKeys = getDefinedKeys(obj, ignoreValues, ignoreEmptyArrays);
2015
2033
  return Object.assign(
2016
2034
  {},
2017
2035
  ...definedKeys.map((key) => {
@@ -2404,7 +2422,7 @@ const matchUpFormatCode = {
2404
2422
  };
2405
2423
 
2406
2424
  function factoryVersion() {
2407
- return "1.8.46";
2425
+ return "1.9.1";
2408
2426
  }
2409
2427
 
2410
2428
  function getObjectTieFormat(obj) {
@@ -2490,34 +2508,6 @@ function decorateResult({
2490
2508
  return result ?? { success: true };
2491
2509
  }
2492
2510
 
2493
- const ANY = "ANY";
2494
- const MALE = "MALE";
2495
- const MIXED = "MIXED";
2496
- const OTHER$3 = "OTHER";
2497
- const FEMALE = "FEMALE";
2498
- const genderConstants = {
2499
- ANY,
2500
- MALE,
2501
- FEMALE,
2502
- MIXED,
2503
- OTHER: OTHER$3
2504
- };
2505
-
2506
- const SINGLES_MATCHUP = "SINGLES";
2507
- const SINGLES$1 = "SINGLES";
2508
- const DOUBLES_MATCHUP = "DOUBLES";
2509
- const DOUBLES$1 = "DOUBLES";
2510
- const TEAM_MATCHUP = "TEAM";
2511
- const TEAM$2 = "TEAM";
2512
- const matchUpTypes = {
2513
- SINGLES_MATCHUP,
2514
- SINGLES: SINGLES$1,
2515
- DOUBLES_MATCHUP,
2516
- DOUBLES: DOUBLES$1,
2517
- TEAM_MATCHUP,
2518
- TEAM: TEAM$2
2519
- };
2520
-
2521
2511
  var DrawTypeEnum = /* @__PURE__ */ ((DrawTypeEnum2) => {
2522
2512
  DrawTypeEnum2["AdHoc"] = "AD_HOC";
2523
2513
  DrawTypeEnum2["Compass"] = "COMPASS";
@@ -2632,6 +2622,19 @@ var ParticipantTypeEnum = /* @__PURE__ */ ((ParticipantTypeEnum2) => {
2632
2622
  return ParticipantTypeEnum2;
2633
2623
  })(ParticipantTypeEnum || {});
2634
2624
 
2625
+ const ANY = "ANY";
2626
+ const MALE = "MALE";
2627
+ const MIXED = "MIXED";
2628
+ const OTHER$3 = "OTHER";
2629
+ const FEMALE = "FEMALE";
2630
+ const genderConstants = {
2631
+ ANY,
2632
+ MALE,
2633
+ FEMALE,
2634
+ MIXED,
2635
+ OTHER: OTHER$3
2636
+ };
2637
+
2635
2638
  const mixedGenderError = "MIXED events can not contain mixed singles or { gender: ANY } collections";
2636
2639
  const anyMixedError = "events with { gender: ANY } can not contain MIXED singles collections";
2637
2640
  function tieFormatGenderValidityCheck(params) {
@@ -2643,8 +2646,7 @@ function tieFormatGenderValidityCheck(params) {
2643
2646
  context: { gender },
2644
2647
  stack
2645
2648
  });
2646
- const eventType = params.eventType ?? params.referenceEvent?.eventType;
2647
- if (referenceGender === MIXED && (eventType !== TEAM$2 || gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
2649
+ if (referenceGender === MIXED && (gender === ANY || gender === MIXED && matchUpType !== TypeEnum.Doubles)) {
2648
2650
  return decorateResult({
2649
2651
  result: { error: INVALID_GENDER, valid: false },
2650
2652
  info: mixedGenderError,
@@ -2932,7 +2934,6 @@ function validateTieFormat(params) {
2932
2934
  const { valid: valid2, errors: collectionDefinitionErrors } = validateCollectionDefinition({
2933
2935
  referenceCategory: params.category,
2934
2936
  referenceGender: params.gender,
2935
- eventType: params.eventType,
2936
2937
  collectionDefinition,
2937
2938
  checkCollectionIds,
2938
2939
  checkCategory,
@@ -2984,7 +2985,6 @@ function validateCollectionDefinition({
2984
2985
  checkGender = true,
2985
2986
  referenceCategory,
2986
2987
  referenceGender,
2987
- eventType,
2988
2988
  event
2989
2989
  }) {
2990
2990
  referenceGender = referenceGender ?? event?.gender;
@@ -3052,7 +3052,6 @@ function validateCollectionDefinition({
3052
3052
  }
3053
3053
  if (checkGender) {
3054
3054
  const result = tieFormatGenderValidityCheck({
3055
- eventType: eventType ?? event?.eventType,
3056
3055
  referenceGender,
3057
3056
  matchUpType,
3058
3057
  gender
@@ -3085,12 +3084,10 @@ function validateCollectionDefinition({
3085
3084
  return { valid: true };
3086
3085
  }
3087
3086
  function checkTieFormat({
3088
- tieFormat,
3089
- eventType
3087
+ tieFormat
3090
3088
  }) {
3091
3089
  const result = validateTieFormat({
3092
3090
  checkCollectionIds: false,
3093
- eventType,
3094
3091
  tieFormat
3095
3092
  });
3096
3093
  if (result.error)
@@ -3503,6 +3500,21 @@ function calculatePercentages({
3503
3500
  });
3504
3501
  }
3505
3502
 
3503
+ const SINGLES_MATCHUP = "SINGLES";
3504
+ const SINGLES$1 = "SINGLES";
3505
+ const DOUBLES_MATCHUP = "DOUBLES";
3506
+ const DOUBLES$1 = "DOUBLES";
3507
+ const TEAM_MATCHUP = "TEAM";
3508
+ const TEAM$2 = "TEAM";
3509
+ const matchUpTypes = {
3510
+ SINGLES_MATCHUP,
3511
+ SINGLES: SINGLES$1,
3512
+ DOUBLES_MATCHUP,
3513
+ DOUBLES: DOUBLES$1,
3514
+ TEAM_MATCHUP,
3515
+ TEAM: TEAM$2
3516
+ };
3517
+
3506
3518
  function getParticipantResults({
3507
3519
  participantIds,
3508
3520
  matchUpFormat,
@@ -4314,6 +4326,7 @@ function tallyParticipantResults({
4314
4326
  return result;
4315
4327
  }
4316
4328
 
4329
+ const ACTIVE_SUSPENSION = "activeSuspension";
4317
4330
  const APPLIED_POLICIES = "appliedPolicies";
4318
4331
  const AUDIT_POSITION_ACTIONS = "positionActions";
4319
4332
  const CONTEXT = "context";
@@ -4325,6 +4338,7 @@ const DRAW_DELETIONS = "drawDeletions";
4325
4338
  const DRAW_PROFILE = "drawProfile";
4326
4339
  const ENTRY_PROFILE = "entryProfile";
4327
4340
  const EVENT_PROFILE = "eventProfile";
4341
+ const EVENT_WITHDRAWAL_REQUESTS = "eventWithdrawalRequests";
4328
4342
  const FACTORY$1 = "factory";
4329
4343
  const FLIGHT_PROFILE = "flightProfile";
4330
4344
  const GROUPING_ATTRIBUTE = "groupingAttribute";
@@ -4343,6 +4357,7 @@ const SUB_ORDER = "subOrder";
4343
4357
  const TALLY = "tally";
4344
4358
  const TIE_FORMAT_MODIFICATIONS = "tieFormatModification";
4345
4359
  const extensionConstants = {
4360
+ ACTIVE_SUSPENSION,
4346
4361
  APPLIED_POLICIES,
4347
4362
  AUDIT_POSITION_ACTIONS,
4348
4363
  CONTEXT,
@@ -4356,6 +4371,7 @@ const extensionConstants = {
4356
4371
  ENTRY_PROFILE,
4357
4372
  // used for drawGeneration; not relevant for anonymized tournaments
4358
4373
  EVENT_PROFILE,
4374
+ EVENT_WITHDRAWAL_REQUESTS,
4359
4375
  FLIGHT_PROFILE,
4360
4376
  GROUPING_ATTRIBUTE,
4361
4377
  // for generating teams; not relevant for anonymized tournaments
@@ -6060,8 +6076,10 @@ function getMatchUpScheduleDetails({
6060
6076
  scheduleVisibilityFilters,
6061
6077
  afterRecoveryTimes,
6062
6078
  tournamentRecord,
6079
+ usePublishState,
6063
6080
  scheduleTiming,
6064
6081
  matchUpFormat,
6082
+ publishStatus,
6065
6083
  matchUpType,
6066
6084
  matchUp,
6067
6085
  event
@@ -6178,15 +6196,36 @@ function getMatchUpScheduleDetails({
6178
6196
  });
6179
6197
  } else {
6180
6198
  schedule = definedAttributes({
6181
- time,
6199
+ milliseconds,
6182
6200
  startTime,
6183
6201
  endTime,
6184
- milliseconds
6202
+ time
6185
6203
  });
6186
6204
  }
6187
- const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
6188
6205
  const { scheduledDate } = scheduledMatchUpDate({ matchUp });
6189
6206
  const { scheduledTime } = scheduledMatchUpTime({ matchUp });
6207
+ if (usePublishState && publishStatus?.displaySettings?.draws) {
6208
+ const drawSettings = publishStatus.displaySettings.draws;
6209
+ const scheduleDetails = (drawSettings?.[matchUp.drawId] ?? drawSettings?.default)?.scheduleDetails;
6210
+ if (scheduleDetails) {
6211
+ const scheduleAttributes = (scheduleDetails.find(
6212
+ (details) => scheduledDate && details.dates?.includes(scheduledDate)
6213
+ ) ?? scheduleDetails.find((details) => !details.dates?.length))?.attributes;
6214
+ if (scheduleAttributes) {
6215
+ const template = Object.assign(
6216
+ {},
6217
+ ...Object.keys(schedule).map((key) => ({ [key]: true })),
6218
+ // overwrite with publishStatus attributes
6219
+ scheduleAttributes
6220
+ );
6221
+ schedule = attributeFilter({
6222
+ source: schedule,
6223
+ template
6224
+ });
6225
+ }
6226
+ }
6227
+ }
6228
+ const hasCompletedStatus = matchUp.matchUpStatus && completedMatchUpStatuses.includes(matchUp.matchUpStatus);
6190
6229
  const endDate = hasCompletedStatus && (extractDate(endTime) || extractDate(scheduledDate) || extractDate(scheduledTime)) || void 0;
6191
6230
  return { schedule, endDate };
6192
6231
  }
@@ -8053,6 +8092,7 @@ function getAllStructureMatchUps({
8053
8092
  policyDefinitions,
8054
8093
  tournamentRecord,
8055
8094
  seedAssignments,
8095
+ usePublishState,
8056
8096
  contextFilters,
8057
8097
  contextContent,
8058
8098
  matchUpFilters,
@@ -8060,6 +8100,7 @@ function getAllStructureMatchUps({
8060
8100
  scheduleTiming,
8061
8101
  contextProfile,
8062
8102
  drawDefinition,
8103
+ publishStatus,
8063
8104
  context = {},
8064
8105
  exitProfiles,
8065
8106
  matchUpsMap,
@@ -8168,6 +8209,8 @@ function getAllStructureMatchUps({
8168
8209
  roundNamingProfile,
8169
8210
  initialRoundOfPlay,
8170
8211
  appliedPolicies,
8212
+ usePublishState,
8213
+ publishStatus,
8171
8214
  isRoundRobin,
8172
8215
  roundProfile,
8173
8216
  matchUp,
@@ -8237,6 +8280,8 @@ function getAllStructureMatchUps({
8237
8280
  tieDrawPositions,
8238
8281
  appliedPolicies: appliedPolicies2,
8239
8282
  isCollectionBye,
8283
+ usePublishState: usePublishState2,
8284
+ publishStatus: publishStatus2,
8240
8285
  matchUpTieId,
8241
8286
  isRoundRobin: isRoundRobin2,
8242
8287
  roundProfile: roundProfile2,
@@ -8262,8 +8307,10 @@ function getAllStructureMatchUps({
8262
8307
  scheduleVisibilityFilters: scheduleVisibilityFilters2,
8263
8308
  afterRecoveryTimes,
8264
8309
  tournamentRecord,
8310
+ usePublishState: usePublishState2,
8265
8311
  scheduleTiming,
8266
8312
  matchUpFormat,
8313
+ publishStatus: publishStatus2,
8267
8314
  matchUpType,
8268
8315
  matchUp,
8269
8316
  event: event2
@@ -8386,7 +8433,7 @@ function getAllStructureMatchUps({
8386
8433
  Object.assign(matchUpWithContext, makeDeepCopy({ sides }, true, true));
8387
8434
  }
8388
8435
  if (tournamentParticipants && matchUpWithContext.sides) {
8389
- const participantAttributes = policyDefinitions?.[POLICY_TYPE_PARTICIPANT];
8436
+ const participantAttributes = appliedPolicies2?.[POLICY_TYPE_PARTICIPANT];
8390
8437
  const getMappedParticipant = (participantId) => {
8391
8438
  const participant = participantMap?.[participantId]?.participant;
8392
8439
  return participant && attributeFilter({
@@ -8502,6 +8549,8 @@ function getAllStructureMatchUps({
8502
8549
  additionalContext: additionalContext2,
8503
8550
  appliedPolicies: appliedPolicies2,
8504
8551
  isCollectionBye: isCollectionBye2,
8552
+ usePublishState: usePublishState2,
8553
+ publishStatus: publishStatus2,
8505
8554
  matchUpTieId: matchUpTieId2,
8506
8555
  isRoundRobin: isRoundRobin2,
8507
8556
  roundProfile: roundProfile2,
@@ -8756,7 +8805,7 @@ function generateTieMatchUpScore(params) {
8756
8805
  const tieFormat = resolveTieFormat({ matchUp, drawDefinition, structure, event })?.tieFormat || params?.tieFormat;
8757
8806
  if (!tieFormat)
8758
8807
  return { error: MISSING_TIE_FORMAT };
8759
- const result = validateTieFormat({ tieFormat, eventType: event?.eventType });
8808
+ const result = validateTieFormat({ tieFormat });
8760
8809
  if (result.error)
8761
8810
  return result;
8762
8811
  const collectionDefinitions = tieFormat?.collectionDefinitions || [];
@@ -9878,11 +9927,13 @@ function getStructureMatchUps({
9878
9927
  afterRecoveryTimes,
9879
9928
  policyDefinitions,
9880
9929
  tournamentRecord,
9930
+ usePublishState,
9881
9931
  matchUpFilters,
9882
9932
  contextFilters,
9883
9933
  contextContent,
9884
9934
  participantMap,
9885
9935
  scheduleTiming,
9936
+ publishStatus,
9886
9937
  contextProfile,
9887
9938
  drawDefinition,
9888
9939
  exitProfiles,
@@ -9903,13 +9954,15 @@ function getStructureMatchUps({
9903
9954
  afterRecoveryTimes,
9904
9955
  policyDefinitions,
9905
9956
  tournamentRecord,
9906
- drawDefinition,
9957
+ usePublishState,
9907
9958
  matchUpFilters,
9908
9959
  contextFilters,
9909
- contextProfile,
9910
9960
  contextContent,
9911
9961
  participantMap,
9912
9962
  scheduleTiming,
9963
+ publishStatus,
9964
+ contextProfile,
9965
+ drawDefinition,
9913
9966
  exitProfiles,
9914
9967
  matchUpsMap,
9915
9968
  structure,
@@ -10005,12 +10058,14 @@ function getDrawMatchUps(params) {
10005
10058
  afterRecoveryTimes,
10006
10059
  policyDefinitions,
10007
10060
  tournamentRecord,
10061
+ usePublishState,
10008
10062
  contextFilters,
10009
- contextProfile,
10010
- drawDefinition,
10011
10063
  matchUpFilters,
10012
10064
  scheduleTiming,
10013
10065
  participantMap,
10066
+ publishStatus,
10067
+ contextProfile,
10068
+ drawDefinition,
10014
10069
  nextMatchUps,
10015
10070
  inContext,
10016
10071
  context,
@@ -10065,9 +10120,11 @@ function getDrawMatchUps(params) {
10065
10120
  afterRecoveryTimes,
10066
10121
  policyDefinitions,
10067
10122
  tournamentRecord,
10123
+ usePublishState,
10124
+ contextContent,
10068
10125
  participantMap,
10069
10126
  scheduleTiming,
10070
- contextContent,
10127
+ publishStatus,
10071
10128
  contextProfile,
10072
10129
  drawDefinition,
10073
10130
  exitProfiles,
@@ -15617,44 +15674,6 @@ const fixtures = {
15617
15674
  flagIOC
15618
15675
  };
15619
15676
 
15620
- function addNationalityCode({
15621
- participant,
15622
- withISO2,
15623
- withIOC
15624
- }) {
15625
- const { person, individualParticipants } = participant;
15626
- const persons = [person, individualParticipants?.map(({ person: person2 }) => person2)].flat().filter(Boolean);
15627
- function annotatePerson(person2) {
15628
- const { nationalityCode } = person2 || {};
15629
- if (nationalityCode) {
15630
- const country = countries.find(({ iso }) => iso === nationalityCode);
15631
- if (withIOC && country?.ioc && !person2.iocNationalityCode)
15632
- person2.iocNationalityCode = country.ioc;
15633
- if (withISO2 && country?.iso2 && !person2.iso2NationalityCode)
15634
- person2.iso2NationalityCode = country.iso2;
15635
- if (country?.label && !person2.countryName)
15636
- person2.countryName = country.label;
15637
- }
15638
- }
15639
- persons.forEach(annotatePerson);
15640
- }
15641
-
15642
- function addIndividualParticipants({ participantMap, template }) {
15643
- const participantObjects = Object.values(participantMap);
15644
- for (const participantObject of participantObjects) {
15645
- const participant = participantObject.participant;
15646
- if (participant.individualParticipantIds?.length) {
15647
- participant.individualParticipants = [];
15648
- for (const participantId of participant.individualParticipantIds) {
15649
- const source = participantMap[participantId].participant;
15650
- participant.individualParticipants.push(
15651
- template ? attributeFilter({ template, source }) : source
15652
- );
15653
- }
15654
- }
15655
- }
15656
- }
15657
-
15658
15677
  function getTimeItem({
15659
15678
  returnPreviousValues,
15660
15679
  itemSubTypes,
@@ -15766,6 +15785,52 @@ function getParticipantTimeItem({
15766
15785
  return timeItem && { timeItem, previousItems } || { info };
15767
15786
  }
15768
15787
 
15788
+ function getEventPublishStatus({ event, status = PUBLIC }) {
15789
+ const itemType = `${PUBLISH}.${STATUS$1}`;
15790
+ return getEventTimeItem({
15791
+ itemType,
15792
+ event
15793
+ })?.timeItem?.itemValue?.[status];
15794
+ }
15795
+
15796
+ function addNationalityCode({
15797
+ participant,
15798
+ withISO2,
15799
+ withIOC
15800
+ }) {
15801
+ const { person, individualParticipants } = participant;
15802
+ const persons = [person, individualParticipants?.map(({ person: person2 }) => person2)].flat().filter(Boolean);
15803
+ function annotatePerson(person2) {
15804
+ const { nationalityCode } = person2 || {};
15805
+ if (nationalityCode) {
15806
+ const country = countries.find(({ iso }) => iso === nationalityCode);
15807
+ if (withIOC && country?.ioc && !person2.iocNationalityCode)
15808
+ person2.iocNationalityCode = country.ioc;
15809
+ if (withISO2 && country?.iso2 && !person2.iso2NationalityCode)
15810
+ person2.iso2NationalityCode = country.iso2;
15811
+ if (country?.label && !person2.countryName)
15812
+ person2.countryName = country.label;
15813
+ }
15814
+ }
15815
+ persons.forEach(annotatePerson);
15816
+ }
15817
+
15818
+ function addIndividualParticipants({ participantMap, template }) {
15819
+ const participantObjects = Object.values(participantMap);
15820
+ for (const participantObject of participantObjects) {
15821
+ const participant = participantObject.participant;
15822
+ if (participant.individualParticipantIds?.length) {
15823
+ participant.individualParticipants = [];
15824
+ for (const participantId of participant.individualParticipantIds) {
15825
+ const source = participantMap[participantId].participant;
15826
+ participant.individualParticipants.push(
15827
+ template ? attributeFilter({ template, source }) : source
15828
+ );
15829
+ }
15830
+ }
15831
+ }
15832
+ }
15833
+
15769
15834
  const typeMap = {
15770
15835
  [GROUP]: "groupParticipantIds",
15771
15836
  [PAIR]: "pairParticipantIds",
@@ -16206,9 +16271,10 @@ function tournamentMatchUps(params) {
16206
16271
  useParticipantMap,
16207
16272
  tournamentRecord,
16208
16273
  inContext = true,
16274
+ usePublishState,
16209
16275
  contextFilters,
16210
- contextProfile,
16211
16276
  matchUpFilters,
16277
+ contextProfile,
16212
16278
  nextMatchUps,
16213
16279
  context
16214
16280
  } = params;
@@ -16246,6 +16312,7 @@ function tournamentMatchUps(params) {
16246
16312
  afterRecoveryTimes,
16247
16313
  policyDefinitions,
16248
16314
  tournamentRecord,
16315
+ usePublishState,
16249
16316
  contextFilters,
16250
16317
  contextProfile,
16251
16318
  contextContent,
@@ -16291,9 +16358,10 @@ function eventMatchUps(params) {
16291
16358
  policyDefinitions,
16292
16359
  useParticipantMap,
16293
16360
  tournamentRecord,
16361
+ usePublishState,
16294
16362
  contextFilters,
16295
- contextProfile,
16296
16363
  matchUpFilters,
16364
+ contextProfile,
16297
16365
  nextMatchUps,
16298
16366
  tournamentId,
16299
16367
  inContext,
@@ -16336,6 +16404,7 @@ function eventMatchUps(params) {
16336
16404
  contextProfile,
16337
16405
  event
16338
16406
  });
16407
+ const publishStatus = getEventPublishStatus({ event });
16339
16408
  const drawDefinitions = event.drawDefinitions ?? [];
16340
16409
  const eventResult = drawDefinitions.reduce((results, drawDefinition) => {
16341
16410
  const drawMatchUpsResult = getDrawMatchUps({
@@ -16347,12 +16416,14 @@ function eventMatchUps(params) {
16347
16416
  afterRecoveryTimes,
16348
16417
  policyDefinitions,
16349
16418
  tournamentRecord,
16350
- drawDefinition,
16419
+ usePublishState,
16351
16420
  contextContent,
16352
16421
  contextFilters,
16353
- contextProfile,
16354
16422
  matchUpFilters,
16355
16423
  participantMap,
16424
+ publishStatus,
16425
+ contextProfile,
16426
+ drawDefinition,
16356
16427
  nextMatchUps,
16357
16428
  inContext,
16358
16429
  event
@@ -16378,12 +16449,14 @@ function drawMatchUps$1({
16378
16449
  policyDefinitions,
16379
16450
  useParticipantMap,
16380
16451
  tournamentRecord,
16452
+ usePublishState,
16381
16453
  contextFilters,
16382
- contextProfile,
16383
16454
  contextContent,
16384
- drawDefinition,
16385
16455
  matchUpFilters,
16386
16456
  participantMap,
16457
+ publishStatus,
16458
+ contextProfile,
16459
+ drawDefinition,
16387
16460
  nextMatchUps,
16388
16461
  tournamentId,
16389
16462
  inContext,
@@ -16434,12 +16507,14 @@ function drawMatchUps$1({
16434
16507
  afterRecoveryTimes,
16435
16508
  policyDefinitions,
16436
16509
  tournamentRecord,
16510
+ usePublishState,
16437
16511
  participantMap,
16438
- drawDefinition,
16439
- matchUpFilters,
16512
+ contextContent,
16440
16513
  contextFilters,
16514
+ matchUpFilters,
16515
+ publishStatus,
16441
16516
  contextProfile,
16442
- contextContent,
16517
+ drawDefinition,
16443
16518
  nextMatchUps,
16444
16519
  inContext,
16445
16520
  event
@@ -17145,6 +17220,7 @@ function competitionMatchUps({
17145
17220
  participantsProfile,
17146
17221
  tournamentRecords,
17147
17222
  policyDefinitions,
17223
+ usePublishState,
17148
17224
  matchUpFilters,
17149
17225
  contextFilters,
17150
17226
  nextMatchUps,
@@ -17160,6 +17236,7 @@ function competitionMatchUps({
17160
17236
  participantsProfile,
17161
17237
  policyDefinitions,
17162
17238
  tournamentRecord,
17239
+ usePublishState,
17163
17240
  matchUpFilters,
17164
17241
  contextFilters,
17165
17242
  nextMatchUps,
@@ -22552,6 +22629,11 @@ function getMatchUpDailyLimits({
22552
22629
  return { matchUpDailyLimits: dailyLimits };
22553
22630
  }
22554
22631
 
22632
+ function getDrawPublishStatus({ drawDetails, drawId }) {
22633
+ const details = drawDetails?.[drawId]?.publishingDetail;
22634
+ return details?.published;
22635
+ }
22636
+
22555
22637
  function scheduledSortedMatchUps({
22556
22638
  schedulingProfile,
22557
22639
  matchUps = []
@@ -22676,11 +22758,10 @@ function competitionScheduleMatchUps(params) {
22676
22758
  status = PUBLIC,
22677
22759
  sortCourtsData
22678
22760
  } = params;
22679
- const timeItem = usePublishState ? getTournamentTimeItem({
22761
+ const tournamentPublishStatus = usePublishState ? getTournamentTimeItem({
22680
22762
  tournamentRecord: tournamentRecords[activeTournamentId ?? getTournamentId()],
22681
22763
  itemType: `${PUBLISH}.${STATUS$1}`
22682
- }).timeItem : void 0;
22683
- const publishStatus = timeItem?.itemValue?.[status];
22764
+ }).timeItem?.itemValue?.[status] : void 0;
22684
22765
  const allCompletedMatchUps = alwaysReturnCompleted ? competitionMatchUps({
22685
22766
  ...params,
22686
22767
  matchUpFilters: {
@@ -22689,7 +22770,7 @@ function competitionScheduleMatchUps(params) {
22689
22770
  },
22690
22771
  contextFilters: params.contextFilters
22691
22772
  }).completedMatchUps : [];
22692
- if (usePublishState && (!publishStatus || !Object.keys(publishStatus).length)) {
22773
+ if (usePublishState && (!tournamentPublishStatus || !Object.keys(tournamentPublishStatus).length)) {
22693
22774
  return {
22694
22775
  completedMatchUps: allCompletedMatchUps,
22695
22776
  dateMatchUps: [],
@@ -22697,7 +22778,12 @@ function competitionScheduleMatchUps(params) {
22697
22778
  venues
22698
22779
  };
22699
22780
  }
22700
- const publishedDrawIds = usePublishState ? getCompetitionPublishedDrawIds({ tournamentRecords }).drawIds : void 0;
22781
+ let publishedDrawIds, detailsMap;
22782
+ if (usePublishState) {
22783
+ ({ drawIds: publishedDrawIds, detailsMap } = getCompetitionPublishedDrawDetails({
22784
+ tournamentRecords
22785
+ }));
22786
+ }
22701
22787
  if (publishedDrawIds?.length) {
22702
22788
  if (!params.contextFilters)
22703
22789
  params.contextFilters = {};
@@ -22709,34 +22795,34 @@ function competitionScheduleMatchUps(params) {
22709
22795
  );
22710
22796
  }
22711
22797
  }
22712
- if (publishStatus?.eventIds?.length) {
22798
+ if (tournamentPublishStatus?.eventIds?.length) {
22713
22799
  if (!params.matchUpFilters)
22714
22800
  params.matchUpFilters = {};
22715
22801
  if (params.matchUpFilters?.eventIds) {
22716
22802
  if (!params.matchUpFilters.eventIds.length) {
22717
- params.matchUpFilters.eventIds = publishStatus.eventIds;
22803
+ params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
22718
22804
  } else {
22719
22805
  params.matchUpFilters.eventIds = params.matchUpFilters.eventIds.filter(
22720
- (eventId) => publishStatus.eventIds.includes(eventId)
22806
+ (eventId) => tournamentPublishStatus.eventIds.includes(eventId)
22721
22807
  );
22722
22808
  }
22723
22809
  } else {
22724
- params.matchUpFilters.eventIds = publishStatus.eventIds;
22810
+ params.matchUpFilters.eventIds = tournamentPublishStatus.eventIds;
22725
22811
  }
22726
22812
  }
22727
- if (publishStatus?.scheduledDates?.length) {
22813
+ if (tournamentPublishStatus?.scheduledDates?.length) {
22728
22814
  if (!params.matchUpFilters)
22729
22815
  params.matchUpFilters = {};
22730
22816
  if (params.matchUpFilters.scheduledDates) {
22731
22817
  if (!params.matchUpFilters.scheduledDates.length) {
22732
- params.matchUpFilters.scheduledDates = publishStatus.scheduledDates;
22818
+ params.matchUpFilters.scheduledDates = tournamentPublishStatus.scheduledDates;
22733
22819
  } else {
22734
22820
  params.matchUpFilters.scheduledDates = params.matchUpFilters.scheduledDates.filter(
22735
- (scheduledDate) => publishStatus.scheduledDates.includes(scheduledDate)
22821
+ (scheduledDate) => tournamentPublishStatus.scheduledDates.includes(scheduledDate)
22736
22822
  );
22737
22823
  }
22738
22824
  } else {
22739
- params.matchUpFilters.scheduledDates = publishStatus.scheduledDates;
22825
+ params.matchUpFilters.scheduledDates = tournamentPublishStatus.scheduledDates;
22740
22826
  }
22741
22827
  }
22742
22828
  if (alwaysReturnCompleted) {
@@ -22755,10 +22841,48 @@ function competitionScheduleMatchUps(params) {
22755
22841
  matchUpFilters: params.matchUpFilters,
22756
22842
  contextFilters: params.contextFilters
22757
22843
  });
22758
- const relevantMatchUps = [
22844
+ let relevantMatchUps = [
22759
22845
  ...upcomingMatchUps ?? [],
22760
22846
  ...pendingMatchUps ?? []
22761
22847
  ];
22848
+ if (detailsMap && Object.keys(detailsMap).length) {
22849
+ relevantMatchUps = relevantMatchUps.filter((matchUp) => {
22850
+ const { drawId, structureId, stage } = matchUp;
22851
+ if (!detailsMap[drawId])
22852
+ return false;
22853
+ if (detailsMap[drawId].stageDetails) {
22854
+ const stageKeys = Object.keys(detailsMap[drawId].stageDetails);
22855
+ const unpublishedStages = stageKeys.filter(
22856
+ (stage2) => !detailsMap[drawId].stageDetails[stage2].published
22857
+ );
22858
+ const publishedStages = stageKeys.filter(
22859
+ (stage2) => detailsMap[drawId].stageDetails[stage2].published
22860
+ );
22861
+ if (unpublishedStages.length && unpublishedStages.includes(stage))
22862
+ return false;
22863
+ if (publishedStages.length && publishedStages.includes(stage))
22864
+ return true;
22865
+ return unpublishedStages.length && !unpublishedStages.includes(stage) && !publishedStages.length;
22866
+ }
22867
+ if (detailsMap[drawId].structureDetails) {
22868
+ const structureIdKeys = Object.keys(
22869
+ detailsMap[drawId].structureDetails
22870
+ );
22871
+ const unpublishedStructureIds = structureIdKeys.filter(
22872
+ (structureId2) => !detailsMap[drawId].structureDetails[structureId2].published
22873
+ );
22874
+ const publishedStructureIds = structureIdKeys.filter(
22875
+ (structureId2) => detailsMap[drawId].structureDetails[structureId2].published
22876
+ );
22877
+ if (unpublishedStructureIds.length && unpublishedStructureIds.includes(structureId))
22878
+ return false;
22879
+ if (publishedStructureIds.length && publishedStructureIds.includes(structureId))
22880
+ return true;
22881
+ return unpublishedStructureIds.length && !unpublishedStructureIds.includes(structureId) && !publishedStructureIds.length;
22882
+ }
22883
+ return true;
22884
+ });
22885
+ }
22762
22886
  const dateMatchUps = sortDateMatchUps ? scheduledSortedMatchUps({ matchUps: relevantMatchUps, schedulingProfile }) : relevantMatchUps;
22763
22887
  const courtsData = courts?.map((court) => {
22764
22888
  const matchUps = getCourtMatchUps(court);
@@ -22769,11 +22893,11 @@ function competitionScheduleMatchUps(params) {
22769
22893
  };
22770
22894
  });
22771
22895
  const result = {
22772
- courtsData,
22773
22896
  completedMatchUps: alwaysReturnCompleted ? allCompletedMatchUps : completedMatchUps,
22774
22897
  // completed matchUps for the filter date
22775
22898
  dateMatchUps,
22776
22899
  // all incomplete matchUps for the filter date
22900
+ courtsData,
22777
22901
  groupInfo,
22778
22902
  venues
22779
22903
  };
@@ -22797,26 +22921,28 @@ function competitionScheduleMatchUps(params) {
22797
22921
  }) : courtMatchUps;
22798
22922
  }
22799
22923
  }
22800
- function getCompetitionPublishedDrawIds({
22924
+ function getCompetitionPublishedDrawDetails({
22801
22925
  tournamentRecords
22802
22926
  }) {
22803
22927
  const drawIds = [];
22928
+ const detailsMap = {};
22804
22929
  for (const tournamentRecord of Object.values(tournamentRecords)) {
22805
22930
  for (const event of tournamentRecord.events ?? []) {
22806
- const { timeItem } = getEventTimeItem({
22807
- itemType: `${PUBLISH}.${STATUS$1}`,
22808
- event
22809
- });
22810
- const pubState = timeItem?.itemValue?.[PUBLIC];
22811
- if (pubState?.drawIds?.length) {
22812
- drawIds.push(...pubState.drawIds);
22813
- } else {
22814
- const eventDrawIds = (event.drawDefinitions ?? []).map(({ drawId }) => drawId).filter(Boolean);
22815
- drawIds.push(...eventDrawIds);
22931
+ const eventPubStatus = getEventPublishStatus({ event });
22932
+ const drawDetails = eventPubStatus?.drawDetails;
22933
+ if (isObject(drawDetails)) {
22934
+ Object.assign(detailsMap, drawDetails);
22935
+ drawIds.push(
22936
+ ...Object.keys(drawDetails).filter(
22937
+ (drawId) => getDrawPublishStatus({ drawId, drawDetails })
22938
+ )
22939
+ );
22940
+ } else if (eventPubStatus?.drawIds?.length) {
22941
+ drawIds.push(...eventPubStatus.drawIds);
22816
22942
  }
22817
22943
  }
22818
22944
  }
22819
- return { drawIds };
22945
+ return { drawIds, detailsMap };
22820
22946
  }
22821
22947
 
22822
22948
  const { stageOrder } = drawDefinitionConstants;
@@ -23135,13 +23261,8 @@ function getEventEntries({ eventEntryStatuses, tournamentEvents }) {
23135
23261
  }
23136
23262
 
23137
23263
  function getEventPublishStatuses({ event }) {
23138
- const itemType = `${PUBLISH}.${STATUS$1}`;
23139
- const { timeItem } = getTimeItem({
23140
- element: event,
23141
- itemType
23142
- });
23143
- if (timeItem?.itemValue?.PUBLIC) {
23144
- const { drawIds: publishedDrawIds = [], seeding } = timeItem.itemValue.PUBLIC || {};
23264
+ const eventPubStatus = getEventPublishStatus({ event });
23265
+ if (eventPubStatus) {
23145
23266
  const publishedSeeding = {
23146
23267
  published: void 0,
23147
23268
  // seeding can be present for all entries in an event when no flights have been defined
@@ -23149,9 +23270,13 @@ function getEventPublishStatuses({ event }) {
23149
23270
  drawIds: []
23150
23271
  // seeding can be specific to drawIds
23151
23272
  };
23152
- if (seeding) {
23153
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
23273
+ if (eventPubStatus.seeding) {
23274
+ Object.assign(publishedSeeding, eventPubStatus.seeding);
23154
23275
  }
23276
+ const { drawDetails, drawIds } = eventPubStatus;
23277
+ const publishedDrawIds = drawDetails && Object.keys(drawDetails).filter(
23278
+ (drawId) => getDrawPublishStatus({ drawDetails, drawId })
23279
+ ) || drawIds || [];
23155
23280
  return {
23156
23281
  publishedDrawIds,
23157
23282
  publishedSeeding
@@ -24108,7 +24233,7 @@ function getParticipantEntries(params) {
24108
24233
  const itemIsPrior = consideredMinutes >= scheduledMinutes;
24109
24234
  const timeOverlap = scheduledMinutesDifference && !isNaN(scheduledMinutesDifference) ? minutesDifference <= scheduledMinutesDifference : itemIsPrior && timeStringMinutes(consideredItem.scheduledTime) < timeStringMinutes(notBeforeTime);
24110
24235
  if (timeOverlap && !(bothPotential && sameDraw) && itemIsPrior) {
24111
- const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort().join("|");
24236
+ const key = [scheduleItem.matchUpId, consideredItem.matchUpId].sort(stringSort).join("|");
24112
24237
  participantAggregator.scheduleConflicts[key] = {
24113
24238
  priorScheduledMatchUpId: scheduleItem.matchUpId,
24114
24239
  matchUpIdWithConflict: consideredItem.matchUpId
@@ -25689,12 +25814,12 @@ function positionActions$1(params) {
25689
25814
  const isActiveDrawPosition = activeDrawPositions.includes(drawPosition);
25690
25815
  if (actionsDisabled)
25691
25816
  return {
25817
+ hasPositionAssigned: !!positionAssignment,
25692
25818
  info: "Actions Disabled for structure",
25693
- isByePosition,
25694
25819
  isActiveDrawPosition,
25695
25820
  isDrawPosition: true,
25696
- hasPositionAssigned: !!positionAssignment,
25697
- validActions: []
25821
+ validActions: [],
25822
+ isByePosition
25698
25823
  };
25699
25824
  if (isAvailableAction({ policyActions, action: ASSIGN_PARTICIPANT }) && !isActiveDrawPosition && positionAssignments && !disablePlacementActions && (!positionAssignment || isByePosition)) {
25700
25825
  const { validAssignmentActions } = getValidAssignmentActions({
@@ -26074,7 +26199,9 @@ function getDrawData(params) {
26074
26199
  policyDefinitions,
26075
26200
  tournamentRecord,
26076
26201
  inContext = true,
26202
+ usePublishState,
26077
26203
  drawDefinition,
26204
+ publishStatus,
26078
26205
  noDeepCopy,
26079
26206
  sortConfig,
26080
26207
  context,
@@ -26146,6 +26273,8 @@ function getDrawData(params) {
26146
26273
  tournamentParticipants,
26147
26274
  policyDefinitions,
26148
26275
  tournamentRecord,
26276
+ usePublishState,
26277
+ publishStatus,
26149
26278
  drawDefinition,
26150
26279
  inContext,
26151
26280
  structure,
@@ -26259,11 +26388,7 @@ function getEventData(params) {
26259
26388
  return { error: MISSING_EVENT };
26260
26389
  const { eventId } = event;
26261
26390
  const { tournamentId, endDate } = tournamentRecord;
26262
- const { timeItem } = getEventTimeItem({
26263
- itemType: `${PUBLISH}.${STATUS$1}`,
26264
- event
26265
- });
26266
- const publishStatus = timeItem?.itemValue?.[status];
26391
+ const publishStatus = getEventPublishStatus({ event, status });
26267
26392
  const { participants: tournamentParticipants } = getParticipants$1({
26268
26393
  withGroupings: true,
26269
26394
  withEvents: false,
@@ -26272,9 +26397,51 @@ function getEventData(params) {
26272
26397
  // order is important!!
26273
26398
  tournamentRecord
26274
26399
  });
26275
- const stageFilter = ({ stage }) => !usePublishState || !publishStatus?.stages?.length || publishStatus.stages.includes(stage);
26276
- const structureFilter = ({ structureId }) => !usePublishState || !publishStatus?.structureIds?.length || publishStatus.structureIds.includes(structureId);
26277
- const drawFilter = ({ drawId }) => !usePublishState || !publishStatus?.drawIds?.length || publishStatus.drawIds.includes(drawId);
26400
+ const stageFilter = ({ stage, drawId }) => {
26401
+ if (!usePublishState)
26402
+ return true;
26403
+ const stageDetails = publishStatus?.drawDetails?.[drawId]?.stageDetails;
26404
+ if (!stageDetails || !Object.keys(stageDetails).length)
26405
+ return true;
26406
+ return stageDetails[stage]?.published;
26407
+ };
26408
+ const structureFilter = ({ structureId, drawId }) => {
26409
+ if (!usePublishState)
26410
+ return true;
26411
+ const structureDetails = publishStatus?.drawDetails?.[drawId]?.structureDetails;
26412
+ if (!structureDetails || !Object.keys(structureDetails).length)
26413
+ return true;
26414
+ return structureDetails[structureId]?.published;
26415
+ };
26416
+ const drawFilter = ({ drawId }) => {
26417
+ if (!usePublishState)
26418
+ return true;
26419
+ if (publishStatus.drawDetails) {
26420
+ return publishStatus.drawDetails[drawId]?.publishingDetail?.published;
26421
+ } else if (publishStatus.drawIds) {
26422
+ return publishStatus.drawIds.includes(drawId);
26423
+ }
26424
+ return true;
26425
+ };
26426
+ const roundLimitMapper = ({ drawId, structure }) => {
26427
+ if (!usePublishState)
26428
+ return structure;
26429
+ const roundLimit = publishStatus?.drawDetails?.[drawId]?.structureDetails?.[structure.structureId]?.roundLimit;
26430
+ if (isConvertableInteger(roundLimit)) {
26431
+ const roundNumbers = generateRange(1, roundLimit + 1);
26432
+ const roundMatchUps = {};
26433
+ const roundProfile = {};
26434
+ for (const roundNumber of roundNumbers) {
26435
+ if (structure.roundMatchUps[roundNumber]) {
26436
+ roundMatchUps[roundNumber] = structure.roundMatchUps[roundNumber];
26437
+ roundProfile[roundNumber] = structure.roundProfile[roundNumber];
26438
+ }
26439
+ }
26440
+ structure.roundMatchUps = roundMatchUps;
26441
+ structure.roundProfile = roundProfile;
26442
+ }
26443
+ return structure;
26444
+ };
26278
26445
  const drawDefinitions = event.drawDefinitions || [];
26279
26446
  const drawsData = drawDefinitions.filter(drawFilter).map(
26280
26447
  (drawDefinition) => (({ drawInfo, structures }) => ({
@@ -26288,15 +26455,24 @@ function getEventData(params) {
26288
26455
  noDeepCopy: true,
26289
26456
  policyDefinitions,
26290
26457
  tournamentRecord,
26458
+ usePublishState,
26291
26459
  drawDefinition,
26460
+ publishStatus,
26292
26461
  sortConfig,
26293
26462
  event
26294
26463
  })
26295
26464
  )
26296
- ).map(({ structures, ...drawData }) => ({
26297
- ...drawData,
26298
- structures: structures?.filter(structureFilter)?.filter(stageFilter)
26299
- })).filter((drawData) => drawData.structures?.length);
26465
+ ).map(({ structures, ...drawData }) => {
26466
+ const filteredStructures = structures?.filter(
26467
+ ({ stage, structureId }) => structureFilter({ structureId, drawId: drawData.drawId }) && stageFilter({ stage, drawId: drawData.drawId })
26468
+ ).map(
26469
+ (structure) => roundLimitMapper({ drawId: drawData.drawId, structure })
26470
+ );
26471
+ return {
26472
+ ...drawData,
26473
+ structures: filteredStructures
26474
+ };
26475
+ }).filter((drawData) => drawData.structures?.length);
26300
26476
  const { tournamentInfo } = getTournamentInfo({ tournamentRecord });
26301
26477
  const venues = tournamentRecord.venues || [];
26302
26478
  const venuesData = venues.map(
@@ -26342,10 +26518,7 @@ function getEventData(params) {
26342
26518
  eventInfo,
26343
26519
  drawsData
26344
26520
  };
26345
- eventData.eventInfo.publish = {
26346
- createdAt: timeItem?.createdAt,
26347
- state: timeItem?.itemValue
26348
- };
26521
+ eventData.eventInfo.publish = publishStatus;
26349
26522
  return { ...SUCCESS, eventData };
26350
26523
  }
26351
26524
 
@@ -29421,18 +29594,14 @@ function conditionallyAdvanceDrawPosition(params) {
29421
29594
  } else {
29422
29595
  sourceSideNumber = 2;
29423
29596
  }
29424
- } else {
29425
- if (targetMatchUp.feedRound) {
29426
- if (sourceMatchUp.structureId === targetMatchUp.structureId) {
29427
- sourceSideNumber = 2;
29428
- } else {
29429
- sourceSideNumber = 1;
29430
- }
29597
+ } else if (targetMatchUp.feedRound) {
29598
+ if (sourceMatchUp.structureId === targetMatchUp.structureId) {
29599
+ sourceSideNumber = 2;
29431
29600
  } else {
29432
- if (walkoverWinningSide)
29433
- sourceSideNumber = 3 - walkoverWinningSide;
29601
+ sourceSideNumber = 1;
29434
29602
  }
29435
- }
29603
+ } else if (walkoverWinningSide)
29604
+ sourceSideNumber = 3 - walkoverWinningSide;
29436
29605
  }
29437
29606
  const sourceMatchUpStatus = params.matchUpStatus;
29438
29607
  const pairedMatchUpStatus = pairedPreviousMatchUp?.matchUpStatus;
@@ -33348,10 +33517,7 @@ function modifyCollectionDefinition$1({
33348
33517
  modifications.push({ collectionId, gender });
33349
33518
  }
33350
33519
  const modifiedTieFormat = definedAttributes(tieFormat);
33351
- result = validateTieFormat({
33352
- tieFormat: modifiedTieFormat,
33353
- eventType: event?.eventType
33354
- });
33520
+ result = validateTieFormat({ tieFormat: modifiedTieFormat });
33355
33521
  if (result.error) {
33356
33522
  return decorateResult({ result, stack });
33357
33523
  }
@@ -33622,8 +33788,7 @@ function removeCollectionDefinition$1({
33622
33788
  matchUp = matchUp ?? result?.matchUp;
33623
33789
  const existingTieFormat = result?.tieFormat;
33624
33790
  const tieFormat = copyTieFormat(existingTieFormat);
33625
- const eventType = event?.eventType;
33626
- result = validateTieFormat({ tieFormat, eventType });
33791
+ result = validateTieFormat({ tieFormat });
33627
33792
  if (result.error)
33628
33793
  return decorateResult({ result, stack });
33629
33794
  const targetCollection = tieFormat?.collectionDefinitions?.find(
@@ -33760,7 +33925,7 @@ function removeCollectionDefinition$1({
33760
33925
  });
33761
33926
  }
33762
33927
  const prunedTieFormat = definedAttributes(tieFormat);
33763
- result = validateTieFormat({ tieFormat: prunedTieFormat, eventType });
33928
+ result = validateTieFormat({ tieFormat: prunedTieFormat });
33764
33929
  if (result.error)
33765
33930
  return decorateResult({ result, stack });
33766
33931
  if (eventId && event) {
@@ -33852,8 +34017,7 @@ function addCollectionDefinition$1({
33852
34017
  matchUp = matchUp ?? result?.matchUp;
33853
34018
  const existingTieFormat = matchUp?.tieFormat ?? result?.tieFormat;
33854
34019
  const tieFormat = copyTieFormat(existingTieFormat);
33855
- const eventType = event?.eventType;
33856
- result = validateTieFormat({ tieFormat, eventType });
34020
+ result = validateTieFormat({ tieFormat });
33857
34021
  if (result?.error) {
33858
34022
  return decorateResult({ result: { error: result.error }, stack });
33859
34023
  }
@@ -33888,7 +34052,7 @@ function addCollectionDefinition$1({
33888
34052
  const addedMatchUps = [];
33889
34053
  let targetMatchUps = [];
33890
34054
  const prunedTieFormat = definedAttributes(tieFormat);
33891
- result = validateTieFormat({ tieFormat: prunedTieFormat, eventType });
34055
+ result = validateTieFormat({ tieFormat: prunedTieFormat });
33892
34056
  if (result?.error) {
33893
34057
  return decorateResult({ result: { error: result.error }, stack });
33894
34058
  }
@@ -34176,10 +34340,7 @@ function collectionGroupUpdate({
34176
34340
  event
34177
34341
  });
34178
34342
  const prunedTieFormat = definedAttributes(tieFormat);
34179
- const result = validateTieFormat({
34180
- eventType: event?.eventType,
34181
- tieFormat: prunedTieFormat
34182
- });
34343
+ const result = validateTieFormat({ tieFormat: prunedTieFormat });
34183
34344
  if (result.error)
34184
34345
  return result;
34185
34346
  if (eventId && event) {
@@ -34229,7 +34390,7 @@ function removeCollectionGroup$1({
34229
34390
  const originalValueGoal = existingTieFormat?.winCriteria.valueGoal;
34230
34391
  const wasAggregateValue = existingTieFormat?.winCriteria.aggregateValue;
34231
34392
  const tieFormat = copyTieFormat(existingTieFormat);
34232
- result = validateTieFormat({ tieFormat, eventType: event?.eventType });
34393
+ result = validateTieFormat({ tieFormat });
34233
34394
  if (result.error)
34234
34395
  return decorateResult({ result, stack });
34235
34396
  const modifiedCollectionIds = [];
@@ -34316,7 +34477,7 @@ function addCollectionGroup$1({
34316
34477
  const existingTieFormat = result?.tieFormat;
34317
34478
  const originalValueGoal = existingTieFormat?.winCriteria.valueGoal;
34318
34479
  const tieFormat = copyTieFormat(existingTieFormat);
34319
- result = validateTieFormat({ tieFormat, eventType: event.eventType });
34480
+ result = validateTieFormat({ tieFormat });
34320
34481
  if (result.error)
34321
34482
  return decorateResult({ result, stack });
34322
34483
  for (const collectionDefinition of tieFormat.collectionDefinitions) {
@@ -34380,10 +34541,7 @@ function modifyTieFormat$1({
34380
34541
  event
34381
34542
  }) {
34382
34543
  const stack = "modifyTieFormat";
34383
- if (!validateTieFormat({
34384
- tieFormat: modifiedTieFormat,
34385
- eventType: event?.eventType
34386
- }).valid) {
34544
+ if (!validateTieFormat({ tieFormat: modifiedTieFormat }).valid) {
34387
34545
  return decorateResult({
34388
34546
  result: { error: INVALID_TIE_FORMAT },
34389
34547
  info: "falied validation",
@@ -41078,10 +41236,11 @@ function generateQualifyingStructures({
41078
41236
  for (const structureProfile of (structureProfiles || []).sort(
41079
41237
  sequenceSort
41080
41238
  )) {
41081
- let drawSize = structureProfile.drawSize || coerceEven(structureProfile.participantsCount);
41239
+ let drawSize = coerceEven(
41240
+ structureProfile.drawSize || structureProfile.participantsCount
41241
+ );
41082
41242
  const {
41083
41243
  qualifyingRoundNumber,
41084
- qualifyingPositions,
41085
41244
  structureOptions,
41086
41245
  matchUpFormat,
41087
41246
  structureName,
@@ -41089,6 +41248,7 @@ function generateQualifyingStructures({
41089
41248
  drawType
41090
41249
  } = structureProfile;
41091
41250
  const matchUpType = structureProfile.matchUpType;
41251
+ const qualifyingPositions = structureProfile.qualifyingPositions || deriveQualifyingPositions({ drawSize, qualifyingRoundNumber });
41092
41252
  let roundLimit, structure, matchUps;
41093
41253
  if (!isConvertableInteger(drawSize)) {
41094
41254
  return decorateResult({
@@ -41195,6 +41355,15 @@ function generateQualifyingStructures({
41195
41355
  links
41196
41356
  };
41197
41357
  }
41358
+ function deriveQualifyingPositions({ drawSize, qualifyingRoundNumber }) {
41359
+ let qualifyingPositions = drawSize;
41360
+ let divisionsCount = 0;
41361
+ while (divisionsCount < qualifyingRoundNumber) {
41362
+ qualifyingPositions = Math.floor(qualifyingPositions / 2);
41363
+ divisionsCount += 1;
41364
+ }
41365
+ return qualifyingPositions;
41366
+ }
41198
41367
 
41199
41368
  function getPositionRangeMap({
41200
41369
  playoffGroups,
@@ -42945,8 +43114,7 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
42945
43114
  const drawDefinition = modifyOriginal ? params.drawDefinition : makeDeepCopy(params.drawDefinition, false, true);
42946
43115
  let { tieFormat, matchUpType } = params;
42947
43116
  if (tieFormat) {
42948
- const eventType = params.event?.eventType;
42949
- const result2 = validateTieFormat({ tieFormat, eventType });
43117
+ const result2 = validateTieFormat({ tieFormat });
42950
43118
  if (result2.error)
42951
43119
  return result2;
42952
43120
  }
@@ -45413,8 +45581,7 @@ function generateVoluntaryConsolation$1(params) {
45413
45581
  return { error: INVALID_DRAW_SIZE };
45414
45582
  let { tieFormat, matchUpType } = params;
45415
45583
  if (tieFormat) {
45416
- const eventType = params.event?.eventType;
45417
- const result2 = validateTieFormat({ tieFormat, eventType });
45584
+ const result2 = validateTieFormat({ tieFormat });
45418
45585
  if (result2.error)
45419
45586
  return result2;
45420
45587
  }
@@ -51416,13 +51583,12 @@ function addParticipantContext(params) {
51416
51583
  (extensionKey) => eventInfo[extensionKey] = event[extensionKey]
51417
51584
  );
51418
51585
  const eventEntries = event.entries || [];
51419
- const itemType = `${PUBLISH}.${STATUS$1}`;
51420
- const { timeItem } = getEventTimeItem({
51421
- itemType,
51422
- event
51423
- });
51424
- if (timeItem?.itemValue?.PUBLIC) {
51425
- const { drawIds: publishedDrawIds = [], seeding } = timeItem.itemValue.PUBLIC || {};
51586
+ const pubStatus = getEventPublishStatus({ event });
51587
+ if (isObject(pubStatus)) {
51588
+ const { drawIds, drawDetails: drawDetails2, seeding } = pubStatus;
51589
+ const publishedDrawIds = drawDetails2 ? Object.keys(drawDetails2).filter(
51590
+ (drawId) => getDrawPublishStatus({ drawId, drawDetails: drawDetails2 })
51591
+ ) : drawIds ?? [];
51426
51592
  const publishedSeeding = {
51427
51593
  published: void 0,
51428
51594
  // seeding can be present for all entries in an event when no flights have been defined
@@ -51431,7 +51597,7 @@ function addParticipantContext(params) {
51431
51597
  // seeding can be specific to drawIds
51432
51598
  };
51433
51599
  if (seeding)
51434
- Object.assign(publishedSeeding, timeItem.itemValue.PUBLIC.seeding);
51600
+ Object.assign(publishedSeeding, pubStatus.seeding);
51435
51601
  eventsPublishStatuses[eventId] = {
51436
51602
  publishedDrawIds,
51437
51603
  publishedSeeding
@@ -53116,6 +53282,27 @@ const participantGovernor = {
53116
53282
  getParticipants: getParticipants$1
53117
53283
  };
53118
53284
 
53285
+ function modifyEventPublishStatus({
53286
+ removePriorValues = true,
53287
+ status = PUBLIC,
53288
+ statusObject,
53289
+ event
53290
+ }) {
53291
+ if (!isObject(statusObject))
53292
+ return { error: INVALID_VALUES };
53293
+ const publishStatus = getEventPublishStatus({ event, status });
53294
+ const itemType = `${PUBLISH}.${STATUS$1}`;
53295
+ const updatedTimeItem = {
53296
+ itemValue: { [status]: { ...publishStatus, ...statusObject } },
53297
+ itemType
53298
+ };
53299
+ return addEventTimeItem({
53300
+ timeItem: updatedTimeItem,
53301
+ removePriorValues,
53302
+ event
53303
+ });
53304
+ }
53305
+
53119
53306
  function publishEventSeeding({
53120
53307
  removePriorValues = true,
53121
53308
  stageSeedingScaleNames,
@@ -53129,31 +53316,27 @@ function publishEventSeeding({
53129
53316
  return { error: MISSING_TOURNAMENT_RECORD };
53130
53317
  if (!event)
53131
53318
  return { error: MISSING_EVENT };
53132
- const itemType = `${PUBLISH}.${STATUS$1}`;
53133
- const { timeItem } = getEventTimeItem({
53134
- itemType,
53135
- event
53136
- });
53137
- const itemValue = timeItem?.itemValue || { [status]: {} };
53138
- const updatedSeedingScaleNames = (itemValue[status].seeding?.seedingScaleNames || seedingScaleNames) && {
53139
- ...itemValue[status].seeding?.seedingScaleNames,
53319
+ const eventPubStatus = getEventPublishStatus({ event, status });
53320
+ const updatedSeedingScaleNames = (eventPubStatus?.seeding?.seedingScaleNames || seedingScaleNames) && {
53321
+ ...eventPubStatus?.seeding?.seedingScaleNames,
53140
53322
  ...seedingScaleNames
53141
53323
  };
53142
- const updatedStageSeedingScaleNames = (itemValue[status].seeding?.stageSeedingScaleNames || stageSeedingScaleNames) && {
53143
- ...itemValue[status].seeding?.stageSeedingScaleNames,
53324
+ const updatedStageSeedingScaleNames = (eventPubStatus?.seeding?.stageSeedingScaleNames || stageSeedingScaleNames) && {
53325
+ ...eventPubStatus?.seeding?.stageSeedingScaleNames,
53144
53326
  ...stageSeedingScaleNames
53145
53327
  };
53146
- itemValue[status].seeding = definedAttributes({
53328
+ const seeding = definedAttributes({
53147
53329
  stageSeedingScaleNames: updatedStageSeedingScaleNames,
53148
53330
  seedingScaleNames: updatedSeedingScaleNames,
53149
53331
  published: true,
53150
53332
  drawIds
53151
53333
  });
53152
- const updatedTimeItem = {
53153
- itemValue,
53154
- itemType
53155
- };
53156
- addEventTimeItem({ event, timeItem: updatedTimeItem, removePriorValues });
53334
+ modifyEventPublishStatus({
53335
+ statusObject: { seeding },
53336
+ removePriorValues,
53337
+ status,
53338
+ event
53339
+ });
53157
53340
  addNotice({
53158
53341
  topic: PUBLISH_EVENT_SEEDING,
53159
53342
  payload: {
@@ -53169,6 +53352,7 @@ function unPublishEventSeeding({
53169
53352
  seedingScaleNames,
53170
53353
  tournamentRecord,
53171
53354
  status = PUBLIC,
53355
+ drawIds,
53172
53356
  stages,
53173
53357
  event
53174
53358
  }) {
@@ -53176,34 +53360,39 @@ function unPublishEventSeeding({
53176
53360
  return { error: MISSING_TOURNAMENT_RECORD };
53177
53361
  if (!event)
53178
53362
  return { error: MISSING_EVENT };
53179
- const itemType = `${PUBLISH}.${STATUS$1}`;
53180
- const { timeItem } = getEventTimeItem({
53181
- itemType,
53182
- event
53183
- });
53184
- const itemValue = timeItem?.itemValue || { [status]: {} };
53185
- if (itemValue[status]) {
53186
- if (Array.isArray(stages) && itemValue[status].seeding?.stageSeedingScaleNames) {
53363
+ const eventPubStatus = getEventPublishStatus({ event });
53364
+ if (eventPubStatus) {
53365
+ const seeding = eventPubStatus.seeding;
53366
+ if (Array.isArray(stages) && seeding.stageSeedingScaleNames) {
53187
53367
  for (const stage of stages) {
53188
- if (itemValue[status].seeding.stageSeedingScaleNames[stage]) {
53189
- delete itemValue[status].seeding.stageSeedingScaleNames[stage];
53368
+ if (seeding.stageSeedingScaleNames[stage]) {
53369
+ delete seeding.stageSeedingScaleNames[stage];
53190
53370
  }
53191
53371
  }
53192
53372
  }
53193
- if (Array.isArray(seedingScaleNames) && itemValue[status].seeding?.seedingScaleNames) {
53194
- itemValue[status].seeding.seedingScaleNames = itemValue[status].seeding.seedingScaleNames.filter(
53373
+ if (Array.isArray(seedingScaleNames) && seeding?.seedingScaleNames) {
53374
+ seeding.seedingScaleNames = seeding.seedingScaleNames.filter(
53195
53375
  (scaleName) => !seedingScaleNames.includes(scaleName)
53196
53376
  );
53197
53377
  }
53198
- if (!stages && !seedingScaleNames) {
53199
- delete itemValue[status].seeding;
53378
+ if (Array.isArray(drawIds) && seeding?.drawIds) {
53379
+ seeding.drawIds = seeding.drawIds.filter(
53380
+ (drawId) => !drawIds.includes(drawId)
53381
+ );
53382
+ }
53383
+ if (!Object.values(seeding.stageSeedingScaleNames ?? {}).length && !seeding.seedingScaleNames?.length && !seeding.drawIds?.length || !stages && !seedingScaleNames && !drawIds?.length) {
53384
+ delete seeding.stageSeedingScaleNames;
53385
+ delete seeding.seedingScaleNames;
53386
+ delete seeding.drawIds;
53387
+ seeding.published = false;
53200
53388
  }
53389
+ modifyEventPublishStatus({
53390
+ statusObject: { seeding },
53391
+ removePriorValues,
53392
+ status,
53393
+ event
53394
+ });
53201
53395
  }
53202
- const updatedTimeItem = {
53203
- itemValue,
53204
- itemType
53205
- };
53206
- addEventTimeItem({ event, timeItem: updatedTimeItem, removePriorValues });
53207
53396
  addNotice({
53208
53397
  topic: UNPUBLISH_EVENT_SEEDING,
53209
53398
  payload: {
@@ -53289,13 +53478,10 @@ function getAllEventData({ tournamentRecord, policyDefinitions }) {
53289
53478
  }
53290
53479
  };
53291
53480
  });
53292
- const { timeItem } = getEventTimeItem({
53293
- itemType: `${PUBLISH}.${STATUS$1}`,
53294
- event
53295
- });
53481
+ const publish = getEventPublishStatus({ event });
53296
53482
  Object.assign(eventInfo, {
53297
- publish: timeItem?.itemValue,
53298
- drawsData
53483
+ drawsData,
53484
+ publish
53299
53485
  });
53300
53486
  return eventInfo;
53301
53487
  });
@@ -53303,6 +53489,49 @@ function getAllEventData({ tournamentRecord, policyDefinitions }) {
53303
53489
  return { allEventData };
53304
53490
  }
53305
53491
 
53492
+ function setEventDisplay({
53493
+ removePriorValues,
53494
+ tournamentRecord,
53495
+ displaySettings,
53496
+ status = PUBLIC,
53497
+ event
53498
+ }) {
53499
+ if (!tournamentRecord)
53500
+ return decorateResult({ result: { error: MISSING_TOURNAMENT_RECORD } });
53501
+ if (!event)
53502
+ return decorateResult({ result: { error: MISSING_EVENT } });
53503
+ if (!isObject(displaySettings))
53504
+ return decorateResult({ result: { error: MISSING_VALUE } });
53505
+ if (isObject(displaySettings.draws)) {
53506
+ for (const key of Object.keys(displaySettings.draws)) {
53507
+ const details = displaySettings.draws[key].scheduleDetails ?? [];
53508
+ if (details.length) {
53509
+ const scheduleDetails = [];
53510
+ for (const detail of details) {
53511
+ const existingDetail = scheduleDetails.find(
53512
+ (sd) => objShallowEqual(sd.attributes, detail.attributes)
53513
+ );
53514
+ if (existingDetail?.dates && detail.dates) {
53515
+ existingDetail.dates.push(...detail.dates);
53516
+ } else {
53517
+ scheduleDetails.push(detail);
53518
+ }
53519
+ }
53520
+ displaySettings.draws[key].scheduleDetails = scheduleDetails;
53521
+ }
53522
+ }
53523
+ }
53524
+ const result = modifyEventPublishStatus({
53525
+ statusObject: { displaySettings },
53526
+ removePriorValues,
53527
+ status,
53528
+ event
53529
+ });
53530
+ if (result.error)
53531
+ return result;
53532
+ return { ...SUCCESS };
53533
+ }
53534
+
53306
53535
  function unPublishEvent({
53307
53536
  removePriorValues = true,
53308
53537
  tournamentRecord,
@@ -53320,9 +53549,20 @@ function unPublishEvent({
53320
53549
  });
53321
53550
  const itemValue = timeItem?.itemValue || { [status]: {} };
53322
53551
  delete itemValue[status].structureIds;
53552
+ delete itemValue[status].drawDetails;
53323
53553
  delete itemValue[status].drawIds;
53324
53554
  const updatedTimeItem = { itemValue, itemType };
53325
53555
  addEventTimeItem({ event, timeItem: updatedTimeItem, removePriorValues });
53556
+ modifyEventPublishStatus({
53557
+ statusObject: {
53558
+ structureIds: void 0,
53559
+ drawIds: void 0,
53560
+ seeding: void 0
53561
+ },
53562
+ removePriorValues,
53563
+ status,
53564
+ event
53565
+ });
53326
53566
  addNotice({
53327
53567
  topic: UNPUBLISH_EVENT,
53328
53568
  payload: {
@@ -53334,7 +53574,6 @@ function unPublishEvent({
53334
53574
  }
53335
53575
 
53336
53576
  function publishEvent(params) {
53337
- let { policyDefinitions, drawIds, structureIds, stages } = params;
53338
53577
  const {
53339
53578
  includePositionAssignments,
53340
53579
  removePriorValues,
@@ -53342,67 +53581,128 @@ function publishEvent(params) {
53342
53581
  status = PUBLIC,
53343
53582
  event,
53344
53583
  drawIdsToRemove,
53345
- drawIdsToAdd,
53346
- stagesToRemove,
53347
- stagesToAdd,
53348
- structureIdsToRemove,
53349
- structureIdsToAdd
53584
+ drawIdsToAdd
53350
53585
  } = params;
53351
53586
  if (!tournamentRecord)
53352
53587
  return { error: MISSING_TOURNAMENT_RECORD };
53353
53588
  if (!event)
53354
53589
  return { error: MISSING_EVENT };
53355
- if (!policyDefinitions) {
53356
- const { appliedPolicies } = getAppliedPolicies({ tournamentRecord, event });
53357
- policyDefinitions = appliedPolicies;
53358
- }
53359
- const itemType = `${PUBLISH}.${STATUS$1}`;
53590
+ const { appliedPolicies } = getAppliedPolicies({ tournamentRecord, event });
53591
+ const policyDefinitions = {
53592
+ ...appliedPolicies,
53593
+ ...params.policyDefinitions
53594
+ };
53360
53595
  const eventDrawIds = event.drawDefinitions?.map(({ drawId }) => drawId) ?? [];
53361
- const { timeItem } = getEventTimeItem({
53362
- itemType,
53363
- event
53364
- });
53365
- if (!drawIds && !drawIdsToAdd && !drawIdsToRemove) {
53366
- drawIds = eventDrawIds;
53367
- } else if (!drawIds && (drawIdsToAdd?.length || drawIdsToRemove?.length)) {
53368
- drawIds = timeItem?.itemValue?.PUBLIC?.drawIds || [];
53369
- }
53370
- drawIds = (drawIds ?? []).filter(
53371
- (drawId) => !drawIdsToRemove?.length || !drawIdsToRemove.includes(drawId)
53596
+ const keyedDrawIds = params.drawDetails ? Object.keys(params.drawDetails) : [];
53597
+ const specifiedDrawIds = keyedDrawIds.length ? [] : params.drawIds;
53598
+ const drawIdsToValidate = (drawIdsToAdd ?? []).concat(
53599
+ ...drawIdsToRemove ?? [],
53600
+ ...specifiedDrawIds ?? [],
53601
+ ...keyedDrawIds
53372
53602
  );
53373
- if (drawIdsToAdd?.length) {
53374
- drawIds = unique(
53375
- drawIds.concat(
53376
- ...drawIdsToAdd.filter((drawId) => eventDrawIds.includes(drawId))
53377
- )
53378
- );
53379
- }
53380
- if (!structureIds && (structureIdsToAdd?.length || structureIdsToRemove?.length)) {
53381
- structureIds = timeItem?.itemValue?.PUBLIC?.structureIds || [];
53382
- }
53383
- structureIds = (structureIds ?? []).filter(
53384
- (structureId) => !structureIdsToRemove?.length || !structureIdsToRemove.includes(structureId)
53603
+ const invalidDrawIds = drawIdsToValidate.filter(
53604
+ (drawId) => !eventDrawIds.includes(drawId)
53385
53605
  );
53386
- if (structureIdsToAdd?.length) {
53387
- structureIds = unique(structureIds.concat(...structureIdsToAdd));
53388
- }
53389
- if (!stages && (stagesToAdd?.length || stagesToRemove?.length)) {
53390
- stages = timeItem?.itemValue?.PUBLIC?.stages || [];
53606
+ if (invalidDrawIds.length) {
53607
+ return decorateResult({
53608
+ result: { error: DRAW_DEFINITION_NOT_FOUND },
53609
+ context: { invalidDrawIds }
53610
+ });
53391
53611
  }
53392
- stages = (stages ?? []).filter(
53393
- (stage) => !stagesToRemove?.length || !stagesToRemove.includes(stage)
53394
- );
53395
- if (stagesToAdd?.length) {
53396
- stages = unique(stages.concat(...stagesToAdd));
53612
+ const pubStatus = getEventPublishStatus({ event, status });
53613
+ const drawDetails = pubStatus?.drawDetails || {};
53614
+ for (const drawId of eventDrawIds) {
53615
+ if (!drawIdsToValidate.length || drawIdsToValidate.includes(drawId)) {
53616
+ if (drawIdsToRemove?.includes(drawId) || specifiedDrawIds?.length && !specifiedDrawIds.includes(drawId)) {
53617
+ drawDetails[drawId] = {
53618
+ ...drawDetails[drawId],
53619
+ publishingDetail: { published: false }
53620
+ };
53621
+ } else if (drawIdsToAdd?.includes(drawId) || specifiedDrawIds?.includes(drawId) || !specifiedDrawIds?.length) {
53622
+ drawDetails[drawId] = {
53623
+ ...drawDetails[drawId],
53624
+ publishingDetail: { published: true }
53625
+ };
53626
+ }
53627
+ }
53628
+ if (params.drawDetails?.[drawId]) {
53629
+ const newDetail = params.drawDetails[drawId];
53630
+ let structureDetails = newDetail.structureDetails ?? drawDetails[drawId].structureDetails;
53631
+ const stageDetails = newDetail.stageDetails ?? drawDetails[drawId].stageDetails ?? {};
53632
+ const {
53633
+ structureIdsToRemove = [],
53634
+ structureIdsToAdd = [],
53635
+ publishingDetail = {},
53636
+ stagesToRemove = [],
53637
+ stagesToAdd = []
53638
+ } = newDetail;
53639
+ if (structureIdsToAdd || stagesToAdd)
53640
+ publishingDetail.published = true;
53641
+ drawDetails[drawId] = {
53642
+ publishingDetail,
53643
+ structureDetails,
53644
+ stageDetails
53645
+ };
53646
+ if (structureIdsToAdd.length || structureIdsToRemove.length) {
53647
+ const drawStructureIds = (event.drawDefinitions?.find(
53648
+ (drawDefinition) => drawDefinition.drawId === drawId
53649
+ )?.structures ?? []).map(({ structureId }) => structureId);
53650
+ const structureIdsToValidate = (structureIdsToAdd ?? []).concat(
53651
+ structureIdsToRemove ?? []
53652
+ );
53653
+ const invalidStructureIds = structureIdsToValidate.filter(
53654
+ (structureId) => !drawStructureIds.includes(structureId)
53655
+ );
53656
+ if (invalidStructureIds.length) {
53657
+ return decorateResult({
53658
+ result: { error: STRUCTURE_NOT_FOUND },
53659
+ context: { invalidStructureIds }
53660
+ });
53661
+ }
53662
+ structureDetails = structureDetails ?? {};
53663
+ for (const structureId of drawStructureIds) {
53664
+ if (structureIdsToRemove.includes(structureId)) {
53665
+ structureDetails[structureId] = { published: false };
53666
+ } else {
53667
+ structureDetails[structureId] = { published: true };
53668
+ }
53669
+ }
53670
+ drawDetails[drawId].structureDetails = structureDetails;
53671
+ }
53672
+ const drawStages = (event.drawDefinitions?.find(
53673
+ (drawDefinition) => drawDefinition.drawId === drawId
53674
+ )?.structures ?? []).map(({ stage }) => stage);
53675
+ if (stagesToAdd.length) {
53676
+ for (const stage of stagesToAdd) {
53677
+ stageDetails[stage] = { published: true };
53678
+ }
53679
+ for (const stage of drawStages) {
53680
+ if (!stageDetails[stage]) {
53681
+ stageDetails[stage] = { published: false };
53682
+ }
53683
+ }
53684
+ }
53685
+ if (stagesToAdd.length || stagesToRemove.length) {
53686
+ for (const stage of stagesToRemove) {
53687
+ stageDetails[stage] = { published: false };
53688
+ }
53689
+ for (const stage of drawStages) {
53690
+ if (!stageDetails[stage]) {
53691
+ stageDetails[stage] = { published: true };
53692
+ }
53693
+ }
53694
+ }
53695
+ if (stagesToAdd.length || stagesToRemove.length) {
53696
+ drawDetails[drawId].stageDetails = stageDetails;
53697
+ }
53698
+ }
53397
53699
  }
53398
- const existingStatusValue = timeItem?.itemValue?.[status];
53399
- const updatedTimeItem = {
53400
- itemValue: {
53401
- [status]: { ...existingStatusValue, drawIds, structureIds, stages }
53402
- },
53403
- itemType
53404
- };
53405
- addEventTimeItem({ event, timeItem: updatedTimeItem, removePriorValues });
53700
+ modifyEventPublishStatus({
53701
+ statusObject: { drawDetails },
53702
+ removePriorValues,
53703
+ status,
53704
+ event
53705
+ });
53406
53706
  const { eventData } = getEventData({
53407
53707
  includePositionAssignments,
53408
53708
  usePublishState: true,
@@ -53410,10 +53710,6 @@ function publishEvent(params) {
53410
53710
  policyDefinitions,
53411
53711
  event
53412
53712
  });
53413
- const publishState = eventData?.eventInfo?.publish?.state;
53414
- eventData.drawsData = eventData.drawsData.filter(
53415
- ({ drawId }) => publishState?.PUBLIC?.drawIds.includes(drawId)
53416
- );
53417
53713
  addNotice({
53418
53714
  payload: { eventData, tournamentId: tournamentRecord.tournamentId },
53419
53715
  topic: PUBLISH_EVENT
@@ -53430,6 +53726,7 @@ const publishingGovernor = {
53430
53726
  getDrawData,
53431
53727
  unPublishEventSeeding,
53432
53728
  publishEventSeeding,
53729
+ setEventDisplay,
53433
53730
  unPublishEvent,
53434
53731
  publishEvent,
53435
53732
  unPublishOrderOfPlay: unPublishOrderOfPlay$1,
@@ -53864,7 +54161,7 @@ function generateLineUps(params) {
53864
54161
  if (!tieFormat && !drawDefinition)
53865
54162
  return { error: DRAW_DEFINITION_NOT_FOUND };
53866
54163
  tieFormat = tieFormat ?? resolveTieFormat({ drawDefinition, event })?.tieFormat;
53867
- if (validateTieFormat({ tieFormat, eventType: params.event?.eventType }).error)
54164
+ if (validateTieFormat({ tieFormat }).error)
53868
54165
  return { error: INVALID_TIE_FORMAT };
53869
54166
  if (typeof scaleAccessor !== "object" && !useDefaultEventRanking)
53870
54167
  return { error: INVALID_VALUES, context: { scaleAccessor } };
@@ -56524,6 +56821,9 @@ function deleteDrawDefinitions(params) {
56524
56821
  bye
56525
56822
  }) => ({ bye, qualifier, drawPosition, participantId });
56526
56823
  const allowDeletionWithScoresPresent = force || appliedPolicies?.[POLICY_TYPE_SCORING]?.allowDeletionWithScoresPresent?.drawDefinitions;
56824
+ const publishStatus = getEventPublishStatus({ event }) ?? {};
56825
+ let updatedDrawIds = publishStatus.drawIds ?? (publishStatus.drawDetails && Object.keys(publishStatus.drawDetails)) ?? [];
56826
+ let publishedDrawsDeleted;
56527
56827
  const drawIdsWithScoresPresent = [];
56528
56828
  const filteredDrawDefinitions = event.drawDefinitions.filter(
56529
56829
  (drawDefinition) => {
@@ -56545,6 +56845,10 @@ function deleteDrawDefinitions(params) {
56545
56845
  (entry) => STRUCTURE_ENTERED_TYPES.includes(entry.entryStatus)
56546
56846
  );
56547
56847
  }
56848
+ if (updatedDrawIds.includes(drawId2)) {
56849
+ updatedDrawIds = updatedDrawIds.filter((id) => id !== drawId2);
56850
+ publishedDrawsDeleted = true;
56851
+ }
56548
56852
  const mainStructure = getDrawStructures({
56549
56853
  stageSequence: 1,
56550
56854
  drawDefinition,
@@ -56616,29 +56920,19 @@ function deleteDrawDefinitions(params) {
56616
56920
  addEventExtension$1({ event, extension });
56617
56921
  }
56618
56922
  checkSchedulingProfile({ tournamentRecord });
56619
- const itemType = `${PUBLISH}.${STATUS$1}`;
56620
- const { timeItem } = getTimeItem({ element: event, itemType });
56621
- const publishStatus = timeItem?.itemValue?.[PUBLIC];
56622
- let publishedDrawsDeleted;
56623
- for (const drawId2 of drawIds) {
56624
- const drawPublished = publishStatus?.drawIds?.includes(drawId2);
56625
- if (drawPublished) {
56626
- publishedDrawsDeleted = true;
56627
- const updatedDrawIds = publishStatus.drawIds?.filter(
56628
- (publishedDrawId) => publishedDrawId !== drawId2
56629
- ) || [];
56630
- const timeItem2 = {
56631
- itemType: `${PUBLISH}.${STATUS$1}`,
56632
- itemValue: {
56633
- [PUBLIC]: {
56634
- drawIds: updatedDrawIds
56635
- }
56636
- }
56923
+ if (publishedDrawsDeleted) {
56924
+ const drawDetails = {};
56925
+ for (const drawId2 of updatedDrawIds) {
56926
+ drawDetails[drawId2] = publishStatus.drawDetails?.[drawId2] ?? {
56927
+ published: true
56637
56928
  };
56638
- const result = addEventTimeItem({ event, timeItem: timeItem2 });
56639
- if (result.error)
56640
- return { error: result.error };
56641
56929
  }
56930
+ const result = modifyEventPublishStatus({
56931
+ statusObject: { drawDetails },
56932
+ event
56933
+ });
56934
+ if (result.error)
56935
+ return { error: result.error };
56642
56936
  }
56643
56937
  if (auditTrail.length) {
56644
56938
  addNotice({ topic: AUDIT, payload: auditTrail });
@@ -56654,9 +56948,14 @@ function deleteDrawDefinitions(params) {
56654
56948
  });
56655
56949
  addDrawDeletionTelemetry({ event, deletedDrawsDetail, auditData });
56656
56950
  if (autoPublish && publishedDrawsDeleted) {
56657
- const result = publishEvent({ tournamentRecord, event, policyDefinitions });
56951
+ const result = publishEvent({
56952
+ drawIdsToRemove: drawIds,
56953
+ policyDefinitions,
56954
+ tournamentRecord,
56955
+ event
56956
+ });
56658
56957
  if (result.error)
56659
- console.log("publish error", result);
56958
+ return { ...SUCCESS, info: result.error };
56660
56959
  }
56661
56960
  return { ...SUCCESS };
56662
56961
  }
@@ -57291,10 +57590,7 @@ function addEvent({
57291
57590
  };
57292
57591
  if (event.eventType === TypeEnum.Team) {
57293
57592
  if (event.tieFormat) {
57294
- const result = validateTieFormat({
57295
- tieFormat: event.tieFormat,
57296
- eventType: event.eventType
57297
- });
57593
+ const result = validateTieFormat({ tieFormat: event.tieFormat });
57298
57594
  if (result.error)
57299
57595
  return result;
57300
57596
  } else if (event.tieFormatName) {
@@ -59705,8 +60001,7 @@ function generateDrawDefinition(params) {
59705
60001
  const result = validateTieFormat({
59706
60002
  gender: event?.gender,
59707
60003
  enforceGender,
59708
- tieFormat,
59709
- event
60004
+ tieFormat
59710
60005
  });
59711
60006
  if (result.error)
59712
60007
  return decorateResult({ result, stack });
@@ -59725,10 +60020,7 @@ function generateDrawDefinition(params) {
59725
60020
  const equivalentInScope = matchUpFormat && event?.matchUpFormat === matchUpFormat || event?.tieFormat && tieFormat && JSON.stringify(event.tieFormat) === JSON.stringify(tieFormat);
59726
60021
  if (!equivalentInScope) {
59727
60022
  if (tieFormat) {
59728
- const result = checkTieFormat({
59729
- eventType: event.eventType,
59730
- tieFormat
59731
- });
60023
+ const result = checkTieFormat({ tieFormat });
59732
60024
  if (result.error)
59733
60025
  return decorateResult({ result, stack });
59734
60026
  drawDefinition.tieFormat = result.tieFormat ?? tieFormat;
@@ -60059,7 +60351,7 @@ function generateDrawDefinition(params) {
60059
60351
  drawDefinition.links.push(link);
60060
60352
  }
60061
60353
  drawDefinition.drawName = params.drawName ?? (drawType && constantToString(drawType));
60062
- if (typeof voluntaryConsolation === "object") {
60354
+ if (typeof voluntaryConsolation === "object" && drawSize >= 4) {
60063
60355
  addVoluntaryConsolationStructure({
60064
60356
  ...voluntaryConsolation,
60065
60357
  tournamentRecord,
@@ -61010,10 +61302,8 @@ function bulkUpdatePublishedEventIds({ tournamentRecord, outcomes }) {
61010
61302
  if (eventId && drawId) {
61011
61303
  if (!eventIdsMap2[eventId]) {
61012
61304
  eventIdsMap2[eventId] = [drawId];
61013
- } else {
61014
- if (!eventIdsMap2[eventId].includes(drawId)) {
61015
- eventIdsMap2[eventId].push(drawId);
61016
- }
61305
+ } else if (!eventIdsMap2[eventId].includes(drawId)) {
61306
+ eventIdsMap2[eventId].push(drawId);
61017
61307
  }
61018
61308
  }
61019
61309
  return eventIdsMap2;
@@ -61023,14 +61313,14 @@ function bulkUpdatePublishedEventIds({ tournamentRecord, outcomes }) {
61023
61313
  (event) => relevantEventsIds.includes(event.eventId)
61024
61314
  );
61025
61315
  const publishedEventIds = relevantEvents.filter((event) => {
61026
- const { timeItem } = getEventTimeItem({
61027
- itemType: `${PUBLISH}.${STATUS$1}`,
61028
- event
61029
- });
61030
- const pubState = timeItem?.itemValue;
61316
+ const pubStatus = getEventPublishStatus({ event });
61317
+ const { drawDetails, drawIds } = pubStatus ?? {};
61031
61318
  const { eventId } = event;
61032
61319
  const publishedDrawIds = eventIdsMap[eventId].filter((drawId) => {
61033
- return pubState?.[PUBLIC]?.drawIds?.includes(drawId);
61320
+ const keyedDrawIds = drawDetails ? Object.keys(pubStatus.drawDetails).filter(
61321
+ (drawId2) => getDrawPublishStatus({ drawId: drawId2, drawDetails })
61322
+ ) : [];
61323
+ return drawIds?.includes(drawId) || keyedDrawIds.includes(drawId);
61034
61324
  });
61035
61325
  return publishedDrawIds.length;
61036
61326
  }).map((event) => event.eventId);