@flarehr/apollo-benefits 0.1.109 → 0.3.53405

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (216) hide show
  1. package/README.md +19 -0
  2. package/dist/assets/@splitsoftware-7d799540.js +18 -0
  3. package/dist/assets/all_tab_color-548783b9.svg +21 -0
  4. package/dist/assets/all_tab_gray-a5051313.svg +6 -0
  5. package/dist/assets/check-57fe1dcb.svg +15 -0
  6. package/dist/assets/datadog-ff247651.js +5 -0
  7. package/dist/assets/date-fns-c5d8fbc0.js +1 -0
  8. package/dist/assets/default_backdrop-fdd955b8.png +0 -0
  9. package/dist/assets/external_link-599a0aec.svg +3 -0
  10. package/dist/assets/external_link_white-55111b2e.svg +3 -0
  11. package/dist/assets/framer-motion-bb8d6b82.js +1 -0
  12. package/dist/assets/index-0b3afb09.js +5 -0
  13. package/dist/assets/index-5e9e5aa9.js +35 -0
  14. package/dist/assets/index-cfa25e28.css +1 -0
  15. package/dist/assets/lodash-5d893f8c.js +1 -0
  16. package/dist/assets/logo-a34e9b4b.png +0 -0
  17. package/dist/assets/oidc-client-6f6e47c2.js +101 -0
  18. package/dist/assets/padlock-8c081120.svg +26 -0
  19. package/dist/assets/suitcase-6471ad05.svg +17 -0
  20. package/dist/assets/vendor-2d0139ca.js +788 -0
  21. package/dist/assets/warning-a7f1af23.svg +14 -0
  22. package/dist/assets/welcome_image_mobile-dbde6c80.png +0 -0
  23. package/dist/assets/welcome_image_v2-869c59e4.png +0 -0
  24. package/dist/assets/wellbeing_banner-6903d615.png +0 -0
  25. package/dist/assets/workplace_link_banner_mobile-6ebaa24b.png +0 -0
  26. package/dist/assets/workplace_link_banner_v2-c81ed849.png +0 -0
  27. package/dist/config.json +14 -0
  28. package/dist/favicon.ico +0 -0
  29. package/dist/icons/android-chrome-192x192.png +0 -0
  30. package/dist/icons/android-chrome-512x512.png +0 -0
  31. package/dist/icons/apple-touch-icon.png +0 -0
  32. package/dist/icons/favicon-16x16.png +0 -0
  33. package/dist/icons/favicon-32x32.png +0 -0
  34. package/dist/index.html +114 -0
  35. package/dist/manifest.json +21 -0
  36. package/dist/sw-esm.js +16 -0
  37. package/package.json +129 -60
  38. package/LICENSE +0 -21
  39. package/dist/lib/apollo-benefits/apollo-benefits.esm.js +0 -1
  40. package/dist/lib/apollo-benefits/assets/car-placeholder.svg +0 -5
  41. package/dist/lib/apollo-benefits/assets/check.svg +0 -13
  42. package/dist/lib/apollo-benefits/index.esm.js +0 -0
  43. package/dist/lib/apollo-benefits/p-06a1f65f.js +0 -1
  44. package/dist/lib/apollo-benefits/p-077d7f8d.entry.js +0 -1
  45. package/dist/lib/apollo-benefits/p-14054f15.js +0 -1
  46. package/dist/lib/apollo-benefits/p-24a37d64.js +0 -1
  47. package/dist/lib/apollo-benefits/p-2b3f3b72.entry.js +0 -1
  48. package/dist/lib/apollo-benefits/p-3111d565.entry.js +0 -1
  49. package/dist/lib/apollo-benefits/p-327396fa.entry.js +0 -1
  50. package/dist/lib/apollo-benefits/p-3d4d2683.js +0 -1
  51. package/dist/lib/apollo-benefits/p-4474bcf8.entry.js +0 -1
  52. package/dist/lib/apollo-benefits/p-4bff99bd.entry.js +0 -1
  53. package/dist/lib/apollo-benefits/p-50fe790f.js +0 -1
  54. package/dist/lib/apollo-benefits/p-53bcbd1d.js +0 -1
  55. package/dist/lib/apollo-benefits/p-68c136da.js +0 -1
  56. package/dist/lib/apollo-benefits/p-6bd16f5b.js +0 -1
  57. package/dist/lib/apollo-benefits/p-71dbc8ff.entry.js +0 -1
  58. package/dist/lib/apollo-benefits/p-774d9bc5.entry.js +0 -1
  59. package/dist/lib/apollo-benefits/p-7a2ca86d.entry.js +0 -1
  60. package/dist/lib/apollo-benefits/p-7a572b50.js +0 -1
  61. package/dist/lib/apollo-benefits/p-7c2cd94a.entry.js +0 -1
  62. package/dist/lib/apollo-benefits/p-839493d7.entry.js +0 -1
  63. package/dist/lib/apollo-benefits/p-a24d169b.entry.js +0 -1
  64. package/dist/lib/apollo-benefits/p-b33fc683.js +0 -1
  65. package/dist/lib/apollo-benefits/p-beb8f728.entry.js +0 -1
  66. package/dist/lib/apollo-benefits/p-e241f55b.entry.js +0 -1
  67. package/dist/lib/apollo-benefits/p-e28cee25.js +0 -1
  68. package/dist/lib/apollo-benefits/p-e3cf51f1.entry.js +0 -1
  69. package/dist/lib/apollo-benefits/p-ef8ea713.entry.js +0 -1
  70. package/dist/lib/apollo-benefits/p-f0a7c9fa.entry.js +0 -1
  71. package/dist/lib/apollo-benefits/p-f603197d.js +0 -15
  72. package/dist/lib/cjs/active-router-0ecaf2b8.js +0 -75
  73. package/dist/lib/cjs/ap-ben-choose-vehicle-section_4.cjs.entry.js +0 -2708
  74. package/dist/lib/cjs/ap-ben-complete-section_4.cjs.entry.js +0 -108
  75. package/dist/lib/cjs/ap-ben-notifications-section.cjs.entry.js +0 -238
  76. package/dist/lib/cjs/apollo-benefits.cjs.js +0 -25
  77. package/dist/lib/cjs/app-globals-67583b8b.js +0 -12
  78. package/dist/lib/cjs/async-6a7926f0.js +0 -753
  79. package/dist/lib/cjs/cars-calculator-app.cjs.entry.js +0 -55
  80. package/dist/lib/cjs/cars-calculator.service-c0e51584.js +0 -904
  81. package/dist/lib/cjs/context-consumer.cjs.entry.js +0 -29
  82. package/dist/lib/cjs/datorama-akita-31d23240.js +0 -2551
  83. package/dist/lib/cjs/delay-d31618c3.js +0 -206
  84. package/dist/lib/cjs/distinctUntilChanged-e8538790.js +0 -371
  85. package/dist/lib/cjs/dom-utils-b8befdd5.js +0 -63
  86. package/dist/lib/cjs/fl-button_2.cjs.entry.js +0 -50
  87. package/dist/lib/cjs/fl-dropdown-async_2.cjs.entry.js +0 -467
  88. package/dist/lib/cjs/fl-dropdown.cjs.entry.js +0 -232
  89. package/dist/lib/cjs/fl-style-guide.cjs.entry.js +0 -91
  90. package/dist/lib/cjs/index-f1fadf90.js +0 -1735
  91. package/dist/lib/cjs/index.cjs.js +0 -2
  92. package/dist/lib/cjs/loader.cjs.js +0 -27
  93. package/dist/lib/cjs/location-utils-36fe7e5e.js +0 -237
  94. package/dist/lib/cjs/match-path-be4ea5f6.js +0 -279
  95. package/dist/lib/cjs/session.query-d61ba7ec.js +0 -1731
  96. package/dist/lib/cjs/stencil-async-content.cjs.entry.js +0 -32
  97. package/dist/lib/cjs/stencil-route-link.cjs.entry.js +0 -78
  98. package/dist/lib/cjs/stencil-route-switch.cjs.entry.js +0 -104
  99. package/dist/lib/cjs/stencil-route-title.cjs.entry.js +0 -32
  100. package/dist/lib/cjs/stencil-route.cjs.entry.js +0 -97
  101. package/dist/lib/cjs/stencil-router-prompt.cjs.entry.js +0 -59
  102. package/dist/lib/cjs/stencil-router-redirect.cjs.entry.js +0 -32
  103. package/dist/lib/cjs/stencil-router.cjs.entry.js +0 -640
  104. package/dist/lib/collection/assets/image/complete.svg +0 -122
  105. package/dist/lib/collection/collection-manifest.json +0 -53
  106. package/dist/lib/collection/components/cars-calculator-app/api/api-client.js +0 -5
  107. package/dist/lib/collection/components/cars-calculator-app/api/cars-calculator.api.js +0 -45
  108. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.css +0 -22
  109. package/dist/lib/collection/components/cars-calculator-app/cars-calculator-app.js +0 -97
  110. package/dist/lib/collection/components/cars-calculator-app/modal-section/modal-section.css +0 -0
  111. package/dist/lib/collection/components/cars-calculator-app/modal-section/modal-section.js +0 -144
  112. package/dist/lib/collection/components/cars-calculator-app/notifications-section/notifications-section.js +0 -25
  113. package/dist/lib/collection/components/cars-calculator-app/pages/assets/car-placeholder.svg +0 -5
  114. package/dist/lib/collection/components/cars-calculator-app/pages/assets/check.svg +0 -13
  115. package/dist/lib/collection/components/cars-calculator-app/pages/choose-vehicle-section.component.js +0 -196
  116. package/dist/lib/collection/components/cars-calculator-app/pages/complete-section.component.js +0 -38
  117. package/dist/lib/collection/components/cars-calculator-app/pages/cost-breakdown-section.component.js +0 -45
  118. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.css +0 -34
  119. package/dist/lib/collection/components/cars-calculator-app/pages/model-variants-section.component.js +0 -85
  120. package/dist/lib/collection/components/cars-calculator-app/pages/personal-info-section.component.js +0 -66
  121. package/dist/lib/collection/components/cars-calculator-app/pages/quote-result-section.component.js +0 -86
  122. package/dist/lib/collection/components/cars-calculator-app/pages/submit-quote-section.component.js +0 -75
  123. package/dist/lib/collection/components/cars-calculator-app/services/app-configuration.service.js +0 -13
  124. package/dist/lib/collection/components/cars-calculator-app/services/cars-calculator.service.js +0 -106
  125. package/dist/lib/collection/components/cars-calculator-app/services/notifications.service.js +0 -37
  126. package/dist/lib/collection/components/cars-calculator-app/services/notifications.store.js +0 -3
  127. package/dist/lib/collection/components/cars-calculator-app/services/session.query.js +0 -35
  128. package/dist/lib/collection/components/cars-calculator-app/services/session.store.js +0 -78
  129. package/dist/lib/collection/global/config.js +0 -2
  130. package/dist/lib/collection/global/main.dev.js +0 -5
  131. package/dist/lib/collection/global/main.js +0 -5
  132. package/dist/lib/collection/index.js +0 -2
  133. package/dist/lib/collection/utils/config.js +0 -2
  134. package/dist/lib/collection/utils/index.js +0 -15
  135. package/dist/lib/collection/utils/lazy.js +0 -29
  136. package/dist/lib/esm/active-router-7c2ca849.js +0 -73
  137. package/dist/lib/esm/ap-ben-choose-vehicle-section_4.entry.js +0 -2701
  138. package/dist/lib/esm/ap-ben-complete-section_4.entry.js +0 -101
  139. package/dist/lib/esm/ap-ben-notifications-section.entry.js +0 -234
  140. package/dist/lib/esm/apollo-benefits.js +0 -23
  141. package/dist/lib/esm/app-globals-65714cca.js +0 -10
  142. package/dist/lib/esm/async-68e9cad7.js +0 -738
  143. package/dist/lib/esm/cars-calculator-app.entry.js +0 -51
  144. package/dist/lib/esm/cars-calculator.service-27826530.js +0 -897
  145. package/dist/lib/esm/context-consumer.entry.js +0 -25
  146. package/dist/lib/esm/datorama-akita-c87196a0.js +0 -2545
  147. package/dist/lib/esm/delay-115d4292.js +0 -200
  148. package/dist/lib/esm/distinctUntilChanged-bf69e0f8.js +0 -363
  149. package/dist/lib/esm/dom-utils-109a7d75.js +0 -55
  150. package/dist/lib/esm/fl-button_2.entry.js +0 -45
  151. package/dist/lib/esm/fl-dropdown-async_2.entry.js +0 -462
  152. package/dist/lib/esm/fl-dropdown.entry.js +0 -228
  153. package/dist/lib/esm/fl-style-guide.entry.js +0 -87
  154. package/dist/lib/esm/index-19c4d245.js +0 -1703
  155. package/dist/lib/esm/index.js +0 -1
  156. package/dist/lib/esm/loader.js +0 -23
  157. package/dist/lib/esm/location-utils-312665d3.js +0 -226
  158. package/dist/lib/esm/match-path-4b5c7d98.js +0 -276
  159. package/dist/lib/esm/polyfills/core-js.js +0 -11
  160. package/dist/lib/esm/polyfills/css-shim.js +0 -1
  161. package/dist/lib/esm/polyfills/dom.js +0 -79
  162. package/dist/lib/esm/polyfills/es5-html-element.js +0 -1
  163. package/dist/lib/esm/polyfills/index.js +0 -34
  164. package/dist/lib/esm/polyfills/system.js +0 -6
  165. package/dist/lib/esm/session.query-0f1c9503.js +0 -1719
  166. package/dist/lib/esm/stencil-async-content.entry.js +0 -28
  167. package/dist/lib/esm/stencil-route-link.entry.js +0 -74
  168. package/dist/lib/esm/stencil-route-switch.entry.js +0 -100
  169. package/dist/lib/esm/stencil-route-title.entry.js +0 -28
  170. package/dist/lib/esm/stencil-route.entry.js +0 -93
  171. package/dist/lib/esm/stencil-router-prompt.entry.js +0 -55
  172. package/dist/lib/esm/stencil-router-redirect.entry.js +0 -28
  173. package/dist/lib/esm/stencil-router.entry.js +0 -636
  174. package/dist/lib/index.cjs.js +0 -1
  175. package/dist/lib/index.js +0 -1
  176. package/dist/lib/loader/cdn.js +0 -3
  177. package/dist/lib/loader/index.cjs.js +0 -3
  178. package/dist/lib/loader/index.d.ts +0 -13
  179. package/dist/lib/loader/index.es2017.js +0 -3
  180. package/dist/lib/loader/index.js +0 -4
  181. package/dist/lib/loader/package.json +0 -10
  182. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/button/button.css +0 -45
  183. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown/dropdown.css +0 -9
  184. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/dropdown-async/dropdown-async.css +0 -9
  185. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/loading-indicator/loading-indicator.css +0 -141
  186. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/promise-button/promise-button.css +0 -5
  187. package/dist/lib/node_modules/@flarehr/beacon/dist/collection/components/style-guide/style-guide.css +0 -0
  188. package/dist/lib/node_modules/@stencil/router/dist/collection/components/route/route.css +0 -3
  189. package/dist/lib/types/components/cars-calculator-app/api/api-client.d.ts +0 -2
  190. package/dist/lib/types/components/cars-calculator-app/api/cars-calculator.api.d.ts +0 -99
  191. package/dist/lib/types/components/cars-calculator-app/cars-calculator-app.d.ts +0 -17
  192. package/dist/lib/types/components/cars-calculator-app/modal-section/modal-section.d.ts +0 -16
  193. package/dist/lib/types/components/cars-calculator-app/notifications-section/notifications-section.d.ts +0 -5
  194. package/dist/lib/types/components/cars-calculator-app/pages/choose-vehicle-section.component.d.ts +0 -23
  195. package/dist/lib/types/components/cars-calculator-app/pages/complete-section.component.d.ts +0 -5
  196. package/dist/lib/types/components/cars-calculator-app/pages/cost-breakdown-section.component.d.ts +0 -6
  197. package/dist/lib/types/components/cars-calculator-app/pages/model-variants-section.component.d.ts +0 -12
  198. package/dist/lib/types/components/cars-calculator-app/pages/personal-info-section.component.d.ts +0 -10
  199. package/dist/lib/types/components/cars-calculator-app/pages/quote-result-section.component.d.ts +0 -13
  200. package/dist/lib/types/components/cars-calculator-app/pages/submit-quote-section.component.d.ts +0 -10
  201. package/dist/lib/types/components/cars-calculator-app/services/app-configuration.service.d.ts +0 -7
  202. package/dist/lib/types/components/cars-calculator-app/services/cars-calculator.service.d.ts +0 -11
  203. package/dist/lib/types/components/cars-calculator-app/services/notifications.service.d.ts +0 -15
  204. package/dist/lib/types/components/cars-calculator-app/services/notifications.store.d.ts +0 -14
  205. package/dist/lib/types/components/cars-calculator-app/services/session.query.d.ts +0 -25
  206. package/dist/lib/types/components/cars-calculator-app/services/session.store.d.ts +0 -77
  207. package/dist/lib/types/components.d.ts +0 -170
  208. package/dist/lib/types/global/config.d.ts +0 -2
  209. package/dist/lib/types/global/main.d.ts +0 -1
  210. package/dist/lib/types/global/main.dev.d.ts +0 -1
  211. package/dist/lib/types/index.d.ts +0 -2
  212. package/dist/lib/types/stencil-public-runtime.d.ts +0 -1555
  213. package/dist/lib/types/utils/config.d.ts +0 -2
  214. package/dist/lib/types/utils/index.d.ts +0 -7
  215. package/dist/lib/types/utils/lazy.d.ts +0 -12
  216. package/readme.md +0 -1
