@infrab4a/connect-angular 0.6.2 → 0.6.3

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 (35) hide show
  1. package/bundles/infrab4a-connect-angular.umd.js +962 -959
  2. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  3. package/esm2015/infrab4a-connect-angular.js +4 -4
  4. package/esm2015/lib/angular-connect.module.js +30 -30
  5. package/esm2015/lib/angular-firebase-auth.module.js +71 -71
  6. package/esm2015/lib/angular-firestore.module.js +295 -295
  7. package/esm2015/lib/consts/default-shop.const.js +2 -2
  8. package/esm2015/lib/consts/index.js +2 -2
  9. package/esm2015/lib/index.js +5 -5
  10. package/esm2015/lib/services/auth.service.js +30 -27
  11. package/esm2015/lib/services/cart.service.js +153 -153
  12. package/esm2015/lib/services/checkout.service.js +57 -57
  13. package/esm2015/lib/services/index.js +5 -5
  14. package/esm2015/lib/services/order.service.js +32 -32
  15. package/esm2015/lib/services/types/index.js +2 -2
  16. package/esm2015/lib/services/types/required-checkout-data.type.js +2 -2
  17. package/esm2015/public-api.js +2 -2
  18. package/fesm2015/infrab4a-connect-angular.js +606 -603
  19. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  20. package/infrab4a-connect-angular.d.ts +5 -5
  21. package/lib/angular-connect.module.d.ts +12 -12
  22. package/lib/angular-firebase-auth.module.d.ts +10 -10
  23. package/lib/angular-firestore.module.d.ts +10 -10
  24. package/lib/consts/default-shop.const.d.ts +1 -1
  25. package/lib/consts/index.d.ts +1 -1
  26. package/lib/index.d.ts +4 -4
  27. package/lib/services/auth.service.d.ts +15 -13
  28. package/lib/services/cart.service.d.ts +35 -35
  29. package/lib/services/checkout.service.d.ts +18 -18
  30. package/lib/services/index.d.ts +4 -4
  31. package/lib/services/order.service.d.ts +13 -13
  32. package/lib/services/types/index.d.ts +1 -1
  33. package/lib/services/types/required-checkout-data.type.d.ts +2 -2
  34. package/package.json +2 -2
  35. package/public-api.d.ts +1 -1
@@ -2,7 +2,7 @@ import * as i0 from '@angular/core';
2
2
  import { Injectable, Inject, NgModule } from '@angular/core';
3
3
  import * as i1 from '@angular/fire/auth';
4
4
  import { AngularFireAuth } from '@angular/fire/auth';
5
- import { from, throwError, of, Subject, iif } from 'rxjs';
5
+ import { throwError, from, of, Subject, iif } from 'rxjs';
6
6
  import { map, mergeMap, concatMap, tap, catchError } from 'rxjs/operators';
7
7
  import * as i1$1 from '@infrab4a/connect';
8
8
  import { isNil, NotFoundError, Checkout, pick, LineItem, CouponTypes, FinancialCoupon, CouponSubtypes, Order, Authentication, AuthenticationFirebaseAuthService, SignOut, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, SubscriptionEditionFirestoreRepository, HomeFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, ProductVariantFirestoreRepository } from '@infrab4a/connect';
@@ -12,624 +12,627 @@ import * as i1$2 from '@angular/fire/firestore';
12
12
  import { AngularFirestore } from '@angular/fire/firestore';
13
13
  import { FIREBASE_OPTIONS, FIREBASE_APP_NAME, AngularFireModule } from '@angular/fire';
14
14
 
15
- class AuthService {
16
- constructor(angularFireAuth, userRepository) {
17
- this.angularFireAuth = angularFireAuth;
18
- this.userRepository = userRepository;
19
- }
20
- getUser() {
21
- return from(this.getTokenId()).pipe(map((id) => id || throwError(() => new Error('Usuário não logado'))), mergeMap((id) => this.userRepository.get({ id })));
22
- }
23
- getTokenId() {
24
- return this.angularFireAuth.idToken;
25
- }
26
- }
27
- AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
28
- AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService });
29
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService, decorators: [{
30
- type: Injectable
31
- }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
32
- type: Inject,
33
- args: ['UserRepository']
15
+ class AuthService {
16
+ constructor(angularFireAuth, userRepository) {
17
+ this.angularFireAuth = angularFireAuth;
18
+ this.userRepository = userRepository;
19
+ }
20
+ getUser() {
21
+ return this.getFireUser().pipe(map((user) => user.uid || throwError(() => new Error('Usuário não logado'))), mergeMap((id) => this.userRepository.get({ id })));
22
+ }
23
+ getTokenId() {
24
+ return this.angularFireAuth.idToken;
25
+ }
26
+ getFireUser() {
27
+ return this.angularFireAuth.user;
28
+ }
29
+ }
30
+ AuthService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService, deps: [{ token: i1.AngularFireAuth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
31
+ AuthService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService });
32
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AuthService, decorators: [{
33
+ type: Injectable
34
+ }], ctorParameters: function () { return [{ type: i1.AngularFireAuth }, { type: undefined, decorators: [{
35
+ type: Inject,
36
+ args: ['UserRepository']
34
37
  }] }]; } });
35
38
 
36
39
  const DEFAULT_SHOP = 'DEFAULT_SHOP';
37
40
 
