@ubnt/store.core 9.9.0-konutis.1 → 9.9.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (102) hide show
  1. package/CHANGELOG.md +5 -0
  2. package/lib/_virtual/_virtual_multi-entry.js +2 -16
  3. package/lib/_virtual/_virtual_multi-entry.js.map +1 -1
  4. package/lib/_virtual/_virtual_multi-entry.mjs +0 -2
  5. package/lib/_virtual/_virtual_multi-entry.mjs.map +1 -1
  6. package/lib/assets/attention.svg +5 -5
  7. package/lib/assets/attention2.svg +5 -5
  8. package/lib/assets/clock.svg +4 -0
  9. package/lib/assets/minus4.svg +8 -8
  10. package/lib/assets/minus5.svg +8 -8
  11. package/lib/assets/packets.svg +3 -0
  12. package/lib/assets/plus5.svg +9 -9
  13. package/lib/assets/plus6.svg +9 -9
  14. package/lib/components/ModelCompareV3/assets/clock.svg.js +27 -0
  15. package/lib/components/ModelCompareV3/assets/clock.svg.js.map +1 -0
  16. package/lib/components/ModelCompareV3/assets/clock.svg.mjs +3 -0
  17. package/lib/components/ModelCompareV3/assets/clock.svg.mjs.map +1 -0
  18. package/lib/components/ModelCompareV3/assets/packets.svg.js +27 -0
  19. package/lib/components/ModelCompareV3/assets/packets.svg.js.map +1 -0
  20. package/lib/components/ModelCompareV3/assets/packets.svg.mjs +3 -0
  21. package/lib/components/ModelCompareV3/assets/packets.svg.mjs.map +1 -0
  22. package/lib/components/ModelCompareV3/data/products/waveApMicro.js +2 -2
  23. package/lib/components/ModelCompareV3/data/products/waveApMicro.js.map +1 -1
  24. package/lib/components/ModelCompareV3/data/products/waveApMicro.mjs +2 -2
  25. package/lib/components/ModelCompareV3/data/products/waveApMicro.mjs.map +1 -1
  26. package/lib/components/ModelCompareV3/data/products/wavePro.js +2 -2
  27. package/lib/components/ModelCompareV3/data/products/wavePro.js.map +1 -1
  28. package/lib/components/ModelCompareV3/data/products/wavePro.mjs +2 -2
  29. package/lib/components/ModelCompareV3/data/products/wavePro.mjs.map +1 -1
  30. package/lib/components/ModelCompareV3/data/properties/swivelLatency.js +2 -2
  31. package/lib/components/ModelCompareV3/data/properties/swivelLatency.js.map +1 -1
  32. package/lib/components/ModelCompareV3/data/properties/swivelLatency.mjs +2 -2
  33. package/lib/components/ModelCompareV3/data/properties/swivelLatency.mjs.map +1 -1
  34. package/lib/components/ModelCompareV3/data/properties/swivelPackets.js +2 -2
  35. package/lib/components/ModelCompareV3/data/properties/swivelPackets.js.map +1 -1
  36. package/lib/components/ModelCompareV3/data/properties/swivelPackets.mjs +2 -2
  37. package/lib/components/ModelCompareV3/data/properties/swivelPackets.mjs.map +1 -1
  38. package/lib/components/ModelCompareV3/data/properties/swivelSpectralEfficiency.js +2 -2
  39. package/lib/components/ModelCompareV3/data/properties/swivelSpectralEfficiency.js.map +1 -1
  40. package/lib/components/ModelCompareV3/data/properties/swivelSpectralEfficiency.mjs +2 -2
  41. package/lib/components/ModelCompareV3/data/properties/swivelSpectralEfficiency.mjs.map +1 -1
  42. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.js +1 -1
  43. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputCard.mjs +1 -1
  44. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.js +2 -2
  45. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/InputSections/CounterSection.mjs +2 -2
  46. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.js +1 -1
  47. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/attention.svg.mjs +2 -2
  48. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.js +1 -1
  49. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/minus.svg.mjs +2 -2
  50. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.js +1 -1
  51. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/InputCard/assets/plus.svg.mjs +2 -2
  52. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.js +1 -1
  53. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/ProgressBarChart.mjs +1 -1
  54. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.js +1 -1
  55. package/lib/components/ResourceCalculatorV1/ComputeResourceCalculator/components/ProgressBarChart/assets/attention.svg.mjs +2 -2
  56. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.js +2 -2
  57. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/PoeConsumerSelectModal/PoeConsumerSelectModal.mjs +2 -2
  58. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.js +1 -1
  59. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/minus.svg.mjs +2 -2
  60. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.js +1 -1
  61. package/lib/components/ResourceCalculatorV1/PoeCalculator/components/PoeConsumerConfigurator/assets/plus.svg.mjs +2 -2
  62. package/lib/constants/icons/options/colors/black.svg.js +5 -5
  63. package/lib/constants/icons/options/colors/index.js +3 -3
  64. package/lib/constants/icons/options/styles/black.svg.js +5 -5
  65. package/lib/constants/icons/options/styles/index.js +3 -3
  66. package/lib/constants/optionIcons.js +6 -6
  67. package/lib/constants/optionIcons.mjs +4 -4
  68. package/lib/contexts/MenuContext/mapping.js +41 -0
  69. package/lib/contexts/MenuContext/mapping.js.map +1 -1
  70. package/lib/contexts/MenuContext/mapping.mjs +41 -0
  71. package/lib/contexts/MenuContext/mapping.mjs.map +1 -1
  72. package/lib/helpers/index.d.ts +0 -1
  73. package/lib/helpers/index.js +0 -12
  74. package/lib/helpers/index.js.map +1 -1
  75. package/lib/helpers/index.mjs +0 -1
  76. package/lib/helpers/index.mjs.map +1 -1
  77. package/lib/types/index.d.ts +0 -1
  78. package/lib/types/index.js +0 -2
  79. package/lib/types/index.js.map +1 -1
  80. package/lib/types/index.mjs +0 -1
  81. package/lib/types/index.mjs.map +1 -1
  82. package/lib/utils/array.d.ts +0 -4
  83. package/lib/utils/array.js +0 -10
  84. package/lib/utils/array.js.map +1 -1
  85. package/lib/utils/array.mjs +1 -10
  86. package/lib/utils/array.mjs.map +1 -1
  87. package/package.json +1 -1
  88. package/lib/helpers/product.d.ts +0 -96
  89. package/lib/helpers/product.js +0 -360
  90. package/lib/helpers/product.js.map +0 -1
  91. package/lib/helpers/product.mjs +0 -348
  92. package/lib/helpers/product.mjs.map +0 -1
  93. package/lib/types/product.d.ts +0 -87
  94. package/lib/types/product.js +0 -14
  95. package/lib/types/product.js.map +0 -1
  96. package/lib/types/product.mjs +0 -13
  97. package/lib/types/product.mjs.map +0 -1
  98. package/lib/utils/productSort.d.ts +0 -41
  99. package/lib/utils/productSort.js +0 -66
  100. package/lib/utils/productSort.js.map +0 -1
  101. package/lib/utils/productSort.mjs +0 -59
  102. package/lib/utils/productSort.mjs.map +0 -1
