@infrab4a/connect-angular 3.9.7 → 3.10.0-beta.1

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