@@ -1,897 +0,0 @@
1
- import { g as getOrElse, a as appConfigurationService, s as sessionQuery, c as sessionStore, n as none, i as isSome, e as some } from './session.query-0f1c9503.js';
2
-
3
- /**
4
- * @since 2.0.0
5
- */
6
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) {
7
- switch (arguments.length) {
8
- case 1:
9
- return a;
10
- case 2:
11
- return ab(a);
12
- case 3:
13
- return bc(ab(a));
14
- case 4:
15
- return cd(bc(ab(a)));
16
- case 5:
17
- return de(cd(bc(ab(a))));
18
- case 6:
19
- return ef(de(cd(bc(ab(a)))));
20
- case 7:
21
- return fg(ef(de(cd(bc(ab(a))))));
22
- case 8:
23
- return gh(fg(ef(de(cd(bc(ab(a)))))));
24
- case 9:
25
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
26
- case 10:
27
- return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))));
28
- case 11:
29
- return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))));
30
- case 12:
31
- return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))));
32
- case 13:
33
- return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))));
34
- case 14:
35
- return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))));
36
- case 15:
37
- return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))));
38
- case 16:
39
- return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))));
40
- case 17:
41
- return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))));
42
- case 18:
43
- return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))));
44
- case 19:
45
- return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))));
46
- case 20:
47
- return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))));
48
- }
49
- return;
50
- }
51
-
52
- // TODO: remove module in v3
53
- /**
54
- * Use [`pipe`](https://gcanti.github.io/fp-ts/modules/function.ts.html#flow) from `function` module instead.
55
- *
56
- * @since 2.0.0
57
- */
58
- var pipe$1 = pipe;
59
-
60
- function getOrDefault(option, value) {
61
- return pipe$1(option, getOrElse(() => value));
62
- }
63
- function getOrError(option) {
64
- return pipe$1(option, getOrElse(() => {
65
- throw new Error('Option value is none.');
66
- }));
67
- }
68
- function toSelectInputOptionsArray(list) {
69
- return list.map((s) => ({ label: String(s), value: s }));
70
- }
71
-
72
- var __assign = (undefined && undefined.__assign) || function () {
73
- __assign = Object.assign || function(t) {
74
- for (var s, i = 1, n = arguments.length; i < n; i++) {
75
- s = arguments[i];
76
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
77
- t[p] = s[p];
78
- }
79
- return t;
80
- };
81
- return __assign.apply(this, arguments);
82
- };
83
- var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
84
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
85
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
86
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
87
- r[k] = a[j];
88
- return r;
89
- };
90
- var mix = function (one, two, mergeArrays) {
91
- if (mergeArrays === void 0) { mergeArrays = false; }
92
- if (!one || !two || typeof one !== "object" || typeof two !== "object")
93
- return one;
94
- var clone = __assign({}, one);
95
- for (var prop in two) {
96
- if (two.hasOwnProperty(prop)) {
97
- if (two[prop] instanceof Array && one[prop] instanceof Array) {
98
- clone[prop] = mergeArrays ? __spreadArrays(one[prop], two[prop]) : two[prop];
99
- }
100
- else if (typeof two[prop] === "object" && typeof one[prop] === "object") {
101
- clone[prop] = mix(one[prop], two[prop], mergeArrays);
102
- }
103
- else {
104
- clone[prop] = two[prop];
105
- }
106
- }
107
- }
108
- return clone;
109
- };
110
-
111
- var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
112
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
113
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
114
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
115
- r[k] = a[j];
116
- return r;
117
- };
118
- var config = {
119
- // Default options
120
- defaults: {},
121
- // Error type
122
- errorType: null,
123
- // Polyfills
124
- polyfills: {
125
- fetch: null,
126
- FormData: null,
127
- URLSearchParams: null,
128
- performance: null,
129
- PerformanceObserver: null,
130
- AbortController: null
131
- },
132
- polyfill: function (p, _a) {
133
- var _b = _a === void 0 ? {} : _a, _c = _b.doThrow, doThrow = _c === void 0 ? true : _c, _d = _b.instance, instance = _d === void 0 ? false : _d;
134
- var args = [];
135
- for (var _i = 2; _i < arguments.length; _i++) {
136
- args[_i - 2] = arguments[_i];
137
- }
138
- var res = this.polyfills[p] ||
139
- (typeof self !== "undefined" ? self[p] : null) ||
140
- (typeof global !== "undefined" ? global[p] : null);
141
- if (doThrow && !res)
142
- throw new Error(p + " is not defined");
143
- return instance && res ? new (res.bind.apply(res, __spreadArrays$1([void 0], args)))() : res;
144
- }
145
- };
146
-
147
- var onMatch = function (entries, name, callback, _performance) {
148
- if (!entries.getEntriesByName)
149
- return false;
150
- var matches = entries.getEntriesByName(name);
151
- if (matches && matches.length > 0) {
152
- callback(matches.reverse()[0]);
153
- if (_performance.clearMeasures)
154
- _performance.clearMeasures(name);
155
- perfs.callbacks.delete(name);
156
- if (perfs.callbacks.size < 1) {
157
- perfs.observer.disconnect();
158
- if (_performance.clearResourceTimings) {
159
- _performance.clearResourceTimings();
160
- }
161
- }
162
- return true;
163
- }
164
- return false;
165
- };
166
- var lazyObserver = function (_performance, _observer) {
167
- if (!perfs.observer && _performance && _observer) {
168
- perfs.observer = new _observer(function (entries) {
169
- perfs.callbacks.forEach(function (callback, name) {
170
- onMatch(entries, name, callback, _performance);
171
- });
172
- });
173
- if (_performance.clearResourceTimings)
174
- _performance.clearResourceTimings();
175
- }
176
- return perfs.observer;
177
- };
178
- var perfs = {
179
- callbacks: new Map(),
180
- observer: null,
181
- observe: function (name, callback) {
182
- if (!name || !callback)
183
- return;
184
- var _performance = config.polyfill("performance", { doThrow: false });
185
- var _observer = config.polyfill("PerformanceObserver", { doThrow: false });
186
- if (!lazyObserver(_performance, _observer))
187
- return;
188
- if (!onMatch(_performance, name, callback, _performance)) {
189
- if (perfs.callbacks.size < 1)
190
- perfs.observer.observe({ entryTypes: ["resource", "measure"] });
191
- perfs.callbacks.set(name, callback);
192
- }
193
- }
194
- };
195
-
196
- var middlewareHelper = function (middlewares) { return function (fetchFunction) {
197
- return (middlewares.length === 0 ?
198
- fetchFunction :
199
- middlewares.length === 1 ?
200
- middlewares[0](fetchFunction) :
201
- middlewares.reduceRight(function (acc, curr, idx) {
202
- return (idx === middlewares.length - 2) ? curr(acc(fetchFunction)) : curr(acc);
203
- }));
204
- }; };
205
-
206
- var WretchErrorWrapper = /** @class */ (function () {
207
- function WretchErrorWrapper(error) {
208
- this.error = error;
209
- }
210
- return WretchErrorWrapper;
211
- }());
212
- var resolver = function (wretcher) {
213
- var url = wretcher._url, _catchers = wretcher._catchers, resolvers = wretcher._resolvers, middlewares = wretcher._middlewares, opts = wretcher._options;
214
- var catchers = new Map(_catchers);
215
- var finalOptions = mix(config.defaults, opts);
216
- var fetchController = config.polyfill("AbortController", { doThrow: false, instance: true });
217
- if (!finalOptions["signal"] && fetchController) {
218
- finalOptions["signal"] = fetchController.signal;
219
- }
220
- // Request timeout
221
- var timeout = {
222
- ref: null,
223
- clear: function () {
224
- if (timeout.ref) {
225
- clearTimeout(timeout.ref);
226
- timeout.ref = null;
227
- }
228
- }
229
- };
230
- // The generated fetch request
231
- var fetchRequest = middlewareHelper(middlewares)(config.polyfill("fetch"))(url, finalOptions);
232
- // Throws on an http error
233
- var throwingPromise = fetchRequest
234
- .catch(function (error) {
235
- throw new WretchErrorWrapper(error);
236
- })
237
- .then(function (response) {
238
- timeout.clear();
239
- if (!response.ok) {
240
- return response[config.errorType || "text"]().then(function (msg) {
241
- // Enhances the error object
242
- var err = new Error(msg);
243
- err[config.errorType || "text"] = msg;
244
- err["status"] = response.status;
245
- err["response"] = response;
246
- throw err;
247
- });
248
- }
249
- return response;
250
- });
251
- // Wraps the Promise in order to dispatch the error to a matching catcher
252
- var catchersWrapper = function (promise) {
253
- return promise.catch(function (err) {
254
- timeout.clear();
255
- var error = err instanceof WretchErrorWrapper ? err.error : err;
256
- if (err instanceof WretchErrorWrapper && catchers.has("__fromFetch"))
257
- return catchers.get("__fromFetch")(error, wretcher);
258
- else if (catchers.has(error.status))
259
- return catchers.get(error.status)(error, wretcher);
260
- else if (catchers.has(error.name))
261
- return catchers.get(error.name)(error, wretcher);
262
- else
263
- throw error;
264
- });
265
- };
266
- var bodyParser = function (funName) { return function (cb) { return funName ?
267
- // If a callback is provided, then callback with the body result otherwise return the parsed body itself.
268
- catchersWrapper(throwingPromise.then(function (_) { return _ && _[funName](); }).then(function (_) { return cb ? cb(_) : _; })) :
269
- // No body parsing method - return the response
270
- catchersWrapper(throwingPromise.then(function (_) { return cb ? cb(_) : _; })); }; };
271
- var responseChain = {
272
- /**
273
- * Retrieves the raw result as a promise.
274
- */
275
- res: bodyParser(null),
276
- /**
277
- * Retrieves the result as a parsed JSON object.
278
- */
279
- json: bodyParser("json"),
280
- /**
281
- * Retrieves the result as a Blob object.
282
- */
283
- blob: bodyParser("blob"),
284
- /**
285
- * Retrieves the result as a FormData object.
286
- */
287
- formData: bodyParser("formData"),
288
- /**
289
- * Retrieves the result as an ArrayBuffer object.
290
- */
291
- arrayBuffer: bodyParser("arrayBuffer"),
292
- /**
293
- * Retrieves the result as a string.
294
- */
295
- text: bodyParser("text"),
296
- /**
297
- * Performs a callback on the API performance timings of the request.
298
- *
299
- * Warning: Still experimental on browsers and node.js
300
- */
301
- perfs: function (cb) {
302
- fetchRequest.then(function (res) { return perfs.observe(res.url, cb); });
303
- return responseChain;
304
- },
305
- /**
306
- * Aborts the request after a fixed time.
307
- *
308
- * @param time Time in milliseconds
309
- * @param controller A custom controller
310
- */
311
- setTimeout: function (time, controller) {
312
- if (controller === void 0) { controller = fetchController; }
313
- timeout.clear();
314
- timeout.ref = setTimeout(function () { return controller.abort(); }, time);
315
- return responseChain;
316
- },
317
- /**
318
- * Returns the automatically generated AbortController alongside the current wretch response as a pair.
319
- */
320
- controller: function () { return [fetchController, responseChain]; },
321
- /**
322
- * Catches an http response with a specific error code or name and performs a callback.
323
- */
324
- error: function (errorId, cb) {
325
- catchers.set(errorId, cb);
326
- return responseChain;
327
- },
328
- /**
329
- * Catches a bad request (http code 400) and performs a callback.
330
- */
331
- badRequest: function (cb) { return responseChain.error(400, cb); },
332
- /**
333
- * Catches an unauthorized request (http code 401) and performs a callback.
334
- */
335
- unauthorized: function (cb) { return responseChain.error(401, cb); },
336
- /**
337
- * Catches a forbidden request (http code 403) and performs a callback.
338
- */
339
- forbidden: function (cb) { return responseChain.error(403, cb); },
340
- /**
341
- * Catches a "not found" request (http code 404) and performs a callback.
342
- */
343
- notFound: function (cb) { return responseChain.error(404, cb); },
344
- /**
345
- * Catches a timeout (http code 408) and performs a callback.
346
- */
347
- timeout: function (cb) { return responseChain.error(408, cb); },
348
- /**
349
- * Catches an internal server error (http code 500) and performs a callback.
350
- */
351
- internalError: function (cb) { return responseChain.error(500, cb); },
352
- /**
353
- * Catches errors thrown when calling the fetch function and performs a callback.
354
- */
355
- fetchError: function (cb) { return responseChain.error("__fromFetch", cb); },
356
- /**
357
- * Catches an AbortError and performs a callback.
358
- */
359
- onAbort: function (cb) { return responseChain.error("AbortError", cb); }
360
- };
361
- return resolvers.reduce(function (chain, r) { return r(chain, wretcher); }, responseChain);
362
- };
363
-
364
- var __assign$1 = (undefined && undefined.__assign) || function () {
365
- __assign$1 = Object.assign || function(t) {
366
- for (var s, i = 1, n = arguments.length; i < n; i++) {
367
- s = arguments[i];
368
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
369
- t[p] = s[p];
370
- }
371
- return t;
372
- };
373
- return __assign$1.apply(this, arguments);
374
- };
375
- var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () {
376
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
377
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
378
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
379
- r[k] = a[j];
380
- return r;
381
- };
382
- var JSON_MIME = "application/json";
383
- var CONTENT_TYPE_HEADER = "Content-Type";
384
- /**
385
- * The Wretcher class used to perform easy fetch requests.
386
- *
387
- * Immutability : almost every method of this class return a fresh Wretcher object.
388
- */
389
- var Wretcher = /** @class */ (function () {
390
- function Wretcher(_url, _options, _catchers, _resolvers, _middlewares, _deferredChain) {
391
- if (_catchers === void 0) { _catchers = new Map(); }
392
- if (_resolvers === void 0) { _resolvers = []; }
393
- if (_middlewares === void 0) { _middlewares = []; }
394
- if (_deferredChain === void 0) { _deferredChain = []; }
395
- this._url = _url;
396
- this._options = _options;
397
- this._catchers = _catchers;
398
- this._resolvers = _resolvers;
399
- this._middlewares = _middlewares;
400
- this._deferredChain = _deferredChain;
401
- }
402
- Wretcher.factory = function (url, options) {
403
- if (url === void 0) { url = ""; }
404
- if (options === void 0) { options = {}; }
405
- return new Wretcher(url, options);
406
- };
407
- Wretcher.prototype.selfFactory = function (_a) {
408
- var _b = _a === void 0 ? {} : _a, _c = _b.url, url = _c === void 0 ? this._url : _c, _d = _b.options, options = _d === void 0 ? this._options : _d, _e = _b.catchers, catchers = _e === void 0 ? this._catchers : _e, _f = _b.resolvers, resolvers = _f === void 0 ? this._resolvers : _f, _g = _b.middlewares, middlewares = _g === void 0 ? this._middlewares : _g, _h = _b.deferredChain, deferredChain = _h === void 0 ? this._deferredChain : _h;
409
- return new Wretcher(url, __assign$1({}, options), new Map(catchers), __spreadArrays$2(resolvers), __spreadArrays$2(middlewares), __spreadArrays$2(deferredChain));
410
- };
411
- /**
412
- * Sets the default fetch options used for every subsequent fetch call.
413
- * @param options New default options
414
- * @param mixin If true, mixes in instead of replacing the existing options
415
- */
416
- Wretcher.prototype.defaults = function (options, mixin) {
417
- if (mixin === void 0) { mixin = false; }
418
- config.defaults = mixin ? mix(config.defaults, options) : options;
419
- return this;
420
- };
421
- /**
422
- * Sets the method (text, json ...) used to parse the data contained in the response body in case of an HTTP error.
423
- *
424
- * Persists for every subsequent requests.
425
- *
426
- * Default is "text".
427
- */
428
- Wretcher.prototype.errorType = function (method) {
429
- config.errorType = method;
430
- return this;
431
- };
432
- /**
433
- * Sets the non-global polyfills which will be used for every subsequent calls.
434
- *
435
- * Needed for libraries like [fetch-ponyfill](https://github.com/qubyte/fetch-ponyfill).
436
- *
437
- * @param polyfills An object containing the polyfills.
438
- */
439
- Wretcher.prototype.polyfills = function (polyfills) {
440
- config.polyfills = __assign$1(__assign$1({}, config.polyfills), polyfills);
441
- return this;
442
- };
443
- /**
444
- * Returns a new Wretcher object with the argument url appended and the same options.
445
- * @param url String url
446
- * @param replace Boolean If true, replaces the current url instead of appending
447
- */
448
- Wretcher.prototype.url = function (url, replace) {
449
- if (replace === void 0) { replace = false; }
450
- if (replace)
451
- return this.selfFactory({ url: url });
452
- var split = this._url.split("?");
453
- return this.selfFactory({
454
- url: split.length > 1 ?
455
- split[0] + url + "?" + split[1] :
456
- this._url + url
457
- });
458
- };
459
- /**
460
- * Returns a new Wretcher object with the same url and new options.
461
- * @param options New options
462
- * @param mixin If true, mixes in instead of replacing the existing options
463
- */
464
- Wretcher.prototype.options = function (options, mixin) {
465
- if (mixin === void 0) { mixin = true; }
466
- return this.selfFactory({ options: mixin ? mix(this._options, options) : options });
467
- };
468
- /**
469
- * Converts a javascript object to query parameters,
470
- * then appends this query string to the current url.
471
- *
472
- * If given a string, use the string as the query verbatim.
473
- *
474
- * ```
475
- * let w = wretch("http://example.com") // url is http://example.com
476
- *
477
- * // Chain query calls
478
- * w = w.query({ a: 1, b : 2 }) // url is now http://example.com?a=1&b=2
479
- * w = w.query("foo-bar-baz-woz") // url is now http://example.com?a=1&b=2&foo-bar-baz-woz
480
- *
481
- * // Pass true as the second argument to replace existing query parameters
482
- * w = w.query("c=3&d=4", true) // url is now http://example.com?c=3&d=4
483
- * ```
484
- *
485
- * @param qp An object which will be converted, or a string which will be used verbatim.
486
- */
487
- Wretcher.prototype.query = function (qp, replace) {
488
- if (replace === void 0) { replace = false; }
489
- return this.selfFactory({ url: appendQueryParams(this._url, qp, replace) });
490
- };
491
- /**
492
- * Set request headers.
493
- * @param headerValues An object containing header keys and values
494
- */
495
- Wretcher.prototype.headers = function (headerValues) {
496
- return this.selfFactory({ options: mix(this._options, { headers: headerValues || {} }) });
497
- };
498
- /**
499
- * Shortcut to set the "Accept" header.
500
- * @param headerValue Header value
501
- */
502
- Wretcher.prototype.accept = function (headerValue) {
503
- return this.headers({ Accept: headerValue });
504
- };
505
- /**
506
- * Shortcut to set the "Content-Type" header.
507
- * @param headerValue Header value
508
- */
509
- Wretcher.prototype.content = function (headerValue) {
510
- var _a;
511
- return this.headers((_a = {}, _a[CONTENT_TYPE_HEADER] = headerValue, _a));
512
- };
513
- /**
514
- * Shortcut to set the "Authorization" header.
515
- * @param headerValue Header value
516
- */
517
- Wretcher.prototype.auth = function (headerValue) {
518
- return this.headers({ Authorization: headerValue });
519
- };
520
- /**
521
- * Adds a default catcher which will be called on every subsequent request error when the error code matches.
522
- * @param errorId Error code or name
523
- * @param catcher: The catcher method
524
- */
525
- Wretcher.prototype.catcher = function (errorId, catcher) {
526
- var newMap = new Map(this._catchers);
527
- newMap.set(errorId, catcher);
528
- return this.selfFactory({ catchers: newMap });
529
- };
530
- /**
531
- * Associates a custom signal with the request.
532
- * @param controller : An AbortController
533
- */
534
- Wretcher.prototype.signal = function (controller) {
535
- return this.selfFactory({ options: __assign$1(__assign$1({}, this._options), { signal: controller.signal }) });
536
- };
537
- /**
538
- * Program a resolver to perform response chain tasks automatically.
539
- * @param doResolve : Resolver callback
540
- */
541
- Wretcher.prototype.resolve = function (doResolve, clear) {
542
- if (clear === void 0) { clear = false; }
543
- return this.selfFactory({ resolvers: clear ? [doResolve] : __spreadArrays$2(this._resolvers, [doResolve]) });
544
- };
545
- /**
546
- * Defer wretcher methods that will be chained and called just before the request is performed.
547
- */
548
- Wretcher.prototype.defer = function (callback, clear) {
549
- if (clear === void 0) { clear = false; }
550
- return this.selfFactory({
551
- deferredChain: clear ? [callback] : __spreadArrays$2(this._deferredChain, [callback])
552
- });
553
- };
554
- /**
555
- * Add middlewares to intercept a request before being sent.
556
- */
557
- Wretcher.prototype.middlewares = function (middlewares, clear) {
558
- if (clear === void 0) { clear = false; }
559
- return this.selfFactory({
560
- middlewares: clear ? middlewares : __spreadArrays$2(this._middlewares, middlewares)
561
- });
562
- };
563
- Wretcher.prototype.method = function (method, options, body) {
564
- if (options === void 0) { options = {}; }
565
- if (body === void 0) { body = null; }
566
- var headers = this._options.headers;
567
- var baseWretcher = !body ? this :
568
- typeof body === "object" && (!headers ||
569
- Object.entries(headers).every(function (_a) {
570
- var k = _a[0], v = _a[1];
571
- return k.toLowerCase() !== CONTENT_TYPE_HEADER.toLowerCase() ||
572
- v.startsWith(JSON_MIME);
573
- })) ? this.json(body) :
574
- this.body(body);
575
- baseWretcher = baseWretcher.options(__assign$1(__assign$1({}, options), { method: method }));
576
- var deferredWretcher = baseWretcher._deferredChain.reduce(function (acc, curr) { return curr(acc, acc._url, acc._options); }, baseWretcher);
577
- return resolver(deferredWretcher);
578
- };
579
- /**
580
- * Performs a get request.
581
- */
582
- Wretcher.prototype.get = function (options) {
583
- return this.method("GET", options);
584
- };
585
- /**
586
- * Performs a delete request.
587
- */
588
- Wretcher.prototype.delete = function (options) {
589
- return this.method("DELETE", options);
590
- };
591
- /**
592
- * Performs a put request.
593
- */
594
- Wretcher.prototype.put = function (body, options) {
595
- return this.method("PUT", options, body);
596
- };
597
- /**
598
- * Performs a post request.
599
- */
600
- Wretcher.prototype.post = function (body, options) {
601
- return this.method("POST", options, body);
602
- };
603
- /**
604
- * Performs a patch request.
605
- */
606
- Wretcher.prototype.patch = function (body, options) {
607
- return this.method("PATCH", options, body);
608
- };
609
- /**
610
- * Performs a head request.
611
- */
612
- Wretcher.prototype.head = function (options) {
613
- return this.method("HEAD", options);
614
- };
615
- /**
616
- * Performs an options request
617
- */
618
- Wretcher.prototype.opts = function (options) {
619
- return this.method("OPTIONS", options);
620
- };
621
- /**
622
- * Replay a request.
623
- */
624
- Wretcher.prototype.replay = function (options) {
625
- return this.method(this._options.method, options);
626
- };
627
- /**
628
- * Sets the request body with any content.
629
- * @param contents The body contents
630
- */
631
- Wretcher.prototype.body = function (contents) {
632
- return this.selfFactory({ options: __assign$1(__assign$1({}, this._options), { body: contents }) });
633
- };
634
- /**
635
- * Sets the content type header, stringifies an object and sets the request body.
636
- * @param jsObject An object which will be serialized into a JSON
637
- */
638
- Wretcher.prototype.json = function (jsObject) {
639
- var _a;
640
- var preservedContentType = (_a = Object.entries(this._options.headers || {}).find(function (_a) {
641
- var k = _a[0], v = _a[1];
642
- return k.toLowerCase() === CONTENT_TYPE_HEADER.toLowerCase() && v.startsWith(JSON_MIME);
643
- })) === null || _a === void 0 ? void 0 : _a[1];
644
- return this.content(preservedContentType || JSON_MIME).body(JSON.stringify(jsObject));
645
- };
646
- /**
647
- * Converts the javascript object to a FormData and sets the request body.
648
- * @param formObject An object which will be converted to a FormData
649
- * @param recursive If `true`, will recurse through all nested objects
650
- * Can be set as an array of string to exclude specific keys.
651
- * See https://github.com/elbywan/wretch/issues/68 for more details.
652
- */
653
- Wretcher.prototype.formData = function (formObject, recursive) {
654
- if (recursive === void 0) { recursive = false; }
655
- return this.body(convertFormData(formObject, recursive));
656
- };
657
- /**
658
- * Converts the input to an url encoded string and sets the content-type header and body.
659
- * If the input argument is already a string, skips the conversion part.
660
- *
661
- * @param input An object to convert into an url encoded string or an already encoded string
662
- */
663
- Wretcher.prototype.formUrl = function (input) {
664
- return this
665
- .body(typeof input === "string" ? input : convertFormUrl(input))
666
- .content("application/x-www-form-urlencoded");
667
- };
668
- return Wretcher;
669
- }());
670
- // Internal helpers
671
- var appendQueryParams = function (url, qp, replace) {
672
- var queryString;
673
- if (typeof qp === "string") {
674
- queryString = qp;
675
- }
676
- else {
677
- var usp = config.polyfill("URLSearchParams", { instance: true });
678
- for (var key in qp) {
679
- if (qp[key] instanceof Array) {
680
- for (var _i = 0, _a = qp[key]; _i < _a.length; _i++) {
681
- var val = _a[_i];
682
- usp.append(key, val);
683
- }
684
- }
685
- else {
686
- usp.append(key, qp[key]);
687
- }
688
- }
689
- queryString = usp.toString();
690
- }
691
- var split = url.split("?");
692
- if (replace || split.length < 2)
693
- return split[0] + "?" + queryString;
694
- return url + "&" + queryString;
695
- };
696
- function convertFormData(formObject, recursive, formData, ancestors) {
697
- if (recursive === void 0) { recursive = false; }
698
- if (formData === void 0) { formData = config.polyfill("FormData", { instance: true }); }
699
- if (ancestors === void 0) { ancestors = []; }
700
- Object.entries(formObject).forEach(function (_a) {
701
- var key = _a[0], value = _a[1];
702
- var formKey = ancestors.reduce(function (acc, ancestor) { return (acc ? acc + "[" + ancestor + "]" : ancestor); }, null);
703
- formKey = formKey ? formKey + "[" + key + "]" : key;
704
- if (value instanceof Array) {
705
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
706
- var item = value_1[_i];
707
- formData.append(formKey + "[]", item);
708
- }
709
- }
710
- else if (recursive &&
711
- typeof value === "object" &&
712
- (!(recursive instanceof Array) ||
713
- !recursive.includes(key))) {
714
- if (value !== null) {
715
- convertFormData(value, recursive, formData, __spreadArrays$2(ancestors, [key]));
716
- }
717
- }
718
- else {
719
- formData.append(formKey, value);
720
- }
721
- });
722
- return formData;
723
- }
724
- function encodeQueryValue(key, value) {
725
- return encodeURIComponent(key) +
726
- "=" +
727
- encodeURIComponent(typeof value === "object" ?
728
- JSON.stringify(value) :
729
- "" + value);
730
- }
731
- function convertFormUrl(formObject) {
732
- return Object.keys(formObject)
733
- .map(function (key) {
734
- var value = formObject[key];
735
- if (value instanceof Array) {
736
- return value.map(function (v) { return encodeQueryValue(key, v); }).join("&");
737
- }
738
- return encodeQueryValue(key, value);
739
- })
740
- .join("&");
741
- }
742
-
743
- var factory = Wretcher.factory;
744
- factory["default"] = Wretcher.factory;
745
-
746
- function backendApiClient() {
747
- return factory(appConfigurationService.apiBaseUrl);
748
- }
749
-
750
- class CarsCalculatorApi {
751
- async getCarsMakes() {
752
- const res = (await backendApiClient().url('/makes').get().json());
753
- return res.qt_makes;
754
- }
755
- async getCarsModels(makeId) {
756
- const res = (await backendApiClient()
757
- .url(`/makes/${makeId}/models`)
758
- .get()
759
- .json());
760
- return res.qt_models;
761
- }
762
- async getCarsModelYears(modelId) {
763
- return backendApiClient().url(`/models/${modelId}/years`).get().json();
764
- }
765
- async getCarsModelBodyTypes(modelId, year) {
766
- const res = (await backendApiClient()
767
- .url(`/models/${modelId}/years/${year}/body-types`)
768
- .get()
769
- .json());
770
- return res.qt_body_types;
771
- }
772
- async getCarsModelVariant(modelId, year, bodyTypeId) {
773
- const res = (await backendApiClient()
774
- .url(`/models/${modelId}/years/${year}/body-types/${bodyTypeId}/variants`)
775
- .get()
776
- .json());
777
- return res.qt_variants;
778
- }
779
- async getCarsVariantPhotos(variantId) {
780
- const res = (await backendApiClient()
781
- .url(`/variants/${variantId}/photos`)
782
- .get()
783
- .json());
784
- return res.qt_variant_photos;
785
- }
786
- async postCarsQuoteResult(req) {
787
- return (await backendApiClient().url(`/quote`).post(req).json());
788
- }
789
- async postQuoteInfoAsync(req) {
790
- return backendApiClient().url(`/enquiry`).post(req).text();
791
- }
792
- }
793
- const backendApi = new CarsCalculatorApi();
794
-
795
- class CarsCalculatorService {
796
- constructor() {
797
- sessionQuery
798
- .select(['user', 'vehicle'])
799
- .subscribe((state) => this.attemptQuoteCalculationAsync(state.user, state.vehicle));
800
- }
801
- selectVariant(variant) {
802
- sessionStore.update((state) => ({
803
- vehicle: Object.assign(Object.assign({}, state.vehicle), { selectedVariant: variant })
804
- }));
805
- }
806
- generateCarsEnquiryRequest() {
807
- const vehicle = sessionQuery.vehicle;
808
- const variant = getOrError(vehicle.selectedVariant);
809
- const result = sessionQuery.result;
810
- const details = sessionQuery.userDetails;
811
- return {
812
- chosenVariant: {
813
- variant_id: variant.variantId,
814
- short_description: variant.description,
815
- build_year: variant.buildYear,
816
- model_month: variant.modelMonth,
817
- list_price_gross: variant.listPriceGross,
818
- engine_litres: variant.engineLitres,
819
- fuel_type_translation_id: variant.fuelTypeId,
820
- transmission: variant.transmission
821
- },
822
- websiteQuote: {
823
- afterTaxEffectPerPayCycle: getOrError(result.afterTaxEffectPerPayCycle),
824
- totalTaxSavings: getOrError(result.taxSaving),
825
- residualValueGross: getOrError(result.residualValue),
826
- financedAmount: getOrError(result.financedAmount),
827
- fuel: getOrError(result.fuel),
828
- serviceAndMaintenance: getOrError(result.serviceAndMaintenance),
829
- registrationAndCtp: getOrError(result.registrationAndCtp),
830
- comprehensiveInsurance: getOrError(result.comprehensiveInsurance),
831
- managementFee: getOrError(result.managementFee)
832
- },
833
- contactDetails: {
834
- firstName: getOrError(details.userFirstName),
835
- lastName: getOrError(details.userLastName),
836
- email: getOrError(details.emailAddress),
837
- mobileNumber: getOrError(details.contactNumber),
838
- employerName: getOrError(details.employerName)
839
- }
840
- };
841
- }
842
- async attemptQuoteCalculationAsync(user, vehicle) {
843
- const isAllInformationAvailable = isSome(user.annualKms) &&
844
- isSome(user.annualSalary) &&
845
- isSome(user.paymentPeriod) &&
846
- isSome(user.state) &&
847
- isSome(user.term) &&
848
- isSome(vehicle.selectedVariant);
849
- if (!isAllInformationAvailable) {
850
- return;
851
- }
852
- sessionStore.updateQuote({
853
- afterTaxEffectPerPayCycle: none,
854
- taxSaving: none,
855
- residualValue: none,
856
- financedAmount: none,
857
- fuel: none,
858
- serviceAndMaintenance: none,
859
- registrationAndCtp: none,
860
- comprehensiveInsurance: none,
861
- managementFee: none,
862
- quoteState: 'Calculation pending'
863
- });
864
- const variant = getOrError(vehicle.selectedVariant);
865
- const isUsedCarRequested = getOrError(vehicle.isUsedCarRequested);
866
- const price = isUsedCarRequested
867
- ? getOrError(vehicle.approximatePrice)
868
- : variant.listPriceGross;
869
- const req = {
870
- variantId: variant.variantId,
871
- isUsedCarRequested: getOrError(vehicle.isUsedCarRequested),
872
- approximatePrice: price,
873
- annualSalaryGross: getOrError(user.annualSalary),
874
- payPeriod: getOrError(user.paymentPeriod),
875
- annualKm: getOrError(user.annualKms),
876
- state: getOrError(user.state),
877
- leaseTermInYears: getOrError(user.term)
878
- };
879
- const response = await backendApi.postCarsQuoteResult(req);
880
- const quoteResult = {
881
- afterTaxEffectPerPayCycle: some(response.afterTaxEffectPerPayCycle),
882
- taxSaving: some(response.totalTaxSavings),
883
- residualValue: some(response.residualValueGross),
884
- financedAmount: some(response.financedAmount),
885
- fuel: some(response.fuel),
886
- serviceAndMaintenance: some(response.serviceAndMaintenance),
887
- registrationAndCtp: some(response.registrationAndCtp),
888
- comprehensiveInsurance: some(response.comprehensiveInsurance),
889
- managementFee: some(response.managementFee),
890
- quoteState: 'Calculated'
891
- };
892
- sessionStore.updateQuote(quoteResult);
893
- }
894
- }
895
- const carsCalculatorService = new CarsCalculatorService();
896
-
897
- export { getOrError as a, backendApi as b, carsCalculatorService as c, getOrDefault as g, pipe as p, toSelectInputOptionsArray as t };