@infrab4a/connect-angular 5.0.0-alpha.9 → 5.0.0-beta.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 (182) hide show
  1. package/angular-connect.module.d.ts +9 -21
  2. package/angular-firestore.module.d.ts +2 -1
  3. package/angular-hasura-graphql.module.d.ts +6 -4
  4. package/consts/firebase-const.d.ts +0 -1
  5. package/consts/index.d.ts +0 -2
  6. package/esm2022/angular-connect.module.mjs +113 -0
  7. package/esm2022/angular-elastic-search.module.mjs +34 -0
  8. package/esm2022/angular-firebase-auth.module.mjs +115 -0
  9. package/esm2022/angular-firestore.module.mjs +502 -0
  10. package/esm2022/angular-hasura-graphql.module.mjs +265 -0
  11. package/{esm2020 → esm2022}/consts/backend-url.const.mjs +1 -1
  12. package/{esm2020 → esm2022}/consts/firebase-const.mjs +1 -2
  13. package/{esm2020 → esm2022}/consts/index.mjs +1 -3
  14. package/{esm2020 → esm2022}/index.mjs +1 -2
  15. package/{esm2020 → esm2022}/services/auth.service.mjs +6 -6
  16. package/esm2022/services/cart.service.mjs +281 -0
  17. package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +41 -0
  18. package/{esm2020 → esm2022}/services/catalog/adapters/old-category-structure.adapter.mjs +6 -6
  19. package/esm2022/services/catalog/catalog.service.mjs +174 -0
  20. package/esm2022/services/catalog/category.service.mjs +51 -0
  21. package/{esm2020 → esm2022}/services/catalog/models/category-with-tree.model.mjs +1 -1
  22. package/esm2022/services/catalog/types/index.mjs +2 -0
  23. package/esm2022/services/catalog/wishlist.service.mjs +116 -0
  24. package/esm2022/services/checkout-subscription.service.mjs +53 -0
  25. package/esm2022/services/checkout.service.mjs +71 -0
  26. package/esm2022/services/coupon.service.mjs +235 -0
  27. package/{esm2020 → esm2022}/services/helpers/util.helper.mjs +3 -3
  28. package/esm2022/services/home-shop.service.mjs +125 -0
  29. package/{esm2020 → esm2022}/services/index.mjs +2 -1
  30. package/{esm2020 → esm2022}/services/order.service.mjs +6 -6
  31. package/esm2022/services/shipping.service.mjs +96 -0
  32. package/esm2022/services/types/shipping-methods.type.mjs +2 -0
  33. package/fesm2022/infrab4a-connect-angular.mjs +2313 -0
  34. package/fesm2022/infrab4a-connect-angular.mjs.map +1 -0
  35. package/index.d.ts +0 -1
  36. package/package.json +10 -18
  37. package/services/cart.service.d.ts +24 -8
  38. package/services/catalog/catalog.service.d.ts +73 -14
  39. package/services/catalog/category.service.d.ts +9 -16
  40. package/services/catalog/types/index.d.ts +0 -4
  41. package/services/catalog/wishlist.service.d.ts +5 -24
  42. package/services/checkout-subscription.service.d.ts +5 -6
  43. package/services/checkout.service.d.ts +10 -17
  44. package/services/coupon.service.d.ts +9 -16
  45. package/services/home-shop.service.d.ts +6 -6
  46. package/services/index.d.ts +1 -0
  47. package/services/shipping.service.d.ts +19 -0
  48. package/services/types/shipping-methods.type.d.ts +12 -0
  49. package/angular-vertex-search.module.d.ts +0 -9
  50. package/consts/persistence.const.d.ts +0 -1
  51. package/consts/vertex-config.const.d.ts +0 -1
  52. package/esm2020/angular-connect.module.mjs +0 -289
  53. package/esm2020/angular-elastic-search.module.mjs +0 -34
  54. package/esm2020/angular-firebase-auth.module.mjs +0 -141
  55. package/esm2020/angular-firestore.module.mjs +0 -541
  56. package/esm2020/angular-hasura-graphql.module.mjs +0 -333
  57. package/esm2020/angular-vertex-search.module.mjs +0 -34
  58. package/esm2020/consts/persistence.const.mjs +0 -2
  59. package/esm2020/consts/vertex-config.const.mjs +0 -2
  60. package/esm2020/interfaces/catalog-strategies.interface.mjs +0 -2
  61. package/esm2020/interfaces/category-facades.interface.mjs +0 -2
  62. package/esm2020/interfaces/index.mjs +0 -3
  63. package/esm2020/persistence/cookie-data-persistence.mjs +0 -22
  64. package/esm2020/persistence/data-persistence.mjs +0 -2
  65. package/esm2020/persistence/index.mjs +0 -3
  66. package/esm2020/services/cart/cart-services.facade.mjs +0 -21
  67. package/esm2020/services/cart/index.mjs +0 -2
  68. package/esm2020/services/cart.service.mjs +0 -73
  69. package/esm2020/services/catalog/adapters/new-category-structure.adapter.mjs +0 -43
  70. package/esm2020/services/catalog/catalog.service.mjs +0 -111
  71. package/esm2020/services/catalog/category.service.mjs +0 -39
  72. package/esm2020/services/catalog/context/catalog-search.context.mjs +0 -40
  73. package/esm2020/services/catalog/facades/catalog-service.facade.mjs +0 -32
  74. package/esm2020/services/catalog/facades/catalog-strategies.facade.mjs +0 -17
  75. package/esm2020/services/catalog/facades/category-repository.facade.mjs +0 -20
  76. package/esm2020/services/catalog/facades/category-service.facade.mjs +0 -30
  77. package/esm2020/services/catalog/facades/index.mjs +0 -6
  78. package/esm2020/services/catalog/facades/product-catalog.facade.mjs +0 -21
  79. package/esm2020/services/catalog/helpers/brand-manager.helper.mjs +0 -57
  80. package/esm2020/services/catalog/helpers/catalog-filter.helper.mjs +0 -44
  81. package/esm2020/services/catalog/helpers/catalog-sort.helper.mjs +0 -52
  82. package/esm2020/services/catalog/helpers/index.mjs +0 -5
  83. package/esm2020/services/catalog/helpers/product-fields.helper.mjs +0 -39
  84. package/esm2020/services/catalog/services/catalog-helpers.service.mjs +0 -33
  85. package/esm2020/services/catalog/services/catalog-operations.facade.mjs +0 -26
  86. package/esm2020/services/catalog/services/catalog-repository.service.mjs +0 -25
  87. package/esm2020/services/catalog/services/index.mjs +0 -5
  88. package/esm2020/services/catalog/services/product-management.facade.mjs +0 -25
  89. package/esm2020/services/catalog/strategies/category-search.strategy.mjs +0 -133
  90. package/esm2020/services/catalog/strategies/index.mjs +0 -4
  91. package/esm2020/services/catalog/strategies/profile-search.strategy.mjs +0 -42
  92. package/esm2020/services/catalog/strategies/term-search.strategy.mjs +0 -126
  93. package/esm2020/services/catalog/strategies/types/strategy-params.type.mjs +0 -2
  94. package/esm2020/services/catalog/types/fetch-products-options.type.mjs +0 -2
  95. package/esm2020/services/catalog/types/fetch-products-params.type.mjs +0 -2
  96. package/esm2020/services/catalog/types/fetch-products-response.type.mjs +0 -2
  97. package/esm2020/services/catalog/types/index.mjs +0 -6
  98. package/esm2020/services/catalog/types/method-params.type.mjs +0 -2
  99. package/esm2020/services/catalog/wishlist.service.mjs +0 -256
  100. package/esm2020/services/checkout/checkout-dependencies.facade.mjs +0 -20
  101. package/esm2020/services/checkout/checkout-repositories.facade.mjs +0 -20
  102. package/esm2020/services/checkout/index.mjs +0 -3
  103. package/esm2020/services/checkout-subscription.service.mjs +0 -55
  104. package/esm2020/services/checkout.service.mjs +0 -106
  105. package/esm2020/services/coupon/coupon-repositories.facade.mjs +0 -24
  106. package/esm2020/services/coupon/index.mjs +0 -2
  107. package/esm2020/services/coupon/types/coupon-params.type.mjs +0 -2
  108. package/esm2020/services/coupon.service.mjs +0 -248
  109. package/esm2020/services/home-shop/home-shop-repositories.facade.mjs +0 -24
  110. package/esm2020/services/home-shop/index.mjs +0 -2
  111. package/esm2020/services/home-shop.service.mjs +0 -119
  112. package/esm2020/services/shared/configuration.facade.mjs +0 -29
  113. package/esm2020/services/shared/index.mjs +0 -2
  114. package/fesm2015/infrab4a-connect-angular.mjs +0 -3373
  115. package/fesm2015/infrab4a-connect-angular.mjs.map +0 -1
  116. package/fesm2020/infrab4a-connect-angular.mjs +0 -3278
  117. package/fesm2020/infrab4a-connect-angular.mjs.map +0 -1
  118. package/interfaces/catalog-strategies.interface.d.ts +0 -31
  119. package/interfaces/category-facades.interface.d.ts +0 -6
  120. package/interfaces/index.d.ts +0 -2
  121. package/persistence/cookie-data-persistence.d.ts +0 -10
  122. package/persistence/data-persistence.d.ts +0 -6
  123. package/persistence/index.d.ts +0 -2
  124. package/services/cart/cart-services.facade.d.ts +0 -12
  125. package/services/cart/index.d.ts +0 -1
  126. package/services/catalog/context/catalog-search.context.d.ts +0 -14
  127. package/services/catalog/facades/catalog-service.facade.d.ts +0 -15
  128. package/services/catalog/facades/catalog-strategies.facade.d.ts +0 -10
  129. package/services/catalog/facades/category-repository.facade.d.ts +0 -9
  130. package/services/catalog/facades/category-service.facade.d.ts +0 -15
  131. package/services/catalog/facades/index.d.ts +0 -5
  132. package/services/catalog/facades/product-catalog.facade.d.ts +0 -10
  133. package/services/catalog/helpers/brand-manager.helper.d.ts +0 -14
  134. package/services/catalog/helpers/catalog-filter.helper.d.ts +0 -8
  135. package/services/catalog/helpers/catalog-sort.helper.d.ts +0 -7
  136. package/services/catalog/helpers/index.d.ts +0 -4
  137. package/services/catalog/helpers/product-fields.helper.d.ts +0 -7
  138. package/services/catalog/services/catalog-helpers.service.d.ts +0 -17
  139. package/services/catalog/services/catalog-operations.facade.d.ts +0 -13
  140. package/services/catalog/services/catalog-repository.service.d.ts +0 -12
  141. package/services/catalog/services/index.d.ts +0 -4
  142. package/services/catalog/services/product-management.facade.d.ts +0 -12
  143. package/services/catalog/strategies/category-search.strategy.d.ts +0 -19
  144. package/services/catalog/strategies/index.d.ts +0 -3
  145. package/services/catalog/strategies/profile-search.strategy.d.ts +0 -14
  146. package/services/catalog/strategies/term-search.strategy.d.ts +0 -20
  147. package/services/catalog/strategies/types/strategy-params.type.d.ts +0 -58
  148. package/services/catalog/types/fetch-products-options.type.d.ts +0 -8
  149. package/services/catalog/types/fetch-products-params.type.d.ts +0 -25
  150. package/services/catalog/types/fetch-products-response.type.d.ts +0 -19
  151. package/services/catalog/types/method-params.type.d.ts +0 -17
  152. package/services/checkout/checkout-dependencies.facade.d.ts +0 -10
  153. package/services/checkout/checkout-repositories.facade.d.ts +0 -9
  154. package/services/checkout/index.d.ts +0 -2
  155. package/services/coupon/coupon-repositories.facade.d.ts +0 -10
  156. package/services/coupon/index.d.ts +0 -1
  157. package/services/coupon/types/coupon-params.type.d.ts +0 -13
  158. package/services/home-shop/home-shop-repositories.facade.d.ts +0 -10
  159. package/services/home-shop/index.d.ts +0 -1
  160. package/services/shared/configuration.facade.d.ts +0 -12
  161. package/services/shared/index.d.ts +0 -1
  162. /package/{esm2020 → esm2022}/consts/category-structure.mjs +0 -0
  163. /package/{esm2020 → esm2022}/consts/default-shop.const.mjs +0 -0
  164. /package/{esm2020 → esm2022}/consts/es-config.const.mjs +0 -0
  165. /package/{esm2020 → esm2022}/consts/hasura-options.const.mjs +0 -0
  166. /package/{esm2020 → esm2022}/consts/storage-base-url.const.mjs +0 -0
  167. /package/{esm2020 → esm2022}/helpers/index.mjs +0 -0
  168. /package/{esm2020 → esm2022}/helpers/mobile-operation-system-checker.helper.mjs +0 -0
  169. /package/{esm2020 → esm2022}/infrab4a-connect-angular.mjs +0 -0
  170. /package/{esm2020 → esm2022}/services/catalog/adapters/category-structure.adapter.mjs +0 -0
  171. /package/{esm2020 → esm2022}/services/catalog/adapters/index.mjs +0 -0
  172. /package/{esm2020 → esm2022}/services/catalog/enums/index.mjs +0 -0
  173. /package/{esm2020 → esm2022}/services/catalog/enums/product-sorts.enum.mjs +0 -0
  174. /package/{esm2020 → esm2022}/services/catalog/index.mjs +0 -0
  175. /package/{esm2020 → esm2022}/services/catalog/models/index.mjs +0 -0
  176. /package/{esm2020 → esm2022}/services/catalog/types/product-sort.type.mjs +0 -0
  177. /package/{esm2020 → esm2022}/services/helpers/index.mjs +0 -0
  178. /package/{esm2020 → esm2022}/services/types/index.mjs +0 -0
  179. /package/{esm2020 → esm2022}/services/types/required-checkout-data.type.mjs +0 -0
  180. /package/{esm2020 → esm2022}/services/types/required-checkout-subscription-data.type.mjs +0 -0
  181. /package/{esm2020 → esm2022}/types/firebase-app-config.type.mjs +0 -0
  182. /package/{esm2020 → esm2022}/types/index.mjs +0 -0
