@infrab4a/connect-angular 3.9.1-beta3 → 3.9.2-beta1

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 (55) hide show
  1. package/angular-connect.module.d.ts +0 -1
  2. package/bundles/infrab4a-connect-angular.umd.js +1161 -1587
  3. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  4. package/consts/index.d.ts +0 -1
  5. package/esm2015/angular-connect.module.js +3 -14
  6. package/esm2015/angular-firestore.module.js +3 -17
  7. package/esm2015/angular-hasura-graphql.module.js +2 -18
  8. package/esm2015/consts/index.js +1 -2
  9. package/esm2015/index.js +3 -3
  10. package/esm2015/services/cart.service.js +14 -27
  11. package/esm2015/services/checkout-subscription.service.js +2 -2
  12. package/esm2015/services/checkout.service.js +7 -2
  13. package/esm2015/services/coupon.service.js +159 -154
  14. package/esm2015/services/errors/group-invalid-coupon.error.js +8 -0
  15. package/esm2015/services/errors/index.js +3 -0
  16. package/esm2015/services/errors/invalid-coupon.error.js +8 -0
  17. package/esm2015/services/index.js +1 -2
  18. package/fesm2015/infrab4a-connect-angular.js +1026 -1286
  19. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  20. package/index.d.ts +2 -2
  21. package/package.json +2 -2
  22. package/services/cart.service.d.ts +2 -3
  23. package/services/coupon.service.d.ts +8 -11
  24. package/services/errors/group-invalid-coupon.error.d.ts +6 -0
  25. package/services/errors/index.d.ts +2 -0
  26. package/services/errors/invalid-coupon.error.d.ts +5 -0
  27. package/services/index.d.ts +0 -1
  28. package/consts/category-structure.d.ts +0 -1
  29. package/esm2015/consts/category-structure.js +0 -2
  30. package/esm2015/services/catalog/adapters/category-structure.adapter.js +0 -2
  31. package/esm2015/services/catalog/adapters/index.js +0 -4
  32. package/esm2015/services/catalog/adapters/new-category-structure.adapter.js +0 -51
  33. package/esm2015/services/catalog/adapters/old-category-structure.adapter.js +0 -27
  34. package/esm2015/services/catalog/catalog.service.js +0 -96
  35. package/esm2015/services/catalog/category.service.js +0 -56
  36. package/esm2015/services/catalog/enums/index.js +0 -2
  37. package/esm2015/services/catalog/enums/product-sorts.enum.js +0 -11
  38. package/esm2015/services/catalog/index.js +0 -6
  39. package/esm2015/services/catalog/models/category-with-tree.model.js +0 -10
  40. package/esm2015/services/catalog/models/index.js +0 -2
  41. package/esm2015/services/catalog/types/index.js +0 -2
  42. package/esm2015/services/catalog/types/product-sort.type.js +0 -2
  43. package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
  44. package/services/catalog/adapters/index.d.ts +0 -3
  45. package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
  46. package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
  47. package/services/catalog/catalog.service.d.ts +0 -54
  48. package/services/catalog/category.service.d.ts +0 -15
  49. package/services/catalog/enums/index.d.ts +0 -1
  50. package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
  51. package/services/catalog/index.d.ts +0 -5
  52. package/services/catalog/models/category-with-tree.model.d.ts +0 -4
  53. package/services/catalog/models/index.d.ts +0 -1
  54. package/services/catalog/types/index.d.ts +0 -1
  55. package/services/catalog/types/product-sort.type.d.ts +0 -2
@@ -1,939 +1,361 @@
1
1
  import * as i0 from '@angular/core';
2
- import { NgModule, APP_INITIALIZER, Injectable, Inject } from '@angular/core';
3
- import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
4
- import * as i1$1 from '@infrab4a/connect';
5
- import { ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, RoundProductPricesHelper, set, Category, CheckoutSubscription, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword } from '@infrab4a/connect';
6
- import * as i1$2 from '@angular/fire/firestore';
7
- import { AngularFirestore } from '@angular/fire/firestore';
2
+ import { Injectable, Inject, NgModule, APP_INITIALIZER } from '@angular/core';
8
3
  import * as i1 from '@angular/fire/auth';
9
4
  import { AngularFireAuth } from '@angular/fire/auth';
10
5
  import { of, combineLatest, from, throwError, Subject, iif, forkJoin } from 'rxjs';
11
6
  import { catchError, map, mergeMap, concatMap, tap } from 'rxjs/operators';
12
- import { __awaiter, __decorate, __metadata } from 'tslib';
7
+ import { __awaiter } from 'tslib';
8
+ import * as i3 from '@infrab4a/connect';
9
+ import { Coupon, Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Category, Product, RequiredArgumentError, add, Order, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, VariantHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository } from '@infrab4a/connect';
13
10
  import cookie from 'js-cookie';
14
- import { Type } from 'class-transformer';
15
- import * as i1$3 from '@angular/common/http';
11
+ import { CustomError } from 'ts-custom-error';
12
+ import * as i1$1 from '@angular/fire/firestore';
13
+ import { AngularFirestore } from '@angular/fire/firestore';
14
+ import * as i1$2 from '@angular/common/http';
15
+ import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
16
+
17
+ class AuthService {
18
+ constructor(angularFireAuth, userRepository) {
19
+ this.angularFireAuth = angularFireAuth;
20
+ this.userRepository = userRepository;
21
+ }
22
+ getAuthstate() {
23
+ const observables = [
24
+ this.angularFireAuth.authState.pipe(catchError(() => of(null))),
25
+ this.getUser().pipe(catchError(() => of(null))),
26
+ ];
27
+ return combineLatest(observables).pipe(map(([fireUser, user]) => {
28
+ return {
29
+ user,
30
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
31
+ };
32
+ }));
33
+ }
34
+ getUser() {
35
+ 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))));
36
+ }
37
+ getTokenId() {
38
+ return this.angularFireAuth.idToken;
39
+ }
40
+ getFireUser() {
41
+ return this.angularFireAuth.user.pipe(catchError(() => of(null)));
42
+ }
43
+ }
44
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
45
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
46
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
47
+ type: Injectable
48
+ }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
49
+ type: Inject,
50
+ args: ['UserRepository']
51
+ }] }]; } });
52
+
53
+ const BACKEND_URL = 'BACKEND_URL';
54
+
55
+ const DEFAULT_SHOP = 'DEFAULT_SHOP';
16
56
 
17
57
  const ES_CONFIG = 'ES_CONFIG';
18
58
 
19
- class AngularElasticSeachModule {
20
- static initializeApp(options) {
21
- return {
22
- ngModule: AngularElasticSeachModule,
23
- providers: [{ provide: ES_CONFIG, useValue: options }],
24
- };
59
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
60
+
61
+ class InvalidCouponError extends CustomError {
62
+ constructor(message) {
63
+ super(message);
64
+ this.message = message;
25
65
  }
26
66
  }
27
- AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
28
- AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
29
- AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
30
- {
31
- provide: ProductsIndex,
32
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
33
- deps: [ES_CONFIG],
34
- },
35
- ] });
36
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
37
- type: NgModule,
67
+
68
+ class GroupInvalidCouponError extends CustomError {
69
+ constructor(errors) {
70
+ super('Many coupon errors throw');
71
+ this.errors = errors;
72
+ }
73
+ }
74
+
75
+ class CouponService {
76
+ constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
77
+ this.couponRepository = couponRepository;
78
+ this.defaultShop = defaultShop;
79
+ this.orderRepository = orderRepository;
80
+ this.categoryRepository = categoryRepository;
81
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
82
+ this.separateValidCoupons = (coupons, userEmail) => coupons
83
+ .map((coupon) => {
84
+ try {
85
+ if (!(coupon instanceof Coupon))
86
+ throw new InvalidCouponError('Cupom inválido.');
87
+ if (this.isValidCoupon(coupon, userEmail))
88
+ return coupon;
89
+ }
90
+ catch (error) {
91
+ return error;
92
+ }
93
+ })
94
+ .reduce((current, coupon) => (Object.assign(Object.assign({}, current), (coupon instanceof Coupon
95
+ ? { valids: [...current.valids, coupon] }
96
+ : { invalids: [...current.invalids, coupon] }))), {
97
+ valids: [],
98
+ invalids: [],
99
+ });
100
+ }
101
+ checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
102
+ return from(this.couponRepository.find({
103
+ filters: {
104
+ nickname: { operator: Where.EQUALS, value: nickname },
105
+ active: { operator: Where.EQUALS, value: true },
106
+ },
107
+ })).pipe(concatMap((coupons) => this.checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription)), concatMap((coupon) => this.checkCouponUseAndLimit(coupon, userEmail, checkout)), map((coupon) => this.isValidCoupon(coupon, userEmail)), map((coupon) => coupon));
108
+ }
109
+ checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
110
+ // Caso não ache nenhum cupom, retorna erro
111
+ if (coupons.count < 1) {
112
+ return throwError('Cupom inválido.');
113
+ }
114
+ // Get Primeiro Cupom (o find do repository retorna um array)
115
+ const coupon = coupons.data.shift();
116
+ // Verifica se o cupom é aplicavel na loja
117
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
118
+ // Cupon não aplicavel a loja retorna erro
119
+ if (!isInShop)
120
+ return throwError('Cupom inválido para loja.');
121
+ // Verifica se o coupon é aplicado no checkout que está sendo realizado
122
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
123
+ // Cupon não aplicavel ao checkout retorna erro
124
+ if (!isCheckoutType)
125
+ return throwError('Cupom inválido. Erro de checkout.');
126
+ // Verifica se o cupom é ou pode ser aplicado para subscription
127
+ if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
128
+ // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
129
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
130
+ return throwError('Cupom inválido para sua assinatura.');
131
+ }
132
+ if (isSubscription)
133
+ return of(coupon);
134
+ // Verifica se possui o valor minimo de compra para utilização do cupom
135
+ const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
136
+ // Se não tem valor mínimo atingido, retorna erro
137
+ if (!hasMinSubTotal)
138
+ return throwError(`Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`);
139
+ return of(coupon);
140
+ }
141
+ isValidCoupon(coupon, userEmail) {
142
+ // Verifica a data de inicio de validade do cupom
143
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
144
+ throw new InvalidCouponError('Cupom ainda não liberado.');
145
+ // Verifica a data de validade do cupom
146
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
147
+ throw new InvalidCouponError('Cupom expirado.');
148
+ return coupon;
149
+ }
150
+ checkCouponUseAndLimit(coupon, userEmail, checkout) {
151
+ return __awaiter(this, void 0, void 0, function* () {
152
+ const orders = yield this.orderRepository.find({
153
+ filters: {
154
+ coupon: { id: coupon.id },
155
+ payment: { status: 'paid' },
156
+ },
157
+ });
158
+ // orders que usuario ja fez com o cupom
159
+ const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
160
+ // Verifica o limite de uso de cupom por usuario
161
+ if (coupon.useLimitPerUser && ordersUserCoupon.length)
162
+ throw new InvalidCouponError('Limite de uso por usuário atingido.');
163
+ // Verifica o limite de uso geral por usuario
164
+ if (coupon.useLimit && orders.data.length >= coupon.useLimit)
165
+ throw new InvalidCouponError('Limite de uso atingido.');
166
+ const validUser = this.userValidationAndSubscriptionStatus(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
167
+ if (!validUser)
168
+ throw new InvalidCouponError('Usuário não elegível.');
169
+ const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
170
+ if (!hasProductCategories)
171
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
172
+ return coupon;
173
+ });
174
+ }
175
+ calcDiscountSubscription(coupon, checkout) {
176
+ //
177
+ let discount = 0;
178
+ if (coupon.type === CouponTypes.ABSOLUTE)
179
+ discount = coupon.discount;
180
+ else if (coupon.type === CouponTypes.PERCENTAGE)
181
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
182
+ return of(discount);
183
+ }
184
+ calcDiscountShopping(coupon, checkout) {
185
+ return __awaiter(this, void 0, void 0, function* () {
186
+ let discount = 0;
187
+ switch (coupon.type) {
188
+ case CouponTypes.ABSOLUTE: {
189
+ discount = coupon.discount;
190
+ break;
191
+ }
192
+ case CouponTypes.PERCENTAGE: {
193
+ discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
194
+ break;
195
+ }
196
+ }
197
+ return discount;
198
+ });
199
+ }
200
+ calcShoppingPercentageDiscount(coupon, checkout) {
201
+ var _a;
202
+ return __awaiter(this, void 0, void 0, function* () {
203
+ let discount = 0;
204
+ const shop = checkout.shop;
205
+ let lineItensDiscount = [];
206
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
207
+ if (coupon.productsCategories && coupon.productsCategories.length) {
208
+ lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
209
+ var _a;
210
+ if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
211
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
212
+ }
213
+ return true;
214
+ });
215
+ }
216
+ else {
217
+ lineItensDiscount = checkout.lineItems;
218
+ }
219
+ const subTotal = lineItensDiscount.reduce((acc, curr) => {
220
+ var _a, _b, _c;
221
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
222
+ ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
223
+ : acc + curr.pricePaid * curr.quantity;
224
+ }, 0) || 0;
225
+ discount = subTotal * (coupon.discount / 100);
226
+ return discount;
227
+ });
228
+ }
229
+ hasMinSubTotal(coupon, checkout) {
230
+ var _a;
231
+ if (!coupon.minSubTotalValue)
232
+ return true;
233
+ const shop = checkout.shop;
234
+ let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
235
+ var _a, _b, _c;
236
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
237
+ ? acc + ((_c = curr.price[shop]) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
238
+ : acc + curr.pricePaid * curr.quantity;
239
+ }, 0)) || 0;
240
+ if (coupon.minSubTotalValue <= subTotal)
241
+ return true;
242
+ return false;
243
+ }
244
+ hasProductCategories(coupon, checkout) {
245
+ var _a;
246
+ return __awaiter(this, void 0, void 0, function* () {
247
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
248
+ return true;
249
+ }
250
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
251
+ const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
252
+ var _a;
253
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
254
+ return true;
255
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
256
+ });
257
+ return hasCategories.length ? true : false;
258
+ });
259
+ }
260
+ userValidationAndSubscriptionStatus(coupon, user) {
261
+ if (coupon.exclusivityType === Exclusivities.ALL_USERS)
262
+ return true;
263
+ if (!user)
264
+ return true;
265
+ // Verifica se o email do usuário é coorporativo
266
+ if (!this.emailIsFromCollaborator(user.email) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
267
+ throw new InvalidCouponError('Você não é colaborador.');
268
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
269
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== user.email)
270
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
271
+ switch (coupon.exclusivityType) {
272
+ case Exclusivities.ACTIVE_SUBSCRIBER:
273
+ return user.isSubscriber ? true : false;
274
+ case Exclusivities.INACTIVE_SUBSCRIBER:
275
+ return user.isSubscriber ? false : true;
276
+ case Exclusivities.NON_SUBSCRIBER:
277
+ return user.isSubscriber ? false : true;
278
+ }
279
+ return true;
280
+ }
281
+ getCouponCategoriesId(coupon) {
282
+ return __awaiter(this, void 0, void 0, function* () {
283
+ let couponCategories = [];
284
+ for (let index = 0; index < coupon.productsCategories.length; index++) {
285
+ let c = yield this.categoryRepository.get({
286
+ id: coupon.productsCategories[index],
287
+ });
288
+ couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
289
+ }
290
+ return couponCategories;
291
+ });
292
+ }
293
+ }
294
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
295
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
296
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
297
+ type: Injectable,
38
298
  args: [{
39
- providers: [
40
- {
41
- provide: ProductsIndex,
42
- useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
43
- deps: [ES_CONFIG],
44
- },
45
- ],
299
+ providedIn: 'root',
46
300
  }]
