@wise/dynamic-flow-client-internal 4.27.0-experimental-renderer-utils-876fd4f → 4.27.0-experimental-edf35fb

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.
package/build/main.mjs CHANGED
@@ -17,16 +17,3492 @@ var __spreadValues = (a, b) => {
17
17
  return a;
18
18
  };
19
19
  var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
20
+ var __objRest = (source, exclude) => {
21
+ var target = {};
22
+ for (var prop in source)
23
+ if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
24
+ target[prop] = source[prop];
25
+ if (source != null && __getOwnPropSymbols)
26
+ for (var prop of __getOwnPropSymbols(source)) {
27
+ if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
28
+ target[prop] = source[prop];
29
+ }
30
+ return target;
31
+ };
32
+
33
+ // src/index.ts
34
+ import { makeHttpClient } from "@wise/dynamic-flow-client";
35
+ import { findRendererPropsByType, isValidSchema, JsonSchemaForm } from "@wise/dynamic-flow-client";
36
+
37
+ // ../renderers/src/AlertRenderer.tsx
38
+ import { Alert } from "@transferwise/components";
39
+
40
+ // ../renderers/src/utils/layout-utils.ts
41
+ var getMargin = (size) => {
42
+ switch (size) {
43
+ case "xs":
44
+ return "m-b-0";
45
+ case "sm":
46
+ return "m-b-1";
47
+ case "md":
48
+ return "m-b-2";
49
+ case "lg":
50
+ return "m-b-3";
51
+ case "xl":
52
+ return "m-b-5";
53
+ default:
54
+ return "";
55
+ }
56
+ };
57
+ var getTextAlignment = (align) => {
58
+ switch (align) {
59
+ case "end":
60
+ return "text-xs-right";
61
+ case "center":
62
+ return "text-xs-center";
63
+ case "start":
64
+ default:
65
+ return "";
66
+ }
67
+ };
68
+ var getTextAlignmentAndMargin = (component) => `${getTextAlignment(component.align)} ${getMargin(component.margin)}`;
69
+
70
+ // ../renderers/src/AlertRenderer.tsx
71
+ import { jsx } from "react/jsx-runtime";
72
+ var AlertRenderer = {
73
+ canRenderType: "alert",
74
+ render: ({ context, markdown, margin, callToAction }) => /* @__PURE__ */ jsx(
75
+ Alert,
76
+ {
77
+ type: context,
78
+ className: getMargin(margin),
79
+ message: markdown,
80
+ action: mapCtaToAlertAction(callToAction)
81
+ }
82
+ )
83
+ };
84
+ var mapCtaToAlertAction = (callToAction) => {
85
+ if (callToAction) {
86
+ return __spreadValues(__spreadValues({
87
+ text: callToAction.title,
88
+ "aria-label": callToAction.accessibilityDescription
89
+ }, "onClick" in callToAction ? { onClick: callToAction.onClick } : {}), callToAction.type === "link" ? { href: callToAction.href, target: "_blank" } : {});
90
+ }
91
+ return void 0;
92
+ };
93
+ var AlertRenderer_default = AlertRenderer;
94
+
95
+ // ../renderers/src/BoxRenderer.tsx
96
+ import classNames from "classnames";
97
+ import { jsx as jsx2 } from "react/jsx-runtime";
98
+ var BoxRenderer = {
99
+ canRenderType: "box",
100
+ render: ({ children, control, margin, width }) => {
101
+ const hasFixedWidth = width !== "xl";
102
+ const hasBorder = control === "bordered" || control === "bordered-web";
103
+ const contents = /* @__PURE__ */ jsx2(
104
+ "div",
105
+ {
106
+ className: classNames({
107
+ "df-box-renderer-border": hasBorder,
108
+ [`df-box-renderer-width-${width}`]: hasFixedWidth,
109
+ [getMargin(margin)]: !hasFixedWidth
110
+ }),
111
+ children
112
+ }
113
+ );
114
+ return hasFixedWidth ? /* @__PURE__ */ jsx2("div", { className: classNames("df-box-renderer-fixed-width", getMargin(margin)), children: contents }) : contents;
115
+ }
116
+ };
117
+ var BoxRenderer_default = BoxRenderer;
118
+
119
+ // ../renderers/src/ButtonRenderer/AddressValidationButtonRenderer.tsx
120
+ import { Button, InlineAlert } from "@transferwise/components";
121
+ import { useIntl } from "react-intl";
122
+
123
+ // ../renderers/src/messages/loading-button.messages.ts
124
+ import { defineMessages } from "react-intl";
125
+ var loading_button_messages_default = defineMessages({
126
+ buttonLoadingMessage: {
127
+ id: "df.wise.ButtonLayout.buttonLoadingMessage",
128
+ defaultMessage: "This might take a few seconds",
129
+ description: "Message displayed below a button when it is in a loading state."
130
+ }
131
+ });
132
+
133
+ // ../renderers/src/ButtonRenderer/AddressValidationButtonRenderer.tsx
134
+ import { useEffect, useState } from "react";
135
+ import { jsx as jsx3, jsxs } from "react/jsx-runtime";
136
+ var AddressValidationButtonRenderer = {
137
+ canRenderType: "button",
138
+ canRender: ({ control }) => control === "address-validation",
139
+ render: AddressValidationButtonComponent
140
+ };
141
+ function AddressValidationButtonComponent(props) {
142
+ const { disabled, margin, title, stepLoadingState, onClick } = props;
143
+ const { formatMessage } = useIntl();
144
+ const [spinny, setSpinny] = useState(false);
145
+ useEffect(() => {
146
+ if (stepLoadingState === "idle") {
147
+ setSpinny(false);
148
+ }
149
+ }, [stepLoadingState]);
150
+ return /* @__PURE__ */ jsxs("div", { className: `d-flex flex-column ${getMargin(margin)}`, children: [
151
+ /* @__PURE__ */ jsx3(
152
+ Button,
153
+ {
154
+ v2: true,
155
+ block: true,
156
+ disabled,
157
+ priority: "primary",
158
+ size: "md",
159
+ loading: spinny,
160
+ onClick: () => {
161
+ setSpinny(true);
162
+ onClick();
163
+ },
164
+ children: title
165
+ }
166
+ ),
167
+ spinny && /* @__PURE__ */ jsx3(InlineAlert, { type: "warning", className: "m-x-auto", children: formatMessage(loading_button_messages_default.buttonLoadingMessage) })
168
+ ] });
169
+ }
170
+ var AddressValidationButtonRenderer_default = AddressValidationButtonRenderer;
171
+
172
+ // ../renderers/src/ButtonRenderer/ButtonRenderer.tsx
173
+ import { Button as Button2 } from "@transferwise/components";
174
+ import { useEffect as useEffect2, useState as useState2 } from "react";
175
+
176
+ // ../renderers/src/ButtonRenderer/mapButtonSize.tsx
177
+ var mapButtonSize = (size) => {
178
+ if (!size) {
179
+ return void 0;
180
+ }
181
+ switch (size) {
182
+ case "xs":
183
+ case "sm":
184
+ return "sm";
185
+ case "lg":
186
+ case "xl":
187
+ return "lg";
188
+ case "md":
189
+ default:
190
+ return "md";
191
+ }
192
+ };
193
+
194
+ // ../renderers/src/ButtonRenderer/ButtonRenderer.tsx
195
+ import { jsx as jsx4 } from "react/jsx-runtime";
196
+ var ButtonRenderer = {
197
+ canRenderType: "button",
198
+ render: ButtonComponent
199
+ };
200
+ function ButtonComponent(props) {
201
+ const { control, context, disabled, margin, title, size, stepLoadingState, onClick } = props;
202
+ const [spinny, setSpinny] = useState2(false);
203
+ useEffect2(() => {
204
+ if (stepLoadingState === "idle") {
205
+ setSpinny(false);
206
+ }
207
+ }, [stepLoadingState]);
208
+ const priority = getPriority(control);
209
+ const type = getButtonType(context, priority);
210
+ const loading = spinny && stepLoadingState !== "idle";
211
+ return /* @__PURE__ */ jsx4(
212
+ Button2,
213
+ {
214
+ block: true,
215
+ className: getMargin(margin),
216
+ disabled,
217
+ priority,
218
+ size: mapButtonSize(size),
219
+ loading,
220
+ type,
221
+ onClick: () => {
222
+ setSpinny(true);
223
+ onClick();
224
+ },
225
+ children: title
226
+ }
227
+ );
228
+ }
229
+ var getPriority = (control) => {
230
+ switch (control) {
231
+ case "primary":
232
+ case "tertiary":
233
+ return control;
234
+ default:
235
+ return "secondary";
236
+ }
237
+ };
238
+ var getButtonType = (context, priority) => {
239
+ if (priority === "tertiary") {
240
+ return void 0;
241
+ }
242
+ switch (context) {
243
+ case "neutral":
244
+ case "warning":
245
+ return "accent";
246
+ default:
247
+ return context;
248
+ }
249
+ };
250
+
251
+ // ../renderers/src/components/FieldInput.tsx
252
+ import { Field } from "@transferwise/components";
253
+
254
+ // ../renderers/src/components/Help.tsx
255
+ import { Info, Markdown } from "@transferwise/components";
256
+ import { useIntl as useIntl2 } from "react-intl";
257
+
258
+ // ../renderers/src/messages/help.messages.ts
259
+ import { defineMessages as defineMessages2 } from "react-intl";
260
+ var help_messages_default = defineMessages2({
261
+ helpAria: {
262
+ id: "df.wise.Help.ariaLabel",
263
+ defaultMessage: "Click here for more info.",
264
+ description: "Aria label for help."
265
+ }
266
+ });
267
+
268
+ // ../renderers/src/components/Help.tsx
269
+ import { jsx as jsx5 } from "react/jsx-runtime";
270
+ function Help({ help, onClick }) {
271
+ const intl = useIntl2();
272
+ return /* @__PURE__ */ jsx5(
273
+ Info,
274
+ {
275
+ content: /* @__PURE__ */ jsx5(Markdown, { config: { link: { target: "_blank" } }, children: help }),
276
+ presentation: "POPOVER",
277
+ size: "sm",
278
+ "aria-label": intl.formatMessage(help_messages_default.helpAria),
279
+ onClick
280
+ }
281
+ );
282
+ }
283
+ var Help_default = Help;
284
+
285
+ // ../renderers/src/components/LabelContentWithHelp.tsx
286
+ import { jsx as jsx6, jsxs as jsxs2 } from "react/jsx-runtime";
287
+ function LabelContentWithHelp({ text, help }) {
288
+ return /* @__PURE__ */ jsxs2("div", { children: [
289
+ text,
290
+ /* @__PURE__ */ jsx6(Help_default, { help })
291
+ ] });
292
+ }
293
+
294
+ // ../renderers/src/components/FieldInput.tsx
295
+ import { jsx as jsx7 } from "react/jsx-runtime";
296
+ function FieldInput({ id, children, label, validation, description, help }) {
297
+ const labelContent = label && help ? /* @__PURE__ */ jsx7(LabelContentWithHelp, { text: label, help }) : label;
298
+ return /* @__PURE__ */ jsx7(
299
+ Field,
300
+ {
301
+ id,
302
+ label: labelContent,
303
+ description,
304
+ message: validation == null ? void 0 : validation.message,
305
+ sentiment: mapStatusToSentiment(validation),
306
+ children
307
+ }
308
+ );
309
+ }
310
+ var mapStatusToSentiment = (validation) => {
311
+ if (validation) {
312
+ if (validation.status === "valid") {
313
+ return "positive";
314
+ }
315
+ return "negative";
316
+ }
317
+ return void 0;
318
+ };
319
+ var FieldInput_default = FieldInput;
320
+
321
+ // ../renderers/src/CheckboxInputRenderer.tsx
322
+ import { Checkbox, ListItem } from "@transferwise/components";
323
+
324
+ // ../renderers/src/utils/UrnFlag.tsx
325
+ import { Flag } from "@wise/art";
326
+ import { jsx as jsx8 } from "react/jsx-runtime";
327
+ var countryUrnPrefix = "urn:wise:countries:";
328
+ var currencyUrnPrefix = "urn:wise:currencies:";
329
+ var isUrnFlag = (uri) => uri.startsWith(countryUrnPrefix) || uri.startsWith(currencyUrnPrefix);
330
+ function UrnFlag({ size, urn }) {
331
+ return /* @__PURE__ */ jsx8(Flag, { code: getCode(urn), intrinsicSize: size });
332
+ }
333
+ var getCode = (urn) => {
334
+ return urn.replace(countryUrnPrefix, "").replace(currencyUrnPrefix, "").replace(":image", "").split("?")[0];
335
+ };
336
+
337
+ // ../renderers/src/components/icon/FlagIcon.tsx
338
+ import { Flag as Flag2 } from "@wise/art";
339
+ import { jsx as jsx9 } from "react/jsx-runtime";
340
+ var isFlagIcon = (name) => name.startsWith("flag-");
341
+ function FlagIcon({ name }) {
342
+ if (!isFlagIcon(name)) {
343
+ return null;
344
+ }
345
+ const code = name.substring(5);
346
+ return /* @__PURE__ */ jsx9(Flag2, { code, intrinsicSize: 24 });
347
+ }
348
+
349
+ // ../renderers/src/components/icon/NamedIcon.tsx
350
+ import * as icons from "@transferwise/icons";
351
+ import { jsx as jsx10 } from "react/jsx-runtime";
352
+ var isNamedIcon = (name) => {
353
+ const iconName = toCapitalisedCamelCase(name);
354
+ return Object.keys(icons).includes(iconName);
355
+ };
356
+ function NamedIcon({ name }) {
357
+ if (!isNamedIcon(name)) {
358
+ return null;
359
+ }
360
+ const iconName = toCapitalisedCamelCase(name);
361
+ const Icon = icons[iconName];
362
+ return /* @__PURE__ */ jsx10(Icon, { size: 24 });
363
+ }
364
+ var toCapitalisedCamelCase = (value) => value.split("-").map(capitaliseFirstChar).join("");
365
+ var capitaliseFirstChar = (value) => `${value[0].toUpperCase()}${value.slice(1)}`;
366
+
367
+ // ../renderers/src/components/icon/DynamicIcon.tsx
368
+ import { jsx as jsx11 } from "react/jsx-runtime";
369
+ function DynamicIcon({ name }) {
370
+ if (isFlagIcon(name)) {
371
+ return /* @__PURE__ */ jsx11(FlagIcon, { name });
372
+ }
373
+ if (isNamedIcon(name)) {
374
+ return /* @__PURE__ */ jsx11(NamedIcon, { name });
375
+ }
376
+ return null;
377
+ }
378
+ function isValidIconName(name) {
379
+ return isNamedIcon(name) || isFlagIcon(name);
380
+ }
381
+ function isValidIconUrn(uri) {
382
+ if (!uri.startsWith("urn:wise:icons:")) {
383
+ return false;
384
+ }
385
+ const name = uri.replace("urn:wise:icons:", "").split("?")[0];
386
+ return isValidIconName(name);
387
+ }
388
+ var DynamicIcon_default = DynamicIcon;
389
+
390
+ // ../renderers/src/components/Media/stringToURN.ts
391
+ var stringToURN = (uri) => {
392
+ var _a, _b, _c;
393
+ const [nameWithRQComponents, _] = uri.split("#");
394
+ const [nameWithRComponent, qComponent] = nameWithRQComponents.split("?=");
395
+ const [name, rComponent] = (_a = nameWithRComponent == null ? void 0 : nameWithRComponent.split("?+")) != null ? _a : ["", ""];
396
+ const rComponents = rComponent ? (_b = decodeURIComponent(rComponent)) == null ? void 0 : _b.split("&").map((c) => c.split("=")).map(([a, b]) => [a, b]) : void 0;
397
+ const qComponents = qComponent ? (_c = decodeURIComponent(qComponent)) == null ? void 0 : _c.split("&").map((c) => c.split("=")).map(([a, b]) => [a, b]) : void 0;
398
+ return {
399
+ name,
400
+ rComponents,
401
+ qComponents
402
+ };
403
+ };
404
+
405
+ // ../renderers/src/components/Media/resolveMediaFromUri.tsx
406
+ import { jsx as jsx12 } from "react/jsx-runtime";
407
+ var resolveMediaFromUri = (uri, size) => {
408
+ var _a, _b;
409
+ const { name, qComponents = [] } = stringToURN(uri);
410
+ if (isValidIconUrn(name)) {
411
+ const icon = /* @__PURE__ */ jsx12(DynamicIcon_default, { name: name.replace("urn:wise:icons:", "") });
412
+ return {
413
+ icon,
414
+ backgroundColor: formatColor((_a = qComponents.find(([key]) => key === "background-color")) == null ? void 0 : _a[1])
415
+ };
416
+ }
417
+ if (isUrnFlag(name)) {
418
+ return {
419
+ asset: /* @__PURE__ */ jsx12(UrnFlag, { urn: name, size })
420
+ };
421
+ }
422
+ if (name.startsWith("data:text/plain,")) {
423
+ const text = decodeURI(name.replace("data:text/plain,", ""));
424
+ return {
425
+ asset: text,
426
+ backgroundColor: formatColor((_b = qComponents.find(([key]) => key === "background-color")) == null ? void 0 : _b[1])
427
+ };
428
+ }
429
+ if (!uri.startsWith("urn:")) {
430
+ return { asset: /* @__PURE__ */ jsx12("img", { src: uri, alt: "", width: `${size}px` }) };
431
+ }
432
+ return { asset: void 0 };
433
+ };
434
+ var formatColor = (color) => {
435
+ if (!color) {
436
+ return void 0;
437
+ }
438
+ if (color.startsWith("#")) {
439
+ return color;
440
+ }
441
+ return `var(--color-${color.replace(/^base-|brand-/, "")})`;
442
+ };
443
+
444
+ // ../renderers/src/components/Media/AvatarMedia.tsx
445
+ import { AvatarLayout, AvatarView } from "@transferwise/components";
446
+ import { jsx as jsx13 } from "react/jsx-runtime";
447
+ var AvatarMedia = ({
448
+ accessibilityDescription,
449
+ content,
450
+ size
451
+ }) => {
452
+ const getRenderableAvatar = (avatar) => {
453
+ if (avatar.type === "text") {
454
+ return { asset: avatar.text };
455
+ }
456
+ return __spreadProps(__spreadValues({}, resolveMediaFromUri(avatar.uri, size)), {
457
+ badge: avatar.badgeUri ? resolveMediaFromUri(avatar.badgeUri, 16) : void 0
458
+ });
459
+ };
460
+ const avatars = content.map(getRenderableAvatar);
461
+ if (avatars.length === 1) {
462
+ const { badge, backgroundColor, asset, icon } = avatars[0];
463
+ if (!asset && !icon) {
464
+ return null;
465
+ }
466
+ return /* @__PURE__ */ jsx13(
467
+ AvatarView,
468
+ {
469
+ "aria-label": accessibilityDescription,
470
+ size,
471
+ badge: badge ? __spreadProps(__spreadValues({}, badge), {
472
+ type: "reference"
473
+ }) : void 0,
474
+ style: { backgroundColor },
475
+ children: icon != null ? icon : asset
476
+ }
477
+ );
478
+ }
479
+ const avatarsWithoutBadges = avatars.filter(({ asset }) => asset).slice(0, 2).map((_a) => {
480
+ var _b = _a, { badge } = _b, rest = __objRest(_b, ["badge"]);
481
+ return __spreadValues({}, rest);
482
+ });
483
+ return /* @__PURE__ */ jsx13(
484
+ AvatarLayout,
485
+ {
486
+ "aria-label": accessibilityDescription,
487
+ size,
488
+ orientation: "diagonal",
489
+ avatars: avatarsWithoutBadges
490
+ }
491
+ );
492
+ };
493
+
494
+ // ../renderers/src/utils/image-utils.tsx
495
+ import { AvatarView as AvatarView2 } from "@transferwise/components";
496
+ import { jsx as jsx14 } from "react/jsx-runtime";
497
+ var getBadgedMedia = (iconNode, imageNode, size) => {
498
+ if (iconNode && imageNode) {
499
+ if (imageNode && iconNode) {
500
+ return /* @__PURE__ */ jsx14(AvatarView2, { size, badge: { asset: iconNode, type: "reference" }, children: imageNode });
501
+ }
502
+ }
503
+ return null;
504
+ };
505
+ var getIconNode = (icon) => {
506
+ if (icon) {
507
+ if ("name" in icon) {
508
+ return /* @__PURE__ */ jsx14(DynamicIcon_default, { name: icon.name });
509
+ }
510
+ if (icon.text) {
511
+ return icon.text;
512
+ }
513
+ }
514
+ return null;
515
+ };
516
+ var getImageNode = (image, size) => {
517
+ if (image) {
518
+ const { accessibilityDescription, uri } = image;
519
+ if (!uri.startsWith("urn:")) {
520
+ return /* @__PURE__ */ jsx14("img", { src: uri, alt: accessibilityDescription, width: `${size}px` });
521
+ }
522
+ if (isUrnFlag(uri)) {
523
+ return /* @__PURE__ */ jsx14(UrnFlag, { urn: uri, accessibilityDescription, size });
524
+ }
525
+ }
526
+ return null;
527
+ };
528
+
529
+ // ../renderers/src/components/Media/LegacyMedia.tsx
530
+ import { AvatarView as AvatarView3 } from "@transferwise/components";
531
+ import { jsx as jsx15 } from "react/jsx-runtime";
532
+ var LegacyMedia = ({ image, icon, preferAvatar, size }) => {
533
+ const imageNode = getImageNode(image, size);
534
+ const iconNode = getIconNode(icon);
535
+ const badge = getBadgedMedia(iconNode, imageNode, size);
536
+ if (badge) {
537
+ return badge;
538
+ }
539
+ if (imageNode) {
540
+ return preferAvatar ? /* @__PURE__ */ jsx15(AvatarView3, { children: imageNode }) : imageNode;
541
+ }
542
+ if (iconNode && icon) {
543
+ if ("text" in icon || size === 48) {
544
+ return /* @__PURE__ */ jsx15(AvatarView3, { size, children: iconNode });
545
+ }
546
+ return iconNode;
547
+ }
548
+ return null;
549
+ };
550
+
551
+ // ../renderers/src/components/Media/Media.tsx
552
+ import { jsx as jsx16 } from "react/jsx-runtime";
553
+ function Media({
554
+ media,
555
+ preferAvatar,
556
+ size
557
+ }) {
558
+ switch (media == null ? void 0 : media.type) {
559
+ case "avatar":
560
+ return /* @__PURE__ */ jsx16(AvatarMedia, __spreadProps(__spreadValues({}, media), { size }));
561
+ case "image": {
562
+ const { asset, icon } = resolveMediaFromUri(media.uri, size);
563
+ return icon != null ? icon : asset;
564
+ }
565
+ case "legacy": {
566
+ return /* @__PURE__ */ jsx16(LegacyMedia, __spreadProps(__spreadValues({}, media), { preferAvatar, size }));
567
+ }
568
+ default:
569
+ return null;
570
+ }
571
+ }
572
+
573
+ // ../renderers/src/components/Media/OptionMedia.tsx
574
+ import { jsx as jsx17 } from "react/jsx-runtime";
575
+ var mediaSize = 48;
576
+ function OptionMedia(props) {
577
+ return /* @__PURE__ */ jsx17(Media, __spreadProps(__spreadValues({}, props), { size: mediaSize }));
578
+ }
579
+
580
+ // ../renderers/src/components/Media/getInlineMedia.tsx
581
+ import { jsx as jsx18 } from "react/jsx-runtime";
582
+ var getInlineMedia = (media) => media ? /* @__PURE__ */ jsx18(Media, { media, preferAvatar: false, size: 24 }) : null;
583
+
584
+ // ../renderers/src/NewListItem/getMedia.tsx
585
+ import { jsx as jsx19 } from "react/jsx-runtime";
586
+ var getMedia = (media, preferAvatar) => media ? /* @__PURE__ */ jsx19(OptionMedia, { media, preferAvatar }) : void 0;
587
+
588
+ // ../renderers/src/CheckboxInputRenderer.tsx
589
+ import { jsx as jsx20 } from "react/jsx-runtime";
590
+ var CheckboxInputRenderer = {
591
+ canRenderType: "input-checkbox",
592
+ render: (props) => props.control === "switch-item" ? /* @__PURE__ */ jsx20(SwitchComponent, __spreadValues({}, props)) : /* @__PURE__ */ jsx20(CheckboxComponent, __spreadValues({}, props))
593
+ };
594
+ var CheckboxComponent = (props) => {
595
+ const _a = props, {
596
+ id,
597
+ control,
598
+ title = "",
599
+ description,
600
+ help,
601
+ type,
602
+ validationState,
603
+ value
604
+ } = _a, rest = __objRest(_a, [
605
+ "id",
606
+ "control",
607
+ "title",
608
+ "description",
609
+ "help",
610
+ "type",
611
+ "validationState",
612
+ "value"
613
+ ]);
614
+ const checkboxProps = __spreadProps(__spreadValues({}, rest), { label: title, secondary: description, checked: value });
615
+ return /* @__PURE__ */ jsx20(FieldInput_default, { id, label: "", description: "", validation: validationState, help, children: /* @__PURE__ */ jsx20(Checkbox, __spreadValues({ id }, checkboxProps)) });
616
+ };
617
+ var SwitchComponent = (props) => {
618
+ const { title, description, disabled, media, validationState, value, onChange } = props;
619
+ return /* @__PURE__ */ jsx20(
620
+ ListItem,
621
+ {
622
+ title,
623
+ subtitle: description,
624
+ media: getMedia(media, false),
625
+ disabled,
626
+ prompt: validationState && validationState.status === "invalid" ? /* @__PURE__ */ jsx20(ListItem.Prompt, { sentiment: "negative", children: validationState.message }) : void 0,
627
+ control: /* @__PURE__ */ jsx20(ListItem.Switch, { checked: value, onClick: () => onChange(!value) })
628
+ }
629
+ );
630
+ };
631
+ var CheckboxInputRenderer_default = CheckboxInputRenderer;
632
+
633
+ // ../renderers/src/ColumnsRenderer.tsx
634
+ import classNames2 from "classnames";
635
+ import { jsx as jsx21, jsxs as jsxs3 } from "react/jsx-runtime";
636
+ var ColumnsRenderer = {
637
+ canRenderType: "columns",
638
+ render: ({ bias, margin, startChildren, endChildren }) => /* @__PURE__ */ jsxs3(
639
+ "div",
640
+ {
641
+ className: classNames2("df-columns-renderer-container", getMargin(margin), {
642
+ "df-columns-renderer-bias-start": bias === "start",
643
+ "df-columns-renderer-bias-end": bias === "end"
644
+ }),
645
+ children: [
646
+ /* @__PURE__ */ jsx21("div", { className: "df-columns-renderer-column", children: startChildren }),
647
+ /* @__PURE__ */ jsx21("div", { className: "df-columns-renderer-column", children: endChildren })
648
+ ]
649
+ }
650
+ )
651
+ };
652
+ var ColumnsRenderer_default = ColumnsRenderer;
653
+
654
+ // ../renderers/src/components/VariableDateInput.tsx
655
+ import { DateInput, DateLookup } from "@transferwise/components";
656
+
657
+ // ../renderers/src/validators/type-validators.ts
658
+ var isNumber = (value) => typeof value === "number" && !Number.isNaN(value);
659
+
660
+ // ../renderers/src/utils/value-utils.ts
661
+ var dateStringToDateOrNull = (dateString) => {
662
+ if (!dateString) {
663
+ return null;
664
+ }
665
+ const [year, month, date] = dateString.split("-").map((number) => Number.parseInt(number, 10));
666
+ if (!isNumber(year) || !isNumber(month) || !isNumber(date)) {
667
+ return null;
668
+ }
669
+ return new Date(year, month - 1, date);
670
+ };
671
+ var dateToDateString = (date) => {
672
+ const d = new Date(date);
673
+ const month = String(d.getMonth() + 1);
674
+ const day = String(d.getDate());
675
+ const year = d.getFullYear();
676
+ const formattedMonth = month.length < 2 ? `0${month}` : month;
677
+ const formattedDay = day.length < 2 ? `0${day}` : day;
678
+ return [year, formattedMonth, formattedDay].join("-");
679
+ };
680
+
681
+ // ../renderers/src/components/VariableDateInput.tsx
682
+ import { jsx as jsx22 } from "react/jsx-runtime";
683
+ function VariableDateInput({
684
+ control,
685
+ inputProps
686
+ }) {
687
+ const {
688
+ autoComplete,
689
+ minimumDate,
690
+ maximumDate,
691
+ placeholder,
692
+ disabled,
693
+ onBlur,
694
+ onChange,
695
+ onFocus
696
+ } = inputProps;
697
+ if (control === "date-lookup") {
698
+ return /* @__PURE__ */ jsx22(
699
+ DateLookup,
700
+ {
701
+ value: dateStringToDateOrNull(inputProps.value),
702
+ min: dateStringToDateOrNull(minimumDate),
703
+ max: dateStringToDateOrNull(maximumDate),
704
+ placeholder,
705
+ disabled,
706
+ onChange: (date) => {
707
+ onChange(date !== null ? dateToDateString(date) : null);
708
+ },
709
+ onBlur,
710
+ onFocus
711
+ }
712
+ );
713
+ }
714
+ return /* @__PURE__ */ jsx22(
715
+ DateInput,
716
+ __spreadProps(__spreadValues({}, inputProps), {
717
+ dayAutoComplete: getAutocompleteString(autoComplete, "day"),
718
+ yearAutoComplete: getAutocompleteString(autoComplete, "year")
719
+ })
720
+ );
721
+ }
722
+ var getAutocompleteString = (value, suffix) => {
723
+ if (value === "bday") {
724
+ return `${value}-${suffix}`;
725
+ }
726
+ return void 0;
727
+ };
728
+ var VariableDateInput_default = VariableDateInput;
729
+
730
+ // ../renderers/src/DateInputRenderer.tsx
731
+ import { jsx as jsx23 } from "react/jsx-runtime";
732
+ var DateInputRenderer = {
733
+ canRenderType: "input-date",
734
+ render: (props) => {
735
+ const _a = props, {
736
+ id,
737
+ control,
738
+ description,
739
+ type,
740
+ help,
741
+ title,
742
+ validationState,
743
+ value: initialValue
744
+ } = _a, rest = __objRest(_a, [
745
+ "id",
746
+ "control",
747
+ "description",
748
+ "type",
749
+ "help",
750
+ "title",
751
+ "validationState",
752
+ "value"
753
+ ]);
754
+ const value = initialValue != null ? initialValue : "";
755
+ const inputProps = __spreadProps(__spreadValues({}, rest), { value, id });
756
+ return /* @__PURE__ */ jsx23(
757
+ FieldInput_default,
758
+ {
759
+ id,
760
+ label: title,
761
+ description,
762
+ validation: validationState,
763
+ help,
764
+ children: /* @__PURE__ */ jsx23(VariableDateInput_default, { control, inputProps })
765
+ }
766
+ );
767
+ }
768
+ };
769
+ var DateInputRenderer_default = DateInputRenderer;
770
+
771
+ // ../renderers/src/DecisionRenderer/DecisionRenderer.tsx
772
+ import { NavigationOption, NavigationOptionsList } from "@transferwise/components";
773
+
774
+ // ../renderers/src/DecisionRenderer/DecisionList.tsx
775
+ import { Header as Header2, SearchInput } from "@transferwise/components";
776
+
777
+ // ../renderers/src/DecisionRenderer/GroupedList.tsx
778
+ import { Header, Section } from "@transferwise/components";
779
+ import { useIntl as useIntl3 } from "react-intl";
780
+
781
+ // ../renderers/src/messages/decision.messages.ts
782
+ import { defineMessages as defineMessages3 } from "react-intl";
783
+ var decision_messages_default = defineMessages3({
784
+ all: {
785
+ id: "df.wise.Decision.all",
786
+ defaultMessage: "All",
787
+ description: "Label for the group of options that encompasses all options"
788
+ },
789
+ popular: {
790
+ id: "df.wise.Decision.popular",
791
+ defaultMessage: "Popular",
792
+ description: "Label for the group of options that are tagged as popular"
793
+ },
794
+ recent: {
795
+ id: "df.wise.Decision.recent",
796
+ defaultMessage: "Recent",
797
+ description: "Label for the group of options that are tagged as recent"
798
+ },
799
+ currenciesWithAccountDetails: {
800
+ id: "df.wise.Decision.currenciesWithAccountDetails",
801
+ defaultMessage: "Currencies with account details",
802
+ description: "Label for the group of options that are tagged as currencies with account details"
803
+ },
804
+ filterPlaceholder: {
805
+ id: "df.wise.Decision.filterPlaceholder",
806
+ defaultMessage: "Start typing to search",
807
+ description: "Placeholder for the filter input"
808
+ },
809
+ results: {
810
+ id: "df.wise.Decision.results",
811
+ defaultMessage: "Search results",
812
+ description: "Label for the results section"
813
+ },
814
+ noResults: {
815
+ id: "df.wise.Decision.noResults",
816
+ defaultMessage: "No results",
817
+ description: "Message for if there are no results"
818
+ }
819
+ });
820
+
821
+ // ../renderers/src/DecisionRenderer/GroupedList.tsx
822
+ import { Fragment, jsx as jsx24, jsxs as jsxs4 } from "react/jsx-runtime";
823
+ var OPTION_GROUPS = {
824
+ popular: "popular",
825
+ recent: "recent",
826
+ currencyWithAccountDetails: "currencies-with-account-details"
827
+ };
828
+ var GroupedList = (_a) => {
829
+ var _b = _a, { renderDecisionList: renderDecisionList3 } = _b, rest = __objRest(_b, ["renderDecisionList"]);
830
+ const { formatMessage } = useIntl3();
831
+ const { options } = rest;
832
+ const popularOptions = options.filter((option) => option.tag === OPTION_GROUPS.popular);
833
+ const recentOptions = options.filter((option) => option.tag === OPTION_GROUPS.recent);
834
+ const currencyWithAccountDetailsOptions = options.filter(
835
+ (option) => option.tag === OPTION_GROUPS.currencyWithAccountDetails
836
+ );
837
+ return /* @__PURE__ */ jsxs4(Fragment, { children: [
838
+ popularOptions.length > 0 ? /* @__PURE__ */ jsxs4(Section, { children: [
839
+ /* @__PURE__ */ jsx24(Header, { as: "h2", title: formatMessage(decision_messages_default.popular) }),
840
+ renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: popularOptions }))
841
+ ] }) : null,
842
+ recentOptions.length > 0 ? /* @__PURE__ */ jsxs4(Section, { children: [
843
+ /* @__PURE__ */ jsx24(Header, { as: "h2", title: formatMessage(decision_messages_default.recent) }),
844
+ renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: recentOptions }))
845
+ ] }) : null,
846
+ currencyWithAccountDetailsOptions.length > 0 ? /* @__PURE__ */ jsxs4(Section, { children: [
847
+ /* @__PURE__ */ jsx24(Header, { as: "h2", title: formatMessage(decision_messages_default.currenciesWithAccountDetails) }),
848
+ renderDecisionList3(__spreadProps(__spreadValues({}, rest), { options: currencyWithAccountDetailsOptions }))
849
+ ] }) : null,
850
+ /* @__PURE__ */ jsxs4(Section, { children: [
851
+ /* @__PURE__ */ jsx24(Header, { as: "h2", title: formatMessage(decision_messages_default.all) }),
852
+ renderDecisionList3(rest)
853
+ ] })
854
+ ] });
855
+ };
856
+ var isGroupedDecision = (options) => {
857
+ const possibleGroups = Object.values(OPTION_GROUPS);
858
+ return options.some(({ tag }) => tag && possibleGroups.includes(tag));
859
+ };
860
+
861
+ // ../renderers/src/DecisionRenderer/DecisionList.tsx
862
+ import { useIntl as useIntl4 } from "react-intl";
863
+ import { useState as useState3 } from "react";
864
+
865
+ // ../renderers/src/DecisionRenderer/filter-and-sort-decision-options.ts
866
+ function filterAndSortDecisionOptions(selectOptions, query) {
867
+ const upperQuery = query.toUpperCase().trim();
868
+ const filteredItems = selectOptions.filter((option) => {
869
+ var _a, _b, _c, _d;
870
+ const searchableWords = [
871
+ option.title,
872
+ option.description,
873
+ option.additionalText,
874
+ (_a = option.supportingValues) == null ? void 0 : _a.value,
875
+ (_b = option.supportingValues) == null ? void 0 : _b.subvalue,
876
+ ...(_c = option.keywords) != null ? _c : []
877
+ ];
878
+ return (_d = searchableWords.some((word) => word == null ? void 0 : word.toUpperCase().includes(upperQuery))) != null ? _d : false;
879
+ });
880
+ return [...filteredItems].sort((a, b) => {
881
+ const aTitleUpper = a.title.toUpperCase();
882
+ const bTitleUpper = b.title.toUpperCase();
883
+ const aTitleStarts = aTitleUpper.startsWith(upperQuery);
884
+ const bTitleStarts = bTitleUpper.startsWith(upperQuery);
885
+ if (aTitleStarts && !bTitleStarts) {
886
+ return -1;
887
+ }
888
+ if (!aTitleStarts && bTitleStarts) {
889
+ return 1;
890
+ }
891
+ const aWordStarts = aTitleUpper.split(" ").some((word) => word.startsWith(upperQuery));
892
+ const bWordStarts = bTitleUpper.split(" ").some((word) => word.startsWith(upperQuery));
893
+ if (aWordStarts && !bWordStarts) {
894
+ return -1;
895
+ }
896
+ if (!aWordStarts && bWordStarts) {
897
+ return 1;
898
+ }
899
+ return a.title.localeCompare(b.title);
900
+ });
901
+ }
902
+
903
+ // ../renderers/src/DecisionRenderer/DecisionList.tsx
904
+ import { Fragment as Fragment2, jsx as jsx25, jsxs as jsxs5 } from "react/jsx-runtime";
905
+ var DecisionWrapper = (props) => {
906
+ return /* @__PURE__ */ jsxs5("div", { className: getMargin(props.margin), children: [
907
+ props.title && /* @__PURE__ */ jsx25(Header2, { as: "h2", title: props.title }),
908
+ props.control === "filtered" ? /* @__PURE__ */ jsx25(FilteredDecisionList, __spreadValues({}, props)) : /* @__PURE__ */ jsx25(UnfilteredDecisionList, __spreadValues({}, props))
909
+ ] });
910
+ };
911
+ var UnfilteredDecisionList = (_a) => {
912
+ var _b = _a, { renderDecisionList: renderDecisionList3 } = _b, rest = __objRest(_b, ["renderDecisionList"]);
913
+ return isGroupedDecision(rest.options) ? /* @__PURE__ */ jsx25(GroupedList, __spreadProps(__spreadValues({}, rest), { renderDecisionList: renderDecisionList3 })) : renderDecisionList3(rest);
914
+ };
915
+ var FilteredDecisionList = (props) => {
916
+ const { formatMessage } = useIntl4();
917
+ const [query, setQuery] = useState3("");
918
+ const { control, options, renderDecisionList: renderDecisionList3 } = props;
919
+ const filteredOptions = filterAndSortDecisionOptions(options, query);
920
+ const isGrouped = isGroupedDecision(options);
921
+ return /* @__PURE__ */ jsxs5(Fragment2, { children: [
922
+ /* @__PURE__ */ jsx25(
923
+ SearchInput,
924
+ {
925
+ placeholder: formatMessage(decision_messages_default.filterPlaceholder),
926
+ value: query,
927
+ onChange: (e) => {
928
+ var _a;
929
+ return setQuery((_a = e.target.value) != null ? _a : "");
930
+ }
931
+ }
932
+ ),
933
+ isGrouped && query.length === 0 ? /* @__PURE__ */ jsx25(GroupedList, __spreadValues({}, props)) : /* @__PURE__ */ jsxs5(Fragment2, { children: [
934
+ query.length > 0 && /* @__PURE__ */ jsx25(Header2, { as: "h2", title: formatMessage(decision_messages_default.results), className: "m-t-4" }),
935
+ filteredOptions.length > 0 ? renderDecisionList3({
936
+ control,
937
+ className: query.length === 0 ? "m-t-3" : "",
938
+ options: filteredOptions
939
+ }) : /* @__PURE__ */ jsx25("p", { children: formatMessage(decision_messages_default.noResults) })
940
+ ] })
941
+ ] });
942
+ };
943
+
944
+ // ../renderers/src/DecisionRenderer/DecisionRenderer.tsx
945
+ import { jsx as jsx26 } from "react/jsx-runtime";
946
+ var DecisionRenderer = {
947
+ canRenderType: "decision",
948
+ render: (props) => {
949
+ return /* @__PURE__ */ jsx26(DecisionWrapper, __spreadProps(__spreadValues({}, props), { renderDecisionList }));
950
+ }
951
+ };
952
+ var renderDecisionList = ({ options, className, control }) => {
953
+ return /* @__PURE__ */ jsx26("div", { className, children: /* @__PURE__ */ jsx26(NavigationOptionsList, { children: options.map((option) => {
954
+ const { description, disabled, media, title: itemTitle, tag, onClick } = option;
955
+ return /* @__PURE__ */ jsx26(
956
+ NavigationOption,
957
+ {
958
+ title: itemTitle,
959
+ content: description,
960
+ disabled,
961
+ media: media ? /* @__PURE__ */ jsx26(
962
+ OptionMedia,
963
+ {
964
+ media,
965
+ preferAvatar: control === "with-avatar" || tag === "with-avatar"
966
+ }
967
+ ) : null,
968
+ showMediaCircle: false,
969
+ showMediaAtAllSizes: true,
970
+ onClick
971
+ },
972
+ JSON.stringify(option)
973
+ );
974
+ }) }) });
975
+ };
976
+ var DecisionRenderer_default = DecisionRenderer;
977
+
978
+ // ../renderers/src/DividerRenderer.tsx
979
+ import { Divider } from "@transferwise/components";
980
+ import { jsx as jsx27 } from "react/jsx-runtime";
981
+ var mapControlToLevel = (control) => {
982
+ switch (control) {
983
+ case "section":
984
+ return "section";
985
+ case "content":
986
+ return "content";
987
+ default:
988
+ return "subsection";
989
+ }
990
+ };
991
+ var DividerRenderer = {
992
+ canRenderType: "divider",
993
+ render: ({ margin, control }) => /* @__PURE__ */ jsx27(Divider, { className: `m-t-0 d-block ${getMargin(margin)}`, level: mapControlToLevel(control) })
994
+ };
995
+ var DividerRenderer_default = DividerRenderer;
996
+
997
+ // ../renderers/src/ExternalConfirmationRenderer.tsx
998
+ import { Button as Button3, Markdown as Markdown2, Modal } from "@transferwise/components";
999
+
1000
+ // ../renderers/src/messages/external-confirmation.messages.ts
1001
+ import { defineMessages as defineMessages4 } from "react-intl";
1002
+ var external_confirmation_messages_default = defineMessages4({
1003
+ title: {
1004
+ id: "df.wise.ExternalConfirmation.title",
1005
+ defaultMessage: "Please confirm",
1006
+ description: "Heading for the confirmation screen."
1007
+ },
1008
+ description: {
1009
+ id: "df.wise.ExternalConfirmation.description",
1010
+ defaultMessage: "Please confirm you want to open **{origin}** in a new browser tab.",
1011
+ description: "Description for the confirmation screen."
1012
+ },
1013
+ open: {
1014
+ id: "df.wise.ExternalConfirmation.open",
1015
+ defaultMessage: "Open in new tab",
1016
+ description: "Button text confirming opening a new browser tab."
1017
+ },
1018
+ cancel: {
1019
+ id: "df.wise.ExternalConfirmation.cancel",
1020
+ defaultMessage: "Cancel",
1021
+ description: "Button text rejecting opening a new browser tab."
1022
+ }
1023
+ });
1024
+
1025
+ // ../renderers/src/ExternalConfirmationRenderer.tsx
1026
+ import { useIntl as useIntl5 } from "react-intl";
1027
+ import { useEffect as useEffect3 } from "react";
1028
+ import { Fragment as Fragment3, jsx as jsx28, jsxs as jsxs6 } from "react/jsx-runtime";
1029
+ var ExternalConfirmationRenderer = {
1030
+ canRenderType: "external-confirmation",
1031
+ render: ExternalConfirmationRendererComponent
1032
+ };
1033
+ function ExternalConfirmationRendererComponent({
1034
+ url,
1035
+ status,
1036
+ onSuccess,
1037
+ onFailure,
1038
+ onCancel
1039
+ }) {
1040
+ const { formatMessage } = useIntl5();
1041
+ useEffect3(() => {
1042
+ if (url) {
1043
+ const w = window.open(url, "_blank");
1044
+ if (w) {
1045
+ onSuccess();
1046
+ } else {
1047
+ onFailure();
1048
+ }
1049
+ }
1050
+ }, []);
1051
+ return /* @__PURE__ */ jsx28(
1052
+ Modal,
1053
+ {
1054
+ open: status === "failure",
1055
+ title: formatMessage(external_confirmation_messages_default.title),
1056
+ body: /* @__PURE__ */ jsxs6(Fragment3, { children: [
1057
+ /* @__PURE__ */ jsx28(Markdown2, { config: { link: { target: "_blank" } }, className: "text-xs-center m-b-5", children: formatMessage(external_confirmation_messages_default.description, { origin: getOrigin(url) }) }),
1058
+ /* @__PURE__ */ jsx28("div", { className: "df-box-renderer-fixed-width", children: /* @__PURE__ */ jsxs6("div", { className: "df-box-renderer-width-lg", children: [
1059
+ /* @__PURE__ */ jsx28(
1060
+ Button3,
1061
+ {
1062
+ v2: true,
1063
+ block: true,
1064
+ className: "m-b-2",
1065
+ priority: "primary",
1066
+ size: "md",
1067
+ onClick: () => {
1068
+ window.open(url);
1069
+ onCancel();
1070
+ },
1071
+ children: formatMessage(external_confirmation_messages_default.open)
1072
+ }
1073
+ ),
1074
+ /* @__PURE__ */ jsx28(Button3, { v2: true, block: true, className: "m-b-2", priority: "tertiary", size: "md", onClick: onCancel, children: formatMessage(external_confirmation_messages_default.cancel) })
1075
+ ] }) })
1076
+ ] }),
1077
+ onClose: onCancel
1078
+ }
1079
+ );
1080
+ }
1081
+ function getOrigin(url) {
1082
+ try {
1083
+ return new URL(url).origin;
1084
+ } catch (e) {
1085
+ return url;
1086
+ }
1087
+ }
1088
+ var ExternalConfirmationRenderer_default = ExternalConfirmationRenderer;
1089
+
1090
+ // ../renderers/src/FormRenderer.tsx
1091
+ import { jsx as jsx29 } from "react/jsx-runtime";
1092
+ var FormRenderer = {
1093
+ canRenderType: "form",
1094
+ render: ({ children, margin }) => /* @__PURE__ */ jsx29("div", { className: getMargin(margin), children })
1095
+ };
1096
+ var FormRenderer_default = FormRenderer;
1097
+
1098
+ // ../renderers/src/FormSectionRenderer.tsx
1099
+ import { Header as Header3 } from "@transferwise/components";
1100
+ import { jsx as jsx30, jsxs as jsxs7 } from "react/jsx-runtime";
1101
+ var FormSectionRenderer = {
1102
+ canRenderType: "form-section",
1103
+ render: ({ title, description, children }) => /* @__PURE__ */ jsxs7("fieldset", { children: [
1104
+ title && /* @__PURE__ */ jsx30(
1105
+ Header3,
1106
+ {
1107
+ as: "h2",
1108
+ title
1109
+ }
1110
+ ),
1111
+ description && /* @__PURE__ */ jsx30("p", { children: description }),
1112
+ children
1113
+ ] })
1114
+ };
1115
+ var FormSectionRenderer_default = FormSectionRenderer;
1116
+
1117
+ // ../renderers/src/HeadingRenderer.tsx
1118
+ import { Display, Title } from "@transferwise/components";
1119
+ import { jsx as jsx31 } from "react/jsx-runtime";
1120
+ var HeadingRenderer = {
1121
+ canRenderType: "heading",
1122
+ render: (props) => /* @__PURE__ */ jsx31(Heading, __spreadValues({}, props))
1123
+ };
1124
+ function Heading(props) {
1125
+ const { text, size, align, margin, control } = props;
1126
+ const className = getTextAlignmentAndMargin({ align, margin });
1127
+ return control === "display" ? /* @__PURE__ */ jsx31(DisplayHeading, { size, text, className }) : /* @__PURE__ */ jsx31(StandardHeading, { size, text, className });
1128
+ }
1129
+ function DisplayHeading({ size, text, className }) {
1130
+ return /* @__PURE__ */ jsx31(Display, { type: getDisplayType(size), className, children: text });
1131
+ }
1132
+ var getDisplayType = (size) => {
1133
+ switch (size) {
1134
+ case "xs":
1135
+ case "sm":
1136
+ return "display-small";
1137
+ case "xl":
1138
+ case "lg":
1139
+ return "display-large";
1140
+ case "md":
1141
+ default:
1142
+ return "display-medium";
1143
+ }
1144
+ };
1145
+ function StandardHeading({ size, text, className }) {
1146
+ return /* @__PURE__ */ jsx31(Title, { type: getTitleTypeBySize(size), className, children: text });
1147
+ }
1148
+ var getTitleTypeBySize = (size) => {
1149
+ var _a;
1150
+ const titleTypes = {
1151
+ xs: "title-group",
1152
+ sm: "title-body",
1153
+ md: "title-subsection",
1154
+ lg: "title-section",
1155
+ xl: "title-screen"
1156
+ };
1157
+ return (_a = titleTypes[size]) != null ? _a : "title-subsection";
1158
+ };
1159
+ var HeadingRenderer_default = HeadingRenderer;
1160
+
1161
+ // ../renderers/src/ImageRenderer/UrlImage.tsx
1162
+ import { Image } from "@transferwise/components";
1163
+ import { useEffect as useEffect4, useState as useState4 } from "react";
1164
+
1165
+ // ../renderers/src/utils/api-utils.ts
1166
+ function isRelativePath(url = "") {
1167
+ return !["https://", "http://", "data:"].some(
1168
+ (prefix) => url.startsWith(prefix) && url.length > prefix.length
1169
+ );
1170
+ }
1171
+
1172
+ // ../renderers/src/ImageRenderer/UrlImage.tsx
1173
+ import { jsx as jsx32 } from "react/jsx-runtime";
1174
+ function UrlImage({
1175
+ accessibilityDescription,
1176
+ align,
1177
+ margin,
1178
+ size,
1179
+ uri,
1180
+ httpClient
1181
+ }) {
1182
+ const [imageSource, setImageSource] = useState4("");
1183
+ useEffect4(() => {
1184
+ if (!uri.startsWith("urn:")) {
1185
+ void getImageSource(httpClient, uri).then(setImageSource);
1186
+ }
1187
+ }, [uri, httpClient]);
1188
+ return /* @__PURE__ */ jsx32("div", { className: `df-image ${align} ${size || "md"}`, children: /* @__PURE__ */ jsx32(
1189
+ Image,
1190
+ {
1191
+ className: `img-responsive ${getMargin(margin)}`,
1192
+ alt: accessibilityDescription != null ? accessibilityDescription : "",
1193
+ src: imageSource,
1194
+ stretch: true,
1195
+ shrink: true
1196
+ }
1197
+ ) });
1198
+ }
1199
+ var readImageBlobAsDataURL = async (imageBlob) => (
1200
+ // we can safely assume the type of reader.result is string
1201
+ // because we're calling reader.readAsDataURL
1202
+ // https://developer.mozilla.org/en-US/docs/Web/API/FileReader/result
1203
+ new Promise((resolve, reject) => {
1204
+ const reader = new FileReader();
1205
+ reader.addEventListener("loadend", () => resolve(reader.result));
1206
+ reader.addEventListener("error", reject);
1207
+ reader.readAsDataURL(imageBlob);
1208
+ })
1209
+ );
1210
+ var getImageSource = async (httpClient, imageUrl) => {
1211
+ var _a;
1212
+ try {
1213
+ if (isRelativePath(imageUrl) || (imageUrl == null ? void 0 : imageUrl.startsWith(`${(_a = window == null ? void 0 : window.location) == null ? void 0 : _a.origin}/`))) {
1214
+ return await httpClient(imageUrl, {
1215
+ method: "GET",
1216
+ headers: { "Content-Type": "image/image" },
1217
+ credentials: "same-origin"
1218
+ }).then(async (response) => {
1219
+ if (response.ok) {
1220
+ return response.blob();
1221
+ }
1222
+ throw new Error("Image fetching failed");
1223
+ }).then(readImageBlobAsDataURL).catch(() => imageUrl);
1224
+ }
1225
+ return imageUrl;
1226
+ } catch (e) {
1227
+ return imageUrl;
1228
+ }
1229
+ };
1230
+
1231
+ // ../renderers/src/ImageRenderer/UrnFlagImage.tsx
1232
+ import { jsx as jsx33 } from "react/jsx-runtime";
1233
+ var maxFlagSize = 600;
1234
+ function UrnFlagImage({
1235
+ accessibilityDescription,
1236
+ align,
1237
+ margin,
1238
+ size,
1239
+ uri
1240
+ }) {
1241
+ return /* @__PURE__ */ jsx33("div", { className: `df-image ${align} ${size || "md"} ${getMargin(margin)}`, children: /* @__PURE__ */ jsx33(UrnFlag, { size: maxFlagSize, urn: uri, accessibilityDescription }) });
1242
+ }
1243
+
1244
+ // ../renderers/src/ImageRenderer/UrnIllustration.tsx
1245
+ import {
1246
+ Illustration,
1247
+ isIllustrationSupport3D
1248
+ } from "@wise/art";
1249
+ import { useState as useState5 } from "react";
1250
+
1251
+ // ../renderers/src/ImageRenderer/isAnimated.ts
1252
+ var isAnimated = (uri) => {
1253
+ var _a;
1254
+ const { rComponents } = stringToURN(uri);
1255
+ return (_a = rComponents == null ? void 0 : rComponents.some(([key, value]) => key === "type" && value === "animated")) != null ? _a : false;
1256
+ };
1257
+
1258
+ // ../renderers/src/ImageRenderer/SafeIllustration3D.tsx
1259
+ import { Illustration3D } from "@wise/art";
1260
+ import { Component } from "react";
1261
+ import { jsx as jsx34 } from "react/jsx-runtime";
1262
+ var Illustration3DErrorBoundary = class extends Component {
1263
+ constructor(props) {
1264
+ super(props);
1265
+ this.state = { hasError: false };
1266
+ }
1267
+ static getDerivedStateFromError() {
1268
+ return { hasError: true };
1269
+ }
1270
+ componentDidCatch() {
1271
+ this.props.onError();
1272
+ }
1273
+ render() {
1274
+ if (this.state.hasError) {
1275
+ return null;
1276
+ }
1277
+ return this.props.children;
1278
+ }
1279
+ };
1280
+ var SafeIllustration3D = ({
1281
+ name,
1282
+ size,
1283
+ onError
1284
+ }) => {
1285
+ return /* @__PURE__ */ jsx34(Illustration3DErrorBoundary, { onError, children: /* @__PURE__ */ jsx34(Illustration3D, { name, size }) });
1286
+ };
1287
+ var SafeIllustration3D_default = SafeIllustration3D;
1288
+
1289
+ // ../renderers/src/ImageRenderer/UrnIllustration.tsx
1290
+ import { jsx as jsx35 } from "react/jsx-runtime";
1291
+ var urnPrefix = "urn:wise:illustrations:";
1292
+ var isUrnIllustration = (uri) => uri.startsWith(urnPrefix);
1293
+ function UrnIllustration({
1294
+ accessibilityDescription,
1295
+ align,
1296
+ margin,
1297
+ size,
1298
+ uri
1299
+ }) {
1300
+ const [has3DFailed, setHas3DFailed] = useState5(false);
1301
+ const illustrationSize = getIllustrationSize(size);
1302
+ const illustrationName = getIllustrationName(uri);
1303
+ const illustration3DName = getIllustration3DName(uri);
1304
+ if (illustration3DName && isAnimated(uri) && !has3DFailed) {
1305
+ return /* @__PURE__ */ jsx35("div", { className: `df-image ${align} ${getMargin(margin)}`, children: /* @__PURE__ */ jsx35(
1306
+ SafeIllustration3D_default,
1307
+ {
1308
+ name: illustration3DName,
1309
+ size: illustrationSize,
1310
+ onError: () => setHas3DFailed(true)
1311
+ }
1312
+ ) });
1313
+ }
1314
+ return /* @__PURE__ */ jsx35("div", { className: `df-image ${align} ${getMargin(margin)}`, children: /* @__PURE__ */ jsx35(
1315
+ Illustration,
1316
+ {
1317
+ className: "df-illustration",
1318
+ name: illustrationName,
1319
+ size: illustrationSize,
1320
+ alt: accessibilityDescription
1321
+ }
1322
+ ) });
1323
+ }
1324
+ var getIllustrationSize = (size) => ({ xs: "small", sm: "small", md: "medium", lg: "large", xl: "large" })[size] || "medium";
1325
+ var getIllustrationName = (uri) => {
1326
+ return uri.replace(urnPrefix, "").split("?")[0];
1327
+ };
1328
+ var getIllustration3DName = (uri) => {
1329
+ const illustrationName = getIllustrationName(uri);
1330
+ return isIllustrationSupport3D(illustrationName) ? illustrationName : null;
1331
+ };
1332
+
1333
+ // ../renderers/src/ImageRenderer/UrnImage.tsx
1334
+ import { jsx as jsx36 } from "react/jsx-runtime";
1335
+ var isUrnImage = (uri) => uri.startsWith("urn:");
1336
+ function UrnImage(props) {
1337
+ const { uri } = props;
1338
+ if (isUrnIllustration(uri)) {
1339
+ return /* @__PURE__ */ jsx36(UrnIllustration, __spreadValues({}, props));
1340
+ }
1341
+ if (isUrnFlag(uri)) {
1342
+ return /* @__PURE__ */ jsx36(UrnFlagImage, __spreadValues({}, props));
1343
+ }
1344
+ return null;
1345
+ }
1346
+
1347
+ // ../renderers/src/ImageRenderer/ImageRenderer.tsx
1348
+ import { jsx as jsx37 } from "react/jsx-runtime";
1349
+ var ImageRenderer = {
1350
+ canRenderType: "image",
1351
+ render: (props) => isUrnImage(props.uri) ? /* @__PURE__ */ jsx37(UrnImage, __spreadValues({}, props)) : /* @__PURE__ */ jsx37(UrlImage, __spreadValues({}, props))
1352
+ };
1353
+
1354
+ // ../renderers/src/ImageRenderer/index.tsx
1355
+ var ImageRenderer_default = ImageRenderer;
1356
+
1357
+ // ../renderers/src/InstructionsRenderer.tsx
1358
+ import { Header as Header4, InstructionsList } from "@transferwise/components";
1359
+ import { jsx as jsx38, jsxs as jsxs8 } from "react/jsx-runtime";
1360
+ var doContext = ["positive", "neutral"];
1361
+ var dontContext = ["warning", "negative"];
1362
+ var InstructionsRenderer = {
1363
+ canRenderType: "instructions",
1364
+ render: ({ items, margin, title }) => {
1365
+ const dos = items.filter((item) => doContext.includes(item.context)).map(({ text }) => text);
1366
+ const donts = items.filter((item) => dontContext.includes(item.context)).map(({ text }) => text);
1367
+ return /* @__PURE__ */ jsxs8("div", { className: getMargin(margin), children: [
1368
+ title ? /* @__PURE__ */ jsx38(Header4, { title }) : null,
1369
+ /* @__PURE__ */ jsx38(InstructionsList, { dos, donts })
1370
+ ] });
1371
+ }
1372
+ };
1373
+ var InstructionsRenderer_default = InstructionsRenderer;
1374
+
1375
+ // ../renderers/src/IntegerInputRenderer.tsx
1376
+ import { Input, InputGroup } from "@transferwise/components";
1377
+
1378
+ // ../renderers/src/utils/input-utils.ts
1379
+ var onWheel = (event) => {
1380
+ if (event.target instanceof HTMLElement) {
1381
+ event.target.blur();
1382
+ }
1383
+ };
1384
+
1385
+ // ../renderers/src/utils/getInputGroupAddonStart.tsx
1386
+ var getInputGroupAddonStart = (media) => {
1387
+ const content = getInlineMedia(media);
1388
+ return content ? { content } : void 0;
1389
+ };
1390
+
1391
+ // ../renderers/src/utils/pick.ts
1392
+ function pick(obj, ...keys) {
1393
+ const result = {};
1394
+ keys.forEach((key) => {
1395
+ result[key] = obj[key];
1396
+ });
1397
+ return result;
1398
+ }
1399
+
1400
+ // ../renderers/src/IntegerInputRenderer.tsx
1401
+ import { jsx as jsx39 } from "react/jsx-runtime";
1402
+ var IntegerInputRenderer = {
1403
+ canRenderType: "input-integer",
1404
+ render: (props) => {
1405
+ const { id, title, description, help, media, validationState, value, onChange } = props;
1406
+ const commonProps = pick(
1407
+ props,
1408
+ "autoComplete",
1409
+ "disabled",
1410
+ "onBlur",
1411
+ "onFocus",
1412
+ "placeholder",
1413
+ "maximum",
1414
+ "minimum"
1415
+ );
1416
+ return /* @__PURE__ */ jsx39(
1417
+ FieldInput_default,
1418
+ {
1419
+ id,
1420
+ label: title,
1421
+ description,
1422
+ validation: validationState,
1423
+ help,
1424
+ children: /* @__PURE__ */ jsx39(InputGroup, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx39(
1425
+ Input,
1426
+ __spreadValues({
1427
+ id,
1428
+ name: id,
1429
+ type: "number",
1430
+ step: "1",
1431
+ pattern: "\\d+",
1432
+ value: value != null ? value : "",
1433
+ onChange: ({ target: { value: newValue } }) => {
1434
+ const parsedValue = Number.parseInt(newValue, 10);
1435
+ onChange(Number.isNaN(parsedValue) ? null : parsedValue);
1436
+ },
1437
+ onWheel
1438
+ }, commonProps)
1439
+ ) })
1440
+ }
1441
+ );
1442
+ }
1443
+ };
1444
+ var IntegerInputRenderer_default = IntegerInputRenderer;
1445
+
1446
+ // ../renderers/src/ListRenderer.tsx
1447
+ import { Body, Header as Header5 } from "@transferwise/components";
1448
+ import classNames3 from "classnames";
1449
+ import { jsx as jsx40, jsxs as jsxs9 } from "react/jsx-runtime";
1450
+ var ListRenderer = {
1451
+ canRenderType: "list",
1452
+ render: ({ callToAction, control, margin, items, title }) => /* @__PURE__ */ jsxs9("div", { className: getMargin(margin), children: [
1453
+ (title || callToAction) && /* @__PURE__ */ jsx40(Header5, { as: "h2", title: title != null ? title : "", action: getListAction(callToAction) }),
1454
+ items.map((props) => /* @__PURE__ */ jsx40(DesignSystemListItem, __spreadProps(__spreadValues({}, props), { control }), props.title))
1455
+ ] })
1456
+ };
1457
+ var DesignSystemListItem = ({
1458
+ title,
1459
+ description,
1460
+ supportingValues,
1461
+ icon,
1462
+ image,
1463
+ media,
1464
+ control,
1465
+ tag
1466
+ }) => /* @__PURE__ */ jsx40(
1467
+ "label",
1468
+ {
1469
+ className: classNames3("np-option p-a-2", {
1470
+ "np-option__sm-media": true,
1471
+ "np-option__container-aligned": true
1472
+ }),
1473
+ children: /* @__PURE__ */ jsxs9("div", { className: "media", children: [
1474
+ icon || image || media ? /* @__PURE__ */ jsx40("div", { className: "media-left", children: /* @__PURE__ */ jsx40(
1475
+ ListItemMedia,
1476
+ {
1477
+ icon,
1478
+ media,
1479
+ preferAvatar: control === "with-avatar" || tag === "with-avatar"
1480
+ }
1481
+ ) }) : null,
1482
+ /* @__PURE__ */ jsxs9("div", { className: "media-body", children: [
1483
+ /* @__PURE__ */ jsxs9("div", { className: "d-flex justify-content-between", children: [
1484
+ /* @__PURE__ */ jsx40("h4", { className: "np-text-body-large-bold text-primary np-option__title", children: title }),
1485
+ /* @__PURE__ */ jsx40("h4", { className: "np-text-body-large-bold text-primary np-option__title", children: supportingValues == null ? void 0 : supportingValues.value })
1486
+ ] }),
1487
+ /* @__PURE__ */ jsxs9("div", { className: "d-flex justify-content-between", children: [
1488
+ /* @__PURE__ */ jsx40(Body, { className: "d-block np-option__body", children: description }),
1489
+ /* @__PURE__ */ jsx40(Body, { className: "d-block np-option__body", children: supportingValues == null ? void 0 : supportingValues.subvalue })
1490
+ ] })
1491
+ ] })
1492
+ ] })
1493
+ },
1494
+ title
1495
+ );
1496
+ var ListItemMedia = ({
1497
+ icon,
1498
+ media,
1499
+ preferAvatar
1500
+ }) => {
1501
+ if (icon) {
1502
+ return /* @__PURE__ */ jsx40("div", { className: "circle circle-sm text-primary circle-inverse", children: /* @__PURE__ */ jsx40(OptionMedia, { media, preferAvatar }) });
1503
+ }
1504
+ return /* @__PURE__ */ jsx40("div", { className: "np-option__no-media-circle", children: /* @__PURE__ */ jsx40(OptionMedia, { media, preferAvatar }) });
1505
+ };
1506
+ var getListAction = (callToAction) => {
1507
+ if (callToAction) {
1508
+ return __spreadValues({
1509
+ "aria-label": callToAction.accessibilityDescription,
1510
+ text: callToAction.title,
1511
+ onClick: callToAction.onClick
1512
+ }, callToAction.type === "link" ? { href: callToAction.href, target: "_blank" } : {});
1513
+ }
1514
+ return void 0;
1515
+ };
1516
+ var ListRenderer_default = ListRenderer;
1517
+
1518
+ // ../renderers/src/LoadingIndicatorRenderer.tsx
1519
+ import { Loader } from "@transferwise/components";
1520
+ import { jsx as jsx41 } from "react/jsx-runtime";
1521
+ var LoadingIndicatorRenderer = {
1522
+ canRenderType: "loading-indicator",
1523
+ render: ({ margin, size }) => /* @__PURE__ */ jsx41(
1524
+ Loader,
1525
+ {
1526
+ size,
1527
+ classNames: { "tw-loader": `tw-loader m-x-auto ${getMargin(margin)}` },
1528
+ "data-testid": "loading-indicator"
1529
+ }
1530
+ )
1531
+ };
1532
+ var LoadingIndicatorRenderer_default = LoadingIndicatorRenderer;
1533
+
1534
+ // ../renderers/src/MarkdownRenderer.tsx
1535
+ import { Markdown as Markdown3 } from "@transferwise/components";
1536
+ import { jsx as jsx42 } from "react/jsx-runtime";
1537
+ var MarkdownRenderer = {
1538
+ canRenderType: "markdown",
1539
+ render: ({ content, align, margin }) => /* @__PURE__ */ jsx42("div", { className: getTextAlignmentAndMargin({ align, margin }), children: /* @__PURE__ */ jsx42(Markdown3, { className: "np-text-body-large", config: { link: { target: "_blank" } }, children: content }) })
1540
+ };
1541
+ var MarkdownRenderer_default = MarkdownRenderer;
1542
+
1543
+ // ../renderers/src/ModalLayoutRenderer.tsx
1544
+ import { Button as Button4, Modal as Modal2 } from "@transferwise/components";
1545
+ import { useState as useState6 } from "react";
1546
+ import { jsx as jsx43, jsxs as jsxs10 } from "react/jsx-runtime";
1547
+ var ModalLayoutRenderer = {
1548
+ canRenderType: "modal-layout",
1549
+ render: (props) => /* @__PURE__ */ jsx43(DFModal, __spreadValues({}, props))
1550
+ };
1551
+ var ModalLayoutRenderer_default = ModalLayoutRenderer;
1552
+ function DFModal({ content, margin, trigger }) {
1553
+ const [visible, setVisible] = useState6(false);
1554
+ const { children, title } = content;
1555
+ return /* @__PURE__ */ jsxs10("div", { className: getMargin(margin), children: [
1556
+ /* @__PURE__ */ jsx43(Button4, { v2: true, priority: "tertiary", block: true, onClick: () => setVisible(true), children: trigger.title }),
1557
+ /* @__PURE__ */ jsx43(
1558
+ Modal2,
1559
+ {
1560
+ scroll: "content",
1561
+ open: visible,
1562
+ size: "lg",
1563
+ title,
1564
+ body: children,
1565
+ onClose: () => setVisible(false)
1566
+ }
1567
+ )
1568
+ ] });
1569
+ }
1570
+
1571
+ // ../renderers/src/ModalRenderer.tsx
1572
+ import { Modal as Modal3 } from "@transferwise/components";
1573
+ import { jsx as jsx44 } from "react/jsx-runtime";
1574
+ var ModalRenderer = {
1575
+ canRenderType: "modal",
1576
+ render: ({ title, children, open, onClose }) => {
1577
+ return /* @__PURE__ */ jsx44(Modal3, { open, title, body: children, onClose });
1578
+ }
1579
+ };
1580
+
1581
+ // ../renderers/src/MultiSelectInputRenderer.tsx
1582
+ import { SelectInput, SelectInputOptionContent } from "@transferwise/components";
1583
+ import { useState as useState7 } from "react";
1584
+ import { useIntl as useIntl6 } from "react-intl";
1585
+
1586
+ // ../renderers/src/messages/multi-select.messages.ts
1587
+ import { defineMessages as defineMessages5 } from "react-intl";
1588
+ var multi_select_messages_default = defineMessages5({
1589
+ summary: {
1590
+ id: "df.wise.MultiSelect.summary",
1591
+ defaultMessage: "{first} and {count} more",
1592
+ description: "A summary of the multiple items selected. Showing the title of the first selected item, and the number of other items that have been selected."
1593
+ }
1594
+ });
1595
+
1596
+ // ../renderers/src/MultiSelectInputRenderer.tsx
1597
+ import { jsx as jsx45 } from "react/jsx-runtime";
1598
+ var MultiSelectInputRenderer = {
1599
+ canRenderType: "input-multi-select",
1600
+ render: (props) => /* @__PURE__ */ jsx45(MultiSelectInputRendererComponent, __spreadValues({}, props))
1601
+ };
1602
+ function MultiSelectInputRendererComponent(props) {
1603
+ const { formatMessage } = useIntl6();
1604
+ const [stagedIndices, setStagedIndices] = useState7();
1605
+ const {
1606
+ id,
1607
+ autoComplete,
1608
+ description,
1609
+ disabled,
1610
+ help,
1611
+ options,
1612
+ placeholder,
1613
+ selectedIndices,
1614
+ title,
1615
+ validationState,
1616
+ onSelect
1617
+ } = props;
1618
+ const mergedIndices = stagedIndices != null ? stagedIndices : selectedIndices;
1619
+ const getFormattedMessage = () => {
1620
+ if (mergedIndices.length > 0) {
1621
+ if (mergedIndices.length > 1) {
1622
+ return formatMessage(multi_select_messages_default.summary, {
1623
+ first: options[mergedIndices[0]].title,
1624
+ count: mergedIndices.length - 1
1625
+ });
1626
+ }
1627
+ return options[mergedIndices[0]].title;
1628
+ }
1629
+ return void 0;
1630
+ };
1631
+ const renderValue = (index, withinTrigger) => {
1632
+ const option = index >= 0 ? options[index] : null;
1633
+ if (option === null) {
1634
+ return null;
1635
+ }
1636
+ if (withinTrigger) {
1637
+ return index === mergedIndices[0] ? getFormattedMessage() : void 0;
1638
+ }
1639
+ const contentProps = {
1640
+ title: option.title,
1641
+ description: option.description,
1642
+ icon: /* @__PURE__ */ jsx45(OptionMedia, { media: option.media, preferAvatar: false })
1643
+ };
1644
+ return /* @__PURE__ */ jsx45(SelectInputOptionContent, __spreadValues({}, contentProps));
1645
+ };
1646
+ const extraProps = { autoComplete };
1647
+ return /* @__PURE__ */ jsx45(
1648
+ FieldInput_default,
1649
+ {
1650
+ id,
1651
+ label: title,
1652
+ help,
1653
+ description,
1654
+ validation: validationState,
1655
+ children: /* @__PURE__ */ jsx45(
1656
+ SelectInput,
1657
+ __spreadValues({
1658
+ id,
1659
+ items: options.map((option, index) => {
1660
+ var _a, _b, _c;
1661
+ return {
1662
+ type: "option",
1663
+ value: index,
1664
+ filterMatchers: [
1665
+ ...(_a = option.keywords) != null ? _a : [],
1666
+ (_b = option.title) != null ? _b : "",
1667
+ (_c = option.description) != null ? _c : ""
1668
+ ],
1669
+ disabled: option.disabled
1670
+ };
1671
+ }),
1672
+ disabled,
1673
+ placeholder,
1674
+ value: mergedIndices,
1675
+ renderValue,
1676
+ multiple: true,
1677
+ filterable: options.length >= 8,
1678
+ onChange: (values) => {
1679
+ setStagedIndices(values);
1680
+ },
1681
+ onClose: () => {
1682
+ if (stagedIndices) {
1683
+ onSelect(stagedIndices);
1684
+ setStagedIndices(void 0);
1685
+ }
1686
+ }
1687
+ }, extraProps)
1688
+ )
1689
+ }
1690
+ );
1691
+ }
1692
+ var MultiSelectInputRenderer_default = MultiSelectInputRenderer;
20
1693
 
