@infrab4a/connect-angular 0.14.2-beta.11 → 0.14.2-beta.2

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 (51) hide show
  1. package/angular-connect.module.d.ts +15 -15
  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/bundles/infrab4a-connect-angular.umd.js +1415 -1420
  6. package/bundles/infrab4a-connect-angular.umd.js.map +1 -1
  7. package/consts/default-shop.const.d.ts +1 -1
  8. package/consts/es-config.const.d.ts +1 -1
  9. package/consts/index.d.ts +2 -2
  10. package/esm2015/angular-connect.module.js +47 -47
  11. package/esm2015/angular-elastic-search.module.js +38 -38
  12. package/esm2015/angular-firebase-auth.module.js +113 -113
  13. package/esm2015/angular-firestore.module.js +340 -340
  14. package/esm2015/consts/default-shop.const.js +2 -2
  15. package/esm2015/consts/es-config.const.js +2 -2
  16. package/esm2015/consts/index.js +3 -3
  17. package/esm2015/index.js +5 -5
  18. package/esm2015/infrab4a-connect-angular.js +4 -4
  19. package/esm2015/services/auth.service.js +42 -42
  20. package/esm2015/services/cart.service.js +150 -169
  21. package/esm2015/services/checkout-subscription.service.js +44 -68
  22. package/esm2015/services/checkout.service.js +87 -79
  23. package/esm2015/services/coupon.service.js +98 -70
  24. package/esm2015/services/errors/group-invalid-coupon.error.js +7 -7
  25. package/esm2015/services/errors/index.js +3 -3
  26. package/esm2015/services/errors/invalid-coupon.error.js +7 -7
  27. package/esm2015/services/home-shop.service.js +108 -108
  28. package/esm2015/services/index.js +8 -8
  29. package/esm2015/services/order.service.js +32 -32
  30. package/esm2015/services/types/index.js +3 -3
  31. package/esm2015/services/types/required-checkout-data.type.js +2 -2
  32. package/esm2015/services/types/required-checkout-subscription-data.type.js +2 -2
  33. package/fesm2015/infrab4a-connect-angular.js +1007 -1013
  34. package/fesm2015/infrab4a-connect-angular.js.map +1 -1
  35. package/index.d.ts +4 -4
  36. package/infrab4a-connect-angular.d.ts +5 -5
  37. package/package.json +3 -3
  38. package/services/auth.service.d.ts +19 -19
  39. package/services/cart.service.d.ts +35 -41
  40. package/services/checkout-subscription.service.d.ts +16 -18
  41. package/services/checkout.service.d.ts +22 -22
  42. package/services/coupon.service.d.ts +17 -14
  43. package/services/errors/group-invalid-coupon.error.d.ts +5 -5
  44. package/services/errors/index.d.ts +2 -2
  45. package/services/errors/invalid-coupon.error.d.ts +4 -4
  46. package/services/home-shop.service.d.ts +24 -24
  47. package/services/index.d.ts +7 -7
  48. package/services/order.service.d.ts +13 -13
  49. package/services/types/index.d.ts +2 -2
  50. package/services/types/required-checkout-data.type.d.ts +2 -2
  51. package/services/types/required-checkout-subscription-data.type.d.ts +2 -2
@@ -30,1458 +30,1453 @@
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';
393
393
 
394
394
  var ES_CONFIG = 'ES_CONFIG';
395
395
 
396
- var InvalidCouponError = /** @class */ (function (_super) {
397
- __extends(InvalidCouponError, _super);
398
- function InvalidCouponError(message) {
399
- var _this = _super.call(this, message) || this;
400
- _this.message = message;
401
- return _this;
402
- }
403
- return InvalidCouponError;
396
+ var InvalidCouponError = /** @class */ (function (_super) {
397
+ __extends(InvalidCouponError, _super);
398
+ function InvalidCouponError(message) {
399
+ var _this = _super.call(this, message) || this;
400
+ _this.message = message;
401
+ return _this;
402
+ }
403
+ return InvalidCouponError;
404
404
  }(Error));
405
405
 
406
- var GroupInvalidCouponError = /** @class */ (function (_super) {
407
- __extends(GroupInvalidCouponError, _super);
408
- function GroupInvalidCouponError(errors) {
409
- var _this = _super.call(this, 'Many coupon errors throw') || this;
410
- _this.errors = errors;
411
- return _this;
412
- }
413
- return GroupInvalidCouponError;
406
+ var GroupInvalidCouponError = /** @class */ (function (_super) {
407
+ __extends(GroupInvalidCouponError, _super);
408
+ function GroupInvalidCouponError(errors) {
409
+ var _this = _super.call(this, 'Many coupon errors throw') || this;
410
+ _this.errors = errors;
411
+ return _this;
412
+ }
413
+ return GroupInvalidCouponError;
414
414
  }(Error));
415
415
 
416
- var CouponService = /** @class */ (function () {
417
- function CouponService(couponRepository, defaultShop) {
418
- var _this = this;
419
- this.couponRepository = couponRepository;
420
- this.defaultShop = defaultShop;
421
- this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
422
- this.separateValidCoupons = function (coupons, userEmail) { return coupons
423
- .map(function (coupon) {
424
- try {
425
- if (!i2.FinancialCoupon.isFinancialCoupon(coupon))
426
- throw new InvalidCouponError('Coupon is not valid');
427
- if (_this.isValidCoupon(coupon, userEmail))
428
- return coupon;
429
- }
430
- catch (error) {
431
- return error;
432
- }
433
- })
434
- .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (i2.FinancialCoupon.isFinancialCoupon(coupon)
435
- ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
436
- : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
437
- valids: [],
438
- invalids: [],
439
- }); };
440
- }
441
- CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType) {
442
- var _this = this;
443
- return rxjs.from(this.couponRepository.find([
444
- {
445
- nickname: { operator: i2.Where.EQUALS, value: nickname },
446
- shopAvailability: { operator: i2.Where.EQUALS, value: this.defaultShop },
447
- checkoutType: { operator: i2.Where.EQUALS, value: checkoutType },
448
- },
449
- ])).pipe(operators.concatMap(function (coupons) { return coupons.count < 1 ? rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); }) : rxjs.of(coupons.data); }), operators.map(function (coupons) { return _this.separateValidCoupons(coupons, userEmail); }), operators.map(function (_a) {
450
- var valids = _a.valids, invalids = _a.invalids;
451
- if (!valids.length)
452
- throw new GroupInvalidCouponError(invalids);
453
- return valids;
454
- }));
455
- };
456
- CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
457
- if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
458
- throw new InvalidCouponError('User is not a collaborator');
459
- if (coupon.exclusivityType === i2.Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
460
- throw new InvalidCouponError('Coupon is not valid for user');
461
- if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
462
- throw new InvalidCouponError('Coupon is expired');
463
- return true;
464
- };
465
- return CouponService;
466
- }());
467
- CouponService.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, deps: [{ token: 'CouponRepository' }, { token: DEFAULT_SHOP }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
468
- CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
469
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
470
- type: i0.Injectable,
471
- args: [{
472
- providedIn: 'root',
473
- }]
474
- }], ctorParameters: function () {
475
- return [{ type: undefined, decorators: [{
476
- type: i0.Inject,
477
- args: ['CouponRepository']
478
- }] }, { type: i2__namespace.Shops, decorators: [{
479
- type: i0.Inject,
480
- args: [DEFAULT_SHOP]
481
- }] }];
416
+ var CouponService = /** @class */ (function () {
417
+ function CouponService(couponRepository, defaultShop, orderRepository) {
418
+ var _this = this;
419
+ this.couponRepository = couponRepository;
420
+ this.defaultShop = defaultShop;
421
+ this.orderRepository = orderRepository;
422
+ this.emailIsFromCollaborator = function (userEmail) { return !!(userEmail === null || userEmail === void 0 ? void 0 : userEmail.match(/@b4a.com.br/g)); };
423
+ this.separateValidCoupons = function (coupons, userEmail) { return coupons
424
+ .map(function (coupon) {
425
+ try {
426
+ if (!(coupon instanceof i2.Coupon))
427
+ throw new InvalidCouponError('Coupon is not valid');
428
+ if (_this.isValidCoupon(coupon, userEmail))
429
+ return coupon;
430
+ }
431
+ catch (error) {
432
+ return error;
433
+ }
434
+ })
435
+ .reduce(function (current, coupon) { return (Object.assign(Object.assign({}, current), (coupon instanceof i2.Coupon
436
+ ? { valids: __spreadArray(__spreadArray([], __read(current.valids)), [coupon]) }
437
+ : { invalids: __spreadArray(__spreadArray([], __read(current.invalids)), [coupon]) }))); }, {
438
+ valids: [],
439
+ invalids: [],
440
+ }); };
441
+ }
442
+ CouponService.prototype.checkCoupon = function (nickname, userEmail, checkoutType, plan) {
443
+ var _this = this;
444
+ return rxjs.from(this.couponRepository.find([
445
+ {
446
+ nickname: { operator: i2.Where.EQUALS, value: nickname },
447
+ // shopAvailability: { operator: Where.EQUALS, value: this.defaultShop },
448
+ // checkoutType: { operator: Where.EQUALS, value: checkoutType },
449
+ },
450
+ ])).pipe(operators.concatMap(function (coupons) { return _this.checkCouponRules(coupons, checkoutType); }), operators.concatMap(function (coupons) { return _this.checkCouponUseLimit(coupons, userEmail); }), operators.map(function (coupon) { return _this.isValidCoupon(coupon, userEmail); }));
451
+ };
452
+ CouponService.prototype.isValidCoupon = function (coupon, userEmail) {
453
+ if (!this.emailIsFromCollaborator(userEmail) && coupon.exclusivityType === i2.Exclusivities.COLLABORATORS)
454
+ throw new InvalidCouponError('User is not a collaborator');
455
+ if (coupon.exclusivityType === i2.Exclusivities.SPECIFIC_USER && coupon.recipient !== userEmail)
456
+ throw new InvalidCouponError('Coupon is not valid for user');
457
+ if ((coupon === null || coupon === void 0 ? void 0 : coupon.expiresIn) < new Date())
458
+ throw new InvalidCouponError('Coupon is expired');
459
+ return coupon;
460
+ };
461
+ CouponService.prototype.checkCouponRules = function (coupons, checkoutType, plan) {
462
+ var _this = this;
463
+ // coupons.count < 1 ? return throwError(() => new NotFoundError('Coupon not found')) : return of(coupons.data);
464
+ if (coupons.count < 1)
465
+ return rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); });
466
+ var isInShop = coupons.data.find(function (c) { return c.shopAvailability == i2.Shops.ALL || c.shopAvailability == _this.defaultShop; });
467
+ if (!isInShop)
468
+ return rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); });
469
+ var isCheckoutType = coupons.data.find(function (c) { return c.checkoutType == i2.CheckoutTypes.ALL || c.checkoutType == checkoutType; });
470
+ if (!isCheckoutType)
471
+ return rxjs.throwError(function () { return new i2.NotFoundError('Coupon not found'); });
472
+ if (checkoutType === i2.CheckoutTypes.ALL || checkoutType === i2.CheckoutTypes.SUBSCRIPTION) {
473
+ //regra
474
+ }
475
+ return coupons.data;
476
+ };
477
+ CouponService.prototype.checkCouponUseLimit = function (coupons, userEmail) {
478
+ return __awaiter(this, void 0, void 0, function () {
479
+ var coupon, orders, ordersUserCoupon;
480
+ return __generator(this, function (_a) {
481
+ switch (_a.label) {
482
+ case 0:
483
+ coupon = coupons.shift();
484
+ return [4 /*yield*/, this.orderRepository.find([{ coupon: { id: coupon.id } }])];
485
+ case 1:
486
+ orders = _a.sent();
487
+ ordersUserCoupon = orders.data.filter(function (o) { return o.user.email == userEmail; });
488
+ if (orders.data.length >= (coupon.useLimit || Infinity))
489
+ return [2 /*return*/, rxjs.throwError(function () { return new Error('Coupon já usou tudo'); })];
490
+ if (ordersUserCoupon.length >= coupon.useLimitPerUser)
491
+ return [2 /*return*/, rxjs.throwError(function () { return new Error('Usuário Coupon já usou tudo'); })];
492
+ return [2 /*return*/, coupon];
493
+ }
494
+ });
495
+ });
496
+ };
497
+ return CouponService;
498
+ }());
499
+ 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' }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
500
+ CouponService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, providedIn: 'root' });
501
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CouponService, decorators: [{
502
+ type: i0.Injectable,
503
+ args: [{
504
+ providedIn: 'root',
505
+ }]
506
+ }], ctorParameters: function () {
507
+ return [{ type: undefined, decorators: [{
508
+ type: i0.Inject,
509
+ args: ['CouponRepository']
510
+ }] }, { type: i2__namespace.Shops, decorators: [{
511
+ type: i0.Inject,
512
+ args: [DEFAULT_SHOP]
513
+ }] }, { type: undefined, decorators: [{
514
+ type: i0.Inject,
515
+ args: ['OrderRepository']
516
+ }] }];
482
517
  } });
