@wise/dynamic-flow-client 2.9.0-beta-5eeb4d.27 → 2.9.0

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 (40) hide show
  1. package/build/main.js +185 -157
  2. package/build/main.min.js +1 -1
  3. package/build/types/common/messages/persist-async.messages.d.ts +8 -0
  4. package/build/types/legacy/formControl/FormControl.d.ts +3 -2
  5. package/build/types/legacy/jsonSchemaForm/JsonSchemaForm.d.ts +1 -0
  6. package/build/types/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.d.ts +1 -1
  7. package/build/types/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.d.ts +2 -1
  8. package/build/types/revamp/domain/components/BooleanInputComponent.d.ts +2 -0
  9. package/build/types/revamp/domain/components/DateInputComponent.d.ts +2 -0
  10. package/build/types/revamp/domain/components/IntegerInputComponent.d.ts +2 -0
  11. package/build/types/revamp/domain/components/NumberInputComponent.d.ts +2 -0
  12. package/build/types/revamp/domain/components/SelectInputComponent.d.ts +2 -0
  13. package/build/types/revamp/domain/components/StatusListComponent.d.ts +8 -0
  14. package/build/types/revamp/domain/components/TextInputComponent.d.ts +2 -0
  15. package/build/types/revamp/domain/components/UploadInputComponent.d.ts +2 -0
  16. package/build/types/revamp/domain/components/repeatableComponent/RepeatableComponent.d.ts +1 -1
  17. package/build/types/revamp/domain/features/persistAsync/getComponentPersistAsync.d.ts +15 -0
  18. package/build/types/revamp/domain/features/persistAsync/getPerformPersistAsync.d.ts +22 -0
  19. package/build/types/revamp/domain/features/persistAsync/persist-async-utils.d.ts +2 -0
  20. package/build/types/revamp/domain/features/validation/spec-utils.d.ts +1 -0
  21. package/build/types/revamp/domain/features/validation/validation-functions.d.ts +7 -0
  22. package/build/types/revamp/domain/mappers/layout/listLayoutToComponent.d.ts +2 -0
  23. package/build/types/revamp/domain/mappers/layout/statusListLayoutToComponent.d.ts +2 -0
  24. package/build/types/revamp/domain/mappers/schema/tests/test-utils.d.ts +1 -0
  25. package/build/types/revamp/domain/mappers/schema/types.d.ts +2 -1
  26. package/build/types/revamp/domain/mappers/schema/utils/mapCommonSchemaProps.d.ts +14 -13
  27. package/build/types/revamp/domain/mappers/types.d.ts +3 -0
  28. package/build/types/revamp/domain/types.d.ts +15 -6
  29. package/build/types/revamp/renderers/mappers/statusListComponentToProps.d.ts +3 -0
  30. package/build/types/revamp/renderers/types.d.ts +13 -0
  31. package/build/types/revamp/utils/{getSubmittableData.d.ts → component-utils.d.ts} +1 -0
  32. package/build/types/revamp/utils/type-utils.d.ts +7 -1
  33. package/build/types/revamp/wise/renderers/StatusListRenderer.d.ts +4 -0
  34. package/build/types/test-utils/fetch-utils.d.ts +2 -2
  35. package/package.json +25 -25
  36. package/build/types/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.d.ts +0 -8
  37. package/build/types/revamp/domain/features/validation/getModelValidationErrors.d.ts +0 -5
  38. package/build/types/revamp/domain/features/validation/validateComponents.d.ts +0 -2
  39. package/build/types/revamp/domain/validation/validation-functions.d.ts +0 -7
  40. /package/build/types/revamp/{domain/mappers/utils → utils}/type-validators.d.ts +0 -0
package/build/main.js CHANGED
@@ -22,6 +22,18 @@ var __spreadValues = (a, b) => {
22
22
  return a;
23
23
  };
24
24
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
25
+ var __objRest = (source, exclude) => {
26
+ var target = {};
27
+ for (var prop in source)
28
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
29
+ target[prop] = source[prop];
30
+ if (source != null && __getOwnPropSymbols)
31
+ for (var prop of __getOwnPropSymbols(source)) {
32
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
33
+ target[prop] = source[prop];
34
+ }
35
+ return target;
36
+ };
25
37
  var __commonJS = (cb, mod) => function __require() {
26
38
  return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
27
39
  };
@@ -1021,7 +1033,7 @@ function isReference(block) {
1021
1033
  }
1022
1034
 
1023
1035
  // src/legacy/dynamicFlow/DynamicFlow.tsx
1024
- var import_react44 = require("react");
1036
+ var import_react45 = require("react");
1025
1037
  var import_react_intl30 = require("react-intl");
1026
1038
 
1027
1039
  // src/legacy/common/contexts/dynamicFlowContexts/DynamicFlowContexts.tsx
@@ -1980,12 +1992,12 @@ function useExternalStepPolling(polling, onAction) {
1980
1992
  }
1981
1993
 
1982
1994
  // src/legacy/common/hooks/usePersistAsync/usePersistAsync.ts
1983
- var import_react31 = require("react");
1995
+ var import_react32 = require("react");
1984
1996
  var import_react_intl21 = require("react-intl");
1985
1997
 
1986
- // src/legacy/jsonSchemaForm/persistAsyncSchema/PersistAsyncSchema.messages.js
1998
+ // src/common/messages/persist-async.messages.ts
1987
1999
  var import_react_intl = require("react-intl");
