@flarehr/apollo-super-selection 5.54.16008 → 5.55.16332

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 (75) 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-1596c9a2.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-2590548f.system.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-645755ee.system.entry.js +1 -0
  13. package/dist/lib/apollo-super-selection/{p-fcb4050d.entry.js → p-69bbf1dd.entry.js} +1 -1
  14. package/dist/lib/apollo-super-selection/p-6b03f1b2.entry.js +1 -0
  15. package/dist/lib/apollo-super-selection/{p-44bec843.system.js → p-71ca4cf8.system.js} +1 -1
  16. package/dist/lib/apollo-super-selection/p-8f3cc4bf.entry.js +14 -0
  17. package/dist/lib/apollo-super-selection/p-97188c78.system.js +1 -0
  18. package/dist/lib/apollo-super-selection/p-99266549.js +1 -0
  19. package/dist/lib/apollo-super-selection/{p-23cfdd82.entry.js → p-9d2a7c0e.entry.js} +1 -1
  20. package/dist/lib/apollo-super-selection/p-bd6e6a8f.system.js +1 -0
  21. package/dist/lib/apollo-super-selection/p-c775c0e4.system.entry.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-713823d3.js +3043 -0
  27. package/dist/lib/cjs/loader.cjs.js +1 -1
  28. package/dist/lib/cjs/{sss-button_33.cjs.entry.js → sss-button_31.cjs.entry.js} +395 -3566
  29. package/dist/lib/cjs/sss-super-byof-host.cjs.entry.js +94 -0
  30. package/dist/lib/collection/apollo-super-selection.css +1 -1
  31. package/dist/lib/collection/collection-manifest.json +1 -4
  32. package/dist/lib/collection/components/super-byof/super-byof-types.js +1 -0
  33. package/dist/lib/collection/components/super-byof/super-byof.form.js +1 -0
  34. package/dist/lib/collection/components/super-byof/super-byof.js +120 -0
  35. package/dist/lib/collection/components/super-selection-app/services/super-selection-app.routes.js +1 -1
  36. package/dist/lib/esm/{active-router-5e40c0f8.js → active-router-d18b36fb.js} +1 -1
  37. package/dist/lib/esm/apollo-super-selection.js +2 -2
  38. package/dist/lib/esm/context-consumer.entry.js +1 -1
  39. package/dist/lib/esm/custom-fund-choice.api-45fa478c.js +3022 -0
  40. package/dist/lib/esm/{index-189b2180.js → index-107d7c24.js} +1 -1
  41. package/dist/lib/esm/loader.js +2 -2
  42. package/dist/lib/esm/{sss-button_33.entry.js → sss-button_31.entry.js} +142 -3311
  43. package/dist/lib/esm/sss-super-byof-host.entry.js +90 -0
  44. package/dist/lib/esm/stencil-async-content.entry.js +1 -1
  45. package/dist/lib/esm/stencil-route-title.entry.js +2 -2
  46. package/dist/lib/esm/stencil-router-prompt.entry.js +2 -2
  47. package/dist/lib/esm/stencil-router-redirect.entry.js +2 -2
  48. package/dist/lib/esm-es5/{active-router-5e40c0f8.js → active-router-d18b36fb.js} +1 -1
  49. package/dist/lib/esm-es5/apollo-super-selection.js +1 -1
  50. package/dist/lib/esm-es5/context-consumer.entry.js +1 -1
  51. package/dist/lib/esm-es5/custom-fund-choice.api-45fa478c.js +1 -0
  52. package/dist/lib/esm-es5/{index-189b2180.js → index-107d7c24.js} +1 -1
  53. package/dist/lib/esm-es5/loader.js +1 -1
  54. package/dist/lib/esm-es5/sss-button_31.entry.js +69 -0
  55. package/dist/lib/esm-es5/sss-super-byof-host.entry.js +1 -0
  56. package/dist/lib/esm-es5/stencil-async-content.entry.js +1 -1
  57. package/dist/lib/esm-es5/stencil-route-title.entry.js +1 -1
  58. package/dist/lib/esm-es5/stencil-router-prompt.entry.js +1 -1
  59. package/dist/lib/esm-es5/stencil-router-redirect.entry.js +1 -1
  60. package/dist/lib/types/components/super-byof/super-byof-types.d.ts +26 -0
  61. package/dist/lib/types/components/super-byof/super-byof.d.ts +18 -0
  62. package/dist/lib/types/components/super-byof/super-byof.form.d.ts +6 -0
  63. package/dist/lib/types/components.d.ts +15 -34
  64. package/package.json +2 -1
  65. package/dist/lib/apollo-super-selection/p-071b8545.entry.js +0 -1
  66. package/dist/lib/apollo-super-selection/p-2298df79.system.entry.js +0 -69
  67. package/dist/lib/apollo-super-selection/p-51aefdb1.system.entry.js +0 -1
  68. package/dist/lib/apollo-super-selection/p-80178f87.system.js +0 -1
  69. package/dist/lib/apollo-super-selection/p-bdcfc026.system.js +0 -1
  70. package/dist/lib/apollo-super-selection/p-d7dbf362.entry.js +0 -14
  71. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund-inputs.js +0 -143
  72. package/dist/lib/collection/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund.js +0 -123
  73. package/dist/lib/esm-es5/sss-button_33.entry.js +0 -69
  74. package/dist/lib/types/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund-inputs.d.ts +0 -16
  75. package/dist/lib/types/components/super-selection-app/funds/custom-fund/my-own-fund/my-own-fund.d.ts +0 -13
@@ -1,6 +1,7 @@
1
- import { r as registerInstance, h, g as getRenderingRef, f as forceUpdate, F as Fragment, a as getAssetPath, H as Host, c as createEvent, s as setErrorHandler, d as getElement, e as getContext } from './index-189b2180.js';
1
+ import { r as registerInstance, h, F as Fragment, g as getAssetPath, H as Host, c as createEvent, s as setErrorHandler, a as getElement, d as getContext } from './index-107d7c24.js';
2
2
  import { f as from, m as map, S as SimpleOuterSubscriber, a as SimpleInnerSubscriber, i as innerSubscribe, b as isArray, O as Observable, c as isFunction, d as async, g as Subscriber, h as distinctUntilChanged, j as filter, k as StoreConfig, l as Store, Q as Query } from './datorama-akita-127aea91.js';
3
- import { A as ActiveRouter } from './active-router-5e40c0f8.js';
3
+ import { n as none, i as isSome, s as some, a as superSelectionAppService, b as navigationService, S as SuperSelectionAppRoutes, c as injectHistory, d as createStore, e as superSelectionApi, O as Option, f as buildBackendApiClient, g as customFundChoiceApi, h as isNone, j as getPromotedFundId, k as getSuperChoiceUsi, l as getSuperChoiceMemberNumber, m as state$1, t as toUndefined, o as slate, p as SuperCampaignComponentStatus, q as iframe, r as superSelectionAppStencilRoutes, u as factory, v as fromNullable } from './custom-fund-choice.api-45fa478c.js';
4
+ import { A as ActiveRouter } from './active-router-d18b36fb.js';
4
5
 
5
6
  function noop() { }
6
7
 
@@ -260,132 +261,7 @@ class TapSubscriber extends Subscriber {
260
261
  }
261
262
  }
262
263
 
263
- const AppVersion = '5.54.16008';
264
-
265
- // -------------------------------------------------------------------------------------
266
- // guards
267
- // -------------------------------------------------------------------------------------
268
- /**
269
- * Returns `true` if the option is an instance of `Some`, `false` otherwise.
270
- *
271
- * @example
272
- * import { some, none, isSome } from 'fp-ts/Option'
273
- *
274
- * assert.strictEqual(isSome(some(1)), true)
275
- * assert.strictEqual(isSome(none), false)
276
- *
277
- * @category guards
278
- * @since 2.0.0
279
- */
280
- var isSome = function (fa) { return fa._tag === 'Some'; };
281
- /**
282
- * Returns `true` if the option is `None`, `false` otherwise.
283
- *
284
- * @example
285
- * import { some, none, isNone } from 'fp-ts/Option'
286
- *
287
- * assert.strictEqual(isNone(some(1)), false)
288
- * assert.strictEqual(isNone(none), true)
289
- *
290
- * @category guards
291
- * @since 2.0.0
292
- */
293
- var isNone = function (fa) { return fa._tag === 'None'; };
294
- // -------------------------------------------------------------------------------------
295
- // constructors
296
- // -------------------------------------------------------------------------------------
297
- /**
298
- * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
299
- *
300
- * @category constructors
301
- * @since 2.0.0
302
- */
303
- var none = { _tag: 'None' };
304
- /**
305
- * Constructs a `Some`. Represents an optional value that exists.
306
- *
307
- * @category constructors
308
- * @since 2.0.0
309
- */
310
- var some = function (a) { return ({ _tag: 'Some', value: a }); };
311
- /**
312
- * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
313
- * returns the value wrapped in a `Some`.
314
- *
315
- * @example
316
- * import { none, some, fromNullable } from 'fp-ts/Option'
317
- *
318
- * assert.deepStrictEqual(fromNullable(undefined), none)
319
- * assert.deepStrictEqual(fromNullable(null), none)
320
- * assert.deepStrictEqual(fromNullable(1), some(1))
321
- *
322
- * @category constructors
323
- * @since 2.0.0
324
- */
325
- function fromNullable(a) {
326
- return a == null ? none : some(a);
327
- }
328
- /**
329
- * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.
330
- *
331
- * @example
332
- * import { some, none, toUndefined } from 'fp-ts/Option'
333
- * import { pipe } from 'fp-ts/function'
334
- *
335
- * assert.strictEqual(
336
- * pipe(
337
- * some(1),
338
- * toUndefined
339
- * ),
340
- * 1
341
- * )
342
- * assert.strictEqual(
343
- * pipe(
344
- * none,
345
- * toUndefined
346
- * ),
347
- * undefined
348
- * )
349
- *
350
- * @category destructors
351
- * @since 2.0.0
352
- */
353
- function toUndefined(ma) {
354
- return isNone(ma) ? undefined : ma.value;
355
- }
356
- /**
357
- * Less strict version of [`getOrElse`](#getOrElse).
358
- *
359
- * @category destructors
360
- * @since 2.6.0
361
- */
362
- var getOrElseW = function (onNone) { return function (ma) { return (isNone(ma) ? onNone() : ma.value); }; };
363
- /**
364
- * Extracts the value out of the structure, if it exists. Otherwise returns the given default value
365
- *
366
- * @example
367
- * import { some, none, getOrElse } from 'fp-ts/Option'
368
- * import { pipe } from 'fp-ts/function'
369
- *
370
- * assert.strictEqual(
371
- * pipe(
372
- * some(1),
373
- * getOrElse(() => 0)
374
- * ),
375
- * 1
376
- * )
377
- * assert.strictEqual(
378
- * pipe(
379
- * none,
380
- * getOrElse(() => 0)
381
- * ),
382
- * 0
383
- * )
384
- *
385
- * @category destructors
386
- * @since 2.0.0
387
- */
388
- var getOrElse = getOrElseW;
264
+ const AppVersion = '5.55.16332';
389
265
 
