@veloceapps/sdk 8.0.0-10 → 8.0.0-101

Sign up to get free protection for your applications and to get access to all the features.
Files changed (312) hide show
  1. package/README.md +0 -1
  2. package/cms/README.md +0 -20
  3. package/cms/cms.actions.d.ts +7 -1
  4. package/cms/components/preview/preview.component.d.ts +1 -2
  5. package/cms/index.d.ts +1 -0
  6. package/cms/modules/runtime/services/runtime.service.d.ts +1 -1
  7. package/cms/services/index.d.ts +0 -1
  8. package/cms/types/index.d.ts +0 -1
  9. package/cms/utils/element.utils.d.ts +1 -0
  10. package/cms/vendor-map.d.ts +21 -13
  11. package/core/README.md +20 -0
  12. package/core/modules/configuration/helpers.d.ts +2 -2
  13. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  14. package/core/modules/configuration/services/configuration.service.d.ts +6 -1
  15. package/core/pipes/action-code.pipe.d.ts +8 -0
  16. package/core/pipes/date.pipe.d.ts +2 -1
  17. package/core/pipes/index.d.ts +1 -0
  18. package/core/pipes/pipes.module.d.ts +2 -1
  19. package/core/services/context.service.d.ts +2 -0
  20. package/core/services/flow-info.service.d.ts +24 -0
  21. package/core/services/flow-state.service.d.ts +50 -0
  22. package/core/services/index.d.ts +3 -0
  23. package/core/services/quote-draft.service.d.ts +8 -1
  24. package/core/services/runtime-settings.service.d.ts +4 -1
  25. package/core/types/formatting-settings.types.d.ts +2 -0
  26. package/core/types/index.d.ts +2 -0
  27. package/{cms → core}/types/integration.types.d.ts +1 -0
  28. package/core/types/pipe.types.d.ts +1 -0
  29. package/esm2020/cms/cms.actions.mjs +15 -1
  30. package/esm2020/cms/components/element-children/element-children.component.mjs +3 -3
  31. package/esm2020/cms/components/element-children/element-children.module.mjs +4 -4
  32. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +3 -3
  33. package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +4 -4
  34. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +3 -3
  35. package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +4 -4
  36. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +5 -5
  37. package/esm2020/cms/components/plugin.component.mjs +3 -3
  38. package/esm2020/cms/components/preview/preview.component.mjs +9 -11
  39. package/esm2020/cms/components/preview/preview.module.mjs +6 -6
  40. package/esm2020/cms/directives/custom-template.directive.mjs +7 -7
  41. package/esm2020/cms/index.mjs +2 -1
  42. package/esm2020/cms/launcher.module.mjs +7 -7
  43. package/esm2020/cms/modules/federated/federated-host.directive.mjs +3 -3
  44. package/esm2020/cms/modules/federated/federated.component.mjs +3 -3
  45. package/esm2020/cms/modules/federated/federated.module.mjs +4 -4
  46. package/esm2020/cms/modules/migrations/migrations.module.mjs +4 -4
  47. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +3 -3
  48. package/esm2020/cms/modules/runtime/runtime.module.mjs +4 -4
  49. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +8 -4
  50. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +3 -3
  51. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +7 -7
  52. package/esm2020/cms/plugins/configuration.plugin.mjs +3 -3
  53. package/esm2020/cms/plugins/element-hover.plugin.mjs +3 -3
  54. package/esm2020/cms/plugins/io.plugin.mjs +8 -7
  55. package/esm2020/cms/plugins/page.plugin.mjs +3 -3
  56. package/esm2020/cms/plugins/region.plugin.mjs +3 -3
  57. package/esm2020/cms/plugins/script.plugin.mjs +3 -3
  58. package/esm2020/cms/services/element-context.service.mjs +3 -3
  59. package/esm2020/cms/services/index.mjs +1 -2
  60. package/esm2020/cms/services/io-provider.service.mjs +3 -3
  61. package/esm2020/cms/services/resources.service.mjs +3 -3
  62. package/esm2020/cms/services/templates.service.mjs +3 -3
  63. package/esm2020/cms/types/index.mjs +1 -2
  64. package/esm2020/cms/utils/element.utils.mjs +10 -3
  65. package/esm2020/cms/utils/elements-resolver.mjs +2 -2
  66. package/esm2020/cms/vendor-map.mjs +13 -5
  67. package/esm2020/core/core.module.mjs +10 -17
  68. package/esm2020/core/directives/directives.module.mjs +4 -4
  69. package/esm2020/core/directives/primeng-calendar.directive.mjs +3 -3
  70. package/esm2020/core/modules/configuration/configuration.module.mjs +4 -4
  71. package/esm2020/core/modules/configuration/helpers.mjs +8 -3
  72. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +11 -14
  73. package/esm2020/core/modules/configuration/services/configuration.service.mjs +29 -10
  74. package/esm2020/core/modules/configuration/services/configuration.state.mjs +5 -5
  75. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +9 -9
  76. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +4 -4
  77. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +3 -3
  78. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +3 -3
  79. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  80. package/esm2020/core/pipes/date.pipe.mjs +13 -7
  81. package/esm2020/core/pipes/index.mjs +2 -1
  82. package/esm2020/core/pipes/number.pipe.mjs +3 -3
  83. package/esm2020/core/pipes/pipes.module.mjs +8 -7
  84. package/esm2020/core/pipes/price.pipe.mjs +3 -3
  85. package/esm2020/core/services/context.service.mjs +20 -5
  86. package/esm2020/core/services/flow-info.service.mjs +72 -0
  87. package/esm2020/core/services/flow-state.service.mjs +320 -0
  88. package/esm2020/core/services/index.mjs +4 -1
  89. package/esm2020/core/services/integration.state.mjs +37 -0
  90. package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +3 -3
  91. package/esm2020/core/services/product-images.service.mjs +3 -3
  92. package/esm2020/core/services/quote-draft.service.mjs +31 -6
  93. package/esm2020/core/services/runtime-settings.service.mjs +20 -5
  94. package/esm2020/core/types/formatting-settings.types.mjs +1 -1
  95. package/esm2020/core/types/index.mjs +3 -1
  96. package/esm2020/core/types/integration.types.mjs +2 -0
  97. package/esm2020/core/types/pipe.types.mjs +2 -0
  98. package/esm2020/src/components/dialog/dialog.component.mjs +3 -3
  99. package/esm2020/src/components/dialog/dialog.module.mjs +4 -4
  100. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +48 -46
  101. package/esm2020/src/components/doc-gen/doc-gen.module.mjs +4 -4
  102. package/esm2020/src/components/flow-header/flow-header.component.mjs +118 -0
  103. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  104. package/esm2020/src/components/flow-header/index.mjs +2 -0
  105. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +45 -44
  106. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +4 -4
  107. package/esm2020/src/configure-primeng.mjs +33 -0
  108. package/esm2020/src/flow-routing.module.mjs +66 -75
  109. package/esm2020/src/flow.component.mjs +21 -29
  110. package/esm2020/src/flow.module.mjs +11 -9
  111. package/esm2020/src/guards/context.guard.mjs +7 -12
  112. package/esm2020/src/guards/flow.guard.mjs +31 -0
  113. package/esm2020/src/guards/product-unload.guard.mjs +7 -4
  114. package/esm2020/src/guards/root.guard.mjs +17 -13
  115. package/esm2020/src/pages/assets/assets.component.mjs +18 -13
  116. package/esm2020/src/pages/assets/assets.module.mjs +4 -4
  117. package/esm2020/src/pages/catalog/catalog.component.mjs +17 -13
  118. package/esm2020/src/pages/catalog/catalog.module.mjs +4 -4
  119. package/esm2020/src/pages/debug/debug.component.mjs +12 -16
  120. package/esm2020/src/pages/debug/debug.module.mjs +4 -4
  121. package/esm2020/src/pages/empty-account/empty-account.component.mjs +3 -3
  122. package/esm2020/src/pages/empty-account/empty-account.module.mjs +4 -4
  123. package/esm2020/src/pages/product/product.component.mjs +7 -9
  124. package/esm2020/src/pages/product/product.module.mjs +4 -4
  125. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +3 -3
  126. package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +4 -4
  127. package/esm2020/src/pages/remote/remote.component.mjs +13 -14
  128. package/esm2020/src/pages/remote/remote.module.mjs +4 -4
  129. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +17 -13
  130. package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +4 -4
  131. package/esm2020/src/resolvers/flow.resolver.mjs +37 -51
  132. package/esm2020/src/resolvers/quote.resolver.mjs +40 -65
  133. package/esm2020/src/services/doc-gen.service.mjs +7 -6
  134. package/esm2020/src/services/flow-dialog.service.mjs +8 -4
  135. package/esm2020/src/services/flow-router.service.mjs +31 -10
  136. package/esm2020/src/services/flow.service.mjs +36 -11
  137. package/esm2020/src/services/guided-selling.service.mjs +7 -6
  138. package/esm2020/src/services/index.mjs +3 -1
  139. package/esm2020/src/types/flow-customization.types.mjs +1 -1
  140. package/esm2020/src/utils/flow.utils.mjs +6 -2
  141. package/fesm2015/veloceapps-sdk-cms.mjs +221 -220
  142. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  143. package/fesm2015/veloceapps-sdk-core.mjs +1325 -841
  144. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  145. package/fesm2015/veloceapps-sdk.mjs +726 -1456
  146. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  147. package/fesm2020/veloceapps-sdk-cms.mjs +243 -242
  148. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  149. package/fesm2020/veloceapps-sdk-core.mjs +1666 -1177
  150. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  151. package/fesm2020/veloceapps-sdk.mjs +831 -1560
  152. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  153. package/package.json +3 -11
  154. package/src/components/doc-gen/doc-gen.component.d.ts +6 -8
  155. package/src/components/flow-header/flow-header.component.d.ts +27 -0
  156. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  157. package/src/components/flow-header/index.d.ts +1 -0
  158. package/src/components/guided-selling/guided-selling.component.d.ts +5 -7
  159. package/src/configure-primeng.d.ts +1 -0
  160. package/src/flow-routing.module.d.ts +6 -7
  161. package/src/flow.component.d.ts +7 -10
  162. package/src/flow.module.d.ts +2 -2
  163. package/src/guards/context.guard.d.ts +4 -5
  164. package/src/guards/flow.guard.d.ts +2 -0
  165. package/src/guards/product-unload.guard.d.ts +2 -2
  166. package/src/guards/root.guard.d.ts +0 -1
  167. package/src/pages/assets/assets.component.d.ts +3 -3
  168. package/src/pages/catalog/catalog.component.d.ts +3 -3
  169. package/src/pages/debug/debug.component.d.ts +5 -8
  170. package/src/pages/product/product.component.d.ts +2 -2
  171. package/src/pages/remote/remote.component.d.ts +1 -2
  172. package/src/pages/shopping-cart/shopping-cart.component.d.ts +3 -3
  173. package/src/resolvers/flow.resolver.d.ts +6 -7
  174. package/src/resolvers/quote.resolver.d.ts +6 -12
  175. package/src/services/doc-gen.service.d.ts +1 -1
  176. package/src/services/flow-dialog.service.d.ts +1 -0
  177. package/src/services/flow-router.service.d.ts +4 -2
  178. package/src/services/flow.service.d.ts +4 -2
  179. package/src/services/guided-selling.service.d.ts +1 -1
  180. package/src/services/index.d.ts +2 -0
  181. package/src/types/flow-customization.types.d.ts +1 -1
  182. package/esm2020/cms/services/integration.state.mjs +0 -37
  183. package/esm2020/cms/types/integration.types.mjs +0 -2
  184. package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
  185. package/esm2020/runtime/components/index.mjs +0 -5
  186. package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
  187. package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
  188. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
  189. package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
  190. package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
  191. package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
  192. package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
  193. package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
  194. package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
  195. package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
  196. package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
  197. package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
  198. package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
  199. package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
  200. package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
  201. package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
  202. package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
  203. package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
  204. package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
  205. package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
  206. package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
  207. package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
  208. package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
  209. package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
  210. package/esm2020/runtime/index.mjs +0 -5
  211. package/esm2020/runtime/runtime.module.mjs +0 -74
  212. package/esm2020/runtime/services/cart.service.mjs +0 -29
  213. package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
  214. package/esm2020/runtime/services/configuration.service.mjs +0 -119
  215. package/esm2020/runtime/services/current-state.service.mjs +0 -17
  216. package/esm2020/runtime/services/form-scope.service.mjs +0 -30
  217. package/esm2020/runtime/services/index.mjs +0 -4
  218. package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
  219. package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
  220. package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
  221. package/esm2020/runtime/services/runtime.service.mjs +0 -115
  222. package/esm2020/runtime/services/section-helper.service.mjs +0 -27
  223. package/esm2020/runtime/services/section-scope.service.mjs +0 -36
  224. package/esm2020/runtime/services/section-store.service.mjs +0 -22
  225. package/esm2020/runtime/services/section.service.mjs +0 -117
  226. package/esm2020/runtime/types/bound-data.types.mjs +0 -7
  227. package/esm2020/runtime/types/index.mjs +0 -3
  228. package/esm2020/runtime/types/quote-states.types.mjs +0 -2
  229. package/esm2020/runtime/types/runtime.types.mjs +0 -2
  230. package/esm2020/runtime/types/script-registry.types.mjs +0 -51
  231. package/esm2020/runtime/utils/line-item.util.mjs +0 -270
  232. package/esm2020/runtime/utils/section.utils.mjs +0 -26
  233. package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
  234. package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
  235. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
  236. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
  237. package/esm2020/src/components/header/header.component.mjs +0 -355
  238. package/esm2020/src/components/header/header.module.mjs +0 -52
  239. package/esm2020/src/components/header/header.types.mjs +0 -2
  240. package/esm2020/src/components/header/metrics/index.mjs +0 -2
  241. package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
  242. package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
  243. package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
  244. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
  245. package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
  246. package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
  247. package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
  248. package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
  249. package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
  250. package/runtime/README.md +0 -5
  251. package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
  252. package/runtime/components/index.d.ts +0 -4
  253. package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
  254. package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
  255. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
  256. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
  257. package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
  258. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
  259. package/runtime/execution/components/federated/federated.component.d.ts +0 -36
  260. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
  261. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
  262. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
  263. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
  264. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
  265. package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
  266. package/runtime/execution/directives/section-script.directive.d.ts +0 -59
  267. package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
  268. package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
  269. package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
  270. package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
  271. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
  272. package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
  273. package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
  274. package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
  275. package/runtime/execution/runtime-execution.module.d.ts +0 -25
  276. package/runtime/execution/utils/federated.util.d.ts +0 -6
  277. package/runtime/index.d.ts +0 -4
  278. package/runtime/runtime.module.d.ts +0 -16
  279. package/runtime/services/cart.service.d.ts +0 -15
  280. package/runtime/services/collapsible-state.service.d.ts +0 -15
  281. package/runtime/services/configuration.service.d.ts +0 -20
  282. package/runtime/services/current-state.service.d.ts +0 -8
  283. package/runtime/services/form-scope.service.d.ts +0 -20
  284. package/runtime/services/index.d.ts +0 -3
  285. package/runtime/services/product-model-cache.service.d.ts +0 -14
  286. package/runtime/services/runtime-context.service.d.ts +0 -16
  287. package/runtime/services/runtime-form.service.d.ts +0 -24
  288. package/runtime/services/runtime.service.d.ts +0 -44
  289. package/runtime/services/section-helper.service.d.ts +0 -8
  290. package/runtime/services/section-scope.service.d.ts +0 -14
  291. package/runtime/services/section-store.service.d.ts +0 -11
  292. package/runtime/services/section.service.d.ts +0 -30
  293. package/runtime/types/bound-data.types.d.ts +0 -13
  294. package/runtime/types/index.d.ts +0 -2
  295. package/runtime/types/quote-states.types.d.ts +0 -6
  296. package/runtime/types/runtime.types.d.ts +0 -19
  297. package/runtime/types/script-registry.types.d.ts +0 -13
  298. package/runtime/utils/line-item.util.d.ts +0 -34
  299. package/runtime/utils/section.utils.d.ts +0 -2
  300. package/runtime/utils/sections-binder.helper.d.ts +0 -16
  301. package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
  302. package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
  303. package/src/components/header/header.component.d.ts +0 -70
  304. package/src/components/header/header.module.d.ts +0 -16
  305. package/src/components/header/header.types.d.ts +0 -20
  306. package/src/components/header/metrics/index.d.ts +0 -1
  307. package/src/components/header/metrics/metrics.component.d.ts +0 -67
  308. package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
  309. package/src/components/header/metrics/metrics.module.d.ts +0 -18
  310. package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
  311. package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
  312. /package/{cms → core}/services/integration.state.d.ts +0 -0