47
- }] });
301
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
302
+ type: Inject,
303
+ args: ['CouponRepository']
304
+ }] }, { type: i3.Shops, decorators: [{
305
+ type: Inject,
306
+ args: [DEFAULT_SHOP]
307
+ }] }, { type: undefined, decorators: [{
308
+ type: Inject,
309
+ args: ['OrderRepository']
310
+ }] }, { type: undefined, decorators: [{
311
+ type: Inject,
312
+ args: ['CategoryRepository']
313
+ }] }]; } });
48
314
 
49
- class AngularFirestoreModule {
50
- static initializeApp(options, nameOrConfig) {
51
- return {
52
- ngModule: AngularFirestoreModule,
53
- providers: [
54
- { provide: FIREBASE_OPTIONS, useValue: options.firebase },
55
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
56
- { provide: ES_CONFIG, useValue: options.elasticSearch },
57
- ],
58
- };
59
- }
60
- }
61
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
62
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
63
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
64
- {
65
- provide: 'BeautyProfileRepository',
66
- useFactory: (firestore, userRepository) => {
67
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
68
- },
69
- deps: [AngularFirestore, 'UserRepository'],
70
- },
71
- {
72
- provide: 'Buy2WinRepository',
73
- useFactory: (firestore) => {
74
- return new Buy2WinFirestoreRepository(firestore.firestore);
75
- },
76
- deps: [AngularFirestore],
77
- },
78
- {
79
- provide: CategoryFirestoreRepository,
80
- useFactory: (firestore) => {
81
- return new CategoryFirestoreRepository(firestore.firestore);
82
- },
83
- deps: [AngularFirestore],
84
- },
85
- {
86
- provide: 'CheckoutRepository',
87
- useFactory: (firestore) => {
88
- return new CheckoutFirestoreRepository(firestore.firestore);
89
- },
90
- deps: [AngularFirestore],
91
- },
92
- {
93
- provide: 'CheckoutSubscriptionRepository',
94
- useFactory: (firestore) => {
95
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
96
- },
97
- deps: [AngularFirestore],
98
- },
99
- {
100
- provide: 'CouponRepository',
101
- useFactory: (firestore) => {
102
- return new CouponFirestoreRepository(firestore.firestore);
103
- },
104
- deps: [AngularFirestore],
105
- },
106
- {
107
- provide: 'CampaignHashtagRepository',
108
- useFactory: (firestore) => {
109
- return new CampaignHashtagFirestoreRepository(firestore.firestore);
110
- },
111
- deps: [AngularFirestore],
112
- },
113
- {
114
- provide: 'CampaignDashboardRepository',
115
- useFactory: (firestore) => {
116
- return new CampaignDashboardFirestoreRepository(firestore.firestore);
117
- },
118
- deps: [AngularFirestore],
119
- },
120
- {
121
- provide: 'EditionRepository',
122
- useFactory: (firestore, subscriptionRepository) => {
123
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
124
- },
125
- deps: [AngularFirestore, 'SubscriptionRepository'],
126
- },
127
- {
128
- provide: 'HomeRepository',
129
- useFactory: (firestore) => {
130
- return new HomeFirestoreRepository(firestore.firestore);
131
- },
132
- deps: [AngularFirestore],
133
- },
134
- {
135
- provide: 'LeadRepository',
136
- useFactory: (firestore) => {
137
- return new LeadFirestoreRepository(firestore.firestore);
138
- },
139
- deps: [AngularFirestore],
140
- },
141
- {
142
- provide: 'LegacyOrderRepository',
143
- useFactory: (firestore) => {
144
- return new LegacyOrderFirestoreRepository(firestore.firestore);
145
- },
146
- deps: [AngularFirestore],
147
- },
148
- {
149
- provide: 'ShopMenuRepository',
150
- useFactory: (firestore) => {
151
- return new ShopMenuFirestoreRepository(firestore.firestore);
152
- },
153
- deps: [AngularFirestore],
154
- },
155
- {
156
- provide: 'OrderRepository',
157
- useFactory: (firestore) => {
158
- return new OrderFirestoreRepository(firestore.firestore);
159
- },
160
- deps: [AngularFirestore],
161
- },
162
- {
163
- provide: 'PaymentRepository',
164
- useFactory: (firestore) => {
165
- return new PaymentFirestoreRepository(firestore.firestore);
166
- },
167
- deps: [AngularFirestore],
168
- },
169
- {
170
- provide: ProductFirestoreRepository,
171
- useFactory: (firestore) => {
172
- return new ProductFirestoreRepository(firestore.firestore);
173
- },
174
- deps: [AngularFirestore],
175
- },
176
- {
177
- provide: 'ShopSettingsRepository',
178
- useFactory: (firestore) => {
179
- return new ShopSettingsFirestoreRepository(firestore.firestore);
180
- },
181
- deps: [AngularFirestore],
182
- },
183
- {
184
- provide: 'SubscriptionPaymentRepository',
185
- useFactory: (firestore, subscriptionRepository) => {
186
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
187
- },
188
- deps: [AngularFirestore, 'SubscriptionRepository'],
189
- },
190
- {
191
- provide: 'SubscriptionPlanRepository',
192
- useFactory: (firestore) => {
193
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
194
- },
195
- deps: [AngularFirestore],
196
- },
197
- {
198
- provide: 'SubscriptionProductRepository',
199
- useFactory: (firestore) => {
200
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
201
- },
202
- deps: [AngularFirestore],
203
- },
204
- {
205
- provide: 'SubscriptionRepository',
206
- useFactory: (firestore) => {
207
- return new SubscriptionFirestoreRepository(firestore.firestore);
208
- },
209
- deps: [AngularFirestore],
210
- },
211
- {
212
- provide: 'UserRepository',
213
- useFactory: (firestore) => {
214
- return new UserFirestoreRepository(firestore.firestore);
215
- },
216
- deps: [AngularFirestore],
217
- },
218
- {
219
- provide: 'UserAddressRepository',
220
- useFactory: (firestore, userRepository) => {
221
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
222
- },
223
- deps: [AngularFirestore, 'UserRepository'],
224
- },
225
- {
226
- provide: 'UserPaymentMethodRepository',
227
- useFactory: (firestore, userRepository) => {
228
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
229
- },
230
- deps: [AngularFirestore, 'UserRepository'],
231
- },
232
- {
233
- provide: 'SubscriptionMaterializationRepository',
234
- useFactory: (firestore) => {
235
- return new SubscriptionMaterializationFirestoreRepository(firestore.firestore);
236
- },
237
- deps: [AngularFirestore],
238
- },
239
- {
240
- provide: ProductVariantFirestoreRepository,
241
- useFactory: (firestore, productRepository) => {
242
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
243
- },
244
- deps: [AngularFirestore, ProductFirestoreRepository],
245
- },
246
- {
247
- provide: APP_INITIALIZER,
248
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
249
- deps: [AngularFirestore],
250
- multi: true,
251
- },
252
- ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
253
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
254
- type: NgModule,
255
- args: [{
256
- imports: [AngularFireModule, AngularElasticSeachModule],
257
- providers: [
258
- {
259
- provide: 'BeautyProfileRepository',
260
- useFactory: (firestore, userRepository) => {
261
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
262
- },
263
- deps: [AngularFirestore, 'UserRepository'],
264
- },
265
- {
266
- provide: 'Buy2WinRepository',
267
- useFactory: (firestore) => {
268
- return new Buy2WinFirestoreRepository(firestore.firestore);
269
- },
270
- deps: [AngularFirestore],
271
- },
272
- {
273
- provide: CategoryFirestoreRepository,
274
- useFactory: (firestore) => {
275
- return new CategoryFirestoreRepository(firestore.firestore);
276
- },
277
- deps: [AngularFirestore],
278
- },
279
- {
280
- provide: 'CheckoutRepository',
281
- useFactory: (firestore) => {
282
- return new CheckoutFirestoreRepository(firestore.firestore);
283
- },
284
- deps: [AngularFirestore],
285
- },
286
- {
287
- provide: 'CheckoutSubscriptionRepository',
288
- useFactory: (firestore) => {
289
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
290
- },
291
- deps: [AngularFirestore],
292
- },
293
- {
294
- provide: 'CouponRepository',
295
- useFactory: (firestore) => {
296
- return new CouponFirestoreRepository(firestore.firestore);
297
- },
298
- deps: [AngularFirestore],
299
- },
300
- {
301
- provide: 'CampaignHashtagRepository',
302
- useFactory: (firestore) => {
303
- return new CampaignHashtagFirestoreRepository(firestore.firestore);
304
- },
305
- deps: [AngularFirestore],
306
- },
307
- {
308
- provide: 'CampaignDashboardRepository',
309
- useFactory: (firestore) => {
310
- return new CampaignDashboardFirestoreRepository(firestore.firestore);
311
- },
312
- deps: [AngularFirestore],
313
- },
314
- {
315
- provide: 'EditionRepository',
316
- useFactory: (firestore, subscriptionRepository) => {
317
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
318
- },
319
- deps: [AngularFirestore, 'SubscriptionRepository'],
320
- },
321
- {
322
- provide: 'HomeRepository',
323
- useFactory: (firestore) => {
324
- return new HomeFirestoreRepository(firestore.firestore);
325
- },
326
- deps: [AngularFirestore],
327
- },
328
- {
329
- provide: 'LeadRepository',
330
- useFactory: (firestore) => {
331
- return new LeadFirestoreRepository(firestore.firestore);
332
- },
333
- deps: [AngularFirestore],
334
- },
335
- {
336
- provide: 'LegacyOrderRepository',
337
- useFactory: (firestore) => {
338
- return new LegacyOrderFirestoreRepository(firestore.firestore);
339
- },
340
- deps: [AngularFirestore],
341
- },
342
- {
343
- provide: 'ShopMenuRepository',
344
- useFactory: (firestore) => {
345
- return new ShopMenuFirestoreRepository(firestore.firestore);
346
- },
347
- deps: [AngularFirestore],
348
- },
349
- {
350
- provide: 'OrderRepository',
351
- useFactory: (firestore) => {
352
- return new OrderFirestoreRepository(firestore.firestore);
353
- },
354
- deps: [AngularFirestore],
355
- },
356
- {
357
- provide: 'PaymentRepository',
358
- useFactory: (firestore) => {
359
- return new PaymentFirestoreRepository(firestore.firestore);
360
- },
361
- deps: [AngularFirestore],
362
- },
363
- {
364
- provide: ProductFirestoreRepository,
365
- useFactory: (firestore) => {
366
- return new ProductFirestoreRepository(firestore.firestore);
367
- },
368
- deps: [AngularFirestore],
369
- },
370
- {
371
- provide: 'ShopSettingsRepository',
372
- useFactory: (firestore) => {
373
- return new ShopSettingsFirestoreRepository(firestore.firestore);
374
- },
375
- deps: [AngularFirestore],
376
- },
377
- {
378
- provide: 'SubscriptionPaymentRepository',
379
- useFactory: (firestore, subscriptionRepository) => {
380
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
381
- },
382
- deps: [AngularFirestore, 'SubscriptionRepository'],
383
- },
384
- {
385
- provide: 'SubscriptionPlanRepository',
386
- useFactory: (firestore) => {
387
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
388
- },
389
- deps: [AngularFirestore],
390
- },
391
- {
392
- provide: 'SubscriptionProductRepository',
393
- useFactory: (firestore) => {
394
- return new SubscriptionProductFirestoreRepository(firestore.firestore);
395
- },
396
- deps: [AngularFirestore],
397
- },
398
- {
399
- provide: 'SubscriptionRepository',
400
- useFactory: (firestore) => {
401
- return new SubscriptionFirestoreRepository(firestore.firestore);
402
- },
403
- deps: [AngularFirestore],
404
- },
405
- {
406
- provide: 'UserRepository',
407
- useFactory: (firestore) => {
408
- return new UserFirestoreRepository(firestore.firestore);
409
- },
410
- deps: [AngularFirestore],
411
- },
412
- {
413
- provide: 'UserAddressRepository',
414
- useFactory: (firestore, userRepository) => {
415
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
416
- },
417
- deps: [AngularFirestore, 'UserRepository'],
418
- },
419
- {
420
- provide: 'UserPaymentMethodRepository',
421
- useFactory: (firestore, userRepository) => {
422
- return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
423
- },
424
- deps: [AngularFirestore, 'UserRepository'],
425
- },
426
- {
427
- provide: 'SubscriptionMaterializationRepository',
428
- useFactory: (firestore) => {
429
- return new SubscriptionMaterializationFirestoreRepository(firestore.firestore);
430
- },
431
- deps: [AngularFirestore],
432
- },
433
- {
434
- provide: ProductVariantFirestoreRepository,
435
- useFactory: (firestore, productRepository) => {
436
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
437
- },
438
- deps: [AngularFirestore, ProductFirestoreRepository],
439
- },
440
- {
441
- provide: APP_INITIALIZER,
442
- useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
443
- deps: [AngularFirestore],
444
- multi: true,
445
- },
446
- ],
447
- }]
448
- }] });
449
-
450
- const BACKEND_URL = 'BACKEND_URL';
451
-
452
- const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
453
-
454
- const DEFAULT_SHOP = 'DEFAULT_SHOP';
455
-
456
- const HASURA_OPTIONS = 'HASURA_OPTIONS';
457
-
458
- class AngularHasuraGraphQLModule {
459
- static initializeApp(options) {
460
- return {
461
- ngModule: AngularHasuraGraphQLModule,
462
- providers: [{ provide: HASURA_OPTIONS, useValue: options }],
463
- };
464
- }
465
- }
466
- AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
467
- AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
468
- AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
469
- {
470
- provide: 'CategoryRepository',
471
- useExisting: CategoryHasuraGraphQLRepository,
472
- },
473
- {
474
- provide: CategoryHasuraGraphQLRepository,
475
- useFactory: (options, productRepository, categoryFilterRepository) => {
476
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
477
- },
478
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
479
- },
480
- {
481
- provide: 'ProductRepository',
482
- useExisting: ProductHasuraGraphQLRepository,
483
- },
484
- {
485
- provide: ProductHasuraGraphQLRepository,
486
- useFactory: (options) => {
487
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
488
- },
489
- deps: [HASURA_OPTIONS],
490
- },
491
- {
492
- provide: 'VariantRepository',
493
- useExisting: VariantHasuraGraphQLRepository,
494
- },
495
- {
496
- provide: VariantHasuraGraphQLRepository,
497
- useFactory: (options) => {
498
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
499
- },
500
- deps: [HASURA_OPTIONS],
501
- },
502
- {
503
- provide: 'CategoryFilterRepository',
504
- useExisting: CategoryFilterHasuraGraphQLRepository,
505
- },
506
- {
507
- provide: CategoryFilterHasuraGraphQLRepository,
508
- useFactory: (options) => {
509
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
510
- },
511
- deps: [HASURA_OPTIONS],
512
- },
513
- {
514
- provide: 'FilterOptionRepository',
515
- useExisting: FilterOptionHasuraGraphQLRepository,
516
- },
517
- {
518
- provide: FilterOptionHasuraGraphQLRepository,
519
- useFactory: (options) => {
520
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
521
- },
522
- deps: [HASURA_OPTIONS],
523
- },
524
- {
525
- provide: 'FilterRepository',
526
- useExisting: FilterHasuraGraphQLRepository,
527
- },
528
- {
529
- provide: FilterHasuraGraphQLRepository,
530
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
531
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
532
- },
533
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
534
- },
535
- {
536
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
537
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
538
- },
539
- {
540
- provide: 'CategoryCollectionChildrenRepository',
541
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
542
- },
543
- ] });
544
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
545
- type: NgModule,
546
- args: [{
547
- providers: [
548
- {
549
- provide: 'CategoryRepository',
550
- useExisting: CategoryHasuraGraphQLRepository,
551
- },
552
- {
553
- provide: CategoryHasuraGraphQLRepository,
554
- useFactory: (options, productRepository, categoryFilterRepository) => {
555
- return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
556
- },
557
- deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
558
- },
559
- {
560
- provide: 'ProductRepository',
561
- useExisting: ProductHasuraGraphQLRepository,
562
- },
563
- {
564
- provide: ProductHasuraGraphQLRepository,
565
- useFactory: (options) => {
566
- return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
567
- },
568
- deps: [HASURA_OPTIONS],
569
- },
570
- {
571
- provide: 'VariantRepository',
572
- useExisting: VariantHasuraGraphQLRepository,
573
- },
574
- {
575
- provide: VariantHasuraGraphQLRepository,
576
- useFactory: (options) => {
577
- return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
578
- },
579
- deps: [HASURA_OPTIONS],
580
- },
581
- {
582
- provide: 'CategoryFilterRepository',
583
- useExisting: CategoryFilterHasuraGraphQLRepository,
584
- },
585
- {
586
- provide: CategoryFilterHasuraGraphQLRepository,
587
- useFactory: (options) => {
588
- return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
589
- },
590
- deps: [HASURA_OPTIONS],
591
- },
592
- {
593
- provide: 'FilterOptionRepository',
594
- useExisting: FilterOptionHasuraGraphQLRepository,
595
- },
596
- {
597
- provide: FilterOptionHasuraGraphQLRepository,
598
- useFactory: (options) => {
599
- return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
600
- },
601
- deps: [HASURA_OPTIONS],
602
- },
603
- {
604
- provide: 'FilterRepository',
605
- useExisting: FilterHasuraGraphQLRepository,
606
- },
607
- {
608
- provide: FilterHasuraGraphQLRepository,
609
- useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
610
- return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
611
- },
612
- deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
613
- },
614
- {
615
- provide: CategoryCollectionChildrenHasuraGraphQLRepository,
616
- useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options.endpoint, options.credentials),
617
- },
618
- {
619
- provide: 'CategoryCollectionChildrenRepository',
620
- useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
621
- },
622
- ],
623
- }]
624
- }] });
625
-
626
- class AuthService {
627
- constructor(angularFireAuth, userRepository) {
628
- this.angularFireAuth = angularFireAuth;
629
- this.userRepository = userRepository;
630
- }
631
- getAuthstate() {
632
- const observables = [
633
- this.angularFireAuth.authState.pipe(catchError(() => of(null))),
634
- this.getUser().pipe(catchError(() => of(null))),
635
- ];
636
- return combineLatest(observables).pipe(map(([fireUser, user]) => {
637
- return {
638
- user,
639
- isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
640
- };
641
- }));
642
- }
643
- getUser() {
644
- 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))));
645
- }
646
- getTokenId() {
647
- return this.angularFireAuth.idToken;
648
- }
649
- getFireUser() {
650
- return this.angularFireAuth.user.pipe(catchError(() => of(null)));
651
- }
652
- }
653
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
654
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService });
655
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AuthService, decorators: [{
656
- type: Injectable
657
- }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
658
- type: Inject,
659
- args: ['UserRepository']
660
- }] }]; } });
661
-
662
- class CouponService {
663
- constructor(couponRepository, defaultShop, orderRepository, categoryRepository) {
664
- this.couponRepository = couponRepository;
665
- this.defaultShop = defaultShop;
666
- this.orderRepository = orderRepository;
667
- this.categoryRepository = categoryRepository;
668
- this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
669
- }
670
- checkCoupon(nickname, checkoutType, checkout, plan) {
671
- return from(this.couponRepository
672
- .find({
673
- filters: {
674
- nickname: { operator: Where.EQUALS, value: nickname },
675
- active: { operator: Where.EQUALS, value: true },
676
- },
677
- })
678
- .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation(couponValid, checkoutType, checkout, plan)), map((couponValidated) => couponValidated));
679
- }
680
- couponValidation(coupon, checkoutType) {
681
- return __awaiter(this, void 0, void 0, function* () {
682
- if (!coupon)
683
- throw 'Cupom inválido.';
684
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) && (coupon === null || coupon === void 0 ? void 0 : coupon.beginAt.getTime()) > new Date().getTime())
685
- throw 'Cupom inválido.';
686
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) && (coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn.getTime()) < new Date().getTime())
687
- throw 'Cupom expirado.';
688
- const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
689
- if (!isInShop)
690
- throw 'Cupom inválido para loja.';
691
- const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
692
- if (!isCheckoutType)
693
- throw 'Cupom inválido. Erro de checkout.';
694
- return coupon;
695
- });
696
- }
697
- couponRulesValidation(coupon, checkoutType, checkout, plan) {
698
- return __awaiter(this, void 0, void 0, function* () {
699
- if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
700
- if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
701
- throw 'Cupom inválido para sua assinatura.';
702
- return coupon;
703
- }
704
- const validUser = this.coupomUserValidation(coupon, checkout === null || checkout === void 0 ? void 0 : checkout.user);
705
- if (!validUser)
706
- throw 'Usuário não elegível.';
707
- const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
708
- if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
709
- const orders = yield this.getOrdersWithCoupon(coupon);
710
- if (!couponUseLimits.unlimited && couponUseLimits.total && orders.length >= couponUseLimits.total)
711
- throw 'Limite de uso atingido.';
712
- if (couponUseLimits.limitedPerUser) {
713
- const ordersWithUser = this.countOrdersWithUser(orders, checkout.user.email);
714
- if (ordersWithUser > 0)
715
- throw 'Limite de uso por usuário atingido.';
716
- }
717
- }
718
- const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
719
- if (!hasProductCategories)
720
- throw 'Seu carrinho não possui produtos elegíveis para desconto.';
721
- const hasMinSubTotal = yield this.hasMinSubTotal(coupon, checkout);
722
- if (!hasMinSubTotal)
723
- throw `Valor mínimo de ${Intl.NumberFormat('pt-BR', { style: 'currency', currency: 'BRL' }).format(coupon.minSubTotalValue)} não atingido`;
724
- return coupon;
725
- });
726
- }
727
- calcDiscountSubscription(coupon, checkout) {
728
- let discount = 0;
729
- if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
730
- discount = coupon.discount.subscription.value;
731
- else
732
- discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
733
- return of(discount);
734
- }
735
- calcDiscountShopping(coupon, checkout) {
736
- return __awaiter(this, void 0, void 0, function* () {
737
- let discount = 0;
738
- if (checkout.user.isSubscriber && coupon.discount.subscriber.value) {
739
- discount = yield this.calcDiscountByType(coupon.discount.subscriber.type, coupon.discount.subscriber.value, coupon.productsCategories, checkout);
740
- }
741
- else {
742
- discount = yield this.calcDiscountByType(coupon.discount.non_subscriber.type, coupon.discount.non_subscriber.value, coupon.productsCategories, checkout);
743
- }
744
- return discount;
745
- });
746
- }
747
- calcDiscountByType(type, value, categories, checkout) {
748
- return __awaiter(this, void 0, void 0, function* () {
749
- let discount = 0;
750
- let lineItensDiscount = yield this.getLineItensEligebleForDiscount(categories, checkout);
751
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
752
- if (type == CouponTypes.ABSOLUTE) {
753
- discount = value > subTotal ? subTotal : value;
754
- }
755
- else {
756
- discount = subTotal * (value / 100);
757
- }
758
- return discount;
759
- });
760
- }
761
- hasMinSubTotal(coupon, checkout) {
762
- return __awaiter(this, void 0, void 0, function* () {
763
- if (!coupon.minSubTotalValue)
764
- return true;
765
- let lineItensDiscount = yield this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
766
- const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user, checkout.shop);
767
- if (coupon.minSubTotalValue <= subTotal)
768
- return true;
769
- return false;
770
- });
771
- }
772
- hasProductCategories(coupon, checkout) {
773
- var _a;
774
- return __awaiter(this, void 0, void 0, function* () {
775
- if (!coupon.productsCategories || !coupon.productsCategories.length) {
776
- return true;
777
- }
778
- const couponCategories = yield this.getCouponCategoriesId(coupon.productsCategories);
779
- const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
780
- var _a;
781
- if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
782
- return true;
783
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
784
- });
785
- return hasCategories.length ? true : false;
786
- });
787
- }
788
- coupomUserValidation(coupon, user) {
789
- if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
790
- return true;
791
- let userTypes = [];
792
- if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) && this.emailIsFromCollaborator(user.email))
793
- userTypes.push(Exclusivities.COLLABORATORS);
794
- if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) && coupon.userExclusiveEmail.includes(user.email))
795
- userTypes.push(Exclusivities.SPECIFIC_USER);
796
- if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
797
- user.isSubscriber &&
798
- user.subscriptionPlan != '')
799
- userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
800
- if (user.isSubscriber &&
801
- user.subscriptionPlan == '' &&
802
- coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
803
- userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
804
- if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
805
- userTypes.push(Exclusivities.NON_SUBSCRIBER);
806
- return coupon.exclusivityType.some((r) => userTypes.includes(r));
807
- }
808
- getCouponCategoriesId(productsCategories) {
809
- return __awaiter(this, void 0, void 0, function* () {
810
- const couponCategories = [];
811
- for (let index = 0; index < productsCategories.length; index++) {
812
- const category = yield this.categoryRepository.get({
813
- id: productsCategories[index],
814
- });
815
- if (category) {
816
- const children = yield this.categoryRepository.getChildren(parseInt(productsCategories[index]));
817
- couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
818
- }
819
- }
820
- return [...new Set(couponCategories)];
821
- });
822
- }
823
- getLineItensEligebleForDiscount(productsCategories, checkout) {
824
- var _a;
825
- return __awaiter(this, void 0, void 0, function* () {
826
- let lineItensDiscount = [];
827
- const couponCategories = yield this.getCouponCategoriesId(productsCategories);
828
- if (productsCategories && productsCategories.length) {
829
- lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
830
- var _a;
831
- if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
832
- return i.categories.some((c) => couponCategories.some((cat) => cat == c));
833
- }
834
- return true;
835
- });
836
- }
837
- else {
838
- lineItensDiscount = checkout.lineItems;
839
- }
840
- return lineItensDiscount;
841
- });
842
- }
843
- calcCheckoutSubtotal(lineItens, user, shop) {
844
- return ((lineItens === null || lineItens === void 0 ? void 0 : lineItens.reduce((acc, curr) => {
845
- var _a, _b;
846
- return (user === null || user === void 0 ? void 0 : user.isSubscriber) && ((_a = curr.price[shop]) === null || _a === void 0 ? void 0 : _a.subscriberPrice)
847
- ? acc + ((_b = curr.price[shop]) === null || _b === void 0 ? void 0 : _b.subscriberPrice) * curr.quantity
848
- : acc + curr.pricePaid * curr.quantity;
849
- }, 0)) || 0);
850
- }
851
- getOrdersWithCoupon(coupon) {
852
- return __awaiter(this, void 0, void 0, function* () {
853
- return yield this.orderRepository
854
- .find({
855
- filters: {
856
- coupon: { id: coupon.id },
857
- payment: { status: 'paid' },
858
- },
859
- })
860
- .then((result) => result.data);
861
- });
862
- }
863
- countOrdersWithUser(orders, email) {
864
- return orders.filter((o) => o.user.email == email).length;
865
- }
866
- getCouponUseLimits(coupon, checkoutType, user) {
867
- let couponUseLimits;
868
- if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
869
- couponUseLimits = user && user.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
870
- }
871
- else {
872
- couponUseLimits = coupon.useLimits.subscription;
873
- }
874
- return couponUseLimits;
875
- }
876
- }
877
- CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
878
- CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, providedIn: 'root' });
879
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CouponService, decorators: [{
880
- type: Injectable,
881
- args: [{
882
- providedIn: 'root',
883
- }]
884
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
885
- type: Inject,
886
- args: ['CouponRepository']
887
- }] }, { type: i1$1.Shops, decorators: [{
888
- type: Inject,
889
- args: [DEFAULT_SHOP]
890
- }] }, { type: undefined, decorators: [{
891
- type: Inject,
892
- args: ['OrderRepository']
893
- }] }, { type: undefined, decorators: [{
894
- type: Inject,
895
- args: ['CategoryRepository']
896
- }] }]; } });
897
-
898
- class CheckoutService {
899
- constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
900
- this.couponService = couponService;
901
- this.checkoutRepository = checkoutRepository;
902
- this.orderRepository = orderRepository;
903
- this.userRepository = userRepository;
904
- this.defaultShop = defaultShop;
905
- }
906
- getCheckout(checkoutData) {
907
- const checkoutId = cookie.get('checkoutId');
908
- if (!isNil(checkoutId))
909
- return from(this.checkoutRepository.get({ id: checkoutId }));
910
- return from(this.createCheckout(checkoutData));
911
- }
912
- getUserByCheckout(checkoutId) {
913
- 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'))));
914
- }
915
- updateCheckoutLineItems(checkout) {
916
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
917
- }
918
- updateCheckoutUser(checkout) {
919
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
920
- }
921
- clearCheckoutFromSession() {
922
- cookie.remove('checkoutId');
923
- return of();
924
- }
925
- calcDiscount(coupon) {
926
- return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
927
- }
928
- checkCoupon(nickname, checkoutType) {
929
- return this.getCheckout().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, CheckoutTypes.ECOMMERCE, checkout, null).pipe()));
930
- }
931
- createCheckout(checkoutData) {
932
- return __awaiter(this, void 0, void 0, function* () {
933
- 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 }));
934
- cookie.set('checkoutId', checkout.id);
935
- return checkout;
936
- });
315
+ class CheckoutService {
316
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
317
+ this.couponService = couponService;
318
+ this.checkoutRepository = checkoutRepository;
319
+ this.orderRepository = orderRepository;
320
+ this.userRepository = userRepository;
321
+ this.defaultShop = defaultShop;
322
+ }
323
+ getCheckout(checkoutData) {
324
+ const checkoutId = cookie.get('checkoutId');
325
+ if (!isNil(checkoutId))
326
+ return from(this.checkoutRepository.get({ id: checkoutId }));
327
+ return from(this.createCheckout(checkoutData));
328
+ }
329
+ getUserByCheckout(checkoutId) {
330
+ 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'))));
331
+ }
332
+ updateCheckoutLineItems(checkout) {
333
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
334
+ }
335
+ updateCheckoutUser(checkout) {
336
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
337
+ }
338
+ clearCheckoutFromSession() {
339
+ cookie.remove('checkoutId');
340
+ return of();
341
+ }
342
+ calcDiscount(coupon) {
343
+ return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
344
+ }
345
+ checkCoupon(nickname, checkoutType) {
346
+ return this.getCheckout().pipe(concatMap((checkout) => {
347
+ var _a;
348
+ return this.couponService
349
+ .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
350
+ .pipe();
351
+ }));
352
+ }
353
+ createCheckout(checkoutData) {
354
+ return __awaiter(this, void 0, void 0, function* () {
355
+ 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 }));
356
+ cookie.set('checkoutId', checkout.id);
357
+ return checkout;
358
+ });
937
359
  }