@@ -1,2 +1 @@
1
1
  export * from "./proStoreCategories";
2
- export * from "./product";
@@ -1,7 +1,6 @@
1
1
  'use strict';
2
2
 
3
3
  var proStoreCategories = require('./proStoreCategories.js');
4
- var product = require('./product.js');
5
4
  "use strict";
6
5
  exports.getCategoriesBySubcategory = proStoreCategories.getCategoriesBySubcategory;
7
6
  exports.getLocalizedCategories = proStoreCategories.getLocalizedCategories;
@@ -11,15 +10,4 @@ exports.getSubCategoryIdByCollectionSlug = proStoreCategories.getSubCategoryIdBy
11
10
  exports.isValidSubCategory = proStoreCategories.isValidSubCategory;
12
11
  exports.parseCategories = proStoreCategories.parseCategories;
13
12
  exports.useTranslatedCategories = proStoreCategories.useTranslatedCategories;
14
- exports.COLLECTION_SECTION_OTHER_ID = product.COLLECTION_SECTION_OTHER_ID;
15
- exports.HDDProductSlugs = product.HDDProductSlugs;
16
- exports.MagicCollectionTags = product.MagicCollectionTags;
17
- exports.ProductOptions = product.ProductOptions;
18
- exports.createSectionHierarchy = product.createSectionHierarchy;
19
- exports.getProStoreCategory = product.getProStoreCategory;
20
- exports.getProductGroups = product.getProductGroups;
21
- exports.getStoreProducts = product.getStoreProducts;
22
- exports.isNonNullish = product.isNonNullish;
23
- exports.removeExcludedProducts = product.removeExcludedProducts;
24
- exports.sortCollections = product.sortCollections;
25
13
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;"}
@@ -1,4 +1,3 @@
1
1
  export { getCategoriesBySubcategory, getLocalizedCategories, getProductLineByCategory, getProductLineBySubcategory, getSubCategoryIdByCollectionSlug, isValidSubCategory, parseCategories, useTranslatedCategories } from './proStoreCategories.mjs';
2
- export { COLLECTION_SECTION_OTHER_ID, HDDProductSlugs, MagicCollectionTags, ProductOptions, createSectionHierarchy, getProStoreCategory, getProductGroups, getStoreProducts, isNonNullish, removeExcludedProducts, sortCollections } from './product.mjs';
3
2
  "use strict";
4
3
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";"}
@@ -3,4 +3,3 @@ export * from "./constants";
3
3
  export * from "./generated";
4
4
  export * from "./object";
5
5
  export * from "./utils";
6
- export * from "./product";
@@ -5,7 +5,6 @@ var constants = require('./constants.js');
5
5
  var generated = require('./generated.js');
6
6
  require('./object.js');
7
7
  require('./utils.js');
8
- var product = require('./product.js');
9
8
  "use strict";
10
9
  exports.AddressUsageType = constants.AddressUsageType;
11
10
  exports.Language = constants.Language;
@@ -19,5 +18,4 @@ exports.Unit = generated.Unit;
19
18
  exports.UnitSystem = generated.UnitSystem;
20
19
  exports.UserAssignedCountryCode = generated.UserAssignedCountryCode;
21
20
  exports.ValidateTaxStatus = generated.ValidateTaxStatus;
22
- exports.DisplayProductStatus = product.DisplayProductStatus;
23
21
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;"}
1
+ {"version":3,"file":"index.js","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;"}
@@ -3,6 +3,5 @@ export { AddressUsageType, Language } from './constants.mjs';
3
3
  export { AddressType, CountryCode, Currency, GlobalStoreId, ProductLine, StoreId, Unit, UnitSystem, UserAssignedCountryCode, ValidateTaxStatus } from './generated.mjs';
4
4
  import './object.mjs';
5
5
  import './utils.mjs';
6
- export { DisplayProductStatus } from './product.mjs';
7
6
  "use strict";
8
7
  //# sourceMappingURL=index.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;;"}
1
+ {"version":3,"file":"index.mjs","sources":[],"sourcesContent":[],"names":[],"mappings":";;;;;"}
@@ -28,7 +28,3 @@ export declare const arraySafeIndexFind: <T>(array: T[], index: number) => T | u
28
28
  * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts
29
29
  */
30
30
  export declare const normalizeSortResult: (sortResult: number) => number;
31
- /**
32
- * Combine multiple sort functions into one
33
- */
34
- export declare const combineSorts: <T>(sorts: ((a: T, b: T) => number)[]) => ((a: T, b: T) => number);
@@ -24,19 +24,9 @@ const arraySafeIndexFind = (array, index) => {
24
24
  return array[safeIndex];
25
25
  };
26
26
  const normalizeSortResult = sortResult => number.clamp(sortResult, -1, 1);
27
- const combineSorts = sorts => (a, b) => {
28
- for (const sort of sorts) {
29
- const result = sort(a, b);
30
- if (result !== 0) {
31
- return result;
32
- }
33
- }
34
- return 0;
35
- };
36
27
  exports.areEqualArrays = areEqualArrays;