@@ -1,17 +1,17 @@
1
1
  import * as i0 from '@angular/core';
2
2
  import { InjectionToken, Injectable, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
- import { UUID, ConfigurationContextMode, ConfigurationContext, RuntimeModel, getUIDefinitionProperties, isLegacyUIDefinition, SalesforceIdUtils, ConfigurationMode, ConfigurationTranslatorUtils, EntityUtil, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, parseJsonSafely, formatNumber } from '@veloceapps/core';
4
- import { BehaviorSubject, combineLatest, zip, noop, throwError, shareReplay as shareReplay$1, switchMap as switchMap$1, of, tap as tap$1, map as map$2, catchError as catchError$1, Subject, take as take$1, distinctUntilChanged } from 'rxjs';
5
- import { filter, tap, map, first, switchMap, skip, take, shareReplay, catchError, finalize } from 'rxjs/operators';
3
+ import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, EntityUtil, isDefined, ChargeGroupUtils, DEFAULT_CURRENCY_ISO_CODE, DEFAULT_CURRENCY_SYMBOL, validateDateFormat, DEFAULT_DATE_FORMAT, DEFAULT_DECIMALS_COUNT, getSupportedDateFormats, DEFAULT_DECIMAL_SEPARATOR, DEFAULT_THOUSANDS_SEPARATOR, DEFAULT_ACTION_CODE_LABELS, parseJsonSafely, ConfigurationMode, ConfigurationTranslatorUtils, RuntimeModel, isNotLegacyUIDefinition, SalesforceIdUtils, DEFAULT_TIME_FORMAT, formatNumber } from '@veloceapps/core';
4
+ import { BehaviorSubject, tap as tap$1, switchMap, map as map$1, noop, catchError, throwError, of, Subject, filter as filter$1, zip, combineLatest, forkJoin, shareReplay as shareReplay$1, take as take$1, distinctUntilChanged } from 'rxjs';
5
+ import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize, first } from 'rxjs/operators';
6
6
  import * as i1 from '@veloceapps/api';
7
7
  import { PriceApiService, ContextApiService, ProductModelApiService, ConfigurationApiService } from '@veloceapps/api';
8
- import { merge, flatten, sortBy, map as map$1, isEqual, transform, omit, cloneDeep, uniq } from 'lodash';
9
- import { HttpErrorResponse } from '@angular/common/http';
10
- import * as i4 from '@veloceapps/components';
8
+ import { merge, isEmpty, flatten, sortBy, map as map$2, omit, isEqual, uniqBy, transform, cloneDeep, uniq } from 'lodash';
9
+ import * as i6 from '@veloceapps/components';
11
10
  import { ToastType, ConfirmationComponent, ConfirmationDialogModule } from '@veloceapps/components';
12
- import * as i5 from 'primeng/api';
13
- import * as i6 from 'primeng/dynamicdialog';
14
11
  import moment from 'moment';
12
+ import { HttpErrorResponse } from '@angular/common/http';
13
+ import * as i5 from 'primeng/api';
14
+ import * as i6$1 from 'primeng/dynamicdialog';
15
15
  import { NgControl } from '@angular/forms';
16
16
  import { DATE_PIPE_DEFAULT_OPTIONS, formatDate } from '@angular/common';
17
17
 
@@ -24,21 +24,16 @@ const getDefaultLineItem = (context, uiDefinitionProperties, qty = 1) => {
24
24
  attributes,
25
25
  lineItems, productName: ((_b = context.properties) === null || _b === void 0 ? void 0 : _b['displayName']) || context.productName, productId: (_c = context.productId) !== null && _c !== void 0 ? _c : '' }, (uiDefinitionProperties.offeringId ? { offeringId: uiDefinitionProperties.offeringId } : {}));
26
26
  };
27
- const getGuidedSellingConfigurationRequest = (data) => {
27
+ const getGuidedSellingConfigurationRequest = (data, context) => {
28
+ const _context = Object.assign({}, context);
29
+ delete _context.configurationToken;
30
+ const properties = Object.assign({}, context.properties);
31
+ delete properties['ConfigurationToken'];
28
32
  return {
29
33
  mode: 'SEARCH',
30
34
  step: 'START',
31
35
  attributeDomainMode: 'ALL',
32
- context: {
33
- headerId: 'TestId',
34
- mode: ConfigurationContextMode.TEST,
35
- properties: {
36
- ModelId: data.modelId,
37
- Name: 'Veloce Guided Selling',
38
- PricingEnabled: 'false',
39
- RuntimeMode: 'TEST',
40
- },
41
- },
36
+ context: Object.assign(Object.assign({}, _context), { mode: ConfigurationContextMode.TEST, properties: Object.assign(Object.assign({}, properties), { ModelId: data.modelId, Name: 'Veloce Guided Selling', PricingEnabled: 'false', RuntimeMode: 'TEST' }) }),
42
37
  lineItem: {
43
38
  actionCode: 'ADD',
44
39
  cfgStatus: 'Default',
@@ -82,6 +77,9 @@ class ContextService {
82
77
  get isInitialized() {
83
78
  return Boolean(this.context.value);
84
79
  }
80
+ get isInitialized$() {
81
+ return this.context.pipe(map(Boolean));
82
+ }
85
83
  get mode() {
86
84
  return this.resolve().properties.mode;
87
85
  }
@@ -97,6 +95,13 @@ class ContextService {
97
95
  create(headerId, mode) {
98
96
  return this.contextApiService.getContext(headerId, mode).pipe(tap(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map(() => this.resolve()));
99
97
  }
98
+ initTestMode() {
99
+ return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
100
+ return this.update({
101
+ properties: Object.assign(Object.assign({}, context.properties), { RuntimeMode: ConfigurationContextMode.TEST, StartDate: new Date().toISOString().substring(0, 10), standalone: 'true' }),
102
+ });
103
+ }));
104
+ }
100
105
  update(partialContext) {
101
106
  const originalContext = this.resolve();
102
107
  const updatedContext = Object.assign(Object.assign(Object.assign({}, originalContext), partialContext), { properties: Object.assign(Object.assign({}, originalContext.properties), partialContext.properties) });
@@ -113,136 +118,77 @@ class ContextService {
113
118
  this.context.next(null);
114
119
  }
115
120
  }
116
- ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
117
- ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, providedIn: 'root' });
118
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ContextService, decorators: [{
121
+ ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
122
+ ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, providedIn: 'root' });
123
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
119
124
  type: Injectable,
120
125
  args: [{ providedIn: 'root' }]
121
126
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
122
127
 
123
- class RuntimeContextService {
124
- constructor(configurationApiService) {
125
- this.configurationApiService = configurationApiService;
126
- }
127
- getRuntimeContext(productId, offeringId) {
128
- return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
129
- var _a;
130
- const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
131
- const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
132
- const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
133
- const uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
134
- return {
135
- modelId: runtimeData.modelId,
136
- uiDefinitionContainer: uiDefinitionContainer,
137
- runtimeModel: runtimeModel,
138
- runtimeMode: RuntimeMode.PROD,
139
- productId: productId,
140
- productType: (properties === null || properties === void 0 ? void 0 : properties['displayName']) || productName,
141
- offeringId: offeringId,
142
- properties: {
143
- PricingEnabled: uiDefinitionProperties.pricingEnabled ? 'true' : 'false',
144
- PriceListId: uiDefinitionProperties.priceList,
145
- },
146
- };
128
+ class FlowInfoService {
129
+ get flow() {
130
+ return this.flowSubj$.value;
131
+ }
132
+ set flow(value) {
133
+ this.flowSubj$.next(value);
134
+ }
135
+ constructor(flowsApiService, templatesApiService) {
136
+ this.flowsApiService = flowsApiService;
137
+ this.templatesApiService = templatesApiService;
138
+ this.templates = {};
139
+ this.flowSubj$ = new BehaviorSubject(null);
140
+ this.flow$ = this.flowSubj$.asObservable();
141
+ }
142
+ init$(flowId, params) {
143
+ this.params = params;
144
+ return this.flowsApiService.getFlow(flowId).pipe(tap$1(flow => this.flowSubj$.next(flow)), switchMap(flow => this.initFlowTemplates$(flow)), map$1(noop), catchError(e => {
145
+ this.flowSubj$.next(null);
146
+ return throwError(() => e);
147
147
  }));
148
148
  }
149
- getUIDefinitionContainer(runtimeData) {
150
- var _a;
151
- const containers = runtimeData.uiDefinitions.filter(container => !isLegacyUIDefinition(container.source));
152
- return (_a = containers.find(container => container.source.primary)) !== null && _a !== void 0 ? _a : containers[0];
153
- }
154
- }
155
- RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
156
- RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService });
157
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeContextService, decorators: [{
158
- type: Injectable
159
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
160
-
161
- class ConfigurationRuntimeService {
162
- constructor(apiService, contextService, runtimeContextService) {
163
- this.apiService = apiService;
164
- this.contextService = contextService;
165
- this.runtimeContextService = runtimeContextService;
166
- this._isInitialized = false;
167
- this.uiDefinitionProperties = {};
168
- }
169
- reset() {
170
- this._isInitialized = false;
171
- this._runtimeContext = undefined;
172
- this.initializationProps = undefined;
173
- this.uiDefinitionProperties = {};
174
- }
175
- initTestMode(uiDefinitionContainer) {
176
- var _a;
177
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
178
- const uiDefinitionExternals = (_a = uiDefinitionContainer.source.externals) !== null && _a !== void 0 ? _a : {};
179
- return combineLatest([
180
- this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
181
- this.contextService.create('TestId', ConfigurationContextMode.TEST),
182
- ]).pipe(first(), map(([runtimeData, context]) => {
183
- var _a;
184
- this.contextService.update({
185
- properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: uiDefinitionContainer.modelId, RuntimeMode: ConfigurationContextMode.TEST, PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', StartDate: new Date().toISOString().substring(0, 10), PriceListId: this.uiDefinitionProperties.priceList, offeringId: this.uiDefinitionProperties.offeringId, standalone: 'true' }), uiDefinitionExternals),
186
- });
187
- this._runtimeContext = {
188
- modelId: uiDefinitionContainer.modelId,
189
- runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
190
- runtimeMode: RuntimeMode.TEST,
191
- uiDefinitionContainer,
192
- };
193
- return this._runtimeContext;
194
- }), tap(() => (this._isInitialized = true)));
195
- }
196
- init(props) {
197
- this.initializationProps = props;
198
- const context = this.contextService.resolve();
199
- return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
200
- var _a, _b;
201
- this.uiDefinitionProperties = getUIDefinitionProperties(runtimeContext.uiDefinitionContainer);
202
- const { PriceListId } = (_a = context.properties) !== null && _a !== void 0 ? _a : {};
203
- const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
204
- this.id15to18('AccountId', mergeContext.properties);
205
- this._runtimeContext = mergeContext;
206
- if (context.properties && ((_b = this._runtimeContext.properties) === null || _b === void 0 ? void 0 : _b.StartDate)) {
207
- this.contextService.update({
208
- properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
209
- });
210
- }
211
- return this._runtimeContext;
212
- }), tap(() => (this._isInitialized = true)));
149
+ cleanup() {
150
+ this.flowSubj$.next(null);
151
+ this.params = undefined;
152
+ this.templates = {};
213
153
  }
214
- overrideUIDefinition(uiDefinitionContainer) {
215
- if (!this._runtimeContext) {
216
- return;
154
+ initFlowTemplates$(flow) {
155
+ if (isEmpty(flow.properties.templates)) {
156
+ return of(undefined);
217
157
  }
218
- this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
219
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
158
+ return this.templatesApiService.fetchTemplates$().pipe(map$1(templates => {
159
+ Object.entries(flow.properties.templates).forEach(([key, name]) => {
160
+ const type = this.remapTemplateName(key);
161
+ if (type) {
162
+ this.templates[type] = templates.find(template => template.name === name && template.type === type);
163
+ }
164
+ });
165
+ }));
220
166
  }
221
- id15to18(propertyName, source) {
222
- if (!source) {
223
- return;
224
- }
225
- const value = source[propertyName];
226
- if (typeof value === 'string' && value.length === 15) {
227
- source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
167
+ remapTemplateName(templateType) {
168
+ switch (templateType) {
169
+ case 'assets':
170
+ case 'shoppingCart':
171
+ // No separate Assets template at the moment
172
+ return UITemplateType.SHOPPING_CART;
173
+ case 'catalog':
174
+ return UITemplateType.CATALOG;
175
+ case 'docGen':
176
+ return UITemplateType.DOCGEN;
177
+ case 'guidedSelling':
178
+ return UITemplateType.GUIDED_SELLING;
179
+ case 'flowHeader':
180
+ return UITemplateType.FLOW_HEADER;
181
+ default:
182
+ return;
228
183
  }
229
184
  }
230
- get isInitialized() {
231
- return this._isInitialized;
232
- }
233
- get runtimeModel() {
234
- var _a;
235
- return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
236
- }
237
- get runtimeContext() {
238
- return this._runtimeContext;
239
- }
240
185
  }
241
- ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
242
- ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService });
243
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
244
- type: Injectable
245
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
186
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }], target: i0.ɵɵFactoryTarget.Injectable });
187
+ FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, providedIn: 'root' });
188
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
189
+ type: Injectable,
190
+ args: [{ providedIn: 'root' }]
191
+ }], ctorParameters: function () { return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }]; } });
246
192
 