483
518
 
484
- var CheckoutService = /** @class */ (function () {
485
- function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
486
- this.couponService = couponService;
487
- this.checkoutRepository = checkoutRepository;
488
- this.orderRepository = orderRepository;
489
- this.userRepository = userRepository;
490
- this.defaultShop = defaultShop;
491
- }
492
- CheckoutService.prototype.getCheckout = function (checkoutData) {
493
- var checkoutId = cookie__default["default"].get('checkoutId');
494
- if (!i2.isNil(checkoutId))
495
- return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
496
- return rxjs.from(this.createCheckout(checkoutData));
497
- };
498
- CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
499
- var _this = this;
500
- 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'); }); }));
501
- };
502
- CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
503
- return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
504
- };
505
- CheckoutService.prototype.updateCheckoutUser = function (checkout) {
506
- return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
507
- };
508
- CheckoutService.prototype.clearCheckoutFromSession = function () {
509
- cookie__default["default"].remove('checkoutId');
510
- return rxjs.of();
511
- };
512
- CheckoutService.prototype.checkCoupon = function (nickname) {
513
- var _this = this;
514
- return this.getCheckout().pipe(operators.concatMap(function (checkout) {
515
- var _a;
516
- return _this.couponService.checkCoupon(nickname, (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email, i2.CheckoutTypes.ECOMMERCE).pipe(operators.concatMap(function (coupons) { return rxjs.of(coupons.shift()); }), operators.concatMap(function (coupon) {
517
- var _a, _b;
518
- return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email)
519
- ? rxjs.from(_this.orderRepository.find([{ user: { email: (_b = checkout.user) === null || _b === void 0 ? void 0 : _b.email }, coupon: { id: coupon.id } }])).pipe(operators.concatMap(function (orders) {
520
- if (orders.data.length >= (coupon.useLimit || Infinity))
521
- return rxjs.throwError(function () { return new Error('Coupon is already applied'); });
522
- return rxjs.of(coupon);
523
- }))
524
- : rxjs.of(coupon);
525
- }));
526
- }));
527
- };
528
- CheckoutService.prototype.createCheckout = function (checkoutData) {
529
- return __awaiter(this, void 0, void 0, function () {
530
- var checkout;
531
- return __generator(this, function (_c) {
532
- switch (_c.label) {
533
- 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 }))];
534
- case 1:
535
- checkout = _c.sent();
536
- cookie__default["default"].set('checkoutId', checkout.id);
537
- return [2 /*return*/, checkout];
538
- }
539
- });
540
- });
541
- };
542
- return CheckoutService;
543
- }());
544
- 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 });
545
- CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
546
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
547
- type: i0.Injectable
548
- }], ctorParameters: function () {
549
- return [{ type: CouponService }, { type: undefined, decorators: [{
550
- type: i0.Inject,
551
- args: ['CheckoutRepository']
552
- }] }, { type: undefined, decorators: [{
553
- type: i0.Inject,
554
- args: ['OrderRepository']
555
- }] }, { type: undefined, decorators: [{
556
- type: i0.Inject,
557
- args: ['UserRepository']
558
- }] }, { type: i2__namespace.Shops, decorators: [{
559
- type: i0.Inject,
560
- args: [DEFAULT_SHOP]
561
- }] }];
519
+ var CheckoutService = /** @class */ (function () {
520
+ function CheckoutService(couponService, checkoutRepository, orderRepository, userRepository, defaultShop) {
521
+ this.couponService = couponService;
522
+ this.checkoutRepository = checkoutRepository;
523
+ this.orderRepository = orderRepository;
524
+ this.userRepository = userRepository;
525
+ this.defaultShop = defaultShop;
526
+ }
527
+ CheckoutService.prototype.getCheckout = function (checkoutData) {
528
+ var checkoutId = cookie__default["default"].get('checkoutId');
529
+ if (!i2.isNil(checkoutId))
530
+ return rxjs.from(this.checkoutRepository.get({ id: checkoutId }));
531
+ return rxjs.from(this.createCheckout(checkoutData));
532
+ };
533
+ CheckoutService.prototype.getUserByCheckout = function (checkoutId) {
534
+ var _this = this;
535
+ 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'); }); }));
536
+ };
537
+ CheckoutService.prototype.updateCheckoutLineItems = function (checkout) {
538
+ return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
539
+ };
540
+ CheckoutService.prototype.updateCheckoutUser = function (checkout) {
541
+ return rxjs.from(this.checkoutRepository.update(i2.Checkout.toInstance({ id: checkout.id, user: checkout.user })));
542
+ };
543
+ CheckoutService.prototype.clearCheckoutFromSession = function () {
544
+ cookie__default["default"].remove('checkoutId');
545
+ return rxjs.of();
546
+ };
547
+ CheckoutService.prototype.applyCupon = function (coupon) { };
548
+ // checkCoupon(nickname: string): Observable<FinancialCoupon> {
549
+ // return this.getCheckout().pipe(
550
+ // concatMap((checkout) =>
551
+ // this.couponService.checkCoupon(nickname, checkout.user?.email, CheckoutTypes.ECOMMERCE).pipe(
552
+ // concatMap((coupons) => of(coupons.shift())),
553
+ // concatMap((coupon) =>
554
+ // !!checkout.user?.email
555
+ // ? from(
556
+ // this.orderRepository.find([{ user: { email: checkout.user?.email }, coupon: { id: coupon.id } }]),
557
+ // ).pipe(
558
+ // concatMap((orders) => {
559
+ // if (orders.data.length >= (coupon.useLimit || Infinity))
560
+ // return throwError(() => new Error('Coupon is already applied'))
561
+ // return of(coupon)
562
+ // }),
563
+ // )
564
+ // : of(coupon),
565
+ // ),
566
+ // ),
567
+ // ),
568
+ // )
569
+ // }
570
+ CheckoutService.prototype.createCheckout = function (checkoutData) {
571
+ return __awaiter(this, void 0, void 0, function () {
572
+ var checkout;
573
+ return __generator(this, function (_b) {
574
+ switch (_b.label) {
575
+ 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 }))];
576
+ case 1:
577
+ checkout = _b.sent();
578
+ cookie__default["default"].set('checkoutId', checkout.id);
579
+ return [2 /*return*/, checkout];
580
+ }
581
+ });
582
+ });
583
+ };
584
+ return CheckoutService;
585
+ }());
586
+ 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 });
587
+ CheckoutService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService });
588
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutService, decorators: [{
589
+ type: i0.Injectable
590
+ }], ctorParameters: function () {
591
+ return [{ type: CouponService }, { type: undefined, decorators: [{
592
+ type: i0.Inject,
593
+ args: ['CheckoutRepository']
594
+ }] }, { type: undefined, decorators: [{
595
+ type: i0.Inject,
596
+ args: ['OrderRepository']
597
+ }] }, { type: undefined, decorators: [{
598
+ type: i0.Inject,
599
+ args: ['UserRepository']
600
+ }] }, { type: i2__namespace.Shops, decorators: [{
601
+ type: i0.Inject,
602
+ args: [DEFAULT_SHOP]
603
+ }] }];
562
604
  } });
563
605
 
