tods-competition-factory 1.8.25 → 1.8.27

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.
@@ -1576,17 +1576,20 @@ function cycleMutationStatus$1() {
1576
1576
  }
1577
1577
  function addNotice$1(_a) {
1578
1578
  var topic = _a.topic, payload = _a.payload, key = _a.key;
1579
- syncGlobalState.modified = true;
1580
1579
  if (typeof topic !== 'string' || typeof payload !== 'object') {
1581
1580
  return;
1582
1581
  }
1582
+ if (!syncGlobalState.disableNotifications)
1583
+ syncGlobalState.modified = true;
1583
1584
  if (syncGlobalState.disableNotifications ||
1584
- !syncGlobalState.subscriptions[topic])
1585
+ !syncGlobalState.subscriptions[topic]) {
1585
1586
  return;
1587
+ }
1586
1588
  if (key) {
1587
1589
  syncGlobalState.notices = syncGlobalState.notices.filter(function (notice) { return !(notice.topic === topic && notice.key === key); });
1588
1590
  }
1589
1591
  syncGlobalState.notices.push({ topic: topic, payload: payload, key: key });
1592
+ return __assign({}, SUCCESS);
1590
1593
  }
1591
1594
  function getNotices$1(_a) {
1592
1595
  var topic = _a.topic;
@@ -1706,6 +1709,14 @@ function getDevContext(contextCriteria) {
1706
1709
  return (Object.keys(contextCriteria).every(function (key) { var _a; return ((_a = globalState.devContext) === null || _a === void 0 ? void 0 : _a[key]) === contextCriteria[key]; }) && globalState.devContext);
1707
1710
  }
1708
1711
  }
1712
+ function setGlobalLog(loggingFx) {
1713
+ if (typeof loggingFx === 'function') {
1714
+ globalState.globalLog = loggingFx;
1715
+ }
1716
+ else {
1717
+ delete globalState.globalLog;
1718
+ }
1719
+ }
1709
1720
  function setDevContext(value) {
1710
1721
  globalState.devContext = value;
1711
1722
  }
@@ -1808,6 +1819,14 @@ function handleCaughtError(_a) {
1808
1819
  err: err,
1809
1820
  });
1810
1821
  }
1822
+ function globalLog$1(engine, log) {
1823
+ if (globalState.globalLog) {
1824
+ return globalState.globalLog(engine, log);
1825
+ }
1826
+ else {
1827
+ console.log(engine, log);
1828
+ }
1829
+ }
1811
1830
 
1812
1831
  var validDateString = /^[\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1])$/;
1813
1832
  var validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
@@ -2910,7 +2929,7 @@ var matchUpFormatCode = {
2910
2929
  };
2911
2930
 
2912
2931
  function factoryVersion() {
2913
- return '1.8.25';
2932
+ return '1.8.27';
2914
2933
  }
2915
2934
 
2916
2935
  function getObjectTieFormat(obj) {
@@ -2972,312 +2991,6 @@ function resolveTieFormat(_a) {
2972
2991
  };
2973
2992
  }
2974
2993
 
2975
- var typeMatch = function (arr, type) {
2976
- return arr.filter(Boolean).every(function (i) { return typeof i === type; });
2977
- };
2978
- var allNumeric = function (arr) { return arr.filter(Boolean).every(isNumeric); };
2979
- function getCategoryAgeDetails(params) {
2980
- var _a, _b;
2981
- var category = params.category;
2982
- if (typeof category !== 'object')
2983
- return { error: INVALID_CATEGORY };
2984
- var ageCategoryCode = category.ageCategoryCode, ageMaxDate = category.ageMaxDate, ageMinDate = category.ageMinDate, ageMax = category.ageMax, ageMin = category.ageMin;
2985
- var categoryName = category.categoryName;
2986
- var combinedAge;
2987
- if (!typeMatch([ageCategoryCode, ageMaxDate, ageMinDate, categoryName], 'string') ||
2988
- !allNumeric([ageMax, ageMin] ||
2989
- ![ageMaxDate, ageMinDate].filter(Boolean).every(isValidDateString)))
2990
- return { error: INVALID_CATEGORY };
2991
- var consideredDate = (_a = params.consideredDate) !== null && _a !== void 0 ? _a : extractDate(new Date().toLocaleDateString('sv'));
2992
- if (!isValidDateString(consideredDate))
2993
- return { error: INVALID_DATE };
2994
- // const [consideredYear, month, day] = consideredDate
2995
- var _c = __read(consideredDate
2996
- .split('-')
2997
- .slice(0, 3)
2998
- .map(function (n) { return parseInt(n); }), 1), consideredYear = _c[0];
2999
- // const monthDay = `${zeroPad(month)}-${zeroPad(day)}`;
3000
- var previousDayDate = dateStringDaysChange(consideredDate, -1);
3001
- var _d = __read(previousDayDate
3002
- .split('-')
3003
- .slice(1, 3)
3004
- .map(function (n) { return parseInt(n); }), 2), previousDayMonth = _d[0], previousDay = _d[1];
3005
- var previousMonthDay = "".concat(zeroPad(previousDayMonth), "-").concat(zeroPad(previousDay));
3006
- var nextDayDate = dateStringDaysChange(consideredDate, 1);
3007
- var _e = __read(nextDayDate
3008
- .split('-')
3009
- .slice(1, 3)
3010
- .map(function (n) { return parseInt(n); }), 2), nextDayMonth = _e[0], nextDay = _e[1];
3011
- var nextMonthDay = "".concat(zeroPad(nextDayMonth), "-").concat(zeroPad(nextDay));
3012
- var calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
3013
- var calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
3014
- // collect errors; e.g. provided ageMin does not equal calculated ageMin
3015
- var errors = [];
3016
- var addError = function (errorString) {
3017
- return !errors.includes(errorString) && errors.push(errorString);
3018
- };
3019
- ageCategoryCode = ageCategoryCode !== null && ageCategoryCode !== void 0 ? ageCategoryCode : categoryName;
3020
- var prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
3021
- var extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
3022
- var isBetween = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.includes('-');
3023
- var isCombined = isBetween && (ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined));
3024
- var isCoded = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(prePost);
3025
- // construct min or max date with or without year
3026
- //const isYYMM = (datePart) => datePart.match(/^\d{2}-\d{2}$/);
3027
- var constructedDate = function (y, df) { return "".concat(y, "-").concat(df); };
3028
- var uPre = function (ageInt) {
3029
- var ageMinYear = consideredYear - ageInt;
3030
- var newMinDate = constructedDate(ageMinYear, nextMonthDay);
3031
- if (category.ageMinDate && category.ageMinDate !== newMinDate)
3032
- addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
3033
- ageMinDate = newMinDate;
3034
- if (ageCategoryCode) {
3035
- if (category.ageMax && category.ageMax !== ageInt - 1) {
3036
- addError("Invalid submitted ageMax: ".concat(ageMax));
3037
- calculatedAgeMinDate = undefined;
3038
- }
3039
- ageMax = ageInt - 1;
3040
- }
3041
- };
3042
- var uPost = function (ageInt) {
3043
- var ageMinYear = consideredYear - ageInt - 1;
3044
- var newMinDate = constructedDate(ageMinYear, nextMonthDay);
3045
- if (category.ageMin && category.ageMin > ageInt) {
3046
- addError("Invalid submitted ageMin: ".concat(ageMin));
3047
- }
3048
- if (category.ageMax && category.ageMax > ageInt) {
3049
- addError("Invalid submitted ageMax: ".concat(ageMax));
3050
- }
3051
- if (category.ageMinDate && category.ageMinDate !== newMinDate)
3052
- addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
3053
- ageMinDate = newMinDate;
3054
- if (ageCategoryCode) {
3055
- if (category.ageMax && category.ageMax !== ageInt) {
3056
- addError("Invalid submitted ageMax: ".concat(ageMax));
3057
- calculatedAgeMaxDate = undefined;
3058
- }
3059
- ageMax = ageInt;
3060
- }
3061
- };
3062
- var oPre = function (ageInt) {
3063
- var ageMaxYear = consideredYear - ageInt;
3064
- var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
3065
- if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
3066
- addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
3067
- ageMaxDate = newMaxDate;
3068
- if (ageCategoryCode) {
3069
- if (category.ageMin && category.ageMin !== ageInt + 1) {
3070
- addError("Invalid submitted ageMin: ".concat(ageMin));
3071
- calculatedAgeMaxDate = undefined;
3072
- }
3073
- ageMin = ageInt + 1;
3074
- }
3075
- };
3076
- var oPost = function (ageInt) {
3077
- var ageMaxYear = consideredYear - ageInt - 1;
3078
- var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
3079
- if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
3080
- addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
3081
- ageMaxDate = newMaxDate;
3082
- if (ageCategoryCode) {
3083
- if (category.ageMin && category.ageMin !== ageInt) {
3084
- addError("Invalid submitted ageMin: ".concat(ageMin));
3085
- calculatedAgeMaxDate = undefined;
3086
- }
3087
- ageMin = ageInt;
3088
- }
3089
- };
3090
- var processCode = function (code) {
3091
- var _a = __read((code.match(prePost) || []).slice(1), 3), pre = _a[0], age = _a[1], post = _a[2];
3092
- var ageInt = parseInt(age);
3093
- if (pre === 'U') {
3094
- if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
3095
- addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
3096
- }
3097
- uPre(ageInt);
3098
- }
3099
- else if (pre === 'O') {
3100
- oPre(ageInt);
3101
- }
3102
- if (post === 'U') {
3103
- if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
3104
- addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
3105
- }
3106
- uPost(ageInt);
3107
- }
3108
- else if (post === 'O') {
3109
- oPost(ageInt);
3110
- }
3111
- ageMaxDate = ageMaxDate !== null && ageMaxDate !== void 0 ? ageMaxDate : calculatedAgeMaxDate;
3112
- ageMinDate = ageMinDate !== null && ageMinDate !== void 0 ? ageMinDate : calculatedAgeMinDate;
3113
- };
3114
- if (isCombined) {
3115
- // min and max birthdates are not relevant
3116
- // TODO: utility function to calculate combined age given two birthdates?
3117
- ageMaxDate = undefined;
3118
- ageMinDate = undefined;
3119
- ageMax = undefined;
3120
- ageMin = undefined;
3121
- if (category.ageMin) {
3122
- // calculate ageMaxDate
3123
- var ageMaxYear = consideredYear - category.ageMin;
3124
- ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
3125
- }
3126
- if (category.ageMax) {
3127
- // calculate ageMinDate
3128
- var ageMinYear = consideredYear - category.ageMax - 1;
3129
- ageMinDate = constructedDate(ageMinYear, nextMonthDay);
3130
- }
3131
- var _f = __read(((_b = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined)) !== null && _b !== void 0 ? _b : [])
3132
- .slice(1)
3133
- .map(function (n) { return parseInt(n); }), 2), lowAge = _f[0], highAge = _f[1];
3134
- if (lowAge <= highAge) {
3135
- ageMin = lowAge;
3136
- ageMax = highAge;
3137
- combinedAge = true;
3138
- }
3139
- else {
3140
- addError("Invalid combined age range ".concat(ageCategoryCode));
3141
- }
3142
- }
3143
- else if (isBetween) {
3144
- ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.split('-').forEach(processCode);
3145
- }
3146
- else if (isCoded) {
3147
- processCode(ageCategoryCode);
3148
- }
3149
- else {
3150
- if (ageMin)
3151
- oPre(ageMin);
3152
- if (ageMax)
3153
- uPost(ageMax);
3154
- }
3155
- if (ageMax && category.ageMin && category.ageMin > ageMax) {
3156
- addError("Invalid submitted ageMin: ".concat(category.ageMin));
3157
- ageMin = undefined;
3158
- }
3159
- var result = definedAttributes({
3160
- consideredDate: consideredDate,
3161
- combinedAge: combinedAge,
3162
- ageMaxDate: ageMaxDate,
3163
- ageMinDate: ageMinDate,
3164
- ageMax: ageMax,
3165
- ageMin: ageMin,
3166
- });
3167
- if (errors.length)
3168
- result.errors = errors;
3169
- return result;
3170
- }
3171
-
3172
- function decorateResult(_a) {
3173
- var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3174
- if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3175
- result.stack = [];
3176
- if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3177
- result.stack.push(stack);
3178
- }
3179
- if (result && info) {
3180
- result.info = info;
3181
- }
3182
- if (result && typeof context === 'object' && Object.keys(context).length) {
3183
- Object.assign(result, definedAttributes(context));
3184
- }
3185
- if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3186
- Object.assign(result, __assign({}, SUCCESS));
3187
- }
3188
- return result !== null && result !== void 0 ? result : { success: true };
3189
- }
3190
-
3191
- function validateCategory(_a) {
3192
- var category = _a.category;
3193
- if (!isObject(category))
3194
- return { error: INVALID_VALUES };
3195
- var categoryDetails = getCategoryAgeDetails({ category: category });
3196
- if (categoryDetails.error)
3197
- return { error: categoryDetails };
3198
- var ratingMax = category.ratingMax, ratingMin = category.ratingMin;
3199
- if (ratingMax && !isNumeric(ratingMax))
3200
- return decorateResult({
3201
- result: { error: INVALID_VALUES },
3202
- context: { ratingMax: ratingMax },
3203
- });
3204
- if (ratingMin && !isNumeric(ratingMin))
3205
- return decorateResult({
3206
- result: { error: INVALID_VALUES },
3207
- context: { ratingMin: ratingMin },
3208
- });
3209
- return __assign({}, categoryDetails);
3210
- }
3211
-
3212
- function categoryCanContain(_a) {
3213
- var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
3214
- var categoryDetails = validateCategory({ category: category });
3215
- var childCategoryDetails = validateCategory({
3216
- category: childCategory,
3217
- });
3218
- var invalidAgeMin = childCategoryDetails.ageMin &&
3219
- ((categoryDetails.ageMin &&
3220
- childCategoryDetails.ageMin < categoryDetails.ageMin) ||
3221
- (categoryDetails.ageMax &&
3222
- childCategoryDetails.ageMin > categoryDetails.ageMax));
3223
- var invalidAgeMax = childCategoryDetails.ageMax &&
3224
- ((categoryDetails.ageMax &&
3225
- childCategoryDetails.ageMax > categoryDetails.ageMax) ||
3226
- (categoryDetails.ageMin &&
3227
- childCategoryDetails.ageMax < categoryDetails.ageMin));
3228
- var invalidAgeMinDate = childCategoryDetails.ageMinDate &&
3229
- categoryDetails.ageMaxDate &&
3230
- new Date(childCategoryDetails.ageMinDate) >
3231
- new Date(categoryDetails.ageMaxDate);
3232
- var invalidAgeMaxDate = childCategoryDetails.ageMaxDate &&
3233
- categoryDetails.ageMinDate &&
3234
- new Date(childCategoryDetails.ageMaxDate) <
3235
- new Date(categoryDetails.ageMinDate);
3236
- var ratingComparison = category.ratingType &&
3237
- childCategory.ratingType &&
3238
- category.ratingType === childCategory.ratingType;
3239
- var invalidRatingRange = ratingComparison &&
3240
- ((category.ratingMin &&
3241
- childCategory.ratingMin &&
3242
- childCategory.ratingMin < category.ratingMin) ||
3243
- (category.ratingMax &&
3244
- childCategory.ratingMax &&
3245
- childCategory.ratingMax > category.ratingMax) ||
3246
- (category.ratingMin &&
3247
- childCategory.ratingMax &&
3248
- childCategory.ratingMax < category.ratingMin) ||
3249
- (category.ratingMax &&
3250
- childCategory.ratingMin &&
3251
- childCategory.ratingMin > category.ratingMax));
3252
- var invalidBallType = category.ballType &&
3253
- childCategory.ballType &&
3254
- category.ballType !== childCategory.ballType;
3255
- var valid = !invalidRatingRange &&
3256
- !invalidAgeMinDate &&
3257
- !invalidAgeMaxDate &&
3258
- !invalidBallType &&
3259
- !invalidAgeMax &&
3260
- !invalidAgeMin;
3261
- var ignoreFalse = true;
3262
- var result = definedAttributes({
3263
- invalidRatingRange: invalidRatingRange,
3264
- invalidAgeMinDate: invalidAgeMinDate,
3265
- invalidAgeMaxDate: invalidAgeMaxDate,
3266
- invalidBallType: invalidBallType,
3267
- invalidAgeMax: invalidAgeMax,
3268
- invalidAgeMin: invalidAgeMin,
3269
- valid: valid,
3270
- }, ignoreFalse);
3271
- if (withDetails) {
3272
- Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
3273
- }
3274
- return result;
3275
- }
3276
-
3277
- function mustBeAnArray(value) {
3278
- return "".concat(value, " must be an array");
3279
- }
3280
-
3281
2994
  var DrawTypeEnum;
