tods-competition-factory 1.7.7 → 1.7.8

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.
@@ -575,93 +575,6 @@ function getTopics() {
575
575
  return _globalStateProvider.getTopics();
576
576
  }
577
577
 
578
- function isObject(obj) {
579
- return typeof obj === "object";
580
- }
581
- const extractAttributes = (atz) => (o) => !atz || typeof o !== "object" ? void 0 : Array.isArray(atz) && atz.map((a) => ({ [a]: o[a] })) || typeof atz === "object" && Object.keys(atz).map((key) => ({ [key]: o[key] })) || typeof atz === "string" && getAttr(o, atz);
582
- function getAttr(o, attr) {
583
- const attrs = attr.split(".");
584
- for (const a of attrs) {
585
- o = o?.[a];
586
- if (!o)
587
- return;
588
- }
589
- return o;
590
- }
591
- function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
592
- if (typeof obj !== "object" || obj === null)
593
- return obj;
594
- const deepCopy = deepCopyEnabled();
595
- if (!deepCopy?.enabled)
596
- shallow = true;
597
- const ignoreValues = ["", void 0, null];
598
- if (ignoreFalse)
599
- ignoreValues.push(false);
600
- const definedKeys = Object.keys(obj).filter(
601
- (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
602
- );
603
- return Object.assign(
604
- {},
605
- ...definedKeys.map((key) => {
606
- return Array.isArray(obj[key]) ? {
607
- [key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
608
- } : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
609
- })
610
- );
611
- }
612
-
613
- function attributeFilter(params) {
614
- if (params === null)
615
- return {};
616
- const { source, template } = params || {};
617
- if (!template)
618
- return source;
619
- const target = {};
620
- attributeCopy(source, template, target);
621
- return target;
622
- function attributeCopy(valuesObject, templateObject, outputObject) {
623
- if (!valuesObject || !templateObject)
624
- return void 0;
625
- const vKeys = Object.keys(valuesObject);
626
- const oKeys = Object.keys(templateObject);
627
- const orMap = Object.assign(
628
- {},
629
- ...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
630
- );
631
- const allKeys = oKeys.concat(...Object.keys(orMap));
632
- const wildcard = allKeys.includes("*");
633
- for (const vKey of vKeys) {
634
- if (allKeys.indexOf(vKey) >= 0 || wildcard) {
635
- const templateKey = orMap[vKey] || vKey;
636
- const tobj = templateObject[templateKey] || wildcard;
637
- const vobj = valuesObject[vKey];
638
- if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
639
- if (Array.isArray(vobj)) {
640
- const mappedElements = vobj.map((arrayMember) => {
641
- const target2 = {};
642
- const result = attributeCopy(arrayMember, tobj, target2);
643
- return result !== false ? target2 : void 0;
644
- }).filter(Boolean);
645
- outputObject[vKey] = mappedElements;
646
- } else if (vobj) {
647
- outputObject[vKey] = {};
648
- attributeCopy(vobj, tobj, outputObject[vKey]);
649
- }
650
- } else {
651
- const value = valuesObject[vKey];
652
- const exclude = Array.isArray(tobj) && !tobj.includes(value);
653
- if (exclude)
654
- return false;
655
- if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
656
- outputObject[vKey] = value;
657
- }
658
- }
659
- }
660
- }
661
- return void 0;
662
- }
663
- }
664
-
665
578
  const validTimeString = /^((0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)([.,][0-9]{3})?$/;
666
579
  const dateValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))([ T](0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
667
580
  const timeValidation = /^([\d]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][\d]|3[0-1]))?([ T]?(0[\d]|1[\d]|2[0-3]):[0-5][\d](:[0-5][\d])?)?([.,][\d]{3})?Z?$/;
@@ -905,6 +818,144 @@ function extensionsToAttributes(extensions) {
905
818
  }).filter(Boolean);
906
819
  }
907
820
 
