@veloceapps/sdk 8.0.0-17 → 8.0.0-170

Sign up to get free protection for your applications and to get access to all the features.
Files changed (347) 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 +2 -3
  5. package/cms/components/preview/preview.types.d.ts +4 -0
  6. package/cms/index.d.ts +1 -0
  7. package/cms/modules/runtime/services/runtime.service.d.ts +1 -1
  8. package/cms/services/index.d.ts +0 -1
  9. package/cms/types/index.d.ts +0 -1
  10. package/cms/utils/element-metadata-worker.d.ts +11 -0
  11. package/cms/utils/elements-resolver.d.ts +0 -2
  12. package/cms/utils/index.d.ts +3 -0
  13. package/cms/utils/transpilation-worker.d.ts +13 -0
  14. package/cms/vendor-map.d.ts +26 -15
  15. package/core/README.md +20 -0
  16. package/core/modules/configuration/configuration.module.d.ts +2 -1
  17. package/core/modules/configuration/helpers.d.ts +4 -3
  18. package/core/modules/configuration/index.d.ts +1 -1
  19. package/core/modules/configuration/services/configuration-runtime.service.d.ts +1 -1
  20. package/core/modules/configuration/services/configuration-state.service.d.ts +51 -0
  21. package/core/modules/configuration/services/configuration.service.d.ts +8 -2
  22. package/core/modules/configuration/types/configuration.types.d.ts +4 -0
  23. package/core/modules/flow-configuration/flow-configuration.module.d.ts +2 -1
  24. package/core/modules/flow-configuration/services/flow-configuration.service.d.ts +5 -0
  25. package/core/pipes/action-code.pipe.d.ts +8 -0
  26. package/core/pipes/date.pipe.d.ts +2 -1
  27. package/core/pipes/index.d.ts +1 -0
  28. package/core/pipes/pipes.module.d.ts +2 -1
  29. package/core/services/context.service.d.ts +4 -0
  30. package/core/services/flow-info.service.d.ts +29 -0
  31. package/core/services/flow-state-configuration.service.d.ts +19 -0
  32. package/core/services/flow-state.service.d.ts +79 -0
  33. package/core/services/index.d.ts +4 -1
  34. package/core/services/quote-draft.service.d.ts +8 -1
  35. package/core/services/runtime-settings.service.d.ts +4 -1
  36. package/core/types/flow-customization.types.d.ts +22 -0
  37. package/core/types/flow-state.types.d.ts +6 -0
  38. package/core/types/formatting-settings.types.d.ts +2 -0
  39. package/core/types/index.d.ts +3 -0
  40. package/{cms → core}/types/integration.types.d.ts +1 -0
  41. package/core/types/pipe.types.d.ts +1 -0
  42. package/core/utils/line-item.utils.d.ts +0 -1
  43. package/esm2020/cms/cms.actions.mjs +15 -1
  44. package/esm2020/cms/components/element-children/element-children.component.mjs +3 -3
  45. package/esm2020/cms/components/element-children/element-children.module.mjs +4 -4
  46. package/esm2020/cms/components/element-drop-handle/element-drop-handle.component.mjs +3 -3
  47. package/esm2020/cms/components/element-drop-handle/element-drop-handle.module.mjs +4 -4
  48. package/esm2020/cms/components/element-renderer/element-renderer.component.mjs +6 -6
  49. package/esm2020/cms/components/element-renderer/element-renderer.module.mjs +4 -4
  50. package/esm2020/cms/components/element-tools-panel/element-tools-panel.component.mjs +5 -5
  51. package/esm2020/cms/components/plugin.component.mjs +3 -3
  52. package/esm2020/cms/components/preview/preview.component.mjs +11 -11
  53. package/esm2020/cms/components/preview/preview.module.mjs +6 -6
  54. package/esm2020/cms/components/preview/preview.types.mjs +1 -1
  55. package/esm2020/cms/directives/custom-template.directive.mjs +7 -7
  56. package/esm2020/cms/index.mjs +2 -1
  57. package/esm2020/cms/launcher.module.mjs +7 -7
  58. package/esm2020/cms/modules/federated/federated-host.directive.mjs +3 -3
  59. package/esm2020/cms/modules/federated/federated.component.mjs +3 -3
  60. package/esm2020/cms/modules/federated/federated.module.mjs +4 -4
  61. package/esm2020/cms/modules/migrations/migrations.mjs +2 -2
  62. package/esm2020/cms/modules/migrations/migrations.module.mjs +4 -4
  63. package/esm2020/cms/modules/migrations/services/migrations.service.mjs +9 -5
  64. package/esm2020/cms/modules/runtime/runtime.module.mjs +4 -4
  65. package/esm2020/cms/modules/runtime/services/compilation.service.mjs +14 -10
  66. package/esm2020/cms/modules/runtime/services/runtime-editor.service.mjs +3 -3
  67. package/esm2020/cms/modules/runtime/services/runtime.service.mjs +7 -7
  68. package/esm2020/cms/plugins/configuration.plugin.mjs +11 -7
  69. package/esm2020/cms/plugins/element-hover.plugin.mjs +3 -3
  70. package/esm2020/cms/plugins/io.plugin.mjs +3 -3
  71. package/esm2020/cms/plugins/page.plugin.mjs +3 -3
  72. package/esm2020/cms/plugins/region.plugin.mjs +3 -3
  73. package/esm2020/cms/plugins/script.plugin.mjs +3 -3
  74. package/esm2020/cms/services/element-context.service.mjs +3 -3
  75. package/esm2020/cms/services/index.mjs +1 -2
  76. package/esm2020/cms/services/io-provider.service.mjs +13 -12
  77. package/esm2020/cms/services/resources.service.mjs +3 -3
  78. package/esm2020/cms/services/templates.service.mjs +13 -12
  79. package/esm2020/cms/types/index.mjs +1 -2
  80. package/esm2020/cms/utils/element-metadata-worker.mjs +31 -0
  81. package/esm2020/cms/utils/elements-resolver.mjs +14 -28
  82. package/esm2020/cms/utils/index.mjs +4 -1
  83. package/esm2020/cms/utils/path.utils.mjs +3 -3
  84. package/esm2020/cms/utils/transpilation-worker.mjs +52 -0
  85. package/esm2020/cms/vendor-map.mjs +18 -6
  86. package/esm2020/core/core.module.mjs +16 -9
  87. package/esm2020/core/directives/directives.module.mjs +4 -4
  88. package/esm2020/core/directives/primeng-calendar.directive.mjs +3 -3
  89. package/esm2020/core/modules/configuration/configuration.module.mjs +9 -25
  90. package/esm2020/core/modules/configuration/helpers.mjs +28 -3
  91. package/esm2020/core/modules/configuration/index.mjs +2 -2
  92. package/esm2020/core/modules/configuration/services/configuration-runtime.service.mjs +11 -14
  93. package/esm2020/core/modules/configuration/services/configuration-state.service.mjs +296 -0
  94. package/esm2020/core/modules/configuration/services/configuration.service.mjs +49 -24
  95. package/esm2020/core/modules/configuration/services/runtime-context.service.mjs +9 -9
  96. package/esm2020/core/modules/configuration/types/configuration.types.mjs +1 -1
  97. package/esm2020/core/modules/flow-configuration/flow-configuration.module.mjs +8 -8
  98. package/esm2020/core/modules/flow-configuration/services/flow-configuration.service.mjs +13 -10
  99. package/esm2020/core/modules/flow-configuration/services/flow-update.service.mjs +3 -3
  100. package/esm2020/core/pipes/action-code.pipe.mjs +20 -0
  101. package/esm2020/core/pipes/date.pipe.mjs +13 -7
  102. package/esm2020/core/pipes/index.mjs +2 -1
  103. package/esm2020/core/pipes/number.pipe.mjs +3 -3
  104. package/esm2020/core/pipes/pipes.module.mjs +8 -7
  105. package/esm2020/core/pipes/price.pipe.mjs +3 -3
  106. package/esm2020/core/services/context.service.mjs +34 -7
  107. package/esm2020/core/services/flow-info.service.mjs +99 -0
  108. package/esm2020/core/services/flow-state-configuration.service.mjs +53 -0
  109. package/esm2020/core/services/flow-state.service.mjs +502 -0
  110. package/esm2020/core/services/index.mjs +5 -2
  111. package/esm2020/core/services/integration.state.mjs +36 -0
  112. package/esm2020/core/services/product-images.service.mjs +6 -7
  113. package/esm2020/core/services/quote-draft.service.mjs +33 -9
  114. package/esm2020/core/services/runtime-settings.service.mjs +21 -7
  115. package/esm2020/core/types/flow-customization.types.mjs +3 -0
  116. package/esm2020/core/types/flow-state.types.mjs +2 -0
  117. package/esm2020/core/types/formatting-settings.types.mjs +1 -1
  118. package/esm2020/core/types/index.mjs +4 -1
  119. package/esm2020/core/types/integration.types.mjs +2 -0
  120. package/esm2020/core/types/pipe.types.mjs +2 -0
  121. package/esm2020/core/utils/line-item.utils.mjs +30 -15
  122. package/esm2020/src/components/dialog/dialog.component.mjs +3 -3
  123. package/esm2020/src/components/dialog/dialog.module.mjs +4 -4
  124. package/esm2020/src/components/doc-gen/doc-gen.component.mjs +51 -51
  125. package/esm2020/src/components/doc-gen/doc-gen.module.mjs +4 -4
  126. package/esm2020/src/components/flow-header/flow-header.component.mjs +108 -0
  127. package/esm2020/src/components/flow-header/flow-header.module.mjs +19 -0
  128. package/esm2020/src/components/flow-header/index.mjs +2 -0
  129. package/esm2020/src/components/guided-selling/guided-selling.component.mjs +39 -45
  130. package/esm2020/src/components/guided-selling/guided-selling.module.mjs +4 -4
  131. package/esm2020/src/configure-primeng.mjs +33 -0
  132. package/esm2020/src/flow-routing.module.mjs +66 -75
  133. package/esm2020/src/flow.component.mjs +24 -33
  134. package/esm2020/src/flow.module.mjs +11 -9
  135. package/esm2020/src/guards/context.guard.mjs +9 -14
  136. package/esm2020/src/guards/flow.guard.mjs +37 -0
  137. package/esm2020/src/guards/product-unload.guard.mjs +7 -4
  138. package/esm2020/src/guards/root.guard.mjs +17 -13
  139. package/esm2020/src/pages/assets/assets.component.mjs +34 -38
  140. package/esm2020/src/pages/assets/assets.module.mjs +4 -4
  141. package/esm2020/src/pages/catalog/catalog.component.mjs +34 -38
  142. package/esm2020/src/pages/catalog/catalog.module.mjs +4 -4
  143. package/esm2020/src/pages/debug/debug.component.mjs +12 -16
  144. package/esm2020/src/pages/debug/debug.module.mjs +4 -4
  145. package/esm2020/src/pages/empty-account/empty-account.component.mjs +3 -3
  146. package/esm2020/src/pages/empty-account/empty-account.module.mjs +4 -4
  147. package/esm2020/src/pages/product/product.component.mjs +24 -14
  148. package/esm2020/src/pages/product/product.module.mjs +4 -4
  149. package/esm2020/src/pages/record-not-found/record-not-found.component.mjs +8 -5
  150. package/esm2020/src/pages/record-not-found/record-not-found.module.mjs +4 -4
  151. package/esm2020/src/pages/remote/remote.component.mjs +20 -20
  152. package/esm2020/src/pages/remote/remote.module.mjs +4 -4
  153. package/esm2020/src/pages/shopping-cart/shopping-cart.component.mjs +35 -39
  154. package/esm2020/src/pages/shopping-cart/shopping-cart.module.mjs +4 -4
  155. package/esm2020/src/resolvers/flow.resolver.mjs +39 -51
  156. package/esm2020/src/resolvers/quote.resolver.mjs +57 -65
  157. package/esm2020/src/services/doc-gen.service.mjs +7 -6
  158. package/esm2020/src/services/flow-dialog.service.mjs +23 -8
  159. package/esm2020/src/services/flow-router.service.mjs +59 -18
  160. package/esm2020/src/services/flow.service.mjs +72 -25
  161. package/esm2020/src/services/guided-selling.service.mjs +8 -7
  162. package/esm2020/src/services/index.mjs +3 -1
  163. package/esm2020/src/types/index.mjs +1 -2
  164. package/esm2020/src/utils/flow.utils.mjs +6 -2
  165. package/fesm2015/veloceapps-sdk-cms.mjs +355 -271
  166. package/fesm2015/veloceapps-sdk-cms.mjs.map +1 -1
  167. package/fesm2015/veloceapps-sdk-core.mjs +1619 -767
  168. package/fesm2015/veloceapps-sdk-core.mjs.map +1 -1
  169. package/fesm2015/veloceapps-sdk.mjs +828 -1541
  170. package/fesm2015/veloceapps-sdk.mjs.map +1 -1
  171. package/fesm2020/veloceapps-sdk-cms.mjs +357 -283
  172. package/fesm2020/veloceapps-sdk-cms.mjs.map +1 -1
  173. package/fesm2020/veloceapps-sdk-core.mjs +1647 -826
  174. package/fesm2020/veloceapps-sdk-core.mjs.map +1 -1
  175. package/fesm2020/veloceapps-sdk.mjs +888 -1599
  176. package/fesm2020/veloceapps-sdk.mjs.map +1 -1
  177. package/package.json +7 -14
  178. package/src/components/doc-gen/doc-gen.component.d.ts +8 -9
  179. package/src/components/flow-header/flow-header.component.d.ts +25 -0
  180. package/src/components/flow-header/flow-header.module.d.ts +9 -0
  181. package/src/components/flow-header/index.d.ts +1 -0
  182. package/src/components/guided-selling/guided-selling.component.d.ts +6 -8
  183. package/src/configure-primeng.d.ts +1 -0
  184. package/src/flow-routing.module.d.ts +6 -7
  185. package/src/flow.component.d.ts +7 -11
  186. package/src/flow.module.d.ts +2 -2
  187. package/src/guards/context.guard.d.ts +4 -5
  188. package/src/guards/flow.guard.d.ts +2 -0
  189. package/src/guards/product-unload.guard.d.ts +2 -2
  190. package/src/guards/root.guard.d.ts +0 -1
  191. package/src/pages/assets/assets.component.d.ts +5 -7
  192. package/src/pages/catalog/catalog.component.d.ts +5 -7
  193. package/src/pages/debug/debug.component.d.ts +5 -8
  194. package/src/pages/product/product.component.d.ts +7 -6
  195. package/src/pages/record-not-found/record-not-found.component.d.ts +2 -0
  196. package/src/pages/remote/remote.component.d.ts +2 -3
  197. package/src/pages/shopping-cart/shopping-cart.component.d.ts +5 -7
  198. package/src/resolvers/flow.resolver.d.ts +6 -7
  199. package/src/resolvers/quote.resolver.d.ts +7 -12
  200. package/src/services/doc-gen.service.d.ts +1 -1
  201. package/src/services/flow-dialog.service.d.ts +5 -2
  202. package/src/services/flow-router.service.d.ts +7 -3
  203. package/src/services/flow.service.d.ts +10 -4
  204. package/src/services/guided-selling.service.d.ts +1 -1
  205. package/src/services/index.d.ts +2 -0
  206. package/src/types/index.d.ts +0 -1
  207. package/core/modules/configuration/services/configuration.state.d.ts +0 -30
  208. package/core/services/metric-calculation/metric-calculation.service.d.ts +0 -25
  209. package/core/services/metric-calculation/metric-calculation.types.d.ts +0 -1
  210. package/core/services/metric-calculation/metric-calculation.utils.d.ts +0 -5
  211. package/esm2020/cms/services/integration.state.mjs +0 -37
  212. package/esm2020/cms/types/integration.types.mjs +0 -2
  213. package/esm2020/core/modules/configuration/services/configuration.state.mjs +0 -142
  214. package/esm2020/core/services/metric-calculation/metric-calculation.service.mjs +0 -85
  215. package/esm2020/core/services/metric-calculation/metric-calculation.types.mjs +0 -2
  216. package/esm2020/core/services/metric-calculation/metric-calculation.utils.mjs +0 -42
  217. package/esm2020/runtime/components/component-preview/component-preview.component.mjs +0 -125
  218. package/esm2020/runtime/components/index.mjs +0 -5
  219. package/esm2020/runtime/components/section-renderer/section-renderer.component.mjs +0 -67
  220. package/esm2020/runtime/components/ui-runtime/runtime.component.mjs +0 -440
  221. package/esm2020/runtime/components/ui-runtime-preview/runtime-preview.component.mjs +0 -108
  222. package/esm2020/runtime/execution/components/children-placeholder/children-placeholder.component.mjs +0 -60
  223. package/esm2020/runtime/execution/components/context-provider/context-provider.component.mjs +0 -39
  224. package/esm2020/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.mjs +0 -67
  225. package/esm2020/runtime/execution/components/federated/federated.component.mjs +0 -74
  226. package/esm2020/runtime/execution/components/velo-attribute/velo-attribute.component.mjs +0 -60
  227. package/esm2020/runtime/execution/components/velo-multiselect/velo-multiselect.component.mjs +0 -130
  228. package/esm2020/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.mjs +0 -72
  229. package/esm2020/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.mjs +0 -97
  230. package/esm2020/runtime/execution/components/velo-port-radio/velo-port-radio.component.mjs +0 -142
  231. package/esm2020/runtime/execution/components/velo-type/velo-type.component.mjs +0 -119
  232. package/esm2020/runtime/execution/directives/section-script.directive.mjs +0 -247
  233. package/esm2020/runtime/execution/directives/sf-query.directive.mjs +0 -35
  234. package/esm2020/runtime/execution/directives/velo-attribute.directive.mjs +0 -88
  235. package/esm2020/runtime/execution/directives/velo-port.directive.mjs +0 -376
  236. package/esm2020/runtime/execution/directives/vl-approval.directive.mjs +0 -23
  237. package/esm2020/runtime/execution/directives/vl-document-attachments.directive.mjs +0 -36
  238. package/esm2020/runtime/execution/directives/vl-document-templates.directive.mjs +0 -60
  239. package/esm2020/runtime/execution/directives/vl-quote.directive.mjs +0 -42
  240. package/esm2020/runtime/execution/directives/vl-ramp.directive.mjs +0 -55
  241. package/esm2020/runtime/execution/runtime-execution.module.mjs +0 -133
  242. package/esm2020/runtime/execution/utils/federated.util.mjs +0 -32
  243. package/esm2020/runtime/index.mjs +0 -5
  244. package/esm2020/runtime/runtime.module.mjs +0 -74
  245. package/esm2020/runtime/services/cart.service.mjs +0 -29
  246. package/esm2020/runtime/services/collapsible-state.service.mjs +0 -34
  247. package/esm2020/runtime/services/configuration.service.mjs +0 -119
  248. package/esm2020/runtime/services/current-state.service.mjs +0 -17
  249. package/esm2020/runtime/services/form-scope.service.mjs +0 -30
  250. package/esm2020/runtime/services/index.mjs +0 -4
  251. package/esm2020/runtime/services/product-model-cache.service.mjs +0 -31
  252. package/esm2020/runtime/services/runtime-context.service.mjs +0 -60
  253. package/esm2020/runtime/services/runtime-form.service.mjs +0 -219
  254. package/esm2020/runtime/services/runtime.service.mjs +0 -115
  255. package/esm2020/runtime/services/section-helper.service.mjs +0 -27
  256. package/esm2020/runtime/services/section-scope.service.mjs +0 -36
  257. package/esm2020/runtime/services/section-store.service.mjs +0 -22
  258. package/esm2020/runtime/services/section.service.mjs +0 -117
  259. package/esm2020/runtime/types/bound-data.types.mjs +0 -7
  260. package/esm2020/runtime/types/index.mjs +0 -3
  261. package/esm2020/runtime/types/quote-states.types.mjs +0 -2
  262. package/esm2020/runtime/types/runtime.types.mjs +0 -2
  263. package/esm2020/runtime/types/script-registry.types.mjs +0 -51
  264. package/esm2020/runtime/utils/line-item.util.mjs +0 -270
  265. package/esm2020/runtime/utils/section.utils.mjs +0 -26
  266. package/esm2020/runtime/utils/sections-binder.helper.mjs +0 -105
  267. package/esm2020/runtime/veloceapps-sdk-runtime.mjs +0 -5
  268. package/esm2020/src/components/header/cart-overlay/cart-preview.component.mjs +0 -119
  269. package/esm2020/src/components/header/cart-overlay/cart-preview.module.mjs +0 -47
  270. package/esm2020/src/components/header/header.component.mjs +0 -355
  271. package/esm2020/src/components/header/header.module.mjs +0 -52
  272. package/esm2020/src/components/header/header.types.mjs +0 -2
  273. package/esm2020/src/components/header/metrics/index.mjs +0 -2
  274. package/esm2020/src/components/header/metrics/metrics.component.mjs +0 -255
  275. package/esm2020/src/components/header/metrics/metrics.definitions.mjs +0 -2
  276. package/esm2020/src/components/header/metrics/metrics.module.mjs +0 -69
  277. package/esm2020/src/pages/legacy-product/legacy-product.component.mjs +0 -137
  278. package/esm2020/src/pages/legacy-product/legacy-product.module.mjs +0 -19
  279. package/esm2020/src/types/flow-customization.types.mjs +0 -3
  280. package/fesm2015/veloceapps-sdk-runtime.mjs +0 -3770
  281. package/fesm2015/veloceapps-sdk-runtime.mjs.map +0 -1
  282. package/fesm2020/veloceapps-sdk-runtime.mjs +0 -3767
  283. package/fesm2020/veloceapps-sdk-runtime.mjs.map +0 -1
  284. package/runtime/README.md +0 -5
  285. package/runtime/components/component-preview/component-preview.component.d.ts +0 -27
  286. package/runtime/components/index.d.ts +0 -4
  287. package/runtime/components/section-renderer/section-renderer.component.d.ts +0 -25
  288. package/runtime/components/ui-runtime/runtime.component.d.ts +0 -53
  289. package/runtime/components/ui-runtime-preview/runtime-preview.component.d.ts +0 -27
  290. package/runtime/execution/components/children-placeholder/children-placeholder.component.d.ts +0 -30
  291. package/runtime/execution/components/context-provider/context-provider.component.d.ts +0 -14
  292. package/runtime/execution/components/execution-section-renderer/execution-section-renderer.component.d.ts +0 -25
  293. package/runtime/execution/components/federated/federated.component.d.ts +0 -36
  294. package/runtime/execution/components/velo-attribute/velo-attribute.component.d.ts +0 -19
  295. package/runtime/execution/components/velo-multiselect/velo-multiselect.component.d.ts +0 -35
  296. package/runtime/execution/components/velo-port-checkbox/velo-port-checkbox.component.d.ts +0 -22
  297. package/runtime/execution/components/velo-port-dropdown/velo-port-dropdown.component.d.ts +0 -22
  298. package/runtime/execution/components/velo-port-radio/velo-port-radio.component.d.ts +0 -28
  299. package/runtime/execution/components/velo-type/velo-type.component.d.ts +0 -31
  300. package/runtime/execution/directives/section-script.directive.d.ts +0 -59
  301. package/runtime/execution/directives/sf-query.directive.d.ts +0 -15
  302. package/runtime/execution/directives/velo-attribute.directive.d.ts +0 -26
  303. package/runtime/execution/directives/velo-port.directive.d.ts +0 -74
  304. package/runtime/execution/directives/vl-approval.directive.d.ts +0 -10
  305. package/runtime/execution/directives/vl-document-attachments.directive.d.ts +0 -15
  306. package/runtime/execution/directives/vl-document-templates.directive.d.ts +0 -33
  307. package/runtime/execution/directives/vl-quote.directive.d.ts +0 -14
  308. package/runtime/execution/directives/vl-ramp.directive.d.ts +0 -15
  309. package/runtime/execution/runtime-execution.module.d.ts +0 -25
  310. package/runtime/execution/utils/federated.util.d.ts +0 -6
  311. package/runtime/index.d.ts +0 -4
  312. package/runtime/runtime.module.d.ts +0 -16
  313. package/runtime/services/cart.service.d.ts +0 -15
  314. package/runtime/services/collapsible-state.service.d.ts +0 -15
  315. package/runtime/services/configuration.service.d.ts +0 -20
  316. package/runtime/services/current-state.service.d.ts +0 -8
  317. package/runtime/services/form-scope.service.d.ts +0 -20
  318. package/runtime/services/index.d.ts +0 -3
  319. package/runtime/services/product-model-cache.service.d.ts +0 -14
  320. package/runtime/services/runtime-context.service.d.ts +0 -16
  321. package/runtime/services/runtime-form.service.d.ts +0 -24
  322. package/runtime/services/runtime.service.d.ts +0 -44
  323. package/runtime/services/section-helper.service.d.ts +0 -8
  324. package/runtime/services/section-scope.service.d.ts +0 -14
  325. package/runtime/services/section-store.service.d.ts +0 -11
  326. package/runtime/services/section.service.d.ts +0 -30
  327. package/runtime/types/bound-data.types.d.ts +0 -13
  328. package/runtime/types/index.d.ts +0 -2
  329. package/runtime/types/quote-states.types.d.ts +0 -6
  330. package/runtime/types/runtime.types.d.ts +0 -19
  331. package/runtime/types/script-registry.types.d.ts +0 -13
  332. package/runtime/utils/line-item.util.d.ts +0 -34
  333. package/runtime/utils/section.utils.d.ts +0 -2
  334. package/runtime/utils/sections-binder.helper.d.ts +0 -16
  335. package/src/components/header/cart-overlay/cart-preview.component.d.ts +0 -36
  336. package/src/components/header/cart-overlay/cart-preview.module.d.ts +0 -14
  337. package/src/components/header/header.component.d.ts +0 -70
  338. package/src/components/header/header.module.d.ts +0 -16
  339. package/src/components/header/header.types.d.ts +0 -20
  340. package/src/components/header/metrics/index.d.ts +0 -1
  341. package/src/components/header/metrics/metrics.component.d.ts +0 -67
  342. package/src/components/header/metrics/metrics.definitions.d.ts +0 -1
  343. package/src/components/header/metrics/metrics.module.d.ts +0 -18
  344. package/src/pages/legacy-product/legacy-product.component.d.ts +0 -37
  345. package/src/pages/legacy-product/legacy-product.module.d.ts +0 -9
  346. package/src/types/flow-customization.types.d.ts +0 -12
  347. /package/{cms → core}/services/integration.state.d.ts +0 -0
