tods-competition-factory 1.8.25 → 1.8.26

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.
@@ -496,18 +496,21 @@ function cycleMutationStatus() {
496
496
  return status;
497
497
  }
498
498
  function addNotice$1({ topic, payload, key }) {
499
- syncGlobalState.modified = true;
500
499
  if (typeof topic !== "string" || typeof payload !== "object") {
501
500
  return;
502
501
  }
503
- if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic])
502
+ if (!syncGlobalState.disableNotifications)
503
+ syncGlobalState.modified = true;
504
+ if (syncGlobalState.disableNotifications || !syncGlobalState.subscriptions[topic]) {
504
505
  return;
506
+ }
505
507
  if (key) {
506
508
  syncGlobalState.notices = syncGlobalState.notices.filter(
507
509
  (notice) => !(notice.topic === topic && notice.key === key)
508
510
  );
509
511
  }
510
512
  syncGlobalState.notices.push({ topic, payload, key });
513
+ return { ...SUCCESS };
511
514
  }
512
515
  function getNotices({ topic }) {
513
516
  const notices = syncGlobalState.notices.filter((notice) => notice.topic === topic).map((notice) => notice.payload);
@@ -4857,6 +4860,66 @@ function getDrawStructures({
4857
4860
  }
4858
4861
  }
4859
4862
 
4863
+ function getPositionAssignments({
4864
+ drawDefinition,
4865
+ structureId,
4866
+ structure
4867
+ }) {
4868
+ let error, positionAssignments = [];
4869
+ if (!structure) {
4870
+ if (!drawDefinition) {
4871
+ return { positionAssignments, error: MISSING_DRAW_DEFINITION };
4872
+ }
4873
+ ({ structure, error } = findStructure({ drawDefinition, structureId }));
4874
+ if (error)
4875
+ return { positionAssignments, error };
4876
+ }
4877
+ if (structure.structures) {
4878
+ positionAssignments = [].concat(
4879
+ ...structure.structures.map((structure2) => {
4880
+ return getPositionAssignments({ structure: structure2 }).positionAssignments;
4881
+ })
4882
+ );
4883
+ } else if (structure.positionAssignments) {
4884
+ positionAssignments = structure.positionAssignments;
4885
+ } else {
4886
+ error = MISSING_POSITION_ASSIGNMENTS;
4887
+ }
4888
+ return { positionAssignments, error };
4889
+ }
4890
+ function structureAssignedDrawPositions({
4891
+ drawDefinition,
4892
+ structureId,
4893
+ structure
4894
+ }) {
4895
+ const positionAssignments = getPositionAssignments({
4896
+ drawDefinition,
4897
+ structureId,
4898
+ structure
4899
+ })?.positionAssignments || [];
4900
+ const assignedPositions = positionAssignments?.filter((assignment) => {
4901
+ return assignment.participantId ?? assignment.bye ?? assignment.qualifier;
4902
+ });
4903
+ const allPositionsAssigned = positionAssignments && positionAssignments?.length === assignedPositions?.length;
4904
+ const unassignedPositions = positionAssignments?.filter((assignment) => {
4905
+ return !assignment.participantId && !assignment.bye && !assignment.qualifier;
4906
+ });
4907
+ const byePositions = positionAssignments?.filter((assignment) => {
4908
+ return !assignment.participantId && assignment.bye;
4909
+ });
4910
+ const qualifierPositions = positionAssignments?.filter((assignment) => {
4911
+ return !assignment.participantId && assignment.qualifier;
4912
+ });
4913
+ return {
4914
+ allPositionsAssigned,
4915
+ positionAssignments,
4916
+ unassignedPositions,
4917
+ assignedPositions,
4918
+ qualifierPositions,
4919
+ byePositions
4920
+ };
4921
+ }
4922
+
4860
4923
  EntryStatusEnum.Alternate;
4861
4924
  EntryStatusEnum.Confirmed;
4862
4925
  EntryStatusEnum.DirectAcceptance;
@@ -4983,6 +5046,7 @@ function getPlayoffEntries({
4983
5046
 
4984
5047
  function getStructureSeedAssignments({
4985
5048
  provisionalPositioning,
5049
+ returnAllProxies,
4986
5050
  drawDefinition,
4987
5051
  structureId,
4988
5052
  structure
@@ -4991,6 +5055,9 @@ function getStructureSeedAssignments({
4991
5055
  if (!structure) {
4992
5056
  ({ structure, error } = findStructure({ drawDefinition, structureId }));
4993
5057
  }
5058
+ const positionAssignments = getPositionAssignments({
5059
+ structure
5060
+ }).positionAssignments;
4994
5061
  if (error || !structure)
4995
5062
  return { seedAssignments: [], error: STRUCTURE_NOT_FOUND };
4996
5063
  if (!structureId)
@@ -5004,18 +5071,22 @@ function getStructureSeedAssignments({
5004
5071
  structureId,
5005
5072
  stage
5006
5073
  });
5007
- const seedProxies = entries ? entries.filter((entry) => entry.placementGroup === 1).sort((a, b) => {
5074
+ const proxiedEntries = entries ? entries.filter((entry) => entry.placementGroup === 1).sort((a, b) => {
5008
5075
  return a.GEMscore < b.GEMscore && 1 || a.GEMscore > b.GEMscore && -1 || 0;
5009
5076
  }).map((entry, index) => {
5010
5077
  const seedNumber = index + 1;
5011
5078
  return {
5012
5079
  participantId: entry.participantId,
5013
5080
  seedValue: seedNumber,
5014
- seedNumber,
5015
- seedProxy: true
5081
+ seedProxy: true,
5016
5082
  // flag so that proxy seeding information doesn't get used externally
5083
+ seedNumber
5017
5084
  };
5018
5085
  }) : [];
5086
+ const seedProxies = proxiedEntries?.slice(
5087
+ 0,
5088
+ returnAllProxies ? proxiedEntries.length : positionAssignments.length / 2
5089
+ );
5019
5090
  if (seedProxies.length) {
5020
5091
  seedAssignments = seedProxies;
5021
5092
  } else if (structure.seedAssignments) {
@@ -5024,7 +5095,13 @@ function getStructureSeedAssignments({
5024
5095
  error = MISSING_SEED_ASSIGNMENTS;
5025
5096
  }
5026
5097
  const seedLimit = structure.seedLimit || structure?.positionAssignments?.length;
5027
- return { seedAssignments, seedLimit, stage, stageSequence, error };
5098
+ return {
5099
+ seedAssignments,
5100
+ stageSequence,
5101
+ seedLimit,
5102
+ stage,
5103
+ error
5104
+ };
5028
5105
  }
5029
5106
 
5030
5107
  function getExitProfiles({ drawDefinition }) {
@@ -5303,66 +5380,6 @@ function getSourceDrawPositionRanges({
5303
5380
  return { sourceDrawPositionRanges };
5304
5381
  }
5305
5382
 
5306
- function getPositionAssignments({
5307
- drawDefinition,
5308
- structureId,
5309
- structure
5310
- }) {
5311
- let error, positionAssignments = [];
5312
- if (!structure) {
5313
- if (!drawDefinition) {
5314
- return { positionAssignments, error: MISSING_DRAW_DEFINITION };
5315
- }
5316
- ({ structure, error } = findStructure({ drawDefinition, structureId }));
5317
- if (error)
5318
- return { positionAssignments, error };
5319
- }
5320
- if (structure.structures) {
5321
- positionAssignments = [].concat(
5322
- ...structure.structures.map((structure2) => {
5323
- return getPositionAssignments({ structure: structure2 }).positionAssignments;
5324
- })
5325
- );
5326
- } else if (structure.positionAssignments) {
5327
- positionAssignments = structure.positionAssignments;
5328
- } else {
5329
- error = MISSING_POSITION_ASSIGNMENTS;
5330
- }
5331
- return { positionAssignments, error };
5332
- }
5333
- function structureAssignedDrawPositions({
5334
- drawDefinition,
5335
- structureId,
5336
- structure
5337
- }) {
5338
- const positionAssignments = getPositionAssignments({
5339
- drawDefinition,
5340
- structureId,
5341
- structure
5342
- })?.positionAssignments || [];
5343
- const assignedPositions = positionAssignments?.filter((assignment) => {
5344
- return assignment.participantId ?? assignment.bye ?? assignment.qualifier;
5345
- });
5346
- const allPositionsAssigned = positionAssignments && positionAssignments?.length === assignedPositions?.length;
5347
- const unassignedPositions = positionAssignments?.filter((assignment) => {
5348
- return !assignment.participantId && !assignment.bye && !assignment.qualifier;
5349
- });
5350
- const byePositions = positionAssignments?.filter((assignment) => {
5351
- return !assignment.participantId && assignment.bye;
5352
- });
5353
- const qualifierPositions = positionAssignments?.filter((assignment) => {
5354
- return !assignment.participantId && assignment.qualifier;
5355
- });
5356
- return {
5357
- allPositionsAssigned,
5358
- positionAssignments,
5359
- unassignedPositions,
5360
- assignedPositions,
5361
- qualifierPositions,
5362
- byePositions
5363
- };
5364
- }
5365
-
5366
5383
  function getOrderedDrawPositions({
5367
5384
  drawPositions,
5368
5385
  roundProfile,
@@ -13525,6 +13542,7 @@ function getSeedGroups({
13525
13542
 
13526
13543
  function getValidSeedBlocks({
13527
13544
  provisionalPositioning,
13545
+ returnAllProxies,
13528
13546
  appliedPolicies,
13529
13547
  drawDefinition,
13530
13548
  allPositions,
@@ -13540,6 +13558,7 @@ function getValidSeedBlocks({
13540
13558
  });
13541
13559
  const { seedAssignments } = getStructureSeedAssignments({
13542
13560
  provisionalPositioning,
13561
+ returnAllProxies,
13543
13562
  drawDefinition,
13544
13563
  structure
13545
13564
  });