564
- var CartService = /** @class */ (function () {
565
- function CartService(authService, checkoutService, defaultShop) {
566
- var _this = this;
567
- this.authService = authService;
568
- this.checkoutService = checkoutService;
569
- this.defaultShop = defaultShop;
570
- this.cartSubject = new rxjs.Subject();
571
- this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i2.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
572
- var _a;
573
- var items = [];
574
- var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
575
- if (index > -1) {
576
- checkoutLoaded.lineItems[index].quantity += quantity;
577
- checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
578
- }
579
- else
580
- checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
581
- return _this.checkoutService
582
- .updateCheckoutLineItems(checkoutLoaded)
583
- .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
584
- })); };
585
- this.generateCartObject = function (items) {
586
- var cart = {};
587
- items === null || items === void 0 ? void 0 : items.forEach(function (item) {
588
- var _a;
589
- 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) })));
590
- });
591
- return cart;
592
- };
593
- this.buildLineItem = function (_f) {
594
- var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
595
- var _a, _b, _c, _d, _e;
596
- 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;
597
- if (_this.checkMaxStock(item, quantity || 0))
598
- throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
599
- var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
600
- var id = item.id, name = item.name, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
601
- var isGift = item.isGift || null;
602
- var pricePaid = _this.getProductPrice({
603
- product: item,
604
- shop: checkout.shop || _this.defaultShop,
605
- isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
606
- });
607
- var EAN = item.EAN;
608
- console.log('set EAN', EAN);
609
- return i2.LineItem.toInstance({
610
- id: id,
611
- EAN: EAN,
612
- name: name,
613
- brand: brand,
614
- slug: slug,
615
- sku: sku,
616
- stock: stock,
617
- price: price,
618
- image: image,
619
- weight: weight,
620
- quantity: (item.quantity || 0) + (quantity || 0),
621
- pricePaid: pricePaid,
622
- categories: categories,
623
- isGift: isGift,
624
- costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
625
- });
626
- };
627
- this.getProductPrice = function (_f) {
628
- var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
629
- var info = product.getInfoByShop(shop);
630
- if (product.isGift)
631
- return 0;
632
- return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
633
- };
634
- this.checkMaxStock = function (item, quantity) {
635
- var _a;
636
- var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
637
- var currentItemAmount = item.quantity || 0;
638
- return currentItemAmount + quantity > maxStock;
639
- };
640
- }
641
- CartService.prototype.addItem = function (item, quantity) {
642
- var _this = this;
643
- if (quantity === void 0) { quantity = 1; }
644
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
645
- checkout: checkout,
646
- lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }),
647
- }); }), operators.concatMap(function (_f) {
648
- var checkout = _f.checkout, lineItem = _f.lineItem;
649
- return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
650
- }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
651
- };
652
- CartService.prototype.decreaseItem = function (item) {
653
- var _this = this;
654
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
655
- var _a;
656
- var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
657
- if (!i2.isNil(checkoutItem))
658
- checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
659
- return checkout;
660
- }), 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); }));
661
- };
662
- CartService.prototype.getCart = function (checkout) {
663
- var _this = this;
664
- this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
665
- return this.cartSubject;
666
- };
667
- /**
668
- * @deprecated The method should not be used
669
- */
670
- CartService.prototype.getDiscount = function (coupon) {
671
- switch (coupon.type) {
672
- case i2.CouponTypes.FINANCIAL:
673
- return this.getFinancialDiscount(coupon);
674
- case i2.CouponTypes.PRODUCT:
675
- return function (subTotalPrice) { return subTotalPrice; };
676
- case i2.CouponTypes.GIFTCARD:
677
- return this.getFinancialDiscount(coupon);
678
- case i2.CouponTypes.VOUCHER:
679
- return function (subTotalPrice) { return subTotalPrice; };
680
- }
681
- };
682
- /**
683
- * @deprecated The method should not be used
684
- */
685
- CartService.prototype.getVariantPriceDiscount = function (item, shop) {
686
- return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice; }, rxjs.of(item.getInfoByShop(shop).subscriberPrice), rxjs.of(item.getInfoByShop(shop).price)); }), operators.catchError(function () { return rxjs.of(item.getInfoByShop(shop).price); }));
687
- };
688
- CartService.prototype.removeItem = function (item) {
689
- var _this = this;
690
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
691
- var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
692
- if (index >= 0)
693
- checkout.lineItems.splice(index, 1);
694
- return checkout;
695
- }), 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); }));
696
- };
697
- CartService.prototype.updateUserCart = function (user) {
698
- var _this = this;
699
- 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) {
700
- var _a;
701
- return _this.checkoutService.updateCheckoutLineItems(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (item) { return _this.buildLineItem({ checkout: checkout, item: item }); })) || [] })));
702
- }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
703
- };
704
- CartService.prototype.clearCart = function () {
705
- var _this = this;
706
- return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
707
- _this.checkoutService.clearCheckoutFromSession();
708
- return checkout;
709
- }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
710
- };
711
- CartService.prototype.buildCartFromCheckout = function (checkoutData) {
712
- var _this = this;
713
- return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
714
- };
715
- CartService.prototype.getFinancialDiscount = function (coupon) {
716
- return function (subTotalPrice) {
717
- if (i2.FinancialCoupon.isFinancialCoupon(coupon))
718
- switch (coupon.subtype) {
719
- case i2.CouponSubtypes.ABSOLUTE:
720
- return subTotalPrice - coupon.discount * 100;
721
- case i2.CouponSubtypes.PERCENTAGE:
722
- return subTotalPrice * (1 - coupon.discount / 100);
723
- }
724
- };
725
- };
726
- return CartService;
727
- }());
728
- 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 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
729
- CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
730
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
731
- type: i0.Injectable
732
- }], ctorParameters: function () {
733
- return [{ type: AuthService }, { type: CheckoutService }, { type: i2__namespace.Shops, decorators: [{
734
- type: i0.Inject,
735
- args: [DEFAULT_SHOP]
736
- }] }];
606
+ var CartService = /** @class */ (function () {
607
+ function CartService(authService, checkoutService, defaultShop) {
608
+ var _this = this;
609
+ this.authService = authService;
610
+ this.checkoutService = checkoutService;
611
+ this.defaultShop = defaultShop;
612
+ this.cartSubject = new rxjs.Subject();
613
+ this.updateLineItemInCart = function (lineItem, quantity, checkout) { return (i2.isNil(checkout) ? _this.checkoutService.getCheckout() : rxjs.of(checkout)).pipe(operators.concatMap(function (checkoutLoaded) {
614
+ var _a;
615
+ var items = [];
616
+ var index = (_a = checkoutLoaded.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (checkoutItem) { return checkoutItem.sku; }).indexOf(lineItem.sku);
617
+ if (index > -1) {
618
+ checkoutLoaded.lineItems[index].quantity += quantity;
619
+ checkoutLoaded.lineItems[index].pricePaid = lineItem.pricePaid;
620
+ }
621
+ else
622
+ checkoutLoaded.lineItems = items.concat(checkoutLoaded.lineItems ? checkoutLoaded.lineItems.concat([lineItem]) : [lineItem]);
623
+ return _this.checkoutService
624
+ .updateCheckoutLineItems(checkoutLoaded)
625
+ .pipe(operators.map(function (updatedCheckout) { return _this.generateCartObject(updatedCheckout.lineItems); }));
626
+ })); };
627
+ this.generateCartObject = function (items) {
628
+ var cart = {};
629
+ items === null || items === void 0 ? void 0 : items.forEach(function (item) {
630
+ var _a;
631
+ 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) })));
632
+ });
633
+ return cart;
634
+ };
635
+ this.buildLineItem = function (_f) {
636
+ var checkout = _f.checkout, item = _f.item, quantity = _f.quantity;
637
+ var _a, _b, _c, _d, _e;
638
+ 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;
639
+ if (_this.checkMaxStock(item, quantity || 0))
640
+ throw new Error('Desculpe! Temos apenas ' + ((_c = item.stock) === null || _c === void 0 ? void 0 : _c.quantity) + ' em estoque.');
641
+ var image = item.image || ((_d = item.images) === null || _d === void 0 ? void 0 : _d.shift());
642
+ var id = item.id, name = item.name, brand = item.brand, slug = item.slug, stock = item.stock, price = item.price, weight = item.weight, categories = item.categories, sku = item.sku;
643
+ var isGift = item.isGift || null;
644
+ var pricePaid = _this.getProductPrice({
645
+ product: item,
646
+ shop: checkout.shop || _this.defaultShop,
647
+ isSubscriber: (_e = checkout.user) === null || _e === void 0 ? void 0 : _e.isSubscriber,
648
+ });
649
+ return i2.LineItem.toInstance({
650
+ id: id,
651
+ name: name,
652
+ brand: brand,
653
+ slug: slug,
654
+ sku: sku,
655
+ stock: stock,
656
+ price: price,
657
+ image: image,
658
+ weight: weight,
659
+ quantity: (item.quantity || 0) + (quantity || 0),
660
+ pricePaid: pricePaid,
661
+ categories: categories,
662
+ isGift: isGift,
663
+ costPrice: item === null || item === void 0 ? void 0 : item.costPrice,
664
+ });
665
+ };
666
+ this.getProductPrice = function (_f) {
667
+ var product = _f.product, shop = _f.shop, isSubscriber = _f.isSubscriber;
668
+ var info = product.getInfoByShop(shop);
669
+ if (product.isGift)
670
+ return 0;
671
+ return isSubscriber && info.subscriberPrice > 0 ? info.subscriberPrice : info.price;
672
+ };
673
+ this.checkMaxStock = function (item, quantity) {
674
+ var _a;
675
+ var maxStock = ((_a = item.stock) === null || _a === void 0 ? void 0 : _a.quantity) || 0;
676
+ var currentItemAmount = item.quantity || 0;
677
+ return currentItemAmount + quantity > maxStock;
678
+ };
679
+ }
680
+ CartService.prototype.addItem = function (item, quantity) {
681
+ var _this = this;
682
+ if (quantity === void 0) { quantity = 1; }
683
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) { return ({
684
+ checkout: checkout,
685
+ lineItem: _this.buildLineItem({ checkout: checkout, item: item, quantity: quantity || 1 }),
686
+ }); }), operators.concatMap(function (_f) {
687
+ var checkout = _f.checkout, lineItem = _f.lineItem;
688
+ return _this.updateLineItemInCart(lineItem, quantity || 1, checkout);
689
+ }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
690
+ };
691
+ CartService.prototype.decreaseItem = function (item) {
692
+ var _this = this;
693
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
694
+ var _a;
695
+ var checkoutItem = (_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.find(function (lineItem) { return lineItem.sku === item.sku; });
696
+ if (!i2.isNil(checkoutItem))
697
+ checkoutItem.quantity -= checkoutItem.quantity > 1 ? 1 : 0;
698
+ return checkout;
699
+ }), 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); }));
700
+ };
701
+ CartService.prototype.getCart = function (checkout) {
702
+ var _this = this;
703
+ this.buildCartFromCheckout(checkout).subscribe(function (cart) { return _this.cartSubject.next(cart); });
704
+ return this.cartSubject;
705
+ };
706
+ /**
707
+ * @deprecated The method should not be used
708
+ */
709
+ CartService.prototype.getVariantPriceDiscount = function (item, shop) {
710
+ return this.authService.getUser().pipe(operators.concatMap(function (user) { return rxjs.iif(function () { return user.isSubscriber && !!item.getInfoByShop(shop).subscriberPrice; }, rxjs.of(item.getInfoByShop(shop).subscriberPrice), rxjs.of(item.getInfoByShop(shop).price)); }), operators.catchError(function () { return rxjs.of(item.getInfoByShop(shop).price); }));
711
+ };
712
+ CartService.prototype.removeItem = function (item) {
713
+ var _this = this;
714
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
715
+ var index = checkout.lineItems.findIndex(function (lineItem) { return lineItem.sku === item.sku; });
716
+ if (index >= 0)
717
+ checkout.lineItems.splice(index, 1);
718
+ return checkout;
719
+ }), 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); }));
720
+ };
721
+ CartService.prototype.updateUserCart = function (user) {
722
+ var _this = this;
723
+ 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) {
724
+ var _a;
725
+ return _this.checkoutService.updateCheckoutLineItems(i2.Checkout.toInstance(Object.assign(Object.assign({}, checkout.toPlain()), { lineItems: ((_a = checkout.lineItems) === null || _a === void 0 ? void 0 : _a.map(function (item) { return _this.buildLineItem({ checkout: checkout, item: item }); })) || [] })));
726
+ }), operators.map(function (checkout) { return _this.generateCartObject(checkout.lineItems); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
727
+ };
728
+ CartService.prototype.clearCart = function () {
729
+ var _this = this;
730
+ return this.checkoutService.getCheckout().pipe(operators.map(function (checkout) {
731
+ _this.checkoutService.clearCheckoutFromSession();
732
+ return checkout;
733
+ }), operators.concatMap(function (oldCheckout) { return _this.buildCartFromCheckout(oldCheckout); }), operators.tap(function (cart) { return _this.cartSubject.next(cart); }));
734
+ };
735
+ CartService.prototype.buildCartFromCheckout = function (checkoutData) {
736
+ var _this = this;
737
+ return this.checkoutService.getCheckout(checkoutData).pipe(operators.map(function (checkout) { return checkout.lineItems; }), operators.concatMap(function (lineItems) { return rxjs.of(_this.generateCartObject(lineItems)); }));
738
+ };
739
+ CartService.prototype.getSubTotalDiscount = function (coupon) {
740
+ return function (subTotalPrice) {
741
+ switch (coupon.type) {
742
+ case i2.CouponTypes.ABSOLUTE:
743
+ return subTotalPrice - coupon.discount;
744
+ case i2.CouponTypes.PERCENTAGE:
745
+ return subTotalPrice * (1 - coupon.discount / 100);
746
+ }
747
+ };
748
+ };
749
+ return CartService;
750
+ }());
751
+ 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 }], target: i0__namespace.ɵɵFactoryTarget.Injectable });
752
+ CartService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService });
753
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CartService, decorators: [{
754
+ type: i0.Injectable
755
+ }], ctorParameters: function () {
756
+ return [{ type: AuthService }, { type: CheckoutService }, { type: i2__namespace.Shops, decorators: [{
757
+ type: i0.Inject,
758
+ args: [DEFAULT_SHOP]
759
+ }] }];
737
760
  } });