@@ -1,17 +1,17 @@
1
1
  import * as i0 from '@angular/core';
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';
2
+ import { InjectionToken, Injectable, Optional, Inject, NgModule, inject, Directive, Input, LOCALE_ID, Pipe } from '@angular/core';
3
+ import { UUID, ConfigurationContextMode, ConfigurationContext, UITemplateType, isDefined, ConfigurationProcessorTypes, EntityUtil, 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, switchMap, map as map$1, tap as tap$1, noop, catchError, throwError, of, forkJoin, Subject, filter as filter$1, zip, combineLatest, shareReplay as shareReplay$1, finalize, takeUntil, buffer, debounceTime, share, take as take$1, distinctUntilChanged } from 'rxjs';
5
+ import { map, filter, tap, switchMap as switchMap$1, skip, take, shareReplay, catchError as catchError$1, finalize as finalize$1, first } from 'rxjs/operators';
6
6
  import * as i1 from '@veloceapps/api';
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';
7
+ import { ApiModule } from '@veloceapps/api';
8
+ import { merge, isEmpty, flatten, entries, sortBy, map as map$2, omit, isEqual, cloneDeep, assign, uniqBy, transform } 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',
@@ -53,6 +48,29 @@ const getGuidedSellingConfigurationRequest = (data) => {
53
48
  },
54
49
  };
55
50
  };
51
+ const generateConfigurationLineItem = (props, qty = 1) => {
52
+ var _a, _b, _c;
53
+ const id = UUID.UUID();
54
+ const attributes = Object.entries((_a = props.attributesMap) !== null && _a !== void 0 ? _a : {}).map(([name, value]) => ({
55
+ name,
56
+ value,
57
+ cfgStatus: 'User',
58
+ }));
59
+ const lineItems = [];
60
+ return {
61
+ id,
62
+ type: (_b = props.product.typeName) !== null && _b !== void 0 ? _b : '',
63
+ cfgStatus: 'Default',
64
+ actionCode: 'ADD',
65
+ qty,
66
+ attributes,
67
+ lineItems,
68
+ productName: props.product.name,
69
+ productId: (_c = props.product.id) !== null && _c !== void 0 ? _c : '',
70
+ };
71
+ };
72
+
73
+ const FLOW_CUSTOMIZATION = new InjectionToken('FLOW_CUSTOMIZATION');
56
74
 
57
75
  const FORMATTING_SETTINGS_TOKEN = new InjectionToken('Summary of formatting settings for variant types of data, e.g. numbers, text, dates, etc');
58
76
 
@@ -82,9 +100,25 @@ class ContextService {
82
100
  get isInitialized() {
83
101
  return Boolean(this.context.value);
84
102
  }
103
+ get isInitialized$() {
104
+ return this.context.pipe(map(Boolean));
105
+ }
85
106
  get mode() {
86
107
  return this.resolve().properties.mode;
87
108
  }
109
+ get isEditMode$() {
110
+ return this.resolve$().pipe(map(() => this.isEditMode));
111
+ }
112
+ get isEditMode() {
113
+ const context = this.resolve();
114
+ if (context.mode === ConfigurationContextMode.ACCOUNT) {
115
+ return true;
116
+ }
117
+ if (context.mode === ConfigurationContextMode.QUOTE) {
118
+ return context.properties.Status === 'Draft';
119
+ }
120
+ return false;
121
+ }
88
122
  resolve() {
89
123
  if (!this.context.value) {
90
124
  throw new Error('Context is not initialized yet!');
@@ -97,6 +131,13 @@ class ContextService {
97
131
  create(headerId, mode) {
98
132
  return this.contextApiService.getContext(headerId, mode).pipe(tap(context => this.context.next(merge(new ConfigurationContext(headerId, mode), context))), map(() => this.resolve()));
99
133
  }
134
+ initTestMode() {
135
+ return this.create('TestId', ConfigurationContextMode.TEST).pipe(map(context => {
136
+ return this.update({
137
+ properties: Object.assign(Object.assign({}, context.properties), { RuntimeMode: ConfigurationContextMode.TEST, StartDate: new Date().toISOString().substring(0, 10), standalone: 'true' }),
138
+ });
139
+ }));
140
+ }
100
141
  update(partialContext) {
101
142
  const originalContext = this.resolve();
102
143
  const updatedContext = Object.assign(Object.assign(Object.assign({}, originalContext), partialContext), { properties: Object.assign(Object.assign({}, originalContext.properties), partialContext.properties) });
@@ -113,136 +154,107 @@ class ContextService {
113
154
  this.context.next(null);
114
155
  }
115
156
  }
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: [{
119
- type: Injectable,
120
- args: [{ providedIn: 'root' }]
157
+ ContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, deps: [{ token: i1.ContextApiService }], target: i0.ɵɵFactoryTarget.Injectable });
158
+ ContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService });
159
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ContextService, decorators: [{
160
+ type: Injectable
121
161
  }], ctorParameters: function () { return [{ type: i1.ContextApiService }]; } });
122
162
 
123
- class RuntimeContextService {
124
- constructor(configurationApiService) {
125
- this.configurationApiService = configurationApiService;
163
+ class FlowInfoService {
164
+ get flow() {
165
+ return this.flowSubj$.value;
126
166
  }
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
- };
147
- }));
167
+ set flow(value) {
168
+ this.flowSubj$.next(value);
148
169
  }
149
- getUIDefinitionContainer(runtimeData) {
170
+ get isLegacy() {
150
171
  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 = {};
172
+ return !!this.flow && ((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) == null;
174
173
  }
175
- initTestMode(uiDefinitionContainer) {
174
+ get isStateful() {
176
175
  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)));
176
+ return !!((_a = this.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful);
177
+ }
178
+ constructor(flowsApiService, templatesApiService, customizationService) {
179
+ this.flowsApiService = flowsApiService;
180
+ this.templatesApiService = templatesApiService;
181
+ this.customizationService = customizationService;
182
+ this.templates = {};
183
+ this.defaultTemplates = {
184
+ flowEngine: 'Flow Engine',
185
+ };
186
+ this.flowSubj$ = new BehaviorSubject(null);
187
+ this.flow$ = this.flowSubj$.asObservable();
188
+ }
189
+ init$(flowId, params) {
190
+ this.params = params;
191
+ return this.flowsApiService.getFlow(flowId).pipe(switchMap(flow => this.initFlowTemplates$(flow).pipe(map$1(() => flow))), tap$1(flow => this.flowSubj$.next(flow)), map$1(noop), catchError(e => {
192
+ this.flowSubj$.next(null);
193
+ return throwError(() => e);
194
+ }));
195
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)));
196
+ cleanup() {
197
+ this.flowSubj$.next(null);
198
+ this.params = undefined;
199
+ this.templates = {};
213
200
  }