938
360
  }
939
361
  CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
@@ -949,18 +371,17 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
949
371
  }] }, { type: undefined, decorators: [{
950
372
  type: Inject,
951
373
  args: ['UserRepository']
952
- }] }, { type: i1$1.Shops, decorators: [{
374
+ }] }, { type: i3.Shops, decorators: [{
953
375
  type: Inject,
954
376
  args: [DEFAULT_SHOP]
955
377
  }] }]; } });
956
378
 
957
379
  class CartService {
958
- constructor(authService, checkoutService, defaultShop, productRepository, categoryRepository, variantRepository, buy2WinRepository) {
380
+ constructor(authService, checkoutService, defaultShop, productRepository, variantRepository, buy2WinRepository) {
959
381
  this.authService = authService;
960
382
  this.checkoutService = checkoutService;
961
383
  this.defaultShop = defaultShop;
962
384
  this.productRepository = productRepository;
963
- this.categoryRepository = categoryRepository;
964
385
  this.variantRepository = variantRepository;
965
386
  this.buy2WinRepository = buy2WinRepository;
966
387
  this.cartSubject = new Subject();
@@ -998,7 +419,6 @@ class CartService {
998
419
  shop: checkout.shop || this.defaultShop,
999
420
  isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
1000
421
  });
1001
- RoundProductPricesHelper.roundProductPrices(item);
1002
422
  return {
1003
423
  checkout,
1004
424
  lineItem: LineItem.toInstance({
@@ -1009,7 +429,7 @@ class CartService {
1009
429
  slug: slug !== null && slug !== void 0 ? slug : product.slug,
1010
430
  sku: sku !== null && sku !== void 0 ? sku : product.sku,
1011
431
  stock,
1012
- price: this.roundPrice(price),
432
+ price,
1013
433
  image,
1014
434
  weight: weight !== null && weight !== void 0 ? weight : product.weight,
1015
435
  quantity: (item.quantity || 0) + (quantity || 0),
@@ -1086,8 +506,9 @@ class CartService {
1086
506
  return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1087
507
  }
1088
508
  roundPrice(productPrice) {
1089
- const { price, fullPrice, subscriberPrice } = productPrice;
1090
- return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(fullPrice.toFixed(2)) }), (subscriberPrice && { subscriberPrice: Number(subscriberPrice.toFixed(2)) }));
509
+ const { price, fullPrice } = productPrice;
510
+ const round = (value) => Math.round((value + Number.EPSILON) * 100) / 100;
511
+ return Object.assign(Object.assign(Object.assign({}, productPrice), { price: Number(price.toFixed(2)), fullPrice: Number(price.toFixed(2)) }), (productPrice.subscriberPrice && { subscriberPrice: Number(productPrice.subscriberPrice.toFixed(2)) }));
1091
512
  }
1092
513
  getProductData(productId) {
1093
514
  return __awaiter(this, void 0, void 0, function* () {
@@ -1099,10 +520,7 @@ class CartService {
1099
520
  catch (error) {
1100
521
  if (!(error instanceof NotFoundError))
1101
522
  throw error;
1102
- const { data: variants } = yield this.variantRepository.find({ filters: { id: productId } });
1103
- variant = variants.shift();
1104
- if (!variant)
1105
- throw error;
523
+ variant = yield this.variantRepository.get({ id: productId });
1106
524
  product = yield this.productRepository.get({ id: variant.productId });
1107
525
  }
1108
526
  return Object.assign(Object.assign({}, product.toPlain()), (variant && Object.assign({}, variant.toPlain())));
@@ -1126,22 +544,16 @@ class CartService {
1126
544
  return Object.assign(Object.assign({}, checkout), { lineItems: notGiftItems });
1127
545
  const elegibleCampaigns = [];
1128
546
  for (const campaign of campaigns) {
1129
- const today = new Date().getDate();
1130
- if (!(campaign.startDate.getDate() <= today) && !(campaign.endDate.getDate() >= today))
547
+ const today = new Date();
548
+ if (!(campaign.startDate <= today) && !(campaign.endDate >= today))
1131
549
  continue;
1132
550
  if (campaign.activeCategory) {
1133
- const categoriesCampaing = campaign.categories.map((c) => c.id.toString());
1134
- const categoriesCampaingFullTree = [];
1135
- for (const id of categoriesCampaing) {
1136
- const children = yield this.categoryRepository.getChildren(parseInt(id));
1137
- categoriesCampaingFullTree.push(id, ...children.map((c) => c.id.toString()));
1138
- }
1139
- const categoriesCampaingTree = [...new Set(categoriesCampaingFullTree)];
551
+ const categoriesCampaing = campaign.categories.map((c) => c.id);
1140
552
  const filterProductsCategories = checkout.lineItems.filter((l) => {
1141
553
  var _a;
1142
554
  if (!l.categories || !((_a = l.categories) === null || _a === void 0 ? void 0 : _a.length))
1143
555
  return true;
1144
- return l.categories.some((c) => categoriesCampaingTree.some((cat) => cat == c));
556
+ return l.categories.some((c) => categoriesCampaing.some((cat) => cat == c));
1145
557
  });
1146
558
  if (filterProductsCategories.length) {
1147
559
  const cartTotalCategories = filterProductsCategories.reduce((a, b) => a + b.pricePaid * b.quantity, 0);
@@ -1202,185 +614,24 @@ class CartService {
1202
614
  });
1203
615
  }
1204
616
  }
1205
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
617
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }, { token: 'VariantRepository' }, { token: 'Buy2WinRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1206
618
  CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService });
1207
619
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CartService, decorators: [{
1208
620
  type: Injectable
1209
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
621
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i3.Shops, decorators: [{
1210
622
  type: Inject,
1211
623
  args: [DEFAULT_SHOP]
1212
624
  }] }, { type: undefined, decorators: [{
1213
625
  type: Inject,
1214
626
  args: ['ProductRepository']
1215
- }] }, { type: undefined, decorators: [{
1216
- type: Inject,
1217
- args: ['CategoryRepository']
1218
627
  }] }, { type: undefined, decorators: [{
1219
628
  type: Inject,
1220
629
  args: ['VariantRepository']
1221
- }] }, { type: i1$1.Buy2WinFirestoreRepository, decorators: [{
630
+ }] }, { type: i3.Buy2WinFirestoreRepository, decorators: [{
1222
631
  type: Inject,
1223
632
  args: ['Buy2WinRepository']
1224
633
  }] }]; } });
1225
634
 
1226
- class CatalogService {
1227
- constructor(productRepository, categoryStructureAdapter, shop) {
1228
- this.productRepository = productRepository;
1229
- this.categoryStructureAdapter = categoryStructureAdapter;
1230
- this.shop = shop;
1231
- this.buildFilterQuery = ({ clubDiscount, brands, prices, gender, tags, rate, customOptions, }) => {
1232
- const filters = {};
1233
- if (clubDiscount === null || clubDiscount === void 0 ? void 0 : clubDiscount.length)
1234
- set(filters, 'price.subscriberDiscountPercentage', { operator: Where.IN, value: clubDiscount });
1235
- if (brands === null || brands === void 0 ? void 0 : brands.length)
1236
- filters.brand = { operator: Where.IN, value: brands };
1237
- if (gender === null || gender === void 0 ? void 0 : gender.length)
1238
- filters.tags = {
1239
- operator: Where.IN,
1240
- value: gender
1241
- .map((genderOptions) => genderOptions === 'female' ? 'feminino' : genderOptions === 'male' ? 'masculino' : null)
1242
- .filter(Boolean),
1243
- };
1244
- if ((prices === null || prices === void 0 ? void 0 : prices.min) || (prices === null || prices === void 0 ? void 0 : prices.max))
1245
- set(filters, prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price', [
1246
- ...(prices.min ? [{ operator: Where.GTE, value: Math.round(prices.min) }] : []),
1247
- ...(prices.max ? [{ operator: Where.LTE, value: Math.ceil(prices.max) }] : []),
1248
- ]);
1249
- if (rate)
1250
- filters.rate = { operator: Where.GTE, value: rate };
1251
- if (tags === null || tags === void 0 ? void 0 : tags.length)
1252
- filters.tags = { operator: Where.LIKE, value: tags };
1253
- if (customOptions === null || customOptions === void 0 ? void 0 : customOptions.length)
1254
- filters.filters = { operator: Where.LIKE, value: customOptions };
1255
- return filters;
1256
- };
1257
- this.buildSortQuery = (sort) => {
1258
- if (!sort || sort === 'most-relevant')
1259
- return {};
1260
- if (sort === 'best-sellers')
1261
- return { shoppingCount: 'desc' };
1262
- if (sort === 'biggest-price')
1263
- return { price: 'desc' };
1264
- if (sort === 'lowest-price')
1265
- return { price: 'asc' };
1266
- if (sort === 'best-rating')
1267
- return { rate: 'desc' };
1268
- if (sort === 'news')
1269
- return { createdAt: 'desc' };
1270
- };
1271
- this.buildLimitQuery = (options) => {
1272
- const limit = (options === null || options === void 0 ? void 0 : options.perPage) || 20;
1273
- return {
1274
- limit,
1275
- offset: (((options === null || options === void 0 ? void 0 : options.page) || 1) - 1) * limit,
1276
- };
1277
- };
1278
- }
1279
- fetchProducts(category, options) {
1280
- return __awaiter(this, void 0, void 0, function* () {
1281
- const limits = this.buildLimitQuery(options);
1282
- return yield this.productRepository
1283
- .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')
1284
- .then(({ data, count: total, maximum, minimal }) => {
1285
- var _a, _b, _c, _d, _e, _f, _g, _h;
1286
- return ({
1287
- products: { data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)), total },
1288
- pages: Math.ceil(total / limits.limit),
1289
- prices: {
1290
- 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)) },
1291
- subscriberPrice: {
1292
- 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)),
1293
- 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)),
1294
- },
1295
- },
1296
- });
1297
- });
1298
- });
1299
- }
1300
- }
1301
- CatalogService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1302
- CatalogService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService });
1303
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CatalogService, decorators: [{
1304
- type: Injectable
1305
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1306
- type: Inject,
1307
- args: ['ProductRepository']
1308
- }] }, { type: undefined, decorators: [{
1309
- type: Inject,
1310
- args: [CATEGORY_STRUCTURE]
1311
- }] }, { type: i1$1.Shops, decorators: [{
1312
- type: Inject,
1313
- args: [DEFAULT_SHOP]
1314
- }] }]; } });
1315
-
1316
- class CategoryService {
1317
- constructor(productRepository, categoryRepository, categoryFilterRepository, categoryStructureAdapter, shop) {
1318
- this.productRepository = productRepository;
1319
- this.categoryRepository = categoryRepository;
1320
- this.categoryFilterRepository = categoryFilterRepository;
1321
- this.categoryStructureAdapter = categoryStructureAdapter;
1322
- this.shop = shop;
1323
- }
1324
- fetchBrands(category, mainGender) {
1325
- return __awaiter(this, void 0, void 0, function* () {
1326
- const brands = yield this.productRepository
1327
- .findCatalog({
1328
- filters: yield this.categoryStructureAdapter.buildProductFilterByCategory(category),
1329
- fields: ['brand'],
1330
- }, mainGender || this.shop === Shops.MENSMARKET ? 'male' : 'female')
1331
- .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => (Object.assign(Object.assign({}, brands), { [brand]: true })), {})));
1332
- return this.categoryRepository
1333
- .find({ filters: { brandCategory: true }, orderBy: { name: 'asc' } })
1334
- .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1335
- });
1336
- }
1337
- fetchFilterOptions(category, filters) {
1338
- return __awaiter(this, void 0, void 0, function* () {
1339
- return yield this.categoryFilterRepository
1340
- .find({ filters: { categoryId: +category.id } })
1341
- .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1342
- });
1343
- }
1344
- }
1345
- CategoryService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CategoryService, deps: [{ token: 'ProductRepository' }, { token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }, { token: CATEGORY_STRUCTURE }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
1346
- CategoryService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CategoryService });
1347
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: CategoryService, decorators: [{
1348
- type: Injectable
1349
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1350
- type: Inject,
1351
- args: ['ProductRepository']
1352
- }] }, { type: undefined, decorators: [{
1353
- type: Inject,
1354
- args: ['CategoryRepository']
1355
- }] }, { type: undefined, decorators: [{
1356
- type: Inject,
1357
- args: ['CategoryFilterRepository']
1358
- }] }, { type: undefined, decorators: [{
1359
- type: Inject,
1360
- args: [CATEGORY_STRUCTURE]
1361
- }] }, { type: i1$1.Shops, decorators: [{
1362
- type: Inject,
1363
- args: [DEFAULT_SHOP]
1364
- }] }]; } });
1365
-
1366
- var ProductSorts;
1367
- (function (ProductSorts) {
1368
- ProductSorts["MOST_RELEVANT"] = "most-relevant";
1369
- ProductSorts["BEST_SELLER"] = "best-sellers";
1370
- ProductSorts["BIGGEST_PRICE"] = "biggest-price";
1371
- ProductSorts["LOWEST_PRICE"] = "lowest-price";
1372
- ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
1373
- ProductSorts["BEST_RATING"] = "best-rating";
1374
- ProductSorts["NEWS"] = "news";
1375
- })(ProductSorts || (ProductSorts = {}));
1376
-
1377
- class CategoryWithTree extends Category {
1378
- }
1379
- __decorate([
1380
- Type(() => CategoryWithTree),
1381
- __metadata("design:type", Array)
1382
- ], CategoryWithTree.prototype, "children", void 0);
1383
-
1384
635
  class CheckoutSubscriptionService {
1385
636
  constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
1386
637
  this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
@@ -1406,7 +657,7 @@ class CheckoutSubscriptionService {
1406
657
  }
1407
658
  checkCoupon(nickname, userEmail) {
1408
659
  return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
1409
- .checkCoupon(nickname, CheckoutTypes.SUBSCRIPTION, checkout, checkout.subscriptionPlan.name)
660
+ .checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, checkout, true)
1410
661
  .pipe()));
