@flarehr/apollo-super-selection 1.3.65232 → 1.4.32906

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 (103) hide show
  1. package/dist/lib/apollo-super-selection/apollo-super-selection.css +1 -1
  2. package/dist/lib/apollo-super-selection/apollo-super-selection.esm.js +1 -1
  3. package/dist/lib/apollo-super-selection/apollo-super-selection.js +1 -1
  4. package/dist/lib/apollo-super-selection/p-2054e932.system.entry.js +69 -0
  5. package/dist/lib/apollo-super-selection/{p-ef3afa00.system.entry.js → p-22939048.system.entry.js} +1 -1
  6. package/dist/lib/apollo-super-selection/p-24d6e2b8.js +1 -0
  7. package/dist/lib/apollo-super-selection/{p-02f24922.system.entry.js → p-2b42304a.system.entry.js} +1 -1
  8. package/dist/lib/apollo-super-selection/{p-9c855634.entry.js → p-33eca162.entry.js} +1 -1
  9. package/dist/lib/apollo-super-selection/p-4e871154.entry.js +1 -0
  10. package/dist/lib/apollo-super-selection/{p-6ac8791e.system.entry.js → p-53b231f0.system.entry.js} +1 -1
  11. package/dist/lib/apollo-super-selection/{p-b89b68db.entry.js → p-5c73c587.entry.js} +1 -1
  12. package/dist/lib/apollo-super-selection/{p-fcb4050d.entry.js → p-69bbf1dd.entry.js} +1 -1
  13. package/dist/lib/apollo-super-selection/{p-44bec843.system.js → p-71ca4cf8.system.js} +1 -1
  14. package/dist/lib/apollo-super-selection/p-9101bd39.entry.js +14 -0
  15. package/dist/lib/apollo-super-selection/p-97188c78.system.js +1 -0
  16. package/dist/lib/apollo-super-selection/{p-23cfdd82.entry.js → p-9d2a7c0e.entry.js} +1 -1
  17. package/dist/lib/apollo-super-selection/p-a0063575.system.entry.js +1 -0
  18. package/dist/lib/apollo-super-selection/p-b00f648b.entry.js +1 -0
  19. package/dist/lib/apollo-super-selection/p-bd6e6a8f.system.js +1 -0
  20. package/dist/lib/apollo-super-selection/p-c775c0e4.system.entry.js +1 -0
  21. package/dist/lib/apollo-super-selection/p-cd3ed541.system.js +1 -0
  22. package/dist/lib/apollo-super-selection/{p-51c6dd08.js → p-db0bded8.js} +1 -1
  23. package/dist/lib/apollo-super-selection/{p-f29066b9.system.entry.js → p-e957b393.system.entry.js} +1 -1
  24. package/dist/lib/apollo-super-selection/{p-7a89efaf.js → p-fdadb647.js} +1 -1
  25. package/dist/lib/cjs/apollo-super-selection.cjs.js +1 -1
  26. package/dist/lib/cjs/custom-fund-choice.api-293c1ace.js +3209 -0
  27. package/dist/lib/cjs/loader.cjs.js +1 -1
  28. package/dist/lib/cjs/{sss-button_34.cjs.entry.js → sss-button_32.cjs.entry.js} +577 -3838
  29. package/dist/lib/cjs/sss-super-byof-host.cjs.entry.js +111 -0
  30. package/dist/lib/collection/apollo-super-selection.css +1 -1
  31. package/dist/lib/collection/collection-manifest.json +6 -9
  32. package/dist/lib/collection/components/super-byof/super-byof-types.js +1 -0
  33. package/dist/lib/collection/components/super-byof/super-byof.js +139 -0
  34. package/dist/lib/collection/components/super-campaign/super-campaign.js +15 -18
  35. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/custom-fund.js +5 -5
  36. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/self-managed-fund/smsf-engagement-step-host.js +161 -0
  37. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/self-managed-fund/smsf-engagement-step-types.js +1 -0
  38. package/dist/lib/collection/components/super-selection-app/header-section/header-section.js +24 -5
  39. package/dist/lib/collection/components/super-selection-app/services/event-tracking.service.js +10 -0
  40. package/dist/lib/collection/components/super-selection-app/services/super-selection-app.routes.js +4 -2
  41. package/dist/lib/collection/components/super-selection-app/services/super-selection-app.service.js +4 -0
  42. package/dist/lib/collection/components/super-selection-app/services/super-selection.store.js +1 -0
  43. package/dist/lib/collection/components/super-smsf/super-smsf-types.js +1 -0
  44. package/dist/lib/collection/components/super-smsf/super-smsf.form.js +1 -0
  45. package/dist/lib/collection/components/super-smsf/super-smsf.js +166 -0
  46. package/dist/lib/esm/{active-router-5e40c0f8.js → active-router-d18b36fb.js} +1 -1
  47. package/dist/lib/esm/apollo-super-selection.js +2 -2
  48. package/dist/lib/esm/context-consumer.entry.js +1 -1
  49. package/dist/lib/esm/custom-fund-choice.api-42801d64.js +3188 -0
  50. package/dist/lib/esm/{index-189b2180.js → index-107d7c24.js} +1 -1
  51. package/dist/lib/esm/loader.js +2 -2
  52. package/dist/lib/esm/{sss-button_34.entry.js → sss-button_32.entry.js} +374 -3633
  53. package/dist/lib/esm/sss-super-byof-host.entry.js +107 -0
  54. package/dist/lib/esm/stencil-async-content.entry.js +1 -1
  55. package/dist/lib/esm/stencil-route-title.entry.js +2 -2
  56. package/dist/lib/esm/stencil-router-prompt.entry.js +2 -2
  57. package/dist/lib/esm/stencil-router-redirect.entry.js +2 -2
  58. package/dist/lib/esm-es5/{active-router-5e40c0f8.js → active-router-d18b36fb.js} +1 -1
  59. package/dist/lib/esm-es5/apollo-super-selection.js +1 -1
  60. package/dist/lib/esm-es5/context-consumer.entry.js +1 -1
  61. package/dist/lib/esm-es5/custom-fund-choice.api-42801d64.js +1 -0
  62. package/dist/lib/esm-es5/{index-189b2180.js → index-107d7c24.js} +1 -1
  63. package/dist/lib/esm-es5/loader.js +1 -1
  64. package/dist/lib/esm-es5/sss-button_32.entry.js +69 -0
  65. package/dist/lib/esm-es5/sss-super-byof-host.entry.js +1 -0
  66. package/dist/lib/esm-es5/stencil-async-content.entry.js +1 -1
  67. package/dist/lib/esm-es5/stencil-route-title.entry.js +1 -1
  68. package/dist/lib/esm-es5/stencil-router-prompt.entry.js +1 -1
  69. package/dist/lib/esm-es5/stencil-router-redirect.entry.js +1 -1
  70. package/dist/lib/types/components/super-byof/super-byof-types.d.ts +26 -0
  71. package/dist/lib/types/components/super-byof/super-byof.d.ts +19 -0
  72. package/dist/lib/types/components/super-byof/super-byof.form.d.ts +6 -0
  73. package/dist/lib/types/components/super-campaign/super-campaign.d.ts +0 -1
  74. package/dist/lib/types/components/super-selection-app/api/super-selection-events.model.d.ts +8 -0
  75. package/dist/lib/types/components/super-selection-app/api/super-selection.api.dto.d.ts +1 -0
  76. package/dist/lib/types/components/super-selection-app/funds/custom-fund/custom-fund.store.d.ts +1 -1
  77. package/dist/lib/types/components/super-selection-app/funds/custom-fund/self-managed-fund/smsf-engagement-step-host.d.ts +28 -0
  78. package/dist/lib/types/components/super-selection-app/funds/custom-fund/self-managed-fund/smsf-engagement-step-types.d.ts +15 -0
  79. package/dist/lib/types/components/super-selection-app/services/event-tracking.service.d.ts +2 -0
  80. package/dist/lib/types/components/super-selection-app/services/super-selection-app.routes.d.ts +1 -0
  81. package/dist/lib/types/components/super-selection-app/services/super-selection-app.service.d.ts +1 -0
  82. package/dist/lib/types/components/super-selection-app/services/super-selection.store.d.ts +1 -0
  83. package/dist/lib/types/components/super-smsf/super-smsf-types.d.ts +34 -0
  84. package/dist/lib/types/components/super-smsf/super-smsf.d.ts +20 -0
  85. package/dist/lib/types/components.d.ts +39 -63
  86. package/package.json +2 -1
  87. package/dist/lib/apollo-super-selection/p-071b8545.entry.js +0 -1
  88. package/dist/lib/apollo-super-selection/p-51aefdb1.system.entry.js +0 -1
  89. package/dist/lib/apollo-super-selection/p-6cfd85e3.system.entry.js +0 -69
  90. package/dist/lib/apollo-super-selection/p-80178f87.system.js +0 -1
  91. package/dist/lib/apollo-super-selection/p-bdcfc026.system.js +0 -1
  92. package/dist/lib/apollo-super-selection/p-d9f1e505.entry.js +0 -14
  93. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund-inputs.js +0 -143
  94. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund.js +0 -123
  95. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/self-managed-fund/self-managed-fund-inputs.js +0 -253
  96. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/self-managed-fund/self-managed-fund.js +0 -121
  97. package/dist/lib/esm-es5/sss-button_34.entry.js +0 -69
  98. package/dist/lib/types/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund-inputs.d.ts +0 -16
  99. package/dist/lib/types/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund.d.ts +0 -13
  100. package/dist/lib/types/components/super-selection-app/funds/custom-fund/self-managed-fund/self-managed-fund-inputs.d.ts +0 -29
  101. package/dist/lib/types/components/super-selection-app/funds/custom-fund/self-managed-fund/self-managed-fund.d.ts +0 -14
  102. /package/dist/lib/collection/components/{super-selection-app/funds/custom-fund/self-managed-fund/self-managed-fund.form.js → super-byof/super-byof.form.js} +0 -0
  103. /package/dist/lib/types/components/{super-selection-app/funds/custom-fund/self-managed-fund/self-managed-fund.form.d.ts → super-smsf/super-smsf.form.d.ts} +0 -0