214
- overrideUIDefinition(uiDefinitionContainer) {
215
- if (!this._runtimeContext) {
216
- return;
201
+ initFlowTemplates$(flow) {
202
+ var _a, _b, _c;
203
+ if (isEmpty(flow.properties.templates)) {
204
+ return of(undefined);
217
205
  }
218
- this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
219
- this.uiDefinitionProperties = getUIDefinitionProperties(uiDefinitionContainer);
206
+ return forkJoin([
207
+ this.templatesApiService.fetchTemplates$(),
208
+ (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplates) === null || _b === void 0 ? void 0 : _b.call(_a)) !== null && _c !== void 0 ? _c : of([]),
209
+ ]).pipe(map$1(([templates, localTemplates]) => {
210
+ Object.entries(Object.assign(Object.assign({}, this.defaultTemplates), flow.properties.templates)).forEach(([key, name]) => {
211
+ var _a;
212
+ const type = this.remapTemplateName(key);
213
+ if (type) {
214
+ this.templates[type] =
215
+ (_a = localTemplates.find(template => template.name === name && template.type === type)) !== null && _a !== void 0 ? _a : templates.find(template => template.name === name && template.type === type);
216
+ }
217
+ });
218
+ }));
220
219
  }
221
- id15to18(propertyName, source) {
222
- if (!source) {
223
- return;
220
+ remapTemplateName(templateType) {
221
+ switch (templateType) {
222
+ case 'flowEngine':
223
+ return UITemplateType.FLOW_ENGINE;
224
+ default:
225
+ break;
224
226
  }
225
- const value = source[propertyName];
226
- if (typeof value === 'string' && value.length === 15) {
227
- source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
227
+ switch (templateType) {
228
+ case 'assets':
229
+ case 'shoppingCart':
230
+ // No separate Assets template at the moment
231
+ return UITemplateType.SHOPPING_CART;
232
+ case 'catalog':
233
+ return UITemplateType.CATALOG;
234
+ case 'docGen':
235
+ return UITemplateType.DOCGEN;
236
+ case 'guidedSelling':
237
+ return UITemplateType.GUIDED_SELLING;
238
+ case 'flowHeader':
239
+ return UITemplateType.FLOW_HEADER;
240
+ default:
241
+ break;
228
242
  }
229
- }
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;
243
+ return undefined;
239
244
  }
240
245
  }
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: [{
246
+ FlowInfoService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, deps: [{ token: i1.FlowsApiService }, { token: i1.UITemplatesApiService }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
247
+ FlowInfoService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService });
248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowInfoService, decorators: [{
244
249
  type: Injectable
245
- }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
250
+ }], ctorParameters: function () {
251
+ return [{ type: i1.FlowsApiService }, { type: i1.UITemplatesApiService }, { type: undefined, decorators: [{
252
+ type: Optional
253
+ }, {
254
+ type: Inject,
255
+ args: [FLOW_CUSTOMIZATION]
256
+ }] }];
257
+ } });
246
258
 
247
259
  const findLineItem = (id, lineItems) => {
248
260
  return findLineItemWithComparator(lineItems, (li) => li.id === id);
@@ -291,28 +303,45 @@ const replaceLineItem = (lineItem, replaceTo, skipCardinalityCalculation = false
291
303
  }
292
304
  return Object.assign(Object.assign({}, lineItem), { lineItems: lineItem.lineItems.map(li => replaceLineItem(li, replaceTo, skipCardinalityCalculation)) });
293
305
  };
294
- const calculateCardinalityVariables = (lineItems) => {
306
+ const collectCardinalityComputations = (portDomains) => {
307
+ const cardinalityComputations = new Map();
308
+ entries(portDomains).forEach(([key, portDomain]) => {
309
+ cardinalityComputations.set(key, portDomain.properties['cardinalityComputation'] === 'true');
310
+ });
311
+ return cardinalityComputations;
312
+ };
313
+ const calculateCardinalityVariables = (lineItems, cardinalityComputations) => {
295
314
  const cardVars = new Map();
296
315
  lineItems
297
316
  .filter(({ port, type }) => !!port && !!type)
298
317
  .forEach(li => {
299
318
  var _a;
300
- const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
301
- cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
319
+ if (cardinalityComputations.get(`${li.port}`)) {
320
+ const cardinalityVariableName = `#CV-${li.type}@${li.port}`;
321
+ cardVars.set(cardinalityVariableName, ((_a = cardVars.get(cardinalityVariableName)) !== null && _a !== void 0 ? _a : 0) + li.qty);
322
+ }
302
323
  });
303
324
  return cardVars;
304
325
  };
326
+ const cardinalityRegexp = new RegExp('#CV-[a-zA-Z0-9_]+@(?<portName>[a-zA-Z0-9_]+)');
305
327
  const recalculateCardinalityVariables = (original, updated) => {
306
- const cardinalityVariables = calculateCardinalityVariables(updated.lineItems);
307
- const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems);
328
+ var _a, _b;
329
+ const cardinalityComputations = collectCardinalityComputations((_b = (_a = updated.portDomains) !== null && _a !== void 0 ? _a : original.portDomains) !== null && _b !== void 0 ? _b : {});
330
+ const cardinalityVariables = calculateCardinalityVariables(updated.lineItems, cardinalityComputations);
331
+ const originalCardinalityVariables = calculateCardinalityVariables(original.lineItems, cardinalityComputations);
308
332
  originalCardinalityVariables.forEach((value, key) => {
309
- if (cardinalityVariables.get(key) === value) {
310
- // no need to update cardinality if no changes
311
- cardinalityVariables.delete(key);
312
- }
313
- else if (!cardinalityVariables.has(key)) {
314
- // remove last item from port
315
- cardinalityVariables.set(key, 0);
333
+ var _a;
334
+ const execArray = cardinalityRegexp.exec(key);
335
+ const portName = (_a = execArray === null || execArray === void 0 ? void 0 : execArray.groups) === null || _a === void 0 ? void 0 : _a['portName'];
336
+ if (!portName || cardinalityComputations.get(portName)) {
337
+ if (cardinalityVariables.get(key) === value) {
338
+ // no need to update cardinality if no changes
339
+ cardinalityVariables.delete(key);
340
+ }
341
+ else if (!cardinalityVariables.has(key)) {
342
+ // remove last item from port
343
+ cardinalityVariables.set(key, 0);
344
+ }
316
345
  }
317
346
  });
318
347
  return Object.assign(Object.assign({}, updated), { attributes: upsertAttributes(updated.attributes, [...cardinalityVariables].map(([name, value]) => ({ name, value, cfgStatus: 'Changed' }))) });
@@ -329,7 +358,7 @@ const upsertAttributes = (originalAttributes, attributesToUpsert) => {
329
358
  const [origAttr] = getAttributes(acc, [name]);
330
359
  return [
331
360
  ...acc.filter(attr => attr.name !== name),
332
- Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name })), { cfgStatus: origAttr ? 'Changed' : 'User', value }),
361
+ Object.assign(Object.assign({}, (origAttr !== null && origAttr !== void 0 ? origAttr : { name, type: '' })), { cfgStatus: origAttr ? 'Changed' : 'User', value }),
333
362
  ];
334
363
  }, originalAttributes);
335
364
  };
@@ -395,7 +424,7 @@ const isLineItemModified = (lineItem) => {
395
424
  const multiplyLineItems = (lineItem, qty, split) => {
396
425
  if (split) {
397
426
  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));
427
+ return map$2(new Array(qty), () => unifyIds(lineItem));
399
428
  }
400
429
  else {
401
430
  return [
@@ -412,7 +441,6 @@ const filterOutTechnicalAttributes = (attributes) => {
412
441
 
413
442
  var lineItem_utils = /*#__PURE__*/Object.freeze({
414
443
  __proto__: null,
415
- calculateCardinalityVariables: calculateCardinalityVariables,
416
444
  filterOutTechnicalAttributes: filterOutTechnicalAttributes,
417
445
  findLineItem: findLineItem,
418
446
  findLineItemWithComparator: findLineItemWithComparator,
@@ -452,7 +480,51 @@ class LineItemWorker {
452
480
  }
453
481
  }
454
482
 
483
+ function extractMetadata(uiDefinition) {
484
+ return omit(uiDefinition, [
485
+ 'children',
486
+ 'pages',
487
+ 'components',
488
+ ]);
489
+ }
490
+
491
+ class IntegrationState {
492
+ constructor() {
493
+ this.stateSubj$ = new BehaviorSubject({});
494
+ this.action$ = new Subject();
495
+ }
496
+ get state$() {
497
+ return this.stateSubj$.asObservable();
498
+ }
499
+ get state() {
500
+ return this.stateSubj$.getValue();
501
+ }
502
+ patchState(update) {
503
+ this.stateSubj$.next(Object.assign(Object.assign({}, this.stateSubj$.getValue()), update));
504
+ }
505
+ dispatch(action) {
506
+ this.action$.next(action);
507
+ }
508
+ listen$(actionType) {
509
+ return this.action$.pipe(filter$1(action => action.type === actionType), map$1(action => action.payload));
510
+ }
511
+ listenAll$() {
512
+ return this.action$.asObservable();
513
+ }
514
+ clear() {
515
+ this.stateSubj$.next({});
516
+ }
517
+ }
518
+ IntegrationState.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
519
+ IntegrationState.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState });
520
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: IntegrationState, decorators: [{
521
+ type: Injectable
522
+ }] });
523
+
455
524
  class QuoteDraftService {
525
+ get isInitialized$() {
526
+ return this.isInitializedSubj$.asObservable();
527
+ }
456
528
  get isInitialized() {
457
529
  return this.isInitializedSubj$.getValue();
458
530
  }
@@ -476,12 +548,20 @@ class QuoteDraftService {
476
548
  }
477
549
  get hasProducts() {
478
550
  const quoteDraft = this.quoteSubj$.value;
479
- return Boolean(quoteDraft && quoteDraft.currentState.length > 0);
551
+ return this.filterByActivePriceList((quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.currentState) || []).some(li => !li.assetId && !li.openOrderLineItemId);
552
+ }
553
+ get hasAssets$() {
554
+ return this.quoteSubj$.pipe(map(() => this.hasAssets));
555
+ }
556
+ get hasAssets() {
557
+ const quoteDraft = this.quoteSubj$.value;
558
+ return this.filterByActivePriceList((quoteDraft === null || quoteDraft === void 0 ? void 0 : quoteDraft.currentState) || []).some(li => li.assetId || li.openOrderLineItemId);
480
559
  }
481
- constructor(context, quoteApiService, priceApiService) {
560
+ constructor(context, quoteApiService, priceApiService, integrationState) {
482
561
  this.context = context;
483
562
  this.quoteApiService = quoteApiService;
484
563
  this.priceApiService = priceApiService;
564
+ this.integrationState = integrationState;
485
565
  this.quoteSubj$ = new BehaviorSubject(null);
486
566
  this.resetSubj$ = new BehaviorSubject(true);
487
567
  this.isInitializedSubj$ = new BehaviorSubject(false);
@@ -492,12 +572,13 @@ class QuoteDraftService {
492
572
  this.reset$ = this.resetSubj$.asObservable();
493
573
  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
574
  this.isInitializedSubj$
495
- .pipe(filter(isInitialized => isInitialized), switchMap(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
575
+ .pipe(filter(isInitialized => isInitialized), switchMap$1(() => this.quoteSubj$.asObservable()), skip(1), tap(quote => this.markAsUpdated(quote)))
496
576
  .subscribe();
497
577
  }
498
578
  reset() {
499
579
  this.resetSubj$.next(true);
500
580
  this.quoteSubj$.next(null);
581
+ this.isInitialized = false;
501
582
  this.hasUnsavedChanges = false;
502
583
  }
503
584
  init(quoteId, params) {
@@ -508,6 +589,11 @@ class QuoteDraftService {
508
589
  this.populateActivePriceLists$();
509
590
  }), map(() => noop()), take(1));
510
591
  }
592
+ finalizeInit() {
593
+ this.initializeModifiedAssetsMap();
594
+ this.isInitialized = true;
595
+ this.hasUnsavedChanges = false;
596
+ }
511
597
  setCurrentLineItemState(lineItems) {
512
598
  const quoteDraft = this.quoteSubj$.value;
513
599
  if (!quoteDraft) {
@@ -653,354 +739,522 @@ class QuoteDraftService {
653
739
  this.hasUnsavedChanges = !isEqual(this.initialCurrentState, quote === null || quote === void 0 ? void 0 : quote.currentState);
654
740
  }
655
741
  }
742
+ initializeModifiedAssetsMap() {
743
+ this.integrationState.patchState({
744
+ modifiedAssets: generateModifiedAssetsMap(this.currentState),
745
+ });
746
+ }
656
747
  }
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: [{
660
- type: Injectable,
661
- args: [{ providedIn: 'root' }]
662
- }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }]; } });
748
+ 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 });
749
+ QuoteDraftService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService });
750
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: QuoteDraftService, decorators: [{
751
+ type: Injectable
752
+ }], ctorParameters: function () { return [{ type: ContextService }, { type: i1.QuoteApiService }, { type: i1.PriceApiService }, { type: IntegrationState }]; } });
663
753
 
664
- class ConfigurationService {
665
- constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService) {
666
- this.quoteDraftService = quoteDraftService;
667
- this.runtimeService = runtimeService;
754
+ class FlowStateService {
755
+ constructor(contextService, quoteDraftService, flowInfoService, flowConfiguration, processorsApiService, flowStateApiService, quoteApiService, toastService, customizationService) {
668
756
  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;
679
- }
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({});
757
+ this.quoteDraftService = quoteDraftService;
758
+ this.flowInfoService = flowInfoService;
759
+ this.flowConfiguration = flowConfiguration;
760
+ this.processorsApiService = processorsApiService;
761
+ this.flowStateApiService = flowStateApiService;
762
+ this.quoteApiService = quoteApiService;
763
+ this.toastService = toastService;
764
+ this.customizationService = customizationService;
765
+ this.NOT_INITIALIZED = Symbol();
766
+ this.EXECUTION_BUFFER_TIME = 100;
767
+ this.executedFunctions = {};
768
+ this.stateId$ = new BehaviorSubject(null);
769
+ this._hasStatefulUnsavedChanges = true;
770
+ this.processors = {};
771
+ this.subscriptions = {};
772
+ this.flowStore = {};
773
+ this.statefulExecutionInProgress$ = new BehaviorSubject(false);
774
+ this.statefulRequestStream$ = new Subject();
775
+ this.cleanup$ = new Subject();
776
+ this.statefulExecutionRequest$ = this.initBufferedRequest$();
777
+ /*
778
+ In stateless mode watch QuoteDraft changes and call executeRequest so that
779
+ all subscriptions get their updates according to updated QuoteDraft
780
+ */
781
+ this.isInitialized$()
782
+ .pipe(filter$1(Boolean), filter$1(() => !this.getFlowSafe().properties.stateful), switchMap(() => this.flowConfiguration.updated$), switchMap(() => this.executeRequest$({}, true)))
783
+ .subscribe();
784
+ this.charges$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
785
+ if (!flow.properties.stateful) {
786
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.charges));
787
+ }
788
+ else {
789
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'CHARGES', null, {
790
+ cold: true,
791
+ }).pipe(map$1(response => (response.success ? response.result : {})));
792
+ }
793
+ }), filter$1(isDefined), shareReplay$1());
794
+ this.charges$.subscribe();
795
+ this.pricePlans$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
796
+ if (!flow.properties.stateful) {
797
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.pricePlans));
798
+ }
799
+ else {
800
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'PRICE_PLANS', null, {
801
+ cold: true,
802
+ }).pipe(map$1(response => (response.success ? response.result : {})));
803
+ }
804
+ }), filter$1(isDefined), shareReplay$1());
805
+ this.pricePlans$.subscribe();
806
+ this.activeMetrics$ = this.flowInfoService.flow$.pipe(filter$1(isDefined), switchMap(flow => {
807
+ if (!flow.properties.stateful) {
808
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(quoteDraft => quoteDraft.activeMetrics));
809
+ }
810
+ else {
811
+ return this.subscribe$(UITemplateType.FLOW_ENGINE, 'ACTIVE_METRICS', null, {
812
+ cold: true,
813
+ }).pipe(map$1(response => (response.success ? response.result : [])));
814
+ }
815
+ }), filter$1(isDefined), shareReplay$1());
816
+ this.activeMetrics$.subscribe();
687
817
  }
688
- patch$(lineItem, options) {
689
- if (!this.lineItem.value) {
690
- return throwError(() => new Error(`Source LineItem not found`));
691
- }
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 });
818
+ init$() {
819
+ return this.initProcessors$().pipe(switchMap(() => {
820
+ if (this.getFlowSafe().properties.stateful) {
821
+ return this.initStateful$();
698
822
  }
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;
823
+ else {
824
+ return this.initStateless$();
705
825
  }
706
826
  }));
707
827
  }