1988
- var PersistAsyncSchema_messages_default = (0, import_react_intl.defineMessages)({
2000
+ var persist_async_messages_default = (0, import_react_intl.defineMessages)({
1989
2001
  genericError: {
1990
2002
  id: "dynamicFlows.PersistAsyncSchema.genericError",
1991
2003
  defaultMessage: "Something went wrong, please try again later!",
@@ -1994,7 +2006,7 @@ var PersistAsyncSchema_messages_default = (0, import_react_intl.defineMessages)(
1994
2006
  });
1995
2007
 
1996
2008
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBasicSchema/PersistAsyncBasicSchema.tsx
1997
- var import_react30 = require("react");
2009
+ var import_react31 = require("react");
1998
2010
  var import_react_intl20 = require("react-intl");
1999
2011
 
2000
2012
  // src/legacy/common/constants/DateMode.ts
@@ -2043,7 +2055,7 @@ var Size = {
2043
2055
 
2044
2056
  // src/legacy/jsonSchemaForm/basicTypeSchema/BasicTypeSchema.tsx
2045
2057
  var import_classnames7 = __toESM(require_classnames());
2046
- var import_react29 = require("react");
2058
+ var import_react30 = require("react");
2047
2059
 
2048
2060
  // src/legacy/layout/alert/DynamicAlert.tsx
2049
2061
  var import_components2 = require("@transferwise/components");
@@ -2620,7 +2632,7 @@ var DynamicExternal = ({ component, onAction }) => {
2620
2632
  var DynamicExternal_default = DynamicExternal;
2621
2633
 
2622
2634
  // src/legacy/jsonSchemaForm/genericSchema/GenericSchema.tsx
2623
- var import_react22 = require("react");
2635
+ var import_react23 = require("react");
2624
2636
 
2625
2637
  // src/legacy/jsonSchemaForm/allOfSchema/AllOfSchema.tsx
2626
2638
  var import_components6 = require("@transferwise/components");
@@ -2998,7 +3010,7 @@ function getValidationMessages(schema, required, defaultErrorMessages) {
2998
3010
  // src/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.tsx
2999
3011
  var import_components10 = require("@transferwise/components");
3000
3012
  var import_icons = require("@transferwise/icons");
3001
- var import_react13 = require("react");
3013
+ var import_react14 = require("react");
3002
3014
  var import_react_intl11 = require("react-intl");
3003
3015
 
3004
3016
  // src/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/ItemSummary.tsx
@@ -3046,6 +3058,7 @@ var repeatable_messages_default = (0, import_react_intl9.defineMessages)({
3046
3058
  });
3047
3059
 
3048
3060
  // src/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchemaStep.tsx
3061
+ var import_react13 = require("react");
3049
3062
  var import_react_intl10 = require("react-intl");
3050
3063
  var import_jsx_runtime21 = require("react/jsx-runtime");
3051
3064
  function RepeatableSchemaStep({
@@ -3058,6 +3071,7 @@ function RepeatableSchemaStep({
3058
3071
  onAction
3059
3072
  }) {
3060
3073
  const { formatMessage } = (0, import_react_intl10.useIntl)();
3074
+ const [filename, setFilename] = (0, import_react13.useState)(void 0);
3061
3075
  const step = {
3062
3076
  layout: [
3063
3077
  {
@@ -3087,6 +3101,13 @@ function RepeatableSchemaStep({
3087
3101
  actions: [],
3088
3102
  schemas: []
3089
3103
  };
3104
+ const onChange = (props) => {
3105
+ const _a = props, { metadata, model: model2 } = _a, modelChangeProps = __objRest(_a, ["metadata", "model"]);
3106
+ if (schema.items.format === "base64url" && typeof model2 === "string" && typeof (metadata == null ? void 0 : metadata.filename) === "string") {
3107
+ setFilename(metadata.filename);
3108
+ }
3109
+ onModelChange(__spreadProps(__spreadValues({}, modelChangeProps), { model: model2 }));
3110
+ };
3090
3111
  return /* @__PURE__ */ (0, import_jsx_runtime21.jsx)(
3091
3112
  DynamicFlowStep,
3092
3113
  {
@@ -3097,9 +3118,10 @@ function RepeatableSchemaStep({
3097
3118
  formErrors: errors,
3098
3119
  globalError: null,
3099
3120
  onAction: (action) => {
3100
- onAction(action.url);
3121
+ onAction(action.url, filename);
3122
+ setFilename(void 0);
3101
3123
  },
3102
- onModelChange
3124
+ onModelChange: onChange
3103
3125
  }
3104
3126
  );
3105
3127
  }
@@ -3293,8 +3315,8 @@ var schemaSummaryProvides = (summary, providesProp) => (
3293
3315
  // src/legacy/jsonSchemaForm/arrayTypeSchema/arrayListSchema/repeatableSchema/RepeatableSchema.tsx
3294
3316
  var import_jsx_runtime22 = require("react/jsx-runtime");
3295
3317
  function RepeatableSchema({ schema, model, errors, submitted, onChange }) {
3296
- const [openModalType, setOpenModalType] = (0, import_react13.useState)(null);
3297
- const [itemSummaries, setItemSummaries] = (0, import_react13.useState)(() => {
3318
+ const [openModalType, setOpenModalType] = (0, import_react14.useState)(null);
3319
+ const [itemSummaries, setItemSummaries] = (0, import_react14.useState)(() => {
3298
3320
  if (isObject(model) && !isArray(model)) {
3299
3321
  throw new Error(
3300
3322
  "RepeatableSchema does not support object models. Ensure your array schema is wrapped inside an object schema."
@@ -3302,7 +3324,7 @@ function RepeatableSchema({ schema, model, errors, submitted, onChange }) {
3302
3324
  }
3303
3325
  return model ? model.map((item) => getItemSummaryFromSchema(schema.items, item, schema == null ? void 0 : schema.summary)) : null;
3304
3326
  });
3305
- const [editableItem, setEditableItem] = (0, import_react13.useState)({ item: null, model: null });
3327
+ const [editableItem, setEditableItem] = (0, import_react14.useState)({ item: null, model: null });
3306
3328
  const broadcastModelChange = (updatedItems) => {
3307
3329
  const updatedModel = updatedItems ? updatedItems.map(({ value }) => value) : null;
3308
3330
  onChange({
@@ -3318,9 +3340,13 @@ function RepeatableSchema({ schema, model, errors, submitted, onChange }) {
3318
3340
  setEditableItem({ item, model: item.value });
3319
3341
  setOpenModalType("edit");
3320
3342
  };
3321
- const onSaveItem = (action) => {
3343
+ const onSaveItem = (action, summaryTextOverride) => {
3322
3344
  var _a;
3323
- const updatedItem = action === "remove" ? null : getItemSummaryFromSchema(schema.items, editableItem.model, schema == null ? void 0 : schema.summary);
3345
+ const updatedItem = action === "remove" ? null : getItemSummaryFromSchema(
3346
+ schema.items,
3347
+ summaryTextOverride != null ? summaryTextOverride : editableItem.model,
3348
+ schema.summary
3349
+ );
3324
3350
  if (action !== "remove" && !isValidSchema((_a = updatedItem == null ? void 0 : updatedItem.value) != null ? _a : null, schema.items)) {
3325
3351
  return;
3326
3352
  }
@@ -3439,7 +3465,7 @@ var ArraySchema_default = ArraySchema;
3439
3465
  // src/legacy/jsonSchemaForm/objectSchema/ObjectSchema.tsx
3440
3466
  var import_components11 = require("@transferwise/components");
3441
3467
  var import_classnames3 = __toESM(require_classnames());
3442
- var import_react14 = require("react");
3468
+ var import_react15 = require("react");
3443
3469
  var import_jsx_runtime25 = require("react/jsx-runtime");
3444
3470
  var getSchemaColumnClasses2 = (width) => ({
3445
3471
  "col-xs-12": true,
@@ -3447,7 +3473,7 @@ var getSchemaColumnClasses2 = (width) => ({
3447
3473
  "col-sm-4": width === "sm"
3448
3474
  });
3449
3475
  function ObjectSchema(props) {
3450
- const [model, setModel] = (0, import_react14.useState)(() => __spreadValues({}, getValidObjectModelParts(props.model, props.schema)));
3476
+ const [model, setModel] = (0, import_react15.useState)(() => __spreadValues({}, getValidObjectModelParts(props.model, props.schema)));
3451
3477
  const onChangeProperty = (propertyName, onChangeProps) => {
3452
3478
  if (onChangeProps.model !== null) {
3453
3479
  model[propertyName] = onChangeProps.model;
@@ -3458,7 +3484,7 @@ function ObjectSchema(props) {
3458
3484
  props.onChange(__spreadProps(__spreadValues({}, onChangeProps), { model }));
3459
3485
  };
3460
3486
  const isRequired = (propertyName) => props.schema.required && props.schema.required.includes(propertyName);
3461
- (0, import_react14.useEffect)(() => {
3487
+ (0, import_react15.useEffect)(() => {
3462
3488
  const newModel = getValidObjectModelParts(model, props.schema) || {};
3463
3489
  setModel(newModel);
3464
3490
  if (!isEqual(newModel, model)) {
@@ -3519,7 +3545,7 @@ var ObjectSchema_default = ObjectSchema;
3519
3545
  // src/legacy/jsonSchemaForm/oneOfSchema/OneOfSchema.tsx
3520
3546
  var import_components15 = require("@transferwise/components");
3521
3547
  var import_classnames4 = __toESM(require_classnames());
3522
- var import_react17 = require("react");
3548
+ var import_react18 = require("react");
3523
3549
 
3524
3550
  // src/legacy/jsonSchemaForm/help/Help.tsx
3525
3551
  var import_components12 = require("@transferwise/components");
@@ -3553,11 +3579,11 @@ function Help(props) {
3553
3579
  var Help_default = Help;
3554
3580
 
3555
3581
  // src/legacy/jsonSchemaForm/schemaFormControl/SchemaFormControl.tsx
3556
- var import_react16 = require("react");
3582
+ var import_react17 = require("react");
3557
3583
 
3558
3584
  // src/legacy/formControl/FormControl.tsx
3559
3585
  var import_components13 = require("@transferwise/components");
3560
- var import_react15 = require("react");
3586
+ var import_react16 = require("react");
3561
3587
 
3562
3588
  // src/legacy/formControl/utils/value-utils.ts
3563
3589
  var getSafeStringValue = (value, options = {}) => {
@@ -3743,7 +3769,7 @@ var autocompleteTokenMap = {
3743
3769
 
3744
3770
  // src/legacy/formControl/FormControl.tsx
3745
3771
  var import_jsx_runtime27 = require("react/jsx-runtime");
3746
- var _FormControl = class _FormControl extends import_react15.PureComponent {
3772
+ var _FormControl = class _FormControl extends import_react16.PureComponent {
3747
3773
  constructor(props) {
3748
3774
  super(props);
3749
3775
  this.getAutocompleteValue = () => {
@@ -3756,8 +3782,8 @@ var _FormControl = class _FormControl extends import_react15.PureComponent {
3756
3782
  }
3757
3783
  return "off";
3758
3784
  };
3759
- this.handleOnChange = (value) => {
3760
- this.props.onChange(value);
3785
+ this.handleOnChange = (value, metadata) => {
3786
+ this.props.onChange(value, void 0, metadata);
3761
3787
  };
3762
3788
  this.handleInputOnChange = (event) => {
3763
3789
  this.props.onChange(event.target.value);
@@ -4060,8 +4086,8 @@ var _FormControl = class _FormControl extends import_react15.PureComponent {
4060
4086
  __spreadProps(__spreadValues({}, uploadProps), {
4061
4087
  usAccept: uploadProps.usAccept || "*",
4062
4088
  usDisabled: uploadProps.usDisabled || disabled,
4063
- onSuccess: (base64url) => {
4064
- this.handleOnChange(base64url);
4089
+ onSuccess: (base64url, filename) => {
4090
+ this.handleOnChange(base64url, { filename });
4065
4091
  },
4066
4092
  onFailure: () => {
4067
4093
  this.handleOnChange(null);
@@ -4297,11 +4323,11 @@ function SchemaFormControl(props) {
4297
4323
  const { id, schema, value, disabled, onChange, onFocus, onBlur, onSearchChange, describedBy } = props;
4298
4324
  const log = useLogger();
4299
4325
  const getSanitisedValue = (value2) => isNativeInput(schema.type) && (isNull(value2) || isUndefined(value2)) ? "" : value2;
4300
- const onModelChange = (value2, type) => {
4301
- onChange(getValidBasicModelOrNull(value2, schema), type);
4326
+ const onModelChange = (value2, type, metadata) => {
4327
+ onChange(getValidBasicModelOrNull(value2, schema), type, metadata);
4302
4328
  };
4303
4329
  const controlType = getControlType(schema);
4304
- (0, import_react16.useEffect)(() => {
4330
+ (0, import_react17.useEffect)(() => {
4305
4331
  warnIfInvalidSchema(schema, log, controlType);
4306
4332
  }, [JSON.stringify(schema), log, controlType]);
4307
4333
  const options = schema.values || getOptions(schema, controlType);
@@ -4358,14 +4384,14 @@ var SchemaFormControl_default = SchemaFormControl;
4358
4384
  var import_jsx_runtime30 = require("react/jsx-runtime");
4359
4385
  function OneOfSchema(props) {
4360
4386
  const onEvent = useEventDispatcher();
4361
- const [changed, setChanged] = (0, import_react17.useState)(false);
4362
- const [focused, setFocused] = (0, import_react17.useState)(false);
4363
- const [blurred, setBlurred] = (0, import_react17.useState)(false);
4364
- const id = (0, import_react17.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
4365
- const [schemaIndex, setSchemaIndex] = (0, import_react17.useState)(
4387
+ const [changed, setChanged] = (0, import_react18.useState)(false);
4388
+ const [focused, setFocused] = (0, import_react18.useState)(false);
4389
+ const [blurred, setBlurred] = (0, import_react18.useState)(false);
4390
+ const id = (0, import_react18.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
4391
+ const [schemaIndex, setSchemaIndex] = (0, import_react18.useState)(
4366
4392
  getActiveSchemaIndex(props.schema, props.model)
4367
4393
  );
4368
- const [models, setModels] = (0, import_react17.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
4394
+ const [models, setModels] = (0, import_react18.useState)(getModelPartsForSchemas(props.model, props.schema.oneOf));
4369
4395
  const debouncedTrackEvent = useDebouncedFunction(onEvent, 200);
4370
4396
  const onSearchChange = (searchValue) => {
4371
4397
  debouncedTrackEvent("Dynamic Flow - OneOf Searched", {
@@ -4373,7 +4399,7 @@ function OneOfSchema(props) {
4373
4399
  searchValueLength: searchValue.length
4374
4400
  });
4375
4401
  };
4376
- (0, import_react17.useEffect)(() => {
4402
+ (0, import_react18.useEffect)(() => {
4377
4403
  const modelIndex = getValidIndexFromValue(props.schema, props.model);
4378
4404
  const defaultIndex = getValidIndexFromValue(props.schema, props.schema.default);
4379
4405
  if (modelIndex === -1 && defaultIndex >= 0) {
@@ -4396,7 +4422,7 @@ function OneOfSchema(props) {
4396
4422
  setFocused(false);
4397
4423
  setBlurred(true);
4398
4424
  };
4399
- const onChooseNewSchema = (index, type) => {
4425
+ const onChooseNewSchema = (index, type, metadata) => {
4400
4426
  setSchemaIndex(index);
4401
4427
  const newSchema = props.schema.oneOf[index];
4402
4428
  if (isConstSchema(newSchema)) {
@@ -4405,14 +4431,16 @@ function OneOfSchema(props) {
4405
4431
  model,
4406
4432
  triggerSchema: props.schema,
4407
4433
  triggerModel: model,
4408
- type
4434
+ type,
4435
+ metadata
4409
4436
  });
4410
4437
  } else {
4411
4438
  props.onChange({
4412
4439
  model: models[index],
4413
4440
  triggerSchema: newSchema,
4414
4441
  triggerModel: models[index],
4415
- type
4442
+ type,
4443
+ metadata
4416
4444
  });
4417
4445
  }
4418
4446
  if (type !== "init" && props.schema.analyticsId) {
@@ -4527,11 +4555,11 @@ var OneOfSchema_default = OneOfSchema;
4527
4555
 
4528
4556
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/PersistAsyncBlobSchema.tsx
4529
4557
  var import_classnames5 = __toESM(require_classnames());
4530
- var import_react19 = require("react");
4558
+ var import_react20 = require("react");
4531
4559
 
4532
4560
  // src/legacy/jsonSchemaForm/persistAsyncSchema/persistAsyncBlobSchema/UploadInputAdapter.tsx
4533
4561
  var import_components16 = require("@transferwise/components");
4534
- var import_react18 = require("react");
4562
+ var import_react19 = require("react");
4535
4563
  var import_jsx_runtime31 = require("react/jsx-runtime");
4536
4564
  function UploadInputAdapter(props) {
4537
4565
  const {
@@ -4548,7 +4576,7 @@ function UploadInputAdapter(props) {
4548
4576
  onCancel
4549
4577
  } = props;
4550
4578
  const onEvent = useEventDispatcher();
4551
- const files = (0, import_react18.useMemo)(() => fileId ? [{ id: fileId, status: import_components16.Status.SUCCEEDED }] : [], [fileId]);
4579
+ const files = (0, import_react19.useMemo)(() => fileId ? [{ id: fileId, status: import_components16.Status.SUCCEEDED }] : [], [fileId]);
4552
4580
  const uploadFile = (formData) => {
4553
4581
  onEvent("Dynamic Flow - PersistAsync", { status: "pending", schemaId: id });
4554
4582
  return httpClient(String(httpOptions.url), {
@@ -4588,14 +4616,13 @@ function UploadInputAdapter(props) {
4588
4616
  var import_jsx_runtime32 = require("react/jsx-runtime");
4589
4617
  function PersistAsyncBlobSchema(props) {
4590
4618
  const { model, schema, submitted, required, errors, onChange } = props;
4591
- const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react19.useState)({});
4592
- const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react19.useState)(null);
4593
- const [validations, setValidations] = (0, import_react19.useState)([]);
4594
- const [changed, setChanged] = (0, import_react19.useState)(false);
4619
+ const [persistAsyncValidationMessages, setPersistAsyncValidationMessages] = (0, import_react20.useState)({});
4620
+ const [persistAsyncValidations, setPersistAsyncValidations] = (0, import_react20.useState)(null);
4621
+ const [validations, setValidations] = (0, import_react20.useState)([]);
4622
+ const [changed, setChanged] = (0, import_react20.useState)(false);
4595
4623
  const httpClient = useHttpClient();
4596
4624
  const onEvent = useEventDispatcher();
4597
- (0, import_react19.useEffect)(() => {
4598
- console.log(submitted);
4625
+ (0, import_react20.useEffect)(() => {
4599
4626
  if (submitted) {
4600
4627
  setValidations(getValidationFailures(model, schema, Boolean(required)));
4601
4628
  } else {
@@ -4693,7 +4720,7 @@ PersistAsyncSchema.defaultProps = {
4693
4720
  var PersistAsyncSchema_default = PersistAsyncSchema;
4694
4721
 
4695
4722
  // src/legacy/jsonSchemaForm/promotedOneOfSchema/PromotedOneOfSchema.tsx
4696
- var import_react20 = require("react");
4723
+ var import_react21 = require("react");
4697
4724
 
4698
4725
  // src/legacy/jsonSchemaForm/promotedOneOfSchema/promoted-one-of-utils.ts
4699
4726
  var getSelectionFromModel = (schema, model) => {
@@ -4784,7 +4811,7 @@ var import_jsx_runtime37 = require("react/jsx-runtime");
4784
4811
  var isPromoted = (schema) => schema.promoted === true;
4785
4812
  var PromotedOneOfSchema = (props) => {
4786
4813
  var _a;
4787
- const [selection, setSelection] = (0, import_react20.useState)(
4814
+ const [selection, setSelection] = (0, import_react21.useState)(
4788
4815
  getSelectionFromModel(props.schema, props.model) || ((_a = props.schema.promotion) == null ? void 0 : _a.default) || "promoted"
4789
4816
  );
4790
4817
  const promotedAlert = props.schema.alert;
@@ -4900,22 +4927,22 @@ function getValueFromOption(option) {
4900
4927
  }
4901
4928
 
4902
4929
  // src/legacy/jsonSchemaForm/validationAsyncSchema/ValidationAsyncSchema.tsx
4903
- var import_react21 = require("react");
4930
+ var import_react22 = require("react");
4904
4931
  var import_jsx_runtime39 = require("react/jsx-runtime");
4905
4932
  function ValidationAsyncSchema(props) {
4906
4933
  const { schema, model, required, submitted, errors, onChange } = props;
4907
- const [validationAsyncModel, setValidationAsyncModel] = (0, import_react21.useState)(model);
4908
- const previousRequestedModelReference = (0, import_react21.useRef)(null);
4909
- const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react21.useState)(
4934
+ const [validationAsyncModel, setValidationAsyncModel] = (0, import_react22.useState)(model);
4935
+ const previousRequestedModelReference = (0, import_react22.useRef)(null);
4936
+ const [validationAsyncSuccessMessage, setValidationAsyncSuccessMessage] = (0, import_react22.useState)(
4910
4937
  null
4911
4938
  );
4912
- const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react21.useState)(null);
4913
- const [fieldSubmitted, setFieldSubmitted] = (0, import_react21.useState)(false);
4914
- const [abortController, setAbortController] = (0, import_react21.useState)(null);
4939
+ const [validationAsyncErrors, setValidationAsyncErrors] = (0, import_react22.useState)(null);
4940
+ const [fieldSubmitted, setFieldSubmitted] = (0, import_react22.useState)(false);
4941
+ const [abortController, setAbortController] = (0, import_react22.useState)(null);
4915
4942
  const httpClient = useHttpClient();
4916
4943
  const onEvent = useEventDispatcher();
4917
4944
  const log = useLogger();
4918
- (0, import_react21.useEffect)(() => {
4945
+ (0, import_react22.useEffect)(() => {
4919
4946
  if (!schema.validationAsync.method) {
4920
4947
  log.warning(
4921
4948
  "Invalid schema or model",
@@ -4992,13 +5019,13 @@ var ValidationAsyncSchema_default = ValidationAsyncSchema;
4992
5019
 
4993
5020
  // src/legacy/jsonSchemaForm/genericSchema/GenericSchema.tsx
4994
5021
  var import_jsx_runtime40 = require("react/jsx-runtime");
4995
- var import_react23 = require("react");
5022
+ var import_react24 = require("react");
4996
5023
  function GenericSchemaForm(props) {
4997
5024
  const { schema, model = null, errors = null, hideTitle = false, disabled = false } = props;
4998
5025
  const schemaProps = __spreadProps(__spreadValues({}, props), { model, errors, hideTitle, disabled });
4999
5026
  const type = getSchemaType(schema);
5000
5027
  const log = useLogger();
5001
- (0, import_react22.useEffect)(() => {
5028
+ (0, import_react23.useEffect)(() => {
5002
5029
  if (!isValidGenericSchema(schema, model, errors)) {
5003
5030
  log.error(
5004
5031
  "Invalid schema or model",
@@ -5020,7 +5047,7 @@ function GenericSchemaForm(props) {
5020
5047
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(BasicTypeSchema_default, __spreadValues({}, basicTypeProps));
5021
5048
  }
5022
5049
  case "object":
5023
- return /* @__PURE__ */ (0, import_react23.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema) }));
5050
+ return /* @__PURE__ */ (0, import_react24.createElement)(ObjectSchema_default, __spreadProps(__spreadValues({}, schemaProps), { key: JSON.stringify(schema) }));
5024
5051
  case "array":
5025
5052
  return /* @__PURE__ */ (0, import_jsx_runtime40.jsx)(ArraySchema_default, __spreadValues({}, schemaProps));
5026
5053
  case "promotedOneOf":
@@ -5135,13 +5162,13 @@ var DynamicInfo = ({ component }) => {
5135
5162
 
5136
5163
  // src/legacy/layout/image/DynamicImage.tsx
5137
5164
  var import_components22 = require("@transferwise/components");
5138
- var import_react24 = require("react");
5165
+ var import_react25 = require("react");
5139
5166
  var import_jsx_runtime44 = require("react/jsx-runtime");
5140
5167
  function DynamicImage({ component: image }) {
5141
5168
  const { url, size, text, margin, accessibilityDescription } = image;
5142
5169
  const httpClient = useHttpClient();
5143
- const [imageSource, setImageSource] = (0, import_react24.useState)("");
5144
- (0, import_react24.useEffect)(() => {
5170
+ const [imageSource, setImageSource] = (0, import_react25.useState)("");
5171
+ (0, import_react25.useEffect)(() => {
5145
5172
  void getImageSource(httpClient, url).then(setImageSource);
5146
5173
  }, [url, httpClient]);
5147
5174
  const imageProps = {
@@ -5377,9 +5404,9 @@ var paragraph_messages_default = (0, import_react_intl16.defineMessages)({
5377
5404
 
5378
5405
  // src/legacy/layout/paragraph/useSnackBarIfAvailable.ts
5379
5406
  var import_components26 = require("@transferwise/components");
5380
- var import_react25 = require("react");
5407
+ var import_react26 = require("react");
5381
5408
  function useSnackBarIfAvailable() {
5382
- const context = (0, import_react25.useContext)(import_components26.SnackbarContext);
5409
+ const context = (0, import_react26.useContext)(import_components26.SnackbarContext);
5383
5410
  return context ? context.createSnackbar : noop2;
5384
5411
  }
5385
5412
  function noop2() {
@@ -5477,7 +5504,7 @@ function DynamicReview(props) {
5477
5504
  var DynamicReview_default = DynamicReview;
5478
5505
 
5479
5506
  // src/legacy/layout/search/DynamicSearch.tsx
5480
- var import_react27 = require("react");
5507
+ var import_react28 = require("react");
5481
5508
 
5482
5509
  // src/legacy/layout/search/SearchInput.tsx
5483
5510
  var import_components29 = require("@transferwise/components");
@@ -5558,15 +5585,15 @@ var ErrorResult = ({ onRetrySearch }) => {
5558
5585
  };
5559
5586
 
5560
5587
  // src/legacy/layout/search/useSearch.tsx
5561
- var import_react26 = require("react");
5588
+ var import_react27 = require("react");
5562
5589
  var headers = { "Content-Type": "application/json" };
5563
5590
  var useSearch = (defaultSearchConfig) => {
5564
- const [state, setState] = (0, import_react26.useState)({
5591
+ const [state, setState] = (0, import_react27.useState)({
5565
5592
  status: "idle"
5566
5593
  });
5567
- const abortControllerRef = (0, import_react26.useRef)(null);
5594
+ const abortControllerRef = (0, import_react27.useRef)(null);
5568
5595
  const httpClient = useHttpClient();
5569
- const search = (0, import_react26.useCallback)(
5596
+ const search = (0, import_react27.useCallback)(
5570
5597
  async (query, { url, method, param } = defaultSearchConfig) => {
5571
5598
  var _a;
5572
5599
  (_a = abortControllerRef.current) == null ? void 0 : _a.abort();
@@ -5630,11 +5657,11 @@ var addQueryParameter = (url, key, value) => {
5630
5657
  var import_jsx_runtime53 = require("react/jsx-runtime");
5631
5658
  var DEBOUNCE_TIME = 400;
5632
5659
  function DynamicSearch({ component, onAction }) {
5633
- const [query, setQuery] = (0, import_react27.useState)("");
5660
+ const [query, setQuery] = (0, import_react28.useState)("");
5634
5661
  const { title, margin, url, method, param, emptyMessage } = component;
5635
5662
  const { status, results, search } = useSearch({ url, method, param });
5636
5663
  const onEvent = useEventDispatcher();
5637
- const debouncedSearch = (0, import_react27.useMemo)(() => debounce(search, DEBOUNCE_TIME), [search]);
5664
+ const debouncedSearch = (0, import_react28.useMemo)(() => debounce(search, DEBOUNCE_TIME), [search]);
5638
5665
  const onSearchStart = () => {
5639
5666
  onEvent("Dynamic Flow - Search Started", {});
5640
5667
  };
@@ -5672,10 +5699,10 @@ var DynamicSearch_default = DynamicSearch;
5672
5699
 
5673
5700
  // src/legacy/layout/modal/DynamicModal.tsx
5674
5701
  var import_components31 = require("@transferwise/components");
5675
- var import_react28 = require("react");
5702
+ var import_react29 = require("react");
5676
5703
  var import_jsx_runtime54 = require("react/jsx-runtime");
5677
5704
  var DynamicModal = (props) => {
5678
- const [visible, isVisible] = (0, import_react28.useState)(false);
5705
+ const [visible, isVisible] = (0, import_react29.useState)(false);
5679
5706
  const { component, onAction } = props;
5680
5707
  const { margin = "md" } = component;
5681
5708
  return /* @__PURE__ */ (0, import_jsx_runtime54.jsxs)("div", { className: getTextAlignmentAndMargin({ margin }), children: [
@@ -5702,12 +5729,12 @@ var getDefaultValue = (schema) => {
5702
5729
  };
5703
5730
  var BasicTypeSchema = (props) => {
5704
5731
  var _a, _b, _c;
5705
- const onChange = (newModel) => {
5732
+ const onChange = (newModel, _type, metadata) => {
5706
5733
  setChanged(true);
5707
- setModelAndBroadcast(sanitiseModel(newModel), "user");
5734
+ setModelAndBroadcast(sanitiseModel(newModel), "user", metadata);
5708
5735
  };
5709
5736
  const getValidationKeys = (newModel) => getValidationFailures(newModel, props.schema, props.required);
5710
- const setModelAndBroadcast = (newModel, type) => {
5737
+ const setModelAndBroadcast = (newModel, type, metadata) => {
5711
5738
  setModel(newModel);
5712
5739
  const validationKeys = getValidationKeys(newModel);
5713
5740
  setValidations(validationKeys);
@@ -5719,7 +5746,8 @@ var BasicTypeSchema = (props) => {
5719
5746
  triggerSchema: props.schema,
5720
5747
  triggerModel: broadcastModel,
5721
5748
  lastTriggerModel: lastModel,
5722
- type
5749
+ type,
5750
+ metadata
5723
5751
  });
5724
5752
  }
5725
5753
  };
@@ -5732,13 +5760,13 @@ var BasicTypeSchema = (props) => {
5732
5760
  props.onBlur();
5733
5761
  }
5734
5762
  };
5735
- const [model, setModel] = (0, import_react29.useState)((_a = props.model) != null ? _a : null);
5736
- const [lastModel, setLastModel] = (0, import_react29.useState)((_b = props.model) != null ? _b : null);
5737
- const [changed, setChanged] = (0, import_react29.useState)(false);
5738
- const [focused, setFocused] = (0, import_react29.useState)(false);
5739
- const [blurred, setBlurred] = (0, import_react29.useState)(false);
5740
- const [validations, setValidations] = (0, import_react29.useState)([]);
5741
- const id = (0, import_react29.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
5763
+ const [model, setModel] = (0, import_react30.useState)((_a = props.model) != null ? _a : null);
5764
+ const [lastModel, setLastModel] = (0, import_react30.useState)((_b = props.model) != null ? _b : null);
5765
+ const [changed, setChanged] = (0, import_react30.useState)(false);
5766
+ const [focused, setFocused] = (0, import_react30.useState)(false);
5767
+ const [blurred, setBlurred] = (0, import_react30.useState)(false);
5768
+ const [validations, setValidations] = (0, import_react30.useState)([]);
5769
+ const id = (0, import_react30.useMemo)(() => props.schema.$id || generateRandomId(), [props.schema.$id]);
5742
5770
  const onSchemaChange = () => {
5743
5771
  const defaultValue = getDefaultValue(props.schema);
5744
5772
  if (isNullish(model) && !isNullish(defaultValue)) {
@@ -5753,9 +5781,9 @@ var BasicTypeSchema = (props) => {
5753
5781
  };
5754
5782
  const isConst = props.schema.const;
5755
5783
  const isHidden = props.schema.hidden || isConst;
5756
- (0, import_react29.useEffect)(refreshValidations, [props.model, props.submitted]);
5757
- (0, import_react29.useEffect)(onSchemaChange, [props.schema]);
5758
- (0, import_react29.useEffect)(() => {
5784
+ (0, import_react30.useEffect)(refreshValidations, [props.model, props.submitted]);
5785
+ (0, import_react30.useEffect)(onSchemaChange, [props.schema]);
5786
+ (0, import_react30.useEffect)(() => {
5759
5787
  var _a2;
5760
5788
  const newModel = (_a2 = props.model) != null ? _a2 : null;
5761
5789
  if (newModel !== model) {
@@ -5834,12 +5862,12 @@ function PersistAsyncBasicSchema(props) {
5834
5862
  const intl = (0, import_react_intl20.useIntl)();
5835
5863
  const httpClient = useHttpClient();
5836
5864
  const onEvent = useEventDispatcher();
5837
- const [persistAsyncModel, setPersistAsyncModel] = (0, import_react30.useState)(null);
5865
+ const [persistAsyncModel, setPersistAsyncModel] = (0, import_react31.useState)(null);
5838
5866
  const previousPersistAsyncModel = usePrevious(persistAsyncModel);
5839
- const [persistAsyncError, setPersistAsyncError] = (0, import_react30.useState)(null);
5840
- const [fieldSubmitted, setFieldSubmitted] = (0, import_react30.useState)(false);
5841
- const [abortController, setAbortController] = (0, import_react30.useState)(null);
5842
- (0, import_react30.useEffect)(() => {
5867
+ const [persistAsyncError, setPersistAsyncError] = (0, import_react31.useState)(null);
5868
+ const [fieldSubmitted, setFieldSubmitted] = (0, import_react31.useState)(false);
5869
+ const [abortController, setAbortController] = (0, import_react31.useState)(null);
5870
+ (0, import_react31.useEffect)(() => {
5843
5871
  if (controlTypesWithPersistOnChange.has(
5844
5872
  // TODO: LOW avoid type assertion below -- control type may be nullish. consider ?? ''
5845
5873
  getControlType(schema.persistAsync.schema)
@@ -5847,7 +5875,7 @@ function PersistAsyncBasicSchema(props) {
5847
5875
  persistAsyncIfValid();
5848
5876
  }
5849
5877
  }, [persistAsyncModel]);
5850
- const setGenericPersistAsyncError = () => setPersistAsyncError(intl.formatMessage(PersistAsyncSchema_messages_default.genericError));
5878
+ const setGenericPersistAsyncError = () => setPersistAsyncError(intl.formatMessage(persist_async_messages_default.genericError));
5851
5879
  const getPersistAsyncResponse = async (currentPersistAsyncModel, persistAsyncSpec) => {
5852
5880
  const signal = abortCurrentRequestAndGetNewAbortSignal();
5853
5881
  const requestBody = { [persistAsyncSpec.param]: currentPersistAsyncModel };
@@ -5927,7 +5955,7 @@ var PersistAsyncBasicSchema_default = PersistAsyncBasicSchema;
5927
5955
 
5928
5956
  // src/legacy/common/hooks/usePersistAsync/usePersistAsync.ts
5929
5957
  var usePersistAsync = (persistAsync) => {
5930
- const [abortController, setAbortController] = (0, import_react31.useState)(null);
5958
+ const [abortController, setAbortController] = (0, import_react32.useState)(null);
5931
5959
  const httpClient = useHttpClient();
5932
5960
  const intl = (0, import_react_intl21.useIntl)();
5933
5961
  const { schema } = persistAsync;
@@ -5986,10 +6014,10 @@ var usePersistAsync = (persistAsync) => {
5986
6014
  }
5987
6015
  }
5988
6016
  }
5989
- throw new Error(intl.formatMessage(PersistAsyncSchema_messages_default.genericError));
6017
+ throw new Error(intl.formatMessage(persist_async_messages_default.genericError));
5990
6018
  }
5991
6019
  const handleError = (error) => {
5992
- const message = hasStringMessage(error) ? error.message : intl.formatMessage(PersistAsyncSchema_messages_default.genericError);
6020
+ const message = hasStringMessage(error) ? error.message : intl.formatMessage(persist_async_messages_default.genericError);
5993
6021
  throw new Error(message);
5994
6022
  };
5995
6023
  return handlePersistAsync;
@@ -6006,7 +6034,7 @@ function hasStringMessage(value) {
6006
6034
  }
6007
6035
 
6008
6036
  // src/legacy/common/hooks/usePolling/usePolling.tsx
6009
- var import_react32 = require("react");
6037
+ var import_react33 = require("react");
6010
6038
  function usePolling({
6011
6039
  asyncFn,
6012
6040
  interval,
@@ -6015,9 +6043,9 @@ function usePolling({
6015
6043
  onPollingResponse,
6016
6044
  onFailure
6017
6045
  }) {
6018
- const onPollingResponseReference = (0, import_react32.useRef)(onPollingResponse);
6019
- const onFailureReference = (0, import_react32.useRef)(onFailure);
6020
- const poll = (0, import_react32.useMemo)(
6046
+ const onPollingResponseReference = (0, import_react33.useRef)(onPollingResponse);
6047
+ const onFailureReference = (0, import_react33.useRef)(onFailure);
6048
+ const poll = (0, import_react33.useMemo)(
6021
6049
  () => createPollingClosure(
6022
6050
  asyncFn,
6023
6051
  maxAttempts,
@@ -6027,7 +6055,7 @@ function usePolling({
6027
6055
  ),
6028
6056
  [asyncFn, maxAttempts, maxConsecutiveFails]
6029
6057
  );
6030
- (0, import_react32.useEffect)(() => {
6058
+ (0, import_react33.useEffect)(() => {
6031
6059
  if (interval > 0) {
6032
6060
  const intervalReference = setInterval(() => {
6033
6061
  poll();
@@ -6035,7 +6063,7 @@ function usePolling({
6035
6063
  return () => clearInterval(intervalReference);
6036
6064
  }
6037
6065
  }, [poll, interval]);
6038
- (0, import_react32.useEffect)(() => {
6066
+ (0, import_react33.useEffect)(() => {
6039
6067
  onPollingResponseReference.current = onPollingResponse;
6040
6068
  onFailureReference.current = onFailure;
6041
6069
  }, [onPollingResponse, onFailure]);
@@ -6066,20 +6094,20 @@ function createPollingClosure(asyncFn, maxAttempts, maxConsecutiveFails, onPolli
6066
6094
  }
6067
6095
 
6068
6096
  // src/legacy/common/hooks/usePrevious/usePrevious.js
6069
- var import_react33 = require("react");
6097
+ var import_react34 = require("react");
6070
6098
  var usePrevious = (value) => {
6071
- const reference = (0, import_react33.useRef)();
6072
- (0, import_react33.useEffect)(() => {
6099
+ const reference = (0, import_react34.useRef)();
6100
+ (0, import_react34.useEffect)(() => {
6073
6101
  reference.current = value;
6074
6102
  }, [value]);
6075
6103
  return reference.current;
6076
6104
  };
6077
6105
 
6078
6106
  // src/legacy/common/hooks/useStepPolling/useStepPolling.tsx
6079
- var import_react34 = require("react");
6107
+ var import_react35 = require("react");
6080
6108
  function useStepPolling(polling, onAction) {
6081
6109
  const httpClient = useHttpClient();
6082
- const asyncFn = (0, import_react34.useMemo)(() => {
6110
+ const asyncFn = (0, import_react35.useMemo)(() => {
6083
6111
  if (polling) {
6084
6112
  return () => httpClient(polling.url).then((response) => {
6085
6113
  if (response.ok) {
@@ -6092,7 +6120,7 @@ function useStepPolling(polling, onAction) {
6092
6120
  }
6093
6121
  return void 0;
6094
6122
  }, [polling, httpClient]);
6095
- const onPollingResponse = (0, import_react34.useCallback)(
6123
+ const onPollingResponse = (0, import_react35.useCallback)(
6096
6124
  (pollingResponse) => {
6097
6125
  if (pollingResponse == null ? void 0 : pollingResponse.action) {
6098
6126
  onAction(pollingResponse.action);
@@ -6108,7 +6136,7 @@ function useStepPolling(polling, onAction) {
6108
6136
  maxAttempts: (polling == null ? void 0 : polling.maxAttempts) || 0,
6109
6137
  maxConsecutiveFails: 1,
6110
6138
  onPollingResponse,
6111
- onFailure: (0, import_react34.useCallback)(() => {
6139
+ onFailure: (0, import_react35.useCallback)(() => {
6112
6140
  if (polling) {
6113
6141
  onAction(polling.onError.action);
6114
6142
  }
@@ -6156,10 +6184,10 @@ var LayoutStep = (props) => {
6156
6184
  var LayoutStep_default = LayoutStep;
6157
6185
 
6158
6186
  // src/legacy/step/cameraStep/CameraStep.tsx
6159
- var import_react39 = require("react");
6187
+ var import_react40 = require("react");
6160
6188
 
6161
6189
  // src/legacy/step/cameraStep/cameraCapture/CameraCapture.tsx
6162
- var import_react38 = require("react");
6190
+ var import_react39 = require("react");
6163
6191
  var import_react_intl26 = require("react-intl");
6164
6192
  var import_react_webcam = __toESM(require_react_webcam());
6165
6193
 
@@ -6316,7 +6344,7 @@ function CameraErrorScreen({ title, description, actionButton, onAction }) {
6316
6344
  var CameraErrorScreen_default = CameraErrorScreen;
6317
6345
 
6318
6346
  // src/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.ts
6319
- var import_react35 = require("react");
6347
+ var import_react36 = require("react");
6320
6348
  var import_screenfull = __toESM(require_screenfull());
6321
6349
 
6322
6350
  // src/legacy/step/cameraStep/cameraCapture/utils/index.ts
@@ -6395,16 +6423,16 @@ var trackCameraOrientationLocked = (onEvent) => {
6395
6423
 
6396
6424
  // src/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.ts
6397
6425
  var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
6398
- const lockOrientation = (0, import_react35.useCallback)(() => {
6426
+ const lockOrientation = (0, import_react36.useCallback)(() => {
6399
6427
  if (window.screen.orientation && "lock" in window.screen.orientation && typeof window.screen.orientation.lock === "function") {
6400
6428
  window.screen.orientation.lock("portrait").then(() => trackCameraOrientationLocked(onEvent)).catch(noop4);
6401
6429
  }
6402
6430
  }, [onEvent]);
6403
- const unlockOrientation = (0, import_react35.useCallback)(() => {
6431
+ const unlockOrientation = (0, import_react36.useCallback)(() => {
6404
6432
  var _a, _b, _c;
6405
6433
  return (_c = (_b = (_a = window == null ? void 0 : window.screen) == null ? void 0 : _a.orientation) == null ? void 0 : _b.unlock) == null ? void 0 : _c.call(_b);
6406
6434
  }, []);
6407
- const enterFullScreen = (0, import_react35.useCallback)(() => {
6435
+ const enterFullScreen = (0, import_react36.useCallback)(() => {
6408
6436
  setTimeout(() => {
6409
6437
  if (shouldLockOrientation && !import_screenfull.default.isFullscreen && import_screenfull.default.isEnabled) {
6410
6438
  import_screenfull.default.request(document.documentElement, { navigationUI: "show" }).then(() => {
@@ -6413,13 +6441,13 @@ var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
6413
6441
  }
6414
6442
  }, 100);
6415
6443
  }, [shouldLockOrientation, lockOrientation]);
6416
- const exitFullScreen = (0, import_react35.useCallback)(() => {
6444
+ const exitFullScreen = (0, import_react36.useCallback)(() => {
6417
6445
  if (import_screenfull.default.isFullscreen) {
6418
6446
  import_screenfull.default.exit().catch(noop4);
6419
6447
  }
6420
6448
  unlockOrientation();
6421
6449
  }, [unlockOrientation]);
6422
- const handleOrientationChange = (0, import_react35.useCallback)(
6450
+ const handleOrientationChange = (0, import_react36.useCallback)(
6423
6451
  (event) => {
6424
6452
  var _a, _b;
6425
6453
  if ((_a = event == null ? void 0 : event.target) == null ? void 0 : _a.type.includes("landscape")) {
@@ -6430,7 +6458,7 @@ var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
6430
6458
  },
6431
6459
  [onEvent]
6432
6460
  );
6433
- (0, import_react35.useEffect)(() => {
6461
+ (0, import_react36.useEffect)(() => {
6434
6462
  var _a, _b;
6435
6463
  if (shouldLockOrientation) {
6436
6464
  (_b = (_a = window.screen) == null ? void 0 : _a.orientation) == null ? void 0 : _b.addEventListener(
@@ -6453,9 +6481,9 @@ var noop4 = () => {
6453
6481
  };
6454
6482
 
6455
6483
  // src/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.ts
6456
- var import_react36 = require("react");
6484
+ var import_react37 = require("react");
6457
6485
  var useVideoConstraints = (direction) => {
6458
- const [videoConstraints, setVideoConstraints] = (0, import_react36.useState)();
6486
+ const [videoConstraints, setVideoConstraints] = (0, import_react37.useState)();
6459
6487
  const defaultVideoConstraints = {
6460
6488
  facingMode: direction === "front" ? "user" : "environment",
6461
6489
  height: { min: 480, max: 1080, ideal: 720 },
@@ -6463,7 +6491,7 @@ var useVideoConstraints = (direction) => {
6463
6491
  frameRate: 30,
6464
6492
  aspectRatio: 16 / 9
6465
6493
  };
6466
- (0, import_react36.useEffect)(() => {
6494
+ (0, import_react37.useEffect)(() => {
6467
6495
  void getVideoConstraints(direction).then(setVideoConstraints);
6468
6496
  }, [direction]);
6469
6497
  const getVideoConstraints = async (direction2) => {
@@ -6481,7 +6509,7 @@ var useVideoConstraints = (direction) => {
6481
6509
  };
6482
6510
 
6483
6511
  // src/legacy/step/cameraStep/cameraCapture/overlay/Overlay.tsx
6484
- var import_react37 = require("react");
6512
+ var import_react38 = require("react");
6485
6513
  var import_jsx_runtime61 = require("react/jsx-runtime");
6486
6514
  var captureButtonHeight = 92;
6487
6515
  var reviewButtonsHeight = 120;
@@ -6491,8 +6519,8 @@ var instructionsHeight = 48;
6491
6519
  var reviewInstructionsHeight = 40;
6492
6520
  var overlayMaxWidth = 800;
6493
6521
  function Overlay({ overlay, outline, imageUrl, title, instructions, reviewInstructions }) {
6494
- const svgReference = (0, import_react37.useRef)(null);
6495
- (0, import_react37.useEffect)(() => {
6522
+ const svgReference = (0, import_react38.useRef)(null);
6523
+ (0, import_react38.useEffect)(() => {
6496
6524
  const listener = debounce(() => {
6497
6525
  var _a;
6498
6526
  if ((_a = svgReference.current) == null ? void 0 : _a.innerHTML) {
@@ -6558,14 +6586,14 @@ function CameraCapture({
6558
6586
  onCapture,
6559
6587
  onEvent
6560
6588
  }) {
6561
- const [mode, setMode] = (0, import_react38.useState)("CAPTURE" /* CAPTURE */);
6562
- const [cameraError, setCameraError] = (0, import_react38.useState)();
6563
- const [isVideoMirrored, setIsVideoMirrored] = (0, import_react38.useState)(false);
6564
- const [ready, setReady] = (0, import_react38.useState)(false);
6565
- const [reviewImage, setReviewImage] = (0, import_react38.useState)();
6566
- const webcamReference = (0, import_react38.useRef)(null);
6589
+ const [mode, setMode] = (0, import_react39.useState)("CAPTURE" /* CAPTURE */);
6590
+ const [cameraError, setCameraError] = (0, import_react39.useState)();
6591
+ const [isVideoMirrored, setIsVideoMirrored] = (0, import_react39.useState)(false);
6592
+ const [ready, setReady] = (0, import_react39.useState)(false);
6593
+ const [reviewImage, setReviewImage] = (0, import_react39.useState)();
6594
+ const webcamReference = (0, import_react39.useRef)(null);
6567
6595
  const { videoConstraints } = useVideoConstraints(direction);
6568
- const shouldLockOrientation = (0, import_react38.useMemo)(
6596
+ const shouldLockOrientation = (0, import_react39.useMemo)(
6569
6597
  () => !!(isMobile() && mode === "CAPTURE" /* CAPTURE */),
6570
6598
  [mode]
6571
6599
  );
@@ -6574,7 +6602,7 @@ function CameraCapture({
6574
6602
  onEvent
6575
6603
  );
6576
6604
  const intl = (0, import_react_intl26.useIntl)();
6577
- const handleCapture = (0, import_react38.useCallback)(async () => {
6605
+ const handleCapture = (0, import_react39.useCallback)(async () => {
6578
6606
  var _a, _b, _c, _d, _e, _f;
6579
6607
  if (((_a = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _a.video) && ((_c = (_b = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _b.video) == null ? void 0 : _c.readyState) >= 3) {
6580
6608
  (_e = (_d = webcamReference == null ? void 0 : webcamReference.current) == null ? void 0 : _d.video) == null ? void 0 : _e.pause();
@@ -6596,7 +6624,7 @@ function CameraCapture({
6596
6624
  );
6597
6625
  }
6598
6626
  }, [webcamReference, showReview, setReviewImage, setMode, onCapture, isVideoMirrored]);
6599
- const handleUserMediaError = (0, import_react38.useCallback)(
6627
+ const handleUserMediaError = (0, import_react39.useCallback)(
6600
6628
  (error) => {
6601
6629
  setMode("ERROR" /* ERROR */);
6602
6630
  if (error instanceof DOMException) {
@@ -6632,7 +6660,7 @@ function CameraCapture({
6632
6660
  },
6633
6661
  [intl, onEvent]
6634
6662
  );
6635
- const handleUserMedia = (0, import_react38.useCallback)(
6663
+ const handleUserMedia = (0, import_react39.useCallback)(
6636
6664
  (stream) => {
6637
6665
  enterFullScreen();
6638
6666
  setReady(true);
@@ -6649,7 +6677,7 @@ function CameraCapture({
6649
6677
  setReviewImage(void 0);
6650
6678
  };
6651
6679
  const handleRetryCameraAccess = () => setMode("CAPTURE" /* CAPTURE */);
6652
- (0, import_react38.useEffect)(() => {
6680
+ (0, import_react39.useEffect)(() => {
6653
6681
  if (mode !== "CAPTURE" /* CAPTURE */) {
6654
6682
  exitFullScreen();
6655
6683
  }
@@ -6727,8 +6755,8 @@ function CameraStep(props) {
6727
6755
  const { assets, direction, instructions } = cameraConfig || {};
6728
6756
  const { overlay, outline } = assets || {};
6729
6757
  const { url: imageUrl } = image || {};
6730
- const [captureClicked, setCaptureClicked] = (0, import_react39.useState)(false);
6731
- (0, import_react39.useEffect)(() => {
6758
+ const [captureClicked, setCaptureClicked] = (0, import_react40.useState)(false);
6759
+ (0, import_react40.useEffect)(() => {
6732
6760
  if (captureClicked) {
6733
6761
  onAction(action);
6734
6762
  }
@@ -6945,10 +6973,10 @@ function DynamicFlowStep(props) {
6945
6973
  }
6946
6974
 
6947
6975
  // src/legacy/dynamicFlow/utils/useDebouncedRefresh/useDebouncedRefresh.ts
6948
- var import_react40 = require("react");
6976
+ var import_react41 = require("react");
6949
6977
  var DEBOUNCE_DELAY = 1e3;
6950
6978
  function useDebouncedRefresh(fetchRefresh) {
6951
- const map = (0, import_react40.useRef)(/* @__PURE__ */ new Map());
6979
+ const map = (0, import_react41.useRef)(/* @__PURE__ */ new Map());
6952
6980
  const retrieveOrCreate = (key) => {
6953
6981
  if (map.current.has(key)) {
6954
6982
  return map.current.get(key);
@@ -6971,12 +6999,12 @@ function useDebouncedRefresh(fetchRefresh) {
6971
6999
  var shouldDebounceSchema = (schema) => getSchemaType(schema) === "basic" && schema.type !== "boolean" && schema.format !== "base64url";
6972
7000
 
6973
7001
  // src/legacy/dynamicFlow/utils/useDynamicFlowState.ts
6974
- var import_react41 = require("react");
7002
+ var import_react42 = require("react");
6975
7003
  var useDynamicFlowState = (initialStep) => {
6976
7004
  var _a, _b;
6977
- const [formErrors, setFormErrors] = (0, import_react41.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
6978
- const [globalError, setGlobalError] = (0, import_react41.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
6979
- const [stepAndModels, setStepAndModels] = (0, import_react41.useState)({
7005
+ const [formErrors, setFormErrors] = (0, import_react42.useState)((_a = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _a.validation);
7006
+ const [globalError, setGlobalError] = (0, import_react42.useState)((_b = initialStep == null ? void 0 : initialStep.errors) == null ? void 0 : _b.error);
7007
+ const [stepAndModels, setStepAndModels] = (0, import_react42.useState)({
6980
7008
  step: initialStep || void 0,
6981
7009
  models: (initialStep == null ? void 0 : initialStep.model) ? buildInitialModels(initialStep.model, getAllSchemas(initialStep)) : {},
6982
7010
  etag: void 0
@@ -7006,7 +7034,7 @@ var useDynamicFlowState = (initialStep) => {
7006
7034
  return updatedState;
7007
7035
  });
7008
7036
  };
7009
- const modelIsValid = (0, import_react41.useMemo)(
7037
+ const modelIsValid = (0, import_react42.useMemo)(
7010
7038
  () => areModelsValid(models, getAllValidatableSchemas(step)),
7011
7039
  [models, step]
7012
7040
  );
@@ -7079,7 +7107,7 @@ var isInlineSchema = (schema) => schema !== void 0 && typeof schema === "object"
7079
7107
 
7080
7108
  // src/legacy/dynamicFlow/utils/useLoader.tsx
7081
7109
  var import_components36 = require("@transferwise/components");
7082
- var import_react42 = require("react");
7110
+ var import_react43 = require("react");
7083
7111
  var import_jsx_runtime67 = require("react/jsx-runtime");
7084
7112
  function useLoader(loaderConfig, initialState) {
7085
7113
  const config = __spreadValues({
@@ -7087,7 +7115,7 @@ function useLoader(loaderConfig, initialState) {
7087
7115
  initial: true,
7088
7116
  submission: false
7089
7117
  }, loaderConfig);
7090
- const [loadingState, setLoadingState] = (0, import_react42.useState)(initialState);
7118
+ const [loadingState, setLoadingState] = (0, import_react43.useState)(initialState);
7091
7119
  const shouldDisplayLoader = config.initial && loadingState === "initial" || config.submission && loadingState === "submission";
7092
7120
  const loader = shouldDisplayLoader ? /* @__PURE__ */ (0, import_jsx_runtime67.jsx)(
7093
7121
  import_components36.Loader,
@@ -7101,7 +7129,7 @@ function useLoader(loaderConfig, initialState) {
7101
7129
  }
7102
7130
 
7103
7131
  // src/common/errorBoundary/ErrorBoundary.tsx
7104
- var import_react43 = require("react");
7132
+ var import_react44 = require("react");
7105
7133
 
7106
7134
  // src/common/errorBoundary/ErrorBoundaryAlert.tsx
7107
7135
  var import_components37 = require("@transferwise/components");
@@ -7128,7 +7156,7 @@ function ErrorBoundaryAlert({ onDismiss }) {
7128
7156
  var import_jsx_runtime69 = require("react/jsx-runtime");
7129
7157
  var noop6 = () => {
7130
7158
  };
7131
- var ErrorBoundary = class extends import_react43.Component {
7159
+ var ErrorBoundary = class extends import_react44.Component {
7132
7160
  constructor(props) {
7133
7161
  super(props);
7134
7162
  this.handleErrorReset = () => {
@@ -7279,24 +7307,24 @@ var DynamicFlowComponent = ({
7279
7307
  setStepAndEtag,
7280
7308
  setSchemaModel
7281
7309
  } = useDynamicFlowState(initialStep);
7282
- const [submitted, setSubmitted] = (0, import_react44.useState)(false);
7310
+ const [submitted, setSubmitted] = (0, import_react45.useState)(false);
7283
7311
  const { isLoading, loader, setLoadingState } = useLoader(
7284
7312
  loaderConfig,
7285
7313
  initialStep ? "idle" : "initial"
7286
7314
  );
7287
7315
  const logCritical = getLogger("critical", onLog, flowId, (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key));
7288
- const analyticsMetadata = (0, import_react44.useMemo)(
7316
+ const analyticsMetadata = (0, import_react45.useMemo)(
7289
7317
  () => {
7290
7318
  var _a;
7291
7319
  return __spreadValues({ flowId, stepId: (step == null ? void 0 : step.id) || (step == null ? void 0 : step.key) }, (_a = step == null ? void 0 : step.analytics) != null ? _a : {});
7292
7320
  },
7293
7321
  [flowId, step]
7294
7322
  );
7295
- const dispatchEvent = (0, import_react44.useMemo)(
7323
+ const dispatchEvent = (0, import_react45.useMemo)(
7296
7324
  () => getEventDispatcher(onEvent, analyticsMetadata),
7297
7325
  [onEvent, analyticsMetadata]
7298
7326
  );
7299
- const dfHttpClient = (0, import_react44.useCallback)(
7327
+ const dfHttpClient = (0, import_react45.useCallback)(
7300
7328
  ({
7301
7329
  action,
7302
7330
  data,
@@ -7348,17 +7376,17 @@ var DynamicFlowComponent = ({
7348
7376
  dispatchEventAndComplete(__spreadValues(__spreadValues({}, exitResult), actionResult));
7349
7377
  };
7350
7378
  const debouncedRefresh = useDebouncedRefresh(performRefresh);
7351
- const dispatchEventAndComplete = (0, import_react44.useCallback)(
7379
+ const dispatchEventAndComplete = (0, import_react45.useCallback)(
7352
7380
  (result) => {
7353
7381
  dispatchEvent("Dynamic Flow - Flow Finished", { result: "success" });
7354
7382
  onCompletion(result);
7355
7383
  },
7356
7384
  [onCompletion, dispatchEvent]
7357
7385
  );
7358
- (0, import_react44.useEffect)(() => {
7386
+ (0, import_react45.useEffect)(() => {
7359
7387
  dispatchEvent("Dynamic Flow - Flow Started", {});
7360
7388
  }, []);
7361
- (0, import_react44.useEffect)(() => {
7389
+ (0, import_react45.useEffect)(() => {
7362
7390
  if (!initialStep) {
7363
7391
  const action = __spreadValues({
7364
7392
  id: "#initial-step-request",