738
761
 
739
- var CheckoutSubscriptionService = /** @class */ (function () {
740
- function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
741
- var _this = this;
742
- this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
743
- this.subscriptionRepository = subscriptionRepository;
744
- this.couponService = couponService;
745
- this.checkCouponsWithCheckout = function (coupons, checkout) { return rxjs.forkJoin(coupons.map(function (coupon) {
746
- var _a;
747
- return rxjs.from(_this.subscriptionRepository.find([{ user: { email: (_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email }, coupon: { id: coupon.id } }])).pipe(operators.map(function (subscriptions) { return ({ coupon: coupon, subscriptions: subscriptions }); }));
748
- })).pipe(operators.map(function (results) { return results.map(function (_b) {
749
- var coupon = _b.coupon, subscriptions = _b.subscriptions;
750
- if (subscriptions.data.length >= (coupon.useLimit || Infinity))
751
- return new InvalidCouponError('Coupon is already applied');
752
- return coupon;
753
- }); }), operators.map(function (validatedCoupons) { return ({
754
- valids: validatedCoupons.filter(function (coupon) { return i2.FinancialCoupon.isFinancialCoupon(coupon); }),
755
- invalids: validatedCoupons.filter(function (coupon) { return coupon instanceof InvalidCouponError; }),
756
- }); }), operators.concatMap(function (_b) {
757
- var valids = _b.valids, invalids = _b.invalids;
758
- return valids.length ? rxjs.of(valids) : rxjs.throwError(new GroupInvalidCouponError(invalids));
759
- })); };
760
- }
761
- CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
762
- var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
763
- if (!i2.isNil(checkoutId))
764
- return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
765
- return rxjs.from(this.createCheckoutSubscription(checkoutData));
766
- };
767
- CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
768
- return __awaiter(this, void 0, void 0, function () {
769
- var checkout;
770
- return __generator(this, function (_b) {
771
- switch (_b.label) {
772
- case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
773
- case 1:
774
- checkout = _b.sent();
775
- cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
776
- return [2 /*return*/, checkout];
777
- }
778
- });
779
- });
780
- };
781
- CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
782
- cookie__default["default"].remove('checkoutSubscriptionId');
783
- return rxjs.of();
784
- };
785
- CheckoutSubscriptionService.prototype.checkCoupon = function (nickname, userEmail) {
786
- var _this = this;
787
- return this.getCheckoutSubscription().pipe(operators.concatMap(function (checkout) { return _this.couponService.checkCoupon(nickname, userEmail, i2.CheckoutTypes.SUBSCRIPTION).pipe(operators.concatMap(function (coupons) {
788
- var couponsWithSamePlan = coupons.filter(function (coupon) { return checkout.subscriptionPlan.name === coupon.plan; });
789
- var couponsWithNoPlan = coupons.filter(function (coupon) { return !coupon.plan; });
790
- if (couponsWithSamePlan.length > 0)
791
- return rxjs.of(couponsWithSamePlan);
792
- if (couponsWithNoPlan.length > 0)
793
- return rxjs.of(couponsWithNoPlan);
794
- throw new Error("Coupon subscription plan is invalid.");
795
- }), operators.concatMap(function (coupons) { var _a; return !!((_a = checkout.user) === null || _a === void 0 ? void 0 : _a.email) ? _this.checkCouponsWithCheckout(coupons, checkout) : rxjs.of(coupons); }), operators.map(function (validatedCoupons) { return validatedCoupons.shift(); })); }));
796
- };
797
- return CheckoutSubscriptionService;
798
- }());
799
- 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 });
800
- CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
801
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
802
- type: i0.Injectable
803
- }], ctorParameters: function () {
804
- return [{ type: undefined, decorators: [{
805
- type: i0.Inject,
806
- args: ['CheckoutSubscriptionRepository']
807
- }] }, { type: undefined, decorators: [{
808
- type: i0.Inject,
809
- args: ['SubscriptionRepository']
810
- }] }, { type: CouponService }];
762
+ var CheckoutSubscriptionService = /** @class */ (function () {
763
+ function CheckoutSubscriptionService(checkoutSubscriptionRepository, subscriptionRepository, couponService) {
764
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
765
+ this.subscriptionRepository = subscriptionRepository;
766
+ this.couponService = couponService;
767
+ }
768
+ CheckoutSubscriptionService.prototype.getCheckoutSubscription = function (checkoutData) {
769
+ var checkoutId = cookie__default["default"].get('checkoutSubscriptionId');
770
+ if (!i2.isNil(checkoutId))
771
+ return rxjs.from(this.checkoutSubscriptionRepository.get({ id: checkoutId }));
772
+ return rxjs.from(this.createCheckoutSubscription(checkoutData));
773
+ };
774
+ CheckoutSubscriptionService.prototype.createCheckoutSubscription = function (checkoutData) {
775
+ return __awaiter(this, void 0, void 0, function () {
776
+ var checkout;
777
+ return __generator(this, function (_a) {
778
+ switch (_a.label) {
779
+ case 0: return [4 /*yield*/, this.checkoutSubscriptionRepository.create(Object.assign({ createdAt: new Date() }, i2.CheckoutSubscription.toInstance(i2.pick(checkoutData, ['user', 'shop'])).toPlain()))];
780
+ case 1:
781
+ checkout = _a.sent();
782
+ cookie__default["default"].set('checkoutSubscriptionId', checkout.id);
783
+ return [2 /*return*/, checkout];
784
+ }
785
+ });
786
+ });
787
+ };
788
+ CheckoutSubscriptionService.prototype.clearCheckoutSubscriptionFromSession = function () {
789
+ cookie__default["default"].remove('checkoutSubscriptionId');
790
+ return rxjs.of();
791
+ };
792
+ return CheckoutSubscriptionService;
793
+ }());
794
+ 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 });
795
+ CheckoutSubscriptionService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService });
796
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: CheckoutSubscriptionService, decorators: [{
797
+ type: i0.Injectable
798
+ }], ctorParameters: function () {
799
+ return [{ type: undefined, decorators: [{
800
+ type: i0.Inject,
801
+ args: ['CheckoutSubscriptionRepository']
802
+ }] }, { type: undefined, decorators: [{
803
+ type: i0.Inject,
804
+ args: ['SubscriptionRepository']
805
+ }] }, { type: CouponService }];
811
806
  } });
812
807
 
813
- var OrderService = /** @class */ (function () {
814
- function OrderService(angularFirestore, orderRepository) {
815
- this.angularFirestore = angularFirestore;
816
- this.orderRepository = orderRepository;
817
- this.orderSubject = new rxjs.Subject();
818
- }
819
- OrderService.prototype.getOrder = function (id) {
820
- var _this = this;
821
- this.angularFirestore
822
- .doc(this.orderRepository.collectionName + "/" + id)
823
- .valueChanges()
824
- .pipe(operators.map(function (doc) { return i2.Order.toInstance(doc); }))
825
- .subscribe(function (doc) { return _this.orderSubject.next(doc); });
826
- return this.orderSubject;
827
- };
828
- return OrderService;
829
- }());
830
- 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 });
831
- OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
832
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
833
- type: i0.Injectable
834
- }], ctorParameters: function () {
835
- return [{ type: i1__namespace$1.AngularFirestore }, { type: i2__namespace.OrderFirestoreRepository, decorators: [{
836
- type: i0.Inject,
837
- args: ['OrderRepository']
838
- }] }];
808
+ var OrderService = /** @class */ (function () {
809
+ function OrderService(angularFirestore, orderRepository) {
810
+ this.angularFirestore = angularFirestore;
811
+ this.orderRepository = orderRepository;
812
+ this.orderSubject = new rxjs.Subject();
813
+ }
814
+ OrderService.prototype.getOrder = function (id) {
815
+ var _this = this;
816
+ this.angularFirestore
817
+ .doc(this.orderRepository.collectionName + "/" + id)
818
+ .valueChanges()
819
+ .pipe(operators.map(function (doc) { return i2.Order.toInstance(doc); }))
820
+ .subscribe(function (doc) { return _this.orderSubject.next(doc); });
821
+ return this.orderSubject;
822
+ };
823
+ return OrderService;
824
+ }());
825
+ 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 });
826
+ OrderService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService });
827
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: OrderService, decorators: [{
828
+ type: i0.Injectable
829
+ }], ctorParameters: function () {
830
+ return [{ type: i1__namespace$1.AngularFirestore }, { type: i2__namespace.OrderFirestoreRepository, decorators: [{
831
+ type: i0.Inject,
832
+ args: ['OrderRepository']
833
+ }] }];
839
834
  } });
840
835
 