37
28
  exports.arraySafeIndex = arraySafeIndex;
38
29
  exports.arraySafeIndexFind = arraySafeIndexFind;
39
- exports.combineSorts = combineSorts;
40
30
  exports.dedupe = dedupe;
41
31
  exports.ensureArray = ensureArray;
42
32
  exports.normalizeSortResult = normalizeSortResult;
@@ -1 +1 @@
1
- {"version":3,"file":"array.js","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n\n/**\n * Combine multiple sort functions into one\n */\nexport const combineSorts =\n <T>(sorts: ((a: T, b: T) => number)[]): ((a: T, b: T) => number) =>\n (a, b) => {\n for (const sort of sorts) {\n const result = sort(a, b);\n\n if (result !== 0) {\n return result;\n }\n }\n\n return 0;\n };\n"],"names":["ensureArray","value","Array","isArray","dedupe","arr","Set","areEqualArrays","a","b","length","every","el","includes","arraySafeIndex","array","index","indexSize","arraySafeIndexFind","safeIndex","normalizeSortResult","sortResult","clamp","combineSorts","sorts","sort","result"],"mappings":";;;;AAMO,SAASA,YAAeC,KAAqB,EAAA;EAClD,OAAOC,MAAMC,OAAQ,CAAAF,KAAK,CAAI,GAAAA,KAAA,GAAQ,CAACA,KAAK,CAAA;AAC9C;AAOa,MAAAG,MAAA,GAAaC,GAAa,IAAA,CAAC,GAAG,IAAIC,GAAA,CAAID,GAAG,CAAC,CAAA;AAS1C,MAAAE,cAAA,GAAiBA,CAACC,CAAA,EAAaC,CAAyB,KAAA;EAC/D,IAAAD,CAAA,CAAEE,MAAW,KAAAD,CAAA,CAAEC,MAAQ,EAAA;IAClB,OAAA,KAAA;EACT;EACI,IAAA,CAACF,EAAEG,KAAM,CAACC,MAAOH,CAAE,CAAAI,QAAA,CAASD,EAAE,CAAC,CAAG,EAAA;IAC7B,OAAA,KAAA;EACT;EACO,OAAA,CAACH,CAAE,CAAAE,KAAA,CAAOC,EAAA,IAAOJ,EAAEK,QAAS,CAAAD,EAAE,CAAC,CAAA,GAAI,KAAQ,GAAA,IAAA;AACpD,CAAA;AAOa,MAAAE,cAAA,GAAiBA,CAAIC,KAAA,EAAYC,KAA0B,KAAA;EACtE,MAAMC,YAAYF,KAAM,CAAAL,MAAA;EAEf,OAAA,CAAAM,KAAA,GAAQC,YAAaA,SAAa,IAAAA,SAAA;AAC7C,CAAA;AAEa,MAAAC,kBAAA,GAAqBA,CAChCH,KAAA,EACAC,KACkB,KAAA;EACZ,MAAAG,SAAA,GAAYL,cAAe,CAAAC,KAAA,EAAOC,KAAK,CAAA;EAE7C,OAAOD,MAAMI,SAAS,CAAA;AACxB,CAAA;AAKO,MAAMC,sBAAuBC,UAAA,IAClCC,MAAAA,CAAAA,KAAM,CAAAD,UAAA,EAAY,IAAI,CAAC,CAAA;AAKlB,MAAME,YACX,GAAIC,KACJ,IAAA,CAAChB,GAAGC,CAAM,KAAA;EACR,KAAA,MAAWgB,QAAQD,KAAO,EAAA;IAClB,MAAAE,MAAA,GAASD,IAAK,CAAAjB,CAAA,EAAGC,CAAC,CAAA;IAExB,IAAIiB,WAAW,CAAG,EAAA;MACT,OAAAA,MAAA;IACT;EACF;EAEO,OAAA,CAAA;AACT,CAAA;;;;;;;"}
1
+ {"version":3,"file":"array.js","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n"],"names":["ensureArray","value","Array","isArray","dedupe","arr","Set","areEqualArrays","a","b","length","every","el","includes","arraySafeIndex","array","index","indexSize","arraySafeIndexFind","safeIndex","normalizeSortResult","sortResult","clamp"],"mappings":";;;;AAMO,SAASA,YAAeC,KAAqB,EAAA;EAClD,OAAOC,MAAMC,OAAQ,CAAAF,KAAK,CAAI,GAAAA,KAAA,GAAQ,CAACA,KAAK,CAAA;AAC9C;AAOa,MAAAG,MAAA,GAAaC,GAAa,IAAA,CAAC,GAAG,IAAIC,GAAA,CAAID,GAAG,CAAC,CAAA;AAS1C,MAAAE,cAAA,GAAiBA,CAACC,CAAA,EAAaC,CAAyB,KAAA;EAC/D,IAAAD,CAAA,CAAEE,MAAW,KAAAD,CAAA,CAAEC,MAAQ,EAAA;IAClB,OAAA,KAAA;EACT;EACI,IAAA,CAACF,EAAEG,KAAM,CAACC,MAAOH,CAAE,CAAAI,QAAA,CAASD,EAAE,CAAC,CAAG,EAAA;IAC7B,OAAA,KAAA;EACT;EACO,OAAA,CAACH,CAAE,CAAAE,KAAA,CAAOC,EAAA,IAAOJ,EAAEK,QAAS,CAAAD,EAAE,CAAC,CAAA,GAAI,KAAQ,GAAA,IAAA;AACpD,CAAA;AAOa,MAAAE,cAAA,GAAiBA,CAAIC,KAAA,EAAYC,KAA0B,KAAA;EACtE,MAAMC,YAAYF,KAAM,CAAAL,MAAA;EAEf,OAAA,CAAAM,KAAA,GAAQC,YAAaA,SAAa,IAAAA,SAAA;AAC7C,CAAA;AAEa,MAAAC,kBAAA,GAAqBA,CAChCH,KAAA,EACAC,KACkB,KAAA;EACZ,MAAAG,SAAA,GAAYL,cAAe,CAAAC,KAAA,EAAOC,KAAK,CAAA;EAE7C,OAAOD,MAAMI,SAAS,CAAA;AACxB,CAAA;AAKO,MAAMC,sBAAuBC,UAAA,IAClCC,MAAAA,CAAAA,KAAM,CAAAD,UAAA,EAAY,IAAI,CAAC,CAAA;;;;;;"}
@@ -22,14 +22,5 @@ const arraySafeIndexFind = (array, index) => {
22
22
  return array[safeIndex];
23
23
  };
