@infrab4a/connect-angular 3.2.0-beta.0 → 3.2.0

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