841
- var HomeShopService = /** @class */ (function () {
842
- function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
843
- this.categoryRepository = categoryRepository;
844
- this.homeRepository = homeRepository;
845
- this.productRepository = productRepository;
846
- this.defaultShop = defaultShop;
847
- this.buildCategoryGroupWithRequiredData = function (group) { return ({
848
- category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
849
- products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
850
- 'id',
851
- 'price',
852
- 'reviews',
853
- 'hasVariants',
854
- 'slug',
855
- 'sku',
856
- 'stock',
857
- 'costPrice',
858
- 'images',
859
- 'miniatures',
860
- 'name',
861
- 'weight',
862
- ])); }),
863
- }); };
864
- }
865
- Object.defineProperty(HomeShopService.prototype, "homeId", {
866
- get: function () {
867
- if (this.defaultShop === i2.Shops.GLAMSHOP)
868
- return 'glamshop';
869
- if (this.defaultShop === i2.Shops.MENSMARKET)
870
- return 'mens_market';
871
- return null;
872
- },
873
- enumerable: false,
874
- configurable: true
875
- });
876
- HomeShopService.prototype.getHomeData = function () {
877
- var _this = this;
878
- return this.getHomeConfiguration().pipe(operators.tap(function (home) { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), 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
879
- ? rxjs.of(home)
880
- : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
881
- var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
882
- return ({
883
- discoverProducts: discoverProducts,
884
- featuredProducts: featuredProducts,
885
- verticalProducts: verticalProducts,
886
- });
887
- }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
888
- };
889
- HomeShopService.prototype.getBanners = function (type) {
890
- return this.getHomeConfiguration().pipe(operators.map(function (home) {
891
- if (type === 'brand')
892
- return home.brandsCarousel;
893
- if (type === 'buyToWin')
894
- return [home.buyToWinBanner];
895
- if (type === 'block')
896
- return home.blockBanners;
897
- if (type === 'blog')
898
- return [home.blogBanner];
899
- }));
900
- };
901
- HomeShopService.prototype.getDiscoverProducts = function () {
902
- var _this = this;
903
- 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); })); }));
904
- };
905
- HomeShopService.prototype.getFeaturedProducts = function () {
906
- var _this = this;
907
- 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); })); }));
908
- };
909
- HomeShopService.prototype.getVerticalProducts = function () {
910
- var _this = this;
911
- return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.forkJoin([
912
- _this.categoryRepository.get({ id: id }),
913
- _this.productRepository.find([{ categories: { operator: i2.Where.LIKE, value: [id] } }], { limit: 12 }),
914
- ]).pipe(operators.map(function (_b) {
915
- var _c = __read(_b, 2), category = _c[0], products = _c[1];
916
- return ({ category: category, products: products.data });
917
- }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
918
- };
919
- HomeShopService.prototype.getHomeConfiguration = function () {
920
- var _this = this;
921
- return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
922
- ? rxjs.of(home)
923
- : !_this.homeId
924
- ? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
925
- : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
926
- };
927
- HomeShopService.prototype.saveHomeData = function (homeData) {
928
- var _this = this;
929
- var data = {
930
- createdAt: new Date(),
931
- expiresAt: i2.add(new Date(), { hours: 1 }),
932
- data: homeData,
933
- };
934
- return rxjs.from(this.homeRepository.update({
935
- id: this.homeId,
936
- data: data,
937
- })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
938
- };
939
- return HomeShopService;
940
- }());
941
- 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 });
942
- HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
943
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
944
- type: i0.Injectable
945
- }], ctorParameters: function () {
946
- return [{ type: undefined, decorators: [{
947
- type: i0.Inject,
948
- args: ['CategoryRepository']
949
- }] }, { type: undefined, decorators: [{
950
- type: i0.Inject,
951
- args: ['HomeRepository']
952
- }] }, { type: undefined, decorators: [{
953
- type: i0.Inject,
954
- args: ['ProductRepository']
955
- }] }, { type: i2__namespace.Shops, decorators: [{
956
- type: i0.Inject,
957
- args: [DEFAULT_SHOP]
958
- }] }];
836
+ var HomeShopService = /** @class */ (function () {
837
+ function HomeShopService(categoryRepository, homeRepository, productRepository, defaultShop) {
838
+ this.categoryRepository = categoryRepository;
839
+ this.homeRepository = homeRepository;
840
+ this.productRepository = productRepository;
841
+ this.defaultShop = defaultShop;
842
+ this.buildCategoryGroupWithRequiredData = function (group) { return ({
843
+ category: i2.Category.toInstance(i2.pick(group.category.toPlain(), ['id', 'name', 'slug', 'conditions'])),
844
+ products: group.products.map(function (product) { return i2.Product.toInstance(i2.pick(product.toPlain(), [
845
+ 'id',
846
+ 'price',
847
+ 'reviews',
848
+ 'hasVariants',
849
+ 'slug',
850
+ 'sku',
851
+ 'stock',
852
+ 'costPrice',
853
+ 'images',
854
+ 'miniatures',
855
+ 'name',
856
+ 'weight',
857
+ ])); }),
858
+ }); };
859
+ }
860
+ Object.defineProperty(HomeShopService.prototype, "homeId", {
861
+ get: function () {
862
+ if (this.defaultShop === i2.Shops.GLAMSHOP)
863
+ return 'glamshop';
864
+ if (this.defaultShop === i2.Shops.MENSMARKET)
865
+ return 'mens_market';
866
+ return null;
867
+ },
868
+ enumerable: false,
869
+ configurable: true
870
+ });
871
+ HomeShopService.prototype.getHomeData = function () {
872
+ var _this = this;
873
+ return this.getHomeConfiguration().pipe(operators.tap(function (home) { var _a; return console.log((_a = home === null || home === void 0 ? void 0 : home.data) === null || _a === void 0 ? void 0 : _a.expiresAt); }), 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
874
+ ? rxjs.of(home)
875
+ : rxjs.forkJoin([_this.getDiscoverProducts(), _this.getFeaturedProducts(), _this.getVerticalProducts()]).pipe(operators.map(function (_b) {
876
+ var _c = __read(_b, 3), discoverProducts = _c[0], featuredProducts = _c[1], verticalProducts = _c[2];
877
+ return ({
878
+ discoverProducts: discoverProducts,
879
+ featuredProducts: featuredProducts,
880
+ verticalProducts: verticalProducts,
881
+ });
882
+ }), operators.concatMap(function (data) { return _this.saveHomeData(data); })); }));
883
+ };
884
+ HomeShopService.prototype.getBanners = function (type) {
885
+ return this.getHomeConfiguration().pipe(operators.map(function (home) {
886
+ if (type === 'brand')
887
+ return home.brandsCarousel;
888
+ if (type === 'buyToWin')
889
+ return [home.buyToWinBanner];
890
+ if (type === 'block')
891
+ return home.blockBanners;
892
+ if (type === 'blog')
893
+ return [home.blogBanner];
894
+ }));
895
+ };
896
+ HomeShopService.prototype.getDiscoverProducts = function () {
897
+ var _this = this;
898
+ 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); })); }));
899
+ };
900
+ HomeShopService.prototype.getFeaturedProducts = function () {
901
+ var _this = this;
902
+ 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); })); }));
903
+ };
904
+ HomeShopService.prototype.getVerticalProducts = function () {
905
+ var _this = this;
906
+ return this.getHomeConfiguration().pipe(operators.concatMap(function (home) { return rxjs.forkJoin(home.verticalCarousels.filter(Boolean).map(function (id) { return rxjs.forkJoin([
907
+ _this.categoryRepository.get({ id: id }),
908
+ _this.productRepository.find([{ categories: { operator: i2.Where.LIKE, value: [id] } }], { limit: 12 }),
909
+ ]).pipe(operators.map(function (_b) {
910
+ var _c = __read(_b, 2), category = _c[0], products = _c[1];
911
+ return ({ category: category, products: products.data });
912
+ }), operators.map(_this.buildCategoryGroupWithRequiredData)); })); }));
913
+ };
914
+ HomeShopService.prototype.getHomeConfiguration = function () {
915
+ var _this = this;
916
+ return rxjs.of(this.homeConfiguration).pipe(operators.concatMap(function (home) { return home
917
+ ? rxjs.of(home)
918
+ : !_this.homeId
919
+ ? rxjs.throwError(new i2.RequiredArgumentError(['homeId']))
920
+ : rxjs.from(_this.homeRepository.get({ id: _this.homeId })).pipe(operators.tap(function (homeLoaded) { return (_this.homeConfiguration = homeLoaded); })); }));
921
+ };
922
+ HomeShopService.prototype.saveHomeData = function (homeData) {
923
+ var _this = this;
924
+ var data = {
925
+ createdAt: new Date(),
926
+ expiresAt: i2.add(new Date(), { hours: 1 }),
927
+ data: homeData,
928
+ };
929
+ return rxjs.from(this.homeRepository.update({
930
+ id: this.homeId,
931
+ data: data,
932
+ })).pipe(operators.tap(function () { return (_this.homeConfiguration.data = data); }), operators.map(function () { return _this.homeConfiguration; }));
933
+ };
934
+ return HomeShopService;
935
+ }());
936
+ 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 });
937
+ HomeShopService.ɵprov = i0__namespace.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService });
938
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: HomeShopService, decorators: [{
939
+ type: i0.Injectable
940
+ }], ctorParameters: function () {
941
+ return [{ type: undefined, decorators: [{
942
+ type: i0.Inject,
943
+ args: ['CategoryRepository']
944
+ }] }, { type: undefined, decorators: [{
945
+ type: i0.Inject,
946
+ args: ['HomeRepository']
947
+ }] }, { type: undefined, decorators: [{
948
+ type: i0.Inject,
949
+ args: ['ProductRepository']
950
+ }] }, { type: i2__namespace.Shops, decorators: [{
951
+ type: i0.Inject,
952
+ args: [DEFAULT_SHOP]
953
+ }] }];
959
954
  } });
960
955
 