@@ -0,0 +1,3209 @@
1
+ 'use strict';
2
+
3
+ const index = require('./index-eb4f212f.js');
4
+ const activeRouter = require('./active-router-1f555f75.js');
5
+
6
+ // -------------------------------------------------------------------------------------
7
+ // guards
8
+ // -------------------------------------------------------------------------------------
9
+ /**
10
+ * Returns `true` if the option is an instance of `Some`, `false` otherwise.
11
+ *
12
+ * @example
13
+ * import { some, none, isSome } from 'fp-ts/Option'
14
+ *
15
+ * assert.strictEqual(isSome(some(1)), true)
16
+ * assert.strictEqual(isSome(none), false)
17
+ *
18
+ * @category guards
19
+ * @since 2.0.0
20
+ */
21
+ var isSome = function (fa) { return fa._tag === 'Some'; };
22
+ /**
23
+ * Returns `true` if the option is `None`, `false` otherwise.
24
+ *
25
+ * @example
26
+ * import { some, none, isNone } from 'fp-ts/Option'
27
+ *
28
+ * assert.strictEqual(isNone(some(1)), false)
29
+ * assert.strictEqual(isNone(none), true)
30
+ *
31
+ * @category guards
32
+ * @since 2.0.0
33
+ */
34
+ var isNone = function (fa) { return fa._tag === 'None'; };
35
+ // -------------------------------------------------------------------------------------
36
+ // constructors
37
+ // -------------------------------------------------------------------------------------
38
+ /**
39
+ * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
40
+ *
41
+ * @category constructors
42
+ * @since 2.0.0
43
+ */
44
+ var none = { _tag: 'None' };
45
+ /**
46
+ * Constructs a `Some`. Represents an optional value that exists.
47
+ *
48
+ * @category constructors
49
+ * @since 2.0.0
50
+ */
51
+ var some = function (a) { return ({ _tag: 'Some', value: a }); };
52
+ /**
53
+ * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
54
+ * returns the value wrapped in a `Some`.
55
+ *
56
+ * @example
57
+ * import { none, some, fromNullable } from 'fp-ts/Option'
58
+ *
59
+ * assert.deepStrictEqual(fromNullable(undefined), none)
60
+ * assert.deepStrictEqual(fromNullable(null), none)
61
+ * assert.deepStrictEqual(fromNullable(1), some(1))
62
+ *
63
+ * @category constructors
64
+ * @since 2.0.0
65
+ */
66
+ function fromNullable(a) {
67
+ return a == null ? none : some(a);
68
+ }
69
+ /**
70
+ * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.
71
+ *
72
+ * @example
73
+ * import { some, none, toUndefined } from 'fp-ts/Option'
74
+ * import { pipe } from 'fp-ts/function'
75
+ *
76
+ * assert.strictEqual(
77
+ * pipe(
78
+ * some(1),
79
+ * toUndefined
80
+ * ),
81
+ * 1
82
+ * )
83
+ * assert.strictEqual(
84
+ * pipe(
85
+ * none,
86
+ * toUndefined
87
+ * ),
88
+ * undefined
89
+ * )
90
+ *
91
+ * @category destructors
92
+ * @since 2.0.0
93
+ */
94
+ function toUndefined(ma) {
95
+ return isNone(ma) ? undefined : ma.value;
96
+ }
97
+
98
+ function injectHistory(Component) {
99
+ activeRouter.ActiveRouter.injectProps(Component, ['history', 'location']);
100
+ }
101
+
102
+ function appReady() {
103
+ postMessage({
104
+ type: 'appReady'
105
+ });
106
+ }
107
+ function postMessage(message, origin) {
108
+ if (origin === undefined)
109
+ origin = '*';
110
+ message.sender = 'flare';
111
+ window.parent.postMessage(message, origin);
112
+ }
113
+ function resize(height, width) {
114
+ postMessage({
115
+ type: 'contentResized',
116
+ height,
117
+ width
118
+ });
119
+ }
120
+ function navigation(url) {
121
+ postMessage({
122
+ type: 'pageNavigated',
123
+ url
124
+ });
125
+ }
126
+ function complete() {
127
+ postMessage({ type: 'complete' });
128
+ }
129
+ function submitSuccess() {
130
+ postMessage({
131
+ type: 'submitSuccess'
132
+ });
133
+ }
134
+ const iframe = { appReady, resize, navigation, complete, submitSuccess };
135
+
136
+ const appendToMap = (map, propName, value) => {
137
+ const items = map.get(propName);
138
+ if (!items) {
139
+ map.set(propName, [value]);
140
+ }
141
+ else if (!items.includes(value)) {
142
+ items.push(value);
143
+ }
144
+ };
145
+ const debounce = (fn, ms) => {
146
+ let timeoutId;
147
+ return (...args) => {
148
+ if (timeoutId) {
149
+ clearTimeout(timeoutId);
150
+ }
151
+ timeoutId = setTimeout(() => {
152
+ timeoutId = 0;
153
+ fn(...args);
154
+ }, ms);
155
+ };
156
+ };
157
+
158
+ /**
159
+ * Check if a possible element isConnected.
160
+ * The property might not be there, so we check for it.
161
+ *
162
+ * We want it to return true if isConnected is not a property,
163
+ * otherwise we would remove these elements and would not update.
164
+ *
165
+ * Better leak in Edge than to be useless.
166
+ */
167
+ const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
168
+ const cleanupElements = debounce((map) => {
169
+ for (let key of map.keys()) {
170
+ map.set(key, map.get(key).filter(isConnected));
171
+ }
172
+ }, 2000);
173
+ const stencilSubscription = ({ on }) => {
174
+ const elmsToUpdate = new Map();
175
+ if (typeof index.getRenderingRef === 'function') {
176
+ // If we are not in a stencil project, we do nothing.
177
+ // This function is not really exported by @stencil/core.
178
+ on('dispose', () => {
179
+ elmsToUpdate.clear();
180
+ });
181
+ on('get', (propName) => {
182
+ const elm = index.getRenderingRef();
183
+ if (elm) {
184
+ appendToMap(elmsToUpdate, propName, elm);
185
+ }
186
+ });
187
+ on('set', (propName) => {
188
+ const elements = elmsToUpdate.get(propName);
189
+ if (elements) {
190
+ elmsToUpdate.set(propName, elements.filter(index.forceUpdate));
191
+ }
192
+ cleanupElements(elmsToUpdate);
193
+ });
194
+ on('reset', () => {
195
+ elmsToUpdate.forEach((elms) => elms.forEach(index.forceUpdate));
196
+ cleanupElements(elmsToUpdate);
197
+ });
198
+ }
199
+ };
200
+
201
+ const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
202
+ let states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
203
+ const handlers = {
204
+ dispose: [],
205
+ get: [],
206
+ set: [],
207
+ reset: [],
208
+ };
209
+ const reset = () => {
210
+ states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
211
+ handlers.reset.forEach((cb) => cb());
212
+ };
213
+ const dispose = () => {
214
+ // Call first dispose as resetting the state would
215
+ // cause less updates ;)
216
+ handlers.dispose.forEach((cb) => cb());
217
+ reset();
218
+ };
219
+ const get = (propName) => {
220
+ handlers.get.forEach((cb) => cb(propName));
221
+ return states.get(propName);
222
+ };
223
+ const set = (propName, value) => {
224
+ const oldValue = states.get(propName);
225
+ if (shouldUpdate(value, oldValue, propName)) {
226
+ states.set(propName, value);
227
+ handlers.set.forEach((cb) => cb(propName, value, oldValue));
228
+ }
229
+ };
230
+ const state = (typeof Proxy === 'undefined'
231
+ ? {}
232
+ : new Proxy(defaultState, {
233
+ get(_, propName) {
234
+ return get(propName);
235
+ },
236
+ ownKeys(_) {
237
+ return Array.from(states.keys());
238
+ },
239
+ getOwnPropertyDescriptor() {
240
+ return {
241
+ enumerable: true,
242
+ configurable: true,
243
+ };
244
+ },
245
+ has(_, propName) {
246
+ return states.has(propName);
247
+ },
248
+ set(_, propName, value) {
249
+ set(propName, value);
250
+ return true;
251
+ },
252
+ }));
253
+ const on = (eventName, callback) => {
254
+ handlers[eventName].push(callback);
255
+ return () => {
256
+ removeFromArray(handlers[eventName], callback);
257
+ };
258
+ };
259
+ const onChange = (propName, cb) => {
260
+ const unSet = on('set', (key, newValue) => {
261
+ if (key === propName) {
262
+ cb(newValue);
263
+ }
264
+ });
265
+ const unReset = on('reset', () => cb(defaultState[propName]));
266
+ return () => {
267
+ unSet();
268
+ unReset();
269
+ };
270
+ };
271
+ const use = (...subscriptions) => subscriptions.forEach((subscription) => {
272
+ if (subscription.set) {
273
+ on('set', subscription.set);
274
+ }
275
+ if (subscription.get) {
276
+ on('get', subscription.get);
277
+ }
278
+ if (subscription.reset) {
279
+ on('reset', subscription.reset);
280
+ }
281
+ });
282
+ return {
283
+ state,
284
+ get,
285
+ set,
286
+ on,
287
+ onChange,
288
+ use,
289
+ dispose,
290
+ reset,
291
+ };
292
+ };
293
+ const removeFromArray = (array, item) => {
294
+ const index = array.indexOf(item);
295
+ if (index >= 0) {
296
+ array[index] = array[array.length - 1];
297
+ array.length--;
298
+ }
299
+ };
300
+
301
+ const createStore = (defaultState, shouldUpdate) => {
302
+ const map = createObservableMap(defaultState, shouldUpdate);
303
+ stencilSubscription(map);
304
+ return map;
305
+ };
306
+
307
+ const initial = {
308
+ handleSubmitFn: async function () {
309
+ return;
310
+ },
311
+ fundName: '',
312
+ fundDetails: { type: 'null' },
313
+ promotedFundId: undefined
314
+ };
315
+ const { state } = createStore(initial);
316
+
317
+ (function (SuperSelectionAppRoutes) {
318
+ SuperSelectionAppRoutes["ExistingChoicePage"] = "/existing";
319
+ SuperSelectionAppRoutes["SuperCampaign"] = "/super-campaign";
320
+ SuperSelectionAppRoutes["ChoicePage"] = "/";
321
+ SuperSelectionAppRoutes["MyOwnFund"] = "/super-choice/my-own-fund/";
322
+ SuperSelectionAppRoutes["MyOwnFundEngagementStep"] = "/super-choice/my-own-fund-engagement/";
323
+ SuperSelectionAppRoutes["SmsfEngagementStep"] = "/super-choice/smsf-engagement/";
324
+ SuperSelectionAppRoutes["Prefill"] = "/super-choice/prefill/";
325
+ SuperSelectionAppRoutes["PrefillInvalidMyOwnFundPage"] = "/super-choice/sss-prefill-invalid-my-own-fund/";
326
+ SuperSelectionAppRoutes["PrefillMyOwnFundPage"] = "/super-choice/prefill-my-own-fund/";
327
+ SuperSelectionAppRoutes["PrefillSMSFPage"] = "/super-choice/prefill-smsf/";
328
+ SuperSelectionAppRoutes["PrefillInvalidSMSFPage"] = "/super-choice/prefill-invalid-smsf/";
329
+ SuperSelectionAppRoutes["SelfManagedFund"] = "/super-choice/smsf/";
330
+ SuperSelectionAppRoutes["DefaultFund"] = "/super-choice/default/";
331
+ SuperSelectionAppRoutes["FeaturedFunds"] = "/super-choice/featured-funds/";
332
+ SuperSelectionAppRoutes["StandardChoice"] = "/standard-choice/";
333
+ SuperSelectionAppRoutes["Success"] = "/success/";
334
+ })(exports.SuperSelectionAppRoutes || (exports.SuperSelectionAppRoutes = {}));
335
+ const superSelectionAppStencilRoutes = [
336
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.ExistingChoicePage, component: "sss-existing-choice-page" }),
337
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.SuperCampaign, component: "sss-super-campaign-host" }),
338
+ index.h("stencil-route", { exact: true, url: exports.SuperSelectionAppRoutes.ChoicePage, component: "sss-choice-router" }),
339
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.MyOwnFund, component: "sss-super-byof-host" }),
340
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.MyOwnFundEngagementStep, component: "sss-my-own-fund-engagement-step-host" }),
341
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.SmsfEngagementStep, component: "sss-smsf-engagement-step-host" }),
342
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.PrefillInvalidMyOwnFundPage, component: "sss-prefill-invalid-my-own-fund" }),
343
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.Prefill, component: "sss-prefill" }),
344
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.PrefillMyOwnFundPage, component: "sss-prefill-my-own-fund" }),
345
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.PrefillSMSFPage, component: "sss-prefill-smsf" }),
346
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.PrefillInvalidSMSFPage, component: "sss-prefill-invalid-smsf" }),
347
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.SelfManagedFund, component: "sss-super-smsf-host" }),
348
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.DefaultFund, component: "sss-default-fund" }),
349
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.FeaturedFunds, component: "sss-super-campaign-featured-funds" }),
350
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.StandardChoice, component: "sss-standard-choice-form" }),
351
+ index.h("stencil-route", { url: exports.SuperSelectionAppRoutes.Success, component: "sss-success" })
352
+ ];
353
+
354
+ function createCommonjsModule(fn, basedir, module) {
355
+ return module = {
356
+ path: basedir,
357
+ exports: {},
358
+ require: function (path, base) {
359
+ return commonjsRequire();
360
+ }
361
+ }, fn(module, module.exports), module.exports;
362
+ }
363
+
364
+ function commonjsRequire () {
365
+ throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
366
+ }
367
+
368
+ var _function = createCommonjsModule(function (module, exports) {
369
+ /**
370
+ * @since 2.0.0
371
+ */
372
+ Object.defineProperty(exports, "__esModule", { value: true });
373
+ exports.bindTo_ = exports.bind_ = exports.hole = exports.pipe = exports.untupled = exports.tupled = exports.absurd = exports.decrement = exports.increment = exports.tuple = exports.flow = exports.flip = exports.constVoid = exports.constUndefined = exports.constNull = exports.constFalse = exports.constTrue = exports.constant = exports.not = exports.unsafeCoerce = exports.identity = void 0;
374
+ /**
375
+ * @since 2.0.0
376
+ */
377
+ function identity(a) {
378
+ return a;
379
+ }
380
+ exports.identity = identity;
381
+ /**
382
+ * @since 2.0.0
383
+ */
384
+ exports.unsafeCoerce = identity;
385
+ /**
386
+ * @since 2.0.0
387
+ */
388
+ function not(predicate) {
389
+ return function (a) { return !predicate(a); };
390
+ }
391
+ exports.not = not;
392
+ /**
393
+ * @since 2.0.0
394
+ */
395
+ function constant(a) {
396
+ return function () { return a; };
397
+ }
398
+ exports.constant = constant;
399
+ /**
400
+ * A thunk that returns always `true`.
401
+ *
402
+ * @since 2.0.0
403
+ */
404
+ exports.constTrue =
405
+ /*#__PURE__*/
406
+ constant(true);
407
+ /**
408
+ * A thunk that returns always `false`.
409
+ *
410
+ * @since 2.0.0
411
+ */
412
+ exports.constFalse =
413
+ /*#__PURE__*/
414
+ constant(false);
415
+ /**
416
+ * A thunk that returns always `null`.
417
+ *
418
+ * @since 2.0.0
419
+ */
420
+ exports.constNull =
421
+ /*#__PURE__*/
422
+ constant(null);
423
+ /**
424
+ * A thunk that returns always `undefined`.
425
+ *
426
+ * @since 2.0.0
427
+ */
428
+ exports.constUndefined =
429
+ /*#__PURE__*/
430
+ constant(undefined);
431
+ /**
432
+ * A thunk that returns always `void`.
433
+ *
434
+ * @since 2.0.0
435
+ */
436
+ exports.constVoid = exports.constUndefined;
437
+ // TODO: remove in v3
438
+ /**
439
+ * Flips the order of the arguments of a function of two arguments.
440
+ *
441
+ * @since 2.0.0
442
+ */
443
+ function flip(f) {
444
+ return function (b, a) { return f(a, b); };
445
+ }
446
+ exports.flip = flip;
447
+ function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
448
+ switch (arguments.length) {
449
+ case 1:
450
+ return ab;
451
+ case 2:
452
+ return function () {
453
+ return bc(ab.apply(this, arguments));
454
+ };
455
+ case 3:
456
+ return function () {
457
+ return cd(bc(ab.apply(this, arguments)));
458
+ };
459
+ case 4:
460
+ return function () {
461
+ return de(cd(bc(ab.apply(this, arguments))));
462
+ };
463
+ case 5:
464
+ return function () {
465
+ return ef(de(cd(bc(ab.apply(this, arguments)))));
466
+ };
467
+ case 6:
468
+ return function () {
469
+ return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
470
+ };
471
+ case 7:
472
+ return function () {
473
+ return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
474
+ };
475
+ case 8:
476
+ return function () {
477
+ return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
478
+ };
479
+ case 9:
480
+ return function () {
481
+ return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
482
+ };
483
+ }
484
+ return;
485
+ }
486
+ exports.flow = flow;
487
+ /**
488
+ * @since 2.0.0
489
+ */
490
+ function tuple() {
491
+ var t = [];
492
+ for (var _i = 0; _i < arguments.length; _i++) {
493
+ t[_i] = arguments[_i];
494
+ }
495
+ return t;
496
+ }
497
+ exports.tuple = tuple;
498
+ /**
499
+ * @since 2.0.0
500
+ */
501
+ function increment(n) {
502
+ return n + 1;
503
+ }
504
+ exports.increment = increment;
505
+ /**
506
+ * @since 2.0.0
507
+ */
508
+ function decrement(n) {
509
+ return n - 1;
510
+ }
511
+ exports.decrement = decrement;
512
+ /**
513
+ * @since 2.0.0
514
+ */
515
+ function absurd(_) {
516
+ throw new Error('Called `absurd` function which should be uncallable');
517
+ }
518
+ exports.absurd = absurd;
519
+ /**
520
+ * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.
521
+ *
522
+ * @example
523
+ * import { tupled } from 'fp-ts/function'
524
+ *
525
+ * const add = tupled((x: number, y: number): number => x + y)
526
+ *
527
+ * assert.strictEqual(add([1, 2]), 3)
528
+ *
529
+ * @since 2.4.0
530
+ */
531
+ function tupled(f) {
532
+ return function (a) { return f.apply(void 0, a); };
533
+ }
534
+ exports.tupled = tupled;
535
+ /**
536
+ * Inverse function of `tupled`
537
+ *
538
+ * @since 2.4.0
539
+ */
540
+ function untupled(f) {
541
+ return function () {
542
+ var a = [];
543
+ for (var _i = 0; _i < arguments.length; _i++) {
544
+ a[_i] = arguments[_i];
545
+ }
546
+ return f(a);
547
+ };
548
+ }
549
+ exports.untupled = untupled;
550
+ function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) {
551
+ switch (arguments.length) {
552
+ case 1:
553
+ return a;
554
+ case 2:
555
+ return ab(a);
556
+ case 3:
557
+ return bc(ab(a));
558
+ case 4:
559
+ return cd(bc(ab(a)));
560
+ case 5:
561
+ return de(cd(bc(ab(a))));
562
+ case 6:
563
+ return ef(de(cd(bc(ab(a)))));
564
+ case 7:
565
+ return fg(ef(de(cd(bc(ab(a))))));
566
+ case 8:
567
+ return gh(fg(ef(de(cd(bc(ab(a)))))));
568
+ case 9:
569
+ return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
570
+ case 10:
571
+ return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))));
572
+ case 11:
573
+ return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))));
574
+ case 12:
575
+ return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))));
576
+ case 13:
577
+ return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))));
578
+ case 14:
579
+ return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))));
580
+ case 15:
581
+ return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))));
582
+ case 16:
583
+ return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))));
584
+ case 17:
585
+ return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))));
586
+ case 18:
587
+ return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))));
588
+ case 19:
589
+ return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))));
590
+ case 20:
591
+ return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))));
592
+ }
593
+ return;
594
+ }
595
+ exports.pipe = pipe;
596
+ /**
597
+ * Type hole simulation
598
+ *
599
+ * @since 2.7.0
600
+ */
601
+ exports.hole = absurd;
602
+ /**
603
+ * @internal
604
+ */
605
+ var bind_ = function (a, name, b) {
606
+ var _a;
607
+ return Object.assign({}, a, (_a = {}, _a[name] = b, _a));
608
+ };
609
+ exports.bind_ = bind_;
610
+ /**
611
+ * @internal
612
+ */
613
+ var bindTo_ = function (name) { return function (b) {
614
+ var _a;
615
+ return (_a = {}, _a[name] = b, _a);
616
+ }; };
617
+ exports.bindTo_ = bindTo_;
618
+ });
619
+
620
+ var Option = createCommonjsModule(function (module, exports) {
621
+ Object.defineProperty(exports, "__esModule", { value: true });
622
+ exports.getApplySemigroup = exports.getOrd = exports.getEq = exports.getShow = exports.URI = exports.wilt = exports.wither = exports.sequence = exports.traverse = exports.partitionMap = exports.partition = exports.filterMap = exports.filter = exports.separate = exports.compact = exports.reduceRight = exports.foldMap = exports.reduce = exports.duplicate = exports.extend = exports.throwError = exports.zero = exports.alt = exports.altW = exports.flatten = exports.chainFirst = exports.chain = exports.of = exports.apSecond = exports.apFirst = exports.ap = exports.map = exports.chainNullableK = exports.mapNullable = exports.fromNullableK = exports.getOrElse = exports.getOrElseW = exports.toUndefined = exports.toNullable = exports.fold = exports.fromEither = exports.getRight = exports.getLeft = exports.tryCatch = exports.fromPredicate = exports.fromNullable = exports.some = exports.none = exports.isNone = exports.isSome = void 0;
623
+ exports.sequenceArray = exports.traverseArray = exports.traverseArrayWithIndex = exports.apS = exports.bind = exports.bindTo = exports.Do = exports.getRefinement = exports.exists = exports.elem = exports.option = exports.MonadThrow = exports.Witherable = exports.Traversable = exports.Filterable = exports.Compactable = exports.Extend = exports.Alternative = exports.Alt = exports.Foldable = exports.Monad = exports.Applicative = exports.Functor = exports.getMonoid = exports.getLastMonoid = exports.getFirstMonoid = exports.getApplyMonoid = void 0;
624
+
625
+ // -------------------------------------------------------------------------------------
626
+ // guards
627
+ // -------------------------------------------------------------------------------------
628
+ /**
629
+ * Returns `true` if the option is an instance of `Some`, `false` otherwise.
630
+ *
631
+ * @example
632
+ * import { some, none, isSome } from 'fp-ts/Option'
633
+ *
634
+ * assert.strictEqual(isSome(some(1)), true)
635
+ * assert.strictEqual(isSome(none), false)
636
+ *
637
+ * @category guards
638
+ * @since 2.0.0
639
+ */
640
+ var isSome = function (fa) { return fa._tag === 'Some'; };
641
+ exports.isSome = isSome;
642
+ /**
643
+ * Returns `true` if the option is `None`, `false` otherwise.
644
+ *
645
+ * @example
646
+ * import { some, none, isNone } from 'fp-ts/Option'
647
+ *
648
+ * assert.strictEqual(isNone(some(1)), false)
649
+ * assert.strictEqual(isNone(none), true)
650
+ *
651
+ * @category guards
652
+ * @since 2.0.0
653
+ */
654
+ var isNone = function (fa) { return fa._tag === 'None'; };
655
+ exports.isNone = isNone;
656
+ // -------------------------------------------------------------------------------------
657
+ // constructors
658
+ // -------------------------------------------------------------------------------------
659
+ /**
660
+ * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
661
+ *
662
+ * @category constructors
663
+ * @since 2.0.0
664
+ */
665
+ exports.none = { _tag: 'None' };
666
+ /**
667
+ * Constructs a `Some`. Represents an optional value that exists.
668
+ *
669
+ * @category constructors
670
+ * @since 2.0.0
671
+ */
672
+ var some = function (a) { return ({ _tag: 'Some', value: a }); };
673
+ exports.some = some;
674
+ /**
675
+ * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
676
+ * returns the value wrapped in a `Some`.
677
+ *
678
+ * @example
679
+ * import { none, some, fromNullable } from 'fp-ts/Option'
680
+ *
681
+ * assert.deepStrictEqual(fromNullable(undefined), none)
682
+ * assert.deepStrictEqual(fromNullable(null), none)
683
+ * assert.deepStrictEqual(fromNullable(1), some(1))
684
+ *
685
+ * @category constructors
686
+ * @since 2.0.0
687
+ */
688
+ function fromNullable(a) {
689
+ return a == null ? exports.none : exports.some(a);
690
+ }
691
+ exports.fromNullable = fromNullable;
692
+ function fromPredicate(predicate) {
693
+ return function (a) { return (predicate(a) ? exports.some(a) : exports.none); };
694
+ }
695
+ exports.fromPredicate = fromPredicate;
696
+ /**
697
+ * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a
698
+ * `Some`.
699
+ *
700
+ * @example
701
+ * import { none, some, tryCatch } from 'fp-ts/Option'
702
+ *
703
+ * assert.deepStrictEqual(
704
+ * tryCatch(() => {
705
+ * throw new Error()
706
+ * }),
707
+ * none
708
+ * )
709
+ * assert.deepStrictEqual(tryCatch(() => 1), some(1))
710
+ *
711
+ * @category constructors
712
+ * @since 2.0.0
713
+ */
714
+ function tryCatch(f) {
715
+ try {
716
+ return exports.some(f());
717
+ }
718
+ catch (e) {
719
+ return exports.none;
720
+ }
721
+ }
722
+ exports.tryCatch = tryCatch;
723
+ /**
724
+ * Returns the `Left` value of an `Either` if possible.
725
+ *
726
+ * @example
727
+ * import { getLeft, none, some } from 'fp-ts/Option'
728
+ * import { right, left } from 'fp-ts/Either'
729
+ *
730
+ * assert.deepStrictEqual(getLeft(right(1)), none)
731
+ * assert.deepStrictEqual(getLeft(left('a')), some('a'))
732
+ *
733
+ * @category constructors
734
+ * @since 2.0.0
735
+ */
736
+ function getLeft(ma) {
737
+ return ma._tag === 'Right' ? exports.none : exports.some(ma.left);
738
+ }
739
+ exports.getLeft = getLeft;
740
+ /**
741
+ * Returns the `Right` value of an `Either` if possible.
742
+ *
743
+ * @example
744
+ * import { getRight, none, some } from 'fp-ts/Option'
745
+ * import { right, left } from 'fp-ts/Either'
746
+ *
747
+ * assert.deepStrictEqual(getRight(right(1)), some(1))
748
+ * assert.deepStrictEqual(getRight(left('a')), none)
749
+ *
750
+ * @category constructors
751
+ * @since 2.0.0
752
+ */
753
+ function getRight(ma) {
754
+ return ma._tag === 'Left' ? exports.none : exports.some(ma.right);
755
+ }
756
+ exports.getRight = getRight;
757
+ /**
758
+ * Transforms an `Either` to an `Option` discarding the error.
759
+ *
760
+ * Alias of [getRight](#getRight)
761
+ *
762
+ * Derivable from `MonadThrow`.
763
+ *
764
+ * @category constructors
765
+ * @since 2.0.0
766
+ */
767
+ exports.fromEither = getRight;
768
+ // -------------------------------------------------------------------------------------
769
+ // destructors
770
+ // -------------------------------------------------------------------------------------
771
+ /**
772
+ * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is
773
+ * returned, otherwise the function is applied to the value inside the `Some` and the result is returned.
774
+ *
775
+ * @example
776
+ * import { some, none, fold } from 'fp-ts/Option'
777
+ * import { pipe } from 'fp-ts/function'
778
+ *
779
+ * assert.strictEqual(
780
+ * pipe(
781
+ * some(1),
782
+ * fold(() => 'a none', a => `a some containing ${a}`)
783
+ * ),
784
+ * 'a some containing 1'
785
+ * )
786
+ *
787
+ * assert.strictEqual(
788
+ * pipe(
789
+ * none,
790
+ * fold(() => 'a none', a => `a some containing ${a}`)
791
+ * ),
792
+ * 'a none'
793
+ * )
794
+ *
795
+ * @category destructors
796
+ * @since 2.0.0
797
+ */
798
+ function fold(onNone, onSome) {
799
+ return function (ma) { return (exports.isNone(ma) ? onNone() : onSome(ma.value)); };
800
+ }
801
+ exports.fold = fold;
802
+ /**
803
+ * Extracts the value out of the structure, if it exists. Otherwise returns `null`.
804
+ *
805
+ * @example
806
+ * import { some, none, toNullable } from 'fp-ts/Option'
807
+ * import { pipe } from 'fp-ts/function'
808
+ *
809
+ * assert.strictEqual(
810
+ * pipe(
811
+ * some(1),
812
+ * toNullable
813
+ * ),
814
+ * 1
815
+ * )
816
+ * assert.strictEqual(
817
+ * pipe(
818
+ * none,
819
+ * toNullable
820
+ * ),
821
+ * null
822
+ * )
823
+ *
824
+ * @category destructors
825
+ * @since 2.0.0
826
+ */
827
+ function toNullable(ma) {
828
+ return exports.isNone(ma) ? null : ma.value;
829
+ }
830
+ exports.toNullable = toNullable;
831
+ /**
832
+ * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.
833
+ *
834
+ * @example
835
+ * import { some, none, toUndefined } from 'fp-ts/Option'
836
+ * import { pipe } from 'fp-ts/function'
837
+ *
838
+ * assert.strictEqual(
839
+ * pipe(
840
+ * some(1),
841
+ * toUndefined
842
+ * ),
843
+ * 1
844
+ * )
845
+ * assert.strictEqual(
846
+ * pipe(
847
+ * none,
848
+ * toUndefined
849
+ * ),
850
+ * undefined
851
+ * )
852
+ *
853
+ * @category destructors
854
+ * @since 2.0.0
855
+ */
856
+ function toUndefined(ma) {
857
+ return exports.isNone(ma) ? undefined : ma.value;
858
+ }
859
+ exports.toUndefined = toUndefined;
860
+ /**
861
+ * Less strict version of [`getOrElse`](#getOrElse).
862
+ *
863
+ * @category destructors
864
+ * @since 2.6.0
865
+ */
866
+ var getOrElseW = function (onNone) { return function (ma) { return (exports.isNone(ma) ? onNone() : ma.value); }; };
867
+ exports.getOrElseW = getOrElseW;
868
+ /**
869
+ * Extracts the value out of the structure, if it exists. Otherwise returns the given default value
870
+ *
871
+ * @example
872
+ * import { some, none, getOrElse } from 'fp-ts/Option'
873
+ * import { pipe } from 'fp-ts/function'
874
+ *
875
+ * assert.strictEqual(
876
+ * pipe(
877
+ * some(1),
878
+ * getOrElse(() => 0)
879
+ * ),
880
+ * 1
881
+ * )
882
+ * assert.strictEqual(
883
+ * pipe(
884
+ * none,
885
+ * getOrElse(() => 0)
886
+ * ),
887
+ * 0
888
+ * )
889
+ *
890
+ * @category destructors
891
+ * @since 2.0.0
892
+ */
893
+ exports.getOrElse = exports.getOrElseW;
894
+ // -------------------------------------------------------------------------------------
895
+ // combinators
896
+ // -------------------------------------------------------------------------------------
897
+ /**
898
+ * Returns a *smart constructor* from a function that returns a nullable value.
899
+ *
900
+ * @example
901
+ * import { fromNullableK, none, some } from 'fp-ts/Option'
902
+ *
903
+ * const f = (s: string): number | undefined => {
904
+ * const n = parseFloat(s)
905
+ * return isNaN(n) ? undefined : n
906
+ * }
907
+ *
908
+ * const g = fromNullableK(f)
909
+ *
910
+ * assert.deepStrictEqual(g('1'), some(1))
911
+ * assert.deepStrictEqual(g('a'), none)
912
+ *
913
+ * @category combinators
914
+ * @since 2.9.0
915
+ */
916
+ function fromNullableK(f) {
917
+ return function () {
918
+ var a = [];
919
+ for (var _i = 0; _i < arguments.length; _i++) {
920
+ a[_i] = arguments[_i];
921
+ }
922
+ return fromNullable(f.apply(void 0, a));
923
+ };
924
+ }
925
+ exports.fromNullableK = fromNullableK;
926
+ /**
927
+ * @category combinators
928
+ * @since 2.0.0
929
+ * @deprecated
930
+ */
931
+ exports.mapNullable = chainNullableK;
932
+ /**
933
+ * This is `chain` + `fromNullable`, useful when working with optional values.
934
+ *
935
+ * @example
936
+ * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'
937
+ * import { pipe } from 'fp-ts/function'
938
+ *
939
+ * interface Employee {
940
+ * company?: {
941
+ * address?: {
942
+ * street?: {
943
+ * name?: string
944
+ * }
945
+ * }
946
+ * }
947
+ * }
948
+ *
949
+ * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
950
+ *
951
+ * assert.deepStrictEqual(
952
+ * pipe(
953
+ * fromNullable(employee1.company),
954
+ * chainNullableK(company => company.address),
955
+ * chainNullableK(address => address.street),
956
+ * chainNullableK(street => street.name)
957
+ * ),
958
+ * some('high street')
959
+ * )
960
+ *
961
+ * const employee2: Employee = { company: { address: { street: {} } } }
962
+ *
963
+ * assert.deepStrictEqual(
964
+ * pipe(
965
+ * fromNullable(employee2.company),
966
+ * chainNullableK(company => company.address),
967
+ * chainNullableK(address => address.street),
968
+ * chainNullableK(street => street.name)
969
+ * ),
970
+ * none
971
+ * )
972
+ *
973
+ * @category combinators
974
+ * @since 2.9.0
975
+ */
976
+ function chainNullableK(f) {
977
+ return function (ma) { return (exports.isNone(ma) ? exports.none : fromNullable(f(ma.value))); };
978
+ }
979
+ exports.chainNullableK = chainNullableK;
980
+ // -------------------------------------------------------------------------------------
981
+ // non-pipeables
982
+ // -------------------------------------------------------------------------------------
983
+ var map_ = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
984
+ var ap_ = function (fab, fa) { return _function.pipe(fab, exports.ap(fa)); };
985
+ var chain_ = function (ma, f) { return _function.pipe(ma, exports.chain(f)); };
986
+ var reduce_ = function (fa, b, f) { return _function.pipe(fa, exports.reduce(b, f)); };
987
+ var foldMap_ = function (M) {
988
+ var foldMapM = exports.foldMap(M);
989
+ return function (fa, f) { return _function.pipe(fa, foldMapM(f)); };
990
+ };
991
+ var reduceRight_ = function (fa, b, f) { return _function.pipe(fa, exports.reduceRight(b, f)); };
992
+ var traverse_ = function (F) {
993
+ var traverseF = exports.traverse(F);
994
+ return function (ta, f) { return _function.pipe(ta, traverseF(f)); };
995
+ };
996
+ /* istanbul ignore next */
997
+ var alt_ = function (fa, that) { return _function.pipe(fa, exports.alt(that)); };
998
+ var filter_ = function (fa, predicate) {
999
+ return _function.pipe(fa, exports.filter(predicate));
1000
+ };
1001
+ /* istanbul ignore next */
1002
+ var filterMap_ = function (fa, f) { return _function.pipe(fa, exports.filterMap(f)); };
1003
+ /* istanbul ignore next */
1004
+ var extend_ = function (wa, f) { return _function.pipe(wa, exports.extend(f)); };
1005
+ /* istanbul ignore next */
1006
+ var partition_ = function (fa, predicate) { return _function.pipe(fa, exports.partition(predicate)); };
1007
+ /* istanbul ignore next */
1008
+ var partitionMap_ = function (fa, f) { return _function.pipe(fa, exports.partitionMap(f)); };
1009
+ /* istanbul ignore next */
1010
+ var wither_ = function (F) {
1011
+ var witherF = exports.wither(F);
1012
+ return function (fa, f) { return _function.pipe(fa, witherF(f)); };
1013
+ };
1014
+ /* istanbul ignore next */
1015
+ var wilt_ = function (F) {
1016
+ var wiltF = exports.wilt(F);
1017
+ return function (fa, f) { return _function.pipe(fa, wiltF(f)); };
1018
+ };
1019
+ // -------------------------------------------------------------------------------------
1020
+ // pipeables
1021
+ // -------------------------------------------------------------------------------------
1022
+ /**
1023
+ * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
1024
+ * use the type constructor `F` to represent some computational context.
1025
+ *
1026
+ * @category Functor
1027
+ * @since 2.0.0
1028
+ */
1029
+ var map = function (f) { return function (fa) {
1030
+ return exports.isNone(fa) ? exports.none : exports.some(f(fa.value));
1031
+ }; };
1032
+ exports.map = map;
1033
+ /**
1034
+ * Apply a function to an argument under a type constructor.
1035
+ *
1036
+ * @category Apply
1037
+ * @since 2.0.0
1038
+ */
1039
+ var ap = function (fa) { return function (fab) {
1040
+ return exports.isNone(fab) ? exports.none : exports.isNone(fa) ? exports.none : exports.some(fab.value(fa.value));
1041
+ }; };
1042
+ exports.ap = ap;
1043
+ /**
1044
+ * Combine two effectful actions, keeping only the result of the first.
1045
+ *
1046
+ * Derivable from `Apply`.
1047
+ *
1048
+ * @category combinators
1049
+ * @since 2.0.0
1050
+ */
1051
+ var apFirst = function (fb) {
1052
+ return _function.flow(exports.map(function (a) { return function () { return a; }; }), exports.ap(fb));
1053
+ };
1054
+ exports.apFirst = apFirst;
1055
+ /**
1056
+ * Combine two effectful actions, keeping only the result of the second.
1057
+ *
1058
+ * Derivable from `Apply`.
1059
+ *
1060
+ * @category combinators
1061
+ * @since 2.0.0
1062
+ */
1063
+ var apSecond = function (fb) {
1064
+ return _function.flow(exports.map(function () { return function (b) { return b; }; }), exports.ap(fb));
1065
+ };
1066
+ exports.apSecond = apSecond;
1067
+ /**
1068
+ * Wrap a value into the type constructor.
1069
+ *
1070
+ * @category Applicative
1071
+ * @since 2.7.0
1072
+ */
1073
+ exports.of = exports.some;
1074
+ /**
1075
+ * Composes computations in sequence, using the return value of one computation to determine the next computation.
1076
+ *
1077
+ * @category Monad
1078
+ * @since 2.0.0
1079
+ */
1080
+ var chain = function (f) { return function (ma) {
1081
+ return exports.isNone(ma) ? exports.none : f(ma.value);
1082
+ }; };
1083
+ exports.chain = chain;
1084
+ /**
1085
+ * Composes computations in sequence, using the return value of one computation to determine the next computation and
1086
+ * keeping only the result of the first.
1087
+ *
1088
+ * Derivable from `Monad`.
1089
+ *
1090
+ * @category combinators
1091
+ * @since 2.0.0
1092
+ */
1093
+ var chainFirst = function (f) {
1094
+ return exports.chain(function (a) {
1095
+ return _function.pipe(f(a), exports.map(function () { return a; }));
1096
+ });
1097
+ };
1098
+ exports.chainFirst = chainFirst;
1099
+ /**
1100
+ * Derivable from `Monad`.
1101
+ *
1102
+ * @category combinators
1103
+ * @since 2.0.0
1104
+ */
1105
+ exports.flatten =
1106
+ /*#__PURE__*/
1107
+ exports.chain(_function.identity);
1108
+ /**
1109
+ * Less strict version of [`alt`](#alt).
1110
+ *
1111
+ * @category Alt
1112
+ * @since 2.9.0
1113
+ */
1114
+ var altW = function (that) { return function (fa) {
1115
+ return exports.isNone(fa) ? that() : fa;
1116
+ }; };
1117
+ exports.altW = altW;
1118
+ /**
1119
+ * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
1120
+ * types of kind `* -> *`.
1121
+ *
1122
+ * In case of `Option` returns the left-most non-`None` value.
1123
+ *
1124
+ * @example
1125
+ * import * as O from 'fp-ts/Option'
1126
+ * import { pipe } from 'fp-ts/function'
1127
+ *
1128
+ * assert.deepStrictEqual(
1129
+ * pipe(
1130
+ * O.some('a'),
1131
+ * O.alt(() => O.some('b'))
1132
+ * ),
1133
+ * O.some('a')
1134
+ * )
1135
+ * assert.deepStrictEqual(
1136
+ * pipe(
1137
+ * O.none,
1138
+ * O.alt(() => O.some('b'))
1139
+ * ),
1140
+ * O.some('b')
1141
+ * )
1142
+ *
1143
+ * @category Alt
1144
+ * @since 2.0.0
1145
+ */
1146
+ exports.alt = exports.altW;
1147
+ /**
1148
+ * @category Alternative
1149
+ * @since 2.7.0
1150
+ */
1151
+ var zero = function () { return exports.none; };
1152
+ exports.zero = zero;
1153
+ /**
1154
+ * @category MonadThrow
1155
+ * @since 2.7.0
1156
+ */
1157
+ var throwError = function () { return exports.none; };
1158
+ exports.throwError = throwError;
1159
+ /**
1160
+ * @category Extend
1161
+ * @since 2.0.0
1162
+ */
1163
+ var extend = function (f) { return function (wa) {
1164
+ return exports.isNone(wa) ? exports.none : exports.some(f(wa));
1165
+ }; };
1166
+ exports.extend = extend;
1167
+ /**
1168
+ * Derivable from `Extend`.
1169
+ *
1170
+ * @category combinators
1171
+ * @since 2.0.0
1172
+ */
1173
+ exports.duplicate =
1174
+ /*#__PURE__*/
1175
+ exports.extend(_function.identity);
1176
+ /**
1177
+ * @category Foldable
1178
+ * @since 2.0.0
1179
+ */
1180
+ var reduce = function (b, f) { return function (fa) {
1181
+ return exports.isNone(fa) ? b : f(b, fa.value);
1182
+ }; };
1183
+ exports.reduce = reduce;
1184
+ /**
1185
+ * @category Foldable
1186
+ * @since 2.0.0
1187
+ */
1188
+ var foldMap = function (M) { return function (f) { return function (fa) {
1189
+ return exports.isNone(fa) ? M.empty : f(fa.value);
1190
+ }; }; };
1191
+ exports.foldMap = foldMap;
1192
+ /**
1193
+ * @category Foldable
1194
+ * @since 2.0.0
1195
+ */
1196
+ var reduceRight = function (b, f) { return function (fa) {
1197
+ return exports.isNone(fa) ? b : f(fa.value, b);
1198
+ }; };
1199
+ exports.reduceRight = reduceRight;
1200
+ /**
1201
+ * @category Compactable
1202
+ * @since 2.0.0
1203
+ */
1204
+ exports.compact = exports.flatten;
1205
+ var defaultSeparate = { left: exports.none, right: exports.none };
1206
+ /**
1207
+ * @category Compactable
1208
+ * @since 2.0.0
1209
+ */
1210
+ var separate = function (ma) {
1211
+ var o = _function.pipe(ma, exports.map(function (e) { return ({
1212
+ left: getLeft(e),
1213
+ right: getRight(e)
1214
+ }); }));
1215
+ return exports.isNone(o) ? defaultSeparate : o.value;
1216
+ };
1217
+ exports.separate = separate;
1218
+ /**
1219
+ * @category Filterable
1220
+ * @since 2.0.0
1221
+ */
1222
+ var filter = function (predicate) { return function (fa) { return (exports.isNone(fa) ? exports.none : predicate(fa.value) ? fa : exports.none); }; };
1223
+ exports.filter = filter;
1224
+ /**
1225
+ * @category Filterable
1226
+ * @since 2.0.0
1227
+ */
1228
+ var filterMap = function (f) { return function (fa) {
1229
+ return exports.isNone(fa) ? exports.none : f(fa.value);
1230
+ }; };
1231
+ exports.filterMap = filterMap;
1232
+ /**
1233
+ * @category Filterable
1234
+ * @since 2.0.0
1235
+ */
1236
+ var partition = function (predicate) { return function (fa) {
1237
+ return {
1238
+ left: filter_(fa, function (a) { return !predicate(a); }),
1239
+ right: filter_(fa, predicate)
1240
+ };
1241
+ }; };
1242
+ exports.partition = partition;
1243
+ /**
1244
+ * @category Filterable
1245
+ * @since 2.0.0
1246
+ */
1247
+ var partitionMap = function (f) { return _function.flow(exports.map(f), exports.separate); };
1248
+ exports.partitionMap = partitionMap;
1249
+ /**
1250
+ * @category Traversable
1251
+ * @since 2.6.3
1252
+ */
1253
+ var traverse = function (F) { return function (f) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(f(ta.value), exports.some)); }; }; };
1254
+ exports.traverse = traverse;
1255
+ /**
1256
+ * @category Traversable
1257
+ * @since 2.6.3
1258
+ */
1259
+ var sequence = function (F) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(ta.value, exports.some)); }; };
1260
+ exports.sequence = sequence;
1261
+ /**
1262
+ * @category Witherable
1263
+ * @since 2.6.5
1264
+ */
1265
+ var wither = function (F) { return function (f) { return function (fa) { return (exports.isNone(fa) ? F.of(exports.none) : f(fa.value)); }; }; };
1266
+ exports.wither = wither;
1267
+ /**
1268
+ * @category Witherable
1269
+ * @since 2.6.5
1270
+ */
1271
+ var wilt = function (F) { return function (f) { return function (fa) {
1272
+ return exports.isNone(fa)
1273
+ ? F.of({
1274
+ left: exports.none,
1275
+ right: exports.none
1276
+ })
1277
+ : F.map(f(fa.value), function (e) { return ({
1278
+ left: getLeft(e),
1279
+ right: getRight(e)
1280
+ }); });
1281
+ }; }; };
1282
+ exports.wilt = wilt;
1283
+ // -------------------------------------------------------------------------------------
1284
+ // instances
1285
+ // -------------------------------------------------------------------------------------
1286
+ /**
1287
+ * @category instances
1288
+ * @since 2.0.0
1289
+ */
1290
+ exports.URI = 'Option';
1291
+ /**
1292
+ * @category instances
1293
+ * @since 2.0.0
1294
+ */
1295
+ function getShow(S) {
1296
+ return {
1297
+ show: function (ma) { return (exports.isNone(ma) ? 'none' : "some(" + S.show(ma.value) + ")"); }
1298
+ };
1299
+ }
1300
+ exports.getShow = getShow;
1301
+ /**
1302
+ * @example
1303
+ * import { none, some, getEq } from 'fp-ts/Option'
1304
+ * import { eqNumber } from 'fp-ts/Eq'
1305
+ *
1306
+ * const E = getEq(eqNumber)
1307
+ * assert.strictEqual(E.equals(none, none), true)
1308
+ * assert.strictEqual(E.equals(none, some(1)), false)
1309
+ * assert.strictEqual(E.equals(some(1), none), false)
1310
+ * assert.strictEqual(E.equals(some(1), some(2)), false)
1311
+ * assert.strictEqual(E.equals(some(1), some(1)), true)
1312
+ *
1313
+ * @category instances
1314
+ * @since 2.0.0
1315
+ */
1316
+ function getEq(E) {
1317
+ return {
1318
+ equals: function (x, y) { return x === y || (exports.isNone(x) ? exports.isNone(y) : exports.isNone(y) ? false : E.equals(x.value, y.value)); }
1319
+ };
1320
+ }
1321
+ exports.getEq = getEq;
1322
+ /**
1323
+ * The `Ord` instance allows `Option` values to be compared with
1324
+ * `compare`, whenever there is an `Ord` instance for
1325
+ * the type the `Option` contains.
1326
+ *
1327
+ * `None` is considered to be less than any `Some` value.
1328
+ *
1329
+ *
1330
+ * @example
1331
+ * import { none, some, getOrd } from 'fp-ts/Option'
1332
+ * import { ordNumber } from 'fp-ts/Ord'
1333
+ *
1334
+ * const O = getOrd(ordNumber)
1335
+ * assert.strictEqual(O.compare(none, none), 0)
1336
+ * assert.strictEqual(O.compare(none, some(1)), -1)
1337
+ * assert.strictEqual(O.compare(some(1), none), 1)
1338
+ * assert.strictEqual(O.compare(some(1), some(2)), -1)
1339
+ * assert.strictEqual(O.compare(some(1), some(1)), 0)
1340
+ *
1341
+ * @category instances
1342
+ * @since 2.0.0
1343
+ */
1344
+ function getOrd(O) {
1345
+ return {
1346
+ equals: getEq(O).equals,
1347
+ compare: function (x, y) { return (x === y ? 0 : exports.isSome(x) ? (exports.isSome(y) ? O.compare(x.value, y.value) : 1) : -1); }
1348
+ };
1349
+ }
1350
+ exports.getOrd = getOrd;
1351
+ /**
1352
+ * `Apply` semigroup
1353
+ *
1354
+ * | x | y | concat(x, y) |
1355
+ * | ------- | ------- | ------------------ |
1356
+ * | none | none | none |
1357
+ * | some(a) | none | none |
1358
+ * | none | some(a) | none |
1359
+ * | some(a) | some(b) | some(concat(a, b)) |
1360
+ *
1361
+ * @example
1362
+ * import { getApplySemigroup, some, none } from 'fp-ts/Option'
1363
+ * import { semigroupSum } from 'fp-ts/Semigroup'
1364
+ *
1365
+ * const S = getApplySemigroup(semigroupSum)
1366
+ * assert.deepStrictEqual(S.concat(none, none), none)
1367
+ * assert.deepStrictEqual(S.concat(some(1), none), none)
1368
+ * assert.deepStrictEqual(S.concat(none, some(1)), none)
1369
+ * assert.deepStrictEqual(S.concat(some(1), some(2)), some(3))
1370
+ *
1371
+ * @category instances
1372
+ * @since 2.0.0
1373
+ */
1374
+ function getApplySemigroup(S) {
1375
+ return {
1376
+ concat: function (x, y) { return (exports.isSome(x) && exports.isSome(y) ? exports.some(S.concat(x.value, y.value)) : exports.none); }
1377
+ };
1378
+ }
1379
+ exports.getApplySemigroup = getApplySemigroup;
1380
+ /**
1381
+ * @category instances
1382
+ * @since 2.0.0
1383
+ */
1384
+ function getApplyMonoid(M) {
1385
+ return {
1386
+ concat: getApplySemigroup(M).concat,
1387
+ empty: exports.some(M.empty)
1388
+ };
1389
+ }
1390
+ exports.getApplyMonoid = getApplyMonoid;
1391
+ /**
1392
+ * Monoid returning the left-most non-`None` value
1393
+ *
1394
+ * | x | y | concat(x, y) |
1395
+ * | ------- | ------- | ------------ |
1396
+ * | none | none | none |
1397
+ * | some(a) | none | some(a) |
1398
+ * | none | some(a) | some(a) |
1399
+ * | some(a) | some(b) | some(a) |
1400
+ *
1401
+ * @example
1402
+ * import { getFirstMonoid, some, none } from 'fp-ts/Option'
1403
+ *
1404
+ * const M = getFirstMonoid<number>()
1405
+ * assert.deepStrictEqual(M.concat(none, none), none)
1406
+ * assert.deepStrictEqual(M.concat(some(1), none), some(1))
1407
+ * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
1408
+ * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))
1409
+ *
1410
+ * @category instances
1411
+ * @since 2.0.0
1412
+ */
1413
+ function getFirstMonoid() {
1414
+ return {
1415
+ concat: function (x, y) { return (exports.isNone(x) ? y : x); },
1416
+ empty: exports.none
1417
+ };
1418
+ }
1419
+ exports.getFirstMonoid = getFirstMonoid;
1420
+ /**
1421
+ * Monoid returning the right-most non-`None` value
1422
+ *
1423
+ * | x | y | concat(x, y) |
1424
+ * | ------- | ------- | ------------ |
1425
+ * | none | none | none |
1426
+ * | some(a) | none | some(a) |
1427
+ * | none | some(a) | some(a) |
1428
+ * | some(a) | some(b) | some(b) |
1429
+ *
1430
+ * @example
1431
+ * import { getLastMonoid, some, none } from 'fp-ts/Option'
1432
+ *
1433
+ * const M = getLastMonoid<number>()
1434
+ * assert.deepStrictEqual(M.concat(none, none), none)
1435
+ * assert.deepStrictEqual(M.concat(some(1), none), some(1))
1436
+ * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
1437
+ * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))
1438
+ *
1439
+ * @category instances
1440
+ * @since 2.0.0
1441
+ */
1442
+ function getLastMonoid() {
1443
+ return {
1444
+ concat: function (x, y) { return (exports.isNone(y) ? x : y); },
1445
+ empty: exports.none
1446
+ };
1447
+ }
1448
+ exports.getLastMonoid = getLastMonoid;
1449
+ /**
1450
+ * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are
1451
+ * concatenated using the provided `Semigroup`
1452
+ *
1453
+ * | x | y | concat(x, y) |
1454
+ * | ------- | ------- | ------------------ |
1455
+ * | none | none | none |
1456
+ * | some(a) | none | some(a) |
1457
+ * | none | some(a) | some(a) |
1458
+ * | some(a) | some(b) | some(concat(a, b)) |
1459
+ *
1460
+ * @example
1461
+ * import { getMonoid, some, none } from 'fp-ts/Option'
1462
+ * import { semigroupSum } from 'fp-ts/Semigroup'
1463
+ *
1464
+ * const M = getMonoid(semigroupSum)
1465
+ * assert.deepStrictEqual(M.concat(none, none), none)
1466
+ * assert.deepStrictEqual(M.concat(some(1), none), some(1))
1467
+ * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
1468
+ * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))
1469
+ *
1470
+ * @category instances
1471
+ * @since 2.0.0
1472
+ */
1473
+ function getMonoid(S) {
1474
+ return {
1475
+ concat: function (x, y) { return (exports.isNone(x) ? y : exports.isNone(y) ? x : exports.some(S.concat(x.value, y.value))); },
1476
+ empty: exports.none
1477
+ };
1478
+ }
1479
+ exports.getMonoid = getMonoid;
1480
+ /**
1481
+ * @category instances
1482
+ * @since 2.7.0
1483
+ */
1484
+ exports.Functor = {
1485
+ URI: exports.URI,
1486
+ map: map_
1487
+ };
1488
+ /**
1489
+ * @category instances
1490
+ * @since 2.7.0
1491
+ */
1492
+ exports.Applicative = {
1493
+ URI: exports.URI,
1494
+ map: map_,
1495
+ ap: ap_,
1496
+ of: exports.of
1497
+ };
1498
+ /**
1499
+ * @category instances
1500
+ * @since 2.7.0
1501
+ */
1502
+ exports.Monad = {
1503
+ URI: exports.URI,
1504
+ map: map_,
1505
+ ap: ap_,
1506
+ of: exports.of,
1507
+ chain: chain_
1508
+ };
1509
+ /**
1510
+ * @category instances
1511
+ * @since 2.7.0
1512
+ */
1513
+ exports.Foldable = {
1514
+ URI: exports.URI,
1515
+ reduce: reduce_,
1516
+ foldMap: foldMap_,
1517
+ reduceRight: reduceRight_
1518
+ };
1519
+ /**
1520
+ * @category instances
1521
+ * @since 2.7.0
1522
+ */
1523
+ exports.Alt = {
1524
+ URI: exports.URI,
1525
+ map: map_,
1526
+ alt: alt_
1527
+ };
1528
+ /**
1529
+ * @category instances
1530
+ * @since 2.7.0
1531
+ */
1532
+ exports.Alternative = {
1533
+ URI: exports.URI,
1534
+ map: map_,
1535
+ ap: ap_,
1536
+ of: exports.of,
1537
+ alt: alt_,
1538
+ zero: exports.zero
1539
+ };
1540
+ /**
1541
+ * @category instances
1542
+ * @since 2.7.0
1543
+ */
1544
+ exports.Extend = {
1545
+ URI: exports.URI,
1546
+ map: map_,
1547
+ extend: extend_
1548
+ };
1549
+ /**
1550
+ * @category instances
1551
+ * @since 2.7.0
1552
+ */
1553
+ exports.Compactable = {
1554
+ URI: exports.URI,
1555
+ compact: exports.compact,
1556
+ separate: exports.separate
1557
+ };
1558
+ /**
1559
+ * @category instances
1560
+ * @since 2.7.0
1561
+ */
1562
+ exports.Filterable = {
1563
+ URI: exports.URI,
1564
+ map: map_,
1565
+ compact: exports.compact,
1566
+ separate: exports.separate,
1567
+ filter: filter_,
1568
+ filterMap: filterMap_,
1569
+ partition: partition_,
1570
+ partitionMap: partitionMap_
1571
+ };
1572
+ /**
1573
+ * @category instances
1574
+ * @since 2.7.0
1575
+ */
1576
+ exports.Traversable = {
1577
+ URI: exports.URI,
1578
+ map: map_,
1579
+ reduce: reduce_,
1580
+ foldMap: foldMap_,
1581
+ reduceRight: reduceRight_,
1582
+ traverse: traverse_,
1583
+ sequence: exports.sequence
1584
+ };
1585
+ /**
1586
+ * @category instances
1587
+ * @since 2.7.0
1588
+ */
1589
+ exports.Witherable = {
1590
+ URI: exports.URI,
1591
+ map: map_,
1592
+ reduce: reduce_,
1593
+ foldMap: foldMap_,
1594
+ reduceRight: reduceRight_,
1595
+ traverse: traverse_,
1596
+ sequence: exports.sequence,
1597
+ compact: exports.compact,
1598
+ separate: exports.separate,
1599
+ filter: filter_,
1600
+ filterMap: filterMap_,
1601
+ partition: partition_,
1602
+ partitionMap: partitionMap_,
1603
+ wither: wither_,
1604
+ wilt: wilt_
1605
+ };
1606
+ /**
1607
+ * @category instances
1608
+ * @since 2.7.0
1609
+ */
1610
+ exports.MonadThrow = {
1611
+ URI: exports.URI,
1612
+ map: map_,
1613
+ ap: ap_,
1614
+ of: exports.of,
1615
+ chain: chain_,
1616
+ throwError: exports.throwError
1617
+ };
1618
+ // TODO: remove in v3
1619
+ /**
1620
+ * @category instances
1621
+ * @since 2.0.0
1622
+ */
1623
+ exports.option = {
1624
+ URI: exports.URI,
1625
+ map: map_,
1626
+ of: exports.of,
1627
+ ap: ap_,
1628
+ chain: chain_,
1629
+ reduce: reduce_,
1630
+ foldMap: foldMap_,
1631
+ reduceRight: reduceRight_,
1632
+ traverse: traverse_,
1633
+ sequence: exports.sequence,
1634
+ zero: exports.zero,
1635
+ alt: alt_,
1636
+ extend: extend_,
1637
+ compact: exports.compact,
1638
+ separate: exports.separate,
1639
+ filter: filter_,
1640
+ filterMap: filterMap_,
1641
+ partition: partition_,
1642
+ partitionMap: partitionMap_,
1643
+ wither: wither_,
1644
+ wilt: wilt_,
1645
+ throwError: exports.throwError
1646
+ };
1647
+ // -------------------------------------------------------------------------------------
1648
+ // utils
1649
+ // -------------------------------------------------------------------------------------
1650
+ /**
1651
+ * Returns `true` if `ma` contains `a`
1652
+ *
1653
+ * @example
1654
+ * import { some, none, elem } from 'fp-ts/Option'
1655
+ * import { eqNumber } from 'fp-ts/Eq'
1656
+ *
1657
+ * assert.strictEqual(elem(eqNumber)(1, some(1)), true)
1658
+ * assert.strictEqual(elem(eqNumber)(2, some(1)), false)
1659
+ * assert.strictEqual(elem(eqNumber)(1, none), false)
1660
+ *
1661
+ * @since 2.0.0
1662
+ */
1663
+ function elem(E) {
1664
+ return function (a, ma) { return (exports.isNone(ma) ? false : E.equals(a, ma.value)); };
1665
+ }
1666
+ exports.elem = elem;
1667
+ /**
1668
+ * Returns `true` if the predicate is satisfied by the wrapped value
1669
+ *
1670
+ * @example
1671
+ * import { some, none, exists } from 'fp-ts/Option'
1672
+ * import { pipe } from 'fp-ts/function'
1673
+ *
1674
+ * assert.strictEqual(
1675
+ * pipe(
1676
+ * some(1),
1677
+ * exists(n => n > 0)
1678
+ * ),
1679
+ * true
1680
+ * )
1681
+ * assert.strictEqual(
1682
+ * pipe(
1683
+ * some(1),
1684
+ * exists(n => n > 1)
1685
+ * ),
1686
+ * false
1687
+ * )
1688
+ * assert.strictEqual(
1689
+ * pipe(
1690
+ * none,
1691
+ * exists(n => n > 0)
1692
+ * ),
1693
+ * false
1694
+ * )
1695
+ *
1696
+ * @since 2.0.0
1697
+ */
1698
+ function exists(predicate) {
1699
+ return function (ma) { return (exports.isNone(ma) ? false : predicate(ma.value)); };
1700
+ }
1701
+ exports.exists = exists;
1702
+ /**
1703
+ * Returns a `Refinement` (i.e. a custom type guard) from a `Option` returning function.
1704
+ * This function ensures that a custom type guard definition is type-safe.
1705
+ *
1706
+ * ```ts
1707
+ * import { some, none, getRefinement } from 'fp-ts/Option'
1708
+ *
1709
+ * type A = { type: 'A' }
1710
+ * type B = { type: 'B' }
1711
+ * type C = A | B
1712
+ *
1713
+ * const isA = (c: C): c is A => c.type === 'B' // <= typo but typescript doesn't complain
1714
+ * const isA = getRefinement<C, A>(c => (c.type === 'B' ? some(c) : none)) // static error: Type '"B"' is not assignable to type '"A"'
1715
+ * ```
1716
+ *
1717
+ * @since 2.0.0
1718
+ */
1719
+ function getRefinement(getOption) {
1720
+ return function (a) { return exports.isSome(getOption(a)); };
1721
+ }
1722
+ exports.getRefinement = getRefinement;
1723
+ // -------------------------------------------------------------------------------------
1724
+ // do notation
1725
+ // -------------------------------------------------------------------------------------
1726
+ /**
1727
+ * @since 2.9.0
1728
+ */
1729
+ exports.Do =
1730
+ /*#__PURE__*/
1731
+ exports.of({});
1732
+ /**
1733
+ * @since 2.8.0
1734
+ */
1735
+ var bindTo = function (name) { return exports.map(_function.bindTo_(name)); };
1736
+ exports.bindTo = bindTo;
1737
+ /**
1738
+ * @since 2.8.0
1739
+ */
1740
+ var bind = function (name, f) {
1741
+ return exports.chain(function (a) {
1742
+ return _function.pipe(f(a), exports.map(function (b) { return _function.bind_(a, name, b); }));
1743
+ });
1744
+ };
1745
+ exports.bind = bind;
1746
+ // -------------------------------------------------------------------------------------
1747
+ // pipeable sequence S
1748
+ // -------------------------------------------------------------------------------------
1749
+ /**
1750
+ * @since 2.8.0
1751
+ */
1752
+ var apS = function (name, fb) {
1753
+ return _function.flow(exports.map(function (a) { return function (b) { return _function.bind_(a, name, b); }; }), exports.ap(fb));
1754
+ };
1755
+ exports.apS = apS;
1756
+ // -------------------------------------------------------------------------------------
1757
+ // array utils
1758
+ // -------------------------------------------------------------------------------------
1759
+ /**
1760
+ *
1761
+ * @since 2.9.0
1762
+ */
1763
+ var traverseArrayWithIndex = function (f) { return function (arr) {
1764
+ // tslint:disable-next-line: readonly-array
1765
+ var result = [];
1766
+ for (var i = 0; i < arr.length; i++) {
1767
+ var b = f(i, arr[i]);
1768
+ if (exports.isNone(b)) {
1769
+ return exports.none;
1770
+ }
1771
+ result.push(b.value);
1772
+ }
1773
+ return exports.some(result);
1774
+ }; };
1775
+ exports.traverseArrayWithIndex = traverseArrayWithIndex;
1776
+ /**
1777
+ * Runs an action for every element in array and accumulates the results in option
1778
+ *
1779
+ * this function have the same behavior of `A.sequence(O.option)` but it's optimized and perform better
1780
+ *
1781
+ * @example
1782
+ *
1783
+ * import * as A from 'fp-ts/Array'
1784
+ * import { traverseArray, some, fromPredicate, none } from 'fp-ts/Option'
1785
+ * import { pipe } from 'fp-ts/function'
1786
+ *
1787
+ * const arr = A.range(0, 10)
1788
+ * assert.deepStrictEqual(pipe(arr, traverseArray(some)), some(arr))
1789
+ * assert.deepStrictEqual(pipe(arr, traverseArray(fromPredicate((x) => x > 5))), none)
1790
+ *
1791
+ * @since 2.9.0
1792
+ */
1793
+ var traverseArray = function (f) { return exports.traverseArrayWithIndex(function (_, a) { return f(a); }); };
1794
+ exports.traverseArray = traverseArray;
1795
+ /**
1796
+ * get an array of option and convert it to option of array
1797
+ *
1798
+ * this function have the same behavior of `A.sequence(O.option)` but it's optimized and perform better
1799
+ *
1800
+ * @example
1801
+ *
1802
+ * import * as A from 'fp-ts/Array'
1803
+ * import { sequenceArray, some, none, fromPredicate } from 'fp-ts/Option'
1804
+ * import { pipe } from 'fp-ts/function'
1805
+ *
1806
+ * const arr = A.range(0, 10)
1807
+ * assert.deepStrictEqual(pipe(arr, A.map(some), sequenceArray), some(arr))
1808
+ * assert.deepStrictEqual(pipe(arr, A.map(fromPredicate(x => x > 8)), sequenceArray), none)
1809
+ *
1810
+ * @since 2.9.0
1811
+ */
1812
+ exports.sequenceArray =
1813
+ /*#__PURE__*/
1814
+ exports.traverseArray(_function.identity);
1815
+ });
1816
+
1817
+ function e(e){this.message=e;}e.prototype=new Error,e.prototype.name="InvalidCharacterError";var r="undefined"!=typeof window&&window.atob&&window.atob.bind(window)||function(r){var t=String(r).replace(/=+$/,"");if(t.length%4==1)throw new e("'atob' failed: The string to be decoded is not correctly encoded.");for(var n,o,a=0,i=0,c="";o=t.charAt(i++);~o&&(n=a%4?64*n+o:o,a++%4)?c+=String.fromCharCode(255&n>>(-2*a&6)):0)o="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=".indexOf(o);return c};function t(e){var t=e.replace(/-/g,"+").replace(/_/g,"/");switch(t.length%4){case 0:break;case 2:t+="==";break;case 3:t+="=";break;default:throw "Illegal base64url string!"}try{return function(e){return decodeURIComponent(r(e).replace(/(.)/g,(function(e,r){var t=r.charCodeAt(0).toString(16).toUpperCase();return t.length<2&&(t="0"+t),"%"+t})))}(t)}catch(e){return r(t)}}function n(e){this.message=e;}function o(e,r){if("string"!=typeof e)throw new n("Invalid token specified");var o=!0===(r=r||{}).header?0:1;try{return JSON.parse(t(e.split(".")[o]))}catch(e){throw new n("Invalid token specified: "+e.message)}}n.prototype=new Error,n.prototype.name="InvalidTokenError";
1818
+
1819
+ var __assign = (undefined && undefined.__assign) || function () {
1820
+ __assign = Object.assign || function(t) {
1821
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
1822
+ s = arguments[i];
1823
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
1824
+ t[p] = s[p];
1825
+ }
1826
+ return t;
1827
+ };
1828
+ return __assign.apply(this, arguments);
1829
+ };
1830
+ var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
1831
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1832
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
1833
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1834
+ r[k] = a[j];
1835
+ return r;
1836
+ };
1837
+ var mix = function (one, two, mergeArrays) {
1838
+ if (mergeArrays === void 0) { mergeArrays = false; }
1839
+ if (!one || !two || typeof one !== "object" || typeof two !== "object")
1840
+ return one;
1841
+ var clone = __assign({}, one);
1842
+ for (var prop in two) {
1843
+ if (two.hasOwnProperty(prop)) {
1844
+ if (two[prop] instanceof Array && one[prop] instanceof Array) {
1845
+ clone[prop] = mergeArrays ? __spreadArrays(one[prop], two[prop]) : two[prop];
1846
+ }
1847
+ else if (typeof two[prop] === "object" && typeof one[prop] === "object") {
1848
+ clone[prop] = mix(one[prop], two[prop], mergeArrays);
1849
+ }
1850
+ else {
1851
+ clone[prop] = two[prop];
1852
+ }
1853
+ }
1854
+ }
1855
+ return clone;
1856
+ };
1857
+
1858
+ var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
1859
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
1860
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
1861
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
1862
+ r[k] = a[j];
1863
+ return r;
1864
+ };
1865
+ var config = {
1866
+ // Default options
1867
+ defaults: {},
1868
+ // Error type
1869
+ errorType: null,
1870
+ // Polyfills
1871
+ polyfills: {
1872
+ fetch: null,
1873
+ FormData: null,
1874
+ URLSearchParams: null,
1875
+ performance: null,
1876
+ PerformanceObserver: null,
1877
+ AbortController: null
1878
+ },
1879
+ polyfill: function (p, _a) {
1880
+ var _b = _a === void 0 ? {} : _a, _c = _b.doThrow, doThrow = _c === void 0 ? true : _c, _d = _b.instance, instance = _d === void 0 ? false : _d;
1881
+ var args = [];
1882
+ for (var _i = 2; _i < arguments.length; _i++) {
1883
+ args[_i - 2] = arguments[_i];
1884
+ }
1885
+ var res = this.polyfills[p] ||
1886
+ (typeof self !== "undefined" ? self[p] : null) ||
1887
+ (typeof global !== "undefined" ? global[p] : null);
1888
+ if (doThrow && !res)
1889
+ throw new Error(p + " is not defined");
1890
+ return instance && res ? new (res.bind.apply(res, __spreadArrays$1([void 0], args)))() : res;
1891
+ }
1892
+ };
1893
+
1894
+ var onMatch = function (entries, name, callback, _performance) {
1895
+ if (!entries.getEntriesByName)
1896
+ return false;
1897
+ var matches = entries.getEntriesByName(name);
1898
+ if (matches && matches.length > 0) {
1899
+ callback(matches.reverse()[0]);
1900
+ if (_performance.clearMeasures)
1901
+ _performance.clearMeasures(name);
1902
+ perfs.callbacks.delete(name);
1903
+ if (perfs.callbacks.size < 1) {
1904
+ perfs.observer.disconnect();
1905
+ if (_performance.clearResourceTimings) {
1906
+ _performance.clearResourceTimings();
1907
+ }
1908
+ }
1909
+ return true;
1910
+ }
1911
+ return false;
1912
+ };
1913
+ var lazyObserver = function (_performance, _observer) {
1914
+ if (!perfs.observer && _performance && _observer) {
1915
+ perfs.observer = new _observer(function (entries) {
1916
+ perfs.callbacks.forEach(function (callback, name) {
1917
+ onMatch(entries, name, callback, _performance);
1918
+ });
1919
+ });
1920
+ if (_performance.clearResourceTimings)
1921
+ _performance.clearResourceTimings();
1922
+ }
1923
+ return perfs.observer;
1924
+ };
1925
+ var perfs = {
1926
+ callbacks: new Map(),
1927
+ observer: null,
1928
+ observe: function (name, callback) {
1929
+ if (!name || !callback)
1930
+ return;
1931
+ var _performance = config.polyfill("performance", { doThrow: false });
1932
+ var _observer = config.polyfill("PerformanceObserver", { doThrow: false });
1933
+ if (!lazyObserver(_performance, _observer))
1934
+ return;
1935
+ if (!onMatch(_performance, name, callback, _performance)) {
1936
+ if (perfs.callbacks.size < 1)
1937
+ perfs.observer.observe({ entryTypes: ["resource", "measure"] });
1938
+ perfs.callbacks.set(name, callback);
1939
+ }
1940
+ }
1941
+ };
1942
+
1943
+ var middlewareHelper = function (middlewares) { return function (fetchFunction) {
1944
+ return (middlewares.length === 0 ?
1945
+ fetchFunction :
1946
+ middlewares.length === 1 ?
1947
+ middlewares[0](fetchFunction) :
1948
+ middlewares.reduceRight(function (acc, curr, idx) {
1949
+ return (idx === middlewares.length - 2) ? curr(acc(fetchFunction)) : curr(acc);
1950
+ }));
1951
+ }; };
1952
+
1953
+ var WretchErrorWrapper = /** @class */ (function () {
1954
+ function WretchErrorWrapper(error) {
1955
+ this.error = error;
1956
+ }
1957
+ return WretchErrorWrapper;
1958
+ }());
1959
+ var resolver = function (wretcher) {
1960
+ var url = wretcher._url, _catchers = wretcher._catchers, resolvers = wretcher._resolvers, middlewares = wretcher._middlewares, opts = wretcher._options;
1961
+ var catchers = new Map(_catchers);
1962
+ var finalOptions = mix(config.defaults, opts);
1963
+ var fetchController = config.polyfill("AbortController", { doThrow: false, instance: true });
1964
+ if (!finalOptions["signal"] && fetchController) {
1965
+ finalOptions["signal"] = fetchController.signal;
1966
+ }
1967
+ // Request timeout
1968
+ var timeout = {
1969
+ ref: null,
1970
+ clear: function () {
1971
+ if (timeout.ref) {
1972
+ clearTimeout(timeout.ref);
1973
+ timeout.ref = null;
1974
+ }
1975
+ }
1976
+ };
1977
+ // The generated fetch request
1978
+ var fetchRequest = middlewareHelper(middlewares)(config.polyfill("fetch"))(url, finalOptions);
1979
+ // Throws on an http error
1980
+ var throwingPromise = fetchRequest
1981
+ .catch(function (error) {
1982
+ throw new WretchErrorWrapper(error);
1983
+ })
1984
+ .then(function (response) {
1985
+ timeout.clear();
1986
+ if (!response.ok) {
1987
+ return response[config.errorType || "text"]().then(function (msg) {
1988
+ // Enhances the error object
1989
+ var err = new Error(msg);
1990
+ err[config.errorType || "text"] = msg;
1991
+ err["status"] = response.status;
1992
+ err["response"] = response;
1993
+ throw err;
1994
+ });
1995
+ }
1996
+ return response;
1997
+ });
1998
+ // Wraps the Promise in order to dispatch the error to a matching catcher
1999
+ var catchersWrapper = function (promise) {
2000
+ return promise.catch(function (err) {
2001
+ timeout.clear();
2002
+ var error = err instanceof WretchErrorWrapper ? err.error : err;
2003
+ if (err instanceof WretchErrorWrapper && catchers.has("__fromFetch"))
2004
+ return catchers.get("__fromFetch")(error, wretcher);
2005
+ else if (catchers.has(error.status))
2006
+ return catchers.get(error.status)(error, wretcher);
2007
+ else if (catchers.has(error.name))
2008
+ return catchers.get(error.name)(error, wretcher);
2009
+ else
2010
+ throw error;
2011
+ });
2012
+ };
2013
+ var bodyParser = function (funName) { return function (cb) { return funName ?
2014
+ // If a callback is provided, then callback with the body result otherwise return the parsed body itself.
2015
+ catchersWrapper(throwingPromise.then(function (_) { return _ && _[funName](); }).then(function (_) { return cb ? cb(_) : _; })) :
2016
+ // No body parsing method - return the response
2017
+ catchersWrapper(throwingPromise.then(function (_) { return cb ? cb(_) : _; })); }; };
2018
+ var responseChain = {
2019
+ /**
2020
+ * Retrieves the raw result as a promise.
2021
+ */
2022
+ res: bodyParser(null),
2023
+ /**
2024
+ * Retrieves the result as a parsed JSON object.
2025
+ */
2026
+ json: bodyParser("json"),
2027
+ /**
2028
+ * Retrieves the result as a Blob object.
2029
+ */
2030
+ blob: bodyParser("blob"),
2031
+ /**
2032
+ * Retrieves the result as a FormData object.
2033
+ */
2034
+ formData: bodyParser("formData"),
2035
+ /**
2036
+ * Retrieves the result as an ArrayBuffer object.
2037
+ */
2038
+ arrayBuffer: bodyParser("arrayBuffer"),
2039
+ /**
2040
+ * Retrieves the result as a string.
2041
+ */
2042
+ text: bodyParser("text"),
2043
+ /**
2044
+ * Performs a callback on the API performance timings of the request.
2045
+ *
2046
+ * Warning: Still experimental on browsers and node.js
2047
+ */
2048
+ perfs: function (cb) {
2049
+ fetchRequest.then(function (res) { return perfs.observe(res.url, cb); });
2050
+ return responseChain;
2051
+ },
2052
+ /**
2053
+ * Aborts the request after a fixed time.
2054
+ *
2055
+ * @param time Time in milliseconds
2056
+ * @param controller A custom controller
2057
+ */
2058
+ setTimeout: function (time, controller) {
2059
+ if (controller === void 0) { controller = fetchController; }
2060
+ timeout.clear();
2061
+ timeout.ref = setTimeout(function () { return controller.abort(); }, time);
2062
+ return responseChain;
2063
+ },
2064
+ /**
2065
+ * Returns the automatically generated AbortController alongside the current wretch response as a pair.
2066
+ */
2067
+ controller: function () { return [fetchController, responseChain]; },
2068
+ /**
2069
+ * Catches an http response with a specific error code or name and performs a callback.
2070
+ */
2071
+ error: function (errorId, cb) {
2072
+ catchers.set(errorId, cb);
2073
+ return responseChain;
2074
+ },
2075
+ /**
2076
+ * Catches a bad request (http code 400) and performs a callback.
2077
+ */
2078
+ badRequest: function (cb) { return responseChain.error(400, cb); },
2079
+ /**
2080
+ * Catches an unauthorized request (http code 401) and performs a callback.
2081
+ */
2082
+ unauthorized: function (cb) { return responseChain.error(401, cb); },
2083
+ /**
2084
+ * Catches a forbidden request (http code 403) and performs a callback.
2085
+ */
2086
+ forbidden: function (cb) { return responseChain.error(403, cb); },
2087
+ /**
2088
+ * Catches a "not found" request (http code 404) and performs a callback.
2089
+ */
2090
+ notFound: function (cb) { return responseChain.error(404, cb); },
2091
+ /**
2092
+ * Catches a timeout (http code 408) and performs a callback.
2093
+ */
2094
+ timeout: function (cb) { return responseChain.error(408, cb); },
2095
+ /**
2096
+ * Catches an internal server error (http code 500) and performs a callback.
2097
+ */
2098
+ internalError: function (cb) { return responseChain.error(500, cb); },
2099
+ /**
2100
+ * Catches errors thrown when calling the fetch function and performs a callback.
2101
+ */
2102
+ fetchError: function (cb) { return responseChain.error("__fromFetch", cb); },
2103
+ /**
2104
+ * Catches an AbortError and performs a callback.
2105
+ */
2106
+ onAbort: function (cb) { return responseChain.error("AbortError", cb); }
2107
+ };
2108
+ return resolvers.reduce(function (chain, r) { return r(chain, wretcher); }, responseChain);
2109
+ };
2110
+
2111
+ var __assign$1 = (undefined && undefined.__assign) || function () {
2112
+ __assign$1 = Object.assign || function(t) {
2113
+ for (var s, i = 1, n = arguments.length; i < n; i++) {
2114
+ s = arguments[i];
2115
+ for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2116
+ t[p] = s[p];
2117
+ }
2118
+ return t;
2119
+ };
2120
+ return __assign$1.apply(this, arguments);
2121
+ };
2122
+ var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () {
2123
+ for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
2124
+ for (var r = Array(s), k = 0, i = 0; i < il; i++)
2125
+ for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2126
+ r[k] = a[j];
2127
+ return r;
2128
+ };
2129
+ var JSON_MIME = "application/json";
2130
+ var CONTENT_TYPE_HEADER = "Content-Type";
2131
+ /**
2132
+ * The Wretcher class used to perform easy fetch requests.
2133
+ *
2134
+ * Immutability : almost every method of this class return a fresh Wretcher object.
2135
+ */
2136
+ var Wretcher = /** @class */ (function () {
2137
+ function Wretcher(_url, _options, _catchers, _resolvers, _middlewares, _deferredChain) {
2138
+ if (_catchers === void 0) { _catchers = new Map(); }
2139
+ if (_resolvers === void 0) { _resolvers = []; }
2140
+ if (_middlewares === void 0) { _middlewares = []; }
2141
+ if (_deferredChain === void 0) { _deferredChain = []; }
2142
+ this._url = _url;
2143
+ this._options = _options;
2144
+ this._catchers = _catchers;
2145
+ this._resolvers = _resolvers;
2146
+ this._middlewares = _middlewares;
2147
+ this._deferredChain = _deferredChain;
2148
+ }
2149
+ Wretcher.factory = function (url, options) {
2150
+ if (url === void 0) { url = ""; }
2151
+ if (options === void 0) { options = {}; }
2152
+ return new Wretcher(url, options);
2153
+ };
2154
+ Wretcher.prototype.selfFactory = function (_a) {
2155
+ 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;
2156
+ return new Wretcher(url, __assign$1({}, options), new Map(catchers), __spreadArrays$2(resolvers), __spreadArrays$2(middlewares), __spreadArrays$2(deferredChain));
2157
+ };
2158
+ /**
2159
+ * Sets the default fetch options used for every subsequent fetch call.
2160
+ * @param options New default options
2161
+ * @param mixin If true, mixes in instead of replacing the existing options
2162
+ */
2163
+ Wretcher.prototype.defaults = function (options, mixin) {
2164
+ if (mixin === void 0) { mixin = false; }
2165
+ config.defaults = mixin ? mix(config.defaults, options) : options;
2166
+ return this;
2167
+ };
2168
+ /**
2169
+ * Sets the method (text, json ...) used to parse the data contained in the response body in case of an HTTP error.
2170
+ *
2171
+ * Persists for every subsequent requests.
2172
+ *
2173
+ * Default is "text".
2174
+ */
2175
+ Wretcher.prototype.errorType = function (method) {
2176
+ config.errorType = method;
2177
+ return this;
2178
+ };
2179
+ /**
2180
+ * Sets the non-global polyfills which will be used for every subsequent calls.
2181
+ *
2182
+ * Needed for libraries like [fetch-ponyfill](https://github.com/qubyte/fetch-ponyfill).
2183
+ *
2184
+ * @param polyfills An object containing the polyfills.
2185
+ */
2186
+ Wretcher.prototype.polyfills = function (polyfills) {
2187
+ config.polyfills = __assign$1(__assign$1({}, config.polyfills), polyfills);
2188
+ return this;
2189
+ };
2190
+ /**
2191
+ * Returns a new Wretcher object with the argument url appended and the same options.
2192
+ * @param url String url
2193
+ * @param replace Boolean If true, replaces the current url instead of appending
2194
+ */
2195
+ Wretcher.prototype.url = function (url, replace) {
2196
+ if (replace === void 0) { replace = false; }
2197
+ if (replace)
2198
+ return this.selfFactory({ url: url });
2199
+ var split = this._url.split("?");
2200
+ return this.selfFactory({
2201
+ url: split.length > 1 ?
2202
+ split[0] + url + "?" + split[1] :
2203
+ this._url + url
2204
+ });
2205
+ };
2206
+ /**
2207
+ * Returns a new Wretcher object with the same url and new options.
2208
+ * @param options New options
2209
+ * @param mixin If true, mixes in instead of replacing the existing options
2210
+ */
2211
+ Wretcher.prototype.options = function (options, mixin) {
2212
+ if (mixin === void 0) { mixin = true; }
2213
+ return this.selfFactory({ options: mixin ? mix(this._options, options) : options });
2214
+ };
2215
+ /**
2216
+ * Converts a javascript object to query parameters,
2217
+ * then appends this query string to the current url.
2218
+ *
2219
+ * If given a string, use the string as the query verbatim.
2220
+ *
2221
+ * ```
2222
+ * let w = wretch("http://example.com") // url is http://example.com
2223
+ *
2224
+ * // Chain query calls
2225
+ * w = w.query({ a: 1, b : 2 }) // url is now http://example.com?a=1&b=2
2226
+ * w = w.query("foo-bar-baz-woz") // url is now http://example.com?a=1&b=2&foo-bar-baz-woz
2227
+ *
2228
+ * // Pass true as the second argument to replace existing query parameters
2229
+ * w = w.query("c=3&d=4", true) // url is now http://example.com?c=3&d=4
2230
+ * ```
2231
+ *
2232
+ * @param qp An object which will be converted, or a string which will be used verbatim.
2233
+ */
2234
+ Wretcher.prototype.query = function (qp, replace) {
2235
+ if (replace === void 0) { replace = false; }
2236
+ return this.selfFactory({ url: appendQueryParams(this._url, qp, replace) });
2237
+ };
2238
+ /**
2239
+ * Set request headers.
2240
+ * @param headerValues An object containing header keys and values
2241
+ */
2242
+ Wretcher.prototype.headers = function (headerValues) {
2243
+ return this.selfFactory({ options: mix(this._options, { headers: headerValues || {} }) });
2244
+ };
2245
+ /**
2246
+ * Shortcut to set the "Accept" header.
2247
+ * @param headerValue Header value
2248
+ */
2249
+ Wretcher.prototype.accept = function (headerValue) {
2250
+ return this.headers({ Accept: headerValue });
2251
+ };
2252
+ /**
2253
+ * Shortcut to set the "Content-Type" header.
2254
+ * @param headerValue Header value
2255
+ */
2256
+ Wretcher.prototype.content = function (headerValue) {
2257
+ var _a;
2258
+ return this.headers((_a = {}, _a[CONTENT_TYPE_HEADER] = headerValue, _a));
2259
+ };
2260
+ /**
2261
+ * Shortcut to set the "Authorization" header.
2262
+ * @param headerValue Header value
2263
+ */
2264
+ Wretcher.prototype.auth = function (headerValue) {
2265
+ return this.headers({ Authorization: headerValue });
2266
+ };
2267
+ /**
2268
+ * Adds a default catcher which will be called on every subsequent request error when the error code matches.
2269
+ * @param errorId Error code or name
2270
+ * @param catcher: The catcher method
2271
+ */
2272
+ Wretcher.prototype.catcher = function (errorId, catcher) {
2273
+ var newMap = new Map(this._catchers);
2274
+ newMap.set(errorId, catcher);
2275
+ return this.selfFactory({ catchers: newMap });
2276
+ };
2277
+ /**
2278
+ * Associates a custom signal with the request.
2279
+ * @param controller : An AbortController
2280
+ */
2281
+ Wretcher.prototype.signal = function (controller) {
2282
+ return this.selfFactory({ options: __assign$1(__assign$1({}, this._options), { signal: controller.signal }) });
2283
+ };
2284
+ /**
2285
+ * Program a resolver to perform response chain tasks automatically.
2286
+ * @param doResolve : Resolver callback
2287
+ */
2288
+ Wretcher.prototype.resolve = function (doResolve, clear) {
2289
+ if (clear === void 0) { clear = false; }
2290
+ return this.selfFactory({ resolvers: clear ? [doResolve] : __spreadArrays$2(this._resolvers, [doResolve]) });
2291
+ };
2292
+ /**
2293
+ * Defer wretcher methods that will be chained and called just before the request is performed.
2294
+ */
2295
+ Wretcher.prototype.defer = function (callback, clear) {
2296
+ if (clear === void 0) { clear = false; }
2297
+ return this.selfFactory({
2298
+ deferredChain: clear ? [callback] : __spreadArrays$2(this._deferredChain, [callback])
2299
+ });
2300
+ };
2301
+ /**
2302
+ * Add middlewares to intercept a request before being sent.
2303
+ */
2304
+ Wretcher.prototype.middlewares = function (middlewares, clear) {
2305
+ if (clear === void 0) { clear = false; }
2306
+ return this.selfFactory({
2307
+ middlewares: clear ? middlewares : __spreadArrays$2(this._middlewares, middlewares)
2308
+ });
2309
+ };
2310
+ Wretcher.prototype.method = function (method, options, body) {
2311
+ if (options === void 0) { options = {}; }
2312
+ if (body === void 0) { body = null; }
2313
+ var headers = this._options.headers;
2314
+ var baseWretcher = !body ? this :
2315
+ typeof body === "object" && (!headers ||
2316
+ Object.entries(headers).every(function (_a) {
2317
+ var k = _a[0], v = _a[1];
2318
+ return k.toLowerCase() !== CONTENT_TYPE_HEADER.toLowerCase() ||
2319
+ v.startsWith(JSON_MIME);
2320
+ })) ? this.json(body) :
2321
+ this.body(body);
2322
+ baseWretcher = baseWretcher.options(__assign$1(__assign$1({}, options), { method: method }));
2323
+ var deferredWretcher = baseWretcher._deferredChain.reduce(function (acc, curr) { return curr(acc, acc._url, acc._options); }, baseWretcher);
2324
+ return resolver(deferredWretcher);
2325
+ };
2326
+ /**
2327
+ * Performs a get request.
2328
+ */
2329
+ Wretcher.prototype.get = function (options) {
2330
+ return this.method("GET", options);
2331
+ };
2332
+ /**
2333
+ * Performs a delete request.
2334
+ */
2335
+ Wretcher.prototype.delete = function (options) {
2336
+ return this.method("DELETE", options);
2337
+ };
2338
+ /**
2339
+ * Performs a put request.
2340
+ */
2341
+ Wretcher.prototype.put = function (body, options) {
2342
+ return this.method("PUT", options, body);
2343
+ };
2344
+ /**
2345
+ * Performs a post request.
2346
+ */
2347
+ Wretcher.prototype.post = function (body, options) {
2348
+ return this.method("POST", options, body);
2349
+ };
2350
+ /**
2351
+ * Performs a patch request.
2352
+ */
2353
+ Wretcher.prototype.patch = function (body, options) {
2354
+ return this.method("PATCH", options, body);
2355
+ };
2356
+ /**
2357
+ * Performs a head request.
2358
+ */
2359
+ Wretcher.prototype.head = function (options) {
2360
+ return this.method("HEAD", options);
2361
+ };
2362
+ /**
2363
+ * Performs an options request
2364
+ */
2365
+ Wretcher.prototype.opts = function (options) {
2366
+ return this.method("OPTIONS", options);
2367
+ };
2368
+ /**
2369
+ * Replay a request.
2370
+ */
2371
+ Wretcher.prototype.replay = function (options) {
2372
+ return this.method(this._options.method, options);
2373
+ };
2374
+ /**
2375
+ * Sets the request body with any content.
2376
+ * @param contents The body contents
2377
+ */
2378
+ Wretcher.prototype.body = function (contents) {
2379
+ return this.selfFactory({ options: __assign$1(__assign$1({}, this._options), { body: contents }) });
2380
+ };
2381
+ /**
2382
+ * Sets the content type header, stringifies an object and sets the request body.
2383
+ * @param jsObject An object which will be serialized into a JSON
2384
+ */
2385
+ Wretcher.prototype.json = function (jsObject) {
2386
+ var _a;
2387
+ var preservedContentType = (_a = Object.entries(this._options.headers || {}).find(function (_a) {
2388
+ var k = _a[0], v = _a[1];
2389
+ return k.toLowerCase() === CONTENT_TYPE_HEADER.toLowerCase() && v.startsWith(JSON_MIME);
2390
+ })) === null || _a === void 0 ? void 0 : _a[1];
2391
+ return this.content(preservedContentType || JSON_MIME).body(JSON.stringify(jsObject));
2392
+ };
2393
+ /**
2394
+ * Converts the javascript object to a FormData and sets the request body.
2395
+ * @param formObject An object which will be converted to a FormData
2396
+ * @param recursive If `true`, will recurse through all nested objects
2397
+ * Can be set as an array of string to exclude specific keys.
2398
+ * See https://github.com/elbywan/wretch/issues/68 for more details.
2399
+ */
2400
+ Wretcher.prototype.formData = function (formObject, recursive) {
2401
+ if (recursive === void 0) { recursive = false; }
2402
+ return this.body(convertFormData(formObject, recursive));
2403
+ };
2404
+ /**
2405
+ * Converts the input to an url encoded string and sets the content-type header and body.
2406
+ * If the input argument is already a string, skips the conversion part.
2407
+ *
2408
+ * @param input An object to convert into an url encoded string or an already encoded string
2409
+ */
2410
+ Wretcher.prototype.formUrl = function (input) {
2411
+ return this
2412
+ .body(typeof input === "string" ? input : convertFormUrl(input))
2413
+ .content("application/x-www-form-urlencoded");
2414
+ };
2415
+ return Wretcher;
2416
+ }());
2417
+ // Internal helpers
2418
+ var appendQueryParams = function (url, qp, replace) {
2419
+ var queryString;
2420
+ if (typeof qp === "string") {
2421
+ queryString = qp;
2422
+ }
2423
+ else {
2424
+ var usp = config.polyfill("URLSearchParams", { instance: true });
2425
+ for (var key in qp) {
2426
+ if (qp[key] instanceof Array) {
2427
+ for (var _i = 0, _a = qp[key]; _i < _a.length; _i++) {
2428
+ var val = _a[_i];
2429
+ usp.append(key, val);
2430
+ }
2431
+ }
2432
+ else {
2433
+ usp.append(key, qp[key]);
2434
+ }
2435
+ }
2436
+ queryString = usp.toString();
2437
+ }
2438
+ var split = url.split("?");
2439
+ if (replace || split.length < 2)
2440
+ return split[0] + "?" + queryString;
2441
+ return url + "&" + queryString;
2442
+ };
2443
+ function convertFormData(formObject, recursive, formData, ancestors) {
2444
+ if (recursive === void 0) { recursive = false; }
2445
+ if (formData === void 0) { formData = config.polyfill("FormData", { instance: true }); }
2446
+ if (ancestors === void 0) { ancestors = []; }
2447
+ Object.entries(formObject).forEach(function (_a) {
2448
+ var key = _a[0], value = _a[1];
2449
+ var formKey = ancestors.reduce(function (acc, ancestor) { return (acc ? acc + "[" + ancestor + "]" : ancestor); }, null);
2450
+ formKey = formKey ? formKey + "[" + key + "]" : key;
2451
+ if (value instanceof Array) {
2452
+ for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
2453
+ var item = value_1[_i];
2454
+ formData.append(formKey + "[]", item);
2455
+ }
2456
+ }
2457
+ else if (recursive &&
2458
+ typeof value === "object" &&
2459
+ (!(recursive instanceof Array) ||
2460
+ !recursive.includes(key))) {
2461
+ if (value !== null) {
2462
+ convertFormData(value, recursive, formData, __spreadArrays$2(ancestors, [key]));
2463
+ }
2464
+ }
2465
+ else {
2466
+ formData.append(formKey, value);
2467
+ }
2468
+ });
2469
+ return formData;
2470
+ }
2471
+ function encodeQueryValue(key, value) {
2472
+ return encodeURIComponent(key) +
2473
+ "=" +
2474
+ encodeURIComponent(typeof value === "object" ?
2475
+ JSON.stringify(value) :
2476
+ "" + value);
2477
+ }
2478
+ function convertFormUrl(formObject) {
2479
+ return Object.keys(formObject)
2480
+ .map(function (key) {
2481
+ var value = formObject[key];
2482
+ if (value instanceof Array) {
2483
+ return value.map(function (v) { return encodeQueryValue(key, v); }).join("&");
2484
+ }
2485
+ return encodeQueryValue(key, value);
2486
+ })
2487
+ .join("&");
2488
+ }
2489
+
2490
+ var factory = Wretcher.factory;
2491
+ factory["default"] = Wretcher.factory;
2492
+
2493
+ function buildBackendApiClient() {
2494
+ const jwt = superSelectionAppService.jwt;
2495
+ const profileId = superSelectionAppService.profileId;
2496
+ const accountId = superSelectionAppService.accountIdOrDefault;
2497
+ const partnerId = superSelectionAppService.partnerIdOrDefault;
2498
+ return factory(superSelectionAppService.apiBaseUrl).headers({
2499
+ Authorization: `Bearer ${jwt}`,
2500
+ 'X-PROFILE-ID': profileId,
2501
+ 'X-PARTNER-ID': partnerId,
2502
+ 'X-ACCOUNT-ID': accountId
2503
+ });
2504
+ }
2505
+
2506
+ const slate = {
2507
+ fundId: 'slate',
2508
+ usi: '32367272075001'
2509
+ };
2510
+
2511
+ function hydratePromotedFundChoiceDtoKind(dto) {
2512
+ if ('slate' in dto) {
2513
+ dto.kind = 'slate';
2514
+ }
2515
+ else if ('australianRetirementTrust' in dto) {
2516
+ dto.kind = 'australianRetirementTrust';
2517
+ }
2518
+ else if ('aware' in dto) {
2519
+ dto.kind = 'aware';
2520
+ }
2521
+ else if ('active' in dto) {
2522
+ dto.kind = 'active';
2523
+ }
2524
+ else if ('australianEthical' in dto) {
2525
+ dto.kind = 'australianEthical';
2526
+ }
2527
+ else if ('virgin' in dto) {
2528
+ dto.kind = 'virgin';
2529
+ }
2530
+ else if ('spirit' in dto) {
2531
+ dto.kind = 'spirit';
2532
+ }
2533
+ else if ('firstSuper' in dto) {
2534
+ dto.kind = 'firstSuper';
2535
+ }
2536
+ else if ('mercerMyChoice' in dto) {
2537
+ dto.kind = 'mercerMyChoice';
2538
+ }
2539
+ else if ('generic' in dto) {
2540
+ dto.kind = 'generic';
2541
+ }
2542
+ }
2543
+ function getPromotedFundUsi(dto) {
2544
+ switch (dto.kind) {
2545
+ case 'slate':
2546
+ return slate.usi;
2547
+ case 'australianRetirementTrust':
2548
+ return dto.australianRetirementTrust.usi;
2549
+ case 'aware':
2550
+ return dto.aware.usi;
2551
+ case 'active':
2552
+ return dto.active.usi;
2553
+ case 'australianEthical':
2554
+ return dto.australianEthical.usi;
2555
+ case 'virgin':
2556
+ return dto.virgin.usi;
2557
+ case 'spirit':
2558
+ return dto.spirit.usi;
2559
+ case 'firstSuper':
2560
+ return dto.firstSuper.usi;
2561
+ case 'mercerMyChoice':
2562
+ return dto.mercerMyChoice.usi;
2563
+ case 'generic':
2564
+ return dto.generic.usi;
2565
+ default:
2566
+ return '';
2567
+ }
2568
+ }
2569
+ function getPromotedFundId(dto) {
2570
+ switch (dto.kind) {
2571
+ case 'slate':
2572
+ return slate.fundId;
2573
+ case 'australianRetirementTrust':
2574
+ return 'australian-retirement-trust';
2575
+ case 'aware':
2576
+ return 'aware';
2577
+ case 'active':
2578
+ return 'active';
2579
+ case 'australianEthical':
2580
+ return 'australian-ethical';
2581
+ case 'virgin':
2582
+ return 'virgin';
2583
+ case 'spirit':
2584
+ return 'spirit';
2585
+ case 'firstSuper':
2586
+ return 'first-super';
2587
+ case 'mercerMyChoice':
2588
+ return 'mercermychoice';
2589
+ case 'generic':
2590
+ return dto.generic.fundId;
2591
+ default:
2592
+ return '';
2593
+ }
2594
+ }
2595
+ function getSuperChoiceUsi(dto) {
2596
+ switch (dto.kind) {
2597
+ case 'Promoted':
2598
+ return some(getPromotedFundUsi(dto.promoted));
2599
+ case 'MyOwnFund':
2600
+ return some(dto.myOwnFund.usi);
2601
+ case 'SMSF':
2602
+ return none;
2603
+ case 'Default':
2604
+ return some(dto.default.usi);
2605
+ case 'PromotedDefault':
2606
+ return some(dto.promotedDefault.usi);
2607
+ case 'DefinedBenefits':
2608
+ return some(dto.definedBenefits.usi);
2609
+ case 'PromotedDefaultWithJoin':
2610
+ return some(dto.promotedDefaultWithJoin.usi);
2611
+ default:
2612
+ return none;
2613
+ }
2614
+ }
2615
+ function getPromotedFundMemberNumber(dto) {
2616
+ switch (dto.kind) {
2617
+ case 'slate':
2618
+ return dto.slate.memberNumber;
2619
+ case 'australianRetirementTrust':
2620
+ return dto.australianRetirementTrust.memberNumber;
2621
+ case 'aware':
2622
+ return dto.aware.memberNumber;
2623
+ case 'active':
2624
+ return dto.active.memberNumber;
2625
+ case 'australianEthical':
2626
+ return dto.australianEthical.memberNumber;
2627
+ case 'virgin':
2628
+ return dto.virgin.memberNumber;
2629
+ case 'spirit':
2630
+ return dto.spirit.memberNumber;
2631
+ case 'firstSuper':
2632
+ return dto.firstSuper.memberNumber;
2633
+ case 'mercerMyChoice':
2634
+ return dto.mercerMyChoice.memberNumber;
2635
+ case 'generic':
2636
+ return dto.generic.memberNumber;
2637
+ default:
2638
+ return '';
2639
+ }
2640
+ }
2641
+ function getSuperChoiceMemberNumber(dto) {
2642
+ switch (dto.kind) {
2643
+ case 'Promoted':
2644
+ return some(getPromotedFundMemberNumber(dto.promoted));
2645
+ case 'MyOwnFund':
2646
+ return some(dto.myOwnFund.memberNumber);
2647
+ case 'DefinedBenefits':
2648
+ return some(dto.definedBenefits.memberNumber);
2649
+ case 'PromotedDefaultWithJoin':
2650
+ return some(dto.promotedDefaultWithJoin.memberNumber);
2651
+ case 'SMSF':
2652
+ case 'Default':
2653
+ case 'PromotedDefault':
2654
+ return none;
2655
+ default:
2656
+ return none;
2657
+ }
2658
+ }
2659
+ function hydrateSuperChoiceDetailsDtoKind(dto) {
2660
+ if ('promoted' in dto) {
2661
+ dto.kind = 'Promoted';
2662
+ }
2663
+ else if ('myOwnFund' in dto) {
2664
+ dto.kind = 'MyOwnFund';
2665
+ }
2666
+ else if ('smsf' in dto) {
2667
+ dto.kind = 'SMSF';
2668
+ }
2669
+ else if ('default' in dto) {
2670
+ dto.kind = 'Default';
2671
+ }
2672
+ else if ('promotedDefault' in dto) {
2673
+ dto.kind = 'PromotedDefault';
2674
+ }
2675
+ else if ('definedBenefits' in dto) {
2676
+ dto.kind = 'DefinedBenefits';
2677
+ }
2678
+ else if ('promotedDefaultWithJoin' in dto) {
2679
+ dto.kind = 'PromotedDefaultWithJoin';
2680
+ }
2681
+ }
2682
+
2683
+ class SuperSelectionApi {
2684
+ async getAustralianFundsAsync(searchFilter, includeInactive = false) {
2685
+ return buildBackendApiClient()
2686
+ .url(`super-choice/australian-funds-v2?${this.toQueryString(includeInactive, searchFilter)}`)
2687
+ .get()
2688
+ .notFound(() => {
2689
+ throw new Error('Failed to fetch the list of australian super funds.');
2690
+ })
2691
+ .json();
2692
+ }
2693
+ async getAustralianFundAsync(usi, includeInactive) {
2694
+ const queryStr = includeInactive ? '?includeInactive=true' : '';
2695
+ return buildBackendApiClient()
2696
+ .url(`super-choice/australian-funds/${usi}${queryStr}`)
2697
+ .get()
2698
+ .notFound(() => {
2699
+ throw new Error('Failed to fetch australian super fund.');
2700
+ })
2701
+ .json();
2702
+ }
2703
+ async getAppStateAsync() {
2704
+ var _a;
2705
+ const response = await buildBackendApiClient()
2706
+ .url('client-app-state')
2707
+ .get()
2708
+ .notFound(() => {
2709
+ throw new Error('Failed to fetch application configuration.');
2710
+ })
2711
+ .json();
2712
+ if ((_a = response.superBuyer.superChoice) === null || _a === void 0 ? void 0 : _a.choiceDetails) {
2713
+ hydrateSuperChoiceDetailsDtoKind(response.superBuyer.superChoice.choiceDetails);
2714
+ switch (response.superBuyer.superChoice.choiceDetails.kind) {
2715
+ case 'Promoted':
2716
+ hydratePromotedFundChoiceDtoKind(response.superBuyer.superChoice.choiceDetails.promoted);
2717
+ break;
2718
+ }
2719
+ }
2720
+ return response;
2721
+ }
2722
+ async clickPromotedTileAsync(payload) {
2723
+ return buildBackendApiClient().url('click-promoted-tile').post(payload).res();
2724
+ }
2725
+ async viewSuperFundPanelAsync(payload) {
2726
+ return buildBackendApiClient().url('view-super-fund-panel').post(payload).res();
2727
+ }
2728
+ toSearchFilterQueryString(searchFilter) {
2729
+ return (`search=${searchFilter.searchString}` +
2730
+ (searchFilter.maxRecordCount > 0 ? '&maxRecordCount=' + searchFilter.maxRecordCount : ''));
2731
+ }
2732
+ toQueryString(includeInactive, searchFilter) {
2733
+ const search = this.toSearchFilterQueryString(searchFilter);
2734
+ const inactive = includeInactive ? 'includeInactive=true' : '';
2735
+ const isNotEmpty = (s) => s && s.length;
2736
+ return [search, inactive].filter(isNotEmpty).join('&');
2737
+ }
2738
+ }
2739
+ const superSelectionApi = new SuperSelectionApi();
2740
+
2741
+ (function (SuperCampaignComponentStatus) {
2742
+ SuperCampaignComponentStatus[SuperCampaignComponentStatus["NotLoaded"] = 1] = "NotLoaded";
2743
+ SuperCampaignComponentStatus[SuperCampaignComponentStatus["Loaded"] = 2] = "Loaded";
2744
+ SuperCampaignComponentStatus[SuperCampaignComponentStatus["NotWorking"] = 3] = "NotWorking";
2745
+ })(exports.SuperCampaignComponentStatus || (exports.SuperCampaignComponentStatus = {}));
2746
+ class SuperCampaignState {
2747
+ constructor() {
2748
+ this._promotedFundsShown = [];
2749
+ }
2750
+ get PromotedFundIds() {
2751
+ return this._promotedFundsShown.map((p) => p.fundId);
2752
+ }
2753
+ set promotedFundsShown(value) {
2754
+ this._promotedFundsShown = value;
2755
+ }
2756
+ get DefaultFundPosition() {
2757
+ const index = this._promotedFundsShown.findIndex((value) => value.fundType === 'promoted-default');
2758
+ if (index === -1)
2759
+ return undefined;
2760
+ return index + 1;
2761
+ }
2762
+ }
2763
+ const initialState = {
2764
+ apiBaseUrl: Option.none,
2765
+ appBaseUrl: Option.none,
2766
+ profileId: Option.none,
2767
+ jwt: Option.none,
2768
+ superBuyer: Option.none,
2769
+ superChoicePrefill: Option.none,
2770
+ promotedFunds: Option.none,
2771
+ accountConfiguration: Option.none,
2772
+ profileConfiguration: Option.none,
2773
+ hasSuccessPageBeenAcknowledged: false,
2774
+ hasSuperSelectionBeenSubmitted: false,
2775
+ isDefinedBenefitsEligible: Option.none,
2776
+ superCampaignEnabled: true,
2777
+ superCampaignState: undefined,
2778
+ superCampaignComponentStatus: exports.SuperCampaignComponentStatus.NotLoaded,
2779
+ hideFooterSection: false,
2780
+ bringYourOwnFundCustomStepEnabled: false,
2781
+ smsfCustomStepEnabled: false,
2782
+ featuredFundsEnabled: false
2783
+ };
2784
+
2785
+ class SuperSelectionAppService {
2786
+ constructor() {
2787
+ const { state, onChange } = createStore(initialState);
2788
+ this._state = state;
2789
+ this._onChange = onChange;
2790
+ onChange('jwt', (jwt) => {
2791
+ this._state.profileId = _function.pipe(jwt, Option.chain((jwtValue) => Option.fromNullable(o(jwtValue).sub)));
2792
+ });
2793
+ }
2794
+ get state() {
2795
+ return this._state;
2796
+ }
2797
+ get onChange() {
2798
+ return this._onChange;
2799
+ }
2800
+ get superBuyer() {
2801
+ if (Option.isNone(this._state.superBuyer)) {
2802
+ throw Error('User information is not set');
2803
+ }
2804
+ return this._state.superBuyer.value;
2805
+ }
2806
+ get apiBaseUrl() {
2807
+ if (Option.isNone(this._state.apiBaseUrl)) {
2808
+ throw Error('API base URL is not set');
2809
+ }
2810
+ return this._state.apiBaseUrl.value;
2811
+ }
2812
+ get appBaseUrl() {
2813
+ if (Option.isNone(this._state.appBaseUrl)) {
2814
+ throw Error('App base URL is not set');
2815
+ }
2816
+ return this._state.appBaseUrl.value;
2817
+ }
2818
+ get promotedFunds() {
2819
+ if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
2820
+ return this.superCampaignState.PromotedFundIds;
2821
+ }
2822
+ if (Option.isNone(this._state.promotedFunds)) {
2823
+ throw Error('Promoted Funds is not set');
2824
+ }
2825
+ return this._state.promotedFunds.value;
2826
+ }
2827
+ get promotedDefaultFundPosition() {
2828
+ if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
2829
+ return Option.fromNullable(this.superCampaignState.DefaultFundPosition);
2830
+ }
2831
+ return Option.none;
2832
+ }
2833
+ get promotedFundsConfig() {
2834
+ return {
2835
+ shownFunds: this.promotedFunds,
2836
+ promotedDefaultFundPosition: Option.toUndefined(this.promotedDefaultFundPosition),
2837
+ promotedFundsConfigSource: this.isUsingSuperCampaign ? 'superCampaign' : 'superSelection'
2838
+ };
2839
+ }
2840
+ get profileId() {
2841
+ if (Option.isNone(this._state.profileId)) {
2842
+ throw Error('Failed to get Profile ID from JWT');
2843
+ }
2844
+ return this._state.profileId.value;
2845
+ }
2846
+ get defaultFundUsi() {
2847
+ const profileConfigDefaultFundUsi = _function.pipe(this._state.profileConfiguration, Option.map((config) => Option.fromNullable(config.defaultFundUsi)), Option.flatten);
2848
+ if (Option.isSome(profileConfigDefaultFundUsi)) {
2849
+ return profileConfigDefaultFundUsi;
2850
+ }
2851
+ return _function.pipe(this._state.accountConfiguration, Option.map((config) => Option.fromNullable(config.defaultFundUsi)), Option.flatten);
2852
+ }
2853
+ get accountIdOrDefault() {
2854
+ return _function.pipe(this._state.accountConfiguration, Option.map((config) => config.accountId), Option.getOrElse(() => ''));
2855
+ }
2856
+ get partnerIdOrDefault() {
2857
+ return _function.pipe(this._state.superBuyer, Option.map((superBuyer) => superBuyer.partnerId), Option.getOrElse(() => ''));
2858
+ }
2859
+ get jwt() {
2860
+ if (Option.isNone(this._state.jwt)) {
2861
+ throw Error('No authentication information was found');
2862
+ }
2863
+ return this._state.jwt.value;
2864
+ }
2865
+ completeSuperSelectionFlow() {
2866
+ this._state.hasSuccessPageBeenAcknowledged = true;
2867
+ }
2868
+ markSuperSelectionAsSubmitted() {
2869
+ this._state.hasSuperSelectionBeenSubmitted = true;
2870
+ }
2871
+ get isDefinedBenefitsEligible() {
2872
+ return this._state.isDefinedBenefitsEligible;
2873
+ }
2874
+ async loadAppStateAsync() {
2875
+ const appStateResponse = await superSelectionApi.getAppStateAsync();
2876
+ this._state.accountConfiguration = Option.fromNullable(appStateResponse.accountConfiguration);
2877
+ this._state.profileConfiguration = Option.fromNullable(appStateResponse.profileConfiguration);
2878
+ this._state.superBuyer = Option.fromNullable(appStateResponse.superBuyer);
2879
+ this._state.promotedFunds = Option.fromNullable(appStateResponse.promotedFunds);
2880
+ this._state.bringYourOwnFundCustomStepEnabled =
2881
+ appStateResponse.bringYourOwnFundCustomStepEnabled;
2882
+ this._state.smsfCustomStepEnabled = appStateResponse.smsfCustomStepEnabled;
2883
+ this._state.featuredFundsEnabled = appStateResponse.featuredFundsEnabled;
2884
+ this._state.superChoicePrefill = Option.fromNullable(appStateResponse.prefill);
2885
+ this._state.isDefinedBenefitsEligible = Option.fromNullable(appStateResponse.isDefinedBenefitsEligible);
2886
+ if (Option.isSome(this._state.accountConfiguration)) {
2887
+ if (this._state.accountConfiguration.value.featureSet.type === 'basic') {
2888
+ this._state.superCampaignEnabled = false;
2889
+ }
2890
+ }
2891
+ }
2892
+ setSuperCampaignPromotedFundsShown(shownFunds) {
2893
+ if (this._state.superCampaignState !== undefined)
2894
+ this._state.superCampaignState.promotedFundsShown = shownFunds;
2895
+ else
2896
+ throw new Error('Cannot set shown funds for SuperCampaing state because it is undefined');
2897
+ }
2898
+ viewSuperFundPanelAsync(placementId, promotedFundIdListOverride) {
2899
+ return superSelectionApi.viewSuperFundPanelAsync(Object.assign(Object.assign({}, this.promotedFundsConfig), { shownFunds: promotedFundIdListOverride
2900
+ ? promotedFundIdListOverride
2901
+ : this.promotedFundsConfig.shownFunds, placementId }));
2902
+ }
2903
+ get superCampaignState() {
2904
+ return this._state.superCampaignState;
2905
+ }
2906
+ get superCampaignComponentStatus() {
2907
+ return this._state.superCampaignComponentStatus;
2908
+ }
2909
+ set superCampaignComponentStatus(value) {
2910
+ if (value === exports.SuperCampaignComponentStatus.Loaded) {
2911
+ this._state.superCampaignComponentStatus = exports.SuperCampaignComponentStatus.Loaded;
2912
+ this._state.superCampaignState = new SuperCampaignState();
2913
+ }
2914
+ else {
2915
+ this._state.superCampaignComponentStatus = value;
2916
+ this._state.superCampaignState = undefined;
2917
+ }
2918
+ }
2919
+ get isUsingSuperCampaign() {
2920
+ return this.state.superCampaignEnabled && this.superCampaignState !== undefined;
2921
+ }
2922
+ get isBringYourOwnFundCustomStepEnabled() {
2923
+ return this.state.bringYourOwnFundCustomStepEnabled;
2924
+ }
2925
+ get isSmsfCustomStepEnabled() {
2926
+ return this.state.smsfCustomStepEnabled;
2927
+ }
2928
+ get isFeaturedFundsEnabled() {
2929
+ return this.state.featuredFundsEnabled;
2930
+ }
2931
+ get superCampaignCanNotBeActivated() {
2932
+ return (!this.state.superCampaignEnabled ||
2933
+ this.superCampaignComponentStatus === exports.SuperCampaignComponentStatus.NotWorking);
2934
+ }
2935
+ get hideFooterSection() {
2936
+ return this._state.hideFooterSection;
2937
+ }
2938
+ set hideFooterSection(value) {
2939
+ this._state.hideFooterSection = value;
2940
+ }
2941
+ get backendUrl() {
2942
+ return Option.map(this.getBaseUrl)(this.state.apiBaseUrl);
2943
+ }
2944
+ getBaseUrl(url) {
2945
+ const parsedUrl = new URL(url);
2946
+ return `${parsedUrl.protocol}//${parsedUrl.hostname}${parsedUrl.port.length > 0 ? `:${parsedUrl.port}` : ''}`;
2947
+ }
2948
+ }
2949
+ const superSelectionAppService = new SuperSelectionAppService();
2950
+
2951
+ class NavigationService {
2952
+ navigateInternally(history, route) {
2953
+ const path = `${this.appBaseUrl}${this.toRouteWithLeadingSlash(route)}`;
2954
+ iframe.navigation(path);
2955
+ history.push(path);
2956
+ }
2957
+ navigateInternallyToStandardChoice(options) {
2958
+ state.handleSubmitFn = options.handleSubmitFn;
2959
+ state.fundName = options.fundName;
2960
+ state.fundDetails = options.fundDetails;
2961
+ state.promotedFundId = options.promotedFundId;
2962
+ this.navigateInternally(options.history, exports.SuperSelectionAppRoutes.StandardChoice);
2963
+ }
2964
+ toExternalUrl(url) {
2965
+ const externalUrl = new URL(url);
2966
+ externalUrl.searchParams.append('_extnav', 'true');
2967
+ return externalUrl.href;
2968
+ }
2969
+ get appBaseUrl() {
2970
+ const baseUrl = superSelectionAppService.appBaseUrl;
2971
+ return baseUrl.replace(/\/$/, '');
2972
+ }
2973
+ toRouteWithLeadingSlash(route) {
2974
+ return route.length > 0 && route[0] === '/' ? route : `/${route}`;
2975
+ }
2976
+ }
2977
+ const navigationService = new NavigationService();
2978
+
2979
+ (function (CustomFundTypes) {
2980
+ CustomFundTypes["MyOwnFund"] = "Existing super fund";
2981
+ CustomFundTypes["DefaultFund"] = "Default super fund";
2982
+ CustomFundTypes["SelfManagedFund"] = "Self-managed super fund";
2983
+ CustomFundTypes["FeaturedFunds"] = "Featured super funds";
2984
+ })(exports.CustomFundTypes || (exports.CustomFundTypes = {}));
2985
+ const initialStateCustomFund = {
2986
+ myOwnFundForm: {
2987
+ fundUsi: none,
2988
+ fundName: none,
2989
+ memberNumber: none,
2990
+ memberFirstName: none,
2991
+ memberFamilyName: none
2992
+ },
2993
+ selfManagedFundForm: {
2994
+ fundName: '',
2995
+ fundAbn: '',
2996
+ fundEsa: '',
2997
+ addressLine1: '',
2998
+ addressLine2: '',
2999
+ state: '',
3000
+ postcode: '',
3001
+ city: '',
3002
+ bankAccountName: '',
3003
+ bsb: '',
3004
+ bankAccountNumber: '',
3005
+ memberFirstName: '',
3006
+ memberFamilyName: ''
3007
+ }
3008
+ };
3009
+ const { state: state$1, reset } = createStore(initialStateCustomFund);
3010
+
3011
+ class EventTrackingApi {
3012
+ static get Instance() {
3013
+ return this.instance || (this.instance = new this());
3014
+ }
3015
+ async PostAnalyticsEventAsync(event) {
3016
+ return buildBackendApiClient().url('analytics-events').post(event).res();
3017
+ }
3018
+ }
3019
+
3020
+ class EventTrackingService {
3021
+ constructor() {
3022
+ this.eventTrackingApi = EventTrackingApi.Instance;
3023
+ }
3024
+ static get Instance() {
3025
+ return this.instance || (this.instance = new this());
3026
+ }
3027
+ async TrackSuperFundPdsViewedAsync(detail) {
3028
+ return this.trackEventAsync({
3029
+ SuperFundPdsViewed: detail
3030
+ });
3031
+ }
3032
+ async TrackPromotedSuperFundDetailViewedAsync(detail) {
3033
+ return this.trackEventAsync({
3034
+ SuperFundDetailViewed: {
3035
+ PromotedFund: detail
3036
+ }
3037
+ });
3038
+ }
3039
+ async TrackPromotedDefaultSuperFundDetailViewedAsync(detail) {
3040
+ return this.trackEventAsync({
3041
+ SuperFundDetailViewed: {
3042
+ PromotedDefaultFund: detail
3043
+ }
3044
+ });
3045
+ }
3046
+ async TrackMyOwnSuperFundDetailViewedAsync(detail) {
3047
+ return this.trackEventAsync({
3048
+ SuperFundDetailViewed: {
3049
+ MyOwnFund: detail
3050
+ }
3051
+ });
3052
+ }
3053
+ async TrackSmsfSuperFundDetailViewedAsync(detail) {
3054
+ return this.trackEventAsync({
3055
+ SuperFundDetailViewed: {
3056
+ Smsf: detail
3057
+ }
3058
+ });
3059
+ }
3060
+ async TrackDefaultSuperFundDetailViewedAsync(detail) {
3061
+ return this.trackEventAsync({
3062
+ SuperFundDetailViewed: {
3063
+ DefaultFund: detail
3064
+ }
3065
+ });
3066
+ }
3067
+ async TrackSuperFundNominationViewedAsync(detail) {
3068
+ return this.trackEventAsync({
3069
+ SuperFundNominationViewed: detail
3070
+ });
3071
+ }
3072
+ async TrackSuperFundNominationDeclinedAsync(detail) {
3073
+ return this.trackEventAsync({
3074
+ SuperFundNominationDeclined: detail
3075
+ });
3076
+ }
3077
+ async TrackSuperFundDisclaimerViewedAsync(detail) {
3078
+ return this.trackEventAsync({
3079
+ SuperFundDisclaimerViewed: detail
3080
+ });
3081
+ }
3082
+ async TrackSuperFundDisclaimerAcceptedAsync(detail) {
3083
+ return this.trackEventAsync({
3084
+ SuperFundDisclaimerAccepted: detail
3085
+ });
3086
+ }
3087
+ async TrackSuperFundPrefillViewedAsync(detail) {
3088
+ return this.trackEventAsync({
3089
+ SuperFundPrefillViewed: detail
3090
+ });
3091
+ }
3092
+ async TrackSuperFundPrefillDeclinedAsync(detail) {
3093
+ return this.trackEventAsync({
3094
+ SuperFundPrefillDeclined: detail
3095
+ });
3096
+ }
3097
+ async TrackSuperFundDetailChangeRequestedAsync(detail) {
3098
+ return this.trackEventAsync({
3099
+ SuperFundDetailChangeRequested: detail
3100
+ });
3101
+ }
3102
+ async TrackSuperCampaignActivationSucceededAsync(detail) {
3103
+ return this.trackEventAsync({
3104
+ SuperCampaignActivationSucceeded: detail
3105
+ });
3106
+ }
3107
+ async TrackSuperMyOwnFundEngagementStepActivationSucceeded(fundUsi) {
3108
+ return this.trackEventAsync({
3109
+ SuperMyOwnFundEngagementStepActivationSucceeded: { fundUsi }
3110
+ });
3111
+ }
3112
+ async TrackSuperMyOwnFundEngagementStepContinued(fundUsi, reason) {
3113
+ return this.trackEventAsync({
3114
+ SuperMyOwnFundEngagementStepContinued: { fundUsi, reason }
3115
+ });
3116
+ }
3117
+ async TrackSuperSmsfEngagementStepActivationSucceeded() {
3118
+ return this.trackEventAsync({
3119
+ SuperSmsfEngagementStepActivationSucceeded: {}
3120
+ });
3121
+ }
3122
+ async TrackSuperSmsfEngagementStepContinued(reason) {
3123
+ return this.trackEventAsync({
3124
+ SuperSmsfEngagementStepContinued: { reason }
3125
+ });
3126
+ }
3127
+ async trackEventAsync(event) {
3128
+ try {
3129
+ await this.eventTrackingApi.PostAnalyticsEventAsync({ event });
3130
+ }
3131
+ catch (_a) {
3132
+ return;
3133
+ }
3134
+ }
3135
+ }
3136
+
3137
+ class CustomFundChoiceApi {
3138
+ async submitDefaultFundChoiceAsync(dto) {
3139
+ return buildBackendApiClient()
3140
+ .url('super-choice/default')
3141
+ .post(dto)
3142
+ .badRequest(() => {
3143
+ throw new Error('Failed to process default fund join request');
3144
+ })
3145
+ .text();
3146
+ }
3147
+ async submitCustomFundChoiceAsync(dto) {
3148
+ return buildBackendApiClient()
3149
+ .url('super-choice/custom-fund')
3150
+ .post(dto)
3151
+ .badRequest(() => {
3152
+ throw new Error('Failed to process custom fund join request');
3153
+ })
3154
+ .text();
3155
+ }
3156
+ async submitSelfManagedFundChoiceAsync(dto) {
3157
+ return buildBackendApiClient()
3158
+ .url('super-choice/smsf')
3159
+ .post(dto)
3160
+ .badRequest(() => {
3161
+ throw new Error('Failed to process SMSF choice request');
3162
+ })
3163
+ .text();
3164
+ }
3165
+ async submitDefinedBenefitsChoiceAsync(dto) {
3166
+ return buildBackendApiClient()
3167
+ .url('super-choice/defined-benefits')
3168
+ .post(dto)
3169
+ .badRequest(() => {
3170
+ throw new Error('Failed to process Defined Benefits choice request');
3171
+ })
3172
+ .text();
3173
+ }
3174
+ async validateAbnForSMSF(abn) {
3175
+ const response = await buildBackendApiClient()
3176
+ .url(`super-choice/smsf/${abn}/validate`)
3177
+ .get()
3178
+ .badRequest(() => {
3179
+ throw new Error('Failed to verify that if the provided abn is used for regulated fund');
3180
+ })
3181
+ .json();
3182
+ return response.result;
3183
+ }
3184
+ }
3185
+ const customFundChoiceApi = new CustomFundChoiceApi();
3186
+
3187
+ exports.EventTrackingService = EventTrackingService;
3188
+ exports.Option = Option;
3189
+ exports.buildBackendApiClient = buildBackendApiClient;
3190
+ exports.customFundChoiceApi = customFundChoiceApi;
3191
+ exports.factory = factory;
3192
+ exports.fromNullable = fromNullable;
3193
+ exports.getPromotedFundId = getPromotedFundId;
3194
+ exports.getSuperChoiceMemberNumber = getSuperChoiceMemberNumber;
3195
+ exports.getSuperChoiceUsi = getSuperChoiceUsi;
3196
+ exports.iframe = iframe;
3197
+ exports.injectHistory = injectHistory;
3198
+ exports.isNone = isNone;
3199
+ exports.isSome = isSome;
3200
+ exports.navigationService = navigationService;
3201
+ exports.none = none;
3202
+ exports.slate = slate;
3203
+ exports.some = some;
3204
+ exports.state = state$1;
3205
+ exports.state$1 = state;
3206
+ exports.superSelectionApi = superSelectionApi;
3207
+ exports.superSelectionAppService = superSelectionAppService;
3208
+ exports.superSelectionAppStencilRoutes = superSelectionAppStencilRoutes;
3209
+ exports.toUndefined = toUndefined;