@infrab4a/connect-angular 4.0.0-beta.47 → 4.0.0-beta.49

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