961
- var AngularFirebaseAuthModule = /** @class */ (function () {
962
- function AngularFirebaseAuthModule() {
963
- }
964
- AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
965
- return {
966
- ngModule: AngularFirebaseAuthModule,
967
- providers: [
968
- { provide: fire.FIREBASE_OPTIONS, useValue: options },
969
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
970
- ],
971
- };
972
- };
973
- return AngularFirebaseAuthModule;
974
- }());
975
- AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
976
- AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
977
- AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
978
- {
979
- provide: 'Authentication',
980
- useFactory: function (authenticationService, userRepository) {
981
- return new i2.Authentication(authenticationService, userRepository);
982
- },
983
- deps: ['AuthenticationService', 'UserRepository'],
984
- },
985
- {
986
- provide: 'AuthenticationService',
987
- useFactory: function (angularFireAuth) {
988
- return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
989
- },
990
- deps: [i1.AngularFireAuth],
991
- },
992
- {
993
- provide: 'Register',
994
- useFactory: function (registerService, userRepository) {
995
- return new i2.Register(registerService, userRepository);
996
- },
997
- deps: ['RegisterService', 'UserRepository'],
998
- },
999
- {
1000
- provide: 'RegisterService',
1001
- useFactory: function (angularFireAuth) {
1002
- return new i2.RegisterFirebaseAuthService(angularFireAuth);
1003
- },
1004
- deps: [i1.AngularFireAuth],
1005
- },
1006
- {
1007
- provide: 'SignOut',
1008
- useFactory: function (authenticationService) {
1009
- return new i2.SignOut(authenticationService);
1010
- },
1011
- deps: ['AuthenticationService'],
1012
- },
1013
- {
1014
- provide: 'RecoveryPassword',
1015
- useFactory: function (authenticationService) {
1016
- return new i2.RecoveryPassword(authenticationService);
1017
- },
1018
- deps: ['AuthenticationService'],
1019
- },
1020
- ], imports: [[fire.AngularFireModule]] });
1021
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1022
- type: i0.NgModule,
1023
- args: [{
1024
- imports: [fire.AngularFireModule],
1025
- providers: [
1026
- {
1027
- provide: 'Authentication',
1028
- useFactory: function (authenticationService, userRepository) {
1029
- return new i2.Authentication(authenticationService, userRepository);
1030
- },
1031
- deps: ['AuthenticationService', 'UserRepository'],
1032
- },
1033
- {
1034
- provide: 'AuthenticationService',
1035
- useFactory: function (angularFireAuth) {
1036
- return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
1037
- },
1038
- deps: [i1.AngularFireAuth],
1039
- },
1040
- {
1041
- provide: 'Register',
1042
- useFactory: function (registerService, userRepository) {
1043
- return new i2.Register(registerService, userRepository);
1044
- },
1045
- deps: ['RegisterService', 'UserRepository'],
1046
- },
1047
- {
1048
- provide: 'RegisterService',
1049
- useFactory: function (angularFireAuth) {
1050
- return new i2.RegisterFirebaseAuthService(angularFireAuth);
1051
- },
1052
- deps: [i1.AngularFireAuth],
1053
- },
1054
- {
1055
- provide: 'SignOut',
1056
- useFactory: function (authenticationService) {
1057
- return new i2.SignOut(authenticationService);
1058
- },
1059
- deps: ['AuthenticationService'],
1060
- },
1061
- {
1062
- provide: 'RecoveryPassword',
1063
- useFactory: function (authenticationService) {
1064
- return new i2.RecoveryPassword(authenticationService);
1065
- },
1066
- deps: ['AuthenticationService'],
1067
- },
1068
- ],
1069
- }]
956
+ var AngularFirebaseAuthModule = /** @class */ (function () {
957
+ function AngularFirebaseAuthModule() {
958
+ }
959
+ AngularFirebaseAuthModule.initializeApp = function (options, nameOrConfig) {
960
+ return {
961
+ ngModule: AngularFirebaseAuthModule,
962
+ providers: [
963
+ { provide: fire.FIREBASE_OPTIONS, useValue: options },
964
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
965
+ ],
966
+ };
967
+ };
968
+ return AngularFirebaseAuthModule;
969
+ }());
970
+ AngularFirebaseAuthModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
971
+ AngularFirebaseAuthModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, imports: [fire.AngularFireModule] });
972
+ AngularFirebaseAuthModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, providers: [
973
+ {
974
+ provide: 'Authentication',
975
+ useFactory: function (authenticationService, userRepository) {
976
+ return new i2.Authentication(authenticationService, userRepository);
977
+ },
978
+ deps: ['AuthenticationService', 'UserRepository'],
979
+ },
980
+ {
981
+ provide: 'AuthenticationService',
982
+ useFactory: function (angularFireAuth) {
983
+ return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
984
+ },
985
+ deps: [i1.AngularFireAuth],
986
+ },
987
+ {
988
+ provide: 'Register',
989
+ useFactory: function (registerService, userRepository) {
990
+ return new i2.Register(registerService, userRepository);
991
+ },
992
+ deps: ['RegisterService', 'UserRepository'],
993
+ },
994
+ {
995
+ provide: 'RegisterService',
996
+ useFactory: function (angularFireAuth) {
997
+ return new i2.RegisterFirebaseAuthService(angularFireAuth);
998
+ },
999
+ deps: [i1.AngularFireAuth],
1000
+ },
1001
+ {
1002
+ provide: 'SignOut',
1003
+ useFactory: function (authenticationService) {
1004
+ return new i2.SignOut(authenticationService);
1005
+ },
1006
+ deps: ['AuthenticationService'],
1007
+ },
1008
+ {
1009
+ provide: 'RecoveryPassword',
1010
+ useFactory: function (authenticationService) {
1011
+ return new i2.RecoveryPassword(authenticationService);
1012
+ },
1013
+ deps: ['AuthenticationService'],
1014
+ },
1015
+ ], imports: [[fire.AngularFireModule]] });
1016
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirebaseAuthModule, decorators: [{
1017
+ type: i0.NgModule,
1018
+ args: [{
1019
+ imports: [fire.AngularFireModule],
1020
+ providers: [
1021
+ {
1022
+ provide: 'Authentication',
1023
+ useFactory: function (authenticationService, userRepository) {
1024
+ return new i2.Authentication(authenticationService, userRepository);
1025
+ },
1026
+ deps: ['AuthenticationService', 'UserRepository'],
1027
+ },
1028
+ {
1029
+ provide: 'AuthenticationService',
1030
+ useFactory: function (angularFireAuth) {
1031
+ return new i2.AuthenticationFirebaseAuthService(angularFireAuth);
1032
+ },
1033
+ deps: [i1.AngularFireAuth],
1034
+ },
1035
+ {
1036
+ provide: 'Register',
1037
+ useFactory: function (registerService, userRepository) {
1038
+ return new i2.Register(registerService, userRepository);
1039
+ },
1040
+ deps: ['RegisterService', 'UserRepository'],
1041
+ },
1042
+ {
1043
+ provide: 'RegisterService',
1044
+ useFactory: function (angularFireAuth) {
1045
+ return new i2.RegisterFirebaseAuthService(angularFireAuth);
1046
+ },
1047
+ deps: [i1.AngularFireAuth],
1048
+ },
1049
+ {
1050
+ provide: 'SignOut',
1051
+ useFactory: function (authenticationService) {
1052
+ return new i2.SignOut(authenticationService);
1053
+ },
1054
+ deps: ['AuthenticationService'],
1055
+ },
1056
+ {
1057
+ provide: 'RecoveryPassword',
1058
+ useFactory: function (authenticationService) {
1059
+ return new i2.RecoveryPassword(authenticationService);
1060
+ },
1061
+ deps: ['AuthenticationService'],
1062
+ },
1063
+ ],
1064
+ }]
1070
1065
  }] });
1071
1066
 
1072
- var AngularElasticSeachModule = /** @class */ (function () {
1073
- function AngularElasticSeachModule() {
1074
- }
1075
- AngularElasticSeachModule.initializeApp = function (options) {
1076
- return {
1077
- ngModule: AngularElasticSeachModule,
1078
- providers: [{ provide: ES_CONFIG, useValue: options }],
1079
- };
1080
- };
1081
- return AngularElasticSeachModule;
1082
- }());
1083
- AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1084
- AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1085
- AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1086
- {
1087
- provide: i2.ProductsIndex,
1088
- useFactory: function (configuration) {
1089
- return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1090
- },
1091
- deps: [ES_CONFIG],
1092
- },
1093
- ] });
1094
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1095
- type: i0.NgModule,
1096
- args: [{
1097
- providers: [
1098
- {
1099
- provide: i2.ProductsIndex,
1100
- useFactory: function (configuration) {
1101
- return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1102
- },
1103
- deps: [ES_CONFIG],
1104
- },
1105
- ],
1106
- }]
1067
+ var AngularElasticSeachModule = /** @class */ (function () {
1068
+ function AngularElasticSeachModule() {
1069
+ }
1070
+ AngularElasticSeachModule.initializeApp = function (options) {
1071
+ return {
1072
+ ngModule: AngularElasticSeachModule,
1073
+ providers: [{ provide: ES_CONFIG, useValue: options }],
1074
+ };
1075
+ };
1076
+ return AngularElasticSeachModule;
1077
+ }());
1078
+ AngularElasticSeachModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1079
+ AngularElasticSeachModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule });
1080
+ AngularElasticSeachModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, providers: [
1081
+ {
1082
+ provide: i2.ProductsIndex,
1083
+ useFactory: function (configuration) {
1084
+ return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1085
+ },
1086
+ deps: [ES_CONFIG],
1087
+ },
1088
+ ] });
1089
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularElasticSeachModule, decorators: [{
1090
+ type: i0.NgModule,
1091
+ args: [{
1092
+ providers: [
1093
+ {
1094
+ provide: i2.ProductsIndex,
1095
+ useFactory: function (configuration) {
1096
+ return new i2.ProductsIndex(new i2.AxiosAdapter(configuration));
1097
+ },
1098
+ deps: [ES_CONFIG],
1099
+ },
1100
+ ],
1101
+ }]
1107
1102
  }] });
1108
1103
 