21
- // src/index.ts
22
- import { makeHttpClient } from "@wise/dynamic-flow-client";
23
- import { findRendererPropsByType, isValidSchema, JsonSchemaForm } from "@wise/dynamic-flow-client";
1694
+ // ../renderers/src/MultiUploadInputRenderer.tsx
1695
+ import { UploadInput } from "@transferwise/components";
1696
+
1697
+ // ../renderers/src/components/UploadFieldInput.tsx
1698
+ import { InlineAlert as InlineAlert2 } from "@transferwise/components";
1699
+ import classNames4 from "classnames";
1700
+ import { jsx as jsx46, jsxs as jsxs11 } from "react/jsx-runtime";
1701
+ function UploadFieldInput({
1702
+ id,
1703
+ children,
1704
+ label,
1705
+ description,
1706
+ help,
1707
+ validation
1708
+ }) {
1709
+ const labelContent = label && help ? /* @__PURE__ */ jsx46(LabelContentWithHelp, { text: label, help }) : label;
1710
+ const descriptionId = description ? `${id}-description` : void 0;
1711
+ return /* @__PURE__ */ jsxs11(
1712
+ "div",
1713
+ {
1714
+ className: classNames4("form-group d-block", {
1715
+ "has-error": (validation == null ? void 0 : validation.status) === "invalid"
1716
+ }),
1717
+ children: [
1718
+ /* @__PURE__ */ jsx46("label", { htmlFor: id, className: "control-label", children: labelContent }),
1719
+ children,
1720
+ (validation == null ? void 0 : validation.status) === "invalid" && /* @__PURE__ */ jsx46(InlineAlert2, { type: "negative", id: descriptionId, children: validation.message })
1721
+ ]
1722
+ }
1723
+ );
1724
+ }
1725
+ var UploadFieldInput_default = UploadFieldInput;
1726
+
1727
+ // ../renderers/src/utils/file-utils.ts
1728
+ var acceptsToFileTypes = (accepts) => Array.isArray(accepts) && accepts.length >= 1 ? accepts : "*";
1729
+ var toKilobytes = (sizeInBytes) => {
1730
+ const ONE_KB_IN_BYTES = 1024;
1731
+ return Math.floor(sizeInBytes / ONE_KB_IN_BYTES);
1732
+ };
1733
+ var toFile = async (base64Url, name) => {
1734
+ const type = getFileType(base64Url);
1735
+ const blob = await toBlob(base64Url);
1736
+ return new File([blob], name, { type });
1737
+ };
1738
+ var toBlob = async (base64Url) => (await fetch(base64Url)).blob();
1739
+ var getFileType = (base64Url) => {
1740
+ const contentTypeRegex = /^data:(.+);/;
1741
+ const matches = contentTypeRegex.exec(base64Url);
1742
+ if (matches && matches.length > 1) {
1743
+ return matches[1];
1744
+ }
1745
+ return void 0;
1746
+ };
1747
+ var getSizeLimit = (maxSize) => {
1748
+ if (maxSize === void 0) {
1749
+ return null;
1750
+ }
1751
+ return toKilobytes(maxSize);
1752
+ };
1753
+
1754
+ // ../renderers/src/MultiUploadInputRenderer.tsx
1755
+ import { jsx as jsx47 } from "react/jsx-runtime";
1756
+ var MultiUploadInputRenderer = {
1757
+ canRenderType: "input-upload-multi",
1758
+ render: (props) => {
1759
+ const {
1760
+ id,
1761
+ accepts,
1762
+ help,
1763
+ title,
1764
+ description,
1765
+ disabled,
1766
+ maxSize,
1767
+ maxItems,
1768
+ uploadLabel,
1769
+ validationState,
1770
+ value,
1771
+ onInsertFile,
1772
+ onRemoveFile
1773
+ } = props;
1774
+ const onUploadFile = async (formData) => {
1775
+ const file = formData.get("file");
1776
+ return onInsertFile(value.length, file).then((newId) => ({ id: newId }));
1777
+ };
1778
+ const onDeleteFile = async (fileId) => onRemoveFile(value.findIndex((file) => file.id === fileId));
1779
+ const descriptionId = description ? `${id}-description` : void 0;
1780
+ return /* @__PURE__ */ jsx47(
1781
+ UploadFieldInput_default,
1782
+ {
1783
+ id,
1784
+ label: title,
1785
+ description,
1786
+ validation: validationState,
1787
+ help,
1788
+ children: /* @__PURE__ */ jsx47(
1789
+ UploadInput,
1790
+ {
1791
+ id,
1792
+ "aria-describedby": descriptionId,
1793
+ description,
1794
+ disabled,
1795
+ fileTypes: acceptsToFileTypes(accepts),
1796
+ maxFiles: maxItems,
1797
+ multiple: true,
1798
+ sizeLimit: getSizeLimit(maxSize),
1799
+ uploadButtonTitle: uploadLabel,
1800
+ onDeleteFile,
1801
+ onUploadFile
1802
+ }
1803
+ )
1804
+ }
1805
+ );
1806
+ }
1807
+ };
1808
+ var MultiUploadInputRenderer_default = MultiUploadInputRenderer;
1809
+
1810
+ // ../renderers/src/NumberInputRenderer.tsx
1811
+ import { Input as Input2, InputGroup as InputGroup2 } from "@transferwise/components";
1812
+ import { jsx as jsx48 } from "react/jsx-runtime";
1813
+ var NumberInputRenderer = {
1814
+ canRenderType: "input-number",
1815
+ render: (props) => {
1816
+ const { id, title, description, help, media, validationState, value, onChange } = props;
1817
+ const commonProps = pick(
1818
+ props,
1819
+ "disabled",
1820
+ "onBlur",
1821
+ "onFocus",
1822
+ "placeholder",
1823
+ "maximum",
1824
+ "minimum"
1825
+ );
1826
+ return /* @__PURE__ */ jsx48(
1827
+ FieldInput_default,
1828
+ {
1829
+ id,
1830
+ label: title,
1831
+ description,
1832
+ validation: validationState,
1833
+ help,
1834
+ children: /* @__PURE__ */ jsx48(InputGroup2, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx48(
1835
+ Input2,
1836
+ __spreadValues({
1837
+ id,
1838
+ name: id,
1839
+ type: "number",
1840
+ value: value != null ? value : "",
1841
+ onChange: ({ target: { value: newValue } }) => {
1842
+ const parsedValue = Number.parseFloat(newValue);
1843
+ onChange(Number.isNaN(parsedValue) ? null : parsedValue);
1844
+ },
1845
+ onWheel
1846
+ }, commonProps)
1847
+ ) })
1848
+ }
1849
+ );
1850
+ }
1851
+ };
1852
+ var NumberInputRenderer_default = NumberInputRenderer;
1853
+
1854
+ // ../renderers/src/ParagraphRenderer.tsx
1855
+ import { useIntl as useIntl7 } from "react-intl";
1856
+
1857
+ // ../renderers/src/hooks/useSnackBarIfAvailable.ts
1858
+ import { SnackbarContext } from "@transferwise/components";
1859
+ import { useContext } from "react";
1860
+ function useSnackBarIfAvailable() {
1861
+ const context = useContext(SnackbarContext);
1862
+ return context ? context.createSnackbar : () => {
1863
+ };
1864
+ }
1865
+
1866
+ // ../renderers/src/ParagraphRenderer.tsx
1867
+ import { Button as Button5, Input as Input3 } from "@transferwise/components";
1868
+ import classNames5 from "classnames";
1869
+
1870
+ // ../renderers/src/messages/paragraph.messages.ts
1871
+ import { defineMessages as defineMessages6 } from "react-intl";
1872
+ var paragraph_messages_default = defineMessages6({
1873
+ copy: {
1874
+ id: "df.wise.DynamicParagraph.copy",
1875
+ defaultMessage: "Copy",
1876
+ description: "Copy to clipboard button label."
1877
+ },
1878
+ copied: {
1879
+ id: "df.wise.DynamicParagraph.copied",
1880
+ defaultMessage: "Copied to clipboard",
1881
+ description: "Appears in a snackbar when the copy operation succeeds."
1882
+ }
1883
+ });
1884
+
1885
+ // ../renderers/src/ParagraphRenderer.tsx
1886
+ import { jsx as jsx49, jsxs as jsxs12 } from "react/jsx-runtime";
1887
+ var ParagraphRenderer = {
1888
+ canRenderType: "paragraph",
1889
+ render: (props) => /* @__PURE__ */ jsx49(Paragraph, __spreadValues({}, props))
1890
+ };
1891
+ function Paragraph({ align, control, margin, text }) {
1892
+ const className = getTextAlignmentAndMargin({ align, margin });
1893
+ return control === "copyable" ? /* @__PURE__ */ jsx49(CopyableParagraph, { className, align, text }) : /* @__PURE__ */ jsx49(StandardParagraph, { className, text });
1894
+ }
1895
+ function StandardParagraph({ text, className }) {
1896
+ return /* @__PURE__ */ jsx49("p", { className: `np-text-body-large ${className}`, children: text });
1897
+ }
1898
+ function CopyableParagraph({
1899
+ text,
1900
+ align,
1901
+ className
1902
+ }) {
1903
+ const { formatMessage } = useIntl7();
1904
+ const createSnackbar = useSnackBarIfAvailable();
1905
+ const copy = () => {
1906
+ navigator.clipboard.writeText(text).then(() => createSnackbar({ text: formatMessage(paragraph_messages_default.copied) })).catch(() => {
1907
+ });
1908
+ };
1909
+ const inputAlignmentClasses = getTextAlignmentAndMargin({ align, margin: "sm" });
1910
+ return /* @__PURE__ */ jsxs12("div", { className, children: [
1911
+ /* @__PURE__ */ jsx49(
1912
+ Input3,
1913
+ {
1914
+ type: "text",
1915
+ value: text,
1916
+ readOnly: true,
1917
+ className: classNames5("text-ellipsis", inputAlignmentClasses)
1918
+ }
1919
+ ),
1920
+ /* @__PURE__ */ jsx49(Button5, { v2: true, block: true, onClick: copy, children: formatMessage(paragraph_messages_default.copy) })
1921
+ ] });
1922
+ }
1923
+ var ParagraphRenderer_default = ParagraphRenderer;
1924
+
1925
+ // ../renderers/src/RepeatableRenderer.tsx
1926
+ import { Button as Button6, Header as Header6, InlineAlert as InlineAlert3, Modal as Modal4, NavigationOption as NavigationOption2 } from "@transferwise/components";
1927
+ import { Plus } from "@transferwise/icons";
1928
+ import classNames6 from "classnames";
1929
+ import { useState as useState8 } from "react";
1930
+ import { useIntl as useIntl8 } from "react-intl";
1931
+
1932
+ // ../renderers/src/messages/repeatable.messages.ts
1933
+ import { defineMessages as defineMessages7 } from "react-intl";
1934
+ var repeatable_messages_default = defineMessages7({
1935
+ addItemTitle: {
1936
+ id: "df.wise.ArraySchema.addItemTitle",
1937
+ defaultMessage: "Add Item",
1938
+ description: "Label on the button used to open a form to add an item"
1939
+ },
1940
+ addItem: {
1941
+ id: "df.wise.ArraySchema.addItem",
1942
+ defaultMessage: "Save",
1943
+ description: "Label on the add button used to submit a form that adds an item"
1944
+ },
1945
+ editItem: {
1946
+ id: "df.wise.ArraySchema.editItem",
1947
+ defaultMessage: "Save",
1948
+ description: "Label on the edit button used to submit a form that edits an item"
1949
+ },
1950
+ removeItem: {
1951
+ id: "df.wise.ArraySchema.removeItem",
1952
+ defaultMessage: "Remove",
1953
+ description: "Label on the remove button used to confirm deletion of an item"
1954
+ }
1955
+ });
1956
+
1957
+ // ../renderers/src/RepeatableRenderer.tsx
1958
+ import { Fragment as Fragment4, jsx as jsx50, jsxs as jsxs13 } from "react/jsx-runtime";
1959
+ var RepeatableRenderer = {
1960
+ canRenderType: "repeatable",
1961
+ render: (props) => /* @__PURE__ */ jsx50(Repeatable, __spreadValues({}, props))
1962
+ };
1963
+ function Repeatable(props) {
1964
+ const {
1965
+ addItemTitle,
1966
+ description,
1967
+ editableItem,
1968
+ editItemTitle,
1969
+ items,
1970
+ title,
1971
+ validationState,
1972
+ onEdit,
1973
+ onAdd,
1974
+ onSave,
1975
+ onRemove
1976
+ } = props;
1977
+ const { formatMessage } = useIntl8();
1978
+ const [openModalType, setOpenModalType] = useState8(null);
1979
+ const onAddItem = () => {
1980
+ onAdd();
1981
+ setOpenModalType("add");
1982
+ };
1983
+ const onEditItem = (itemIndex) => {
1984
+ onEdit(itemIndex);
1985
+ setOpenModalType("edit");
1986
+ };
1987
+ const onSaveItem = () => {
1988
+ const saveSuccessful = onSave();
1989
+ if (saveSuccessful) {
1990
+ setOpenModalType(null);
1991
+ }
1992
+ };
1993
+ const onRemoveItem = () => {
1994
+ onRemove();
1995
+ setOpenModalType(null);
1996
+ };
1997
+ const onCancelEdit = () => {
1998
+ setOpenModalType(null);
1999
+ };
2000
+ return /* @__PURE__ */ jsxs13(Fragment4, { children: [
2001
+ title && /* @__PURE__ */ jsx50(Header6, { title }),
2002
+ description && /* @__PURE__ */ jsx50("p", { children: description }),
2003
+ /* @__PURE__ */ jsxs13(
2004
+ "div",
2005
+ {
2006
+ className: classNames6("form-group", {
2007
+ "has-error": (validationState == null ? void 0 : validationState.status) === "invalid"
2008
+ }),
2009
+ children: [
2010
+ items == null ? void 0 : items.map((item, index) => /* @__PURE__ */ jsx50(ItemSummaryOption, { item, onClick: () => onEditItem(index) }, item.id)),
2011
+ /* @__PURE__ */ jsx50(
2012
+ NavigationOption2,
2013
+ {
2014
+ media: /* @__PURE__ */ jsx50(Plus, {}),
2015
+ title: addItemTitle || formatMessage(repeatable_messages_default.addItemTitle),
2016
+ showMediaAtAllSizes: true,
2017
+ onClick: () => onAddItem()
2018
+ }
2019
+ ),
2020
+ (validationState == null ? void 0 : validationState.status) === "invalid" && /* @__PURE__ */ jsx50(InlineAlert3, { type: "negative", children: validationState.message })
2021
+ ]
2022
+ }
2023
+ ),
2024
+ /* @__PURE__ */ jsx50(
2025
+ Modal4,
2026
+ {
2027
+ open: openModalType !== null,
2028
+ title: (openModalType === "add" ? addItemTitle : editItemTitle) || formatMessage(repeatable_messages_default.addItemTitle),
2029
+ body: /* @__PURE__ */ jsxs13(Fragment4, { children: [
2030
+ /* @__PURE__ */ jsx50("div", { className: "m-b-2", children: editableItem }),
2031
+ /* @__PURE__ */ jsxs13("div", { children: [
2032
+ /* @__PURE__ */ jsx50(Button6, { priority: "primary", block: true, className: "m-b-2", onClick: () => onSaveItem(), children: formatMessage(repeatable_messages_default.addItem) }),
2033
+ /* @__PURE__ */ jsx50(
2034
+ Button6,
2035
+ {
2036
+ v2: true,
2037
+ priority: "secondary",
2038
+ sentiment: "negative",
2039
+ block: true,
2040
+ onClick: () => onRemoveItem(),
2041
+ children: formatMessage(repeatable_messages_default.removeItem)
2042
+ }
2043
+ )
2044
+ ] })
2045
+ ] }),
2046
+ onClose: () => onCancelEdit()
2047
+ }
2048
+ )
2049
+ ] });
2050
+ }
2051
+ function ItemSummaryOption({
2052
+ item,
2053
+ onClick
2054
+ }) {
2055
+ return /* @__PURE__ */ jsx50(
2056
+ NavigationOption2,
2057
+ {
2058
+ media: /* @__PURE__ */ jsx50(OptionMedia, { media: item.media, preferAvatar: false }),
2059
+ title: item.title,
2060
+ content: item.description,
2061
+ showMediaAtAllSizes: true,
2062
+ onClick
2063
+ }
2064
+ );
2065
+ }
2066
+ var RepeatableRenderer_default = RepeatableRenderer;
2067
+
2068
+ // ../renderers/src/ReviewRenderer.tsx
2069
+ import { DefinitionList } from "@transferwise/components";
2070
+
2071
+ // ../renderers/src/components/Header.tsx
2072
+ import { Header as DSHeader } from "@transferwise/components";
2073
+ import { jsx as jsx51 } from "react/jsx-runtime";
2074
+ var Header7 = ({ title, callToAction }) => (title || callToAction) && /* @__PURE__ */ jsx51(DSHeader, { title: title != null ? title : "", action: getHeaderAction(callToAction) });
2075
+ var getHeaderAction = (callToAction) => {
2076
+ if (!callToAction) {
2077
+ return void 0;
2078
+ }
2079
+ const { accessibilityDescription, href, title, onClick } = callToAction;
2080
+ return href ? {
2081
+ "aria-label": accessibilityDescription,
2082
+ text: title,
2083
+ href,
2084
+ target: "_blank"
2085
+ } : {
2086
+ "aria-label": accessibilityDescription,
2087
+ text: title,
2088
+ onClick: (event) => {
2089
+ event.preventDefault();
2090
+ onClick();
2091
+ }
2092
+ };
2093
+ };
2094
+
2095
+ // ../renderers/src/ReviewRenderer.tsx
2096
+ import { Fragment as Fragment5, jsx as jsx52, jsxs as jsxs14 } from "react/jsx-runtime";
2097
+ var ReviewRenderer = {
2098
+ canRenderType: "review",
2099
+ render: ({ callToAction, control, fields, margin, title, trackEvent }) => {
2100
+ const orientation = mapControlToDefinitionListLayout(control);
2101
+ return /* @__PURE__ */ jsxs14("div", { className: getMargin(margin), children: [
2102
+ /* @__PURE__ */ jsx52(Header7, { title, callToAction }),
2103
+ /* @__PURE__ */ jsx52("div", { className: margin, children: /* @__PURE__ */ jsx52(
2104
+ DefinitionList,
2105
+ {
2106
+ layout: orientation,
2107
+ definitions: fields.map(
2108
+ ({ label, value, help, analyticsId: fieldAnalyticsId }, index) => ({
2109
+ key: String(index),
2110
+ value,
2111
+ title: getFieldLabel(
2112
+ label,
2113
+ help,
2114
+ () => trackEvent("Help Pressed", { layoutItemId: fieldAnalyticsId })
2115
+ )
2116
+ })
2117
+ )
2118
+ }
2119
+ ) })
2120
+ ] });
2121
+ }
2122
+ };
2123
+ var ReviewRenderer_default = ReviewRenderer;
2124
+ var mapControlToDefinitionListLayout = (control) => {
2125
+ switch (control) {
2126
+ case "horizontal":
2127
+ case "horizontal-end-aligned":
2128
+ return "HORIZONTAL_RIGHT_ALIGNED";
2129
+ case "horizontal-start-aligned":
2130
+ return "HORIZONTAL_LEFT_ALIGNED";
2131
+ case "vertical-two-column":
2132
+ return "VERTICAL_TWO_COLUMN";
2133
+ case "vertical":
2134
+ case "vertical-one-column":
2135
+ default:
2136
+ return "VERTICAL_ONE_COLUMN";
2137
+ }
2138
+ };
2139
+ var getFieldLabel = (label, help, onClick) => {
2140
+ if (help) {
2141
+ return /* @__PURE__ */ jsxs14(Fragment5, { children: [
2142
+ label,
2143
+ " ",
2144
+ /* @__PURE__ */ jsx52(Help_default, { help, onClick })
2145
+ ] });
2146
+ }
2147
+ return label;
2148
+ };
2149
+
2150
+ // ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
2151
+ import { Input as Input4, Markdown as Markdown4, NavigationOption as NavigationOption3, NavigationOptionsList as NavigationOptionsList2 } from "@transferwise/components";
2152
+ import { useState as useState9 } from "react";
2153
+ import { useIntl as useIntl10 } from "react-intl";
2154
+
2155
+ // ../renderers/src/messages/search.messages.ts
2156
+ import { defineMessages as defineMessages8 } from "react-intl";
2157
+ var search_messages_default = defineMessages8({
2158
+ loading: {
2159
+ id: "df.wise.SearchLayout.loading",
2160
+ defaultMessage: "Loading...",
2161
+ description: "A message shown to the user while their search is being processed, before results appear."
2162
+ }
2163
+ });
2164
+
2165
+ // ../renderers/src/SearchRenderer/ErrorResult.tsx
2166
+ import { useIntl as useIntl9 } from "react-intl";
2167
+
2168
+ // ../renderers/src/messages/generic-error.messages.ts
2169
+ import { defineMessages as defineMessages9 } from "react-intl";
2170
+ var generic_error_messages_default = defineMessages9({
2171
+ genericErrorRetryHint: {
2172
+ id: "df.wise.PersistAsyncSchema.genericError",
2173
+ defaultMessage: "Something went wrong, please try again.",
2174
+ description: "Generic error message for persist async schema"
2175
+ },
2176
+ genericError: {
2177
+ id: "df.wise.ErrorBoundary.errorAlert",
2178
+ defaultMessage: "Something went wrong.",
2179
+ description: "Generic error message for when something has gone wrong."
2180
+ },
2181
+ retry: {
2182
+ id: "df.wise.ErrorBoundary.retry",
2183
+ defaultMessage: "Retry",
2184
+ description: "Usually this follows the generic error and contains a link."
2185
+ }
2186
+ });
2187
+
2188
+ // ../renderers/src/SearchRenderer/ErrorResult.tsx
2189
+ import { Link } from "@transferwise/components";
2190
+ import { jsx as jsx53, jsxs as jsxs15 } from "react/jsx-runtime";
2191
+ function ErrorResult({ state }) {
2192
+ const intl = useIntl9();
2193
+ return /* @__PURE__ */ jsxs15("p", { className: "m-t-2", children: [
2194
+ intl.formatMessage(generic_error_messages_default.genericError),
2195
+ "\xA0",
2196
+ /* @__PURE__ */ jsx53(Link, { onClick: () => state.onRetry(), children: intl.formatMessage(generic_error_messages_default.retry) })
2197
+ ] });
2198
+ }
2199
+
2200
+ // ../renderers/src/SearchRenderer/BlockSearchRendererComponent.tsx
2201
+ import { Fragment as Fragment6, jsx as jsx54, jsxs as jsxs16 } from "react/jsx-runtime";
2202
+ function BlockSearchRendererComponent({
2203
+ id,
2204
+ isLoading,
2205
+ margin,
2206
+ query,
2207
+ state,
2208
+ title,
2209
+ trackEvent,
2210
+ onChange
2211
+ }) {
2212
+ const [hasSearched, setHasSearched] = useState9(false);
2213
+ const { formatMessage } = useIntl10();
2214
+ return /* @__PURE__ */ jsxs16("div", { className: getMargin(margin), children: [
2215
+ /* @__PURE__ */ jsx54(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ jsx54(
2216
+ Input4,
2217
+ {
2218
+ id,
2219
+ name: id,
2220
+ type: "text",
2221
+ value: query,
2222
+ className: "m-t-1",
2223
+ onChange: ({ currentTarget: { value } }) => {
2224
+ if (!hasSearched) {
2225
+ setHasSearched(true);
2226
+ trackEvent("Search Started");
2227
+ }
2228
+ onChange(value);
2229
+ }
2230
+ }
2231
+ ) }),
2232
+ isLoading ? /* @__PURE__ */ jsx54(Fragment6, { children: formatMessage(search_messages_default.loading) }) : /* @__PURE__ */ jsx54(SearchResultContent, { state, trackEvent })
2233
+ ] });
2234
+ }
2235
+ function SearchResultContent({
2236
+ state,
2237
+ trackEvent
2238
+ }) {
2239
+ switch (state.type) {
2240
+ case "error":
2241
+ return /* @__PURE__ */ jsx54(ErrorResult, { state });
2242
+ case "results":
2243
+ return /* @__PURE__ */ jsx54(SearchResults, { state, trackEvent });
2244
+ case "noResults":
2245
+ return /* @__PURE__ */ jsx54(EmptySearchResult, { state });
2246
+ case "pending":
2247
+ default:
2248
+ return null;
2249
+ }
2250
+ }
2251
+ function EmptySearchResult({ state }) {
2252
+ return /* @__PURE__ */ jsx54(Markdown4, { className: "m-t-2", config: { link: { target: "_blank" } }, children: state.message });
2253
+ }
2254
+ function SearchResults({
2255
+ state,
2256
+ trackEvent
2257
+ }) {
2258
+ return /* @__PURE__ */ jsx54(NavigationOptionsList2, { children: state.results.map((result) => {
2259
+ const { media } = result;
2260
+ return /* @__PURE__ */ jsx54(
2261
+ NavigationOption3,
2262
+ {
2263
+ title: result.title,
2264
+ content: result.description,
2265
+ media: media ? /* @__PURE__ */ jsx54(OptionMedia, { media, preferAvatar: false }) : void 0,
2266
+ showMediaCircle: false,
2267
+ showMediaAtAllSizes: true,
2268
+ onClick: () => {
2269
+ trackEvent("Search Result Selected", __spreadValues({
2270
+ type: result.type
2271
+ }, result.type === "action" ? { actionId: result.id } : {}));
2272
+ result.onClick();
2273
+ }
2274
+ },
2275
+ JSON.stringify(result)
2276
+ );
2277
+ }) });
2278
+ }
2279
+ var BlockSearchRendererComponent_default = BlockSearchRendererComponent;
2280
+
2281
+ // ../renderers/src/SearchRenderer/InlineSearchRendererComponent.tsx
2282
+ import { Markdown as Markdown5, Typeahead } from "@transferwise/components";
2283
+ import { Search } from "@transferwise/icons";
2284
+ import { useState as useState10 } from "react";
2285
+ import { useIntl as useIntl11 } from "react-intl";
2286
+ import { jsx as jsx55 } from "react/jsx-runtime";
2287
+ function InlineSearchRenderer({
2288
+ id,
2289
+ isLoading,
2290
+ margin,
2291
+ onChange,
2292
+ state,
2293
+ title,
2294
+ trackEvent
2295
+ }) {
2296
+ const [hasSearched, setHasSearched] = useState10(false);
2297
+ const intl = useIntl11();
2298
+ return /* @__PURE__ */ jsx55("div", { className: getMargin(margin), children: /* @__PURE__ */ jsx55(FieldInput_default, { id, description: "", validation: void 0, help: "", label: title, children: /* @__PURE__ */ jsx55(
2299
+ Typeahead,
2300
+ {
2301
+ id: "typeahead-input-id",
2302
+ intl,
2303
+ name: "typeahead-input-name",
2304
+ size: "md",
2305
+ maxHeight: 100,
2306
+ footer: /* @__PURE__ */ jsx55(TypeaheadFooter, { state, isLoading }),
2307
+ multiple: false,
2308
+ clearable: false,
2309
+ addon: /* @__PURE__ */ jsx55(Search, { size: 24 }),
2310
+ options: state.type === "results" ? state.results.map(mapResultToTypeaheadOption) : [],
2311
+ minQueryLength: 1,
2312
+ onChange: (values) => {
2313
+ if (values.length > 0) {
2314
+ const [updatedValue] = values;
2315
+ const { value: result } = updatedValue;
2316
+ if (result) {
2317
+ trackEvent("Search Result Selected", __spreadValues({
2318
+ type: result.type
2319
+ }, result.type === "action" ? { actionId: result.id } : {}));
2320
+ result.onClick();
2321
+ }
2322
+ }
2323
+ },
2324
+ onInputChange: (query) => {
2325
+ if (!hasSearched) {
2326
+ setHasSearched(true);
2327
+ trackEvent("Search Started");
2328
+ }
2329
+ onChange(query);
2330
+ }
2331
+ }
2332
+ ) }) });
2333
+ }
2334
+ function mapResultToTypeaheadOption(result) {
2335
+ return {
2336
+ label: result.title,
2337
+ secondary: result.description,
2338
+ value: result,
2339
+ clearQueryOnSelect: result.type === "action",
2340
+ keepFocusOnSelect: result.type === "search"
2341
+ };
2342
+ }
2343
+ function TypeaheadFooter({ state, isLoading }) {
2344
+ const { formatMessage } = useIntl11();
2345
+ if (state.type === "noResults") {
2346
+ return /* @__PURE__ */ jsx55(Markdown5, { className: "m-t-2 m-x-2", config: { link: { target: "_blank" } }, children: state.message });
2347
+ }
2348
+ if (state.type === "error") {
2349
+ return /* @__PURE__ */ jsx55("div", { className: "m-t-2 m-x-2", children: /* @__PURE__ */ jsx55(ErrorResult, { state }) });
2350
+ }
2351
+ if (state.type === "pending" || isLoading) {
2352
+ return /* @__PURE__ */ jsx55("p", { className: "m-t-2 m-x-2", children: formatMessage(search_messages_default.loading) });
2353
+ }
2354
+ return null;
2355
+ }
2356
+ var InlineSearchRendererComponent_default = InlineSearchRenderer;
2357
+
2358
+ // ../renderers/src/SearchRenderer/SearchRenderer.tsx
2359
+ import { jsx as jsx56 } from "react/jsx-runtime";
2360
+ var SearchRenderer = {
2361
+ canRenderType: "search",
2362
+ render: (props) => props.control === "inline" ? /* @__PURE__ */ jsx56(InlineSearchRendererComponent_default, __spreadValues({}, props)) : /* @__PURE__ */ jsx56(BlockSearchRendererComponent_default, __spreadValues({}, props))
2363
+ };
2364
+ var SearchRenderer_default = SearchRenderer;
2365
+
2366
+ // ../renderers/src/SectionRenderer.tsx
2367
+ import { Header as Header8 } from "@transferwise/components";
2368
+
2369
+ // ../renderers/src/utils/getHeaderAction.tsx
2370
+ var getHeaderAction2 = (callToAction) => {
2371
+ if (!callToAction) {
2372
+ return void 0;
2373
+ }
2374
+ const { accessibilityDescription, href, title, onClick } = callToAction;
2375
+ return href ? {
2376
+ "aria-label": accessibilityDescription,
2377
+ text: title,
2378
+ href,
2379
+ target: "_blank"
2380
+ } : {
2381
+ "aria-label": accessibilityDescription,
2382
+ text: title,
2383
+ onClick: (event) => {
2384
+ event.preventDefault();
2385
+ onClick();
2386
+ }
2387
+ };
2388
+ };
2389
+
2390
+ // ../renderers/src/SectionRenderer.tsx
2391
+ import { jsx as jsx57, jsxs as jsxs17 } from "react/jsx-runtime";
2392
+ var SectionRenderer = {
2393
+ canRenderType: "section",
2394
+ render: ({ children, callToAction, margin, title }) => {
2395
+ return /* @__PURE__ */ jsxs17("section", { className: getMargin(margin), children: [
2396
+ (title || callToAction) && /* @__PURE__ */ jsx57(Header8, { title: title != null ? title : "", action: getHeaderAction2(callToAction) }),
2397
+ children
2398
+ ] });
2399
+ }
2400
+ };
2401
+ var SectionRenderer_default = SectionRenderer;
2402
+
2403
+ // ../renderers/src/SelectInputRenderer/RadioInputRendererComponent.tsx
2404
+ import { RadioGroup } from "@transferwise/components";
2405
+ import { Fragment as Fragment7, jsx as jsx58, jsxs as jsxs18 } from "react/jsx-runtime";
2406
+ function RadioInputRendererComponent(props) {
2407
+ const {
2408
+ id,
2409
+ children,
2410
+ description,
2411
+ disabled,
2412
+ help,
2413
+ title,
2414
+ options,
2415
+ selectedIndex,
2416
+ validationState,
2417
+ onSelect
2418
+ } = props;
2419
+ return /* @__PURE__ */ jsxs18(Fragment7, { children: [
2420
+ /* @__PURE__ */ jsx58(
2421
+ FieldInput_default,
2422
+ {
2423
+ id,
2424
+ label: title,
2425
+ help,
2426
+ description,
2427
+ validation: validationState,
2428
+ children: /* @__PURE__ */ jsx58("span", { children: /* @__PURE__ */ jsx58(
2429
+ RadioGroup,
2430
+ {
2431
+ name: id,
2432
+ radios: options.map((option, index) => ({
2433
+ label: option.title,
2434
+ value: index,
2435
+ secondary: option.description,
2436
+ disabled: option.disabled || disabled,
2437
+ avatar: /* @__PURE__ */ jsx58(OptionMedia, { media: option.media, preferAvatar: false })
2438
+ })),
2439
+ selectedValue: selectedIndex != null ? selectedIndex : void 0,
2440
+ onChange: onSelect
2441
+ },
2442
+ `${id}-${selectedIndex}`
2443
+ ) })
2444
+ }
2445
+ ),
2446
+ children
2447
+ ] });
2448
+ }
2449
+
2450
+ // ../renderers/src/SelectInputRenderer/TabInputRendererComponent.tsx
2451
+ import { Tabs } from "@transferwise/components";
2452
+ import { useEffect as useEffect5 } from "react";
2453
+ import { Fragment as Fragment8, jsx as jsx59, jsxs as jsxs19 } from "react/jsx-runtime";
2454
+ function TabInputRendererComponent(props) {
2455
+ const {
2456
+ id,
2457
+ children,
2458
+ description,
2459
+ disabled,
2460
+ help,
2461
+ title,
2462
+ options,
2463
+ selectedIndex,
2464
+ validationState,
2465
+ onSelect
2466
+ } = props;
2467
+ useEffect5(() => {
2468
+ if (!isValidIndex(selectedIndex, options.length)) {
2469
+ onSelect(0);
2470
+ }
2471
+ }, [selectedIndex, onSelect, options.length]);
2472
+ return /* @__PURE__ */ jsxs19(Fragment8, { children: [
2473
+ /* @__PURE__ */ jsx59(
2474
+ FieldInput_default,
2475
+ {
2476
+ id,
2477
+ label: title,
2478
+ help,
2479
+ description,
2480
+ validation: validationState,
2481
+ children: /* @__PURE__ */ jsx59(
2482
+ Tabs,
2483
+ {
2484
+ name: id,
2485
+ selected: selectedIndex != null ? selectedIndex : 0,
2486
+ tabs: options.map((option) => ({
2487
+ title: option.title,
2488
+ // if we pass null, we get some props-types console errors
2489
+ // eslint-disable-next-line react/jsx-no-useless-fragment
2490
+ content: /* @__PURE__ */ jsx59(Fragment8, {}),
2491
+ disabled: option.disabled || disabled
2492
+ })),
2493
+ onTabSelect: onSelect
2494
+ }
2495
+ )
2496
+ }
2497
+ ),
2498
+ children
2499
+ ] });
2500
+ }
2501
+ var isValidIndex = (index, options) => index !== null && index >= 0 && index < options;
2502
+
2503
+ // ../renderers/src/SelectInputRenderer/SelectInputRendererComponent.tsx
2504
+ import { SelectInput as SelectInput2, SelectInputOptionContent as SelectInputOptionContent2 } from "@transferwise/components";
2505
+ import { Fragment as Fragment9, jsx as jsx60, jsxs as jsxs20 } from "react/jsx-runtime";
2506
+ function SelectInputRendererComponent(props) {
2507
+ const {
2508
+ id,
2509
+ autoComplete,
2510
+ children,
2511
+ description,
2512
+ disabled,
2513
+ help,
2514
+ title,
2515
+ options,
2516
+ placeholder,
2517
+ required,
2518
+ selectedIndex,
2519
+ validationState,
2520
+ onSelect
2521
+ } = props;
2522
+ const items = options.map(
2523
+ (option, index) => {
2524
+ var _a, _b, _c;
2525
+ return {
2526
+ type: "option",
2527
+ value: index,
2528
+ filterMatchers: [...(_a = option.keywords) != null ? _a : [], (_b = option.title) != null ? _b : "", (_c = option.description) != null ? _c : ""],
2529
+ disabled: option.disabled
2530
+ };
2531
+ }
2532
+ );
2533
+ const renderValue = (index, withinTrigger) => {
2534
+ const option = index >= 0 ? options[index] : null;
2535
+ if (option === null) {
2536
+ return null;
2537
+ }
2538
+ const contentProps = withinTrigger ? {
2539
+ title: option.title,
2540
+ note: option.description,
2541
+ icon: getInlineMedia(option.media)
2542
+ } : {
2543
+ title: option.title,
2544
+ description: option.description,
2545
+ icon: /* @__PURE__ */ jsx60(OptionMedia, { media: option.media, preferAvatar: false })
2546
+ };
2547
+ return /* @__PURE__ */ jsx60(SelectInputOptionContent2, __spreadValues({}, contentProps));
2548
+ };
2549
+ const extraProps = { autoComplete };
2550
+ return /* @__PURE__ */ jsxs20(Fragment9, { children: [
2551
+ /* @__PURE__ */ jsx60(
2552
+ FieldInput_default,
2553
+ {
2554
+ id,
2555
+ label: title,
2556
+ help,
2557
+ description,
2558
+ validation: validationState,
2559
+ children: /* @__PURE__ */ jsx60(
2560
+ SelectInput2,
2561
+ __spreadValues({
2562
+ name: id,
2563
+ placeholder,
2564
+ items,
2565
+ disabled,
2566
+ value: selectedIndex,
2567
+ renderValue,
2568
+ filterable: items.length >= 8,
2569
+ onChange: onSelect,
2570
+ onClear: required ? void 0 : () => onSelect(null)
2571
+ }, extraProps)
2572
+ )
2573
+ }
2574
+ ),
2575
+ children
2576
+ ] });
2577
+ }
2578
+
2579
+ // ../renderers/src/SelectInputRenderer/SegmentedInputRendererComponent.tsx
2580
+ import { useEffect as useEffect6 } from "react";
2581
+ import { SegmentedControl } from "@transferwise/components";
2582
+ import { Fragment as Fragment10, jsx as jsx61, jsxs as jsxs21 } from "react/jsx-runtime";
2583
+ function SegmentedInputRendererComponent(props) {
2584
+ const {
2585
+ id,
2586
+ children,
2587
+ description,
2588
+ help,
2589
+ title,
2590
+ options,
2591
+ selectedIndex,
2592
+ validationState,
2593
+ onSelect
2594
+ } = props;
2595
+ useEffect6(() => {
2596
+ if (!isValidIndex2(selectedIndex, options.length)) {
2597
+ onSelect(0);
2598
+ }
2599
+ }, [selectedIndex, onSelect, options.length]);
2600
+ return /* @__PURE__ */ jsxs21(Fragment10, { children: [
2601
+ /* @__PURE__ */ jsx61(
2602
+ FieldInput_default,
2603
+ {
2604
+ id,
2605
+ label: title,
2606
+ help,
2607
+ description,
2608
+ validation: validationState,
2609
+ children: /* @__PURE__ */ jsx61(
2610
+ SegmentedControl,
2611
+ {
2612
+ name: `${id}-segmented-control`,
2613
+ value: String(selectedIndex),
2614
+ mode: "view",
2615
+ segments: options.map((option, index) => ({
2616
+ id: String(index),
2617
+ value: String(index),
2618
+ label: option.title,
2619
+ controls: `${id}-children`
2620
+ })),
2621
+ onChange: (value) => onSelect(Number(value))
2622
+ }
2623
+ )
2624
+ }
2625
+ ),
2626
+ /* @__PURE__ */ jsx61("div", { id: `${id}-children`, children })
2627
+ ] });
2628
+ }
2629
+ var isValidIndex2 = (index, options) => index !== null && index >= 0 && index < options;
2630
+
2631
+ // ../renderers/src/SelectInputRenderer/SelectInputRenderer.tsx
2632
+ import { jsx as jsx62 } from "react/jsx-runtime";
2633
+ var SelectInputRenderer = {
2634
+ canRenderType: "input-select",
2635
+ render: (props) => {
2636
+ switch (props.control) {
2637
+ case "radio":
2638
+ return /* @__PURE__ */ jsx62(RadioInputRendererComponent, __spreadValues({}, props));
2639
+ case "tab":
2640
+ return props.options.length > 3 ? /* @__PURE__ */ jsx62(SelectInputRendererComponent, __spreadValues({}, props)) : /* @__PURE__ */ jsx62(TabInputRendererComponent, __spreadValues({}, props));
2641
+ case "segmented":
2642
+ return props.options.length > 3 ? /* @__PURE__ */ jsx62(SelectInputRendererComponent, __spreadValues({}, props)) : /* @__PURE__ */ jsx62(SegmentedInputRendererComponent, __spreadValues({}, props));
2643
+ case "select":
2644
+ default:
2645
+ return /* @__PURE__ */ jsx62(SelectInputRendererComponent, __spreadValues({}, props));
2646
+ }
2647
+ }
2648
+ };
2649
+ var SelectInputRenderer_default = SelectInputRenderer;
2650
+
2651
+ // ../renderers/src/StatusListRenderer.tsx
2652
+ import { Header as Header9, Summary } from "@transferwise/components";
2653
+ import { jsx as jsx63, jsxs as jsxs22 } from "react/jsx-runtime";
2654
+ var StatusListRenderer = {
2655
+ canRenderType: "status-list",
2656
+ render: ({ margin, items, title }) => /* @__PURE__ */ jsxs22("div", { className: getMargin(margin), children: [
2657
+ title ? /* @__PURE__ */ jsx63(Header9, { title, className: "m-b-2" }) : null,
2658
+ items.map(({ callToAction, description, icon, status, title: itemTitle }) => /* @__PURE__ */ jsx63(
2659
+ Summary,
2660
+ {
2661
+ title: itemTitle,
2662
+ description,
2663
+ icon: icon && "name" in icon ? /* @__PURE__ */ jsx63(DynamicIcon_default, { name: icon.name }) : null,
2664
+ status: mapStatus(status),
2665
+ action: getSummaryAction(callToAction)
2666
+ },
2667
+ `${itemTitle}/${description || ""}`
2668
+ ))
2669
+ ] })
2670
+ };
2671
+ var StatusListRenderer_default = StatusListRenderer;
2672
+ var getSummaryAction = (callToAction) => {
2673
+ if (!callToAction) {
2674
+ return void 0;
2675
+ }
2676
+ const { accessibilityDescription, href, title, onClick } = callToAction;
2677
+ if (!href) {
2678
+ return {
2679
+ "aria-label": accessibilityDescription,
2680
+ text: title,
2681
+ onClick
2682
+ };
2683
+ }
2684
+ return {
2685
+ "aria-label": accessibilityDescription,
2686
+ href,
2687
+ target: "_blank",
2688
+ text: title
2689
+ };
2690
+ };
2691
+ var mapStatus = (status) => {
2692
+ if (status === "not-done") {
2693
+ return "notDone";
2694
+ }
2695
+ return status;
2696
+ };
2697
+
2698
+ // ../renderers/src/utils/useCustomTheme.ts
2699
+ import { useTheme } from "@wise/components-theming";
2700
+ import { useEffect as useEffect7, useMemo } from "react";
2701
+ var ThemeRequiredEventName = "Theme Required";
2702
+ var useCustomTheme = (theme, trackEvent) => {
2703
+ const previousThemeHookValue = useTheme();
2704
+ const previousTheme = useMemo(() => previousThemeHookValue.theme, []);
2705
+ useEffect7(() => {
2706
+ trackEvent(ThemeRequiredEventName, { theme });
2707
+ return theme !== previousTheme ? () => {
2708
+ trackEvent(ThemeRequiredEventName, { theme: previousTheme });
2709
+ } : () => {
2710
+ };
2711
+ }, []);
2712
+ };
2713
+
2714
+ // ../renderers/src/step/topbar/BackButton.tsx
2715
+ import { IconButton } from "@transferwise/components";
2716
+ import { ArrowLeft } from "@transferwise/icons";
2717
+ import { jsx as jsx64, jsxs as jsxs23 } from "react/jsx-runtime";
2718
+ function BackButton({ title, onClick }) {
2719
+ return /* @__PURE__ */ jsxs23(IconButton, { priority: "tertiary", onClick, children: [
2720
+ /* @__PURE__ */ jsx64("span", { className: "sr-only", children: title }),
2721
+ /* @__PURE__ */ jsx64(ArrowLeft, {})
2722
+ ] });
2723
+ }
2724
+
2725
+ // ../renderers/src/step/topbar/Toolbar.tsx
2726
+ import { Button as Button7, IconButton as IconButton2 } from "@transferwise/components";
2727
+ import { jsx as jsx65, jsxs as jsxs24 } from "react/jsx-runtime";
2728
+ var Toolbar = ({ items }) => {
2729
+ return (items == null ? void 0 : items.length) > 0 ? /* @__PURE__ */ jsx65("div", { className: "df-toolbar", children: items.map((item, index) => /* @__PURE__ */ jsx65(ToolbarButton, __spreadValues({}, item), `${item.type}-${index}-${item.title}`)) }) : null;
2730
+ };
2731
+ function ToolbarButton(props) {
2732
+ return prefersMedia(props.control) ? /* @__PURE__ */ jsx65(MediaToolbarButton, __spreadValues({}, props)) : /* @__PURE__ */ jsx65(TextToolbarButton, __spreadValues({}, props));
2733
+ }
2734
+ function MediaToolbarButton(props) {
2735
+ var _a;
2736
+ const { context, control, media, accessibilityDescription, disabled, onClick } = props;
2737
+ const priority = getIconButtonPriority(control);
2738
+ const type = getSentiment(context);
2739
+ return /* @__PURE__ */ jsxs24(
2740
+ IconButton2,
2741
+ {
2742
+ className: "df-toolbar-button",
2743
+ disabled,
2744
+ priority,
2745
+ size: 32,
2746
+ type,
2747
+ onClick,
2748
+ children: [
2749
+ accessibilityDescription ? /* @__PURE__ */ jsx65("span", { className: "sr-only", children: accessibilityDescription }) : null,
2750
+ media ? (_a = getAddonStart(media)) == null ? void 0 : _a.value : null
2751
+ ]
2752
+ }
2753
+ );
2754
+ }
2755
+ function TextToolbarButton(props) {
2756
+ const { context, control, title, media, disabled, onClick } = props;
2757
+ const addonStart = media ? getAddonStart(media) : void 0;
2758
+ const priority = getPriority2(control);
2759
+ const sentiment = getSentiment(context);
2760
+ return /* @__PURE__ */ jsx65(
2761
+ Button7,
2762
+ {
2763
+ v2: true,
2764
+ size: "sm",
2765
+ className: "df-toolbar-button",
2766
+ disabled,
2767
+ priority,
2768
+ addonStart,
2769
+ sentiment,
2770
+ onClick,
2771
+ children: title
2772
+ }
2773
+ );
2774
+ }
2775
+ var getAddonStart = (media) => {
2776
+ if (media.type === "avatar") {
2777
+ if (media.content.length > 0 && media.content[0].type === "uri" && isValidIconUrn(media.content[0].uri)) {
2778
+ return {
2779
+ type: "icon",
2780
+ value: getInlineMedia({
2781
+ type: "image",
2782
+ uri: media.content[0].uri
2783
+ })
2784
+ };
2785
+ }
2786
+ return void 0;
2787
+ }
2788
+ return { type: "icon", value: getInlineMedia(media) };
2789
+ };
2790
+ var getPriority2 = (control) => isKnownControl(control) ? control : "secondary";
2791
+ var prefersMedia = (control) => {
2792
+ return false;
2793
+ };
2794
+ var knownControls = ["primary", "secondary", "secondary-neutral"];
2795
+ var isKnownControl = (control) => control !== void 0 && knownControls.includes(control);
2796
+ var getSentiment = (context) => {
2797
+ return "default";
2798
+ };
2799
+ var getIconButtonPriority = (control) => {
2800
+ const priority = getPriority2(control);
2801
+ return priority === "secondary-neutral" ? "tertiary" : priority;
2802
+ };
2803
+
2804
+ // ../renderers/src/step/topbar/TopBar.tsx
2805
+ import { jsx as jsx66, jsxs as jsxs25 } from "react/jsx-runtime";
2806
+ function TopBar({ back, toolbar }) {
2807
+ return back || toolbar ? /* @__PURE__ */ jsxs25("div", { className: "d-flex m-b-2", children: [
2808
+ back ? /* @__PURE__ */ jsx66(BackButton, __spreadValues({}, back)) : null,
2809
+ toolbar ? /* @__PURE__ */ jsx66(Toolbar, __spreadValues({}, toolbar)) : null
2810
+ ] }) : null;
2811
+ }
2812
+
2813
+ // ../renderers/src/step/SplashCelebrationStepRenderer.tsx
2814
+ import { jsx as jsx67, jsxs as jsxs26 } from "react/jsx-runtime";
2815
+ var SplashCelebrationStepRenderer = {
2816
+ canRenderType: "step",
2817
+ canRender: ({ control }) => control === "splash-celebration",
2818
+ render: SplashCelebrationStepRendererComponent
2819
+ };
2820
+ function SplashCelebrationStepRendererComponent(props) {
2821
+ const { back, toolbar, children, trackEvent } = props;
2822
+ useCustomTheme("forest-green", trackEvent);
2823
+ return /* @__PURE__ */ jsxs26("div", { className: "splash-screen m-t-5", children: [
2824
+ /* @__PURE__ */ jsx67(TopBar, { back, toolbar }),
2825
+ children
2826
+ ] });
2827
+ }
2828
+
2829
+ // ../renderers/src/step/SplashStepRenderer.tsx
2830
+ import { jsx as jsx68, jsxs as jsxs27 } from "react/jsx-runtime";
2831
+ var SplashStepRenderer = {
2832
+ canRenderType: "step",
2833
+ canRender: ({ control }) => control === "splash",
2834
+ render: SplashStepRendererComponent
2835
+ };
2836
+ function SplashStepRendererComponent(props) {
2837
+ const { back, toolbar, children } = props;
2838
+ return /* @__PURE__ */ jsxs27("div", { className: "splash-screen m-t-5", children: [
2839
+ /* @__PURE__ */ jsx68(TopBar, { back, toolbar }),
2840
+ children
2841
+ ] });
2842
+ }
2843
+
2844
+ // ../renderers/src/step/StepRenderer.tsx
2845
+ import { Alert as Alert2, Title as Title2 } from "@transferwise/components";
2846
+ import { Fragment as Fragment11, jsx as jsx69, jsxs as jsxs28 } from "react/jsx-runtime";
2847
+ var StepRenderer = {
2848
+ canRenderType: "step",
2849
+ render: StepRendererComponent
2850
+ };
2851
+ function StepRendererComponent(props) {
2852
+ const { back, description, error, title, children, toolbar } = props;
2853
+ return /* @__PURE__ */ jsxs28(Fragment11, { children: [
2854
+ /* @__PURE__ */ jsx69(TopBar, { back, toolbar }),
2855
+ title || description ? /* @__PURE__ */ jsxs28("div", { className: "m-b-4", children: [
2856
+ title ? /* @__PURE__ */ jsx69(Title2, { as: "h1", type: "title-section", className: "text-xs-center m-b-2", children: title }) : void 0,
2857
+ description ? /* @__PURE__ */ jsx69("p", { className: "text-xs-center np-text-body-large", children: description }) : void 0
2858
+ ] }) : void 0,
2859
+ error ? /* @__PURE__ */ jsx69(Alert2, { type: "negative", className: "m-b-2", message: error }) : void 0,
2860
+ children
2861
+ ] });
2862
+ }
2863
+
2864
+ // ../renderers/src/TabsRenderer.tsx
2865
+ import { Chips, SegmentedControl as SegmentedControl2, Tabs as Tabs2 } from "@transferwise/components";
2866
+ import { useState as useState11 } from "react";
2867
+ import { jsx as jsx70, jsxs as jsxs29 } from "react/jsx-runtime";
2868
+ var TabsRenderer = {
2869
+ canRenderType: "tabs",
2870
+ render: (props) => {
2871
+ switch (props.control) {
2872
+ case "segmented":
2873
+ if (props.tabs.length > 3) {
2874
+ return /* @__PURE__ */ jsx70(TabsRendererComponent, __spreadValues({}, props));
2875
+ }
2876
+ return /* @__PURE__ */ jsx70(SegmentedTabsRendererComponent, __spreadValues({}, props));
2877
+ case "chips":
2878
+ return /* @__PURE__ */ jsx70(ChipsTabsRendererComponent, __spreadValues({}, props));
2879
+ default:
2880
+ return /* @__PURE__ */ jsx70(TabsRendererComponent, __spreadValues({}, props));
2881
+ }
2882
+ }
2883
+ };
2884
+ function TabsRendererComponent({ uid, margin, tabs }) {
2885
+ const [selectedIndex, setSelectedIndex] = useState11(0);
2886
+ return /* @__PURE__ */ jsx70("div", { className: getMargin(margin), children: /* @__PURE__ */ jsx70(
2887
+ Tabs2,
2888
+ {
2889
+ name: uid,
2890
+ selected: selectedIndex != null ? selectedIndex : 0,
2891
+ tabs: tabs.map((option) => ({
2892
+ title: option.title,
2893
+ disabled: false,
2894
+ content: /* @__PURE__ */ jsxs29("div", { className: "m-t-2", children: [
2895
+ " ",
2896
+ option.children,
2897
+ " "
2898
+ ] })
2899
+ })),
2900
+ onTabSelect: setSelectedIndex
2901
+ }
2902
+ ) });
2903
+ }
2904
+ function SegmentedTabsRendererComponent({ uid, margin, tabs }) {
2905
+ var _a;
2906
+ const [selectedIndex, setSelectedIndex] = useState11(0);
2907
+ return /* @__PURE__ */ jsxs29("div", { className: getMargin(margin), children: [
2908
+ /* @__PURE__ */ jsx70(
2909
+ SegmentedControl2,
2910
+ {
2911
+ name: uid,
2912
+ value: String(selectedIndex),
2913
+ mode: "view",
2914
+ segments: tabs.map((tab, index) => ({
2915
+ id: String(index),
2916
+ value: String(index),
2917
+ label: tab.title,
2918
+ controls: `${uid}-children`
2919
+ })),
2920
+ onChange: (value) => setSelectedIndex(Number(value))
2921
+ }
2922
+ ),
2923
+ /* @__PURE__ */ jsx70("div", { id: `${uid}-children`, className: "m-t-2", children: (_a = tabs[selectedIndex]) == null ? void 0 : _a.children })
2924
+ ] });
2925
+ }
2926
+ function ChipsTabsRendererComponent({ margin, tabs }) {
2927
+ var _a;
2928
+ const [selectedIndex, setSelectedIndex] = useState11(0);
2929
+ return /* @__PURE__ */ jsxs29("div", { className: getMargin(margin), children: [
2930
+ /* @__PURE__ */ jsx70("div", { className: "chips-container", children: /* @__PURE__ */ jsx70(
2931
+ Chips,
2932
+ {
2933
+ chips: tabs.map((tab, index) => ({ label: tab.title, value: index })),
2934
+ selected: selectedIndex,
2935
+ onChange: ({ selectedValue }) => setSelectedIndex(Number(selectedValue))
2936
+ }
2937
+ ) }),
2938
+ /* @__PURE__ */ jsx70("div", { className: "m-t-2", children: (_a = tabs[selectedIndex]) == null ? void 0 : _a.children })
2939
+ ] });
2940
+ }
2941
+
2942
+ // ../renderers/src/TextInputRenderer.tsx
2943
+ import { InputGroup as InputGroup3 } from "@transferwise/components";
2944
+
2945
+ // ../renderers/src/components/VariableTextInput.tsx
24
2946
  import {
25
- Header,
26
- getMargin,
27
- getListItemRenderers,
28
- getButtonV2Renderers
29
- } from "@wise/dynamic-flow-renderers";
2947
+ Input as Input5,
2948
+ InputWithDisplayFormat,
2949
+ PhoneNumberInput,
2950
+ TextArea,
2951
+ TextareaWithDisplayFormat
2952
+ } from "@transferwise/components";
2953
+ import { jsx as jsx71 } from "react/jsx-runtime";
2954
+ var commonKeys = [
2955
+ "autoComplete",
2956
+ "autoCapitalize",
2957
+ "placeholder",
2958
+ "control",
2959
+ "disabled",
2960
+ "displayFormat",
2961
+ "id",
2962
+ "onBlur",
2963
+ "onFocus",
2964
+ "placeholder",
2965
+ "value"
2966
+ ];
2967
+ function VariableTextInput(inputProps) {
2968
+ const { id, value, control, onChange } = inputProps;
2969
+ const commonProps = __spreadProps(__spreadValues({}, pick(inputProps, ...commonKeys)), { name: id });
2970
+ switch (control) {
2971
+ case "email":
2972
+ return /* @__PURE__ */ jsx71(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "email", onChange }));
2973
+ case "password":
2974
+ return /* @__PURE__ */ jsx71(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "password", onChange }));
2975
+ case "numeric": {
2976
+ const numericProps = __spreadProps(__spreadValues({}, commonProps), { type: "number", onWheel });
2977
+ return /* @__PURE__ */ jsx71(
2978
+ TextInput,
2979
+ __spreadProps(__spreadValues({}, numericProps), {
2980
+ onChange: (newValue) => {
2981
+ const numericValueOrNull = !Number.isNaN(Number.parseFloat(newValue)) ? newValue : null;
2982
+ onChange(numericValueOrNull);
2983
+ }
2984
+ })
2985
+ );
2986
+ }
2987
+ case "phone-number":
2988
+ return /* @__PURE__ */ jsx71(PhoneNumberInput, __spreadProps(__spreadValues({ initialValue: value }, commonProps), { onChange }));
2989
+ default: {
2990
+ return /* @__PURE__ */ jsx71(TextInput, __spreadProps(__spreadValues({}, commonProps), { type: "text", onChange }));
2991
+ }
2992
+ }
2993
+ }
2994
+ function TextInput(props) {
2995
+ const _a = props, { control, displayFormat, onChange } = _a, commonProps = __objRest(_a, ["control", "displayFormat", "onChange"]);
2996
+ const InputWithPattern = control === "textarea" ? TextareaWithDisplayFormat : InputWithDisplayFormat;
2997
+ const InputWithoutPattern = control === "textarea" ? TextArea : Input5;
2998
+ return displayFormat ? /* @__PURE__ */ jsx71(InputWithPattern, __spreadProps(__spreadValues({ displayPattern: displayFormat }, commonProps), { onChange })) : /* @__PURE__ */ jsx71(InputWithoutPattern, __spreadProps(__spreadValues({}, commonProps), { onChange: (e) => onChange(e.target.value) }));
2999
+ }
3000
+
3001
+ // ../renderers/src/TextInputRenderer.tsx
3002
+ import { jsx as jsx72 } from "react/jsx-runtime";
3003
+ var TextInputRenderer = {
3004
+ canRenderType: "input-text",
3005
+ render: (props) => {
3006
+ const _a = props, {
3007
+ id,
3008
+ title,
3009
+ description,
3010
+ help,
3011
+ media,
3012
+ validationState,
3013
+ value: initialValue,
3014
+ onChange
3015
+ } = _a, rest = __objRest(_a, [
3016
+ "id",
3017
+ "title",
3018
+ "description",
3019
+ "help",
3020
+ "media",
3021
+ "validationState",
3022
+ "value",
3023
+ "onChange"
3024
+ ]);
3025
+ const value = initialValue != null ? initialValue : "";
3026
+ const inputProps = __spreadProps(__spreadValues({}, rest), {
3027
+ value,
3028
+ id,
3029
+ onChange: (newValue) => {
3030
+ if ((value != null ? value : "") !== (newValue != null ? newValue : "")) {
3031
+ onChange(newValue);
3032
+ }
3033
+ }
3034
+ });
3035
+ return /* @__PURE__ */ jsx72(
3036
+ FieldInput_default,
3037
+ {
3038
+ id,
3039
+ label: title,
3040
+ description,
3041
+ validation: validationState,
3042
+ help,
3043
+ children: /* @__PURE__ */ jsx72(InputGroup3, { addonStart: getInputGroupAddonStart(media), children: /* @__PURE__ */ jsx72(VariableTextInput, __spreadValues({}, inputProps)) })
3044
+ }
3045
+ );
3046
+ }
3047
+ };
3048
+ var TextInputRenderer_default = TextInputRenderer;
3049
+
3050
+ // ../renderers/src/UploadInputRenderer.tsx
3051
+ import { Upload, UploadInput as UploadInput2 } from "@transferwise/components";
3052
+
3053
+ // ../renderers/src/utils/getRandomId.ts
3054
+ var getRandomId = () => Math.random().toString(36).substring(2);
3055
+
3056
+ // ../renderers/src/UploadInputRenderer.tsx
3057
+ import { jsx as jsx73 } from "react/jsx-runtime";
3058
+ var UploadInputRenderer = {
3059
+ canRenderType: "input-upload",
3060
+ render: (props) => {
3061
+ const { id, accepts, title, description, disabled, maxSize, validationState, onUpload } = props;
3062
+ const onUploadFile = async (formData) => {
3063
+ const file = formData.get("file");
3064
+ return onUpload(file).then(() => ({
3065
+ id: getRandomId()
3066
+ }));
3067
+ };
3068
+ const onDeleteFile = async () => {
3069
+ await onUpload(null);
3070
+ };
3071
+ return (
3072
+ // We don't pass help here as there is no sensible place to display it
3073
+ /* @__PURE__ */ jsx73(
3074
+ UploadFieldInput_default,
3075
+ {
3076
+ id,
3077
+ label: void 0,
3078
+ description: void 0,
3079
+ validation: validationState,
3080
+ children: /* @__PURE__ */ jsx73(
3081
+ UploadInput2,
3082
+ {
3083
+ id,
3084
+ description,
3085
+ disabled,
3086
+ sizeLimit: getSizeLimit(maxSize),
3087
+ fileTypes: acceptsToFileTypes(accepts),
3088
+ uploadButtonTitle: title,
3089
+ onDeleteFile,
3090
+ onUploadFile
3091
+ }
3092
+ )
3093
+ }
3094
+ )
3095
+ );
3096
+ }
3097
+ };
3098
+ var LargeUploadRenderer = {
3099
+ canRenderType: "input-upload",
3100
+ canRender: (props) => props.control === "upload-large",
3101
+ render: (props) => {
3102
+ const _a = props, {
3103
+ id,
3104
+ accepts,
3105
+ control,
3106
+ title,
3107
+ description,
3108
+ disabled,
3109
+ help,
3110
+ type,
3111
+ validationState,
3112
+ maxSize = null,
3113
+ onUpload
3114
+ } = _a, rest = __objRest(_a, [
3115
+ "id",
3116
+ "accepts",
3117
+ "control",
3118
+ "title",
3119
+ "description",
3120
+ "disabled",
3121
+ "help",
3122
+ "type",
3123
+ "validationState",
3124
+ "maxSize",
3125
+ "onUpload"
3126
+ ]);
3127
+ const uploadProps = __spreadProps(__spreadValues({}, rest), { id, name: id, maxSize });
3128
+ const onUploadFile = async (file, fileName) => {
3129
+ try {
3130
+ const convertedFile = file ? await toFile(file, fileName) : null;
3131
+ await onUpload(convertedFile);
3132
+ } catch (e) {
3133
+ await onUpload(null);
3134
+ throw e;
3135
+ }
3136
+ };
3137
+ const filetypes = acceptsToFileTypes(accepts);
3138
+ const usAccept = filetypes === "*" ? "*" : filetypes.join(",");
3139
+ return /* @__PURE__ */ jsx73(
3140
+ FieldInput_default,
3141
+ {
3142
+ id,
3143
+ label: title,
3144
+ description,
3145
+ validation: validationState,
3146
+ help,
3147
+ children: /* @__PURE__ */ jsx73(
3148
+ Upload,
3149
+ __spreadProps(__spreadValues({}, uploadProps), {
3150
+ usAccept,
3151
+ usDisabled: disabled,
3152
+ onSuccess: onUploadFile,
3153
+ onFailure: async () => onUpload(null),
3154
+ onCancel: async () => onUpload(null)
3155
+ })
3156
+ )
3157
+ }
3158
+ );
3159
+ }
3160
+ };
3161
+
3162
+ // ../renderers/src/NewListItem/NewDecisionRenderer.tsx
3163
+ import { ListItem as ListItem4 } from "@transferwise/components";
3164
+
3165
+ // ../renderers/src/NewListItem/getInlineAlert.tsx
3166
+ import { ListItem as ListItem2 } from "@transferwise/components";
3167
+ import { jsx as jsx74 } from "react/jsx-runtime";
3168
+ var getInlineAlert = (inlineAlert) => inlineAlert ? /* @__PURE__ */ jsx74(ListItem2.Prompt, { sentiment: inlineAlert == null ? void 0 : inlineAlert.context, children: inlineAlert.content }) : void 0;
3169
+
3170
+ // ../renderers/src/NewListItem/getAdditionalInfo.tsx
3171
+ import { ListItem as ListItem3 } from "@transferwise/components";
3172
+ import { jsx as jsx75 } from "react/jsx-runtime";
3173
+ var getAdditionalInfo = (additionalInfo) => {
3174
+ if (!additionalInfo) {
3175
+ return void 0;
3176
+ }
3177
+ const { href, text, onClick } = additionalInfo;
3178
+ if (href || onClick) {
3179
+ return /* @__PURE__ */ jsx75(
3180
+ ListItem3.AdditionalInfo,
3181
+ {
3182
+ action: {
3183
+ label: text,
3184
+ href,
3185
+ onClick,
3186
+ target: "_blank"
3187
+ }
3188
+ }
3189
+ );
3190
+ }
3191
+ return /* @__PURE__ */ jsx75(ListItem3.AdditionalInfo, { children: additionalInfo == null ? void 0 : additionalInfo.text });
3192
+ };
3193
+
3194
+ // ../renderers/src/NewListItem/NewDecisionRenderer.tsx
3195
+ import { Fragment as Fragment12, jsx as jsx76 } from "react/jsx-runtime";
3196
+ var DecisionRenderer2 = {
3197
+ canRenderType: "decision",
3198
+ render: (props) => /* @__PURE__ */ jsx76(DecisionWrapper, __spreadProps(__spreadValues({}, props), { renderDecisionList: renderDecisionList2 }))
3199
+ };
3200
+ var renderDecisionList2 = ({ options, control }) => {
3201
+ return /* @__PURE__ */ jsx76(Fragment12, { children: options.map((option) => {
3202
+ const {
3203
+ description,
3204
+ disabled,
3205
+ media,
3206
+ title: itemTitle,
3207
+ tag,
3208
+ href,
3209
+ additionalText,
3210
+ inlineAlert,
3211
+ supportingValues,
3212
+ onClick
3213
+ } = option;
3214
+ return /* @__PURE__ */ jsx76(
3215
+ ListItem4,
3216
+ {
3217
+ title: itemTitle,
3218
+ subtitle: description,
3219
+ spotlight: control === "spotlight" ? tag === "spotlight-active" ? "active" : "inactive" : void 0,
3220
+ disabled,
3221
+ valueTitle: supportingValues == null ? void 0 : supportingValues.value,
3222
+ valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
3223
+ media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
3224
+ prompt: getInlineAlert(inlineAlert),
3225
+ additionalInfo: additionalText ? getAdditionalInfo({ text: additionalText }) : void 0,
3226
+ control: href ? /* @__PURE__ */ jsx76(ListItem4.Navigation, { href, target: "_blank" }) : /* @__PURE__ */ jsx76(ListItem4.Navigation, { onClick })
3227
+ },
3228
+ JSON.stringify(option)
3229
+ );
3230
+ }) });
3231
+ };
3232
+ var NewDecisionRenderer_default = DecisionRenderer2;
3233
+
3234
+ // ../renderers/src/NewListItem/NewListRenderer.tsx
3235
+ import { ListItem as ListItem5 } from "@transferwise/components";
3236
+ import { jsx as jsx77, jsxs as jsxs30 } from "react/jsx-runtime";
3237
+ var ListRenderer2 = {
3238
+ canRenderType: "list",
3239
+ render: ({ callToAction, control, margin, items, title }) => /* @__PURE__ */ jsxs30("div", { className: getMargin(margin), children: [
3240
+ /* @__PURE__ */ jsx77(Header7, { title, callToAction }),
3241
+ items.map((item) => {
3242
+ const {
3243
+ title: itemTitle,
3244
+ description,
3245
+ supportingValues,
3246
+ media,
3247
+ tag,
3248
+ additionalInfo,
3249
+ inlineAlert
3250
+ } = item;
3251
+ return /* @__PURE__ */ jsx77(
3252
+ ListItem5,
3253
+ {
3254
+ title: itemTitle,
3255
+ subtitle: description,
3256
+ valueTitle: supportingValues == null ? void 0 : supportingValues.value,
3257
+ valueSubtitle: supportingValues == null ? void 0 : supportingValues.subvalue,
3258
+ media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
3259
+ prompt: getInlineAlert(inlineAlert),
3260
+ additionalInfo: getAdditionalInfo(additionalInfo)
3261
+ },
3262
+ itemTitle
3263
+ );
3264
+ })
3265
+ ] })
3266
+ };
3267
+ var NewListRenderer_default = ListRenderer2;
3268
+
3269
+ // ../renderers/src/NewListItem/NewReviewRenderer.tsx
3270
+ import { ListItem as ListItem6, Popover } from "@transferwise/components";
3271
+ import { QuestionMarkCircle } from "@transferwise/icons";
3272
+ import { jsx as jsx78, jsxs as jsxs31 } from "react/jsx-runtime";
3273
+ var IGNORED_CONTROLS = [
3274
+ "horizontal",
3275
+ "horizontal-end-aligned",
3276
+ "horizontal-start-aligned",
3277
+ "vertical-two-column"
3278
+ ];
3279
+ var ReviewRenderer2 = {
3280
+ canRenderType: "review",
3281
+ canRender: ({ control }) => control ? !IGNORED_CONTROLS.includes(control) : true,
3282
+ render: ({ callToAction, control, margin, fields, title }) => /* @__PURE__ */ jsxs31("div", { className: getMargin(margin), children: [
3283
+ /* @__PURE__ */ jsx78(Header7, { title, callToAction }),
3284
+ fields.map((field) => {
3285
+ var _a;
3286
+ const {
3287
+ label,
3288
+ value,
3289
+ media,
3290
+ tag,
3291
+ additionalInfo,
3292
+ inlineAlert,
3293
+ help,
3294
+ callToAction: itemCallToAction
3295
+ } = field;
3296
+ return /* @__PURE__ */ jsx78(
3297
+ ListItem6,
3298
+ {
3299
+ title: value,
3300
+ subtitle: label,
3301
+ inverted: true,
3302
+ media: getMedia(media, control === "with-avatar" || tag === "with-avatar"),
3303
+ control: (_a = getCTAControl(itemCallToAction)) != null ? _a : getHelpControl(help),
3304
+ prompt: getInlineAlert(inlineAlert),
3305
+ additionalInfo: getAdditionalInfo(additionalInfo)
3306
+ },
3307
+ JSON.stringify(field)
3308
+ );
3309
+ })
3310
+ ] })
3311
+ };
3312
+ var getCTAControl = (callToAction) => {
3313
+ if (!callToAction) {
3314
+ return void 0;
3315
+ }
3316
+ const { accessibilityDescription, href, title, onClick } = callToAction;
3317
+ if (href) {
3318
+ return /* @__PURE__ */ jsx78(ListItem6.Button, { href, partiallyInteractive: true, "aria-description": accessibilityDescription, children: title });
3319
+ }
3320
+ return /* @__PURE__ */ jsx78(
3321
+ ListItem6.Button,
3322
+ {
3323
+ "aria-description": accessibilityDescription,
3324
+ partiallyInteractive: true,
3325
+ onClick,
3326
+ children: title
3327
+ }
3328
+ );
3329
+ };
3330
+ var getHelpControl = (help) => {
3331
+ if (!help) {
3332
+ return void 0;
3333
+ }
3334
+ return /* @__PURE__ */ jsx78(Popover, { content: help, children: /* @__PURE__ */ jsx78(ListItem6.IconButton, { partiallyInteractive: true, children: /* @__PURE__ */ jsx78(QuestionMarkCircle, {}) }) });
3335
+ };
3336
+ var NewReviewRenderer_default = ReviewRenderer2;
3337
+
3338
+ // ../renderers/src/NewListItem/NewStatusListRenderer.tsx
3339
+ import { AvatarView as AvatarView4, Header as Header10, ListItem as ListItem7 } from "@transferwise/components";
3340
+ import { jsx as jsx79, jsxs as jsxs32 } from "react/jsx-runtime";
3341
+ var NewStatusListRenderer = {
3342
+ canRenderType: "status-list",
3343
+ render: ({ margin, items, title }) => /* @__PURE__ */ jsxs32("div", { className: getMargin(margin), children: [
3344
+ title ? /* @__PURE__ */ jsx79(Header10, { title, className: "m-b-2" }) : null,
3345
+ items.map((item) => {
3346
+ const { callToAction, description, icon, status, title: itemTitle } = item;
3347
+ return /* @__PURE__ */ jsx79(
3348
+ ListItem7,
3349
+ {
3350
+ title: itemTitle,
3351
+ subtitle: description,
3352
+ media: icon && "name" in icon ? /* @__PURE__ */ jsx79(AvatarView4, { badge: { status: mapStatus2(status) }, children: /* @__PURE__ */ jsx79(DynamicIcon_default, { name: icon.name }) }) : void 0,
3353
+ additionalInfo: callToAction ? /* @__PURE__ */ jsx79(
3354
+ ListItem7.AdditionalInfo,
3355
+ {
3356
+ action: {
3357
+ href: callToAction.href,
3358
+ onClick: callToAction.href ? void 0 : callToAction.onClick,
3359
+ label: callToAction.title,
3360
+ target: "_blank"
3361
+ }
3362
+ }
3363
+ ) : void 0
3364
+ },
3365
+ JSON.stringify(item)
3366
+ );
3367
+ })
3368
+ ] })
3369
+ };
3370
+ var mapStatus2 = (status) => {
3371
+ switch (status) {
3372
+ case "done":
3373
+ return "positive";
3374
+ case "pending":
3375
+ return "pending";
3376
+ default:
3377
+ return void 0;
3378
+ }
3379
+ };
3380
+ var NewStatusListRenderer_default = NewStatusListRenderer;
3381
+
3382
+ // ../renderers/src/ButtonRenderer/ButtonRendererV2.tsx
3383
+ import { Button as Button8 } from "@transferwise/components";
3384
+
3385
+ // ../renderers/src/utils/isButtonPriority.ts
3386
+ var validPriorities = ["primary", "secondary", "secondary-neutral", "tertiary"];
3387
+ var isButtonPriority = (control) => validPriorities.includes(control);
3388
+
3389
+ // ../renderers/src/ButtonRenderer/ButtonRendererV2.tsx
3390
+ import { useEffect as useEffect8, useState as useState12 } from "react";
3391
+ import { jsx as jsx80 } from "react/jsx-runtime";
3392
+ var ButtonRendererV2 = {
3393
+ canRenderType: "button",
3394
+ render: ButtonComponent2
3395
+ };
3396
+ function ButtonComponent2(props) {
3397
+ const { control, context, disabled, margin, title, size, stepLoadingState, onClick } = props;
3398
+ const [spinny, setSpinny] = useState12(false);
3399
+ useEffect8(() => {
3400
+ if (stepLoadingState === "idle") {
3401
+ setSpinny(false);
3402
+ }
3403
+ }, [stepLoadingState]);
3404
+ const loading = spinny && stepLoadingState !== "idle";
3405
+ return /* @__PURE__ */ jsx80(
3406
+ Button8,
3407
+ {
3408
+ v2: true,
3409
+ block: true,
3410
+ className: getMargin(margin),
3411
+ disabled,
3412
+ priority: getPriority3(control),
3413
+ loading,
3414
+ size: mapButtonSize(size),
3415
+ sentiment: getSentiment2(context),
3416
+ onClick: () => {
3417
+ setSpinny(true);
3418
+ onClick();
3419
+ },
3420
+ children: title
3421
+ }
3422
+ );
3423
+ }
3424
+ var getSentiment2 = (context) => context === "negative" ? "negative" : "default";
3425
+ var getPriority3 = (control) => control && isButtonPriority(control) ? control : "secondary";
3426
+
3427
+ // ../renderers/src/ProgressRenderer.tsx
3428
+ import { ProgressBar } from "@transferwise/components";
3429
+ import { jsx as jsx81 } from "react/jsx-runtime";
3430
+ var ProgressRenderer = {
3431
+ canRenderType: "progress",
3432
+ render: ({ uid, title, help, progress, progressText, margin, description }) => {
3433
+ return /* @__PURE__ */ jsx81(
3434
+ ProgressBar,
3435
+ {
3436
+ id: uid,
3437
+ className: getMargin(margin),
3438
+ title: title && help ? /* @__PURE__ */ jsx81(LabelContentWithHelp, { text: title, help }) : title,
3439
+ description,
3440
+ progress: {
3441
+ max: 1,
3442
+ value: progress
3443
+ },
3444
+ textEnd: progressText
3445
+ }
3446
+ );
3447
+ }
3448
+ };
3449
+
3450
+ // ../renderers/src/getWiseRenderers.ts
3451
+ var getListItemRenderers = () => [
3452
+ NewDecisionRenderer_default,
3453
+ NewListRenderer_default,
3454
+ NewReviewRenderer_default,
3455
+ NewStatusListRenderer_default
3456
+ ];
3457
+ var getButtonV2Renderers = () => [ButtonRendererV2];
3458
+ var getWiseRenderers = () => [
3459
+ AddressValidationButtonRenderer_default,
3460
+ AlertRenderer_default,
3461
+ CheckboxInputRenderer_default,
3462
+ BoxRenderer_default,
3463
+ ButtonRenderer,
3464
+ ColumnsRenderer_default,
3465
+ DateInputRenderer_default,
3466
+ DecisionRenderer_default,
3467
+ DividerRenderer_default,
3468
+ ExternalConfirmationRenderer_default,
3469
+ FormRenderer_default,
3470
+ FormSectionRenderer_default,
3471
+ HeadingRenderer_default,
3472
+ ImageRenderer_default,
3473
+ InstructionsRenderer_default,
3474
+ IntegerInputRenderer_default,
3475
+ LargeUploadRenderer,
3476
+ ListRenderer_default,
3477
+ LoadingIndicatorRenderer_default,
3478
+ MarkdownRenderer_default,
3479
+ ModalRenderer,
3480
+ ModalLayoutRenderer_default,
3481
+ MultiSelectInputRenderer_default,
3482
+ MultiUploadInputRenderer_default,
3483
+ NumberInputRenderer_default,
3484
+ ParagraphRenderer_default,
3485
+ ProgressRenderer,
3486
+ RepeatableRenderer_default,
3487
+ ReviewRenderer_default,
3488
+ SearchRenderer_default,
3489
+ SelectInputRenderer_default,
3490
+ SectionRenderer_default,
3491
+ StatusListRenderer_default,
3492
+ TabsRenderer,
3493
+ TextInputRenderer_default,
3494
+ UploadInputRenderer,
3495
+ SplashStepRenderer,
3496
+ SplashCelebrationStepRenderer,
3497
+ StepRenderer
3498
+ ];
3499
+
3500
+ // src/dynamicFlow/renderers.ts
3501
+ var Header11 = Header7;
3502
+ var Media2 = Media;
3503
+ var getMargin2 = getMargin;
3504
+ var getListItemRenderers2 = getListItemRenderers;
3505
+ var getButtonV2Renderers2 = getButtonV2Renderers;
30
3506
 
