@wise/dynamic-flow-client 3.11.6 → 3.11.8

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 (25) hide show
  1. package/build/main.js +162 -161
  2. package/build/main.min.js +1 -1
  3. package/build/main.mjs +162 -161
  4. package/build/types/{legacy/step/cameraStep → common}/cameraCapture/CameraCapture.d.ts +3 -2
  5. package/build/types/{legacy/step/cameraStep → common}/cameraCapture/hooks/useFullScreenOrientationLock.d.ts +2 -2
  6. package/build/types/common/cameraCapture/tracking/index.d.ts +8 -0
  7. package/build/types/legacy/common/utils/index.d.ts +5 -5
  8. package/build/types/legacy/dynamic-flow-types.d.ts +2 -1
  9. package/build/types/legacy/dynamicFlow/utils/useErrorResponse.d.ts +1 -1
  10. package/package.json +23 -17
  11. package/build/types/legacy/step/cameraStep/cameraCapture/tracking/index.d.ts +0 -8
  12. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/CameraCapture.messages.d.ts +0 -0
  13. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/components/bottomBar/BottomBar.d.ts +0 -0
  14. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/components/index.d.ts +0 -0
  15. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.d.ts +0 -0
  16. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.d.ts +0 -0
  17. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/hooks/useVideoConstraints.d.ts +0 -0
  18. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/index.d.ts +0 -0
  19. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/overlay/Overlay.d.ts +0 -0
  20. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.d.ts +0 -0
  21. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/screens/index.d.ts +0 -0
  22. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/types/index.d.ts +0 -0
  23. /package/build/types/{legacy/step/cameraStep → common}/cameraCapture/utils/index.d.ts +0 -0
  24. /package/build/types/{legacy/common → common/cameraCapture}/utils/mobile-utils.d.ts +0 -0
  25. /package/build/types/{legacy/common → common}/utils/debounce.d.ts +0 -0
package/build/main.mjs CHANGED
@@ -10602,7 +10602,7 @@ function $1746a345f3d73bb7$export$f680877a34711e37(deterministicId) {
10602
10602
  return deterministicId || (id ? `radix-${id}` : "");
10603
10603
  }
10604
10604
 
10605
- // ../../node_modules/.pnpm/@wise+forms@0.3.4_@transferwise+components@46.36.0_@types+react@18.3.3_react@18.3.1/node_modules/@wise/forms/dist/index.mjs
10605
+ // ../../node_modules/.pnpm/@wise+forms@0.3.4_@transferwise+components@46.37.0_@types+react@18.3.3_react@18.3.1/node_modules/@wise/forms/dist/index.mjs
10606
10606
  var import_classnames = __toESM(require_classnames(), 1);
10607
10607
  import { InlineAlert, Sentiment as Sentiment2, Input, TextArea } from "@transferwise/components";
10608
10608
  import { createContext as createContext2, useContext as useContext2, forwardRef } from "react";
@@ -13192,6 +13192,61 @@ function FeatureContextProvider({ features, children }) {
13192
13192
  return /* @__PURE__ */ jsx64(FeatureContext.Provider, { value: features, children });
13193
13193
  }
13194
13194
 
13195
+ // src/common/cameraCapture/utils/mobile-utils.ts
13196
+ var isMobile = () => isMobileScreenSize() && (isTouchScreen() || isMobileUA());
13197
+ var isMobileUA = (userAgent = window.navigator.userAgent) => (
13198
+ // eslint-disable-next-line regexp/no-unused-capturing-group
13199
+ /mobi|\b(iphone|android|blackberry|webos|windows phone)\b/i.test(userAgent)
13200
+ );
13201
+ var isMobileScreenSize = (width = window.screen.width, height = window.screen.height) => width < 768 || height < 768;
13202
+ var isTouchScreen = (navigator2 = window.navigator, matchMedia = window.matchMedia) => {
13203
+ if ("maxTouchPoints" in navigator2) {
13204
+ return navigator2.maxTouchPoints > 0;
13205
+ }
13206
+ const mQ = matchMedia == null ? void 0 : matchMedia("(pointer:coarse)");
13207
+ if ((mQ == null ? void 0 : mQ.media) === "(pointer:coarse)") {
13208
+ return Boolean(mQ.matches);
13209
+ }
13210
+ return false;
13211
+ };
13212
+
13213
+ // src/common/utils/debounce.ts
13214
+ var debounce2 = (callback, waitMs) => {
13215
+ let timeoutId;
13216
+ let lastArgs;
13217
+ const clearTimer = () => {
13218
+ if (timeoutId) {
13219
+ clearTimeout(timeoutId);
13220
+ timeoutId = null;
13221
+ }
13222
+ lastArgs = null;
13223
+ };
13224
+ const debouncedFn = (...args) => {
13225
+ lastArgs = args;
13226
+ if (timeoutId !== null) {
13227
+ clearTimeout(timeoutId);
13228
+ }
13229
+ timeoutId = setTimeout(() => {
13230
+ callback(...lastArgs);
13231
+ timeoutId = null;
13232
+ lastArgs = null;
13233
+ }, waitMs);
13234
+ };
13235
+ debouncedFn.cancel = () => {
13236
+ if (timeoutId !== null) {
13237
+ clearTimer();
13238
+ }
13239
+ };
13240
+ debouncedFn.flush = () => {
13241
+ if (timeoutId !== null) {
13242
+ callback(...lastArgs);
13243
+ clearTimer();
13244
+ }
13245
+ };
13246
+ debouncedFn.isPending = () => timeoutId !== null;
13247
+ return debouncedFn;
13248
+ };
13249
+
13195
13250
  // src/legacy/common/utils/api-utils.ts