@@ -0,0 +1,2313 @@
1
+ import * as i0 from '@angular/core';
2
+ import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
3
+ import * as i1$4 from '@angular/fire/app';
4
+ import { FirebaseApp, getApp, initializeApp, provideFirebaseApp } from '@angular/fire/app';
5
+ import * as i1$2 from '@infrab4a/connect';
6
+ import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, FirebaseFileUploaderService, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewsHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, InvalidArgumentError, Category, Wishlist, CheckoutSubscription, Product, RequiredArgumentError, add, Order, UpdateUserImage } from '@infrab4a/connect';
7
+ import * as i1 from '@angular/fire/auth';
8
+ import { Auth, getAuth, provideAuth, getIdToken, authState } from '@angular/fire/auth';
9
+ import { isPlatformBrowser, isPlatformServer } from '@angular/common';
10
+ import * as i1$1 from '@angular/fire/firestore';
11
+ import { Firestore, getFirestore, memoryLocalCache, initializeFirestore, provideFirestore, doc, docSnapshots } from '@angular/fire/firestore';
12
+ import * as i2 from '@angular/fire/storage';
13
+ import { Storage, getStorage, provideStorage } from '@angular/fire/storage';
14
+ import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
15
+ import { map, catchError, mergeMap, concatMap, tap } from 'rxjs/operators';
16
+ import cookie from 'js-cookie';
17
+ import { __metadata, __decorate } from 'tslib';
18
+ import { Type } from 'class-transformer';
19
+ import * as i1$3 from '@angular/common/http';
20
+
21
+ const ES_CONFIG = 'ES_CONFIG';
22
+
23
+ class AngularElasticSeachModule {
24
+ static initializeApp(options) {
25
+ return {
26
+ ngModule: AngularElasticSeachModule,
27
+ providers: [{ provide: ES_CONFIG, useValue: options }],
28
+ };
29
+ }
30
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
31
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule }); }
32
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule, providers: [
33
+ {
34
+ provide: ProductsIndex,
35
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
36
+ deps: [ES_CONFIG],
37
+ },
38
+ ] }); }
39
+ }
40
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
41
+ type: NgModule,
42
+ args: [{
43
+ providers: [
44
+ {
45
+ provide: ProductsIndex,
46
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
47
+ deps: [ES_CONFIG],
48
+ },
49
+ ],
50
+ }]
51
+ }] });
52
+
53
+ const BACKEND_URL = 'BACKEND_URL';
54
+
55
+ const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
56
+
57
+ const DEFAULT_SHOP = 'DEFAULT_SHOP';
58
+
59
+ const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
60
+ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
61
+
62
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
63
+
64
+ class AngularFirebaseAuthModule {
65
+ static initializeApp(options, nameOrConfig) {
66
+ return {
67
+ ngModule: AngularFirebaseAuthModule,
68
+ providers: [
69
+ { provide: FIREBASE_OPTIONS, useValue: options },
70
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
71
+ ],
72
+ };
73
+ }
74
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
75
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] }); }
76
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
77
+ {
78
+ provide: 'Authentication',
79
+ useFactory: (authenticationService, userRepository) => {
80
+ return new Authentication(authenticationService, userRepository);
81
+ },
82
+ deps: ['AuthenticationService', 'UserRepository'],
83
+ },
84
+ {
85
+ provide: 'AuthenticationService',
86
+ useFactory: (angularFireAuth) => {
87
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
88
+ },
89
+ deps: [Auth],
90
+ },
91
+ {
92
+ provide: 'Register',
93
+ useFactory: (registerService, userRepository) => {
94
+ return new Register(registerService, userRepository);
95
+ },
96
+ deps: ['RegisterService', 'UserRepository'],
97
+ },
98
+ {
99
+ provide: 'RegisterService',
100
+ useFactory: (angularFireAuth) => {
101
+ return new RegisterFirebaseAuthService(angularFireAuth);
102
+ },
103
+ deps: [Auth],
104
+ },
105
+ {
106
+ provide: 'SignOut',
107
+ useFactory: (authenticationService) => {
108
+ return new SignOut(authenticationService);
109
+ },
110
+ deps: ['AuthenticationService'],
111
+ },
112
+ {
113
+ provide: 'RecoveryPassword',
114
+ useFactory: (authenticationService) => {
115
+ return new RecoveryPassword(authenticationService);
116
+ },
117
+ deps: ['AuthenticationService'],
118
+ },
119
+ ], imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))] }); }
120
+ }
121
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
122
+ type: NgModule,
123
+ args: [{
124
+ imports: [provideAuth((injector) => getAuth(injector.get(FirebaseApp)))],
125
+ providers: [
126
+ {
127
+ provide: 'Authentication',
128
+ useFactory: (authenticationService, userRepository) => {
129
+ return new Authentication(authenticationService, userRepository);
130
+ },
131
+ deps: ['AuthenticationService', 'UserRepository'],
132
+ },
133
+ {
134
+ provide: 'AuthenticationService',
135
+ useFactory: (angularFireAuth) => {
136
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
137
+ },
138
+ deps: [Auth],
139
+ },
140
+ {
141
+ provide: 'Register',
142
+ useFactory: (registerService, userRepository) => {
143
+ return new Register(registerService, userRepository);
144
+ },
145
+ deps: ['RegisterService', 'UserRepository'],
146
+ },
147
+ {
148
+ provide: 'RegisterService',
149
+ useFactory: (angularFireAuth) => {
150
+ return new RegisterFirebaseAuthService(angularFireAuth);
151
+ },
152
+ deps: [Auth],
153
+ },
154
+ {
155
+ provide: 'SignOut',
156
+ useFactory: (authenticationService) => {
157
+ return new SignOut(authenticationService);
158
+ },
159
+ deps: ['AuthenticationService'],
160
+ },
161
+ {
162
+ provide: 'RecoveryPassword',
163
+ useFactory: (authenticationService) => {
164
+ return new RecoveryPassword(authenticationService);
165
+ },
166
+ deps: ['AuthenticationService'],
167
+ },
168
+ ],
169
+ }]
170
+ }] });
171
+
172
+ const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
173
+
174
+ class MobileOperationSystemCheckerHelper {
175
+ static isAppleDevice() {
176
+ return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
177
+ (navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
178
+ }
179
+ }
180
+
181
+ class AngularFirestoreModule {
182
+ static initializeApp(options, nameOrConfig) {
183
+ return {
184
+ ngModule: AngularFirestoreModule,
185
+ providers: [
186
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
187
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
188
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
189
+ ],
190
+ };
191
+ }
192
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
193
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule, i2.StorageModule] }); }
194
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, providers: [
195
+ {
196
+ provide: 'FirestoreOptions',
197
+ useFactory: (firestore, platformId) => ({
198
+ firestore,
199
+ interceptors: {
200
+ request: (request) => {
201
+ if (isPlatformBrowser(platformId))
202
+ return request;
203
+ const interval = setInterval(() => { }, 100);
204
+ request.interval = interval;
205
+ return request;
206
+ },
207
+ response: (response, request) => {
208
+ if (isPlatformBrowser(platformId))
209
+ return response;
210
+ clearInterval(request.interval);
211
+ return response;
212
+ },
213
+ },
214
+ }),
215
+ deps: [Firestore, PLATFORM_ID],
216
+ },
217
+ {
218
+ provide: 'BeautyProfileRepository',
219
+ useFactory: (config, userRepository) => {
220
+ return new UserBeautyProfileFirestoreRepository(config, userRepository);
221
+ },
222
+ deps: ['FirestoreOptions', 'UserRepository'],
223
+ },
224
+ {
225
+ provide: 'Buy2WinRepository',
226
+ useFactory: (options) => {
227
+ return new Buy2WinFirestoreRepository(options);
228
+ },
229
+ deps: ['FirestoreOptions'],
230
+ },
231
+ {
232
+ provide: CategoryFirestoreRepository,
233
+ useFactory: (options) => {
234
+ return new CategoryFirestoreRepository(options);
235
+ },
236
+ deps: ['FirestoreOptions'],
237
+ },
238
+ {
239
+ provide: 'CheckoutRepository',
240
+ useFactory: (options) => {
241
+ return new CheckoutFirestoreRepository(options);
242
+ },
243
+ deps: ['FirestoreOptions'],
244
+ },
245
+ {
246
+ provide: 'CheckoutSubscriptionRepository',
247
+ useFactory: (options) => {
248
+ return new CheckoutSubscriptionFirestoreRepository(options);
249
+ },
250
+ deps: ['FirestoreOptions'],
251
+ },
252
+ {
253
+ provide: 'CouponRepository',
254
+ useFactory: (options) => {
255
+ return new CouponFirestoreRepository(options);
256
+ },
257
+ deps: ['FirestoreOptions'],
258
+ },
259
+ {
260
+ provide: 'CampaignHashtagRepository',
261
+ useFactory: (options) => {
262
+ return new CampaignHashtagFirestoreRepository(options);
263
+ },
264
+ deps: ['FirestoreOptions'],
265
+ },
266
+ {
267
+ provide: 'CampaignDashboardRepository',
268
+ useFactory: (options) => {
269
+ return new CampaignDashboardFirestoreRepository(options);
270
+ },
271
+ deps: ['FirestoreOptions'],
272
+ },
273
+ {
274
+ provide: 'EditionRepository',
275
+ useFactory: (options, subscriptionRepository) => {
276
+ return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
277
+ },
278
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
279
+ },
280
+ {
281
+ provide: 'HomeRepository',
282
+ useFactory: (options) => {
283
+ return new HomeFirestoreRepository(options);
284
+ },
285
+ deps: ['FirestoreOptions'],
286
+ },
287
+ {
288
+ provide: 'LeadRepository',
289
+ useFactory: (options) => {
290
+ return new LeadFirestoreRepository(options);
291
+ },
292
+ deps: ['FirestoreOptions'],
293
+ },
294
+ {
295
+ provide: 'LegacyOrderRepository',
296
+ useFactory: (options) => {
297
+ return new LegacyOrderFirestoreRepository(options);
298
+ },
299
+ deps: ['FirestoreOptions'],
300
+ },
301
+ {
302
+ provide: 'ShopMenuRepository',
303
+ useFactory: (options) => {
304
+ return new ShopMenuFirestoreRepository(options);
305
+ },
306
+ deps: ['FirestoreOptions'],
307
+ },
308
+ {
309
+ provide: 'OrderRepository',
310
+ useFactory: (options) => {
311
+ return new OrderFirestoreRepository(options);
312
+ },
313
+ deps: ['FirestoreOptions'],
314
+ },
315
+ {
316
+ provide: 'PaymentRepository',
317
+ useFactory: (options) => {
318
+ return new PaymentFirestoreRepository(options);
319
+ },
320
+ deps: ['FirestoreOptions'],
321
+ },
322
+ {
323
+ provide: ProductFirestoreRepository,
324
+ useFactory: (options) => {
325
+ return new ProductFirestoreRepository(options);
326
+ },
327
+ deps: ['FirestoreOptions'],
328
+ },
329
+ {
330
+ provide: 'ShopSettingsRepository',
331
+ useFactory: (options) => {
332
+ return new ShopSettingsFirestoreRepository(options);
333
+ },
334
+ deps: ['FirestoreOptions'],
335
+ },
336
+ {
337
+ provide: 'SubscriptionPaymentRepository',
338
+ useFactory: (options, subscriptionRepository) => {
339
+ return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
340
+ },
341
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
342
+ },
343
+ {
344
+ provide: 'SubscriptionPlanRepository',
345
+ useFactory: (options) => {
346
+ return new SubscriptionPlanFirestoreRepository(options);
347
+ },
348
+ deps: ['FirestoreOptions'],
349
+ },
350
+ {
351
+ provide: 'SubscriptionProductRepository',
352
+ useFactory: (options) => {
353
+ return new SubscriptionProductFirestoreRepository(options);
354
+ },
355
+ deps: ['FirestoreOptions'],
356
+ },
357
+ {
358
+ provide: 'SubscriptionRepository',
359
+ useFactory: (options) => {
360
+ return new SubscriptionFirestoreRepository(options);
361
+ },
362
+ deps: ['FirestoreOptions'],
363
+ },
364
+ {
365
+ provide: 'UserRepository',
366
+ useFactory: (options) => {
367
+ return new UserFirestoreRepository(options);
368
+ },
369
+ deps: ['FirestoreOptions'],
370
+ },
371
+ {
372
+ provide: 'UserAddressRepository',
373
+ useFactory: (options, userRepository) => {
374
+ return new UserAddressFirestoreRepository(options, userRepository);
375
+ },
376
+ deps: ['FirestoreOptions', 'UserRepository'],
377
+ },
378
+ {
379
+ provide: 'UserPaymentMethodRepository',
380
+ useFactory: (options, userRepository) => {
381
+ return new UserPaymentMethodFirestoreRepository(options, userRepository);
382
+ },
383
+ deps: ['FirestoreOptions', 'UserRepository'],
384
+ },
385
+ {
386
+ provide: 'SubscriptionMaterializationRepository',
387
+ useFactory: (options) => {
388
+ return new SubscriptionMaterializationFirestoreRepository(options);
389
+ },
390
+ deps: ['FirestoreOptions'],
391
+ },
392
+ {
393
+ provide: 'SubscriptionSummaryRepository',
394
+ useFactory: (options) => {
395
+ return new SubscriptionSummaryFirestoreRepository(options);
396
+ },
397
+ deps: ['FirestoreOptions'],
398
+ },
399
+ {
400
+ provide: ProductVariantFirestoreRepository,
401
+ useFactory: (options, productRepository) => {
402
+ return new ProductVariantFirestoreRepository(options, productRepository);
403
+ },
404
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
405
+ },
406
+ {
407
+ provide: 'FileUploaderService',
408
+ useFactory: (storage, baseUrl) => {
409
+ return new FirebaseFileUploaderService(storage, baseUrl);
410
+ },
411
+ deps: [Storage, STORAGE_BASE_URL],
412
+ },
413
+ ], imports: [AngularElasticSeachModule,
414
+ provideFirestore((injector) => {
415
+ const platformId = injector.get(PLATFORM_ID);
416
+ if (isPlatformServer(platformId))
417
+ return getFirestore(injector.get(FirebaseApp));
418
+ if (!MobileOperationSystemCheckerHelper.isAppleDevice())
419
+ return getFirestore(injector.get(FirebaseApp));
420
+ const firestore = initializeFirestore(injector.get(FirebaseApp), {
421
+ experimentalForceLongPolling: true,
422
+ localCache: memoryLocalCache(),
423
+ });
424
+ return firestore;
425
+ }),
426
+ provideStorage(() => getStorage())] }); }
427
+ }
428
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, decorators: [{
429
+ type: NgModule,
430
+ args: [{
431
+ imports: [
432
+ AngularElasticSeachModule,
433
+ provideFirestore((injector) => {
434
+ const platformId = injector.get(PLATFORM_ID);
435
+ if (isPlatformServer(platformId))
436
+ return getFirestore(injector.get(FirebaseApp));
437
+ if (!MobileOperationSystemCheckerHelper.isAppleDevice())
438
+ return getFirestore(injector.get(FirebaseApp));
439
+ const firestore = initializeFirestore(injector.get(FirebaseApp), {
440
+ experimentalForceLongPolling: true,
441
+ localCache: memoryLocalCache(),
442
+ });
443
+ return firestore;
444
+ }),
445
+ provideStorage(() => getStorage()),
446
+ ],
447
+ providers: [
448
+ {
449
+ provide: 'FirestoreOptions',
450
+ useFactory: (firestore, platformId) => ({
451
+ firestore,
452
+ interceptors: {
453
+ request: (request) => {
454
+ if (isPlatformBrowser(platformId))
455
+ return request;
456
+ const interval = setInterval(() => { }, 100);
457
+ request.interval = interval;
458
+ return request;
459
+ },
460
+ response: (response, request) => {
461
+ if (isPlatformBrowser(platformId))
462
+ return response;
463
+ clearInterval(request.interval);
464
+ return response;
465
+ },
466
+ },
467
+ }),
468
+ deps: [Firestore, PLATFORM_ID],
469
+ },
470
+ {
471
+ provide: 'BeautyProfileRepository',
472
+ useFactory: (config, userRepository) => {
473
+ return new UserBeautyProfileFirestoreRepository(config, userRepository);
474
+ },
475
+ deps: ['FirestoreOptions', 'UserRepository'],
476
+ },
477
+ {
478
+ provide: 'Buy2WinRepository',
479
+ useFactory: (options) => {
480
+ return new Buy2WinFirestoreRepository(options);
481
+ },
482
+ deps: ['FirestoreOptions'],
483
+ },
484
+ {
485
+ provide: CategoryFirestoreRepository,
486
+ useFactory: (options) => {
487
+ return new CategoryFirestoreRepository(options);
488
+ },
489
+ deps: ['FirestoreOptions'],
490
+ },
491
+ {
492
+ provide: 'CheckoutRepository',
493
+ useFactory: (options) => {
494
+ return new CheckoutFirestoreRepository(options);
495
+ },
496
+ deps: ['FirestoreOptions'],
497
+ },
498
+ {
499
+ provide: 'CheckoutSubscriptionRepository',
500
+ useFactory: (options) => {
501
+ return new CheckoutSubscriptionFirestoreRepository(options);
502
+ },
503
+ deps: ['FirestoreOptions'],
504
+ },
505
+ {
506
+ provide: 'CouponRepository',
507
+ useFactory: (options) => {
508
+ return new CouponFirestoreRepository(options);
509
+ },
510
+ deps: ['FirestoreOptions'],
511
+ },
512
+ {
513
+ provide: 'CampaignHashtagRepository',
514
+ useFactory: (options) => {
515
+ return new CampaignHashtagFirestoreRepository(options);
516
+ },
517
+ deps: ['FirestoreOptions'],
518
+ },
519
+ {
520
+ provide: 'CampaignDashboardRepository',
521
+ useFactory: (options) => {
522
+ return new CampaignDashboardFirestoreRepository(options);
523
+ },
524
+ deps: ['FirestoreOptions'],
525
+ },
526
+ {
527
+ provide: 'EditionRepository',
528
+ useFactory: (options, subscriptionRepository) => {
529
+ return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
530
+ },
531
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
532
+ },
533
+ {
534
+ provide: 'HomeRepository',
535
+ useFactory: (options) => {
536
+ return new HomeFirestoreRepository(options);
537
+ },
538
+ deps: ['FirestoreOptions'],
539
+ },
540
+ {
541
+ provide: 'LeadRepository',
542
+ useFactory: (options) => {
543
+ return new LeadFirestoreRepository(options);
544
+ },
545
+ deps: ['FirestoreOptions'],
546
+ },
547
+ {
548
+ provide: 'LegacyOrderRepository',
549
+ useFactory: (options) => {
550
+ return new LegacyOrderFirestoreRepository(options);
551
+ },
552
+ deps: ['FirestoreOptions'],
553
+ },
554
+ {
555
+ provide: 'ShopMenuRepository',
556
+ useFactory: (options) => {
557
+ return new ShopMenuFirestoreRepository(options);
558
+ },
559
+ deps: ['FirestoreOptions'],
560
+ },
561
+ {
562
+ provide: 'OrderRepository',
563
+ useFactory: (options) => {
564
+ return new OrderFirestoreRepository(options);
565
+ },
566
+ deps: ['FirestoreOptions'],
567
+ },
568
+ {
569
+ provide: 'PaymentRepository',
570
+ useFactory: (options) => {
571
+ return new PaymentFirestoreRepository(options);
572
+ },
573
+ deps: ['FirestoreOptions'],
574
+ },
575
+ {
576
+ provide: ProductFirestoreRepository,
577
+ useFactory: (options) => {
578
+ return new ProductFirestoreRepository(options);
579
+ },
580
+ deps: ['FirestoreOptions'],
581
+ },
582
+ {
583
+ provide: 'ShopSettingsRepository',
584
+ useFactory: (options) => {
585
+ return new ShopSettingsFirestoreRepository(options);
586
+ },
587
+ deps: ['FirestoreOptions'],
588
+ },
589
+ {
590
+ provide: 'SubscriptionPaymentRepository',
591
+ useFactory: (options, subscriptionRepository) => {
592
+ return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
593
+ },
594
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
595
+ },
596
+ {
597
+ provide: 'SubscriptionPlanRepository',
598
+ useFactory: (options) => {
599
+ return new SubscriptionPlanFirestoreRepository(options);
600
+ },
601
+ deps: ['FirestoreOptions'],
602
+ },
603
+ {
604
+ provide: 'SubscriptionProductRepository',
605
+ useFactory: (options) => {
606
+ return new SubscriptionProductFirestoreRepository(options);
607
+ },
608
+ deps: ['FirestoreOptions'],
609
+ },
610
+ {
611
+ provide: 'SubscriptionRepository',
612
+ useFactory: (options) => {
613
+ return new SubscriptionFirestoreRepository(options);
614
+ },
615
+ deps: ['FirestoreOptions'],
616
+ },
617
+ {
618
+ provide: 'UserRepository',
619
+ useFactory: (options) => {
620
+ return new UserFirestoreRepository(options);
621
+ },
622
+ deps: ['FirestoreOptions'],
623
+ },
624
+ {
625
+ provide: 'UserAddressRepository',
626
+ useFactory: (options, userRepository) => {
627
+ return new UserAddressFirestoreRepository(options, userRepository);
628
+ },
629
+ deps: ['FirestoreOptions', 'UserRepository'],
630
+ },
631
+ {
632
+ provide: 'UserPaymentMethodRepository',
633
+ useFactory: (options, userRepository) => {
634
+ return new UserPaymentMethodFirestoreRepository(options, userRepository);
635
+ },
636
+ deps: ['FirestoreOptions', 'UserRepository'],
637
+ },
638
+ {
639
+ provide: 'SubscriptionMaterializationRepository',
640
+ useFactory: (options) => {
641
+ return new SubscriptionMaterializationFirestoreRepository(options);
642
+ },
643
+ deps: ['FirestoreOptions'],
644
+ },
645
+ {
646
+ provide: 'SubscriptionSummaryRepository',
647
+ useFactory: (options) => {
648
+ return new SubscriptionSummaryFirestoreRepository(options);
649
+ },
650
+ deps: ['FirestoreOptions'],
651
+ },
652
+ {
653
+ provide: ProductVariantFirestoreRepository,
654
+ useFactory: (options, productRepository) => {
655
+ return new ProductVariantFirestoreRepository(options, productRepository);
656
+ },
657
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
658
+ },
659
+ {
660
+ provide: 'FileUploaderService',
661
+ useFactory: (storage, baseUrl) => {
662
+ return new FirebaseFileUploaderService(storage, baseUrl);
663
+ },
664
+ deps: [Storage, STORAGE_BASE_URL],
665
+ },
666
+ ],
667
+ }]
668
+ }] });
669
+
670
+ class AngularHasuraGraphQLModule {
671
+ static initializeApp(options) {
672
+ return {
673
+ ngModule: AngularHasuraGraphQLModule,
674
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
675
+ };
676
+ }
677
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
678
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule }); }
679
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
680
+ {
681
+ provide: 'HasuraConfig',
682
+ useFactory: (options, platformId) => ({
683
+ endpoint: options.endpoint,
684
+ authOptions: options.credentials,
685
+ interceptors: {
686
+ request: (request) => {
687
+ if (isPlatformBrowser(platformId))
688
+ return request;
689
+ const interval = setInterval(() => { }, 100);
690
+ request.interval = interval;
691
+ return request;
692
+ },
693
+ response: (response, request) => {
694
+ if (isPlatformBrowser(platformId))
695
+ return response;
696
+ clearInterval(request.interval);
697
+ return response;
698
+ },
699
+ },
700
+ }),
701
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
702
+ },
703
+ {
704
+ provide: 'CategoryRepository',
705
+ useExisting: CategoryHasuraGraphQLRepository,
706
+ },
707
+ {
708
+ provide: CategoryHasuraGraphQLRepository,
709
+ useFactory: (options, productRepository, categoryFilterRepository) => {
710
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
711
+ },
712
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
713
+ },
714
+ {
715
+ provide: 'ProductRepository',
716
+ useExisting: ProductHasuraGraphQLRepository,
717
+ },
718
+ {
719
+ provide: ProductHasuraGraphQLRepository,
720
+ useFactory: (hasuraConfig) => {
721
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
722
+ },
723
+ deps: ['HasuraConfig'],
724
+ },
725
+ {
726
+ provide: 'ProductReviewsRepository',
727
+ useExisting: ProductReviewsHasuraGraphQLRepository,
728
+ },
729
+ {
730
+ provide: ProductReviewsHasuraGraphQLRepository,
731
+ useFactory: (hasuraConfig) => {
732
+ return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
733
+ },
734
+ deps: ['HasuraConfig'],
735
+ },
736
+ {
737
+ provide: 'VariantRepository',
738
+ useExisting: VariantHasuraGraphQLRepository,
739
+ },
740
+ {
741
+ provide: VariantHasuraGraphQLRepository,
742
+ useFactory: (hasuraConfig) => {
743
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
744
+ },
745
+ deps: ['HasuraConfig'],
746
+ },
747
+ {
748
+ provide: 'CategoryFilterRepository',
749
+ useExisting: CategoryFilterHasuraGraphQLRepository,
750
+ },
751
+ {
752
+ provide: CategoryFilterHasuraGraphQLRepository,
753
+ useFactory: (options) => {
754
+ return new CategoryFilterHasuraGraphQLRepository(options);
755
+ },
756
+ deps: ['HasuraConfig'],
757
+ },
758
+ {
759
+ provide: 'FilterOptionRepository',
760
+ useExisting: FilterOptionHasuraGraphQLRepository,
761
+ },
762
+ {
763
+ provide: FilterOptionHasuraGraphQLRepository,
764
+ useFactory: (options) => {
765
+ return new FilterOptionHasuraGraphQLRepository(options);
766
+ },
767
+ deps: ['HasuraConfig'],
768
+ },
769
+ {
770
+ provide: 'FilterRepository',
771
+ useExisting: FilterHasuraGraphQLRepository,
772
+ },
773
+ {
774
+ provide: FilterHasuraGraphQLRepository,
775
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
776
+ return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
777
+ },
778
+ deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
779
+ },
780
+ {
781
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
782
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
783
+ deps: ['HasuraConfig'],
784
+ },
785
+ {
786
+ provide: 'CategoryCollectionChildrenRepository',
787
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
788
+ },
789
+ {
790
+ provide: WishlistHasuraGraphQLRepository,
791
+ useFactory: (options, categoryFilterRepository) => {
792
+ return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
793
+ },
794
+ deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
795
+ },
796
+ {
797
+ provide: 'WishlistRepository',
798
+ useExisting: WishlistHasuraGraphQLRepository,
799
+ },
800
+ ] }); }
801
+ }
802
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
803
+ type: NgModule,
804
+ args: [{
805
+ providers: [
806
+ {
807
+ provide: 'HasuraConfig',
808
+ useFactory: (options, platformId) => ({
809
+ endpoint: options.endpoint,
810
+ authOptions: options.credentials,
811
+ interceptors: {
812
+ request: (request) => {
813
+ if (isPlatformBrowser(platformId))
814
+ return request;
815
+ const interval = setInterval(() => { }, 100);
816
+ request.interval = interval;
817
+ return request;
818
+ },
819
+ response: (response, request) => {
820
+ if (isPlatformBrowser(platformId))
821
+ return response;
822
+ clearInterval(request.interval);
823
+ return response;
824
+ },
825
+ },
826
+ }),
827
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
828
+ },
829
+ {
830
+ provide: 'CategoryRepository',
831
+ useExisting: CategoryHasuraGraphQLRepository,
832
+ },
833
+ {
834
+ provide: CategoryHasuraGraphQLRepository,
835
+ useFactory: (options, productRepository, categoryFilterRepository) => {
836
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
837
+ },
838
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
839
+ },
840
+ {
841
+ provide: 'ProductRepository',
842
+ useExisting: ProductHasuraGraphQLRepository,
843
+ },
844
+ {
845
+ provide: ProductHasuraGraphQLRepository,
846
+ useFactory: (hasuraConfig) => {
847
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
848
+ },
849
+ deps: ['HasuraConfig'],
850
+ },
851
+ {
852
+ provide: 'ProductReviewsRepository',
853
+ useExisting: ProductReviewsHasuraGraphQLRepository,
854
+ },
855
+ {
856
+ provide: ProductReviewsHasuraGraphQLRepository,
857
+ useFactory: (hasuraConfig) => {
858
+ return new ProductReviewsHasuraGraphQLRepository(hasuraConfig);
859
+ },
860
+ deps: ['HasuraConfig'],
861
+ },
862
+ {
863
+ provide: 'VariantRepository',
864
+ useExisting: VariantHasuraGraphQLRepository,
865
+ },
866
+ {
867
+ provide: VariantHasuraGraphQLRepository,
868
+ useFactory: (hasuraConfig) => {
869
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
870
+ },
871
+ deps: ['HasuraConfig'],
872
+ },
873
+ {
874
+ provide: 'CategoryFilterRepository',
875
+ useExisting: CategoryFilterHasuraGraphQLRepository,
876
+ },
877
+ {
878
+ provide: CategoryFilterHasuraGraphQLRepository,
879
+ useFactory: (options) => {
880
+ return new CategoryFilterHasuraGraphQLRepository(options);
881
+ },
882
+ deps: ['HasuraConfig'],
883
+ },
884
+ {
885
+ provide: 'FilterOptionRepository',
886
+ useExisting: FilterOptionHasuraGraphQLRepository,
887
+ },
888
+ {
889
+ provide: FilterOptionHasuraGraphQLRepository,
890
+ useFactory: (options) => {
891
+ return new FilterOptionHasuraGraphQLRepository(options);
892
+ },
893
+ deps: ['HasuraConfig'],
894
+ },
895
+ {
896
+ provide: 'FilterRepository',
897
+ useExisting: FilterHasuraGraphQLRepository,
898
+ },
899
+ {
900
+ provide: FilterHasuraGraphQLRepository,
901
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
902
+ return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
903
+ },
904
+ deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
905
+ },
906
+ {
907
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
908
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
909
+ deps: ['HasuraConfig'],
910
+ },
911
+ {
912
+ provide: 'CategoryCollectionChildrenRepository',
913
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
914
+ },
915
+ {
916
+ provide: WishlistHasuraGraphQLRepository,
917
+ useFactory: (options, categoryFilterRepository) => {
918
+ return new WishlistHasuraGraphQLRepository(options, categoryFilterRepository);
919
+ },
920
+ deps: ['HasuraConfig', CategoryFilterHasuraGraphQLRepository],
921
+ },
922
+ {
923
+ provide: 'WishlistRepository',
924
+ useExisting: WishlistHasuraGraphQLRepository,
925
+ },
926
+ ],
927
+ }]
928
+ }] });
929
+
930
+ class AuthService {
931
+ constructor(angularFireAuth, userRepository) {
932
+ this.angularFireAuth = angularFireAuth;
933
+ this.userRepository = userRepository;
934
+ }
935
+ getAuthstate() {
936
+ const observables = [this.getFireUser(), this.getUser()];
937
+ return combineLatest(observables).pipe(map(([fireUser, user]) => ({
938
+ user,
939
+ isAnonymous: fireUser?.isAnonymous,
940
+ })));
941
+ }
942
+ getUser() {
943
+ return this.getFireUser().pipe(map((user) => user?.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
944
+ }
945
+ getTokenId() {
946
+ return from(getIdToken(this.angularFireAuth.currentUser));
947
+ }
948
+ getFireUser() {
949
+ return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
950
+ }
951
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
952
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthService }); }
953
+ }
954
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthService, decorators: [{
955
+ type: Injectable
956
+ }], ctorParameters: () => [{ type: i1.Auth }, { type: undefined, decorators: [{
957
+ type: Inject,
958
+ args: ['UserRepository']
959
+ }] }] });
960
+
961
+ class CouponService {
962
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
963
+ this.couponRepository = couponRepository;
964
+ this.defaultShop = defaultShop;
965
+ this.orderRepository = orderRepository;
966
+ this.categoryRepository = categoryRepository;
967
+ this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
968
+ }
969
+ checkCoupon(nickname, checkoutType, checkout, plan) {
970
+ return from(this.couponRepository
971
+ .find({
972
+ filters: {
973
+ nickname: { operator: Where.EQUALS, value: nickname },
974
+ active: { operator: Where.EQUALS, value: true },
975
+ },
976
+ })
977
+ .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
978
+ }
979
+ async couponValidation(coupon, checkoutType) {
980
+ if (!coupon)
981
+ throw 'Cupom inválido.';
982
+ if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
983
+ throw 'Cupom inválido.';
984
+ if (coupon?.expiresIn && coupon?.expiresIn.getTime() < new Date().getTime())
985
+ throw 'Cupom expirado.';
986
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
987
+ if (!isInShop)
988
+ throw 'Cupom inválido para loja.';
989
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
990
+ if (!isCheckoutType)
991
+ throw 'Cupom inválido. Erro de checkout.';
992
+ return coupon;
993
+ }
994
+ async couponRulesValidation(coupon, checkoutType, checkout, plan) {
995
+ if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
996
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
997
+ throw 'Cupom inválido para sua assinatura.';
998
+ return coupon;
999
+ }
1000
+ const validUser = this.coupomUserValidation(coupon, checkout?.user);
1001
+ if (!validUser)
1002
+ throw 'Usuário não elegível.';
1003
+ const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
1004
+ if (couponUseLimits.firstOrder) {
1005
+ const ordersUser = await this.getOrdersFromUser(checkout.user.email.toLocaleLowerCase());
1006
+ if (couponUseLimits.firstOrder && ordersUser.length >= 1)
1007
+ throw 'Limite de uso atingido';
1008
+ }
1009
+ if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
1010
+ const orders = await this.getOrdersWithCoupon(coupon);
1011
+ if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
1012
+ throw 'Limite de uso atingido.';
1013
+ if (couponUseLimits.limitedPerUser) {
1014
+ const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
1015
+ if (ordersWithUser > 0)
1016
+ throw 'Limite de uso por usuário atingido.';
1017
+ }
1018
+ }
1019
+ const hasProductCategories = await this.hasProductCategories(coupon, checkout);
1020
+ if (!hasProductCategories)
1021
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
1022
+ const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
1023
+ if (!hasMinSubTotal)
1024
+ throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
1025
+ return coupon;
1026
+ }
1027
+ calcDiscountSubscription(coupon, checkout) {
1028
+ let discount = 0;
1029
+ if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
1030
+ discount = coupon.discount.subscription.value;
1031
+ else
1032
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
1033
+ return of(discount);
1034
+ }
1035
+ async calcDiscountShopping(coupon, checkout) {
1036
+ let discount = 0;
1037
+ if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
1038
+ discount = await this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
1039
+ }
1040
+ else {
1041
+ discount = await this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
1042
+ }
1043
+ return discount;
1044
+ }
1045
+ async calcDiscountByType(type, value, categories, checkout) {
1046
+ let discount = 0;
1047
+ let lineItensDiscount = await this.getLineItensEligebleForDiscount(categories, checkout);
1048
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1049
+ if (type == CouponTypes.ABSOLUTE) {
1050
+ discount = value > subTotal ? subTotal : value;
1051
+ }
1052
+ else {
1053
+ discount = subTotal * (value / 100);
1054
+ }
1055
+ return discount;
1056
+ }
1057
+ async hasMinSubTotal(coupon, checkout) {
1058
+ if (!coupon.minSubTotalValue)
1059
+ return true;
1060
+ let lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
1061
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
1062
+ if (coupon.minSubTotalValue <= subTotal)
1063
+ return true;
1064
+ return false;
1065
+ }
1066
+ async hasProductCategories(coupon, checkout) {
1067
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
1068
+ return true;
1069
+ }
1070
+ const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
1071
+ const hasCategories = checkout.lineItems?.filter((i) => {
1072
+ if (!i.categories || !i.categories?.length)
1073
+ return true;
1074
+ return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1075
+ });
1076
+ return hasCategories.length ? true : false;
1077
+ }
1078
+ coupomUserValidation(coupon, user) {
1079
+ if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
1080
+ return true;
1081
+ let userTypes = [];
1082
+ if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
1083
+ this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
1084
+ userTypes.push(Exclusivities.COLLABORATORS);
1085
+ if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
1086
+ coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
1087
+ userTypes.push(Exclusivities.SPECIFIC_USER);
1088
+ if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
1089
+ user.isSubscriber &&
1090
+ user.subscriptionPlan != '')
1091
+ userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
1092
+ if (user.isSubscriber &&
1093
+ user.subscriptionPlan == '' &&
1094
+ coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
1095
+ userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
1096
+ if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
1097
+ userTypes.push(Exclusivities.NON_SUBSCRIBER);
1098
+ return coupon.exclusivityType.some((r) => userTypes.includes(r));
1099
+ }
1100
+ async getCouponCategoriesId(productsCategories) {
1101
+ const couponCategories = [];
1102
+ for (let index = 0; index < productsCategories.length; index++) {
1103
+ const category = await this.categoryRepository.get({
1104
+ id: productsCategories[index],
1105
+ });
1106
+ if (category) {
1107
+ const children = await this.categoryRepository.getChildren(parseInt(productsCategories[index]));
1108
+ couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
1109
+ }
1110
+ }
1111
+ return [...new Set(couponCategories)];
1112
+ }
1113
+ async getLineItensEligebleForDiscount(productsCategories, checkout) {
1114
+ let lineItensDiscount = [];
1115
+ const couponCategories = await this.getCouponCategoriesId(productsCategories);
1116
+ if (productsCategories && productsCategories.length) {
1117
+ lineItensDiscount = checkout.lineItems?.filter((i) => {
1118
+ if (i.categories?.length) {
1119
+ return i.categories.some((c) => couponCategories.some((cat) => cat == c));
1120
+ }
1121
+ return true;
1122
+ });
1123
+ }
1124
+ else {
1125
+ lineItensDiscount = checkout.lineItems;
1126
+ }
1127
+ return lineItensDiscount;
1128
+ }
1129
+ calcCheckoutSubtotal(lineItens, user, shop) {
1130
+ return (lineItens?.reduce((acc, curr) => user?.isSubscriber && curr.price.subscriberPrice
1131
+ ? acc + curr.price?.subscriberPrice * curr.quantity
1132
+ : acc + curr.pricePaid * curr.quantity, 0) || 0);
1133
+ }
1134
+ async getOrdersWithCoupon(coupon) {
1135
+ return await this.orderRepository
1136
+ .find({
1137
+ filters: {
1138
+ coupon: { id: coupon.id },
1139
+ payment: { status: 'paid' },
1140
+ },
1141
+ })
1142
+ .then((result) => result.data);
1143
+ }
1144
+ async getOrdersFromUser(email) {
1145
+ return await this.orderRepository
1146
+ .find({
1147
+ filters: {
1148
+ user: { email: { operator: Where.EQUALS, value: email } },
1149
+ payment: { status: 'paid' },
1150
+ },
1151
+ })
1152
+ .then((result) => result.data);
1153
+ }
1154
+ countOrdersWithUser(orders, email) {
1155
+ return orders.filter((o) => o.user.email == email).length;
1156
+ }
1157
+ getCouponUseLimits(coupon, checkoutType, user) {
1158
+ let couponUseLimits;
1159
+ if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
1160
+ couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
1161
+ }
1162
+ else {
1163
+ couponUseLimits = coupon.useLimits.subscription;
1164
+ }
1165
+ return couponUseLimits;
1166
+ }
1167
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1168
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
1169
+ }
1170
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, decorators: [{
1171
+ type: Injectable,
1172
+ args: [{
1173
+ providedIn: 'root',
1174
+ }]
1175
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1176
+ type: Inject,
1177
+ args: ['CouponRepository']
1178
+ }] }, { type: i1$2.Shops, decorators: [{
1179
+ type: Inject,
1180
+ args: [DEFAULT_SHOP]
1181
+ }] }, { type: undefined, decorators: [{
1182
+ type: Inject,
1183
+ args: ['OrderRepository']
1184
+ }] }, { type: undefined, decorators: [{
1185
+ type: Inject,
1186
+ args: ['CategoryRepository']
1187
+ }] }] });
1188
+
1189
+ class CheckoutService {
1190
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
1191
+ this.couponService = couponService;
1192
+ this.checkoutRepository = checkoutRepository;
1193
+ this.orderRepository = orderRepository;
1194
+ this.userRepository = userRepository;
1195
+ this.defaultShop = defaultShop;
1196
+ }
1197
+ getCheckout(checkoutData) {
1198
+ const checkoutId = cookie.get('checkoutId');
1199
+ if (!isNil(checkoutId))
1200
+ return from(this.checkoutRepository.get({ id: checkoutId }));
1201
+ return from(this.createCheckout(checkoutData));
1202
+ }
1203
+ getUserByCheckout(checkoutId) {
1204
+ return from(this.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id ? of(checkout.user) : from(this.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
1205
+ }
1206
+ updateCheckoutLineItems(checkout) {
1207
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1208
+ }
1209
+ updateCheckoutUser(checkout) {
1210
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1211
+ }
1212
+ clearCheckoutFromSession() {
1213
+ cookie.remove('checkoutId');
1214
+ return of();
1215
+ }
1216
+ calcDiscount(coupon) {
1217
+ return this.getCheckout().pipe(concatMap(async (checkout) => await this.couponService.calcDiscountShopping(coupon, checkout)));
1218
+ }
1219
+ checkCoupon(nickname, checkoutType) {
1220
+ return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
1221
+ }
1222
+ async createCheckout(checkoutData) {
1223
+ const checkout = await this.checkoutRepository.create({
1224
+ createdAt: new Date(),
1225
+ ...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1226
+ shop: checkoutData?.shop || this.defaultShop,
1227
+ });
1228
+ cookie.set('checkoutId', checkout.id);
1229
+ return checkout;
1230
+ }
1231
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
1232
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
1233
+ }
1234
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
1235
+ type: Injectable
1236
+ }], ctorParameters: () => [{ type: CouponService }, { type: undefined, decorators: [{
1237
+ type: Inject,
1238
+ args: ['CheckoutRepository']
1239
+ }] }, { type: undefined, decorators: [{
1240
+ type: Inject,
1241
+ args: ['OrderRepository']
1242
+ }] }, { type: undefined, decorators: [{
1243
+ type: Inject,
1244
+ args: ['UserRepository']
1245
+ }] }, { type: i1$2.Shops, decorators: [{
1246
+ type: Inject,
1247
+ args: [DEFAULT_SHOP]
1248
+ }] }] });
1249
+
1250
+ class CartService {
1251
+ constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
1252
+ this.authService = authService;
1253
+ this.checkoutService = checkoutService;
1254
+ this.defaultShop = defaultShop;
1255
+ this.productRepository = productRepository;
1256
+ this.categoryRepository = categoryRepository;
1257
+ this.variantRepository = variantRepository;
1258
+ this.buy2WinRepository = buy2WinRepository;
1259
+ this.cartSubject = new Subject();
1260
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
1261
+ const items = [];
1262
+ const index = checkoutLoaded.lineItems?.map((checkoutItem) => checkoutItem.id).indexOf(lineItem.id);
1263
+ if (index > -1) {
1264
+ checkoutLoaded.lineItems[index].quantity += quantity;
1265
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
1266
+ }
1267
+ else
1268
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
1269
+ return this.checkoutService
1270
+ .updateCheckoutLineItems(checkoutLoaded)
1271
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
1272
+ }));
1273
+ this.generateCartObject = (items) => items?.reduce((cart, item) => ({
1274
+ ...cart,
1275
+ [item.id]: LineItem.toInstance({
1276
+ ...(cart[item.id] || item),
1277
+ quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
1278
+ }),
1279
+ }), {}) || {};
1280
+ this.buildLineItem = async ({ checkout, item, quantity, }) => {
1281
+ const product = await this.getProductData(item.id);
1282
+ item.quantity = item?.quantity || checkout?.lineItems?.find((lineItem) => lineItem.id === item.id)?.quantity || 0;
1283
+ if (this.checkMaxStock(item, quantity || 0))
1284
+ throw new Error('Desculpe! Temos apenas ' + item.stock?.quantity + ' em estoque.');
1285
+ const image = item.image || item.images?.shift();
1286
+ const { id, name, EAN, slug, stock, price, weight, sku, type } = item;
1287
+ const isGift = item.isGift || null;
1288
+ const pricePaid = this.getProductPrice({
1289
+ product: item,
1290
+ shop: checkout.shop || this.defaultShop,
1291
+ isSubscriber: checkout.user?.isSubscriber,
1292
+ });
1293
+ RoundProductPricesHelper.roundProductPrices(item);
1294
+ return {
1295
+ checkout,
1296
+ lineItem: LineItem.toInstance({
1297
+ id,
1298
+ name: name ?? product.name,
1299
+ EAN: EAN ?? product.EAN,
1300
+ brand: product.brand,
1301
+ slug: slug ?? product.slug,
1302
+ sku: sku ?? product.sku,
1303
+ stock,
1304
+ price: this.roundPrice(price),
1305
+ image,
1306
+ weight: weight ?? product.weight,
1307
+ quantity: (item.quantity || 0) + (quantity || 0),
1308
+ pricePaid,
1309
+ categories: product.categories ?? [],
1310
+ isGift: isGift ?? null,
1311
+ costPrice: product.costPrice ?? 0,
1312
+ type,
1313
+ }),
1314
+ };
1315
+ };
1316
+ this.getProductPrice = ({ product, isSubscriber, }) => {
1317
+ const info = product.price;
1318
+ if (product.isGift)
1319
+ return 0;
1320
+ return isSubscriber && info.subscriberPrice > 0
1321
+ ? Number(info.subscriberPrice.toFixed(2))
1322
+ : Number(info.price.toFixed(2));
1323
+ };
1324
+ this.checkMaxStock = (item, quantity) => {
1325
+ const maxStock = item.stock?.quantity || 0;
1326
+ const currentItemAmount = item.quantity || 0;
1327
+ return currentItemAmount + quantity > maxStock;
1328
+ };
1329
+ }
1330
+ addItem(item, quantity = 1) {
1331
+ return from(this.checkoutService.getCheckout()).pipe(concatMap(async (checkout) => await this.buildLineItem({ checkout, item, quantity: quantity || 1 })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
1332
+ }
1333
+ decreaseItem(item) {
1334
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1335
+ const checkoutItem = checkout.lineItems?.find((lineItem) => lineItem.id === item.id);
1336
+ if (!isNil(checkoutItem))
1337
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
1338
+ return checkout;
1339
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1340
+ }
1341
+ getCart(checkout) {
1342
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1343
+ return this.cartSubject;
1344
+ }
1345
+ /**
1346
+ * @deprecated The method should not be used
1347
+ */
1348
+ getVariantPriceDiscount(item) {
1349
+ return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
1350
+ }
1351
+ removeItem(item) {
1352
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1353
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.id === item.id);
1354
+ if (index >= 0)
1355
+ checkout.lineItems.splice(index, 1);
1356
+ return checkout;
1357
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1358
+ }
1359
+ updateUserCart(user) {
1360
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap(async (checkout) => this.checkoutService
1361
+ .updateCheckoutLineItems(Checkout.toInstance({
1362
+ ...checkout.toPlain(),
1363
+ lineItems: checkout.lineItems?.length
1364
+ ? await Promise.all(checkout.lineItems?.map(async (item) => (await this.buildLineItem({ checkout, item })).lineItem))
1365
+ : [],
1366
+ }))
1367
+ .toPromise()), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1368
+ }
1369
+ clearCart() {
1370
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
1371
+ this.checkoutService.clearCheckoutFromSession();
1372
+ return checkout;
1373
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1374
+ }
1375
+ buildCartFromCheckout(checkoutData) {
1376
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1377
+ }
1378
+ roundPrice(productPrice) {
1379
+ const { price, fullPrice, subscriberPrice } = productPrice;
1380
+ return {
1381
+ ...productPrice,
1382
+ price: Number(price.toFixed(2)),
1383
+ fullPrice: Number(fullPrice.toFixed(2)),
1384
+ ...(subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }),
1385
+ };
1386
+ }
1387
+ async getProductData(productId) {
1388
+ let product;
1389
+ let variant;
1390
+ try {
1391
+ product = await this.productRepository.get({ id: productId });
1392
+ }
1393
+ catch (error) {
1394
+ if (!(error instanceof NotFoundError))
1395
+ throw error;
1396
+ const { data: variants } = await this.variantRepository.find({ filters: { id: productId } });
1397
+ variant = variants.shift();
1398
+ if (!variant)
1399
+ throw error;
1400
+ product = await this.productRepository.get({ id: variant.productId });
1401
+ }
1402
+ return {
1403
+ ...product.toPlain(),
1404
+ ...(variant && { ...variant.toPlain() }),
1405
+ };
1406
+ }
1407
+ getGifts() {
1408
+ return this.checkoutService.getCheckout().pipe(mergeMap(async (checkout) => {
1409
+ const notGiftItems = checkout.lineItems ? checkout.lineItems.filter((item) => !item.isGift) : [];
1410
+ if (!notGiftItems.length)
1411
+ return { ...checkout, lineItems: [] };
1412
+ const cartTotal = notGiftItems.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1413
+ const campaigns = await this.buy2WinRepository
1414
+ .find({
1415
+ filters: {
1416
+ active: { operator: Where.EQUALS, value: true },
1417
+ shop: { operator: Where.EQUALS, value: this.defaultShop },
1418
+ },
1419
+ })
1420
+ .then((data) => data.data);
1421
+ if (!campaigns.length)
1422
+ return { ...checkout, lineItems: notGiftItems };
1423
+ const elegibleCampaigns = [];
1424
+ for (const campaign of campaigns) {
1425
+ const today = new Date().getTime();
1426
+ if (!(campaign.startDate.getTime() <= today) && !(campaign.endDate.getTime() >= today))
1427
+ continue;
1428
+ if (campaign.activeCategory) {
1429
+ const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1430
+ const categoriesCampaingFullTree = [];
1431
+ for (const id of categoriesCampaing) {
1432
+ const children = await this.categoryRepository.getChildren(parseInt(id));
1433
+ categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1434
+ }
1435
+ const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
1436
+ const filterProductsCategories = checkout.lineItems.filter((l) => {
1437
+ if (!l.categories || !l.categories?.length)
1438
+ return true;
1439
+ return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
1440
+ });
1441
+ if (filterProductsCategories.length) {
1442
+ const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
1443
+ if (cartTotalCategories >= campaign.cartValueMin)
1444
+ elegibleCampaigns.push(campaign);
1445
+ }
1446
+ }
1447
+ else {
1448
+ if (campaign.cartValue && campaign.cartValue > 0) {
1449
+ if (campaign.cartValue <= cartTotal)
1450
+ elegibleCampaigns.push(campaign);
1451
+ }
1452
+ }
1453
+ }
1454
+ if (!elegibleCampaigns.length)
1455
+ return { ...checkout, lineItems: notGiftItems };
1456
+ const campaingnProducts = [];
1457
+ for (const campaign of elegibleCampaigns) {
1458
+ let elegibleProducts = [];
1459
+ for (const product of campaign.products) {
1460
+ const { data: productData } = await this.productRepository.find({ filters: { sku: product } });
1461
+ if (!productData.length)
1462
+ continue;
1463
+ const gift = productData.shift();
1464
+ if (gift.stock.quantity < 1)
1465
+ continue;
1466
+ elegibleProducts.push(gift);
1467
+ }
1468
+ campaingnProducts.push(elegibleProducts);
1469
+ }
1470
+ if (!campaingnProducts.length)
1471
+ return { ...checkout, lineItems: notGiftItems };
1472
+ const gifts = this.giftToLineItems([].concat(...campaingnProducts));
1473
+ return { ...checkout, lineItems: notGiftItems.concat(gifts) };
1474
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1475
+ }
1476
+ giftToLineItems(items) {
1477
+ return items.map((item) => {
1478
+ const { brand, categories, id, name, price, sku, slug, stock, weight, EAN } = item;
1479
+ const image = item?.miniatures?.length ? item.miniatures[0] : item.images[0];
1480
+ return LineItem.toInstance({
1481
+ brand,
1482
+ categories,
1483
+ id: id.toString(),
1484
+ name,
1485
+ price,
1486
+ sku,
1487
+ slug,
1488
+ stock,
1489
+ weight,
1490
+ EAN,
1491
+ image,
1492
+ pricePaid: 0,
1493
+ quantity: 1,
1494
+ isGift: true,
1495
+ });
1496
+ });
1497
+ }
1498
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1499
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartService }); }
1500
+ }
1501
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartService, decorators: [{
1502
+ type: Injectable
1503
+ }], ctorParameters: () => [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.Shops, decorators: [{
1504
+ type: Inject,
1505
+ args: [DEFAULT_SHOP]
1506
+ }] }, { type: undefined, decorators: [{
1507
+ type: Inject,
1508
+ args: ['ProductRepository']
1509
+ }] }, { type: undefined, decorators: [{
1510
+ type: Inject,
1511
+ args: ['CategoryRepository']
1512
+ }] }, { type: undefined, decorators: [{
1513
+ type: Inject,
1514
+ args: ['VariantRepository']
1515
+ }] }, { type: i1$2.Buy2WinFirestoreRepository, decorators: [{
1516
+ type: Inject,
1517
+ args: ['Buy2WinRepository']
1518
+ }] }] });
1519
+
1520
+ class NewCategoryStructureAdapter {
1521
+ constructor(categoryRepository) {
1522
+ this.categoryRepository = categoryRepository;
1523
+ }
1524
+ async buildProductFilterByCategory(category) {
1525
+ const loadedCategory = await this.getCategory(category);
1526
+ if (loadedCategory.isCollection)
1527
+ return { id: { operator: Where.IN, value: loadedCategory.products } };
1528
+ const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1529
+ return {
1530
+ category: {
1531
+ id: {
1532
+ operator: Where.IN,
1533
+ value: categoryIds,
1534
+ },
1535
+ },
1536
+ };
1537
+ }
1538
+ async getAllCategoriesIdFromCategory(category) {
1539
+ return this.categoryRepository
1540
+ .getChildren(+category.id)
1541
+ .then((categories) => categories.map((category) => category.id.toString()));
1542
+ }
1543
+ async getCategory(category) {
1544
+ return isNil(category.isCollection) || (category.isCollection && !category.products?.length)
1545
+ ? this.categoryRepository.get({ id: category.id })
1546
+ : category;
1547
+ }
1548
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1549
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
1550
+ }
1551
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1552
+ type: Injectable
1553
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1554
+ type: Inject,
1555
+ args: ['CategoryRepository']
1556
+ }] }] });
1557
+
1558
+ class OldCategoryStructureAdapter {
1559
+ constructor(categoryRepository) {
1560
+ this.categoryRepository = categoryRepository;
1561
+ }
1562
+ async buildProductFilterByCategory(category) {
1563
+ const productsIds = category.products?.length
1564
+ ? category.products
1565
+ : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1566
+ return { id: { operator: Where.IN, value: productsIds } };
1567
+ }
1568
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1569
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OldCategoryStructureAdapter }); }
1570
+ }
1571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1572
+ type: Injectable
1573
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1574
+ type: Inject,
1575
+ args: ['CategoryRepository']
1576
+ }] }] });
1577
+
1578
+ class CatalogService {
1579
+ constructor(productRepository, categoryStructureAdapter, shop, productIndex) {
1580
+ this.productRepository = productRepository;
1581
+ this.categoryStructureAdapter = categoryStructureAdapter;
1582
+ this.shop = shop;
1583
+ this.productIndex = productIndex;
1584
+ this.productsByTerm = {};
1585
+ this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1586
+ const filters = {};
1587
+ if (clubDiscount?.length)
1588
+ set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1589
+ if (brands?.length)
1590
+ filters.brand = { operator: Where.IN, value: brands };
1591
+ if (gender?.length)
1592
+ filters.gender = { operator: Where.IN, value: gender };
1593
+ if (prices?.min || prices?.max)
1594
+ set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1595
+ ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1596
+ ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1597
+ ]);
1598
+ if (rate)
1599
+ filters.rate = { operator: Where.GTE, value: rate };
1600
+ if (tags?.length)
1601
+ filters.tags = { operator: Where.LIKE, value: tags };
1602
+ if (customOptions?.length)
1603
+ filters.filters = { operator: Where.LIKE, value: customOptions };
1604
+ return filters;
1605
+ };
1606
+ this.buildSortQuery = (sort) => {
1607
+ if (!sort || sort === 'most-relevant')
1608
+ return {};
1609
+ if (sort === 'best-sellers')
1610
+ return { shoppingCount: 'desc' };
1611
+ if (sort === 'biggest-price')
1612
+ return { subscriberPrice: 'desc' };
1613
+ if (sort === 'lowest-price')
1614
+ return { subscriberPrice: 'asc' };
1615
+ if (sort === 'best-rating')
1616
+ return { rate: 'desc' };
1617
+ if (sort === 'news')
1618
+ return { createdAt: 'desc' };
1619
+ if (sort === 'biggest-discount')
1620
+ return { subscriberDiscountPercentage: 'desc' };
1621
+ };
1622
+ this.buildLimitQuery = (options) => {
1623
+ const limit = options?.perPage || 20;
1624
+ return {
1625
+ limit,
1626
+ offset: ((options?.page || 1) - 1) * limit,
1627
+ };
1628
+ };
1629
+ this.hasProfile = (options) => 'profile' in options;
1630
+ this.hasTerm = (options) => 'term' in options;
1631
+ this.hasCategory = (options) => 'category' in options;
1632
+ }
1633
+ async fetchProducts(options) {
1634
+ const limits = this.buildLimitQuery(options);
1635
+ if (this.hasProfile(options) && options.filters?.customOptions)
1636
+ throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
1637
+ if (this.hasProfile(options) && options.filters?.tags)
1638
+ throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
1639
+ if (this.hasTerm(options) && options.filters?.customOptions)
1640
+ throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
1641
+ return await this.findCatalog(options, limits).then(({ data, count: total, maximum, minimal, distinct }) => ({
1642
+ products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1643
+ pages: Math.ceil(total / limits.limit),
1644
+ prices: {
1645
+ price: { min: +minimal?.price?.price?.toFixed(2), max: +maximum?.price?.price?.toFixed(2) },
1646
+ subscriberPrice: {
1647
+ min: +minimal?.price?.subscriberPrice?.toFixed(2),
1648
+ max: +maximum?.price?.subscriberPrice?.toFixed(2),
1649
+ },
1650
+ },
1651
+ brands: distinct?.brand,
1652
+ }));
1653
+ }
1654
+ async findCatalog(options, limits) {
1655
+ if (this.hasTerm(options) && options.sort === 'most-relevant')
1656
+ return this.findCatalogByTermAndSortByMostRevelant(options, limits);
1657
+ const repoParams = {
1658
+ filters: {
1659
+ ...(await this.buildMainFilter(options)),
1660
+ ...this.buildFilterQuery(options?.filters || {}),
1661
+ },
1662
+ ...(options?.sort ? { orderBy: this.buildSortQuery(options?.sort) } : {}),
1663
+ limits,
1664
+ options: {
1665
+ minimal: ['price'],
1666
+ maximum: ['price'],
1667
+ ...(!this.hasCategory(options) ? { distinct: ['brand'] } : {}),
1668
+ },
1669
+ };
1670
+ if (['biggest-price', 'lowest-price', 'biggest-discount', 'best-rating'].includes(options.sort))
1671
+ return this.productRepository.findCatalog(repoParams);
1672
+ return this.productRepository.findCatalog(repoParams, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1673
+ }
1674
+ async buildMainFilter({ category, profile, term, }) {
1675
+ if (category)
1676
+ return this.categoryStructureAdapter.buildProductFilterByCategory(category);
1677
+ if (profile)
1678
+ return { tags: { operator: Where.LIKE, value: profile } };
1679
+ if (term)
1680
+ return this.productIndex
1681
+ .search(term, 999, this.shop)
1682
+ .then((data) => ({ id: { operator: Where.IN, value: data.hits.map(({ _source }) => _source.id) } }));
1683
+ }
1684
+ async findCatalogByTermAndSortByMostRevelant(options, limits) {
1685
+ const productIds = await this.findCatalogIdsByElasticSearch(options.term);
1686
+ const totalResult = await this.productRepository.findCatalog({
1687
+ fields: ['id', 'stock'],
1688
+ filters: {
1689
+ id: { operator: Where.IN, value: productIds },
1690
+ ...this.buildFilterQuery(options?.filters || {}),
1691
+ },
1692
+ options: {
1693
+ minimal: ['price'],
1694
+ maximum: ['price'],
1695
+ distinct: ['brand'],
1696
+ },
1697
+ }, options?.mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female');
1698
+ const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1699
+ const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1700
+ const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id == product));
1701
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id == product));
1702
+ const limitedProductId = productIdsStock
1703
+ .concat(productIdsStockOut)
1704
+ .slice(limits.offset, limits.offset + limits.limit);
1705
+ const orderedId = productIds.filter((product) => limitedProductId.includes(product));
1706
+ const productResult = await this.productRepository.findCatalog({
1707
+ filters: {
1708
+ id: { operator: Where.IN, value: orderedId },
1709
+ },
1710
+ });
1711
+ return {
1712
+ data: limitedProductId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1713
+ count: totalResult.count,
1714
+ maximum: totalResult.maximum,
1715
+ minimal: totalResult.minimal,
1716
+ distinct: totalResult.distinct,
1717
+ };
1718
+ }
1719
+ async findCatalogIdsByElasticSearch(term) {
1720
+ if (this.productsByTerm[term])
1721
+ return this.productsByTerm[term];
1722
+ return (this.productsByTerm[term] = await this.productIndex
1723
+ .search(term, 999, this.shop)
1724
+ .then(({ hits: products }) => {
1725
+ const withStock = products.filter(({ _source }) => _source.stock.quantity > 0);
1726
+ const withOutStock = products.filter(({ _source }) => _source.stock.quantity <= 0);
1727
+ const sorted = [...withStock, ...withOutStock];
1728
+ return [...new Set(sorted.map(({ _source }) => _source.id))];
1729
+ }));
1730
+ }
1731
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
1732
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
1733
+ }
1734
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
1735
+ type: Injectable
1736
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1737
+ type: Inject,
1738
+ args: ['ProductRepository']
1739
+ }] }, { type: undefined, decorators: [{
1740
+ type: Inject,
1741
+ args: [CATEGORY_STRUCTURE]
1742
+ }] }, { type: i1$2.Shops, decorators: [{
1743
+ type: Inject,
1744
+ args: [DEFAULT_SHOP]
1745
+ }] }, { type: i1$2.ProductsIndex }] });
1746
+
1747
+ class CategoryService {
1748
+ constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1749
+ this.productRepository = productRepository;
1750
+ this.categoryRepository = categoryRepository;
1751
+ this.categoryFilterRepository = categoryFilterRepository;
1752
+ this.categoryStructureAdapter = categoryStructureAdapter;
1753
+ this.shop = shop;
1754
+ }
1755
+ async fetchBrands(category, mainGender) {
1756
+ const brands = await this.productRepository
1757
+ .findCatalog({
1758
+ filters: await this.categoryStructureAdapter.buildProductFilterByCategory(category),
1759
+ fields: ['brand'],
1760
+ }, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1761
+ .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1762
+ return this.categoryRepository
1763
+ .find({ filters: { brandCategory: true, shop: this.shop }, orderBy: { name: 'asc' } })
1764
+ .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1765
+ }
1766
+ async fetchFilterOptions(category) {
1767
+ return await this.categoryFilterRepository
1768
+ .find({ filters: { categoryId: +category.id } })
1769
+ .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1770
+ }
1771
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
1772
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService }); }
1773
+ }
1774
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService, decorators: [{
1775
+ type: Injectable
1776
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1777
+ type: Inject,
1778
+ args: ['ProductRepository']
1779
+ }] }, { type: undefined, decorators: [{
1780
+ type: Inject,
1781
+ args: ['CategoryRepository']
1782
+ }] }, { type: undefined, decorators: [{
1783
+ type: Inject,
1784
+ args: ['CategoryFilterRepository']
1785
+ }] }, { type: undefined, decorators: [{
1786
+ type: Inject,
1787
+ args: [CATEGORY_STRUCTURE]
1788
+ }] }, { type: i1$2.Shops, decorators: [{
1789
+ type: Inject,
1790
+ args: [DEFAULT_SHOP]
1791
+ }] }] });
1792
+
1793
+ var ProductSorts;
1794
+ (function (ProductSorts) {
1795
+ ProductSorts["MOST_RELEVANT"] = "most-relevant";
1796
+ ProductSorts["BEST_SELLER"] = "best-sellers";
1797
+ ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1798
+ ProductSorts["LOWEST_PRICE"] = "lowest-price";
1799
+ ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1800
+ ProductSorts["BEST_RATING"] = "best-rating";
1801
+ ProductSorts["NEWS"] = "news";
1802
+ })(ProductSorts || (ProductSorts = {}));
1803
+
1804
+ class CategoryWithTree extends Category {
1805
+ }
1806
+ __decorate([
1807
+ Type(() => CategoryWithTree),
1808
+ __metadata("design:type", Array)
1809
+ ], CategoryWithTree.prototype, "children", void 0);
1810
+
1811
+ class WishlistService {
1812
+ constructor(wishlistRepository, categoryRepository, shop, productRepository, categoryFilterRepository, productIndex) {
1813
+ this.wishlistRepository = wishlistRepository;
1814
+ this.categoryRepository = categoryRepository;
1815
+ this.shop = shop;
1816
+ const categoryStructureAdapter = new NewCategoryStructureAdapter(wishlistRepository);
1817
+ this.catalogService = new CatalogService(productRepository, categoryStructureAdapter, shop, productIndex);
1818
+ this.categoryService = new CategoryService(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop);
1819
+ }
1820
+ getCatalogService() {
1821
+ return this.catalogService;
1822
+ }
1823
+ getCategoryService() {
1824
+ return this.categoryService;
1825
+ }
1826
+ async create({ personId, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1827
+ const data = {
1828
+ slug: '',
1829
+ name: title,
1830
+ description,
1831
+ metadata: {
1832
+ title: `${userFullName} - ${title}`,
1833
+ description: `${userFullName} - ${description}`,
1834
+ },
1835
+ shop: this.shop,
1836
+ shops: [this.shop],
1837
+ personId,
1838
+ personName: userFullName,
1839
+ personPhoto: userPhoto,
1840
+ brandCategory: false,
1841
+ published: true,
1842
+ theme,
1843
+ bannerUrl,
1844
+ };
1845
+ const newWishlist = await this.wishlistRepository.create(data);
1846
+ await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
1847
+ return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
1848
+ }
1849
+ update({ id, title, description, userFullName, userPhoto, theme, bannerUrl, }) {
1850
+ const data = {
1851
+ id,
1852
+ name: title,
1853
+ description,
1854
+ metadata: {
1855
+ title: `${userFullName} - ${title}`,
1856
+ description: `${userFullName} - ${description}`,
1857
+ },
1858
+ personName: userFullName,
1859
+ personPhoto: userPhoto,
1860
+ theme,
1861
+ bannerUrl,
1862
+ };
1863
+ return this.wishlistRepository.update(data);
1864
+ }
1865
+ delete(wishlistId) {
1866
+ return this.wishlistRepository.delete({ id: wishlistId });
1867
+ }
1868
+ getWishlistBySlug(slug) {
1869
+ const [id] = slug.split('-');
1870
+ if (+id)
1871
+ return this.wishlistRepository.get({ id });
1872
+ return this.wishlistRepository.getWishlistBySlug(slug);
1873
+ }
1874
+ getWishlistsByPerson(personId) {
1875
+ return this.wishlistRepository.getWishlistByPerson(personId);
1876
+ }
1877
+ async addProduct(wishlistId, productId) {
1878
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1879
+ const hasProduct = wishlist.products.some((p) => p == productId);
1880
+ if (!hasProduct) {
1881
+ wishlist.products = [...wishlist.products, productId];
1882
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1883
+ }
1884
+ return wishlist;
1885
+ }
1886
+ async removeProduct(wishlistId, productId) {
1887
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
1888
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
1889
+ if (productIndex != -1) {
1890
+ wishlist.products.splice(productIndex, 1);
1891
+ if (!wishlist.products.length)
1892
+ return this.wishlistRepository.update({ id: wishlistId, products: { action: 'remove' } });
1893
+ return this.wishlistRepository.update({ id: wishlistId, products: wishlist.products });
1894
+ }
1895
+ return wishlist;
1896
+ }
1897
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: 'CategoryRepository' }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryFilterRepository' }, { token: i1$2.ProductsIndex }], target: i0.ɵɵFactoryTarget.Injectable }); }
1898
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
1899
+ }
1900
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
1901
+ type: Injectable
1902
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1903
+ type: Inject,
1904
+ args: ['WishlistRepository']
1905
+ }] }, { type: undefined, decorators: [{
1906
+ type: Inject,
1907
+ args: ['CategoryRepository']
1908
+ }] }, { type: i1$2.Shops, decorators: [{
1909
+ type: Inject,
1910
+ args: [DEFAULT_SHOP]
1911
+ }] }, { type: undefined, decorators: [{
1912
+ type: Inject,
1913
+ args: ['ProductRepository']
1914
+ }] }, { type: undefined, decorators: [{
1915
+ type: Inject,
1916
+ args: ['CategoryFilterRepository']
1917
+ }] }, { type: i1$2.ProductsIndex }] });
1918
+
1919
+ class CheckoutSubscriptionService {
1920
+ constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1921
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
1922
+ this.subscriptionRepository = subscriptionRepository;
1923
+ this.couponService = couponService;
1924
+ }
1925
+ getCheckoutSubscription(checkoutData) {
1926
+ const checkoutId = cookie.get('checkoutSubscriptionId');
1927
+ if (!isNil(checkoutId))
1928
+ return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
1929
+ return from(this.createCheckoutSubscription(checkoutData));
1930
+ }
1931
+ async createCheckoutSubscription(checkoutData) {
1932
+ const checkout = await this.checkoutSubscriptionRepository.create({
1933
+ createdAt: new Date(),
1934
+ ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1935
+ });
1936
+ cookie.set('checkoutSubscriptionId', checkout.id);
1937
+ return checkout;
1938
+ }
1939
+ clearCheckoutSubscriptionFromSession() {
1940
+ cookie.remove('checkoutSubscriptionId');
1941
+ return of();
1942
+ }
1943
+ checkCoupon(nickname, userEmail) {
1944
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1945
+ .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
1946
+ .pipe()));
1947
+ }
1948
+ calcDiscountSubscription(coupon) {
1949
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
1950
+ }
1951
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1952
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
1953
+ }
1954
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
1955
+ type: Injectable
1956
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1957
+ type: Inject,
1958
+ args: ['CheckoutSubscriptionRepository']
1959
+ }] }, { type: undefined, decorators: [{
1960
+ type: Inject,
1961
+ args: ['SubscriptionRepository']
1962
+ }] }, { type: CouponService }] });
1963
+
1964
+ class UtilHelper {
1965
+ static createSlug(name) {
1966
+ return name
1967
+ .toLowerCase()
1968
+ .replace(/\s+/g, '-') // Replace spaces with -
1969
+ .replace(/[ãàáäâ]/g, 'a') // Replace spaces with -
1970
+ .replace(/[ẽèéëê]/g, 'e') // Replace spaces with -
1971
+ .replace(/[ìíïî]/g, 'i') // Replace spaces with -
1972
+ .replace(/[õòóöô]/g, 'o') // Replace spaces with -
1973
+ .replace(/[ùúüû]/g, 'u') // Replace spaces with -
1974
+ .replace(/[ñ]/g, 'n') // Replace spaces with -
1975
+ .replace(/[ç]/g, 'c') // Replace spaces with -
1976
+ .replace(/[&]/g, 'and') // Replace spaces with -
1977
+ .replace(/[^\w\-]+/g, '') // Remove all non-word chars
1978
+ .replace(/\-\-+/g, '-'); // Replace multiple - with single -
1979
+ }
1980
+ }
1981
+
1982
+ class HomeShopService {
1983
+ get homeId() {
1984
+ if (this.defaultShop === Shops.GLAMSHOP)
1985
+ return 'glamshop';
1986
+ if (this.defaultShop === Shops.MENSMARKET)
1987
+ return 'mens_market';
1988
+ return null;
1989
+ }
1990
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
1991
+ this.categoryRepository = categoryRepository;
1992
+ this.homeRepository = homeRepository;
1993
+ this.productRepository = productRepository;
1994
+ this.defaultShop = defaultShop;
1995
+ this.buildCategoryGroupWithRequiredData = (group) => ({
1996
+ category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
1997
+ products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
1998
+ 'id',
1999
+ 'price',
2000
+ 'reviews',
2001
+ 'hasVariants',
2002
+ 'slug',
2003
+ 'sku',
2004
+ 'stock',
2005
+ 'costPrice',
2006
+ 'images',
2007
+ 'miniatures',
2008
+ 'name',
2009
+ 'weight',
2010
+ 'rate',
2011
+ 'type',
2012
+ 'brand',
2013
+ ]))) || [],
2014
+ });
2015
+ }
2016
+ getHomeData() {
2017
+ return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
2018
+ ? of(home)
2019
+ : forkJoin([
2020
+ this.getDiscoverProducts(this.gender),
2021
+ this.getFeaturedProducts(this.gender),
2022
+ this.getVerticalProducts(this.gender),
2023
+ ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2024
+ discoverProducts,
2025
+ featuredProducts,
2026
+ verticalProducts,
2027
+ })), concatMap((data) => this.saveHomeData(data)))));
2028
+ }
2029
+ getBanners(type) {
2030
+ return this.getHomeConfiguration().pipe(map((home) => {
2031
+ if (type === 'brand')
2032
+ return home.brandsCarousel;
2033
+ if (type === 'buyToWin')
2034
+ return [home.buyToWinBanner];
2035
+ if (type === 'block')
2036
+ return home.blockBanners;
2037
+ if (type === 'blog')
2038
+ return [home.blogBanner];
2039
+ return [];
2040
+ }));
2041
+ }
2042
+ getMinValueForFreeShipping() {
2043
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2044
+ }
2045
+ getDiscoverProducts(gender) {
2046
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2047
+ }
2048
+ getFeaturedProducts(gender) {
2049
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories, undefined, gender)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2050
+ }
2051
+ getVerticalProducts(gender) {
2052
+ return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
2053
+ filters: {
2054
+ categories: { operator: Where.IN, value: [category.id] },
2055
+ ...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
2056
+ },
2057
+ limits: { limit: 12 },
2058
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2059
+ }
2060
+ getHomeConfiguration() {
2061
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
2062
+ ? of(home)
2063
+ : !this.homeId
2064
+ ? throwError(new RequiredArgumentError(['homeId']))
2065
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2066
+ }
2067
+ saveHomeData(homeData) {
2068
+ const data = {
2069
+ createdAt: new Date(),
2070
+ expiresAt: add(new Date(), { hours: 1 }),
2071
+ data: homeData,
2072
+ };
2073
+ return from(this.homeRepository.update({
2074
+ id: this.homeId,
2075
+ data,
2076
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2077
+ }
2078
+ get gender() {
2079
+ return this.homeId === 'mens_market' ? 'masculino' : undefined;
2080
+ }
2081
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
2082
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopService }); }
2083
+ }
2084
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopService, decorators: [{
2085
+ type: Injectable
2086
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2087
+ type: Inject,
2088
+ args: ['CategoryRepository']
2089
+ }] }, { type: undefined, decorators: [{
2090
+ type: Inject,
2091
+ args: ['HomeRepository']
2092
+ }] }, { type: undefined, decorators: [{
2093
+ type: Inject,
2094
+ args: ['ProductRepository']
2095
+ }] }, { type: i1$2.Shops, decorators: [{
2096
+ type: Inject,
2097
+ args: [DEFAULT_SHOP]
2098
+ }] }] });
2099
+
2100
+ class OrderService {
2101
+ constructor(angularFirestore, orderRepository) {
2102
+ this.angularFirestore = angularFirestore;
2103
+ this.orderRepository = orderRepository;
2104
+ this.orderSubject = new Subject();
2105
+ }
2106
+ getOrder(id) {
2107
+ docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
2108
+ .pipe(map((doc) => Order.toInstance(doc.data())))
2109
+ .subscribe((doc) => this.orderSubject.next(doc));
2110
+ return this.orderSubject;
2111
+ }
2112
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
2113
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderService }); }
2114
+ }
2115
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderService, decorators: [{
2116
+ type: Injectable
2117
+ }], ctorParameters: () => [{ type: i1$1.Firestore }, { type: i1$2.OrderFirestoreRepository, decorators: [{
2118
+ type: Inject,
2119
+ args: ['OrderRepository']
2120
+ }] }] });
2121
+
2122
+ class ShippingService {
2123
+ constructor(http, apiUrl, homeService) {
2124
+ this.http = http;
2125
+ this.apiUrl = apiUrl;
2126
+ this.homeService = homeService;
2127
+ }
2128
+ getShippingMethods(shop, zip, weightGrams, totalPrice, personId, subscriptionPlan) {
2129
+ return combineLatest([
2130
+ this.homeService.getHomeData(),
2131
+ this.http.get(`${this.apiUrl}open/checkshippingcompany?personId=${personId}&postalCode=${zip}&weightGrams=${weightGrams}`),
2132
+ ]).pipe(map(([datas, shippingMethodsResponse]) => {
2133
+ let shippingMethods = shippingMethodsResponse.result;
2134
+ if (!shippingMethods.length)
2135
+ return [];
2136
+ shippingMethods = shippingMethods.map((shippingMethod) => {
2137
+ if (shippingMethod.ShippingCompanyName == 'Same Day EG')
2138
+ shippingMethod.ShippingCompanyName = 'Same Day';
2139
+ return shippingMethod;
2140
+ });
2141
+ const datasSameDayNotAvaliable = datas.sameDayNotAvaliable;
2142
+ if (this.isHolidays(datasSameDayNotAvaliable)) {
2143
+ shippingMethods = shippingMethods.filter((method) => method.serviceName !== 'Same Day');
2144
+ }
2145
+ if (totalPrice >= 200) {
2146
+ shippingMethods = shippingMethods.map((s) => {
2147
+ if (s.serviceName !== 'Same Day')
2148
+ return { ...s, totalPrice: 0 };
2149
+ else
2150
+ return s;
2151
+ });
2152
+ }
2153
+ if (shop == Shops.GLAMSHOP)
2154
+ return shippingMethods;
2155
+ if (this.isFreeShippingBySubscription(shop, subscriptionPlan)) {
2156
+ shippingMethods = shippingMethods.map((s) => {
2157
+ if (s.serviceName == 'Same Day')
2158
+ return { ...s, totalPrice: s.totalPrice / 2 };
2159
+ else
2160
+ return { ...s, totalPrice: 0 };
2161
+ });
2162
+ }
2163
+ if (this.isHalfShippingBySubscription(shop, subscriptionPlan)) {
2164
+ shippingMethods = shippingMethods.map((s) => {
2165
+ return { ...s, totalPrice: s.totalPrice / 2 };
2166
+ });
2167
+ }
2168
+ return shippingMethods;
2169
+ }));
2170
+ }
2171
+ isFreeShippingBySubscription(shop, subscriptionPlan) {
2172
+ if (!subscriptionPlan)
2173
+ return false;
2174
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'SELECT')
2175
+ return true;
2176
+ return false;
2177
+ }
2178
+ isHalfShippingBySubscription(shop, subscriptionPlan) {
2179
+ if (!subscriptionPlan)
2180
+ return false;
2181
+ if (shop == Shops.MENSMARKET && subscriptionPlan == 'PRIME') {
2182
+ return true;
2183
+ }
2184
+ return false;
2185
+ }
2186
+ isHolidays(datas) {
2187
+ const today = new Date();
2188
+ for (const key in datas) {
2189
+ let start = new Date(`${today.getFullYear()}-${datas[key].beginDate}`);
2190
+ let end = new Date(`${today.getFullYear()}-${datas[key].endDate}`);
2191
+ if (start > end)
2192
+ end = new Date(`${today.getFullYear() + 1}-${datas[key].endDate}`);
2193
+ if (today >= start && today <= end)
2194
+ return true;
2195
+ }
2196
+ return false;
2197
+ }
2198
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2199
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ShippingService }); }
2200
+ }
2201
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ShippingService, decorators: [{
2202
+ type: Injectable
2203
+ }], ctorParameters: () => [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
2204
+ type: Inject,
2205
+ args: [BACKEND_URL]
2206
+ }] }, { type: HomeShopService }] });
2207
+
2208
+ class AngularConnectModule {
2209
+ static initializeApp(defaultShop, options, nameOrConfig) {
2210
+ return {
2211
+ ngModule: AngularConnectModule,
2212
+ providers: [
2213
+ {
2214
+ provide: CATEGORY_STRUCTURE,
2215
+ useClass: isNil(options?.oldCategoryStructure) || options?.oldCategoryStructure
2216
+ ? OldCategoryStructureAdapter
2217
+ : NewCategoryStructureAdapter,
2218
+ },
2219
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
2220
+ ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options?.firebase }]),
2221
+ ...(isNil(options?.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
2222
+ ...(isNil(options?.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
2223
+ ...(isNil(options?.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
2224
+ ...(isNil(options?.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
2225
+ ...(isNil(options?.storageBaseUrl) ? [] : [{ provide: STORAGE_BASE_URL, useValue: options.storageBaseUrl }]),
2226
+ ],
2227
+ };
2228
+ }
2229
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
2230
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$4.FirebaseAppModule, AngularElasticSeachModule,
2231
+ AngularFirebaseAuthModule,
2232
+ AngularFirestoreModule,
2233
+ AngularHasuraGraphQLModule] }); }
2234
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, providers: [
2235
+ AuthService,
2236
+ CartService,
2237
+ CatalogService,
2238
+ CategoryService,
2239
+ CheckoutService,
2240
+ CheckoutSubscriptionService,
2241
+ CouponService,
2242
+ HomeShopService,
2243
+ OrderService,
2244
+ ShippingService,
2245
+ WishlistService,
2246
+ {
2247
+ provide: UpdateUserImage,
2248
+ useFactory: (userRepository, fileUploader) => {
2249
+ return new UpdateUserImage(userRepository, fileUploader);
2250
+ },
2251
+ deps: ['UserRepository', 'FileUploaderService'],
2252
+ },
2253
+ ], imports: [provideFirebaseApp((injector) => {
2254
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2255
+ try {
2256
+ return getApp(appName);
2257
+ }
2258
+ catch (error) {
2259
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2260
+ }
2261
+ }),
2262
+ AngularElasticSeachModule,
2263
+ AngularFirebaseAuthModule,
2264
+ AngularFirestoreModule,
2265
+ AngularHasuraGraphQLModule] }); }
2266
+ }
2267
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, decorators: [{
2268
+ type: NgModule,
2269
+ args: [{
2270
+ imports: [
2271
+ provideFirebaseApp((injector) => {
2272
+ const appName = injector.get(FIREBASE_APP_NAME) || '[DEFAULT]';
2273
+ try {
2274
+ return getApp(appName);
2275
+ }
2276
+ catch (error) {
2277
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
2278
+ }
2279
+ }),
2280
+ AngularElasticSeachModule,
2281
+ AngularFirebaseAuthModule,
2282
+ AngularFirestoreModule,
2283
+ AngularHasuraGraphQLModule,
2284
+ ],
2285
+ providers: [
2286
+ AuthService,
2287
+ CartService,
2288
+ CatalogService,
2289
+ CategoryService,
2290
+ CheckoutService,
2291
+ CheckoutSubscriptionService,
2292
+ CouponService,
2293
+ HomeShopService,
2294
+ OrderService,
2295
+ ShippingService,
2296
+ WishlistService,
2297
+ {
2298
+ provide: UpdateUserImage,
2299
+ useFactory: (userRepository, fileUploader) => {
2300
+ return new UpdateUserImage(userRepository, fileUploader);
2301
+ },
2302
+ deps: ['UserRepository', 'FileUploaderService'],
2303
+ },
2304
+ ],
2305
+ }]
2306
+ }] });
2307
+
2308
+ /**
2309
+ * Generated bundle index. Do not edit.
2310
+ */
2311
+
2312
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderService, ProductSorts, ShippingService, UtilHelper, WishlistService };
2313
+ //# sourceMappingURL=infrab4a-connect-angular.mjs.map