1109
- var AngularFirestoreModule = /** @class */ (function () {
1110
- function AngularFirestoreModule() {
1111
- }
1112
- AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1113
- return {
1114
- ngModule: AngularFirestoreModule,
1115
- providers: [
1116
- { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1117
- { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1118
- { provide: ES_CONFIG, useValue: options.elasticSearch },
1119
- ],
1120
- };
1121
- };
1122
- return AngularFirestoreModule;
1123
- }());
1124
- AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1125
- AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1126
- AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1127
- {
1128
- provide: 'BeautyProfileRepository',
1129
- useFactory: function (firestore, userRepository) {
1130
- return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1131
- },
1132
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1133
- },
1134
- {
1135
- provide: 'Buy2WinRepository',
1136
- useFactory: function (firestore) {
1137
- return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1138
- },
1139
- deps: [i1$1.AngularFirestore],
1140
- },
1141
- {
1142
- provide: 'CategoryRepository',
1143
- useFactory: function (firestore, productsIndex) {
1144
- return new i2.CategoryFirestoreRepository(firestore.firestore, productsIndex);
1145
- },
1146
- deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1147
- },
1148
- {
1149
- provide: 'CheckoutRepository',
1150
- useFactory: function (firestore) {
1151
- return new i2.CheckoutFirestoreRepository(firestore.firestore);
1152
- },
1153
- deps: [i1$1.AngularFirestore],
1154
- },
1155
- {
1156
- provide: 'CheckoutSubscriptionRepository',
1157
- useFactory: function (firestore) {
1158
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1159
- },
1160
- deps: [i1$1.AngularFirestore],
1161
- },
1162
- {
1163
- provide: 'CouponRepository',
1164
- useFactory: function (firestore) {
1165
- return new i2.CouponFirestoreRepository(firestore.firestore);
1166
- },
1167
- deps: [i1$1.AngularFirestore],
1168
- },
1169
- {
1170
- provide: 'EditionRepository',
1171
- useFactory: function (firestore, subscriptionRepository) {
1172
- return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1173
- },
1174
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1175
- },
1176
- {
1177
- provide: 'HomeRepository',
1178
- useFactory: function (firestore) {
1179
- return new i2.HomeFirestoreRepository(firestore.firestore);
1180
- },
1181
- deps: [i1$1.AngularFirestore],
1182
- },
1183
- {
1184
- provide: 'LeadRepository',
1185
- useFactory: function (firestore) {
1186
- return new i2.LeadFirestoreRepository(firestore.firestore);
1187
- },
1188
- deps: [i1$1.AngularFirestore],
1189
- },
1190
- {
1191
- provide: 'LegacyOrderRepository',
1192
- useFactory: function (firestore) {
1193
- return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1194
- },
1195
- deps: [i1$1.AngularFirestore],
1196
- },
1197
- {
1198
- provide: 'ShopMenuRepository',
1199
- useFactory: function (firestore) {
1200
- return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1201
- },
1202
- deps: [i1$1.AngularFirestore],
1203
- },
1204
- {
1205
- provide: 'OrderRepository',
1206
- useFactory: function (firestore) {
1207
- return new i2.OrderFirestoreRepository(firestore.firestore);
1208
- },
1209
- deps: [i1$1.AngularFirestore],
1210
- },
1211
- {
1212
- provide: 'PaymentRepository',
1213
- useFactory: function (firestore) {
1214
- return new i2.PaymentFirestoreRepository(firestore.firestore);
1215
- },
1216
- deps: [i1$1.AngularFirestore],
1217
- },
1218
- {
1219
- provide: 'ProductRepository',
1220
- useFactory: function (firestore) {
1221
- return new i2.ProductFirestoreRepository(firestore.firestore);
1222
- },
1223
- deps: [i1$1.AngularFirestore],
1224
- },
1225
- {
1226
- provide: 'SubscriptionPaymentRepository',
1227
- useFactory: function (firestore, subscriptionRepository) {
1228
- return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1229
- },
1230
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1231
- },
1232
- {
1233
- provide: 'SubscriptionPlanRepository',
1234
- useFactory: function (firestore) {
1235
- return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1236
- },
1237
- deps: [i1$1.AngularFirestore],
1238
- },
1239
- {
1240
- provide: 'SubscriptionProductRepository',
1241
- useFactory: function (firestore) {
1242
- return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1243
- },
1244
- deps: [i1$1.AngularFirestore],
1245
- },
1246
- {
1247
- provide: 'SubscriptionRepository',
1248
- useFactory: function (firestore) {
1249
- return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1250
- },
1251
- deps: [i1$1.AngularFirestore],
1252
- },
1253
- {
1254
- provide: 'UserRepository',
1255
- useFactory: function (firestore) {
1256
- return new i2.UserFirestoreRepository(firestore.firestore);
1257
- },
1258
- deps: [i1$1.AngularFirestore],
1259
- },
1260
- {
1261
- provide: 'UserAddressRepository',
1262
- useFactory: function (firestore, userRepository) {
1263
- return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1264
- },
1265
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1266
- },
1267
- {
1268
- provide: 'UserPaymentMethodRepository',
1269
- useFactory: function (firestore, userRepository) {
1270
- return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1271
- },
1272
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1273
- },
1274
- {
1275
- provide: 'VariantRepository',
1276
- useFactory: function (firestore, productRepository) {
1277
- return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1278
- },
1279
- deps: [i1$1.AngularFirestore, 'ProductRepository'],
1280
- },
1281
- ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1282
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1283
- type: i0.NgModule,
1284
- args: [{
1285
- imports: [fire.AngularFireModule, AngularElasticSeachModule],
1286
- providers: [
1287
- {
1288
- provide: 'BeautyProfileRepository',
1289
- useFactory: function (firestore, userRepository) {
1290
- return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1291
- },
1292
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1293
- },
1294
- {
1295
- provide: 'Buy2WinRepository',
1296
- useFactory: function (firestore) {
1297
- return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1298
- },
1299
- deps: [i1$1.AngularFirestore],
1300
- },
1301
- {
1302
- provide: 'CategoryRepository',
1303
- useFactory: function (firestore, productsIndex) {
1304
- return new i2.CategoryFirestoreRepository(firestore.firestore, productsIndex);
1305
- },
1306
- deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1307
- },
1308
- {
1309
- provide: 'CheckoutRepository',
1310
- useFactory: function (firestore) {
1311
- return new i2.CheckoutFirestoreRepository(firestore.firestore);
1312
- },
1313
- deps: [i1$1.AngularFirestore],
1314
- },
1315
- {
1316
- provide: 'CheckoutSubscriptionRepository',
1317
- useFactory: function (firestore) {
1318
- return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1319
- },
1320
- deps: [i1$1.AngularFirestore],
1321
- },
1322
- {
1323
- provide: 'CouponRepository',
1324
- useFactory: function (firestore) {
1325
- return new i2.CouponFirestoreRepository(firestore.firestore);
1326
- },
1327
- deps: [i1$1.AngularFirestore],
1328
- },
1329
- {
1330
- provide: 'EditionRepository',
1331
- useFactory: function (firestore, subscriptionRepository) {
1332
- return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1333
- },
1334
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1335
- },
1336
- {
1337
- provide: 'HomeRepository',
1338
- useFactory: function (firestore) {
1339
- return new i2.HomeFirestoreRepository(firestore.firestore);
1340
- },
1341
- deps: [i1$1.AngularFirestore],
1342
- },
1343
- {
1344
- provide: 'LeadRepository',
1345
- useFactory: function (firestore) {
1346
- return new i2.LeadFirestoreRepository(firestore.firestore);
1347
- },
1348
- deps: [i1$1.AngularFirestore],
1349
- },
1350
- {
1351
- provide: 'LegacyOrderRepository',
1352
- useFactory: function (firestore) {
1353
- return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1354
- },
1355
- deps: [i1$1.AngularFirestore],
1356
- },
1357
- {
1358
- provide: 'ShopMenuRepository',
1359
- useFactory: function (firestore) {
1360
- return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1361
- },
1362
- deps: [i1$1.AngularFirestore],
1363
- },
1364
- {
1365
- provide: 'OrderRepository',
1366
- useFactory: function (firestore) {
1367
- return new i2.OrderFirestoreRepository(firestore.firestore);
1368
- },
1369
- deps: [i1$1.AngularFirestore],
1370
- },
1371
- {
1372
- provide: 'PaymentRepository',
1373
- useFactory: function (firestore) {
1374
- return new i2.PaymentFirestoreRepository(firestore.firestore);
1375
- },
1376
- deps: [i1$1.AngularFirestore],
1377
- },
1378
- {
1379
- provide: 'ProductRepository',
1380
- useFactory: function (firestore) {
1381
- return new i2.ProductFirestoreRepository(firestore.firestore);
1382
- },
1383
- deps: [i1$1.AngularFirestore],
1384
- },
1385
- {
1386
- provide: 'SubscriptionPaymentRepository',
1387
- useFactory: function (firestore, subscriptionRepository) {
1388
- return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1389
- },
1390
- deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1391
- },
1392
- {
1393
- provide: 'SubscriptionPlanRepository',
1394
- useFactory: function (firestore) {
1395
- return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1396
- },
1397
- deps: [i1$1.AngularFirestore],
1398
- },
1399
- {
1400
- provide: 'SubscriptionProductRepository',
1401
- useFactory: function (firestore) {
1402
- return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1403
- },
1404
- deps: [i1$1.AngularFirestore],
1405
- },
1406
- {
1407
- provide: 'SubscriptionRepository',
1408
- useFactory: function (firestore) {
1409
- return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1410
- },
1411
- deps: [i1$1.AngularFirestore],
1412
- },
1413
- {
1414
- provide: 'UserRepository',
1415
- useFactory: function (firestore) {
1416
- return new i2.UserFirestoreRepository(firestore.firestore);
1417
- },
1418
- deps: [i1$1.AngularFirestore],
1419
- },
1420
- {
1421
- provide: 'UserAddressRepository',
1422
- useFactory: function (firestore, userRepository) {
1423
- return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1424
- },
1425
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1426
- },
1427
- {
1428
- provide: 'UserPaymentMethodRepository',
1429
- useFactory: function (firestore, userRepository) {
1430
- return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1431
- },
1432
- deps: [i1$1.AngularFirestore, 'UserRepository'],
1433
- },
1434
- {
1435
- provide: 'VariantRepository',
1436
- useFactory: function (firestore, productRepository) {
1437
- return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1438
- },
1439
- deps: [i1$1.AngularFirestore, 'ProductRepository'],
1440
- },
1441
- ],
1442
- }]
1104
+ var AngularFirestoreModule = /** @class */ (function () {
1105
+ function AngularFirestoreModule() {
1106
+ }
1107
+ AngularFirestoreModule.initializeApp = function (options, nameOrConfig) {
1108
+ return {
1109
+ ngModule: AngularFirestoreModule,
1110
+ providers: [
1111
+ { provide: fire.FIREBASE_OPTIONS, useValue: options.firebase },
1112
+ { provide: fire.FIREBASE_APP_NAME, useValue: nameOrConfig },
1113
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
1114
+ ],
1115
+ };
1116
+ };
1117
+ return AngularFirestoreModule;
1118
+ }());
1119
+ AngularFirestoreModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1120
+ AngularFirestoreModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, imports: [fire.AngularFireModule, AngularElasticSeachModule] });
1121
+ AngularFirestoreModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, providers: [
1122
+ {
1123
+ provide: 'BeautyProfileRepository',
1124
+ useFactory: function (firestore, userRepository) {
1125
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1126
+ },
1127
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1128
+ },
1129
+ {
1130
+ provide: 'Buy2WinRepository',
1131
+ useFactory: function (firestore) {
1132
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1133
+ },
1134
+ deps: [i1$1.AngularFirestore],
1135
+ },
1136
+ {
1137
+ provide: 'CategoryRepository',
1138
+ useFactory: function (firestore, productsIndex) {
1139
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
1140
+ },
1141
+ deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1142
+ },
1143
+ {
1144
+ provide: 'CheckoutRepository',
1145
+ useFactory: function (firestore) {
1146
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
1147
+ },
1148
+ deps: [i1$1.AngularFirestore],
1149
+ },
1150
+ {
1151
+ provide: 'CheckoutSubscriptionRepository',
1152
+ useFactory: function (firestore) {
1153
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1154
+ },
1155
+ deps: [i1$1.AngularFirestore],
1156
+ },
1157
+ {
1158
+ provide: 'CouponRepository',
1159
+ useFactory: function (firestore) {
1160
+ return new i2.CouponFirestoreRepository(firestore.firestore);
1161
+ },
1162
+ deps: [i1$1.AngularFirestore],
1163
+ },
1164
+ {
1165
+ provide: 'EditionRepository',
1166
+ useFactory: function (firestore, subscriptionRepository) {
1167
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1168
+ },
1169
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1170
+ },
1171
+ {
1172
+ provide: 'HomeRepository',
1173
+ useFactory: function (firestore) {
1174
+ return new i2.HomeFirestoreRepository(firestore.firestore);
1175
+ },
1176
+ deps: [i1$1.AngularFirestore],
1177
+ },
1178
+ {
1179
+ provide: 'LeadRepository',
1180
+ useFactory: function (firestore) {
1181
+ return new i2.LeadFirestoreRepository(firestore.firestore);
1182
+ },
1183
+ deps: [i1$1.AngularFirestore],
1184
+ },
1185
+ {
1186
+ provide: 'LegacyOrderRepository',
1187
+ useFactory: function (firestore) {
1188
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1189
+ },
1190
+ deps: [i1$1.AngularFirestore],
1191
+ },
1192
+ {
1193
+ provide: 'ShopMenuRepository',
1194
+ useFactory: function (firestore) {
1195
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1196
+ },
1197
+ deps: [i1$1.AngularFirestore],
1198
+ },
1199
+ {
1200
+ provide: 'OrderRepository',
1201
+ useFactory: function (firestore) {
1202
+ return new i2.OrderFirestoreRepository(firestore.firestore);
1203
+ },
1204
+ deps: [i1$1.AngularFirestore],
1205
+ },
1206
+ {
1207
+ provide: 'PaymentRepository',
1208
+ useFactory: function (firestore) {
1209
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
1210
+ },
1211
+ deps: [i1$1.AngularFirestore],
1212
+ },
1213
+ {
1214
+ provide: 'ProductRepository',
1215
+ useFactory: function (firestore) {
1216
+ return new i2.ProductFirestoreRepository(firestore.firestore);
1217
+ },
1218
+ deps: [i1$1.AngularFirestore],
1219
+ },
1220
+ {
1221
+ provide: 'SubscriptionPaymentRepository',
1222
+ useFactory: function (firestore, subscriptionRepository) {
1223
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1224
+ },
1225
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1226
+ },
1227
+ {
1228
+ provide: 'SubscriptionPlanRepository',
1229
+ useFactory: function (firestore) {
1230
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1231
+ },
1232
+ deps: [i1$1.AngularFirestore],
1233
+ },
1234
+ {
1235
+ provide: 'SubscriptionProductRepository',
1236
+ useFactory: function (firestore) {
1237
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1238
+ },
1239
+ deps: [i1$1.AngularFirestore],
1240
+ },
1241
+ {
1242
+ provide: 'SubscriptionRepository',
1243
+ useFactory: function (firestore) {
1244
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1245
+ },
1246
+ deps: [i1$1.AngularFirestore],
1247
+ },
1248
+ {
1249
+ provide: 'UserRepository',
1250
+ useFactory: function (firestore) {
1251
+ return new i2.UserFirestoreRepository(firestore.firestore);
1252
+ },
1253
+ deps: [i1$1.AngularFirestore],
1254
+ },
1255
+ {
1256
+ provide: 'UserAddressRepository',
1257
+ useFactory: function (firestore, userRepository) {
1258
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1259
+ },
1260
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1261
+ },
1262
+ {
1263
+ provide: 'UserPaymentMethodRepository',
1264
+ useFactory: function (firestore, userRepository) {
1265
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1266
+ },
1267
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1268
+ },
1269
+ {
1270
+ provide: 'VariantRepository',
1271
+ useFactory: function (firestore, productRepository) {
1272
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1273
+ },
1274
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1275
+ },
1276
+ ], imports: [[fire.AngularFireModule, AngularElasticSeachModule]] });
1277
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularFirestoreModule, decorators: [{
1278
+ type: i0.NgModule,
1279
+ args: [{
1280
+ imports: [fire.AngularFireModule, AngularElasticSeachModule],
1281
+ providers: [
1282
+ {
1283
+ provide: 'BeautyProfileRepository',
1284
+ useFactory: function (firestore, userRepository) {
1285
+ return new i2.UserBeautyProfileFirestoreRepository(firestore.firestore, userRepository);
1286
+ },
1287
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1288
+ },
1289
+ {
1290
+ provide: 'Buy2WinRepository',
1291
+ useFactory: function (firestore) {
1292
+ return new i2.Buy2WinFirestoreRepository(firestore.firestore);
1293
+ },
1294
+ deps: [i1$1.AngularFirestore],
1295
+ },
1296
+ {
1297
+ provide: 'CategoryRepository',
1298
+ useFactory: function (firestore, productsIndex) {
1299
+ return new i2.CategoryFirestoreRepository(firestore.firestore);
1300
+ },
1301
+ deps: [i1$1.AngularFirestore, i2.ProductsIndex],
1302
+ },
1303
+ {
1304
+ provide: 'CheckoutRepository',
1305
+ useFactory: function (firestore) {
1306
+ return new i2.CheckoutFirestoreRepository(firestore.firestore);
1307
+ },
1308
+ deps: [i1$1.AngularFirestore],
1309
+ },
1310
+ {
1311
+ provide: 'CheckoutSubscriptionRepository',
1312
+ useFactory: function (firestore) {
1313
+ return new i2.CheckoutSubscriptionFirestoreRepository(firestore.firestore);
1314
+ },
1315
+ deps: [i1$1.AngularFirestore],
1316
+ },
1317
+ {
1318
+ provide: 'CouponRepository',
1319
+ useFactory: function (firestore) {
1320
+ return new i2.CouponFirestoreRepository(firestore.firestore);
1321
+ },
1322
+ deps: [i1$1.AngularFirestore],
1323
+ },
1324
+ {
1325
+ provide: 'EditionRepository',
1326
+ useFactory: function (firestore, subscriptionRepository) {
1327
+ return new i2.SubscriptionEditionFirestoreRepository(firestore.firestore, subscriptionRepository);
1328
+ },
1329
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1330
+ },
1331
+ {
1332
+ provide: 'HomeRepository',
1333
+ useFactory: function (firestore) {
1334
+ return new i2.HomeFirestoreRepository(firestore.firestore);
1335
+ },
1336
+ deps: [i1$1.AngularFirestore],
1337
+ },
1338
+ {
1339
+ provide: 'LeadRepository',
1340
+ useFactory: function (firestore) {
1341
+ return new i2.LeadFirestoreRepository(firestore.firestore);
1342
+ },
1343
+ deps: [i1$1.AngularFirestore],
1344
+ },
1345
+ {
1346
+ provide: 'LegacyOrderRepository',
1347
+ useFactory: function (firestore) {
1348
+ return new i2.LegacyOrderFirestoreRepository(firestore.firestore);
1349
+ },
1350
+ deps: [i1$1.AngularFirestore],
1351
+ },
1352
+ {
1353
+ provide: 'ShopMenuRepository',
1354
+ useFactory: function (firestore) {
1355
+ return new i2.ShopMenuFirestoreRepository(firestore.firestore);
1356
+ },
1357
+ deps: [i1$1.AngularFirestore],
1358
+ },
1359
+ {
1360
+ provide: 'OrderRepository',
1361
+ useFactory: function (firestore) {
1362
+ return new i2.OrderFirestoreRepository(firestore.firestore);
1363
+ },
1364
+ deps: [i1$1.AngularFirestore],
1365
+ },
1366
+ {
1367
+ provide: 'PaymentRepository',
1368
+ useFactory: function (firestore) {
1369
+ return new i2.PaymentFirestoreRepository(firestore.firestore);
1370
+ },
1371
+ deps: [i1$1.AngularFirestore],
1372
+ },
1373
+ {
1374
+ provide: 'ProductRepository',
1375
+ useFactory: function (firestore) {
1376
+ return new i2.ProductFirestoreRepository(firestore.firestore);
1377
+ },
1378
+ deps: [i1$1.AngularFirestore],
1379
+ },
1380
+ {
1381
+ provide: 'SubscriptionPaymentRepository',
1382
+ useFactory: function (firestore, subscriptionRepository) {
1383
+ return new i2.SubscriptionPaymentFirestoreRepository(firestore.firestore, subscriptionRepository);
1384
+ },
1385
+ deps: [i1$1.AngularFirestore, 'SubscriptionRepository'],
1386
+ },
1387
+ {
1388
+ provide: 'SubscriptionPlanRepository',
1389
+ useFactory: function (firestore) {
1390
+ return new i2.SubscriptionPlanFirestoreRepository(firestore.firestore);
1391
+ },
1392
+ deps: [i1$1.AngularFirestore],
1393
+ },
1394
+ {
1395
+ provide: 'SubscriptionProductRepository',
1396
+ useFactory: function (firestore) {
1397
+ return new i2.SubscriptionProductFirestoreRepository(firestore.firestore);
1398
+ },
1399
+ deps: [i1$1.AngularFirestore],
1400
+ },
1401
+ {
1402
+ provide: 'SubscriptionRepository',
1403
+ useFactory: function (firestore) {
1404
+ return new i2.SubscriptionFirestoreRepository(firestore.firestore);
1405
+ },
1406
+ deps: [i1$1.AngularFirestore],
1407
+ },
1408
+ {
1409
+ provide: 'UserRepository',
1410
+ useFactory: function (firestore) {
1411
+ return new i2.UserFirestoreRepository(firestore.firestore);
1412
+ },
1413
+ deps: [i1$1.AngularFirestore],
1414
+ },
1415
+ {
1416
+ provide: 'UserAddressRepository',
1417
+ useFactory: function (firestore, userRepository) {
1418
+ return new i2.UserAddressFirestoreRepository(firestore.firestore, userRepository);
1419
+ },
1420
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1421
+ },
1422
+ {
1423
+ provide: 'UserPaymentMethodRepository',
1424
+ useFactory: function (firestore, userRepository) {
1425
+ return new i2.UserPaymentMethodFirestoreRepository(firestore.firestore, userRepository);
1426
+ },
1427
+ deps: [i1$1.AngularFirestore, 'UserRepository'],
1428
+ },
1429
+ {
1430
+ provide: 'VariantRepository',
1431
+ useFactory: function (firestore, productRepository) {
1432
+ return new i2.ProductVariantFirestoreRepository(firestore.firestore, productRepository);
1433
+ },
1434
+ deps: [i1$1.AngularFirestore, 'ProductRepository'],
1435
+ },
1436
+ ],
1437
+ }]
1443
1438
  }] });