708
- patch(lineItem, options) {
709
- this.patch$(lineItem, options).subscribe();
828
+ cleanup() {
829
+ Object.values(this.subscriptions).forEach(({ data$ }) => data$.complete());
830
+ this.subscriptions = {};
831
+ if (this.stateId$.value) {
832
+ this.flowStateApiService.cancel(this.stateId$.value).subscribe();
833
+ this.stateId$.next(null);
834
+ }
835
+ this.processors = {};
836
+ this.flowStore = {};
837
+ this.cleanup$.next();
710
838
  }
711
- setConfigurableRamp(lineItem) {
712
- this.configurableRamp = lineItem;
839
+ get hasUnsavedChanges() {
840
+ return this.getFlowSafe().properties.stateful
841
+ ? this._hasStatefulUnsavedChanges
842
+ : this.quoteDraftService.hasUnsavedChanges;
713
843
  }
714
- get() {
715
- return this.lineItem.asObservable().pipe(shareReplay$1());
844
+ get stateId() {
845
+ return this.stateId$.value;
716
846
  }
717
- getSnapshot() {
718
- return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
847
+ get isExecutionInProgress$() {
848
+ return this.statefulExecutionInProgress$.asObservable();
719
849
  }
720
- getRuntimeModel() {
721
- const runtimeModel = this.runtimeService.runtimeModel;
722
- if (!runtimeModel) {
723
- throw new Error('Runtime model not initialized');
724
- }
725
- return runtimeModel;
850
+ isInitialized$() {
851
+ return combineLatest([this.stateId$, this.quoteDraftService.isInitialized$]).pipe(map$1(values => values.some(Boolean)));
726
852
  }
727
- getRuntimeContext() {
728
- const runtimeContext = this.runtimeService.runtimeContext;
729
- if (!runtimeContext) {
730
- throw new Error('Runtime context not initialized');
731
- }
732
- return runtimeContext;
853
+ isInitialized() {
854
+ return Boolean(this.stateId$.value) || this.quoteDraftService.isInitialized;
733
855
  }
734
- get contextSnapshot() {
735
- return this.contextService.resolve();
856
+ execute$(scope, exec) {
857
+ const request = this.execToRequest(scope, exec);
858
+ return this.executeRequest$(request).pipe(map$1(result => {
859
+ // Keep only requested results
860
+ const actualSelectors = Object.entries(result.selectors).reduce((trunk, [requestId, result]) => {
861
+ var _a;
862
+ if ((_a = exec.selectors) === null || _a === void 0 ? void 0 : _a[requestId]) {
863
+ trunk[requestId] = result;
864
+ }
865
+ return trunk;
866
+ }, {});
867
+ return actualSelectors;
868
+ }));
736
869
  }
737
- get context$() {
738
- return this.contextService.resolve$();
870
+ dispatch$(scope, action, inputData) {
871
+ const exec = {
872
+ actions: [{ name: action, inputData }],
873
+ };
874
+ const request = this.execToRequest(scope, exec);
875
+ return this.executeRequest$(request).pipe(map$1(noop));
739
876
  }
740
- get charges$() {
741
- return this.charges.asObservable();
742
- }
743
- get chargesSnapshot() {
744
- return this.charges.value;
745
- }
746
- get pricePlans$() {
747
- return this.pricePlans.asObservable();
748
- }
749
- get pricePlansSnapshot() {
750
- return this.pricePlans.value;
877
+ select$(scope, selectorName, inputData) {
878
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
879
+ const request = this.execToRequest(scope, {
880
+ selectors: {
881
+ [requestId]: {
882
+ name: selectorName,
883
+ inputData,
884
+ },
885
+ },
886
+ });
887
+ return this.executeRequest$(request).pipe(map$1(response => response.selectors[requestId]));
888
+ }
889
+ subscribe$(scope, selectorName, inputData, options) {
890
+ const requestId = this.generateRequestId(scope, selectorName, inputData);
891
+ let subscription = this.subscriptions[requestId];
892
+ if (!subscription) {
893
+ const request = this.execToRequest(scope, {
894
+ selectors: {
895
+ [requestId]: {
896
+ name: selectorName,
897
+ inputData,
898
+ },
899
+ },
900
+ });
901
+ subscription = {
902
+ request,
903
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
904
+ };
905
+ this.subscriptions[requestId] = subscription;
906
+ if (!(options === null || options === void 0 ? void 0 : options.cold)) {
907
+ this.executeRequest$(request).subscribe();
908
+ }
909
+ }
910
+ return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
911
+ var _a;
912
+ if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
913
+ delete this.subscriptions[requestId];
914
+ }
915
+ }));
751
916
  }
752
- configure() {
753
- return this.configureRequest$(this.generateRequest());
917
+ save$() {
918
+ if (this.getFlowSafe().properties.stateful) {
919
+ if (this.stateId$.value) {
920
+ return this.flowStateApiService.save(this.stateId$.value);
921
+ }
922
+ }
923
+ else {
924
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
925
+ if (quoteDraft) {
926
+ return this.quoteApiService.upsertQuote(quoteDraft);
927
+ }
928
+ }
929
+ return of({ quoteId: '' });
754
930
  }
755
- configureRequest$(configurationRequest) {
756
- 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);
931
+ submit$() {
932
+ if (this.getFlowSafe().properties.stateful) {
933
+ if (this.stateId$.value) {
934
+ return this.flowStateApiService.submit(this.stateId$.value);
769
935
  }
770
- if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
771
- this.showInactiveProductsConfirmation();
936
+ }
937
+ else {
938
+ const quoteDraft = this.quoteDraftService.quoteDraftForActivePriceList;
939
+ if (quoteDraft) {
940
+ return this.quoteApiService.submitQuote(quoteDraft);
772
941
  }
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)));
942
+ }
943
+ return of({ quoteId: '' });
775
944
  }
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()));
945
+ getFlowStore() {
946
+ return this.flowStore;
783
947
  }
784
- configureGuidedSelling$(data) {
785
- return this.configurationApiService
786
- .configureLineItem({
787
- configurationRequest: getGuidedSellingConfigurationRequest(data),
788
- })
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;
794
- }));
948
+ getOwnerIdByScope(scope) {
949
+ var _a;
950
+ const ownerId = (_a = this.flowInfoService.templates[scope]) === null || _a === void 0 ? void 0 : _a.id;
951
+ if (!ownerId) {
952
+ throw `OwnerId is not found for scope ${scope}`;
953
+ }
954
+ return ownerId;
795
955
  }
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;
956
+ getScopeByOwnerId(id) {
957
+ for (const template of Object.values(this.flowInfoService.templates)) {
958
+ if (template.id === id) {
959
+ return template.type;
808
960
  }
809
961
  }
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;
962
+ return;
821
963
  }
822
- getUIDefinitionProperties() {
964
+ execToRequest(scope, exec) {
823
965
  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',
966
+ const ownerId = this.getOwnerIdByScope(scope);
967
+ return {
968
+ 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 : {} }); }),
969
+ selectors: exec.selectors &&
970
+ Object.entries(exec.selectors).reduce((trunk, [key, selector]) => {
971
+ var _a;
972
+ return (Object.assign(Object.assign({}, trunk), { [key]: { apiName: selector.name, ownerId, inputData: (_a = selector.inputData) !== null && _a !== void 0 ? _a : {} } }));
973
+ }, {}),
832
974
  };
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
- });
849
975
  }
850
- getAsset() {
976
+ executeRequest$(request, forceSubscriptions = false) {
851
977
  var _a;
852
- const lineItem = this.configurableRamp;
853
- if (!lineItem) {
854
- return;
978
+ const fullRequest = cloneDeep(request);
979
+ if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
980
+ for (const subscription of Object.values(this.subscriptions)) {
981
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
982
+ }
855
983
  }
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;
984
+ const execution$ = this.getFlowSafe().properties.stateful
985
+ ? this.executeStateful$(fullRequest)
986
+ : this.executeStateless$(fullRequest);
987
+ return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
874
988
  }
875
- init$() {
876
- return this.configurationService.configure().pipe(switchMap$1(() => {
877
- var _a, _b;
878
- if (!this.isStatefulConfiguration) {
879
- return of(undefined);
989
+ handleSelectorsResponse(selectors) {
990
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
991
+ var _a;
992
+ if (!selectorResult.success) {
993
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
880
994
  }
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));
995
+ const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
996
+ if (subscription$ && subscription$.value !== selectorResult) {
997
+ subscription$.next(selectorResult);
998
+ }
999
+ });
888
1000
  }
889
- cleanup() {
890
- this.stateId = null;
891
- this.configurationService.reset();
892
- this.stateSubj$.next({});
1001
+ initStateful$() {
1002
+ var _a;
1003
+ // Subscriptions
1004
+ this.subscribe$(UITemplateType.FLOW_ENGINE, 'CONTEXT', null, { cold: true })
1005
+ .pipe(tap$1(response => {
1006
+ if (response.success) {
1007
+ this.contextService.update(response.result);
1008
+ }
1009
+ }), takeUntil(this.cleanup$))
1010
+ .subscribe();
1011
+ const processorsList = flatten(Object.values(this.processors).map(ownerMap => Object.values(ownerMap !== null && ownerMap !== void 0 ? ownerMap : {})));
1012
+ const processors = processorsList.length ? processorsList : undefined;
1013
+ const selectors = Object.values(this.subscriptions)
1014
+ .map(({ request }) => request.selectors)
1015
+ .filter(isDefined)
1016
+ .reduce((trunk, selectors) => (Object.assign(Object.assign({}, trunk), selectors)), {});
1017
+ const request = this.getDefaultExecutionRequestDTO();
1018
+ return this.flowStateApiService
1019
+ .init({
1020
+ quoteId: this.contextService.resolve().headerId,
1021
+ params: (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {},
1022
+ actionsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.ACTION),
1023
+ selectorsOverride: processors === null || processors === void 0 ? void 0 : processors.filter(processor => processor.type === ConfigurationProcessorTypes.SELECTOR),
1024
+ selectors: Object.assign(Object.assign({}, selectors), request.selectors),
1025
+ actions: request.actions,
1026
+ })
1027
+ .pipe(map$1(({ stateId, selectors }) => {
1028
+ this.handleSelectorsResponse(selectors);
1029
+ this.stateId$.next(stateId);
1030
+ }));
893
1031
  }
894
- execute$(req) {
895
- if (this.isStatefulConfiguration) {
896
- return this.executeStateful$(req);
897
- }
898
- else {
899
- return this.executeStateless$(req);
900
- }
1032
+ initBufferedRequest$() {
1033
+ return this.statefulRequestStream$.pipe(buffer(this.statefulRequestStream$.pipe(debounceTime(this.EXECUTION_BUFFER_TIME))), switchMap(requests => {
1034
+ if (!this.stateId$.value) {
1035
+ throw 'Stateful session is not initialized';
1036
+ }
1037
+ // merge buffered requests
1038
+ const request = {
1039
+ actions: requests.flatMap(({ actions }) => actions).filter(isDefined),
1040
+ selectors: requests
1041
+ .map(({ selectors }) => selectors)
1042
+ .filter(isDefined)
1043
+ .reduce((acc, selectorsMap) => Object.assign(acc, selectorsMap), {}),
1044
+ };
1045
+ this.statefulExecutionInProgress$.next(true);
1046
+ return this.flowStateApiService.execute(this.stateId$.value, request);
1047
+ }), tap$1(({ stateId }) => this.stateId$.next(stateId)), share(), tap$1(() => this.statefulExecutionInProgress$.next(false)), catchError(e => {
1048
+ this.statefulExecutionInProgress$.next(false);
1049
+ return throwError(() => e);
1050
+ }));
901
1051
  }
902
- dispatch$(actionName, inputData) {
903
- return this.execute$({ actions: [{ name: actionName, inputData }] });
1052
+ executeStateful$(request) {
1053
+ return this.statefulExecutionInProgress$.pipe(filter$1(inProgress => !inProgress), take$1(1), switchMap(() =>
1054
+ // make sure stream switches to statefulExecutionRequest$ before pushing an execution request
1055
+ combineLatest([
1056
+ this.statefulExecutionRequest$,
1057
+ of(undefined).pipe(tap$1(() => this.statefulRequestStream$.next(request))),
1058
+ ])), map$1(([response]) => response), take$1(1));
904
1059
  }
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))));
1060
+ initStateless$() {
1061
+ var _a;
1062
+ const { headerId } = this.contextService.resolve();
1063
+ return this.quoteDraftService.init(headerId, (_a = this.flowInfoService.params) !== null && _a !== void 0 ? _a : {}).pipe(switchMap(() => this.executeRequest$(this.getDefaultExecutionRequestDTO())), switchMap(() => this.calculate$()), tap$1(() => this.quoteDraftService.finalizeInit()), map$1(noop));
915
1064
  }
916
- get isStatefulConfiguration() {
1065
+ calculate$() {
917
1066
  var _a;
918
- return (_a = this.runtimeService.uiDefinitionProperties.statefulConfigurationEnabled) !== null && _a !== void 0 ? _a : false;
1067
+ const flowState = this.quoteDraftService.quoteDraft;
1068
+ if (!flowState) {
1069
+ return of(undefined);
1070
+ }
1071
+ /*
1072
+ Don't execute procedures when:
1073
+ * Initializing a standalone product configuration UI, as procedure is execute in /price call
1074
+ * Initializing an empty account (account with no assets)
1075
+ */
1076
+ const isEmptyAccountMode = this.contextService.mode === ConfigurationContextMode.ACCOUNT &&
1077
+ !this.quoteDraftService.hasProducts &&
1078
+ !this.quoteDraftService.hasAssets &&
1079
+ !((_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.length);
1080
+ if (this.quoteDraftService.isStandalone || isEmptyAccountMode) {
1081
+ return of(undefined);
1082
+ }
1083
+ return this.flowConfiguration.calculate$(flowState);
919
1084
  }
920
1085
  executeStateless$(request) {
921
- return of(undefined).pipe(switchMap$1(() => {
1086
+ return of(undefined).pipe(tap$1(() => this.executeStatelessActions(request)), switchMap(() => {
922
1087
  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)) {
1088
+ /*
1089
+ Skip price calculation in case
1090
+ 1. No actions in the request
1091
+ 2. Initialization process execution (state not initialized yet)
1092
+ */
1093
+ if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length) || !this.isInitialized()) {
926
1094
  return of(undefined);
927
1095
  }
928
- let configurationRequest = this.configurationService.generateRequest();
929
- request.actions.forEach(action => {
930
- var _a;
931
- configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
932
- });
933
- return this.configurationService.configureRequest$(configurationRequest);
934
- }), tap$1(() => {
935
- if (!request.selectors) {
936
- return;
1096
+ else {
1097
+ return this.calculate$();
937
1098
  }
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));
1099
+ }), map$1(() => this.executeStatelessSelectors(request)));
946
1100
  }
947
- executeStateful$(request) {
948
- if (!this.stateId) {
1101
+ executeStatelessActions(request) {
1102
+ var _a;
1103
+ if (!this.quoteDraftService.quoteDraft || !((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
1104
+ return;
1105
+ }
1106
+ let flowState = this.quoteDraftService.quoteDraft;
1107
+ request.actions.forEach(action => {
1108
+ var _a;
1109
+ try {
1110
+ flowState = (_a = this.executeActionScript(flowState, action)) !== null && _a !== void 0 ? _a : flowState;
1111
+ }
1112
+ catch (e) {
1113
+ console.error(e);
1114
+ this.toastService.add({ severity: ToastType.error, summary: String(e) });
1115
+ throw e;
1116
+ }
1117
+ });
1118
+ this.quoteDraftService.updateQuoteDraft(flowState);
1119
+ }
1120
+ executeStatelessSelectors(request) {
1121
+ var _a;
1122
+ if (!this.quoteDraftService.quoteDraft) {
1123
+ throw 'QuoteDraft is not initialized';
1124
+ }
1125
+ const flowState = this.quoteDraftService.quoteDraft;
1126
+ return EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
1127
+ try {
1128
+ result.selectors[key] = {
1129
+ success: true,
1130
+ result: this.executeSelectorScript(flowState, selector),
1131
+ };
1132
+ }
1133
+ catch (e) {
1134
+ console.error(e);
1135
+ result.selectors[key] = {
1136
+ success: false,
1137
+ errorMessage: String(e),
1138
+ };
1139
+ }
1140
+ return result;
1141
+ }, { stateId: '', selectors: {} });
1142
+ }
1143
+ getFlowSafe() {
1144
+ if (!this.flowInfoService.flow) {
1145
+ throw 'Flow is not defined';
1146
+ }
1147
+ return this.flowInfoService.flow;
1148
+ }
1149
+ initProcessors$() {
1150
+ var _a;
1151
+ const hasOverrides = Boolean((_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors);
1152
+ const flow = this.getFlowSafe();
1153
+ if (flow.properties.stateful && !hasOverrides) {
1154
+ // Skip initialization as backend will take processors from SF
949
1155
  return of(undefined);
950
1156
  }
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));
1157
+ const owners$ = Object.values(this.flowInfoService.templates)
1158
+ .map(template => {
1159
+ var _a, _b, _c;
1160
+ if (!template) {
1161
+ return;
1162
+ }
1163
+ const localProcessors$ = (_c = (_b = (_a = this.customizationService) === null || _a === void 0 ? void 0 : _a.getTemplateConfigurationProcessors) === null || _b === void 0 ? void 0 : _b.call(_a, template.name)) !== null && _c !== void 0 ? _c : of(null);
1164
+ return localProcessors$.pipe(switchMap(processors => processors ? of(processors) : this.processorsApiService.fetchConfigurationProcessors$(template.id)), tap$1(processors => {
1165
+ const processorsMap = processors.reduce((acc, p) => {
1166
+ acc[p.apiName] = p;
1167
+ return acc;
1168
+ }, {});
1169
+ this.processors[template.id] = processorsMap;
1170
+ }));
1171
+ })
1172
+ .filter(isDefined);
1173
+ if (!owners$.length) {
1174
+ return of(undefined);
1175
+ }
1176
+ return forkJoin(owners$).pipe(map$1(noop));
965
1177
  }
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;
970
- if (!script) {
971
- return null;
1178
+ executeActionScript(request, executable) {
1179
+ var _a;
1180
+ const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
1181
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
1182
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1183
+ const scopeText = scope ? ` in ${scope}` : '';
1184
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
972
1185
  }
973
- return this.executeProcessorScript(request, script, processor.inputData);
1186
+ return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
974
1187
  }
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;
979
- if (!script) {
980
- return null;
1188
+ executeSelectorScript(request, executable) {
1189
+ var _a;
1190
+ const configurationProcessor = (_a = this.processors[executable.ownerId]) === null || _a === void 0 ? void 0 : _a[executable.apiName];
1191
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
1192
+ const scope = this.getScopeByOwnerId(executable.ownerId);
1193
+ const scopeText = scope ? ` in ${scope}` : '';
1194
+ throw `ConfigurationProcessor ${executable.apiName}${scopeText} not found`;
981
1195
  }
982
- return this.executeProcessorScript(request, script, processor.inputData);
1196
+ return this.executeProcessorScript(request, configurationProcessor, executable.inputData);
983
1197
  }
984
- executeProcessorScript(request, script, inputData) {
985
- return new Function(`${script}\nreturn transform;`)()({
1198
+ executeProcessorScript(request, configurationProcessor, inputData) {
1199
+ var _a;
1200
+ const scope = this.getScopeByOwnerId((_a = configurationProcessor.ownerId) !== null && _a !== void 0 ? _a : '');
1201
+ let functionToExecute = this.executedFunctions[scope + configurationProcessor.apiName];
1202
+ if (!functionToExecute) {
1203
+ const script = `${configurationProcessor.script}\nreturn transform;`;
1204
+ const sourceMap = `\n//# sourceURL=${scope ? scope + '/' : ''}${configurationProcessor.apiName}.js`;
1205
+ functionToExecute = new Function(script + sourceMap)();
1206
+ this.executedFunctions[scope + configurationProcessor.apiName] = functionToExecute;
1207
+ }
1208
+ return functionToExecute({
986
1209
  request,
987
- inputData: inputData,
1210
+ inputData,
1211
+ flowStore: this.flowStore,
1212
+ });
1213
+ }
1214
+ generateRequestId(scope, selectorName, inputData) {
1215
+ const inputDataHash = UUID.hex(JSON.stringify(inputData) || '').slice(0, 8);
1216
+ return `${scope}/${selectorName}/${inputDataHash}`;
1217
+ }
1218
+ getDefaultExecutionRequestDTO() {
1219
+ var _a, _b, _c;
1220
+ const request = {
1221
+ actions: [],
1222
+ selectors: {},
1223
+ };
1224
+ if (this.getFlowSafe().properties.standalone) {
1225
+ return request;
1226
+ }
1227
+ const ownerId = this.getOwnerIdByScope(UITemplateType.FLOW_ENGINE);
1228
+ (_a = request.actions) === null || _a === void 0 ? void 0 : _a.push({
1229
+ apiName: 'UPDATE_PRICE_LIST',
1230
+ ownerId,
1231
+ inputData: {},
1232
+ });
1233
+ (_b = request.actions) === null || _b === void 0 ? void 0 : _b.push({
1234
+ apiName: 'UPDATE_ASSET_IDS',
1235
+ ownerId,
1236
+ inputData: {},
988
1237
  });
1238
+ (_c = request.actions) === null || _c === void 0 ? void 0 : _c.push({
1239
+ apiName: 'UPDATE_CONTEXT_PROPERTIES',
1240
+ ownerId,
1241
+ inputData: this.contextService.resolve().properties,
1242
+ });
1243
+ return request;
989
1244
  }
990
1245
  }
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: [{
1246
+ 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 }, { token: FLOW_CUSTOMIZATION, optional: true }], target: i0.ɵɵFactoryTarget.Injectable });
1247
+ FlowStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService });
1248
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateService, decorators: [{
994
1249
  type: Injectable
995
- }], ctorParameters: function () { return [{ type: i1.StatefulConfigurationApiService }, { type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: i4.ToastService }]; } });
996
-
997
- function extractMetadata(uiDefinition) {
998
- return omit(uiDefinition, [
999
- 'children',
1000
- 'pages',
1001
- 'components',
1002
- ]);
1003
- }
1250
+ }], ctorParameters: function () {
1251
+ return [{ type: ContextService }, { type: QuoteDraftService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.ConfigurationProcessorsApiService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }, { type: i6.ToastService }, { type: undefined, decorators: [{
1252
+ type: Optional
1253
+ }, {
1254
+ type: Inject,
1255
+ args: [FLOW_CUSTOMIZATION]
1256
+ }] }];
1257
+ } });
1004
1258
 