1411
662
  }
1412
663
  calcDiscountSubscription(coupon) {
@@ -1529,7 +780,7 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImpo
1529
780
  }] }, { type: undefined, decorators: [{
1530
781
  type: Inject,
1531
782
  args: ['ProductRepository']
1532
- }] }, { type: i1$1.Shops, decorators: [{
783
+ }] }, { type: i3.Shops, decorators: [{
1533
784
  type: Inject,
1534
785
  args: [DEFAULT_SHOP]
1535
786
  }] }]; } });
@@ -1549,11 +800,11 @@ class OrderService {
1549
800
  return this.orderSubject;
1550
801
  }
1551
802
  }
1552
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
803
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, deps: [{ token: i1$1.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1553
804
  OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService });
1554
805
  i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OrderService, decorators: [{
1555
806
  type: Injectable
1556
- }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
807
+ }], ctorParameters: function () { return [{ type: i1$1.AngularFirestore }, { type: i3.OrderFirestoreRepository, decorators: [{
1557
808
  type: Inject,
1558
809
  args: ['OrderRepository']
1559
810
  }] }]; } });
@@ -1637,250 +888,739 @@ class ShippingService {
1637
888
  return false;
1638
889
  }
1639
890
  }
1640
- ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$3.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
1641
- ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
1642
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
1643
- type: Injectable
1644
- }], ctorParameters: function () { return [{ type: i1$3.HttpClient }, { type: undefined, decorators: [{
1645
- type: Inject,
1646
- args: [BACKEND_URL]
1647
- }] }, { type: HomeShopService }]; } });
1648
-
1649
- class NewCategoryStructureAdapter {
1650
- constructor(categoryRepository, categoryCollectionChildrenRepository) {
1651
- this.categoryRepository = categoryRepository;
1652
- this.categoryCollectionChildrenRepository = categoryCollectionChildrenRepository;
1653
- }
1654
- buildProductFilterByCategory(category) {
1655
- return __awaiter(this, void 0, void 0, function* () {
1656
- const categoriesIds = (yield this.isCollection(category))
1657
- ? yield this.getAllCategoriesIdFromCollection(category)
1658
- : [...(yield this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1659
- return { category: { id: { operator: Where.IN, value: categoriesIds } } };
1660
- });
1661
- }
1662
- getAllCategoriesIdFromCategory(category) {
1663
- return __awaiter(this, void 0, void 0, function* () {
1664
- return this.categoryRepository
1665
- .getChildren(+category.id)
1666
- .then((categories) => categories.map((category) => category.id.toString()));
1667
- });
1668
- }
1669
- getAllCategoriesIdFromCollection(category) {
1670
- return __awaiter(this, void 0, void 0, function* () {
1671
- return this.categoryCollectionChildrenRepository
1672
- .find({ filters: { collectionId: +category.id } })
1673
- .then(({ data }) => data.map((categoryCollection) => categoryCollection.categoryId.toString()));
1674
- });
1675
- }
1676
- isCollection(category) {
1677
- return __awaiter(this, void 0, void 0, function* () {
1678
- return !isNil(category.isCollection)
1679
- ? category.isCollection
1680
- : this.categoryRepository.get({ id: category.id }).then((category) => category.isCollection);
1681
- });
1682
- }
1683
- }
1684
- NewCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryCollectionChildrenRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1685
- NewCategoryStructureAdapter.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter });
1686
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
891
+ ShippingService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, deps: [{ token: i1$2.HttpClient }, { token: BACKEND_URL }, { token: HomeShopService }], target: i0.ɵɵFactoryTarget.Injectable });
892
+ ShippingService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService });
893
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: ShippingService, decorators: [{
1687
894
  type: Injectable
1688
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1689
- type: Inject,
1690
- args: ['CategoryRepository']
1691
- }] }, { type: undefined, decorators: [{
895
+ }], ctorParameters: function () { return [{ type: i1$2.HttpClient }, { type: undefined, decorators: [{
1692
896
  type: Inject,
1693
- args: ['CategoryCollectionChildrenRepository']
1694
- }] }]; } });
897
+ args: [BACKEND_URL]
898
+ }] }, { type: HomeShopService }]; } });
1695
899
 