247
193
  const findLineItem = (id, lineItems) => {
248
194
  return findLineItemWithComparator(lineItems, (li) => li.id === id);
@@ -395,7 +341,7 @@ const isLineItemModified = (lineItem) => {
395
341
  const multiplyLineItems = (lineItem, qty, split) => {
396
342
  if (split) {
397
343
  const unifyIds = (lineItem) => (Object.assign(Object.assign({}, lineItem), { id: UUID.UUID(), lineItems: lineItem.lineItems.map(unifyIds) }));
398
- return map$1(new Array(qty), () => unifyIds(lineItem));
344
+ return map$2(new Array(qty), () => unifyIds(lineItem));
399
345
  }
400
346
  else {
401
347
  return [
@@ -452,7 +398,52 @@ class LineItemWorker {
452
398
  }
453
399
  }
454
400
 
401
+ function extractMetadata(uiDefinition) {
402
+ return omit(uiDefinition, [
403
+ 'children',
404
+ 'pages',
405
+ 'components',
406
+ ]);
407
+ }
408
+
409
+ class IntegrationState {
410
+ constructor() {
411
+ this.stateSubj$ = new BehaviorSubject({});
412
+ this.action$ = new Subject();
413
+ }
414
+ get state$() {
415
+ return this.stateSubj$.asObservable();
416
+ }
417
+ get state() {
418
+ return this.stateSubj$.getValue();
419
+ }
420
+ patchState(update) {
421
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
422
+ }
423
+ dispatch(action) {
424
+ this.action$.next(action);
425
+ }
426
+ listen$(actionType) {
427
+ return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
428
+ }
429
+ listenAll$() {
430
+ return this.action$.asObservable();
431
+ }
432
+ clear() {
433
+ this.stateSubj$.next({});
434
+ }
435
+ }
436
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
437
+ IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, providedIn: 'root' });
438
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
439
+ type: Injectable,
440
+ args: [{ providedIn: 'root' }]
441
+ }] });
442
+
455
443
  class QuoteDraftService {
444
+ get isInitialized$() {
445
+ return this.isInitializedSubj$.asObservable();
446
+ }
456
447
  get isInitialized() {
457
448
  return this.isInitializedSubj$.getValue();
458
449
  }
@@ -478,10 +469,19 @@ class QuoteDraftService {
478
469
  const quoteDraft = this.quoteSubj$.value;
479
470
  return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
480
471
  }
481
- constructor(context, quoteApiService, priceApiService) {
472
+ get hasAssets$() {
473
+ return this.quoteSubj$.pipe(map(() => this.hasAssets));
474
+ }
475
+ get hasAssets() {
476
+ var _a;
477
+ const quoteDraft = this.quoteSubj$.value;
478
+ return (_a = quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.currentState.some(li => li.assetId || li.openOrderLineItemId)) !== null && _a !== void 0 ? _a : false;
479
+ }
480
+ constructor(context, quoteApiService, priceApiService, integrationState) {
482
481
  this.context = context;
483
482
  this.quoteApiService = quoteApiService;
484
483
  this.priceApiService = priceApiService;
484
+ this.integrationState = integrationState;
485
485
  this.quoteSubj$ = new BehaviorSubject(null);
486
486
  this.resetSubj$ = new BehaviorSubject(true);
487
487
  this.isInitializedSubj$ = new BehaviorSubject(false);
@@ -492,12 +492,13 @@ class QuoteDraftService {
492
492
  this.reset$ = this.resetSubj$.asObservable();
493
493
  this.activePriceList$ = this.context.resolve$().pipe(map(ctx => this.allPriceLists.find(priceList => priceList.id === ctx.properties.PriceListId)), map(priceList => priceList !== null && priceList !== void 0 ? priceList : null));
494
494
  this.isInitializedSubj$
495
- .pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
495
+ .pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
496
496
  .subscribe();
497
497
  }
498
498
  reset() {
499
499
  this.resetSubj$.next(true);
500
500
  this.quoteSubj$.next(null);
501
+ this.isInitialized = false;
501
502
  this.hasUnsavedChanges = false;
502
503
  }
503
504
  init(quoteId, params) {
@@ -508,6 +509,11 @@ class QuoteDraftService {
508
509
  this.populateActivePriceLists$();
509
510
  }), map(() => noop()), take(1));
510
511
  }
512
+ finalizeInit() {
513
+ this.initializeModifiedAssetsMap();
514
+ this.isInitialized = true;
515
+ this.hasUnsavedChanges = false;
516
+ }
511
517
  setCurrentLineItemState(lineItems) {
512
518
  const quoteDraft = this.quoteSubj$.value;
513
519
  if (!quoteDraft) {
@@ -653,333 +659,310 @@ class QuoteDraftService {
653
659
  this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
654
660
  }
655
661
  }
662
+ initializeModifiedAssetsMap() {
663
+ this.integrationState.patchState({
664
+ modifiedAssets: generateModifiedAssetsMap(this.currentState),
665
+ });
666
+ }
656
667
  }
657
- QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }], target: i0.ɵɵFactoryTarget.Injectable });
658
- QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
659
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: QuoteDraftService, decorators: [{
668
+ QuoteDraftService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, deps: [{ token: ContextService }, { token: i1.QuoteApiService }, { token: i1.PriceApiService }, { token: IntegrationState }], target: i0.ɵɵFactoryTarget.Injectable });
669
+ QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, providedIn: 'root' });
670
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
660
671
  type: Injectable,
661
672
  args: [{ providedIn: 'root' }]
662
- }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
673
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: IntegrationState }]; } });
663
674
 
