@infrab4a/connect-angular 2.0.5-beta.1 → 2.0.6-beta.0

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