390
266
  class Lazy {
391
267
  constructor(factory) {
@@ -409,10 +285,6 @@ function addSlashToUrl() {
409
285
  }
410
286
  }
411
287
 
412
- function injectHistory(Component) {
413
- ActiveRouter.injectProps(Component, ['history', 'location']);
414
- }
415
-
416
288
  /**
417
289
  * TS adaption of https://github.com/pillarjs/path-to-regexp/blob/master/index.js
418
290
  */
@@ -836,3004 +708,132 @@ const createLocation = (path, state, key, currentLocation) => {
836
708
  if (!location.pathname) {
837
709
  location.pathname = currentLocation.pathname;
838
710
  }
839
- else if (location.pathname.charAt(0) !== '/') {
840
- location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
841
- }
842
- }
843
- else {
844
- // When there is no prior location and pathname is empty, set it to /
845
- if (!location.pathname) {
846
- location.pathname = '/';
847
- }
848
- }
849
- location.query = parseQueryString(location.search || '');
850
- return location;
851
- };
852
-
853
- let cacheCount = 0;
854
- const patternCache = {};
855
- const cacheLimit = 10000;
856
- // Memoized function for creating the path match regex
857
- const compilePath = (pattern, options) => {
858
- const cacheKey = `${options.end}${options.strict}`;
859
- const cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
860
- const cachePattern = JSON.stringify(pattern);
861
- if (cache[cachePattern]) {
862
- return cache[cachePattern];
863
- }
864
- const keys = [];
865
- const re = pathToRegexp(pattern, keys, options);
866
- const compiledPattern = { re, keys };
867
- if (cacheCount < cacheLimit) {
868
- cache[cachePattern] = compiledPattern;
869
- cacheCount += 1;
870
- }
871
- return compiledPattern;
872
- };
873
- /**
874
- * Public API for matching a URL pathname to a path pattern.
875
- */
876
- const matchPath = (pathname, options = {}) => {
877
- if (typeof options === 'string') {
878
- options = { path: options };
879
- }
880
- const { path = '/', exact = false, strict = false } = options;
881
- const { re, keys } = compilePath(path, { end: exact, strict });
882
- const match = re.exec(pathname);
883
- if (!match) {
884
- return null;
885
- }
886
- const [url, ...values] = match;
887
- const isExact = pathname === url;
888
- if (exact && !isExact) {
889
- return null;
890
- }
891
- return {
892
- path,
893
- url: path === '/' && url === '' ? '/' : url,
894
- isExact,
895
- params: keys.reduce((memo, key, index) => {
896
- memo[key.name] = values[index];
897
- return memo;
898
- }, {})
899
- };
900
- };
901
- const matchesAreEqual = (a, b) => {
902
- if (a == null && b == null) {
903
- return true;
904
- }
905
- if (b == null) {
906
- return false;
907
- }
908
- return a && b &&
909
- a.path === b.path &&
910
- a.url === b.url &&
911
- valueEqual(a.params, b.params);
912
- };
913
-
914
- var PromiseButtonState;
915
- (function (PromiseButtonState) {
916
- PromiseButtonState[PromiseButtonState["Available"] = 0] = "Available";
917
- PromiseButtonState[PromiseButtonState["Pending"] = 1] = "Pending";
918
- PromiseButtonState[PromiseButtonState["Error"] = 2] = "Error";
919
- })(PromiseButtonState || (PromiseButtonState = {}));
920
- const Button = class {
921
- constructor(hostRef) {
922
- registerInstance(this, hostRef);
923
- this.fillWidth = false;
924
- this.fillWidthOnMobile = false;
925
- this.disabled = false;
926
- this.variant = 'primary';
927
- this.size = 'base';
928
- this.promiseFn = () => Promise.resolve();
929
- // eslint-disable-next-line @typescript-eslint/member-ordering
930
- this.state = PromiseButtonState.Available;
931
- }
932
- render() {
933
- const sizeCss = {
934
- xs: 'px-2.5 py-1.5 text-xs',
935
- base: 'px-4 py-2 text-base',
936
- xl: 'px-6 py-3 text-base'
937
- };
938
- return (h("button", { "data-testid": this.testid, class: {
939
- [sizeCss[this.size]]: true,
940
- 'inline-flex items-center justify-center border font-medium': true,
941
- 'rounded-md shadow-sm focus:outline-none focus:ring-2': true,
942
- 'focus:ring-offset-2 focus:ring-primary-focus pointer-events-auto': true,
943
- 'disabled:pointer-events-none disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400': true,
944
- 'border-transparent text-white bg-primary-base hover:bg-primary-hover': this.variant === 'primary',
945
- 'border-gray-300 text-gray-700 bg-white hover:bg-gray-50': this.variant === 'secondary',
946
- 'border-transparent bg-primary-light hover:bg-primary-base text-primary-dark hover:text-white': this.variant === 'light',
947
- 'w-full': this.fillWidth || this.fillWidthOnMobile,
948
- 'sm:w-auto': this.fillWidthOnMobile
949
- }, disabled: this.disabled, onClick: () => this.clicked() }, this.state === PromiseButtonState.Pending && (h("sss-loading-indicator", { theme: this.variant === 'primary' ? 'light' : 'primary', size: 16 })), h("div", { class: { hidden: this.state === PromiseButtonState.Pending } }, h("slot", null))));
950
- }
951
- async clicked() {
952
- if (!this.promiseFn || this.state === PromiseButtonState.Pending)
953
- return;
954
- try {
955
- this.state = PromiseButtonState.Pending;
956
- await this.promiseFn();
957
- this.state = PromiseButtonState.Available;
958
- }
959
- catch (err) {
960
- this.state = PromiseButtonState.Error;
961
- throw err;
962
- }
963
- }
964
- };
965
-
966
- function appReady() {
967
- postMessage({
968
- type: 'appReady'
969
- });
970
- }
971
- function postMessage(message, origin) {
972
- if (origin === undefined)
973
- origin = '*';
974
- message.sender = 'flare';
975
- window.parent.postMessage(message, origin);
976
- }
977
- function resize(height, width) {
978
- postMessage({
979
- type: 'contentResized',
980
- height,
981
- width
982
- });
983
- }
984
- function navigation(url) {
985
- postMessage({
986
- type: 'pageNavigated',
987
- url
988
- });
989
- }
990
- function complete() {
991
- postMessage({ type: 'complete' });
992
- }
993
- function submitSuccess() {
994
- postMessage({
995
- type: 'submitSuccess'
996
- });
997
- }
998
- const iframe = { appReady, resize, navigation, complete, submitSuccess };
999
-
1000
- const appendToMap = (map, propName, value) => {
1001
- const items = map.get(propName);
1002
- if (!items) {
1003
- map.set(propName, [value]);
1004
- }
1005
- else if (!items.includes(value)) {
1006
- items.push(value);
1007
- }
1008
- };
1009
- const debounce = (fn, ms) => {
1010
- let timeoutId;
1011
- return (...args) => {
1012
- if (timeoutId) {
1013
- clearTimeout(timeoutId);
1014
- }
1015
- timeoutId = setTimeout(() => {
1016
- timeoutId = 0;
1017
- fn(...args);
1018
- }, ms);
1019
- };
1020
- };
1021
-
1022
- /**
1023
- * Check if a possible element isConnected.
1024
- * The property might not be there, so we check for it.
1025
- *
1026
- * We want it to return true if isConnected is not a property,
1027
- * otherwise we would remove these elements and would not update.
1028
- *
1029
- * Better leak in Edge than to be useless.
1030
- */
1031
- const isConnected = (maybeElement) => !('isConnected' in maybeElement) || maybeElement.isConnected;
1032
- const cleanupElements = debounce((map) => {
1033
- for (let key of map.keys()) {
1034
- map.set(key, map.get(key).filter(isConnected));
1035
- }
1036
- }, 2000);
1037
- const stencilSubscription = ({ on }) => {
1038
- const elmsToUpdate = new Map();
1039
- if (typeof getRenderingRef === 'function') {
1040
- // If we are not in a stencil project, we do nothing.
1041
- // This function is not really exported by @stencil/core.
1042
- on('dispose', () => {
1043
- elmsToUpdate.clear();
1044
- });
1045
- on('get', (propName) => {
1046
- const elm = getRenderingRef();
1047
- if (elm) {
1048
- appendToMap(elmsToUpdate, propName, elm);
1049
- }
1050
- });
1051
- on('set', (propName) => {
1052
- const elements = elmsToUpdate.get(propName);
1053
- if (elements) {
1054
- elmsToUpdate.set(propName, elements.filter(forceUpdate));
1055
- }
1056
- cleanupElements(elmsToUpdate);
1057
- });
1058
- on('reset', () => {
1059
- elmsToUpdate.forEach((elms) => elms.forEach(forceUpdate));
1060
- cleanupElements(elmsToUpdate);
1061
- });
1062
- }
1063
- };
1064
-
1065
- const createObservableMap = (defaultState, shouldUpdate = (a, b) => a !== b) => {
1066
- let states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
1067
- const handlers = {
1068
- dispose: [],
1069
- get: [],
1070
- set: [],
1071
- reset: [],
1072
- };
1073
- const reset = () => {
1074
- states = new Map(Object.entries(defaultState !== null && defaultState !== void 0 ? defaultState : {}));
1075
- handlers.reset.forEach((cb) => cb());
1076
- };
1077
- const dispose = () => {
1078
- // Call first dispose as resetting the state would
1079
- // cause less updates ;)
1080
- handlers.dispose.forEach((cb) => cb());
1081
- reset();
1082
- };
1083
- const get = (propName) => {
1084
- handlers.get.forEach((cb) => cb(propName));
1085
- return states.get(propName);
1086
- };
1087
- const set = (propName, value) => {
1088
- const oldValue = states.get(propName);
1089
- if (shouldUpdate(value, oldValue, propName)) {
1090
- states.set(propName, value);
1091
- handlers.set.forEach((cb) => cb(propName, value, oldValue));
1092
- }
1093
- };
1094
- const state = (typeof Proxy === 'undefined'
1095
- ? {}
1096
- : new Proxy(defaultState, {
1097
- get(_, propName) {
1098
- return get(propName);
1099
- },
1100
- ownKeys(_) {
1101
- return Array.from(states.keys());
1102
- },
1103
- getOwnPropertyDescriptor() {
1104
- return {
1105
- enumerable: true,
1106
- configurable: true,
1107
- };
1108
- },
1109
- has(_, propName) {
1110
- return states.has(propName);
1111
- },
1112
- set(_, propName, value) {
1113
- set(propName, value);
1114
- return true;
1115
- },
1116
- }));
1117
- const on = (eventName, callback) => {
1118
- handlers[eventName].push(callback);
1119
- return () => {
1120
- removeFromArray(handlers[eventName], callback);
1121
- };
1122
- };
1123
- const onChange = (propName, cb) => {
1124
- const unSet = on('set', (key, newValue) => {
1125
- if (key === propName) {
1126
- cb(newValue);
1127
- }
1128
- });
1129
- const unReset = on('reset', () => cb(defaultState[propName]));
1130
- return () => {
1131
- unSet();
1132
- unReset();
1133
- };
1134
- };
1135
- const use = (...subscriptions) => subscriptions.forEach((subscription) => {
1136
- if (subscription.set) {
1137
- on('set', subscription.set);
1138
- }
1139
- if (subscription.get) {
1140
- on('get', subscription.get);
1141
- }
1142
- if (subscription.reset) {
1143
- on('reset', subscription.reset);
1144
- }
1145
- });
1146
- return {
1147
- state,
1148
- get,
1149
- set,
1150
- on,
1151
- onChange,
1152
- use,
1153
- dispose,
1154
- reset,
1155
- };
1156
- };
1157
- const removeFromArray = (array, item) => {
1158
- const index = array.indexOf(item);
1159
- if (index >= 0) {
1160
- array[index] = array[array.length - 1];
1161
- array.length--;
1162
- }
1163
- };
1164
-
1165
- const createStore = (defaultState, shouldUpdate) => {
1166
- const map = createObservableMap(defaultState, shouldUpdate);
1167
- stencilSubscription(map);
1168
- return map;
1169
- };
1170
-
1171
- const initial = {
1172
- handleSubmitFn: async function () {
1173
- return;
1174
- },
1175
- fundName: '',
1176
- fundDetails: { type: 'null' },
1177
- promotedFundId: undefined
1178
- };
1179
- const { state } = createStore(initial);
1180
-
1181
- var SuperSelectionAppRoutes;
1182
- (function (SuperSelectionAppRoutes) {
1183
- SuperSelectionAppRoutes["ExistingChoicePage"] = "/existing";
1184
- SuperSelectionAppRoutes["SuperCampaign"] = "/super-campaign";
1185
- SuperSelectionAppRoutes["ChoicePage"] = "/";
1186
- SuperSelectionAppRoutes["MyOwnFund"] = "/super-choice/my-own-fund/";
1187
- SuperSelectionAppRoutes["MyOwnFundEngagementStep"] = "/super-choice/my-own-fund-engagement/";
1188
- SuperSelectionAppRoutes["Prefill"] = "/super-choice/prefill/";
1189
- SuperSelectionAppRoutes["PrefillInvalidMyOwnFundPage"] = "/super-choice/sss-prefill-invalid-my-own-fund/";
1190
- SuperSelectionAppRoutes["PrefillMyOwnFundPage"] = "/super-choice/prefill-my-own-fund/";
1191
- SuperSelectionAppRoutes["PrefillSMSFPage"] = "/super-choice/prefill-smsf/";
1192
- SuperSelectionAppRoutes["PrefillInvalidSMSFPage"] = "/super-choice/prefill-invalid-smsf/";
1193
- SuperSelectionAppRoutes["SelfManagedFund"] = "/super-choice/smsf/";
1194
- SuperSelectionAppRoutes["DefaultFund"] = "/super-choice/default/";
1195
- SuperSelectionAppRoutes["FeaturedFunds"] = "/super-choice/featured-funds/";
1196
- SuperSelectionAppRoutes["StandardChoice"] = "/standard-choice/";
1197
- SuperSelectionAppRoutes["Success"] = "/success/";
1198
- })(SuperSelectionAppRoutes || (SuperSelectionAppRoutes = {}));
1199
- const superSelectionAppStencilRoutes = [
1200
- h("stencil-route", { url: SuperSelectionAppRoutes.ExistingChoicePage, component: "sss-existing-choice-page" }),
1201
- h("stencil-route", { url: SuperSelectionAppRoutes.SuperCampaign, component: "sss-super-campaign-host" }),
1202
- h("stencil-route", { exact: true, url: SuperSelectionAppRoutes.ChoicePage, component: "sss-choice-router" }),
1203
- h("stencil-route", { url: SuperSelectionAppRoutes.MyOwnFund, component: "sss-my-own-fund" }),
1204
- h("stencil-route", { url: SuperSelectionAppRoutes.MyOwnFundEngagementStep, component: "sss-my-own-fund-engagement-step-host" }),
1205
- h("stencil-route", { url: SuperSelectionAppRoutes.PrefillInvalidMyOwnFundPage, component: "sss-prefill-invalid-my-own-fund" }),
1206
- h("stencil-route", { url: SuperSelectionAppRoutes.Prefill, component: "sss-prefill" }),
1207
- h("stencil-route", { url: SuperSelectionAppRoutes.PrefillMyOwnFundPage, component: "sss-prefill-my-own-fund" }),
1208
- h("stencil-route", { url: SuperSelectionAppRoutes.PrefillSMSFPage, component: "sss-prefill-smsf" }),
1209
- h("stencil-route", { url: SuperSelectionAppRoutes.PrefillInvalidSMSFPage, component: "sss-prefill-invalid-smsf" }),
1210
- h("stencil-route", { url: SuperSelectionAppRoutes.SelfManagedFund, component: "sss-super-smsf-host" }),
1211
- h("stencil-route", { url: SuperSelectionAppRoutes.DefaultFund, component: "sss-default-fund" }),
1212
- h("stencil-route", { url: SuperSelectionAppRoutes.FeaturedFunds, component: "sss-super-campaign-featured-funds" }),
1213
- h("stencil-route", { url: SuperSelectionAppRoutes.StandardChoice, component: "sss-standard-choice-form" }),
1214
- h("stencil-route", { url: SuperSelectionAppRoutes.Success, component: "sss-success" })
1215
- ];
1216
-
1217
- function createCommonjsModule(fn, basedir, module) {
1218
- return module = {
1219
- path: basedir,
1220
- exports: {},
1221
- require: function (path, base) {
1222
- return commonjsRequire();
1223
- }
1224
- }, fn(module, module.exports), module.exports;
1225
- }
1226
-
1227
- function commonjsRequire () {
1228
- throw new Error('Dynamic requires are not currently supported by @rollup/plugin-commonjs');
1229
- }
1230
-
1231
- var _function = createCommonjsModule(function (module, exports) {
1232
- /**
1233
- * @since 2.0.0
1234
- */
1235
- Object.defineProperty(exports, "__esModule", { value: true });
1236
- 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;
1237
- /**
1238
- * @since 2.0.0
1239
- */
1240
- function identity(a) {
1241
- return a;
1242
- }
1243
- exports.identity = identity;
1244
- /**
1245
- * @since 2.0.0
1246
- */
1247
- exports.unsafeCoerce = identity;
1248
- /**
1249
- * @since 2.0.0
1250
- */
1251
- function not(predicate) {
1252
- return function (a) { return !predicate(a); };
1253
- }
1254
- exports.not = not;
1255
- /**
1256
- * @since 2.0.0
1257
- */
1258
- function constant(a) {
1259
- return function () { return a; };
1260
- }
1261
- exports.constant = constant;
1262
- /**
1263
- * A thunk that returns always `true`.
1264
- *
1265
- * @since 2.0.0
1266
- */
1267
- exports.constTrue =
1268
- /*#__PURE__*/
1269
- constant(true);
1270
- /**
1271
- * A thunk that returns always `false`.
1272
- *
1273
- * @since 2.0.0
1274
- */
1275
- exports.constFalse =
1276
- /*#__PURE__*/
1277
- constant(false);
1278
- /**
1279
- * A thunk that returns always `null`.
1280
- *
1281
- * @since 2.0.0
1282
- */
1283
- exports.constNull =
1284
- /*#__PURE__*/
1285
- constant(null);
1286
- /**
1287
- * A thunk that returns always `undefined`.
1288
- *
1289
- * @since 2.0.0
1290
- */
1291
- exports.constUndefined =
1292
- /*#__PURE__*/
1293
- constant(undefined);
1294
- /**
1295
- * A thunk that returns always `void`.
1296
- *
1297
- * @since 2.0.0
1298
- */
1299
- exports.constVoid = exports.constUndefined;
1300
- // TODO: remove in v3
1301
- /**
1302
- * Flips the order of the arguments of a function of two arguments.
1303
- *
1304
- * @since 2.0.0
1305
- */
1306
- function flip(f) {
1307
- return function (b, a) { return f(a, b); };
1308
- }
1309
- exports.flip = flip;
1310
- function flow(ab, bc, cd, de, ef, fg, gh, hi, ij) {
1311
- switch (arguments.length) {
1312
- case 1:
1313
- return ab;
1314
- case 2:
1315
- return function () {
1316
- return bc(ab.apply(this, arguments));
1317
- };
1318
- case 3:
1319
- return function () {
1320
- return cd(bc(ab.apply(this, arguments)));
1321
- };
1322
- case 4:
1323
- return function () {
1324
- return de(cd(bc(ab.apply(this, arguments))));
1325
- };
1326
- case 5:
1327
- return function () {
1328
- return ef(de(cd(bc(ab.apply(this, arguments)))));
1329
- };
1330
- case 6:
1331
- return function () {
1332
- return fg(ef(de(cd(bc(ab.apply(this, arguments))))));
1333
- };
1334
- case 7:
1335
- return function () {
1336
- return gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))));
1337
- };
1338
- case 8:
1339
- return function () {
1340
- return hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments))))))));
1341
- };
1342
- case 9:
1343
- return function () {
1344
- return ij(hi(gh(fg(ef(de(cd(bc(ab.apply(this, arguments)))))))));
1345
- };
1346
- }
1347
- return;
1348
- }
1349
- exports.flow = flow;
1350
- /**
1351
- * @since 2.0.0
1352
- */
1353
- function tuple() {
1354
- var t = [];
1355
- for (var _i = 0; _i < arguments.length; _i++) {
1356
- t[_i] = arguments[_i];
1357
- }
1358
- return t;
1359
- }
1360
- exports.tuple = tuple;
1361
- /**
1362
- * @since 2.0.0
1363
- */
1364
- function increment(n) {
1365
- return n + 1;
1366
- }
1367
- exports.increment = increment;
1368
- /**
1369
- * @since 2.0.0
1370
- */
1371
- function decrement(n) {
1372
- return n - 1;
1373
- }
1374
- exports.decrement = decrement;
1375
- /**
1376
- * @since 2.0.0
1377
- */
1378
- function absurd(_) {
1379
- throw new Error('Called `absurd` function which should be uncallable');
1380
- }
1381
- exports.absurd = absurd;
1382
- /**
1383
- * Creates a tupled version of this function: instead of `n` arguments, it accepts a single tuple argument.
1384
- *
1385
- * @example
1386
- * import { tupled } from 'fp-ts/function'
1387
- *
1388
- * const add = tupled((x: number, y: number): number => x + y)
1389
- *
1390
- * assert.strictEqual(add([1, 2]), 3)
1391
- *
1392
- * @since 2.4.0
1393
- */
1394
- function tupled(f) {
1395
- return function (a) { return f.apply(void 0, a); };
1396
- }
1397
- exports.tupled = tupled;
1398
- /**
1399
- * Inverse function of `tupled`
1400
- *
1401
- * @since 2.4.0
1402
- */
1403
- function untupled(f) {
1404
- return function () {
1405
- var a = [];
1406
- for (var _i = 0; _i < arguments.length; _i++) {
1407
- a[_i] = arguments[_i];
1408
- }
1409
- return f(a);
1410
- };
1411
- }
1412
- exports.untupled = untupled;
1413
- function pipe(a, ab, bc, cd, de, ef, fg, gh, hi, ij, jk, kl, lm, mn, no, op, pq, qr, rs, st) {
1414
- switch (arguments.length) {
1415
- case 1:
1416
- return a;
1417
- case 2:
1418
- return ab(a);
1419
- case 3:
1420
- return bc(ab(a));
1421
- case 4:
1422
- return cd(bc(ab(a)));
1423
- case 5:
1424
- return de(cd(bc(ab(a))));
1425
- case 6:
1426
- return ef(de(cd(bc(ab(a)))));
1427
- case 7:
1428
- return fg(ef(de(cd(bc(ab(a))))));
1429
- case 8:
1430
- return gh(fg(ef(de(cd(bc(ab(a)))))));
1431
- case 9:
1432
- return hi(gh(fg(ef(de(cd(bc(ab(a))))))));
1433
- case 10:
1434
- return ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))));
1435
- case 11:
1436
- return jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))));
1437
- case 12:
1438
- return kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))));
1439
- case 13:
1440
- return lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))));
1441
- case 14:
1442
- return mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))));
1443
- case 15:
1444
- return no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))));
1445
- case 16:
1446
- return op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))));
1447
- case 17:
1448
- return pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))));
1449
- case 18:
1450
- return qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))));
1451
- case 19:
1452
- return rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a))))))))))))))))));
1453
- case 20:
1454
- return st(rs(qr(pq(op(no(mn(lm(kl(jk(ij(hi(gh(fg(ef(de(cd(bc(ab(a)))))))))))))))))));
1455
- }
1456
- return;
1457
- }
1458
- exports.pipe = pipe;
1459
- /**
1460
- * Type hole simulation
1461
- *
1462
- * @since 2.7.0
1463
- */
1464
- exports.hole = absurd;
1465
- /**
1466
- * @internal
1467
- */
1468
- var bind_ = function (a, name, b) {
1469
- var _a;
1470
- return Object.assign({}, a, (_a = {}, _a[name] = b, _a));
1471
- };
1472
- exports.bind_ = bind_;
1473
- /**
1474
- * @internal
1475
- */
1476
- var bindTo_ = function (name) { return function (b) {
1477
- var _a;
1478
- return (_a = {}, _a[name] = b, _a);
1479
- }; };
1480
- exports.bindTo_ = bindTo_;
1481
- });
1482
-
1483
- var Option = createCommonjsModule(function (module, exports) {
1484
- Object.defineProperty(exports, "__esModule", { value: true });
1485
- 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;
1486
- 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;
1487
-
1488
- // -------------------------------------------------------------------------------------
1489
- // guards
1490
- // -------------------------------------------------------------------------------------
1491
- /**
1492
- * Returns `true` if the option is an instance of `Some`, `false` otherwise.
1493
- *
1494
- * @example
1495
- * import { some, none, isSome } from 'fp-ts/Option'
1496
- *
1497
- * assert.strictEqual(isSome(some(1)), true)
1498
- * assert.strictEqual(isSome(none), false)
1499
- *
1500
- * @category guards
1501
- * @since 2.0.0
1502
- */
1503
- var isSome = function (fa) { return fa._tag === 'Some'; };
1504
- exports.isSome = isSome;
1505
- /**
1506
- * Returns `true` if the option is `None`, `false` otherwise.
1507
- *
1508
- * @example
1509
- * import { some, none, isNone } from 'fp-ts/Option'
1510
- *
1511
- * assert.strictEqual(isNone(some(1)), false)
1512
- * assert.strictEqual(isNone(none), true)
1513
- *
1514
- * @category guards
1515
- * @since 2.0.0
1516
- */
1517
- var isNone = function (fa) { return fa._tag === 'None'; };
1518
- exports.isNone = isNone;
1519
- // -------------------------------------------------------------------------------------
1520
- // constructors
1521
- // -------------------------------------------------------------------------------------
1522
- /**
1523
- * `None` doesn't have a constructor, instead you can use it directly as a value. Represents a missing value.
1524
- *
1525
- * @category constructors
1526
- * @since 2.0.0
1527
- */
1528
- exports.none = { _tag: 'None' };
1529
- /**
1530
- * Constructs a `Some`. Represents an optional value that exists.
1531
- *
1532
- * @category constructors
1533
- * @since 2.0.0
1534
- */
1535
- var some = function (a) { return ({ _tag: 'Some', value: a }); };
1536
- exports.some = some;
1537
- /**
1538
- * Constructs a new `Option` from a nullable type. If the value is `null` or `undefined`, returns `None`, otherwise
1539
- * returns the value wrapped in a `Some`.
1540
- *
1541
- * @example
1542
- * import { none, some, fromNullable } from 'fp-ts/Option'
1543
- *
1544
- * assert.deepStrictEqual(fromNullable(undefined), none)
1545
- * assert.deepStrictEqual(fromNullable(null), none)
1546
- * assert.deepStrictEqual(fromNullable(1), some(1))
1547
- *
1548
- * @category constructors
1549
- * @since 2.0.0
1550
- */
1551
- function fromNullable(a) {
1552
- return a == null ? exports.none : exports.some(a);
1553
- }
1554
- exports.fromNullable = fromNullable;
1555
- function fromPredicate(predicate) {
1556
- return function (a) { return (predicate(a) ? exports.some(a) : exports.none); };
1557
- }
1558
- exports.fromPredicate = fromPredicate;
1559
- /**
1560
- * Transforms an exception into an `Option`. If `f` throws, returns `None`, otherwise returns the output wrapped in a
1561
- * `Some`.
1562
- *
1563
- * @example
1564
- * import { none, some, tryCatch } from 'fp-ts/Option'
1565
- *
1566
- * assert.deepStrictEqual(
1567
- * tryCatch(() => {
1568
- * throw new Error()
1569
- * }),
1570
- * none
1571
- * )
1572
- * assert.deepStrictEqual(tryCatch(() => 1), some(1))
1573
- *
1574
- * @category constructors
1575
- * @since 2.0.0
1576
- */
1577
- function tryCatch(f) {
1578
- try {
1579
- return exports.some(f());
1580
- }
1581
- catch (e) {
1582
- return exports.none;
1583
- }
1584
- }
1585
- exports.tryCatch = tryCatch;
1586
- /**
1587
- * Returns the `Left` value of an `Either` if possible.
1588
- *
1589
- * @example
1590
- * import { getLeft, none, some } from 'fp-ts/Option'
1591
- * import { right, left } from 'fp-ts/Either'
1592
- *
1593
- * assert.deepStrictEqual(getLeft(right(1)), none)
1594
- * assert.deepStrictEqual(getLeft(left('a')), some('a'))
1595
- *
1596
- * @category constructors
1597
- * @since 2.0.0
1598
- */
1599
- function getLeft(ma) {
1600
- return ma._tag === 'Right' ? exports.none : exports.some(ma.left);
1601
- }
1602
- exports.getLeft = getLeft;
1603
- /**
1604
- * Returns the `Right` value of an `Either` if possible.
1605
- *
1606
- * @example
1607
- * import { getRight, none, some } from 'fp-ts/Option'
1608
- * import { right, left } from 'fp-ts/Either'
1609
- *
1610
- * assert.deepStrictEqual(getRight(right(1)), some(1))
1611
- * assert.deepStrictEqual(getRight(left('a')), none)
1612
- *
1613
- * @category constructors
1614
- * @since 2.0.0
1615
- */
1616
- function getRight(ma) {
1617
- return ma._tag === 'Left' ? exports.none : exports.some(ma.right);
1618
- }
1619
- exports.getRight = getRight;
1620
- /**
1621
- * Transforms an `Either` to an `Option` discarding the error.
1622
- *
1623
- * Alias of [getRight](#getRight)
1624
- *
1625
- * Derivable from `MonadThrow`.
1626
- *
1627
- * @category constructors
1628
- * @since 2.0.0
1629
- */
1630
- exports.fromEither = getRight;
1631
- // -------------------------------------------------------------------------------------
1632
- // destructors
1633
- // -------------------------------------------------------------------------------------
1634
- /**
1635
- * Takes a (lazy) default value, a function, and an `Option` value, if the `Option` value is `None` the default value is
1636
- * returned, otherwise the function is applied to the value inside the `Some` and the result is returned.
1637
- *
1638
- * @example
1639
- * import { some, none, fold } from 'fp-ts/Option'
1640
- * import { pipe } from 'fp-ts/function'
1641
- *
1642
- * assert.strictEqual(
1643
- * pipe(
1644
- * some(1),
1645
- * fold(() => 'a none', a => `a some containing ${a}`)
1646
- * ),
1647
- * 'a some containing 1'
1648
- * )
1649
- *
1650
- * assert.strictEqual(
1651
- * pipe(
1652
- * none,
1653
- * fold(() => 'a none', a => `a some containing ${a}`)
1654
- * ),
1655
- * 'a none'
1656
- * )
1657
- *
1658
- * @category destructors
1659
- * @since 2.0.0
1660
- */
1661
- function fold(onNone, onSome) {
1662
- return function (ma) { return (exports.isNone(ma) ? onNone() : onSome(ma.value)); };
1663
- }
1664
- exports.fold = fold;
1665
- /**
1666
- * Extracts the value out of the structure, if it exists. Otherwise returns `null`.
1667
- *
1668
- * @example
1669
- * import { some, none, toNullable } from 'fp-ts/Option'
1670
- * import { pipe } from 'fp-ts/function'
1671
- *
1672
- * assert.strictEqual(
1673
- * pipe(
1674
- * some(1),
1675
- * toNullable
1676
- * ),
1677
- * 1
1678
- * )
1679
- * assert.strictEqual(
1680
- * pipe(
1681
- * none,
1682
- * toNullable
1683
- * ),
1684
- * null
1685
- * )
1686
- *
1687
- * @category destructors
1688
- * @since 2.0.0
1689
- */
1690
- function toNullable(ma) {
1691
- return exports.isNone(ma) ? null : ma.value;
1692
- }
1693
- exports.toNullable = toNullable;
1694
- /**
1695
- * Extracts the value out of the structure, if it exists. Otherwise returns `undefined`.
1696
- *
1697
- * @example
1698
- * import { some, none, toUndefined } from 'fp-ts/Option'
1699
- * import { pipe } from 'fp-ts/function'
1700
- *
1701
- * assert.strictEqual(
1702
- * pipe(
1703
- * some(1),
1704
- * toUndefined
1705
- * ),
1706
- * 1
1707
- * )
1708
- * assert.strictEqual(
1709
- * pipe(
1710
- * none,
1711
- * toUndefined
1712
- * ),
1713
- * undefined
1714
- * )
1715
- *
1716
- * @category destructors
1717
- * @since 2.0.0
1718
- */
1719
- function toUndefined(ma) {
1720
- return exports.isNone(ma) ? undefined : ma.value;
1721
- }
1722
- exports.toUndefined = toUndefined;
1723
- /**
1724
- * Less strict version of [`getOrElse`](#getOrElse).
1725
- *
1726
- * @category destructors
1727
- * @since 2.6.0
1728
- */
1729
- var getOrElseW = function (onNone) { return function (ma) { return (exports.isNone(ma) ? onNone() : ma.value); }; };
1730
- exports.getOrElseW = getOrElseW;
1731
- /**
1732
- * Extracts the value out of the structure, if it exists. Otherwise returns the given default value
1733
- *
1734
- * @example
1735
- * import { some, none, getOrElse } from 'fp-ts/Option'
1736
- * import { pipe } from 'fp-ts/function'
1737
- *
1738
- * assert.strictEqual(
1739
- * pipe(
1740
- * some(1),
1741
- * getOrElse(() => 0)
1742
- * ),
1743
- * 1
1744
- * )
1745
- * assert.strictEqual(
1746
- * pipe(
1747
- * none,
1748
- * getOrElse(() => 0)
1749
- * ),
1750
- * 0
1751
- * )
1752
- *
1753
- * @category destructors
1754
- * @since 2.0.0
1755
- */
1756
- exports.getOrElse = exports.getOrElseW;
1757
- // -------------------------------------------------------------------------------------
1758
- // combinators
1759
- // -------------------------------------------------------------------------------------
1760
- /**
1761
- * Returns a *smart constructor* from a function that returns a nullable value.
1762
- *
1763
- * @example
1764
- * import { fromNullableK, none, some } from 'fp-ts/Option'
1765
- *
1766
- * const f = (s: string): number | undefined => {
1767
- * const n = parseFloat(s)
1768
- * return isNaN(n) ? undefined : n
1769
- * }
1770
- *
1771
- * const g = fromNullableK(f)
1772
- *
1773
- * assert.deepStrictEqual(g('1'), some(1))
1774
- * assert.deepStrictEqual(g('a'), none)
1775
- *
1776
- * @category combinators
1777
- * @since 2.9.0
1778
- */
1779
- function fromNullableK(f) {
1780
- return function () {
1781
- var a = [];
1782
- for (var _i = 0; _i < arguments.length; _i++) {
1783
- a[_i] = arguments[_i];
1784
- }
1785
- return fromNullable(f.apply(void 0, a));
1786
- };
1787
- }
1788
- exports.fromNullableK = fromNullableK;
1789
- /**
1790
- * @category combinators
1791
- * @since 2.0.0
1792
- * @deprecated
1793
- */
1794
- exports.mapNullable = chainNullableK;
1795
- /**
1796
- * This is `chain` + `fromNullable`, useful when working with optional values.
1797
- *
1798
- * @example
1799
- * import { some, none, fromNullable, chainNullableK } from 'fp-ts/Option'
1800
- * import { pipe } from 'fp-ts/function'
1801
- *
1802
- * interface Employee {
1803
- * company?: {
1804
- * address?: {
1805
- * street?: {
1806
- * name?: string
1807
- * }
1808
- * }
1809
- * }
1810
- * }
1811
- *
1812
- * const employee1: Employee = { company: { address: { street: { name: 'high street' } } } }
1813
- *
1814
- * assert.deepStrictEqual(
1815
- * pipe(
1816
- * fromNullable(employee1.company),
1817
- * chainNullableK(company => company.address),
1818
- * chainNullableK(address => address.street),
1819
- * chainNullableK(street => street.name)
1820
- * ),
1821
- * some('high street')
1822
- * )
1823
- *
1824
- * const employee2: Employee = { company: { address: { street: {} } } }
1825
- *
1826
- * assert.deepStrictEqual(
1827
- * pipe(
1828
- * fromNullable(employee2.company),
1829
- * chainNullableK(company => company.address),
1830
- * chainNullableK(address => address.street),
1831
- * chainNullableK(street => street.name)
1832
- * ),
1833
- * none
1834
- * )
1835
- *
1836
- * @category combinators
1837
- * @since 2.9.0
1838
- */
1839
- function chainNullableK(f) {
1840
- return function (ma) { return (exports.isNone(ma) ? exports.none : fromNullable(f(ma.value))); };
1841
- }
1842
- exports.chainNullableK = chainNullableK;
1843
- // -------------------------------------------------------------------------------------
1844
- // non-pipeables
1845
- // -------------------------------------------------------------------------------------
1846
- var map_ = function (fa, f) { return _function.pipe(fa, exports.map(f)); };
1847
- var ap_ = function (fab, fa) { return _function.pipe(fab, exports.ap(fa)); };
1848
- var chain_ = function (ma, f) { return _function.pipe(ma, exports.chain(f)); };
1849
- var reduce_ = function (fa, b, f) { return _function.pipe(fa, exports.reduce(b, f)); };
1850
- var foldMap_ = function (M) {
1851
- var foldMapM = exports.foldMap(M);
1852
- return function (fa, f) { return _function.pipe(fa, foldMapM(f)); };
1853
- };
1854
- var reduceRight_ = function (fa, b, f) { return _function.pipe(fa, exports.reduceRight(b, f)); };
1855
- var traverse_ = function (F) {
1856
- var traverseF = exports.traverse(F);
1857
- return function (ta, f) { return _function.pipe(ta, traverseF(f)); };
1858
- };
1859
- /* istanbul ignore next */
1860
- var alt_ = function (fa, that) { return _function.pipe(fa, exports.alt(that)); };
1861
- var filter_ = function (fa, predicate) {
1862
- return _function.pipe(fa, exports.filter(predicate));
1863
- };
1864
- /* istanbul ignore next */
1865
- var filterMap_ = function (fa, f) { return _function.pipe(fa, exports.filterMap(f)); };
1866
- /* istanbul ignore next */
1867
- var extend_ = function (wa, f) { return _function.pipe(wa, exports.extend(f)); };
1868
- /* istanbul ignore next */
1869
- var partition_ = function (fa, predicate) { return _function.pipe(fa, exports.partition(predicate)); };
1870
- /* istanbul ignore next */
1871
- var partitionMap_ = function (fa, f) { return _function.pipe(fa, exports.partitionMap(f)); };
1872
- /* istanbul ignore next */
1873
- var wither_ = function (F) {
1874
- var witherF = exports.wither(F);
1875
- return function (fa, f) { return _function.pipe(fa, witherF(f)); };
1876
- };
1877
- /* istanbul ignore next */
1878
- var wilt_ = function (F) {
1879
- var wiltF = exports.wilt(F);
1880
- return function (fa, f) { return _function.pipe(fa, wiltF(f)); };
1881
- };
1882
- // -------------------------------------------------------------------------------------
1883
- // pipeables
1884
- // -------------------------------------------------------------------------------------
1885
- /**
1886
- * `map` can be used to turn functions `(a: A) => B` into functions `(fa: F<A>) => F<B>` whose argument and return types
1887
- * use the type constructor `F` to represent some computational context.
1888
- *
1889
- * @category Functor
1890
- * @since 2.0.0
1891
- */
1892
- var map = function (f) { return function (fa) {
1893
- return exports.isNone(fa) ? exports.none : exports.some(f(fa.value));
1894
- }; };
1895
- exports.map = map;
1896
- /**
1897
- * Apply a function to an argument under a type constructor.
1898
- *
1899
- * @category Apply
1900
- * @since 2.0.0
1901
- */
1902
- var ap = function (fa) { return function (fab) {
1903
- return exports.isNone(fab) ? exports.none : exports.isNone(fa) ? exports.none : exports.some(fab.value(fa.value));
1904
- }; };
1905
- exports.ap = ap;
1906
- /**
1907
- * Combine two effectful actions, keeping only the result of the first.
1908
- *
1909
- * Derivable from `Apply`.
1910
- *
1911
- * @category combinators
1912
- * @since 2.0.0
1913
- */
1914
- var apFirst = function (fb) {
1915
- return _function.flow(exports.map(function (a) { return function () { return a; }; }), exports.ap(fb));
1916
- };
1917
- exports.apFirst = apFirst;
1918
- /**
1919
- * Combine two effectful actions, keeping only the result of the second.
1920
- *
1921
- * Derivable from `Apply`.
1922
- *
1923
- * @category combinators
1924
- * @since 2.0.0
1925
- */
1926
- var apSecond = function (fb) {
1927
- return _function.flow(exports.map(function () { return function (b) { return b; }; }), exports.ap(fb));
1928
- };
1929
- exports.apSecond = apSecond;
1930
- /**
1931
- * Wrap a value into the type constructor.
1932
- *
1933
- * @category Applicative
1934
- * @since 2.7.0
1935
- */
1936
- exports.of = exports.some;
1937
- /**
1938
- * Composes computations in sequence, using the return value of one computation to determine the next computation.
1939
- *
1940
- * @category Monad
1941
- * @since 2.0.0
1942
- */
1943
- var chain = function (f) { return function (ma) {
1944
- return exports.isNone(ma) ? exports.none : f(ma.value);
1945
- }; };
1946
- exports.chain = chain;
1947
- /**
1948
- * Composes computations in sequence, using the return value of one computation to determine the next computation and
1949
- * keeping only the result of the first.
1950
- *
1951
- * Derivable from `Monad`.
1952
- *
1953
- * @category combinators
1954
- * @since 2.0.0
1955
- */
1956
- var chainFirst = function (f) {
1957
- return exports.chain(function (a) {
1958
- return _function.pipe(f(a), exports.map(function () { return a; }));
1959
- });
1960
- };
1961
- exports.chainFirst = chainFirst;
1962
- /**
1963
- * Derivable from `Monad`.
1964
- *
1965
- * @category combinators
1966
- * @since 2.0.0
1967
- */
1968
- exports.flatten =
1969
- /*#__PURE__*/
1970
- exports.chain(_function.identity);
1971
- /**
1972
- * Less strict version of [`alt`](#alt).
1973
- *
1974
- * @category Alt
1975
- * @since 2.9.0
1976
- */
1977
- var altW = function (that) { return function (fa) {
1978
- return exports.isNone(fa) ? that() : fa;
1979
- }; };
1980
- exports.altW = altW;
1981
- /**
1982
- * Identifies an associative operation on a type constructor. It is similar to `Semigroup`, except that it applies to
1983
- * types of kind `* -> *`.
1984
- *
1985
- * In case of `Option` returns the left-most non-`None` value.
1986
- *
1987
- * @example
1988
- * import * as O from 'fp-ts/Option'
1989
- * import { pipe } from 'fp-ts/function'
1990
- *
1991
- * assert.deepStrictEqual(
1992
- * pipe(
1993
- * O.some('a'),
1994
- * O.alt(() => O.some('b'))
1995
- * ),
1996
- * O.some('a')
1997
- * )
1998
- * assert.deepStrictEqual(
1999
- * pipe(
2000
- * O.none,
2001
- * O.alt(() => O.some('b'))
2002
- * ),
2003
- * O.some('b')
2004
- * )
2005
- *
2006
- * @category Alt
2007
- * @since 2.0.0
2008
- */
2009
- exports.alt = exports.altW;
2010
- /**
2011
- * @category Alternative
2012
- * @since 2.7.0
2013
- */
2014
- var zero = function () { return exports.none; };
2015
- exports.zero = zero;
2016
- /**
2017
- * @category MonadThrow
2018
- * @since 2.7.0
2019
- */
2020
- var throwError = function () { return exports.none; };
2021
- exports.throwError = throwError;
2022
- /**
2023
- * @category Extend
2024
- * @since 2.0.0
2025
- */
2026
- var extend = function (f) { return function (wa) {
2027
- return exports.isNone(wa) ? exports.none : exports.some(f(wa));
2028
- }; };
2029
- exports.extend = extend;
2030
- /**
2031
- * Derivable from `Extend`.
2032
- *
2033
- * @category combinators
2034
- * @since 2.0.0
2035
- */
2036
- exports.duplicate =
2037
- /*#__PURE__*/
2038
- exports.extend(_function.identity);
2039
- /**
2040
- * @category Foldable
2041
- * @since 2.0.0
2042
- */
2043
- var reduce = function (b, f) { return function (fa) {
2044
- return exports.isNone(fa) ? b : f(b, fa.value);
2045
- }; };
2046
- exports.reduce = reduce;
2047
- /**
2048
- * @category Foldable
2049
- * @since 2.0.0
2050
- */
2051
- var foldMap = function (M) { return function (f) { return function (fa) {
2052
- return exports.isNone(fa) ? M.empty : f(fa.value);
2053
- }; }; };
2054
- exports.foldMap = foldMap;
2055
- /**
2056
- * @category Foldable
2057
- * @since 2.0.0
2058
- */
2059
- var reduceRight = function (b, f) { return function (fa) {
2060
- return exports.isNone(fa) ? b : f(fa.value, b);
2061
- }; };
2062
- exports.reduceRight = reduceRight;
2063
- /**
2064
- * @category Compactable
2065
- * @since 2.0.0
2066
- */
2067
- exports.compact = exports.flatten;
2068
- var defaultSeparate = { left: exports.none, right: exports.none };
2069
- /**
2070
- * @category Compactable
2071
- * @since 2.0.0
2072
- */
2073
- var separate = function (ma) {
2074
- var o = _function.pipe(ma, exports.map(function (e) { return ({
2075
- left: getLeft(e),
2076
- right: getRight(e)
2077
- }); }));
2078
- return exports.isNone(o) ? defaultSeparate : o.value;
2079
- };
2080
- exports.separate = separate;
2081
- /**
2082
- * @category Filterable
2083
- * @since 2.0.0
2084
- */
2085
- var filter = function (predicate) { return function (fa) { return (exports.isNone(fa) ? exports.none : predicate(fa.value) ? fa : exports.none); }; };
2086
- exports.filter = filter;
2087
- /**
2088
- * @category Filterable
2089
- * @since 2.0.0
2090
- */
2091
- var filterMap = function (f) { return function (fa) {
2092
- return exports.isNone(fa) ? exports.none : f(fa.value);
2093
- }; };
2094
- exports.filterMap = filterMap;
2095
- /**
2096
- * @category Filterable
2097
- * @since 2.0.0
2098
- */
2099
- var partition = function (predicate) { return function (fa) {
2100
- return {
2101
- left: filter_(fa, function (a) { return !predicate(a); }),
2102
- right: filter_(fa, predicate)
2103
- };
2104
- }; };
2105
- exports.partition = partition;
2106
- /**
2107
- * @category Filterable
2108
- * @since 2.0.0
2109
- */
2110
- var partitionMap = function (f) { return _function.flow(exports.map(f), exports.separate); };
2111
- exports.partitionMap = partitionMap;
2112
- /**
2113
- * @category Traversable
2114
- * @since 2.6.3
2115
- */
2116
- 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)); }; }; };
2117
- exports.traverse = traverse;
2118
- /**
2119
- * @category Traversable
2120
- * @since 2.6.3
2121
- */
2122
- var sequence = function (F) { return function (ta) { return (exports.isNone(ta) ? F.of(exports.none) : F.map(ta.value, exports.some)); }; };
2123
- exports.sequence = sequence;
2124
- /**
2125
- * @category Witherable
2126
- * @since 2.6.5
2127
- */
2128
- var wither = function (F) { return function (f) { return function (fa) { return (exports.isNone(fa) ? F.of(exports.none) : f(fa.value)); }; }; };
2129
- exports.wither = wither;
2130
- /**
2131
- * @category Witherable
2132
- * @since 2.6.5
2133
- */
2134
- var wilt = function (F) { return function (f) { return function (fa) {
2135
- return exports.isNone(fa)
2136
- ? F.of({
2137
- left: exports.none,
2138
- right: exports.none
2139
- })
2140
- : F.map(f(fa.value), function (e) { return ({
2141
- left: getLeft(e),
2142
- right: getRight(e)
2143
- }); });
2144
- }; }; };
2145
- exports.wilt = wilt;
2146
- // -------------------------------------------------------------------------------------
2147
- // instances
2148
- // -------------------------------------------------------------------------------------
2149
- /**
2150
- * @category instances
2151
- * @since 2.0.0
2152
- */
2153
- exports.URI = 'Option';
2154
- /**
2155
- * @category instances
2156
- * @since 2.0.0
2157
- */
2158
- function getShow(S) {
2159
- return {
2160
- show: function (ma) { return (exports.isNone(ma) ? 'none' : "some(" + S.show(ma.value) + ")"); }
2161
- };
2162
- }
2163
- exports.getShow = getShow;
2164
- /**
2165
- * @example
2166
- * import { none, some, getEq } from 'fp-ts/Option'
2167
- * import { eqNumber } from 'fp-ts/Eq'
2168
- *
2169
- * const E = getEq(eqNumber)
2170
- * assert.strictEqual(E.equals(none, none), true)
2171
- * assert.strictEqual(E.equals(none, some(1)), false)
2172
- * assert.strictEqual(E.equals(some(1), none), false)
2173
- * assert.strictEqual(E.equals(some(1), some(2)), false)
2174
- * assert.strictEqual(E.equals(some(1), some(1)), true)
2175
- *
2176
- * @category instances
2177
- * @since 2.0.0
2178
- */
2179
- function getEq(E) {
2180
- return {
2181
- equals: function (x, y) { return x === y || (exports.isNone(x) ? exports.isNone(y) : exports.isNone(y) ? false : E.equals(x.value, y.value)); }
2182
- };
2183
- }
2184
- exports.getEq = getEq;
2185
- /**
2186
- * The `Ord` instance allows `Option` values to be compared with
2187
- * `compare`, whenever there is an `Ord` instance for
2188
- * the type the `Option` contains.
2189
- *
2190
- * `None` is considered to be less than any `Some` value.
2191
- *
2192
- *
2193
- * @example
2194
- * import { none, some, getOrd } from 'fp-ts/Option'
2195
- * import { ordNumber } from 'fp-ts/Ord'
2196
- *
2197
- * const O = getOrd(ordNumber)
2198
- * assert.strictEqual(O.compare(none, none), 0)
2199
- * assert.strictEqual(O.compare(none, some(1)), -1)
2200
- * assert.strictEqual(O.compare(some(1), none), 1)
2201
- * assert.strictEqual(O.compare(some(1), some(2)), -1)
2202
- * assert.strictEqual(O.compare(some(1), some(1)), 0)
2203
- *
2204
- * @category instances
2205
- * @since 2.0.0
2206
- */
2207
- function getOrd(O) {
2208
- return {
2209
- equals: getEq(O).equals,
2210
- compare: function (x, y) { return (x === y ? 0 : exports.isSome(x) ? (exports.isSome(y) ? O.compare(x.value, y.value) : 1) : -1); }
2211
- };
2212
- }
2213
- exports.getOrd = getOrd;
2214
- /**
2215
- * `Apply` semigroup
2216
- *
2217
- * | x | y | concat(x, y) |
2218
- * | ------- | ------- | ------------------ |
2219
- * | none | none | none |
2220
- * | some(a) | none | none |
2221
- * | none | some(a) | none |
2222
- * | some(a) | some(b) | some(concat(a, b)) |
2223
- *
2224
- * @example
2225
- * import { getApplySemigroup, some, none } from 'fp-ts/Option'
2226
- * import { semigroupSum } from 'fp-ts/Semigroup'
2227
- *
2228
- * const S = getApplySemigroup(semigroupSum)
2229
- * assert.deepStrictEqual(S.concat(none, none), none)
2230
- * assert.deepStrictEqual(S.concat(some(1), none), none)
2231
- * assert.deepStrictEqual(S.concat(none, some(1)), none)
2232
- * assert.deepStrictEqual(S.concat(some(1), some(2)), some(3))
2233
- *
2234
- * @category instances
2235
- * @since 2.0.0
2236
- */
2237
- function getApplySemigroup(S) {
2238
- return {
2239
- concat: function (x, y) { return (exports.isSome(x) && exports.isSome(y) ? exports.some(S.concat(x.value, y.value)) : exports.none); }
2240
- };
2241
- }
2242
- exports.getApplySemigroup = getApplySemigroup;
2243
- /**
2244
- * @category instances
2245
- * @since 2.0.0
2246
- */
2247
- function getApplyMonoid(M) {
2248
- return {
2249
- concat: getApplySemigroup(M).concat,
2250
- empty: exports.some(M.empty)
2251
- };
2252
- }
2253
- exports.getApplyMonoid = getApplyMonoid;
2254
- /**
2255
- * Monoid returning the left-most non-`None` value
2256
- *
2257
- * | x | y | concat(x, y) |
2258
- * | ------- | ------- | ------------ |
2259
- * | none | none | none |
2260
- * | some(a) | none | some(a) |
2261
- * | none | some(a) | some(a) |
2262
- * | some(a) | some(b) | some(a) |
2263
- *
2264
- * @example
2265
- * import { getFirstMonoid, some, none } from 'fp-ts/Option'
2266
- *
2267
- * const M = getFirstMonoid<number>()
2268
- * assert.deepStrictEqual(M.concat(none, none), none)
2269
- * assert.deepStrictEqual(M.concat(some(1), none), some(1))
2270
- * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
2271
- * assert.deepStrictEqual(M.concat(some(1), some(2)), some(1))
2272
- *
2273
- * @category instances
2274
- * @since 2.0.0
2275
- */
2276
- function getFirstMonoid() {
2277
- return {
2278
- concat: function (x, y) { return (exports.isNone(x) ? y : x); },
2279
- empty: exports.none
2280
- };
2281
- }
2282
- exports.getFirstMonoid = getFirstMonoid;
2283
- /**
2284
- * Monoid returning the right-most non-`None` value
2285
- *
2286
- * | x | y | concat(x, y) |
2287
- * | ------- | ------- | ------------ |
2288
- * | none | none | none |
2289
- * | some(a) | none | some(a) |
2290
- * | none | some(a) | some(a) |
2291
- * | some(a) | some(b) | some(b) |
2292
- *
2293
- * @example
2294
- * import { getLastMonoid, some, none } from 'fp-ts/Option'
2295
- *
2296
- * const M = getLastMonoid<number>()
2297
- * assert.deepStrictEqual(M.concat(none, none), none)
2298
- * assert.deepStrictEqual(M.concat(some(1), none), some(1))
2299
- * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
2300
- * assert.deepStrictEqual(M.concat(some(1), some(2)), some(2))
2301
- *
2302
- * @category instances
2303
- * @since 2.0.0
2304
- */
2305
- function getLastMonoid() {
2306
- return {
2307
- concat: function (x, y) { return (exports.isNone(y) ? x : y); },
2308
- empty: exports.none
2309
- };
2310
- }
2311
- exports.getLastMonoid = getLastMonoid;
2312
- /**
2313
- * Monoid returning the left-most non-`None` value. If both operands are `Some`s then the inner values are
2314
- * concatenated using the provided `Semigroup`
2315
- *
2316
- * | x | y | concat(x, y) |
2317
- * | ------- | ------- | ------------------ |
2318
- * | none | none | none |
2319
- * | some(a) | none | some(a) |
2320
- * | none | some(a) | some(a) |
2321
- * | some(a) | some(b) | some(concat(a, b)) |
2322
- *
2323
- * @example
2324
- * import { getMonoid, some, none } from 'fp-ts/Option'
2325
- * import { semigroupSum } from 'fp-ts/Semigroup'
2326
- *
2327
- * const M = getMonoid(semigroupSum)
2328
- * assert.deepStrictEqual(M.concat(none, none), none)
2329
- * assert.deepStrictEqual(M.concat(some(1), none), some(1))
2330
- * assert.deepStrictEqual(M.concat(none, some(1)), some(1))
2331
- * assert.deepStrictEqual(M.concat(some(1), some(2)), some(3))
2332
- *
2333
- * @category instances
2334
- * @since 2.0.0
2335
- */
2336
- function getMonoid(S) {
2337
- return {
2338
- concat: function (x, y) { return (exports.isNone(x) ? y : exports.isNone(y) ? x : exports.some(S.concat(x.value, y.value))); },
2339
- empty: exports.none
2340
- };
2341
- }
2342
- exports.getMonoid = getMonoid;
2343
- /**
2344
- * @category instances
2345
- * @since 2.7.0
2346
- */
2347
- exports.Functor = {
2348
- URI: exports.URI,
2349
- map: map_
2350
- };
2351
- /**
2352
- * @category instances
2353
- * @since 2.7.0
2354
- */
2355
- exports.Applicative = {
2356
- URI: exports.URI,
2357
- map: map_,
2358
- ap: ap_,
2359
- of: exports.of
2360
- };
2361
- /**
2362
- * @category instances
2363
- * @since 2.7.0
2364
- */
2365
- exports.Monad = {
2366
- URI: exports.URI,
2367
- map: map_,
2368
- ap: ap_,
2369
- of: exports.of,
2370
- chain: chain_
2371
- };
2372
- /**
2373
- * @category instances
2374
- * @since 2.7.0
2375
- */
2376
- exports.Foldable = {
2377
- URI: exports.URI,
2378
- reduce: reduce_,
2379
- foldMap: foldMap_,
2380
- reduceRight: reduceRight_
2381
- };
2382
- /**
2383
- * @category instances
2384
- * @since 2.7.0
2385
- */
2386
- exports.Alt = {
2387
- URI: exports.URI,
2388
- map: map_,
2389
- alt: alt_
2390
- };
2391
- /**
2392
- * @category instances
2393
- * @since 2.7.0
2394
- */
2395
- exports.Alternative = {
2396
- URI: exports.URI,
2397
- map: map_,
2398
- ap: ap_,
2399
- of: exports.of,
2400
- alt: alt_,
2401
- zero: exports.zero
2402
- };
2403
- /**
2404
- * @category instances
2405
- * @since 2.7.0
2406
- */
2407
- exports.Extend = {
2408
- URI: exports.URI,
2409
- map: map_,
2410
- extend: extend_
2411
- };
2412
- /**
2413
- * @category instances
2414
- * @since 2.7.0
2415
- */
2416
- exports.Compactable = {
2417
- URI: exports.URI,
2418
- compact: exports.compact,
2419
- separate: exports.separate
2420
- };
2421
- /**
2422
- * @category instances
2423
- * @since 2.7.0
2424
- */
2425
- exports.Filterable = {
2426
- URI: exports.URI,
2427
- map: map_,
2428
- compact: exports.compact,
2429
- separate: exports.separate,
2430
- filter: filter_,
2431
- filterMap: filterMap_,
2432
- partition: partition_,
2433
- partitionMap: partitionMap_
2434
- };
2435
- /**
2436
- * @category instances
2437
- * @since 2.7.0
2438
- */
2439
- exports.Traversable = {
2440
- URI: exports.URI,
2441
- map: map_,
2442
- reduce: reduce_,
2443
- foldMap: foldMap_,
2444
- reduceRight: reduceRight_,
2445
- traverse: traverse_,
2446
- sequence: exports.sequence
2447
- };
2448
- /**
2449
- * @category instances
2450
- * @since 2.7.0
2451
- */
2452
- exports.Witherable = {
2453
- URI: exports.URI,
2454
- map: map_,
2455
- reduce: reduce_,
2456
- foldMap: foldMap_,
2457
- reduceRight: reduceRight_,
2458
- traverse: traverse_,
2459
- sequence: exports.sequence,
2460
- compact: exports.compact,
2461
- separate: exports.separate,
2462
- filter: filter_,
2463
- filterMap: filterMap_,
2464
- partition: partition_,
2465
- partitionMap: partitionMap_,
2466
- wither: wither_,
2467
- wilt: wilt_
2468
- };
2469
- /**
2470
- * @category instances
2471
- * @since 2.7.0
2472
- */
2473
- exports.MonadThrow = {
2474
- URI: exports.URI,
2475
- map: map_,
2476
- ap: ap_,
2477
- of: exports.of,
2478
- chain: chain_,
2479
- throwError: exports.throwError
2480
- };
2481
- // TODO: remove in v3
2482
- /**
2483
- * @category instances
2484
- * @since 2.0.0
2485
- */
2486
- exports.option = {
2487
- URI: exports.URI,
2488
- map: map_,
2489
- of: exports.of,
2490
- ap: ap_,
2491
- chain: chain_,
2492
- reduce: reduce_,
2493
- foldMap: foldMap_,
2494
- reduceRight: reduceRight_,
2495
- traverse: traverse_,
2496
- sequence: exports.sequence,
2497
- zero: exports.zero,
2498
- alt: alt_,
2499
- extend: extend_,
2500
- compact: exports.compact,
2501
- separate: exports.separate,
2502
- filter: filter_,
2503
- filterMap: filterMap_,
2504
- partition: partition_,
2505
- partitionMap: partitionMap_,
2506
- wither: wither_,
2507
- wilt: wilt_,
2508
- throwError: exports.throwError
2509
- };
2510
- // -------------------------------------------------------------------------------------
2511
- // utils
2512
- // -------------------------------------------------------------------------------------
2513
- /**
2514
- * Returns `true` if `ma` contains `a`
2515
- *
2516
- * @example
2517
- * import { some, none, elem } from 'fp-ts/Option'
2518
- * import { eqNumber } from 'fp-ts/Eq'
2519
- *
2520
- * assert.strictEqual(elem(eqNumber)(1, some(1)), true)
2521
- * assert.strictEqual(elem(eqNumber)(2, some(1)), false)
2522
- * assert.strictEqual(elem(eqNumber)(1, none), false)
2523
- *
2524
- * @since 2.0.0
2525
- */
2526
- function elem(E) {
2527
- return function (a, ma) { return (exports.isNone(ma) ? false : E.equals(a, ma.value)); };
2528
- }
2529
- exports.elem = elem;
2530
- /**
2531
- * Returns `true` if the predicate is satisfied by the wrapped value
2532
- *
2533
- * @example
2534
- * import { some, none, exists } from 'fp-ts/Option'
2535
- * import { pipe } from 'fp-ts/function'
2536
- *
2537
- * assert.strictEqual(
2538
- * pipe(
2539
- * some(1),
2540
- * exists(n => n > 0)
2541
- * ),
2542
- * true
2543
- * )
2544
- * assert.strictEqual(
2545
- * pipe(
2546
- * some(1),
2547
- * exists(n => n > 1)
2548
- * ),
2549
- * false
2550
- * )
2551
- * assert.strictEqual(
2552
- * pipe(
2553
- * none,
2554
- * exists(n => n > 0)
2555
- * ),
2556
- * false
2557
- * )
2558
- *
2559
- * @since 2.0.0
2560
- */
2561
- function exists(predicate) {
2562
- return function (ma) { return (exports.isNone(ma) ? false : predicate(ma.value)); };
2563
- }
2564
- exports.exists = exists;
2565
- /**
2566
- * Returns a `Refinement` (i.e. a custom type guard) from a `Option` returning function.
2567
- * This function ensures that a custom type guard definition is type-safe.
2568
- *
2569
- * ```ts
2570
- * import { some, none, getRefinement } from 'fp-ts/Option'
2571
- *
2572
- * type A = { type: 'A' }
2573
- * type B = { type: 'B' }
2574
- * type C = A | B
2575
- *
2576
- * const isA = (c: C): c is A => c.type === 'B' // <= typo but typescript doesn't complain
2577
- * const isA = getRefinement<C, A>(c => (c.type === 'B' ? some(c) : none)) // static error: Type '"B"' is not assignable to type '"A"'
2578
- * ```
2579
- *
2580
- * @since 2.0.0
2581
- */
2582
- function getRefinement(getOption) {
2583
- return function (a) { return exports.isSome(getOption(a)); };
2584
- }
2585
- exports.getRefinement = getRefinement;
2586
- // -------------------------------------------------------------------------------------
2587
- // do notation
2588
- // -------------------------------------------------------------------------------------
2589
- /**
2590
- * @since 2.9.0
2591
- */
2592
- exports.Do =
2593
- /*#__PURE__*/
2594
- exports.of({});
2595
- /**
2596
- * @since 2.8.0
2597
- */
2598
- var bindTo = function (name) { return exports.map(_function.bindTo_(name)); };
2599
- exports.bindTo = bindTo;
2600
- /**
2601
- * @since 2.8.0
2602
- */
2603
- var bind = function (name, f) {
2604
- return exports.chain(function (a) {
2605
- return _function.pipe(f(a), exports.map(function (b) { return _function.bind_(a, name, b); }));
2606
- });
2607
- };
2608
- exports.bind = bind;
2609
- // -------------------------------------------------------------------------------------
2610
- // pipeable sequence S
2611
- // -------------------------------------------------------------------------------------
2612
- /**
2613
- * @since 2.8.0
2614
- */
2615
- var apS = function (name, fb) {
2616
- return _function.flow(exports.map(function (a) { return function (b) { return _function.bind_(a, name, b); }; }), exports.ap(fb));
2617
- };
2618
- exports.apS = apS;
2619
- // -------------------------------------------------------------------------------------
2620
- // array utils
2621
- // -------------------------------------------------------------------------------------
2622
- /**
2623
- *
2624
- * @since 2.9.0
2625
- */
2626
- var traverseArrayWithIndex = function (f) { return function (arr) {
2627
- // tslint:disable-next-line: readonly-array
2628
- var result = [];
2629
- for (var i = 0; i < arr.length; i++) {
2630
- var b = f(i, arr[i]);
2631
- if (exports.isNone(b)) {
2632
- return exports.none;
2633
- }
2634
- result.push(b.value);
2635
- }
2636
- return exports.some(result);
2637
- }; };
2638
- exports.traverseArrayWithIndex = traverseArrayWithIndex;
2639
- /**
2640
- * Runs an action for every element in array and accumulates the results in option
2641
- *
2642
- * this function have the same behavior of `A.sequence(O.option)` but it's optimized and perform better
2643
- *
2644
- * @example
2645
- *
2646
- * import * as A from 'fp-ts/Array'
2647
- * import { traverseArray, some, fromPredicate, none } from 'fp-ts/Option'
2648
- * import { pipe } from 'fp-ts/function'
2649
- *
2650
- * const arr = A.range(0, 10)
2651
- * assert.deepStrictEqual(pipe(arr, traverseArray(some)), some(arr))
2652
- * assert.deepStrictEqual(pipe(arr, traverseArray(fromPredicate((x) => x > 5))), none)
2653
- *
2654
- * @since 2.9.0
2655
- */
2656
- var traverseArray = function (f) { return exports.traverseArrayWithIndex(function (_, a) { return f(a); }); };
2657
- exports.traverseArray = traverseArray;
2658
- /**
2659
- * get an array of option and convert it to option of array
2660
- *
2661
- * this function have the same behavior of `A.sequence(O.option)` but it's optimized and perform better
2662
- *
2663
- * @example
2664
- *
2665
- * import * as A from 'fp-ts/Array'
2666
- * import { sequenceArray, some, none, fromPredicate } from 'fp-ts/Option'
2667
- * import { pipe } from 'fp-ts/function'
2668
- *
2669
- * const arr = A.range(0, 10)
2670
- * assert.deepStrictEqual(pipe(arr, A.map(some), sequenceArray), some(arr))
2671
- * assert.deepStrictEqual(pipe(arr, A.map(fromPredicate(x => x > 8)), sequenceArray), none)
2672
- *
2673
- * @since 2.9.0
2674
- */
2675
- exports.sequenceArray =
2676
- /*#__PURE__*/
2677
- exports.traverseArray(_function.identity);
2678
- });
2679
-
2680
- 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";
2681
-
2682
- var __assign$1 = (undefined && undefined.__assign) || function () {
2683
- __assign$1 = Object.assign || function(t) {
2684
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2685
- s = arguments[i];
2686
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2687
- t[p] = s[p];
2688
- }
2689
- return t;
2690
- };
2691
- return __assign$1.apply(this, arguments);
2692
- };
2693
- var __spreadArrays = (undefined && undefined.__spreadArrays) || function () {
2694
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
2695
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
2696
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2697
- r[k] = a[j];
2698
- return r;
2699
- };
2700
- var mix = function (one, two, mergeArrays) {
2701
- if (mergeArrays === void 0) { mergeArrays = false; }
2702
- if (!one || !two || typeof one !== "object" || typeof two !== "object")
2703
- return one;
2704
- var clone = __assign$1({}, one);
2705
- for (var prop in two) {
2706
- if (two.hasOwnProperty(prop)) {
2707
- if (two[prop] instanceof Array && one[prop] instanceof Array) {
2708
- clone[prop] = mergeArrays ? __spreadArrays(one[prop], two[prop]) : two[prop];
2709
- }
2710
- else if (typeof two[prop] === "object" && typeof one[prop] === "object") {
2711
- clone[prop] = mix(one[prop], two[prop], mergeArrays);
2712
- }
2713
- else {
2714
- clone[prop] = two[prop];
2715
- }
2716
- }
2717
- }
2718
- return clone;
2719
- };
2720
-
2721
- var __spreadArrays$1 = (undefined && undefined.__spreadArrays) || function () {
2722
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
2723
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
2724
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2725
- r[k] = a[j];
2726
- return r;
2727
- };
2728
- var config = {
2729
- // Default options
2730
- defaults: {},
2731
- // Error type
2732
- errorType: null,
2733
- // Polyfills
2734
- polyfills: {
2735
- fetch: null,
2736
- FormData: null,
2737
- URLSearchParams: null,
2738
- performance: null,
2739
- PerformanceObserver: null,
2740
- AbortController: null
2741
- },
2742
- polyfill: function (p, _a) {
2743
- var _b = _a === void 0 ? {} : _a, _c = _b.doThrow, doThrow = _c === void 0 ? true : _c, _d = _b.instance, instance = _d === void 0 ? false : _d;
2744
- var args = [];
2745
- for (var _i = 2; _i < arguments.length; _i++) {
2746
- args[_i - 2] = arguments[_i];
2747
- }
2748
- var res = this.polyfills[p] ||
2749
- (typeof self !== "undefined" ? self[p] : null) ||
2750
- (typeof global !== "undefined" ? global[p] : null);
2751
- if (doThrow && !res)
2752
- throw new Error(p + " is not defined");
2753
- return instance && res ? new (res.bind.apply(res, __spreadArrays$1([void 0], args)))() : res;
2754
- }
2755
- };
2756
-
2757
- var onMatch = function (entries, name, callback, _performance) {
2758
- if (!entries.getEntriesByName)
2759
- return false;
2760
- var matches = entries.getEntriesByName(name);
2761
- if (matches && matches.length > 0) {
2762
- callback(matches.reverse()[0]);
2763
- if (_performance.clearMeasures)
2764
- _performance.clearMeasures(name);
2765
- perfs.callbacks.delete(name);
2766
- if (perfs.callbacks.size < 1) {
2767
- perfs.observer.disconnect();
2768
- if (_performance.clearResourceTimings) {
2769
- _performance.clearResourceTimings();
2770
- }
2771
- }
2772
- return true;
2773
- }
2774
- return false;
2775
- };
2776
- var lazyObserver = function (_performance, _observer) {
2777
- if (!perfs.observer && _performance && _observer) {
2778
- perfs.observer = new _observer(function (entries) {
2779
- perfs.callbacks.forEach(function (callback, name) {
2780
- onMatch(entries, name, callback, _performance);
2781
- });
2782
- });
2783
- if (_performance.clearResourceTimings)
2784
- _performance.clearResourceTimings();
2785
- }
2786
- return perfs.observer;
2787
- };
2788
- var perfs = {
2789
- callbacks: new Map(),
2790
- observer: null,
2791
- observe: function (name, callback) {
2792
- if (!name || !callback)
2793
- return;
2794
- var _performance = config.polyfill("performance", { doThrow: false });
2795
- var _observer = config.polyfill("PerformanceObserver", { doThrow: false });
2796
- if (!lazyObserver(_performance, _observer))
2797
- return;
2798
- if (!onMatch(_performance, name, callback, _performance)) {
2799
- if (perfs.callbacks.size < 1)
2800
- perfs.observer.observe({ entryTypes: ["resource", "measure"] });
2801
- perfs.callbacks.set(name, callback);
2802
- }
2803
- }
2804
- };
2805
-
2806
- var middlewareHelper = function (middlewares) { return function (fetchFunction) {
2807
- return (middlewares.length === 0 ?
2808
- fetchFunction :
2809
- middlewares.length === 1 ?
2810
- middlewares[0](fetchFunction) :
2811
- middlewares.reduceRight(function (acc, curr, idx) {
2812
- return (idx === middlewares.length - 2) ? curr(acc(fetchFunction)) : curr(acc);
2813
- }));
2814
- }; };
2815
-
2816
- var WretchErrorWrapper = /** @class */ (function () {
2817
- function WretchErrorWrapper(error) {
2818
- this.error = error;
2819
- }
2820
- return WretchErrorWrapper;
2821
- }());
2822
- var resolver = function (wretcher) {
2823
- var url = wretcher._url, _catchers = wretcher._catchers, resolvers = wretcher._resolvers, middlewares = wretcher._middlewares, opts = wretcher._options;
2824
- var catchers = new Map(_catchers);
2825
- var finalOptions = mix(config.defaults, opts);
2826
- var fetchController = config.polyfill("AbortController", { doThrow: false, instance: true });
2827
- if (!finalOptions["signal"] && fetchController) {
2828
- finalOptions["signal"] = fetchController.signal;
2829
- }
2830
- // Request timeout
2831
- var timeout = {
2832
- ref: null,
2833
- clear: function () {
2834
- if (timeout.ref) {
2835
- clearTimeout(timeout.ref);
2836
- timeout.ref = null;
2837
- }
2838
- }
2839
- };
2840
- // The generated fetch request
2841
- var fetchRequest = middlewareHelper(middlewares)(config.polyfill("fetch"))(url, finalOptions);
2842
- // Throws on an http error
2843
- var throwingPromise = fetchRequest
2844
- .catch(function (error) {
2845
- throw new WretchErrorWrapper(error);
2846
- })
2847
- .then(function (response) {
2848
- timeout.clear();
2849
- if (!response.ok) {
2850
- return response[config.errorType || "text"]().then(function (msg) {
2851
- // Enhances the error object
2852
- var err = new Error(msg);
2853
- err[config.errorType || "text"] = msg;
2854
- err["status"] = response.status;
2855
- err["response"] = response;
2856
- throw err;
2857
- });
2858
- }
2859
- return response;
2860
- });
2861
- // Wraps the Promise in order to dispatch the error to a matching catcher
2862
- var catchersWrapper = function (promise) {
2863
- return promise.catch(function (err) {
2864
- timeout.clear();
2865
- var error = err instanceof WretchErrorWrapper ? err.error : err;
2866
- if (err instanceof WretchErrorWrapper && catchers.has("__fromFetch"))
2867
- return catchers.get("__fromFetch")(error, wretcher);
2868
- else if (catchers.has(error.status))
2869
- return catchers.get(error.status)(error, wretcher);
2870
- else if (catchers.has(error.name))
2871
- return catchers.get(error.name)(error, wretcher);
2872
- else
2873
- throw error;
2874
- });
2875
- };
2876
- var bodyParser = function (funName) { return function (cb) { return funName ?
2877
- // If a callback is provided, then callback with the body result otherwise return the parsed body itself.
2878
- catchersWrapper(throwingPromise.then(function (_) { return _ && _[funName](); }).then(function (_) { return cb ? cb(_) : _; })) :
2879
- // No body parsing method - return the response
2880
- catchersWrapper(throwingPromise.then(function (_) { return cb ? cb(_) : _; })); }; };
2881
- var responseChain = {
2882
- /**
2883
- * Retrieves the raw result as a promise.
2884
- */
2885
- res: bodyParser(null),
2886
- /**
2887
- * Retrieves the result as a parsed JSON object.
2888
- */
2889
- json: bodyParser("json"),
2890
- /**
2891
- * Retrieves the result as a Blob object.
2892
- */
2893
- blob: bodyParser("blob"),
2894
- /**
2895
- * Retrieves the result as a FormData object.
2896
- */
2897
- formData: bodyParser("formData"),
2898
- /**
2899
- * Retrieves the result as an ArrayBuffer object.
2900
- */
2901
- arrayBuffer: bodyParser("arrayBuffer"),
2902
- /**
2903
- * Retrieves the result as a string.
2904
- */
2905
- text: bodyParser("text"),
2906
- /**
2907
- * Performs a callback on the API performance timings of the request.
2908
- *
2909
- * Warning: Still experimental on browsers and node.js
2910
- */
2911
- perfs: function (cb) {
2912
- fetchRequest.then(function (res) { return perfs.observe(res.url, cb); });
2913
- return responseChain;
2914
- },
2915
- /**
2916
- * Aborts the request after a fixed time.
2917
- *
2918
- * @param time Time in milliseconds
2919
- * @param controller A custom controller
2920
- */
2921
- setTimeout: function (time, controller) {
2922
- if (controller === void 0) { controller = fetchController; }
2923
- timeout.clear();
2924
- timeout.ref = setTimeout(function () { return controller.abort(); }, time);
2925
- return responseChain;
2926
- },
2927
- /**
2928
- * Returns the automatically generated AbortController alongside the current wretch response as a pair.
2929
- */
2930
- controller: function () { return [fetchController, responseChain]; },
2931
- /**
2932
- * Catches an http response with a specific error code or name and performs a callback.
2933
- */
2934
- error: function (errorId, cb) {
2935
- catchers.set(errorId, cb);
2936
- return responseChain;
2937
- },
2938
- /**
2939
- * Catches a bad request (http code 400) and performs a callback.
2940
- */
2941
- badRequest: function (cb) { return responseChain.error(400, cb); },
2942
- /**
2943
- * Catches an unauthorized request (http code 401) and performs a callback.
2944
- */
2945
- unauthorized: function (cb) { return responseChain.error(401, cb); },
2946
- /**
2947
- * Catches a forbidden request (http code 403) and performs a callback.
2948
- */
2949
- forbidden: function (cb) { return responseChain.error(403, cb); },
2950
- /**
2951
- * Catches a "not found" request (http code 404) and performs a callback.
2952
- */
2953
- notFound: function (cb) { return responseChain.error(404, cb); },
2954
- /**
2955
- * Catches a timeout (http code 408) and performs a callback.
2956
- */
2957
- timeout: function (cb) { return responseChain.error(408, cb); },
2958
- /**
2959
- * Catches an internal server error (http code 500) and performs a callback.
2960
- */
2961
- internalError: function (cb) { return responseChain.error(500, cb); },
2962
- /**
2963
- * Catches errors thrown when calling the fetch function and performs a callback.
2964
- */
2965
- fetchError: function (cb) { return responseChain.error("__fromFetch", cb); },
2966
- /**
2967
- * Catches an AbortError and performs a callback.
2968
- */
2969
- onAbort: function (cb) { return responseChain.error("AbortError", cb); }
2970
- };
2971
- return resolvers.reduce(function (chain, r) { return r(chain, wretcher); }, responseChain);
2972
- };
2973
-
2974
- var __assign$2 = (undefined && undefined.__assign) || function () {
2975
- __assign$2 = Object.assign || function(t) {
2976
- for (var s, i = 1, n = arguments.length; i < n; i++) {
2977
- s = arguments[i];
2978
- for (var p in s) if (Object.prototype.hasOwnProperty.call(s, p))
2979
- t[p] = s[p];
2980
- }
2981
- return t;
2982
- };
2983
- return __assign$2.apply(this, arguments);
2984
- };
2985
- var __spreadArrays$2 = (undefined && undefined.__spreadArrays) || function () {
2986
- for (var s = 0, i = 0, il = arguments.length; i < il; i++) s += arguments[i].length;
2987
- for (var r = Array(s), k = 0, i = 0; i < il; i++)
2988
- for (var a = arguments[i], j = 0, jl = a.length; j < jl; j++, k++)
2989
- r[k] = a[j];
2990
- return r;
2991
- };
2992
- var JSON_MIME = "application/json";
2993
- var CONTENT_TYPE_HEADER = "Content-Type";
2994
- /**
2995
- * The Wretcher class used to perform easy fetch requests.
2996
- *
2997
- * Immutability : almost every method of this class return a fresh Wretcher object.
2998
- */
2999
- var Wretcher = /** @class */ (function () {
3000
- function Wretcher(_url, _options, _catchers, _resolvers, _middlewares, _deferredChain) {
3001
- if (_catchers === void 0) { _catchers = new Map(); }
3002
- if (_resolvers === void 0) { _resolvers = []; }
3003
- if (_middlewares === void 0) { _middlewares = []; }
3004
- if (_deferredChain === void 0) { _deferredChain = []; }
3005
- this._url = _url;
3006
- this._options = _options;
3007
- this._catchers = _catchers;
3008
- this._resolvers = _resolvers;
3009
- this._middlewares = _middlewares;
3010
- this._deferredChain = _deferredChain;
3011
- }
3012
- Wretcher.factory = function (url, options) {
3013
- if (url === void 0) { url = ""; }
3014
- if (options === void 0) { options = {}; }
3015
- return new Wretcher(url, options);
3016
- };
3017
- Wretcher.prototype.selfFactory = function (_a) {
3018
- 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;
3019
- return new Wretcher(url, __assign$2({}, options), new Map(catchers), __spreadArrays$2(resolvers), __spreadArrays$2(middlewares), __spreadArrays$2(deferredChain));
3020
- };
3021
- /**
3022
- * Sets the default fetch options used for every subsequent fetch call.
3023
- * @param options New default options
3024
- * @param mixin If true, mixes in instead of replacing the existing options
3025
- */
3026
- Wretcher.prototype.defaults = function (options, mixin) {
3027
- if (mixin === void 0) { mixin = false; }
3028
- config.defaults = mixin ? mix(config.defaults, options) : options;
3029
- return this;
3030
- };
3031
- /**
3032
- * Sets the method (text, json ...) used to parse the data contained in the response body in case of an HTTP error.
3033
- *
3034
- * Persists for every subsequent requests.
3035
- *
3036
- * Default is "text".
3037
- */
3038
- Wretcher.prototype.errorType = function (method) {
3039
- config.errorType = method;
3040
- return this;
3041
- };
3042
- /**
3043
- * Sets the non-global polyfills which will be used for every subsequent calls.
3044
- *
3045
- * Needed for libraries like [fetch-ponyfill](https://github.com/qubyte/fetch-ponyfill).
3046
- *
3047
- * @param polyfills An object containing the polyfills.
3048
- */
3049
- Wretcher.prototype.polyfills = function (polyfills) {
3050
- config.polyfills = __assign$2(__assign$2({}, config.polyfills), polyfills);
3051
- return this;
3052
- };
3053
- /**
3054
- * Returns a new Wretcher object with the argument url appended and the same options.
3055
- * @param url String url
3056
- * @param replace Boolean If true, replaces the current url instead of appending
3057
- */
3058
- Wretcher.prototype.url = function (url, replace) {
3059
- if (replace === void 0) { replace = false; }
3060
- if (replace)
3061
- return this.selfFactory({ url: url });
3062
- var split = this._url.split("?");
3063
- return this.selfFactory({
3064
- url: split.length > 1 ?
3065
- split[0] + url + "?" + split[1] :
3066
- this._url + url
3067
- });
3068
- };
3069
- /**
3070
- * Returns a new Wretcher object with the same url and new options.
3071
- * @param options New options
3072
- * @param mixin If true, mixes in instead of replacing the existing options
3073
- */
3074
- Wretcher.prototype.options = function (options, mixin) {
3075
- if (mixin === void 0) { mixin = true; }
3076
- return this.selfFactory({ options: mixin ? mix(this._options, options) : options });
3077
- };
3078
- /**
3079
- * Converts a javascript object to query parameters,
3080
- * then appends this query string to the current url.
3081
- *
3082
- * If given a string, use the string as the query verbatim.
3083
- *
3084
- * ```
3085
- * let w = wretch("http://example.com") // url is http://example.com
3086
- *
3087
- * // Chain query calls
3088
- * w = w.query({ a: 1, b : 2 }) // url is now http://example.com?a=1&b=2
3089
- * w = w.query("foo-bar-baz-woz") // url is now http://example.com?a=1&b=2&foo-bar-baz-woz
3090
- *
3091
- * // Pass true as the second argument to replace existing query parameters
3092
- * w = w.query("c=3&d=4", true) // url is now http://example.com?c=3&d=4
3093
- * ```
3094
- *
3095
- * @param qp An object which will be converted, or a string which will be used verbatim.
3096
- */
3097
- Wretcher.prototype.query = function (qp, replace) {
3098
- if (replace === void 0) { replace = false; }
3099
- return this.selfFactory({ url: appendQueryParams(this._url, qp, replace) });
3100
- };
3101
- /**
3102
- * Set request headers.
3103
- * @param headerValues An object containing header keys and values
3104
- */
3105
- Wretcher.prototype.headers = function (headerValues) {
3106
- return this.selfFactory({ options: mix(this._options, { headers: headerValues || {} }) });
3107
- };
3108
- /**
3109
- * Shortcut to set the "Accept" header.
3110
- * @param headerValue Header value
3111
- */
3112
- Wretcher.prototype.accept = function (headerValue) {
3113
- return this.headers({ Accept: headerValue });
3114
- };
3115
- /**
3116
- * Shortcut to set the "Content-Type" header.
3117
- * @param headerValue Header value
3118
- */
3119
- Wretcher.prototype.content = function (headerValue) {
3120
- var _a;
3121
- return this.headers((_a = {}, _a[CONTENT_TYPE_HEADER] = headerValue, _a));
3122
- };
3123
- /**
3124
- * Shortcut to set the "Authorization" header.
3125
- * @param headerValue Header value
3126
- */
3127
- Wretcher.prototype.auth = function (headerValue) {
3128
- return this.headers({ Authorization: headerValue });
3129
- };
3130
- /**
3131
- * Adds a default catcher which will be called on every subsequent request error when the error code matches.
3132
- * @param errorId Error code or name
3133
- * @param catcher: The catcher method
3134
- */
3135
- Wretcher.prototype.catcher = function (errorId, catcher) {
3136
- var newMap = new Map(this._catchers);
3137
- newMap.set(errorId, catcher);
3138
- return this.selfFactory({ catchers: newMap });
3139
- };
3140
- /**
3141
- * Associates a custom signal with the request.
3142
- * @param controller : An AbortController
3143
- */
3144
- Wretcher.prototype.signal = function (controller) {
3145
- return this.selfFactory({ options: __assign$2(__assign$2({}, this._options), { signal: controller.signal }) });
3146
- };
3147
- /**
3148
- * Program a resolver to perform response chain tasks automatically.
3149
- * @param doResolve : Resolver callback
3150
- */
3151
- Wretcher.prototype.resolve = function (doResolve, clear) {
3152
- if (clear === void 0) { clear = false; }
3153
- return this.selfFactory({ resolvers: clear ? [doResolve] : __spreadArrays$2(this._resolvers, [doResolve]) });
3154
- };
3155
- /**
3156
- * Defer wretcher methods that will be chained and called just before the request is performed.
3157
- */
3158
- Wretcher.prototype.defer = function (callback, clear) {
3159
- if (clear === void 0) { clear = false; }
3160
- return this.selfFactory({
3161
- deferredChain: clear ? [callback] : __spreadArrays$2(this._deferredChain, [callback])
3162
- });
3163
- };
3164
- /**
3165
- * Add middlewares to intercept a request before being sent.
3166
- */
3167
- Wretcher.prototype.middlewares = function (middlewares, clear) {
3168
- if (clear === void 0) { clear = false; }
3169
- return this.selfFactory({
3170
- middlewares: clear ? middlewares : __spreadArrays$2(this._middlewares, middlewares)
3171
- });
3172
- };
3173
- Wretcher.prototype.method = function (method, options, body) {
3174
- if (options === void 0) { options = {}; }
3175
- if (body === void 0) { body = null; }
3176
- var headers = this._options.headers;
3177
- var baseWretcher = !body ? this :
3178
- typeof body === "object" && (!headers ||
3179
- Object.entries(headers).every(function (_a) {
3180
- var k = _a[0], v = _a[1];
3181
- return k.toLowerCase() !== CONTENT_TYPE_HEADER.toLowerCase() ||
3182
- v.startsWith(JSON_MIME);
3183
- })) ? this.json(body) :
3184
- this.body(body);
3185
- baseWretcher = baseWretcher.options(__assign$2(__assign$2({}, options), { method: method }));
3186
- var deferredWretcher = baseWretcher._deferredChain.reduce(function (acc, curr) { return curr(acc, acc._url, acc._options); }, baseWretcher);
3187
- return resolver(deferredWretcher);
3188
- };
3189
- /**
3190
- * Performs a get request.
3191
- */
3192
- Wretcher.prototype.get = function (options) {
3193
- return this.method("GET", options);
3194
- };
3195
- /**
3196
- * Performs a delete request.
3197
- */
3198
- Wretcher.prototype.delete = function (options) {
3199
- return this.method("DELETE", options);
3200
- };
3201
- /**
3202
- * Performs a put request.
3203
- */
3204
- Wretcher.prototype.put = function (body, options) {
3205
- return this.method("PUT", options, body);
3206
- };
3207
- /**
3208
- * Performs a post request.
3209
- */
3210
- Wretcher.prototype.post = function (body, options) {
3211
- return this.method("POST", options, body);
3212
- };
3213
- /**
3214
- * Performs a patch request.
3215
- */
3216
- Wretcher.prototype.patch = function (body, options) {
3217
- return this.method("PATCH", options, body);
3218
- };
3219
- /**
3220
- * Performs a head request.
3221
- */
3222
- Wretcher.prototype.head = function (options) {
3223
- return this.method("HEAD", options);
3224
- };
3225
- /**
3226
- * Performs an options request
3227
- */
3228
- Wretcher.prototype.opts = function (options) {
3229
- return this.method("OPTIONS", options);
3230
- };
3231
- /**
3232
- * Replay a request.
3233
- */
3234
- Wretcher.prototype.replay = function (options) {
3235
- return this.method(this._options.method, options);
3236
- };
3237
- /**
3238
- * Sets the request body with any content.
3239
- * @param contents The body contents
3240
- */
3241
- Wretcher.prototype.body = function (contents) {
3242
- return this.selfFactory({ options: __assign$2(__assign$2({}, this._options), { body: contents }) });
3243
- };
3244
- /**
3245
- * Sets the content type header, stringifies an object and sets the request body.
3246
- * @param jsObject An object which will be serialized into a JSON
3247
- */
3248
- Wretcher.prototype.json = function (jsObject) {
3249
- var _a;
3250
- var preservedContentType = (_a = Object.entries(this._options.headers || {}).find(function (_a) {
3251
- var k = _a[0], v = _a[1];
3252
- return k.toLowerCase() === CONTENT_TYPE_HEADER.toLowerCase() && v.startsWith(JSON_MIME);
3253
- })) === null || _a === void 0 ? void 0 : _a[1];
3254
- return this.content(preservedContentType || JSON_MIME).body(JSON.stringify(jsObject));
3255
- };
3256
- /**
3257
- * Converts the javascript object to a FormData and sets the request body.
3258
- * @param formObject An object which will be converted to a FormData
3259
- * @param recursive If `true`, will recurse through all nested objects
3260
- * Can be set as an array of string to exclude specific keys.
3261
- * See https://github.com/elbywan/wretch/issues/68 for more details.
3262
- */
3263
- Wretcher.prototype.formData = function (formObject, recursive) {
3264
- if (recursive === void 0) { recursive = false; }
3265
- return this.body(convertFormData(formObject, recursive));
3266
- };
3267
- /**
3268
- * Converts the input to an url encoded string and sets the content-type header and body.
3269
- * If the input argument is already a string, skips the conversion part.
3270
- *
3271
- * @param input An object to convert into an url encoded string or an already encoded string
3272
- */
3273
- Wretcher.prototype.formUrl = function (input) {
3274
- return this
3275
- .body(typeof input === "string" ? input : convertFormUrl(input))
3276
- .content("application/x-www-form-urlencoded");
3277
- };
3278
- return Wretcher;
3279
- }());
3280
- // Internal helpers
3281
- var appendQueryParams = function (url, qp, replace) {
3282
- var queryString;
3283
- if (typeof qp === "string") {
3284
- queryString = qp;
3285
- }
3286
- else {
3287
- var usp = config.polyfill("URLSearchParams", { instance: true });
3288
- for (var key in qp) {
3289
- if (qp[key] instanceof Array) {
3290
- for (var _i = 0, _a = qp[key]; _i < _a.length; _i++) {
3291
- var val = _a[_i];
3292
- usp.append(key, val);
3293
- }
3294
- }
3295
- else {
3296
- usp.append(key, qp[key]);
3297
- }
3298
- }
3299
- queryString = usp.toString();
3300
- }
3301
- var split = url.split("?");
3302
- if (replace || split.length < 2)
3303
- return split[0] + "?" + queryString;
3304
- return url + "&" + queryString;
3305
- };
3306
- function convertFormData(formObject, recursive, formData, ancestors) {
3307
- if (recursive === void 0) { recursive = false; }
3308
- if (formData === void 0) { formData = config.polyfill("FormData", { instance: true }); }
3309
- if (ancestors === void 0) { ancestors = []; }
3310
- Object.entries(formObject).forEach(function (_a) {
3311
- var key = _a[0], value = _a[1];
3312
- var formKey = ancestors.reduce(function (acc, ancestor) { return (acc ? acc + "[" + ancestor + "]" : ancestor); }, null);
3313
- formKey = formKey ? formKey + "[" + key + "]" : key;
3314
- if (value instanceof Array) {
3315
- for (var _i = 0, value_1 = value; _i < value_1.length; _i++) {
3316
- var item = value_1[_i];
3317
- formData.append(formKey + "[]", item);
3318
- }
3319
- }
3320
- else if (recursive &&
3321
- typeof value === "object" &&
3322
- (!(recursive instanceof Array) ||
3323
- !recursive.includes(key))) {
3324
- if (value !== null) {
3325
- convertFormData(value, recursive, formData, __spreadArrays$2(ancestors, [key]));
3326
- }
3327
- }
3328
- else {
3329
- formData.append(formKey, value);
3330
- }
3331
- });
3332
- return formData;
3333
- }
3334
- function encodeQueryValue(key, value) {
3335
- return encodeURIComponent(key) +
3336
- "=" +
3337
- encodeURIComponent(typeof value === "object" ?
3338
- JSON.stringify(value) :
3339
- "" + value);
3340
- }
3341
- function convertFormUrl(formObject) {
3342
- return Object.keys(formObject)
3343
- .map(function (key) {
3344
- var value = formObject[key];
3345
- if (value instanceof Array) {
3346
- return value.map(function (v) { return encodeQueryValue(key, v); }).join("&");
3347
- }
3348
- return encodeQueryValue(key, value);
3349
- })
3350
- .join("&");
3351
- }
3352
-
3353
- var factory = Wretcher.factory;
3354
- factory["default"] = Wretcher.factory;
3355
-
3356
- function buildBackendApiClient() {
3357
- const jwt = superSelectionAppService.jwt;
3358
- const profileId = superSelectionAppService.profileId;
3359
- const accountId = superSelectionAppService.accountIdOrDefault;
3360
- const partnerId = superSelectionAppService.partnerIdOrDefault;
3361
- return factory(superSelectionAppService.apiBaseUrl).headers({
3362
- Authorization: `Bearer ${jwt}`,
3363
- 'X-PROFILE-ID': profileId,
3364
- 'X-PARTNER-ID': partnerId,
3365
- 'X-ACCOUNT-ID': accountId
3366
- });
3367
- }
3368
-
3369
- const slate = {
3370
- fundId: 'slate',
3371
- usi: '32367272075001'
3372
- };
3373
-
3374
- function hydratePromotedFundChoiceDtoKind(dto) {
3375
- if ('slate' in dto) {
3376
- dto.kind = 'slate';
3377
- }
3378
- else if ('australianRetirementTrust' in dto) {
3379
- dto.kind = 'australianRetirementTrust';
3380
- }
3381
- else if ('aware' in dto) {
3382
- dto.kind = 'aware';
3383
- }
3384
- else if ('active' in dto) {
3385
- dto.kind = 'active';
3386
- }
3387
- else if ('australianEthical' in dto) {
3388
- dto.kind = 'australianEthical';
3389
- }
3390
- else if ('virgin' in dto) {
3391
- dto.kind = 'virgin';
3392
- }
3393
- else if ('spirit' in dto) {
3394
- dto.kind = 'spirit';
3395
- }
3396
- else if ('firstSuper' in dto) {
3397
- dto.kind = 'firstSuper';
3398
- }
3399
- else if ('mercerMyChoice' in dto) {
3400
- dto.kind = 'mercerMyChoice';
3401
- }
3402
- else if ('generic' in dto) {
3403
- dto.kind = 'generic';
3404
- }
3405
- }
3406
- function getPromotedFundUsi(dto) {
3407
- switch (dto.kind) {
3408
- case 'slate':
3409
- return slate.usi;
3410
- case 'australianRetirementTrust':
3411
- return dto.australianRetirementTrust.usi;
3412
- case 'aware':
3413
- return dto.aware.usi;
3414
- case 'active':
3415
- return dto.active.usi;
3416
- case 'australianEthical':
3417
- return dto.australianEthical.usi;
3418
- case 'virgin':
3419
- return dto.virgin.usi;
3420
- case 'spirit':
3421
- return dto.spirit.usi;
3422
- case 'firstSuper':
3423
- return dto.firstSuper.usi;
3424
- case 'mercerMyChoice':
3425
- return dto.mercerMyChoice.usi;
3426
- case 'generic':
3427
- return dto.generic.usi;
3428
- default:
3429
- return '';
3430
- }
3431
- }
3432
- function getPromotedFundId(dto) {
3433
- switch (dto.kind) {
3434
- case 'slate':
3435
- return slate.fundId;
3436
- case 'australianRetirementTrust':
3437
- return 'australian-retirement-trust';
3438
- case 'aware':
3439
- return 'aware';
3440
- case 'active':
3441
- return 'active';
3442
- case 'australianEthical':
3443
- return 'australian-ethical';
3444
- case 'virgin':
3445
- return 'virgin';
3446
- case 'spirit':
3447
- return 'spirit';
3448
- case 'firstSuper':
3449
- return 'first-super';
3450
- case 'mercerMyChoice':
3451
- return 'mercermychoice';
3452
- case 'generic':
3453
- return dto.generic.fundId;
3454
- default:
3455
- return '';
3456
- }
3457
- }
3458
- function getSuperChoiceUsi(dto) {
3459
- switch (dto.kind) {
3460
- case 'Promoted':
3461
- return some(getPromotedFundUsi(dto.promoted));
3462
- case 'MyOwnFund':
3463
- return some(dto.myOwnFund.usi);
3464
- case 'SMSF':
3465
- return none;
3466
- case 'Default':
3467
- return some(dto.default.usi);
3468
- case 'PromotedDefault':
3469
- return some(dto.promotedDefault.usi);
3470
- case 'DefinedBenefits':
3471
- return some(dto.definedBenefits.usi);
3472
- case 'PromotedDefaultWithJoin':
3473
- return some(dto.promotedDefaultWithJoin.usi);
3474
- default:
3475
- return none;
3476
- }
3477
- }
3478
- function getPromotedFundMemberNumber(dto) {
3479
- switch (dto.kind) {
3480
- case 'slate':
3481
- return dto.slate.memberNumber;
3482
- case 'australianRetirementTrust':
3483
- return dto.australianRetirementTrust.memberNumber;
3484
- case 'aware':
3485
- return dto.aware.memberNumber;
3486
- case 'active':
3487
- return dto.active.memberNumber;
3488
- case 'australianEthical':
3489
- return dto.australianEthical.memberNumber;
3490
- case 'virgin':
3491
- return dto.virgin.memberNumber;
3492
- case 'spirit':
3493
- return dto.spirit.memberNumber;
3494
- case 'firstSuper':
3495
- return dto.firstSuper.memberNumber;
3496
- case 'mercerMyChoice':
3497
- return dto.mercerMyChoice.memberNumber;
3498
- case 'generic':
3499
- return dto.generic.memberNumber;
3500
- default:
3501
- return '';
3502
- }
3503
- }
3504
- function getSuperChoiceMemberNumber(dto) {
3505
- switch (dto.kind) {
3506
- case 'Promoted':
3507
- return some(getPromotedFundMemberNumber(dto.promoted));
3508
- case 'MyOwnFund':
3509
- return some(dto.myOwnFund.memberNumber);
3510
- case 'DefinedBenefits':
3511
- return some(dto.definedBenefits.memberNumber);
3512
- case 'PromotedDefaultWithJoin':
3513
- return some(dto.promotedDefaultWithJoin.memberNumber);
3514
- case 'SMSF':
3515
- case 'Default':
3516
- case 'PromotedDefault':
3517
- return none;
3518
- default:
3519
- return none;
3520
- }
3521
- }
3522
- function hydrateSuperChoiceDetailsDtoKind(dto) {
3523
- if ('promoted' in dto) {
3524
- dto.kind = 'Promoted';
3525
- }
3526
- else if ('myOwnFund' in dto) {
3527
- dto.kind = 'MyOwnFund';
3528
- }
3529
- else if ('smsf' in dto) {
3530
- dto.kind = 'SMSF';
3531
- }
3532
- else if ('default' in dto) {
3533
- dto.kind = 'Default';
3534
- }
3535
- else if ('promotedDefault' in dto) {
3536
- dto.kind = 'PromotedDefault';
3537
- }
3538
- else if ('definedBenefits' in dto) {
3539
- dto.kind = 'DefinedBenefits';
3540
- }
3541
- else if ('promotedDefaultWithJoin' in dto) {
3542
- dto.kind = 'PromotedDefaultWithJoin';
3543
- }
3544
- }
3545
-
3546
- class SuperSelectionApi {
3547
- async getAustralianFundsAsync(searchFilter, includeInactive = false) {
3548
- return buildBackendApiClient()
3549
- .url(`super-choice/australian-funds-v2?${this.toQueryString(includeInactive, searchFilter)}`)
3550
- .get()
3551
- .notFound(() => {
3552
- throw new Error('Failed to fetch the list of australian super funds.');
3553
- })
3554
- .json();
3555
- }
3556
- async getAustralianFundAsync(usi, includeInactive) {
3557
- const queryStr = includeInactive ? '?includeInactive=true' : '';
3558
- return buildBackendApiClient()
3559
- .url(`super-choice/australian-funds/${usi}${queryStr}`)
3560
- .get()
3561
- .notFound(() => {
3562
- throw new Error('Failed to fetch australian super fund.');
3563
- })
3564
- .json();
3565
- }
3566
- async getAppStateAsync() {
3567
- var _a;
3568
- const response = await buildBackendApiClient()
3569
- .url('client-app-state')
3570
- .get()
3571
- .notFound(() => {
3572
- throw new Error('Failed to fetch application configuration.');
3573
- })
3574
- .json();
3575
- if ((_a = response.superBuyer.superChoice) === null || _a === void 0 ? void 0 : _a.choiceDetails) {
3576
- hydrateSuperChoiceDetailsDtoKind(response.superBuyer.superChoice.choiceDetails);
3577
- switch (response.superBuyer.superChoice.choiceDetails.kind) {
3578
- case 'Promoted':
3579
- hydratePromotedFundChoiceDtoKind(response.superBuyer.superChoice.choiceDetails.promoted);
3580
- break;
3581
- }
3582
- }
3583
- return response;
3584
- }
3585
- async clickPromotedTileAsync(payload) {
3586
- return buildBackendApiClient().url('click-promoted-tile').post(payload).res();
3587
- }
3588
- async viewSuperFundPanelAsync(payload) {
3589
- return buildBackendApiClient().url('view-super-fund-panel').post(payload).res();
3590
- }
3591
- toSearchFilterQueryString(searchFilter) {
3592
- return (`search=${searchFilter.searchString}` +
3593
- (searchFilter.maxRecordCount > 0 ? '&maxRecordCount=' + searchFilter.maxRecordCount : ''));
3594
- }
3595
- toQueryString(includeInactive, searchFilter) {
3596
- const search = this.toSearchFilterQueryString(searchFilter);
3597
- const inactive = includeInactive ? 'includeInactive=true' : '';
3598
- const isNotEmpty = (s) => s && s.length;
3599
- return [search, inactive].filter(isNotEmpty).join('&');
3600
- }
3601
- }
3602
- const superSelectionApi = new SuperSelectionApi();
711
+ else if (location.pathname.charAt(0) !== '/') {
712
+ location.pathname = resolvePathname(location.pathname, currentLocation.pathname);
713
+ }
714
+ }
715
+ else {
716
+ // When there is no prior location and pathname is empty, set it to /
717
+ if (!location.pathname) {
718
+ location.pathname = '/';
719
+ }
720
+ }
721
+ location.query = parseQueryString(location.search || '');
722
+ return location;
723
+ };
3603
724
 