821
+ function getAccessorValue({ element, accessor }) {
822
+ if (typeof accessor !== "string")
823
+ return { values: [] };
824
+ const targetElement = makeDeepCopy(element);
825
+ const attributes = accessor.split(".");
826
+ const values = [];
827
+ let value;
828
+ processKeys({ targetElement, attributes });
829
+ const result = { value };
830
+ if (values.length)
831
+ result.values = values;
832
+ return result;
833
+ function processKeys({
834
+ targetElement: targetElement2,
835
+ attributes: attributes2 = [],
836
+ significantCharacters
837
+ }) {
838
+ for (const [index, attribute] of attributes2.entries()) {
839
+ if (targetElement2?.[attribute]) {
840
+ const remainingKeys = attributes2.slice(index + 1);
841
+ if (!remainingKeys.length) {
842
+ if (!value)
843
+ value = targetElement2[attribute];
844
+ if (!values.includes(targetElement2[attribute])) {
845
+ values.push(targetElement2[attribute]);
846
+ }
847
+ } else if (Array.isArray(targetElement2[attribute])) {
848
+ const values2 = targetElement2[attribute];
849
+ values2.forEach(
850
+ (nestedTarget) => processKeys({
851
+ targetElement: nestedTarget,
852
+ attributes: remainingKeys
853
+ })
854
+ );
855
+ } else {
856
+ targetElement2 = targetElement2[attribute];
857
+ checkValue({ targetElement: targetElement2, index });
858
+ }
859
+ }
860
+ }
861
+ function checkValue({ targetElement: targetElement3, index }) {
862
+ if (targetElement3 && index === attributes2.length - 1 && ["string", "number"].includes(typeof targetElement3)) {
863
+ const extractedValue = significantCharacters ? targetElement3.slice(0, significantCharacters) : targetElement3;
864
+ if (value) {
865
+ if (!values.includes(extractedValue)) {
866
+ values.push(extractedValue);
867
+ }
868
+ } else {
869
+ value = extractedValue;
870
+ values.push(extractedValue);
871
+ }
872
+ }
873
+ }
874
+ }
875
+ }
876
+
877
+ function isObject(obj) {
878
+ return typeof obj === "object";
879
+ }
880
+ const extractAttributes = (accessor) => (element) => !accessor || typeof element !== "object" ? void 0 : Array.isArray(accessor) && accessor.map((a) => ({
881
+ [a]: getAccessorValue({ element, accessor: a })?.value
882
+ })) || typeof accessor === "object" && Object.keys(accessor).map((key) => ({
883
+ [key]: getAccessorValue({ element, accessor: key })?.value
884
+ })) || (typeof accessor === "string" && getAccessorValue({ element, accessor }))?.value;
885
+ function definedAttributes(obj, ignoreFalse, ignoreEmptyArrays, shallow) {
886
+ if (typeof obj !== "object" || obj === null)
887
+ return obj;
888
+ const deepCopy = deepCopyEnabled();
889
+ if (!deepCopy?.enabled)
890
+ shallow = true;
891
+ const ignoreValues = ["", void 0, null];
892
+ if (ignoreFalse)
893
+ ignoreValues.push(false);
894
+ const definedKeys = Object.keys(obj).filter(
895
+ (key) => !ignoreValues.includes(obj[key]) && (!ignoreEmptyArrays || (Array.isArray(obj[key]) ? obj[key].length : true))
896
+ );
897
+ return Object.assign(
898
+ {},
899
+ ...definedKeys.map((key) => {
900
+ return Array.isArray(obj[key]) ? {
901
+ [key]: shallow ? obj[key] : obj[key].map((m) => definedAttributes(m))
902
+ } : { [key]: shallow ? obj[key] : definedAttributes(obj[key]) };
903
+ })
904
+ );
905
+ }
906
+
907
+ function attributeFilter(params) {
908
+ if (params === null)
909
+ return {};
910
+ const { source, template } = params || {};
911
+ if (!template)
912
+ return source;
913
+ const target = {};
914
+ attributeCopy(source, template, target);
915
+ return target;
916
+ function attributeCopy(valuesObject, templateObject, outputObject) {
917
+ if (!valuesObject || !templateObject)
918
+ return void 0;
919
+ const vKeys = Object.keys(valuesObject);
920
+ const oKeys = Object.keys(templateObject);
921
+ const orMap = Object.assign(
922
+ {},
923
+ ...oKeys.filter((key) => key.indexOf("||")).map((key) => key.split("||").map((or) => ({ [or]: key }))).flat()
924
+ );
925
+ const allKeys = oKeys.concat(...Object.keys(orMap));
926
+ const wildcard = allKeys.includes("*");
927
+ for (const vKey of vKeys) {
928
+ if (allKeys.indexOf(vKey) >= 0 || wildcard) {
929
+ const templateKey = orMap[vKey] || vKey;
930
+ const tobj = templateObject[templateKey] || wildcard;
931
+ const vobj = valuesObject[vKey];
932
+ if (typeof tobj === "object" && typeof vobj !== "function" && !Array.isArray(tobj)) {
933
+ if (Array.isArray(vobj)) {
934
+ const mappedElements = vobj.map((arrayMember) => {
935
+ const target2 = {};
936
+ const result = attributeCopy(arrayMember, tobj, target2);
937
+ return result !== false ? target2 : void 0;
938
+ }).filter(Boolean);
939
+ outputObject[vKey] = mappedElements;
940
+ } else if (vobj) {
941
+ outputObject[vKey] = {};
942
+ attributeCopy(vobj, tobj, outputObject[vKey]);
943
+ }
944
+ } else {
945
+ const value = valuesObject[vKey];
946
+ const exclude = Array.isArray(tobj) && !tobj.includes(value);
947
+ if (exclude)
948
+ return false;
949
+ if (templateObject[vKey] || wildcard && templateObject[vKey] !== false) {
950
+ outputObject[vKey] = value;
951
+ }
952
+ }
953
+ }
954
+ }
955
+ return void 0;
956
+ }
957
+ }
958
+
908
959
  function numericSort(a, b) {
909
960
  return a - b;
910
961
  }
@@ -5566,7 +5617,7 @@ function isAdHoc({ drawDefinition, structure }) {
5566
5617
  const hasDrawPosition = matchUps?.find(
5567
5618
  (matchUp) => matchUp?.drawPositions?.length
5568
5619
  );
5569
- return !structure?.structures && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
5620
+ return !structure?.structures && structure?.stage !== VOLUNTARY_CONSOLATION && !(drawDefinition?.drawType && drawDefinition.drawType !== AD_HOC) && !hasRoundPosition && !hasDrawPosition;
5570
5621
  }
5571
5622
 
5572
5623
  const POLICY_ROUND_NAMING_DEFAULT = {