@infrab4a/connect-angular 4.0.0-beta.58 → 4.0.0-beta.6

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 (107) hide show
  1. package/angular-connect.module.d.ts +4 -7
  2. package/angular-firestore.module.d.ts +1 -2
  3. package/angular-hasura-graphql.module.d.ts +1 -1
  4. package/consts/index.d.ts +0 -2
  5. package/esm2020/angular-connect.module.mjs +49 -0
  6. package/esm2020/angular-elastic-search.module.mjs +38 -0
  7. package/esm2020/angular-firebase-auth.module.mjs +130 -0
  8. package/esm2020/angular-firestore.module.mjs +358 -0
  9. package/esm2020/angular-hasura-graphql.module.mjs +142 -0
  10. package/esm2020/consts/index.mjs +5 -0
  11. package/esm2020/index.mjs +6 -0
  12. package/esm2020/services/auth.service.mjs +37 -0
  13. package/esm2020/services/cart.service.mjs +143 -0
  14. package/esm2020/services/checkout-subscription.service.mjs +51 -0
  15. package/esm2020/services/checkout.service.mjs +73 -0
  16. package/esm2020/services/coupon.service.mjs +226 -0
  17. package/esm2020/services/errors/group-invalid-coupon.error.mjs +8 -0
  18. package/esm2020/services/errors/index.mjs +3 -0
  19. package/esm2020/services/errors/invalid-coupon.error.mjs +7 -0
  20. package/{esm2022 → esm2020}/services/home-shop.service.mjs +11 -11
  21. package/esm2020/services/index.mjs +8 -0
  22. package/{esm2022 → esm2020}/services/order.service.mjs +4 -4
  23. package/fesm2015/infrab4a-connect-angular.mjs +1388 -0
  24. package/fesm2015/infrab4a-connect-angular.mjs.map +1 -0
  25. package/fesm2020/infrab4a-connect-angular.mjs +1343 -0
  26. package/fesm2020/infrab4a-connect-angular.mjs.map +1 -0
  27. package/index.d.ts +2 -2
  28. package/package.json +16 -9
  29. package/services/cart.service.d.ts +3 -10
  30. package/services/coupon.service.d.ts +10 -13
  31. package/services/errors/group-invalid-coupon.error.d.ts +6 -0
  32. package/services/errors/index.d.ts +2 -0
  33. package/services/errors/invalid-coupon.error.d.ts +4 -0
  34. package/services/home-shop.service.d.ts +1 -1
  35. package/services/index.d.ts +2 -5
  36. package/services/types/required-checkout-data.type.d.ts +1 -1
  37. package/services/types/required-checkout-subscription-data.type.d.ts +1 -1
  38. package/types/firebase-app-config.type.d.ts +1 -1
  39. package/consts/backend-url.const.d.ts +0 -1
  40. package/consts/category-structure.d.ts +0 -1
  41. package/esm2022/angular-connect.module.mjs +0 -66
  42. package/esm2022/angular-elastic-search.module.mjs +0 -34
  43. package/esm2022/angular-firebase-auth.module.mjs +0 -130
  44. package/esm2022/angular-firestore.module.mjs +0 -459
  45. package/esm2022/angular-hasura-graphql.module.mjs +0 -243
  46. package/esm2022/consts/backend-url.const.mjs +0 -2
  47. package/esm2022/consts/category-structure.mjs +0 -2
  48. package/esm2022/consts/index.mjs +0 -7
  49. package/esm2022/helpers/index.mjs +0 -2
  50. package/esm2022/helpers/mobile-operation-system-checker.helper.mjs +0 -7
  51. package/esm2022/index.mjs +0 -6
  52. package/esm2022/services/auth.service.mjs +0 -37
  53. package/esm2022/services/cart.service.mjs +0 -281
  54. package/esm2022/services/catalog/adapters/category-structure.adapter.mjs +0 -2
  55. package/esm2022/services/catalog/adapters/index.mjs +0 -4
  56. package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +0 -42
  57. package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +0 -23
  58. package/esm2022/services/catalog/catalog.service.mjs +0 -127
  59. package/esm2022/services/catalog/category.service.mjs +0 -51
  60. package/esm2022/services/catalog/enums/index.mjs +0 -2
  61. package/esm2022/services/catalog/enums/product-sorts.enum.mjs +0 -11
  62. package/esm2022/services/catalog/index.mjs +0 -7
  63. package/esm2022/services/catalog/models/category-with-tree.model.mjs +0 -10
  64. package/esm2022/services/catalog/models/index.mjs +0 -2
  65. package/esm2022/services/catalog/types/index.mjs +0 -2
  66. package/esm2022/services/catalog/types/product-sort.type.mjs +0 -2
  67. package/esm2022/services/catalog/wishlist.service.mjs +0 -105
  68. package/esm2022/services/checkout-subscription.service.mjs +0 -53
  69. package/esm2022/services/checkout.service.mjs +0 -71
  70. package/esm2022/services/coupon.service.mjs +0 -218
  71. package/esm2022/services/helpers/index.mjs +0 -2
  72. package/esm2022/services/helpers/util.helper.mjs +0 -18
  73. package/esm2022/services/index.mjs +0 -11
  74. package/esm2022/services/shipping.service.mjs +0 -96
  75. package/esm2022/services/types/shipping-methods.type.mjs +0 -2
  76. package/fesm2022/infrab4a-connect-angular.mjs +0 -2130
  77. package/fesm2022/infrab4a-connect-angular.mjs.map +0 -1
  78. package/helpers/index.d.ts +0 -1
  79. package/helpers/mobile-operation-system-checker.helper.d.ts +0 -3
  80. package/services/catalog/adapters/category-structure.adapter.d.ts +0 -4
  81. package/services/catalog/adapters/index.d.ts +0 -3
  82. package/services/catalog/adapters/new-category-structure.adapter.d.ts +0 -14
  83. package/services/catalog/adapters/old-category-structure.adapter.d.ts +0 -10
  84. package/services/catalog/catalog.service.d.ts +0 -80
  85. package/services/catalog/category.service.d.ts +0 -15
  86. package/services/catalog/enums/index.d.ts +0 -1
  87. package/services/catalog/enums/product-sorts.enum.d.ts +0 -9
  88. package/services/catalog/index.d.ts +0 -6
  89. package/services/catalog/models/category-with-tree.model.d.ts +0 -4
  90. package/services/catalog/models/index.d.ts +0 -1
  91. package/services/catalog/types/index.d.ts +0 -1
  92. package/services/catalog/types/product-sort.type.d.ts +0 -2
  93. package/services/catalog/wishlist.service.d.ts +0 -22
  94. package/services/helpers/index.d.ts +0 -1
  95. package/services/helpers/util.helper.d.ts +0 -3
  96. package/services/shipping.service.d.ts +0 -19
  97. package/services/types/shipping-methods.type.d.ts +0 -12
  98. /package/{esm2022 → esm2020}/consts/default-shop.const.mjs +0 -0
  99. /package/{esm2022 → esm2020}/consts/es-config.const.mjs +0 -0
  100. /package/{esm2022 → esm2020}/consts/firebase-const.mjs +0 -0
  101. /package/{esm2022 → esm2020}/consts/hasura-options.const.mjs +0 -0
  102. /package/{esm2022 → esm2020}/infrab4a-connect-angular.mjs +0 -0
  103. /package/{esm2022 → esm2020}/services/types/index.mjs +0 -0
  104. /package/{esm2022 → esm2020}/services/types/required-checkout-data.type.mjs +0 -0
  105. /package/{esm2022 → esm2020}/services/types/required-checkout-subscription-data.type.mjs +0 -0
  106. /package/{esm2022 → esm2020}/types/firebase-app-config.type.mjs +0 -0
  107. /package/{esm2022 → esm2020}/types/index.mjs +0 -0