1005
1259
  class FlowUpdateService {
1006
1260
  update(rootLineItems, updates, charges) {
@@ -1128,29 +1382,360 @@ class FlowUpdateService {
1128
1382
  return true;
1129
1383
  }
1130
1384
  }
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: [{
1385
+ FlowUpdateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, deps: [], target: i0.ɵɵFactoryTarget.Injectable });
1386
+ FlowUpdateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService });
1387
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowUpdateService, decorators: [{
1134
1388
  type: Injectable
1135
1389
  }] });
1136
1390
 
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;
1391
+ class RuntimeSettingsService {
1392
+ constructor(configurationSettingsApiService) {
1393
+ this.configurationSettingsApiService = configurationSettingsApiService;
1394
+ this.configurationSettings$ = new BehaviorSubject({});
1395
+ this.currencySettings$ = new BehaviorSubject({
1396
+ iso: DEFAULT_CURRENCY_ISO_CODE,
1397
+ symbol: DEFAULT_CURRENCY_SYMBOL,
1398
+ });
1399
+ this.shoppingCartSettings$ = new BehaviorSubject([]);
1400
+ this.getCurrencySymbol = (locale, currency) => {
1401
+ return (0)
1402
+ .toLocaleString(locale, { style: 'currency', currency, minimumFractionDigits: 0, maximumFractionDigits: 0 })
1403
+ .replace(/\d/g, '')
1404
+ .trim();
1405
+ };
1144
1406
  }
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
1407
+ create() {
1408
+ return this.configurationSettingsApiService.fetchSettings().pipe(map$1(settings => this.parseConfigurationSettings(settings)), tap$1(configurationSettings => {
1409
+ var _a;
1410
+ this.configurationSettings$.next(configurationSettings);
1411
+ this.addShoppingCartSettings((_a = configurationSettings['shopping-cart']) !== null && _a !== void 0 ? _a : []);
1412
+ this.formattingSettings = this.getFormattingSettings();
1413
+ }), map$1(() => undefined));
1414
+ }
1415
+ initCurrency(iso) {
1416
+ if (iso) {
1417
+ const symbol = this.getCurrencySymbol('en-US', iso);
1418
+ this.currencySettings$.next({ iso, symbol });
1419
+ }
1420
+ }
1421
+ getFormattingSettings() {
1422
+ var _a, _b;
1423
+ if (this.formattingSettings) {
1424
+ return this.formattingSettings;
1425
+ }
1426
+ const shoppingCartSettings = (_a = this.getConfigurationSettings()['shopping-cart']) === null || _a === void 0 ? void 0 : _a.reduce((acc, setting) => {
1427
+ return Object.assign(Object.assign({}, acc), { [setting.id]: setting.properties });
1428
+ }, {});
1429
+ const currencySettings = this.getCurrencySettings();
1430
+ 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)) ||
1431
+ DEFAULT_DATE_FORMAT;
1432
+ const decimalSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.DECIMAL_SEPARATOR;
1433
+ const thousandsSeparator = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.THOUSANDS_SEPARATOR;
1434
+ // the number of decimal places can be 0
1435
+ const priceScale = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.PRICE_SCALE;
1436
+ const decimalsCount = priceScale !== null && priceScale !== '' && !isNaN(Number(priceScale)) && Number(priceScale) >= 0
1437
+ ? Number(priceScale)
1438
+ : DEFAULT_DECIMALS_COUNT;
1439
+ const actionCodeSettings = shoppingCartSettings === null || shoppingCartSettings === void 0 ? void 0 : shoppingCartSettings.STATUS_LABEL;
1440
+ return {
1441
+ currencySymbol: currencySettings.symbol,
1442
+ dateFormats: getSupportedDateFormats(dateFormat),
1443
+ decimalsCount,
1444
+ decimalSeparator: decimalSeparator !== undefined && ['.', ','].includes(decimalSeparator)
1445
+ ? decimalSeparator
1446
+ : DEFAULT_DECIMAL_SEPARATOR,
1447
+ // thousands separator can be a blank value, so it can also be null
1448
+ thousandsSeparator: thousandsSeparator !== undefined && ['.', ',', '', null].includes(thousandsSeparator)
1449
+ ? thousandsSeparator || ''
1450
+ : DEFAULT_THOUSANDS_SEPARATOR,
1451
+ actionCodeLabels: (actionCodeSettings === null || actionCodeSettings === void 0 ? void 0 : actionCodeSettings.length)
1452
+ ? actionCodeSettings.reduce((result, setting) => (Object.assign(Object.assign({}, result), { [setting.status_label]: setting.custom_label })), {})
1453
+ : DEFAULT_ACTION_CODE_LABELS,
1454
+ };
1455
+ }
1456
+ getConfigurationSettings() {
1457
+ return this.configurationSettings$.value;
1458
+ }
1459
+ getShoppingCartSettings() {
1460
+ return this.shoppingCartSettings$.value;
1461
+ }
1462
+ getCurrencySettings() {
1463
+ return this.currencySettings$.value;
1464
+ }
1465
+ parseConfigurationSettings(settings) {
1466
+ return settings.reduce((acc, setting) => {
1467
+ switch (setting.key) {
1468
+ case 'shopping-cart':
1469
+ acc['shopping-cart'] = parseJsonSafely(setting.value, []);
1470
+ break;
1471
+ case 'navigation':
1472
+ acc.navigation = parseJsonSafely(setting.value, {});
1473
+ break;
1474
+ case 'flows':
1475
+ acc.flows = parseJsonSafely(setting.value, []);
1476
+ break;
1477
+ default:
1478
+ acc[setting.key] = setting.value;
1479
+ }
1480
+ return acc;
1481
+ }, {});
1482
+ }
1483
+ addShoppingCartSettings(settings) {
1484
+ // uniqBy removes items with the biggest index
1485
+ const newSettings = uniqBy([...settings, ...this.shoppingCartSettings$.value], 'id');
1486
+ this.shoppingCartSettings$.next(newSettings);
1487
+ }
1488
+ }
1489
+ RuntimeSettingsService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, deps: [{ token: i1.ConfigurationSettingsApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1490
+ RuntimeSettingsService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService });
1491
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeSettingsService, decorators: [{
1492
+ type: Injectable
1493
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationSettingsApiService }]; } });
1494
+
1495
+ class ConfigurationService {
1496
+ constructor(quoteDraftService, runtimeService, contextService, configurationApiService, messageService, dialogService, runtimeSettings) {
1497
+ this.quoteDraftService = quoteDraftService;
1498
+ this.runtimeService = runtimeService;
1499
+ this.contextService = contextService;
1500
+ this.configurationApiService = configurationApiService;
1501
+ this.messageService = messageService;
1502
+ this.dialogService = dialogService;
1503
+ this.runtimeSettings = runtimeSettings;
1504
+ this.mode = ConfigurationMode.SEARCH;
1505
+ this.lineItem = new BehaviorSubject(undefined);
1506
+ this.charges = new BehaviorSubject({});
1507
+ this.pricePlans = new BehaviorSubject({});
1508
+ this.procedureContext = new BehaviorSubject({});
1509
+ this.isLoadingSubj$ = new BehaviorSubject(false);
1510
+ this.isLoading$ = this.isLoadingSubj$.asObservable();
1511
+ this.hasUnsavedChanges = false;
1512
+ }
1513
+ reset() {
1514
+ this.hasUnsavedChanges = false;
1515
+ this.runtimeService.reset();
1516
+ this.configurableRamp = undefined;
1517
+ this.lineItem.next(undefined);
1518
+ this.charges.next({});
1519
+ this.pricePlans.next({});
1520
+ }
1521
+ patch$(lineItem, options) {
1522
+ if (!this.lineItem.value) {
1523
+ return throwError(() => new Error(`Source LineItem not found`));
1524
+ }
1525
+ const skipCardinalityCalculation = (options === null || options === void 0 ? void 0 : options.skipCardinalityCalculation) || this.contextSnapshot.properties['#skipCardinalityCalculation'] === 'true';
1526
+ this.configurableRamp = new LineItemWorker(this.lineItem.value).replace(lineItem, skipCardinalityCalculation).li;
1527
+ return this.configure().pipe(catchError$1(error => {
1528
+ console.error(error);
1529
+ if (!this.runtimeService.uiDefinitionProperties.suppressToastMessages) {
1530
+ this.messageService.add({ severity: 'error', summary: error });
1531
+ }
1532
+ // bounce back if configuration call has failed
1533
+ this.lineItem.next(this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined);
1534
+ return throwError(() => error);
1535
+ }), tap(() => {
1536
+ if (!this.hasUnsavedChanges) {
1537
+ this.hasUnsavedChanges = true;
1538
+ }
1539
+ }));
1540
+ }
1541
+ patch(lineItem, options) {
1542
+ this.patch$(lineItem, options).subscribe();
1543
+ }
1544
+ setConfigurableRamp(lineItem) {
1545
+ this.configurableRamp = lineItem;
1546
+ }
1547
+ get() {
1548
+ return this.lineItem.asObservable().pipe(shareReplay$1());
1549
+ }
1550
+ getSnapshot() {
1551
+ return this.lineItem.value ? Object.assign({}, this.lineItem.value) : undefined;
1552
+ }
1553
+ getRuntimeModel() {
1554
+ const runtimeModel = this.runtimeService.runtimeModel;
1555
+ if (!runtimeModel) {
1556
+ throw new Error('Runtime model not initialized');
1557
+ }
1558
+ return runtimeModel;
1559
+ }
1560
+ getRuntimeContext() {
1561
+ const runtimeContext = this.runtimeService.runtimeContext;
1562
+ if (!runtimeContext) {
1563
+ throw new Error('Runtime context not initialized');
1564
+ }
1565
+ return runtimeContext;
1566
+ }
1567
+ get contextSnapshot() {
1568
+ return this.contextService.resolve();
1569
+ }
1570
+ get context$() {
1571
+ return this.contextService.resolve$();
1572
+ }
1573
+ get charges$() {
1574
+ return this.charges.asObservable();
1575
+ }
1576
+ get chargesSnapshot() {
1577
+ return this.charges.value;
1578
+ }
1579
+ get pricePlans$() {
1580
+ return this.pricePlans.asObservable();
1581
+ }
1582
+ get pricePlansSnapshot() {
1583
+ return this.pricePlans.value;
1584
+ }
1585
+ get procedureContext$() {
1586
+ return this.procedureContext.asObservable();
1587
+ }
1588
+ get procedureContextSnapshot() {
1589
+ return this.procedureContext.value;
1590
+ }
1591
+ configure() {
1592
+ return this.configureRequest$(this.generateRequest());
1593
+ }
1594
+ configureRequest$(configurationRequest) {
1595
+ var _a;
1596
+ const runtimeContext = this.getRuntimeContext();
1597
+ const runtimeModel = this.getRuntimeModel();
1598
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1599
+ const mainPricingEnabled = (_a = runtimeContext.properties) === null || _a === void 0 ? void 0 : _a.PricingEnabled;
1600
+ const pricingEnabled = mainPricingEnabled ? mainPricingEnabled === 'true' : uiDefinitionProperties.pricingEnabled;
1601
+ const customPriceApi = this.runtimeSettings.getConfigurationSettings()['CUSTOM_PRICE_API'];
1602
+ this.isLoadingSubj$.next(true);
1603
+ const configure$ = pricingEnabled && customPriceApi
1604
+ ? this.configurationApiService.customConfigurePrice({ url: customPriceApi, configurationRequest, runtimeModel })
1605
+ : this.configurationApiService.configureLineItem({
1606
+ configurationRequest,
1607
+ runtimeModel,
1608
+ pricingEnabled,
1609
+ });
1610
+ return configure$.pipe(tap(({ lineItem, context, charges, pricePlans, deletedLineItems, procedureContext }) => {
1611
+ this.contextService.update(context !== null && context !== void 0 ? context : {});
1612
+ this.charges.next(charges !== null && charges !== void 0 ? charges : {});
1613
+ this.pricePlans.next(pricePlans !== null && pricePlans !== void 0 ? pricePlans : {});
1614
+ this.procedureContext.next(procedureContext !== null && procedureContext !== void 0 ? procedureContext : {});
1615
+ if (lineItem) {
1616
+ this.lineItem.next(lineItem);
1617
+ }
1618
+ if (deletedLineItems === null || deletedLineItems === void 0 ? void 0 : deletedLineItems.length) {
1619
+ this.showInactiveProductsConfirmation();
1620
+ }
1621
+ this.configurableRamp = lineItem;
1622
+ }), 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$1(() => this.isLoadingSubj$.next(false)));
1623
+ }
1624
+ configureExternal$(props) {
1625
+ return this.runtimeService
1626
+ .init({ productId: props.productId, defaultQty: props.qty, attributesMap: props.attributesMap })
1627
+ .pipe(switchMap$1(() => this.configure()), first(), catchError$1(error => {
1628
+ this.messageService.add({ severity: ToastType.error, summary: error });
1629
+ throw error;
1630
+ }), finalize$1(() => this.reset()));
1631
+ }
1632
+ configureGuidedSelling$(data) {
1633
+ return this.configurationApiService
1634
+ .configureLineItem({
1635
+ configurationRequest: getGuidedSellingConfigurationRequest(data, this.contextService.resolve()),
1636
+ })
1637
+ .pipe(catchError$1(error => {
1638
+ if (error instanceof HttpErrorResponse) {
1639
+ this.messageService.add({ severity: ToastType.error, summary: error.error.message || error.error });
1640
+ }
1641
+ throw error;
1642
+ }));
1643
+ }
1644
+ generateRequest(lightMode = true) {
1645
+ var _a;
1646
+ const lineItem = this.generateLineItem();
1647
+ let request = {
1648
+ lineItem,
1649
+ mode: this.mode,
1650
+ step: !this.lineItem.value ? RuntimeStep.START : RuntimeStep.UPDATE,
1651
+ attributeDomainMode: 'ALL',
1652
+ context: this.contextService.resolve(),
1653
+ lineItems: ((_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.currentState) || [],
1654
+ asset: this.getAsset(),
1655
+ };
1656
+ if (lightMode) {
1657
+ request = ConfigurationTranslatorUtils.lightenConfigurationRequest(request);
1658
+ }
1659
+ return request;
1660
+ }
1661
+ generateLineItem() {
1662
+ var _a;
1663
+ const runtimeContext = this.getRuntimeContext();
1664
+ const uiDefinitionProperties = this.getUIDefinitionProperties();
1665
+ let lineItem = cloneDeep(this.configurableRamp);
1666
+ if (!lineItem) {
1667
+ const { initializationProps } = (_a = this.runtimeService) !== null && _a !== void 0 ? _a : {};
1668
+ lineItem = getDefaultLineItem(runtimeContext, uiDefinitionProperties, initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.defaultQty);
1669
+ // Set default attributes
1670
+ if (initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap) {
1671
+ const attributes = transform(initializationProps === null || initializationProps === void 0 ? void 0 : initializationProps.attributesMap, (acc, value, name) => acc.push({ name, value }), []);
1672
+ lineItem = new LineItemWorker(lineItem).patchAttribute(attributes).li;
1673
+ }
1674
+ }
1675
+ return lineItem;
1676
+ }
1677
+ getUIDefinitionProperties() {
1678
+ var _a, _b, _c;
1679
+ 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 : {}));
1680
+ }
1681
+ showInactiveProductsConfirmation() {
1682
+ const confirmationConfig = {
1683
+ title: ' ',
1684
+ description: 'This quote contains inactive products. Do you want to remove them?',
1685
+ primaryButtonLabel: 'Remove products',
1686
+ secondaryButtonLabel: 'Back to Quote',
1687
+ };
1688
+ this.dialogService
1689
+ .open(ConfirmationComponent, {
1690
+ dismissableMask: false,
1691
+ closeOnEscape: false,
1692
+ closable: false,
1693
+ showHeader: true,
1694
+ header: `Inactive Products in Quote`,
1695
+ width: '440px',
1696
+ data: { confirmationConfig },
1697
+ })
1698
+ .onClose.subscribe(result => {
1699
+ if (!result) {
1700
+ const context = this.contextService.resolve();
1701
+ window['VELO_BACK_FN'].apply(null, [context.headerId]);
1702
+ }
1703
+ });
1704
+ }
1705
+ getAsset() {
1706
+ var _a;
1707
+ const lineItem = this.configurableRamp;
1708
+ if (!lineItem) {
1709
+ return;
1710
+ }
1711
+ return (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.initialState.find(a => a.id === lineItem.openOrderLineItemId || a.id === lineItem.assetId);
1712
+ }
1713
+ }
1714
+ 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 });
1715
+ ConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService });
1716
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationService, decorators: [{
1717
+ type: Injectable
1718
+ }], ctorParameters: function () { return [{ type: QuoteDraftService }, { type: ConfigurationRuntimeService }, { type: ContextService }, { type: i1.ConfigurationApiService }, { type: i5.MessageService }, { type: i6$1.DialogService }, { type: RuntimeSettingsService }]; } });
1719
+
1720
+ class FlowConfigurationService {
1721
+ constructor(proceduresApiService, contextService, quoteDraftService, updateService, configurationService) {
1722
+ this.proceduresApiService = proceduresApiService;
1723
+ this.contextService = contextService;
1724
+ this.quoteDraftService = quoteDraftService;
1725
+ this.updateService = updateService;
1726
+ this.configurationService = configurationService;
1727
+ this.updatedSubj$ = new Subject();
1728
+ this.updated$ = this.updatedSubj$.asObservable();
1729
+ }
1730
+ calculate$(quoteDraft) {
1731
+ return this.proceduresApiService.apply$(quoteDraft).pipe(tap$1(result => {
1732
+ // sort the result current state based on the quote draft initial state
1733
+ const initialStateIds = quoteDraft.initialState.map(lineItem => lineItem.integrationId);
1734
+ result.currentState = result.currentState
1150
1735
  .slice()
1151
1736
  .sort((a, b) => initialStateIds.indexOf(a.integrationId) - initialStateIds.indexOf(b.integrationId));
1152
1737
  this.quoteDraftService.updateQuoteDraft(result);
1153
- }), map$2(noop));
1738
+ }), map$1(noop));
1154
1739
  }
