@empathyco/x-components 6.0.0-alpha.45 → 6.0.0-alpha.46

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 (68) hide show
  1. package/CHANGELOG.md +9 -0
  2. package/design-system/deprecated-full-theme.css +469 -469
  3. package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice._constructor_.md → x-components.defaultexternaltaggingservice._constructor_.md} +3 -3
  4. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.add_to_cart_id_key.md +13 -0
  5. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.instance.md +13 -0
  6. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.localstorageservice.md +11 -0
  7. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.md +43 -0
  8. package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.movetosessionstorage.md → x-components.defaultexternaltaggingservice.movetosessionstorage.md} +2 -2
  9. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.result_clicked_id_key.md +13 -0
  10. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.sessionstorageservice.md +11 -0
  11. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.storagekey.md +11 -0
  12. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.storagettlms.md +11 -0
  13. package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.store.md → x-components.defaultexternaltaggingservice.store.md} +2 -2
  14. package/docs/API-reference/api/x-components.defaultexternaltaggingservice.storeaddtocart.md +24 -0
  15. package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.storeresultclicked.md → x-components.defaultexternaltaggingservice.storeresultclicked.md} +3 -3
  16. package/docs/API-reference/api/{x-components.defaultpdpaddtocartservice.trackaddtocart.md → x-components.defaultexternaltaggingservice.trackaddtocart.md} +3 -3
  17. package/docs/API-reference/api/x-components.externaltaggingservice.md +23 -0
  18. package/docs/API-reference/api/{x-components.pdpaddtocartservice.movetosessionstorage.md → x-components.externaltaggingservice.movetosessionstorage.md} +2 -2
  19. package/docs/API-reference/api/x-components.externaltaggingservice.storeaddtocart.md +24 -0
  20. package/docs/API-reference/api/{x-components.pdpaddtocartservice.storeresultclicked.md → x-components.externaltaggingservice.storeresultclicked.md} +3 -3
  21. package/docs/API-reference/api/{x-components.pdpaddtocartservice.trackaddtocart.md → x-components.externaltaggingservice.trackaddtocart.md} +3 -3
  22. package/docs/API-reference/api/x-components.md +2 -2
  23. package/docs/API-reference/api/x-components.tagging.md +6 -6
  24. package/docs/API-reference/api/x-components.taggingconfig.md +2 -2
  25. package/docs/API-reference/api/{x-components.taggingconfig.clickedresultstoragekey.md → x-components.taggingconfig.storagekey.md} +3 -3
  26. package/docs/API-reference/api/x-components.taggingconfig.storagettlms.md +13 -0
  27. package/docs/API-reference/api/x-components.taggingxevents.md +1 -1
  28. package/docs/API-reference/api/x-components.taggingxevents.resulturltrackingenabled.md +1 -1
  29. package/docs/API-reference/components/tagging/x-components.tagging.md +15 -16
  30. package/js/index.js +1 -1
  31. package/js/x-modules/tagging/components/tagging.vue.js +8 -7
  32. package/js/x-modules/tagging/components/tagging.vue.js.map +1 -1
  33. package/js/x-modules/tagging/service/{pdp-add-to-cart.service.js → external-tagging.service.js} +56 -25
  34. package/js/x-modules/tagging/service/external-tagging.service.js.map +1 -0
  35. package/js/x-modules/tagging/store/emitters.js +1 -1
  36. package/js/x-modules/tagging/store/emitters.js.map +1 -1
  37. package/js/x-modules/tagging/store/module.js +2 -2
  38. package/js/x-modules/tagging/store/module.js.map +1 -1
  39. package/js/x-modules/tagging/wiring.js +14 -7
  40. package/js/x-modules/tagging/wiring.js.map +1 -1
  41. package/package.json +2 -2
  42. package/report/x-components.api.json +768 -639
  43. package/report/x-components.api.md +45 -41
  44. package/tagging/index.js +1 -1
  45. package/types/x-modules/tagging/components/tagging.vue.d.ts +14 -12
  46. package/types/x-modules/tagging/components/tagging.vue.d.ts.map +1 -1
  47. package/types/x-modules/tagging/config.types.d.ts +3 -3
  48. package/types/x-modules/tagging/config.types.d.ts.map +1 -1
  49. package/types/x-modules/tagging/events.types.d.ts +2 -2
  50. package/types/x-modules/tagging/service/{pdp-add-to-cart.service.d.ts → external-tagging.service.d.ts} +31 -13
  51. package/types/x-modules/tagging/service/external-tagging.service.d.ts.map +1 -0
  52. package/types/x-modules/tagging/service/index.d.ts +1 -1
  53. package/types/x-modules/tagging/service/index.d.ts.map +1 -1
  54. package/types/x-modules/tagging/service/types.d.ts +13 -4
  55. package/types/x-modules/tagging/service/types.d.ts.map +1 -1
  56. package/types/x-modules/tagging/wiring.d.ts +1 -0
  57. package/types/x-modules/tagging/wiring.d.ts.map +1 -1
  58. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.clickedresultstoragekey.md +0 -11
  59. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.clickedresultstoragettlms.md +0 -11
  60. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.instance.md +0 -13
  61. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.localstorageservice.md +0 -11
  62. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.md +0 -41
  63. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.result_clicked_id_key.md +0 -13
  64. package/docs/API-reference/api/x-components.defaultpdpaddtocartservice.sessionstorageservice.md +0 -11
  65. package/docs/API-reference/api/x-components.pdpaddtocartservice.md +0 -22
  66. package/docs/API-reference/api/x-components.taggingconfig.clickedresultstoragettlms.md +0 -13
  67. package/js/x-modules/tagging/service/pdp-add-to-cart.service.js.map +0 -1
  68. package/types/x-modules/tagging/service/pdp-add-to-cart.service.d.ts.map +0 -1