1696
- class OldCategoryStructureAdapter {
1697
- constructor(categoryRepository) {
1698
- this.categoryRepository = categoryRepository;
900
+ class AngularFirebaseAuthModule {
901
+ static initializeApp(options, nameOrConfig) {
902
+ return {
903
+ ngModule: AngularFirebaseAuthModule,
904
+ providers: [
905
+ { provide: FIREBASE_OPTIONS, useValue: options },
906
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
907
+ ],
908
+ };
1699
909
  }
1700
- buildProductFilterByCategory(category) {
1701
- var _a;
1702
- return __awaiter(this, void 0, void 0, function* () {
1703
- const productsIds = ((_a = category.products) === null || _a === void 0 ? void 0 : _a.length)
1704
- ? category.products
1705
- : yield this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1706
- return { id: { operator: Where.IN, value: productsIds } };
1707
- });
910
+ }
911
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
912
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
913
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
914
+ {
915
+ provide: 'Authentication',
916
+ useFactory: (authenticationService, userRepository) => {
917
+ return new Authentication(authenticationService, userRepository);
918
+ },
919
+ deps: ['AuthenticationService', 'UserRepository'],
920
+ },
921
+ {
922
+ provide: 'AuthenticationService',
923
+ useFactory: (angularFireAuth) => {
924
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
925
+ },
926
+ deps: [AngularFireAuth],
927
+ },
928
+ {
929
+ provide: 'Register',
930
+ useFactory: (registerService, userRepository) => {
931
+ return new Register(registerService, userRepository);
932
+ },
933
+ deps: ['RegisterService', 'UserRepository'],
934
+ },
935
+ {
936
+ provide: 'RegisterService',
937
+ useFactory: (angularFireAuth) => {
938
+ return new RegisterFirebaseAuthService(angularFireAuth);
939
+ },
940
+ deps: [AngularFireAuth],
941
+ },
942
+ {
943
+ provide: 'SignOut',
944
+ useFactory: (authenticationService) => {
945
+ return new SignOut(authenticationService);
946
+ },
947
+ deps: ['AuthenticationService'],
948
+ },
949
+ {
950
+ provide: 'RecoveryPassword',
951
+ useFactory: (authenticationService) => {
952
+ return new RecoveryPassword(authenticationService);
953
+ },
954
+ deps: ['AuthenticationService'],
955
+ },
956
+ ], imports: [[AngularFireModule]] });
957
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
958
+ type: NgModule,
959
+ args: [{
960
+ imports: [AngularFireModule],
961
+ providers: [
962
+ {
963
+ provide: 'Authentication',
964
+ useFactory: (authenticationService, userRepository) => {
965
+ return new Authentication(authenticationService, userRepository);
966
+ },
967
+ deps: ['AuthenticationService', 'UserRepository'],
968
+ },
969
+ {
970
+ provide: 'AuthenticationService',
971
+ useFactory: (angularFireAuth) => {
972
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
973
+ },
974
+ deps: [AngularFireAuth],
975
+ },
976
+ {
977
+ provide: 'Register',
978
+ useFactory: (registerService, userRepository) => {
979
+ return new Register(registerService, userRepository);
980
+ },
981
+ deps: ['RegisterService', 'UserRepository'],
982
+ },
983
+ {
984
+ provide: 'RegisterService',
985
+ useFactory: (angularFireAuth) => {
986
+ return new RegisterFirebaseAuthService(angularFireAuth);
987
+ },
988
+ deps: [AngularFireAuth],
989
+ },
990
+ {
991
+ provide: 'SignOut',
992
+ useFactory: (authenticationService) => {
993
+ return new SignOut(authenticationService);
994
+ },
995
+ deps: ['AuthenticationService'],
996
+ },
997
+ {
998
+ provide: 'RecoveryPassword',
999
+ useFactory: (authenticationService) => {
1000
+ return new RecoveryPassword(authenticationService);
1001
+ },
1002
+ deps: ['AuthenticationService'],
1003
+ },
1004
+ ],
1005
+ }]
1006
+ }] });
1007
+
1008
+ class AngularElasticSeachModule {
1009
+ static initializeApp(options) {
1010
+ return {
1011
+ ngModule: AngularElasticSeachModule,
1012
+ providers: [{ provide: ES_CONFIG, useValue: options }],
1013
+ };
1708
1014
  }
1709
1015
  }