1444
1439
 
1445
- var AngularConnectModule = /** @class */ (function () {
1446
- function AngularConnectModule() {
1447
- }
1448
- AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1449
- return {
1450
- ngModule: AngularConnectModule,
1451
- providers: __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 }]))),
1452
- };
1453
- };
1454
- return AngularConnectModule;
1455
- }());
1456
- AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1457
- AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1458
- AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1459
- AuthService,
1460
- CartService,
1461
- CheckoutService,
1462
- CheckoutSubscriptionService,
1463
- CouponService,
1464
- HomeShopService,
1465
- OrderService,
1466
- ], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1467
- i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1468
- type: i0.NgModule,
1469
- args: [{
1470
- imports: [fire.AngularFireModule, AngularFirestoreModule],
1471
- providers: [
1472
- AuthService,
1473
- CartService,
1474
- CheckoutService,
1475
- CheckoutSubscriptionService,
1476
- CouponService,
1477
- HomeShopService,
1478
- OrderService,
1479
- ],
1480
- }]
1440
+ var AngularConnectModule = /** @class */ (function () {
1441
+ function AngularConnectModule() {
1442
+ }
1443
+ AngularConnectModule.initializeApp = function (defaultShop, options, nameOrConfig) {
1444
+ return {
1445
+ ngModule: AngularConnectModule,
1446
+ providers: __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 }]))),
1447
+ };
1448
+ };
1449
+ return AngularConnectModule;
1450
+ }());
1451
+ AngularConnectModule.ɵfac = i0__namespace.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, deps: [], target: i0__namespace.ɵɵFactoryTarget.NgModule });
1452
+ AngularConnectModule.ɵmod = i0__namespace.ɵɵngDeclareNgModule({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, imports: [fire.AngularFireModule, AngularFirestoreModule] });
1453
+ AngularConnectModule.ɵinj = i0__namespace.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, providers: [
1454
+ AuthService,
1455
+ CartService,
1456
+ CheckoutService,
1457
+ CheckoutSubscriptionService,
1458
+ CouponService,
1459
+ HomeShopService,
1460
+ OrderService,
1461
+ ], imports: [[fire.AngularFireModule, AngularFirestoreModule]] });
1462
+ i0__namespace.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "12.2.12", ngImport: i0__namespace, type: AngularConnectModule, decorators: [{
1463
+ type: i0.NgModule,
1464
+ args: [{
1465
+ imports: [fire.AngularFireModule, AngularFirestoreModule],
1466
+ providers: [
1467
+ AuthService,
1468
+ CartService,
1469
+ CheckoutService,
1470
+ CheckoutSubscriptionService,
1471
+ CouponService,
1472
+ HomeShopService,
1473
+ OrderService,
1474
+ ],
1475
+ }]
1481
1476
  }] });
1482
1477
 
1483
- /**
1484
- * Generated bundle index. Do not edit.
1478
+ /**
1479
+ * Generated bundle index. Do not edit.
1485
1480
  */
1486
1481
 
1487
1482
  exports.AngularConnectModule = AngularConnectModule;