@infrab4a/connect-angular 6.0.0-alpha.0 → 6.0.0-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 (293) hide show
  1. package/angular-connect.module.d.ts +36 -0
  2. package/angular-elastic-search.module.d.ts +9 -0
  3. package/angular-firebase-auth.module.d.ts +11 -0
  4. package/angular-firestore.module.d.ts +17 -0
  5. package/angular-hasura-graphql.module.d.ts +14 -0
  6. package/angular-vertex-search.module.d.ts +9 -0
  7. package/consts/backend-url.const.d.ts +1 -0
  8. package/consts/category-structure.d.ts +1 -0
  9. package/consts/default-shop.const.d.ts +1 -0
  10. package/consts/es-config.const.d.ts +1 -0
  11. package/consts/firebase-const.d.ts +4 -0
  12. package/consts/hasura-options.const.d.ts +1 -0
  13. package/consts/index.d.ts +8 -0
  14. package/consts/persistence.const.d.ts +1 -0
  15. package/consts/storage-base-url.const.d.ts +1 -0
  16. package/consts/vertex-config.const.d.ts +1 -0
  17. package/esm2022/angular-connect.module.mjs +291 -0
  18. package/esm2022/angular-elastic-search.module.mjs +34 -0
  19. package/esm2022/angular-firebase-auth.module.mjs +141 -0
  20. package/esm2022/angular-firestore.module.mjs +541 -0
  21. package/esm2022/angular-hasura-graphql.module.mjs +333 -0
  22. package/esm2022/angular-vertex-search.module.mjs +34 -0
  23. package/esm2022/consts/backend-url.const.mjs +2 -0
  24. package/esm2022/consts/category-structure.mjs +2 -0
  25. package/esm2022/consts/default-shop.const.mjs +2 -0
  26. package/esm2022/consts/es-config.const.mjs +2 -0
  27. package/esm2022/consts/firebase-const.mjs +5 -0
  28. package/esm2022/consts/hasura-options.const.mjs +2 -0
  29. package/esm2022/consts/index.mjs +9 -0
  30. package/esm2022/consts/persistence.const.mjs +2 -0
  31. package/esm2022/consts/storage-base-url.const.mjs +2 -0
  32. package/esm2022/consts/vertex-config.const.mjs +2 -0
  33. package/esm2022/helpers/index.mjs +2 -0
  34. package/esm2022/helpers/mobile-operation-system-checker.helper.mjs +7 -0
  35. package/esm2022/index.mjs +7 -0
  36. package/esm2022/infrab4a-connect-angular.mjs +5 -0
  37. package/esm2022/interfaces/catalog-strategies.interface.mjs +2 -0
  38. package/esm2022/interfaces/category-facades.interface.mjs +2 -0
  39. package/esm2022/interfaces/index.mjs +3 -0
  40. package/esm2022/persistence/cookie-data-persistence.mjs +22 -0
  41. package/esm2022/persistence/data-persistence.mjs +2 -0
  42. package/esm2022/persistence/index.mjs +3 -0
  43. package/esm2022/services/auth.service.mjs +37 -0
  44. package/esm2022/services/cart/cart-services.facade.mjs +21 -0
  45. package/esm2022/services/cart/index.mjs +2 -0
  46. package/esm2022/services/cart.service.mjs +73 -0
  47. package/esm2022/services/catalog/adapters/category-structure.adapter.mjs +2 -0
  48. package/esm2022/services/catalog/adapters/index.mjs +4 -0
  49. package/esm2022/services/catalog/adapters/new-category-structure.adapter.mjs +43 -0
  50. package/esm2022/services/catalog/adapters/old-category-structure.adapter.mjs +23 -0
  51. package/esm2022/services/catalog/catalog.service.mjs +111 -0
  52. package/esm2022/services/catalog/category.service.mjs +39 -0
  53. package/esm2022/services/catalog/context/catalog-search.context.mjs +40 -0
  54. package/esm2022/services/catalog/enums/index.mjs +2 -0
  55. package/esm2022/services/catalog/enums/product-sorts.enum.mjs +11 -0
  56. package/esm2022/services/catalog/facades/catalog-service.facade.mjs +32 -0
  57. package/esm2022/services/catalog/facades/catalog-strategies.facade.mjs +17 -0
  58. package/esm2022/services/catalog/facades/category-repository.facade.mjs +20 -0
  59. package/esm2022/services/catalog/facades/category-service.facade.mjs +30 -0
  60. package/esm2022/services/catalog/facades/index.mjs +6 -0
  61. package/esm2022/services/catalog/facades/product-catalog.facade.mjs +21 -0
  62. package/esm2022/services/catalog/helpers/brand-manager.helper.mjs +57 -0
  63. package/esm2022/services/catalog/helpers/catalog-filter.helper.mjs +44 -0
  64. package/esm2022/services/catalog/helpers/catalog-sort.helper.mjs +52 -0
  65. package/esm2022/services/catalog/helpers/index.mjs +5 -0
  66. package/esm2022/services/catalog/helpers/product-fields.helper.mjs +39 -0
  67. package/esm2022/services/catalog/index.mjs +8 -0
  68. package/esm2022/services/catalog/models/category-with-tree.model.mjs +10 -0
  69. package/esm2022/services/catalog/models/index.mjs +2 -0
  70. package/esm2022/services/catalog/services/catalog-helpers.service.mjs +33 -0
  71. package/esm2022/services/catalog/services/catalog-operations.facade.mjs +26 -0
  72. package/esm2022/services/catalog/services/catalog-repository.service.mjs +25 -0
  73. package/esm2022/services/catalog/services/index.mjs +5 -0
  74. package/esm2022/services/catalog/services/product-management.facade.mjs +25 -0
  75. package/esm2022/services/catalog/strategies/category-search.strategy.mjs +133 -0
  76. package/esm2022/services/catalog/strategies/index.mjs +4 -0
  77. package/esm2022/services/catalog/strategies/profile-search.strategy.mjs +42 -0
  78. package/esm2022/services/catalog/strategies/term-search.strategy.mjs +123 -0
  79. package/esm2022/services/catalog/strategies/types/strategy-params.type.mjs +2 -0
  80. package/esm2022/services/catalog/types/fetch-products-options.type.mjs +2 -0
  81. package/esm2022/services/catalog/types/fetch-products-params.type.mjs +2 -0
  82. package/esm2022/services/catalog/types/fetch-products-response.type.mjs +2 -0
  83. package/esm2022/services/catalog/types/index.mjs +6 -0
  84. package/esm2022/services/catalog/types/method-params.type.mjs +2 -0
  85. package/esm2022/services/catalog/types/product-sort.type.mjs +2 -0
  86. package/esm2022/services/catalog/wishlist.service.mjs +254 -0
  87. package/esm2022/services/checkout/checkout-dependencies.facade.mjs +20 -0
  88. package/esm2022/services/checkout/checkout-repositories.facade.mjs +20 -0
  89. package/esm2022/services/checkout/index.mjs +3 -0
  90. package/esm2022/services/checkout-subscription.service.mjs +55 -0
  91. package/esm2022/services/checkout.service.mjs +106 -0
  92. package/esm2022/services/coupon/coupon-repositories.facade.mjs +24 -0
  93. package/esm2022/services/coupon/index.mjs +2 -0
  94. package/esm2022/services/coupon/types/coupon-params.type.mjs +2 -0
  95. package/esm2022/services/coupon.service.mjs +248 -0
  96. package/esm2022/services/helpers/index.mjs +2 -0
  97. package/esm2022/services/helpers/util.helper.mjs +18 -0
  98. package/esm2022/services/home-shop/home-shop-repositories.facade.mjs +24 -0
  99. package/esm2022/services/home-shop/index.mjs +2 -0
  100. package/esm2022/services/home-shop.service.mjs +119 -0
  101. package/esm2022/services/index.mjs +11 -0
  102. package/esm2022/services/order-product-review.service.mjs +81 -0
  103. package/esm2022/services/order.service.mjs +30 -0
  104. package/esm2022/services/shared/configuration.facade.mjs +29 -0
  105. package/esm2022/services/shared/index.mjs +2 -0
  106. package/esm2022/services/types/index.mjs +5 -0
  107. package/esm2022/services/types/pending-product-review.type.mjs +2 -0
  108. package/esm2022/services/types/product-review-create.type.mjs +2 -0
  109. package/esm2022/services/types/required-checkout-data.type.mjs +2 -0
  110. package/esm2022/services/types/required-checkout-subscription-data.type.mjs +2 -0
  111. package/esm2022/types/firebase-app-config.type.mjs +2 -0
  112. package/esm2022/types/index.mjs +2 -0
  113. package/fesm2022/infrab4a-connect-angular.mjs +3352 -0
  114. package/fesm2022/infrab4a-connect-angular.mjs.map +1 -0
  115. package/helpers/index.d.ts +1 -0
  116. package/helpers/mobile-operation-system-checker.helper.d.ts +3 -0
  117. package/index.d.ts +6 -0
  118. package/interfaces/catalog-strategies.interface.d.ts +31 -0
  119. package/interfaces/category-facades.interface.d.ts +6 -0
  120. package/interfaces/index.d.ts +2 -0
  121. package/package.json +23 -9
  122. package/persistence/cookie-data-persistence.d.ts +10 -0
  123. package/persistence/data-persistence.d.ts +6 -0
  124. package/persistence/index.d.ts +2 -0
  125. package/services/auth.service.d.ts +18 -0
  126. package/services/cart/cart-services.facade.d.ts +12 -0
  127. package/services/cart/index.d.ts +1 -0
  128. package/services/cart.service.d.ts +26 -0
  129. package/services/catalog/adapters/category-structure.adapter.d.ts +4 -0
  130. package/services/catalog/adapters/index.d.ts +3 -0
  131. package/services/catalog/adapters/new-category-structure.adapter.d.ts +12 -0
  132. package/services/catalog/adapters/old-category-structure.adapter.d.ts +10 -0
  133. package/services/catalog/catalog.service.d.ts +24 -0
  134. package/services/catalog/category.service.d.ts +22 -0
  135. package/services/catalog/context/catalog-search.context.d.ts +14 -0
  136. package/services/catalog/enums/index.d.ts +1 -0
  137. package/services/catalog/enums/product-sorts.enum.d.ts +9 -0
  138. package/services/catalog/facades/catalog-service.facade.d.ts +15 -0
  139. package/services/catalog/facades/catalog-strategies.facade.d.ts +10 -0
  140. package/services/catalog/facades/category-repository.facade.d.ts +9 -0
  141. package/services/catalog/facades/category-service.facade.d.ts +15 -0
  142. package/{src/services/catalog/facades/index.ts → services/catalog/facades/index.d.ts} +5 -5
  143. package/services/catalog/facades/product-catalog.facade.d.ts +10 -0
  144. package/services/catalog/helpers/brand-manager.helper.d.ts +14 -0
  145. package/services/catalog/helpers/catalog-filter.helper.d.ts +8 -0
  146. package/services/catalog/helpers/catalog-sort.helper.d.ts +7 -0
  147. package/services/catalog/helpers/index.d.ts +4 -0
  148. package/services/catalog/helpers/product-fields.helper.d.ts +7 -0
  149. package/services/catalog/index.d.ts +7 -0
  150. package/services/catalog/models/category-with-tree.model.d.ts +4 -0
  151. package/services/catalog/models/index.d.ts +1 -0
  152. package/services/catalog/services/catalog-helpers.service.d.ts +17 -0
  153. package/services/catalog/services/catalog-operations.facade.d.ts +13 -0
  154. package/services/catalog/services/catalog-repository.service.d.ts +12 -0
  155. package/{src/services/catalog/services/index.ts → services/catalog/services/index.d.ts} +4 -4
  156. package/services/catalog/services/product-management.facade.d.ts +12 -0
  157. package/services/catalog/strategies/category-search.strategy.d.ts +19 -0
  158. package/services/catalog/strategies/index.d.ts +3 -0
  159. package/services/catalog/strategies/profile-search.strategy.d.ts +14 -0
  160. package/services/catalog/strategies/term-search.strategy.d.ts +20 -0
  161. package/services/catalog/strategies/types/strategy-params.type.d.ts +58 -0
  162. package/services/catalog/types/fetch-products-options.type.d.ts +8 -0
  163. package/services/catalog/types/fetch-products-params.type.d.ts +25 -0
  164. package/services/catalog/types/fetch-products-response.type.d.ts +19 -0
  165. package/services/catalog/types/index.d.ts +5 -0
  166. package/services/catalog/types/method-params.type.d.ts +17 -0
  167. package/services/catalog/types/product-sort.type.d.ts +2 -0
  168. package/services/catalog/wishlist.service.d.ts +59 -0
  169. package/services/checkout/checkout-dependencies.facade.d.ts +10 -0
  170. package/services/checkout/checkout-repositories.facade.d.ts +9 -0
  171. package/{src/services/checkout/index.ts → services/checkout/index.d.ts} +2 -2
  172. package/services/checkout-subscription.service.d.ts +19 -0
  173. package/services/checkout.service.d.ts +30 -0
  174. package/services/coupon/coupon-repositories.facade.d.ts +10 -0
  175. package/{src/services/coupon/index.ts → services/coupon/index.d.ts} +1 -1
  176. package/services/coupon/types/coupon-params.type.d.ts +13 -0
  177. package/services/coupon.service.d.ts +36 -0
  178. package/services/helpers/index.d.ts +1 -0
  179. package/services/helpers/util.helper.d.ts +3 -0
  180. package/services/home-shop/home-shop-repositories.facade.d.ts +10 -0
  181. package/{src/services/home-shop/index.ts → services/home-shop/index.d.ts} +1 -1
  182. package/services/home-shop.service.d.ts +26 -0
  183. package/services/index.d.ts +10 -0
  184. package/services/order-product-review.service.d.ts +13 -0
  185. package/services/order.service.d.ts +13 -0
  186. package/services/shared/configuration.facade.d.ts +12 -0
  187. package/services/shared/index.d.ts +1 -0
  188. package/services/types/index.d.ts +4 -0
  189. package/services/types/pending-product-review.type.d.ts +10 -0
  190. package/services/types/product-review-create.type.d.ts +14 -0
  191. package/services/types/required-checkout-data.type.d.ts +2 -0
  192. package/services/types/required-checkout-subscription-data.type.d.ts +2 -0
  193. package/types/firebase-app-config.type.d.ts +1 -0
  194. package/types/index.d.ts +1 -0
  195. package/eslint.config.js +0 -18
  196. package/index.ts +0 -1
  197. package/karma.conf.js +0 -32
  198. package/ng-package.json +0 -8
  199. package/project.json +0 -37
  200. package/src/angular-connect.module.ts +0 -256
  201. package/src/angular-elastic-search.module.ts +0 -23
  202. package/src/angular-firebase-auth.module.ts +0 -101
  203. package/src/angular-firestore.module.ts +0 -371
  204. package/src/angular-hasura-graphql.module.ts +0 -219
  205. package/src/angular-vertex-search.module.ts +0 -23
  206. package/src/consts/backend-url.const.ts +0 -1
  207. package/src/consts/category-structure.ts +0 -1
  208. package/src/consts/default-shop.const.ts +0 -1
  209. package/src/consts/es-config.const.ts +0 -1
  210. package/src/consts/firebase-const.ts +0 -5
  211. package/src/consts/hasura-options.const.ts +0 -1
  212. package/src/consts/index.ts +0 -8
  213. package/src/consts/persistence.const.ts +0 -1
  214. package/src/consts/storage-base-url.const.ts +0 -1
  215. package/src/consts/vertex-config.const.ts +0 -1
  216. package/src/helpers/index.ts +0 -1
  217. package/src/helpers/mobile-operation-system-checker.helper.ts +0 -10
  218. package/src/index.ts +0 -6
  219. package/src/interfaces/catalog-strategies.interface.ts +0 -36
  220. package/src/interfaces/category-facades.interface.ts +0 -7
  221. package/src/interfaces/index.ts +0 -2
  222. package/src/persistence/cookie-data-persistence.ts +0 -21
  223. package/src/persistence/data-persistence.ts +0 -7
  224. package/src/persistence/index.ts +0 -2
  225. package/src/services/auth.service.ts +0 -39
  226. package/src/services/cart/cart-services.facade.ts +0 -14
  227. package/src/services/cart/index.ts +0 -1
  228. package/src/services/cart.service.ts +0 -124
  229. package/src/services/catalog/adapters/category-structure.adapter.ts +0 -5
  230. package/src/services/catalog/adapters/index.ts +0 -3
  231. package/src/services/catalog/adapters/new-category-structure.adapter.ts +0 -42
  232. package/src/services/catalog/adapters/old-category-structure.adapter.ts +0 -17
  233. package/src/services/catalog/catalog.service.ts +0 -153
  234. package/src/services/catalog/category.service.ts +0 -52
  235. package/src/services/catalog/context/catalog-search.context.ts +0 -61
  236. package/src/services/catalog/enums/index.ts +0 -1
  237. package/src/services/catalog/enums/product-sorts.enum.ts +0 -9
  238. package/src/services/catalog/facades/catalog-service.facade.ts +0 -32
  239. package/src/services/catalog/facades/catalog-strategies.facade.ts +0 -12
  240. package/src/services/catalog/facades/category-repository.facade.ts +0 -10
  241. package/src/services/catalog/facades/category-service.facade.ts +0 -25
  242. package/src/services/catalog/facades/product-catalog.facade.ts +0 -13
  243. package/src/services/catalog/helpers/brand-manager.helper.ts +0 -63
  244. package/src/services/catalog/helpers/catalog-filter.helper.ts +0 -50
  245. package/src/services/catalog/helpers/catalog-sort.helper.ts +0 -54
  246. package/src/services/catalog/helpers/index.ts +0 -4
  247. package/src/services/catalog/helpers/product-fields.helper.ts +0 -35
  248. package/src/services/catalog/index.ts +0 -7
  249. package/src/services/catalog/models/category-with-tree.model.ts +0 -7
  250. package/src/services/catalog/models/index.ts +0 -1
  251. package/src/services/catalog/services/catalog-helpers.service.ts +0 -35
  252. package/src/services/catalog/services/catalog-operations.facade.ts +0 -24
  253. package/src/services/catalog/services/catalog-repository.service.ts +0 -20
  254. package/src/services/catalog/services/product-management.facade.ts +0 -20
  255. package/src/services/catalog/strategies/category-search.strategy.ts +0 -172
  256. package/src/services/catalog/strategies/index.ts +0 -3
  257. package/src/services/catalog/strategies/profile-search.strategy.ts +0 -51
  258. package/src/services/catalog/strategies/term-search.strategy.ts +0 -178
  259. package/src/services/catalog/strategies/types/strategy-params.type.ts +0 -58
  260. package/src/services/catalog/types/fetch-products-options.type.ts +0 -10
  261. package/src/services/catalog/types/fetch-products-params.type.ts +0 -27
  262. package/src/services/catalog/types/fetch-products-response.type.ts +0 -11
  263. package/src/services/catalog/types/index.ts +0 -5
  264. package/src/services/catalog/types/method-params.type.ts +0 -21
  265. package/src/services/catalog/types/product-sort.type.ts +0 -3
  266. package/src/services/catalog/wishlist.service.ts +0 -368
  267. package/src/services/checkout/checkout-dependencies.facade.ts +0 -13
  268. package/src/services/checkout/checkout-repositories.facade.ts +0 -10
  269. package/src/services/checkout-subscription.service.ts +0 -76
  270. package/src/services/checkout.service.ts +0 -196
  271. package/src/services/coupon/coupon-repositories.facade.ts +0 -11
  272. package/src/services/coupon/types/coupon-params.type.ts +0 -15
  273. package/src/services/coupon.service.ts +0 -347
  274. package/src/services/errors/group-invalid-coupon.error.ts +0 -9
  275. package/src/services/errors/index.ts +0 -2
  276. package/src/services/errors/invalid-coupon.error.ts +0 -7
  277. package/src/services/helpers/index.ts +0 -1
  278. package/src/services/helpers/util.helper.ts +0 -17
  279. package/src/services/home-shop/home-shop-repositories.facade.ts +0 -11
  280. package/src/services/home-shop.service.ts +0 -196
  281. package/src/services/index.ts +0 -9
  282. package/src/services/order.service.ts +0 -23
  283. package/src/services/shared/configuration.facade.ts +0 -21
  284. package/src/services/shared/index.ts +0 -1
  285. package/src/services/types/index.ts +0 -2
  286. package/src/services/types/required-checkout-data.type.ts +0 -3
  287. package/src/services/types/required-checkout-subscription-data.type.ts +0 -3
  288. package/src/types/firebase-app-config.type.ts +0 -1
  289. package/src/types/index.ts +0 -1
  290. package/tsconfig.json +0 -17
  291. package/tsconfig.lib.json +0 -13
  292. package/tsconfig.lib.prod.json +0 -13
  293. package/tsconfig.spec.json +0 -17