38
- class CheckoutService {
39
- constructor(checkoutRepository, userRepository, defaultShop) {
40
- this.checkoutRepository = checkoutRepository;
41
- this.userRepository = userRepository;
42
- this.defaultShop = defaultShop;
43
- }
44
- getCheckout(checkoutData) {
45
- const checkoutId = cookie.get('checkoutId');
46
- if (!isNil(checkoutId))
47
- return from(this.checkoutRepository.get({ id: checkoutId }));
48
- return from(this.createCheckout(checkoutData));
49
- }
50
- getUserByCheckout(checkoutId) {
51
- 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'))));
52
- }
53
- updateCheckoutLineItems(checkout) {
54
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
55
- }
56
- updateCheckoutUser(checkout) {
57
- return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
58
- }
59
- clearCheckoutFromSession() {
60
- cookie.remove('checkoutId');
61
- return of();
62
- }
63
- createCheckout(checkoutData) {
64
- return __awaiter(this, void 0, void 0, function* () {
65
- 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 }));
66
- cookie.set('checkoutId', checkout.id);
67
- return checkout;
68
- });
69
- }
70
- }
71
- CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
72
- CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService });
73
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService, decorators: [{
74
- type: Injectable
75
- }], ctorParameters: function () { return [{ type: undefined, decorators: [{
76
- type: Inject,
77
- args: ['CheckoutRepository']
78
- }] }, { type: undefined, decorators: [{
79
- type: Inject,
80
- args: ['UserRepository']
81
- }] }, { type: i1$1.Shops, decorators: [{
82
- type: Inject,
83
- args: [DEFAULT_SHOP]
41
+ class CheckoutService {
42
+ constructor(checkoutRepository, userRepository, defaultShop) {
43
+ this.checkoutRepository = checkoutRepository;
44
+ this.userRepository = userRepository;
45
+ this.defaultShop = defaultShop;
46
+ }
47
+ getCheckout(checkoutData) {
48
+ const checkoutId = cookie.get('checkoutId');
49
+ if (!isNil(checkoutId))
50
+ return from(this.checkoutRepository.get({ id: checkoutId }));
51
+ return from(this.createCheckout(checkoutData));
52
+ }
53
+ getUserByCheckout(checkoutId) {
54
+ 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'))));
55
+ }
56
+ updateCheckoutLineItems(checkout) {
57
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
58
+ }
59
+ updateCheckoutUser(checkout) {
60
+ return from(this.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
61
+ }
62
+ clearCheckoutFromSession() {
63
+ cookie.remove('checkoutId');
64
+ return of();
65
+ }
66
+ createCheckout(checkoutData) {
67
+ return __awaiter(this, void 0, void 0, function* () {
68
+ 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 }));
69
+ cookie.set('checkoutId', checkout.id);
70
+ return checkout;
71
+ });
72
+ }
73
+ }
74
+ CheckoutService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
75
+ CheckoutService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService });
76
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CheckoutService, decorators: [{
77
+ type: Injectable
78
+ }], ctorParameters: function () { return [{ type: undefined, decorators: [{
79
+ type: Inject,
80
+ args: ['CheckoutRepository']
81
+ }] }, { type: undefined, decorators: [{
82
+ type: Inject,
83
+ args: ['UserRepository']
84
+ }] }, { type: i1$1.Shops, decorators: [{
85
+ type: Inject,
86
+ args: [DEFAULT_SHOP]
84
87
  }] }]; } });
85
88
 