1155
1740
  calculate(quoteDraft) {
1156
1741
  this.calculate$(quoteDraft).subscribe();
@@ -1160,11 +1745,11 @@ class FlowConfigurationService {
1160
1745
  if (!quoteDraft) {
1161
1746
  return of(null);
1162
1747
  }
1163
- return of([]).pipe(map$2(() => {
1748
+ return of([]).pipe(map$1(() => {
1164
1749
  const updatedState = cloneDeep(quoteDraft.currentState);
1165
1750
  this.updateService.update(updatedState, updates, quoteDraft.charges);
1166
1751
  return updatedState;
1167
- }), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1752
+ }), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1168
1753
  }
1169
1754
  update(updates) {
1170
1755
  this.update$(updates).subscribe();
@@ -1183,7 +1768,7 @@ class FlowConfigurationService {
1183
1768
  updatedState.splice(currentLineItemIndex, 1, initialLineItem);
1184
1769
  return of([]).pipe(tap$1(() => {
1185
1770
  this.quoteDraftService.setCurrentLineItemState(updatedState);
1186
- }), switchMap$1(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1771
+ }), switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1187
1772
  }
1188
1773
  revert(lineItemId) {
1189
1774
  this.revert$(lineItemId).subscribe();
@@ -1194,7 +1779,7 @@ class FlowConfigurationService {
1194
1779
  if (!quoteDraft) {
1195
1780
  return of(null);
1196
1781
  }
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());
1782
+ 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), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1198
1783
  }
1199
1784
  delete(ids) {
1200
1785
  this.delete$(ids).subscribe();
@@ -1205,36 +1790,36 @@ class FlowConfigurationService {
1205
1790
  return of(null);
1206
1791
  }
1207
1792
  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());
1793
+ return of([]).pipe(switchMap(() => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1209
1794
  }
1210
1795
  addToCart$(props) {
1211
1796
  const quoteDraft = this.quoteDraftService.quoteDraft;
1212
1797
  if (!quoteDraft) {
1213
1798
  return of(null);
1214
1799
  }
1215
- return this.configurationService.configureExternal$(props).pipe(map$2(lineItem => {
1800
+ return this.configurationService.configureExternal$(props).pipe(map$1(lineItem => {
1216
1801
  var _a, _b, _c;
1217
1802
  const model = this.configurationService.getRuntimeModel();
1218
1803
  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
1804
  const lineItems = multiplyLineItems(lineItem, (_c = props.qty) !== null && _c !== void 0 ? _c : 1, split);
1220
1805
  return [...quoteDraft.currentState, ...lineItems];
1221
- }), switchMap$1(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$2(() => this.quoteDraftService.quoteDraft), this.handleErrorAndBounceBack());
1806
+ }), switchMap(updatedState => this.calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))), map$1(() => this.quoteDraftService.quoteDraft), tap$1(() => this.updatedSubj$.next()), this.handleErrorAndBounceBack());
1222
1807
  }
1223
1808
  get() {
1224
- return this.quoteDraftService.quoteDraft$.pipe(map$2(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1809
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(() => this.quoteDraftService.activeCurrentState), shareReplay$1());
1225
1810
  }
1226
1811
  getSnapshot() {
1227
1812
  var _a, _b;
1228
1813
  return (_b = (_a = this.quoteDraftService) === null || _a === void 0 ? void 0 : _a.currentState.slice()) !== null && _b !== void 0 ? _b : [];
1229
1814
  }
1230
1815
  get charges$() {
1231
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ charges }) => charges));
1816
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ charges }) => charges));
1232
1817
  }
1233
1818
  get pricePlans$() {
1234
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ pricePlans }) => pricePlans));
1819
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ pricePlans }) => pricePlans));
1235
1820
  }
1236
1821
  get activeMetrics$() {
1237
- return this.quoteDraftService.quoteDraft$.pipe(map$2(({ activeMetrics }) => activeMetrics));
1822
+ return this.quoteDraftService.quoteDraft$.pipe(map$1(({ activeMetrics }) => activeMetrics));
1238
1823
  }
1239
1824
  get chargesSnapshot() {
1240
1825
  var _a, _b;
@@ -1248,306 +1833,541 @@ class FlowConfigurationService {
1248
1833
  var _a, _b;
1249
1834
  return (_b = (_a = this.quoteDraftService.quoteDraft) === null || _a === void 0 ? void 0 : _a.activeMetrics) !== null && _b !== void 0 ? _b : [];
1250
1835
  }
1251
- get contextSnapshot() {
1252
- return this.contextService.resolve();
1836
+ get contextSnapshot() {
1837
+ return this.contextService.resolve();
1838
+ }
1839
+ get context$() {
1840
+ return this.contextService.resolve$();
1841
+ }
1842
+ handleErrorAndBounceBack() {
1843
+ return (source$) => {
1844
+ return source$.pipe(catchError(error => {
1845
+ console.error(error);
1846
+ // bounce back if configuration call has failed
1847
+ const quoteDraft = this.quoteDraftService.quoteDraft;
1848
+ if (quoteDraft) {
1849
+ this.quoteDraftService.updateQuoteDraft(quoteDraft);
1850
+ this.updatedSubj$.next();
1851
+ }
1852
+ return throwError(() => error);
1853
+ }));
1854
+ };
1855
+ }
1856
+ }
1857
+ 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 });
1858
+ FlowConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService });
1859
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationService, decorators: [{
1860
+ type: Injectable
1861
+ }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1862
+
1863
+ class FlowConfigurationModule {
1864
+ }
1865
+ FlowConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
1866
+ FlowConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, imports: [ApiModule] });
1867
+ FlowConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, providers: [FlowConfigurationService, FlowUpdateService], imports: [ApiModule] });
1868
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowConfigurationModule, decorators: [{
1869
+ type: NgModule,
1870
+ args: [{
1871
+ imports: [ApiModule],
1872
+ providers: [FlowConfigurationService, FlowUpdateService],
1873
+ }]
1874
+ }] });
1875
+
1876
+ class FlowStateConfigurationService {
1877
+ constructor(flowInfoService, flowConfigurationService, flowStateApiService, flowStateService) {
1878
+ this.flowInfoService = flowInfoService;
1879
+ this.flowConfigurationService = flowConfigurationService;
1880
+ this.flowStateApiService = flowStateApiService;
1881
+ this.flowStateService = flowStateService;
1882
+ this.configurationStateId$ = new BehaviorSubject(null);
1883
+ }
1884
+ get configurationStateId() {
1885
+ return this.configurationStateId$.value;
1886
+ }
1887
+ addToCart$(props) {
1888
+ var _a;
1889
+ let request$;
1890
+ const stateful = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful;
1891
+ if (stateful) {
1892
+ const stateId = this.flowStateService.stateId;
1893
+ if (!stateId) {
1894
+ request$ = of();
1895
+ }
1896
+ else {
1897
+ const lineItem = generateConfigurationLineItem(props, props.qty);
1898
+ request$ = this.flowStateApiService.newConfiguration(stateId, { lineItem }).pipe(tap$1(r => this.configurationStateId$.next(r.stateId)), switchMap(() => {
1899
+ if (!this.configurationStateId) {
1900
+ return of();
1901
+ }
1902
+ return this.flowStateApiService.saveConfiguration(stateId, this.configurationStateId).pipe(tap$1(() => this.configurationStateId$.next(null)), map$1(noop));
1903
+ }));
1904
+ }
1905
+ }
1906
+ else {
1907
+ request$ = this.flowConfigurationService.addToCart$(props).pipe(map$1(noop));
1908
+ }
1909
+ return request$.pipe(switchMap(() => this.flowStateService.executeRequest$({}, true)), map$1(noop));
1910
+ }
1911
+ }
1912
+ FlowStateConfigurationService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, deps: [{ token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: FlowStateService }], target: i0.ɵɵFactoryTarget.Injectable });
1913
+ FlowStateConfigurationService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService });
1914
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: FlowStateConfigurationService, decorators: [{
1915
+ type: Injectable
1916
+ }], ctorParameters: function () { return [{ type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: FlowStateService }]; } });
1917
+
1918
+ class ProductImagesService {
1919
+ constructor(productApiService) {
1920
+ this.productApiService = productApiService;
1921
+ this.imagesMap$ = new BehaviorSubject({});
1922
+ }
1923
+ getImageUrl$(productId) {
1924
+ if (this.imagesMap$.value[productId] == null) {
1925
+ this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: '' }));
1926
+ this.fetchProductImage(productId);
1927
+ }
1928
+ return this.imagesMap$.pipe(map$1(imagesMap => { var _a; return (_a = imagesMap[productId]) !== null && _a !== void 0 ? _a : null; }), distinctUntilChanged());
1929
+ }
1930
+ fetchProductImage(productId) {
1931
+ this.productApiService
1932
+ .fetchImage$(productId)
1933
+ .pipe(map$1(file => URL.createObjectURL(file)), catchError(() => of('')), tap$1(url => this.imagesMap$.next(Object.assign(Object.assign({}, this.imagesMap$.value), { [productId]: url }))))
1934
+ .subscribe();
1935
+ }
1936
+ }
1937
+ ProductImagesService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, deps: [{ token: i1.ProductApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1938
+ ProductImagesService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService });
1939
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ProductImagesService, decorators: [{
1940
+ type: Injectable
1941
+ }], ctorParameters: function () { return [{ type: i1.ProductApiService }]; } });
1942
+
1943
+ class RuntimeContextService {
1944
+ constructor(configurationApiService) {
1945
+ this.configurationApiService = configurationApiService;
1946
+ }
1947
+ getRuntimeContext(productId, offeringId) {
1948
+ return this.configurationApiService.getRuntimeDataByProductId(productId, offeringId).pipe(map(runtimeData => {
1949
+ var _a;
1950
+ const uiDefinitionContainer = this.getUIDefinitionContainer(runtimeData);
1951
+ const runtimeModel = RuntimeModel.create(runtimeData.types, runtimeData.products);
1952
+ const { productName, properties } = (_a = Array.from(runtimeModel.components.values()).find(c => c.productId === productId)) !== null && _a !== void 0 ? _a : {};
1953
+ const uiDefinitionProperties = uiDefinitionContainer === null || uiDefinitionContainer === void 0 ? void 0 : uiDefinitionContainer.source.properties;
1954
+ return {
1955
+ modelId: runtimeData.modelId,
1956
+ uiDefinitionContainer: uiDefinitionContainer,
1957
+ runtimeModel: runtimeModel,
1958
+ runtimeMode: RuntimeMode.PROD,
1959
+ productId: productId,
1960
+ productType: (properties === null || properties === void 0 ? void 0 : properties['displayName']) || productName,
1961
+ offeringId: offeringId,
1962
+ properties: {
1963
+ PricingEnabled: (uiDefinitionProperties === null || uiDefinitionProperties === void 0 ? void 0 : uiDefinitionProperties.pricingEnabled) ? 'true' : 'false',
1964
+ PriceListId: uiDefinitionProperties === null || uiDefinitionProperties === void 0 ? void 0 : uiDefinitionProperties.priceList,
1965
+ },
1966
+ };
1967
+ }));
1968
+ }
1969
+ getUIDefinitionContainer(runtimeData) {
1970
+ var _a;
1971
+ const containers = runtimeData.uiDefinitions.filter(container => isNotLegacyUIDefinition(container.source));
1972
+ return (_a = containers.find(container => container.source.primary)) !== null && _a !== void 0 ? _a : containers[0];
1973
+ }
1974
+ }
1975
+ RuntimeContextService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, deps: [{ token: i1.ConfigurationApiService }], target: i0.ɵɵFactoryTarget.Injectable });
1976
+ RuntimeContextService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService });
1977
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: RuntimeContextService, decorators: [{
1978
+ type: Injectable
1979
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }]; } });
1980
+
1981
+ class ConfigurationRuntimeService {
1982
+ constructor(apiService, contextService, runtimeContextService) {
1983
+ this.apiService = apiService;
1984
+ this.contextService = contextService;
1985
+ this.runtimeContextService = runtimeContextService;
1986
+ this._isInitialized = false;
1987
+ this.uiDefinitionProperties = {};
1988
+ }
1989
+ reset() {
1990
+ this._isInitialized = false;
1991
+ this._runtimeContext = undefined;
1992
+ this.initializationProps = undefined;
1993
+ this.uiDefinitionProperties = {};
1994
+ }
1995
+ initTestMode(uiDefinitionContainer) {
1996
+ var _a, _b;
1997
+ this.uiDefinitionProperties = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
1998
+ const uiDefinitionExternals = (_b = uiDefinitionContainer.source.externals) !== null && _b !== void 0 ? _b : {};
1999
+ return combineLatest([
2000
+ this.apiService.getRuntimeDataByModelId(uiDefinitionContainer.modelId),
2001
+ this.contextService.initTestMode(),
2002
+ ]).pipe(first(), map(([runtimeData, context]) => {
2003
+ var _a;
2004
+ this.contextService.update({
2005
+ 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),
2006
+ });
2007
+ this._runtimeContext = {
2008
+ modelId: uiDefinitionContainer.modelId,
2009
+ runtimeModel: RuntimeModel.create(runtimeData.types, runtimeData.products),
2010
+ runtimeMode: RuntimeMode.TEST,
2011
+ uiDefinitionContainer,
2012
+ };
2013
+ return this._runtimeContext;
2014
+ }), tap(() => (this._isInitialized = true)));
2015
+ }
2016
+ init(props) {
2017
+ this.initializationProps = props;
2018
+ const context = this.contextService.resolve();
2019
+ return this.runtimeContextService.getRuntimeContext(props.productId, props.offeringId).pipe(tap(runtimeContext => {
2020
+ var _a, _b, _c, _d;
2021
+ this.uiDefinitionProperties = (_b = (_a = runtimeContext.uiDefinitionContainer) === null || _a === void 0 ? void 0 : _a.source.properties) !== null && _b !== void 0 ? _b : {};
2022
+ const { PriceListId } = (_c = context.properties) !== null && _c !== void 0 ? _c : {};
2023
+ const mergeContext = Object.assign(Object.assign({}, runtimeContext), { properties: Object.assign(Object.assign(Object.assign({}, runtimeContext.properties), context.properties), { PricingEnabled: PriceListId ? 'true' : 'false' }) });
2024
+ this.id15to18('AccountId', mergeContext.properties);
2025
+ this._runtimeContext = mergeContext;
2026
+ if (context.properties && ((_d = this._runtimeContext.properties) === null || _d === void 0 ? void 0 : _d.StartDate)) {
2027
+ this.contextService.update({
2028
+ properties: Object.assign(Object.assign({}, this._runtimeContext.properties), context.properties),
2029
+ });
2030
+ }
2031
+ return this._runtimeContext;
2032
+ }), tap(() => (this._isInitialized = true)));
2033
+ }
2034
+ overrideUIDefinition(uiDefinitionContainer) {
2035
+ var _a;
2036
+ if (!this._runtimeContext) {
2037
+ return;
2038
+ }
2039
+ this._runtimeContext.uiDefinitionContainer = uiDefinitionContainer;
2040
+ this.uiDefinitionProperties = (_a = uiDefinitionContainer.source.properties) !== null && _a !== void 0 ? _a : {};
2041
+ }
2042
+ id15to18(propertyName, source) {
2043
+ if (!source) {
2044
+ return;
2045
+ }
2046
+ const value = source[propertyName];
2047
+ if (typeof value === 'string' && value.length === 15) {
2048
+ source[propertyName] = SalesforceIdUtils.generateId18FromId15(value);
2049
+ }
2050
+ }
2051
+ get isInitialized() {
2052
+ return this._isInitialized;
1253
2053
  }