1710
- OldCategoryStructureAdapter.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
1711
- OldCategoryStructureAdapterprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter });
1712
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1713
- type: Injectable
1714
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
1715
- type: Inject,
1716
- args: ['CategoryRepository']
1717
- }] }]; } });
1016
+ AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1017
+ AngularElasticSeachModulemod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule });
1018
+ AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, providers: [
1019
+ {
1020
+ provide: ProductsIndex,
1021
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
1022
+ deps: [ES_CONFIG],
1023
+ },
1024
+ ] });
1025
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
1026
+ type: NgModule,
1027
+ args: [{
1028
+ providers: [
1029
+ {
1030
+ provide: ProductsIndex,
1031
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
1032
+ deps: [ES_CONFIG],
1033
+ },
1034
+ ],
1035
+ }]
1036
+ }] });
1718
1037
 
1719
- class AngularConnectModule {
1720
- static initializeApp(defaultShop, options, nameOrConfig) {
1038
+ class AngularFirestoreModule {
1039
+ static initializeApp(options, nameOrConfig) {
1721
1040
  return {
1722
- ngModule: AngularConnectModule,
1041
+ ngModule: AngularFirestoreModule,
1723
1042
  providers: [
1724
- {
1725
- provide: CATEGORY_STRUCTURE,
1726
- useClass: isNil(options === null || options === void 0 ? void 0 : options.oldCategoryStructure) || (options === null || options === void 0 ? void 0 : options.oldCategoryStructure)
1727
- ? OldCategoryStructureAdapter
1728
- : NewCategoryStructureAdapter,
1729
- },
1730
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1731
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1732
- ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1733
- ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1734
- ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1735
- ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1043
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
1044
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
1045
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
1736
1046
  ],
1737
1047
  };
1738
1048
  }
1739
1049
  }
1740
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1741
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1742
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1743
- AuthService,
1744
- CartService,
1745
- CatalogService,
1746
- CategoryService,
1747
- CheckoutService,
1748
- CheckoutSubscriptionService,
1749
- CouponService,
1750
- HomeShopService,
1751
- OrderService,
1752
- ShippingService,
1753
- ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1754
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1050
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1051
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule, AngularElasticSeachModule] });
1052
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, providers: [
1053
+ {
1054
+ provide: 'BeautyProfileRepository',
1055
+ useFactory: (firestore, userRepository) => {
1056
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1057
+ },
1058
+ deps: [AngularFirestore, 'UserRepository'],
1059
+ },
1060
+ {
1061
+ provide: 'Buy2WinRepository',
1062
+ useFactory: (firestore) => {
1063
+ return new Buy2WinFirestoreRepository(firestore.firestore);
1064
+ },
1065
+ deps: [AngularFirestore],
1066
+ },
1067
+ {
1068
+ provide: CategoryFirestoreRepository,
1069
+ useFactory: (firestore) => {
1070
+ return new CategoryFirestoreRepository(firestore.firestore);
1071
+ },
1072
+ deps: [AngularFirestore],
1073
+ },
1074
+ {
1075
+ provide: 'CheckoutRepository',
1076
+ useFactory: (firestore) => {
1077
+ return new CheckoutFirestoreRepository(firestore.firestore);
1078
+ },
1079
+ deps: [AngularFirestore],
1080
+ },
1081
+ {
1082
+ provide: 'CheckoutSubscriptionRepository',
1083
+ useFactory: (firestore) => {
1084
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1085
+ },
1086
+ deps: [AngularFirestore],
1087
+ },
1088
+ {
1089
+ provide: 'CouponRepository',
1090
+ useFactory: (firestore) => {
1091
+ return new CouponFirestoreRepository(firestore.firestore);
1092
+ },
1093
+ deps: [AngularFirestore],
1094
+ },
1095
+ {
1096
+ provide: 'CampaignHashtagRepository',
1097
+ useFactory: (firestore) => {
1098
+ return new CampaignHashtagFirestoreRepository(firestore.firestore);
1099
+ },
1100
+ deps: [AngularFirestore],
1101
+ },
1102
+ {
1103
+ provide: 'CampaignDashboardRepository',
1104
+ useFactory: (firestore) => {
1105
+ return new CampaignDashboardFirestoreRepository(firestore.firestore);
1106
+ },
1107
+ deps: [AngularFirestore],
1108
+ },
1109
+ {
1110
+ provide: 'EditionRepository',
1111
+ useFactory: (firestore, subscriptionRepository) => {
1112
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1113
+ },
1114
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1115
+ },
1116
+ {
1117
+ provide: 'HomeRepository',
1118
+ useFactory: (firestore) => {
1119
+ return new HomeFirestoreRepository(firestore.firestore);
1120
+ },
1121
+ deps: [AngularFirestore],
1122
+ },
1123
+ {
1124
+ provide: 'LeadRepository',
1125
+ useFactory: (firestore) => {
1126
+ return new LeadFirestoreRepository(firestore.firestore);
1127
+ },
1128
+ deps: [AngularFirestore],
1129
+ },
1130
+ {
1131
+ provide: 'LegacyOrderRepository',
1132
+ useFactory: (firestore) => {
1133
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
1134
+ },
1135
+ deps: [AngularFirestore],
1136
+ },
1137
+ {
1138
+ provide: 'ShopMenuRepository',
1139
+ useFactory: (firestore) => {
1140
+ return new ShopMenuFirestoreRepository(firestore.firestore);
1141
+ },
1142
+ deps: [AngularFirestore],
1143
+ },
1144
+ {
1145
+ provide: 'OrderRepository',
1146
+ useFactory: (firestore) => {
1147
+ return new OrderFirestoreRepository(firestore.firestore);
1148
+ },
1149
+ deps: [AngularFirestore],
1150
+ },
1151
+ {
1152
+ provide: 'PaymentRepository',
1153
+ useFactory: (firestore) => {
1154
+ return new PaymentFirestoreRepository(firestore.firestore);
1155
+ },
1156
+ deps: [AngularFirestore],
1157
+ },
1158
+ {
1159
+ provide: ProductFirestoreRepository,
1160
+ useFactory: (firestore) => {
1161
+ return new ProductFirestoreRepository(firestore.firestore);
1162
+ },
1163
+ deps: [AngularFirestore],
1164
+ },
1165
+ {
1166
+ provide: 'ShopSettingsRepository',
1167
+ useFactory: (firestore) => {
1168
+ return new ShopSettingsFirestoreRepository(firestore.firestore);
1169
+ },
1170
+ deps: [AngularFirestore],
1171
+ },
1172
+ {
1173
+ provide: 'SubscriptionPaymentRepository',
1174
+ useFactory: (firestore, subscriptionRepository) => {
1175
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1176
+ },
1177
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1178
+ },
1179
+ {
1180
+ provide: 'SubscriptionPlanRepository',
1181
+ useFactory: (firestore) => {
1182
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1183
+ },
1184
+ deps: [AngularFirestore],
1185
+ },
1186
+ {
1187
+ provide: 'SubscriptionProductRepository',
1188
+ useFactory: (firestore) => {
1189
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
1190
+ },
1191
+ deps: [AngularFirestore],
1192
+ },
1193
+ {
1194
+ provide: 'SubscriptionRepository',
1195
+ useFactory: (firestore) => {
1196
+ return new SubscriptionFirestoreRepository(firestore.firestore);
1197
+ },
1198
+ deps: [AngularFirestore],
1199
+ },
1200
+ {
1201
+ provide: 'UserRepository',
1202
+ useFactory: (firestore) => {
1203
+ return new UserFirestoreRepository(firestore.firestore);
1204
+ },
1205
+ deps: [AngularFirestore],
1206
+ },
1207
+ {
1208
+ provide: 'UserAddressRepository',
1209
+ useFactory: (firestore, userRepository) => {
1210
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1211
+ },
1212
+ deps: [AngularFirestore, 'UserRepository'],
1213
+ },
1214
+ {
1215
+ provide: 'UserPaymentMethodRepository',
1216
+ useFactory: (firestore, userRepository) => {
1217
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1218
+ },
1219
+ deps: [AngularFirestore, 'UserRepository'],
1220
+ },
1221
+ {
1222
+ provide: ProductVariantFirestoreRepository,
1223
+ useFactory: (firestore, productRepository) => {
1224
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1225
+ },
1226
+ deps: [AngularFirestore, ProductFirestoreRepository],
1227
+ },
1228
+ {
1229
+ provide: APP_INITIALIZER,
1230
+ useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1231
+ deps: [AngularFirestore],
1232
+ multi: true,
1233
+ },
1234
+ ], imports: [[AngularFireModule, AngularElasticSeachModule]] });
1235
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1755
1236
  type: NgModule,