86
- class CartService {
87
- constructor(authService, checkoutService, defaultShop) {
88
- this.authService = authService;
89
- this.checkoutService = checkoutService;
90
- this.defaultShop = defaultShop;
91
- this.cartSubject = new Subject();
92
- this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
93
- var _a;
94
- const items = [];
95
- const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
96
- if (index > -1) {
97
- checkoutLoaded.lineItems[index].quantity += quantity;
98
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
99
- }
100
- else
101
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
102
- return this.checkoutService
103
- .updateCheckoutLineItems(checkoutLoaded)
104
- .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
105
- }));
106
- this.generateCartObject = (items) => {
107
- const cart = {};
108
- items === null || items === void 0 ? void 0 : items.forEach((item) => {
109
- var _a;
110
- 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) })));
111
- });
112
- return cart;
113
- };
114
- this.buildLineItem = ({ checkout, item, quantity, }) => {
115
- var _a, _b, _c, _d, _e;
116
- 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;
117
- if (this.checkMaxStock(item, quantity || 0))
118
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
119
- const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
120
- const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
121
- const isGift = item.isGift || null;
122
- const pricePaid = this.getProductPrice({
123
- product: item,
124
- shop: checkout.shop || this.defaultShop,
125
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
126
- });
127
- return LineItem.toInstance({
128
- id,
129
- name,
130
- brand,
131
- slug,
132
- sku,
133
- stock,
134
- price,
135
- image,
136
- weight,
137
- quantity: (item.quantity || 0) + (quantity || 0),
138
- pricePaid,
139
- categories,
140
- isGift,
141
- });
142
- };
143
- this.getProductPrice = ({ product, shop, isSubscriber, }) => {
144
- const info = product.getInfoByShop(shop);
145
- if (product.isGift)
146
- return 0;
147
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
148
- };
149
- this.checkMaxStock = (item, quantity) => {
150
- var _a;
151
- const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
152
- const currentItemAmount = item.quantity || 0;
153
- return currentItemAmount + quantity > maxStock;
154
- };
155
- }
156
- addItem(item, quantity = 1) {
157
- return this.checkoutService.getCheckout().pipe(map((checkout) => ({ checkout, lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }) })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
158
- }
159
- decreaseItem(item) {
160
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
161
- var _a;
162
- const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
163
- if (!isNil(checkoutItem))
164
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
165
- return checkout;
166
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
167
- }
168
- getCart(checkout) {
169
- this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
170
- return this.cartSubject;
171
- }
172
- getDiscount(coupon) {
173
- switch (coupon.type) {
174
- case CouponTypes.FINANCIAL:
175
- return this.getFinancialDiscount(coupon);
176
- case CouponTypes.PRODUCT:
177
- return (subTotalPrice) => subTotalPrice;
178
- case CouponTypes.GIFTCARD:
179
- return this.getFinancialDiscount(coupon);
180
- case CouponTypes.VOUCHER:
181
- return (subTotalPrice) => subTotalPrice;
182
- }
183
- }
184
- getVariantPriceDiscount(item, shop) {
185
- return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
186
- }
187
- removeItem(item) {
188
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
189
- const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
190
- if (index >= 0)
191
- checkout.lineItems.splice(index, 1);
192
- return checkout;
193
- }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
194
- }
195
- updateUserCart(user) {
196
- return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map((item) => this.buildLineItem({ checkout, item })) })))), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
197
- }
198
- clearCart() {
199
- return this.checkoutService.getCheckout().pipe(map((checkout) => {
200
- this.checkoutService.clearCheckoutFromSession();
201
- return checkout;
202
- }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
203
- }
204
- buildCartFromCheckout(checkoutData) {
205
- return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
206
- }
207
- getFinancialDiscount(coupon) {
208
- return (subTotalPrice) => {
209
- if (FinancialCoupon.isFinancialCoupon(coupon))
210
- switch (coupon.subtype) {
211
- case CouponSubtypes.ABSOLUTE:
212
- return subTotalPrice - coupon.discount * 100;
213
- case CouponSubtypes.PERCENTAGE:
214
- return subTotalPrice * (1 - coupon.discount / 100);
215
- }
216
- };
217
- }
218
- }
219
- CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
220
- CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService });
221
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService, decorators: [{
222
- type: Injectable
223
- }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
224
- type: Inject,
225
- args: [DEFAULT_SHOP]
89
+ class CartService {
90
+ constructor(authService, checkoutService, defaultShop) {
91
+ this.authService = authService;
92
+ this.checkoutService = checkoutService;
93
+ this.defaultShop = defaultShop;
94
+ this.cartSubject = new Subject();
95
+ this.updateLineItemInCart = (lineItem, quantity, checkout) => (isNil(checkout) ? this.checkoutService.getCheckout() : of(checkout)).pipe(concatMap((checkoutLoaded) => {
96
+ var _a;
97
+ const items = [];
98
+ const index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map((checkoutItem) => checkoutItem.sku).indexOf(lineItem.sku);
99
+ if (index > -1) {
100
+ checkoutLoaded.lineItems[index].quantity += quantity;
101
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
102
+ }
103
+ else
104
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
105
+ return this.checkoutService
106
+ .updateCheckoutLineItems(checkoutLoaded)
107
+ .pipe(map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)));
108
+ }));
109
+ this.generateCartObject = (items) => {
110
+ const cart = {};
111
+ items === null || items === void 0 ? void 0 : items.forEach((item) => {
112
+ var _a;
113
+ 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) })));
114
+ });
115
+ return cart;
116
+ };
117
+ this.buildLineItem = ({ checkout, item, quantity, }) => {
118
+ var _a, _b, _c, _d, _e;
119
+ 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;
120
+ if (this.checkMaxStock(item, quantity || 0))
121
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
122
+ const image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
123
+ const { id, name, brand, slug, stock, price, weight, categories, sku } = item;
124
+ const isGift = item.isGift || null;
125
+ const pricePaid = this.getProductPrice({
126
+ product: item,
127
+ shop: checkout.shop || this.defaultShop,
128
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
129
+ });
130
+ return LineItem.toInstance({
131
+ id,
132
+ name,
133
+ brand,
134
+ slug,
135
+ sku,
136
+ stock,
137
+ price,
138
+ image,
139
+ weight,
140
+ quantity: (item.quantity || 0) + (quantity || 0),
141
+ pricePaid,
142
+ categories,
143
+ isGift,
144
+ });
145
+ };
146
+ this.getProductPrice = ({ product, shop, isSubscriber, }) => {
147
+ const info = product.getInfoByShop(shop);
148
+ if (product.isGift)
149
+ return 0;
150
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
151
+ };
152
+ this.checkMaxStock = (item, quantity) => {
153
+ var _a;
154
+ const maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
155
+ const currentItemAmount = item.quantity || 0;
156
+ return currentItemAmount + quantity > maxStock;
157
+ };
158
+ }
159
+ addItem(item, quantity = 1) {
160
+ return this.checkoutService.getCheckout().pipe(map((checkout) => ({ checkout, lineItem: this.buildLineItem({ checkout, item, quantity: quantity || 1 }) })), concatMap(({ checkout, lineItem }) => this.updateLineItemInCart(lineItem, quantity || 1, checkout)), tap((cart) => this.cartSubject.next(cart)));
161
+ }
162
+ decreaseItem(item) {
163
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
164
+ var _a;
165
+ const checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find((lineItem) => lineItem.sku === item.sku);
166
+ if (!isNil(checkoutItem))
167
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
168
+ return checkout;
169
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
170
+ }
171
+ getCart(checkout) {
172
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
173
+ return this.cartSubject;
174
+ }
175
+ getDiscount(coupon) {
176
+ switch (coupon.type) {
177
+ case CouponTypes.FINANCIAL:
178
+ return this.getFinancialDiscount(coupon);
179
+ case CouponTypes.PRODUCT:
180
+ return (subTotalPrice) => subTotalPrice;
181
+ case CouponTypes.GIFTCARD:
182
+ return this.getFinancialDiscount(coupon);
183
+ case CouponTypes.VOUCHER:
184
+ return (subTotalPrice) => subTotalPrice;
185
+ }
186
+ }
187
+ getVariantPriceDiscount(item, shop) {
188
+ return this.authService.getUser().pipe(concatMap((user) => iif(() => user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice, of(item.getInfoByShop(shop).subscriberPrice), of(item.getInfoByShop(shop).price))), catchError(() => of(item.getInfoByShop(shop).price)));
189
+ }
190
+ removeItem(item) {
191
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
192
+ const index = checkout.lineItems.findIndex((lineItem) => lineItem.sku === item.sku);
193
+ if (index >= 0)
194
+ checkout.lineItems.splice(index, 1);
195
+ return checkout;
196
+ }), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(checkout)), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
197
+ }
198
+ updateUserCart(user) {
199
+ return this.checkoutService.getCheckout().pipe(concatMap((checkout) => this.checkoutService.updateCheckoutUser(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { user })))), concatMap((checkout) => this.checkoutService.updateCheckoutLineItems(Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: checkout.lineItems.map((item) => this.buildLineItem({ checkout, item })) })))), map((checkout) => this.generateCartObject(checkout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
200
+ }
201
+ clearCart() {
202
+ return this.checkoutService.getCheckout().pipe(map((checkout) => {
203
+ this.checkoutService.clearCheckoutFromSession();
204
+ return checkout;
205
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
206
+ }
207
+ buildCartFromCheckout(checkoutData) {
208
+ return this.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
209
+ }
210
+ getFinancialDiscount(coupon) {
211
+ return (subTotalPrice) => {
212
+ if (FinancialCoupon.isFinancialCoupon(coupon))
213
+ switch (coupon.subtype) {
214
+ case CouponSubtypes.ABSOLUTE:
215
+ return subTotalPrice - coupon.discount * 100;
216
+ case CouponSubtypes.PERCENTAGE:
217
+ return subTotalPrice * (1 - coupon.discount / 100);
218
+ }
219
+ };
220
+ }
221
+ }
222
+ CartService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService, deps: [{ token: AuthService }, { token: CheckoutService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable });
223
+ CartService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService });
224
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: CartService, decorators: [{
225
+ type: Injectable
226
+ }], ctorParameters: function () { return [{ type: AuthService }, { type: CheckoutService }, { type: i1$1.Shops, decorators: [{
227
+ type: Inject,
228
+ args: [DEFAULT_SHOP]
226
229
  }] }]; } });