1254
- get context$() {
1255
- return this.contextService.resolve$();
2054
+ get runtimeModel() {
2055
+ var _a;
2056
+ return (_a = this.runtimeContext) === null || _a === void 0 ? void 0 : _a.runtimeModel;
1256
2057
  }
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
- };
2058
+ get runtimeContext() {
2059
+ return this._runtimeContext;
1269
2060
  }
1270
2061
  }
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: [{
2062
+ 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 });
2063
+ ConfigurationRuntimeService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService });
2064
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationRuntimeService, decorators: [{
1274
2065
  type: Injectable
1275
- }], ctorParameters: function () { return [{ type: i1.ProceduresApiService }, { type: ContextService }, { type: QuoteDraftService }, { type: FlowUpdateService }, { type: ConfigurationService }]; } });
1276
-
1277
- class FlowConfigurationModule {
1278
- }
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: [{
1283
- type: NgModule,
1284
- args: [{
1285
- imports: [],
1286
- providers: [FlowConfigurationService, FlowUpdateService, PriceApiService],
1287
- }]
1288
- }] });
1289
-
1290
- class ConfigurationModule {
1291
- }
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: [
1295
- ContextApiService,
1296
- ProductModelApiService,
1297
- ConfigurationApiService,
1298
- ConfigurationRuntimeService,
1299
- RuntimeContextService,
1300
- ConfigurationService,
1301
- ConfigurationState,
1302
- ], imports: [ConfirmationDialogModule] });
1303
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: ConfigurationModule, decorators: [{
1304
- type: NgModule,
1305
- args: [{
1306
- imports: [ConfirmationDialogModule],
1307
- providers: [
1308
- ContextApiService,
1309
- ProductModelApiService,
1310
- ConfigurationApiService,
1311
- ConfigurationRuntimeService,
1312
- RuntimeContextService,
1313
- ConfigurationService,
1314
- ConfigurationState,
1315
- ],
1316
- }]
1317
- }] });
2066
+ }], ctorParameters: function () { return [{ type: i1.ConfigurationApiService }, { type: ContextService }, { type: RuntimeContextService }]; } });
1318
2067
 
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]);
2068
+ class ConfigurationStateService {
2069
+ constructor(configurationRuntimeService, configurationService, quoteDraftService, toastService, flowStateService, flowInfoService, flowConfigurationService, flowStateApiService, quoteApiService) {
2070
+ this.configurationRuntimeService = configurationRuntimeService;
2071
+ this.configurationService = configurationService;
2072
+ this.quoteDraftService = quoteDraftService;
2073
+ this.toastService = toastService;
2074
+ this.flowStateService = flowStateService;
2075
+ this.flowInfoService = flowInfoService;
2076
+ this.flowConfigurationService = flowConfigurationService;
2077
+ this.flowStateApiService = flowStateApiService;
2078
+ this.quoteApiService = quoteApiService;
2079
+ this.isInitialized$ = new BehaviorSubject(false);
2080
+ this.canceledConfiguration$ = new Subject();
2081
+ this.NOT_INITIALIZED = Symbol();
2082
+ this.executedFunctions = {};
2083
+ this.stateId = null;
2084
+ this.ownerId = '';
2085
+ this.subscriptions = {};
2086
+ this.configurationStore = {};
2087
+ }
2088
+ init$() {
2089
+ let request$;
2090
+ if (this.flowStateService.stateId && this.isStatefulConfiguration) {
2091
+ request$ = this.initStateful$();
1344
2092
  }
1345
- case 'avg': {
1346
- const rootTermItems = lineItems.filter(li => !li.rampInstanceId);
1347
- return rootTermItems.map(lineItem => [lineItem, ...lineItems.filter(li => li.rampInstanceId === lineItem.id)]);
2093
+ else {
2094
+ request$ = this.initStateless$();
1348
2095
  }
1349
- case 'sum': {
1350
- return lineItems.map(item => [item]);
2096
+ return request$.pipe(finalize(() => {
2097
+ this.isInitialized$.next(true);
2098
+ this.canceledConfiguration$ = new Subject();
2099
+ }));
2100
+ }
2101
+ cleanup() {
2102
+ this.stateId = null;
2103
+ this.configurationStore = {};
2104
+ this.configurationService.reset();
2105
+ }
2106
+ execute$(req, forceSubscriptions) {
2107
+ var _a;
2108
+ const fullRequest = cloneDeep(req);
2109
+ if (((_a = fullRequest.actions) === null || _a === void 0 ? void 0 : _a.length) || forceSubscriptions) {
2110
+ for (const subscription of Object.values(this.subscriptions)) {
2111
+ fullRequest.selectors = assign(fullRequest.selectors, subscription.request.selectors);
2112
+ }
1351
2113
  }
1352
- default: {
1353
- return lineItems.map(item => [item]);
2114
+ let execution$;
2115
+ if (this.isStatefulConfiguration) {
2116
+ execution$ = this.executeStateful$(fullRequest);
1354
2117
  }
2118
+ else {
2119
+ execution$ = this.executeStateless$(fullRequest);
2120
+ }
2121
+ return execution$.pipe(tap$1(result => this.handleSelectorsResponse(result.selectors)));
1355
2122
  }
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) || '{}');
2123
+ handleSelectorsResponse(selectors) {
2124
+ Object.entries(selectors).forEach(([requestId, selectorResult]) => {
2125
+ var _a;
2126
+ if (!selectorResult.success) {
2127
+ this.toastService.add({ severity: ToastType.error, summary: selectorResult.errorMessage });
1382
2128
  }
1383
- catch (error) {
1384
- settingsData = {};
2129
+ const subscription$ = (_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$;
2130
+ if (subscription$) {
2131
+ subscription$.next(selectorResult);
1385
2132
  }
1386
- this.quoteMetricsSettings = settingsData;
1387
- this.updateMetrics(lineItems);
1388
2133
  });
1389
2134
  }
1390
- getMetricValue(metric) {
1391
- return this.metricsData[metric] || 0;
2135
+ dispatch$(actionName, inputData = {}) {
2136
+ return this.execute$({ actions: [{ apiName: actionName, inputData, ownerId: this.ownerId }] });
1392
2137
  }
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');
2138
+ select$(selectorName, inputData = {}) {
2139
+ const requestId = UUID.UUID();
2140
+ return this.execute$({
2141
+ selectors: {
2142
+ [requestId]: {
2143
+ apiName: selectorName,
2144
+ inputData,
2145
+ ownerId: this.ownerId,
2146
+ },
2147
+ },
2148
+ }).pipe(map$1(response => response.selectors[requestId]));
1401
2149
  }
1402
- buildMetricsCalculationMethods(metricKeys, initial) {
1403
- return metricKeys.reduce((acc, name) => {
1404
- var _a, _b;
1405
- if (acc[name]) {
1406
- return acc;
2150
+ subscribe$(selectorName, inputData = {}, options) {
2151
+ const requestId = UUID.UUID();
2152
+ let subscription = this.subscriptions[requestId];
2153
+ if (!subscription) {
2154
+ const request = {
2155
+ selectors: {
2156
+ [requestId]: {
2157
+ apiName: selectorName,
2158
+ inputData,
2159
+ ownerId: this.ownerId,
2160
+ },
2161
+ },
2162
+ };
2163
+ subscription = {
2164
+ request,
2165
+ data$: new BehaviorSubject(this.NOT_INITIALIZED),
2166
+ };
2167
+ this.subscriptions[requestId] = subscription;
2168
+ if (!(options === null || options === void 0 ? void 0 : options.cold)) {
2169
+ this.execute$(request).subscribe();
1407
2170
  }
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] });
2171
+ }
2172
+ return subscription.data$.pipe(filter$1(data => data != this.NOT_INITIALIZED), map$1(data => data), finalize(() => {
2173
+ var _a;
2174
+ if (!((_a = this.subscriptions[requestId]) === null || _a === void 0 ? void 0 : _a.data$.observed)) {
2175
+ delete this.subscriptions[requestId];
1413
2176
  }
1414
- return acc;
1415
- }, initial);
2177
+ }), takeUntil(this.canceledConfiguration$));
1416
2178
  }
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);
2179
+ saveConfiguration(quoteId, flow) {
2180
+ var _a, _b;
2181
+ if (this.isStatefulConfiguration) {
2182
+ return this.flowStateApiService
2183
+ .saveConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '')
2184
+ .pipe(switchMap(r => this.flowStateService.executeRequest$({}, true).pipe(map$1(() => r))));
2185
+ }
2186
+ else {
2187
+ if (!flow) {
2188
+ if (!quoteId) {
2189
+ return of({ quoteId: '' });
2190
+ }
2191
+ const rootLineItem = this.configurationService.getSnapshot();
2192
+ const currentState = rootLineItem ? [rootLineItem] : [];
2193
+ return this.quoteApiService
2194
+ .getQuoteDraft(quoteId)
2195
+ .pipe(switchMap(quoteDraft => this.quoteApiService.upsertQuote(Object.assign(Object.assign({}, quoteDraft), { currentState }))));
2196
+ }
2197
+ else {
2198
+ const quoteDraft = this.quoteDraftService.quoteDraft;
2199
+ const lineItem = this.configurationService.getSnapshot();
2200
+ if (!quoteDraft || !lineItem) {
2201
+ return of({ quoteId: '' });
2202
+ }
2203
+ const isNewLineItem = quoteDraft.currentState.every(li => li.id !== lineItem.id);
2204
+ let updatedState;
2205
+ if (isNewLineItem) {
2206
+ updatedState = [...quoteDraft.currentState, lineItem];
2207
+ }
2208
+ else {
2209
+ updatedState = quoteDraft.currentState.map(li => (li.id === lineItem.id ? lineItem : li));
2210
+ }
2211
+ return this.flowConfigurationService
2212
+ .calculate$(Object.assign(Object.assign({}, quoteDraft), { currentState: updatedState }))
2213
+ .pipe(map$1(() => ({ quoteId: '' })));
2214
+ }
2215
+ }
1424
2216
  }
1425
- getMetricRuleByTotalMetricName(name) {
1426
- return this.activeMetricRules.find(metricRule => metricRule.metrics.find(metric => metric.totalName === name));
2217
+ cancelConfiguration() {
2218
+ var _a, _b;
2219
+ if (!this.isInitialized$.value) {
2220
+ return of(undefined);
2221
+ }
2222
+ this.canceledConfiguration$.next();
2223
+ this.canceledConfiguration$.complete();
2224
+ this.subscriptions = {};
2225
+ this.isInitialized$.next(false);
2226
+ if (!this.isInitialized$.value || !this.isStatefulConfiguration) {
2227
+ return of(undefined);
2228
+ }
2229
+ return this.flowStateApiService.cancelConfiguration((_a = this.flowStateService.stateId) !== null && _a !== void 0 ? _a : '', (_b = this.stateId) !== null && _b !== void 0 ? _b : '');
1427
2230
  }
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({});
2231
+ get isStatefulConfiguration() {
2232
+ var _a, _b;
2233
+ return (_b = (_a = this.flowInfoService.flow) === null || _a === void 0 ? void 0 : _a.properties.stateful) !== null && _b !== void 0 ? _b : false;
1440
2234
  }
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);
2235
+ initStateful$() {
2236
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k;
2237
+ this.ownerId = (_c = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) === null || _b === void 0 ? void 0 : _b.id) !== null && _c !== void 0 ? _c : '';
2238
+ const lineItemId = (_e = (_d = this.configurationRuntimeService.runtimeContext) === null || _d === void 0 ? void 0 : _d.properties) === null || _e === void 0 ? void 0 : _e.lineItemId;
2239
+ if (!this.flowStateService.stateId) {
2240
+ return of(undefined);
1445
2241
  }
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();
2242
+ const container = (_f = this.configurationRuntimeService.runtimeContext) === null || _f === void 0 ? void 0 : _f.uiDefinitionContainer;
2243
+ const lineItem = this.configurationService.generateLineItem();
2244
+ let request$;
2245
+ if (!lineItemId) {
2246
+ request$ = this.flowStateApiService.newConfiguration(this.flowStateService.stateId, {
2247
+ lineItem,
2248
+ actionsOverride: (_g = container === null || container === void 0 ? void 0 : container.actions) === null || _g === void 0 ? void 0 : _g.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
2249
+ selectorsOverride: (_h = container === null || container === void 0 ? void 0 : container.selectors) === null || _h === void 0 ? void 0 : _h.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
2250
+ });
2251
+ }
2252
+ else {
2253
+ request$ = this.flowStateApiService.startConfiguration(this.flowStateService.stateId, {
2254
+ lineItemId,
2255
+ actionsOverride: (_j = container === null || container === void 0 ? void 0 : container.actions) === null || _j === void 0 ? void 0 : _j.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
2256
+ selectorsOverride: (_k = container === null || container === void 0 ? void 0 : container.selectors) === null || _k === void 0 ? void 0 : _k.map(processor => (Object.assign(Object.assign({}, processor), { ownerId: this.ownerId }))),
2257
+ });
2258
+ }
2259
+ return request$.pipe(map$1(r => {
2260
+ this.stateId = r.stateId;
2261
+ return undefined;
2262
+ }));
1453
2263
  }
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
- };
2264
+ initStateless$() {
2265
+ return this.configurationService.configure().pipe(map$1(() => undefined));
1476
2266
  }
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));
2267
+ executeStateless$(request) {
2268
+ return of(undefined).pipe(switchMap(() => {
2269
+ var _a;
2270
+ // Apply actions and execute configuration/price call
2271
+ // No need to run configuration if no actions in the request
2272
+ if (!((_a = request.actions) === null || _a === void 0 ? void 0 : _a.length)) {
2273
+ return of(undefined);
2274
+ }
2275
+ let configurationRequest = this.configurationService.generateRequest();
2276
+ request.actions.forEach(action => {
2277
+ var _a;
2278
+ try {
2279
+ configurationRequest = (_a = this.executeActionScript(configurationRequest, action)) !== null && _a !== void 0 ? _a : configurationRequest;
2280
+ }
2281
+ catch (e) {
2282
+ console.error(e);
2283
+ this.toastService.add({ severity: ToastType.error, summary: String(e) });
2284
+ throw e;
2285
+ }
2286
+ });
2287
+ return this.configurationService.configureRequest$(configurationRequest);
2288
+ }), map$1(() => {
2289
+ var _a;
2290
+ // Run selectors and apply them to the state
2291
+ const finalConfigurationRequest = this.configurationService.generateRequest(false);
2292
+ const selectorsResult = EntityUtil.entries((_a = request.selectors) !== null && _a !== void 0 ? _a : {}).reduce((result, [key, selector]) => {
2293
+ try {
2294
+ result.selectors[key] = {
2295
+ success: true,
2296
+ result: this.executeSelectorScript(finalConfigurationRequest, selector),
2297
+ };
2298
+ }
2299
+ catch (e) {
2300
+ console.error(e);
2301
+ result.selectors[key] = {
2302
+ success: false,
2303
+ errorMessage: String(e),
2304
+ };
2305
+ }
2306
+ return result;
2307
+ }, { stateId: '', selectors: {} });
2308
+ return selectorsResult;
2309
+ }));
1482
2310
  }