@@ -1891,6 +1891,34 @@ export function deepFlat<Item extends {
1891
1891
  [key in Key]?: Item[];
1892
1892
  }, Key extends keyof Item>(array: Item[], childrenKey: Key): Item[];
1893
1893
 
1894
+ // @public
1895
+ export class DefaultExternalTaggingService implements ExternalTaggingService {
1896
+ constructor(localStorageService?: StorageService, sessionStorageService?: StorageService);
1897
+ static readonly ADD_TO_CART_ID_KEY = "checkout";
1898
+ // @internal
1899
+ protected getPathName(url: string): string;
1900
+ // @internal
1901
+ protected getStorageId(keyPrefix: string, id?: string): string | null;
1902
+ static instance: ExternalTaggingService;
1903
+ // (undocumented)
1904
+ protected localStorageService: StorageService;
1905
+ moveToSessionStorage(id?: string): void;
1906
+ static readonly RESULT_CLICKED_ID_KEY = "add-to-cart";
1907
+ // (undocumented)
1908
+ protected sessionStorageService: StorageService;
1909
+ // @internal
1910
+ protected showWarningMessage(): void;
1911
+ // (undocumented)
1912
+ protected get storageKey(): string;
1913
+ // (undocumented)
1914
+ protected get storageTTLMs(): number;
1915
+ // (undocumented)
1916
+ protected get store(): Store<RootXStoreState>;
1917
+ storeAddToCart(result: Result): void;
1918
+ storeResultClicked(result: Result): void;
1919
+ trackAddToCart(id?: string): void;
1920
+ }
1921
+
1894
1922
  // @public