227
230
 
228
- class OrderService {
229
- constructor(angularFirestore, orderRepository) {
230
- this.angularFirestore = angularFirestore;
231
- this.orderRepository = orderRepository;
232
- this.orderSubject = new Subject();
233
- }
234
- getOrder(id) {
235
- this.angularFirestore
236
- .doc(`${this.orderRepository.collectionName}/${id}`)
237
- .valueChanges()
238
- .pipe(map((doc) => Order.toInstance(doc)))
239
- .subscribe((doc) => this.orderSubject.next(doc));
240
- return this.orderSubject;
241
- }
242
- }
243
- OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
244
- OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService });
245
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService, decorators: [{
246
- type: Injectable
247
- }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
248
- type: Inject,
249
- args: ['OrderRepository']
231
+ class OrderService {
232
+ constructor(angularFirestore, orderRepository) {
233
+ this.angularFirestore = angularFirestore;
234
+ this.orderRepository = orderRepository;
235
+ this.orderSubject = new Subject();
236
+ }
237
+ getOrder(id) {
238
+ this.angularFirestore
239
+ .doc(`${this.orderRepository.collectionName}/${id}`)
240
+ .valueChanges()
241
+ .pipe(map((doc) => Order.toInstance(doc)))
242
+ .subscribe((doc) => this.orderSubject.next(doc));
243
+ return this.orderSubject;
244
+ }
245
+ }
246
+ OrderService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService, deps: [{ token: i1$2.AngularFirestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable });
247
+ OrderService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService });
248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: OrderService, decorators: [{
249
+ type: Injectable
250
+ }], ctorParameters: function () { return [{ type: i1$2.AngularFirestore }, { type: i1$1.OrderFirestoreRepository, decorators: [{
251
+ type: Inject,
252
+ args: ['OrderRepository']
250
253
  }] }]; } });
251
254
 
252
- class AngularFirebaseAuthModule {
253
- static initializeApp(options, nameOrConfig) {
254
- return {
255
- ngModule: AngularFirebaseAuthModule,
256
- providers: [
257
- { provide: FIREBASE_OPTIONS, useValue: options },
258
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
259
- ],
260
- };
261
- }
262
- }
263
- AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
264
- AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
265
- AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
266
- {
267
- provide: 'Authentication',
268
- useFactory: (authenticationService, userRepository) => {
269
- return new Authentication(authenticationService, userRepository);
270
- },
271
- deps: ['AuthenticationService', 'UserRepository'],
272
- },
273
- {
274
- provide: 'AuthenticationService',
275
- useFactory: (angularFireAuth) => {
276
- return new AuthenticationFirebaseAuthService(angularFireAuth);
277
- },
278
- deps: [AngularFireAuth],
279
- },
280
- {
281
- provide: 'SignOut',
282
- useFactory: (authenticationService) => {
283
- return new SignOut(authenticationService);
284
- },
285
- deps: ['AuthenticationService'],
286
- },
287
- ], imports: [[AngularFireModule]] });
288
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
289
- type: NgModule,
290
- args: [{
291
- imports: [AngularFireModule],
292
- providers: [
293
- {
294
- provide: 'Authentication',
295
- useFactory: (authenticationService, userRepository) => {
296
- return new Authentication(authenticationService, userRepository);
297
- },
298
- deps: ['AuthenticationService', 'UserRepository'],
299
- },
300
- {
301
- provide: 'AuthenticationService',
302
- useFactory: (angularFireAuth) => {
303
- return new AuthenticationFirebaseAuthService(angularFireAuth);
304
- },
305
- deps: [AngularFireAuth],
306
- },
307
- {
308
- provide: 'SignOut',
309
- useFactory: (authenticationService) => {
310
- return new SignOut(authenticationService);
311
- },
312
- deps: ['AuthenticationService'],
313
- },
314
- ],
315
- }]
255
+ class AngularFirebaseAuthModule {
256
+ static initializeApp(options, nameOrConfig) {
257
+ return {
258
+ ngModule: AngularFirebaseAuthModule,
259
+ providers: [
260
+ { provide: FIREBASE_OPTIONS, useValue: options },
261
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
262
+ ],
263
+ };
264
+ }
265
+ }
266
+ AngularFirebaseAuthModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
267
+ AngularFirebaseAuthModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, imports: [AngularFireModule] });
268
+ AngularFirebaseAuthModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
269
+ {
270
+ provide: 'Authentication',
271
+ useFactory: (authenticationService, userRepository) => {
272
+ return new Authentication(authenticationService, userRepository);
273
+ },
274
+ deps: ['AuthenticationService', 'UserRepository'],
275
+ },
276
+ {
277
+ provide: 'AuthenticationService',
278
+ useFactory: (angularFireAuth) => {
279
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
280
+ },
281
+ deps: [AngularFireAuth],
282
+ },
283
+ {
284
+ provide: 'SignOut',
285
+ useFactory: (authenticationService) => {
286
+ return new SignOut(authenticationService);
287
+ },
288
+ deps: ['AuthenticationService'],
289
+ },
290
+ ], imports: [[AngularFireModule]] });
291
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
292
+ type: NgModule,
293
+ args: [{
294
+ imports: [AngularFireModule],
295
+ providers: [
296
+ {
297
+ provide: 'Authentication',
298
+ useFactory: (authenticationService, userRepository) => {
299
+ return new Authentication(authenticationService, userRepository);
300
+ },
301
+ deps: ['AuthenticationService', 'UserRepository'],
302
+ },
303
+ {
304
+ provide: 'AuthenticationService',
305
+ useFactory: (angularFireAuth) => {
306
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
307
+ },
308
+ deps: [AngularFireAuth],
309
+ },
310
+ {
311
+ provide: 'SignOut',
312
+ useFactory: (authenticationService) => {
313
+ return new SignOut(authenticationService);
314
+ },
315
+ deps: ['AuthenticationService'],
316
+ },
317
+ ],
318
+ }]
316
319
  }] });