664
- class ConfigurationService {
665
- constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
666
- this.quoteDraftService = quoteDraftService;
667
- this.runtimeService = runtimeService;
675
+ class FlowStateService {
676
+ constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService) {
668
677
  this.contextService = contextService;
669
- this.configurationApiService = configurationApiService;
670
- this.messageService = messageService;
671
- this.dialogService = dialogService;
672
- this.mode = ConfigurationMode.SEARCH;
673
- this.lineItem = new BehaviorSubject(undefined);
674
- this.charges = new BehaviorSubject({});
675
- this.pricePlans = new BehaviorSubject({});
676
- this.isLoadingSubj$ = new BehaviorSubject(false);
677
- this.isLoading$ = this.isLoadingSubj$.asObservable();
678
- this.hasUnsavedChanges = false;
678
+ this.quoteDraftService = quoteDraftService;
679
+ this.flowInfoService = flowInfoService;
680
+ this.flowConfiguration = flowConfiguration;
681
+ this.processorsApiService = processorsApiService;
682
+ this.flowStateApiService = flowStateApiService;
683
+ this.quoteApiService = quoteApiService;
684
+ this.toastService = toastService;
685
+ this.NOT_INITIALIZED = Symbol();
686
+ this.stateId$ = new BehaviorSubject(null);
687
+ this.processors = {};
688
+ this.subscriptions = {};
679
689
  }
680
- reset() {
681
- this.hasUnsavedChanges = false;
682
- this.runtimeService.reset();
683
- this.configurableRamp = undefined;
684
- this.lineItem.next(undefined);
685
- this.charges.next({});
686
- this.pricePlans.next({});
690
+ init$() {
691
+ if (this.getFlowSafe().properties.stateful) {
692
+ return this.initStateful$();
693
+ }
694
+ else {
695
+ return this.initStateless$();
696
+ }
687
697
  }
688
- patch$(lineItem, options) {
689
- if (!this.lineItem.value) {
690
- return throwError(() => new Error(`Source LineItem not found`));
698
+ cleanup() {
699
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
700
+ this.subscriptions = {};
701
+ if (this.stateId$.value) {
702
+ this.flowStateApiService.cancel(this.stateId$.value).subscribe();
703
+ this.stateId$.next(null);
691
704
  }
692
- const skipCardinalityCalculation = (options === null || options === void 0 ? void 0 : options.skipCardinalityCalculation) || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
693
- this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
694
- return this.configure().pipe(catchError(error => {
695
- console.error(error);
696
- if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
697
- this.messageService.add({ severity: 'error', summary: error });
698
- }
699
- // bounce back if configuration call has failed
700
- this.lineItem.next(this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined);
701
- return throwError(() => error);
702
- }), tap(() => {
703
- if (!this.hasUnsavedChanges) {
704
- this.hasUnsavedChanges = true;
705
- }
706
- }));
705
+ this.processors = {};
707
706
  }
708
- patch(lineItem, options) {
709
- this.patch$(lineItem, options).subscribe();
707
+ isInitialized$() {
708
+ return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
710
709
  }
711
- setConfigurableRamp(lineItem) {
712
- this.configurableRamp = lineItem;
710
+ isInitialized() {
711
+ return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
713
712
  }
714
- get() {
715
- return this.lineItem.asObservable().pipe(shareReplay$1());
713
+ execute$(scope, exec) {
714
+ const request = this.execToRequest(scope, exec);
715
+ return this.executeRequest$(request).pipe(map$1(result => {
716
+ // Keep only requested results
717
+ const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
718
+ var _a;
719
+ if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
720
+ trunk[requestId] = result;
721
+ }
722
+ return trunk;
723
+ }, {});
724
+ return actualSelectors;
725
+ }));
716
726
  }
717
- getSnapshot() {
718
- return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
727
+ dispatch$(scope, action, inputData) {
728
+ const exec = {
729
+ actions: [{ name: action, inputData }],
730
+ };
731
+ const request = this.execToRequest(scope, exec);
732
+ return this.executeRequest$(request).pipe(map$1(noop));
719
733
  }
720
- getRuntimeModel() {
721
- const runtimeModel = this.runtimeService.runtimeModel;
722
- if (!runtimeModel) {
723
- throw new Error('Runtime model not initialized');
734
+ select$(scope, selectorName, inputData) {
735
+ const requestId = UUID.UUID();
736
+ const request = this.execToRequest(scope, {
737
+ selectors: {
738
+ [requestId]: {
739
+ name: selectorName,
740
+ inputData,
741
+ },
742
+ },
743
+ });
744
+ return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
745
+ }
746
+ subscribe$(scope, selectorName, inputData) {
747
+ const inputDataHash = UUID.hex(JSON.stringify(inputData)).slice(0, 8);
748
+ const requestId = `${scope}/${selectorName}/${inputDataHash}`;
749
+ if (!this.subscriptions[requestId]) {
750
+ const request = this.execToRequest(scope, {
751
+ selectors: {
752
+ [requestId]: {
753
+ name: selectorName,
754
+ inputData,
755
+ },
756
+ },
757
+ });
758
+ this.subscriptions[requestId] = {
759
+ request,
760
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
761
+ };
762
+ this.executeRequest$({}).subscribe();
724
763
  }
725
- return runtimeModel;
764
+ return this.subscriptions[requestId].data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data));
726
765
  }
727
- getRuntimeContext() {
728
- const runtimeContext = this.runtimeService.runtimeContext;
729
- if (!runtimeContext) {
730
- throw new Error('Runtime context not initialized');
766
+ save$() {
767
+ if (this.getFlowSafe().properties.stateful) {
768
+ if (this.stateId$.value) {
769
+ return this.flowStateApiService.save(this.stateId$.value);
770
+ }
731
771
  }
732
- return runtimeContext;
772
+ else {
773
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
774
+ if (quoteDraft) {
775
+ return this.quoteApiService.upsertQuote(quoteDraft).pipe(map$1(noop));
776
+ }
777
+ }
778
+ return of(undefined);
733
779
  }
734
- get contextSnapshot() {
735
- return this.contextService.resolve();
780
+ submit$() {
781
+ if (this.getFlowSafe().properties.stateful) {
782
+ if (this.stateId$.value) {
783
+ return this.flowStateApiService.submit(this.stateId$.value);
784
+ }
785
+ }
786
+ else {
787
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
788
+ if (quoteDraft) {
789
+ return this.quoteApiService.submitQuote(quoteDraft).pipe(map$1(noop));
790
+ }
791
+ }
792
+ return of(undefined);
736
793
  }
737
- get context$() {
738
- return this.contextService.resolve$();
794
+ getOwnerIdByScope(scope) {
795
+ var _a;
796
+ const ownerId = (_a = this.flowInfoService.templates[scope]) === null || _a === void 0 ? void 0 : _a.id;
797
+ if (!ownerId) {
798
+ throw `OwnerId is not found for scope ${scope}`;
799
+ }
800
+ return ownerId;
739
801
  }
740
- get charges$() {
741
- return this.charges.asObservable();
802
+ getScopeByOwnerId(id) {
803
+ for (const template of Object.values(this.flowInfoService.templates)) {
804
+ if (template.id === id) {
805
+ return template.type;
806
+ }
807
+ }
808
+ return;
742
809
  }
743
- get chargesSnapshot() {
744
- return this.charges.value;
810
+ execToRequest(scope, exec) {
811
+ var _a;
812
+ const ownerId = this.getOwnerIdByScope(scope);
813
+ return {
814
+ actions: (_a = exec.actions) === null || _a === void 0 ? void 0 : _a.map(action => { var _a; return ({ apiName: action.name, ownerId, inputData: (_a = action.inputData) !== null && _a !== void 0 ? _a : {} }); }),
815
+ selectors: exec.selectors &&
816
+ Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
817
+ var _a;
818
+ return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
819
+ }, {}),
820
+ };
745
821
  }
746
- get pricePlans$() {
747
- return this.pricePlans.asObservable();
748
- }
749
- get pricePlansSnapshot() {
750
- return this.pricePlans.value;
751
- }
752
- configure() {
753
- return this.configureRequest$(this.generateRequest());
822
+ executeRequest$(request) {
823
+ const fullRequest = Object.assign(Object.assign({}, request), { selectors: Object.assign(Object.assign({}, request.selectors), Object.values(this.subscriptions).reduce((trunk, subscription) => {
824
+ return Object.assign(Object.assign({}, trunk), subscription.request.selectors);
825
+ }, {})) });
826
+ const execution$ = this.getFlowSafe().properties.stateful
827
+ ? this.executeStateful$(fullRequest)
828
+ : this.executeStateless$(fullRequest);
829
+ return execution$.pipe(tap$1(result => {
830
+ Object.entries(result.selectors).forEach(([requestId, selectorResult]) => {
831
+ var _a;
832
+ if (!selectorResult.success) {
833
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
834
+ }
835
+ const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
836
+ if (subscription$) {
837
+ subscription$.next(selectorResult);
838
+ }
839
+ });
840
+ }));
754
841
  }
755
- configureRequest$(configurationRequest) {
842
+ initStateful$() {
756
843
  var _a;
757
- const runtimeContext = this.getRuntimeContext();
758
- const runtimeModel = this.getRuntimeModel();
759
- const uiDefinitionProperties = this.getUIDefinitionProperties();
760
- const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
761
- const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
762
- this.isLoadingSubj$.next(true);
763
- return this.configurationApiService.configureLineItem({ configurationRequest, runtimeModel, pricingEnabled }).pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems }) => {
764
- this.contextService.update(context !== null && context !== void 0 ? context : {});
765
- this.charges.next(charges !== null && charges !== void 0 ? charges : {});
766
- this.pricePlans.next(pricePlans !== null && pricePlans !== void 0 ? pricePlans : {});
767
- if (lineItem) {
768
- this.lineItem.next(lineItem);
769
- }
770
- if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
771
- this.showInactiveProductsConfirmation();
772
- }
773
- this.configurableRamp = lineItem;
774
- }), map(({ lineItem }) => lineItem), catchError(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })), finalize(() => this.isLoadingSubj$.next(false)));
775
- }
776
- configureExternal$(props) {
777
- return this.runtimeService
778
- .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
779
- .pipe(switchMap(() => this.configure()), first(), catchError(error => {
780
- this.messageService.add({ severity: ToastType.error, summary: error });
781
- throw error;
782
- }), finalize(() => this.reset()));
783
- }
784
- configureGuidedSelling$(data) {
785
- return this.configurationApiService
786
- .configureLineItem({
787
- configurationRequest: getGuidedSellingConfigurationRequest(data),
844
+ return this.flowStateApiService
845
+ .init({
846
+ quoteId: this.contextService.resolve().headerId,
847
+ params: (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {},
788
848
  })
789
- .pipe(catchError(error => {
790
- if (error instanceof HttpErrorResponse) {
791
- this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
792
- }
793
- throw error;
849
+ .pipe(map$1(({ stateId }) => {
850
+ this.stateId$.next(stateId);
794
851
  }));
795
852
  }
796
- generateRequest() {
797
- var _a, _b;
798
- const runtimeContext = this.getRuntimeContext();
799
- const uiDefinitionProperties = this.getUIDefinitionProperties();
800
- let lineItem = this.configurableRamp;
801
- if (!lineItem) {
802
- const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
803
- lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
804
- // Set default attributes
805
- if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
806
- const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
807
- lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
808
- }
853
+ executeStateful$(request) {
854
+ if (!this.stateId$.value) {
855
+ throw 'Stateful session is not initialized';
809
856
  }
810
- let request = {
811
- lineItem,
812
- mode: this.mode,
813
- step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
814
- attributeDomainMode: 'ALL',
815
- context: this.contextService.resolve(),
816
- lineItems: ((_b = this.quoteDraftService.quoteDraft) === null || _b === void 0 ? void 0 : _b.currentState) || [],
817
- asset: this.getAsset(),
818
- };
819
- request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
820
- return request;
821
- }
822
- getUIDefinitionProperties() {
823
- var _a;
824
- return Object.assign(Object.assign({}, getUIDefinitionProperties(this.getRuntimeContext().uiDefinitionContainer)), ((_a = this.runtimeService.uiDefinitionProperties) !== null && _a !== void 0 ? _a : {}));
825
- }
826
- showInactiveProductsConfirmation() {
827
- const confirmationConfig = {
828
- title: ' ',
829
- description: 'This quote contains inactive products. Do you want to remove them?',
830
- primaryButtonLabel: 'Remove products',
831
- secondaryButtonLabel: 'Back to Quote',
832
- };
833
- this.dialogService
834
- .open(ConfirmationComponent, {
835
- dismissableMask: false,
836
- closeOnEscape: false,
837
- closable: false,
838
- showHeader: true,
839
- header: `Inactive Products in Quote`,
840
- width: '440px',
841
- data: { confirmationConfig },
842
- })
843
- .onClose.subscribe(result => {
844
- if (!result) {
845
- const context = this.contextService.resolve();
846
- window['VELO_BACK_FN'].apply(null, [context.headerId]);
847
- }
848
- });
857
+ return this.flowStateApiService
858
+ .execute(this.stateId$.value, request)
859
+ .pipe(tap$1(response => this.stateId$.next(response.stateId)));
849
860
  }
850
- getAsset() {
861
+ initStateless$() {
851
862
  var _a;
852
- const lineItem = this.configurableRamp;
853
- if (!lineItem) {
854
- return;
855
- }
856
- return (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
857
- }
858
- }
859
- ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6.DialogService }], target: i0.ɵɵFactoryTarget.Injectable });
860
- ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService });
861
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationService, decorators: [{
862
- type: Injectable
863
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6.DialogService }]; } });
864
-
865
- class ConfigurationState {
866
- constructor(statefulConfigurationApiService, runtimeService, configurationService, toastService) {
867
- this.statefulConfigurationApiService = statefulConfigurationApiService;
868
- this.runtimeService = runtimeService;
869
- this.configurationService = configurationService;
870
- this.toastService = toastService;
871
- this.stateSubj$ = new BehaviorSubject({});
872
- this.state$ = this.stateSubj$.asObservable();
873
- this.stateId = null;
874
- }
875
- init$() {
876
- return this.configurationService.configure().pipe(switchMap$1(() => {
877
- var _a, _b;
878
- if (!this.isStatefulConfiguration) {
879
- return of(undefined);
880
- }
881
- const { actions, selectors } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
882
- return this.statefulConfigurationApiService.init({
883
- request: this.configurationService.generateRequest(),
884
- actions: actions === null || actions === void 0 ? void 0 : actions.map(action => ({ name: action.apiName, script: action.script })),
885
- selectors: selectors === null || selectors === void 0 ? void 0 : selectors.map(selector => ({ name: selector.apiName, script: selector.script })),
886
- });
887
- }), tap$1(stateId => (this.stateId = stateId || null)), map$2(() => undefined));
888
- }
889
- cleanup() {
890
- this.stateId = null;
891
- this.configurationService.reset();
892
- this.stateSubj$.next({});
893
- }
894
- execute$(req) {
895
- if (this.isStatefulConfiguration) {
896
- return this.executeStateful$(req);
863
+ const { headerId } = this.contextService.resolve();
864
+ const { stateful } = this.getFlowSafe().properties;
865
+ const processorsInit$ = stateful == false ? this.initProcessors$() : of(undefined);
866
+ const stateInit$ = this.quoteDraftService
867
+ .init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {})
868
+ .pipe(switchMap(() => this.calculate$()));
869
+ return forkJoin([processorsInit$, stateInit$]).pipe(tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
870
+ }
871
+ calculate$() {
872
+ const flowState = this.quoteDraftService.quoteDraft;
873
+ if (!flowState) {
874
+ return of(undefined);
897
875
  }
898
- else {
899
- return this.executeStateless$(req);
876
+ /*
877
+ Don't execute procedures when:
878
+ * Initializing a standalone product configuration UI, as procedure is execute in /price call
879
+ * Initializing an empty account (account with no assets)
880
+ */
881
+ const isEmptyAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT && !this.quoteDraftService.hasProducts;
882
+ if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
883
+ return of(undefined);
900
884
  }
901
- }
902
- dispatch$(actionName, inputData) {
903
- return this.execute$({ actions: [{ name: actionName, inputData }] });
904
- }
905
- select$(selectorName, inputData) {
906
- const requestId = UUID.UUID();
907
- return this.execute$({
908
- selectors: {
909
- [requestId]: {
910
- name: selectorName,
911
- inputData,
912
- },
913
- },
914
- }).pipe(map$2(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
915
- }
916
- get isStatefulConfiguration() {
917
- var _a;
918
- return (_a = this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled) !== null && _a !== void 0 ? _a : false;
885
+ return this.flowConfiguration.calculate$(flowState);
919
886
  }
920
887
  executeStateless$(request) {
921
- return of(undefined).pipe(switchMap$1(() => {
888
+ return of(undefined).pipe(switchMap(() => {
922
889
  var _a;
923
- // Apply actions and execute configuration/price call
924
- // No need to run configuration if no actions in the request
925
- if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
890
+ if (!this.quoteDraftService.quoteDraft || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
926
891
  return of(undefined);
927
892
  }
928
- let configurationRequest = this.configurationService.generateRequest();
893
+ let flowState = this.quoteDraftService.quoteDraft;
929
894
  request.actions.forEach(action => {
930
895
  var _a;
931
- configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
896
+ flowState = (_a = this.executeActionScript(flowState, action)) !== null && _a !== void 0 ? _a : flowState;
932
897
  });
933
- return this.configurationService.configureRequest$(configurationRequest);
934
- }), tap$1(() => {
935
- if (!request.selectors) {
936
- return;
898
+ this.quoteDraftService.updateQuoteDraft(flowState);
899
+ return this.calculate$();
900
+ }), map$1(() => {
901
+ var _a;
902
+ if (!this.quoteDraftService.quoteDraft) {
903
+ throw 'QuoteDraft is not initialized';
937
904
  }
938
- // Run selectors and apply them to the state
939
- const finalConfigurationRequest = this.configurationService.generateRequest();
940
- const selectorsResult = EntityUtil.entries(request.selectors).reduce((trunk, [key, selector]) => {
941
- trunk[key] = this.executeSelectorScript(finalConfigurationRequest, selector);
942
- return trunk;
943
- }, {});
944
- this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.value), selectorsResult));
945
- }), map$2(() => undefined));
905
+ const flowState = this.quoteDraftService.quoteDraft;
906
+ const executionResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
907
+ try {
908
+ result.selectors[key] = {
909
+ success: true,
910
+ result: this.executeSelectorScript(flowState, selector),
911
+ };
912
+ }
913
+ catch (e) {
914
+ result.selectors[key] = {
915
+ success: false,
916
+ errorMessage: String(e),
917
+ };
918
+ }
919
+ return result;
920
+ }, { stateId: '', selectors: {} });
921
+ return executionResult;
922
+ }));
946
923
  }
947
- executeStateful$(request) {
948
- if (!this.stateId) {
949
- return of(undefined);
924
+ getFlowSafe() {
925
+ if (!this.flowInfoService.flow) {
926
+ throw 'Flow is not defined';
950
927
  }
951
- return this.statefulConfigurationApiService.execute(this.stateId, request).pipe(tap$1(response => {
952
- this.stateId = response.stateId;
953
- const updatedState = this.stateSubj$.value;
954
- EntityUtil.entries(response.selectors).forEach(([key, value]) => {
955
- if (!value.success) {
956
- if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
957
- this.toastService.add({ summary: value.errorMessage, severity: ToastType.error });
958
- }
959
- return;
960
- }
961
- updatedState[key] = value.result;
962
- });
963
- this.stateSubj$.next(updatedState);
964
- }), map$2(() => undefined));
928
+ return this.flowInfoService.flow;
965
929
  }
966
- executeActionScript(request, processor) {
967
- var _a, _b, _c;
968
- const { actions } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
969
- const script = (_c = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.name)) === null || _c === void 0 ? void 0 : _c.script;
930
+ initProcessors$() {
931
+ const owners$ = Object.values(this.flowInfoService.templates)
932
+ .map(template => {
933
+ if (!template) {
934
+ return;
935
+ }
936
+ return this.processorsApiService.fetchConfigurationProcessors$(template.id).pipe(tap$1(processors => {
937
+ const processorsMap = processors.reduce((acc, p) => {
938
+ acc[p.apiName] = p;
939
+ return acc;
940
+ }, {});
941
+ this.processors[template.id] = processorsMap;
942
+ }));
943
+ })
944
+ .filter(isDefined);
945
+ return forkJoin(owners$).pipe(map$1(noop));
946
+ }
947
+ executeActionScript(request, executable) {
948
+ var _a, _b;
949
+ const script = (_b = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName]) === null || _b === void 0 ? void 0 : _b.script;
970
950
  if (!script) {
971
- return null;
951
+ const scope = this.getScopeByOwnerId(executable.ownerId);
952
+ const scopeText = scope ? ` in ${scope}` : '';
953
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
972
954
  }
973
- return this.executeProcessorScript(request, script, processor.inputData);
955
+ return this.executeProcessorScript(request, script, executable.inputData);
974
956
  }
975
- executeSelectorScript(request, processor) {
976
- var _a, _b, _c;
977
- const { selectors } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
978
- const script = (_c = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.name)) === null || _c === void 0 ? void 0 : _c.script;
957
+ executeSelectorScript(request, executable) {
958
+ var _a, _b;
959
+ const script = (_b = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName]) === null || _b === void 0 ? void 0 : _b.script;
979
960
  if (!script) {
980
- return null;
961
+ const scope = this.getScopeByOwnerId(executable.ownerId);
962
+ const scopeText = scope ? ` in ${scope}` : '';
963
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
981
964
  }
982
- return this.executeProcessorScript(request, script, processor.inputData);
965
+ return this.executeProcessorScript(request, script, executable.inputData);
983
966
  }
984
967
  executeProcessorScript(request, script, inputData) {
985
968
  return new Function(`${script}\nreturn transform;`)()({
@@ -988,47 +971,82 @@ class ConfigurationState {
988
971
  });
989
972
  }
990
973
  }
991
- ConfigurationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, deps: [{ token: i1.StatefulConfigurationApiService }, { token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: i4.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
992
- ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState });
993
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationState, decorators: [{
994
- type: Injectable
995
- }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i4.ToastService }]; } });
974
+ FlowStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, deps: [{ token: ContextService }, { token: QuoteDraftService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.ConfigurationProcessorsApiService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
975
+ FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, providedIn: 'root' });
976
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
977
+ type: Injectable,
978
+ args: [{ providedIn: 'root' }]
979
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }]; } });
996
980
 