1483
- initCurrency(iso) {
1484
- if (iso) {
1485
- const symbol = this.getCurrencySymbol('en-US', iso);
1486
- this.currencySettings$.next({ iso, symbol });
2311
+ executeStateful$(request) {
2312
+ if (!this.flowStateService.stateId || !this.stateId) {
2313
+ return of();
1487
2314
  }
2315
+ return this.flowStateApiService.executeConfiguration(this.flowStateService.stateId, this.stateId, request).pipe(tap$1(response => {
2316
+ this.stateId = response.stateId;
2317
+ }));
1488
2318
  }
1489
- getFormattingSettings() {
2319
+ executeActionScript(request, processor) {
1490
2320
  var _a, _b;
1491
- if (this.formattingSettings) {
1492
- return this.formattingSettings;
2321
+ const { actions } = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
2322
+ const configurationProcessor = actions === null || actions === void 0 ? void 0 : actions.find(action => action.apiName === processor.apiName);
2323
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
2324
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
1493
2325
  }
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;
2326
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
1525
2327
  }
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
- }, {});
2328
+ executeSelectorScript(request, processor) {
2329
+ var _a, _b;
2330
+ const { selectors } = (_b = (_a = this.configurationRuntimeService.runtimeContext) === null || _a === void 0 ? void 0 : _a.uiDefinitionContainer) !== null && _b !== void 0 ? _b : {};
2331
+ const configurationProcessor = selectors === null || selectors === void 0 ? void 0 : selectors.find(selector => selector.apiName === processor.apiName);
2332
+ if (!(configurationProcessor === null || configurationProcessor === void 0 ? void 0 : configurationProcessor.script)) {
2333
+ throw `ConfigurationProcessor ${processor.apiName} not found`;
2334
+ }
2335
+ return this.executeProcessorScript(request, configurationProcessor, processor.inputData);
2336
+ }
2337
+ executeProcessorScript(request, configurationProcessor, inputData) {
2338
+ let functionToExecute = this.executedFunctions[configurationProcessor.apiName];
2339
+ if (!functionToExecute) {
2340
+ const script = `${configurationProcessor.script}\nreturn transform;`;
2341
+ const sourceMap = `\n//# sourceURL=${configurationProcessor.apiName}.js`;
2342
+ functionToExecute = new Function(script + sourceMap)();
2343
+ this.executedFunctions[configurationProcessor.apiName] = functionToExecute;
2344
+ }
2345
+ return functionToExecute({
2346
+ request,
2347
+ inputData,
2348
+ flowStore: this.flowStateService.getFlowStore(),
2349
+ configurationStore: this.configurationStore,
2350
+ });
1543
2351
  }
1544
2352
  }
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 }]; } });
2353
+ ConfigurationStateService.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, deps: [{ token: ConfigurationRuntimeService }, { token: ConfigurationService }, { token: QuoteDraftService }, { token: i6.ToastService }, { token: FlowStateService }, { token: FlowInfoService }, { token: FlowConfigurationService }, { token: i1.FlowStateApiService }, { token: i1.QuoteApiService }], target: i0.ɵɵFactoryTarget.Injectable });
2354
+ ConfigurationStateService.ɵprov = i0.ɵɵngDeclareInjectable({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService });
2355
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationStateService, decorators: [{
2356
+ type: Injectable
2357
+ }], ctorParameters: function () { return [{ type: ConfigurationRuntimeService }, { type: ConfigurationService }, { type: QuoteDraftService }, { type: i6.ToastService }, { type: FlowStateService }, { type: FlowInfoService }, { type: FlowConfigurationService }, { type: i1.FlowStateApiService }, { type: i1.QuoteApiService }]; } });
2358
+
2359
+ class ConfigurationModule {
2360
+ }
2361
+ ConfigurationModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2362
+ ConfigurationModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, imports: [ConfirmationDialogModule, ApiModule] });
2363
+ ConfigurationModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService], imports: [ConfirmationDialogModule, ApiModule] });
2364
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ConfigurationModule, decorators: [{
2365
+ type: NgModule,
2366
+ args: [{
2367
+ imports: [ConfirmationDialogModule, ApiModule],
2368
+ providers: [ConfigurationRuntimeService, RuntimeContextService, ConfigurationService, ConfigurationStateService],
2369
+ }]
2370
+ }] });
1551
2371
 
1552
2372
  const DEFAULT_FORMATTING_SETTINGS = {
1553
2373
  currencySymbol: DEFAULT_CURRENCY_SYMBOL,
@@ -1555,31 +2375,38 @@ const DEFAULT_FORMATTING_SETTINGS = {
1555
2375
  dateFormats: getSupportedDateFormats(DEFAULT_DATE_FORMAT),
1556
2376
  decimalSeparator: DEFAULT_DECIMAL_SEPARATOR,
1557
2377
  thousandsSeparator: DEFAULT_THOUSANDS_SEPARATOR,
2378
+ actionCodeLabels: DEFAULT_ACTION_CODE_LABELS,
1558
2379
  };
1559
2380
  class SdkCoreModule {
1560
2381
  }
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: [
2382
+ SdkCoreModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2383
+ SdkCoreModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, imports: [ConfigurationModule, FlowConfigurationModule] });
2384
+ SdkCoreModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, providers: [
1564
2385
  ContextService,
2386
+ FlowInfoService,
1565
2387
  QuoteDraftService,
1566
2388
  ProductImagesService,
1567
- MetricsCalculationService,
2389
+ IntegrationState,
2390
+ FlowStateService,
2391
+ FlowStateConfigurationService,
1568
2392
  RuntimeSettingsService,
1569
2393
  {
1570
2394
  provide: FORMATTING_SETTINGS_TOKEN,
1571
2395
  useExisting: RuntimeSettingsService,
1572
2396
  },
1573
2397
  ], imports: [ConfigurationModule, FlowConfigurationModule] });
1574
- i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImport: i0, type: SdkCoreModule, decorators: [{
2398
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkCoreModule, decorators: [{
1575
2399
  type: NgModule,
1576
2400
  args: [{
1577
2401
  imports: [ConfigurationModule, FlowConfigurationModule],
1578
2402
  providers: [
1579
2403
  ContextService,
2404
+ FlowInfoService,
1580
2405
  QuoteDraftService,
1581
2406
  ProductImagesService,
1582
- MetricsCalculationService,
2407
+ IntegrationState,
2408
+ FlowStateService,
2409
+ FlowStateConfigurationService,
1583
2410
  RuntimeSettingsService,
1584
2411
  {
1585
2412
  provide: FORMATTING_SETTINGS_TOKEN,
@@ -1614,9 +2441,9 @@ class CalendarDirective {
1614
2441
  }
1615
2442
  }
1616
2443
  }
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: [{
2444
+ CalendarDirective.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, deps: [], target: i0.ɵɵFactoryTarget.Directive });
2445
+ CalendarDirective.ɵdir = i0.ɵɵngDeclareDirective({ minVersion: "14.0.0", version: "15.2.9", type: CalendarDirective, selector: "[vlCalendar]", inputs: { vlCalendar: "vlCalendar" }, ngImport: i0 });
2446
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: CalendarDirective, decorators: [{
1620
2447
  type: Directive,
1621
2448
  args: [{
1622
2449
  selector: '[vlCalendar]',
@@ -1627,10 +2454,10 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1627
2454
 
1628
2455
  class SdkDirectivesModule {
1629
2456
  }
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: [{
2457
+ SdkDirectivesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2458
+ SdkDirectivesModule.ɵmod = i0.ɵɵngDeclareNgModule({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, declarations: [CalendarDirective], exports: [CalendarDirective] });
2459
+ SdkDirectivesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule });
2460
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkDirectivesModule, decorators: [{
1634
2461
  type: NgModule,
1635
2462
  args: [{
1636
2463
  declarations: [CalendarDirective],
@@ -1650,22 +2477,28 @@ class DatePipe {
1650
2477
  this.destroy$.next();
1651
2478
  this.destroy$.complete();
1652
2479
  }
1653
- transform(date) {
2480
+ transform(date, type = 'date') {
1654
2481
  var _a, _b;
1655
2482
  if (!date) {
1656
2483
  return '';
1657
2484
  }
2485
+ const dateFormat = ((_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.dateFormats.datePipeFormat) || DEFAULT_DATE_FORMAT;
2486
+ const formatMap = {
2487
+ date: dateFormat,
2488
+ time: DEFAULT_TIME_FORMAT,
2489
+ datetime: `${dateFormat} ${DEFAULT_TIME_FORMAT}`,
2490
+ };
1658
2491
  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);
2492
+ return formatDate(date, formatMap[type], this.locale, (_b = this.defaultOptions) === null || _b === void 0 ? void 0 : _b.timezone);
1660
2493
  }
1661
2494
  catch (error) {
1662
2495
  return new Date(date).toString();
1663
2496
  }
1664
2497
  }
1665
2498
  }
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: [{
2499
+ DatePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2500
+ DatePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, name: "vlDate" });
2501
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: DatePipe, decorators: [{
1669
2502
  type: Pipe,
1670
2503
  args: [{
1671
2504
  name: 'vlDate',
@@ -1687,9 +2520,9 @@ class NumberPipe {
1687
2520
  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
2521
  }
1689
2522
  }
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: [{
2523
+ NumberPipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2524
+ NumberPipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, name: "vlNumber" });
2525
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: NumberPipe, decorators: [{
1693
2526
  type: Pipe,
1694
2527
  args: [{
1695
2528
  name: 'vlNumber',
@@ -1714,25 +2547,44 @@ class PricePipe {
1714
2547
  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
2548
  }
1716
2549
  }
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: [{
2550
+ PricePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2551
+ PricePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, name: "vlPrice" });
2552
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: PricePipe, decorators: [{
1720
2553
  type: Pipe,
1721
2554
  args: [{
1722
2555
  name: 'vlPrice',
1723
2556
  }]
1724
2557
  }] });
1725
2558
 
2559
+ class ActionCodePipe {
2560
+ constructor() {
2561
+ var _a;
2562
+ this.formattingSettings = (_a = inject(FORMATTING_SETTINGS_TOKEN, { optional: true })) === null || _a === void 0 ? void 0 : _a.getFormattingSettings();
2563
+ }
2564
+ transform(actionCode) {
2565
+ var _a, _b;
2566
+ return (_b = (_a = this.formattingSettings) === null || _a === void 0 ? void 0 : _a.actionCodeLabels[actionCode]) !== null && _b !== void 0 ? _b : actionCode;
2567
+ }
2568
+ }
2569
+ ActionCodePipe.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, deps: [], target: i0.ɵɵFactoryTarget.Pipe });
2570
+ ActionCodePipe.ɵpipe = i0.ɵɵngDeclarePipe({ minVersion: "14.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, name: "vlActionCode" });
2571
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: ActionCodePipe, decorators: [{
2572
+ type: Pipe,
2573
+ args: [{
2574
+ name: 'vlActionCode',
2575
+ }]
2576
+ }] });
2577
+
1726
2578
  class SdkPipesModule {
1727
2579
  }
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: [{
2580
+ SdkPipesModule.ɵfac = i0.ɵɵngDeclareFactory({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, deps: [], target: i0.ɵɵFactoryTarget.NgModule });
2581
+ 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] });
2582
+ SdkPipesModule.ɵinj = i0.ɵɵngDeclareInjector({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule });
2583
+ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.9", ngImport: i0, type: SdkPipesModule, decorators: [{
1732
2584
  type: NgModule,
1733
2585
  args: [{
1734
- declarations: [NumberPipe, PricePipe, DatePipe],
1735
- exports: [NumberPipe, PricePipe, DatePipe],
2586
+ declarations: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
2587
+ exports: [NumberPipe, PricePipe, DatePipe, ActionCodePipe],
1736
2588
  }]
1737
2589
  }] });
1738
2590
 
@@ -1740,5 +2592,5 @@ i0.ɵɵngDeclareClassMetadata({ minVersion: "12.0.0", version: "15.2.8", ngImpor
1740
2592
  * Generated bundle index. Do not edit.
1741
2593
  */
1742
2594
 
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 };
2595
+ export { ActionCodePipe, CalendarDirective, ConfigurationRuntimeService, ConfigurationService, ConfigurationStateService, ContextService, DEFAULT_FORMATTING_SETTINGS, DatePipe, FLOW_CUSTOMIZATION, FORMATTING_SETTINGS_TOKEN, FlowConfigurationModule, FlowConfigurationService, FlowInfoService, FlowStateConfigurationService, FlowStateService, FlowUpdateService, IntegrationState, LineItemWorker, NumberPipe, PricePipe, ProductImagesService, QuoteDraftService, RuntimeMode, RuntimeOperation, RuntimeSettingsService, RuntimeStep, SdkCoreModule, SdkDirectivesModule, SdkPipesModule, UI_DEFINITION_VERSION, extractMetadata, filterOutTechnicalAttributes, findLineItem, findLineItemWithComparator, generateConfigurationLineItem, generateLineItem, generateModifiedAssetsMap, getAttributeValue, getAttributes, getDefaultLineItem, getGuidedSellingConfigurationRequest, getOriginParent, getRecommendedPrices, insertLineItem, isLineItemModified, isTechnicalAttribute, lineItem_utils as lineItemUtils, mapAttributes, multiplyLineItems, patchAttributes, recalculateCardinalityVariables, removeLineItem, replaceLineItem, upsertAttributes };
1744
2596
  //# sourceMappingURL=veloceapps-sdk-core.mjs.map