3282
2995
  (function (DrawTypeEnum) {
3283
2996
  DrawTypeEnum["AdHoc"] = "AD_HOC";
@@ -3838,6 +3551,350 @@ var SexEnum;
3838
3551
  SexEnum["Other"] = "OTHER";
3839
3552
  })(SexEnum || (SexEnum = {}));
3840
3553
 
3554
+ function decorateResult(_a) {
3555
+ var context = _a.context, result = _a.result, stack = _a.stack, info = _a.info;
3556
+ if (result && !Array.isArray(result === null || result === void 0 ? void 0 : result.stack))
3557
+ result.stack = [];
3558
+ if (result && Array.isArray(result === null || result === void 0 ? void 0 : result.stack) && typeof stack === 'string') {
3559
+ result.stack.push(stack);
3560
+ }
3561
+ if (result && info) {
3562
+ result.info = info;
3563
+ }
3564
+ if (result && typeof context === 'object' && Object.keys(context).length) {
3565
+ Object.assign(result, definedAttributes(context));
3566
+ }
3567
+ if (result && !(result === null || result === void 0 ? void 0 : result.error) && !(result === null || result === void 0 ? void 0 : result.success)) {
3568
+ Object.assign(result, __assign({}, SUCCESS));
3569
+ }
3570
+ return result !== null && result !== void 0 ? result : { success: true };
3571
+ }
3572
+
3573
+ var ANY = 'ANY';
3574
+ var MALE = 'MALE';
3575
+ var MIXED = 'MIXED';
3576
+ var OTHER$3 = 'OTHER';
3577
+ var FEMALE = 'FEMALE';
3578
+ var genderConstants = {
3579
+ ANY: ANY,
3580
+ MALE: MALE,
3581
+ FEMALE: FEMALE,
3582
+ MIXED: MIXED,
3583
+ OTHER: OTHER$3,
3584
+ };
3585
+
3586
+ function genderValidityCheck(_a) {
3587
+ var referenceGender = _a.referenceGender, matchUpType = _a.matchUpType, gender = _a.gender;
3588
+ var stack = 'genderValidityCheck';
3589
+ if (referenceGender &&
3590
+ gender &&
3591
+ [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) &&
3592
+ [GenderEnum.Male, GenderEnum.Female].includes(gender)) {
3593
+ var valid = gender === referenceGender;
3594
+ return valid
3595
+ ? { valid: true }
3596
+ : decorateResult({
3597
+ result: { valid: false, error: INVALID_GENDER },
3598
+ context: { gender: gender },
3599
+ stack: stack,
3600
+ });
3601
+ }
3602
+ if (matchUpType === TypeEnum.Singles && referenceGender === MIXED)
3603
+ return decorateResult({
3604
+ info: 'matchUpType SINGLES is invalid for gender MIXED',
3605
+ result: { error: INVALID_GENDER, valid: false },
3606
+ stack: stack,
3607
+ });
3608
+ return { valid: true };
3609
+ }
3610
+
3611
+ var typeMatch = function (arr, type) {
3612
+ return arr.filter(Boolean).every(function (i) { return typeof i === type; });
3613
+ };
3614
+ var allNumeric = function (arr) { return arr.filter(Boolean).every(isNumeric); };
3615
+ function getCategoryAgeDetails(params) {
3616
+ var _a, _b;
3617
+ var category = params.category;
3618
+ if (typeof category !== 'object')
3619
+ return { error: INVALID_CATEGORY };
3620
+ var ageCategoryCode = category.ageCategoryCode, ageMaxDate = category.ageMaxDate, ageMinDate = category.ageMinDate, ageMax = category.ageMax, ageMin = category.ageMin;
3621
+ var categoryName = category.categoryName;
3622
+ var combinedAge;
3623
+ if (!typeMatch([ageCategoryCode, ageMaxDate, ageMinDate, categoryName], 'string') ||
3624
+ !allNumeric([ageMax, ageMin] ||
3625
+ ![ageMaxDate, ageMinDate].filter(Boolean).every(isValidDateString)))
3626
+ return { error: INVALID_CATEGORY };
3627
+ var consideredDate = (_a = params.consideredDate) !== null && _a !== void 0 ? _a : extractDate(new Date().toLocaleDateString('sv'));
3628
+ if (!isValidDateString(consideredDate))
3629
+ return { error: INVALID_DATE };
3630
+ // const [consideredYear, month, day] = consideredDate
3631
+ var _c = __read(consideredDate
3632
+ .split('-')
3633
+ .slice(0, 3)
3634
+ .map(function (n) { return parseInt(n); }), 1), consideredYear = _c[0];
3635
+ // const monthDay = `${zeroPad(month)}-${zeroPad(day)}`;
3636
+ var previousDayDate = dateStringDaysChange(consideredDate, -1);
3637
+ var _d = __read(previousDayDate
3638
+ .split('-')
3639
+ .slice(1, 3)
3640
+ .map(function (n) { return parseInt(n); }), 2), previousDayMonth = _d[0], previousDay = _d[1];
3641
+ var previousMonthDay = "".concat(zeroPad(previousDayMonth), "-").concat(zeroPad(previousDay));
3642
+ var nextDayDate = dateStringDaysChange(consideredDate, 1);
3643
+ var _e = __read(nextDayDate
3644
+ .split('-')
3645
+ .slice(1, 3)
3646
+ .map(function (n) { return parseInt(n); }), 2), nextDayMonth = _e[0], nextDay = _e[1];
3647
+ var nextMonthDay = "".concat(zeroPad(nextDayMonth), "-").concat(zeroPad(nextDay));
3648
+ var calculatedAgeMaxDate = ageMin && dateStringDaysChange(consideredDate, -1 * 365 * ageMin);
3649
+ var calculatedAgeMinDate = ageMax && dateStringDaysChange(consideredDate, -1 * 365 * ageMax);
3650
+ // collect errors; e.g. provided ageMin does not equal calculated ageMin
3651
+ var errors = [];
3652
+ var addError = function (errorString) {
3653
+ return !errors.includes(errorString) && errors.push(errorString);
3654
+ };
3655
+ ageCategoryCode = ageCategoryCode !== null && ageCategoryCode !== void 0 ? ageCategoryCode : categoryName;
3656
+ var prePost = /^([UO]?)(\d{1,2})([UO]?)$/;
3657
+ var extractCombined = /^C(\d{1,2})-(\d{1,2})$/;
3658
+ var isBetween = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.includes('-');
3659
+ var isCombined = isBetween && (ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined));
3660
+ var isCoded = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(prePost);
3661
+ // construct min or max date with or without year
3662
+ //const isYYMM = (datePart) => datePart.match(/^\d{2}-\d{2}$/);
3663
+ var constructedDate = function (y, df) { return "".concat(y, "-").concat(df); };
3664
+ var uPre = function (ageInt) {
3665
+ var ageMinYear = consideredYear - ageInt;
3666
+ var newMinDate = constructedDate(ageMinYear, nextMonthDay);
3667
+ if (category.ageMinDate && category.ageMinDate !== newMinDate)
3668
+ addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
3669
+ ageMinDate = newMinDate;
3670
+ if (ageCategoryCode) {
3671
+ if (category.ageMax && category.ageMax !== ageInt - 1) {
3672
+ addError("Invalid submitted ageMax: ".concat(ageMax));
3673
+ calculatedAgeMinDate = undefined;
3674
+ }
3675
+ ageMax = ageInt - 1;
3676
+ }
3677
+ };
3678
+ var uPost = function (ageInt) {
3679
+ var ageMinYear = consideredYear - ageInt - 1;
3680
+ var newMinDate = constructedDate(ageMinYear, nextMonthDay);
3681
+ if (category.ageMin && category.ageMin > ageInt) {
3682
+ addError("Invalid submitted ageMin: ".concat(ageMin));
3683
+ }
3684
+ if (category.ageMax && category.ageMax > ageInt) {
3685
+ addError("Invalid submitted ageMax: ".concat(ageMax));
3686
+ }
3687
+ if (category.ageMinDate && category.ageMinDate !== newMinDate)
3688
+ addError("Invalid submitted ageMinDate: ".concat(ageMinDate));
3689
+ ageMinDate = newMinDate;
3690
+ if (ageCategoryCode) {
3691
+ if (category.ageMax && category.ageMax !== ageInt) {
3692
+ addError("Invalid submitted ageMax: ".concat(ageMax));
3693
+ calculatedAgeMaxDate = undefined;
3694
+ }
3695
+ ageMax = ageInt;
3696
+ }
3697
+ };
3698
+ var oPre = function (ageInt) {
3699
+ var ageMaxYear = consideredYear - ageInt;
3700
+ var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
3701
+ if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
3702
+ addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
3703
+ ageMaxDate = newMaxDate;
3704
+ if (ageCategoryCode) {
3705
+ if (category.ageMin && category.ageMin !== ageInt + 1) {
3706
+ addError("Invalid submitted ageMin: ".concat(ageMin));
3707
+ calculatedAgeMaxDate = undefined;
3708
+ }
3709
+ ageMin = ageInt + 1;
3710
+ }
3711
+ };
3712
+ var oPost = function (ageInt) {
3713
+ var ageMaxYear = consideredYear - ageInt - 1;
3714
+ var newMaxDate = constructedDate(ageMaxYear, previousMonthDay);
3715
+ if (category.ageMaxDate && category.ageMaxDate !== newMaxDate)
3716
+ addError("Invalid submitted ageMaxDate: ".concat(ageMaxDate));
3717
+ ageMaxDate = newMaxDate;
3718
+ if (ageCategoryCode) {
3719
+ if (category.ageMin && category.ageMin !== ageInt) {
3720
+ addError("Invalid submitted ageMin: ".concat(ageMin));
3721
+ calculatedAgeMaxDate = undefined;
3722
+ }
3723
+ ageMin = ageInt;
3724
+ }
3725
+ };
3726
+ var processCode = function (code) {
3727
+ var _a = __read((code.match(prePost) || []).slice(1), 3), pre = _a[0], age = _a[1], post = _a[2];
3728
+ var ageInt = parseInt(age);
3729
+ if (pre === 'U') {
3730
+ if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
3731
+ addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
3732
+ }
3733
+ uPre(ageInt);
3734
+ }
3735
+ else if (pre === 'O') {
3736
+ oPre(ageInt);
3737
+ }
3738
+ if (post === 'U') {
3739
+ if (category.ageMaxDate && category.ageMaxDate !== ageMaxDate) {
3740
+ addError("Invalid submitted ageMaxDate: ".concat(category.ageMaxDate));
3741
+ }
3742
+ uPost(ageInt);
3743
+ }
3744
+ else if (post === 'O') {
3745
+ oPost(ageInt);
3746
+ }
3747
+ ageMaxDate = ageMaxDate !== null && ageMaxDate !== void 0 ? ageMaxDate : calculatedAgeMaxDate;
3748
+ ageMinDate = ageMinDate !== null && ageMinDate !== void 0 ? ageMinDate : calculatedAgeMinDate;
3749
+ };
3750
+ if (isCombined) {
3751
+ // min and max birthdates are not relevant
3752
+ // TODO: utility function to calculate combined age given two birthdates?
3753
+ ageMaxDate = undefined;
3754
+ ageMinDate = undefined;
3755
+ ageMax = undefined;
3756
+ ageMin = undefined;
3757
+ if (category.ageMin) {
3758
+ // calculate ageMaxDate
3759
+ var ageMaxYear = consideredYear - category.ageMin;
3760
+ ageMaxDate = constructedDate(ageMaxYear, previousMonthDay);
3761
+ }
3762
+ if (category.ageMax) {
3763
+ // calculate ageMinDate
3764
+ var ageMinYear = consideredYear - category.ageMax - 1;
3765
+ ageMinDate = constructedDate(ageMinYear, nextMonthDay);
3766
+ }
3767
+ var _f = __read(((_b = ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.match(extractCombined)) !== null && _b !== void 0 ? _b : [])
3768
+ .slice(1)
3769
+ .map(function (n) { return parseInt(n); }), 2), lowAge = _f[0], highAge = _f[1];
3770
+ if (lowAge <= highAge) {
3771
+ ageMin = lowAge;
3772
+ ageMax = highAge;
3773
+ combinedAge = true;
3774
+ }
3775
+ else {
3776
+ addError("Invalid combined age range ".concat(ageCategoryCode));
3777
+ }
3778
+ }
3779
+ else if (isBetween) {
3780
+ ageCategoryCode === null || ageCategoryCode === void 0 ? void 0 : ageCategoryCode.split('-').forEach(processCode);
3781
+ }
3782
+ else if (isCoded) {
3783
+ processCode(ageCategoryCode);
3784
+ }
3785
+ else {
3786
+ if (ageMin)
3787
+ oPre(ageMin);
3788
+ if (ageMax)
3789
+ uPost(ageMax);
3790
+ }
3791
+ if (ageMax && category.ageMin && category.ageMin > ageMax) {
3792
+ addError("Invalid submitted ageMin: ".concat(category.ageMin));
3793
+ ageMin = undefined;
3794
+ }
3795
+ var result = definedAttributes({
3796
+ consideredDate: consideredDate,
3797
+ combinedAge: combinedAge,
3798
+ ageMaxDate: ageMaxDate,
3799
+ ageMinDate: ageMinDate,
3800
+ ageMax: ageMax,
3801
+ ageMin: ageMin,
3802
+ });
3803
+ if (errors.length)
3804
+ result.errors = errors;
3805
+ return result;
3806
+ }
3807
+
3808
+ function validateCategory(_a) {
3809
+ var category = _a.category;
3810
+ if (!isObject(category))
3811
+ return { error: INVALID_VALUES };
3812
+ var categoryDetails = getCategoryAgeDetails({ category: category });
3813
+ if (categoryDetails.error)
3814
+ return { error: categoryDetails };
3815
+ var ratingMax = category.ratingMax, ratingMin = category.ratingMin;
3816
+ if (ratingMax && !isNumeric(ratingMax))
3817
+ return decorateResult({
3818
+ result: { error: INVALID_VALUES },
3819
+ context: { ratingMax: ratingMax },
3820
+ });
3821
+ if (ratingMin && !isNumeric(ratingMin))
3822
+ return decorateResult({
3823
+ result: { error: INVALID_VALUES },
3824
+ context: { ratingMin: ratingMin },
3825
+ });
3826
+ return __assign({}, categoryDetails);
3827
+ }
3828
+
3829
+ function categoryCanContain(_a) {
3830
+ var childCategory = _a.childCategory, withDetails = _a.withDetails, category = _a.category;
3831
+ var categoryDetails = validateCategory({ category: category });
3832
+ var childCategoryDetails = validateCategory({
3833
+ category: childCategory,
3834
+ });
3835
+ var invalidAgeMin = childCategoryDetails.ageMin &&
3836
+ ((categoryDetails.ageMin &&
3837
+ childCategoryDetails.ageMin < categoryDetails.ageMin) ||
3838
+ (categoryDetails.ageMax &&
3839
+ childCategoryDetails.ageMin > categoryDetails.ageMax));
3840
+ var invalidAgeMax = childCategoryDetails.ageMax &&
3841
+ ((categoryDetails.ageMax &&
3842
+ childCategoryDetails.ageMax > categoryDetails.ageMax) ||
3843
+ (categoryDetails.ageMin &&
3844
+ childCategoryDetails.ageMax < categoryDetails.ageMin));
3845
+ var invalidAgeMinDate = childCategoryDetails.ageMinDate &&
3846
+ categoryDetails.ageMaxDate &&
3847
+ new Date(childCategoryDetails.ageMinDate) >
3848
+ new Date(categoryDetails.ageMaxDate);
3849
+ var invalidAgeMaxDate = childCategoryDetails.ageMaxDate &&
3850
+ categoryDetails.ageMinDate &&
3851
+ new Date(childCategoryDetails.ageMaxDate) <
3852
+ new Date(categoryDetails.ageMinDate);
3853
+ var ratingComparison = category.ratingType &&
3854
+ childCategory.ratingType &&
3855
+ category.ratingType === childCategory.ratingType;
3856
+ var invalidRatingRange = ratingComparison &&
3857
+ ((category.ratingMin &&
3858
+ childCategory.ratingMin &&
3859
+ childCategory.ratingMin < category.ratingMin) ||
3860
+ (category.ratingMax &&
3861
+ childCategory.ratingMax &&
3862
+ childCategory.ratingMax > category.ratingMax) ||
3863
+ (category.ratingMin &&
3864
+ childCategory.ratingMax &&
3865
+ childCategory.ratingMax < category.ratingMin) ||
3866
+ (category.ratingMax &&
3867
+ childCategory.ratingMin &&
3868
+ childCategory.ratingMin > category.ratingMax));
3869
+ var invalidBallType = category.ballType &&
3870
+ childCategory.ballType &&
3871
+ category.ballType !== childCategory.ballType;
3872
+ var valid = !invalidRatingRange &&
3873
+ !invalidAgeMinDate &&
3874
+ !invalidAgeMaxDate &&
3875
+ !invalidBallType &&
3876
+ !invalidAgeMax &&
3877
+ !invalidAgeMin;
3878
+ var ignoreFalse = true;
3879
+ var result = definedAttributes({
3880
+ invalidRatingRange: invalidRatingRange,
3881
+ invalidAgeMinDate: invalidAgeMinDate,
3882
+ invalidAgeMaxDate: invalidAgeMaxDate,
3883
+ invalidBallType: invalidBallType,
3884
+ invalidAgeMax: invalidAgeMax,
3885
+ invalidAgeMin: invalidAgeMin,
3886
+ valid: valid,
3887
+ }, ignoreFalse);
3888
+ if (withDetails) {
3889
+ Object.assign(result, { categoryDetails: categoryDetails, childCategoryDetails: childCategoryDetails });
3890
+ }
3891
+ return result;
3892
+ }
3893
+
3894
+ function mustBeAnArray(value) {
3895
+ return "".concat(value, " must be an array");
3896
+ }
3897
+
3841
3898
  function validateTieFormat(params) {
3842
3899
  var _a, _b, _c, _d;
3843
3900
  var checkCategory = !!((params === null || params === void 0 ? void 0 : params.enforceCategory) !== false && (params === null || params === void 0 ? void 0 : params.category));
@@ -3972,17 +4029,19 @@ function validateCollectionDefinition(_a) {
3972
4029
  if (matchUpFormat && !matchUpFormatCode.isValid(matchUpFormat)) {
3973
4030
  errors.push("Invalid matchUpFormat: ".concat(matchUpFormat));
3974
4031
  }
3975
- if (checkGender &&
3976
- referenceGender &&
3977
- gender &&
3978
- [GenderEnum.Male, GenderEnum.Female].includes(referenceGender) &&
3979
- referenceGender !== gender) {
3980
- errors.push("Invalid gender: ".concat(gender));
3981
- return decorateResult({
3982
- result: { error: INVALID_GENDER, errors: errors },
3983
- context: { referenceGender: referenceGender, gender: gender },
3984
- stack: stack,
4032
+ if (checkGender) {
4033
+ var result = genderValidityCheck({
4034
+ referenceGender: referenceGender,
4035
+ matchUpType: matchUpType,
4036
+ gender: gender,
3985
4037
  });
4038
+ if (result.error) {
4039
+ return decorateResult({
4040
+ context: { referenceGender: referenceGender, gender: gender },
4041
+ result: result,
4042
+ stack: stack,
4043
+ });
4044
+ }
3986
4045
  }
3987
4046
  if (checkCategory && referenceCategory && category) {
3988
4047
  var result = categoryCanContain({
@@ -6912,7 +6971,7 @@ var PUBLIC = 'PUBLIC';
6912
6971
  var STATUS$1 = 'STATUS';
6913
6972
  var MODIFICATION = 'MODIFICATION';
6914
6973
  var RETRIEVAL = 'RETRIEVAL';
6915
- var OTHER$3 = 'other';
6974
+ var OTHER$2 = 'other';
6916
6975
  var timeItemConstants = {
6917
6976
  MUTUALLY_EXCLUSIVE_TIME_MODIFIERS: MUTUALLY_EXCLUSIVE_TIME_MODIFIERS,
6918
6977
  AFTER_REST: AFTER_REST,
@@ -6931,7 +6990,7 @@ var timeItemConstants = {
6931
6990
  MODIFICATION: MODIFICATION,
6932
6991
  NEXT_AVAILABLE: NEXT_AVAILABLE,
6933
6992
  NOT_BEFORE: NOT_BEFORE,
6934
- OTHER: OTHER$3,
6993
+ OTHER: OTHER$2,
6935
6994
  PENALTY: PENALTY$1,
6936
6995
  PUBLIC: PUBLIC,
6937
6996
  PUBLISH: PUBLISH,
@@ -7768,41 +7827,6 @@ function getMatchUpType(params) {
7768
7827
  return { matchUpType: matchUpType };
7769
7828
  }
7770
7829
 
7771
- function modifyEntryProfile(_a) {
7772
- var drawDefinition = _a.drawDefinition, attributes = _a.attributes;
7773
- var extension = findDrawDefinitionExtension({
7774
- name: ENTRY_PROFILE,
7775
- drawDefinition: drawDefinition,
7776
- }).extension;
7777
- var entryProfile = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
7778
- attributes.forEach(function (attribute) {
7779
- Object.keys(attribute).forEach(function (key) {
7780
- if (!entryProfile[key]) {
7781
- entryProfile[key] = attribute[key];
7782
- }
7783
- else {
7784
- Object.assign(entryProfile[key], attribute[key]);
7785
- }
7786
- });
7787
- });
7788
- extension = {
7789
- name: ENTRY_PROFILE,
7790
- value: entryProfile,
7791
- };
7792
- addDrawDefinitionExtension({ drawDefinition: drawDefinition, extension: extension });
7793
- return { entryProfile: entryProfile };
7794
- }
7795
-
7796
- function getEntryProfile(_a) {
7797
- var drawDefinition = _a.drawDefinition;
7798
- var extension = findDrawDefinitionExtension({
7799
- name: ENTRY_PROFILE,
7800
- drawDefinition: drawDefinition,
7801
- }).extension;
7802
- var entryProfile = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
7803
- return { entryProfile: entryProfile };
7804
- }
7805
-
7806
7830
  var _a$i, _b$5, _c$1;
7807
7831
  // stage types
7808
7832
  var MAIN = 'MAIN';
@@ -7861,6 +7885,7 @@ var FIRST_MATCHUP = 'FIRST_MATCHUP'; // condition for valididty of link
7861
7885
  // draw types
7862
7886
  // PLAY_OFF is also a stage type
7863
7887
  var AD_HOC = 'AD_HOC';
7888
+ var FLEX_ROUNDS = 'AD_HOC';
7864
7889
  var FEED_IN$1 = 'FEED_IN';
7865
7890
  var COMPASS = 'COMPASS';
7866
7891
  var OLYMPIC = 'OLYMPIC';
@@ -7954,6 +7979,7 @@ var drawDefinitionConstants = {
7954
7979
  LOSER: LOSER,
7955
7980
  AD_HOC: AD_HOC,
7956
7981
  FEED_IN: FEED_IN$1,
7982
+ FLEX_ROUNDS: FLEX_ROUNDS,
7957
7983
  COMPASS: COMPASS,
7958
7984
  PLAY_OFF: PLAY_OFF,
7959
7985
  OLYMPIC: OLYMPIC,
@@ -8092,6 +8118,119 @@ function getDrawStructures(_a) {
8092
8118
  }
8093
8119
  }
8094
8120
 
8121
+ function getAllPositionedParticipantIds(_a) {
8122
+ var drawDefinition = _a.drawDefinition;
8123
+ if (!drawDefinition)
8124
+ return { error: MISSING_DRAW_DEFINITION };
8125
+ var stagePositionedParticipantIds = {};
8126
+ var allPositionedParticipantIds = (drawDefinition.structures || [])
8127
+ .map(function (structure) {
8128
+ var _a;
8129
+ var _b;
8130
+ var stage = structure.stage;
8131
+ if (!stagePositionedParticipantIds[stage])
8132
+ stagePositionedParticipantIds[stage] = [];
8133
+ var positionAssignments = getPositionAssignments$1({ structure: structure }).positionAssignments;
8134
+ var particiapntIds = (_b = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.map(extractAttributes('participantId')).filter(Boolean)) !== null && _b !== void 0 ? _b : [];
8135
+ (_a = stagePositionedParticipantIds[stage]).push.apply(_a, __spreadArray([], __read(particiapntIds), false));
8136
+ return particiapntIds;
8137
+ })
8138
+ .flat();
8139
+ return { allPositionedParticipantIds: allPositionedParticipantIds, stagePositionedParticipantIds: stagePositionedParticipantIds };
8140
+ }
8141
+ function getPositionAssignments$1(_a) {
8142
+ var _b;
8143
+ var drawDefinition = _a.drawDefinition, structureId = _a.structureId, structure = _a.structure;
8144
+ var error, positionAssignments = [];
8145
+ if (!structure) {
8146
+ if (!drawDefinition) {
8147
+ return { positionAssignments: positionAssignments, error: MISSING_DRAW_DEFINITION };
8148
+ }
8149
+ (_b = findStructure({ drawDefinition: drawDefinition, structureId: structureId }), structure = _b.structure, error = _b.error);
8150
+ if (error)
8151
+ return { positionAssignments: positionAssignments, error: error };
8152
+ }
8153
+ if (structure.structures) {
8154
+ positionAssignments = [].concat.apply([], __spreadArray([], __read(structure.structures.map(function (structure) {
8155
+ return getPositionAssignments$1({ structure: structure }).positionAssignments;
8156
+ })), false));
8157
+ }
8158
+ else if (structure.positionAssignments) {
8159
+ positionAssignments = structure.positionAssignments;
8160
+ }
8161
+ else {
8162
+ error = MISSING_POSITION_ASSIGNMENTS;
8163
+ }
8164
+ return { positionAssignments: positionAssignments, error: error };
8165
+ }
8166
+ function structureAssignedDrawPositions(_a) {
8167
+ var _b;
8168
+ var drawDefinition = _a.drawDefinition, structureId = _a.structureId, structure = _a.structure;
8169
+ var positionAssignments = ((_b = getPositionAssignments$1({
8170
+ drawDefinition: drawDefinition,
8171
+ structureId: structureId,
8172
+ structure: structure,
8173
+ })) === null || _b === void 0 ? void 0 : _b.positionAssignments) || [];
8174
+ var assignedPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8175
+ var _a, _b;
8176
+ return (_b = (_a = assignment.participantId) !== null && _a !== void 0 ? _a : assignment.bye) !== null && _b !== void 0 ? _b : assignment.qualifier;
8177
+ });
8178
+ var allPositionsAssigned = positionAssignments &&
8179
+ (positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.length) === (assignedPositions === null || assignedPositions === void 0 ? void 0 : assignedPositions.length);
8180
+ var unassignedPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8181
+ return (!assignment.participantId && !assignment.bye && !assignment.qualifier);
8182
+ });
8183
+ var byePositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8184
+ return !assignment.participantId && assignment.bye;
8185
+ });
8186
+ var qualifierPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8187
+ return !assignment.participantId && assignment.qualifier;
8188
+ });
8189
+ return {
8190
+ allPositionsAssigned: allPositionsAssigned,
8191
+ positionAssignments: positionAssignments,
8192
+ unassignedPositions: unassignedPositions,
8193
+ assignedPositions: assignedPositions,
8194
+ qualifierPositions: qualifierPositions,
8195
+ byePositions: byePositions,
8196
+ };
8197
+ }
8198
+
8199
+ function modifyEntryProfile(_a) {
8200
+ var drawDefinition = _a.drawDefinition, attributes = _a.attributes;
8201
+ var extension = findDrawDefinitionExtension({
8202
+ name: ENTRY_PROFILE,
8203
+ drawDefinition: drawDefinition,
8204
+ }).extension;
8205
+ var entryProfile = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
8206
+ attributes.forEach(function (attribute) {
8207
+ Object.keys(attribute).forEach(function (key) {
8208
+ if (!entryProfile[key]) {
8209
+ entryProfile[key] = attribute[key];
8210
+ }
8211
+ else {
8212
+ Object.assign(entryProfile[key], attribute[key]);
8213
+ }
8214
+ });
8215
+ });
8216
+ extension = {
8217
+ name: ENTRY_PROFILE,
8218
+ value: entryProfile,
8219
+ };
8220
+ addDrawDefinitionExtension({ drawDefinition: drawDefinition, extension: extension });
8221
+ return { entryProfile: entryProfile };
8222
+ }
8223
+
8224
+ function getEntryProfile(_a) {
8225
+ var drawDefinition = _a.drawDefinition;
8226
+ var extension = findDrawDefinitionExtension({
8227
+ name: ENTRY_PROFILE,
8228
+ drawDefinition: drawDefinition,
8229
+ }).extension;
8230
+ var entryProfile = (extension === null || extension === void 0 ? void 0 : extension.value) || {};
8231
+ return { entryProfile: entryProfile };
8232
+ }
8233
+
8095
8234
  var ALTERNATE = exports.EntryStatusEnum.Alternate;
8096
8235
  var CONFIRMED = exports.EntryStatusEnum.Confirmed;
8097
8236
  var DIRECT_ACCEPTANCE = exports.EntryStatusEnum.DirectAcceptance;
@@ -8348,11 +8487,14 @@ function getStageWildcardEntriesCount(_a) {
8348
8487
  function getStructureSeedAssignments(_a) {
8349
8488
  var _b;
8350
8489
  var _c;
8351
- var provisionalPositioning = _a.provisionalPositioning, drawDefinition = _a.drawDefinition, structureId = _a.structureId, structure = _a.structure;
8490
+ var provisionalPositioning = _a.provisionalPositioning, returnAllProxies = _a.returnAllProxies, drawDefinition = _a.drawDefinition, structureId = _a.structureId, structure = _a.structure;
8352
8491
  var error, seedAssignments = [];
8353
8492
  if (!structure) {
8354
8493
  (_b = findStructure({ drawDefinition: drawDefinition, structureId: structureId }), structure = _b.structure, error = _b.error);
8355
8494
  }
8495
+ var positionAssignments = getPositionAssignments$1({
8496
+ structure: structure,
8497
+ }).positionAssignments;
8356
8498
  if (error || !structure)
8357
8499
  return { seedAssignments: [], error: STRUCTURE_NOT_FOUND };
8358
8500
  if (!structureId)
@@ -8368,7 +8510,7 @@ function getStructureSeedAssignments(_a) {
8368
8510
  structureId: structureId,
8369
8511
  stage: stage,
8370
8512
  });
8371
- var seedProxies = entries
8513
+ var proxiedEntries = entries
8372
8514
  ? entries
8373
8515
  .filter(function (entry) { return entry.placementGroup === 1; })
8374
8516
  .sort(function (a, b) {
@@ -8383,11 +8525,12 @@ function getStructureSeedAssignments(_a) {
8383
8525
  return {
8384
8526
  participantId: entry.participantId,
8385
8527
  seedValue: seedNumber,
8528
+ seedProxy: true,
8386
8529
  seedNumber: seedNumber,
8387
- seedProxy: true, // flag so that proxy seeding information doesn't get used externally
8388
8530
  };
8389
8531
  })
8390
8532
  : [];
8533
+ var seedProxies = proxiedEntries === null || proxiedEntries === void 0 ? void 0 : proxiedEntries.slice(0, returnAllProxies ? proxiedEntries.length : positionAssignments.length / 2);
8391
8534
  if (seedProxies.length) {
8392
8535
  // seedProxies are only found in PLAY_OFF when ROUND_ROBIN is MAIN stage
8393
8536
  seedAssignments = seedProxies;
@@ -8399,7 +8542,13 @@ function getStructureSeedAssignments(_a) {
8399
8542
  error = MISSING_SEED_ASSIGNMENTS;
8400
8543
  }
8401
8544
  var seedLimit = structure.seedLimit || ((_c = structure === null || structure === void 0 ? void 0 : structure.positionAssignments) === null || _c === void 0 ? void 0 : _c.length);
8402
- return { seedAssignments: seedAssignments, seedLimit: seedLimit, stage: stage, stageSequence: stageSequence, error: error };
8545
+ return {
8546
+ seedAssignments: seedAssignments,
8547
+ stageSequence: stageSequence,
8548
+ seedLimit: seedLimit,
8549
+ stage: stage,
8550
+ error: error,
8551
+ };
8403
8552
  }
8404
8553
 
8405
8554
  function getExitProfiles(_a) {
@@ -8723,84 +8872,6 @@ function getSourceDrawPositionRanges(_a) {
8723
8872
  * }
8724
8873
  */
8725
8874
 
8726
- function getAllPositionedParticipantIds(_a) {
8727
- var drawDefinition = _a.drawDefinition;
8728
- if (!drawDefinition)
8729
- return { error: MISSING_DRAW_DEFINITION };
8730
- var stagePositionedParticipantIds = {};
8731
- var allPositionedParticipantIds = (drawDefinition.structures || [])
8732
- .map(function (structure) {
8733
- var _a;
8734
- var _b;
8735
- var stage = structure.stage;
8736
- if (!stagePositionedParticipantIds[stage])
8737
- stagePositionedParticipantIds[stage] = [];
8738
- var positionAssignments = getPositionAssignments$1({ structure: structure }).positionAssignments;
8739
- var particiapntIds = (_b = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.map(extractAttributes('participantId')).filter(Boolean)) !== null && _b !== void 0 ? _b : [];
8740
- (_a = stagePositionedParticipantIds[stage]).push.apply(_a, __spreadArray([], __read(particiapntIds), false));
8741
- return particiapntIds;
8742
- })
8743
- .flat();
8744
- return { allPositionedParticipantIds: allPositionedParticipantIds, stagePositionedParticipantIds: stagePositionedParticipantIds };
8745
- }
8746
- function getPositionAssignments$1(_a) {
8747
- var _b;
8748
- var drawDefinition = _a.drawDefinition, structureId = _a.structureId, structure = _a.structure;
8749
- var error, positionAssignments = [];
8750
- if (!structure) {
8751
- if (!drawDefinition) {
8752
- return { positionAssignments: positionAssignments, error: MISSING_DRAW_DEFINITION };
8753
- }
8754
- (_b = findStructure({ drawDefinition: drawDefinition, structureId: structureId }), structure = _b.structure, error = _b.error);
8755
- if (error)
8756
- return { positionAssignments: positionAssignments, error: error };
8757
- }
8758
- if (structure.structures) {
8759
- positionAssignments = [].concat.apply([], __spreadArray([], __read(structure.structures.map(function (structure) {
8760
- return getPositionAssignments$1({ structure: structure }).positionAssignments;
8761
- })), false));
8762
- }
8763
- else if (structure.positionAssignments) {
8764
- positionAssignments = structure.positionAssignments;
8765
- }
8766
- else {
8767
- error = MISSING_POSITION_ASSIGNMENTS;
8768
- }
8769
- return { positionAssignments: positionAssignments, error: error };
8770
- }
8771
- function structureAssignedDrawPositions(_a) {
8772
- var _b;
8773
- var drawDefinition = _a.drawDefinition, structureId = _a.structureId, structure = _a.structure;
8774
- var positionAssignments = ((_b = getPositionAssignments$1({
8775
- drawDefinition: drawDefinition,
8776
- structureId: structureId,
8777
- structure: structure,
8778
- })) === null || _b === void 0 ? void 0 : _b.positionAssignments) || [];
8779
- var assignedPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8780
- var _a, _b;
8781
- return (_b = (_a = assignment.participantId) !== null && _a !== void 0 ? _a : assignment.bye) !== null && _b !== void 0 ? _b : assignment.qualifier;
8782
- });
8783
- var allPositionsAssigned = positionAssignments &&
8784
- (positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.length) === (assignedPositions === null || assignedPositions === void 0 ? void 0 : assignedPositions.length);
8785
- var unassignedPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8786
- return (!assignment.participantId && !assignment.bye && !assignment.qualifier);
8787
- });
8788
- var byePositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8789
- return !assignment.participantId && assignment.bye;
8790
- });
8791
- var qualifierPositions = positionAssignments === null || positionAssignments === void 0 ? void 0 : positionAssignments.filter(function (assignment) {
8792
- return !assignment.participantId && assignment.qualifier;
8793
- });
8794
- return {
8795
- allPositionsAssigned: allPositionsAssigned,
8796
- positionAssignments: positionAssignments,
8797
- unassignedPositions: unassignedPositions,
8798
- assignedPositions: assignedPositions,
8799
- qualifierPositions: qualifierPositions,
8800
- byePositions: byePositions,
8801
- };
8802
- }
8803
-
8804
8875
  function getOrderedDrawPositions(_a) {
8805
8876
  var _b;
8806
8877
  var drawPositions = _a.drawPositions, roundProfile = _a.roundProfile, roundNumber = _a.roundNumber;
@@ -9452,19 +9523,6 @@ function getSeeding(_a) {
9452
9523
  });