@@ -0,0 +1,1388 @@
1
+ import * as i0 from '@angular/core';
2
+ import { Injectable, Inject, InjectionToken, NgModule, PLATFORM_ID } from '@angular/core';
3
+ import * as i1 from '@angular/fire/auth';
4
+ import { getIdToken, authState, Auth, provideAuth, getAuth } from '@angular/fire/auth';
5
+ import { combineLatest, of, from, throwError, Subject, iif, forkJoin } from 'rxjs';
6
+ import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
7
+ import { __awaiter } from 'tslib';
8
+ import * as i2 from '@infrab4a/connect';
9
+ import { Where, Shops, CheckoutTypes, CouponTypes, Exclusivities, Status, isNil, NotFoundError, Checkout, pick, LineItem, CheckoutSubscription, Order, Category, Product, RequiredArgumentError, add, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ProductsIndex, AxiosAdapter, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, ProductVariantFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, VariantHasuraGraphQLRepository } from '@infrab4a/connect';
10
+ import cookie from 'js-cookie';
11
+ import { CustomError } from 'ts-custom-error';
12
+ import * as i1$1 from '@angular/fire/firestore';
13
+ import { docSnapshots, doc, Firestore, provideFirestore, getFirestore } from '@angular/fire/firestore';
14
+ import * as i1$2 from '@angular/fire/app';
15
+ import { provideFirebaseApp, initializeApp } from '@angular/fire/app';
16
+ import { isPlatformBrowser } from '@angular/common';
17
+
18
+ class AuthService {
19
+ constructor(angularFireAuth, userRepository) {
20
+ this.angularFireAuth = angularFireAuth;
21
+ this.userRepository = userRepository;
22
+ }
23
+ getAuthstate() {
24
+ const observables = [this.getFireUser(), this.getUser()];
25
+ return combineLatest(observables).pipe(map(([fireUser, user]) => ({
26
+ user,
27
+ isAnonymous: fireUser === null || fireUser === void 0 ? void 0 : fireUser.isAnonymous,
28
+ })));
29
+ }
30
+ getUser() {
31
+ return this.getFireUser().pipe(map((user) => user === null || user === void 0 ? void 0 : user.uid), mergeMap((id) => (id ? this.userRepository.get({ id }) : of(null))), catchError(() => of(null)));
32
+ }
33
+ getTokenId() {
34
+ return from(getIdToken(this.angularFireAuth.currentUser));
35
+ }
36
+ getFireUser() {
37
+ return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
38
+ }
39
+ }
40
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
41
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService });
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AuthService, decorators: [{
43
+ type: Injectable
44
+ }], ctorParameters: function () {
45
+ return [{ type: i1.Auth }, { type: undefined, decorators: [{
46
+ type: Inject,
47
+ args: ['UserRepository']
48
+ }] }];
49
+ } });
50
+
51
+ const DEFAULT_SHOP = 'DEFAULT_SHOP';
52
+
53
+ const ES_CONFIG = 'ES_CONFIG';
54
+
55
+ const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
56
+ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
57
+
58
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
59
+
60
+ class InvalidCouponError extends CustomError {
61
+ constructor(message) {
62
+ super(message);
63
+ }
64
+ }
65
+
66
+ class GroupInvalidCouponError extends CustomError {
67
+ constructor(errors) {
68
+ super('Many coupon errors throw');
69
+ this.errors = errors;
70
+ }
71
+ }
72
+
73
+ class CouponService {
74
+ constructor(couponRepository, defaultShop, orderRepository, subscriptionRepository, categoryRepository) {
75
+ this.couponRepository = couponRepository;
76
+ this.defaultShop = defaultShop;
77
+ this.orderRepository = orderRepository;
78
+ this.subscriptionRepository = subscriptionRepository;
79
+ this.categoryRepository = categoryRepository;
80
+ this.emailIsFromCollaborator = (userEmail) => !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g));
81
+ }
82
+ checkCoupon(nickname, userEmail, checkoutType, plan, checkout, isSubscription) {
83
+ return from(this.couponRepository.find({
84
+ filters: {
85
+ nickname: { operator: Where.EQUALS, value: nickname },
86
+ active: { operator: Where.EQUALS, value: true },
87
+ },
88
+ })).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));
89
+ }
90
+ checkCouponRules(coupons, checkoutType, plan, checkout, isSubscription) {
91
+ // Caso não ache nenhum cupom, retorna erro
92
+ if (coupons.count < 1) {
93
+ return throwError('Cupom inválido.');
94
+ }
95
+ // Get Primeiro Cupom (o find do repository retorna um array)
96
+ const coupon = coupons.data.shift();
97
+ // Verifica se o cupom é aplicavel na loja
98
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.defaultShop;
99
+ // Cupon não aplicavel a loja retorna erro
100
+ if (!isInShop)
101
+ return throwError('Cupom inválido para loja.');
102
+ // Verifica se o coupon é aplicado no checkout que está sendo realizado
103
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
104
+ // Cupon não aplicavel ao checkout retorna erro
105
+ if (!isCheckoutType)
106
+ return throwError('Cupom inválido. Erro de checkout.');
107
+ // Verifica se o cupom é ou pode ser aplicado para subscription
108
+ if (checkoutType === CheckoutTypes.ALL || checkoutType === CheckoutTypes.SUBSCRIPTION) {
109
+ // Se o cupom tiver um plano associado, verifica se é o mesmo plano do checkout da assinatura
110
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase())
111
+ return throwError('Cupom inválido para sua assinatura.');
112
+ }
113
+ if (isSubscription)
114
+ return of(coupon);
115
+ // Verifica se possui o valor minimo de compra para utilização do cupom
116
+ const hasMinSubTotal = this.hasMinSubTotal(coupon, checkout);
117
+ // Se não tem valor mínimo atingido, retorna erro
118
+ if (!hasMinSubTotal)
119
+ return throwError('Valor mínimo não atingido');
120
+ return of(coupon);
121
+ }
122
+ isValidCoupon(coupon, userEmail) {
123
+ // Verifica a data de inicio de validade do cupom
124
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.beginAt) > new Date())
125
+ throw new InvalidCouponError('Cupom ainda não liberado.');
126
+ // Verifica a data de validade do cupom
127
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
128
+ throw new InvalidCouponError('Cupom expirado.');
129
+ return coupon;
130
+ }
131
+ checkCouponUseAndLimit(coupon, userEmail, checkout) {
132
+ return __awaiter(this, void 0, void 0, function* () {
133
+ const orders = yield this.orderRepository.find({
134
+ filters: {
135
+ coupon: { id: coupon.id },
136
+ payment: { status: 'paid' },
137
+ },
138
+ });
139
+ // orders que usuario ja fez com o cupom
140
+ const ordersUserCoupon = orders.data.filter((o) => o.user.email == userEmail);
141
+ // Verifica o limite de uso de cupom por usuario
142
+ if (coupon.useLimitPerUser && ordersUserCoupon.length)
143
+ throw new InvalidCouponError('Limite de uso por usuário atingido.');
144
+ // Verifica o limite de uso geral por usuario
145
+ if (coupon.useLimit && orders.data.length >= coupon.useLimit)
146
+ throw new InvalidCouponError('Limite de uso atingido.');
147
+ const validUser = yield this.userValidationAndSubscriptionStatus(coupon, userEmail);
148
+ if (!validUser)
149
+ throw new InvalidCouponError('Usuário não elegível.');
150
+ const hasProductCategories = yield this.hasProductCategories(coupon, checkout);
151
+ if (!hasProductCategories)
152
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
153
+ return coupon;
154
+ });
155
+ }
156
+ calcDiscountSubscription(coupon, checkout) {
157
+ //
158
+ let discount = 0;
159
+ if (coupon.type === CouponTypes.ABSOLUTE)
160
+ discount = coupon.discount;
161
+ else if (coupon.type === CouponTypes.PERCENTAGE)
162
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount / 100);
163
+ return of(discount);
164
+ }
165
+ calcDiscountShopping(coupon, checkout) {
166
+ return __awaiter(this, void 0, void 0, function* () {
167
+ let discount = 0;
168
+ switch (coupon.type) {
169
+ case CouponTypes.ABSOLUTE: {
170
+ discount = coupon.discount;
171
+ break;
172
+ }
173
+ case CouponTypes.PERCENTAGE: {
174
+ discount = yield this.calcShoppingPercentageDiscount(coupon, checkout);
175
+ break;
176
+ }
177
+ }
178
+ return discount;
179
+ });
180
+ }
181
+ calcShoppingPercentageDiscount(coupon, checkout) {
182
+ var _a;
183
+ return __awaiter(this, void 0, void 0, function* () {
184
+ let discount = 0;
185
+ const shop = checkout.shop;
186
+ let lineItensDiscount = [];
187
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
188
+ if (coupon.productsCategories && coupon.productsCategories.length) {
189
+ lineItensDiscount = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
190
+ var _a;
191
+ if ((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length) {
192
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
193
+ }
194
+ return true;
195
+ });
196
+ }
197
+ else {
198
+ lineItensDiscount = checkout.lineItems;
199
+ }
200
+ const subTotal = lineItensDiscount.reduce((acc, curr) => {
201
+ var _a, _b, _c;
202
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
203
+ ? acc + ((_c = curr.price) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
204
+ : acc + curr.pricePaid * curr.quantity;
205
+ }, 0) || 0;
206
+ discount = subTotal * (coupon.discount / 100);
207
+ return discount;
208
+ });
209
+ }
210
+ hasMinSubTotal(coupon, checkout) {
211
+ var _a;
212
+ if (!coupon.minSubTotalValue)
213
+ return true;
214
+ const shop = checkout.shop;
215
+ let subTotal = ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.reduce((acc, curr) => {
216
+ var _a, _b, _c;
217
+ return ((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.isSubscriber) && ((_b = curr.price) === null || _b === void 0 ? void 0 : _b.subscriberPrice)
218
+ ? acc + ((_c = curr.price) === null || _c === void 0 ? void 0 : _c.subscriberPrice) * curr.quantity
219
+ : acc + curr.pricePaid * curr.quantity;
220
+ }, 0)) || 0;
221
+ if (coupon.minSubTotalValue <= subTotal)
222
+ return true;
223
+ return false;
224
+ }
225
+ hasProductCategories(coupon, checkout) {
226
+ var _a;
227
+ return __awaiter(this, void 0, void 0, function* () {
228
+ if (!coupon.productsCategories || !coupon.productsCategories.length) {
229
+ return true;
230
+ }
231
+ const couponCategories = yield this.getCouponCategoriesId(coupon);
232
+ const hasCategories = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.filter((i) => {
233
+ var _a;
234
+ if (!i.categories || !((_a = i.categories) === null || _a === void 0 ? void 0 : _a.length))
235
+ return true;
236
+ return i.categories.some((c) => couponCategories.some((cat) => cat.id == c || cat.firestoreId == c));
237
+ });
238
+ return hasCategories.length ? true : false;
239
+ });
240
+ }
241
+ userValidationAndSubscriptionStatus(coupon, userEmail) {
242
+ return __awaiter(this, void 0, void 0, function* () {
243
+ // Verifica se o email do usuário é coorporativo
244
+ if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === Exclusivities.COLLABORATORS)
245
+ throw new InvalidCouponError('Você não é colaborador.');
246
+ // Verifica se o email do usuário é associado ao cupom de uso por usuario
247
+ if (coupon.exclusivityType === Exclusivities.SPECIFIC_USER && coupon.userExclusiveEmail !== userEmail)
248
+ throw new InvalidCouponError('Cupom não é válido para este usuário.');
249
+ const couponRuleSubscription = coupon.exclusivityType === Exclusivities.ACTIVE_SUBSCRIBER ||
250
+ coupon.exclusivityType === Exclusivities.INACTIVE_SUBSCRIBER ||
251
+ coupon.exclusivityType === Exclusivities.NON_SUBSCRIBER;
252
+ if (couponRuleSubscription && userEmail) {
253
+ const sub = yield this.subscriptionRepository
254
+ .find({
255
+ filters: {
256
+ user: {
257
+ email: { operator: Where.EQUALS, value: userEmail },
258
+ },
259
+ },
260
+ })
261
+ .then((sub) => sub.data);
262
+ const activeSubs = sub === null || sub === void 0 ? void 0 : sub.filter((s) => s.status === Status.ACTIVE);
263
+ switch (coupon.exclusivityType) {
264
+ case Exclusivities.ACTIVE_SUBSCRIBER:
265
+ return activeSubs.length > 0;
266
+ case Exclusivities.INACTIVE_SUBSCRIBER:
267
+ return activeSubs.length === 0;
268
+ case Exclusivities.NON_SUBSCRIBER:
269
+ return sub.length === 0;
270
+ default:
271
+ return false;
272
+ }
273
+ }
274
+ return true;
275
+ });
276
+ }
277
+ getCouponCategoriesId(coupon) {
278
+ return __awaiter(this, void 0, void 0, function* () {
279
+ let couponCategories = [];
280
+ for (let index = 0; index < coupon.productsCategories.length; index++) {
281
+ let c = yield this.categoryRepository.get({
282
+ id: coupon.productsCategories[index],
283
+ });
284
+ couponCategories.push({ id: c.id, firestoreId: c.firestoreId });
285
+ }
286
+ return couponCategories;
287
+ });
288
+ }
289
+ }
290
+ CouponService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }, { token: 'OrderRepository' }, { token: 'SubscriptionRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
291
+ CouponService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, providedIn: 'root' });
292
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CouponService, decorators: [{
293
+ type: Injectable,
294
+ args: [{
295
+ providedIn: 'root',
296
+ }]
297
+ }], ctorParameters: function () {
298
+ return [{ type: undefined, decorators: [{
299
+ type: Inject,
300
+ args: ['CouponRepository']
301
+ }] }, { type: i2.Shops, decorators: [{
302
+ type: Inject,
303
+ args: [DEFAULT_SHOP]
304
+ }] }, { type: undefined, decorators: [{
305
+ type: Inject,
306
+ args: ['OrderRepository']
307
+ }] }, { type: undefined, decorators: [{
308
+ type: Inject,
309
+ args: ['SubscriptionRepository']
310
+ }] }, { type: undefined, decorators: [{
311
+ type: Inject,
312
+ args: ['CategoryRepository']
313
+ }] }];
314
+ } });
315
+
316
+ class CheckoutService {
317
+ constructor(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
318
+ this.couponService = couponService;
319
+ this.checkoutRepository = checkoutRepository;
320
+ this.orderRepository = orderRepository;
321
+ this.userRepository = userRepository;
322
+ this.defaultShop = defaultShop;
323
+ }
324
+ getCheckout(checkoutData) {
325
+ const checkoutId = cookie.get('checkoutId');
326
+ if (!isNil(checkoutId))
327
+ return from(this.checkoutRepository.get({ id: checkoutId }));
328
+ return from(this.createCheckout(checkoutData));
329
+ }
330
+ getUserByCheckout(checkoutId) {
331
+ 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'))));
332
+ }
333
+ updateCheckoutLineItems(checkout) {
334
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
335
+ }
336
+ updateCheckoutUser(checkout) {
337
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
338
+ }
339
+ clearCheckoutFromSession() {
340
+ cookie.remove('checkoutId');
341
+ return of();
342
+ }
343
+ calcDiscount(coupon) {
344
+ return this.getCheckout().pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.couponService.calcDiscountShopping(coupon, checkout); })));
345
+ }
346
+ checkCoupon(nickname, checkoutType) {
347
+ return this.getCheckout().pipe(concatMap((checkout) => {
348
+ var _a;
349
+ return this.couponService
350
+ .checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, CheckoutTypes.ECOMMERCE, checkout.user.subscriptionPlan, checkout, false)
351
+ .pipe();
352
+ }));
353
+ }
354
+ createCheckout(checkoutData) {
355
+ return __awaiter(this, void 0, void 0, function* () {
356
+ 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 }));
357
+ cookie.set('checkoutId', checkout.id);
358
+ return checkout;
359
+ });
360
+ }
361
+ }
362
+ CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, deps: [{ token: CouponService }, { token: 'CheckoutRepository' }, { token: 'OrderRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
363
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService });
364
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutService, decorators: [{
365
+ type: Injectable
366
+ }], ctorParameters: function () {
367
+ return [{ type: CouponService }, { type: undefined, decorators: [{
368
+ type: Inject,
369
+ args: ['CheckoutRepository']
370
+ }] }, { type: undefined, decorators: [{
371
+ type: Inject,
372
+ args: ['OrderRepository']
373
+ }] }, { type: undefined, decorators: [{
374
+ type: Inject,
375
+ args: ['UserRepository']
376
+ }] }, { type: i2.Shops, decorators: [{
377
+ type: Inject,
378
+ args: [DEFAULT_SHOP]
379
+ }] }];
380
+ } });
381
+
382
+ class CartService {
383
+ constructor(authService, checkoutService, defaultShop, productRepository) {
384
+ this.authService = authService;
385
+ this.checkoutService = checkoutService;
386
+ this.defaultShop = defaultShop;
387
+ this.productRepository = productRepository;
388
+ this.cartSubject = new Subject();
389
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
390
+ var _a;
391
+ const items = [];
392
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
393
+ if (index > -1) {
394
+ checkoutLoaded.lineItems[index].quantity += quantity;
395
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
396
+ }
397
+ else
398
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
399
+ return this.checkoutService
400
+ .updateCheckoutLineItems(checkoutLoaded)
401
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
402
+ }));
403
+ this.generateCartObject = (items) => {
404
+ const cart = {};
405
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
406
+ var _a;
407
+ return (cart[item.sku] = LineItem.toInstance(Object.assign(Object.assign({}, (cart[item.sku] || item)), { quantity: (((_a = cart[item.sku]) === null || _a === void 0 ? void 0 : _a.quantity) || 0) + (item.quantity ? item.quantity : 1) })));
408
+ });
409
+ return cart;
410
+ };
411
+ this.buildLineItem = ({ checkout, item, quantity, }) => __awaiter(this, void 0, void 0, function* () {
412
+ var _a, _b, _c, _d, _e, _f, _g;
413
+ const product = yield this.productRepository.get({ id: item.id });
414
+ item.quantity = (item === null || item === void 0 ? void 0 : item.quantity) || ((_b = (_a = checkout === null || checkout === void 0 ? void 0 : checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku)) === null || _b === void 0 ? void 0 : _b.quantity) || 0;
415
+ if (this.checkMaxStock(item, quantity || 0))
416
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
417
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
418
+ const { id, name, EAN, brand, slug, stock, price, weight, categories, sku, type } = item;
419
+ const isGift = item.isGift || null;
420
+ const pricePaid = this.getProductPrice({
421
+ product: item,
422
+ shop: checkout.shop || this.defaultShop,
423
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
424
+ });
425
+ return {
426
+ checkout,
427
+ lineItem: LineItem.toInstance({
428
+ id,
429
+ name: name !== null && name !== void 0 ? name : product.name,
430
+ EAN: EAN !== null && EAN !== void 0 ? EAN : product.EAN,
431
+ brand: product.brand,
432
+ slug: slug !== null && slug !== void 0 ? slug : product.slug,
433
+ sku: sku !== null && sku !== void 0 ? sku : product.sku,
434
+ stock,
435
+ price,
436
+ image,
437
+ weight: weight !== null && weight !== void 0 ? weight : product.weight,
438
+ quantity: (item.quantity || 0) + (quantity || 0),
439
+ pricePaid,
440
+ categories: (_f = product.categories) !== null && _f !== void 0 ? _f : [],
441
+ isGift: isGift !== null && isGift !== void 0 ? isGift : null,
442
+ costPrice: (_g = product.costPrice) !== null && _g !== void 0 ? _g : 0,
443
+ type,
444
+ }),
445
+ };
446
+ });
447
+ this.getProductPrice = ({ product, isSubscriber, }) => {
448
+ const info = product.price;
449
+ if (product.isGift)
450
+ return 0;
451
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
452
+ };
453
+ this.checkMaxStock = (item, quantity) => {
454
+ var _a;
455
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
456
+ const currentItemAmount = item.quantity || 0;
457
+ return currentItemAmount + quantity > maxStock;
458
+ };
459
+ }
460
+ addItem(item, quantity = 1) {
461
+ return from(this.checkoutService.getCheckout()).pipe(concatMap((checkout) => __awaiter(this, void 0, void 0, function* () { return yield this.buildLineItem({ checkout, item, quantity: quantity || 1 }); })), mergeMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
462
+ }
463
+ decreaseItem(item) {
464
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
465
+ var _a;
466
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
467
+ if (!isNil(checkoutItem))
468
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
469
+ return checkout;
470
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
471
+ }
472
+ getCart(checkout) {
473
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
474
+ return this.cartSubject;
475
+ }
476
+ /**
477
+ * @deprecated The method should not be used
478
+ */
479
+ getVariantPriceDiscount(item) {
480
+ return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.price.subscriberPrice, of(item.price.subscriberPrice), of(item.price.price))), catchError(() => of(item.price.price)));
481
+ }
482
+ removeItem(item) {
483
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
484
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
485
+ if (index >= 0)
486
+ checkout.lineItems.splice(index, 1);
487
+ return checkout;
488
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
489
+ }
490
+ updateUserCart(user) {
491
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => __awaiter(this, void 0, void 0, function* () {
492
+ var _a, _b;
493
+ return this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.length) ? yield Promise.all((_b = checkout.lineItems) === null || _b === void 0 ? void 0 : _b.map((item) => __awaiter(this, void 0, void 0, function* () { return (yield this.buildLineItem({ checkout, item })).lineItem; }))) : [] }))).toPromise();
494
+ })), map(checkout => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
495
+ }
496
+ clearCart() {
497
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
498
+ this.checkoutService.clearCheckoutFromSession();
499
+ return checkout;
500
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
501
+ }
502
+ buildCartFromCheckout(checkoutData) {
503
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
504
+ }
505
+ }
506
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
507
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService });
508
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CartService, decorators: [{
509
+ type: Injectable
510
+ }], ctorParameters: function () {
511
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i2.Shops, decorators: [{
512
+ type: Inject,
513
+ args: [DEFAULT_SHOP]
514
+ }] }, { type: undefined, decorators: [{
515
+ type: Inject,
516
+ args: ['ProductRepository']
517
+ }] }];
518
+ } });
519
+
520
+ class CheckoutSubscriptionService {
521
+ constructor(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
522
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
523
+ this.subscriptionRepository = subscriptionRepository;
524
+ this.couponService = couponService;
525
+ }
526
+ getCheckoutSubscription(checkoutData) {
527
+ const checkoutId = cookie.get('checkoutSubscriptionId');
528
+ if (!isNil(checkoutId))
529
+ return from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
530
+ return from(this.createCheckoutSubscription(checkoutData));
531
+ }
532
+ createCheckoutSubscription(checkoutData) {
533
+ return __awaiter(this, void 0, void 0, function* () {
534
+ const checkout = yield this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain()));
535
+ cookie.set('checkoutSubscriptionId', checkout.id);
536
+ return checkout;
537
+ });
538
+ }
539
+ clearCheckoutSubscriptionFromSession() {
540
+ cookie.remove('checkoutSubscriptionId');
541
+ return of();
542
+ }
543
+ checkCoupon(nickname, userEmail) {
544
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.checkCoupon(nickname, userEmail, CheckoutTypes.SUBSCRIPTION, checkout.subscriptionPlan.name, null, true).pipe()));
545
+ }
546
+ calcDiscountSubscription(coupon) {
547
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
548
+ }
549
+ }
550
+ CheckoutSubscriptionService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: 'SubscriptionRepository' }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable });
551
+ CheckoutSubscriptionService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService });
552
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
553
+ type: Injectable
554
+ }], ctorParameters: function () {
555
+ return [{ type: undefined, decorators: [{
556
+ type: Inject,
557
+ args: ['CheckoutSubscriptionRepository']
558
+ }] }, { type: undefined, decorators: [{
559
+ type: Inject,
560
+ args: ['SubscriptionRepository']
561
+ }] }, { type: CouponService }];
562
+ } });
563
+
564
+ class OrderService {
565
+ constructor(angularFirestore, orderRepository) {
566
+ this.angularFirestore = angularFirestore;
567
+ this.orderRepository = orderRepository;
568
+ this.orderSubject = new Subject();
569
+ }
570
+ getOrder(id) {
571
+ docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
572
+ .pipe(map((doc) => Order.toInstance(doc.data())))
573
+ .subscribe((doc) => this.orderSubject.next(doc));
574
+ return this.orderSubject;
575
+ }
576
+ }
577
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
578
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService });
579
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: OrderService, decorators: [{
580
+ type: Injectable
581
+ }], ctorParameters: function () {
582
+ return [{ type: i1$1.Firestore }, { type: i2.OrderFirestoreRepository, decorators: [{
583
+ type: Inject,
584
+ args: ['OrderRepository']
585
+ }] }];
586
+ } });
587
+
588
+ class HomeShopService {
589
+ constructor(categoryRepository, homeRepository, productRepository, defaultShop) {
590
+ this.categoryRepository = categoryRepository;
591
+ this.homeRepository = homeRepository;
592
+ this.productRepository = productRepository;
593
+ this.defaultShop = defaultShop;
594
+ this.buildCategoryGroupWithRequiredData = (group) => {
595
+ var _a, _b;
596
+ return ({
597
+ category: Category.toInstance(pick(((_a = group === null || group === void 0 ? void 0 : group.category) === null || _a === void 0 ? void 0 : _a.toPlain()) || {}, ['id', 'name', 'slug', 'conditions'])),
598
+ products: ((_b = group === null || group === void 0 ? void 0 : group.products) === null || _b === void 0 ? void 0 : _b.map((product) => Product.toInstance(pick((product === null || product === void 0 ? void 0 : product.toPlain()) || {}, [
599
+ 'id',
600
+ 'price',
601
+ 'reviews',
602
+ 'hasVariants',
603
+ 'slug',
604
+ 'sku',
605
+ 'stock',
606
+ 'costPrice',
607
+ 'images',
608
+ 'miniatures',
609
+ 'name',
610
+ 'weight',
611
+ 'rate',
612
+ 'type',
613
+ ])))) || [],
614
+ });
615
+ };
616
+ }
617
+ get homeId() {
618
+ if (this.defaultShop === Shops.GLAMSHOP)
619
+ return 'glamshop';
620
+ if (this.defaultShop === Shops.MENSMARKET)
621
+ return 'mens_market';
622
+ return null;
623
+ }
624
+ getHomeData() {
625
+ return this.getHomeConfiguration().pipe(map((home) => { var _a; return (((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt) > new Date() ? home : null); }), concatMap((home) => home
626
+ ? of(home)
627
+ : forkJoin([this.getDiscoverProducts(), this.getFeaturedProducts(), this.getVerticalProducts()]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
628
+ discoverProducts,
629
+ featuredProducts,
630
+ verticalProducts,
631
+ })), concatMap((data) => this.saveHomeData(data)))));
632
+ }
633
+ getBanners(type) {
634
+ return this.getHomeConfiguration().pipe(map((home) => {
635
+ if (type === 'brand')
636
+ return home.brandsCarousel;
637
+ if (type === 'buyToWin')
638
+ return [home.buyToWinBanner];
639
+ if (type === 'block')
640
+ return home.blockBanners;
641
+ if (type === 'blog')
642
+ return [home.blogBanner];
643
+ return [];
644
+ }));
645
+ }
646
+ getMinValueForFreeShipping() {
647
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
648
+ }
649
+ getDiscoverProducts() {
650
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.discoverCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
651
+ }
652
+ getFeaturedProducts() {
653
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.categoryRepository.getCategoriesForHome(home.featuredCategories)).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
654
+ }
655
+ getVerticalProducts() {
656
+ return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.productRepository.find({
657
+ filters: { categories: { operator: Where.IN, value: [category.id] } },
658
+ limits: { limit: 12 },
659
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
660
+ }
661
+ getHomeConfiguration() {
662
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
663
+ ? of(home)
664
+ : !this.homeId
665
+ ? throwError(new RequiredArgumentError(['homeId']))
666
+ : from(this.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
667
+ }
668
+ saveHomeData(homeData) {
669
+ const data = {
670
+ createdAt: new Date(),
671
+ expiresAt: add(new Date(), { hours: 1 }),
672
+ data: homeData,
673
+ };
674
+ return from(this.homeRepository.update({
675
+ id: this.homeId,
676
+ data,
677
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
678
+ }
679
+ }
680
+ HomeShopService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
681
+ HomeShopService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService });
682
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: HomeShopService, decorators: [{
683
+ type: Injectable
684
+ }], ctorParameters: function () {
685
+ return [{ type: undefined, decorators: [{
686
+ type: Inject,
687
+ args: ['CategoryRepository']
688
+ }] }, { type: undefined, decorators: [{
689
+ type: Inject,
690
+ args: ['HomeRepository']
691
+ }] }, { type: undefined, decorators: [{
692
+ type: Inject,
693
+ args: ['ProductRepository']
694
+ }] }, { type: i2.Shops, decorators: [{
695
+ type: Inject,
696
+ args: [DEFAULT_SHOP]
697
+ }] }];
698
+ } });
699
+
700
+ class AngularFirebaseAuthModule {
701
+ static initializeApp(options, nameOrConfig) {
702
+ return {
703
+ ngModule: AngularFirebaseAuthModule,
704
+ providers: [
705
+ { provide: FIREBASE_OPTIONS, useValue: options },
706
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
707
+ ],
708
+ };
709
+ }
710
+ }
711
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
712
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1$2.FirebaseAppModule, i1.AuthModule] });
713
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
714
+ {
715
+ provide: 'Authentication',
716
+ useFactory: (authenticationService, userRepository) => {
717
+ return new Authentication(authenticationService, userRepository);
718
+ },
719
+ deps: ['AuthenticationService', 'UserRepository'],
720
+ },
721
+ {
722
+ provide: 'AuthenticationService',
723
+ useFactory: (angularFireAuth) => {
724
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
725
+ },
726
+ deps: [Auth],
727
+ },
728
+ {
729
+ provide: 'Register',
730
+ useFactory: (registerService, userRepository) => {
731
+ return new Register(registerService, userRepository);
732
+ },
733
+ deps: ['RegisterService', 'UserRepository'],
734
+ },
735
+ {
736
+ provide: 'RegisterService',
737
+ useFactory: (angularFireAuth) => {
738
+ return new RegisterFirebaseAuthService(angularFireAuth);
739
+ },
740
+ deps: [Auth],
741
+ },
742
+ {
743
+ provide: 'SignOut',
744
+ useFactory: (authenticationService) => {
745
+ return new SignOut(authenticationService);
746
+ },
747
+ deps: ['AuthenticationService'],
748
+ },
749
+ {
750
+ provide: 'RecoveryPassword',
751
+ useFactory: (authenticationService) => {
752
+ return new RecoveryPassword(authenticationService);
753
+ },
754
+ deps: ['AuthenticationService'],
755
+ },
756
+ ], imports: [provideFirebaseApp((injector) => {
757
+ const appName = injector.get(FIREBASE_APP_NAME);
758
+ return appName
759
+ ? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
760
+ : initializeApp(injector.get(FIREBASE_OPTIONS));
761
+ }),
762
+ provideAuth(() => getAuth())] });
763
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
764
+ type: NgModule,
765
+ args: [{
766
+ imports: [
767
+ provideFirebaseApp((injector) => {
768
+ const appName = injector.get(FIREBASE_APP_NAME);
769
+ return appName
770
+ ? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
771
+ : initializeApp(injector.get(FIREBASE_OPTIONS));
772
+ }),
773
+ provideAuth(() => getAuth()),
774
+ ],
775
+ providers: [
776
+ {
777
+ provide: 'Authentication',
778
+ useFactory: (authenticationService, userRepository) => {
779
+ return new Authentication(authenticationService, userRepository);
780
+ },
781
+ deps: ['AuthenticationService', 'UserRepository'],
782
+ },
783
+ {
784
+ provide: 'AuthenticationService',
785
+ useFactory: (angularFireAuth) => {
786
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
787
+ },
788
+ deps: [Auth],
789
+ },
790
+ {
791
+ provide: 'Register',
792
+ useFactory: (registerService, userRepository) => {
793
+ return new Register(registerService, userRepository);
794
+ },
795
+ deps: ['RegisterService', 'UserRepository'],
796
+ },
797
+ {
798
+ provide: 'RegisterService',
799
+ useFactory: (angularFireAuth) => {
800
+ return new RegisterFirebaseAuthService(angularFireAuth);
801
+ },
802
+ deps: [Auth],
803
+ },
804
+ {
805
+ provide: 'SignOut',
806
+ useFactory: (authenticationService) => {
807
+ return new SignOut(authenticationService);
808
+ },
809
+ deps: ['AuthenticationService'],
810
+ },
811
+ {
812
+ provide: 'RecoveryPassword',
813
+ useFactory: (authenticationService) => {
814
+ return new RecoveryPassword(authenticationService);
815
+ },
816
+ deps: ['AuthenticationService'],
817
+ },
818
+ ],
819
+ }]
820
+ }] });
821
+
822
+ class AngularElasticSeachModule {
823
+ static initializeApp(options) {
824
+ return {
825
+ ngModule: AngularElasticSeachModule,
826
+ providers: [{ provide: ES_CONFIG, useValue: options }],
827
+ };
828
+ }
829
+ }
830
+ AngularElasticSeachModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
831
+ AngularElasticSeachModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule });
832
+ AngularElasticSeachModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, providers: [
833
+ {
834
+ provide: ProductsIndex,
835
+ useFactory: (configuration) => {
836
+ return new ProductsIndex(new AxiosAdapter(configuration));
837
+ },
838
+ deps: [ES_CONFIG],
839
+ },
840
+ ] });
841
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
842
+ type: NgModule,
843
+ args: [{
844
+ providers: [
845
+ {
846
+ provide: ProductsIndex,
847
+ useFactory: (configuration) => {
848
+ return new ProductsIndex(new AxiosAdapter(configuration));
849
+ },
850
+ deps: [ES_CONFIG],
851
+ },
852
+ ],
853
+ }]
854
+ }] });
855
+
856
+ class AngularFirestoreModule {
857
+ static initializeApp(options, nameOrConfig) {
858
+ return {
859
+ ngModule: AngularFirestoreModule,
860
+ providers: [
861
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
862
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
863
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
864
+ ],
865
+ };
866
+ }
867
+ }
868
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
869
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$2.FirebaseAppModule, i1$1.FirestoreModule] });
870
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, providers: [
871
+ {
872
+ provide: 'BeautyProfileRepository',
873
+ useFactory: (firestore, userRepository) => {
874
+ return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
875
+ },
876
+ deps: [Firestore, 'UserRepository'],
877
+ },
878
+ {
879
+ provide: 'Buy2WinRepository',
880
+ useFactory: (firestore) => {
881
+ return new Buy2WinFirestoreRepository(firestore);
882
+ },
883
+ deps: [Firestore],
884
+ },
885
+ {
886
+ provide: CategoryFirestoreRepository,
887
+ useFactory: (firestore) => {
888
+ return new CategoryFirestoreRepository(firestore);
889
+ },
890
+ deps: [Firestore],
891
+ },
892
+ {
893
+ provide: 'CheckoutRepository',
894
+ useFactory: (firestore) => {
895
+ return new CheckoutFirestoreRepository(firestore);
896
+ },
897
+ deps: [Firestore],
898
+ },
899
+ {
900
+ provide: 'CheckoutSubscriptionRepository',
901
+ useFactory: (firestore) => {
902
+ return new CheckoutSubscriptionFirestoreRepository(firestore);
903
+ },
904
+ deps: [Firestore],
905
+ },
906
+ {
907
+ provide: 'CouponRepository',
908
+ useFactory: (firestore) => {
909
+ return new CouponFirestoreRepository(firestore);
910
+ },
911
+ deps: [Firestore],
912
+ },
913
+ {
914
+ provide: 'EditionRepository',
915
+ useFactory: (firestore, subscriptionRepository) => {
916
+ return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
917
+ },
918
+ deps: [Firestore, 'SubscriptionRepository'],
919
+ },
920
+ {
921
+ provide: 'HomeRepository',
922
+ useFactory: (firestore) => {
923
+ return new HomeFirestoreRepository(firestore);
924
+ },
925
+ deps: [Firestore],
926
+ },
927
+ {
928
+ provide: 'LeadRepository',
929
+ useFactory: (firestore) => {
930
+ return new LeadFirestoreRepository(firestore);
931
+ },
932
+ deps: [Firestore],
933
+ },
934
+ {
935
+ provide: 'LegacyOrderRepository',
936
+ useFactory: (firestore) => {
937
+ return new LegacyOrderFirestoreRepository(firestore);
938
+ },
939
+ deps: [Firestore],
940
+ },
941
+ {
942
+ provide: 'ShopMenuRepository',
943
+ useFactory: (firestore) => {
944
+ return new ShopMenuFirestoreRepository(firestore);
945
+ },
946
+ deps: [Firestore],
947
+ },
948
+ {
949
+ provide: 'OrderRepository',
950
+ useFactory: (firestore) => {
951
+ return new OrderFirestoreRepository(firestore);
952
+ },
953
+ deps: [Firestore],
954
+ },
955
+ {
956
+ provide: 'PaymentRepository',
957
+ useFactory: (firestore) => {
958
+ return new PaymentFirestoreRepository(firestore);
959
+ },
960
+ deps: [Firestore],
961
+ },
962
+ {
963
+ provide: ProductFirestoreRepository,
964
+ useFactory: (firestore) => {
965
+ return new ProductFirestoreRepository(firestore);
966
+ },
967
+ deps: [Firestore],
968
+ },
969
+ {
970
+ provide: 'SubscriptionPaymentRepository',
971
+ useFactory: (firestore, subscriptionRepository) => {
972
+ return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
973
+ },
974
+ deps: [Firestore, 'SubscriptionRepository'],
975
+ },
976
+ {
977
+ provide: 'SubscriptionPlanRepository',
978
+ useFactory: (firestore) => {
979
+ return new SubscriptionPlanFirestoreRepository(firestore);
980
+ },
981
+ deps: [Firestore],
982
+ },
983
+ {
984
+ provide: 'SubscriptionProductRepository',
985
+ useFactory: (firestore) => {
986
+ return new SubscriptionProductFirestoreRepository(firestore);
987
+ },
988
+ deps: [Firestore],
989
+ },
990
+ {
991
+ provide: 'SubscriptionRepository',
992
+ useFactory: (firestore) => {
993
+ return new SubscriptionFirestoreRepository(firestore);
994
+ },
995
+ deps: [Firestore],
996
+ },
997
+ {
998
+ provide: 'UserRepository',
999
+ useFactory: (firestore) => {
1000
+ return new UserFirestoreRepository(firestore);
1001
+ },
1002
+ deps: [Firestore],
1003
+ },
1004
+ {
1005
+ provide: 'UserAddressRepository',
1006
+ useFactory: (firestore, userRepository) => {
1007
+ return new UserAddressFirestoreRepository(firestore, userRepository);
1008
+ },
1009
+ deps: [Firestore, 'UserRepository'],
1010
+ },
1011
+ {
1012
+ provide: 'UserPaymentMethodRepository',
1013
+ useFactory: (firestore, userRepository) => {
1014
+ return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
1015
+ },
1016
+ deps: [Firestore, 'UserRepository'],
1017
+ },
1018
+ {
1019
+ provide: ProductVariantFirestoreRepository,
1020
+ useFactory: (firestore, productRepository) => {
1021
+ return new ProductVariantFirestoreRepository(firestore, productRepository);
1022
+ },
1023
+ deps: [Firestore, ProductFirestoreRepository],
1024
+ },
1025
+ ], imports: [AngularElasticSeachModule,
1026
+ provideFirebaseApp((injector) => {
1027
+ const appName = injector.get(FIREBASE_APP_NAME);
1028
+ return appName
1029
+ ? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
1030
+ : initializeApp(injector.get(FIREBASE_OPTIONS));
1031
+ }),
1032
+ provideFirestore(() => getFirestore())] });
1033
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularFirestoreModule, decorators: [{
1034
+ type: NgModule,
1035
+ args: [{
1036
+ imports: [
1037
+ AngularElasticSeachModule,
1038
+ provideFirebaseApp((injector) => {
1039
+ const appName = injector.get(FIREBASE_APP_NAME);
1040
+ return appName
1041
+ ? initializeApp(injector.get(FIREBASE_OPTIONS), appName)
1042
+ : initializeApp(injector.get(FIREBASE_OPTIONS));
1043
+ }),
1044
+ provideFirestore(() => getFirestore()),
1045
+ ],
1046
+ providers: [
1047
+ {
1048
+ provide: 'BeautyProfileRepository',
1049
+ useFactory: (firestore, userRepository) => {
1050
+ return new UserBeautyProfileFirestoreRepository(firestore, userRepository);
1051
+ },
1052
+ deps: [Firestore, 'UserRepository'],
1053
+ },
1054
+ {
1055
+ provide: 'Buy2WinRepository',
1056
+ useFactory: (firestore) => {
1057
+ return new Buy2WinFirestoreRepository(firestore);
1058
+ },
1059
+ deps: [Firestore],
1060
+ },
1061
+ {
1062
+ provide: CategoryFirestoreRepository,
1063
+ useFactory: (firestore) => {
1064
+ return new CategoryFirestoreRepository(firestore);
1065
+ },
1066
+ deps: [Firestore],
1067
+ },
1068
+ {
1069
+ provide: 'CheckoutRepository',
1070
+ useFactory: (firestore) => {
1071
+ return new CheckoutFirestoreRepository(firestore);
1072
+ },
1073
+ deps: [Firestore],
1074
+ },
1075
+ {
1076
+ provide: 'CheckoutSubscriptionRepository',
1077
+ useFactory: (firestore) => {
1078
+ return new CheckoutSubscriptionFirestoreRepository(firestore);
1079
+ },
1080
+ deps: [Firestore],
1081
+ },
1082
+ {
1083
+ provide: 'CouponRepository',
1084
+ useFactory: (firestore) => {
1085
+ return new CouponFirestoreRepository(firestore);
1086
+ },
1087
+ deps: [Firestore],
1088
+ },
1089
+ {
1090
+ provide: 'EditionRepository',
1091
+ useFactory: (firestore, subscriptionRepository) => {
1092
+ return new SubscriptionEditionFirestoreRepository(firestore, subscriptionRepository);
1093
+ },
1094
+ deps: [Firestore, 'SubscriptionRepository'],
1095
+ },
1096
+ {
1097
+ provide: 'HomeRepository',
1098
+ useFactory: (firestore) => {
1099
+ return new HomeFirestoreRepository(firestore);
1100
+ },
1101
+ deps: [Firestore],
1102
+ },
1103
+ {
1104
+ provide: 'LeadRepository',
1105
+ useFactory: (firestore) => {
1106
+ return new LeadFirestoreRepository(firestore);
1107
+ },
1108
+ deps: [Firestore],
1109
+ },
1110
+ {
1111
+ provide: 'LegacyOrderRepository',
1112
+ useFactory: (firestore) => {
1113
+ return new LegacyOrderFirestoreRepository(firestore);
1114
+ },
1115
+ deps: [Firestore],
1116
+ },
1117
+ {
1118
+ provide: 'ShopMenuRepository',
1119
+ useFactory: (firestore) => {
1120
+ return new ShopMenuFirestoreRepository(firestore);
1121
+ },
1122
+ deps: [Firestore],
1123
+ },
1124
+ {
1125
+ provide: 'OrderRepository',
1126
+ useFactory: (firestore) => {
1127
+ return new OrderFirestoreRepository(firestore);
1128
+ },
1129
+ deps: [Firestore],
1130
+ },
1131
+ {
1132
+ provide: 'PaymentRepository',
1133
+ useFactory: (firestore) => {
1134
+ return new PaymentFirestoreRepository(firestore);
1135
+ },
1136
+ deps: [Firestore],
1137
+ },
1138
+ {
1139
+ provide: ProductFirestoreRepository,
1140
+ useFactory: (firestore) => {
1141
+ return new ProductFirestoreRepository(firestore);
1142
+ },
1143
+ deps: [Firestore],
1144
+ },
1145
+ {
1146
+ provide: 'SubscriptionPaymentRepository',
1147
+ useFactory: (firestore, subscriptionRepository) => {
1148
+ return new SubscriptionPaymentFirestoreRepository(firestore, subscriptionRepository);
1149
+ },
1150
+ deps: [Firestore, 'SubscriptionRepository'],
1151
+ },
1152
+ {
1153
+ provide: 'SubscriptionPlanRepository',
1154
+ useFactory: (firestore) => {
1155
+ return new SubscriptionPlanFirestoreRepository(firestore);
1156
+ },
1157
+ deps: [Firestore],
1158
+ },
1159
+ {
1160
+ provide: 'SubscriptionProductRepository',
1161
+ useFactory: (firestore) => {
1162
+ return new SubscriptionProductFirestoreRepository(firestore);
1163
+ },
1164
+ deps: [Firestore],
1165
+ },
1166
+ {
1167
+ provide: 'SubscriptionRepository',
1168
+ useFactory: (firestore) => {
1169
+ return new SubscriptionFirestoreRepository(firestore);
1170
+ },
1171
+ deps: [Firestore],
1172
+ },
1173
+ {
1174
+ provide: 'UserRepository',
1175
+ useFactory: (firestore) => {
1176
+ return new UserFirestoreRepository(firestore);
1177
+ },
1178
+ deps: [Firestore],
1179
+ },
1180
+ {
1181
+ provide: 'UserAddressRepository',
1182
+ useFactory: (firestore, userRepository) => {
1183
+ return new UserAddressFirestoreRepository(firestore, userRepository);
1184
+ },
1185
+ deps: [Firestore, 'UserRepository'],
1186
+ },
1187
+ {
1188
+ provide: 'UserPaymentMethodRepository',
1189
+ useFactory: (firestore, userRepository) => {
1190
+ return new UserPaymentMethodFirestoreRepository(firestore, userRepository);
1191
+ },
1192
+ deps: [Firestore, 'UserRepository'],
1193
+ },
1194
+ {
1195
+ provide: ProductVariantFirestoreRepository,
1196
+ useFactory: (firestore, productRepository) => {
1197
+ return new ProductVariantFirestoreRepository(firestore, productRepository);
1198
+ },
1199
+ deps: [Firestore, ProductFirestoreRepository],
1200
+ },
1201
+ ],
1202
+ }]
1203
+ }] });
1204
+
1205
+ const processes = {};
1206
+ class AngularHasuraGraphQLModule {
1207
+ static initializeApp(options) {
1208
+ return {
1209
+ ngModule: AngularHasuraGraphQLModule,
1210
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
1211
+ };
1212
+ }
1213
+ }
1214
+ AngularHasuraGraphQLModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1215
+ AngularHasuraGraphQLModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule });
1216
+ AngularHasuraGraphQLModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
1217
+ {
1218
+ provide: 'HasuraConfig',
1219
+ useFactory: (options, platformId) => ({
1220
+ endpoint: options.endpoint,
1221
+ authOptions: options.credentials,
1222
+ interceptors: {
1223
+ request: (request) => {
1224
+ if (isPlatformBrowser(platformId))
1225
+ return request;
1226
+ const index = Date.now();
1227
+ processes[index] = true;
1228
+ request.proccess = index;
1229
+ console.log('request', request.proccess);
1230
+ return request;
1231
+ },
1232
+ response: (response, request) => {
1233
+ if (isPlatformBrowser(platformId))
1234
+ return response;
1235
+ console.log('response', request.proccess);
1236
+ delete processes[request.proccess];
1237
+ },
1238
+ },
1239
+ }),
1240
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
1241
+ },
1242
+ {
1243
+ provide: 'CategoryRepository',
1244
+ useExisting: CategoryHasuraGraphQLRepository,
1245
+ },
1246
+ {
1247
+ provide: CategoryHasuraGraphQLRepository,
1248
+ useFactory: (hasuraConfig, productRepository) => {
1249
+ return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
1250
+ },
1251
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1252
+ },
1253
+ {
1254
+ provide: 'ProductRepository',
1255
+ useExisting: ProductHasuraGraphQLRepository,
1256
+ },
1257
+ {
1258
+ provide: ProductHasuraGraphQLRepository,
1259
+ useFactory: (hasuraConfig) => {
1260
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
1261
+ },
1262
+ deps: ['HasuraConfig'],
1263
+ },
1264
+ {
1265
+ provide: 'VariantRepository',
1266
+ useExisting: VariantHasuraGraphQLRepository,
1267
+ },
1268
+ {
1269
+ provide: VariantHasuraGraphQLRepository,
1270
+ useFactory: (hasuraConfig) => {
1271
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
1272
+ },
1273
+ deps: ['HasuraConfig'],
1274
+ },
1275
+ ] });
1276
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
1277
+ type: NgModule,
1278
+ args: [{
1279
+ providers: [
1280
+ {
1281
+ provide: 'HasuraConfig',
1282
+ useFactory: (options, platformId) => ({
1283
+ endpoint: options.endpoint,
1284
+ authOptions: options.credentials,
1285
+ interceptors: {
1286
+ request: (request) => {
1287
+ if (isPlatformBrowser(platformId))
1288
+ return request;
1289
+ const index = Date.now();
1290
+ processes[index] = true;
1291
+ request.proccess = index;
1292
+ console.log('request', request.proccess);
1293
+ return request;
1294
+ },
1295
+ response: (response, request) => {
1296
+ if (isPlatformBrowser(platformId))
1297
+ return response;
1298
+ console.log('response', request.proccess);
1299
+ delete processes[request.proccess];
1300
+ },
1301
+ },
1302
+ }),
1303
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
1304
+ },
1305
+ {
1306
+ provide: 'CategoryRepository',
1307
+ useExisting: CategoryHasuraGraphQLRepository,
1308
+ },
1309
+ {
1310
+ provide: CategoryHasuraGraphQLRepository,
1311
+ useFactory: (hasuraConfig, productRepository) => {
1312
+ return new CategoryHasuraGraphQLRepository(hasuraConfig, productRepository);
1313
+ },
1314
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1315
+ },
1316
+ {
1317
+ provide: 'ProductRepository',
1318
+ useExisting: ProductHasuraGraphQLRepository,
1319
+ },
1320
+ {
1321
+ provide: ProductHasuraGraphQLRepository,
1322
+ useFactory: (hasuraConfig) => {
1323
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
1324
+ },
1325
+ deps: ['HasuraConfig'],
1326
+ },
1327
+ {
1328
+ provide: 'VariantRepository',
1329
+ useExisting: VariantHasuraGraphQLRepository,
1330
+ },
1331
+ {
1332
+ provide: VariantHasuraGraphQLRepository,
1333
+ useFactory: (hasuraConfig) => {
1334
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
1335
+ },
1336
+ deps: ['HasuraConfig'],
1337
+ },
1338
+ ],
1339
+ }]
1340
+ }] });
1341
+
1342
+ class AngularConnectModule {
1343
+ static initializeApp(defaultShop, options, nameOrConfig) {
1344
+ return {
1345
+ ngModule: AngularConnectModule,
1346
+ providers: [
1347
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
1348
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options === null || options === void 0 ? void 0 : options.firebase }]),
1349
+ ...(isNil(options === null || options === void 0 ? void 0 : options.firebase) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
1350
+ ...(isNil(options === null || options === void 0 ? void 0 : options.elasticSearch) ? [] : [{ provide: ES_CONFIG, useValue: options.elasticSearch }]),
1351
+ ...(isNil(options === null || options === void 0 ? void 0 : options.hasura) ? [] : [{ provide: HASURA_OPTIONS, useValue: options.hasura }]),
1352
+ ],
1353
+ };
1354
+ }
1355
+ }
1356
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1357
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1358
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, providers: [
1359
+ AuthService,
1360
+ CartService,
1361
+ CheckoutService,
1362
+ CheckoutSubscriptionService,
1363
+ CouponService,
1364
+ HomeShopService,
1365
+ OrderService,
1366
+ ], imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule] });
1367
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.1.0", ngImport: i0, type: AngularConnectModule, decorators: [{
1368
+ type: NgModule,
1369
+ args: [{
1370
+ imports: [AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule],
1371
+ providers: [
1372
+ AuthService,
1373
+ CartService,
1374
+ CheckoutService,
1375
+ CheckoutSubscriptionService,
1376
+ CouponService,
1377
+ HomeShopService,
1378
+ OrderService,
1379
+ ],
1380
+ }]
1381
+ }] });
1382
+
1383
+ /**
1384
+ * Generated bundle index. Do not edit.
1385
+ */
1386
+
1387
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CheckoutService, CheckoutSubscriptionService, CouponService, HomeShopService, OrderService };
1388
+ //# sourceMappingURL=infrab4a-connect-angular.mjs.map