997
- function extractMetadata(uiDefinition) {
998
- return omit(uiDefinition, [
999
- 'children',
1000
- 'pages',
1001
- 'components',
1002
- ]);
981
+ function calculateMetricByMethod(lineItems, metric, method) {
982
+ const items = getLineItemsByMethod(lineItems, method);
983
+ return items.reduce((acc, li) => {
984
+ let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
985
+ if (method === 'avg' && li.length > 0) {
986
+ value /= li.length;
987
+ }
988
+ return acc + value;
989
+ }, 0);
1003
990
  }
1004
-
1005
- class FlowUpdateService {
1006
- update(rootLineItems, updates, charges) {
1007
- let remainingUpdates = [...updates];
1008
- let currentLevel = rootLineItems;
1009
- while (currentLevel.length && remainingUpdates.length) {
1010
- currentLevel.forEach(li => {
1011
- const unhandledUpdates = [];
1012
- remainingUpdates.forEach(update => {
1013
- let updated = false;
1014
- switch (update.dataType) {
1015
- case 'LINEITEM':
1016
- updated = this.applyLineItemUpdate(li, update, charges);
1017
- break;
1018
- case 'CHARGE':
1019
- updated = this.applyChargeUpdate(li, update);
1020
- break;
1021
- case 'GROUP_CHARGE':
1022
- updated = this.applyChargeGroupUpdate(li, update);
1023
- break;
1024
- default:
1025
- // Unknown dataType. Do not try to handle it anymore
1026
- updated = true;
1027
- }
1028
- if (!updated) {
1029
- unhandledUpdates.push(update);
1030
- }
1031
- });
991
+ function getLineItemsByMethod(lineItems, method) {
992
+ switch (method) {
993
+ case 'first': {
994
+ return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
995
+ }
996
+ case 'last': {
997
+ const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
998
+ const products = rootTermItems.map(lineItem => [
999
+ lineItem,
1000
+ ...lineItems.filter(li => li.rampInstanceId === lineItem.id),
1001
+ ]);
1002
+ return products
1003
+ .map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
1004
+ .filter((li) => Boolean(li))
1005
+ .map(item => [item]);
1006
+ }
1007
+ case 'avg': {
1008
+ const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1009
+ return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
1010
+ }
1011
+ case 'sum': {
1012
+ return lineItems.map(item => [item]);
1013
+ }
1014
+ default: {
1015
+ return lineItems.map(item => [item]);
1016
+ }
1017
+ }
1018
+ }
1019
+ function getDateValue(date) {
1020
+ return date ? new Date(date).getTime() : 0;
1021
+ }
1022
+
1023
+ class FlowUpdateService {
1024
+ update(rootLineItems, updates, charges) {
1025
+ let remainingUpdates = [...updates];
1026
+ let currentLevel = rootLineItems;
1027
+ while (currentLevel.length && remainingUpdates.length) {
1028
+ currentLevel.forEach(li => {
1029
+ const unhandledUpdates = [];
1030
+ remainingUpdates.forEach(update => {
1031
+ let updated = false;
1032
+ switch (update.dataType) {
1033
+ case 'LINEITEM':
1034
+ updated = this.applyLineItemUpdate(li, update, charges);
1035
+ break;
1036
+ case 'CHARGE':
1037
+ updated = this.applyChargeUpdate(li, update);
1038
+ break;
1039
+ case 'GROUP_CHARGE':
1040
+ updated = this.applyChargeGroupUpdate(li, update);
1041
+ break;
1042
+ default:
1043
+ // Unknown dataType. Do not try to handle it anymore
1044
+ updated = true;
1045
+ }
1046
+ if (!updated) {
1047
+ unhandledUpdates.push(update);
1048
+ }
1049
+ });
1032
1050
  remainingUpdates = unhandledUpdates;
1033
1051
  });
1034
1052
  currentLevel = flatten(currentLevel.map(parent => parent.lineItems));
@@ -1128,113 +1146,436 @@ class FlowUpdateService {
1128
1146
  return true;
1129
1147
  }
1130
1148
  }
1131
- FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1132
- FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService });
1133
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowUpdateService, decorators: [{
1149
+ FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1150
+ FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService });
1151
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, decorators: [{
1134
1152
  type: Injectable
1135
1153
  }] });
1136
1154
 
1137
- class FlowConfigurationService {
1138
- constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1139
- this.proceduresApiService = proceduresApiService;
1140
- this.contextService = contextService;
1141
- this.quoteDraftService = quoteDraftService;
1142
- this.updateService = updateService;
1143
- this.configurationService = configurationService;
1155
+ class RuntimeSettingsService {
1156
+ constructor(configurationSettingsApiService) {
1157
+ this.configurationSettingsApiService = configurationSettingsApiService;
1158
+ this.configurationSettings$ = new BehaviorSubject({});
1159
+ this.currencySettings$ = new BehaviorSubject({
1160
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1161
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1162
+ });
1163
+ this.shoppingCartSettings$ = new BehaviorSubject([]);
1164
+ this.getCurrencySymbol = (locale, currency) => {
1165
+ return (0)
1166
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1167
+ .replace(/\d/g, '')
1168
+ .trim();
1169
+ };
1144
1170
  }
1145
- calculate$(quoteDraft) {
1146
- return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1147
- // sort the result current state based on the quote draft initial state
1148
- const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1149
- result.currentState = result.currentState
1150
- .slice()
1151
- .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1152
- this.quoteDraftService.updateQuoteDraft(result);
1153
- }), map$2(noop));
1171
+ create() {
1172
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1173
+ var _a;
1174
+ this.configurationSettings$.next(configurationSettings);
1175
+ this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
1176
+ this.formattingSettings = this.getFormattingSettings();
1177
+ }), map$1(() => undefined));
1154
1178
  }
1155
- calculate(quoteDraft) {
1156
- this.calculate$(quoteDraft).subscribe();
1179
+ initCurrency(iso) {
1180
+ if (iso) {
1181
+ const symbol = this.getCurrencySymbol('en-US', iso);
1182
+ this.currencySettings$.next({ iso, symbol });
1183
+ }
1157
1184
  }
1158
- update$(updates) {
1159
- const quoteDraft = this.quoteDraftService.quoteDraft;
1160
- if (!quoteDraft) {
1161
- return of(null);
1185
+ getFormattingSettings() {
1186
+ var _a, _b;
1187
+ if (this.formattingSettings) {
1188
+ return this.formattingSettings;
1162
1189
  }
1163
- return of([]).pipe(map$2(() => {
1164
- const updatedState = cloneDeep(quoteDraft.currentState);
1165
- this.updateService.update(updatedState, updates, quoteDraft.charges);
1166
- return updatedState;
1167
- }), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1190
+ const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
1191
+ return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
1192
+ }, {});
1193
+ const currencySettings = this.getCurrencySettings();
1194
+ const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
1195
+ DEFAULT_DATE_FORMAT;
1196
+ const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
1197
+ const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
1198
+ // the number of decimal places can be 0
1199
+ const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
1200
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1201
+ ? Number(priceScale)
1202
+ : DEFAULT_DECIMALS_COUNT;
1203
+ const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
1204
+ return {
1205
+ currencySymbol: currencySettings.symbol,
1206
+ dateFormats: getSupportedDateFormats(dateFormat),
1207
+ decimalsCount,
1208
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1209
+ ? decimalSeparator
1210
+ : DEFAULT_DECIMAL_SEPARATOR,
1211
+ // thousands separator can be a blank value, so it can also be null
1212
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1213
+ ? thousandsSeparator || ''
1214
+ : DEFAULT_THOUSANDS_SEPARATOR,
1215
+ actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
1216
+ ? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
1217
+ : DEFAULT_ACTION_CODE_LABELS,
1218
+ };
1168
1219
  }
1169
- update(updates) {
1170
- this.update$(updates).subscribe();
1220
+ getConfigurationSettings() {
1221
+ return this.configurationSettings$.value;
1171
1222
  }
1172
- revert$(lineItemId) {
1173
- const quoteDraft = this.quoteDraftService.quoteDraft;
1174
- const initialCurrentState = this.quoteDraftService.getInitialCurrentState();
1175
- const currentState = this.quoteDraftService.activeCurrentState;
1176
- const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
1177
- const currentLineItem = currentState[currentLineItemIndex];
1178
- const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === (currentLineItem === null || currentLineItem === void 0 ? void 0 : currentLineItem.integrationId));
1179
- if (!quoteDraft || !currentLineItem || !initialLineItem) {
1180
- return of(null);
1181
- }
1182
- const updatedState = cloneDeep(currentState);
1183
- updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1184
- return of([]).pipe(tap$1(() => {
1185
- this.quoteDraftService.setCurrentLineItemState(updatedState);
1186
- }), switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1223
+ getShoppingCartSettings() {
1224
+ return this.shoppingCartSettings$.value;
1187
1225
  }
1188
- revert(lineItemId) {
1189
- this.revert$(lineItemId).subscribe();
1226
+ getCurrencySettings() {
1227
+ return this.currencySettings$.value;
1190
1228
  }
1191
- delete$(ids) {
1192
- const quoteDraft = this.quoteDraftService.quoteDraft;
1193
- const currentState = this.quoteDraftService.currentState;
1194
- if (!quoteDraft) {
1195
- return of(null);
1196
- }
1197
- return of([]).pipe(map$2(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1229
+ parseConfigurationSettings(settings) {
1230
+ return settings.reduce((acc, setting) => {
1231
+ switch (setting.key) {
1232
+ case 'shopping-cart':
1233
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1234
+ break;
1235
+ case 'navigation':
1236
+ acc.navigation = parseJsonSafely(setting.value, {});
1237
+ break;
1238
+ case 'flows':
1239
+ acc.flows = parseJsonSafely(setting.value, []);
1240
+ break;
1241
+ default:
1242
+ acc[setting.key] = setting.value;
1243
+ }
1244
+ return acc;
1245
+ }, {});
1198
1246
  }
1199
- delete(ids) {
1200
- this.delete$(ids).subscribe();
1247
+ addShoppingCartSettings(settings) {
1248
+ // uniqBy removes items with the biggest index
1249
+ const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
1250
+ this.shoppingCartSettings$.next(newSettings);
1201
1251
  }
1202
- addTerm$(term) {
1203
- const quoteDraft = this.quoteDraftService.quoteDraft;
1204
- if (!quoteDraft) {
1205
- return of(null);
1206
- }
1207
- const updatedState = [...quoteDraft.currentState, term];
1208
- return of([]).pipe(switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1252
+ }
1253
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1254
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1255
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1256
+ type: Injectable,
1257
+ args: [{ providedIn: 'root' }]
1258
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1259
+
1260
+ class ConfigurationService {
1261
+ constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
1262
+ this.quoteDraftService = quoteDraftService;
1263
+ this.runtimeService = runtimeService;
1264
+ this.contextService = contextService;
1265
+ this.configurationApiService = configurationApiService;
1266
+ this.messageService = messageService;
1267
+ this.dialogService = dialogService;
1268
+ this.runtimeSettings = runtimeSettings;
1269
+ this.mode = ConfigurationMode.SEARCH;
1270
+ this.lineItem = new BehaviorSubject(undefined);
1271
+ this.charges = new BehaviorSubject({});
1272
+ this.pricePlans = new BehaviorSubject({});
1273
+ this.procedureContext = new BehaviorSubject({});
1274
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1275
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1276
+ this.hasUnsavedChanges = false;
1209
1277
  }
1210
- addToCart$(props) {
1211
- const quoteDraft = this.quoteDraftService.quoteDraft;
1212
- if (!quoteDraft) {
1213
- return of(null);
1278
+ reset() {
1279
+ this.hasUnsavedChanges = false;
1280
+ this.runtimeService.reset();
1281
+ this.configurableRamp = undefined;
1282
+ this.lineItem.next(undefined);
1283
+ this.charges.next({});
1284
+ this.pricePlans.next({});
1285
+ }
1286
+ patch$(lineItem, options) {
1287
+ if (!this.lineItem.value) {
1288
+ return throwError(() => new Error(`Source LineItem not found`));
1214
1289
  }
1215
- return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
1216
- var _a, _b, _c;
1217
- const model = this.configurationService.getRuntimeModel();
1218
- const split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(type => type.name === lineItem.type)) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
1219
- const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
1220
- return [...quoteDraft.currentState, ...lineItems];
1221
- }), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1290
+ const skipCardinalityCalculation = (options === null || options === void 0 ? void 0 : options.skipCardinalityCalculation) || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
1291
+ this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
1292
+ return this.configure().pipe(catchError$1(error => {
1293
+ console.error(error);
1294
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1295
+ this.messageService.add({ severity: 'error', summary: error });
1296
+ }
1297
+ // bounce back if configuration call has failed
1298
+ this.lineItem.next(this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined);
1299
+ return throwError(() => error);
1300
+ }), tap(() => {
1301
+ if (!this.hasUnsavedChanges) {
1302
+ this.hasUnsavedChanges = true;
1303
+ }
1304
+ }));
1222
1305
  }
1223
- get() {
1224
- return this.quoteDraftService.quoteDraft$.pipe(map$2(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1306
+ patch(lineItem, options) {
1307
+ this.patch$(lineItem, options).subscribe();
1225
1308
  }
1226
- getSnapshot() {
1227
- var _a, _b;
1228
- return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
1309
+ setConfigurableRamp(lineItem) {
1310
+ this.configurableRamp = lineItem;
1229
1311
  }
1230
- get charges$() {
1231
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ charges }) => charges));
1312
+ get() {
1313
+ return this.lineItem.asObservable().pipe(shareReplay$1());
1232
1314
  }
1233
- get pricePlans$() {
1234
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ pricePlans }) => pricePlans));
1315
+ getSnapshot() {
1316
+ return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
1235
1317
  }
1236
- get activeMetrics$() {
1237
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ activeMetrics }) => activeMetrics));
1318
+ getRuntimeModel() {
1319
+ const runtimeModel = this.runtimeService.runtimeModel;
1320
+ if (!runtimeModel) {
1321
+ throw new Error('Runtime model not initialized');
1322
+ }
1323
+ return runtimeModel;
1324
+ }
1325
+ getRuntimeContext() {
1326
+ const runtimeContext = this.runtimeService.runtimeContext;
1327
+ if (!runtimeContext) {
1328
+ throw new Error('Runtime context not initialized');
1329
+ }
1330
+ return runtimeContext;
1331
+ }
1332
+ get contextSnapshot() {
1333
+ return this.contextService.resolve();
1334
+ }
1335
+ get context$() {
1336
+ return this.contextService.resolve$();
1337
+ }
1338
+ get charges$() {
1339
+ return this.charges.asObservable();
1340
+ }
1341
+ get chargesSnapshot() {
1342
+ return this.charges.value;
1343
+ }
1344
+ get pricePlans$() {
1345
+ return this.pricePlans.asObservable();
1346
+ }
1347
+ get pricePlansSnapshot() {
1348
+ return this.pricePlans.value;
1349
+ }
1350
+ get procedureContext$() {
1351
+ return this.procedureContext.asObservable();
1352
+ }
1353
+ get procedureContextSnapshot() {
1354
+ return this.procedureContext.value;
1355
+ }
1356
+ configure() {
1357
+ return this.configureRequest$(this.generateRequest());
1358
+ }
1359
+ configureRequest$(configurationRequest) {
1360
+ var _a;
1361
+ const runtimeContext = this.getRuntimeContext();
1362
+ const runtimeModel = this.getRuntimeModel();
1363
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1364
+ const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
1365
+ const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
1366
+ const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
1367
+ this.isLoadingSubj$.next(true);
1368
+ const configure$ = pricingEnabled && customPriceApi
1369
+ ? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
1370
+ : this.configurationApiService.configureLineItem({
1371
+ configurationRequest,
1372
+ runtimeModel,
1373
+ pricingEnabled,
1374
+ });
1375
+ return configure$.pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems, procedureContext }) => {
1376
+ this.contextService.update(context !== null && context !== void 0 ? context : {});
1377
+ this.charges.next(charges !== null && charges !== void 0 ? charges : {});
1378
+ this.pricePlans.next(pricePlans !== null && pricePlans !== void 0 ? pricePlans : {});
1379
+ this.procedureContext.next(procedureContext !== null && procedureContext !== void 0 ? procedureContext : {});
1380
+ if (lineItem) {
1381
+ this.lineItem.next(lineItem);
1382
+ }
1383
+ if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
1384
+ this.showInactiveProductsConfirmation();
1385
+ }
1386
+ this.configurableRamp = lineItem;
1387
+ }), map(({ lineItem }) => lineItem), catchError$1(error => throwError(() => { var _a; return new Error(((_a = error.error) === null || _a === void 0 ? void 0 : _a.message) || error.message || JSON.stringify(error)); })), finalize(() => this.isLoadingSubj$.next(false)));
1388
+ }
1389
+ configureExternal$(props) {
1390
+ return this.runtimeService
1391
+ .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
1392
+ .pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
1393
+ this.messageService.add({ severity: ToastType.error, summary: error });
1394
+ throw error;
1395
+ }), finalize(() => this.reset()));
1396
+ }
1397
+ configureGuidedSelling$(data) {
1398
+ return this.configurationApiService
1399
+ .configureLineItem({
1400
+ configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
1401
+ })
1402
+ .pipe(catchError$1(error => {
1403
+ if (error instanceof HttpErrorResponse) {
1404
+ this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
1405
+ }
1406
+ throw error;
1407
+ }));
1408
+ }
1409
+ generateRequest() {
1410
+ var _a, _b;
1411
+ const runtimeContext = this.getRuntimeContext();
1412
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1413
+ let lineItem = this.configurableRamp;
1414
+ if (!lineItem) {
1415
+ const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
1416
+ lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
1417
+ // Set default attributes
1418
+ if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
1419
+ const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
1420
+ lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
1421
+ }
1422
+ }
1423
+ let request = {
1424
+ lineItem,
1425
+ mode: this.mode,
1426
+ step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
1427
+ attributeDomainMode: 'ALL',
1428
+ context: this.contextService.resolve(),
1429
+ lineItems: ((_b = this.quoteDraftService.quoteDraft) === null || _b === void 0 ? void 0 : _b.currentState) || [],
1430
+ asset: this.getAsset(),
1431
+ };
1432
+ request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
1433
+ return request;
1434
+ }
1435
+ getUIDefinitionProperties() {
1436
+ var _a, _b, _c;
1437
+ return Object.assign(Object.assign({}, ((_b = (_a = this.getRuntimeContext().uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {})), ((_c = this.runtimeService.uiDefinitionProperties) !== null && _c !== void 0 ? _c : {}));
1438
+ }
1439
+ showInactiveProductsConfirmation() {
1440
+ const confirmationConfig = {
1441
+ title: ' ',
1442
+ description: 'This quote contains inactive products. Do you want to remove them?',
1443
+ primaryButtonLabel: 'Remove products',
1444
+ secondaryButtonLabel: 'Back to Quote',
1445
+ };
1446
+ this.dialogService
1447
+ .open(ConfirmationComponent, {
1448
+ dismissableMask: false,
1449
+ closeOnEscape: false,
1450
+ closable: false,
1451
+ showHeader: true,
1452
+ header: `Inactive Products in Quote`,
1453
+ width: '440px',
1454
+ data: { confirmationConfig },
1455
+ })
1456
+ .onClose.subscribe(result => {
1457
+ if (!result) {
1458
+ const context = this.contextService.resolve();
1459
+ window['VELO_BACK_FN'].apply(null, [context.headerId]);
1460
+ }
1461
+ });
1462
+ }
1463
+ getAsset() {
1464
+ var _a;
1465
+ const lineItem = this.configurableRamp;
1466
+ if (!lineItem) {
1467
+ return;
1468
+ }
1469
+ return (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
1470
+ }
1471
+ }
1472
+ ConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, deps: [{ token: QuoteDraftService }, { token: ConfigurationRuntimeService }, { token: ContextService }, { token: i1.ConfigurationApiService }, { token: i5.MessageService }, { token: i6$1.DialogService }, { token: RuntimeSettingsService }], target: i0.ɵɵFactoryTarget.Injectable });
1473
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1474
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1475
+ type: Injectable
1476
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1477
+
1478
+ class FlowConfigurationService {
1479
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1480
+ this.proceduresApiService = proceduresApiService;
1481
+ this.contextService = contextService;
1482
+ this.quoteDraftService = quoteDraftService;
1483
+ this.updateService = updateService;
1484
+ this.configurationService = configurationService;
1485
+ }
1486
+ calculate$(quoteDraft) {
1487
+ return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1488
+ // sort the result current state based on the quote draft initial state
1489
+ const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1490
+ result.currentState = result.currentState
1491
+ .slice()
1492
+ .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1493
+ this.quoteDraftService.updateQuoteDraft(result);
1494
+ }), map$1(noop));
1495
+ }
1496
+ calculate(quoteDraft) {
1497
+ this.calculate$(quoteDraft).subscribe();
1498
+ }
1499
+ update$(updates) {
1500
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1501
+ if (!quoteDraft) {
1502
+ return of(null);
1503
+ }
1504
+ return of([]).pipe(map$1(() => {
1505
+ const updatedState = cloneDeep(quoteDraft.currentState);
1506
+ this.updateService.update(updatedState, updates, quoteDraft.charges);
1507
+ return updatedState;
1508
+ }), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1509
+ }
1510
+ update(updates) {
1511
+ this.update$(updates).subscribe();
1512
+ }
1513
+ revert$(lineItemId) {
1514
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1515
+ const initialCurrentState = this.quoteDraftService.getInitialCurrentState();
1516
+ const currentState = this.quoteDraftService.activeCurrentState;
1517
+ const currentLineItemIndex = currentState.findIndex(({ id }) => id === lineItemId);
1518
+ const currentLineItem = currentState[currentLineItemIndex];
1519
+ const initialLineItem = initialCurrentState.find(({ integrationId }) => integrationId === (currentLineItem === null || currentLineItem === void 0 ? void 0 : currentLineItem.integrationId));
1520
+ if (!quoteDraft || !currentLineItem || !initialLineItem) {
1521
+ return of(null);
1522
+ }
1523
+ const updatedState = cloneDeep(currentState);
1524
+ updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1525
+ return of([]).pipe(tap$1(() => {
1526
+ this.quoteDraftService.setCurrentLineItemState(updatedState);
1527
+ }), switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1528
+ }
1529
+ revert(lineItemId) {
1530
+ this.revert$(lineItemId).subscribe();
1531
+ }
1532
+ delete$(ids) {
1533
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1534
+ const currentState = this.quoteDraftService.currentState;
1535
+ if (!quoteDraft) {
1536
+ return of(null);
1537
+ }
1538
+ return of([]).pipe(map$1(() => ids.reduce((result, id) => this.updateService.delete(result, id), currentState)), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1539
+ }
1540
+ delete(ids) {
1541
+ this.delete$(ids).subscribe();
1542
+ }
1543
+ addTerm$(term) {
1544
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1545
+ if (!quoteDraft) {
1546
+ return of(null);
1547
+ }
1548
+ const updatedState = [...quoteDraft.currentState, term];
1549
+ return of([]).pipe(switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1550
+ }
1551
+ addToCart$(props) {
1552
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1553
+ if (!quoteDraft) {
1554
+ return of(null);
1555
+ }
1556
+ return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
1557
+ var _a, _b, _c;
1558
+ const model = this.configurationService.getRuntimeModel();
1559
+ const split = (_b = (_a = model === null || model === void 0 ? void 0 : model.types.find(type => type.name === lineItem.type)) === null || _a === void 0 ? void 0 : _a.split) !== null && _b !== void 0 ? _b : false;
1560
+ const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
1561
+ return [...quoteDraft.currentState, ...lineItems];
1562
+ }), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1563
+ }
1564
+ get() {
1565
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1566
+ }
1567
+ getSnapshot() {
1568
+ var _a, _b;
1569
+ return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
1570
+ }
1571
+ get charges$() {
1572
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
1573
+ }
1574
+ get pricePlans$() {
1575
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
1576
+ }
1577
+ get activeMetrics$() {
1578
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
1238
1579
  }
1239
1580
  get chargesSnapshot() {
1240
1581
  var _a, _b;
@@ -1254,32 +1595,390 @@ class FlowConfigurationService {
1254
1595
  get context$() {
1255
1596
  return this.contextService.resolve$();
1256
1597
  }
1257
- handleErrorAndBounceBack() {
1258
- return (source$) => {
1259
- return source$.pipe(catchError$1(error => {
1260
- console.error(error);
1261
- // bounce back if configuration call has failed
1262
- const quoteDraft = this.quoteDraftService.quoteDraft;
1263
- if (quoteDraft) {
1264
- this.quoteDraftService.updateQuoteDraft(quoteDraft);
1265
- }
1266
- return throwError(() => error);
1267
- }));
1268
- };
1598
+ handleErrorAndBounceBack() {
1599
+ return (source$) => {
1600
+ return source$.pipe(catchError(error => {
1601
+ console.error(error);
1602
+ // bounce back if configuration call has failed
1603
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1604
+ if (quoteDraft) {
1605
+ this.quoteDraftService.updateQuoteDraft(quoteDraft);
1606
+ }
1607
+ return throwError(() => error);
1608
+ }));
1609
+ };
1610
+ }
1611
+ }
1612
+ FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1613
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1614
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1615
+ type: Injectable
1616
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1617
+
1618
+ class MetricsCalculationService {
1619
+ get onMetricsUpdate$() {
1620
+ return this.metricsUpdated$.asObservable();
1621
+ }
1622
+ constructor(quoteDraftService, flowConfiguration, settingsService) {
1623
+ this.quoteDraftService = quoteDraftService;
1624
+ this.flowConfiguration = flowConfiguration;
1625
+ this.settingsService = settingsService;
1626
+ this.metricsUpdated$ = new Subject();
1627
+ this.quoteMetricsSettings = {};
1628
+ this.metricsCalculationMethodMap = {};
1629
+ this.metricsData = {};
1630
+ this.activeMetricRules = [];
1631
+ this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
1632
+ combineLatest([
1633
+ this.quoteDraftService.currentState$,
1634
+ this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
1635
+ ]).subscribe(([lineItems, setting]) => {
1636
+ let settingsData = {};
1637
+ try {
1638
+ settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
1639
+ }
1640
+ catch (error) {
1641
+ settingsData = {};
1642
+ }
1643
+ this.quoteMetricsSettings = settingsData;
1644
+ this.updateMetrics(lineItems);
1645
+ });
1646
+ }
1647
+ getMetricValue(metric) {
1648
+ return this.metricsData[metric] || 0;
1649
+ }
1650
+ updateMetrics(lineItems) {
1651
+ const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
1652
+ this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1653
+ this.metricsData = metricKeys.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: this.calculateMetric(lineItems, key) })), {});
1654
+ this.metricsUpdated$.next();
1655
+ }
1656
+ calculateMetric(lineItems, metric) {
1657
+ return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
1658
+ }
1659
+ buildMetricsCalculationMethods(metricKeys, initial) {
1660
+ return metricKeys.reduce((acc, name) => {
1661
+ var _a, _b;
1662
+ if (acc[name]) {
1663
+ return acc;
1664
+ }
1665
+ acc = Object.assign(Object.assign({}, acc), { [name]: 'sum' });
1666
+ const metricRule = this.getMetricRuleByTotalMetricName(name);
1667
+ const settingKey = ((_b = (_a = metricRule === null || metricRule === void 0 ? void 0 : metricRule.metrics) === null || _a === void 0 ? void 0 : _a.find(metric => metric.totalName === name)) === null || _b === void 0 ? void 0 : _b.name) || name;
1668
+ if (this.quoteMetricsSettings[settingKey]) {
1669
+ acc = Object.assign(Object.assign({}, acc), { [name]: this.quoteMetricsSettings[settingKey] });
1670
+ }
1671
+ return acc;
1672
+ }, initial);
1673
+ }
1674
+ collectMetricKeys(lineItems) {
1675
+ const keys = [];
1676
+ lineItems.forEach(lineItem => {
1677
+ keys.push(...Object.keys(lineItem.totalMetrics || {}));
1678
+ keys.push(...this.collectMetricKeys(lineItem.lineItems));
1679
+ });
1680
+ return uniq(keys);
1681
+ }
1682
+ getMetricRuleByTotalMetricName(name) {
1683
+ return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
1684
+ }
1685
+ }
1686
+ MetricsCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: FlowConfigurationService }, { token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1687
+ MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
1688
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: MetricsCalculationService, decorators: [{
1689
+ type: Injectable,
1690
+ args: [{ providedIn: 'root' }]
1691
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
1692
+
1693
+ class ProductImagesService {
1694
+ constructor(productApiService) {
1695
+ this.productApiService = productApiService;
1696
+ this.imagesMap$ = new BehaviorSubject({});
1697
+ }
1698
+ getImageUrl$(productId) {
1699
+ if (this.imagesMap$.value[productId] == null) {
1700
+ this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
1701
+ this.fetchProductImage(productId);
1702
+ }
1703
+ return this.imagesMap$.pipe(map$1(imagesMap => imagesMap[productId]), distinctUntilChanged());
1704
+ }
1705
+ fetchProductImage(productId) {
1706
+ this.productApiService
1707
+ .fetchImage$(productId)
1708
+ .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
1709
+ .subscribe();
1710
+ }
1711
+ }
1712
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1713
+ ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
1714
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
1715
+ type: Injectable,
1716
+ args: [{ providedIn: 'root' }]
1717
+ }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1718
+
1719
+ class RuntimeContextService {
1720
+ constructor(configurationApiService) {
1721
+ this.configurationApiService = configurationApiService;
1722
+ }
1723
+ getRuntimeContext(productId, offeringId) {
1724
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
1725
+ var _a;
1726
+ const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
1727
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
1728
+ const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
1729
+ const uiDefinitionProperties = uiDefinitionContainer === null || uiDefinitionContainer === void 0 ? void 0 : uiDefinitionContainer.source.properties;
1730
+ return {
1731
+ modelId: runtimeData.modelId,
1732
+ uiDefinitionContainer: uiDefinitionContainer,
1733
+ runtimeModel: runtimeModel,
1734
+ runtimeMode: RuntimeMode.PROD,
1735
+ productId: productId,
1736
+ productType: (properties === null || properties === void 0 ? void 0 : properties['displayName']) || productName,
1737
+ offeringId: offeringId,
1738
+ properties: {
1739
+ PricingEnabled: (uiDefinitionProperties === null || uiDefinitionProperties === void 0 ? void 0 : uiDefinitionProperties.pricingEnabled) ? 'true' : 'false',
1740
+ PriceListId: uiDefinitionProperties === null || uiDefinitionProperties === void 0 ? void 0 : uiDefinitionProperties.priceList,
1741
+ },
1742
+ };
1743
+ }));
1744
+ }
1745
+ getUIDefinitionContainer(runtimeData) {
1746
+ var _a;
1747
+ const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
1748
+ return (_a = containers.find(container => container.source.primary)) !== null && _a !== void 0 ? _a : containers[0];
1749
+ }
1750
+ }
1751
+ RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1752
+ RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
1753
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
1754
+ type: Injectable
1755
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
1756
+
1757
+ class ConfigurationRuntimeService {
1758
+ constructor(apiService, contextService, runtimeContextService) {
1759
+ this.apiService = apiService;
1760
+ this.contextService = contextService;
1761
+ this.runtimeContextService = runtimeContextService;
1762
+ this._isInitialized = false;
1763
+ this.uiDefinitionProperties = {};
1764
+ }
1765
+ reset() {
1766
+ this._isInitialized = false;
1767
+ this._runtimeContext = undefined;
1768
+ this.initializationProps = undefined;
1769
+ this.uiDefinitionProperties = {};
1770
+ }
1771
+ initTestMode(uiDefinitionContainer) {
1772
+ var _a, _b;
1773
+ this.uiDefinitionProperties = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
1774
+ const uiDefinitionExternals = (_b = uiDefinitionContainer.source.externals) !== null && _b !== void 0 ? _b : {};
1775
+ return combineLatest([
1776
+ this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
1777
+ this.contextService.initTestMode(),
1778
+ ]).pipe(first(), map(([runtimeData, context]) => {
1779
+ var _a;
1780
+ this.contextService.update({
1781
+ properties: Object.assign(Object.assign(Object.assign(Object.assign({}, (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.properties), context.properties), { ModelId: uiDefinitionContainer.modelId, PricingEnabled: this.uiDefinitionProperties.pricingEnabled ? 'true' : 'false', PriceListId: this.uiDefinitionProperties.priceList, offeringId: this.uiDefinitionProperties.offeringId }), uiDefinitionExternals),
1782
+ });
1783
+ this._runtimeContext = {
1784
+ modelId: uiDefinitionContainer.modelId,
1785
+ runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
1786
+ runtimeMode: RuntimeMode.TEST,
1787
+ uiDefinitionContainer,
1788
+ };
1789
+ return this._runtimeContext;
1790
+ }), tap(() => (this._isInitialized = true)));
1791
+ }
1792
+ init(props) {
1793
+ this.initializationProps = props;
1794
+ const context = this.contextService.resolve();
1795
+ return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
1796
+ var _a, _b, _c, _d;
1797
+ this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
1798
+ const { PriceListId } = (_c = context.properties) !== null && _c !== void 0 ? _c : {};
1799
+ const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
1800
+ this.id15to18('AccountId', mergeContext.properties);
1801
+ this._runtimeContext = mergeContext;
1802
+ if (context.properties && ((_d = this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
1803
+ this.contextService.update({
1804
+ properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
1805
+ });
1806
+ }
1807
+ return this._runtimeContext;
1808
+ }), tap(() => (this._isInitialized = true)));
1809
+ }
1810
+ overrideUIDefinition(uiDefinitionContainer) {
1811
+ var _a;
1812
+ if (!this._runtimeContext) {
1813
+ return;
1814
+ }
1815
+ this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
1816
+ this.uiDefinitionProperties = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
1817
+ }
1818
+ id15to18(propertyName, source) {
1819
+ if (!source) {
1820
+ return;
1821
+ }
1822
+ const value = source[propertyName];
1823
+ if (typeof value === 'string' && value.length === 15) {
1824
+ source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
1825
+ }
1826
+ }
1827
+ get isInitialized() {
1828
+ return this._isInitialized;
1829
+ }
1830
+ get runtimeModel() {
1831
+ var _a;
1832
+ return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
1833
+ }
1834
+ get runtimeContext() {
1835
+ return this._runtimeContext;
1836
+ }
1837
+ }
1838
+ ConfigurationRuntimeService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, deps: [{ token: i1.ConfigurationApiService }, { token: ContextService }, { token: RuntimeContextService }], target: i0.ɵɵFactoryTarget.Injectable });
1839
+ ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
1840
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
1841
+ type: Injectable
1842
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
1843
+
1844
+ class ConfigurationState {
1845
+ constructor(statefulConfigurationApiService, runtimeService, configurationService, toastService) {
1846
+ this.statefulConfigurationApiService = statefulConfigurationApiService;
1847
+ this.runtimeService = runtimeService;
1848
+ this.configurationService = configurationService;
1849
+ this.toastService = toastService;
1850
+ this.stateSubj$ = new BehaviorSubject({});
1851
+ this.state$ = this.stateSubj$.asObservable();
1852
+ this.stateId = null;
1853
+ }
1854
+ init$() {
1855
+ return this.configurationService.configure().pipe(switchMap(() => {
1856
+ var _a, _b;
1857
+ if (!this.isStatefulConfiguration) {
1858
+ return of(undefined);
1859
+ }
1860
+ const { actions, selectors } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
1861
+ return this.statefulConfigurationApiService.init({
1862
+ item: this.configurationService.generateRequest(),
1863
+ actions: actions === null || actions === void 0 ? void 0 : actions.map(action => ({ name: action.apiName, script: action.script })),
1864
+ selectors: selectors === null || selectors === void 0 ? void 0 : selectors.map(selector => ({ name: selector.apiName, script: selector.script })),
1865
+ });
1866
+ }), tap$1(stateId => (this.stateId = stateId || null)), map$1(() => undefined));
1867
+ }
1868
+ cleanup() {
1869
+ this.stateId = null;
1870
+ this.configurationService.reset();
1871
+ this.stateSubj$.next({});
1872
+ }
1873
+ execute$(req) {
1874
+ if (this.isStatefulConfiguration) {
1875
+ return this.executeStateful$(req);
1876
+ }
1877
+ else {
1878
+ return this.executeStateless$(req);
1879
+ }
1880
+ }
1881
+ dispatch$(actionName, inputData) {
1882
+ return this.execute$({ actions: [{ name: actionName, inputData }] });
1883
+ }
1884
+ select$(selectorName, inputData) {
1885
+ const requestId = UUID.UUID();
1886
+ return this.execute$({
1887
+ selectors: {
1888
+ [requestId]: {
1889
+ name: selectorName,
1890
+ inputData,
1891
+ },
1892
+ },
1893
+ }).pipe(map$1(() => this.stateSubj$.value[requestId]), tap$1(() => this.stateSubj$.next(omit(this.stateSubj$.value, requestId))));
1894
+ }
1895
+ get isStatefulConfiguration() {
1896
+ var _a;
1897
+ return (_a = this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled) !== null && _a !== void 0 ? _a : false;
1898
+ }
1899
+ executeStateless$(request) {
1900
+ return of(undefined).pipe(switchMap(() => {
1901
+ var _a;
1902
+ // Apply actions and execute configuration/price call
1903
+ // No need to run configuration if no actions in the request
1904
+ if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
1905
+ return of(undefined);
1906
+ }
1907
+ let configurationRequest = this.configurationService.generateRequest();
1908
+ request.actions.forEach(action => {
1909
+ var _a;
1910
+ configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
1911
+ });
1912
+ return this.configurationService.configureRequest$(configurationRequest);
1913
+ }), tap$1(() => {
1914
+ if (!request.selectors) {
1915
+ return;
1916
+ }
1917
+ // Run selectors and apply them to the state
1918
+ const finalConfigurationRequest = this.configurationService.generateRequest();
1919
+ const selectorsResult = EntityUtil.entries(request.selectors).reduce((trunk, [key, selector]) => {
1920
+ trunk[key] = this.executeSelectorScript(finalConfigurationRequest, selector);
1921
+ return trunk;
1922
+ }, {});
1923
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.value), selectorsResult));
1924
+ }), map$1(() => undefined));
1925
+ }
1926
+ executeStateful$(request) {
1927
+ if (!this.stateId) {
1928
+ return of(undefined);
1929
+ }
1930
+ return this.statefulConfigurationApiService.execute(this.stateId, request).pipe(tap$1(response => {
1931
+ this.stateId = response.stateId;
1932
+ const updatedState = this.stateSubj$.value;
1933
+ EntityUtil.entries(response.selectors).forEach(([key, value]) => {
1934
+ if (!value.success) {
1935
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1936
+ this.toastService.add({ summary: value.errorMessage, severity: ToastType.error });
1937
+ }
1938
+ return;
1939
+ }
1940
+ updatedState[key] = value.result;
1941
+ });
1942
+ this.stateSubj$.next(updatedState);
1943
+ }), map$1(() => undefined));
1944
+ }
1945
+ executeActionScript(request, processor) {
1946
+ var _a, _b, _c;
1947
+ const { actions } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
1948
+ const script = (_c = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.name)) === null || _c === void 0 ? void 0 : _c.script;
1949
+ if (!script) {
1950
+ return null;
1951
+ }
1952
+ return this.executeProcessorScript(request, script, processor.inputData);
1953
+ }
1954
+ executeSelectorScript(request, processor) {
1955
+ var _a, _b, _c;
1956
+ const { selectors } = (_b = (_a = this.runtimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
1957
+ const script = (_c = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.name)) === null || _c === void 0 ? void 0 : _c.script;
1958
+ if (!script) {
1959
+ return null;
1960
+ }
1961
+ return this.executeProcessorScript(request, script, processor.inputData);
1962
+ }
1963
+ executeProcessorScript(request, script, inputData) {
1964
+ return new Function(`${script}\nreturn transform;`)()({
1965
+ request,
1966
+ inputData: inputData,
1967
+ });
1269
1968
  }
1270
1969
  }