1756
1237
  args: [{
1757
- imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1238
+ imports: [AngularFireModule, AngularElasticSeachModule],
1758
1239
  providers: [
1759
- AuthService,
1760
- CartService,
1761
- CatalogService,
1762
- CategoryService,
1763
- CheckoutService,
1764
- CheckoutSubscriptionService,
1765
- CouponService,
1766
- HomeShopService,
1767
- OrderService,
1768
- ShippingService,
1240
+ {
1241
+ provide: 'BeautyProfileRepository',
1242
+ useFactory: (firestore, userRepository) => {
1243
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1244
+ },
1245
+ deps: [AngularFirestore, 'UserRepository'],
1246
+ },
1247
+ {
1248
+ provide: 'Buy2WinRepository',
1249
+ useFactory: (firestore) => {
1250
+ return new Buy2WinFirestoreRepository(firestore.firestore);
1251
+ },
1252
+ deps: [AngularFirestore],
1253
+ },
1254
+ {
1255
+ provide: CategoryFirestoreRepository,
1256
+ useFactory: (firestore) => {
1257
+ return new CategoryFirestoreRepository(firestore.firestore);
1258
+ },
1259
+ deps: [AngularFirestore],
1260
+ },
1261
+ {
1262
+ provide: 'CheckoutRepository',
1263
+ useFactory: (firestore) => {
1264
+ return new CheckoutFirestoreRepository(firestore.firestore);
1265
+ },
1266
+ deps: [AngularFirestore],
1267
+ },
1268
+ {
1269
+ provide: 'CheckoutSubscriptionRepository',
1270
+ useFactory: (firestore) => {
1271
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1272
+ },
1273
+ deps: [AngularFirestore],
1274
+ },
1275
+ {
1276
+ provide: 'CouponRepository',
1277
+ useFactory: (firestore) => {
1278
+ return new CouponFirestoreRepository(firestore.firestore);
1279
+ },
1280
+ deps: [AngularFirestore],
1281
+ },
1282
+ {
1283
+ provide: 'CampaignHashtagRepository',
1284
+ useFactory: (firestore) => {
1285
+ return new CampaignHashtagFirestoreRepository(firestore.firestore);
1286
+ },
1287
+ deps: [AngularFirestore],
1288
+ },
1289
+ {
1290
+ provide: 'CampaignDashboardRepository',
1291
+ useFactory: (firestore) => {
1292
+ return new CampaignDashboardFirestoreRepository(firestore.firestore);
1293
+ },
1294
+ deps: [AngularFirestore],
1295
+ },
1296
+ {
1297
+ provide: 'EditionRepository',
1298
+ useFactory: (firestore, subscriptionRepository) => {
1299
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1300
+ },
1301
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1302
+ },
1303
+ {
1304
+ provide: 'HomeRepository',
1305
+ useFactory: (firestore) => {
1306
+ return new HomeFirestoreRepository(firestore.firestore);
1307
+ },
1308
+ deps: [AngularFirestore],
1309
+ },
1310
+ {
1311
+ provide: 'LeadRepository',
1312
+ useFactory: (firestore) => {
1313
+ return new LeadFirestoreRepository(firestore.firestore);
1314
+ },
1315
+ deps: [AngularFirestore],
1316
+ },
1317
+ {
1318
+ provide: 'LegacyOrderRepository',
1319
+ useFactory: (firestore) => {
1320
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
1321
+ },
1322
+ deps: [AngularFirestore],
1323
+ },
1324
+ {
1325
+ provide: 'ShopMenuRepository',
1326
+ useFactory: (firestore) => {
1327
+ return new ShopMenuFirestoreRepository(firestore.firestore);
1328
+ },
1329
+ deps: [AngularFirestore],
1330
+ },
1331
+ {
1332
+ provide: 'OrderRepository',
1333
+ useFactory: (firestore) => {
1334
+ return new OrderFirestoreRepository(firestore.firestore);
1335
+ },
1336
+ deps: [AngularFirestore],
1337
+ },
1338
+ {
1339
+ provide: 'PaymentRepository',
1340
+ useFactory: (firestore) => {
1341
+ return new PaymentFirestoreRepository(firestore.firestore);
1342
+ },
1343
+ deps: [AngularFirestore],
1344
+ },
1345
+ {
1346
+ provide: ProductFirestoreRepository,
1347
+ useFactory: (firestore) => {
1348
+ return new ProductFirestoreRepository(firestore.firestore);
1349
+ },
1350
+ deps: [AngularFirestore],
1351
+ },
1352
+ {
1353
+ provide: 'ShopSettingsRepository',
1354
+ useFactory: (firestore) => {
1355
+ return new ShopSettingsFirestoreRepository(firestore.firestore);
1356
+ },
1357
+ deps: [AngularFirestore],
1358
+ },
1359
+ {
1360
+ provide: 'SubscriptionPaymentRepository',
1361
+ useFactory: (firestore, subscriptionRepository) => {
1362
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1363
+ },
1364
+ deps: [AngularFirestore, 'SubscriptionRepository'],
1365
+ },
1366
+ {
1367
+ provide: 'SubscriptionPlanRepository',
1368
+ useFactory: (firestore) => {
1369
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
1370
+ },
1371
+ deps: [AngularFirestore],
1372
+ },
1373
+ {
1374
+ provide: 'SubscriptionProductRepository',
1375
+ useFactory: (firestore) => {
1376
+ return new SubscriptionProductFirestoreRepository(firestore.firestore);
1377
+ },
1378
+ deps: [AngularFirestore],
1379
+ },
1380
+ {
1381
+ provide: 'SubscriptionRepository',
1382
+ useFactory: (firestore) => {
1383
+ return new SubscriptionFirestoreRepository(firestore.firestore);
1384
+ },
1385
+ deps: [AngularFirestore],
1386
+ },
1387
+ {
1388
+ provide: 'UserRepository',
1389
+ useFactory: (firestore) => {
1390
+ return new UserFirestoreRepository(firestore.firestore);
1391
+ },
1392
+ deps: [AngularFirestore],
1393
+ },
1394
+ {
1395
+ provide: 'UserAddressRepository',
1396
+ useFactory: (firestore, userRepository) => {
1397
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
1398
+ },
1399
+ deps: [AngularFirestore, 'UserRepository'],
1400
+ },
1401
+ {
1402
+ provide: 'UserPaymentMethodRepository',
1403
+ useFactory: (firestore, userRepository) => {
1404
+ return new UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1405
+ },
1406
+ deps: [AngularFirestore, 'UserRepository'],
1407
+ },
1408
+ {
1409
+ provide: ProductVariantFirestoreRepository,
1410
+ useFactory: (firestore, productRepository) => {
1411
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1412
+ },
1413
+ deps: [AngularFirestore, ProductFirestoreRepository],
1414
+ },
1415
+ {
1416
+ provide: APP_INITIALIZER,
1417
+ useFactory: (firestore) => () => firestore.firestore.settings({ ignoreUndefinedProperties: true }),
1418
+ deps: [AngularFirestore],
1419
+ multi: true,
1420
+ },
1769
1421
  ],
1770
1422
  }]