3604
- var SuperCampaignComponentStatus;
3605
- (function (SuperCampaignComponentStatus) {
3606
- SuperCampaignComponentStatus[SuperCampaignComponentStatus["NotLoaded"] = 1] = "NotLoaded";
3607
- SuperCampaignComponentStatus[SuperCampaignComponentStatus["Loaded"] = 2] = "Loaded";
3608
- SuperCampaignComponentStatus[SuperCampaignComponentStatus["NotWorking"] = 3] = "NotWorking";
3609
- })(SuperCampaignComponentStatus || (SuperCampaignComponentStatus = {}));
3610
- class SuperCampaignState {
3611
- constructor() {
3612
- this._promotedFundsShown = [];
3613
- }
3614
- get PromotedFundIds() {
3615
- return this._promotedFundsShown.map((p) => p.fundId);
3616
- }
3617
- set promotedFundsShown(value) {
3618
- this._promotedFundsShown = value;
3619
- }
3620
- get DefaultFundPosition() {
3621
- const index = this._promotedFundsShown.findIndex((value) => value.fundType === 'promoted-default');
3622
- if (index === -1)
3623
- return undefined;
3624
- return index + 1;
3625
- }
3626
- }
3627
- const initialState = {
3628
- apiBaseUrl: Option.none,
3629
- appBaseUrl: Option.none,
3630
- profileId: Option.none,
3631
- jwt: Option.none,
3632
- superBuyer: Option.none,
3633
- superChoicePrefill: Option.none,
3634
- promotedFunds: Option.none,
3635
- accountConfiguration: Option.none,
3636
- profileConfiguration: Option.none,
3637
- hasSuccessPageBeenAcknowledged: false,
3638
- hasSuperSelectionBeenSubmitted: false,
3639
- isDefinedBenefitsEligible: Option.none,
3640
- superCampaignEnabled: true,
3641
- superCampaignState: undefined,
3642
- superCampaignComponentStatus: SuperCampaignComponentStatus.NotLoaded,
3643
- hideFooterSection: false,
3644
- bringYourOwnFundCustomStepEnabled: false,
3645
- featuredFundsEnabled: false
725
+ let cacheCount = 0;
726
+ const patternCache = {};
727
+ const cacheLimit = 10000;
728
+ // Memoized function for creating the path match regex
729
+ const compilePath = (pattern, options) => {
730
+ const cacheKey = `${options.end}${options.strict}`;
731
+ const cache = patternCache[cacheKey] || (patternCache[cacheKey] = {});
732
+ const cachePattern = JSON.stringify(pattern);
733
+ if (cache[cachePattern]) {
734
+ return cache[cachePattern];
735
+ }
736
+ const keys = [];
737
+ const re = pathToRegexp(pattern, keys, options);
738
+ const compiledPattern = { re, keys };
739
+ if (cacheCount < cacheLimit) {
740
+ cache[cachePattern] = compiledPattern;
741
+ cacheCount += 1;
742
+ }
743
+ return compiledPattern;
744
+ };
745
+ /**
746
+ * Public API for matching a URL pathname to a path pattern.
747
+ */
748
+ const matchPath = (pathname, options = {}) => {
749
+ if (typeof options === 'string') {
750
+ options = { path: options };
751
+ }
752
+ const { path = '/', exact = false, strict = false } = options;
753
+ const { re, keys } = compilePath(path, { end: exact, strict });
754
+ const match = re.exec(pathname);
755
+ if (!match) {
756
+ return null;
757
+ }
758
+ const [url, ...values] = match;
759
+ const isExact = pathname === url;
760
+ if (exact && !isExact) {
761
+ return null;
762
+ }
763
+ return {
764
+ path,
765
+ url: path === '/' && url === '' ? '/' : url,
766
+ isExact,
767
+ params: keys.reduce((memo, key, index) => {
768
+ memo[key.name] = values[index];
769
+ return memo;
770
+ }, {})
771
+ };
772
+ };
773
+ const matchesAreEqual = (a, b) => {
774
+ if (a == null && b == null) {
775
+ return true;
776
+ }
777
+ if (b == null) {
778
+ return false;
779
+ }
780
+ return a && b &&
781
+ a.path === b.path &&
782
+ a.url === b.url &&
783
+ valueEqual(a.params, b.params);
3646
784
  };
3647
785
 
3648
- class SuperSelectionAppService {
3649
- constructor() {
3650
- const { state, onChange } = createStore(initialState);
3651
- this._state = state;
3652
- this._onChange = onChange;
3653
- onChange('jwt', (jwt) => {
3654
- this._state.profileId = _function.pipe(jwt, Option.chain((jwtValue) => Option.fromNullable(o(jwtValue).sub)));
3655
- });
3656
- }
3657
- get state() {
3658
- return this._state;
3659
- }
3660
- get onChange() {
3661
- return this._onChange;
3662
- }
3663
- get superBuyer() {
3664
- if (Option.isNone(this._state.superBuyer)) {
3665
- throw Error('User information is not set');
3666
- }
3667
- return this._state.superBuyer.value;
3668
- }
3669
- get apiBaseUrl() {
3670
- if (Option.isNone(this._state.apiBaseUrl)) {
3671
- throw Error('API base URL is not set');
3672
- }
3673
- return this._state.apiBaseUrl.value;
3674
- }
3675
- get appBaseUrl() {
3676
- if (Option.isNone(this._state.appBaseUrl)) {
3677
- throw Error('App base URL is not set');
3678
- }
3679
- return this._state.appBaseUrl.value;
3680
- }
3681
- get promotedFunds() {
3682
- if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
3683
- return this.superCampaignState.PromotedFundIds;
3684
- }
3685
- if (Option.isNone(this._state.promotedFunds)) {
3686
- throw Error('Promoted Funds is not set');
3687
- }
3688
- return this._state.promotedFunds.value;
3689
- }
3690
- get promotedDefaultFundPosition() {
3691
- if (this.state.superCampaignEnabled && this.superCampaignState !== undefined) {
3692
- return Option.fromNullable(this.superCampaignState.DefaultFundPosition);
3693
- }
3694
- return Option.none;
786
+ var PromiseButtonState;
787
+ (function (PromiseButtonState) {
788
+ PromiseButtonState[PromiseButtonState["Available"] = 0] = "Available";
789
+ PromiseButtonState[PromiseButtonState["Pending"] = 1] = "Pending";
790
+ PromiseButtonState[PromiseButtonState["Error"] = 2] = "Error";
791
+ })(PromiseButtonState || (PromiseButtonState = {}));
792
+ const Button = class {
793
+ constructor(hostRef) {
794
+ registerInstance(this, hostRef);
795
+ this.fillWidth = false;
796
+ this.fillWidthOnMobile = false;
797
+ this.disabled = false;
798
+ this.variant = 'primary';
799
+ this.size = 'base';
800
+ this.promiseFn = () => Promise.resolve();
801
+ // eslint-disable-next-line @typescript-eslint/member-ordering
802
+ this.state = PromiseButtonState.Available;
3695
803
  }
3696
- get promotedFundsConfig() {
3697
- return {
3698
- shownFunds: this.promotedFunds,
3699
- promotedDefaultFundPosition: Option.toUndefined(this.promotedDefaultFundPosition),
3700
- promotedFundsConfigSource: this.isUsingSuperCampaign ? 'superCampaign' : 'superSelection'
804
+ render() {
805
+ const sizeCss = {
806
+ xs: 'px-2.5 py-1.5 text-xs',
807
+ base: 'px-4 py-2 text-base',
808
+ xl: 'px-6 py-3 text-base'
3701
809
  };
810
+ return (h("button", { "data-testid": this.testid, class: {
811
+ [sizeCss[this.size]]: true,
812
+ 'inline-flex items-center justify-center border font-medium': true,
813
+ 'rounded-md shadow-sm focus:outline-none focus:ring-2': true,
814
+ 'focus:ring-offset-2 focus:ring-primary-focus pointer-events-auto': true,
815
+ 'disabled:pointer-events-none disabled:border-gray-300 disabled:bg-gray-100 disabled:text-gray-400': true,
816
+ 'border-transparent text-white bg-primary-base hover:bg-primary-hover': this.variant === 'primary',
817
+ 'border-gray-300 text-gray-700 bg-white hover:bg-gray-50': this.variant === 'secondary',
818
+ 'border-transparent bg-primary-light hover:bg-primary-base text-primary-dark hover:text-white': this.variant === 'light',
819
+ 'w-full': this.fillWidth || this.fillWidthOnMobile,
820
+ 'sm:w-auto': this.fillWidthOnMobile
821
+ }, disabled: this.disabled, onClick: () => this.clicked() }, this.state === PromiseButtonState.Pending && (h("sss-loading-indicator", { theme: this.variant === 'primary' ? 'light' : 'primary', size: 16 })), h("div", { class: { hidden: this.state === PromiseButtonState.Pending } }, h("slot", null))));
3702
822
  }
3703
- get profileId() {
3704
- if (Option.isNone(this._state.profileId)) {
3705
- throw Error('Failed to get Profile ID from JWT');
3706
- }
3707
- return this._state.profileId.value;
3708
- }
3709
- get defaultFundUsi() {
3710
- const profileConfigDefaultFundUsi = _function.pipe(this._state.profileConfiguration, Option.map((config) => Option.fromNullable(config.defaultFundUsi)), Option.flatten);
3711
- if (Option.isSome(profileConfigDefaultFundUsi)) {
3712
- return profileConfigDefaultFundUsi;
3713
- }
3714
- return _function.pipe(this._state.accountConfiguration, Option.map((config) => Option.fromNullable(config.defaultFundUsi)), Option.flatten);
3715
- }
3716
- get accountIdOrDefault() {
3717
- return _function.pipe(this._state.accountConfiguration, Option.map((config) => config.accountId), Option.getOrElse(() => ''));
3718
- }
3719
- get partnerIdOrDefault() {
3720
- return _function.pipe(this._state.superBuyer, Option.map((superBuyer) => superBuyer.partnerId), Option.getOrElse(() => ''));
3721
- }
3722
- get jwt() {
3723
- if (Option.isNone(this._state.jwt)) {
3724
- throw Error('No authentication information was found');
3725
- }
3726
- return this._state.jwt.value;
3727
- }
3728
- completeSuperSelectionFlow() {
3729
- this._state.hasSuccessPageBeenAcknowledged = true;
3730
- }
3731
- markSuperSelectionAsSubmitted() {
3732
- this._state.hasSuperSelectionBeenSubmitted = true;
3733
- }
3734
- get isDefinedBenefitsEligible() {
3735
- return this._state.isDefinedBenefitsEligible;
3736
- }
3737
- async loadAppStateAsync() {
3738
- const appStateResponse = await superSelectionApi.getAppStateAsync();
3739
- this._state.accountConfiguration = Option.fromNullable(appStateResponse.accountConfiguration);
3740
- this._state.profileConfiguration = Option.fromNullable(appStateResponse.profileConfiguration);
3741
- this._state.superBuyer = Option.fromNullable(appStateResponse.superBuyer);
3742
- this._state.promotedFunds = Option.fromNullable(appStateResponse.promotedFunds);
3743
- this._state.bringYourOwnFundCustomStepEnabled =
3744
- appStateResponse.bringYourOwnFundCustomStepEnabled;
3745
- this._state.featuredFundsEnabled = appStateResponse.featuredFundsEnabled;
3746
- this._state.superChoicePrefill = Option.fromNullable(appStateResponse.prefill);
3747
- this._state.isDefinedBenefitsEligible = Option.fromNullable(appStateResponse.isDefinedBenefitsEligible);
3748
- if (Option.isSome(this._state.accountConfiguration)) {
3749
- if (this._state.accountConfiguration.value.featureSet.type === 'basic') {
3750
- this._state.superCampaignEnabled = false;
3751
- }
3752
- }
3753
- }
3754
- setSuperCampaignPromotedFundsShown(shownFunds) {
3755
- if (this._state.superCampaignState !== undefined)
3756
- this._state.superCampaignState.promotedFundsShown = shownFunds;
3757
- else
3758
- throw new Error('Cannot set shown funds for SuperCampaing state because it is undefined');
3759
- }
3760
- viewSuperFundPanelAsync(placementId, promotedFundIdListOverride) {
3761
- return superSelectionApi.viewSuperFundPanelAsync(Object.assign(Object.assign({}, this.promotedFundsConfig), { shownFunds: promotedFundIdListOverride
3762
- ? promotedFundIdListOverride
3763
- : this.promotedFundsConfig.shownFunds, placementId }));
3764
- }
3765
- get superCampaignState() {
3766
- return this._state.superCampaignState;
3767
- }
3768
- get superCampaignComponentStatus() {
3769
- return this._state.superCampaignComponentStatus;
3770
- }
3771
- set superCampaignComponentStatus(value) {
3772
- if (value === SuperCampaignComponentStatus.Loaded) {
3773
- this._state.superCampaignComponentStatus = SuperCampaignComponentStatus.Loaded;
3774
- this._state.superCampaignState = new SuperCampaignState();
823
+ async clicked() {
824
+ if (!this.promiseFn || this.state === PromiseButtonState.Pending)
825
+ return;
826
+ try {
827
+ this.state = PromiseButtonState.Pending;
828
+ await this.promiseFn();
829
+ this.state = PromiseButtonState.Available;
3775
830
  }
3776
- else {
3777
- this._state.superCampaignComponentStatus = value;
3778
- this._state.superCampaignState = undefined;
831
+ catch (err) {
832
+ this.state = PromiseButtonState.Error;
833
+ throw err;
3779
834
  }
3780
835
  }
3781
- get isUsingSuperCampaign() {
3782
- return this.state.superCampaignEnabled && this.superCampaignState !== undefined;
3783
- }
3784
- get isBringYourOwnFundCustomStepEnabled() {
3785
- return this.state.bringYourOwnFundCustomStepEnabled;
3786
- }
3787
- get isFeaturedFundsEnabled() {
3788
- return this.state.featuredFundsEnabled;
3789
- }
3790
- get superCampaignCanNotBeActivated() {
3791
- return (!this.state.superCampaignEnabled ||
3792
- this.superCampaignComponentStatus === SuperCampaignComponentStatus.NotWorking);
3793
- }
3794
- get hideFooterSection() {
3795
- return this._state.hideFooterSection;
3796
- }
3797
- set hideFooterSection(value) {
3798
- this._state.hideFooterSection = value;
3799
- }
3800
- get backendUrl() {
3801
- return Option.map(this.getBaseUrl)(this.state.apiBaseUrl);
3802
- }
3803
- getBaseUrl(url) {
3804
- const parsedUrl = new URL(url);
3805
- return `${parsedUrl.protocol}//${parsedUrl.hostname}${parsedUrl.port.length > 0 ? `:${parsedUrl.port}` : ''}`;
3806
- }
3807
- }
3808
- const superSelectionAppService = new SuperSelectionAppService();
3809
-
3810
- class NavigationService {
3811
- navigateInternally(history, route) {
3812
- const path = `${this.appBaseUrl}${this.toRouteWithLeadingSlash(route)}`;
3813
- iframe.navigation(path);
3814
- history.push(path);
3815
- }
3816
- navigateInternallyToStandardChoice(options) {
3817
- state.handleSubmitFn = options.handleSubmitFn;
3818
- state.fundName = options.fundName;
3819
- state.fundDetails = options.fundDetails;
3820
- state.promotedFundId = options.promotedFundId;
3821
- this.navigateInternally(options.history, SuperSelectionAppRoutes.StandardChoice);
3822
- }
3823
- toExternalUrl(url) {
3824
- const externalUrl = new URL(url);
3825
- externalUrl.searchParams.append('_extnav', 'true');
3826
- return externalUrl.href;
3827
- }
3828
- get appBaseUrl() {
3829
- const baseUrl = superSelectionAppService.appBaseUrl;
3830
- return baseUrl.replace(/\/$/, '');
3831
- }
3832
- toRouteWithLeadingSlash(route) {
3833
- return route.length > 0 && route[0] === '/' ? route : `/${route}`;
3834
- }
3835
- }
3836
- const navigationService = new NavigationService();
836
+ };
3837
837
 
3838
838
  const ChoiceRouter = class {
3839
839
  constructor(hostRef) {
@@ -3884,7 +884,7 @@ const initialStateCustomFund = {
3884
884
  memberFamilyName: ''
3885
885
  }
3886
886
  };
3887
- const { state: state$1, reset } = createStore(initialStateCustomFund);
887
+ const { state, reset } = createStore(initialStateCustomFund);
3888
888
 
3889
889
  const myOwnFundCustomOption = {
3890
890
  label: CustomFundTypes.MyOwnFund,
@@ -4079,56 +1079,6 @@ class EventTrackingService {
4079
1079
  }
4080
1080
  }
4081
1081
 
4082
- class CustomFundChoiceApi {
4083
- async submitDefaultFundChoiceAsync(dto) {
4084
- return buildBackendApiClient()
4085
- .url('super-choice/default')
4086
- .post(dto)
4087
- .badRequest(() => {
4088
- throw new Error('Failed to process default fund join request');
4089
- })
4090
- .text();
4091
- }
4092
- async submitCustomFundChoiceAsync(dto) {
4093
- return buildBackendApiClient()
4094
- .url('super-choice/custom-fund')
4095
- .post(dto)
4096
- .badRequest(() => {
4097
- throw new Error('Failed to process custom fund join request');
4098
- })
4099
- .text();
4100
- }
4101
- async submitSelfManagedFundChoiceAsync(dto) {
4102
- return buildBackendApiClient()
4103
- .url('super-choice/smsf')
4104
- .post(dto)
4105
- .badRequest(() => {
4106
- throw new Error('Failed to process SMSF choice request');
4107
- })
4108
- .text();
4109
- }
4110
- async submitDefinedBenefitsChoiceAsync(dto) {
4111
- return buildBackendApiClient()
4112
- .url('super-choice/defined-benefits')
4113
- .post(dto)
4114
- .badRequest(() => {
4115
- throw new Error('Failed to process Defined Benefits choice request');
4116
- })
4117
- .text();
4118
- }
4119
- async validateAbnForSMSF(abn) {
4120
- const response = await buildBackendApiClient()
4121
- .url(`super-choice/smsf/${abn}/validate`)
4122
- .get()
4123
- .badRequest(() => {
4124
- throw new Error('Failed to verify that if the provided abn is used for regulated fund');
4125
- })
4126
- .json();
4127
- return response.result;
4128
- }
4129
- }
4130
- const customFundChoiceApi = new CustomFundChoiceApi();
4131
-
4132
1082
  const DefaultFund = class {
4133
1083
  constructor(hostRef) {
4134
1084
  registerInstance(this, hostRef);
@@ -4632,71 +1582,6 @@ const LoadingPage = class {
4632
1582
  }
4633
1583
  };
4634
1584
 
4635
- const MyOwnFund = class {
4636
- constructor(hostRef) {
4637
- registerInstance(this, hostRef);
4638
- this.isNotAllInformationProvidedMessageVisible = false;
4639
- this.isSubmitDisabled = true;
4640
- this.eventTrackingService = EventTrackingService.Instance;
4641
- }
4642
- componentDidLoad() {
4643
- return this.eventTrackingService.TrackMyOwnSuperFundDetailViewedAsync({
4644
- promotedFundsShown: superSelectionAppService.promotedFunds,
4645
- defaultFundUsiSet: toUndefined(superSelectionAppService.defaultFundUsi)
4646
- });
4647
- }
4648
- render() {
4649
- const superCampaignCanNotBeActivated = superSelectionAppService.superCampaignCanNotBeActivated;
4650
- return (h(Host, null, h("sss-header-section", null), h("div", { class: "flex justify-center mt-11" }, h("sss-custom-fund", null, h("form", { noValidate: true, onSubmit: (ev) => ev.preventDefault(), class: {
4651
- 'was-validated': this.formState === 'validated'
4652
- }, ref: (el) => (this.formElement = el), onInput: (_) => (this.isSubmitDisabled = !this.formElement.checkValidity()) }, h("div", { class: "p-4 sm:p-6 pb-6 sm:pb-8 border shadow-sm rounded-lg" }, h("p", { class: "sm:text-lg font-bold mb-3" }, "Fund details"), h("div", { class: "bg-yellow-50 border-l-4 border-yellow-400 p-4 mb-3 sm:mb-4" }, h("div", { class: "flex" }, h("div", { class: "flex-shrink-0" }, h("img", { class: "h-5 w-5", src: getAssetPath('assets/icon-exclamation.svg') })), h("div", { class: "ml-2" }, h("ul", { class: "list-disc list-outside ml-6 space-y-2 text-sm text-yellow-700 leading-5" }, h("li", null, "Make sure you are a current member of the fund before completing this step."), h("li", null, "Please check that the fund USI is correct as some funds have similar names."))))), h("sss-my-own-fund-inputs", { myOwnFundForm: state$1.myOwnFundForm, showValidationErrors: this.formState === 'validated', onFormChanged: (event) => {
4653
- state$1.myOwnFundForm = Object.assign(Object.assign({}, state$1.myOwnFundForm), event.detail);
4654
- this.isNotAllInformationProvidedMessageVisible = false;
4655
- } }), this.isNotAllInformationProvidedMessageVisible && (h("div", { class: "mt-4 rounded-md bg-red-50 p-4 text-sm text-red-700" }, "All fields are required to complete submission. Make sure you have selected a fund."))), h("div", { class: "flex justify-center mt-8" }, h("div", { class: "sm:max-w-320 w-full" }, h("div", { class: "mb-4", onClick:
4656
- // user clicks on disabled button (div wrapper) then validation errors will show
4657
- () => (this.formState = 'validated') }, h("sss-button", { testid: "continue-button", fillWidth: true, promiseFn: () => this.handleSubmitForm(), disabled: this.isSubmitDisabled }, "Continue")), !superCampaignCanNotBeActivated && (h("stencil-route-link", { url: SuperSelectionAppRoutes.ChoicePage }, h("sss-button", { testid: "back-button", fillWidth: true, variant: "secondary" }, "Back"))))))))));
4658
- }
4659
- async handleSubmitForm() {
4660
- this.formState = 'validated';
4661
- if (!this.formElement.checkValidity()) {
4662
- return;
4663
- }
4664
- const isAllInformationProvided = isSome(state$1.myOwnFundForm.fundUsi) &&
4665
- isSome(state$1.myOwnFundForm.memberNumber) &&
4666
- isSome(state$1.myOwnFundForm.memberFirstName) &&
4667
- isSome(state$1.myOwnFundForm.memberFamilyName);
4668
- if (!isAllInformationProvided) {
4669
- this.isNotAllInformationProvidedMessageVisible = true;
4670
- return;
4671
- }
4672
- if (superSelectionAppService.isBringYourOwnFundCustomStepEnabled &&
4673
- superSelectionAppService.isUsingSuperCampaign) {
4674
- navigationService.navigateInternally(this.history, SuperSelectionAppRoutes.MyOwnFundEngagementStep);
4675
- return;
4676
- }
4677
- navigationService.navigateInternallyToStandardChoice({
4678
- history: this.history,
4679
- fundName: this.getOrError(state$1.myOwnFundForm.fundName),
4680
- fundDetails: {
4681
- type: 'myOwnFund',
4682
- fundName: this.getOrError(state$1.myOwnFundForm.fundName),
4683
- fundUsi: this.getOrError(state$1.myOwnFundForm.fundUsi),
4684
- memberNumber: this.getOrError(state$1.myOwnFundForm.memberNumber)
4685
- },
4686
- handleSubmitFn: async (standardChoiceFormSignature) => {
4687
- const customFundChoiceDto = Object.assign({ fundUsi: this.getOrError(state$1.myOwnFundForm.fundUsi), memberNumber: this.getOrError(state$1.myOwnFundForm.memberNumber), memberFirstName: this.getOrError(state$1.myOwnFundForm.memberFirstName), memberFamilyName: this.getOrError(state$1.myOwnFundForm.memberFamilyName), standardChoiceFormSignature }, superSelectionAppService.promotedFundsConfig);
4688
- await customFundChoiceApi.submitCustomFundChoiceAsync(customFundChoiceDto);
4689
- }
4690
- });
4691
- }
4692
- getOrError(option) {
4693
- return _function.pipe(option, getOrElse(() => {
4694
- throw new Error('Option value is none.');
4695
- }));
4696
- }
4697
- };
4698
- injectHistory(MyOwnFund);
4699
-
4700
1585
  const MyOwnFundEngagementStep = class {
4701
1586
  constructor(hostRef) {
4702
1587
  registerInstance(this, hostRef);
@@ -4723,20 +1608,20 @@ const MyOwnFundEngagementStep = class {
4723
1608
  async componentWillLoad() {
4724
1609
  if (superSelectionAppService.isBringYourOwnFundCustomStepEnabled &&
4725
1610
  superSelectionAppService.isUsingSuperCampaign &&
4726
- Option.isSome(state$1.myOwnFundForm.fundUsi) &&
4727
- Option.isSome(state$1.myOwnFundForm.fundName) &&
4728
- Option.isSome(state$1.myOwnFundForm.memberNumber) &&
4729
- Option.isSome(state$1.myOwnFundForm.memberFirstName) &&
4730
- Option.isSome(state$1.myOwnFundForm.memberFamilyName) &&
1611
+ Option.isSome(state.myOwnFundForm.fundUsi) &&
1612
+ Option.isSome(state.myOwnFundForm.fundName) &&
1613
+ Option.isSome(state.myOwnFundForm.memberNumber) &&
1614
+ Option.isSome(state.myOwnFundForm.memberFirstName) &&
1615
+ Option.isSome(state.myOwnFundForm.memberFamilyName) &&
4731
1616
  Option.isSome(superSelectionAppService.backendUrl) &&
4732
1617
  Option.isSome(superSelectionAppService.state.jwt)) {
4733
1618
  this.backendUrl = superSelectionAppService.backendUrl.value;
4734
1619
  this.accessToken = superSelectionAppService.state.jwt.value;
4735
- this.fundUsi = state$1.myOwnFundForm.fundUsi.value;
4736
- this.fundName = state$1.myOwnFundForm.fundName.value;
4737
- this.memberNumber = state$1.myOwnFundForm.memberNumber.value;
4738
- this.memberFirstName = state$1.myOwnFundForm.memberFirstName.value;
4739
- this.memberFamilyName = state$1.myOwnFundForm.memberFamilyName.value;
1620
+ this.fundUsi = state.myOwnFundForm.fundUsi.value;
1621
+ this.fundName = state.myOwnFundForm.fundName.value;
1622
+ this.memberNumber = state.myOwnFundForm.memberNumber.value;
1623
+ this.memberFirstName = state.myOwnFundForm.memberFirstName.value;
1624
+ this.memberFamilyName = state.myOwnFundForm.memberFamilyName.value;
4740
1625
  this.unSubscribeFromStepEvents();
4741
1626
  this.subscribeToStepEvents();
4742
1627
  superSelectionAppService.hideFooterSection = true;
@@ -4772,60 +1657,6 @@ const MyOwnFundEngagementStep = class {
4772
1657
  };
4773
1658
  injectHistory(MyOwnFundEngagementStep);
4774
1659
 
4775
- const MyOwnFundInputs = class {
4776
- constructor(hostRef) {
4777
- registerInstance(this, hostRef);
4778
- this.formChanged = createEvent(this, "formChanged", 7);
4779
- this.MIN_SEARCH_STRING_LENGTH = 3;
4780
- this.MAX_RECORD_COUNT = 25;
4781
- this.searchFundsAsync = async (searchBy) => {
4782
- const response = await australianFundLookupService.searchFundsAsync(searchBy, this.MAX_RECORD_COUNT);
4783
- switch (response.result) {
4784
- case 'TooManyResults': {
4785
- return { kind: 'too-many-results' };
4786
- }
4787
- default: {
4788
- const funds = response.data
4789
- .sort((a, b) => a.productName.localeCompare(b.productName))
4790
- .map((fund) => ({
4791
- label: `${fund.productName} (${fund.usi})`,
4792
- value: fund.usi
4793
- }));
4794
- return { kind: 'success', value: funds };
4795
- }
4796
- }
4797
- };
4798
- if (isSome(this.myOwnFundForm.fundUsi) && isSome(this.myOwnFundForm.fundName)) {
4799
- this.selectedOption = {
4800
- label: this.myOwnFundForm.fundName.value,
4801
- value: this.myOwnFundForm.fundUsi.value
4802
- };
4803
- }
4804
- }
4805
- render() {
4806
- return (h("div", null, h("div", null, h("label", { class: "text-sm font-medium text-gray-700" }, "Fund name"), h("div", { class: "mt-1" }, h("sss-dropdown-async", { testId: "fund-search-input", searchFunction: this.searchFundsAsync, minSearchStringLength: this.MIN_SEARCH_STRING_LENGTH, required: true, requiredValidationMessage: "Select a fund", placeholder: `Type to search by name or USI...`, value: this.selectedOption, onValueChanged: (ev) => {
4807
- this.selectedOption = ev.detail;
4808
- this.updateFund(ev.detail);
4809
- }, showValidationErrors: this.showValidationErrors })), isSome(this.myOwnFundForm.fundUsi) && (h("div", { class: "mt-3" }, h("label", { class: "text-sm font-medium text-gray-700" }, "Fund USI"), h("div", { class: "mt-1 shadow-sm px-3 py-2 rounded-md border border-gray-300 bg-gray-50 text-gray-500 text-base sm:text-sm" }, this.myOwnFundForm.fundUsi.value)))), h("div", { class: "mt-3" }, h("label", { class: "text-sm font-medium text-gray-700" }, "Member number"), h("div", { class: "mt-1" }, h("input", { "data-testid": "member-number-input", type: "text", class: {
4810
- 'shadow-sm focus:ring-primary-focus focus:border-primary-base block w-full text-base sm:text-sm border-gray-300 rounded-md': true,
4811
- 'invalid:border-red-300 invalid:text-red-900 invalid:focus:ring-red-500 invalid:focus:border-red-500': this
4812
- .showValidationErrors
4813
- }, required: true, pattern: "[A-Za-z0-9]{4,16}", name: "memberNumber", id: "memberNumber", value: toUndefined(state$1.myOwnFundForm.memberNumber), onChange: (ev) => this.updateMemberNumber(ev.target.value.trim()) }), h("div", { class: "invalid-feedback mt-2 text-sm text-red-600" }, "Enter a valid member number (only numbers and / or letters)"))), h("div", { class: "flex space-x-4" }, h("div", { class: "mt-3 w-1/2" }, h("label", { class: "text-sm font-medium text-gray-700" }, "Given name(s)"), h("div", { class: "mt-1" }, h("sss-name-input", { testId: "member-given-names-input", name: "memberFirstName", readableName: "Member given name(s)", showValidationErrors: this.showValidationErrors, value: toUndefined(state$1.myOwnFundForm.memberFirstName), onChange: (ev) => this.updateMemberFirstName(ev.target.value.trim()) }))), h("div", { class: "mt-3 w-1/2" }, h("label", { class: "text-sm font-medium text-gray-700" }, "Last name"), h("div", { class: "mt-1" }, h("sss-name-input", { testId: "member-last-name-input", name: "memberFamilyName", readableName: "Member last name", showValidationErrors: this.showValidationErrors, value: toUndefined(state$1.myOwnFundForm.memberFamilyName), onChange: (ev) => this.updateMemberFamilyName(ev.target.value.trim()) }))))));
4814
- }
4815
- updateFund(fund) {
4816
- this.formChanged.emit({ fundUsi: some(fund.value), fundName: some(fund.label) });
4817
- }
4818
- updateMemberNumber(memberNumber) {
4819
- this.formChanged.emit({ memberNumber: some(memberNumber) });
4820
- }
4821
- updateMemberFirstName(memberFirstName) {
4822
- this.formChanged.emit({ memberFirstName: some(memberFirstName) });
4823
- }
4824
- updateMemberFamilyName(memberFamilyName) {
4825
- this.formChanged.emit({ memberFamilyName: some(memberFamilyName) });
4826
- }
4827
- };
4828
-
4829
1660
  const MemberNameInput = class {
4830
1661
  constructor(hostRef) {
4831
1662
  registerInstance(this, hostRef);
@@ -5893,7 +2724,7 @@ const StandardChoiceFormInputDefaultFund = class {
5893
2724
  window.removeEventListener('popstate', this.ignorePopState);
5894
2725
  }
5895
2726
  render() {
5896
- return (h(Host, null, h("div", { class: "text-2xl sm:text-3xl font-bold text-center" }, "Confirm your super choice"), h("div", { class: "sm:text-lg text-gray-600 max-w-800 mt-4 text-center leading-7 sm:leading-8" }, "Your authorisation is required to complete your super choice by signing the standard choice form, which informs your employer of your choice of fund."), h("div", { class: "flex justify-center mt-8 sm:mt-12" }, h("div", { class: "max-w-560" }, h("div", { class: "p-4 sm:p-6 border shadow-sm rounded-lg flex flex-col sm:flex-row" }, this.renderLogo(), h("div", { class: "flex justify-between w-full" }, h("div", null, h("div", { class: "text-xs font-semibold text-gray-500 uppercase" }, "Nominated fund"), h("div", { class: "text-sm mt-2" }, state.fundName)), h("div", { class: "grid content-center ml-4" }, h("sss-button", { testid: "change-fund-button", size: "xs", variant: "secondary", promiseFn: async () => {
2727
+ return (h(Host, null, h("div", { class: "text-2xl sm:text-3xl font-bold text-center" }, "Confirm your super choice"), h("div", { class: "sm:text-lg text-gray-600 max-w-800 mt-4 text-center leading-7 sm:leading-8" }, "Your authorisation is required to complete your super choice by signing the standard choice form, which informs your employer of your choice of fund."), h("div", { class: "flex justify-center mt-8 sm:mt-12" }, h("div", { class: "max-w-560" }, h("div", { class: "p-4 sm:p-6 border shadow-sm rounded-lg flex flex-col sm:flex-row" }, this.renderLogo(), h("div", { class: "flex justify-between w-full" }, h("div", null, h("div", { class: "text-xs font-semibold text-gray-500 uppercase" }, "Nominated fund"), h("div", { class: "text-sm mt-2" }, state$1.fundName)), h("div", { class: "grid content-center ml-4" }, h("sss-button", { testid: "change-fund-button", size: "xs", variant: "secondary", promiseFn: async () => {
5897
2728
  await this.trackChangeRequestedAsync();
5898
2729
  navigationService.navigateInternally(this.history, SuperSelectionAppRoutes.ChoicePage);
5899
2730
  } }, "Change")))), h("div", { class: "mt-4 p-4 sm:p-6 border shadow-sm rounded-lg" }, h("div", { class: "sm:text-lg font-bold" }, "Superannuation Standard Choice Form"), h("div", { class: "bg-blue-50 border-l-4 border-blue-400 p-4 mt-3" }, h("div", { class: "flex" }, h("div", { class: "flex-shrink-0" }, h("img", { class: "h-5 w-5", src: getAssetPath('assets/icon-information-circle.svg') })), h("div", { class: "ml-2" }, h("p", { class: "text-sm text-blue-800 leading-5" }, "Applying your full name in the text field below is the same as applying your written signature and is legally binding.")))), h("form", { noValidate: true, onSubmit: (ev) => ev.preventDefault(), class: {
@@ -5926,35 +2757,35 @@ const StandardChoiceFormInputDefaultFund = class {
5926
2757
  promotedFundsShown: superSelectionAppService.promotedFunds,
5927
2758
  defaultFundUsiSet: toUndefined(superSelectionAppService.defaultFundUsi)
5928
2759
  };
5929
- switch (state.fundDetails.type) {
2760
+ switch (state$1.fundDetails.type) {
5930
2761
  case 'default':
5931
2762
  await this.eventTrackingService.TrackSuperFundDetailChangeRequestedAsync({
5932
- DefaultFund: Object.assign(Object.assign({}, state.fundDetails), common)
2763
+ DefaultFund: Object.assign(Object.assign({}, state$1.fundDetails), common)
5933
2764
  });
5934
2765
  break;
5935
2766
  case 'myOwnFund':
5936
2767
  await this.eventTrackingService.TrackSuperFundDetailChangeRequestedAsync({
5937
- MyOwnFund: Object.assign(Object.assign({}, state.fundDetails), common)
2768
+ MyOwnFund: Object.assign(Object.assign({}, state$1.fundDetails), common)
5938
2769
  });
5939
2770
  break;
5940
2771
  case 'smsf':
5941
2772
  await this.eventTrackingService.TrackSuperFundDetailChangeRequestedAsync({
5942
- Smsf: Object.assign(Object.assign({}, state.fundDetails), common)
2773
+ Smsf: Object.assign(Object.assign({}, state$1.fundDetails), common)
5943
2774
  });
5944
2775
  break;
5945
2776
  case 'promoted':
5946
2777
  await this.eventTrackingService.TrackSuperFundDetailChangeRequestedAsync({
5947
- PromotedFund: Object.assign(Object.assign({}, state.fundDetails), common)
2778
+ PromotedFund: Object.assign(Object.assign({}, state$1.fundDetails), common)
5948
2779
  });
5949
2780
  break;
5950
2781
  case 'promotedDefault':
5951
2782
  await this.eventTrackingService.TrackSuperFundDetailChangeRequestedAsync({
5952
- PromotedDefaultFund: Object.assign(Object.assign({}, state.fundDetails), common)
2783
+ PromotedDefaultFund: Object.assign(Object.assign({}, state$1.fundDetails), common)
5953
2784
  });
5954
2785
  break;
5955
2786
  case 'promotedDefaultWithJoin':
5956
2787
  await this.eventTrackingService.TrackSuperFundDetailChangeRequestedAsync({
5957
- PromotedDefaultFundWithJoin: Object.assign(Object.assign({}, state.fundDetails), common)
2788
+ PromotedDefaultFundWithJoin: Object.assign(Object.assign({}, state$1.fundDetails), common)
5958
2789
  });
5959
2790
  break;
5960
2791
  case 'null':
@@ -5964,7 +2795,7 @@ const StandardChoiceFormInputDefaultFund = class {
5964
2795
  async handleSubmitForm() {
5965
2796
  this.formState = 'validated';
5966
2797
  if (this.formElement.checkValidity()) {
5967
- await state.handleSubmitFn(this.standardChoiceFormSignature.trim());
2798
+ await state$1.handleSubmitFn(this.standardChoiceFormSignature.trim());
5968
2799
  superSelectionAppService.markSuperSelectionAsSubmitted();
5969
2800
  }
5970
2801
  }
@@ -18054,4 +14885,4 @@ const SuperSelectionAppHost = class {
18054
14885
  };
18055
14886
  SuperSelectionAppHost.style = superSelectionAppHostCss;
18056
14887
 
18057
- export { Button as sss_button, ChoiceRouter as sss_choice_router, CustomFund as sss_custom_fund, DefaultFund as sss_default_fund, SelectInputAsync as sss_dropdown_async, ExistingChoice as sss_existing_choice_page, FooterSection as sss_footer_section, HeaderSection as sss_header_section, LoadingIndicator as sss_loading_indicator, LoadingPage as sss_loading_page, MyOwnFund as sss_my_own_fund, MyOwnFundEngagementStep as sss_my_own_fund_engagement_step_host, MyOwnFundInputs as sss_my_own_fund_inputs, MemberNameInput as sss_name_input, Prefill as sss_prefill, DisplayField as sss_prefill_display_field, PrefillErrorBox as sss_prefill_error_box, PrefillInvalidMyOwnFund as sss_prefill_invalid_my_own_fund, PrefillInvalidSMSF as sss_prefill_invalid_smsf, PrefillMyOwnFund as sss_prefill_my_own_fund, PrefillSMSF as sss_prefill_smsf, PrefillWarningBox as sss_prefill_warning_box, StandardChoiceFormInputDefaultFund as sss_standard_choice_form, Success as sss_success, FeaturedFunds as sss_super_campaign_featured_funds, SuperCampaignHost as sss_super_campaign_host, SuperSmsfHost as sss_super_smsf_host, Route as stencil_route, RouteLink$1 as stencil_route_link, RouteSwitch as stencil_route_switch, Router as stencil_router, SuperSelectionApp as super_selection_app, SuperSelectionAppHost as super_selection_app_host };
14888
+ export { Button as sss_button, ChoiceRouter as sss_choice_router, CustomFund as sss_custom_fund, DefaultFund as sss_default_fund, SelectInputAsync as sss_dropdown_async, ExistingChoice as sss_existing_choice_page, FooterSection as sss_footer_section, HeaderSection as sss_header_section, LoadingIndicator as sss_loading_indicator, LoadingPage as sss_loading_page, MyOwnFundEngagementStep as sss_my_own_fund_engagement_step_host, MemberNameInput as sss_name_input, Prefill as sss_prefill, DisplayField as sss_prefill_display_field, PrefillErrorBox as sss_prefill_error_box, PrefillInvalidMyOwnFund as sss_prefill_invalid_my_own_fund, PrefillInvalidSMSF as sss_prefill_invalid_smsf, PrefillMyOwnFund as sss_prefill_my_own_fund, PrefillSMSF as sss_prefill_smsf, PrefillWarningBox as sss_prefill_warning_box, StandardChoiceFormInputDefaultFund as sss_standard_choice_form, Success as sss_success, FeaturedFunds as sss_super_campaign_featured_funds, SuperCampaignHost as sss_super_campaign_host, SuperSmsfHost as sss_super_smsf_host, Route as stencil_route, RouteLink$1 as stencil_route_link, RouteSwitch as stencil_route_switch, Router as stencil_router, SuperSelectionApp as super_selection_app, SuperSelectionAppHost as super_selection_app_host };