31
3507
  // src/i18n/index.ts
32
3508
  import { translations as coreTranslations } from "@wise/dynamic-flow-client";
@@ -873,14 +4349,13 @@ var translations = languages.reduce(
873
4349
  var i18n_default = translations;
874
4350
 
875
4351
  // src/dynamicFlow/DynamicFlow.tsx
876
- import { forwardRef, useCallback, useMemo } from "react";
877
- import { useIntl } from "react-intl";
4352
+ import { forwardRef, useCallback, useMemo as useMemo2 } from "react";
4353
+ import { useIntl as useIntl12 } from "react-intl";
878
4354
  import {
879
4355
  DynamicFlow as DynamicFlowCoreLegacy,
880
4356
  DynamicFlowCoreRevamp,
881
4357
  DynamicFormCore
882
4358
  } from "@wise/dynamic-flow-client";
883
- import { getWiseRenderers, useSnackBarIfAvailable } from "@wise/dynamic-flow-renderers";
884
4359
 
885
4360
  // src/dynamicFlow/telemetry/app-version.ts
886
4361
  var appVersion = (
@@ -912,7 +4387,6 @@ var logToRollbar = (level, message, extra) => {
912
4387
 
913
4388
  // src/dynamicFlow/telemetry/getTrackEvent.ts
914
4389
  import { isThemeModern } from "@wise/components-theming";
915
- import { ThemeRequiredEventName } from "@wise/dynamic-flow-renderers";
916
4390
  var getTrackEvent = (onEvent, onAnalytics, onThemeChange) => (name, properties) => {
917
4391
  onEvent == null ? void 0 : onEvent(name, properties);
918
4392
  if (name.includes(ThemeRequiredEventName)) {
@@ -926,8 +4400,8 @@ var getTrackEvent = (onEvent, onAnalytics, onThemeChange) => (name, properties)
926
4400
  };
927
4401
 
928
4402
  // src/dynamicFlow/messages.ts
929
- import { defineMessages } from "react-intl";
930
- var messages_default = defineMessages({
4403
+ import { defineMessages as defineMessages10 } from "react-intl";
4404
+ var messages_default = defineMessages10({
931
4405
  copied: {
932
4406
  id: "df.wise.CopyFeedback.copy",
933
4407
  defaultMessage: "Copied to clipboard",
@@ -941,12 +4415,12 @@ var messages_default = defineMessages({
941
4415
  });
942
4416
 
943
4417
  // src/dynamicFlow/DynamicFlow.tsx
944
- import { jsx } from "react/jsx-runtime";
4418
+ import { jsx as jsx82 } from "react/jsx-runtime";
945
4419
  var wiseRenderers = getWiseRenderers();
946
4420
  function DynamicFlowLegacy(props) {
947
4421
  const { customFetch = globalThis.fetch } = props;
948
4422
  const coreProps = __spreadProps(__spreadValues({}, props), { httpClient: customFetch });
949
- return /* @__PURE__ */ jsx(DynamicFlowCoreLegacy, __spreadValues({}, coreProps));
4423
+ return /* @__PURE__ */ jsx82(DynamicFlowCoreLegacy, __spreadValues({}, coreProps));
950
4424
  }
951
4425
  function DynamicFlowRevamp(props) {
952
4426
  const {
@@ -959,12 +4433,12 @@ function DynamicFlowRevamp(props) {
959
4433
  onLink = openLinkInNewTab,
960
4434
  onThemeChange
961
4435
  } = props;
962
- const { formatMessage } = useIntl();
4436
+ const { formatMessage } = useIntl12();
963
4437
  const createSnackBar = useSnackBarIfAvailable();
964
4438
  const httpClient = useWiseHttpClient(customFetch);
965
- const mergedRenderers = useMemo(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
966
- const logEvent = useMemo(() => getLogEvent(onLog), [onLog]);
967
- const trackEvent = useMemo(
4439
+ const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
4440
+ const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
4441
+ const trackEvent = useMemo2(
968
4442
  () => getTrackEvent(onEvent, onAnalytics, onThemeChange),
969
4443
  [onEvent, onAnalytics, onThemeChange]
970
4444
  );
@@ -983,7 +4457,7 @@ function DynamicFlowRevamp(props) {
983
4457
  onLink,
984
4458
  onCopy
985
4459
  });
986
- return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(DynamicFlowCoreRevamp, __spreadValues({}, coreProps)) });
4460
+ return /* @__PURE__ */ jsx82("div", { className, children: /* @__PURE__ */ jsx82(DynamicFlowCoreRevamp, __spreadValues({}, coreProps)) });
987
4461
  }
988
4462
  var DynamicForm = forwardRef(function DynamicForm2(props, ref) {
989
4463
  const {
@@ -996,12 +4470,12 @@ var DynamicForm = forwardRef(function DynamicForm2(props, ref) {
996
4470
  onLink = openLinkInNewTab,
997
4471
  onThemeChange
998
4472
  } = props;
999
- const { formatMessage } = useIntl();
4473
+ const { formatMessage } = useIntl12();
1000
4474
  const createSnackBar = useSnackBarIfAvailable();
1001
4475
  const httpClient = useWiseHttpClient(customFetch);
1002
- const mergedRenderers = useMemo(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
1003
- const logEvent = useMemo(() => getLogEvent(onLog), [onLog]);
1004
- const trackEvent = useMemo(
4476
+ const mergedRenderers = useMemo2(() => [...renderers != null ? renderers : [], ...wiseRenderers], [renderers]);
4477
+ const logEvent = useMemo2(() => getLogEvent(onLog), [onLog]);
4478
+ const trackEvent = useMemo2(
1005
4479
  () => getTrackEvent(onEvent, onAnalytics, onThemeChange),
1006
4480
  [onEvent, onAnalytics, onThemeChange]
1007
4481
  );
@@ -1020,10 +4494,10 @@ var DynamicForm = forwardRef(function DynamicForm2(props, ref) {
1020
4494
  onLink,
1021
4495
  onCopy
1022
4496
  });
1023
- return /* @__PURE__ */ jsx("div", { className, children: /* @__PURE__ */ jsx(DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
4497
+ return /* @__PURE__ */ jsx82("div", { className, children: /* @__PURE__ */ jsx82(DynamicFormCore, __spreadProps(__spreadValues({}, coreProps), { ref })) });
1024
4498
  });
1025
4499
  var useWiseHttpClient = (httpClient) => {
1026
- const { locale } = useIntl();
4500
+ const { locale } = useIntl12();
1027
4501
  return useCallback(
1028
4502
  async (input, init = {}) => {
1029
4503
  const headers = new Headers(init.headers);
@@ -1051,12 +4525,13 @@ export {
1051
4525
  DynamicFlowLegacy,
1052
4526
  DynamicFlowRevamp,
1053
4527
  DynamicForm,
1054
- Header,
4528
+ Header11 as Header,
1055
4529
  JsonSchemaForm,
4530
+ Media2 as Media,
1056
4531
  findRendererPropsByType,
1057
- getButtonV2Renderers,
1058
- getListItemRenderers,
1059
- getMargin,
4532
+ getButtonV2Renderers2 as getButtonV2Renderers,
4533
+ getListItemRenderers2 as getListItemRenderers,
4534
+ getMargin2 as getMargin,
1060
4535
  isValidSchema,
1061
4536
  makeHttpClient as makeCustomFetch,
1062
4537
  i18n_default as translations