1271
- FlowConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService, deps: [{ token: i1.ProceduresApiService }, { token: ContextService }, { token: QuoteDraftService }, { token: FlowUpdateService }, { token: ConfigurationService }], target: i0.ɵɵFactoryTarget.Injectable });
1272
- FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService });
1273
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationService, decorators: [{
1970
+ ConfigurationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState, deps: [{ token: i1.StatefulConfigurationApiService }, { token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: i6.ToastService }], target: i0.ɵɵFactoryTarget.Injectable });
1971
+ ConfigurationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState });
1972
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationState, decorators: [{
1274
1973
  type: Injectable
1275
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1974
+ }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i6.ToastService }]; } });
1276
1975
 
1277
1976
  class FlowConfigurationModule {
1278
1977
  }
1279
- FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1280
- FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule });
1281
- FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
1282
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1978
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1979
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule });
1980
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService, PriceApiService] });
1981
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1283
1982
  type: NgModule,
1284
1983
  args: [{
1285
1984
  imports: [],
@@ -1289,9 +1988,9 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1289
1988
 
1290
1989
  class ConfigurationModule {
1291
1990
  }
1292
- ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1293
- ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1294
- ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, providers: [
1991
+ ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1992
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule] });
1993
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [
1295
1994
  ContextApiService,
1296
1995
  ProductModelApiService,
1297
1996
  ConfigurationApiService,
@@ -1300,7 +1999,7 @@ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", ver
1300
1999
  ConfigurationService,
1301
2000
  ConfigurationState,
1302
2001
  ], imports: [ConfirmationDialogModule] });