317
320
 
318
- class AngularFirestoreModule {
319
- static initializeApp(options, nameOrConfig) {
320
- return {
321
- ngModule: AngularFirestoreModule,
322
- providers: [
323
- { provide: FIREBASE_OPTIONS, useValue: options },
324
- { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
325
- ],
326
- };
327
- }
328
- }
329
- AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
330
- AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
331
- AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, providers: [
332
- {
333
- provide: 'BeautyProfileRepository',
334
- useFactory: (firestore, userRepository) => {
335
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
336
- },
337
- deps: [AngularFirestore, 'UserRepository'],
338
- },
339
- {
340
- provide: 'Buy2WinRepository',
341
- useFactory: (firestore) => {
342
- return new Buy2WinFirestoreRepository(firestore.firestore);
343
- },
344
- deps: [AngularFirestore],
345
- },
346
- {
347
- provide: 'CategoryRepository',
348
- useFactory: (firestore) => {
349
- return new CategoryFirestoreRepository(firestore.firestore);
350
- },
351
- deps: [AngularFirestore],
352
- },
353
- {
354
- provide: 'CheckoutRepository',
355
- useFactory: (firestore) => {
356
- return new CheckoutFirestoreRepository(firestore.firestore);
357
- },
358
- deps: [AngularFirestore],
359
- },
360
- {
361
- provide: 'CheckoutSubscriptionRepository',
362
- useFactory: (firestore) => {
363
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
364
- },
365
- deps: [AngularFirestore],
366
- },
367
- {
368
- provide: 'CouponRepository',
369
- useFactory: (firestore) => {
370
- return new CouponFirestoreRepository(firestore.firestore);
371
- },
372
- deps: [AngularFirestore],
373
- },
374
- {
375
- provide: 'EditionRepository',
376
- useFactory: (firestore, subscriptionRepository) => {
377
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
378
- },
379
- deps: [AngularFirestore, 'SubscriptionRepository'],
380
- },
381
- {
382
- provide: 'HomeRepository',
383
- useFactory: (firestore) => {
384
- return new HomeFirestoreRepository(firestore.firestore);
385
- },
386
- deps: [AngularFirestore],
387
- },
388
- {
389
- provide: 'LegacyOrderRepository',
390
- useFactory: (firestore) => {
391
- return new LegacyOrderFirestoreRepository(firestore.firestore);
392
- },
393
- deps: [AngularFirestore],
394
- },
395
- {
396
- provide: 'ShopMenuRepository',
397
- useFactory: (firestore) => {
398
- return new ShopMenuFirestoreRepository(firestore.firestore);
399
- },
400
- deps: [AngularFirestore],
401
- },
402
- {
403
- provide: 'OrderRepository',
404
- useFactory: (firestore) => {
405
- return new OrderFirestoreRepository(firestore.firestore);
406
- },
407
- deps: [AngularFirestore],
408
- },
409
- {
410
- provide: 'PaymentRepository',
411
- useFactory: (firestore) => {
412
- return new PaymentFirestoreRepository(firestore.firestore);
413
- },
414
- deps: [AngularFirestore],
415
- },
416
- {
417
- provide: 'ProductRepository',
418
- useFactory: (firestore) => {
419
- return new ProductFirestoreRepository(firestore.firestore);
420
- },
421
- deps: [AngularFirestore],
422
- },
423
- {
424
- provide: 'SubscriptionPaymentRepository',
425
- useFactory: (firestore, subscriptionRepository) => {
426
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
427
- },
428
- deps: [AngularFirestore, 'SubscriptionRepository'],
429
- },
430
- {
431
- provide: 'SubscriptionPlanRepository',
432
- useFactory: (firestore) => {
433
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
434
- },
435
- deps: [AngularFirestore],
436
- },
437
- {
438
- provide: 'SubscriptionRepository',
439
- useFactory: (firestore) => {
440
- return new SubscriptionFirestoreRepository(firestore.firestore);
441
- },
442
- deps: [AngularFirestore],
443
- },
444
- {
445
- provide: 'UserRepository',
446
- useFactory: (firestore) => {
447
- return new UserFirestoreRepository(firestore.firestore);
448
- },
449
- deps: [AngularFirestore],
450
- },
451
- {
452
- provide: 'UserAddressRepository',
453
- useFactory: (firestore, userRepository) => {
454
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
455
- },
456
- deps: [AngularFirestore, 'UserRepository'],
457
- },
458
- {
459
- provide: 'VariantRepository',
460
- useFactory: (firestore, productRepository) => {
461
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
462
- },
463
- deps: [AngularFirestore, 'ProductRepository'],
464
- },
465
- ], imports: [[AngularFireModule]] });
466
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, decorators: [{
467
- type: NgModule,
468
- args: [{
469
- imports: [AngularFireModule],
470
- providers: [
471
- {
472
- provide: 'BeautyProfileRepository',
473
- useFactory: (firestore, userRepository) => {
474
- return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
475
- },
476
- deps: [AngularFirestore, 'UserRepository'],
477
- },
478
- {
479
- provide: 'Buy2WinRepository',
480
- useFactory: (firestore) => {
481
- return new Buy2WinFirestoreRepository(firestore.firestore);
482
- },
483
- deps: [AngularFirestore],
484
- },
485
- {
486
- provide: 'CategoryRepository',
487
- useFactory: (firestore) => {
488
- return new CategoryFirestoreRepository(firestore.firestore);
489
- },
490
- deps: [AngularFirestore],
491
- },
492
- {
493
- provide: 'CheckoutRepository',
494
- useFactory: (firestore) => {
495
- return new CheckoutFirestoreRepository(firestore.firestore);
496
- },
497
- deps: [AngularFirestore],
498
- },
499
- {
500
- provide: 'CheckoutSubscriptionRepository',
501
- useFactory: (firestore) => {
502
- return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
503
- },
504
- deps: [AngularFirestore],
505
- },
506
- {
507
- provide: 'CouponRepository',
508
- useFactory: (firestore) => {
509
- return new CouponFirestoreRepository(firestore.firestore);
510
- },
511
- deps: [AngularFirestore],
512
- },
513
- {
514
- provide: 'EditionRepository',
515
- useFactory: (firestore, subscriptionRepository) => {
516
- return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
517
- },
518
- deps: [AngularFirestore, 'SubscriptionRepository'],
519
- },
520
- {
521
- provide: 'HomeRepository',
522
- useFactory: (firestore) => {
523
- return new HomeFirestoreRepository(firestore.firestore);
524
- },
525
- deps: [AngularFirestore],
526
- },
527
- {
528
- provide: 'LegacyOrderRepository',
529
- useFactory: (firestore) => {
530
- return new LegacyOrderFirestoreRepository(firestore.firestore);
531
- },
532
- deps: [AngularFirestore],
533
- },
534
- {
535
- provide: 'ShopMenuRepository',
536
- useFactory: (firestore) => {
537
- return new ShopMenuFirestoreRepository(firestore.firestore);
538
- },
539
- deps: [AngularFirestore],
540
- },
541
- {
542
- provide: 'OrderRepository',
543
- useFactory: (firestore) => {
544
- return new OrderFirestoreRepository(firestore.firestore);
545
- },
546
- deps: [AngularFirestore],
547
- },
548
- {
549
- provide: 'PaymentRepository',
550
- useFactory: (firestore) => {
551
- return new PaymentFirestoreRepository(firestore.firestore);
552
- },
553
- deps: [AngularFirestore],
554
- },
555
- {
556
- provide: 'ProductRepository',
557
- useFactory: (firestore) => {
558
- return new ProductFirestoreRepository(firestore.firestore);
559
- },
560
- deps: [AngularFirestore],
561
- },
562
- {
563
- provide: 'SubscriptionPaymentRepository',
564
- useFactory: (firestore, subscriptionRepository) => {
565
- return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
566
- },
567
- deps: [AngularFirestore, 'SubscriptionRepository'],
568
- },
569
- {
570
- provide: 'SubscriptionPlanRepository',
571
- useFactory: (firestore) => {
572
- return new SubscriptionPlanFirestoreRepository(firestore.firestore);
573
- },
574
- deps: [AngularFirestore],
575
- },
576
- {
577
- provide: 'SubscriptionRepository',
578
- useFactory: (firestore) => {
579
- return new SubscriptionFirestoreRepository(firestore.firestore);
580
- },
581
- deps: [AngularFirestore],
582
- },
583
- {
584
- provide: 'UserRepository',
585
- useFactory: (firestore) => {
586
- return new UserFirestoreRepository(firestore.firestore);
587
- },
588
- deps: [AngularFirestore],
589
- },
590
- {
591
- provide: 'UserAddressRepository',
592
- useFactory: (firestore, userRepository) => {
593
- return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
594
- },
595
- deps: [AngularFirestore, 'UserRepository'],
596
- },
597
- {
598
- provide: 'VariantRepository',
599
- useFactory: (firestore, productRepository) => {
600
- return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
601
- },
602
- deps: [AngularFirestore, 'ProductRepository'],
603
- },
604
- ],
605
- }]
321
+ class AngularFirestoreModule {
322
+ static initializeApp(options, nameOrConfig) {
323
+ return {
324
+ ngModule: AngularFirestoreModule,
325
+ providers: [
326
+ { provide: FIREBASE_OPTIONS, useValue: options },
327
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
328
+ ],
329
+ };
330
+ }
331
+ }
332
+ AngularFirestoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
333
+ AngularFirestoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, imports: [AngularFireModule] });
334
+ AngularFirestoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, providers: [
335
+ {
336
+ provide: 'BeautyProfileRepository',
337
+ useFactory: (firestore, userRepository) => {
338
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
339
+ },
340
+ deps: [AngularFirestore, 'UserRepository'],
341
+ },
342
+ {
343
+ provide: 'Buy2WinRepository',
344
+ useFactory: (firestore) => {
345
+ return new Buy2WinFirestoreRepository(firestore.firestore);
346
+ },
347
+ deps: [AngularFirestore],
348
+ },
349
+ {
350
+ provide: 'CategoryRepository',
351
+ useFactory: (firestore) => {
352
+ return new CategoryFirestoreRepository(firestore.firestore);
353
+ },
354
+ deps: [AngularFirestore],
355
+ },
356
+ {
357
+ provide: 'CheckoutRepository',
358
+ useFactory: (firestore) => {
359
+ return new CheckoutFirestoreRepository(firestore.firestore);
360
+ },
361
+ deps: [AngularFirestore],
362
+ },
363
+ {
364
+ provide: 'CheckoutSubscriptionRepository',
365
+ useFactory: (firestore) => {
366
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
367
+ },
368
+ deps: [AngularFirestore],
369
+ },
370
+ {
371
+ provide: 'CouponRepository',
372
+ useFactory: (firestore) => {
373
+ return new CouponFirestoreRepository(firestore.firestore);
374
+ },
375
+ deps: [AngularFirestore],
376
+ },
377
+ {
378
+ provide: 'EditionRepository',
379
+ useFactory: (firestore, subscriptionRepository) => {
380
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
381
+ },
382
+ deps: [AngularFirestore, 'SubscriptionRepository'],
383
+ },
384
+ {
385
+ provide: 'HomeRepository',
386
+ useFactory: (firestore) => {
387
+ return new HomeFirestoreRepository(firestore.firestore);
388
+ },
389
+ deps: [AngularFirestore],
390
+ },
391
+ {
392
+ provide: 'LegacyOrderRepository',
393
+ useFactory: (firestore) => {
394
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
395
+ },
396
+ deps: [AngularFirestore],
397
+ },
398
+ {
399
+ provide: 'ShopMenuRepository',
400
+ useFactory: (firestore) => {
401
+ return new ShopMenuFirestoreRepository(firestore.firestore);
402
+ },
403
+ deps: [AngularFirestore],
404
+ },
405
+ {
406
+ provide: 'OrderRepository',
407
+ useFactory: (firestore) => {
408
+ return new OrderFirestoreRepository(firestore.firestore);
409
+ },
410
+ deps: [AngularFirestore],
411
+ },
412
+ {
413
+ provide: 'PaymentRepository',
414
+ useFactory: (firestore) => {
415
+ return new PaymentFirestoreRepository(firestore.firestore);
416
+ },
417
+ deps: [AngularFirestore],
418
+ },
419
+ {
420
+ provide: 'ProductRepository',
421
+ useFactory: (firestore) => {
422
+ return new ProductFirestoreRepository(firestore.firestore);
423
+ },
424
+ deps: [AngularFirestore],
425
+ },
426
+ {
427
+ provide: 'SubscriptionPaymentRepository',
428
+ useFactory: (firestore, subscriptionRepository) => {
429
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
430
+ },
431
+ deps: [AngularFirestore, 'SubscriptionRepository'],
432
+ },
433
+ {
434
+ provide: 'SubscriptionPlanRepository',
435
+ useFactory: (firestore) => {
436
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
437
+ },
438
+ deps: [AngularFirestore],
439
+ },
440
+ {
441
+ provide: 'SubscriptionRepository',
442
+ useFactory: (firestore) => {
443
+ return new SubscriptionFirestoreRepository(firestore.firestore);
444
+ },
445
+ deps: [AngularFirestore],
446
+ },
447
+ {
448
+ provide: 'UserRepository',
449
+ useFactory: (firestore) => {
450
+ return new UserFirestoreRepository(firestore.firestore);
451
+ },
452
+ deps: [AngularFirestore],
453
+ },
454
+ {
455
+ provide: 'UserAddressRepository',
456
+ useFactory: (firestore, userRepository) => {
457
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
458
+ },
459
+ deps: [AngularFirestore, 'UserRepository'],
460
+ },
461
+ {
462
+ provide: 'VariantRepository',
463
+ useFactory: (firestore, productRepository) => {
464
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
465
+ },
466
+ deps: [AngularFirestore, 'ProductRepository'],
467
+ },
468
+ ], imports: [[AngularFireModule]] });
469
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularFirestoreModule, decorators: [{
470
+ type: NgModule,
471
+ args: [{
472
+ imports: [AngularFireModule],
473
+ providers: [
474
+ {
475
+ provide: 'BeautyProfileRepository',
476
+ useFactory: (firestore, userRepository) => {
477
+ return new UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
478
+ },
479
+ deps: [AngularFirestore, 'UserRepository'],
480
+ },
481
+ {
482
+ provide: 'Buy2WinRepository',
483
+ useFactory: (firestore) => {
484
+ return new Buy2WinFirestoreRepository(firestore.firestore);
485
+ },
486
+ deps: [AngularFirestore],
487
+ },
488
+ {
489
+ provide: 'CategoryRepository',
490
+ useFactory: (firestore) => {
491
+ return new CategoryFirestoreRepository(firestore.firestore);
492
+ },
493
+ deps: [AngularFirestore],
494
+ },
495
+ {
496
+ provide: 'CheckoutRepository',
497
+ useFactory: (firestore) => {
498
+ return new CheckoutFirestoreRepository(firestore.firestore);
499
+ },
500
+ deps: [AngularFirestore],
501
+ },
502
+ {
503
+ provide: 'CheckoutSubscriptionRepository',
504
+ useFactory: (firestore) => {
505
+ return new CheckoutSubscriptionFirestoreRepository(firestore.firestore);
506
+ },
507
+ deps: [AngularFirestore],
508
+ },
509
+ {
510
+ provide: 'CouponRepository',
511
+ useFactory: (firestore) => {
512
+ return new CouponFirestoreRepository(firestore.firestore);
513
+ },
514
+ deps: [AngularFirestore],
515
+ },
516
+ {
517
+ provide: 'EditionRepository',
518
+ useFactory: (firestore, subscriptionRepository) => {
519
+ return new SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
520
+ },
521
+ deps: [AngularFirestore, 'SubscriptionRepository'],
522
+ },
523
+ {
524
+ provide: 'HomeRepository',
525
+ useFactory: (firestore) => {
526
+ return new HomeFirestoreRepository(firestore.firestore);
527
+ },
528
+ deps: [AngularFirestore],
529
+ },
530
+ {
531
+ provide: 'LegacyOrderRepository',
532
+ useFactory: (firestore) => {
533
+ return new LegacyOrderFirestoreRepository(firestore.firestore);
534
+ },
535
+ deps: [AngularFirestore],
536
+ },
537
+ {
538
+ provide: 'ShopMenuRepository',
539
+ useFactory: (firestore) => {
540
+ return new ShopMenuFirestoreRepository(firestore.firestore);
541
+ },
542
+ deps: [AngularFirestore],
543
+ },
544
+ {
545
+ provide: 'OrderRepository',
546
+ useFactory: (firestore) => {
547
+ return new OrderFirestoreRepository(firestore.firestore);
548
+ },
549
+ deps: [AngularFirestore],
550
+ },
551
+ {
552
+ provide: 'PaymentRepository',
553
+ useFactory: (firestore) => {
554
+ return new PaymentFirestoreRepository(firestore.firestore);
555
+ },
556
+ deps: [AngularFirestore],
557
+ },
558
+ {
559
+ provide: 'ProductRepository',
560
+ useFactory: (firestore) => {
561
+ return new ProductFirestoreRepository(firestore.firestore);
562
+ },
563
+ deps: [AngularFirestore],
564
+ },
565
+ {
566
+ provide: 'SubscriptionPaymentRepository',
567
+ useFactory: (firestore, subscriptionRepository) => {
568
+ return new SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
569
+ },
570
+ deps: [AngularFirestore, 'SubscriptionRepository'],
571
+ },
572
+ {
573
+ provide: 'SubscriptionPlanRepository',
574
+ useFactory: (firestore) => {
575
+ return new SubscriptionPlanFirestoreRepository(firestore.firestore);
576
+ },
577
+ deps: [AngularFirestore],
578
+ },
579
+ {
580
+ provide: 'SubscriptionRepository',
581
+ useFactory: (firestore) => {
582
+ return new SubscriptionFirestoreRepository(firestore.firestore);
583
+ },
584
+ deps: [AngularFirestore],
585
+ },
586
+ {
587
+ provide: 'UserRepository',
588
+ useFactory: (firestore) => {
589
+ return new UserFirestoreRepository(firestore.firestore);
590
+ },
591
+ deps: [AngularFirestore],
592
+ },
593
+ {
594
+ provide: 'UserAddressRepository',
595
+ useFactory: (firestore, userRepository) => {
596
+ return new UserAddressFirestoreRepository(firestore.firestore, userRepository);
597
+ },
598
+ deps: [AngularFirestore, 'UserRepository'],
599
+ },
600
+ {
601
+ provide: 'VariantRepository',
602
+ useFactory: (firestore, productRepository) => {
603
+ return new ProductVariantFirestoreRepository(firestore.firestore, productRepository);
604
+ },
605
+ deps: [AngularFirestore, 'ProductRepository'],
606
+ },
607
+ ],
608
+ }]
606
609
  }] });