9453
9524
  }
9454
9525
 
9455
- var ANY = 'ANY';
9456
- var MALE = 'MALE';
9457
- var MIXED = 'MIXED';
9458
- var OTHER$2 = 'OTHER';
9459
- var FEMALE = 'FEMALE';
9460
- var genderConstants = {
9461
- ANY: ANY,
9462
- MALE: MALE,
9463
- FEMALE: FEMALE,
9464
- MIXED: MIXED,
9465
- OTHER: OTHER$2,
9466
- };
9467
-
9468
9526
  function getAllStructureMatchUps(_a) {
9469
9527
  var _b, _c, _d, _e, _f, _g, _h;
9470
9528
  var scheduleVisibilityFilters = _a.scheduleVisibilityFilters, tournamentAppliedPolicies = _a.tournamentAppliedPolicies, provisionalPositioning = _a.provisionalPositioning, tournamentParticipants = _a.tournamentParticipants, afterRecoveryTimes = _a.afterRecoveryTimes, policyDefinitions = _a.policyDefinitions, tournamentRecord = _a.tournamentRecord, seedAssignments = _a.seedAssignments, contextFilters = _a.contextFilters, contextContent = _a.contextContent, matchUpFilters = _a.matchUpFilters, participantMap = _a.participantMap, scheduleTiming = _a.scheduleTiming, contextProfile = _a.contextProfile, drawDefinition = _a.drawDefinition, _j = _a.context, context = _j === void 0 ? {} : _j, exitProfiles = _a.exitProfiles, matchUpsMap = _a.matchUpsMap, structure = _a.structure, inContext = _a.inContext, event = _a.event;
@@ -22995,10 +23053,11 @@ function updateMatchUpStatusCodes(_a) {
22995
23053
  // ... and fed positions are always sideNumber 1
22996
23054
  (sourceMatchUp.structureId === (pairedMatchUp === null || pairedMatchUp === void 0 ? void 0 : pairedMatchUp.structureId) && 2) || 1;
22997
23055
  matchUp.matchUpStatusCodes = ((_b = matchUp.matchUpStatusCodes) !== null && _b !== void 0 ? _b : []).map(function (code) {
22998
- if (code.sideNumber === sourceSideNumber_1) {
22999
- return __assign(__assign({}, code), { previousMatchUpStatus: sourceMatchUpStatus });
23056
+ var value = isString(code) || !isNaN(code) ? { code: code } : code;
23057
+ if (value.sideNumber === sourceSideNumber_1) {
23058
+ return __assign(__assign({}, value), { previousMatchUpStatus: sourceMatchUpStatus });
23000
23059
  }
23001
- return code;
23060
+ return value;
23002
23061
  });
23003
23062
  }
23004
23063
  }
@@ -25832,7 +25891,7 @@ function getSeedingThresholds(_a) {
25832
25891
 
25833
25892
  function getValidSeedBlocks(_a) {
25834
25893
  var _b, _c;
25835
- var provisionalPositioning = _a.provisionalPositioning, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, allPositions = _a.allPositions, structure = _a.structure;
25894
+ var provisionalPositioning = _a.provisionalPositioning, returnAllProxies = _a.returnAllProxies, appliedPolicies = _a.appliedPolicies, drawDefinition = _a.drawDefinition, allPositions = _a.allPositions, structure = _a.structure;
25836
25895
  var validSeedBlocks = [];
25837
25896
  if (!structure)
25838
25897
  return { error: MISSING_STRUCTURE };
@@ -25843,6 +25902,7 @@ function getValidSeedBlocks(_a) {
25843
25902
  }), matchUps = _d.matchUps, roundMatchUps = _d.roundMatchUps;
25844
25903
  var seedAssignments = getStructureSeedAssignments({
25845
25904
  provisionalPositioning: provisionalPositioning,
25905
+ returnAllProxies: returnAllProxies,
25846
25906
  drawDefinition: drawDefinition,
25847
25907
  structure: structure,
25848
25908
  }).seedAssignments;
@@ -26083,6 +26143,7 @@ function getNextSeedBlock(params) {
26083
26143
  var provisionalPositioning = params.provisionalPositioning, drawDefinition = params.drawDefinition, seedBlockInfo = params.seedBlockInfo, structureId = params.structureId, randomize = params.randomize;
26084
26144
  var structure = findStructure({ drawDefinition: drawDefinition, structureId: structureId }).structure;
26085
26145
  var seedAssignments = getStructureSeedAssignments({
26146
+ returnAllProxies: params.returnAllProxies,
26086
26147
  provisionalPositioning: provisionalPositioning,
26087
26148
  drawDefinition: drawDefinition,
26088
26149
  structure: structure,
@@ -26094,6 +26155,7 @@ function getNextSeedBlock(params) {
26094
26155
  var validSeedBlocks = (seedBlockInfo === null || seedBlockInfo === void 0 ? void 0 : seedBlockInfo.validSeedBlocks) ||
26095
26156
  (structure &&
26096
26157
  ((_a = getValidSeedBlocks({
26158
+ returnAllProxies: params.returnAllProxies,
26097
26159
  provisionalPositioning: provisionalPositioning,
26098
26160
  appliedPolicies: appliedPolicies,
26099
26161
  drawDefinition: drawDefinition,
@@ -41377,7 +41439,7 @@ function engineLogging(_a) {
41377
41439
  log.result = result;
41378
41440
  }
41379
41441
  if (Object.keys(log).length > 1)
41380
- console.log(engine, log);
41442
+ globalLog$1(engine, log);
41381
41443
  if (result && devContext.makeDeepCopy)
41382
41444
  result.deepCopyIterations = getDeepCopyIterations();
41383
41445
  }
@@ -44328,6 +44390,50 @@ function generateDrawTypeAndModifyDrawDefinition$1(params) {
44328
44390
  return __assign(__assign({ inContextDrawMatchUps: inContextDrawMatchUps, drawDefinition: drawDefinition, matchUpsMap: matchUpsMap }, SUCCESS), { structures: structures, matchUps: matchUps, links: links });
44329
44391
  }
44330
44392
 
44393
+ function processAccessors(_a) {
44394
+ var significantCharacters = _a.significantCharacters, _b = _a.accessors, accessors = _b === void 0 ? [] : _b, value = _a.value;
44395
+ var extractedValues = [];
44396
+ var accessor = accessors[0];
44397
+ if (value === null || value === void 0 ? void 0 : value[accessor]) {
44398
+ var remainingKeys_1 = accessors.slice(1);
44399
+ if (Array.isArray(value[accessor])) {
44400
+ var values = value[accessor];
44401
+ values.forEach(function (nestedValue) {
44402
+ var result = processAccessors({
44403
+ accessors: remainingKeys_1,
44404
+ significantCharacters: significantCharacters,
44405
+ value: nestedValue,
44406
+ });
44407
+ extractedValues.push.apply(extractedValues, __spreadArray([], __read(result), false));
44408
+ });
44409
+ }
44410
+ else {
44411
+ value = value[accessor];
44412
+ if (remainingKeys_1.length) {
44413
+ var result = processAccessors({
44414
+ accessors: remainingKeys_1,
44415
+ significantCharacters: significantCharacters,
44416
+ value: value,
44417
+ });
44418
+ extractedValues.push.apply(extractedValues, __spreadArray([], __read(result), false));
44419
+ }
44420
+ else {
44421
+ checkValue({ value: value });
44422
+ }
44423
+ }
44424
+ }
44425
+ function checkValue(_a) {
44426
+ var value = _a.value;
44427
+ if (value && ['string', 'number'].includes(typeof value)) {
44428
+ var extractedValue = significantCharacters
44429
+ ? value.slice(0, significantCharacters)
44430
+ : value;
44431
+ extractedValues.push(extractedValue);
44432
+ }
44433
+ }
44434
+ return extractedValues;
44435
+ }
44436
+
44331
44437
  function getAttributeGroupings(_a) {
44332
44438
  var targetParticipantIds = _a.targetParticipantIds, policyAttributes = _a.policyAttributes, idCollections = _a.idCollections, participants = _a.participants;
44333
44439
  if (!Array.isArray(policyAttributes)) {
@@ -44369,8 +44475,12 @@ function extractAttributeValues(_a) {
44369
44475
  policyAttributes.forEach(function (policyAttribute) {
44370
44476
  var _a = policyAttribute || {}, directive = _a.directive, groupings = _a.groupings, key = _a.key, significantCharacters = _a.significantCharacters;
44371
44477
  if (key) {
44372
- var keys = key.split('.');
44373
- processKeys({ value: participant, keys: keys, significantCharacters: significantCharacters });
44478
+ var accessors = key.split('.');
44479
+ extractedValues.push.apply(extractedValues, __spreadArray([], __read(processAccessors({
44480
+ significantCharacters: significantCharacters,
44481
+ value: participant,
44482
+ accessors: accessors,
44483
+ })), false));
44374
44484
  }
44375
44485
  else if (directive) {
44376
44486
  // extractedValues are values to be avoided
@@ -44400,53 +44510,6 @@ function extractAttributeValues(_a) {
44400
44510
  });
44401
44511
  var values = unique(extractedValues);
44402
44512
  return { values: values };
44403
- function processKeys(_a) {
44404
- var e_1, _b;
44405
- var value = _a.value, _c = _a.keys, keys = _c === void 0 ? [] : _c, significantCharacters = _a.significantCharacters;
44406
- var _loop_1 = function (index, key) {
44407
- if (value === null || value === void 0 ? void 0 : value[key]) {
44408
- if (Array.isArray(value[key])) {
44409
- var values_1 = value[key];
44410
- var remainingKeys_1 = keys.slice(index);
44411
- values_1.forEach(function (nestedValue) {
44412
- return processKeys({
44413
- value: nestedValue,
44414
- keys: remainingKeys_1,
44415
- significantCharacters: significantCharacters,
44416
- });
44417
- });
44418
- }
44419
- else {
44420
- value = value[key];
44421
- checkValue({ value: value, index: index });
44422
- }
44423
- }
44424
- };
44425
- try {
44426
- for (var _d = __values(keys.entries()), _e = _d.next(); !_e.done; _e = _d.next()) {
44427
- var _f = __read(_e.value, 2), index = _f[0], key = _f[1];
44428
- _loop_1(index, key);
44429
- }
44430
- }
44431
- catch (e_1_1) { e_1 = { error: e_1_1 }; }
44432
- finally {
44433
- try {
44434
- if (_e && !_e.done && (_b = _d.return)) _b.call(_d);
44435
- }
44436
- finally { if (e_1) throw e_1.error; }
44437
- }
44438
- function checkValue(_a) {
44439
- var value = _a.value, index = _a.index;
44440
- if (value &&
44441
- index === keys.length - 1 &&
44442
- ['string', 'number'].includes(typeof value)) {
44443
- var extractedValue = significantCharacters
44444
- ? value.slice(0, significantCharacters)
44445
- : value;
44446
- extractedValues.push(extractedValue);
44447
- }
44448
- }
44449
- }
44450
44513
  }
44451
44514
 
44452
44515
  function getPositionedParticipants(_a) {
@@ -44893,22 +44956,6 @@ function getSwapOptions(_a) {
44893
44956
  .flat(1);
44894
44957
  }
44895
44958
 
44896
- /**
44897
- *
44898
- * NOTE: some of these parameters are passed directly through to other functions via ...params
44899
- *
44900
- * @param {object[]} initialPositionAssignments - positionAssignments before any new participants placed
44901
- * @param {object[]} participantsWithGroupings - participants with added team/group/pair participantIds arrays
44902
- * @param {string[]} unseededParticipantIds - ids of participants who are unseeded
44903
- * @param {object[]} drawPositionChunks - drawPositions grouped by round starting with the final round
44904
- * @param {object[]} drawPositionGroups - drawPositions paird with their initial round opponent drawPosition
44905
- * @param {object[]} policyAttributes - { key: '' } objects defining accessors for participant values to be compared
44906
- * @param {object} drawDefinition - drawDefinition object
44907
- * @param {boolean} pairedPriority - flag whether to prioritize positions which already have one opponent placed
44908
- * @param {string} structureId - id of the structure in which participants are to be placed
44909
- * @param {object[]} allGroups - map of values and participantIds which have those values
44910
- *
44911
- */
44912
44959
  function generatePositioningCandidate(params) {
44913
44960
  var initialPositionAssignments = params.initialPositionAssignments, participantsWithGroupings = params.participantsWithGroupings, opponentsToPlaceCount = params.opponentsToPlaceCount, unseededByePositions = params.unseededByePositions, drawPositionGroups = params.drawPositionGroups, policyAttributes = params.policyAttributes, idCollections = params.idCollections, allGroups = params.allGroups;
44914
44961
  var errors = [];
@@ -45022,7 +45069,8 @@ function swapAssignedPositions(_a) {
45022
45069
  function randomUnseededSeparation(_a) {
45023
45070
  var e_1, _b;
45024
45071
  var _c, _d;
45025
- var provisionalPositioning = _a.provisionalPositioning, unseededParticipantIds = _a.unseededParticipantIds, inContextDrawMatchUps = _a.inContextDrawMatchUps, unseededByePositions = _a.unseededByePositions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, participants = _a.participants, matchUpsMap = _a.matchUpsMap, structureId = _a.structureId, avoidance = _a.avoidance, drawSize = _a.drawSize, entries = _a.entries, // entries for the specific stage of drawDefinition
45072
+ var provisionalPositioning = _a.provisionalPositioning, unseededParticipantIds = _a.unseededParticipantIds, inContextDrawMatchUps = _a.inContextDrawMatchUps, unseededByePositions = _a.unseededByePositions, tournamentRecord = _a.tournamentRecord, drawDefinition = _a.drawDefinition, seedBlockInfo = _a.seedBlockInfo, participants = _a.participants, matchUpsMap = _a.matchUpsMap, structureId = _a.structureId, avoidance = _a.avoidance, drawSize = _a.drawSize,
45073
+ // entries, // entries for the specific stage of drawDefinition
45026
45074
  event = _a.event;
45027
45075
  if (!avoidance) {
45028
45076
  return { error: MISSING_AVOIDANCE_POLICY };
@@ -45061,16 +45109,17 @@ function randomUnseededSeparation(_a) {
45061
45109
  var _f = isRoundRobin
45062
45110
  ? roundRobinParticipantGroups(params)
45063
45111
  : eliminationParticipantGroups(params), drawPositionGroups = _f.drawPositionGroups, drawPositionChunks = _f.drawPositionChunks;
45064
- var idCollections = {};
45065
- idCollections.groupParticipants = participants
45066
- .filter(function (participant) { return participant.participantType === GROUP; })
45067
- .map(function (participant) { return participant.participantId; });
45068
- idCollections.teamParticipants = participants
45069
- .filter(function (participant) { return participant.participantType === TEAM; })
45070
- .map(function (participant) { return participant.participantId; });
45071
- idCollections.pairParticipants = participants
45072
- .filter(function (participant) { return participant.participantType === PAIR; })
45073
- .map(function (participant) { return participant.participantId; });
45112
+ var idCollections = {
45113
+ groupParticipants: participants
45114
+ .filter(function (participant) { return participant.participantType === GROUP; })
45115
+ .map(function (participant) { return participant.participantId; }),
45116
+ teamParticipants: participants
45117
+ .filter(function (participant) { return participant.participantType === TEAM; })
45118
+ .map(function (participant) { return participant.participantId; }),
45119
+ pairParticipants: participants
45120
+ .filter(function (participant) { return participant.participantType === PAIR; })
45121
+ .map(function (participant) { return participant.participantId; }),
45122
+ };
45074
45123
  var allGroups = getAttributeGroupings({
45075
45124
  targetParticipantIds: unseededParticipantIds,
45076
45125
  policyAttributes: policyAttributes,
@@ -45127,7 +45176,7 @@ function randomUnseededSeparation(_a) {
45127
45176
  idCollections: idCollections,
45128
45177
  allGroups: allGroups,
45129
45178
  drawSize: drawSize,
45130
- entries: entries,
45179
+ // entries,
45131
45180
  });
45132
45181
  });
45133
45182
  var candidates = noPairPriorityCandidates
@@ -45252,7 +45301,7 @@ function positionUnseededParticipants(_a) {
45252
45301
  drawDefinition: drawDefinition,
45253
45302
  event: event,
45254
45303
  }).appliedPolicies;
45255
- var avoidance = (appliedPolicies !== null && appliedPolicies !== void 0 ? appliedPolicies : {}).avoidance;
45304
+ var avoidance = (appliedPolicies !== null && appliedPolicies !== void 0 ? appliedPolicies : {})[POLICY_TYPE_AVOIDANCE];
45256
45305
  if (structure.stage === PLAY_OFF) {
45257
45306
  // generate avoidance policies automatically for Playoffs from Round Robin Groups
45258
45307
  var groupings = entries.reduce(function (groupings, entry) {
@@ -45516,11 +45565,11 @@ function getSeedOrderByePositions(_a) {
45516
45565
  var strictSeedOrderByePositions = getOrderedByePositions({
45517
45566
  orderedSeedDrawPositions: orderedSortedFirstRoundSeededDrawPositions,
45518
45567
  relevantMatchUps: relevantMatchUps,
45519
- }).slice(0, positionedSeeds.length);
45568
+ }).slice(0, byesToPlace);
45520
45569
  var blockSeedOrderByePositions = getOrderedByePositions({
45521
45570
  orderedSeedDrawPositions: blockSortedRandomDrawPositions,
45522
45571
  relevantMatchUps: relevantMatchUps,
45523
- }).slice(0, positionedSeeds.length);
45572
+ }).slice(0, byesToPlace);
45524
45573
  return {
45525
45574
  strictSeedOrderByePositions: strictSeedOrderByePositions,
45526
45575
  blockSeedOrderByePositions: blockSeedOrderByePositions,
@@ -46247,7 +46296,6 @@ function automatedPositioning$1(_a) {
46247
46296
  })
46248
46297
  : undefined;
46249
46298
  if (result_3 === null || result_3 === void 0 ? void 0 : result_3.error) {
46250
- console.log('positionByes', { result: result_3 });
46251
46299
  return handleErrorCondition(result_3);
46252
46300
  }
46253
46301
  unseededByePositions = result_3 === null || result_3 === void 0 ? void 0 : result_3.unseededByePositions;
@@ -46357,6 +46405,7 @@ function automatedPlayoffPositioning(params) {
46357
46405
  }).playoffStructures) === null || _b === void 0 ? void 0 : _b.sort(function (a, b) { return getMinFinishingPositionRange(a) - getMinFinishingPositionRange(b); });
46358
46406
  var structurePositionAssignments = [];
46359
46407
  var participants = tournamentRecord === null || tournamentRecord === void 0 ? void 0 : tournamentRecord.participants;
46408
+ var positioningReports = [];
46360
46409
  if (playoffStructures) {
46361
46410
  try {
46362
46411
  for (var playoffStructures_1 = __values(playoffStructures), playoffStructures_1_1 = playoffStructures_1.next(); !playoffStructures_1_1.done; playoffStructures_1_1 = playoffStructures_1.next()) {
@@ -46380,6 +46429,8 @@ function automatedPlayoffPositioning(params) {
46380
46429
  structureId: playoffStructureId,
46381
46430
  });
46382
46431
  }
46432
+ if (result.positioningReport)
46433
+ positioningReports.push(result.positioningReport);
46383
46434
  }
46384
46435
  }
46385
46436
  catch (e_1_1) { e_1 = { error: e_1_1 }; }
@@ -46390,7 +46441,7 @@ function automatedPlayoffPositioning(params) {
46390
46441
  finally { if (e_1) throw e_1.error; }
46391
46442
  }
46392
46443
  }
46393
- return __assign(__assign({}, SUCCESS), { structurePositionAssignments: structurePositionAssignments });
46444
+ return __assign(__assign({}, SUCCESS), { structurePositionAssignments: structurePositionAssignments, positioningReports: positioningReports });
46394
46445
  }
46395
46446
 
46396
46447
  function generateAndPopulateRRplayoffStructures(params) {
@@ -47108,18 +47159,37 @@ function getStructureGroups(_a) {
47108
47159
  function generateQualifyingStructure$1(params) {
47109
47160
  var _a;
47110
47161
  var _b, _c, _d, _e, _f, _g, _h, _j;
47111
- if (!params.drawDefinition)
47112
- return { error: MISSING_DRAW_DEFINITION };
47113
47162
  var stack = 'generateQualifyingStructure';
47163
+ if (!params.drawDefinition)
47164
+ return decorateResult({
47165
+ result: { error: MISSING_DRAW_DEFINITION },
47166
+ stack: stack,
47167
+ });
47168
+ if ((params.drawSize && !isConvertableInteger(params.drawSize)) ||
47169
+ (params.participantsCount &&
47170
+ !isConvertableInteger(params.participantsCount)) ||
47171
+ (params.qualifyingPositions &&
47172
+ !isConvertableInteger(params.qualifyingPositions))) {
47173
+ return decorateResult({ result: { error: INVALID_VALUES }, stack: stack });
47174
+ }
47114
47175
  var drawSize = (_b = params.drawSize) !== null && _b !== void 0 ? _b : coerceEven(params.participantsCount);
47115
47176
  var qualifyingRoundNumber = params.qualifyingRoundNumber, qualifyingPositions = params.qualifyingPositions, targetStructureId = params.targetStructureId, structureOptions = params.structureOptions, appliedPolicies = params.appliedPolicies, drawDefinition = params.drawDefinition, matchUpFormat = params.matchUpFormat, structureName = params.structureName, structureId = params.structureId, roundTarget = params.roundTarget, drawType = params.drawType, idPrefix = params.idPrefix, isMock = params.isMock, uuids = params.uuids;
47177
+ if (!params.drawSize)
47178
+ return decorateResult({
47179
+ result: { error: MISSING_DRAW_SIZE },
47180
+ context: { drawSize: drawSize },
47181
+ stack: stack,
47182
+ });
47183
+ if (qualifyingPositions && qualifyingPositions >= params.drawSize)
47184
+ return decorateResult({
47185
+ result: { error: INVALID_VALUES },
47186
+ context: { drawSize: drawSize, qualifyingPositions: qualifyingPositions },
47187
+ stack: stack,
47188
+ });
47116
47189
  var roundLimit, roundsCount, structure, matchUps;
47117
47190
  var qualifiersCount = 0;
47118
47191
  var finishingPositions;
47119
47192
  var stageSequence = 1;
47120
- if (!isConvertableInteger(drawSize)) {
47121
- return decorateResult({ result: { error: MISSING_DRAW_SIZE }, stack: stack });
47122
- }
47123
47193
  var structureProfiles = getStructureGroups({ drawDefinition: drawDefinition }).structureProfiles;
47124
47194
  var structureProfile = structureProfiles[targetStructureId];
47125
47195
  if (!structureProfile) {
@@ -47814,6 +47884,7 @@ function removeStructure(_a) {
47814
47884
  var structure = structures.find(function (structure) { return structure.structureId === structureId; });
47815
47885
  if (!structure)
47816
47886
  return { error: STRUCTURE_NOT_FOUND };
47887
+ // TODO: if structure being rmoved is qualifying structure, ensure no source structures have scored matchUps
47817
47888
  var structureMatchUps = getAllStructureMatchUps({ structure: structure }).matchUps;
47818
47889
  var scoresPresent = structureMatchUps.some(function (_a) {
47819
47890
  var score = _a.score;
@@ -51964,6 +52035,7 @@ function getValidAssignmentActions(_a) {
51964
52035
  if (!ignoreSeedPositions) {
51965
52036
  var result = getNextSeedBlock({
51966
52037
  provisionalPositioning: provisionalPositioning,
52038
+ returnAllProxies: true,
51967
52039
  randomize: true,
51968
52040
  drawDefinition: drawDefinition,
51969
52041
  structureId: structureId,
@@ -52540,6 +52612,7 @@ function positionActions$1(params) {
52540
52612
  isValidSeedPosition({ drawDefinition: drawDefinition, structureId: structureId, drawPosition: drawPosition }) &&
52541
52613
  validToAssignSeed) {
52542
52614
  var seedAssignments = getStructureSeedAssignments({
52615
+ returnAllProxies: true,
52543
52616
  drawDefinition: drawDefinition,
52544
52617
  structure: structure,
52545
52618
  }).seedAssignments;
@@ -52568,6 +52641,7 @@ function positionActions$1(params) {
52568
52641
  isValidSeedPosition({ drawDefinition: drawDefinition, structureId: structureId, drawPosition: drawPosition }) &&
52569
52642
  validToAssignSeed) {
52570
52643
  var seedAssignments = getStructureSeedAssignments({
52644
+ returnAllProxies: true,
52571
52645
  drawDefinition: drawDefinition,
52572
52646
  structure: structure,
52573
52647
  }).seedAssignments;
@@ -59342,8 +59416,8 @@ function getEntryStatusReports(_a) {
59342
59416
  return sides === null || sides === void 0 ? void 0 : sides.flatMap(function (side) {
59343
59417
  var _a, _b;
59344
59418
  return matchUpType === DOUBLES_MATCHUP
59345
- ? (_a = side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds
59346
- : ((_b = side.participant) === null || _b === void 0 ? void 0 : _b.participantId) || side.participantId;
59419
+ ? (_a = side === null || side === void 0 ? void 0 : side.participant) === null || _a === void 0 ? void 0 : _a.individualParticipantIds
59420
+ : ((_b = side === null || side === void 0 ? void 0 : side.participant) === null || _b === void 0 ? void 0 : _b.participantId) || side.participantId;
59347
59421
  }).filter(Boolean);
59348
59422
  })
59349
59423
  .filter(Boolean);
@@ -59492,7 +59566,7 @@ function getEntryStatusReports(_a) {
59492
59566
  var _b = _a.participant, participantType = _b.participantType, participantRole = _b.participantRole;
59493
59567
  return participantType === INDIVIDUAL && participantRole === COMPETITOR;
59494
59568
  });
59495
- var nonParticipatingParticipants = individualParticipants
59569
+ var nonParticipatingParticipantIds = individualParticipants
59496
59570
  .filter(function (_a) {
59497
59571
  var participant = _a.participant;
59498
59572
  return !nonTeamEnteredParticipantIds.includes(participant.participantId);
@@ -59502,9 +59576,10 @@ function getEntryStatusReports(_a) {
59502
59576
  return participant.participantId;
59503
59577
  });
59504
59578
  var tournamentEntryReport = {
59505
- nonParticipatingEntriesCount: nonParticipatingParticipants.length,
59579
+ nonParticipatingEntriesCount: nonParticipatingParticipantIds.length,
59506
59580
  individualParticipantsCount: individualParticipants.length,
59507
59581
  eventsCount: Object.values(eventReports).length,
59582
+ nonParticipatingParticipantIds: nonParticipatingParticipantIds,
59508
59583
  drawDefinitionsCount: drawDefinitionsCount,
59509
59584
  tournamentId: tournamentId,
59510
59585
  };
@@ -68577,10 +68652,10 @@ function anonymizeTournamentRecord(_a) {
68577
68652
  counts[gender] += 1;
68578
68653
  }
68579
68654
  else {
68580
- counts[OTHER$2] += 1;
68655
+ counts[OTHER$3] += 1;
68581
68656
  }
68582
68657
  return counts;
68583
- }, (_m = {}, _m[MALE] = 0, _m[FEMALE] = 0, _m[OTHER$2] = 0, _m));
68658
+ }, (_m = {}, _m[MALE] = 0, _m[FEMALE] = 0, _m[OTHER$3] = 0, _m));
68584
68659
  var genderedPersons = Object.assign.apply(Object, __spreadArray([{}], __read(Object.keys(gendersCount).map(function (gender) {
68585
68660
  var _a;
68586
68661
  var _b;
@@ -68595,7 +68670,7 @@ function anonymizeTournamentRecord(_a) {
68595
68670
  })) === null || _b === void 0 ? void 0 : _b.persons) || [],
68596
68671
  _a);
68597
68672
  })), false));
68598
- var genderedIndices = (_o = {}, _o[MALE] = 0, _o[FEMALE] = 0, _o[OTHER$2] = 0, _o);
68673
+ var genderedIndices = (_o = {}, _o[MALE] = 0, _o[FEMALE] = 0, _o[OTHER$3] = 0, _o);
68599
68674
  var individualParticipantsCount = individualParticipants.length;
68600
68675
  var addressComponents = individualParticipants.reduce(function (components, participant) {
68601
68676
  var _a, _b;
@@ -68628,7 +68703,7 @@ function anonymizeTournamentRecord(_a) {
68628
68703
  individualParticipants.forEach(function (individualParticipant, participantIndex) {
68629
68704
  var _a, _b;
68630
68705
  var person = individualParticipant === null || individualParticipant === void 0 ? void 0 : individualParticipant.person;
68631
- var gender = (person === null || person === void 0 ? void 0 : person.sex) || OTHER$2;
68706
+ var gender = (person === null || person === void 0 ? void 0 : person.sex) || OTHER$3;
68632
68707
  var birthYear = (_a = extractDate(person === null || person === void 0 ? void 0 : person.birthDate)) === null || _a === void 0 ? void 0 : _a.split('-')[0];
68633
68708
  var genderedIndex = genderedIndices[gender];
68634
68709
  var generatedPerson = genderedPersons[gender][genderedIndex];
@@ -69192,7 +69267,7 @@ function processTieFormat(_a) {
69192
69267
  var maxDoublesCount = 0, maxSinglesCount = 0;
69193
69268
  var singlesMatchUpTotal = 0, doublesMatchUpTotal = 0;
69194
69269
  var categories = {};
69195
- var genders = (_b = {}, _b[MALE] = 0, _b[FEMALE] = 0, _b[MIXED] = 0, _b[OTHER$2] = 0, _b[ANY] = 0, _b);
69270
+ var genders = (_b = {}, _b[MALE] = 0, _b[FEMALE] = 0, _b[MIXED] = 0, _b[OTHER$3] = 0, _b[ANY] = 0, _b);
69196
69271
  tieFormat =
69197
69272
  typeof tieFormat === 'object'
69198
69273
  ? tieFormat
@@ -69249,7 +69324,7 @@ function getParticipantsCount(_a) {
69249
69324
  var gendersCount = (_b = {},
69250
69325
  _b[FEMALE] = 0,
69251
69326
  _b[MIXED] = 0,
69252
- _b[OTHER$2] = 0,
69327
+ _b[OTHER$3] = 0,
69253
69328
  _b[MALE] = 0,
69254
69329
  _b[ANY] = 0,
69255
69330
  _b);
@@ -70926,6 +71001,7 @@ var utilities = {
70926
71001
  findExtension: findExtension$2,
70927
71002
  flattenJSON: flattenJSON,
70928
71003
  garman: garman,
71004
+ genderValidityCheck: genderValidityCheck,
70929
71005
  generateHashCode: generateHashCode,
70930
71006
  generateRange: generateRange,
70931
71007
  generateScoreString: generateScoreString,
@@ -71002,6 +71078,7 @@ exports.scaleEngineAsync = scaleEngineAsync;
71002
71078
  exports.scoreGovernor = scoreGovernor;
71003
71079
  exports.setDeepCopy = setDeepCopy;
71004
71080
  exports.setDevContext = setDevContext;
71081
+ exports.setGlobalLog = setGlobalLog;
71005
71082
  exports.setStateProvider = setStateProvider;
71006
71083
  exports.setSubscriptions = setSubscriptions;
71007
71084
  exports.surfaceConstants = surfaceConstants;