1895
1923
  export class DefaultFacetsService implements FacetsService {
1896
1924
  // Warning: (ae-incompatible-release-tags) The symbol "__constructor" is marked as @public, but its signature references "FilterEntityFactory" which is marked as @internal
@@ -1952,32 +1980,6 @@ export class DefaultFacetsService implements FacetsService {
1952
1980
  protected updateStore(facetsGroup: FacetsGroup): Filter[];
1953
1981
  }
1954
1982
 
1955
- // @public
1956
- export class DefaultPDPAddToCartService implements PDPAddToCartService {
1957
- constructor(localStorageService?: StorageService, sessionStorageService?: StorageService);
1958
- // (undocumented)
1959
- protected get clickedResultStorageKey(): string;
1960
- // (undocumented)
1961
- protected get clickedResultStorageTTLMs(): number;
1962
- // @internal
1963
- protected getPathName(url: string): string;
1964
- // @internal
1965
- protected getStorageId(id?: string): string | null;
1966
- static instance: PDPAddToCartService;
1967
- // (undocumented)
1968
- protected localStorageService: StorageService;
1969
- moveToSessionStorage(id?: string): void;
1970
- static readonly RESULT_CLICKED_ID_KEY = "add-to-cart";
1971
- // (undocumented)
1972
- protected sessionStorageService: StorageService;
1973
- // @internal
1974
- protected showWarningMessage(): void;
1975
- // (undocumented)
1976
- protected get store(): Store<RootXStoreState>;
1977
- storeResultClicked(result: Result): void;
1978
- trackAddToCart(id?: string): void;
1979
- }
1980
-
1981
1983
  // @public
1982
1984
  export interface DeviceActions {
1983
1985
  }
@@ -2408,6 +2410,14 @@ export type ExperienceControlsXStoreModule = XStoreModule<ExperienceControlsStat
2408
2410
  // @internal
2409
2411
  export const experienceControlsXStoreModule: ExperienceControlsXStoreModule;
2410
2412
 
2413
+ // @public
2414
+ export interface ExternalTaggingService {
2415
+ moveToSessionStorage(id?: string): void;
2416
+ storeAddToCart(result: Result): void;
2417
+ storeResultClicked(result: Result): void;
2418
+ trackAddToCart(id?: string): void;
2419
+ }
2420
+
2411
2421
  // @public
2412
2422
  export type ExtractActionPayload<ModuleName extends XModuleName, ActionName extends ActionNamesFor<ModuleName>> = ExtractPayload<ExtractActions<XModulesTree[ModuleName]>[ActionName]>;
2413
2423
 
@@ -4968,13 +4978,6 @@ export type PayloadFactoryData<Payload> = RootStoreStateAndGetters & {
4968
4978
  metadata: WireMetadata;
4969
4979
  };
4970
4980
 
4971
- // @public
4972
- export interface PDPAddToCartService {
4973
- moveToSessionStorage(id?: string): void;
4974
- storeResultClicked(result: Result): void;
4975
- trackAddToCart(id?: string): void;
4976
- }
4977
-
4978
4981
  export { PlusIcon }
4979
4982
 
4980
4983
  export { PlusTinyIcon }
@@ -8158,11 +8161,11 @@ export { TagFilledIcon }
8158
8161
 
8159
8162
  // @public
8160
8163
  export const Tagging: DefineComponent< {
8161
- clickedResultStorageTTLMs: {
8164
+ storageTTLMs: {
8162
8165
  type: NumberConstructor;
8163
8166
  default: number;
8164
8167
  };
8165
- clickedResultStorageKey: {
8168
+ storageKey: {
8166
8169
  type: StringConstructor;
8167
8170
  default: string;
8168
8171
  };
@@ -8176,11 +8179,11 @@ type: BooleanConstructor;
8176
8179
  default: null;
8177
8180
  };
8178
8181
  }, () => void, unknown, {}, {}, ComponentOptionsMixin, ComponentOptionsMixin, {}, string, PublicProps, Readonly<ExtractPropTypes< {
8179
- clickedResultStorageTTLMs: {
8182
+ storageTTLMs: {
8180
8183
  type: NumberConstructor;
8181
8184
  default: number;
8182
8185
  };
8183
- clickedResultStorageKey: {
8186
+ storageKey: {
8184
8187
  type: StringConstructor;
8185
8188
  default: string;
8186
8189
  };
@@ -8194,8 +8197,8 @@ type: BooleanConstructor;
8194
8197
  default: null;
8195
8198
  };
8196
8199
  }>>, {
8197
- clickedResultStorageTTLMs: number;
8198
- clickedResultStorageKey: string;
8200
+ storageTTLMs: number;
8201
+ storageKey: string;
8199
8202
  queryTaggingDebounceMs: number;
8200
8203
  consent: boolean;
8201
8204
  }, {}>;
@@ -8207,10 +8210,10 @@ export interface TaggingActions {
8207
8210
 
8208
8211
  // @public
8209
8212
  export interface TaggingConfig {
8210
- clickedResultStorageKey: string | null;
8211
- clickedResultStorageTTLMs: number | null;
8212
8213
  queryTaggingDebounceMs: number;
8213
8214
  sessionTTLMs: number;
8215
+ storageKey: string | null;
8216
+ storageTTLMs: number | null;
8214
8217
  }
8215
8218
 
8216
8219
  // @internal
@@ -8275,6 +8278,7 @@ export const taggingWiring: {
8275
8278
  UserClickedResultAddToCart: {
8276
8279
  trackAddToCartWire: Wire<Taggable>;
8277
8280
  trackResultClickedWire: Wire<Taggable>;
8281
+ storeAddToCartWire: Wire<Result>;
8278
8282
  };
8279
8283
  UserClickedPDPAddToCart: {
8280
8284
  trackAddToCartFromSessionStorage: Wire<string | undefined>;
package/tagging/index.js CHANGED
@@ -1,5 +1,5 @@
1
1
  export { default as Tagging } from '../js/x-modules/tagging/components/tagging.vue.js';
2
- export { DefaultPDPAddToCartService } from '../js/x-modules/tagging/service/pdp-add-to-cart.service.js';
2
+ export { DefaultExternalTaggingService } from '../js/x-modules/tagging/service/external-tagging.service.js';
3
3
  export { track } from '../js/x-modules/tagging/store/actions/track.action.js';
4
4
  export { taggingEmitters } from '../js/x-modules/tagging/store/emitters.js';
5
5
  export { taggingXStoreModule } from '../js/x-modules/tagging/store/module.js';
@@ -7,17 +7,18 @@
7
7
  */
8
8
  declare const _default: import("vue").DefineComponent<{
9
9
  /**
10
- * The TTL in milliseconds for storing the clicked result info.
10
+ * The TTL in milliseconds for storing the result info.
11
11
  */
12
- clickedResultStorageTTLMs: {
12
+ storageTTLMs: {
13
13
  type: NumberConstructor;
14
14
  default: number;
15
15
  };
16
16
  /**
17
- * The Object key of the {@link @empathyco/x-types#Result} clicked by the user
18
- * that will be used as id for the storage. By default, the Result url will be used.
17
+ * The Object key of the {@link @empathyco/x-types#Result} clicked or added to the cart by the user
18
+ * that will be used as id for the storage.
19
+ * By default, the Result url will be used.
19
20
  */
20
- clickedResultStorageKey: {
21
+ storageKey: {
21
22
  type: StringConstructor;
22
23
  default: string;
23
24
  };
@@ -41,17 +42,18 @@ declare const _default: import("vue").DefineComponent<{
41
42
  };
42
43
  }, () => void, unknown, {}, {}, import("vue").ComponentOptionsMixin, import("vue").ComponentOptionsMixin, {}, string, import("vue").PublicProps, Readonly<import("vue").ExtractPropTypes<{
43
44
  /**
44
- * The TTL in milliseconds for storing the clicked result info.
45
+ * The TTL in milliseconds for storing the result info.
45
46
  */
46
- clickedResultStorageTTLMs: {
47
+ storageTTLMs: {
47
48
  type: NumberConstructor;
48
49
  default: number;
49
50
  };
50
51
  /**
51
- * The Object key of the {@link @empathyco/x-types#Result} clicked by the user
52
- * that will be used as id for the storage. By default, the Result url will be used.
52
+ * The Object key of the {@link @empathyco/x-types#Result} clicked or added to the cart by the user
53
+ * that will be used as id for the storage.
54
+ * By default, the Result url will be used.
53
55
  */
54
- clickedResultStorageKey: {
56
+ storageKey: {
55
57
  type: StringConstructor;
56
58
  default: string;
57
59
  };
@@ -74,8 +76,8 @@ declare const _default: import("vue").DefineComponent<{
74
76
  default: null;
75
77
  };
76
78
  }>>, {
77
- clickedResultStorageTTLMs: number;
78
- clickedResultStorageKey: string;
79
+ storageTTLMs: number;
80
+ storageKey: string;
79
81
  queryTaggingDebounceMs: number;
80
82
  consent: boolean;
81
83
  }, {}>;
@@ -1 +1 @@
1
- {"version":3,"file":"tagging.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/components/tagging.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AAME;;;;;;GAMG;;IAKC;;OAEG;;;;;IAKH;;;OAGG;;;;;IAKH;;OAEG;;IAEH;;OAEG;;;;;IAKH;;OAEG;;;;;;IA5BH;;OAEG;;;;;IAKH;;;OAGG;;;;;IAKH;;OAEG;;IAEH;;OAEG;;;;;IAKH;;OAEG;;;;;;;;;;;AAhCP,wBAgGG"}
1
+ {"version":3,"file":"tagging.vue?vue&type=script&lang.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/components/tagging.vue?vue&type=script&lang.ts"],"names":[],"mappings":"AAME;;;;;;GAMG;;IAKC;;OAEG;;;;;IAKH;;;;OAIG;;;;;IAKH;;OAEG;;IAEH;;OAEG;;;;;IAKH;;OAEG;;;;;;IA7BH;;OAEG;;;;;IAKH;;;;OAIG;;;;;IAKH;;OAEG;;IAEH;;OAEG;;;;;IAKH;;OAEG;;;;;;;;;;;AAjCP,wBAiGG"}
@@ -14,13 +14,13 @@ export interface TaggingConfig {
14
14
  */
15
15
  sessionTTLMs: number;
16
16
  /**
17
- * Time in milliseconds to keep the information for a result clicked by the user.
17
+ * Time in milliseconds to keep the information for a result.
18
18
  */
19
- clickedResultStorageTTLMs: number | null;
19
+ storageTTLMs: number | null;
20
20
  /**
21
21
  * Field of the {@link @empathyco/x-types#Result | result} to use as id for storing the
22
22
  * information.
23
23
  */
24
- clickedResultStorageKey: string | null;
24
+ storageKey: string | null;
25
25
  }
26
26
  //# sourceMappingURL=config.types.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../../src/x-modules/tagging/config.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,yBAAyB,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC;;;OAGG;IACH,uBAAuB,EAAE,MAAM,GAAG,IAAI,CAAC;CACxC"}
1
+ {"version":3,"file":"config.types.d.ts","sourceRoot":"","sources":["../../../../src/x-modules/tagging/config.types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,MAAM,WAAW,aAAa;IAC5B;;OAEG;IACH,sBAAsB,EAAE,MAAM,CAAC;IAC/B;;;OAGG;IACH,YAAY,EAAE,MAAM,CAAC;IAErB;;OAEG;IACH,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;IAE5B;;;OAGG;IACH,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B"}
@@ -23,9 +23,9 @@ export interface TaggingXEvents {
23
23
  */
24
24
  PDPIsLoaded: string;
25
25
  /**
26
- * ClickedResultStorageKey has been configured to use the
26
+ * StorageKey has been configured to use the
27
27
  * {@link @empathyco/x-types#Result | result} url.
28
- * Payload: The new clickedResultStorageKey.
28
+ * Payload: The new storageKey.
29
29
  */
30
30
  ResultURLTrackingEnabled: string;
31
31
  /**
@@ -2,38 +2,54 @@ import { Store } from 'vuex';
2
2
  import { Result } from '@empathyco/x-types';
3
3
  import { StorageService } from '@empathyco/x-storage-service';
4
4
  import { RootXStoreState } from '../../../store/index';
5
- import { PDPAddToCartService } from './types';
5
+ import { ExternalTaggingService } from './types';
6
6
  /**
7
- * Default implementation for the {@link PDPAddToCartService}.
7
+ * Default implementation for the {@link ExternalTaggingService}.
8
8
  *
9
9
  * @public
10
10
  */
11
- export declare class DefaultPDPAddToCartService implements PDPAddToCartService {
11
+ export declare class DefaultExternalTaggingService implements ExternalTaggingService {
12
12
  protected localStorageService: StorageService;
13
13
  protected sessionStorageService: StorageService;
14
14
  /**
15
- * Session id key to use as key in the storage.
15
+ * Session id key to use as key in the storage for result clicks.
16
16
  *
17
17
  * @public
18
18
  */
19
19
  static readonly RESULT_CLICKED_ID_KEY = "add-to-cart";
20
20
  /**
21
- * Global instance of the {@link PDPAddToCartService}.
21
+ * Session id key to use as key in the storage for add to carts.
22
+ *
23
+ * @public
22
24
  */
23
- static instance: PDPAddToCartService;
25
+ static readonly ADD_TO_CART_ID_KEY = "checkout";
26
+ /**
27
+ * Global instance of the {@link ExternalTaggingService}.
28
+ */
29
+ static instance: ExternalTaggingService;
24
30
  constructor(localStorageService?: StorageService, sessionStorageService?: StorageService);
25
31
  protected get store(): Store<RootXStoreState>;
26
- protected get clickedResultStorageKey(): string;
27
- protected get clickedResultStorageTTLMs(): number;
32
+ protected get storageKey(): string;
33
+ protected get storageTTLMs(): number;
28
34
  /**
29
35
  * Stores in the local storage the information from the Result clicked by the user
30
- * in order to be able to track later on.
36
+ * in order to be able to track the add to cart later on the result's PDP.
31
37
  *
32
38
  * @param result - The result to store.
33
39
  *
34
40
  * @public
35
41
  */
36
42
  storeResultClicked(result: Result): void;
43
+ /**
44
+ * Stores in the session storage the information from the Result added to the cart
45
+ * by the user in order to be able to track the checkout later on when the checkout
46
+ * process has been completed by shopper.
47
+ *
48
+ * @param result - The result to store.
49
+ *
50
+ * @public
51
+ */
52
+ storeAddToCart(result: Result): void;
37
53
  /**
38
54
  * Checks if the local storage contains a result information for the given id and moves
39
55
  * the result info from the local storage to the session storage.
@@ -44,8 +60,9 @@ export declare class DefaultPDPAddToCartService implements PDPAddToCartService {
44
60
  */
45
61
  moveToSessionStorage(id?: string): void;
46
62
  /**
47
- * Checks if the session storage contains a result information for given id or the current url
48
- * and tracks the add to cart if exists.
63
+ * Checks if the session storage contains a result information for a given id or the current url.
64
+ * If exists, it tracks the add to cart and saves the add to cart information into session
65
+ * storage.
49
66
  *
50
67
  * @param id - The id of the result to track.
51
68
  *
@@ -55,13 +72,14 @@ export declare class DefaultPDPAddToCartService implements PDPAddToCartService {
55
72
  /**
56
73
  * Calculates the browser storage key for the given id.
57
74
  *
75
+ * @param keyPrefix - The key prefix to use in the storage.
58
76
  * @param id - The id to be used for the storage key.
59
77
  *
60
78
  * @returns The complete key to be used for storage.
61
79
  *
62
80
  * @internal
63
81
  */
64
- protected getStorageId(id?: string): string | null;
82
+ protected getStorageId(keyPrefix: string, id?: string): string | null;
65
83
  /**
66
84
  * Logs a warning message in case the tracking cannot be done.
67
85
  *
@@ -79,4 +97,4 @@ export declare class DefaultPDPAddToCartService implements PDPAddToCartService {
79
97
  */
80
98
  protected getPathName(url: string): string;
81
99
  }
82
- //# sourceMappingURL=pdp-add-to-cart.service.d.ts.map
100
+ //# sourceMappingURL=external-tagging.service.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"external-tagging.service.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/service/external-tagging.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,MAAM,CAAC;AAC7B,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAC5C,OAAO,EAAyB,cAAc,EAAE,MAAM,8BAA8B,CAAC;AACrF,OAAO,EAAE,eAAe,EAAE,MAAM,sBAAsB,CAAC;AAEvD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD;;;;GAIG;AACH,qBAAa,6BAA8B,YAAW,sBAAsB;IAqBxE,SAAS,CAAC,mBAAmB,EAAE,cAAc;IAC7C,SAAS,CAAC,qBAAqB,EAAE,cAAc;IArBjD;;;;OAIG;IACH,gBAAuB,qBAAqB,iBAAiB;IAE7D;;;;OAIG;IACH,gBAAuB,kBAAkB,cAAc;IAEvD;;OAEG;IACH,OAAc,QAAQ,EAAE,sBAAsB,CAAuC;gBAGzE,mBAAmB,GAAE,cAA6D,EAClF,qBAAqB,GAAE,cAA+D;IAGlG,SAAS,KAAK,KAAK,IAAI,KAAK,CAAC,eAAe,CAAC,CAE5C;IAED,SAAS,KAAK,UAAU,IAAI,MAAM,CAEjC;IAED,SAAS,KAAK,YAAY,IAAI,MAAM,CAEnC;IAED;;;;;;;OAOG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQxC;;;;;;;;OAQG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI;IAQpC;;;;;;;OAOG;IACH,oBAAoB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAUvC;;;;;;;;OAQG;IACH,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI;IAmBjC;;;;;;;;;OASG;IACH,SAAS,CAAC,YAAY,CAAC,SAAS,EAAE,MAAM,EAAE,EAAE,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI;IAcrE;;;;OAIG;IACH,SAAS,CAAC,kBAAkB,IAAI,IAAI;IAQpC;;;;;;;;OAQG;IACH,SAAS,CAAC,WAAW,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM;CAiB3C"}
@@ -1,3 +1,3 @@
1
- export * from './pdp-add-to-cart.service';
1
+ export * from './external-tagging.service';
2
2
  export * from './types';
3
3
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/service/index.ts"],"names":[],"mappings":"AAAA,cAAc,2BAA2B,CAAC;AAC1C,cAAc,SAAS,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/service/index.ts"],"names":[],"mappings":"AAAA,cAAc,4BAA4B,CAAC;AAC3C,cAAc,SAAS,CAAC"}
@@ -4,14 +4,22 @@ import { Result } from '@empathyco/x-types';
4
4
  *
5
5
  * @public
6
6
  */
7
- export interface PDPAddToCartService {
7
+ export interface ExternalTaggingService {
8
8
  /**
9
9
  * Stores in the local storage the information from the Result clicked by the user
10
- * in order to be able to track later on.
10
+ * in order to be able to track the add to cart later on the result's PDP.
11
11
  *
12
12
  * @param result - The result to store.
13
13
  */
14
14
  storeResultClicked(result: Result): void;
15
+ /**
16
+ * Stores in the session storage the information from the Result added to the cart
17
+ * by the user in order to be able to track the checkout later on when the checkout
18
+ * process has been completed by shopper.
19
+ *
20
+ * @param result - The result to store.
21
+ */
22
+ storeAddToCart(result: Result): void;
15
23
  /**
16
24
  * Checks if the local storage contains a result information for the given id and moves
17
25
  * the result info from the local storage to the session storage.
@@ -20,8 +28,9 @@ export interface PDPAddToCartService {
20
28
  */
21
29
  moveToSessionStorage(id?: string): void;
22
30
  /**
23
- * Checks if the session storage contains a result information for given id or the current url
24
- * and tracks the add to cart if exists.
31
+ * Checks if the session storage contains a result information for a given id or the current url.
32
+ * If exists, it tracks the add to cart and saves the add to cart information into session
33
+ * storage.
25
34
  *
26
35
  * @param id - The id of the result to track.
27
36
  */
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/service/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,mBAAmB;IAClC;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;;;OAKG;IACH,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC"}
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../../../src/x-modules/tagging/service/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAC;AAE5C;;;;GAIG;AACH,MAAM,WAAW,sBAAsB;IACrC;;;;;OAKG;IACH,kBAAkB,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAEzC;;;;;;OAMG;IACH,cAAc,CAAC,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;IAErC;;;;;OAKG;IACH,oBAAoB,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;IAExC;;;;;;OAMG;IACH,cAAc,CAAC,EAAE,CAAC,EAAE,MAAM,GAAG,IAAI,CAAC;CACnC"}
@@ -186,6 +186,7 @@ export declare const taggingWiring: {
186
186
  UserClickedResultAddToCart: {
187
187
  trackAddToCartWire: Wire<Taggable>;
188
188
  trackResultClickedWire: Wire<Taggable>;
189
+ storeAddToCartWire: Wire<Result>;
189
190
  };
190
191
  UserClickedPDPAddToCart: {
191
192
  trackAddToCartFromSessionStorage: Wire<string | undefined>;
@@ -1 +1 @@
1
- {"version":3,"file":"wiring.d.ts","sourceRoot":"","sources":["../../../../src/x-modules/tagging/wiring.ts"],"names":[],"mappings":"AAAA,OAAO,EAEL,MAAM,EAEN,QAAQ,EACR,OAAO,EACP,cAAc,EACf,MAAM,oBAAoB,CAAC;AAS5B,OAAO,EAAuB,IAAI,EAAE,MAAM,2BAA2B,CAAC;AA8EtE;;;;GAIG;AACH,eAAO,MAAM,UAAU,eAA2B,CAAC;AAEnD;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,uDAA2C,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,gBAAgB,8CAA4B,CAAC;AAE1D;;;;GAIG;AACH,eAAO,MAAM,cAAc,yCAK1B,CAAC;AAEF;;;;;GAKG;AACH,eAAO,MAAM,mBAAmB,sBAa/B,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,+BAA+B,gBAA0C,CAAC;AAEvF;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,gBAA2B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,gBAA2B,CAAC;AAE/D;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,gBAA8B,CAAC;AAE9D;;;;GAIG;AACH,eAAO,MAAM,uBAAuB,gBAAyC,CAAC;AAE9E;;;;GAIG;AACH,eAAO,MAAM,8BAA8B,gBAAkC,CAAC;AAE9E;;;;GAIG;AACH,e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AAC,QAAQ,CAAC,CAQtE;AAED;;;;GAIG;AACH,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2DxB,CAAC"}
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md) &gt; [clickedResultStorageKey](./x-components.defaultpdpaddtocartservice.clickedresultstoragekey.md)
4
-
5
- ## DefaultPDPAddToCartService.clickedResultStorageKey property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- protected get clickedResultStorageKey(): string;
11
- ```
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md) &gt; [clickedResultStorageTTLMs](./x-components.defaultpdpaddtocartservice.clickedresultstoragettlms.md)
4
-
5
- ## DefaultPDPAddToCartService.clickedResultStorageTTLMs property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- protected get clickedResultStorageTTLMs(): number;
11
- ```
@@ -1,13 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md) &gt; [instance](./x-components.defaultpdpaddtocartservice.instance.md)
4
-
5
- ## DefaultPDPAddToCartService.instance property
6
-
7
- Global instance of the [PDPAddToCartService](./x-components.pdpaddtocartservice.md)<!-- -->.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- static instance: PDPAddToCartService;
13
- ```
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md) &gt; [localStorageService](./x-components.defaultpdpaddtocartservice.localstorageservice.md)
4
-
5
- ## DefaultPDPAddToCartService.localStorageService property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- protected localStorageService: StorageService;
11
- ```
@@ -1,41 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md)
4
-
5
- ## DefaultPDPAddToCartService class
6
-
7
- Default implementation for the [PDPAddToCartService](./x-components.pdpaddtocartservice.md)<!-- -->.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- export declare class DefaultPDPAddToCartService implements PDPAddToCartService
13
- ```
14
- **Implements:** [PDPAddToCartService](./x-components.pdpaddtocartservice.md)
15
-
16
- ## Constructors
17
-
18
- | Constructor | Modifiers | Description |
19
- | --- | --- | --- |
20
- | [(constructor)(localStorageService, sessionStorageService)](./x-components.defaultpdpaddtocartservice._constructor_.md) | | Constructs a new instance of the <code>DefaultPDPAddToCartService</code> class |
21
-
22
- ## Properties
23
-
24
- | Property | Modifiers | Type | Description |
25
- | --- | --- | --- | --- |
26
- | [clickedResultStorageKey](./x-components.defaultpdpaddtocartservice.clickedresultstoragekey.md) | <p><code>protected</code></p><p><code>readonly</code></p> | string | |
27
- | [clickedResultStorageTTLMs](./x-components.defaultpdpaddtocartservice.clickedresultstoragettlms.md) | <p><code>protected</code></p><p><code>readonly</code></p> | number | |
28
- | [instance](./x-components.defaultpdpaddtocartservice.instance.md) | <code>static</code> | [PDPAddToCartService](./x-components.pdpaddtocartservice.md) | Global instance of the [PDPAddToCartService](./x-components.pdpaddtocartservice.md)<!-- -->. |
29
- | [localStorageService](./x-components.defaultpdpaddtocartservice.localstorageservice.md) | <code>protected</code> | StorageService | |
30
- | [RESULT\_CLICKED\_ID\_KEY](./x-components.defaultpdpaddtocartservice.result_clicked_id_key.md) | <p><code>static</code></p><p><code>readonly</code></p> | (not declared) | Session id key to use as key in the storage. |
31
- | [sessionStorageService](./x-components.defaultpdpaddtocartservice.sessionstorageservice.md) | <code>protected</code> | StorageService | |
32
- | [store](./x-components.defaultpdpaddtocartservice.store.md) | <p><code>protected</code></p><p><code>readonly</code></p> | Store&lt;[RootXStoreState](./x-components.rootxstorestate.md)<!-- -->&gt; | |
33
-
34
- ## Methods
35
-
36
- | Method | Modifiers | Description |
37
- | --- | --- | --- |
38
- | [moveToSessionStorage(id)](./x-components.defaultpdpaddtocartservice.movetosessionstorage.md) | | Checks if the local storage contains a result information for the given id and moves the result info from the local storage to the session storage. |
39
- | [storeResultClicked(result)](./x-components.defaultpdpaddtocartservice.storeresultclicked.md) | | Stores in the local storage the information from the Result clicked by the user in order to be able to track later on. |
40
- | [trackAddToCart(id)](./x-components.defaultpdpaddtocartservice.trackaddtocart.md) | | Checks if the session storage contains a result information for given id or the current url and tracks the add to cart if exists. |
41
-
@@ -1,13 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md) &gt; [RESULT\_CLICKED\_ID\_KEY](./x-components.defaultpdpaddtocartservice.result_clicked_id_key.md)
4
-
5
- ## DefaultPDPAddToCartService.RESULT\_CLICKED\_ID\_KEY property
6
-
7
- Session id key to use as key in the storage.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- static readonly RESULT_CLICKED_ID_KEY = "add-to-cart";
13
- ```
@@ -1,11 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [DefaultPDPAddToCartService](./x-components.defaultpdpaddtocartservice.md) &gt; [sessionStorageService](./x-components.defaultpdpaddtocartservice.sessionstorageservice.md)
4
-
5
- ## DefaultPDPAddToCartService.sessionStorageService property
6
-
7
- **Signature:**
8
-
9
- ```typescript
10
- protected sessionStorageService: StorageService;
11
- ```
@@ -1,22 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [PDPAddToCartService](./x-components.pdpaddtocartservice.md)
4
-
5
- ## PDPAddToCartService interface
6
-
7
- Service to handle the workflow for tracking add to cart from PDP.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- export interface PDPAddToCartService
13
- ```
14
-
15
- ## Methods
16
-
17
- | Method | Description |
18
- | --- | --- |
19
- | [moveToSessionStorage(id)](./x-components.pdpaddtocartservice.movetosessionstorage.md) | Checks if the local storage contains a result information for the given id and moves the result info from the local storage to the session storage. |
20
- | [storeResultClicked(result)](./x-components.pdpaddtocartservice.storeresultclicked.md) | Stores in the local storage the information from the Result clicked by the user in order to be able to track later on. |
21
- | [trackAddToCart(id)](./x-components.pdpaddtocartservice.trackaddtocart.md) | Checks if the session storage contains a result information for given id or the current url and tracks the add to cart if exists. |
22
-
@@ -1,13 +0,0 @@
1
- <!-- Do not edit this file. It is automatically generated by API Documenter. -->
2
-
3
- [Home](./index.md) &gt; [@empathyco/x-components](./x-components.md) &gt; [TaggingConfig](./x-components.taggingconfig.md) &gt; [clickedResultStorageTTLMs](./x-components.taggingconfig.clickedresultstoragettlms.md)
4
-
5
- ## TaggingConfig.clickedResultStorageTTLMs property
6
-
7
- Time in milliseconds to keep the information for a result clicked by the user.
8
-
9
- **Signature:**
10
-
11
- ```typescript
12
- clickedResultStorageTTLMs: number | null;
13
- ```
@@ -1 +0,0 @@
1
- {"version":3,"file":"pdp-add-to-cart.service.js","sources":["../../../../../src/x-modules/tagging/service/pdp-add-to-cart.service.ts"],"sourcesContent":["import { Store } from 'vuex';\nimport { Result } from '@empathyco/x-types';\nimport { BrowserStorageService, StorageService } from '@empathyco/x-storage-service';\nimport { RootXStoreState } from '../../../store/index';\nimport { XPlugin } from '../../../plugins/index';\nimport { PDPAddToCartService } from './types';\n\n/**\n * Default implementation for the {@link PDPAddToCartService}.\n *\n * @public\n */\nexport class DefaultPDPAddToCartService implements PDPAddToCartService {\n /**\n * Session id key to use as key in the storage.\n *\n * @public\n */\n public static readonly RESULT_CLICKED_ID_KEY = 'add-to-cart';\n\n /**\n * Global instance of the {@link PDPAddToCartService}.\n */\n public static instance: PDPAddToCartService = new DefaultPDPAddToCartService();\n\n public constructor(\n protected localStorageService: StorageService = new BrowserStorageService(localStorage, 'x'),\n protected sessionStorageService: StorageService = new BrowserStorageService(sessionStorage, 'x')\n ) {}\n\n protected get store(): Store<RootXStoreState> {\n return XPlugin.store;\n }\n\n protected get clickedResultStorageKey(): string {\n return this.store.state.x.tagging.config.clickedResultStorageKey as string;\n }\n\n protected get clickedResultStorageTTLMs(): number {\n return this.store.state.x.tagging.config.clickedResultStorageTTLMs as number;\n }\n\n /**\n * Stores in the local storage the information from the Result clicked by the user\n * in order to be able to track later on.\n *\n * @param result - The result to store.\n *\n * @public\n */\n storeResultClicked(result: Result): void {\n const key = result[this.clickedResultStorageKey as keyof Result] as string;\n const storageId = this.getStorageId(key);\n if (storageId) {\n this.localStorageService.setItem(storageId, result, this.clickedResultStorageTTLMs);\n }\n }\n\n /**\n * Checks if the local storage contains a result information for the given id and moves\n * the result info from the local storage to the session storage.\n *\n * @param id - The id of the result to move to the session storage.\n *\n * @public\n */\n moveToSessionStorage(id?: string): void {\n const storageId = this.getStorageId(id);\n if (storageId) {\n const result = this.localStorageService.removeItem(storageId);\n if (result) {\n this.sessionStorageService.setItem(storageId, result);\n }\n }\n }\n\n /**\n * Checks if the session storage contains a result information for given id or the current url\n * and tracks the add to cart if exists.\n *\n * @param id - The id of the result to track.\n *\n * @public\n */\n trackAddToCart(id?: string): void {\n const storageId =\n this.clickedResultStorageKey === 'url' ? this.getStorageId() : this.getStorageId(id);\n if (storageId) {\n const result = this.sessionStorageService.getItem<Result>(storageId);\n if (result?.tagging?.add2cart) {\n result.tagging.add2cart.params.location = 'pdp';\n this.store.dispatch('x/tagging/track', result.tagging.add2cart);\n }\n }\n }\n\n /**\n * Calculates the browser storage key for the given id.\n *\n * @param id - The id to be used for the storage key.\n *\n * @returns The complete key to be used for storage.\n *\n * @internal\n */\n protected getStorageId(id?: string): string | null {\n if (this.clickedResultStorageKey === 'url') {\n let url = id ?? window.location.href;\n url = url.replace(/\\s|\\+/g, '%20');\n const pathName = this.getPathName(url);\n return `${DefaultPDPAddToCartService.RESULT_CLICKED_ID_KEY}-${pathName}`;\n } else if (id) {\n return `${DefaultPDPAddToCartService.RESULT_CLICKED_ID_KEY}-${id}`;\n } else {\n this.showWarningMessage();\n return null;\n }\n }\n\n /**\n * Logs a warning message in case the tracking cannot be done.\n *\n * @internal\n */\n protected showWarningMessage(): void {\n if (this.clickedResultStorageKey !== 'url') {\n //TODO: add here logger\n //eslint-disable-next-line no-console\n console.warn('No product id was provided but the storage was not configured to use the url');\n }\n }\n\n /**\n * Returns the pathname for a given url.\n *\n * @param url - The url to get the pathname from.\n *\n * @returns The pathname of the url.\n *\n * @internal\n */\n protected getPathName(url: string): string {\n let urlObject: URL;\n try {\n // Check if the url is relative or absolute path\n if (/^(\\.\\.\\/|\\.\\/|\\/)/.test(url)) {\n urlObject = new URL(url, location.origin);\n } else {\n urlObject = new URL(url);\n }\n return urlObject.pathname;\n } catch (e) {\n //TODO: add here logger\n //eslint-disable-next-line no-console\n console.warn(`There was a problem with url ${url}`);\n return url;\n }\n }\n}\n"],"names":[],"mappings":";;;;;;;;;;AAOA;;;;AAIG;MACU,0BAA0B,CAAA;AAarC,IAAA,WAAA,CACY,sBAAsC,IAAI,qBAAqB,CAAC,YAAY,EAAE,GAAG,CAAC,EAClF,qBAAA,GAAwC,IAAI,qBAAqB,CAAC,cAAc,EAAE,GAAG,CAAC,EAAA;QADtF,IAAmB,CAAA,mBAAA,GAAnB,mBAAmB,CAA+D;QAClF,IAAqB,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