607
610
 
608
- class AngularConnectModule {
609
- static initializeApp(defaultShop, options, nameOrConfig) {
610
- return {
611
- ngModule: AngularConnectModule,
612
- providers: [
613
- ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
614
- ...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
615
- ...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
616
- ],
617
- };
618
- }
619
- }
620
- AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
621
- AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
622
- AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, OrderService], imports: [[AngularFireModule, AngularFirestoreModule]] });
623
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, decorators: [{
624
- type: NgModule,
625
- args: [{
626
- imports: [AngularFireModule, AngularFirestoreModule],
627
- providers: [AuthService, CartService, CheckoutService, OrderService],
628
- }]
611
+ class AngularConnectModule {
612
+ static initializeApp(defaultShop, options, nameOrConfig) {
613
+ return {
614
+ ngModule: AngularConnectModule,
615
+ providers: [
616
+ ...(isNil(defaultShop) ? [] : [{ provide: DEFAULT_SHOP, useValue: defaultShop }]),
617
+ ...(isNil(options) ? [] : [{ provide: FIREBASE_OPTIONS, useValue: options }]),
618
+ ...(isNil(options) ? [] : [{ provide: FIREBASE_APP_NAME, useValue: nameOrConfig }]),
619
+ ],
620
+ };
621
+ }
622
+ }
623
+ AngularConnectModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
624
+ AngularConnectModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, imports: [AngularFireModule, AngularFirestoreModule] });
625
+ AngularConnectModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, providers: [AuthService, CartService, CheckoutService, OrderService], imports: [[AngularFireModule, AngularFirestoreModule]] });
626
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.7", ngImport: i0, type: AngularConnectModule, decorators: [{
627
+ type: NgModule,
628
+ args: [{
629
+ imports: [AngularFireModule, AngularFirestoreModule],
630
+ providers: [AuthService, CartService, CheckoutService, OrderService],
631
+ }]
629
632
  }] });
630
633
 
631
- /**
632
- * Generated bundle index. Do not edit.
634
+ /**
635
+ * Generated bundle index. Do not edit.
633
636
  */
634
637
 
635
638
  export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AuthService, CartService, CheckoutService, OrderService };