1303
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
2002
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
1304
2003
  type: NgModule,
1305
2004
  args: [{
1306
2005
  imports: [ConfirmationDialogModule],
@@ -1316,271 +2015,31 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1316
2015
  }]
1317
2016
  }] });
1318
2017
 
1319
- function calculateMetricByMethod(lineItems, metric, method) {
1320
- const items = getLineItemsByMethod(lineItems, method);
1321
- return items.reduce((acc, li) => {
1322
- let value = li.reduce((accProduct, item) => accProduct + ((item.totalMetrics && item.totalMetrics[metric]) || 0), 0);
1323
- if (method === 'avg' && li.length > 0) {
1324
- value /= li.length;
1325
- }
1326
- return acc + value;
1327
- }, 0);
1328
- }
1329
- function getLineItemsByMethod(lineItems, method) {
1330
- switch (method) {
1331
- case 'first': {
1332
- return lineItems.filter(li => !li.rampInstanceId).map(item => [item]);
1333
- }
1334
- case 'last': {
1335
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1336
- const products = rootTermItems.map(lineItem => [
1337
- lineItem,
1338
- ...lineItems.filter(li => li.rampInstanceId === lineItem.id),
1339
- ]);
1340
- return products
1341
- .map(items => [...items].sort((a, b) => getDateValue(a.endDate || '') - getDateValue(b.endDate || '')).pop())
1342
- .filter((li) => Boolean(li))
1343
- .map(item => [item]);
1344
- }
1345
- case 'avg': {
1346
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1347
- return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
1348
- }
1349
- case 'sum': {
1350
- return lineItems.map(item => [item]);
1351
- }
1352
- default: {
1353
- return lineItems.map(item => [item]);
1354
- }
1355
- }
1356
- }
1357
- function getDateValue(date) {
1358
- return date ? new Date(date).getTime() : 0;
1359
- }
1360
-
1361
- class MetricsCalculationService {
1362
- get onMetricsUpdate$() {
1363
- return this.metricsUpdated$.asObservable();
1364
- }
1365
- constructor(quoteDraftService, flowConfiguration, settingsService) {
1366
- this.quoteDraftService = quoteDraftService;
1367
- this.flowConfiguration = flowConfiguration;
1368
- this.settingsService = settingsService;
1369
- this.metricsUpdated$ = new Subject();
1370
- this.quoteMetricsSettings = {};
1371
- this.metricsCalculationMethodMap = {};
1372
- this.metricsData = {};
1373
- this.activeMetricRules = [];
1374
- this.activeMetricRules = this.flowConfiguration.activeMetricsSnapshot.filter(metricRule => metricRule.metrics.some(metric => !!metric.totalName));
1375
- combineLatest([
1376
- this.quoteDraftService.currentState$,
1377
- this.settingsService.fetchSetting('QUOTE_LEVEL_METRIC_CALCULATION_METHOD').pipe(take$1(1)),
1378
- ]).subscribe(([lineItems, setting]) => {
1379
- let settingsData = {};
1380
- try {
1381
- settingsData = JSON.parse((setting === null || setting === void 0 ? void 0 : setting.value) || '{}');
1382
- }
1383
- catch (error) {
1384
- settingsData = {};
1385
- }
1386
- this.quoteMetricsSettings = settingsData;
1387
- this.updateMetrics(lineItems);
1388
- });
1389
- }
1390
- getMetricValue(metric) {
1391
- return this.metricsData[metric] || 0;
1392
- }
1393
- updateMetrics(lineItems) {
1394
- const metricKeys = this.collectMetricKeys(lineItems).filter(key => !key.includes('Effective_'));
1395
- this.metricsCalculationMethodMap = this.buildMetricsCalculationMethods(metricKeys, this.metricsCalculationMethodMap);
1396
- this.metricsData = metricKeys.reduce((acc, key) => (Object.assign(Object.assign({}, acc), { [key]: this.calculateMetric(lineItems, key) })), {});
1397
- this.metricsUpdated$.next();
1398
- }
1399
- calculateMetric(lineItems, metric) {
1400
- return calculateMetricByMethod(lineItems, metric, this.metricsCalculationMethodMap[metric] || 'sum');
1401
- }
1402
- buildMetricsCalculationMethods(metricKeys, initial) {
1403
- return metricKeys.reduce((acc, name) => {
1404
- var _a, _b;
1405
- if (acc[name]) {
1406
- return acc;
1407
- }
1408
- acc = Object.assign(Object.assign({}, acc), { [name]: 'sum' });
1409
- const metricRule = this.getMetricRuleByTotalMetricName(name);
1410
- const settingKey = ((_b = (_a = metricRule === null || metricRule === void 0 ? void 0 : metricRule.metrics) === null || _a === void 0 ? void 0 : _a.find(metric => metric.totalName === name)) === null || _b === void 0 ? void 0 : _b.name) || name;
1411
- if (this.quoteMetricsSettings[settingKey]) {
1412
- acc = Object.assign(Object.assign({}, acc), { [name]: this.quoteMetricsSettings[settingKey] });
1413
- }
1414
- return acc;
1415
- }, initial);
1416
- }
1417
- collectMetricKeys(lineItems) {
1418
- const keys = [];
1419
- lineItems.forEach(lineItem => {
1420
- keys.push(...Object.keys(lineItem.totalMetrics || {}));
1421
- keys.push(...this.collectMetricKeys(lineItem.lineItems));
1422
- });
1423
- return uniq(keys);
1424
- }
1425
- getMetricRuleByTotalMetricName(name) {
1426
- return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
1427
- }
1428
- }
1429
- MetricsCalculationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, deps: [{ token: QuoteDraftService }, { token: FlowConfigurationService }, { token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1430
- MetricsCalculationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, providedIn: 'root' });
1431
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: MetricsCalculationService, decorators: [{
1432
- type: Injectable,
1433
- args: [{ providedIn: 'root' }]
1434
- }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: FlowConfigurationService }, { type: i1.ConfigurationSettingsApiService }]; } });
1435
-
1436
- class ProductImagesService {
1437
- constructor(productApiService) {
1438
- this.productApiService = productApiService;
1439
- this.imagesMap$ = new BehaviorSubject({});
1440
- }
1441
- getImageUrl$(productId) {
1442
- if (this.imagesMap$.value[productId] == null) {
1443
- this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
1444
- this.fetchProductImage(productId);
1445
- }
1446
- return this.imagesMap$.pipe(map$2(imagesMap => imagesMap[productId]), distinctUntilChanged());
1447
- }
1448
- fetchProductImage(productId) {
1449
- this.productApiService
1450
- .fetchImage$(productId)
1451
- .pipe(map$2(file => URL.createObjectURL(file)), catchError$1(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
1452
- .subscribe();
1453
- }
1454
- }
1455
- ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1456
- ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, providedIn: 'root' });
1457
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ProductImagesService, decorators: [{
1458
- type: Injectable,
1459
- args: [{ providedIn: 'root' }]
1460
- }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1461
-
1462
- class RuntimeSettingsService {
1463
- constructor(configurationSettingsApiService) {
1464
- this.configurationSettingsApiService = configurationSettingsApiService;
1465
- this.configurationSettings$ = new BehaviorSubject({});
1466
- this.currencySettings$ = new BehaviorSubject({
1467
- iso: DEFAULT_CURRENCY_ISO_CODE,
1468
- symbol: DEFAULT_CURRENCY_SYMBOL,
1469
- });
1470
- this.getCurrencySymbol = (locale, currency) => {
1471
- return (0)
1472
- .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1473
- .replace(/\d/g, '')
1474
- .trim();
1475
- };
1476
- }
1477
- create() {
1478
- return this.configurationSettingsApiService.fetchSettings().pipe(map$2(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1479
- this.configurationSettings$.next(configurationSettings);
1480
- this.formattingSettings = this.getFormattingSettings();
1481
- }), map$2(() => undefined));
1482
- }
1483
- initCurrency(iso) {
1484
- if (iso) {
1485
- const symbol = this.getCurrencySymbol('en-US', iso);
1486
- this.currencySettings$.next({ iso, symbol });
1487
- }
1488
- }
1489
- getFormattingSettings() {
1490
- var _a, _b;
1491
- if (this.formattingSettings) {
1492
- return this.formattingSettings;
1493
- }
1494
- const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
1495
- return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
1496
- }, {});
1497
- const currencySettings = this.getCurrencySettings();
1498
- const dateFormat = (validateDateFormat((_b = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT) !== null && _b !== void 0 ? _b : '') && (shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DATE_FORMAT)) ||
1499
- DEFAULT_DATE_FORMAT;
1500
- const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
1501
- const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
1502
- // the number of decimal places can be 0
1503
- const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
1504
- const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1505
- ? Number(priceScale)
1506
- : DEFAULT_DECIMALS_COUNT;
1507
- return {
1508
- currencySymbol: currencySettings.symbol,
1509
- dateFormats: getSupportedDateFormats(dateFormat),
1510
- decimalsCount,
1511
- decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1512
- ? decimalSeparator
1513
- : DEFAULT_DECIMAL_SEPARATOR,
1514
- // thousands separator can be a blank value, so it can also be null
1515
- thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1516
- ? thousandsSeparator || ''
1517
- : DEFAULT_THOUSANDS_SEPARATOR,
1518
- };
1519
- }
1520
- getConfigurationSettings() {
1521
- return this.configurationSettings$.value;
1522
- }
1523
- getCurrencySettings() {
1524
- return this.currencySettings$.value;
1525
- }
1526
- parseConfigurationSettings(settings) {
1527
- return settings.reduce((acc, setting) => {
1528
- switch (setting.key) {
1529
- case 'shopping-cart':
1530
- acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1531
- break;
1532
- case 'navigation':
1533
- acc.navigation = parseJsonSafely(setting.value, {});
1534
- break;
1535
- case 'flows':
1536
- acc.flows = parseJsonSafely(setting.value, []);
1537
- break;
1538
- default:
1539
- acc[setting.key] = setting.value;
1540
- }
1541
- return acc;
1542
- }, {});
1543
- }
1544
- }
1545
- RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1546
- RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, providedIn: 'root' });
1547
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1548
- type: Injectable,
1549
- args: [{ providedIn: 'root' }]
1550
- }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1551
-
1552
2018
  const DEFAULT_FORMATTING_SETTINGS = {
1553
2019
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
1554
2020
  decimalsCount: DEFAULT_DECIMALS_COUNT,
1555
2021
  dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1556
2022
  decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1557
2023
  thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
2024
+ actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
1558
2025
  };