@@ -0,0 +1,3352 @@
1
+ import * as i0 from '@angular/core';
2
+ import { NgModule, InjectionToken, PLATFORM_ID, Injectable, Inject } from '@angular/core';
3
+ import * as i1$3 from '@angular/fire/app';
4
+ import { FirebaseApp, provideFirebaseApp, getApp, initializeApp } from '@angular/fire/app';
5
+ import * as i2 from '@angular/fire/app-check';
6
+ import { provideAppCheck, initializeAppCheck } from '@angular/fire/app-check';
7
+ import * as i3$1 from '@angular/fire/storage';
8
+ import { Storage, provideStorage, getStorage } from '@angular/fire/storage';
9
+ import * as i3 from '@infrab4a/connect';
10
+ import { ProductsIndex, AxiosAdapter, Authentication, AuthenticationFirebaseAuthService, Register, RegisterFirebaseAuthService, SignOut, RecoveryPassword, ConnectFirestoreService, UserBeautyProfileFirestoreRepository, Buy2WinFirestoreRepository, CategoryFirestoreRepository, CheckoutFirestoreRepository, CheckoutSubscriptionFirestoreRepository, CouponFirestoreRepository, CampaignHashtagFirestoreRepository, CampaignDashboardFirestoreRepository, SubscriptionEditionFirestoreRepository, GroupFirestoreRepository, HomeFirestoreRepository, LeadFirestoreRepository, LegacyOrderFirestoreRepository, ShopMenuFirestoreRepository, OrderFirestoreRepository, PaymentFirestoreRepository, ProductFirestoreRepository, ShopSettingsFirestoreRepository, SubscriptionPaymentFirestoreRepository, SubscriptionPlanFirestoreRepository, SubscriptionProductFirestoreRepository, SubscriptionFirestoreRepository, UserFirestoreRepository, UserAddressFirestoreRepository, UserPaymentMethodFirestoreRepository, SubscriptionMaterializationFirestoreRepository, SubscriptionSummaryFirestoreRepository, ProductVariantFirestoreRepository, OrderBlockedFirestoreRepository, LogFirestoreRepository, SequenceFirestoreRepository, CategoryHasuraGraphQLRepository, ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository, ProductReviewHasuraGraphQLRepository, VariantHasuraGraphQLRepository, ProductStockNotificationHasuraGraphQLRepository, FilterOptionHasuraGraphQLRepository, FilterHasuraGraphQLRepository, CategoryCollectionChildrenHasuraGraphQLRepository, CategoryProductHasuraGraphQLRepository, WishlistHasuraGraphQLRepository, ProductErrorsHasuraGraphQLRepository, ProductsVertexSearch, VertexAxiosAdapter, isNil, NotFoundError, Checkout, pick, LineItem, Where, isEmpty, Shops, set, InvalidArgumentError, RoundProductPricesHelper, Category, WishlistLogType, PersonTypes, Wishlist, CheckoutTypes, CouponTypes, Exclusivities, OrderStatus, CheckoutSubscription, Product, RequiredArgumentError, add, ProductReview, Order, UpdateUserImage, FirebaseFileUploaderService } from '@infrab4a/connect';
11
+ import * as i1 from '@angular/fire/auth';
12
+ import { Auth, provideAuth, initializeAuth, indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence, getAuth, getIdToken, authState } from '@angular/fire/auth';
13
+ import { isPlatformBrowser, isPlatformServer } from '@angular/common';
14
+ import * as i1$1 from '@angular/fire/firestore';
15
+ import { Firestore, provideFirestore, initializeFirestore, memoryLocalCache, docSnapshots, doc } from '@angular/fire/firestore';
16
+ import cookie from 'js-cookie';
17
+ import { of, from, combineLatest, throwError, Subject, forkJoin } from 'rxjs';
18
+ import { map, mergeMap, catchError, concatMap, tap } from 'rxjs/operators';
19
+ import * as i1$2 from '@angular/common/http';
20
+ import { __decorate, __metadata } from 'tslib';
21
+ import { Type } from 'class-transformer';
22
+
23
+ const ES_CONFIG = 'ES_CONFIG';
24
+
25
+ class AngularElasticSeachModule {
26
+ static initializeApp(options) {
27
+ return {
28
+ ngModule: AngularElasticSeachModule,
29
+ providers: [{ provide: ES_CONFIG, useValue: options }],
30
+ };
31
+ }
32
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
33
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule }); }
34
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule, providers: [
35
+ {
36
+ provide: ProductsIndex,
37
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
38
+ deps: [ES_CONFIG],
39
+ },
40
+ ] }); }
41
+ }
42
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularElasticSeachModule, decorators: [{
43
+ type: NgModule,
44
+ args: [{
45
+ providers: [
46
+ {
47
+ provide: ProductsIndex,
48
+ useFactory: (configuration) => new ProductsIndex(new AxiosAdapter(configuration)),
49
+ deps: [ES_CONFIG],
50
+ },
51
+ ],
52
+ }]
53
+ }] });
54
+
55
+ const BACKEND_URL = 'BACKEND_URL';
56
+
57
+ const CATEGORY_STRUCTURE = 'CATEGORY_STRUCTURE';
58
+
59
+ const DEFAULT_SHOP = 'DEFAULT_SHOP';
60
+
61
+ const FIREBASE_APP_NAME = new InjectionToken('firebaseAppName');
62
+ const FIREBASE_OPTIONS = new InjectionToken('firebaseOptions');
63
+ const APP_CHECK_PROVIDER = new InjectionToken('appCheckProvider');
64
+
65
+ const HASURA_OPTIONS = 'HASURA_OPTIONS';
66
+
67
+ const PERSISTENCE_PROVIDER = 'PERSISTENCE_PROVIDER';
68
+
69
+ const VERTEX_CONFIG = 'VERTEX_CONFIG';
70
+
71
+ class AngularFirebaseAuthModule {
72
+ static initializeApp(options, nameOrConfig) {
73
+ return {
74
+ ngModule: AngularFirebaseAuthModule,
75
+ providers: [
76
+ { provide: FIREBASE_OPTIONS, useValue: options },
77
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
78
+ ],
79
+ };
80
+ }
81
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
82
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, imports: [i1.AuthModule] }); }
83
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, providers: [
84
+ {
85
+ provide: 'Authentication',
86
+ useFactory: (authenticationService, userRepository) => {
87
+ return new Authentication(authenticationService, userRepository);
88
+ },
89
+ deps: ['AuthenticationService', 'UserRepository'],
90
+ },
91
+ {
92
+ provide: 'AuthenticationService',
93
+ useFactory: (angularFireAuth) => {
94
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
95
+ },
96
+ deps: [Auth],
97
+ },
98
+ {
99
+ provide: 'Register',
100
+ useFactory: (registerService, userRepository) => {
101
+ return new Register(registerService, userRepository);
102
+ },
103
+ deps: ['RegisterService', 'UserRepository'],
104
+ },
105
+ {
106
+ provide: 'RegisterService',
107
+ useFactory: (angularFireAuth) => {
108
+ return new RegisterFirebaseAuthService(angularFireAuth);
109
+ },
110
+ deps: [Auth],
111
+ },
112
+ {
113
+ provide: 'SignOut',
114
+ useFactory: (authenticationService) => {
115
+ return new SignOut(authenticationService);
116
+ },
117
+ deps: ['AuthenticationService'],
118
+ },
119
+ {
120
+ provide: 'RecoveryPassword',
121
+ useFactory: (authenticationService) => {
122
+ return new RecoveryPassword(authenticationService);
123
+ },
124
+ deps: ['AuthenticationService'],
125
+ },
126
+ ], imports: [provideAuth((injector) => {
127
+ const app = injector.get(FirebaseApp);
128
+ try {
129
+ return initializeAuth(app, {
130
+ persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence],
131
+ });
132
+ }
133
+ catch (error) {
134
+ if (error instanceof Error)
135
+ console.error('Error initializing auth', error.message);
136
+ return getAuth(app);
137
+ }
138
+ })] }); }
139
+ }
140
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirebaseAuthModule, decorators: [{
141
+ type: NgModule,
142
+ args: [{
143
+ imports: [
144
+ provideAuth((injector) => {
145
+ const app = injector.get(FirebaseApp);
146
+ try {
147
+ return initializeAuth(app, {
148
+ persistence: [indexedDBLocalPersistence, browserLocalPersistence, browserSessionPersistence],
149
+ });
150
+ }
151
+ catch (error) {
152
+ if (error instanceof Error)
153
+ console.error('Error initializing auth', error.message);
154
+ return getAuth(app);
155
+ }
156
+ }),
157
+ ],
158
+ providers: [
159
+ {
160
+ provide: 'Authentication',
161
+ useFactory: (authenticationService, userRepository) => {
162
+ return new Authentication(authenticationService, userRepository);
163
+ },
164
+ deps: ['AuthenticationService', 'UserRepository'],
165
+ },
166
+ {
167
+ provide: 'AuthenticationService',
168
+ useFactory: (angularFireAuth) => {
169
+ return new AuthenticationFirebaseAuthService(angularFireAuth);
170
+ },
171
+ deps: [Auth],
172
+ },
173
+ {
174
+ provide: 'Register',
175
+ useFactory: (registerService, userRepository) => {
176
+ return new Register(registerService, userRepository);
177
+ },
178
+ deps: ['RegisterService', 'UserRepository'],
179
+ },
180
+ {
181
+ provide: 'RegisterService',
182
+ useFactory: (angularFireAuth) => {
183
+ return new RegisterFirebaseAuthService(angularFireAuth);
184
+ },
185
+ deps: [Auth],
186
+ },
187
+ {
188
+ provide: 'SignOut',
189
+ useFactory: (authenticationService) => {
190
+ return new SignOut(authenticationService);
191
+ },
192
+ deps: ['AuthenticationService'],
193
+ },
194
+ {
195
+ provide: 'RecoveryPassword',
196
+ useFactory: (authenticationService) => {
197
+ return new RecoveryPassword(authenticationService);
198
+ },
199
+ deps: ['AuthenticationService'],
200
+ },
201
+ ],
202
+ }]
203
+ }] });
204
+
205
+ class MobileOperationSystemCheckerHelper {
206
+ static isAppleDevice() {
207
+ return (['iPad Simulator', 'iPhone Simulator', 'iPod Simulator', 'iPad', 'iPhone', 'iPod'].includes(navigator?.platform) ||
208
+ (navigator?.userAgent?.includes?.('Mac') && 'ontouchend' in (document || {})));
209
+ }
210
+ }
211
+
212
+ class AngularFirestoreModule {
213
+ static initializeApp(options, nameOrConfig) {
214
+ return {
215
+ ngModule: AngularFirestoreModule,
216
+ providers: [
217
+ { provide: FIREBASE_OPTIONS, useValue: options.firebase },
218
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
219
+ { provide: ES_CONFIG, useValue: options.elasticSearch },
220
+ ],
221
+ };
222
+ }
223
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
224
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, imports: [AngularElasticSeachModule, i1$1.FirestoreModule] }); }
225
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, providers: [
226
+ {
227
+ provide: 'FirestoreOptions',
228
+ useFactory: (firestore, platformId) => ({
229
+ firestore: new ConnectFirestoreService(firestore),
230
+ interceptors: {
231
+ request: (request) => {
232
+ if (isPlatformBrowser(platformId))
233
+ return request;
234
+ const interval = setInterval(() => { }, 100);
235
+ request.interval = interval;
236
+ return request;
237
+ },
238
+ response: (response, request) => {
239
+ if (isPlatformBrowser(platformId))
240
+ return response;
241
+ clearInterval(request.interval);
242
+ return response;
243
+ },
244
+ },
245
+ }),
246
+ deps: [Firestore, PLATFORM_ID],
247
+ },
248
+ {
249
+ provide: 'BeautyProfileRepository',
250
+ useFactory: (config, userRepository) => {
251
+ return new UserBeautyProfileFirestoreRepository(config, userRepository);
252
+ },
253
+ deps: ['FirestoreOptions', 'UserRepository'],
254
+ },
255
+ {
256
+ provide: 'Buy2WinRepository',
257
+ useFactory: (options) => {
258
+ return new Buy2WinFirestoreRepository(options);
259
+ },
260
+ deps: ['FirestoreOptions'],
261
+ },
262
+ {
263
+ provide: CategoryFirestoreRepository,
264
+ useFactory: (options) => {
265
+ return new CategoryFirestoreRepository(options);
266
+ },
267
+ deps: ['FirestoreOptions'],
268
+ },
269
+ {
270
+ provide: 'CheckoutRepository',
271
+ useFactory: (options) => {
272
+ return new CheckoutFirestoreRepository(options);
273
+ },
274
+ deps: ['FirestoreOptions'],
275
+ },
276
+ {
277
+ provide: 'CheckoutSubscriptionRepository',
278
+ useFactory: (options) => {
279
+ return new CheckoutSubscriptionFirestoreRepository(options);
280
+ },
281
+ deps: ['FirestoreOptions'],
282
+ },
283
+ {
284
+ provide: 'CouponRepository',
285
+ useFactory: (options) => {
286
+ return new CouponFirestoreRepository(options);
287
+ },
288
+ deps: ['FirestoreOptions'],
289
+ },
290
+ {
291
+ provide: 'CampaignHashtagRepository',
292
+ useFactory: (options) => {
293
+ return new CampaignHashtagFirestoreRepository(options);
294
+ },
295
+ deps: ['FirestoreOptions'],
296
+ },
297
+ {
298
+ provide: 'CampaignDashboardRepository',
299
+ useFactory: (options) => {
300
+ return new CampaignDashboardFirestoreRepository(options);
301
+ },
302
+ deps: ['FirestoreOptions'],
303
+ },
304
+ {
305
+ provide: 'EditionRepository',
306
+ useFactory: (options, subscriptionRepository) => {
307
+ return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
308
+ },
309
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
310
+ },
311
+ {
312
+ provide: 'GroupRepository',
313
+ useFactory: (options) => {
314
+ return new GroupFirestoreRepository(options);
315
+ },
316
+ deps: ['FirestoreOptions'],
317
+ },
318
+ {
319
+ provide: 'HomeRepository',
320
+ useFactory: (options) => {
321
+ return new HomeFirestoreRepository(options);
322
+ },
323
+ deps: ['FirestoreOptions'],
324
+ },
325
+ {
326
+ provide: 'LeadRepository',
327
+ useFactory: (options) => {
328
+ return new LeadFirestoreRepository(options);
329
+ },
330
+ deps: ['FirestoreOptions'],
331
+ },
332
+ {
333
+ provide: 'LegacyOrderRepository',
334
+ useFactory: (options) => {
335
+ return new LegacyOrderFirestoreRepository(options);
336
+ },
337
+ deps: ['FirestoreOptions'],
338
+ },
339
+ {
340
+ provide: 'ShopMenuRepository',
341
+ useFactory: (options) => {
342
+ return new ShopMenuFirestoreRepository(options);
343
+ },
344
+ deps: ['FirestoreOptions'],
345
+ },
346
+ {
347
+ provide: 'OrderRepository',
348
+ useFactory: (options) => {
349
+ return new OrderFirestoreRepository(options);
350
+ },
351
+ deps: ['FirestoreOptions'],
352
+ },
353
+ {
354
+ provide: 'PaymentRepository',
355
+ useFactory: (options) => {
356
+ return new PaymentFirestoreRepository(options);
357
+ },
358
+ deps: ['FirestoreOptions'],
359
+ },
360
+ {
361
+ provide: ProductFirestoreRepository,
362
+ useFactory: (options) => {
363
+ return new ProductFirestoreRepository(options);
364
+ },
365
+ deps: ['FirestoreOptions'],
366
+ },
367
+ {
368
+ provide: 'ShopSettingsRepository',
369
+ useFactory: (options) => {
370
+ return new ShopSettingsFirestoreRepository(options);
371
+ },
372
+ deps: ['FirestoreOptions'],
373
+ },
374
+ {
375
+ provide: 'SubscriptionPaymentRepository',
376
+ useFactory: (options, subscriptionRepository) => {
377
+ return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
378
+ },
379
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
380
+ },
381
+ {
382
+ provide: 'SubscriptionPlanRepository',
383
+ useFactory: (options) => {
384
+ return new SubscriptionPlanFirestoreRepository(options);
385
+ },
386
+ deps: ['FirestoreOptions'],
387
+ },
388
+ {
389
+ provide: 'SubscriptionProductRepository',
390
+ useFactory: (options) => {
391
+ return new SubscriptionProductFirestoreRepository(options);
392
+ },
393
+ deps: ['FirestoreOptions'],
394
+ },
395
+ {
396
+ provide: 'SubscriptionRepository',
397
+ useFactory: (options) => {
398
+ return new SubscriptionFirestoreRepository(options);
399
+ },
400
+ deps: ['FirestoreOptions'],
401
+ },
402
+ {
403
+ provide: 'UserRepository',
404
+ useFactory: (options) => {
405
+ return new UserFirestoreRepository(options);
406
+ },
407
+ deps: ['FirestoreOptions'],
408
+ },
409
+ {
410
+ provide: 'UserAddressRepository',
411
+ useFactory: (options, userRepository) => {
412
+ return new UserAddressFirestoreRepository(options, userRepository);
413
+ },
414
+ deps: ['FirestoreOptions', 'UserRepository'],
415
+ },
416
+ {
417
+ provide: 'UserPaymentMethodRepository',
418
+ useFactory: (options, userRepository) => {
419
+ return new UserPaymentMethodFirestoreRepository(options, userRepository);
420
+ },
421
+ deps: ['FirestoreOptions', 'UserRepository'],
422
+ },
423
+ {
424
+ provide: 'SubscriptionMaterializationRepository',
425
+ useFactory: (options) => {
426
+ return new SubscriptionMaterializationFirestoreRepository(options);
427
+ },
428
+ deps: ['FirestoreOptions'],
429
+ },
430
+ {
431
+ provide: 'SubscriptionSummaryRepository',
432
+ useFactory: (options) => {
433
+ return new SubscriptionSummaryFirestoreRepository(options);
434
+ },
435
+ deps: ['FirestoreOptions'],
436
+ },
437
+ {
438
+ provide: ProductVariantFirestoreRepository,
439
+ useFactory: (options, productRepository) => {
440
+ return new ProductVariantFirestoreRepository(options, productRepository);
441
+ },
442
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
443
+ },
444
+ {
445
+ provide: 'OrderBlockedRepository',
446
+ useFactory: (options) => {
447
+ return new OrderBlockedFirestoreRepository(options);
448
+ },
449
+ deps: ['FirestoreOptions'],
450
+ },
451
+ {
452
+ provide: 'LogRepository',
453
+ useFactory: (options) => {
454
+ return new LogFirestoreRepository(options);
455
+ },
456
+ deps: ['FirestoreOptions'],
457
+ },
458
+ {
459
+ provide: 'SequenceRepository',
460
+ useFactory: (options) => {
461
+ return new SequenceFirestoreRepository(options);
462
+ },
463
+ deps: ['FirestoreOptions'],
464
+ },
465
+ ], imports: [AngularElasticSeachModule,
466
+ provideFirestore((injector) => {
467
+ const platformId = injector.get(PLATFORM_ID);
468
+ if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
469
+ return initializeFirestore(injector.get(FirebaseApp), {
470
+ ignoreUndefinedProperties: true,
471
+ });
472
+ const firestore = initializeFirestore(injector.get(FirebaseApp), {
473
+ experimentalForceLongPolling: true,
474
+ ignoreUndefinedProperties: true,
475
+ localCache: memoryLocalCache(),
476
+ });
477
+ return firestore;
478
+ })] }); }
479
+ }
480
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularFirestoreModule, decorators: [{
481
+ type: NgModule,
482
+ args: [{
483
+ imports: [
484
+ AngularElasticSeachModule,
485
+ provideFirestore((injector) => {
486
+ const platformId = injector.get(PLATFORM_ID);
487
+ if (isPlatformServer(platformId) || !MobileOperationSystemCheckerHelper.isAppleDevice())
488
+ return initializeFirestore(injector.get(FirebaseApp), {
489
+ ignoreUndefinedProperties: true,
490
+ });
491
+ const firestore = initializeFirestore(injector.get(FirebaseApp), {
492
+ experimentalForceLongPolling: true,
493
+ ignoreUndefinedProperties: true,
494
+ localCache: memoryLocalCache(),
495
+ });
496
+ return firestore;
497
+ }),
498
+ ],
499
+ providers: [
500
+ {
501
+ provide: 'FirestoreOptions',
502
+ useFactory: (firestore, platformId) => ({
503
+ firestore: new ConnectFirestoreService(firestore),
504
+ interceptors: {
505
+ request: (request) => {
506
+ if (isPlatformBrowser(platformId))
507
+ return request;
508
+ const interval = setInterval(() => { }, 100);
509
+ request.interval = interval;
510
+ return request;
511
+ },
512
+ response: (response, request) => {
513
+ if (isPlatformBrowser(platformId))
514
+ return response;
515
+ clearInterval(request.interval);
516
+ return response;
517
+ },
518
+ },
519
+ }),
520
+ deps: [Firestore, PLATFORM_ID],
521
+ },
522
+ {
523
+ provide: 'BeautyProfileRepository',
524
+ useFactory: (config, userRepository) => {
525
+ return new UserBeautyProfileFirestoreRepository(config, userRepository);
526
+ },
527
+ deps: ['FirestoreOptions', 'UserRepository'],
528
+ },
529
+ {
530
+ provide: 'Buy2WinRepository',
531
+ useFactory: (options) => {
532
+ return new Buy2WinFirestoreRepository(options);
533
+ },
534
+ deps: ['FirestoreOptions'],
535
+ },
536
+ {
537
+ provide: CategoryFirestoreRepository,
538
+ useFactory: (options) => {
539
+ return new CategoryFirestoreRepository(options);
540
+ },
541
+ deps: ['FirestoreOptions'],
542
+ },
543
+ {
544
+ provide: 'CheckoutRepository',
545
+ useFactory: (options) => {
546
+ return new CheckoutFirestoreRepository(options);
547
+ },
548
+ deps: ['FirestoreOptions'],
549
+ },
550
+ {
551
+ provide: 'CheckoutSubscriptionRepository',
552
+ useFactory: (options) => {
553
+ return new CheckoutSubscriptionFirestoreRepository(options);
554
+ },
555
+ deps: ['FirestoreOptions'],
556
+ },
557
+ {
558
+ provide: 'CouponRepository',
559
+ useFactory: (options) => {
560
+ return new CouponFirestoreRepository(options);
561
+ },
562
+ deps: ['FirestoreOptions'],
563
+ },
564
+ {
565
+ provide: 'CampaignHashtagRepository',
566
+ useFactory: (options) => {
567
+ return new CampaignHashtagFirestoreRepository(options);
568
+ },
569
+ deps: ['FirestoreOptions'],
570
+ },
571
+ {
572
+ provide: 'CampaignDashboardRepository',
573
+ useFactory: (options) => {
574
+ return new CampaignDashboardFirestoreRepository(options);
575
+ },
576
+ deps: ['FirestoreOptions'],
577
+ },
578
+ {
579
+ provide: 'EditionRepository',
580
+ useFactory: (options, subscriptionRepository) => {
581
+ return new SubscriptionEditionFirestoreRepository(options, subscriptionRepository);
582
+ },
583
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
584
+ },
585
+ {
586
+ provide: 'GroupRepository',
587
+ useFactory: (options) => {
588
+ return new GroupFirestoreRepository(options);
589
+ },
590
+ deps: ['FirestoreOptions'],
591
+ },
592
+ {
593
+ provide: 'HomeRepository',
594
+ useFactory: (options) => {
595
+ return new HomeFirestoreRepository(options);
596
+ },
597
+ deps: ['FirestoreOptions'],
598
+ },
599
+ {
600
+ provide: 'LeadRepository',
601
+ useFactory: (options) => {
602
+ return new LeadFirestoreRepository(options);
603
+ },
604
+ deps: ['FirestoreOptions'],
605
+ },
606
+ {
607
+ provide: 'LegacyOrderRepository',
608
+ useFactory: (options) => {
609
+ return new LegacyOrderFirestoreRepository(options);
610
+ },
611
+ deps: ['FirestoreOptions'],
612
+ },
613
+ {
614
+ provide: 'ShopMenuRepository',
615
+ useFactory: (options) => {
616
+ return new ShopMenuFirestoreRepository(options);
617
+ },
618
+ deps: ['FirestoreOptions'],
619
+ },
620
+ {
621
+ provide: 'OrderRepository',
622
+ useFactory: (options) => {
623
+ return new OrderFirestoreRepository(options);
624
+ },
625
+ deps: ['FirestoreOptions'],
626
+ },
627
+ {
628
+ provide: 'PaymentRepository',
629
+ useFactory: (options) => {
630
+ return new PaymentFirestoreRepository(options);
631
+ },
632
+ deps: ['FirestoreOptions'],
633
+ },
634
+ {
635
+ provide: ProductFirestoreRepository,
636
+ useFactory: (options) => {
637
+ return new ProductFirestoreRepository(options);
638
+ },
639
+ deps: ['FirestoreOptions'],
640
+ },
641
+ {
642
+ provide: 'ShopSettingsRepository',
643
+ useFactory: (options) => {
644
+ return new ShopSettingsFirestoreRepository(options);
645
+ },
646
+ deps: ['FirestoreOptions'],
647
+ },
648
+ {
649
+ provide: 'SubscriptionPaymentRepository',
650
+ useFactory: (options, subscriptionRepository) => {
651
+ return new SubscriptionPaymentFirestoreRepository(options, subscriptionRepository);
652
+ },
653
+ deps: ['FirestoreOptions', 'SubscriptionRepository'],
654
+ },
655
+ {
656
+ provide: 'SubscriptionPlanRepository',
657
+ useFactory: (options) => {
658
+ return new SubscriptionPlanFirestoreRepository(options);
659
+ },
660
+ deps: ['FirestoreOptions'],
661
+ },
662
+ {
663
+ provide: 'SubscriptionProductRepository',
664
+ useFactory: (options) => {
665
+ return new SubscriptionProductFirestoreRepository(options);
666
+ },
667
+ deps: ['FirestoreOptions'],
668
+ },
669
+ {
670
+ provide: 'SubscriptionRepository',
671
+ useFactory: (options) => {
672
+ return new SubscriptionFirestoreRepository(options);
673
+ },
674
+ deps: ['FirestoreOptions'],
675
+ },
676
+ {
677
+ provide: 'UserRepository',
678
+ useFactory: (options) => {
679
+ return new UserFirestoreRepository(options);
680
+ },
681
+ deps: ['FirestoreOptions'],
682
+ },
683
+ {
684
+ provide: 'UserAddressRepository',
685
+ useFactory: (options, userRepository) => {
686
+ return new UserAddressFirestoreRepository(options, userRepository);
687
+ },
688
+ deps: ['FirestoreOptions', 'UserRepository'],
689
+ },
690
+ {
691
+ provide: 'UserPaymentMethodRepository',
692
+ useFactory: (options, userRepository) => {
693
+ return new UserPaymentMethodFirestoreRepository(options, userRepository);
694
+ },
695
+ deps: ['FirestoreOptions', 'UserRepository'],
696
+ },
697
+ {
698
+ provide: 'SubscriptionMaterializationRepository',
699
+ useFactory: (options) => {
700
+ return new SubscriptionMaterializationFirestoreRepository(options);
701
+ },
702
+ deps: ['FirestoreOptions'],
703
+ },
704
+ {
705
+ provide: 'SubscriptionSummaryRepository',
706
+ useFactory: (options) => {
707
+ return new SubscriptionSummaryFirestoreRepository(options);
708
+ },
709
+ deps: ['FirestoreOptions'],
710
+ },
711
+ {
712
+ provide: ProductVariantFirestoreRepository,
713
+ useFactory: (options, productRepository) => {
714
+ return new ProductVariantFirestoreRepository(options, productRepository);
715
+ },
716
+ deps: ['FirestoreOptions', ProductFirestoreRepository],
717
+ },
718
+ {
719
+ provide: 'OrderBlockedRepository',
720
+ useFactory: (options) => {
721
+ return new OrderBlockedFirestoreRepository(options);
722
+ },
723
+ deps: ['FirestoreOptions'],
724
+ },
725
+ {
726
+ provide: 'LogRepository',
727
+ useFactory: (options) => {
728
+ return new LogFirestoreRepository(options);
729
+ },
730
+ deps: ['FirestoreOptions'],
731
+ },
732
+ {
733
+ provide: 'SequenceRepository',
734
+ useFactory: (options) => {
735
+ return new SequenceFirestoreRepository(options);
736
+ },
737
+ deps: ['FirestoreOptions'],
738
+ },
739
+ ],
740
+ }]
741
+ }] });
742
+
743
+ class AngularHasuraGraphQLModule {
744
+ static initializeApp(options) {
745
+ return {
746
+ ngModule: AngularHasuraGraphQLModule,
747
+ providers: [{ provide: HASURA_OPTIONS, useValue: options }],
748
+ };
749
+ }
750
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
751
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule }); }
752
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, providers: [
753
+ {
754
+ provide: 'HasuraConfig',
755
+ useFactory: (options, platformId) => ({
756
+ endpoint: options.endpoint,
757
+ authOptions: options.credentials,
758
+ cache: options.cache,
759
+ interceptors: {
760
+ request: (request) => {
761
+ if (isPlatformBrowser(platformId))
762
+ return request;
763
+ const interval = setInterval(() => { }, 100);
764
+ request.interval = interval;
765
+ return request;
766
+ },
767
+ response: (response, request) => {
768
+ if (isPlatformBrowser(platformId))
769
+ return response;
770
+ clearInterval(request.interval);
771
+ return response;
772
+ },
773
+ },
774
+ }),
775
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
776
+ },
777
+ {
778
+ provide: 'CategoryRepository',
779
+ useExisting: CategoryHasuraGraphQLRepository,
780
+ },
781
+ {
782
+ provide: CategoryHasuraGraphQLRepository,
783
+ useFactory: (options, productRepository, categoryFilterRepository) => {
784
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
785
+ },
786
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
787
+ },
788
+ {
789
+ provide: 'ProductRepository',
790
+ useExisting: ProductHasuraGraphQLRepository,
791
+ },
792
+ {
793
+ provide: ProductHasuraGraphQLRepository,
794
+ useFactory: (hasuraConfig) => {
795
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
796
+ },
797
+ deps: ['HasuraConfig'],
798
+ },
799
+ {
800
+ provide: 'ProductReviewRepository',
801
+ useExisting: ProductReviewHasuraGraphQLRepository,
802
+ },
803
+ {
804
+ provide: ProductReviewHasuraGraphQLRepository,
805
+ useFactory: (hasuraConfig) => {
806
+ return new ProductReviewHasuraGraphQLRepository(hasuraConfig);
807
+ },
808
+ deps: ['HasuraConfig'],
809
+ },
810
+ {
811
+ provide: 'VariantRepository',
812
+ useExisting: VariantHasuraGraphQLRepository,
813
+ },
814
+ {
815
+ provide: VariantHasuraGraphQLRepository,
816
+ useFactory: (hasuraConfig) => {
817
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
818
+ },
819
+ deps: ['HasuraConfig'],
820
+ },
821
+ {
822
+ provide: 'ProductStockNotificationRepository',
823
+ useExisting: ProductStockNotificationHasuraGraphQLRepository,
824
+ },
825
+ {
826
+ provide: ProductStockNotificationHasuraGraphQLRepository,
827
+ useFactory: (hasuraConfig) => {
828
+ return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
829
+ },
830
+ deps: ['HasuraConfig'],
831
+ },
832
+ {
833
+ provide: 'CategoryFilterRepository',
834
+ useExisting: CategoryFilterHasuraGraphQLRepository,
835
+ },
836
+ {
837
+ provide: CategoryFilterHasuraGraphQLRepository,
838
+ useFactory: (options) => {
839
+ return new CategoryFilterHasuraGraphQLRepository(options);
840
+ },
841
+ deps: ['HasuraConfig'],
842
+ },
843
+ {
844
+ provide: 'FilterOptionRepository',
845
+ useExisting: FilterOptionHasuraGraphQLRepository,
846
+ },
847
+ {
848
+ provide: FilterOptionHasuraGraphQLRepository,
849
+ useFactory: (options) => {
850
+ return new FilterOptionHasuraGraphQLRepository(options);
851
+ },
852
+ deps: ['HasuraConfig'],
853
+ },
854
+ {
855
+ provide: 'FilterRepository',
856
+ useExisting: FilterHasuraGraphQLRepository,
857
+ },
858
+ {
859
+ provide: FilterHasuraGraphQLRepository,
860
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
861
+ return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
862
+ },
863
+ deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
864
+ },
865
+ {
866
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
867
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
868
+ deps: ['HasuraConfig'],
869
+ },
870
+ {
871
+ provide: 'CategoryCollectionChildrenRepository',
872
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
873
+ },
874
+ {
875
+ provide: CategoryProductHasuraGraphQLRepository,
876
+ useFactory: (options) => {
877
+ return new CategoryProductHasuraGraphQLRepository(options);
878
+ },
879
+ deps: ['HasuraConfig'],
880
+ },
881
+ {
882
+ provide: 'CategoryProductRepository',
883
+ useExisting: CategoryProductHasuraGraphQLRepository,
884
+ },
885
+ {
886
+ provide: WishlistHasuraGraphQLRepository,
887
+ useFactory: (options, categoryProductRepository) => {
888
+ return new WishlistHasuraGraphQLRepository(options, categoryProductRepository);
889
+ },
890
+ deps: ['HasuraConfig', CategoryProductHasuraGraphQLRepository],
891
+ },
892
+ {
893
+ provide: 'WishlistRepository',
894
+ useExisting: WishlistHasuraGraphQLRepository,
895
+ },
896
+ {
897
+ provide: ProductErrorsHasuraGraphQLRepository,
898
+ useFactory: (options, productRepository) => {
899
+ return new ProductErrorsHasuraGraphQLRepository(options, productRepository);
900
+ },
901
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
902
+ },
903
+ {
904
+ provide: 'ProductErrorsRepository',
905
+ useExisting: ProductErrorsHasuraGraphQLRepository,
906
+ },
907
+ ] }); }
908
+ }
909
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularHasuraGraphQLModule, decorators: [{
910
+ type: NgModule,
911
+ args: [{
912
+ providers: [
913
+ {
914
+ provide: 'HasuraConfig',
915
+ useFactory: (options, platformId) => ({
916
+ endpoint: options.endpoint,
917
+ authOptions: options.credentials,
918
+ cache: options.cache,
919
+ interceptors: {
920
+ request: (request) => {
921
+ if (isPlatformBrowser(platformId))
922
+ return request;
923
+ const interval = setInterval(() => { }, 100);
924
+ request.interval = interval;
925
+ return request;
926
+ },
927
+ response: (response, request) => {
928
+ if (isPlatformBrowser(platformId))
929
+ return response;
930
+ clearInterval(request.interval);
931
+ return response;
932
+ },
933
+ },
934
+ }),
935
+ deps: [HASURA_OPTIONS, PLATFORM_ID],
936
+ },
937
+ {
938
+ provide: 'CategoryRepository',
939
+ useExisting: CategoryHasuraGraphQLRepository,
940
+ },
941
+ {
942
+ provide: CategoryHasuraGraphQLRepository,
943
+ useFactory: (options, productRepository, categoryFilterRepository) => {
944
+ return new CategoryHasuraGraphQLRepository(options, productRepository, categoryFilterRepository);
945
+ },
946
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
947
+ },
948
+ {
949
+ provide: 'ProductRepository',
950
+ useExisting: ProductHasuraGraphQLRepository,
951
+ },
952
+ {
953
+ provide: ProductHasuraGraphQLRepository,
954
+ useFactory: (hasuraConfig) => {
955
+ return new ProductHasuraGraphQLRepository(hasuraConfig);
956
+ },
957
+ deps: ['HasuraConfig'],
958
+ },
959
+ {
960
+ provide: 'ProductReviewRepository',
961
+ useExisting: ProductReviewHasuraGraphQLRepository,
962
+ },
963
+ {
964
+ provide: ProductReviewHasuraGraphQLRepository,
965
+ useFactory: (hasuraConfig) => {
966
+ return new ProductReviewHasuraGraphQLRepository(hasuraConfig);
967
+ },
968
+ deps: ['HasuraConfig'],
969
+ },
970
+ {
971
+ provide: 'VariantRepository',
972
+ useExisting: VariantHasuraGraphQLRepository,
973
+ },
974
+ {
975
+ provide: VariantHasuraGraphQLRepository,
976
+ useFactory: (hasuraConfig) => {
977
+ return new VariantHasuraGraphQLRepository(hasuraConfig);
978
+ },
979
+ deps: ['HasuraConfig'],
980
+ },
981
+ {
982
+ provide: 'ProductStockNotificationRepository',
983
+ useExisting: ProductStockNotificationHasuraGraphQLRepository,
984
+ },
985
+ {
986
+ provide: ProductStockNotificationHasuraGraphQLRepository,
987
+ useFactory: (hasuraConfig) => {
988
+ return new ProductStockNotificationHasuraGraphQLRepository(hasuraConfig);
989
+ },
990
+ deps: ['HasuraConfig'],
991
+ },
992
+ {
993
+ provide: 'CategoryFilterRepository',
994
+ useExisting: CategoryFilterHasuraGraphQLRepository,
995
+ },
996
+ {
997
+ provide: CategoryFilterHasuraGraphQLRepository,
998
+ useFactory: (options) => {
999
+ return new CategoryFilterHasuraGraphQLRepository(options);
1000
+ },
1001
+ deps: ['HasuraConfig'],
1002
+ },
1003
+ {
1004
+ provide: 'FilterOptionRepository',
1005
+ useExisting: FilterOptionHasuraGraphQLRepository,
1006
+ },
1007
+ {
1008
+ provide: FilterOptionHasuraGraphQLRepository,
1009
+ useFactory: (options) => {
1010
+ return new FilterOptionHasuraGraphQLRepository(options);
1011
+ },
1012
+ deps: ['HasuraConfig'],
1013
+ },
1014
+ {
1015
+ provide: 'FilterRepository',
1016
+ useExisting: FilterHasuraGraphQLRepository,
1017
+ },
1018
+ {
1019
+ provide: FilterHasuraGraphQLRepository,
1020
+ useFactory: (options, filterOptionRepository, categoryFilterRepository) => {
1021
+ return new FilterHasuraGraphQLRepository(options, filterOptionRepository, categoryFilterRepository);
1022
+ },
1023
+ deps: ['HasuraConfig', FilterOptionHasuraGraphQLRepository, CategoryFilterHasuraGraphQLRepository],
1024
+ },
1025
+ {
1026
+ provide: CategoryCollectionChildrenHasuraGraphQLRepository,
1027
+ useFactory: (options) => new CategoryCollectionChildrenHasuraGraphQLRepository(options),
1028
+ deps: ['HasuraConfig'],
1029
+ },
1030
+ {
1031
+ provide: 'CategoryCollectionChildrenRepository',
1032
+ useExisting: CategoryCollectionChildrenHasuraGraphQLRepository,
1033
+ },
1034
+ {
1035
+ provide: CategoryProductHasuraGraphQLRepository,
1036
+ useFactory: (options) => {
1037
+ return new CategoryProductHasuraGraphQLRepository(options);
1038
+ },
1039
+ deps: ['HasuraConfig'],
1040
+ },
1041
+ {
1042
+ provide: 'CategoryProductRepository',
1043
+ useExisting: CategoryProductHasuraGraphQLRepository,
1044
+ },
1045
+ {
1046
+ provide: WishlistHasuraGraphQLRepository,
1047
+ useFactory: (options, categoryProductRepository) => {
1048
+ return new WishlistHasuraGraphQLRepository(options, categoryProductRepository);
1049
+ },
1050
+ deps: ['HasuraConfig', CategoryProductHasuraGraphQLRepository],
1051
+ },
1052
+ {
1053
+ provide: 'WishlistRepository',
1054
+ useExisting: WishlistHasuraGraphQLRepository,
1055
+ },
1056
+ {
1057
+ provide: ProductErrorsHasuraGraphQLRepository,
1058
+ useFactory: (options, productRepository) => {
1059
+ return new ProductErrorsHasuraGraphQLRepository(options, productRepository);
1060
+ },
1061
+ deps: ['HasuraConfig', ProductHasuraGraphQLRepository],
1062
+ },
1063
+ {
1064
+ provide: 'ProductErrorsRepository',
1065
+ useExisting: ProductErrorsHasuraGraphQLRepository,
1066
+ },
1067
+ ],
1068
+ }]
1069
+ }] });
1070
+
1071
+ class AngularVertexSeachModule {
1072
+ static initializeApp(options) {
1073
+ return {
1074
+ ngModule: AngularVertexSeachModule,
1075
+ providers: [{ provide: VERTEX_CONFIG, useValue: options }],
1076
+ };
1077
+ }
1078
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularVertexSeachModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
1079
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularVertexSeachModule }); }
1080
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularVertexSeachModule, providers: [
1081
+ {
1082
+ provide: ProductsVertexSearch,
1083
+ useFactory: (configuration) => new ProductsVertexSearch(new VertexAxiosAdapter(configuration)),
1084
+ deps: [VERTEX_CONFIG],
1085
+ },
1086
+ ] }); }
1087
+ }
1088
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularVertexSeachModule, decorators: [{
1089
+ type: NgModule,
1090
+ args: [{
1091
+ providers: [
1092
+ {
1093
+ provide: ProductsVertexSearch,
1094
+ useFactory: (configuration) => new ProductsVertexSearch(new VertexAxiosAdapter(configuration)),
1095
+ deps: [VERTEX_CONFIG],
1096
+ },
1097
+ ],
1098
+ }]
1099
+ }] });
1100
+
1101
+ const STORAGE_BASE_URL = 'STORAGE_BASE_URL';
1102
+
1103
+ class CookieDataPersistence {
1104
+ get(key) {
1105
+ return of(cookie.get(key));
1106
+ }
1107
+ remove(key) {
1108
+ return of(cookie.remove(key));
1109
+ }
1110
+ set(key, value) {
1111
+ return from(cookie.set(key, value)).pipe(map(() => { }));
1112
+ }
1113
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1114
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence }); }
1115
+ }
1116
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CookieDataPersistence, decorators: [{
1117
+ type: Injectable
1118
+ }] });
1119
+
1120
+ class AuthService {
1121
+ constructor(angularFireAuth, userRepository) {
1122
+ this.angularFireAuth = angularFireAuth;
1123
+ this.userRepository = userRepository;
1124
+ }
1125
+ getAuthstate() {
1126
+ const observables = [this.getFireUser(), this.getUser()];
1127
+ return combineLatest(observables).pipe(map(([fireUser, user]) => ({
1128
+ user,
1129
+ isAnonymous: fireUser?.isAnonymous,
1130
+ })));
1131
+ }
1132
+ getUser() {
1133
+ return this.getFireUser().pipe(map((user) => user?.uid), mergeMap((id) => (id ? from(this.userRepository.get({ id })).pipe(catchError(() => of(null))) : of(null))));
1134
+ }
1135
+ getTokenId() {
1136
+ return from(getIdToken(this.angularFireAuth.currentUser));
1137
+ }
1138
+ getFireUser() {
1139
+ return authState(this.angularFireAuth).pipe(catchError(() => of(null)));
1140
+ }
1141
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthService, deps: [{ token: i1.Auth }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1142
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthService }); }
1143
+ }
1144
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AuthService, decorators: [{
1145
+ type: Injectable
1146
+ }], ctorParameters: () => [{ type: i1.Auth }, { type: undefined, decorators: [{
1147
+ type: Inject,
1148
+ args: ['UserRepository']
1149
+ }] }] });
1150
+
1151
+ class CheckoutRepositoriesFacade {
1152
+ constructor(checkoutRepository, userRepository) {
1153
+ this.checkoutRepository = checkoutRepository;
1154
+ this.userRepository = userRepository;
1155
+ }
1156
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutRepositoriesFacade, deps: [{ token: 'CheckoutRepository' }, { token: 'UserRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1157
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutRepositoriesFacade }); }
1158
+ }
1159
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutRepositoriesFacade, decorators: [{
1160
+ type: Injectable
1161
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1162
+ type: Inject,
1163
+ args: ['CheckoutRepository']
1164
+ }] }, { type: undefined, decorators: [{
1165
+ type: Inject,
1166
+ args: ['UserRepository']
1167
+ }] }] });
1168
+
1169
+ class CheckoutDependenciesFacade {
1170
+ constructor(dataPersistence, httpClient) {
1171
+ this.dataPersistence = dataPersistence;
1172
+ this.httpClient = httpClient;
1173
+ }
1174
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutDependenciesFacade, deps: [{ token: PERSISTENCE_PROVIDER }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
1175
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutDependenciesFacade }); }
1176
+ }
1177
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutDependenciesFacade, decorators: [{
1178
+ type: Injectable
1179
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1180
+ type: Inject,
1181
+ args: [PERSISTENCE_PROVIDER]
1182
+ }] }, { type: i1$2.HttpClient }] });
1183
+
1184
+ class ConfigurationFacade {
1185
+ constructor(defaultShop, firebaseOptions) {
1186
+ this.defaultShop = defaultShop;
1187
+ this.firebaseOptions = firebaseOptions;
1188
+ }
1189
+ getCheckoutUrl() {
1190
+ return `https://southamerica-east1-${this.firebaseOptions.projectId}.cloudfunctions.net`;
1191
+ }
1192
+ getProjectId() {
1193
+ return this.firebaseOptions.projectId;
1194
+ }
1195
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ConfigurationFacade, deps: [{ token: DEFAULT_SHOP }, { token: FIREBASE_OPTIONS }], target: i0.ɵɵFactoryTarget.Injectable }); }
1196
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ConfigurationFacade }); }
1197
+ }
1198
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ConfigurationFacade, decorators: [{
1199
+ type: Injectable
1200
+ }], ctorParameters: () => [{ type: i3.Shops, decorators: [{
1201
+ type: Inject,
1202
+ args: [DEFAULT_SHOP]
1203
+ }] }, { type: undefined, decorators: [{
1204
+ type: Inject,
1205
+ args: [FIREBASE_OPTIONS]
1206
+ }] }] });
1207
+
1208
+ class CheckoutService {
1209
+ constructor(repositoriesFacade, dependenciesFacade, configurationFacade) {
1210
+ this.repositoriesFacade = repositoriesFacade;
1211
+ this.dependenciesFacade = dependenciesFacade;
1212
+ this.configurationFacade = configurationFacade;
1213
+ this.checkoutUrl = null;
1214
+ this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
1215
+ }
1216
+ getCheckout(checkoutData) {
1217
+ return this.dependenciesFacade.dataPersistence
1218
+ .get('checkoutId')
1219
+ .pipe(concatMap((id) => !isNil(id) ? this.repositoriesFacade.checkoutRepository.get({ id }) : this.createCheckout(checkoutData)));
1220
+ }
1221
+ getUserByCheckout(checkoutId) {
1222
+ return from(this.repositoriesFacade.checkoutRepository.get({ id: checkoutId })).pipe(concatMap((checkout) => checkout?.user?.id
1223
+ ? of(checkout.user)
1224
+ : from(this.repositoriesFacade.userRepository.get({ id: checkout.user.id }))), concatMap((user) => of(user) || throwError(() => new NotFoundError('User is not found'))));
1225
+ }
1226
+ updateCheckoutLineItems(checkout) {
1227
+ return from(this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, lineItems: checkout.lineItems })));
1228
+ }
1229
+ updateCheckoutUser(checkout) {
1230
+ return from(this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, user: checkout.user })));
1231
+ }
1232
+ clearCheckoutFromSession() {
1233
+ return this.dependenciesFacade.dataPersistence.remove('checkoutId');
1234
+ }
1235
+ resetCheckoutValues() {
1236
+ return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutResetValues`, {
1237
+ checkoutId: checkout.id,
1238
+ })), concatMap(() => this.getCheckout()));
1239
+ }
1240
+ applyCouponDiscount(nickname, checkoutType) {
1241
+ return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutApplyDiscount`, {
1242
+ checkoutId: checkout.id,
1243
+ coupon: nickname,
1244
+ checkoutType,
1245
+ })), concatMap(() => this.getCheckout()), map((checkout) => checkout.coupon));
1246
+ }
1247
+ removeCouponDiscount() {
1248
+ return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveDiscount`, {
1249
+ checkoutId: checkout.id,
1250
+ })), concatMap(() => this.getCheckout()));
1251
+ }
1252
+ validateStockProducts() {
1253
+ return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutValidateProductStock`, {
1254
+ checkoutId: checkout.id,
1255
+ })));
1256
+ }
1257
+ selectShippingAddress(address) {
1258
+ return this.getCheckout().pipe(concatMap((checkout) => {
1259
+ return this.repositoriesFacade.checkoutRepository.update(Checkout.toInstance({ id: checkout.id, shippingAddress: address, billingAddress: address }));
1260
+ }));
1261
+ }
1262
+ getAvailableShippingForProduct(productShipping) {
1263
+ return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
1264
+ checkoutId: null,
1265
+ productShipping,
1266
+ });
1267
+ }
1268
+ getAvailableShippingForCheckout() {
1269
+ return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutGetAvailableShipping`, {
1270
+ checkoutId: checkout.id,
1271
+ productShipping: null,
1272
+ })));
1273
+ }
1274
+ selectShipping(option) {
1275
+ return this.getCheckout().pipe(concatMap((checkout) => this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkoutSelectShipping`, {
1276
+ checkoutId: checkout.id,
1277
+ shippingOption: option,
1278
+ })), concatMap(() => this.getCheckout()));
1279
+ }
1280
+ createOrder(checkoutPayload, paymentProvider, applicationVersion) {
1281
+ return this.dependenciesFacade.httpClient.post(`${this.checkoutUrl}/checkout`, {
1282
+ data: {
1283
+ ...checkoutPayload,
1284
+ applicationVersion,
1285
+ paymentProvider,
1286
+ },
1287
+ });
1288
+ }
1289
+ async createCheckout(checkoutData) {
1290
+ const checkout = await this.repositoriesFacade.checkoutRepository.create({
1291
+ createdAt: new Date(),
1292
+ ...Checkout.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
1293
+ shop: checkoutData?.shop || this.configurationFacade.defaultShop,
1294
+ });
1295
+ await this.dependenciesFacade.dataPersistence.set('checkoutId', checkout.id).toPromise();
1296
+ return checkout;
1297
+ }
1298
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, deps: [{ token: CheckoutRepositoriesFacade }, { token: CheckoutDependenciesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
1299
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService }); }
1300
+ }
1301
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutService, decorators: [{
1302
+ type: Injectable
1303
+ }], ctorParameters: () => [{ type: CheckoutRepositoriesFacade }, { type: CheckoutDependenciesFacade }, { type: ConfigurationFacade }] });
1304
+
1305
+ class CartServicesFacade {
1306
+ constructor(authService, checkoutService, httpClient) {
1307
+ this.authService = authService;
1308
+ this.checkoutService = checkoutService;
1309
+ this.httpClient = httpClient;
1310
+ }
1311
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartServicesFacade, deps: [{ token: AuthService }, { token: CheckoutService }, { token: i1$2.HttpClient }], target: i0.ɵɵFactoryTarget.Injectable }); }
1312
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartServicesFacade }); }
1313
+ }
1314
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartServicesFacade, decorators: [{
1315
+ type: Injectable
1316
+ }], ctorParameters: () => [{ type: AuthService }, { type: CheckoutService }, { type: i1$2.HttpClient }] });
1317
+
1318
+ class CartService {
1319
+ constructor(servicesFacade, configurationFacade) {
1320
+ this.servicesFacade = servicesFacade;
1321
+ this.configurationFacade = configurationFacade;
1322
+ this.cartSubject = new Subject();
1323
+ this.checkoutUrl = null;
1324
+ this.generateCartObject = (items) => items?.reduce((cart, item) => ({
1325
+ ...cart,
1326
+ [item.id]: LineItem.toInstance({
1327
+ ...(cart[item.id] || item),
1328
+ quantity: (cart[item.id]?.quantity || 0) + (item.quantity ? item.quantity : 1),
1329
+ }),
1330
+ }), {}) || {};
1331
+ this.checkoutUrl = this.configurationFacade.getCheckoutUrl();
1332
+ }
1333
+ addItem(item, quantity = 1) {
1334
+ return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutAddItemToCart`, {
1335
+ checkoutId: checkout.id,
1336
+ productId: item.id,
1337
+ quantity,
1338
+ })), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1339
+ }
1340
+ decreaseItem(item) {
1341
+ return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutDecreaseProductFromCart`, {
1342
+ checkoutId: checkout.id,
1343
+ productId: item.id,
1344
+ quantity: 1,
1345
+ })), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1346
+ }
1347
+ removeItem(item) {
1348
+ return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutRemoveProductFromCart`, {
1349
+ checkoutId: checkout.id,
1350
+ productId: item.id,
1351
+ })), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => this.generateCartObject(updatedCheckout.lineItems)), tap((cart) => this.cartSubject.next(cart)));
1352
+ }
1353
+ updateUserCart(user) {
1354
+ return this.servicesFacade.checkoutService.getCheckout().pipe(concatMap((checkout) => this.servicesFacade.checkoutService.updateCheckoutUser(Checkout.toInstance({ ...checkout.toPlain(), user }))), concatMap((checkout) => {
1355
+ return this.servicesFacade.httpClient.post(`${this.checkoutUrl}/checkoutUpdateUserCart`, {
1356
+ checkoutId: checkout.id,
1357
+ });
1358
+ }), concatMap(() => this.servicesFacade.checkoutService.getCheckout()), map((updatedCheckout) => {
1359
+ return this.generateCartObject(updatedCheckout.lineItems);
1360
+ }), tap((cart) => this.cartSubject.next(cart)));
1361
+ }
1362
+ getCart(checkout) {
1363
+ this.buildCartFromCheckout(checkout).subscribe((cart) => this.cartSubject.next(cart));
1364
+ return this.cartSubject;
1365
+ }
1366
+ clearCart() {
1367
+ return this.servicesFacade.checkoutService.getCheckout().pipe(map((checkout) => {
1368
+ this.servicesFacade.checkoutService.clearCheckoutFromSession();
1369
+ return checkout;
1370
+ }), concatMap((oldCheckout) => this.buildCartFromCheckout(oldCheckout)), tap((cart) => this.cartSubject.next(cart)));
1371
+ }
1372
+ buildCartFromCheckout(checkoutData) {
1373
+ return this.servicesFacade.checkoutService.getCheckout(checkoutData).pipe(map((checkout) => checkout.lineItems), concatMap((lineItems) => of(this.generateCartObject(lineItems))));
1374
+ }
1375
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartService, deps: [{ token: CartServicesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
1376
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartService }); }
1377
+ }
1378
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CartService, decorators: [{
1379
+ type: Injectable
1380
+ }], ctorParameters: () => [{ type: CartServicesFacade }, { type: ConfigurationFacade }] });
1381
+
1382
+ class NewCategoryStructureAdapter {
1383
+ constructor(categoryRepository) {
1384
+ this.categoryRepository = categoryRepository;
1385
+ }
1386
+ async buildProductFilterByCategory(category) {
1387
+ const loadedCategory = await this.getCategory(category);
1388
+ if (loadedCategory.isCollection)
1389
+ return { id: { operator: Where.IN, value: loadedCategory.products } };
1390
+ const categoryIds = [...(await this.getAllCategoriesIdFromCategory(category)), category.id.toString()];
1391
+ return {
1392
+ category: {
1393
+ id: {
1394
+ operator: Where.IN,
1395
+ value: categoryIds,
1396
+ },
1397
+ },
1398
+ };
1399
+ }
1400
+ async getAllCategoriesIdFromCategory(category) {
1401
+ return this.categoryRepository
1402
+ .getChildren(+category.id)
1403
+ .then((categories) => categories.map((category) => category.id.toString()));
1404
+ }
1405
+ async getCategory(category) {
1406
+ const collectionCategory = category.isCollection ||
1407
+ (isNil(category.isCollection) && !category.products?.length) ||
1408
+ category.isWishlist ||
1409
+ category.brandCategory;
1410
+ return collectionCategory ? this.categoryRepository.get({ id: category.id }) : category;
1411
+ }
1412
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1413
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter }); }
1414
+ }
1415
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: NewCategoryStructureAdapter, decorators: [{
1416
+ type: Injectable
1417
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1418
+ type: Inject,
1419
+ args: ['CategoryRepository']
1420
+ }] }] });
1421
+
1422
+ class OldCategoryStructureAdapter {
1423
+ constructor(categoryRepository) {
1424
+ this.categoryRepository = categoryRepository;
1425
+ }
1426
+ async buildProductFilterByCategory(category) {
1427
+ const productsIds = category.products?.length
1428
+ ? category.products
1429
+ : await this.categoryRepository.get({ id: category.id }).then((categoryFound) => categoryFound.products);
1430
+ return { id: { operator: Where.IN, value: productsIds } };
1431
+ }
1432
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OldCategoryStructureAdapter, deps: [{ token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1433
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OldCategoryStructureAdapter }); }
1434
+ }
1435
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OldCategoryStructureAdapter, decorators: [{
1436
+ type: Injectable
1437
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1438
+ type: Inject,
1439
+ args: ['CategoryRepository']
1440
+ }] }] });
1441
+
1442
+ class CatalogSearchContext {
1443
+ constructor(categoryStrategy, termStrategy, profileStrategy) {
1444
+ this.categoryStrategy = categoryStrategy;
1445
+ this.termStrategy = termStrategy;
1446
+ this.profileStrategy = profileStrategy;
1447
+ this.strategies = new Map();
1448
+ this.initializeStrategies();
1449
+ }
1450
+ async executeSearch(params, shop, optionsCache) {
1451
+ const strategy = this.selectStrategy(params);
1452
+ return strategy.search(params, shop, optionsCache);
1453
+ }
1454
+ initializeStrategies() {
1455
+ this.strategies.set('category', this.categoryStrategy);
1456
+ this.strategies.set('term', this.termStrategy);
1457
+ this.strategies.set('profile', this.profileStrategy);
1458
+ }
1459
+ selectStrategy(params) {
1460
+ if (params.category) {
1461
+ const strategy = this.strategies.get('category');
1462
+ if (!strategy)
1463
+ throw new Error('Category strategy not found');
1464
+ return strategy;
1465
+ }
1466
+ if (params.term) {
1467
+ const strategy = this.strategies.get('term');
1468
+ if (!strategy)
1469
+ throw new Error('Term strategy not found');
1470
+ return strategy;
1471
+ }
1472
+ if (params.profile?.length) {
1473
+ const strategy = this.strategies.get('profile');
1474
+ if (!strategy)
1475
+ throw new Error('Profile strategy not found');
1476
+ return strategy;
1477
+ }
1478
+ throw new Error('No valid search strategy found for the given parameters');
1479
+ }
1480
+ }
1481
+
1482
+ class CategorySearchStrategy {
1483
+ constructor(repositoryService, helpersService) {
1484
+ this.repositoryService = repositoryService;
1485
+ this.helpersService = helpersService;
1486
+ }
1487
+ async search(params, shop, optionsCache) {
1488
+ const { category, filters, limits, sort, mainGender } = params;
1489
+ if (!category) {
1490
+ throw new Error('Category is required for CategorySearchStrategy');
1491
+ }
1492
+ const fields = this.helpersService.getFieldsHelper().getStandardFields();
1493
+ if (sort === 'most-relevant') {
1494
+ return this.searchWithMostRelevant({
1495
+ category,
1496
+ filters,
1497
+ limits,
1498
+ shop,
1499
+ mainGender,
1500
+ optionsCache,
1501
+ fields,
1502
+ });
1503
+ }
1504
+ return this.searchDefault({
1505
+ category,
1506
+ filters,
1507
+ limits,
1508
+ shop,
1509
+ mainGender,
1510
+ sort,
1511
+ optionsCache,
1512
+ fields,
1513
+ });
1514
+ }
1515
+ async searchWithMostRelevant(params) {
1516
+ const { category, filters, shop, optionsCache } = params;
1517
+ const mostRelevant = category.isWishlist ? [] : category.getMostRelevantByShop(shop);
1518
+ const productsIds = await this.getProductIds(category, filters, optionsCache);
1519
+ return this.findAndSortByMostRelevant({
1520
+ mostRelevants: mostRelevant,
1521
+ productIds: productsIds,
1522
+ filters: params.filters,
1523
+ limits: params.limits,
1524
+ shop: params.shop,
1525
+ mainGender: params.mainGender,
1526
+ optionsCache: params.optionsCache,
1527
+ fields: params.fields,
1528
+ });
1529
+ }
1530
+ async searchDefault(params) {
1531
+ const { category, filters, limits, sort, optionsCache, fields } = params;
1532
+ const productCatalog = this.repositoryService.getProductCatalog();
1533
+ const filterHelper = this.helpersService.getFilterHelper();
1534
+ const sortHelper = this.helpersService.getSortHelper();
1535
+ const repoParams = {
1536
+ fields,
1537
+ filters: {
1538
+ ...(await productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category)),
1539
+ ...filterHelper.buildFilterQuery(filters || {}),
1540
+ },
1541
+ ...(sort ? { orderBy: sortHelper.buildSortQuery(sort) } : {}),
1542
+ limits,
1543
+ options: {
1544
+ minimal: ['price'],
1545
+ maximum: ['price'],
1546
+ distinct: ['brand'],
1547
+ },
1548
+ };
1549
+ return productCatalog.productRepository.findCatalog(repoParams, null, optionsCache);
1550
+ }
1551
+ async getProductIds(category, filters, optionsCache) {
1552
+ const productCatalog = this.repositoryService.getProductCatalog();
1553
+ const filterHelper = this.helpersService.getFilterHelper();
1554
+ return productCatalog.productRepository
1555
+ .findCatalog({
1556
+ fields: ['id'],
1557
+ filters: {
1558
+ ...(await productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category)),
1559
+ ...filterHelper.buildFilterQuery(filters || {}),
1560
+ },
1561
+ }, undefined, optionsCache)
1562
+ .then((products) => products.data.map((product) => product.id));
1563
+ }
1564
+ async findAndSortByMostRelevant(params) {
1565
+ const { mostRelevants, productIds, filters, shop, mainGender, optionsCache, fields, limits } = params;
1566
+ const productCatalog = this.repositoryService.getProductCatalog();
1567
+ const filterHelper = this.helpersService.getFilterHelper();
1568
+ const sortHelper = this.helpersService.getSortHelper();
1569
+ const mostRelevantProductsIds = [...new Set(mostRelevants.concat(productIds))];
1570
+ const totalResult = await productCatalog.productRepository.findCatalog({
1571
+ fields,
1572
+ filters: {
1573
+ id: { operator: Where.IN, value: mostRelevantProductsIds },
1574
+ ...filterHelper.buildFilterQuery(filters || {}),
1575
+ },
1576
+ orderBy: sortHelper.buildSortQuery('best-sellers'),
1577
+ options: {
1578
+ minimal: ['price'],
1579
+ maximum: ['price'],
1580
+ ...(isEmpty(filters?.brands) ? { distinct: ['brand'] } : {}),
1581
+ },
1582
+ }, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
1583
+ return this.sortProductsByRelevance(totalResult, mostRelevants, limits);
1584
+ }
1585
+ sortProductsByRelevance(totalResult, mostRelevants, limits) {
1586
+ const mostRelevantWithoutStock = totalResult.data.filter((product) => mostRelevants.includes(product.id) && product.stock.quantity <= 0);
1587
+ const firstProducts = totalResult.data
1588
+ .filter((product) => mostRelevants.includes(product.id) && product.stock.quantity > 0)
1589
+ .sort((a, b) => mostRelevants.indexOf(a.id) - mostRelevants.indexOf(b.id));
1590
+ const lastProducts = totalResult.data
1591
+ .filter((product) => !mostRelevants.includes(product.id))
1592
+ .concat(mostRelevantWithoutStock);
1593
+ const categoryMostRelevants = firstProducts.concat(lastProducts);
1594
+ const resultFinal = categoryMostRelevants.slice(limits.offset, limits.offset + limits.limit);
1595
+ return {
1596
+ data: resultFinal,
1597
+ count: totalResult.count,
1598
+ maximum: totalResult.maximum,
1599
+ minimal: totalResult.minimal,
1600
+ distinct: totalResult.distinct,
1601
+ };
1602
+ }
1603
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategorySearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1604
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategorySearchStrategy }); }
1605
+ }
1606
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategorySearchStrategy, decorators: [{
1607
+ type: Injectable
1608
+ }], ctorParameters: () => [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }] });
1609
+
1610
+ class ProfileSearchStrategy {
1611
+ constructor(repositoryService, helpersService) {
1612
+ this.repositoryService = repositoryService;
1613
+ this.helpersService = helpersService;
1614
+ }
1615
+ async search(params, shop, optionsCache) {
1616
+ const { profile, filters, limits, sort, mainGender } = params;
1617
+ if (!profile) {
1618
+ throw new Error('Profile is required for ProfileSearchStrategy');
1619
+ }
1620
+ const productCatalog = this.repositoryService.getProductCatalog();
1621
+ const filterHelper = this.helpersService.getFilterHelper();
1622
+ const sortHelper = this.helpersService.getSortHelper();
1623
+ const fieldsHelper = this.helpersService.getFieldsHelper();
1624
+ const repoParams = {
1625
+ fields: fieldsHelper.getStandardFields(),
1626
+ filters: {
1627
+ tags: { operator: Where.LIKE, value: profile },
1628
+ ...filterHelper.buildFilterQuery(filters || {}),
1629
+ },
1630
+ ...(sort ? { orderBy: sortHelper.buildSortQuery(sort) } : {}),
1631
+ limits,
1632
+ options: {
1633
+ minimal: ['price'],
1634
+ maximum: ['price'],
1635
+ distinct: ['brand'],
1636
+ },
1637
+ };
1638
+ return productCatalog.productRepository.findCatalog(repoParams, mainGender || (shop === Shops.MENSMARKET ? 'male' : 'female'), optionsCache);
1639
+ }
1640
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProfileSearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1641
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProfileSearchStrategy }); }
1642
+ }
1643
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProfileSearchStrategy, decorators: [{
1644
+ type: Injectable
1645
+ }], ctorParameters: () => [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }] });
1646
+
1647
+ class TermSearchStrategy {
1648
+ constructor(repositoryService, helpersService) {
1649
+ this.repositoryService = repositoryService;
1650
+ this.helpersService = helpersService;
1651
+ this.productsByTerm = {};
1652
+ }
1653
+ async search(params, shop, _optionsCache) {
1654
+ const { term, filters, limits, sort, mainGender } = params;
1655
+ if (!term) {
1656
+ throw new Error('Term is required for TermSearchStrategy');
1657
+ }
1658
+ const productIds = await this.findCatalogIdsBySearch(term, shop);
1659
+ if (sort === 'most-relevant') {
1660
+ return this.searchWithMostRelevant({
1661
+ productIds,
1662
+ filters,
1663
+ limits,
1664
+ shop,
1665
+ mainGender,
1666
+ });
1667
+ }
1668
+ return this.searchDefault({
1669
+ productIds,
1670
+ filters,
1671
+ limits,
1672
+ shop,
1673
+ mainGender,
1674
+ fields: this.helpersService.getFieldsHelper().getStandardFields(),
1675
+ });
1676
+ }
1677
+ async searchWithMostRelevant(params) {
1678
+ const { productIds, filters, shop, mainGender } = params;
1679
+ const productCatalog = this.repositoryService.getProductCatalog();
1680
+ const filterHelper = this.helpersService.getFilterHelper();
1681
+ const totalResult = await productCatalog.productRepository.findCatalog({
1682
+ fields: ['id', 'stock', 'gender'],
1683
+ filters: {
1684
+ id: { operator: Where.IN, value: productIds },
1685
+ published: { operator: Where.EQUALS, value: true },
1686
+ ...filterHelper.buildFilterQuery(filters || {}),
1687
+ },
1688
+ options: {
1689
+ minimal: ['price'],
1690
+ maximum: ['price'],
1691
+ ...(isEmpty(filters?.brands) ? { distinct: ['brand'] } : {}),
1692
+ },
1693
+ });
1694
+ return this.sortByTermRelevance({
1695
+ productIds,
1696
+ totalResult,
1697
+ limits: params.limits,
1698
+ filters,
1699
+ fieldsHelper: this.helpersService.getFieldsHelper(),
1700
+ });
1701
+ }
1702
+ async searchDefault(params) {
1703
+ const { productIds, filters, limits, shop, mainGender, fields } = params;
1704
+ const productCatalog = this.repositoryService.getProductCatalog();
1705
+ const filterHelper = this.helpersService.getFilterHelper();
1706
+ return productCatalog.productRepository.findCatalog({
1707
+ fields,
1708
+ filters: {
1709
+ id: { operator: Where.IN, value: productIds },
1710
+ published: { operator: Where.EQUALS, value: true },
1711
+ ...filterHelper.buildFilterQuery(filters || {}),
1712
+ },
1713
+ limits,
1714
+ options: {
1715
+ minimal: ['price'],
1716
+ maximum: ['price'],
1717
+ distinct: ['brand'],
1718
+ },
1719
+ });
1720
+ }
1721
+ sortByTermRelevance(params) {
1722
+ const { productIds, totalResult, limits, filters, fieldsHelper } = params;
1723
+ // const defaultGender = filters?.gender?.at(0) || 'male'
1724
+ const stockData = totalResult.data.filter((product) => product.stock.quantity > 0);
1725
+ const stockOut = totalResult.data.filter((product) => product.stock.quantity <= 0);
1726
+ const productIdsStock = productIds.filter((product) => stockData.some((result) => result.id === product));
1727
+ const productIdsStockOut = productIds.filter((product) => stockOut.some((result) => result.id === product));
1728
+ const limitedProductId = productIdsStock
1729
+ .concat(productIdsStockOut)
1730
+ .slice(limits.offset, limits.offset + limits.limit);
1731
+ return this.getDetailedProducts(limitedProductId, totalResult, fieldsHelper);
1732
+ }
1733
+ async getDetailedProducts(orderedId, totalResult, fieldsHelper) {
1734
+ const productCatalog = this.repositoryService.getProductCatalog();
1735
+ const fields = fieldsHelper.getStandardFields();
1736
+ const productResult = await productCatalog.productRepository.findCatalog({
1737
+ filters: {
1738
+ id: { operator: Where.IN, value: orderedId },
1739
+ },
1740
+ fields,
1741
+ });
1742
+ return {
1743
+ data: orderedId.map((id) => productResult.data.find((product) => product.id === id)).filter(Boolean),
1744
+ count: totalResult.count,
1745
+ maximum: totalResult.maximum,
1746
+ minimal: totalResult.minimal,
1747
+ distinct: totalResult.distinct,
1748
+ };
1749
+ }
1750
+ async findCatalogIdsBySearch(term, shop) {
1751
+ if (this.productsByTerm[term])
1752
+ return this.productsByTerm[term];
1753
+ const productServices = this.repositoryService.getProductServices();
1754
+ return (this.productsByTerm[term] = await productServices.productSearch
1755
+ .search(term, 999, shop === Shops.GLAMSHOP ? 'female' : 'male')
1756
+ .then((products) => [...new Set(products.map((product) => product.id))]));
1757
+ }
1758
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TermSearchStrategy, deps: [{ token: CatalogRepositoryService }, { token: CatalogHelpersService }], target: i0.ɵɵFactoryTarget.Injectable }); }
1759
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TermSearchStrategy }); }
1760
+ }
1761
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: TermSearchStrategy, decorators: [{
1762
+ type: Injectable
1763
+ }], ctorParameters: () => [{ type: CatalogRepositoryService }, { type: CatalogHelpersService }] });
1764
+
1765
+ class CatalogStrategiesFacade {
1766
+ constructor(categoryStrategy, termStrategy, profileStrategy) {
1767
+ this.categoryStrategy = categoryStrategy;
1768
+ this.termStrategy = termStrategy;
1769
+ this.profileStrategy = profileStrategy;
1770
+ }
1771
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogStrategiesFacade, deps: [{ token: CategorySearchStrategy }, { token: TermSearchStrategy }, { token: ProfileSearchStrategy }], target: i0.ɵɵFactoryTarget.Injectable }); }
1772
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogStrategiesFacade }); }
1773
+ }
1774
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogStrategiesFacade, decorators: [{
1775
+ type: Injectable
1776
+ }], ctorParameters: () => [{ type: CategorySearchStrategy }, { type: TermSearchStrategy }, { type: ProfileSearchStrategy }] });
1777
+
1778
+ class CatalogServiceFacade {
1779
+ constructor(helpersService, strategiesFacade, shop) {
1780
+ this.helpersService = helpersService;
1781
+ this.strategiesFacade = strategiesFacade;
1782
+ this.shop = shop;
1783
+ const searchContext = new CatalogSearchContext(this.strategiesFacade.categoryStrategy, this.strategiesFacade.termStrategy, this.strategiesFacade.profileStrategy);
1784
+ this.catalogService = new CatalogService(searchContext, this.helpersService, this.shop);
1785
+ }
1786
+ getCatalogService() {
1787
+ return this.catalogService;
1788
+ }
1789
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogServiceFacade, deps: [{ token: CatalogHelpersService }, { token: CatalogStrategiesFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
1790
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogServiceFacade }); }
1791
+ }
1792
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogServiceFacade, decorators: [{
1793
+ type: Injectable
1794
+ }], ctorParameters: () => [{ type: CatalogHelpersService }, { type: CatalogStrategiesFacade }, { type: i3.Shops, decorators: [{
1795
+ type: Inject,
1796
+ args: [DEFAULT_SHOP]
1797
+ }] }] });
1798
+
1799
+ class CategoryRepositoryFacade {
1800
+ constructor(categoryRepository, categoryFilterRepository) {
1801
+ this.categoryRepository = categoryRepository;
1802
+ this.categoryFilterRepository = categoryFilterRepository;
1803
+ }
1804
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryRepositoryFacade, deps: [{ token: 'CategoryRepository' }, { token: 'CategoryFilterRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
1805
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryRepositoryFacade }); }
1806
+ }
1807
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryRepositoryFacade, decorators: [{
1808
+ type: Injectable
1809
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1810
+ type: Inject,
1811
+ args: ['CategoryRepository']
1812
+ }] }, { type: undefined, decorators: [{
1813
+ type: Inject,
1814
+ args: ['CategoryFilterRepository']
1815
+ }] }] });
1816
+
1817
+ class CategoryService {
1818
+ constructor(categoryFacade, productCatalog, shop) {
1819
+ this.categoryFacade = categoryFacade;
1820
+ this.productCatalog = productCatalog;
1821
+ this.shop = shop;
1822
+ }
1823
+ async fetchBrands(category, options, optionsCache) {
1824
+ const brands = await this.productCatalog.productRepository
1825
+ .findCatalog({
1826
+ filters: await this.productCatalog.categoryStructureAdapter.buildProductFilterByCategory(category),
1827
+ fields: ['brand'],
1828
+ }, null, optionsCache)
1829
+ .then(({ data }) => Object.keys(data.map((product) => product.brand).reduce((brands, brand) => ({ ...brands, [brand]: true }), {})));
1830
+ return this.categoryFacade.categoryRepository
1831
+ .find({ filters: { brandCategory: true, shop: options?.shop || this.shop }, orderBy: { name: 'asc' } }, optionsCache)
1832
+ .then(({ data }) => data.filter((category) => brands.includes(category.conditions.brand)));
1833
+ }
1834
+ async fetchFilterOptions(category, optionsCache) {
1835
+ return await this.categoryFacade.categoryFilterRepository
1836
+ .find({ filters: { categoryId: +category.id } }, optionsCache)
1837
+ .then(({ data }) => data.map((categoryFilter) => categoryFilter.filter));
1838
+ }
1839
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService, deps: [{ token: CategoryRepositoryFacade }, { token: ProductCatalogFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
1840
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService }); }
1841
+ }
1842
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryService, decorators: [{
1843
+ type: Injectable
1844
+ }], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
1845
+ type: Inject,
1846
+ args: [DEFAULT_SHOP]
1847
+ }] }] });
1848
+
1849
+ class ProductCatalogFacade {
1850
+ constructor(productRepository, categoryStructureAdapter) {
1851
+ this.productRepository = productRepository;
1852
+ this.categoryStructureAdapter = categoryStructureAdapter;
1853
+ }
1854
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductCatalogFacade, deps: [{ token: 'ProductRepository' }, { token: CATEGORY_STRUCTURE }], target: i0.ɵɵFactoryTarget.Injectable }); }
1855
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductCatalogFacade }); }
1856
+ }
1857
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductCatalogFacade, decorators: [{
1858
+ type: Injectable
1859
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
1860
+ type: Inject,
1861
+ args: ['ProductRepository']
1862
+ }] }, { type: undefined, decorators: [{
1863
+ type: Inject,
1864
+ args: [CATEGORY_STRUCTURE]
1865
+ }] }] });
1866
+
1867
+ class CategoryServiceFacade {
1868
+ constructor(categoryRepositoryFacade, productCatalogFacade, shop) {
1869
+ this.categoryRepositoryFacade = categoryRepositoryFacade;
1870
+ this.productCatalogFacade = productCatalogFacade;
1871
+ this.shop = shop;
1872
+ this.categoryService = new CategoryService(this.categoryRepositoryFacade, this.productCatalogFacade, this.shop);
1873
+ }
1874
+ getCategoryService() {
1875
+ return this.categoryService;
1876
+ }
1877
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryServiceFacade, deps: [{ token: CategoryRepositoryFacade }, { token: ProductCatalogFacade }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
1878
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryServiceFacade }); }
1879
+ }
1880
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CategoryServiceFacade, decorators: [{
1881
+ type: Injectable
1882
+ }], ctorParameters: () => [{ type: CategoryRepositoryFacade }, { type: ProductCatalogFacade }, { type: i3.Shops, decorators: [{
1883
+ type: Inject,
1884
+ args: [DEFAULT_SHOP]
1885
+ }] }] });
1886
+
1887
+ class BrandManagerHelper {
1888
+ constructor(productCatalog) {
1889
+ this.productCatalog = productCatalog;
1890
+ this.brandsList = {};
1891
+ }
1892
+ async setBrandsList(options, brands) {
1893
+ const filterBrands = options.filters?.brands;
1894
+ const indexKey = this.buildIndexBrands(options);
1895
+ if (isEmpty(brands) && options.filters) {
1896
+ delete options.filters.brands;
1897
+ }
1898
+ this.brandsList[indexKey] = this.brandsList[indexKey] || brands || (await this.fetchBrandsOnly(options));
1899
+ this.brandsList[indexKey] = this.brandsList[indexKey].filter(Boolean);
1900
+ if (options.filters) {
1901
+ options.filters = {
1902
+ ...options.filters,
1903
+ brands: filterBrands,
1904
+ };
1905
+ }
1906
+ }
1907
+ getBrandsList(indexKey) {
1908
+ return this.brandsList[indexKey];
1909
+ }
1910
+ buildIndexBrands(options) {
1911
+ if (options.category)
1912
+ return `category-${options.category.id}`;
1913
+ if (options.term)
1914
+ return `term-${options.term}`;
1915
+ if (options.profile)
1916
+ return `profile-${options.profile.join(',')}`;
1917
+ return '';
1918
+ }
1919
+ async fetchBrandsOnly(options) {
1920
+ return this.productCatalog.productRepository
1921
+ .findCatalog({
1922
+ fields: ['id'],
1923
+ filters: {
1924
+ published: { operator: Where.EQUALS, value: true },
1925
+ },
1926
+ options: {
1927
+ distinct: ['brand'],
1928
+ },
1929
+ }, options.mainGender)
1930
+ .then((result) => result.distinct.brand);
1931
+ }
1932
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrandManagerHelper, deps: [{ token: ProductCatalogFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
1933
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrandManagerHelper }); }
1934
+ }
1935
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: BrandManagerHelper, decorators: [{
1936
+ type: Injectable
1937
+ }], ctorParameters: () => [{ type: ProductCatalogFacade }] });
1938
+
1939
+ class CatalogFilterHelper {
1940
+ buildFilterQuery(filters) {
1941
+ const filterQuery = {};
1942
+ if (filters.clubDiscount?.length) {
1943
+ set(filterQuery, 'price.subscriberDiscountPercentage', {
1944
+ operator: Where.IN,
1945
+ value: filters.clubDiscount,
1946
+ });
1947
+ }
1948
+ if (filters.brands?.length) {
1949
+ filterQuery.brand = { operator: Where.IN, value: filters.brands };
1950
+ }
1951
+ if (filters.gender?.length) {
1952
+ filterQuery.gender = { operator: Where.IN, value: filters.gender };
1953
+ }
1954
+ if (filters.prices?.min || filters.prices?.max) {
1955
+ const priceField = filters.prices.subscriberPrice ? 'price.subscriberPrice' : 'price.price';
1956
+ const priceFilters = [
1957
+ ...(filters.prices.min ? [{ operator: Where.GTE, value: Math.floor(filters.prices.min) }] : []),
1958
+ ...(filters.prices.max ? [{ operator: Where.LTE, value: Math.ceil(filters.prices.max) }] : []),
1959
+ ];
1960
+ set(filterQuery, priceField, priceFilters);
1961
+ }
1962
+ if (filters.rate) {
1963
+ filterQuery.rate = { operator: Where.GTE, value: filters.rate };
1964
+ }
1965
+ if (filters.tags?.length) {
1966
+ filterQuery.tags = { operator: Where.LIKE, value: filters.tags };
1967
+ }
1968
+ if (filters.customOptions?.length) {
1969
+ filterQuery.filters = { operator: Where.LIKE, value: filters.customOptions };
1970
+ }
1971
+ return filterQuery;
1972
+ }
1973
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogFilterHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
1974
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogFilterHelper }); }
1975
+ }
1976
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogFilterHelper, decorators: [{
1977
+ type: Injectable
1978
+ }] });
1979
+
1980
+ class CatalogSortHelper {
1981
+ buildSortQuery(sort) {
1982
+ if (!sort || sort === 'most-relevant')
1983
+ return {};
1984
+ switch (sort) {
1985
+ case 'best-sellers':
1986
+ return {
1987
+ shoppingCount: 'desc',
1988
+ rate: 'desc',
1989
+ stock: 'desc',
1990
+ name: 'asc',
1991
+ };
1992
+ case 'biggest-price':
1993
+ return {
1994
+ subscriberPrice: 'desc',
1995
+ rate: 'desc',
1996
+ shoppingCount: 'desc',
1997
+ };
1998
+ case 'lowest-price':
1999
+ return {
2000
+ subscriberPrice: 'asc',
2001
+ rate: 'desc',
2002
+ shoppingCount: 'desc',
2003
+ };
2004
+ case 'best-rating':
2005
+ return {
2006
+ rate: 'desc',
2007
+ shoppingCount: 'desc',
2008
+ stock: 'desc',
2009
+ name: 'asc',
2010
+ };
2011
+ case 'news':
2012
+ return { createdAt: 'desc' };
2013
+ case 'biggest-discount':
2014
+ return {
2015
+ subscriberDiscountPercentage: 'desc',
2016
+ rate: 'desc',
2017
+ shoppingCount: 'desc',
2018
+ };
2019
+ default:
2020
+ return {};
2021
+ }
2022
+ }
2023
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogSortHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2024
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogSortHelper }); }
2025
+ }
2026
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogSortHelper, decorators: [{
2027
+ type: Injectable
2028
+ }] });
2029
+
2030
+ class ProductFieldsHelper {
2031
+ getStandardFields() {
2032
+ return [
2033
+ 'id',
2034
+ 'name',
2035
+ 'slug',
2036
+ 'images',
2037
+ 'miniatures',
2038
+ 'price',
2039
+ 'stock',
2040
+ 'published',
2041
+ 'CEST',
2042
+ 'EAN',
2043
+ 'NCM',
2044
+ 'brand',
2045
+ 'costPrice',
2046
+ 'hasVariants',
2047
+ 'isKit',
2048
+ 'sku',
2049
+ 'rate',
2050
+ 'tags',
2051
+ 'type',
2052
+ 'shoppingCount',
2053
+ 'gender',
2054
+ 'createdAt',
2055
+ 'label',
2056
+ 'outlet',
2057
+ 'group',
2058
+ ];
2059
+ }
2060
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductFieldsHelper, deps: [], target: i0.ɵɵFactoryTarget.Injectable }); }
2061
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductFieldsHelper }); }
2062
+ }
2063
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductFieldsHelper, decorators: [{
2064
+ type: Injectable
2065
+ }] });
2066
+
2067
+ class CatalogOperationsFacade {
2068
+ constructor(filterHelper, sortHelper, fieldsHelper) {
2069
+ this.filterHelper = filterHelper;
2070
+ this.sortHelper = sortHelper;
2071
+ this.fieldsHelper = fieldsHelper;
2072
+ }
2073
+ getFilterHelper() {
2074
+ return this.filterHelper;
2075
+ }
2076
+ getSortHelper() {
2077
+ return this.sortHelper;
2078
+ }
2079
+ getFieldsHelper() {
2080
+ return this.fieldsHelper;
2081
+ }
2082
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogOperationsFacade, deps: [{ token: CatalogFilterHelper }, { token: CatalogSortHelper }, { token: ProductFieldsHelper }], target: i0.ɵɵFactoryTarget.Injectable }); }
2083
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogOperationsFacade }); }
2084
+ }
2085
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogOperationsFacade, decorators: [{
2086
+ type: Injectable
2087
+ }], ctorParameters: () => [{ type: CatalogFilterHelper }, { type: CatalogSortHelper }, { type: ProductFieldsHelper }] });
2088
+
2089
+ class ProductManagementFacade {
2090
+ constructor(brandManager, productServices) {
2091
+ this.brandManager = brandManager;
2092
+ this.productServices = productServices;
2093
+ }
2094
+ getBrandManager() {
2095
+ return this.brandManager;
2096
+ }
2097
+ getProductServices() {
2098
+ return this.productServices;
2099
+ }
2100
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductManagementFacade, deps: [{ token: BrandManagerHelper }, { token: 'ProductServicesFacade' }], target: i0.ɵɵFactoryTarget.Injectable }); }
2101
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductManagementFacade }); }
2102
+ }
2103
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: ProductManagementFacade, decorators: [{
2104
+ type: Injectable
2105
+ }], ctorParameters: () => [{ type: BrandManagerHelper }, { type: undefined, decorators: [{
2106
+ type: Inject,
2107
+ args: ['ProductServicesFacade']
2108
+ }] }] });
2109
+
2110
+ class CatalogHelpersService {
2111
+ constructor(catalogOperations, productManagement) {
2112
+ this.catalogOperations = catalogOperations;
2113
+ this.productManagement = productManagement;
2114
+ }
2115
+ getFilterHelper() {
2116
+ return this.catalogOperations.getFilterHelper();
2117
+ }
2118
+ getSortHelper() {
2119
+ return this.catalogOperations.getSortHelper();
2120
+ }
2121
+ getFieldsHelper() {
2122
+ return this.catalogOperations.getFieldsHelper();
2123
+ }
2124
+ getBrandManager() {
2125
+ return this.productManagement.getBrandManager();
2126
+ }
2127
+ getProductServices() {
2128
+ return this.productManagement.getProductServices();
2129
+ }
2130
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogHelpersService, deps: [{ token: CatalogOperationsFacade }, { token: ProductManagementFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
2131
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogHelpersService }); }
2132
+ }
2133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogHelpersService, decorators: [{
2134
+ type: Injectable
2135
+ }], ctorParameters: () => [{ type: CatalogOperationsFacade }, { type: ProductManagementFacade }] });
2136
+
2137
+ class CatalogRepositoryService {
2138
+ constructor(productCatalog, productServices) {
2139
+ this.productCatalog = productCatalog;
2140
+ this.productServices = productServices;
2141
+ }
2142
+ getProductCatalog() {
2143
+ return this.productCatalog;
2144
+ }
2145
+ getProductServices() {
2146
+ return this.productServices;
2147
+ }
2148
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogRepositoryService, deps: [{ token: ProductCatalogFacade }, { token: 'ProductServicesFacade' }], target: i0.ɵɵFactoryTarget.Injectable }); }
2149
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogRepositoryService }); }
2150
+ }
2151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogRepositoryService, decorators: [{
2152
+ type: Injectable
2153
+ }], ctorParameters: () => [{ type: ProductCatalogFacade }, { type: undefined, decorators: [{
2154
+ type: Inject,
2155
+ args: ['ProductServicesFacade']
2156
+ }] }] });
2157
+
2158
+ class CatalogService {
2159
+ constructor(searchContext, helpersService, shop) {
2160
+ this.searchContext = searchContext;
2161
+ this.helpersService = helpersService;
2162
+ this.shop = shop;
2163
+ }
2164
+ async fetchProducts(options, optionsCache) {
2165
+ this.validateRequest(options);
2166
+ const searchParams = this.buildSearchParams(options);
2167
+ const { data, count: total, maximum, minimal, distinct, } = await this.searchContext.executeSearch(searchParams, this.shop, optionsCache);
2168
+ await this.helpersService.getBrandManager().setBrandsList(searchParams, distinct?.brand);
2169
+ return this.buildResponse({
2170
+ data,
2171
+ total,
2172
+ maximum,
2173
+ minimal,
2174
+ searchParams,
2175
+ options,
2176
+ });
2177
+ }
2178
+ async addCustomerToStockNotification(params) {
2179
+ const { shop, productId, name, email } = params;
2180
+ const productServices = this.helpersService.getProductServices();
2181
+ return productServices.productStockNotificationRepository.addCustomerEmail({
2182
+ shop,
2183
+ productId,
2184
+ name,
2185
+ email,
2186
+ });
2187
+ }
2188
+ validateRequest(options) {
2189
+ if (this.hasProfile(options) && options.filters?.customOptions) {
2190
+ throw new InvalidArgumentError(`It couldn't filled customOptions when profile is given`);
2191
+ }
2192
+ if (this.hasProfile(options) && options.filters?.tags) {
2193
+ throw new InvalidArgumentError(`It couldn't filled tags when profile is given`);
2194
+ }
2195
+ if (this.hasTerm(options) && options.filters?.customOptions) {
2196
+ throw new InvalidArgumentError(`It couldn't filled customOptions when term is given`);
2197
+ }
2198
+ }
2199
+ buildSearchParams(options) {
2200
+ const limits = this.buildLimitQuery(options);
2201
+ return {
2202
+ category: this.hasCategory(options) ? options.category : undefined,
2203
+ profile: this.hasProfile(options) ? options.profile : undefined,
2204
+ term: this.hasTerm(options) ? options.term : undefined,
2205
+ filters: options.filters,
2206
+ mainGender: options.mainGender,
2207
+ sort: options.sort,
2208
+ limits,
2209
+ };
2210
+ }
2211
+ buildResponse(params) {
2212
+ const { data, total, maximum, minimal, searchParams } = params;
2213
+ const limits = searchParams.limits;
2214
+ const indexKey = this.helpersService.getBrandManager().buildIndexBrands(searchParams);
2215
+ return {
2216
+ products: {
2217
+ data: data.map((product) => RoundProductPricesHelper.roundProductPrices(product)),
2218
+ total,
2219
+ },
2220
+ pages: Math.ceil(total / limits.limit),
2221
+ prices: {
2222
+ price: {
2223
+ min: +(minimal?.price?.price?.toFixed(2) || 0),
2224
+ max: +(maximum?.price?.price?.toFixed(2) || 0),
2225
+ },
2226
+ subscriberPrice: {
2227
+ min: +(minimal?.price?.subscriberPrice?.toFixed(2) || 0),
2228
+ max: +(maximum?.price?.subscriberPrice?.toFixed(2) || 0),
2229
+ },
2230
+ },
2231
+ brands: this.helpersService.getBrandManager().getBrandsList(indexKey),
2232
+ };
2233
+ }
2234
+ buildLimitQuery(options) {
2235
+ const limit = options?.perPage || 20;
2236
+ return {
2237
+ limit,
2238
+ offset: ((options?.page || 1) - 1) * limit,
2239
+ };
2240
+ }
2241
+ hasProfile(options) {
2242
+ return 'profile' in options;
2243
+ }
2244
+ hasTerm(options) {
2245
+ return 'term' in options;
2246
+ }
2247
+ hasCategory(options) {
2248
+ return 'category' in options;
2249
+ }
2250
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, deps: [{ token: CatalogSearchContext }, { token: CatalogHelpersService }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
2251
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService }); }
2252
+ }
2253
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CatalogService, decorators: [{
2254
+ type: Injectable
2255
+ }], ctorParameters: () => [{ type: CatalogSearchContext }, { type: CatalogHelpersService }, { type: i3.Shops, decorators: [{
2256
+ type: Inject,
2257
+ args: [DEFAULT_SHOP]
2258
+ }] }] });
2259
+
2260
+ var ProductSorts;
2261
+ (function (ProductSorts) {
2262
+ ProductSorts["MOST_RELEVANT"] = "most-relevant";
2263
+ ProductSorts["BEST_SELLER"] = "best-sellers";
2264
+ ProductSorts["BIGGEST_PRICE"] = "biggest-price";
2265
+ ProductSorts["LOWEST_PRICE"] = "lowest-price";
2266
+ ProductSorts["BIGGEST_DISCOUNT"] = "biggest-discount";
2267
+ ProductSorts["BEST_RATING"] = "best-rating";
2268
+ ProductSorts["NEWS"] = "news";
2269
+ })(ProductSorts || (ProductSorts = {}));
2270
+
2271
+ class CategoryWithTree extends Category {
2272
+ }
2273
+ __decorate([
2274
+ Type(() => CategoryWithTree),
2275
+ __metadata("design:type", Array)
2276
+ ], CategoryWithTree.prototype, "children", void 0);
2277
+
2278
+ class WishlistService {
2279
+ constructor(wishlistRepository, productRepository, logRepository, shop) {
2280
+ this.wishlistRepository = wishlistRepository;
2281
+ this.productRepository = productRepository;
2282
+ this.logRepository = logRepository;
2283
+ this.shop = shop;
2284
+ }
2285
+ initializeServices(catalogServiceFacade, categoryServiceFacade) {
2286
+ this.catalogService = catalogServiceFacade.getCatalogService();
2287
+ this.categoryService = categoryServiceFacade.getCategoryService();
2288
+ }
2289
+ getCatalogService() {
2290
+ return this.catalogService;
2291
+ }
2292
+ getCategoryService() {
2293
+ return this.categoryService;
2294
+ }
2295
+ async create({ personId, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
2296
+ const wishlistData = this.buildWishlistData({
2297
+ title,
2298
+ description,
2299
+ published,
2300
+ userFullName,
2301
+ userPhoto,
2302
+ theme,
2303
+ bannerUrl,
2304
+ personType,
2305
+ personIsSubscriber,
2306
+ personId,
2307
+ });
2308
+ const existingWishlist = await this.findExistingWishlistByPersonId(personId);
2309
+ await this.createWishlistLog(WishlistLogType.CREATE, wishlistData);
2310
+ if (existingWishlist)
2311
+ return existingWishlist;
2312
+ return this.createNewWishlist(wishlistData);
2313
+ }
2314
+ buildWishlistData({ title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, personId, }) {
2315
+ return {
2316
+ slug: '',
2317
+ name: title,
2318
+ description,
2319
+ metadatas: [
2320
+ {
2321
+ shop: this.shop,
2322
+ title: `${userFullName} - ${title}`,
2323
+ description: `${userFullName} - ${description}`,
2324
+ },
2325
+ ],
2326
+ shop: this.shop,
2327
+ shops: [this.shop],
2328
+ personId,
2329
+ personName: userFullName,
2330
+ personPhoto: userPhoto,
2331
+ brandCategory: false,
2332
+ published,
2333
+ theme,
2334
+ bannerUrl,
2335
+ personType: personType ?? PersonTypes.NONE,
2336
+ personIsSubscriber: personIsSubscriber ?? false,
2337
+ };
2338
+ }
2339
+ async findExistingWishlistByPersonId(personId) {
2340
+ const hasWishlist = await this.wishlistRepository
2341
+ .find({
2342
+ filters: {
2343
+ personId,
2344
+ },
2345
+ options: {
2346
+ enableCount: false,
2347
+ },
2348
+ orderBy: {
2349
+ id: 'asc',
2350
+ },
2351
+ })
2352
+ .then((res) => res.data);
2353
+ return hasWishlist.length ? hasWishlist.at(0) : null;
2354
+ }
2355
+ async createNewWishlist(data) {
2356
+ const newWishlist = await this.wishlistRepository.create(data);
2357
+ await this.wishlistRepository.update({ id: newWishlist.id, slug: newWishlist.id });
2358
+ return Wishlist.toInstance({ ...newWishlist.toPlain(), slug: newWishlist.id });
2359
+ }
2360
+ async update({ id, title, description, published, userFullName, userPhoto, theme, bannerUrl, personType, personIsSubscriber, }) {
2361
+ const data = {
2362
+ id,
2363
+ name: title,
2364
+ description,
2365
+ published,
2366
+ metadatas: [
2367
+ {
2368
+ shop: this.shop,
2369
+ title: `${userFullName} - ${title}`,
2370
+ description: `${userFullName} - ${description}`,
2371
+ },
2372
+ ],
2373
+ personName: userFullName,
2374
+ personPhoto: userPhoto,
2375
+ theme,
2376
+ bannerUrl,
2377
+ personType: personType ?? PersonTypes.NONE,
2378
+ personIsSubscriber: personIsSubscriber ?? false,
2379
+ };
2380
+ await this.createWishlistLog(WishlistLogType.UPDATE, data);
2381
+ return this.wishlistRepository.update(data);
2382
+ }
2383
+ async delete(wishlistId) {
2384
+ const wishlist = await this.findById(wishlistId);
2385
+ await this.createWishlistLog(WishlistLogType.DELETE, wishlist);
2386
+ return this.wishlistRepository.delete({ id: wishlistId });
2387
+ }
2388
+ getWishlistBySlug(slug) {
2389
+ const [id] = slug.split('-');
2390
+ if (+id)
2391
+ return this.wishlistRepository.get({ id });
2392
+ return this.wishlistRepository.getWishlistBySlug(slug);
2393
+ }
2394
+ getWishlistsByPerson(personId) {
2395
+ return this.wishlistRepository.getWishlistByPerson(personId);
2396
+ }
2397
+ async addProduct(wishlistId, productId) {
2398
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
2399
+ const hasProduct = wishlist.products.some((p) => p == productId);
2400
+ const wishlistData = await this.findById(wishlistId);
2401
+ const productData = await this.findProductById(productId);
2402
+ await this.createWishlistLog(WishlistLogType.ADD_PRODUCT, wishlistData, productData);
2403
+ if (!hasProduct) {
2404
+ wishlist.products = [...wishlist.products, productId];
2405
+ await this.wishlistRepository.addProduct(wishlistId, productId);
2406
+ }
2407
+ return wishlist;
2408
+ }
2409
+ async removeProduct(wishlistId, productId) {
2410
+ const wishlist = await this.wishlistRepository.get({ id: wishlistId });
2411
+ const productIndex = wishlist.products.findIndex((p) => p == productId);
2412
+ if (productIndex != -1) {
2413
+ wishlist.products.splice(productIndex, 1);
2414
+ const wishlistData = await this.findById(wishlistId);
2415
+ const productData = await this.findProductById(productId);
2416
+ await this.createWishlistLog(WishlistLogType.REMOVE_PRODUCT, wishlistData, productData);
2417
+ await this.wishlistRepository.removeProduct(wishlistId, productId);
2418
+ }
2419
+ return wishlist;
2420
+ }
2421
+ async findById(id) {
2422
+ return this.wishlistRepository
2423
+ .find({
2424
+ fields: ['id', 'name', 'description', 'personId', 'personIsSubscriber', 'personType', 'personName'],
2425
+ filters: {
2426
+ id,
2427
+ },
2428
+ })
2429
+ .then((res) => res.data.at(0));
2430
+ }
2431
+ async findProductById(id) {
2432
+ return this.productRepository
2433
+ .find({
2434
+ fields: ['id', 'sku', 'EAN', 'name', 'brand'],
2435
+ filters: {
2436
+ id,
2437
+ },
2438
+ })
2439
+ .then((res) => res.data.at(0));
2440
+ }
2441
+ async createWishlistLog(type, wishlist, product) {
2442
+ switch (type) {
2443
+ case WishlistLogType.CREATE:
2444
+ case WishlistLogType.UPDATE:
2445
+ case WishlistLogType.DELETE:
2446
+ await this.createWishlistOperationLog(type, wishlist);
2447
+ break;
2448
+ case WishlistLogType.ADD_PRODUCT:
2449
+ case WishlistLogType.REMOVE_PRODUCT:
2450
+ await this.createWishlistProductLog(type, wishlist, product);
2451
+ break;
2452
+ default:
2453
+ break;
2454
+ }
2455
+ }
2456
+ async createWishlistOperationLog(type, wishlist) {
2457
+ const operation = this.getOperationTypeFromWishlistLogType(type);
2458
+ await this.logRepository.create({
2459
+ collection: 'wishlist',
2460
+ date: new Date(),
2461
+ operation,
2462
+ documentId: wishlist.id,
2463
+ document: this.buildWishlistLogDocument(wishlist, type),
2464
+ });
2465
+ }
2466
+ async createWishlistProductLog(type, wishlist, product) {
2467
+ await this.logRepository.create({
2468
+ collection: 'wishlist',
2469
+ date: new Date(),
2470
+ operation: 'UPDATE',
2471
+ documentId: wishlist.id,
2472
+ document: {
2473
+ ...this.buildWishlistLogDocument(wishlist, type),
2474
+ ...this.buildProductLogData(product),
2475
+ },
2476
+ });
2477
+ }
2478
+ getOperationTypeFromWishlistLogType(type) {
2479
+ if (type === WishlistLogType.CREATE)
2480
+ return 'CREATE';
2481
+ if (type === WishlistLogType.UPDATE)
2482
+ return 'UPDATE';
2483
+ return 'DELETE';
2484
+ }
2485
+ buildWishlistLogDocument(wishlist, type) {
2486
+ return {
2487
+ id: wishlist.id,
2488
+ shop: this.shop,
2489
+ name: wishlist.name,
2490
+ description: wishlist.description,
2491
+ published: wishlist.published,
2492
+ type: type,
2493
+ personType: wishlist.personType,
2494
+ personId: wishlist.personId,
2495
+ personName: wishlist.personName,
2496
+ personIsSubscriber: wishlist.personIsSubscriber,
2497
+ };
2498
+ }
2499
+ buildProductLogData(product) {
2500
+ return {
2501
+ productId: product.id,
2502
+ productEAN: product.EAN,
2503
+ productSKU: product.sku,
2504
+ productName: product.name,
2505
+ productBrand: product.brand,
2506
+ };
2507
+ }
2508
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, deps: [{ token: 'WishlistRepository' }, { token: 'ProductRepository' }, { token: 'LogRepository' }, { token: DEFAULT_SHOP }], target: i0.ɵɵFactoryTarget.Injectable }); }
2509
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService }); }
2510
+ }
2511
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: WishlistService, decorators: [{
2512
+ type: Injectable
2513
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2514
+ type: Inject,
2515
+ args: ['WishlistRepository']
2516
+ }] }, { type: undefined, decorators: [{
2517
+ type: Inject,
2518
+ args: ['ProductRepository']
2519
+ }] }, { type: undefined, decorators: [{
2520
+ type: Inject,
2521
+ args: ['LogRepository']
2522
+ }] }, { type: i3.Shops, decorators: [{
2523
+ type: Inject,
2524
+ args: [DEFAULT_SHOP]
2525
+ }] }] });
2526
+
2527
+ class CouponRepositoriesFacade {
2528
+ constructor(couponRepository, orderRepository, categoryRepository) {
2529
+ this.couponRepository = couponRepository;
2530
+ this.orderRepository = orderRepository;
2531
+ this.categoryRepository = categoryRepository;
2532
+ }
2533
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponRepositoriesFacade, deps: [{ token: 'CouponRepository' }, { token: 'OrderRepository' }, { token: 'CategoryRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
2534
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponRepositoriesFacade }); }
2535
+ }
2536
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponRepositoriesFacade, decorators: [{
2537
+ type: Injectable
2538
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2539
+ type: Inject,
2540
+ args: ['CouponRepository']
2541
+ }] }, { type: undefined, decorators: [{
2542
+ type: Inject,
2543
+ args: ['OrderRepository']
2544
+ }] }, { type: undefined, decorators: [{
2545
+ type: Inject,
2546
+ args: ['CategoryRepository']
2547
+ }] }] });
2548
+
2549
+ class CouponService {
2550
+ constructor(repositoriesFacade, configurationFacade) {
2551
+ this.repositoriesFacade = repositoriesFacade;
2552
+ this.configurationFacade = configurationFacade;
2553
+ this.emailIsFromCollaborator = (userEmail) => !!userEmail?.match(/@b4a.com.br/g);
2554
+ }
2555
+ checkCoupon(params) {
2556
+ const { nickname, checkoutType, checkout, plan } = params;
2557
+ return from(this.repositoriesFacade.couponRepository
2558
+ .find({
2559
+ filters: {
2560
+ nickname: { operator: Where.EQUALS, value: nickname },
2561
+ active: { operator: Where.EQUALS, value: true },
2562
+ },
2563
+ })
2564
+ .then((result) => result.data[0])).pipe(concatMap((coupon) => this.couponValidation(coupon, checkoutType)), concatMap((couponValid) => this.couponRulesValidation({ coupon: couponValid, checkoutType, checkout, plan })), map((couponValidated) => couponValidated));
2565
+ }
2566
+ async couponValidation(coupon, checkoutType) {
2567
+ if (!coupon)
2568
+ throw 'Cupom inválido.';
2569
+ if (coupon?.beginAt && coupon?.beginAt.getTime() > new Date().getTime())
2570
+ throw 'Cupom inválido.';
2571
+ if (coupon?.expiresIn && (coupon?.expiresIn).getTime() < new Date().getTime())
2572
+ throw 'Cupom expirado.';
2573
+ const isInShop = coupon.shopAvailability === Shops.ALL || coupon.shopAvailability === this.configurationFacade.defaultShop;
2574
+ if (!isInShop)
2575
+ throw 'Cupom inválido para loja.';
2576
+ const isCheckoutType = coupon.checkoutType === CheckoutTypes.ALL || coupon.checkoutType === checkoutType;
2577
+ if (!isCheckoutType)
2578
+ throw 'Cupom inválido. Erro de checkout.';
2579
+ return coupon;
2580
+ }
2581
+ async couponRulesValidation(params) {
2582
+ const { coupon, checkoutType, checkout, plan } = params;
2583
+ if (checkoutType == CheckoutTypes.SUBSCRIPTION) {
2584
+ return this.validateSubscriptionCoupon(coupon, plan);
2585
+ }
2586
+ return this.validateEcommerceCoupon(coupon, checkoutType, checkout);
2587
+ }
2588
+ validateSubscriptionCoupon(coupon, plan) {
2589
+ if (coupon.plan && coupon.plan.toUpperCase() !== plan.toUpperCase()) {
2590
+ throw 'Cupom inválido para sua assinatura.';
2591
+ }
2592
+ return coupon;
2593
+ }
2594
+ async validateEcommerceCoupon(coupon, checkoutType, checkout) {
2595
+ this.validateUserEligibility(coupon, checkout?.user);
2596
+ await this.validateUsageLimits(coupon, checkoutType, checkout);
2597
+ await this.validateProductEligibility(coupon, checkout);
2598
+ return coupon;
2599
+ }
2600
+ validateUserEligibility(coupon, user) {
2601
+ const validUser = this.coupomUserValidation(coupon, user);
2602
+ if (!validUser)
2603
+ throw 'Usuário não elegível.';
2604
+ }
2605
+ async validateUsageLimits(coupon, checkoutType, checkout) {
2606
+ const couponUseLimits = this.getCouponUseLimits(coupon, checkoutType, checkout.user);
2607
+ if (couponUseLimits.firstOrder) {
2608
+ await this.validateFirstOrderLimit(checkout.user.email);
2609
+ }
2610
+ if (!couponUseLimits.unlimited || couponUseLimits.limitedPerUser) {
2611
+ await this.validateCouponUsageLimits(coupon, couponUseLimits, checkout.user.email);
2612
+ }
2613
+ }
2614
+ async validateFirstOrderLimit(userEmail) {
2615
+ const ordersUser = await this.getOrdersFromUser(userEmail.toLocaleLowerCase());
2616
+ if (ordersUser.length >= 1)
2617
+ throw 'Limite de uso atingido';
2618
+ }
2619
+ async validateCouponUsageLimits(coupon, couponUseLimits, userEmail) {
2620
+ const ordersCoupon = await this.getOrdersWithCoupon(coupon);
2621
+ if (!couponUseLimits.unlimited && couponUseLimits.total && ordersCoupon.length >= couponUseLimits.total) {
2622
+ throw 'Limite de uso atingido.';
2623
+ }
2624
+ if (couponUseLimits.limitedPerUser) {
2625
+ const ordersWithUser = this.countOrdersWithUser(ordersCoupon, userEmail);
2626
+ if (ordersWithUser > 0)
2627
+ throw 'Limite de uso por usuário atingido.';
2628
+ }
2629
+ }
2630
+ async validateProductEligibility(coupon, checkout) {
2631
+ const hasProductCategories = await this.hasProductCategories(coupon, checkout);
2632
+ if (!hasProductCategories)
2633
+ throw 'Seu carrinho não possui produtos elegíveis para desconto.';
2634
+ const hasMinSubTotal = await this.hasMinSubTotal(coupon, checkout);
2635
+ if (!hasMinSubTotal) {
2636
+ this.throwMinSubTotalError(coupon);
2637
+ }
2638
+ }
2639
+ throwMinSubTotalError(coupon) {
2640
+ const formattedValue = Intl.NumberFormat('pt-BR', {
2641
+ style: 'currency',
2642
+ currency: 'BRL',
2643
+ }).format(coupon.minSubTotalValue);
2644
+ if (coupon.productsCategories?.length) {
2645
+ throw `Valor mínimo de ${formattedValue} não atingido na(s) categoria(s) elegíveis para o desconto.`;
2646
+ }
2647
+ throw `Valor mínimo de ${formattedValue} não atingido.`;
2648
+ }
2649
+ calcDiscountSubscription(coupon, checkout) {
2650
+ let discount = 0;
2651
+ if (coupon.discount.subscription.type == CouponTypes.ABSOLUTE)
2652
+ discount = coupon.discount.subscription.value;
2653
+ else
2654
+ discount = checkout.subscriptionPlan.recurrencePrice * (coupon.discount.subscription.value / 100);
2655
+ return of(discount);
2656
+ }
2657
+ async hasMinSubTotal(coupon, checkout) {
2658
+ if (!coupon.minSubTotalValue)
2659
+ return true;
2660
+ const lineItensDiscount = await this.getLineItensEligebleForDiscount(coupon.productsCategories, checkout);
2661
+ const subTotal = this.calcCheckoutSubtotal(lineItensDiscount, checkout.user);
2662
+ if (coupon.minSubTotalValue <= subTotal)
2663
+ return true;
2664
+ return false;
2665
+ }
2666
+ async hasProductCategories(coupon, checkout) {
2667
+ if (!coupon.productsCategories?.length) {
2668
+ return true;
2669
+ }
2670
+ const couponCategories = await this.getCouponCategoriesId(coupon.productsCategories);
2671
+ const hasCategories = checkout.lineItems?.filter((item) => {
2672
+ if (item.isGift)
2673
+ return false;
2674
+ if (!item.categories?.length)
2675
+ return true;
2676
+ return item.categories.some((c) => couponCategories.some((cat) => cat == c));
2677
+ });
2678
+ return hasCategories?.length ? true : false;
2679
+ }
2680
+ coupomUserValidation(coupon, user) {
2681
+ if (!user || coupon.exclusivityType.includes(Exclusivities.ALL_USERS))
2682
+ return true;
2683
+ const userTypes = [];
2684
+ if (coupon.exclusivityType.includes(Exclusivities.COLLABORATORS) &&
2685
+ this.emailIsFromCollaborator(user.email.toLocaleLowerCase()))
2686
+ userTypes.push(Exclusivities.COLLABORATORS);
2687
+ if (coupon.exclusivityType.includes(Exclusivities.SPECIFIC_USER) &&
2688
+ coupon.userExclusiveEmail.includes(user.email.toLocaleLowerCase()))
2689
+ userTypes.push(Exclusivities.SPECIFIC_USER);
2690
+ if (coupon.exclusivityType.includes(Exclusivities.ACTIVE_SUBSCRIBER) &&
2691
+ user.isSubscriber &&
2692
+ user.subscriptionPlan != '')
2693
+ userTypes.push(Exclusivities.ACTIVE_SUBSCRIBER);
2694
+ if (user.isSubscriber &&
2695
+ user.subscriptionPlan == '' &&
2696
+ coupon.exclusivityType.includes(Exclusivities.INACTIVE_SUBSCRIBER))
2697
+ userTypes.push(Exclusivities.INACTIVE_SUBSCRIBER);
2698
+ if (coupon.exclusivityType.includes(Exclusivities.NON_SUBSCRIBER) && !user.isSubscriber)
2699
+ userTypes.push(Exclusivities.NON_SUBSCRIBER);
2700
+ return coupon.exclusivityType.some((r) => userTypes.includes(r));
2701
+ }
2702
+ async getCouponCategoriesId(productsCategories) {
2703
+ const couponCategories = [];
2704
+ for (let index = 0; index < productsCategories.length; index++) {
2705
+ const category = await this.repositoriesFacade.categoryRepository.get({
2706
+ id: productsCategories[index],
2707
+ });
2708
+ if (category) {
2709
+ const children = await this.repositoriesFacade.categoryRepository.getChildren(parseInt(productsCategories[index]));
2710
+ couponCategories.push(category.id, ...children.map((c) => c.id.toString()));
2711
+ }
2712
+ }
2713
+ return [...new Set(couponCategories)];
2714
+ }
2715
+ async getLineItensEligebleForDiscount(productsCategories, checkout) {
2716
+ let lineItensDiscount = [];
2717
+ const couponCategories = await this.getCouponCategoriesId(productsCategories);
2718
+ if (productsCategories?.length) {
2719
+ lineItensDiscount = checkout.lineItems?.filter((item) => {
2720
+ if (item.isGift)
2721
+ return false;
2722
+ if (item.categories?.length) {
2723
+ return item.categories.some((c) => couponCategories.some((cat) => cat == c));
2724
+ }
2725
+ return true;
2726
+ });
2727
+ }
2728
+ else {
2729
+ lineItensDiscount = checkout.lineItems.filter((item) => !item.isGift);
2730
+ }
2731
+ return lineItensDiscount;
2732
+ }
2733
+ calcCheckoutSubtotal(lineItens, user) {
2734
+ return (lineItens
2735
+ ?.filter((item) => !item.isGift)
2736
+ .reduce((acc, curr) => user?.isSubscriber && curr.price?.subscriberPrice
2737
+ ? acc + curr.price?.subscriberPrice * curr.quantity
2738
+ : acc + curr.pricePaid * curr.quantity, 0) || 0);
2739
+ }
2740
+ async getOrdersWithCoupon(coupon) {
2741
+ return await this.repositoriesFacade.orderRepository
2742
+ .find({
2743
+ filters: {
2744
+ coupon: { id: coupon.id },
2745
+ status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
2746
+ },
2747
+ })
2748
+ .then((result) => result.data);
2749
+ }
2750
+ async getOrdersFromUser(email) {
2751
+ return await this.repositoriesFacade.orderRepository
2752
+ .find({
2753
+ filters: {
2754
+ user: { email: { operator: Where.EQUALS, value: email } },
2755
+ status: { operator: Where.NOTEQUALS, value: OrderStatus.CANCELADO },
2756
+ },
2757
+ })
2758
+ .then((result) => result.data);
2759
+ }
2760
+ countOrdersWithUser(orders, email) {
2761
+ return orders.filter((o) => o.user.email == email).length;
2762
+ }
2763
+ getCouponUseLimits(coupon, checkoutType, user) {
2764
+ let couponUseLimits;
2765
+ if (checkoutType == CheckoutTypes.ECOMMERCE || checkoutType == CheckoutTypes.ALL) {
2766
+ if (coupon.exclusivityType.length === 1 &&
2767
+ (coupon.exclusivityType.at(0) === Exclusivities.SPECIFIC_USER ||
2768
+ coupon.exclusivityType.at(0) === Exclusivities.COLLABORATORS))
2769
+ couponUseLimits = coupon.useLimits.non_subscriber;
2770
+ else
2771
+ couponUseLimits = user?.isSubscriber ? coupon.useLimits.subscriber : coupon.useLimits.non_subscriber;
2772
+ }
2773
+ else {
2774
+ couponUseLimits = coupon.useLimits.subscription;
2775
+ }
2776
+ return couponUseLimits;
2777
+ }
2778
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, deps: [{ token: CouponRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
2779
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, providedIn: 'root' }); }
2780
+ }
2781
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CouponService, decorators: [{
2782
+ type: Injectable,
2783
+ args: [{
2784
+ providedIn: 'root',
2785
+ }]
2786
+ }], ctorParameters: () => [{ type: CouponRepositoriesFacade }, { type: ConfigurationFacade }] });
2787
+
2788
+ class CheckoutSubscriptionService {
2789
+ constructor(checkoutSubscriptionRepository, dataPersistence, couponService) {
2790
+ this.checkoutSubscriptionRepository = checkoutSubscriptionRepository;
2791
+ this.dataPersistence = dataPersistence;
2792
+ this.couponService = couponService;
2793
+ }
2794
+ getCheckoutSubscription(checkoutData) {
2795
+ return this.dataPersistence
2796
+ .get('checkoutSubscriptionId')
2797
+ .pipe(concatMap((id) => !isNil(id) ? this.checkoutSubscriptionRepository.get({ id }) : this.createCheckoutSubscription(checkoutData)));
2798
+ }
2799
+ clearCheckoutSubscriptionFromSession() {
2800
+ return this.dataPersistence.remove('checkoutSubscriptionId');
2801
+ }
2802
+ checkCoupon(nickname, _userEmail) {
2803
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService
2804
+ .checkCoupon({
2805
+ nickname,
2806
+ checkoutType: CheckoutTypes.SUBSCRIPTION,
2807
+ checkout,
2808
+ plan: checkout.subscriptionPlan.name,
2809
+ })
2810
+ .pipe()));
2811
+ }
2812
+ calcDiscountSubscription(coupon) {
2813
+ return this.getCheckoutSubscription().pipe(concatMap((checkout) => this.couponService.calcDiscountSubscription(coupon, checkout).pipe()));
2814
+ }
2815
+ async createCheckoutSubscription(checkoutData) {
2816
+ const checkout = await this.checkoutSubscriptionRepository.create({
2817
+ createdAt: new Date(),
2818
+ ...CheckoutSubscription.toInstance(pick(checkoutData, ['user', 'shop'])).toPlain(),
2819
+ });
2820
+ await this.dataPersistence.set('checkoutSubscriptionId', checkout.id).toPromise();
2821
+ return checkout;
2822
+ }
2823
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, deps: [{ token: 'CheckoutSubscriptionRepository' }, { token: PERSISTENCE_PROVIDER }, { token: CouponService }], target: i0.ɵɵFactoryTarget.Injectable }); }
2824
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService }); }
2825
+ }
2826
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: CheckoutSubscriptionService, decorators: [{
2827
+ type: Injectable
2828
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2829
+ type: Inject,
2830
+ args: ['CheckoutSubscriptionRepository']
2831
+ }] }, { type: undefined, decorators: [{
2832
+ type: Inject,
2833
+ args: [PERSISTENCE_PROVIDER]
2834
+ }] }, { type: CouponService }] });
2835
+
2836
+ class UtilHelper {
2837
+ static createSlug(name) {
2838
+ return name
2839
+ .toLowerCase()
2840
+ .replace(/\s+/g, '-')
2841
+ .replace(/[ãàáäâ]/g, 'a')
2842
+ .replace(/[ẽèéëê]/g, 'e')
2843
+ .replace(/[ìíïî]/g, 'i')
2844
+ .replace(/[õòóöô]/g, 'o')
2845
+ .replace(/[ùúüû]/g, 'u')
2846
+ .replace(/[ñ]/g, 'n')
2847
+ .replace(/[ç]/g, 'c')
2848
+ .replace(/[&]/g, 'and')
2849
+ .replace(/[^\w-]+/g, '')
2850
+ .replace(/--+/g, '-');
2851
+ }
2852
+ }
2853
+
2854
+ class HomeShopRepositoriesFacade {
2855
+ constructor(categoryRepository, homeRepository, productRepository) {
2856
+ this.categoryRepository = categoryRepository;
2857
+ this.homeRepository = homeRepository;
2858
+ this.productRepository = productRepository;
2859
+ }
2860
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopRepositoriesFacade, deps: [{ token: 'CategoryRepository' }, { token: 'HomeRepository' }, { token: 'ProductRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
2861
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopRepositoriesFacade }); }
2862
+ }
2863
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopRepositoriesFacade, decorators: [{
2864
+ type: Injectable
2865
+ }], ctorParameters: () => [{ type: undefined, decorators: [{
2866
+ type: Inject,
2867
+ args: ['CategoryRepository']
2868
+ }] }, { type: undefined, decorators: [{
2869
+ type: Inject,
2870
+ args: ['HomeRepository']
2871
+ }] }, { type: undefined, decorators: [{
2872
+ type: Inject,
2873
+ args: ['ProductRepository']
2874
+ }] }] });
2875
+
2876
+ class HomeShopService {
2877
+ get homeId() {
2878
+ if (this.configurationFacade.defaultShop === Shops.GLAMSHOP)
2879
+ return 'glamshop';
2880
+ if (this.configurationFacade.defaultShop === Shops.MENSMARKET)
2881
+ return 'mens_market';
2882
+ return null;
2883
+ }
2884
+ constructor(repositoriesFacade, configurationFacade) {
2885
+ this.repositoriesFacade = repositoriesFacade;
2886
+ this.configurationFacade = configurationFacade;
2887
+ this.buildCategoryGroupWithRequiredData = (group) => ({
2888
+ category: Category.toInstance(pick(group?.category?.toPlain() || {}, ['id', 'name', 'slug', 'conditions'])),
2889
+ products: group?.products?.map((product) => Product.toInstance(pick(product?.toPlain() || {}, [
2890
+ 'id',
2891
+ 'price',
2892
+ 'reviews',
2893
+ 'hasVariants',
2894
+ 'slug',
2895
+ 'sku',
2896
+ 'stock',
2897
+ 'costPrice',
2898
+ 'images',
2899
+ 'miniatures',
2900
+ 'name',
2901
+ 'weight',
2902
+ 'rate',
2903
+ 'type',
2904
+ 'brand',
2905
+ ]))) || [],
2906
+ });
2907
+ }
2908
+ getHomeData() {
2909
+ return this.getHomeConfiguration().pipe(map((home) => (home?.data?.expiresAt > new Date() ? home : null)), concatMap((home) => home
2910
+ ? of(home)
2911
+ : forkJoin([
2912
+ this.getDiscoverProducts(this.gender),
2913
+ this.getFeaturedProducts(this.gender),
2914
+ this.getVerticalProducts(this.gender),
2915
+ ]).pipe(map(([discoverProducts, featuredProducts, verticalProducts]) => ({
2916
+ discoverProducts,
2917
+ featuredProducts,
2918
+ verticalProducts,
2919
+ })), concatMap((data) => this.saveHomeData(data)))));
2920
+ }
2921
+ getBanners(type) {
2922
+ return this.getHomeConfiguration().pipe(map((home) => {
2923
+ if (type === 'brand')
2924
+ return home.brandsCarousel;
2925
+ if (type === 'buyToWin')
2926
+ return [home.buyToWinBanner];
2927
+ if (type === 'block')
2928
+ return home.blockBanners;
2929
+ if (type === 'blog')
2930
+ return [home.blogBanner];
2931
+ return [];
2932
+ }));
2933
+ }
2934
+ getMinValueForFreeShipping() {
2935
+ return this.getHomeConfiguration().pipe(map((home) => home.minValueForFreeShipping));
2936
+ }
2937
+ getDiscoverProducts(_gender) {
2938
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
2939
+ categoryIds: home.discoverCategories,
2940
+ shop: this.configurationFacade.defaultShop,
2941
+ })).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2942
+ }
2943
+ getFeaturedProducts(_gender) {
2944
+ return this.getHomeConfiguration().pipe(concatMap((home) => from(this.repositoriesFacade.categoryRepository.getCategoriesForHome({
2945
+ categoryIds: home.featuredCategories,
2946
+ shop: this.configurationFacade.defaultShop,
2947
+ })).pipe(map((groups) => groups.map(this.buildCategoryGroupWithRequiredData)))));
2948
+ }
2949
+ getVerticalProducts(gender) {
2950
+ return this.getHomeConfiguration().pipe(concatMap((home) => forkJoin(home.verticalCarousels.filter(Boolean).map((id) => from(this.repositoriesFacade.categoryRepository.get({ id })).pipe(concatMap((category) => from(this.repositoriesFacade.productRepository.find({
2951
+ filters: {
2952
+ categories: { operator: Where.IN, value: [category.id] },
2953
+ ...(gender ? { tags: { operator: Where.IN, value: [gender] } } : {}),
2954
+ },
2955
+ limits: { limit: 12 },
2956
+ })).pipe(map((products) => ({ category, products })))), map(({ category, products }) => ({ category, products: products.data })), map(this.buildCategoryGroupWithRequiredData))))));
2957
+ }
2958
+ getHomeConfiguration() {
2959
+ return of(this.homeConfiguration).pipe(concatMap((home) => home
2960
+ ? of(home)
2961
+ : !this.homeId
2962
+ ? throwError(() => new RequiredArgumentError(['homeId']))
2963
+ : from(this.repositoriesFacade.homeRepository.get({ id: this.homeId })).pipe(tap((homeLoaded) => (this.homeConfiguration = homeLoaded)))));
2964
+ }
2965
+ saveHomeData(homeData) {
2966
+ const data = {
2967
+ createdAt: new Date(),
2968
+ expiresAt: add(new Date(), { hours: 1 }),
2969
+ data: homeData,
2970
+ };
2971
+ return from(this.repositoriesFacade.homeRepository.update({
2972
+ id: this.homeId,
2973
+ data,
2974
+ })).pipe(tap(() => (this.homeConfiguration.data = data)), map(() => this.homeConfiguration));
2975
+ }
2976
+ get gender() {
2977
+ return this.homeId === 'mens_market' ? 'masculino' : undefined;
2978
+ }
2979
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopService, deps: [{ token: HomeShopRepositoriesFacade }, { token: ConfigurationFacade }], target: i0.ɵɵFactoryTarget.Injectable }); }
2980
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopService }); }
2981
+ }
2982
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: HomeShopService, decorators: [{
2983
+ type: Injectable
2984
+ }], ctorParameters: () => [{ type: HomeShopRepositoriesFacade }, { type: ConfigurationFacade }] });
2985
+
2986
+ class OrderProductReviewService {
2987
+ constructor(orderRepository, productReviewRepository) {
2988
+ this.orderRepository = orderRepository;
2989
+ this.productReviewRepository = productReviewRepository;
2990
+ }
2991
+ async getPendingReviewsByEmail(email) {
2992
+ const products = [];
2993
+ const { data: orders } = await this.orderRepository.find({
2994
+ filters: {
2995
+ user: {
2996
+ email: email,
2997
+ },
2998
+ status: OrderStatus.ENTREGUE,
2999
+ },
3000
+ orderBy: {
3001
+ createdAt: 'desc',
3002
+ },
3003
+ });
3004
+ if (orders.length) {
3005
+ for (const order of orders) {
3006
+ const lineItems = order.lineItems.filter((item) => !item.isGift);
3007
+ for (const item of lineItems) {
3008
+ const productReview = await this.productReviewRepository
3009
+ .find({
3010
+ filters: {
3011
+ orderId: order.id,
3012
+ productId: item.id,
3013
+ status: { operator: Where.ISNULL },
3014
+ },
3015
+ })
3016
+ .then((res) => res.data.at(0));
3017
+ products.push(this.buildProductReview(order, item, productReview));
3018
+ }
3019
+ }
3020
+ }
3021
+ return products;
3022
+ }
3023
+ buildProductReview(order, item, review) {
3024
+ return {
3025
+ id: item.id,
3026
+ orderNumber: order.orderNumber ?? order.id,
3027
+ isEdition: false,
3028
+ name: item.name,
3029
+ image: item.image,
3030
+ deliveryDate: order.deliveredAt || null,
3031
+ evaluationInAnalysis: review ? true : false,
3032
+ shopProductSlug: item.slug,
3033
+ };
3034
+ }
3035
+ async createReview(review) {
3036
+ return this.productReviewRepository.create(ProductReview.toInstance({
3037
+ productId: review.productId.toString(),
3038
+ shop: review.shop,
3039
+ rate: review.rate,
3040
+ author: review.author,
3041
+ email: review.email,
3042
+ location: review.location,
3043
+ review: review.comment,
3044
+ title: review.title,
3045
+ personId: review.personId,
3046
+ points: review.points,
3047
+ orderId: review.orderId,
3048
+ }));
3049
+ }
3050
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderProductReviewService, deps: [{ token: 'OrderRepository' }, { token: 'ProductReviewRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
3051
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderProductReviewService }); }
3052
+ }
3053
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderProductReviewService, decorators: [{
3054
+ type: Injectable
3055
+ }], ctorParameters: () => [{ type: i3.OrderFirestoreRepository, decorators: [{
3056
+ type: Inject,
3057
+ args: ['OrderRepository']
3058
+ }] }, { type: undefined, decorators: [{
3059
+ type: Inject,
3060
+ args: ['ProductReviewRepository']
3061
+ }] }] });
3062
+
3063
+ class OrderService {
3064
+ constructor(angularFirestore, orderRepository) {
3065
+ this.angularFirestore = angularFirestore;
3066
+ this.orderRepository = orderRepository;
3067
+ this.orderSubject = new Subject();
3068
+ }
3069
+ getOrder(id) {
3070
+ docSnapshots(doc(this.angularFirestore, `${this.orderRepository.collectionName}/${id}`))
3071
+ .pipe(map((doc) => Order.toInstance(doc.data())))
3072
+ .subscribe((doc) => this.orderSubject.next(doc));
3073
+ return this.orderSubject;
3074
+ }
3075
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderService, deps: [{ token: i1$1.Firestore }, { token: 'OrderRepository' }], target: i0.ɵɵFactoryTarget.Injectable }); }
3076
+ static { this.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderService }); }
3077
+ }
3078
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: OrderService, decorators: [{
3079
+ type: Injectable
3080
+ }], ctorParameters: () => [{ type: i1$1.Firestore }, { type: i3.OrderFirestoreRepository, decorators: [{
3081
+ type: Inject,
3082
+ args: ['OrderRepository']
3083
+ }] }] });
3084
+
3085
+ class AngularConnectModule {
3086
+ static initializeApp(defaultShop, options, nameOrConfig) {
3087
+ return {
3088
+ ngModule: AngularConnectModule,
3089
+ providers: [
3090
+ ...this.buildCoreProviders(nameOrConfig, options),
3091
+ ...this.buildConditionalProviders(defaultShop, options),
3092
+ ],
3093
+ };
3094
+ }
3095
+ static buildCoreProviders(nameOrConfig, options) {
3096
+ return [
3097
+ { provide: FIREBASE_APP_NAME, useValue: nameOrConfig },
3098
+ { provide: APP_CHECK_PROVIDER, useValue: options.appCheckProvider },
3099
+ {
3100
+ provide: CATEGORY_STRUCTURE,
3101
+ useClass: this.selectCategoryStructureAdapter(options.oldCategoryStructure),
3102
+ },
3103
+ { provide: PERSISTENCE_PROVIDER, useClass: options?.persistenceProvider || CookieDataPersistence },
3104
+ ];
3105
+ }
3106
+ static buildConditionalProviders(defaultShop, options) {
3107
+ return [
3108
+ ...this.createProviderIfExists(DEFAULT_SHOP, defaultShop),
3109
+ ...this.createProviderIfExists(FIREBASE_OPTIONS, options.firebase),
3110
+ ...this.createProviderIfExists(ES_CONFIG, options.elasticSearch),
3111
+ ...this.createProviderIfExists(VERTEX_CONFIG, options.vertexConfig),
3112
+ ...this.createProviderIfExists(HASURA_OPTIONS, options.hasura),
3113
+ ...this.createProviderIfExists(BACKEND_URL, options.backendUrl),
3114
+ ...this.createProviderIfExists(STORAGE_BASE_URL, options.storageBaseUrl),
3115
+ ];
3116
+ }
3117
+ static selectCategoryStructureAdapter(oldCategoryStructure) {
3118
+ return isNil(oldCategoryStructure) || oldCategoryStructure
3119
+ ? OldCategoryStructureAdapter
3120
+ : NewCategoryStructureAdapter;
3121
+ }
3122
+ static createProviderIfExists(token, value) {
3123
+ return isNil(value) ? [] : [{ provide: token, useValue: value }];
3124
+ }
3125
+ static { this.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule }); }
3126
+ static { this.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, imports: [i1$3.FirebaseAppModule, i2.AppCheckModule, i3$1.StorageModule, AngularElasticSeachModule,
3127
+ AngularVertexSeachModule,
3128
+ AngularFirebaseAuthModule,
3129
+ AngularFirestoreModule,
3130
+ AngularHasuraGraphQLModule] }); }
3131
+ static { this.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, providers: [
3132
+ AuthService,
3133
+ CartService,
3134
+ CatalogService,
3135
+ CategoryService,
3136
+ CheckoutService,
3137
+ CheckoutSubscriptionService,
3138
+ CouponService,
3139
+ HomeShopService,
3140
+ OrderService,
3141
+ WishlistService,
3142
+ ConfigurationFacade,
3143
+ CartServicesFacade,
3144
+ CheckoutRepositoriesFacade,
3145
+ CheckoutDependenciesFacade,
3146
+ CategoryRepositoryFacade,
3147
+ ProductCatalogFacade,
3148
+ CatalogServiceFacade,
3149
+ CategoryServiceFacade,
3150
+ CatalogStrategiesFacade,
3151
+ CatalogOperationsFacade,
3152
+ ProductManagementFacade,
3153
+ {
3154
+ provide: 'ProductServicesFacade',
3155
+ useFactory: (productStockNotificationRepository, categoryRepository, productSearch) => ({
3156
+ productStockNotificationRepository,
3157
+ categoryRepository,
3158
+ productSearch,
3159
+ }),
3160
+ deps: ['ProductStockNotificationRepository', 'CategoryRepository', 'ProductSearch'],
3161
+ },
3162
+ CatalogFilterHelper,
3163
+ CatalogSortHelper,
3164
+ ProductFieldsHelper,
3165
+ BrandManagerHelper,
3166
+ CatalogRepositoryService,
3167
+ CatalogHelpersService,
3168
+ CategorySearchStrategy,
3169
+ TermSearchStrategy,
3170
+ ProfileSearchStrategy,
3171
+ {
3172
+ provide: CatalogSearchContext,
3173
+ useFactory: (categoryStrategy, termStrategy, profileStrategy) => {
3174
+ return new CatalogSearchContext(categoryStrategy, termStrategy, profileStrategy);
3175
+ },
3176
+ deps: [CategorySearchStrategy, TermSearchStrategy, ProfileSearchStrategy],
3177
+ },
3178
+ {
3179
+ provide: UpdateUserImage,
3180
+ useFactory: (userRepository, fileUploader) => {
3181
+ return new UpdateUserImage(userRepository, fileUploader);
3182
+ },
3183
+ deps: ['UserRepository', 'FileUploaderService'],
3184
+ },
3185
+ {
3186
+ provide: 'FileUploaderService',
3187
+ useFactory: (storage, baseUrl) => {
3188
+ return new FirebaseFileUploaderService(storage, baseUrl);
3189
+ },
3190
+ deps: [Storage, STORAGE_BASE_URL],
3191
+ },
3192
+ {
3193
+ provide: 'ProductSearch',
3194
+ useExisting: ProductsVertexSearch,
3195
+ },
3196
+ CouponRepositoriesFacade,
3197
+ HomeShopRepositoriesFacade,
3198
+ OrderProductReviewService,
3199
+ ], imports: [provideFirebaseApp((injector) => {
3200
+ const appName = injector.get(FIREBASE_APP_NAME);
3201
+ try {
3202
+ const app = appName ? getApp(appName) : getApp();
3203
+ return app;
3204
+ }
3205
+ catch (error) {
3206
+ console.warn('Firebase app not found, initializing new app');
3207
+ if (error instanceof Error)
3208
+ console.error(error.message);
3209
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
3210
+ }
3211
+ }),
3212
+ provideAppCheck((injector) => {
3213
+ const app = injector.get(FirebaseApp);
3214
+ try {
3215
+ const provider = injector.get(APP_CHECK_PROVIDER);
3216
+ if (provider)
3217
+ return initializeAppCheck(app, {
3218
+ provider,
3219
+ isTokenAutoRefreshEnabled: true,
3220
+ });
3221
+ }
3222
+ catch (error) {
3223
+ if (error instanceof Error)
3224
+ console.error(error.message);
3225
+ return;
3226
+ }
3227
+ }),
3228
+ provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
3229
+ AngularElasticSeachModule,
3230
+ AngularVertexSeachModule,
3231
+ AngularFirebaseAuthModule,
3232
+ AngularFirestoreModule,
3233
+ AngularHasuraGraphQLModule] }); }
3234
+ }
3235
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "17.0.3", ngImport: i0, type: AngularConnectModule, decorators: [{
3236
+ type: NgModule,
3237
+ args: [{
3238
+ imports: [
3239
+ provideFirebaseApp((injector) => {
3240
+ const appName = injector.get(FIREBASE_APP_NAME);
3241
+ try {
3242
+ const app = appName ? getApp(appName) : getApp();
3243
+ return app;
3244
+ }
3245
+ catch (error) {
3246
+ console.warn('Firebase app not found, initializing new app');
3247
+ if (error instanceof Error)
3248
+ console.error(error.message);
3249
+ return initializeApp(injector.get(FIREBASE_OPTIONS), appName);
3250
+ }
3251
+ }),
3252
+ provideAppCheck((injector) => {
3253
+ const app = injector.get(FirebaseApp);
3254
+ try {
3255
+ const provider = injector.get(APP_CHECK_PROVIDER);
3256
+ if (provider)
3257
+ return initializeAppCheck(app, {
3258
+ provider,
3259
+ isTokenAutoRefreshEnabled: true,
3260
+ });
3261
+ }
3262
+ catch (error) {
3263
+ if (error instanceof Error)
3264
+ console.error(error.message);
3265
+ return;
3266
+ }
3267
+ }),
3268
+ provideStorage((injector) => getStorage(injector.get(FirebaseApp))),
3269
+ AngularElasticSeachModule,
3270
+ AngularVertexSeachModule,
3271
+ AngularFirebaseAuthModule,
3272
+ AngularFirestoreModule,
3273
+ AngularHasuraGraphQLModule,
3274
+ ],
3275
+ providers: [
3276
+ AuthService,
3277
+ CartService,
3278
+ CatalogService,
3279
+ CategoryService,
3280
+ CheckoutService,
3281
+ CheckoutSubscriptionService,
3282
+ CouponService,
3283
+ HomeShopService,
3284
+ OrderService,
3285
+ WishlistService,
3286
+ ConfigurationFacade,
3287
+ CartServicesFacade,
3288
+ CheckoutRepositoriesFacade,
3289
+ CheckoutDependenciesFacade,
3290
+ CategoryRepositoryFacade,
3291
+ ProductCatalogFacade,
3292
+ CatalogServiceFacade,
3293
+ CategoryServiceFacade,
3294
+ CatalogStrategiesFacade,
3295
+ CatalogOperationsFacade,
3296
+ ProductManagementFacade,
3297
+ {
3298
+ provide: 'ProductServicesFacade',
3299
+ useFactory: (productStockNotificationRepository, categoryRepository, productSearch) => ({
3300
+ productStockNotificationRepository,
3301
+ categoryRepository,
3302
+ productSearch,
3303
+ }),
3304
+ deps: ['ProductStockNotificationRepository', 'CategoryRepository', 'ProductSearch'],
3305
+ },
3306
+ CatalogFilterHelper,
3307
+ CatalogSortHelper,
3308
+ ProductFieldsHelper,
3309
+ BrandManagerHelper,
3310
+ CatalogRepositoryService,
3311
+ CatalogHelpersService,
3312
+ CategorySearchStrategy,
3313
+ TermSearchStrategy,
3314
+ ProfileSearchStrategy,
3315
+ {
3316
+ provide: CatalogSearchContext,
3317
+ useFactory: (categoryStrategy, termStrategy, profileStrategy) => {
3318
+ return new CatalogSearchContext(categoryStrategy, termStrategy, profileStrategy);
3319
+ },
3320
+ deps: [CategorySearchStrategy, TermSearchStrategy, ProfileSearchStrategy],
3321
+ },
3322
+ {
3323
+ provide: UpdateUserImage,
3324
+ useFactory: (userRepository, fileUploader) => {
3325
+ return new UpdateUserImage(userRepository, fileUploader);
3326
+ },
3327
+ deps: ['UserRepository', 'FileUploaderService'],
3328
+ },
3329
+ {
3330
+ provide: 'FileUploaderService',
3331
+ useFactory: (storage, baseUrl) => {
3332
+ return new FirebaseFileUploaderService(storage, baseUrl);
3333
+ },
3334
+ deps: [Storage, STORAGE_BASE_URL],
3335
+ },
3336
+ {
3337
+ provide: 'ProductSearch',
3338
+ useExisting: ProductsVertexSearch,
3339
+ },
3340
+ CouponRepositoriesFacade,
3341
+ HomeShopRepositoriesFacade,
3342
+ OrderProductReviewService,
3343
+ ],
3344
+ }]
3345
+ }] });
3346
+
3347
+ /**
3348
+ * Generated bundle index. Do not edit.
3349
+ */
3350
+
3351
+ export { AngularConnectModule, AngularFirebaseAuthModule, AngularFirestoreModule, AngularHasuraGraphQLModule, AuthService, CartService, CatalogService, CategoryService, CategoryWithTree, CheckoutService, CheckoutSubscriptionService, CookieDataPersistence, CouponService, HomeShopService, NewCategoryStructureAdapter, OldCategoryStructureAdapter, OrderProductReviewService, OrderService, ProductSorts, UtilHelper, WishlistService };
3352
+ //# sourceMappingURL=infrab4a-connect-angular.mjs.map