13196
13251
  function isStatus2xx(status) {
13197
13252
  return status >= 200 && status < 300;
@@ -13654,63 +13709,6 @@ var dateStringToDate = (dateString) => {
13654
13709
  };
13655
13710
  var dateToDateString2 = (date) => formatDate2(date);
13656
13711
 
13657
- // src/legacy/common/utils/debounce.ts
13658
- var debounce2 = (callback, waitMs) => {
13659
- let timeoutId;
13660
- let lastArgs;
13661
- const clearTimer = () => {
13662
- if (timeoutId) {
13663
- clearTimeout(timeoutId);
13664
- timeoutId = null;
13665
- }
13666
- lastArgs = null;
13667
- };
13668
- const debouncedFn = (...args) => {
13669
- lastArgs = args;
13670
- if (timeoutId !== null) {
13671
- clearTimeout(timeoutId);
13672
- }
13673
- timeoutId = setTimeout(() => {
13674
- callback(...lastArgs);
13675
- timeoutId = null;
13676
- lastArgs = null;
13677
- }, waitMs);
13678
- };
13679
- debouncedFn.cancel = () => {
13680
- if (timeoutId !== null) {
13681
- clearTimer();
13682
- }
13683
- };
13684
- debouncedFn.flush = () => {
13685
- if (timeoutId !== null) {
13686
- callback(...lastArgs);
13687
- clearTimer();
13688
- }
13689
- };
13690
- debouncedFn.isPending = () => timeoutId !== null;
13691
- return debouncedFn;
13692
- };
13693
-
13694
- // src/legacy/common/utils/is-equal.ts
13695
- var isEqual = (a, b) => {
13696
- if (a === b) {
13697
- return true;
13698
- }
13699
- if (Array.isArray(a) && Array.isArray(b)) {
13700
- return a.length === b.length && a.every((item, index) => isEqual(item, b[index]));
13701
- }
13702
- if (isNonNullObject(a) && isNonNullObject(b) && isObjectEquals(a, b)) {
13703
- return true;
13704
- }
13705
- return false;
13706
- };
13707
- var isObjectEquals = (a, b) => {
13708
- const keysA = Object.keys(a);
13709
- const keysB = Object.keys(b);
13710
- return keysA.length === keysB.length && keysA.every((key) => Object.hasOwnProperty.call(b, key) && isEqual(a[key], b[key]));
13711
- };
13712
- var isNonNullObject = (a) => typeof a === "object" && a !== null;
13713
-
13714
13712
  // src/legacy/common/utils/file-utils.ts
13715
13713
  function toKilobytes2(sizeInBytes) {
13716
13714
  const ONE_KB_IN_BYTES = 1024;
@@ -13746,6 +13744,52 @@ var generateRandomId = (prefix = "") => {
13746
13744
  return `${prefixString}${Math.floor(1e8 * Math.random())}`;
13747
13745
  };
13748
13746
 
13747
+ // src/legacy/common/utils/is-equal.ts
13748
+ var isEqual = (a, b) => {
13749
+ if (a === b) {
13750
+ return true;
13751
+ }
13752
+ if (Array.isArray(a) && Array.isArray(b)) {
13753
+ return a.length === b.length && a.every((item, index) => isEqual(item, b[index]));
13754
+ }
13755
+ if (isNonNullObject(a) && isNonNullObject(b) && isObjectEquals(a, b)) {
13756
+ return true;
13757
+ }
13758
+ return false;
13759
+ };
13760
+ var isObjectEquals = (a, b) => {
13761
+ const keysA = Object.keys(a);
13762
+ const keysB = Object.keys(b);
13763
+ return keysA.length === keysB.length && keysA.every((key) => Object.hasOwnProperty.call(b, key) && isEqual(a[key], b[key]));
13764
+ };
13765
+ var isNonNullObject = (a) => typeof a === "object" && a !== null;
13766
+
13767
+ // src/legacy/common/utils/misc-utils.ts
13768
+ var isBasicError = (error) => isString2(error) || isNull3(error);
13769
+
13770
+ // src/legacy/common/utils/model-utils.ts
13771
+ var isObjectModel2 = (model) => typeof model === "object" && model !== null && model.constructor === Object;
13772
+ var isNullableObjectModel = (model) => isNull3(model) || isObjectModel2(model);
13773
+ var isNullableBasicModel = (model) => isBoolean2(model) || isNumber3(model) || isString2(model) || isNull3(model);
13774
+ var isNullableStringModel = (model) => isString2(model) || isNull3(model);
13775
+ var isArrayModel2 = (model) => {
13776
+ if (isArray2(model)) {
13777
+ if (model.length === 0) {
13778
+ return true;
13779
+ }
13780
+ return model.every(
13781
+ (item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" || typeof item === "object"
13782
+ );
13783
+ }
13784
+ return false;
13785
+ };
13786
+ var isNullableArrayModel = (model) => {
13787
+ if (isNull3(model)) {
13788
+ return true;
13789
+ }
13790
+ return isArrayModel2(model);
13791
+ };
13792
+
13749
13793
  // src/legacy/common/utils/schema-utils.ts
13750
13794
  function isConstSchema2(schema) {
13751
13795
  return !isUndefined3(schema == null ? void 0 : schema.const);
@@ -13874,50 +13918,6 @@ var filterHiddenSchemas = (schemas) => schemas.filter((schema) => {
13874
13918
  return (schema == null ? void 0 : schema.hidden) !== true;
13875
13919
  });
13876
13920
 
13877
- // src/legacy/common/utils/model-utils.ts
13878
- var isObjectModel2 = (model) => typeof model === "object" && model !== null && model.constructor === Object;
13879
- var isNullableObjectModel = (model) => isNull3(model) || isObjectModel2(model);
13880
- var isNullableBasicModel = (model) => isBoolean2(model) || isNumber3(model) || isString2(model) || isNull3(model);
13881
- var isNullableStringModel = (model) => isString2(model) || isNull3(model);
13882
- var isArrayModel2 = (model) => {
13883
- if (isArray2(model)) {
13884
- if (model.length === 0) {
13885
- return true;
13886
- }
13887
- return model.every(
13888
- (item) => typeof item === "string" || typeof item === "number" || typeof item === "boolean" || typeof item === "object"
13889
- );
13890
- }
13891
- return false;
13892
- };
13893
- var isNullableArrayModel = (model) => {
13894
- if (isNull3(model)) {
13895
- return true;
13896
- }
13897
- return isArrayModel2(model);
13898
- };
13899
-
13900
- // src/legacy/common/utils/misc-utils.ts
13901
- var isBasicError = (error) => isString2(error) || isNull3(error);
13902
-
13903
- // src/legacy/common/utils/mobile-utils.ts
13904
- var isMobile = () => isMobileScreenSize() && (isTouchScreen() || isMobileUA());
13905
- var isMobileUA = (userAgent = window.navigator.userAgent) => (
13906
- // eslint-disable-next-line regexp/no-unused-capturing-group
13907
- /mobi|\b(iphone|android|blackberry|webos|windows phone)\b/i.test(userAgent)
13908
- );
13909
- var isMobileScreenSize = (width = window.screen.width, height = window.screen.height) => width < 768 || height < 768;
13910
- var isTouchScreen = (navigator2 = window.navigator, matchMedia = window.matchMedia) => {
13911
- if ("maxTouchPoints" in navigator2) {
13912
- return navigator2.maxTouchPoints > 0;
13913
- }
13914
- const mQ = matchMedia == null ? void 0 : matchMedia("(pointer:coarse)");
13915
- if ((mQ == null ? void 0 : mQ.media) === "(pointer:coarse)") {
13916
- return Boolean(mQ.matches);
13917
- }
13918
- return false;
13919
- };
13920
-
13921
13921
  // src/legacy/common/hooks/useDebouncedFunction/useDebouncedFunction.tsx
13922
13922
  import { useCallback as useCallback4 } from "react";
13923
13923
  function useDebouncedFunction(callback, waitMs) {
@@ -18146,12 +18146,12 @@ var LayoutStep_default = LayoutStep;
18146
18146
  // src/legacy/step/cameraStep/CameraStep.tsx
18147
18147
  import { useEffect as useEffect25, useState as useState32 } from "react";
18148
18148
 
18149
- // src/legacy/step/cameraStep/cameraCapture/CameraCapture.tsx
18149
+ // src/common/cameraCapture/CameraCapture.tsx
18150
18150
  import { useCallback as useCallback10, useEffect as useEffect24, useMemo as useMemo20, useRef as useRef8, useState as useState31 } from "react";
18151
18151
  import { useIntl as useIntl23 } from "react-intl";
18152
18152
  import Webcam from "react-webcam";
18153
18153
 
18154
- // src/legacy/step/cameraStep/cameraCapture/CameraCapture.messages.ts
18154
+ // src/common/cameraCapture/CameraCapture.messages.ts
18155
18155
  import { defineMessages as defineMessages13 } from "react-intl";
18156
18156
  var CameraCapture_messages_default = defineMessages13({
18157
18157
  reviewSubmit: {
@@ -18211,7 +18211,7 @@ var CameraCapture_messages_default = defineMessages13({
18211
18211
  }
18212
18212
  });
18213
18213
 
18214
- // src/legacy/step/cameraStep/cameraCapture/components/bottomBar/BottomBar.tsx
18214
+ // src/common/cameraCapture/components/bottomBar/BottomBar.tsx
18215
18215
  import { Button as Button10, ControlType, Priority, Size as Size3 } from "@transferwise/components";
18216
18216
  import { useIntl as useIntl21 } from "react-intl";
18217
18217
  import { jsx as jsx118, jsxs as jsxs46 } from "react/jsx-runtime";
@@ -18258,10 +18258,10 @@ var CaptureButton = ({ onClick }) => /* @__PURE__ */ jsx118(
18258
18258
  }
18259
18259
  );
18260
18260
 
18261
- // src/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18261
+ // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18262
18262
  import { useIntl as useIntl22 } from "react-intl";
18263
18263
 
18264
- // src/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.ts
18264
+ // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.messages.ts
18265
18265
  import { defineMessages as defineMessages14 } from "react-intl";
18266
18266
  var OrientationLockOverlay_messages_default = defineMessages14({
18267
18267
  text: {
@@ -18271,7 +18271,7 @@ var OrientationLockOverlay_messages_default = defineMessages14({
18271
18271
  }
18272
18272
  });
18273
18273
 
18274
- // src/legacy/step/cameraStep/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18274
+ // src/common/cameraCapture/components/orientationLockOverlay/OrientationLockOverlay.tsx
18275
18275
  import { jsx as jsx119, jsxs as jsxs47 } from "react/jsx-runtime";
18276
18276
  function OrientationLockOverlay() {
18277
18277
  const intl = useIntl22();
@@ -18291,23 +18291,11 @@ function OrientationLockOverlay() {
18291
18291
  }
18292
18292
  var OrientationLockOverlay_default = OrientationLockOverlay;
18293
18293
 
18294
- // src/legacy/step/cameraStep/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.tsx
18295
- import { Button as Button11 } from "@transferwise/components";
18296
- import { jsx as jsx120, jsxs as jsxs48 } from "react/jsx-runtime";
18297
- function CameraErrorScreen({ title, description, actionButton, onAction }) {
18298
- return /* @__PURE__ */ jsx120("div", { className: "container p-t-5", children: /* @__PURE__ */ jsx120("div", { className: "row", children: /* @__PURE__ */ jsxs48("div", { className: "col-md-6 col-md-offset-3", children: [
18299
- /* @__PURE__ */ jsx120("h2", { className: "text-xs-center m-b-3", children: title }),
18300
- /* @__PURE__ */ jsx120("p", { className: "text-xs-center m-b-5", children: description }),
18301
- onAction && actionButton && /* @__PURE__ */ jsx120(Button11, { block: true, onClick: onAction, children: actionButton })
18302
- ] }) }) });
18303
- }
18304
- var CameraErrorScreen_default = CameraErrorScreen;
18305
-
18306
- // src/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.ts
18294
+ // src/common/cameraCapture/hooks/useFullScreenOrientationLock.ts
18307
18295
  var import_screenfull = __toESM(require_screenfull());
18308
18296
  import { useCallback as useCallback9, useEffect as useEffect21 } from "react";
18309
18297
 
18310
- // src/legacy/step/cameraStep/cameraCapture/utils/index.ts
18298
+ // src/common/cameraCapture/utils/index.ts
18311
18299
  var isSelfieCamera = (stream) => {
18312
18300
  var _a;
18313
18301
  const { facingMode } = ((_a = getVideoTrack(stream)) == null ? void 0 : _a.getSettings()) || {};
@@ -18353,7 +18341,7 @@ var getVideoCapabilities = (videoStream) => {
18353
18341
  return (_b = (_a = getVideoTrack(videoStream)) == null ? void 0 : _a.getCapabilities) == null ? void 0 : _b.call(_a);
18354
18342
  };
18355
18343
 
18356
- // src/legacy/step/cameraStep/cameraCapture/tracking/index.ts
18344
+ // src/common/cameraCapture/tracking/index.ts
18357
18345
  var trackCameraError = (message, onEvent, error) => onEvent == null ? void 0 : onEvent(message, { Error: getSerializedError(error) });
18358
18346
  var getSerializedError = (error) => error instanceof DOMException ? JSON.stringify({
18359
18347
  name: error == null ? void 0 : error.name,
@@ -18375,13 +18363,13 @@ var getCameraStartedProperties = async (props, videoStream) => {
18375
18363
  });
18376
18364
  };
18377
18365
  var trackCameraOrientationLandscape = (onEvent) => {
18378
- onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Orientation Lock Overlay Shown", {});
18366
+ void (onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Orientation Lock Overlay Shown", {}));
18379
18367
  };
18380
18368
  var trackCameraOrientationLocked = (onEvent) => {
18381
- onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Orientation Locked", {});
18369
+ void (onEvent == null ? void 0 : onEvent("Dynamic Flow - Camera Orientation Locked", {}));
18382
18370
  };
18383
18371
 
18384
- // src/legacy/step/cameraStep/cameraCapture/hooks/useFullScreenOrientationLock.ts
18372
+ // src/common/cameraCapture/hooks/useFullScreenOrientationLock.ts
18385
18373
  var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
18386
18374
  const lockOrientation = useCallback9(() => {
18387
18375
  if (window.screen.orientation && "lock" in window.screen.orientation && typeof window.screen.orientation.lock === "function") {
@@ -18443,37 +18431,37 @@ var useFullScreenOrientationLock = (shouldLockOrientation, onEvent) => {
18443
18431
  var noop5 = () => {
18444
18432
  };
18445
18433
 
18446
- // src/legacy/step/cameraStep/cameraCapture/hooks/useVideoConstraints.ts
18434
+ // src/common/cameraCapture/hooks/useVideoConstraints.ts
18447
18435
  import { useEffect as useEffect22, useState as useState30 } from "react";
18448
18436
  var useVideoConstraints = (direction) => {
18449
18437
  const [videoConstraints, setVideoConstraints] = useState30();
18438
+ useEffect22(() => {
18439
+ void getVideoConstraints(direction).then(setVideoConstraints);
18440
+ }, [direction]);
18441
+ return { videoConstraints };
18442
+ };
18443
+ var getVideoConstraints = async (dir) => {
18450
18444
  const defaultVideoConstraints = {
18451
- facingMode: direction === "front" ? "user" : "environment",
18445
+ facingMode: dir === "front" ? "user" : "environment",
18452
18446
  height: { min: 480, max: 1080, ideal: 720 },
18453
18447
  width: { min: 640, max: 1920, ideal: 1280 },
18454
18448
  frameRate: 30,
18455
18449
  aspectRatio: 16 / 9
18456
18450
  };
18457
- useEffect22(() => {
18458
- void getVideoConstraints(direction).then(setVideoConstraints);
18459
- }, [direction]);
18460
- const getVideoConstraints = async (direction2) => {
18461
- if (direction2 === "back") {
18462
- const mainCamera = (await getAvailableVideoDevices()).find(isMainBackCamera);
18463
- if (mainCamera == null ? void 0 : mainCamera.deviceId) {
18464
- return __spreadProps(__spreadValues({}, defaultVideoConstraints), {
18465
- deviceId: { exact: mainCamera.deviceId }
18466
- });
18467
- }
18451
+ if (dir === "back") {
18452
+ const mainCamera = (await getAvailableVideoDevices()).find(isMainBackCamera);
18453
+ if (mainCamera == null ? void 0 : mainCamera.deviceId) {
18454
+ return __spreadProps(__spreadValues({}, defaultVideoConstraints), {
18455
+ deviceId: { exact: mainCamera.deviceId }
18456
+ });
18468
18457
  }
18469
- return defaultVideoConstraints;
18470
- };
18471
- return { videoConstraints };
18458
+ }
18459
+ return defaultVideoConstraints;
18472
18460
  };
18473
18461
 
18474
- // src/legacy/step/cameraStep/cameraCapture/overlay/Overlay.tsx
18462
+ // src/common/cameraCapture/overlay/Overlay.tsx
18475
18463
  import { useEffect as useEffect23, useRef as useRef7 } from "react";
18476
- import { Fragment as Fragment23, jsx as jsx121, jsxs as jsxs49 } from "react/jsx-runtime";
18464
+ import { Fragment as Fragment23, jsx as jsx120, jsxs as jsxs48 } from "react/jsx-runtime";
18477
18465
  var captureButtonHeight = 92;
18478
18466
  var reviewButtonsHeight = 120;
18479
18467
  var imageHeight = 40;
@@ -18495,18 +18483,18 @@ function Overlay({ overlay, outline, imageUrl, title, instructions, reviewInstru
18495
18483
  return () => window.removeEventListener("resize", listener);
18496
18484
  });
18497
18485
  let helperBoxHeight = (imageUrl ? imageHeight : 0) + (title ? titleHeight : 0) + (instructions ? instructionsHeight : 0);
18498
- let helperBox = /* @__PURE__ */ jsxs49(Fragment23, { children: [
18499
- imageUrl && /* @__PURE__ */ jsx121("img", { className: "camera-capture-img", src: imageUrl, alt: "" }),
18500
- title && /* @__PURE__ */ jsx121("h4", { className: "camera-capture-title", children: title }),
18501
- instructions && /* @__PURE__ */ jsx121("small", { className: "camera-capture-instructions", children: instructions })
18486
+ let helperBox = /* @__PURE__ */ jsxs48(Fragment23, { children: [
18487
+ imageUrl && /* @__PURE__ */ jsx120("img", { className: "camera-capture-img", src: imageUrl, alt: "" }),
18488
+ title && /* @__PURE__ */ jsx120("h4", { className: "camera-capture-title", children: title }),
18489
+ instructions && /* @__PURE__ */ jsx120("small", { className: "camera-capture-instructions", children: instructions })
18502
18490
  ] });
18503
18491
  const frameBottomMargin = captureButtonHeight + helperBoxHeight;
18504
18492
  if (reviewInstructions) {
18505
18493
  helperBoxHeight = frameBottomMargin - reviewButtonsHeight;
18506
- helperBox = /* @__PURE__ */ jsx121("small", { className: "camera-capture-instructions", children: reviewInstructions });
18494
+ helperBox = /* @__PURE__ */ jsx120("small", { className: "camera-capture-instructions", children: reviewInstructions });
18507
18495
  const frameWithReviewInstructionsMinBottomMargin = reviewButtonsHeight + reviewInstructionsHeight;
18508
18496
  if (frameBottomMargin < frameWithReviewInstructionsMinBottomMargin) {
18509
- helperBox = /* @__PURE__ */ jsx121(Fragment23, {});
18497
+ helperBox = /* @__PURE__ */ jsx120(Fragment23, {});
18510
18498
  }
18511
18499
  }
18512
18500
  const framePosition = {
@@ -18524,19 +18512,31 @@ function Overlay({ overlay, outline, imageUrl, title, instructions, reviewInstru
18524
18512
  width: "90%"
18525
18513
  }
18526
18514
  };
18527
- return /* @__PURE__ */ jsxs49("svg", { ref: svgReference, xmlns: "http://www.w3.org/2000/svg", children: [
18528
- /* @__PURE__ */ jsx121("defs", { children: /* @__PURE__ */ jsxs49("mask", { id: "mask", children: [
18529
- /* @__PURE__ */ jsx121("rect", { width: "100%", height: "100%", fill: "#fff" }),
18530
- /* @__PURE__ */ jsx121("image", __spreadValues({ href: overlay }, framePosition))
18515
+ return /* @__PURE__ */ jsxs48("svg", { ref: svgReference, xmlns: "http://www.w3.org/2000/svg", children: [
18516
+ /* @__PURE__ */ jsx120("defs", { children: /* @__PURE__ */ jsxs48("mask", { id: "mask", children: [
18517
+ /* @__PURE__ */ jsx120("rect", { width: "100%", height: "100%", fill: "#fff" }),
18518
+ /* @__PURE__ */ jsx120("image", __spreadValues({ href: overlay }, framePosition))
18531
18519
  ] }) }),
18532
- overlay && /* @__PURE__ */ jsx121("rect", { width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.72" }),
18533
- outline && /* @__PURE__ */ jsx121("image", __spreadValues({ href: outline }, framePosition)),
18534
- /* @__PURE__ */ jsx121("foreignObject", { width: "100%", height: "100%", children: /* @__PURE__ */ jsx121("div", __spreadProps(__spreadValues({ className: "camera-capture-text-and-image-container" }, helperBoxPosition), { children: helperBox })) })
18520
+ overlay && /* @__PURE__ */ jsx120("rect", { width: "100%", height: "100%", mask: "url(#mask)", fillOpacity: "0.72" }),
18521
+ outline && /* @__PURE__ */ jsx120("image", __spreadValues({ href: outline }, framePosition)),
18522
+ /* @__PURE__ */ jsx120("foreignObject", { width: "100%", height: "100%", children: /* @__PURE__ */ jsx120("div", __spreadProps(__spreadValues({ className: "camera-capture-text-and-image-container" }, helperBoxPosition), { children: helperBox })) })
18535
18523
  ] });
18536
18524
  }
18537
18525
  var Overlay_default = Overlay;
18538
18526
 
18539
- // src/legacy/step/cameraStep/cameraCapture/CameraCapture.tsx
18527
+ // src/common/cameraCapture/screens/cameraErrorScreen/CameraErrorScreen.tsx
18528
+ import { Button as Button11 } from "@transferwise/components";
18529
+ import { jsx as jsx121, jsxs as jsxs49 } from "react/jsx-runtime";
18530
+ function CameraErrorScreen({ title, description, actionButton, onAction }) {
18531
+ return /* @__PURE__ */ jsx121("div", { className: "container p-t-5", children: /* @__PURE__ */ jsx121("div", { className: "row", children: /* @__PURE__ */ jsxs49("div", { className: "col-md-6 col-md-offset-3", children: [
18532
+ /* @__PURE__ */ jsx121("h2", { className: "text-xs-center m-b-3", children: title }),
18533
+ /* @__PURE__ */ jsx121("p", { className: "text-xs-center m-b-5", children: description }),
18534
+ onAction && actionButton && /* @__PURE__ */ jsx121(Button11, { block: true, onClick: onAction, children: actionButton })
18535
+ ] }) }) });
18536
+ }
18537
+ var CameraErrorScreen_default = CameraErrorScreen;
18538
+
18539
+ // src/common/cameraCapture/CameraCapture.tsx
18540
18540
  import { jsx as jsx122, jsxs as jsxs50 } from "react/jsx-runtime";
18541
18541
  function CameraCapture({
18542
18542
  direction = "back",
@@ -19168,12 +19168,12 @@ var isResponse2 = (response) => typeof response === "object" && response !== nul
19168
19168
  import { useIntl as useIntl25 } from "react-intl";
19169
19169
  var useErrorResponse = () => {
19170
19170
  const { formatMessage } = useIntl25();
19171
- return async (response, fetchType) => {
19171
+ return async (response, fetchType, isInitialRequest) => {
19172
19172
  try {
19173
19173
  const errorResponse = await parseErrorResponse(response);
19174
19174
  return errorResponse;
19175
19175
  } catch (error) {
19176
- if (fetchType === "submission") {
19176
+ if (fetchType === "submission" && !isInitialRequest) {
19177
19177
  return { error: formatMessage(generic_error_messages_default.genericErrorRetryHint) };
19178
19178
  }
19179
19179
  throw error;
@@ -19323,7 +19323,8 @@ var DynamicFlowComponent = ({
19323
19323
  return;
19324
19324
  }
19325
19325
  if (!response.ok) {
19326
- const errorResponse = await getErrorResponse(response, fetchType);
19326
+ const isInitialRequest = step === void 0;
19327
+ const errorResponse = await getErrorResponse(response, fetchType, isInitialRequest);
19327
19328
  void updateAfterError(errorResponse);
19328
19329
  return;
19329
19330
  }
@@ -1,5 +1,6 @@
1
1
  import type { CameraDirection } from '@wise/dynamic-flow-types';
2
- import type { EventHandler } from '../../../dynamic-flow-types';
2
+ export type CameraEventName = 'Dynamic Flow - Camera Permission Denied' | 'Dynamic Flow - Camera Feed Started' | 'Dynamic Flow - Camera Not Supported' | 'Dynamic Flow - Camera Not Accessible' | 'Dynamic Flow - Camera Orientation Locked' | 'Dynamic Flow - Camera Orientation Lock Overlay Shown';
3
+ export type CameraEventHandler = (eventName: CameraEventName, properties: Record<string, unknown>) => void;
3
4
  type Props = {
4
5
  direction?: CameraDirection;
5
6
  overlay?: string;
@@ -9,7 +10,7 @@ type Props = {
9
10
  instructions?: string;
10
11
  showReview?: boolean;
11
12
  onCapture: BlobCallback;
12
- onEvent?: EventHandler;
13
+ onEvent?: CameraEventHandler;
13
14
  };
14
15
  declare function CameraCapture({ direction, overlay, outline, imageUrl, title, instructions, showReview, onCapture, onEvent, }: Props): import("react/jsx-runtime").JSX.Element;
15
16
  export default CameraCapture;
@@ -1,5 +1,5 @@
1
- import type { EventHandler } from '../../../../dynamic-flow-types';
2
- export declare const useFullScreenOrientationLock: (shouldLockOrientation: boolean, onEvent: EventHandler | undefined) => {
1
+ import type { CameraEventHandler } from '../CameraCapture';
2
+ export declare const useFullScreenOrientationLock: (shouldLockOrientation: boolean, onEvent: CameraEventHandler | undefined) => {
3
3
  enterFullScreen: () => void;
4
4
  exitFullScreen: () => void;
5
5
  };
@@ -0,0 +1,8 @@
1
+ import type { CameraDirection } from '@wise/dynamic-flow-types';
2
+ import type { CameraEventHandler, CameraEventName } from '../CameraCapture';
3
+ export declare const trackCameraError: (message: CameraEventName, onEvent: CameraEventHandler | undefined, error: string | DOMException) => void | undefined;
4
+ export declare const trackCameraFeedStarted: (onEvent: CameraEventHandler | undefined, props: {
5
+ direction?: CameraDirection;
6
+ }, stream: MediaStream) => Promise<void | undefined>;
7
+ export declare const trackCameraOrientationLandscape: (onEvent: CameraEventHandler | undefined) => void;
8
+ export declare const trackCameraOrientationLocked: (onEvent: CameraEventHandler | undefined) => void;
@@ -1,11 +1,11 @@
1
+ export * from '../../../common/cameraCapture/utils/mobile-utils';
2
+ export * from '../../../common/utils/debounce';
1
3
  export * from './api-utils';
2
4
  export * from './date-utils';
3
- export * from './debounce';
4
- export * from './is-equal';
5
5
  export * from './file-utils';
6
6
  export * from './id-utils';
7
- export * from './step-utils';
8
- export * from './model-utils';
7
+ export * from './is-equal';
9
8
  export * from './misc-utils';
9
+ export * from './model-utils';
10
10
  export * from './schema-utils';
11
- export * from './mobile-utils';
11
+ export * from './step-utils';
@@ -1,4 +1,5 @@
1
1
  import type { Size, Step } from '@wise/dynamic-flow-types';
2
+ import type { CameraEventName } from '../common/cameraCapture/CameraCapture';
2
3
  export type DynamicFlowProps = DynamicFlowPropsWithInitialAction | DynamicFlowPropsWithInitialStep;
3
4
  export type DynamicFlowPropsWithInitialAction = DynamicFlowPropsBasic & {
4
5
  initialAction: InitialAction;
@@ -10,7 +11,7 @@ export type DynamicFlowPropsWithInitialStep = DynamicFlowPropsBasic & {
10
11
  };
11
12
  export type HttpClient = typeof fetch;
12
13
  export type EventHandler = (eventName: EventName, properties: Record<string, unknown>) => void;
13
- export type EventName = 'Dynamic Flow - Flow Started' | 'Dynamic Flow - Flow Finished' | 'Dynamic Flow - Step Started' | 'Dynamic Flow - Step Submitted' | 'Dynamic Flow - Step Refreshed' | 'Dynamic Flow - OneOf Selected' | 'Dynamic Flow - PersistAsync' | 'Dynamic Flow - ValidationAsync' | 'Dynamic Flow - Camera Permission Denied' | 'Dynamic Flow - Camera Feed Started' | 'Dynamic Flow - Camera Not Supported' | 'Dynamic Flow - Camera Not Accessible' | 'Dynamic Flow - Camera Orientation Locked' | 'Dynamic Flow - Camera Orientation Lock Overlay Shown' | 'Dynamic Flow - Search Started' | 'Dynamic Flow - Search Result Selected' | 'Dynamic Flow - invalid submission response' | 'Dynamic Flow - onAction supressed' | 'Dynamic Flow - OneOf Searched';
14
+ export type EventName = 'Dynamic Flow - Flow Started' | 'Dynamic Flow - Flow Finished' | 'Dynamic Flow - Step Started' | 'Dynamic Flow - Step Submitted' | 'Dynamic Flow - Step Refreshed' | 'Dynamic Flow - OneOf Selected' | 'Dynamic Flow - PersistAsync' | 'Dynamic Flow - ValidationAsync' | 'Dynamic Flow - Search Started' | 'Dynamic Flow - Search Result Selected' | 'Dynamic Flow - invalid submission response' | 'Dynamic Flow - onAction supressed' | 'Dynamic Flow - OneOf Searched' | CameraEventName;
14
15
  export type LogLevel = 'debug' | 'info' | 'warning' | 'error' | 'critical';
15
16
  export type LogEventHandler = (level: LogLevel, message: string, extra: Record<string, unknown>) => void;
16
17
  export type Feature = {
@@ -1,2 +1,2 @@
1
1
  import type { ErrorResponseBody } from '@wise/dynamic-flow-types';
2
- export declare const useErrorResponse: () => (response: Response, fetchType: 'refresh' | 'submission') => Promise<ErrorResponseBody>;
2
+ export declare const useErrorResponse: () => (response: Response, fetchType: 'refresh' | 'submission', isInitialRequest: boolean) => Promise<ErrorResponseBody>;