1559
2026
  class SdkCoreModule {
1560
2027
  }
1561
- SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1562
- SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
1563
- SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, providers: [
1564
- ContextService,
1565
- QuoteDraftService,
1566
- ProductImagesService,
1567
- MetricsCalculationService,
1568
- RuntimeSettingsService,
2028
+ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2029
+ SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2030
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
2031
+ IntegrationState,
1569
2032
  {
1570
2033
  provide: FORMATTING_SETTINGS_TOKEN,
1571
2034
  useExisting: RuntimeSettingsService,
1572
2035
  },
1573
2036
  ], imports: [ConfigurationModule, FlowConfigurationModule] });
1574
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
2037
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
1575
2038
  type: NgModule,
1576
2039
  args: [{
1577
2040
  imports: [ConfigurationModule, FlowConfigurationModule],
1578
2041
  providers: [
1579
- ContextService,
1580
- QuoteDraftService,
1581
- ProductImagesService,
1582
- MetricsCalculationService,
1583
- RuntimeSettingsService,
2042
+ IntegrationState,
1584
2043
  {
1585
2044
  provide: FORMATTING_SETTINGS_TOKEN,
1586
2045
  useExisting: RuntimeSettingsService,
@@ -1614,9 +2073,9 @@ class CalendarDirective {
1614
2073
  }
1615
2074
  }
1616
2075
  }
1617
- CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
1618
- CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.8", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
1619
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: CalendarDirective, decorators: [{
2076
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2077
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
2078
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
1620
2079
  type: Directive,
1621
2080
  args: [{
1622
2081
  selector: '[vlCalendar]',
@@ -1627,10 +2086,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1627
2086
 
1628
2087
  class SdkDirectivesModule {
1629
2088
  }
1630
- SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1631
- SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
1632
- SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule });
1633
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkDirectivesModule, decorators: [{
2089
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2090
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
2091
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
2092
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1634
2093
  type: NgModule,
1635
2094
  args: [{
1636
2095
  declarations: [CalendarDirective],
@@ -1650,22 +2109,28 @@ class DatePipe {
1650
2109
  this.destroy$.next();
1651
2110
  this.destroy$.complete();
1652
2111
  }
1653
- transform(date) {
2112
+ transform(date, type = 'date') {
1654
2113
  var _a, _b;
1655
2114
  if (!date) {
1656
2115
  return '';
1657
2116
  }
2117
+ const dateFormat = ((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.datePipeFormat) || DEFAULT_DATE_FORMAT;
2118
+ const formatMap = {
2119
+ date: dateFormat,
2120
+ time: DEFAULT_TIME_FORMAT,
2121
+ datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
2122
+ };
1658
2123
  try {
1659
- return formatDate(date, ((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.datePipeFormat) || DEFAULT_DATE_FORMAT, this.locale, (_b = this.defaultOptions) === null || _b === void 0 ? void 0 : _b.timezone);
2124
+ return formatDate(date, formatMap[type], this.locale, (_b = this.defaultOptions) === null || _b === void 0 ? void 0 : _b.timezone);
1660
2125
  }
1661
2126
  catch (error) {
1662
2127
  return new Date(date).toString();
1663
2128
  }
1664
2129
  }
1665
2130
  }
1666
- DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1667
- DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, name: "vlDate" });
1668
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: DatePipe, decorators: [{
2131
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2132
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
2133
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
1669
2134
  type: Pipe,
1670
2135
  args: [{
1671
2136
  name: 'vlDate',
@@ -1687,9 +2152,9 @@ class NumberPipe {
1687
2152
  return formatNumber(price, (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.thousandsSeparator, (_b = this.formattingSettings) === null || _b === void 0 ? void 0 : _b.decimalSeparator, (_c = this.formattingSettings) === null || _c === void 0 ? void 0 : _c.decimalsCount);
1688
2153
  }
1689
2154
  }
1690
- NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1691
- NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, name: "vlNumber" });
1692
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: NumberPipe, decorators: [{
2155
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2156
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
2157
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
1693
2158
  type: Pipe,
1694
2159
  args: [{
1695
2160
  name: 'vlNumber',
@@ -1714,25 +2179,44 @@ class PricePipe {
1714
2179
  return `${((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.currencySymbol) || DEFAULT_CURRENCY_SYMBOL}${formatNumber(price, (_b = this.formattingSettings) === null || _b === void 0 ? void 0 : _b.thousandsSeparator, (_c = this.formattingSettings) === null || _c === void 0 ? void 0 : _c.decimalSeparator, (_d = this.formattingSettings) === null || _d === void 0 ? void 0 : _d.decimalsCount)}`;
1715
2180
  }
1716
2181
  }
1717
- PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
1718
- PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, name: "vlPrice" });
1719
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: PricePipe, decorators: [{
2182
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2183
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
2184
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
1720
2185
  type: Pipe,
1721
2186
  args: [{
1722
2187
  name: 'vlPrice',
1723
2188
  }]
1724
2189
  }] });
1725
2190
 
2191
+ class ActionCodePipe {
2192
+ constructor() {
2193
+ var _a;
2194
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
2195
+ }
2196
+ transform(actionCode) {
2197
+ var _a, _b;
2198
+ return (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.actionCodeLabels[actionCode]) !== null && _b !== void 0 ? _b : actionCode;
2199
+ }
2200
+ }
2201
+ ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2202
+ ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
2203
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
2204
+ type: Pipe,
2205
+ args: [{
2206
+ name: 'vlActionCode',
2207
+ }]
2208
+ }] });
2209
+
1726
2210
  class SdkPipesModule {
1727
2211
  }
1728
- SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1729
- SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe], exports: [NumberPipe, PricePipe, DatePipe] });
1730
- SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule });
1731
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkPipesModule, decorators: [{
2212
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2213
+ SdkPipesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe], exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe] });
2214
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
2215
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
1732
2216
  type: NgModule,
1733
2217
  args: [{
1734
- declarations: [NumberPipe, PricePipe, DatePipe],
1735
- exports: [NumberPipe, PricePipe, DatePipe],
2218
+ declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2219
+ exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
1736
2220
  }]
1737
2221
  }] });
1738
2222
 
@@ -1740,5 +2224,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1740
2224
  * Generated bundle index. Do not edit.
1741
2225
  */
1742
2226
 
1743
- export { CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowUpdateService, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
2227
+ export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationState, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, MetricsCalculationService, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, calculateCardinalityVariables, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1744
2228
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map