24
24
  const normalizeSortResult = sortResult => clamp(sortResult, -1, 1);
25
- const combineSorts = sorts => (a, b) => {
26
- for (const sort of sorts) {
27
- const result = sort(a, b);
28
- if (result !== 0) {
29
- return result;
30
- }
31
- }
32
- return 0;
33
- };
34
- export { areEqualArrays, arraySafeIndex, arraySafeIndexFind, combineSorts, dedupe, ensureArray, normalizeSortResult };
25
+ export { areEqualArrays, arraySafeIndex, arraySafeIndexFind, dedupe, ensureArray, normalizeSortResult };
35
26
  //# sourceMappingURL=array.mjs.map
@@ -1 +1 @@
1
- {"version":3,"file":"array.mjs","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n\n/**\n * Combine multiple sort functions into one\n */\nexport const combineSorts =\n <T>(sorts: ((a: T, b: T) => number)[]): ((a: T, b: T) => number) =>\n (a, b) => {\n for (const sort of sorts) {\n const result = sort(a, b);\n\n if (result !== 0) {\n return result;\n }\n }\n\n return 0;\n };\n"],"names":["ensureArray","value","Array","isArray","dedupe","arr","Set","areEqualArrays","a","b","length","every","el","includes","arraySafeIndex","array","index","indexSize","arraySafeIndexFind","safeIndex","normalizeSortResult","sortResult","clamp","combineSorts","sorts","sort","result"],"mappings":";;AAMO,SAASA,YAAeC,KAAqB,EAAA;EAClD,OAAOC,MAAMC,OAAQ,CAAAF,KAAK,CAAI,GAAAA,KAAA,GAAQ,CAACA,KAAK,CAAA;AAC9C;AAOa,MAAAG,MAAA,GAAaC,GAAa,IAAA,CAAC,GAAG,IAAIC,GAAA,CAAID,GAAG,CAAC,CAAA;AAS1C,MAAAE,cAAA,GAAiBA,CAACC,CAAA,EAAaC,CAAyB,KAAA;EAC/D,IAAAD,CAAA,CAAEE,MAAW,KAAAD,CAAA,CAAEC,MAAQ,EAAA;IAClB,OAAA,KAAA;EACT;EACI,IAAA,CAACF,EAAEG,KAAM,CAACC,MAAOH,CAAE,CAAAI,QAAA,CAASD,EAAE,CAAC,CAAG,EAAA;IAC7B,OAAA,KAAA;EACT;EACO,OAAA,CAACH,CAAE,CAAAE,KAAA,CAAOC,EAAA,IAAOJ,EAAEK,QAAS,CAAAD,EAAE,CAAC,CAAA,GAAI,KAAQ,GAAA,IAAA;AACpD,CAAA;AAOa,MAAAE,cAAA,GAAiBA,CAAIC,KAAA,EAAYC,KAA0B,KAAA;EACtE,MAAMC,YAAYF,KAAM,CAAAL,MAAA;EAEf,OAAA,CAAAM,KAAA,GAAQC,YAAaA,SAAa,IAAAA,SAAA;AAC7C,CAAA;AAEa,MAAAC,kBAAA,GAAqBA,CAChCH,KAAA,EACAC,KACkB,KAAA;EACZ,MAAAG,SAAA,GAAYL,cAAe,CAAAC,KAAA,EAAOC,KAAK,CAAA;EAE7C,OAAOD,MAAMI,SAAS,CAAA;AACxB,CAAA;AAKO,MAAMC,sBAAuBC,UAAA,IAClCC,KAAM,CAAAD,UAAA,EAAY,IAAI,CAAC,CAAA;AAKlB,MAAME,YACX,GAAIC,KACJ,IAAA,CAAChB,GAAGC,CAAM,KAAA;EACR,KAAA,MAAWgB,QAAQD,KAAO,EAAA;IAClB,MAAAE,MAAA,GAASD,IAAK,CAAAjB,CAAA,EAAGC,CAAC,CAAA;IAExB,IAAIiB,WAAW,CAAG,EAAA;MACT,OAAAA,MAAA;IACT;EACF;EAEO,OAAA,CAAA;AACT,CAAA;"}
1
+ {"version":3,"file":"array.mjs","sources":["../../src/utils/array.ts"],"sourcesContent":["import { clamp } from \"./number\";\n\n/**\n * Make sure the element is an array\n * If it's not, make it an array of one element\n */\nexport function ensureArray<T>(value: T | T[]): T[] {\n return Array.isArray(value) ? value : [value];\n}\n\n/**\n * Utility to quickly remove duplicates from an array.\n *\n * Similar to lodash's `uniq`, but doesn't require lodash as dependency.\n */\nexport const dedupe = <T>(arr: T[]) => [...new Set(arr)];\n\n/**\n * Utility function check if given arrays contain same elements (regardless the order)\n *\n * @example\n * areArraysEqual([1, 2, 3], [3, 2, 1]) // true\n * areArraysEqual([1, 2, 3], [3, 2, 1, 4]) // false\n */\nexport const areEqualArrays = (a: string[], b: string[]): boolean => {\n if (a.length !== b.length) {\n return false;\n }\n if (!a.every((el) => b.includes(el))) {\n return false;\n }\n return !b.every((el) => a.includes(el)) ? false : true;\n};\n\n/**\n * Function to get array index by positive and negative wrap-around offsets\n *\n * @see https://dirask.com/posts/JavaScript-positive-and-negative-around-index-wrapping-overlapping-to-address-items-in-array-pVyrnD\n */\nexport const arraySafeIndex = <T>(array: T[], index: number): number => {\n const indexSize = array.length;\n\n return ((index % indexSize) + indexSize) % indexSize;\n};\n\nexport const arraySafeIndexFind = <T>(\n array: T[],\n index: number,\n): T | undefined => {\n const safeIndex = arraySafeIndex(array, index);\n\n return array[safeIndex];\n};\n\n/**\n * Normalise sort result to be in range of -1 to 1 so that we can easily combine multiple sorts\n */\nexport const normalizeSortResult = (sortResult: number): number =>\n clamp(sortResult, -1, 1);\n"],"names":["ensureArray","value","Array","isArray","dedupe","arr","Set","areEqualArrays","a","b","length","every","el","includes","arraySafeIndex","array","index","indexSize","arraySafeIndexFind","safeIndex","normalizeSortResult","sortResult","clamp"],"mappings":";;AAMO,SAASA,YAAeC,KAAqB,EAAA;EAClD,OAAOC,MAAMC,OAAQ,CAAAF,KAAK,CAAI,GAAAA,KAAA,GAAQ,CAACA,KAAK,CAAA;AAC9C;AAOa,MAAAG,MAAA,GAAaC,GAAa,IAAA,CAAC,GAAG,IAAIC,GAAA,CAAID,GAAG,CAAC,CAAA;AAS1C,MAAAE,cAAA,GAAiBA,CAACC,CAAA,EAAaC,CAAyB,KAAA;EAC/D,IAAAD,CAAA,CAAEE,MAAW,KAAAD,CAAA,CAAEC,MAAQ,EAAA;IAClB,OAAA,KAAA;EACT;EACI,IAAA,CAACF,EAAEG,KAAM,CAACC,MAAOH,CAAE,CAAAI,QAAA,CAASD,EAAE,CAAC,CAAG,EAAA;IAC7B,OAAA,KAAA;EACT;EACO,OAAA,CAACH,CAAE,CAAAE,KAAA,CAAOC,EAAA,IAAOJ,EAAEK,QAAS,CAAAD,EAAE,CAAC,CAAA,GAAI,KAAQ,GAAA,IAAA;AACpD,CAAA;AAOa,MAAAE,cAAA,GAAiBA,CAAIC,KAAA,EAAYC,KAA0B,KAAA;EACtE,MAAMC,YAAYF,KAAM,CAAAL,MAAA;EAEf,OAAA,CAAAM,KAAA,GAAQC,YAAaA,SAAa,IAAAA,SAAA;AAC7C,CAAA;AAEa,MAAAC,kBAAA,GAAqBA,CAChCH,KAAA,EACAC,KACkB,KAAA;EACZ,MAAAG,SAAA,GAAYL,cAAe,CAAAC,KAAA,EAAOC,KAAK,CAAA;EAE7C,OAAOD,MAAMI,SAAS,CAAA;AACxB,CAAA;AAKO,MAAMC,sBAAuBC,UAAA,IAClCC,KAAM,CAAAD,UAAA,EAAY,IAAI,CAAC,CAAA;"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ubnt/store.core",
3
- "version": "9.9.0-konutis.1",
3
+ "version": "9.9.1",
4
4
  "description": "",
5
5
  "sideEffects": false,
6
6
  "scripts": {
@@ -1,96 +0,0 @@
1
- import type { ParsedCategoryItem } from "../constants/proStoreCategories";
2
- import type { CollectionSection, MappedProductSection, Nullish, ProductTagFragment, Section, StorefrontOption, StorefrontProduct, StoreId } from "../types";
3
- export declare const isNonNullish: <T>(entry: T | null | undefined) => entry is T;
4
- /**
5
- * Sorts collections based on the mapping.
6
- * @param currentSort - mapping of collection slugs to their sort order
7
- */
8
- export declare const sortCollections: (collectionSlugs: string[]) => (a: {
9
- slug: string;
10
- }, b: {
11
- slug: string;
12
- }) => number;
13
- /**
14
- * Removes products that have tag starting with `EXCLUDE_PRODUCT_FROM_STORE_GRID_TAG_PREFIX`
15
- * and ends with `storeId`, e.g. `"exclude-from-store-grid:us`
16
- *
17
- * @warning Use this function only on grid and breadcrumbs products
18
- */
19
- export declare const removeExcludedProducts: <T extends {
20
- tags: ProductTagFragment[];
21
- }>(products: T[], storeId: StoreId) => T[];
22
- export declare enum HDDProductSlugs {
23
- HDD_1TB = "uacc-hdd-s-1tb",
24
- HDD_8TB_Enterprise = "uacc-hdd-e-8tb",
25
- HDD_16TB_Enterprise = "uacc-hdd-e-16tb"
26
- }
27
- /**
28
- * Recursively create section hierarchy
29
- */
30
- export declare const createSectionHierarchy: (sections: CollectionSection[], level?: number) => Section[];
31
- export declare enum MagicCollectionTags {
32
- /**
33
- * Used to determine if collection should be shown in an accessory
34
- * layout style where sections are placed inside variant cards
35
- */
36
- LayoutAccessories = "layout-accessories",
37
- /**
38
- * Used to determine if collection is pro-store specific and should
39
- * be redirected to pro-store's appropriate category
40
- */
41
- ProStore = "pro-store",
42
- /**
43
- * Used to disable length options (disable product splitting by "length")
44
- */
45
- DisableLengthOptions = "disable-length-options",
46
- /**
47
- * Used to disable speed options (disable product splitting by "speed")
48
- */
49
- DisableSpeedOptions = "disable-speed-options"
50
- }
51
- export declare enum ProductOptions {
52
- Length = "length",
53
- Speed = "speed",
54
- Color = "color"
55
- }
56
- export declare const COLLECTION_SECTION_OTHER_ID = "other";
57
- /**
58
- * Create product groups
59
- */
60
- export declare const getProductGroups: <T extends StorefrontProduct & {
61
- options: StorefrontOption[];
62
- }>(products?: T[], sectionHierarchy?: Nullish<Section[]>, tags?: Array<{
63
- id: string;
64
- name: string;
65
- }>) => MappedProductSection<T>[] | undefined;
66
- export declare const getProStoreCategory: ({ queryCategory, product, ignoreQuery, }: {
67
- queryCategory?: string;
68
- product: Pick<StorefrontProduct, "collectionSlug" | "organizationalCollectionSlug" | "proCollectionSlug">;
69
- ignoreQuery?: boolean;
70
- }) => string | null;
71
- type StoreProductsData = {
72
- category: {
73
- id: string;
74
- label: string | null;
75
- } | undefined;
76
- } & {
77
- products: StorefrontProduct[];
78
- } | {
79
- productGroups: MappedProductSection<StorefrontProduct>[];
80
- };
81
- export declare const getStoreProducts: ({ storeId, queryCategory, currentProduct, collections, allCategoryItems, }: {
82
- storeId: StoreId;
83
- queryCategory: string | undefined;
84
- currentProduct: Pick<StorefrontProduct, "id" | "slug" | "collectionSlug" | "organizationalCollectionSlug" | "proCollectionSlug">;
85
- collections: Array<{
86
- slug: string;
87
- sections: Array<{
88
- id: string;
89
- title: string;
90
- productTags: Array<string>;
91
- }>;
92
- products: Array<Pick<StorefrontProduct, "id" | "slug" | "tags" | "variants" | "options" | "title" | "status" | "minDisplayPrice">>;
93
- }>;
94
- allCategoryItems: ParsedCategoryItem[];
95
- }) => StoreProductsData;
96
- export {};
@@ -1,360 +0,0 @@
1
- 'use strict';
2
-
3
- var lodashEs = require('lodash-es');
4
- require('../constants/proStoreCategories/index.js');
5
- require('../types/index.js');
6
- var array = require('../utils/array.js');
7
- var productSort = require('../utils/productSort.js');
8
- var proStoreCategories = require('./proStoreCategories.js');
9
- var unifi = require('../constants/proStoreCategories/mapping/unifi.js');
10
- var uisp = require('../constants/proStoreCategories/mapping/uisp.js');
11
- var product = require('../types/product.js');
12
- "use strict";
13
- const isNonNullish = entry => entry !== null && entry !== void 0;
14
- const sortCollections = collectionSlugs => {
15
- return (a, b) => {
16
- const aIndex = collectionSlugs.indexOf(a.slug);
17
- const bIndex = collectionSlugs.indexOf(b.slug);
18
- if (aIndex === -1) {
19
- return 1;
20
- }
21
- if (bIndex === -1) {
22
- return -1;
23
- }
24
- return aIndex - bIndex;
25
- };
26
- };
27
- const EXCLUDE_PRODUCT_FROM_STORE_GRID_TAG_PREFIX = "exclude-from-store-grid:";
28
- const removeExcludedProducts = (products, storeId) => {
29
- const excludeTag = `${EXCLUDE_PRODUCT_FROM_STORE_GRID_TAG_PREFIX}${storeId}`.toLowerCase();
30
- return products.filter(product => {
31
- return !product.tags.some(tag => tag.name.toLowerCase() === excludeTag);
32
- });
33
- };
34
- const isAccessoryCategoryItem = categoryItem => {
35
- return !!categoryItem && [unifi.UniFiCategoryId.Accessories, uisp.UISPCategoryId.AccessoryTech].includes(
36
- // TODO: Check why this TS error appears
37
- // @ts-expect-error: Unreachable code error
38
- categoryItem.id);
39
- };
40
- var HDDProductSlugs = /* @__PURE__ */(HDDProductSlugs2 => {
41
- HDDProductSlugs2["HDD_1TB"] = "uacc-hdd-s-1tb";
42
- HDDProductSlugs2["HDD_8TB_Enterprise"] = "uacc-hdd-e-8tb";
43
- HDDProductSlugs2["HDD_16TB_Enterprise"] = "uacc-hdd-e-16tb";
44
- return HDDProductSlugs2;
45
- })(HDDProductSlugs || {});
46
- const isAllowedAccessoryCategoryProduct = ({
47
- slug
48
- }) => {
49
- const allowedAccessoryProductSlugs = ["u-lte", "u-lte-backup-pro", "uacc-hdd-s-1tb" /* HDD_1TB */, "uacc-hdd-e-8tb" /* HDD_8TB_Enterprise */, "uacc-hdd-e-16tb" /* HDD_16TB_Enterprise */];
50
- return allowedAccessoryProductSlugs.includes(slug);
51
- };
52
- const isAccessoryCategorySubItem = (categorySubItem, allCategoryItems) => {
53
- const categoryItem = allCategoryItems.find(item => item.items?.some(subItem => subItem.id === categorySubItem.id));
54
- return isAccessoryCategoryItem(categoryItem);
55
- };
56
- const createSectionHierarchy = (sections, level = 1) => {
57
- const currentLevelSections = sections.filter(section => section.productTags.length === level);
58
- if (!currentLevelSections.length) {
59
- return [];
60
- }
61
- return currentLevelSections.map(section => ({
62
- ...section,
63
- items: createSectionHierarchy(sections.filter(nextSection => section.productTags.every(tag => nextSection.productTags.includes(tag))), level + 1)
64
- }));
65
- };
66
- var MagicCollectionTags = /* @__PURE__ */(MagicCollectionTags2 => {
67
- MagicCollectionTags2["LayoutAccessories"] = "layout-accessories";
68
- MagicCollectionTags2["ProStore"] = "pro-store";
69
- MagicCollectionTags2["DisableLengthOptions"] = "disable-length-options";
70
- MagicCollectionTags2["DisableSpeedOptions"] = "disable-speed-options";
71
- return MagicCollectionTags2;
72
- })(MagicCollectionTags || {});
73
- var ProductOptions = /* @__PURE__ */(ProductOptions2 => {
74
- ProductOptions2["Length"] = "length";
75
- ProductOptions2["Speed"] = "speed";
76
- ProductOptions2["Color"] = "color";
77
- return ProductOptions2;
78
- })(ProductOptions || {});
79
- const formatOptionValueTitleToTag = optionValueTitle => optionValueTitle.toLowerCase().replace(/[,\s]/g, "").replace(".", "-");
80
- const divideProductByOption = (product, optionTitle) => {
81
- const option = product.options.find(option2 => option2.slug === optionTitle);
82
- if (!option) {
83
- return [product];
84
- }
85
- return option.values.map(value => {
86
- return {
87
- ...product,
88
- options: product.options.filter(option2 => option2.slug !== optionTitle),
89
- tags: [...product.tags, {
90
- id: value.id,
91
- name: formatOptionValueTitleToTag(value.slug)
92
- }],
93
- variants: product.variants.filter(variant => variant.optionValueIds?.includes(value.id))
94
- };
95
- });
96
- };
97
- const COLLECTION_SECTION_OTHER_ID = "other";
98
- const UNIT_FACTORS = {
99
- m: 1,
100
- km: 1e3
101
- };
102
- const DISTANCE_REGEX = /^\s*(\d+)\s*(m|km)\s*$/;
103
- const mapProductsToSections = (products, section) => {
104
- const productsInThisSection = products.filter(product => {
105
- return section.productTags.every(sectionTag => {
106
- return product.tags.find(tag => tag.name === sectionTag);
107
- });
108
- });
109
- if (productsInThisSection.length === 0) {
110
- return void 0;
111
- }
112
- const items = section?.items?.map(item => mapProductsToSections(productsInThisSection, item)).filter(isNonNullish) ?? [];
113
- const otherProducts = productsInThisSection.filter(product => {
114
- return !items.some(item => item.products.find(p => p.id === product.id));
115
- });
116
- if (otherProducts.length && items.length) {
117
- items.push({
118
- id: `${section.id}-${COLLECTION_SECTION_OTHER_ID}`,
119
- // TODO: Add translation
120
- title: "Other",
121
- productTags: section.productTags,
122
- items: [],
123
- products: otherProducts
124
- });
125
- }
126
- return {
127
- ...section,
128
- items,
129
- products: productsInThisSection
130
- };
131
- };
132
- const compareDistanceTitles = (a, b) => {
133
- const aMatch = a.title.match(DISTANCE_REGEX);
134
- const bMatch = b.title.match(DISTANCE_REGEX);
135
- if (!aMatch?.[1] || !aMatch[2] || !bMatch?.[1] || !bMatch[2]) {
136
- return 0;
137
- }
138
- const aValue = parseInt(aMatch[1]) * (UNIT_FACTORS[aMatch[2]] || 0);
139
- const bValue = parseInt(bMatch[1]) * (UNIT_FACTORS[bMatch[2]] || 0);
140
- return aValue - bValue;
141
- };
142
- const processSectionProductsWithDistanceInOptions = sections => {
143
- return sections.map(section => ({
144
- ...section,
145
- items: section.items.map(sec => {
146
- const section2 = lodashEs.cloneDeep(sec);
147
- const sectionWithDistanceTag = section2.items.find(section3 => section3.productTags.includes("distance"));
148
- const sectionsMainProductTag = sectionWithDistanceTag?.productTags.filter(tag => tag !== "distance");
149
- if (!sectionWithDistanceTag || !sectionsMainProductTag) {
150
- return section2;
151
- }
152
- sectionWithDistanceTag.products.forEach(product => {
153
- const optionValues = product?.options[0]?.values;
154
- if (!optionValues?.length) {
155
- return;
156
- }
157
- const formattedOptionValues = optionValues.map(value => ({
158
- ...value,
159
- titleInTagFormat: formatOptionValueTitleToTag(value.title)
160
- }));
161
- formattedOptionValues.forEach(currentValue => {
162
- const newSecondLevelSectionsTags = [...sectionsMainProductTag, currentValue.titleInTagFormat];
163
- const alreadyExistingSecondLevelSection = section2.items.findIndex(section3 => array.areEqualArrays(section3.productTags, newSecondLevelSectionsTags));
164
- const variantToAdd = product.variants.find(variant => variant.optionValueIds?.includes(currentValue.id));
165
- if (!variantToAdd) {
166
- return;
167
- }
168
- const productToAdd = {
169
- ...product,
170
- options: product.options.filter(option => option.values.some(value => value.id === currentValue.id)).map(option => ({
171
- ...option,
172
- values: option.values.filter(value => value.id === currentValue.id)
173
- })),
174
- variants: [variantToAdd]
175
- };
176
- if (alreadyExistingSecondLevelSection >= 0) {
177
- section2.items[alreadyExistingSecondLevelSection]?.products.push(productToAdd);
178
- } else {
179
- const sectionToAdd = {
180
- id: currentValue.id,
181
- // TODO: Maybe so>me different ID would be better
182
- items: [],
183
- // FIXME: This is problem!
184
- products: [productToAdd],
185
- productTags: newSecondLevelSectionsTags,
186
- title: currentValue.title
187
- };
188
- section2.items.push(sectionToAdd);
189
- }
190
- });
191
- });
192
- return {
193
- ...section2,
194
- items: section2.items.sort(compareDistanceTitles).filter(section3 => !section3.productTags.includes("distance"))
195
- };
196
- })
197
- }));
198
- };
199
- const processSectionsWithOutOfStockProducts = section => {
200
- const isDisabled = section.products.every(product$1 => product$1.variants.every(variant => variant.status !== product.DisplayProductStatus.Available));
201
- return {
202
- ...section,
203
- isDisabled,
204
- items: section.items.map(processSectionsWithOutOfStockProducts)
205
- };
206
- };
207
- const getProductGroups = (products, sectionHierarchy, tags) => {
208
- if (!products?.length || !sectionHierarchy) return void 0;
209
- const processedProducts = products.flatMap(product => {
210
- const disableLengthOptions = tags?.find(tag => tag.name === "disable-length-options" /* DisableLengthOptions */);
211
- const lengthOptions = !disableLengthOptions && product?.options?.find(option => option.slug === "length" /* Length */);
212
- if (lengthOptions && product.options !== void 0) {
213
- return divideProductByOption(product, "length" /* Length */);
214
- }
215
- const disableSpeedOptions = tags?.find(tag => tag.name === "disable-speed-options" /* DisableSpeedOptions */);
216
- const speedOptions = !disableSpeedOptions && product?.options?.find(option => {
217
- return option.slug === "speed" /* Speed */;
218
- });
219
- if (speedOptions) {
220
- return divideProductByOption(product, "speed" /* Speed */);
221
- }
222
- return [product];
223
- });
224
- const mappedProductGroups = sectionHierarchy.map(section => {
225
- return mapProductsToSections(processedProducts, section);
226
- }).filter(section => !!section);
227
- const otherProducts = products.filter(product => {
228
- return !mappedProductGroups.some(section => {
229
- return section.products.find(p => p.id === product.id);
230
- });
231
- });
232
- if (otherProducts.length) {
233
- otherProducts.forEach(product => {
234
- mappedProductGroups.push({
235
- id: product.id,
236
- products: [product],
237
- title: "",
238
- items: [],
239
- productTags: []
240
- });
241
- });
242
- }
243
- const processedProductGroups = processSectionProductsWithDistanceInOptions(mappedProductGroups).map(processSectionsWithOutOfStockProducts);
244
- return processedProductGroups.sort((a, b) => {
245
- const aFirstProductId = a?.products?.[0]?.id;
246
- const bFirstProductId = b?.products?.[0]?.id;
247
- const aFirstProduct = products.findIndex(product => product.id === aFirstProductId);
248
- const bFirstProduct = products.findIndex(product => product.id === bFirstProductId);
249
- return aFirstProduct - bFirstProduct;
250
- });
251
- };
252
- const getProStoreCategory = ({
253
- queryCategory,
254
- product,
255
- ignoreQuery
256
- }) => {
257
- return (
258
- /**
259
- * If category specified via the url search/query parameter then use it
260
- */
261
- !ignoreQuery && queryCategory ||
262
- /**
263
- * Attempt to find category by it's default collection or fallback to the virtual default collection
264
- */
265
- proStoreCategories.getSubCategoryIdByCollectionSlug(product.collectionSlug) || proStoreCategories.getSubCategoryIdByCollectionSlug(product.organizationalCollectionSlug) ||
266
- /**
267
- * If all else fails fallback detecting to category from pro store collection, unlikely but wouldn't hurt to do so
268
- */
269
- proStoreCategories.getSubCategoryIdByCollectionSlug(product.proCollectionSlug)
270
- );
271
- };
272
- const getStoreProducts = ({
273
- storeId,
274
- queryCategory,
275
- currentProduct,
276
- collections,
277
- allCategoryItems
278
- }) => {
279
- const returnObj = {
280
- category: void 0,
281
- products: []
282
- };
283
- const category = getProStoreCategory({
284
- queryCategory,
285
- product: currentProduct
286
- });
287
- const categoryItem = allCategoryItems.find(item => item.items?.some(subItem => subItem.id === category));
288
- const categorySubItem = categoryItem?.items?.find(subItem => subItem.id === category);
289
- const categoryId = categorySubItem?.id ?? category;
290
- if (categoryId) {
291
- returnObj.category = {
292
- id: categoryId,
293
- label: categoryItem?.label ?? null
294
- };
295
- }
296
- const filteredCollections = collections.map(collection => ({
297
- ...collection,
298
- products: removeExcludedProducts(collection.products, storeId)
299
- }));
300
- if (categoryItem?.hideSubItems) {
301
- const products = filteredCollections.flatMap(collection => collection.products);
302
- if (isAccessoryCategoryItem(categoryItem)) {
303
- returnObj.products = isAllowedAccessoryCategoryProduct(currentProduct) ? products.filter(isAllowedAccessoryCategoryProduct) : [];
304
- } else {
305
- returnObj.products = products;
306
- }
307
- } else {
308
- const collection = filteredCollections.find(collection2 => collection2.products.some(el => el.id === currentProduct.id));
309
- if (!collection) {
310
- throw new Error("Collection not found");
311
- }
312
- const subItems = (categoryItem?.items?.slice(1) ?? allCategoryItems.flatMap(el => el.items?.slice(1))).filter(Boolean);
313
- const subItem = subItems.find(item => item.collectionSlugs.includes(collection.slug));
314
- if (subItem && returnObj.category) {
315
- returnObj.category = {
316
- id: subItem.id,
317
- label: subItem.label
318
- };
319
- }
320
- const subItemCollections = filteredCollections.filter(el => subItem?.collectionSlugs.includes(el.slug));
321
- const products = subItemCollections.flatMap(el => el.products);
322
- if (subItem) {
323
- if (isAccessoryCategorySubItem(subItem, allCategoryItems)) {
324
- returnObj.products = isAllowedAccessoryCategoryProduct(currentProduct) ? products.filter(isAllowedAccessoryCategoryProduct) : [];
325
- } else {
326
- returnObj.products = products;
327
- }
328
- }
329
- const sections = subItemCollections.flatMap(el => el.sections);
330
- const sectionHierarchy = createSectionHierarchy(sections);
331
- const productGroups = getProductGroups(products, sectionHierarchy);
332
- if (productGroups) {
333
- return {
334
- category: returnObj.category,
335
- productGroups: productGroups.sort((a, b) => {
336
- if (a.products[0] && b.products[0]) {
337
- return productSort.sortProducts(null, storeId)(a.products[0], b.products[0]);
338
- }
339
- return 0;
340
- })
341
- };
342
- }
343
- }
344
- return {
345
- ...returnObj,
346
- products: returnObj.products.sort(productSort.sortProducts(null, storeId))
347
- };
348
- };
349
- exports.COLLECTION_SECTION_OTHER_ID = COLLECTION_SECTION_OTHER_ID;
350
- exports.HDDProductSlugs = HDDProductSlugs;
351
- exports.MagicCollectionTags = MagicCollectionTags;
352
- exports.ProductOptions = ProductOptions;
353
- exports.createSectionHierarchy = createSectionHierarchy;
354
- exports.getProStoreCategory = getProStoreCategory;
355
- exports.getProductGroups = getProductGroups;
356
- exports.getStoreProducts = getStoreProducts;
357
- exports.isNonNullish = isNonNullish;
358
- exports.removeExcludedProducts = removeExcludedProducts;
359
- exports.sortCollections = sortCollections;
360
- //# sourceMappingURL=product.js.map