1771
1423
  }] });
1772
1424
 
1773
- class AngularFirebaseAuthModule {
1774
- static initializeApp(options, nameOrConfig) {
1425
+ class AngularHasuraGraphQLModule {
1426
+ static initializeApp(options) {
1775
1427
  return {
1776
- ngModule: AngularFirebaseAuthModule,
1777
- providers: [
1778
- { provide: FIREBASE_OPTIONS, useValue: options },
1779
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
1780
- ],
1428
+ ngModule: AngularHasuraGraphQLModule,
1429
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1781
1430
  };
1782
1431
  }
1783
1432
  }
1784
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1785
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
1786
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
1433
+ AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1434
+ AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule });
1435
+ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
1787
1436
  {
1788
- provide: 'Authentication',
1789
- useFactory: (authenticationService, userRepository) => {
1790
- return new Authentication(authenticationService, userRepository);
1437
+ provide: 'CategoryRepository',
1438
+ useExisting: CategoryHasuraGraphQLRepository,
1439
+ },
1440
+ {
1441
+ provide: CategoryHasuraGraphQLRepository,
1442
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1443
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1791
1444
  },
1792
- deps: ['AuthenticationService', 'UserRepository'],
1445
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1793
1446
  },
1794
1447
  {
1795
- provide: 'AuthenticationService',
1796
- useFactory: (angularFireAuth) => {
1797
- return new AuthenticationFirebaseAuthService(angularFireAuth);
1448
+ provide: 'ProductRepository',
1449
+ useExisting: ProductHasuraGraphQLRepository,
1450
+ },
1451
+ {
1452
+ provide: ProductHasuraGraphQLRepository,
1453
+ useFactory: (options) => {
1454
+ return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1798
1455
  },
1799
- deps: [AngularFireAuth],
1456
+ deps: [HASURA_OPTIONS],
1800
1457
  },
1801
1458
  {
1802
- provide: 'Register',
1803
- useFactory: (registerService, userRepository) => {
1804
- return new Register(registerService, userRepository);
1459
+ provide: 'VariantRepository',
1460
+ useExisting: VariantHasuraGraphQLRepository,
1461
+ },
1462
+ {
1463
+ provide: VariantHasuraGraphQLRepository,
1464
+ useFactory: (options) => {
1465
+ return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1805
1466
  },
1806
- deps: ['RegisterService', 'UserRepository'],
1467
+ deps: [HASURA_OPTIONS],
1807
1468
  },
1808
1469
  {
1809
- provide: 'RegisterService',
1810
- useFactory: (angularFireAuth) => {
1811
- return new RegisterFirebaseAuthService(angularFireAuth);
1470
+ provide: 'CategoryFilterRepository',
1471
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1472
+ },
1473
+ {
1474
+ provide: CategoryFilterHasuraGraphQLRepository,
1475
+ useFactory: (options) => {
1476
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1812
1477
  },
1813
- deps: [AngularFireAuth],
1478
+ deps: [HASURA_OPTIONS],
1814
1479
  },
1815
1480
  {
1816
- provide: 'SignOut',
1817
- useFactory: (authenticationService) => {
1818
- return new SignOut(authenticationService);
1481
+ provide: 'FilterOptionRepository',
1482
+ useExisting: FilterOptionHasuraGraphQLRepository,
1483
+ },
1484
+ {
1485
+ provide: FilterOptionHasuraGraphQLRepository,
1486
+ useFactory: (options) => {
1487
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1819
1488
  },
1820
- deps: ['AuthenticationService'],
1489
+ deps: [HASURA_OPTIONS],
1821
1490
  },
1822
1491
  {
1823
- provide: 'RecoveryPassword',
1824
- useFactory: (authenticationService) => {
1825
- return new RecoveryPassword(authenticationService);
1492
+ provide: 'FilterRepository',
1493
+ useExisting: FilterHasuraGraphQLRepository,
1494
+ },
1495
+ {
1496
+ provide: FilterHasuraGraphQLRepository,
1497
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1498
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1826
1499
  },
1827
- deps: ['AuthenticationService'],
1500
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1828
1501
  },
1829
- ], imports: [[AngularFireModule]] });
1830
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
1502
+ ] });
1503
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1831
1504
  type: NgModule,
1832
1505
  args: [{
1833
- imports: [AngularFireModule],
1834
1506
  providers: [
1835
1507
  {
1836
- provide: 'Authentication',
1837
- useFactory: (authenticationService, userRepository) => {
1838
- return new Authentication(authenticationService, userRepository);
1508
+ provide: 'CategoryRepository',
1509
+ useExisting: CategoryHasuraGraphQLRepository,
1510
+ },
1511
+ {
1512
+ provide: CategoryHasuraGraphQLRepository,
1513
+ useFactory: (options, productRepository, categoryFilterRepository) => {
1514
+ return new CategoryHasuraGraphQLRepository(options.endpoint, options.credentials, productRepository, categoryFilterRepository);
1839
1515
  },
1840
- deps: ['AuthenticationService', 'UserRepository'],
1516
+ deps: [HASURA_OPTIONS, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1841
1517
  },
1842
1518
  {
1843
- provide: 'AuthenticationService',
1844
- useFactory: (angularFireAuth) => {
1845
- return new AuthenticationFirebaseAuthService(angularFireAuth);
1519
+ provide: 'ProductRepository',
1520
+ useExisting: ProductHasuraGraphQLRepository,
1521
+ },
1522
+ {
1523
+ provide: ProductHasuraGraphQLRepository,
1524
+ useFactory: (options) => {
1525
+ return new ProductHasuraGraphQLRepository(options.endpoint, options.credentials);
1846
1526
  },
1847
- deps: [AngularFireAuth],
1527
+ deps: [HASURA_OPTIONS],
1848
1528
  },
1849
1529
  {
1850
- provide: 'Register',
1851
- useFactory: (registerService, userRepository) => {
1852
- return new Register(registerService, userRepository);
1530
+ provide: 'VariantRepository',
1531
+ useExisting: VariantHasuraGraphQLRepository,
1532
+ },
1533
+ {
1534
+ provide: VariantHasuraGraphQLRepository,
1535
+ useFactory: (options) => {
1536
+ return new VariantHasuraGraphQLRepository(options.endpoint, options.credentials);
1853
1537
  },
1854
- deps: ['RegisterService', 'UserRepository'],
1538
+ deps: [HASURA_OPTIONS],
1855
1539
  },
1856
1540
  {
1857
- provide: 'RegisterService',
1858
- useFactory: (angularFireAuth) => {
1859
- return new RegisterFirebaseAuthService(angularFireAuth);
1541
+ provide: 'CategoryFilterRepository',
1542
+ useExisting: CategoryFilterHasuraGraphQLRepository,
1543
+ },
1544
+ {
1545
+ provide: CategoryFilterHasuraGraphQLRepository,
1546
+ useFactory: (options) => {
1547
+ return new CategoryFilterHasuraGraphQLRepository(options.endpoint, options.credentials);
1860
1548
  },
1861
- deps: [AngularFireAuth],
1549
+ deps: [HASURA_OPTIONS],
1862
1550
  },
1863
1551
  {
1864
- provide: 'SignOut',
1865
- useFactory: (authenticationService) => {
1866
- return new SignOut(authenticationService);
1552
+ provide: 'FilterOptionRepository',
1553
+ useExisting: FilterOptionHasuraGraphQLRepository,
1554
+ },
1555
+ {
1556
+ provide: FilterOptionHasuraGraphQLRepository,
1557
+ useFactory: (options) => {
1558
+ return new FilterOptionHasuraGraphQLRepository(options.endpoint, options.credentials);
1867
1559
  },
1868
- deps: ['AuthenticationService'],
1560
+ deps: [HASURA_OPTIONS],
1869
1561
  },
1870
1562
  {
1871
- provide: 'RecoveryPassword',
1872
- useFactory: (authenticationService) => {
1873
- return new RecoveryPassword(authenticationService);
1563
+ provide: 'FilterRepository',
1564
+ useExisting: FilterHasuraGraphQLRepository,
1565
+ },
1566
+ {
1567
+ provide: FilterHasuraGraphQLRepository,
1568
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1569
+ return new FilterHasuraGraphQLRepository(options.endpoint, options.credentials, filterOptionRepository, categoryFilterRepository);
1874
1570
  },
1875
- deps: ['AuthenticationService'],
1571
+ deps: [HASURA_OPTIONS, FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1876
1572
  },
1877
1573
  ],
1878
1574
  }]
1879
1575
  }] });
1880
1576
 
1577
+ class AngularConnectModule {
1578
+ static initializeApp(defaultShop, options, nameOrConfig) {
1579
+ return {
1580
+ ngModule: AngularConnectModule,
1581
+ providers: [
1582
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1583
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1584
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1585
+ ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1586
+ ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1587
+ ...(isNil(options === null || options === void 0 ? void 0 : options.backendUrl) ? [] : [{ provide: BACKEND_URL, useValue: options.backendUrl }]),
1588
+ ],
1589
+ };
1590
+ }
1591
+ }
1592
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1593
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1594
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, providers: [
1595
+ AuthService,
1596
+ CartService,
1597
+ CheckoutService,
1598
+ CheckoutSubscriptionService,
1599
+ CouponService,
1600
+ HomeShopService,
1601
+ OrderService,
1602
+ ShippingService,
1603
+ ], imports: [[AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule]] });
1604
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0, type: AngularConnectModule, decorators: [{
1605
+ type: NgModule,
1606
+ args: [{
1607
+ imports: [AngularFireModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1608
+ providers: [
1609
+ AuthService,
1610
+ CartService,
1611
+ CheckoutService,
1612
+ CheckoutSubscriptionService,
1613
+ CouponService,
1614
+ HomeShopService,
1615
+ OrderService,
1616
+ ShippingService,
1617
+ ],
1618
+ }]
1619
+ }] });
1620
+
1881
1621
  /**
1882
1622
  * Generated bundle index. Do not edit.
1883
1623
  */
1884
1624
 
1885
- export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ProductSorts, ShippingService };
1625
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService, ShippingService };
1886
1626
  //# sourceMappingURL=infrab4a-connect-angular.js.map