@dloizides/ui-forms 1.31.0 → 1.33.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.mjs CHANGED
@@ -1,11 +1,12 @@
1
1
  import React2, { forwardRef, useState, useCallback, useMemo, useRef, useEffect, useLayoutEffect } from 'react';
2
- import { Platform, StyleSheet, TextInput, View, Text, useWindowDimensions, ScrollView, Pressable, Switch, Image, TouchableOpacity } from 'react-native';
2
+ import { Platform, StyleSheet, TextInput, View, Text, useWindowDimensions, ScrollView, Pressable, Switch, Image, AccessibilityInfo, Animated, TouchableOpacity, Modal } from 'react-native';
3
3
  import { useUi } from '@dloizides/ui-feedback';
4
4
  import { jsx, jsxs, Fragment } from 'react/jsx-runtime';
5
5
  import { Z_INDEX, focusRingOutline, readableScaleInk } from '@dloizides/design-tokens';
6
6
  import { themeFocusRingColor, Button, useFocusRing } from '@dloizides/ui-buttons';
7
7
  import { createPortal } from 'react-dom';
8
8
  import { MIN_TOUCH_TARGET_PX } from '@dloizides/a11y';
9
+ import Svg, { Rect, Circle, Polygon } from 'react-native-svg';
9
10
 
10
11
  // src/Field/Field.tsx
11
12
  function attachControlId(child, candidateId, describedById) {
@@ -336,7 +337,7 @@ var styles4 = StyleSheet.create({
336
337
  }
337
338
  });
338
339
  var InlineFieldRow = ({
339
- field,
340
+ field: field2,
340
341
  action,
341
342
  fieldMaxWidth,
342
343
  inlineMinWidth,
@@ -349,11 +350,11 @@ var InlineFieldRow = ({
349
350
  const fieldStyle = useMemo(() => [styles4.field, { maxWidth: layout.fieldMaxWidth }], [layout.fieldMaxWidth]);
350
351
  if (!layout.inline)
351
352
  return /* @__PURE__ */ jsxs(Fragment, { children: [
352
- field,
353
+ field2,
353
354
  action
354
355
  ] });
355
356
  return /* @__PURE__ */ jsxs(View, { style: rowStyle, testID, children: [
356
- /* @__PURE__ */ jsx(View, { style: fieldStyle, children: field }),
357
+ /* @__PURE__ */ jsx(View, { style: fieldStyle, children: field2 }),
357
358
  /* @__PURE__ */ jsx(AlignToControl, { style: styles4.action, children: action })
358
359
  ] });
359
360
  };
@@ -632,25 +633,25 @@ function readAnchorRect(ref) {
632
633
  const r = node.getBoundingClientRect();
633
634
  return { top: r.top, left: r.left, width: r.width, bottom: r.bottom };
634
635
  }
635
- function buildPortalPopoverStyle(rect, viewportBottom, viewportWidth) {
636
+ function buildPortalPopoverStyle(rect2, viewportBottom, viewportWidth) {
636
637
  return {
637
- ...viewportBottom !== void 0 ? { maxHeight: menuMaxHeight(rect.bottom, viewportBottom) } : null,
638
+ ...viewportBottom !== void 0 ? { maxHeight: menuMaxHeight(rect2.bottom, viewportBottom) } : null,
638
639
  // RN's ViewStyle union omits 'fixed', but react-native-web honours it at runtime.
639
640
  // eslint-disable-next-line @typescript-eslint/consistent-type-assertions -- web-only position value
640
641
  position: "fixed",
641
- top: rect.bottom + MENU_TOP_GAP2,
642
- ...horizontalPlacement(rect, viewportWidth),
642
+ top: rect2.bottom + MENU_TOP_GAP2,
643
+ ...horizontalPlacement(rect2, viewportWidth),
643
644
  zIndex: MENU_PORTAL_Z_INDEX
644
645
  };
645
646
  }
646
- function horizontalPlacement(rect, viewportWidth) {
647
- if (viewportWidth === void 0) return { left: rect.left, width: rect.width };
648
- const width = Math.min(Math.max(rect.width, MENU_MIN_WIDTH), viewportWidth - 2 * VIEWPORT_MARGIN);
649
- const left = Math.max(VIEWPORT_MARGIN, Math.min(rect.left, viewportWidth - VIEWPORT_MARGIN - width));
647
+ function horizontalPlacement(rect2, viewportWidth) {
648
+ if (viewportWidth === void 0) return { left: rect2.left, width: rect2.width };
649
+ const width = Math.min(Math.max(rect2.width, MENU_MIN_WIDTH), viewportWidth - 2 * VIEWPORT_MARGIN);
650
+ const left = Math.max(VIEWPORT_MARGIN, Math.min(rect2.left, viewportWidth - VIEWPORT_MARGIN - width));
650
651
  return { left, width };
651
652
  }
652
653
  function useAnchorRect(ref, enabled) {
653
- const [rect, setRect] = useState(null);
654
+ const [rect2, setRect] = useState(null);
654
655
  useLayoutEffect(() => {
655
656
  if (!IS_WEB3 || !enabled) {
656
657
  setRect(null);
@@ -684,7 +685,7 @@ function useAnchorRect(ref, enabled) {
684
685
  if (observer !== null) observer.disconnect();
685
686
  };
686
687
  }, [ref, enabled]);
687
- return IS_WEB3 && enabled ? rect : null;
688
+ return IS_WEB3 && enabled ? rect2 : null;
688
689
  }
689
690
  function roomUnderAnchor(anchorBottom, viewportBottom) {
690
691
  return viewportBottom - anchorBottom - MENU_TOP_GAP2 - VIEWPORT_MARGIN;
@@ -789,11 +790,11 @@ function AnchoredMenu({
789
790
  const menuRef = React2.useRef(null);
790
791
  useDismiss(anchorRef, menuRef, onDismiss);
791
792
  useKeepHighlightInView(testID, listbox?.highlightedValue);
792
- const rect = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
793
+ const rect2 = useAnchorRect(placement?.positionRef ?? anchorRef, usePortal);
793
794
  const viewportBottom = useVisualViewportBottom(usePortal);
794
795
  const { width: windowWidth } = useWindowDimensions();
795
- const portalStyle = rect !== null ? buildPortalPopoverStyle(rect, viewportBottom ?? void 0, placement !== void 0 ? windowWidth : void 0) : null;
796
- const menuWidth = rect?.width ?? windowWidth;
796
+ const portalStyle = rect2 !== null ? buildPortalPopoverStyle(rect2, viewportBottom ?? void 0, placement !== void 0 ? windowWidth : void 0) : null;
797
+ const menuWidth = rect2?.width ?? windowWidth;
797
798
  const isListbox = listbox !== void 0;
798
799
  const statusText = listbox?.statusText;
799
800
  const rows = options.map((option) => /* @__PURE__ */ jsx(
@@ -1887,6 +1888,7 @@ var RANK_VALUE_EXACT = 0;
1887
1888
  var RANK_VALUE_PREFIX = 1;
1888
1889
  var RANK_LABEL_PREFIX = 2;
1889
1890
  var RANK_LABEL_CONTAINS = 3;
1891
+ var RANK_DETAIL_CONTAINS = 4;
1890
1892
  var NO_MATCH = -1;
1891
1893
  function rankOf(option, needle) {
1892
1894
  const value = option.value.toLowerCase();
@@ -1895,6 +1897,7 @@ function rankOf(option, needle) {
1895
1897
  if (value.startsWith(needle)) return RANK_VALUE_PREFIX;
1896
1898
  if (label.startsWith(needle)) return RANK_LABEL_PREFIX;
1897
1899
  if (label.includes(needle)) return RANK_LABEL_CONTAINS;
1900
+ if ((option.detail ?? "").toLowerCase().includes(needle)) return RANK_DETAIL_CONTAINS;
1898
1901
  return NO_MATCH;
1899
1902
  }
1900
1903
  function suggestOptions(options, query, minChars, limit) {
@@ -2392,7 +2395,7 @@ function useFocusFirstInvalid(refs) {
2392
2395
  const latest = useRef(refs);
2393
2396
  latest.current = refs;
2394
2397
  return useCallback((invalid) => {
2395
- const first = invalid.map((field) => latest.current[field].current).find((node) => node !== null);
2398
+ const first = invalid.map((field2) => latest.current[field2].current).find((node) => node !== null);
2396
2399
  first?.focus();
2397
2400
  }, []);
2398
2401
  }
@@ -2472,7 +2475,1507 @@ var UploadWithLinkField = ({
2472
2475
  ) : null
2473
2476
  ] });
2474
2477
  };
2478
+ var ACTION_GAP = 8;
2479
+ var GROUP_GAP = 16;
2480
+ var styles16 = StyleSheet.create({
2481
+ action: { alignItems: "flex-start", marginTop: ACTION_GAP },
2482
+ group: { marginBottom: GROUP_GAP }
2483
+ });
2484
+ var isAddOnOpen = (hasValue, requested) => hasValue || requested;
2485
+ var AddOnRequest = ({
2486
+ addLabel,
2487
+ addHint,
2488
+ removeLabel,
2489
+ removeHint,
2490
+ hasValue,
2491
+ onRemove,
2492
+ testID,
2493
+ children,
2494
+ disabled = false,
2495
+ style
2496
+ }) => {
2497
+ const [requested, setRequested] = useState(false);
2498
+ const remove = () => {
2499
+ setRequested(false);
2500
+ onRemove();
2501
+ };
2502
+ if (!isAddOnOpen(hasValue, requested))
2503
+ return /* @__PURE__ */ jsx(View, { style: [styles16.action, style], children: /* @__PURE__ */ jsx(
2504
+ Button,
2505
+ {
2506
+ accessibilityHint: addHint,
2507
+ accessibilityLabel: addLabel,
2508
+ disabled,
2509
+ label: addLabel,
2510
+ testID: `${testID}-add`,
2511
+ variant: "secondary",
2512
+ onPress: () => setRequested(true)
2513
+ }
2514
+ ) });
2515
+ return /* @__PURE__ */ jsxs(View, { style: [styles16.group, style], testID, children: [
2516
+ children,
2517
+ /* @__PURE__ */ jsx(View, { style: styles16.action, children: /* @__PURE__ */ jsx(
2518
+ Button,
2519
+ {
2520
+ accessibilityHint: removeHint,
2521
+ accessibilityLabel: removeLabel,
2522
+ disabled,
2523
+ label: removeLabel,
2524
+ testID: `${testID}-remove`,
2525
+ variant: "secondary",
2526
+ onPress: remove
2527
+ }
2528
+ ) })
2529
+ ] });
2530
+ };
2531
+ var ROW_GAP3 = 8;
2532
+ var TEXT_SIZE = 13;
2533
+ var TEXT_LINE = 18;
2534
+ var styles17 = StyleSheet.create({
2535
+ row: { alignItems: "center", columnGap: ROW_GAP3, flexDirection: "row", justifyContent: "space-between" },
2536
+ text: { flexShrink: 1, fontSize: TEXT_SIZE, fontWeight: "700", lineHeight: TEXT_LINE }
2537
+ });
2538
+ var isFixBarVisible = (count) => count > 0;
2539
+ var FixBar = ({ count, message, showLabel, showHint, onShow, testID, style }) => {
2540
+ const { theme } = useUi();
2541
+ if (!isFixBarVisible(count)) return null;
2542
+ return /* @__PURE__ */ jsxs(View, { style: [styles17.row, style], testID, children: [
2543
+ /* @__PURE__ */ jsx(Text, { role: "alert", style: [styles17.text, { color: fieldErrorInk(theme) }], testID: `${testID}-count`, children: message }),
2544
+ /* @__PURE__ */ jsx(
2545
+ Button,
2546
+ {
2547
+ accessibilityHint: showHint,
2548
+ accessibilityLabel: showLabel,
2549
+ label: showLabel,
2550
+ testID: `${testID}-show`,
2551
+ variant: "secondary",
2552
+ onPress: onShow
2553
+ }
2554
+ )
2555
+ ] });
2556
+ };
2557
+
2558
+ // src/SearchSelect/SelectSurface.ts
2559
+ var SelectSurface = /* @__PURE__ */ ((SelectSurface2) => {
2560
+ SelectSurface2["Sheet"] = "sheet";
2561
+ SelectSurface2["Dropdown"] = "dropdown";
2562
+ return SelectSurface2;
2563
+ })(SelectSurface || {});
2564
+ function isContainer(node) {
2565
+ return "contains" in Object(node);
2566
+ }
2567
+ function isOutside(container, target) {
2568
+ if (!isContainer(container)) return false;
2569
+ return !(target instanceof Node && container.contains(target));
2570
+ }
2571
+ function useOutsidePress(ref, onOutside) {
2572
+ useEffect(() => {
2573
+ if (Platform.OS !== "web" || typeof document === "undefined") return void 0;
2574
+ const onPointerDown = (event) => {
2575
+ if (isOutside(ref.current, event.target)) onOutside();
2576
+ };
2577
+ document.addEventListener("pointerdown", onPointerDown, true);
2578
+ return () => document.removeEventListener("pointerdown", onPointerDown, true);
2579
+ }, [ref, onOutside]);
2580
+ }
2581
+ var PANEL_Z = 10;
2582
+ function DropdownSurface({ progress, translateY, anchorRef, onDismiss, children }) {
2583
+ useOutsidePress(anchorRef, onDismiss);
2584
+ return /* @__PURE__ */ jsx(Animated.View, { style: [styles18.dropdown, { opacity: progress, transform: [{ translateY }] }], children });
2585
+ }
2586
+ var styles18 = StyleSheet.create({
2587
+ dropdown: { position: "absolute", top: "100%", left: 0, right: 0, zIndex: PANEL_Z }
2588
+ });
2589
+ var ROW_PAD_H = 12;
2590
+ var ROW_GAP4 = 8;
2591
+ var OPTION_FONT2 = 14;
2592
+ var DETAIL_FONT2 = 12;
2593
+ function OptionRow2({ option, active, current, renderLeading, renderDetail, onPick, optionHint, testID }) {
2594
+ const { theme } = useUi();
2595
+ const { colors } = theme;
2596
+ const ref = useKeepInView(active ? option.value : null);
2597
+ const detailBelow = renderDetail === void 0 && option.detail !== void 0;
2598
+ return /* @__PURE__ */ jsxs(
2599
+ Pressable,
2600
+ {
2601
+ ref,
2602
+ accessibilityHint: optionHint,
2603
+ accessibilityLabel: option.label,
2604
+ accessibilityRole: "button",
2605
+ accessibilityState: { selected: active, checked: current },
2606
+ style: [styles19.row, active ? { backgroundColor: colors.surface } : null],
2607
+ testID: `${testID}-option-${option.value}`,
2608
+ onPress: () => onPick(option),
2609
+ children: [
2610
+ renderLeading?.(option),
2611
+ /* @__PURE__ */ jsxs(View, { style: styles19.label, children: [
2612
+ /* @__PURE__ */ jsx(Text, { style: [styles19.primary, { color: colors.text }], children: option.label }),
2613
+ detailBelow ? /* @__PURE__ */ jsx(Text, { style: [styles19.secondary, { color: colors.textSecondary }], children: option.detail }) : null
2614
+ ] }),
2615
+ renderDetail?.(option)
2616
+ ]
2617
+ }
2618
+ );
2619
+ }
2620
+ var styles19 = StyleSheet.create({
2621
+ row: { minHeight: MIN_TOUCH_TARGET_PX, flexDirection: "row", alignItems: "center", gap: ROW_GAP4, paddingHorizontal: ROW_PAD_H },
2622
+ label: { flex: 1 },
2623
+ primary: { fontSize: OPTION_FONT2, flexShrink: 1 },
2624
+ secondary: { fontSize: DETAIL_FONT2 }
2625
+ });
2626
+ var ROW_PAD_H2 = 12;
2627
+ var ROW_GAP5 = 8;
2628
+ var HEADER_FONT = 11;
2629
+ function OptionSection({ title, options, offset, highlight, selectedValue, ...row }) {
2630
+ const { theme } = useUi();
2631
+ const { colors } = theme;
2632
+ if (options.length === 0) return null;
2633
+ return /* @__PURE__ */ jsxs(View, { children: [
2634
+ /* @__PURE__ */ jsx(Text, { accessibilityRole: "header", style: [styles20.header, { color: colors.textSecondary }], children: title }),
2635
+ options.map((option, index) => /* @__PURE__ */ jsx(OptionRow2, { ...row, active: offset + index === highlight, current: option.value === selectedValue, option }, option.value))
2636
+ ] });
2637
+ }
2638
+ var styles20 = StyleSheet.create({
2639
+ header: { fontSize: HEADER_FONT, paddingHorizontal: ROW_PAD_H2, paddingTop: ROW_GAP5, textTransform: "uppercase" }
2640
+ });
2641
+ function SheetSurface({ translateY, onDismiss, closeLabel, closeHint, testID, children }) {
2642
+ return /* @__PURE__ */ jsx(Modal, { transparent: true, visible: true, animationType: "none", onRequestClose: onDismiss, children: /* @__PURE__ */ jsxs(View, { style: styles21.backdrop, children: [
2643
+ /* @__PURE__ */ jsx(Pressable, { accessibilityHint: closeHint, accessibilityLabel: closeLabel, accessibilityRole: "button", style: StyleSheet.absoluteFill, testID: `${testID}-backdrop`, onPress: onDismiss }),
2644
+ /* @__PURE__ */ jsx(Animated.View, { style: { transform: [{ translateY }] }, children })
2645
+ ] }) });
2646
+ }
2647
+ var styles21 = StyleSheet.create({
2648
+ backdrop: { flex: 1, justifyContent: "flex-end" }
2649
+ });
2650
+ var KEY_ESCAPE = "Escape";
2651
+ var PANEL_PAD = 8;
2652
+ var PANEL_RADIUS = 8;
2653
+ var SHEET_MAX_HEIGHT = 480;
2654
+ function SearchSelectPanel({ motion, state, labels, anchorRef, renderLeading, renderDetail, selectedValue, testID }) {
2655
+ const { theme } = useUi();
2656
+ const { colors } = theme;
2657
+ const progress = useRef(new Animated.Value(0)).current;
2658
+ const { durationMs } = motion;
2659
+ useEffect(() => {
2660
+ Animated.timing(progress, { toValue: 1, duration: durationMs, useNativeDriver: false }).start();
2661
+ }, [progress, durationMs]);
2662
+ const leaving = useRef(false);
2663
+ const leave = useCallback((after) => {
2664
+ if (leaving.current) return;
2665
+ leaving.current = true;
2666
+ if (durationMs === 0) return after();
2667
+ Animated.timing(progress, { toValue: 0, duration: durationMs, useNativeDriver: false }).start(() => after());
2668
+ }, [progress, durationMs]);
2669
+ const { close, pick: pickNow, submit: submitNow, onKey, sections, highlight } = state;
2670
+ const dismiss = useCallback(() => leave(close), [leave, close]);
2671
+ const pick = useCallback((option) => leave(() => pickNow(option)), [leave, pickNow]);
2672
+ const submit = useCallback(() => submitNow(pick), [submitNow, pick]);
2673
+ const onKeyPress = useCallback((key) => key === KEY_ESCAPE ? dismiss() : onKey(key), [dismiss, onKey]);
2674
+ const translateY = progress.interpolate({ inputRange: [0, 1], outputRange: [motion.fromY, 0] });
2675
+ const isSheet = motion.surface === "sheet" /* Sheet */;
2676
+ const shared = { selectedValue, renderLeading, renderDetail, onPick: pick, optionHint: labels.optionHint, testID, highlight };
2677
+ const list = /* @__PURE__ */ jsxs(View, { style: [styles22.panel, { backgroundColor: colors.surfaceElevated, borderColor: colors.border }], testID: `${testID}-panel`, children: [
2678
+ /* @__PURE__ */ jsx(
2679
+ TextInput,
2680
+ {
2681
+ autoFocus: true,
2682
+ accessibilityHint: labels.searchHint,
2683
+ accessibilityLabel: labels.search,
2684
+ placeholder: labels.search,
2685
+ placeholderTextColor: colors.textSecondary,
2686
+ style: [controlStyles.input, { color: colors.text, borderColor: colors.border }],
2687
+ testID: `${testID}-search`,
2688
+ value: state.query,
2689
+ onChangeText: state.setQuery,
2690
+ onKeyPress: (event) => onKeyPress(event.nativeEvent.key),
2691
+ onSubmitEditing: submit
2692
+ }
2693
+ ),
2694
+ /* @__PURE__ */ jsxs(ScrollView, { keyboardShouldPersistTaps: "handled", style: isSheet ? styles22.sheetList : styles22.dropList, children: [
2695
+ /* @__PURE__ */ jsx(OptionSection, { ...shared, offset: 0, options: sections.recent, title: labels.recent }),
2696
+ /* @__PURE__ */ jsx(OptionSection, { ...shared, offset: sections.recent.length, options: sections.all, title: labels.all }),
2697
+ sections.flat.length === 0 ? /* @__PURE__ */ jsx(Text, { style: [styles22.empty, { color: colors.textSecondary }], children: labels.empty }) : null
2698
+ ] })
2699
+ ] });
2700
+ if (!isSheet) return /* @__PURE__ */ jsx(DropdownSurface, { anchorRef, progress, translateY, onDismiss: dismiss, children: list });
2701
+ return /* @__PURE__ */ jsx(SheetSurface, { closeHint: labels.closeHint, closeLabel: labels.close, testID, translateY, onDismiss: dismiss, children: list });
2702
+ }
2703
+ var styles22 = StyleSheet.create({
2704
+ panel: { borderWidth: 1, borderRadius: PANEL_RADIUS, padding: PANEL_PAD, gap: PANEL_PAD },
2705
+ dropList: { maxHeight: MENU_MAX_HEIGHT },
2706
+ sheetList: { maxHeight: SHEET_MAX_HEIGHT },
2707
+ empty: { padding: PANEL_PAD }
2708
+ });
2709
+ function useReducedMotion() {
2710
+ const [reduced, setReduced] = useState(false);
2711
+ useEffect(() => {
2712
+ let active = true;
2713
+ AccessibilityInfo.isReduceMotionEnabled().then((value) => {
2714
+ if (active) setReduced(value);
2715
+ }).catch(() => void 0);
2716
+ const subscription = AccessibilityInfo.addEventListener("reduceMotionChanged", setReduced);
2717
+ return () => {
2718
+ active = false;
2719
+ subscription.remove();
2720
+ };
2721
+ }, []);
2722
+ return reduced;
2723
+ }
2724
+
2725
+ // src/SearchSelect/utils/searchSelectModel.ts
2726
+ var MIN_QUERY = 1;
2727
+ function buildSearchSelectSections(options, query, recentValues) {
2728
+ const matches = query.trim() === "" ? options : suggestOptions(options, query, MIN_QUERY, options.length);
2729
+ const byValue = new Map(matches.map((option) => [option.value, option]));
2730
+ const recent = recentValues.map((value) => byValue.get(value)).filter((option) => option !== void 0);
2731
+ const recentSet = new Set(recent.map((option) => option.value));
2732
+ const all = matches.filter((option) => !recentSet.has(option.value));
2733
+ return { recent, all, flat: [...recent, ...all] };
2734
+ }
2735
+ function findOption(options, value) {
2736
+ return options.find((option) => option.value === value) ?? null;
2737
+ }
2738
+ function moveHighlight(index, count, step) {
2739
+ if (count === 0) return -1;
2740
+ if (index < 0) return step > 0 ? 0 : count - 1;
2741
+ return (index + step + count) % count;
2742
+ }
2743
+ function highlightAfterQuery(query) {
2744
+ return query.trim() === "" ? -1 : 0;
2745
+ }
2746
+
2747
+ // src/SearchSelect/hooks/useSearchSelectState.ts
2748
+ var KEY_DOWN = "ArrowDown";
2749
+ var KEY_UP = "ArrowUp";
2750
+ var KEY_ESCAPE2 = "Escape";
2751
+ function useSearchSelectState(options, recents, onChange, onClosed) {
2752
+ const [open, setOpen] = useState(false);
2753
+ const [query, setQueryState] = useState("");
2754
+ const [rawHighlight, setHighlight] = useState(-1);
2755
+ const sections = useMemo(() => buildSearchSelectSections(options, query, recents.recents), [options, query, recents.recents]);
2756
+ const highlight = rawHighlight < sections.flat.length ? rawHighlight : -1;
2757
+ const active = sections.flat[highlight];
2758
+ const { remember } = recents;
2759
+ const close = useCallback(() => {
2760
+ setOpen(false);
2761
+ setQueryState("");
2762
+ setHighlight(-1);
2763
+ onClosed();
2764
+ }, [onClosed]);
2765
+ const pick = useCallback((option) => {
2766
+ remember(option.value);
2767
+ onChange(option.value);
2768
+ close();
2769
+ }, [remember, onChange, close]);
2770
+ const submit = useCallback((via = pick) => {
2771
+ if (active !== void 0) via(active);
2772
+ }, [active, pick]);
2773
+ const setQuery = useCallback((next) => {
2774
+ setQueryState(next);
2775
+ setHighlight(highlightAfterQuery(next));
2776
+ }, []);
2777
+ const onKey = useCallback((key) => {
2778
+ const count = sections.flat.length;
2779
+ if (key === KEY_DOWN) setHighlight(moveHighlight(highlight, count, 1));
2780
+ if (key === KEY_UP) setHighlight(moveHighlight(highlight, count, -1));
2781
+ if (key === KEY_ESCAPE2) close();
2782
+ }, [sections.flat.length, highlight, close]);
2783
+ const openList = useCallback(() => setOpen(true), []);
2784
+ return { open, query, highlight, active, sections, openList, close, setQuery, pick, submit, onKey };
2785
+ }
2786
+
2787
+ // src/SearchSelect/utils/searchSelectMotion.ts
2788
+ var PHONE_MAX_WIDTH = 600;
2789
+ var SHEET_TRAVEL_PX = 320;
2790
+ var DROPDOWN_TRAVEL_PX = -8;
2791
+ var SHEET_MS = 240;
2792
+ var DROPDOWN_MS = 160;
2793
+ function resolveSelectMotion(width, reducedMotion) {
2794
+ const isPhone = width < PHONE_MAX_WIDTH;
2795
+ const surface = isPhone ? "sheet" /* Sheet */ : "dropdown" /* Dropdown */;
2796
+ if (reducedMotion) return { surface, fromY: 0, durationMs: 0 };
2797
+ return isPhone ? { surface, fromY: SHEET_TRAVEL_PX, durationMs: SHEET_MS } : { surface, fromY: DROPDOWN_TRAVEL_PX, durationMs: DROPDOWN_MS };
2798
+ }
2799
+ var CHEVRON = "\u25BE";
2800
+ var VALUE_GAP = 8;
2801
+ function SearchSelect(props) {
2802
+ const { options, value, onChange, accessibilityLabel, accessibilityHint, labels, testID, recentKey, renderLeading, renderDetail } = props;
2803
+ const { theme } = useUi();
2804
+ const { colors } = theme;
2805
+ const triggerRef = useRef(null);
2806
+ const anchorRef = useRef(null);
2807
+ const { width } = useWindowDimensions();
2808
+ const motion = resolveSelectMotion(width, useReducedMotion());
2809
+ const recents = useRecentValues(recentKey ?? `search-select:${testID}`);
2810
+ const refocus = useCallback(() => triggerRef.current?.focus(), []);
2811
+ const state = useSearchSelectState(options, recents, onChange, refocus);
2812
+ const selected = findOption(options, value);
2813
+ return /* @__PURE__ */ jsxs(View, { ref: anchorRef, style: styles23.anchor, children: [
2814
+ /* @__PURE__ */ jsxs(
2815
+ Pressable,
2816
+ {
2817
+ ref: triggerRef,
2818
+ accessibilityHint,
2819
+ accessibilityLabel,
2820
+ accessibilityRole: "button",
2821
+ accessibilityState: { expanded: state.open },
2822
+ style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }],
2823
+ testID,
2824
+ onPress: state.open ? state.close : state.openList,
2825
+ children: [
2826
+ /* @__PURE__ */ jsxs(View, { style: styles23.value, children: [
2827
+ selected !== null && renderLeading !== void 0 ? renderLeading(selected) : null,
2828
+ /* @__PURE__ */ jsx(Text, { numberOfLines: 1, style: [controlStyles.selectTriggerText, { color: selected === null ? colors.textSecondary : colors.text }], children: selected?.label ?? labels.placeholder }),
2829
+ selected !== null ? /* @__PURE__ */ jsx(SelectedDetail, { colors, option: selected, renderDetail }) : null
2830
+ ] }),
2831
+ /* @__PURE__ */ jsx(Text, { "aria-hidden": true, style: [controlStyles.chevron, { color: colors.textSecondary }], children: CHEVRON })
2832
+ ]
2833
+ }
2834
+ ),
2835
+ state.open ? /* @__PURE__ */ jsx(SearchSelectPanel, { anchorRef, labels, motion, renderDetail, renderLeading, selectedValue: value, state, testID }) : null
2836
+ ] });
2837
+ }
2838
+ function SelectedDetail({ option, colors, renderDetail }) {
2839
+ if (renderDetail !== void 0) return /* @__PURE__ */ jsx(Fragment, { children: renderDetail(option) });
2840
+ if (option.detail === void 0) return null;
2841
+ return /* @__PURE__ */ jsx(Text, { style: [controlStyles.selectTriggerText, { color: colors.textSecondary }], children: option.detail });
2842
+ }
2843
+ var styles23 = StyleSheet.create({
2844
+ anchor: { position: "relative" },
2845
+ value: { flex: 1, flexDirection: "row", alignItems: "center", gap: VALUE_GAP }
2846
+ });
2847
+
2848
+ // src/CountryFlag/data/flagPalette.ts
2849
+ var FLAG_PALETTE = {
2850
+ R: "#D52B1E",
2851
+ W: "#FFFFFF",
2852
+ B: "#0039A6",
2853
+ N: "#012169",
2854
+ S: "#6CACE4",
2855
+ G: "#009A44",
2856
+ D: "#006A4E",
2857
+ Y: "#FCD116",
2858
+ K: "#000000",
2859
+ O: "#FF8200",
2860
+ M: "#9E3039",
2861
+ A: "#8D1B3D",
2862
+ T: "#00778B",
2863
+ P: "#5B2C83",
2864
+ I: "#A7A8AA",
2865
+ C: "#D57800",
2866
+ E: "#002664"
2867
+ };
2868
+ var FLAG_FALLBACK_FILL = "#C8CDD2";
2869
+ var FLAG_EDGE = "#8A9199";
2870
+
2871
+ // src/CountryFlag/FlagShapeKind.ts
2872
+ var FlagShapeKind = /* @__PURE__ */ ((FlagShapeKind2) => {
2873
+ FlagShapeKind2["Rect"] = "rect";
2874
+ FlagShapeKind2["Circle"] = "circle";
2875
+ FlagShapeKind2["Polygon"] = "polygon";
2876
+ return FlagShapeKind2;
2877
+ })(FlagShapeKind || {});
2878
+
2879
+ // src/CountryFlag/data/flagDrawingsAtoL.ts
2880
+ var BLUE_ENSIGN = "HN j0,0,10,7";
2881
+ var AUSTRALIA = `${BLUE_ENSIGN} s5,10.5,1.6,W s15,3,0.9,W s13,7,0.9,W s17,6,0.9,W s15,11.5,0.9,W`;
2882
+ var SALTIRE_A = "p0,0,1.8,0,20,12.7,20,14,18.2,14,0,1.3";
2883
+ var SALTIRE_B = "p20,0,18.2,0,0,12.7,0,14,1.8,14,20,1.3";
2884
+ var SHIELD = "p13.5,3.5,16.5,3.5,16.5,8.5,15,10,13.5,8.5";
2885
+ var FLAG_DRAWINGS_A_TO_L = {
2886
+ AD: "VBYR p8.6,5.2,11.4,5.2,11.4,8,10,9.2,8.6,8,M",
2887
+ AG: "HR p0,0,20,0,10,14,K c10,7,2.6,Y p5,7,15,7,10,14,B p6.8,9.5,13.2,9.5,10,14,W",
2888
+ AI: `${BLUE_ENSIGN} c15,7,2.6,W c15,8,1.4,O`,
2889
+ AL: "HR p10,2.5,14,5,13,11,10,9,7,11,6,5,K",
2890
+ AO: "HRK s10,7,2.2,Y",
2891
+ AQ: "HS c10,7,3.5,W",
2892
+ AS: "HN p20,0,0,7,20,14,R p20,1.2,2.6,7,20,12.8,W",
2893
+ AU: AUSTRALIA,
2894
+ AW: "HS r0,9,20,0.8,Y r0,10.6,20,0.8,Y s3.5,3.5,2.2,W s3.5,3.5,1.6,R",
2895
+ BA: "HB p5,0,15,0,15,14,Y s4.2,1.2,0.8,W s5.7,3.5,0.8,W s7.2,5.8,0.8,W s8.7,8.1,0.8,W s10.2,10.4,0.8,W s11.7,12.7,0.8,W",
2896
+ BB: "VBYB p9.4,5,10,3,10.6,5,10.4,11,9.6,11,K p7.8,3.5,8.6,3.5,9,6.5,11,6.5,11.4,3.5,12.2,3.5,11.6,7.5,8.4,7.5,K",
2897
+ BF: "HRG s10,7,1.8,Y",
2898
+ BH: "HR p0,0,6,0,8,1.4,6,2.8,8,4.2,6,5.6,8,7,6,8.4,8,9.8,6,11.2,8,12.6,6,14,0,14,W",
2899
+ BI: `HR p0,0,10,7,0,14,G p20,0,10,7,20,14,G ${SALTIRE_A},W ${SALTIRE_B},W c10,7,3,W s10,5.8,0.8,R s9,7.8,0.8,R s11,7.8,0.8,R`,
2900
+ BJ: "HYR r0,0,8,14,G",
2901
+ BM: "HR j0,0,10,7 c15,7.5,2.6,W c15,8.4,1.4,R",
2902
+ BN: "HY p0,3,20,9,20,11.5,0,5.5,W p0,5.5,20,11.5,20,14,0,8,K c10,7,2.5,R",
2903
+ BQ: "HW p0,0,10,0,0,7,Y p20,4,20,14,6,14,B c5.5,6,2,K c5.5,6,1.5,W s5.5,6,1,R",
2904
+ BR: "HG p10,1.5,18.5,7,10,12.5,1.5,7,Y c10,7,3.4,N p6.8,6,13.2,7.6,13.2,8.2,6.8,6.6,W",
2905
+ BS: "HTYT p0,0,8,7,0,14,K",
2906
+ BT: "HO p0,0,20,0,0,14,Y c10,7,2.4,W",
2907
+ BW: "HS r0,5.2,20,3.6,W r0,5.8,20,2.4,K",
2908
+ BZ: "HB r0,0,20,1.2,R r0,12.8,20,1.2,R c10,7,3.8,W c10,7,2.8,G",
2909
+ CA: "HW r0,0,5,14,R r15,0,5,14,R p10,2.5,11,4.5,12,4,11.6,6.5,13.5,5.5,13,7,13.6,7.6,11.3,9,11.6,10,10.2,9.6,10.2,11.5,9.8,11.5,9.8,9.6,8.4,10,8.7,9,6.4,7.6,7,7,6.5,5.5,8.4,6.5,8,4,9,4.5,R",
2910
+ CC: "HG c4,4,2.2,Y p3.5,6,4.5,6,4.2,2.5,3.8,2.5,G c9,7,1.8,Y c9.6,7,1.5,G s16,3,0.8,Y s14,7,0.8,Y s18,7,0.8,Y s16,11,0.8,Y",
2911
+ CD: "HS p0,11,16,0,20,0,20,3,4,14,0,14,Y p0,12.2,17.6,0,20,0,20,1.8,2.4,14,0,14,R s4,3.5,2.2,Y",
2912
+ CF: "HBWGY r8.5,0,3,14,R s3,1.75,1.2,Y",
2913
+ CG: "HY p0,0,13,0,0,14,G p20,0,20,14,7,14,R",
2914
+ CK: `${BLUE_ENSIGN} c15,7,3,W c15,7,2.3,N`,
2915
+ CL: "HWR r0,0,7,7,B s3.5,3.5,1.8,W",
2916
+ CN: "HR s3.5,3.5,2.2,Y s7,1.4,0.7,Y s8.4,2.8,0.7,Y s8.4,4.9,0.7,Y s7,6.3,0.7,Y",
2917
+ CU: "HBWBWB p0,0,10,7,0,14,R s3.3,7,1.8,W",
2918
+ CV: "HB r0,7.4,20,1,W r0,8.4,20,1.2,R r0,9.6,20,1,W s7,6,0.6,Y s9.6,7,0.6,Y s9.6,11,0.6,Y s7,12,0.6,Y s4.4,11,0.6,Y s4.4,7,0.6,Y",
2919
+ CW: "HB r0,9,20,1.8,Y s3,3,1.4,W s5.5,5,1,W",
2920
+ CX: "HB p0,0,20,0,20,14,G c10,7,2,Y s3,10,0.8,W s5.5,12,0.8,W s6,8.5,0.8,W s3,6,0.6,W p13,3,17,2,15,4.5,Y",
2921
+ CY: "HW p3,6,7,4,13,3.5,17,2,15,5,11,7,6,7.5,C p6.5,10.5,9.5,9.2,9.5,10,G p13.5,10.5,10.5,9.2,10.5,10,G",
2922
+ CZ: "HWR p0,0,10,7,0,14,B",
2923
+ DJ: "HSG p0,0,10,7,0,14,W s3.5,7,1.4,R",
2924
+ DM: "HG r8.4,0,1,14,Y r9.4,0,1,14,K r10.4,0,1,14,W r0,5.4,20,1,Y r0,6.4,20,1,K r0,7.4,20,1,W c9.9,6.9,3,R c9.9,6.9,1.2,P",
2925
+ DO: "HW r0,0,8.5,5.5,N r11.5,0,8.5,5.5,R r0,8.5,8.5,5.5,R r11.5,8.5,8.5,5.5,N c10,7,1.2,G",
2926
+ DZ: "VGW c10,7,3.2,R c11.2,7,2.6,W s12.5,7,1.2,R",
2927
+ EC: "HYYBR c10,7,2,Y c10,7,1.4,S",
2928
+ EG: "HRWK p9,5.2,11,5.2,10.6,8.6,9.4,8.6,Y",
2929
+ EH: "HKWG p0,0,7,7,0,14,R c10,7,1.8,R c10.6,7,1.5,W s11,7,0.9,R",
2930
+ ER: "HGB p0,0,20,7,0,14,R c5,7,2.6,Y c5,7,2,R",
2931
+ FJ: "HS j0,0,10,7 r13.5,4,3.5,4.5,W r13.5,4,3.5,1.2,R",
2932
+ FK: `${BLUE_ENSIGN} c15,7,2.6,S c15,8.2,1.4,W`,
2933
+ FM: "HS s10,3.5,1.2,W s6.5,7,1.2,W s13.5,7,1.2,W s10,10.5,1.2,W",
2934
+ GB: "j0,0,20,14",
2935
+ GD: "HR p1.5,1.5,18.5,1.5,10,7,Y p1.5,12.5,18.5,12.5,10,7,Y p1.5,1.5,10,7,1.5,12.5,G p18.5,1.5,10,7,18.5,12.5,G c10,7,2,R s10,7,1.3,Y s5,0.75,0.6,Y s10,0.75,0.6,Y s15,0.75,0.6,Y s5,13.25,0.6,Y s10,13.25,0.6,Y s15,13.25,0.6,Y",
2936
+ GG: "HW r8.5,0,3,14,R r0,5.5,20,3,R r9.6,4.2,0.8,5.6,Y r7.2,6.6,5.6,0.8,Y",
2937
+ GH: "HRYG s10,7,2,K",
2938
+ GI: "HWWR r6.5,3,7,5,R r6.5,1.8,1.5,1.4,R r9.25,1.8,1.5,1.4,R r12,1.8,1.5,1.4,R p9.5,9.3,10.5,9.3,10.5,12,9.5,12,Y",
2939
+ GL: "HWR c7,7,4.5,R p2.5,7,3.1,9.25,4.75,10.9,7,11.5,9.25,10.9,10.9,9.25,11.5,7,W",
2940
+ GQ: "HGWR p0,0,5,7,0,14,B c10,7,1.3,G",
2941
+ GR: "HBWBWBWBWB r0,0,7.78,7.78,B r3.11,0,1.56,7.78,W r0,3.11,7.78,1.56,W",
2942
+ GS: `${BLUE_ENSIGN} c15,7,2.6,W c15,7.5,1.4,Y`,
2943
+ GU: "HR r1,1,18,12,N p10,3,13,7,10,11,7,7,S",
2944
+ GW: "HYG r0,0,7,14,R s3.5,7,2,K",
2945
+ GY: "HG p0,0,20,7,0,14,W p0,0.8,18.6,7,0,13.2,Y p0,0,10,7,0,14,K p0,1,8.6,7,0,13,R",
2946
+ HK: "HR s10,7,3.4,W s10,7,1,R",
2947
+ HM: AUSTRALIA,
2948
+ HN: "HBWB s10,7,0.9,B s6.5,5.8,0.9,B s6.5,8.2,0.9,B s13.5,5.8,0.9,B s13.5,8.2,0.9,B",
2949
+ HR: "HRWB r8.5,3.5,3,4,W r8.5,3.5,1,1,R r10.5,3.5,1,1,R r9.5,4.5,1,1,R r8.5,5.5,1,1,R r10.5,5.5,1,1,R r9.5,6.5,1,1,R",
2950
+ HT: "HBR r7,4.5,6,5,W r9.3,5.3,1.4,3.4,G",
2951
+ IL: "HW r0,1.4,20,2,B r0,10.6,20,2,B p10,4,12.6,8.5,7.4,8.5,B p10,10,7.4,5.5,12.6,5.5,B p10,4.8,11.9,8.1,8.1,8.1,W p10,9.2,8.1,5.9,11.9,5.9,W",
2952
+ IM: "HR p9.6,6.6,6.2,3.4,6.8,2.8,10.4,6.4,W p10,6.4,14.5,4.3,14.8,5.1,10.2,7.2,W p9.6,7.2,9.1,11.8,10,11.9,10.4,7,W",
2953
+ IN: "HOWG c10,7,1.8,N c10,7,1.4,W",
2954
+ IO: "HW r0,3,20,1,N r0,6,20,1,N r0,9,20,1,N r0,12,20,1,N j0,0,10,7 p14,10,15,10,14.8,5,14.2,5,G c14.5,5,1.4,G",
2955
+ IQ: "HRWK r7,5.6,6,1.4,G",
2956
+ JE: `HW ${SALTIRE_A},R ${SALTIRE_B},R p8.8,1.5,11.2,1.5,11.2,3.5,10,4.3,8.8,3.5,R c10,1.2,0.6,Y`,
2957
+ JM: `HG p0,0,10,7,0,14,K p20,0,10,7,20,14,K ${SALTIRE_A},Y ${SALTIRE_B},Y`,
2958
+ JO: "HKWG p0,0,10,7,0,14,R s3.5,7,1.2,W",
2959
+ KE: "HK r0,4.2,20,5.6,W r0,5,20,4,R r0,9.8,20,4.2,G p10,2,12.2,7,10,12,7.8,7,K p10,3,11.4,7,10,11,8.6,7,R r9.8,4,0.4,6,W",
2960
+ KH: "HBRRB p6,9.5,6.5,6.5,8,6.5,8.5,5,9.5,5,10,3.5,10.5,5,11.5,5,12,6.5,13.5,6.5,14,9.5,W",
2961
+ KI: "HR c10,7.2,3,Y r0,7,20,7,B r0,8.2,20,0.8,W r0,10.2,20,0.8,W r0,12.2,20,0.8,W p6.5,3.5,13.5,2.5,10.5,4.5,Y",
2962
+ KM: "HYWRB p0,0,9,7,0,14,G c3.2,7,2.2,W c4,7,1.9,G",
2963
+ KN: "HR p0,0,20,0,0,14,G p0,10,14.3,0,20,0,20,4,5.7,14,0,14,Y p0,11.6,16.6,0,20,0,20,2.4,3.4,14,0,14,K s7,8,0.9,W s13,4,0.9,W",
2964
+ KP: "HB r0,2.4,20,9.2,W r0,2.9,20,8.2,R c6.5,7,2.6,W s6.5,7,2.3,R",
2965
+ KR: "HW c10,7,3.4,R p6.6,7,7.1,8.7,8.3,9.9,10,10.4,11.7,9.9,12.9,8.7,13.4,7,B c8.3,7,1.7,R c11.7,7,1.7,B r3,2,2.4,0.5,K r3,3,2.4,0.5,K r3,4,2.4,0.5,K r14.6,10,2.4,0.5,K r14.6,11,2.4,0.5,K r14.6,12,2.4,0.5,K r3,10,2.4,0.5,K r3,11,2.4,0.5,K r3,12,2.4,0.5,K r14.6,2,2.4,0.5,K r14.6,3,2.4,0.5,K r14.6,4,2.4,0.5,K",
2966
+ KW: "HGWR p0,0,5,4.67,5,9.33,0,14,K",
2967
+ KY: `${BLUE_ENSIGN} c15,7,2.6,W c15,7.8,1.6,R`,
2968
+ KZ: "HS c10,6,2.2,Y p6,9,14,9,10,10.5,Y r1,0,1,14,Y",
2969
+ LB: "HR r0,3.5,20,7,W p10,4.2,13,9.5,7,9.5,G",
2970
+ LC: "HS p10,2,15,12,5,12,W p10,3.5,14,12,6,12,K p10,7,15,12,5,12,Y",
2971
+ LI: "HBR p3,4.5,3,2,4.2,3,5,1.5,5.8,3,7,2,7,4.5,Y",
2972
+ LK: "HY r1,1,2.5,12,G r3.5,1,2.5,12,O r7,1,12,12,A p9,11,17,11,16,4,13,3.5,11,5,Y",
2973
+ LR: "HRWRWRWRWRWR r0,0,6.36,6.36,N s3.18,3.18,1.8,W",
2974
+ LY: "HRKKG c10,7,2.2,W c10.7,7,1.8,K s12.2,7,0.9,W"
2975
+ };
2976
+
2977
+ // src/CountryFlag/data/flagDrawingsMtoZ.ts
2978
+ var USA = "HRWRWRWRWRWRWR r0,0,9,7.54,N s2,1.5,0.5,W s4.5,1.5,0.5,W s7,1.5,0.5,W s3.2,3.8,0.5,W s5.8,3.8,0.5,W s2,6,0.5,W s4.5,6,0.5,W s7,6,0.5,W";
2979
+ var TRIBAND_FIMBRIATED = "HK r0,4.2,20,5.6,W r0,5,20,4,R r0,9.8,20,4.2,G";
2980
+ var FLAG_DRAWINGS_M_TO_Z = {
2981
+ MA: "HR s10,7,3.2,G s10,7,2.4,R",
2982
+ MD: "VBYR p8.5,5,11.5,5,11,8.5,10,9.5,9,8.5,C",
2983
+ ME: "HY r1,1,18,12,R p10,4,13,6,12,10,10,9,8,10,7,6,Y",
2984
+ MG: "HRG r0,0,6.7,14,W",
2985
+ MH: "HN p0,14,20,0.2,20,2.5,O p0,14,20,2.5,20,4.8,W s4.5,4.5,2.2,W",
2986
+ MK: "HR p0,0,3,0,10,7,0,2,Y p20,0,17,0,10,7,20,2,Y p0,14,3,14,10,7,0,12,Y p20,14,17,14,10,7,20,12,Y p8.5,0,11.5,0,10,7,Y p8.5,14,11.5,14,10,7,Y p0,5.5,0,8.5,10,7,Y p20,5.5,20,8.5,10,7,Y c10,7,2.4,R c10,7,2,Y",
2987
+ MM: "HYGR s10,7.4,4,W",
2988
+ MO: "HG c10,8.5,1.8,W p7,10.5,13,10.5,12,11.2,8,11.2,W s10,4,0.9,Y s7.5,5,0.6,Y s12.5,5,0.6,Y s6,6.5,0.6,Y s14,6.5,0.6,Y",
2989
+ MP: "HB c10,7,3.4,O c10,7,2.8,B p9,10,11,10,10.6,4.5,9.4,4.5,I s10,7,1.8,W",
2990
+ MR: "HG r0,0,20,2,R r0,12,20,2,R c10,6.2,3,Y c10,5.2,2.8,G s10,5.4,1,Y",
2991
+ MS: `${BLUE_ENSIGN} c15,7,2.6,S c15,8.2,1.4,G`,
2992
+ MV: "HR r4,3.5,12,7,G c10,7,2.6,W c11,7,2.3,G",
2993
+ MX: "VGWR c10,6.8,1.5,M p8.2,7.6,11.8,7.6,11,9,9,9,G",
2994
+ MY: "HRWRWRWRWRWRWRW r0,0,10,8,N c4,4,2.6,Y c4.8,4,2.2,N s7.6,4,1.6,Y",
2995
+ MZ: "HG r0,4.5,20,5,W r0,5,20,4,K r0,9.5,20,4.5,Y p0,0,8,7,0,14,R s3,7,1.8,Y",
2996
+ NA: "HG p0,0,20,0,0,14,B p0,14,0,11,15.7,0,20,0,20,3,4.3,14,W p0,14,0,12.4,17.7,0,20,0,20,1.6,2.3,14,R s4.5,3.5,2.2,Y",
2997
+ NE: "HOWG c10,7,1.5,O",
2998
+ NF: "VGWG p10,2,12,11,8,11,G r9.6,11,0.8,1.5,G",
2999
+ NI: "HBWB p10,5.2,12,8.6,8,8.6,S",
3000
+ NP: "HW p2,0,14,6,5.5,6,14,13.5,2,13.5,B p3,1.2,11.5,5.5,4,5.5,11.5,12.8,3,12.8,R c5.5,4,1,W s5.5,10,1.3,W",
3001
+ NR: "HN r0,6.3,20,1.4,Y s5,10.5,1.8,W",
3002
+ NU: "HY j0,0,10,7 c5,3.5,1,N s5,3.5,0.8,Y",
3003
+ NZ: `${BLUE_ENSIGN} s15,3,1.1,W s15,3,0.7,R s12.5,7,1.1,W s12.5,7,0.7,R s17.5,6,1,W s17.5,6,0.6,R s15,11,1.2,W s15,11,0.8,R`,
3004
+ OM: "HWRG r0,0,5.5,14,R p1.5,2,4,2,2.75,3.5,W",
3005
+ PA: "HW r10,0,10,7,R r0,7,10,7,B s5,3.5,1.6,B s15,10.5,1.6,R",
3006
+ PG: "HK p0,0,20,0,20,14,R p12,3,17,2,16,4,13,6,Y s4,5,0.8,W s6.5,7,0.8,W s4,10,0.9,W s2,7,0.7,W",
3007
+ PH: "HBR p0,0,10,7,0,14,W c3.2,7,1.4,Y s1.2,1.8,0.6,Y s1.2,12.2,0.6,Y s7.8,7,0.6,Y",
3008
+ PK: "HG r0,0,5,14,W c12.5,7,3.4,W c13.5,6.3,3,G s14.8,5.5,1.2,W",
3009
+ PN: `${BLUE_ENSIGN} p13.5,4,16.5,4,16.5,8,15,9.5,13.5,8,G r13.5,4,3,1.5,S`,
3010
+ PR: "HRWRWR p0,0,10,7,0,14,B s3.5,7,1.8,W",
3011
+ PS: "HKWG p0,0,8,7,0,14,R",
3012
+ PY: "HRWB c10,7,1.6,Y c10,7,1.1,W",
3013
+ QA: "HA p0,0,5.5,0,7.5,0.78,5.5,1.56,7.5,2.33,5.5,3.11,7.5,3.89,5.5,4.67,7.5,5.44,5.5,6.22,7.5,7,5.5,7.78,7.5,8.56,5.5,9.33,7.5,10.11,5.5,10.89,7.5,11.67,5.5,12.44,7.5,13.22,5.5,14,0,14,W",
3014
+ SA: "HG r4,4,12,1.2,W r5,6,10,0.8,W r5,9,10,0.7,W r14.5,8.5,1.2,1.2,W",
3015
+ SB: "HG p0,0,20,0,0,14,B p0,13,18.6,0,20,0,20,1,1.4,14,0,14,Y s2.5,2,0.8,W s6.5,2,0.8,W s4.5,3.5,0.8,W s2.5,5,0.8,W s6.5,5,0.8,W",
3016
+ SC: "HG p0,14,0,0,6.7,0,B p0,14,6.7,0,13.3,0,Y p0,14,13.3,0,20,0,20,4.7,R p0,14,20,4.7,20,9.3,W",
3017
+ SD: "HRWK p0,0,7,7,0,14,G",
3018
+ SG: "HRW c4.5,3.5,2.6,W c5.5,3.5,2.4,R s6.5,1.9,0.5,W s5.3,3,0.5,W s7.7,3,0.5,W s5.8,4.6,0.5,W s7.2,4.6,0.5,W",
3019
+ SH: `${BLUE_ENSIGN} ${SHIELD},S r13.5,3.5,3,1.8,Y`,
3020
+ SI: "HWBR p3.5,2.5,6.5,2.5,6.5,6,5,7.2,3.5,6,B",
3021
+ SK: "HWBR p3.5,3.5,8,3.5,8,9,5.75,10.5,3.5,9,R p5.4,5,6.1,5,6.1,9,5.4,9,W",
3022
+ SM: "HWS c10,7,1.8,Y c10,7,1.2,G",
3023
+ SN: "VGYR s10,7,1.8,G",
3024
+ SO: "HS s10,7,3.2,W",
3025
+ SR: "HG r0,2.8,20,8.4,W r0,4.2,20,5.6,R s10,7,2.4,Y",
3026
+ SS: `${TRIBAND_FIMBRIATED} p0,0,8,7,0,14,B s3,7,1.5,Y`,
3027
+ ST: "HG r0,4,20,6,Y p0,0,6,7,0,14,R s10,7,1.3,K s14.5,7,1.3,K",
3028
+ SX: "HRB p0,0,10,7,0,14,W c3.6,7,1.6,Y c3.6,7,1.1,S",
3029
+ SY: "HRWK s7,7,1.3,G s13,7,1.3,G",
3030
+ SZ: "HB r0,3,20,8,Y r0,4,20,6,R p4,7,10,4.4,16,7,10,9.6,W p10,4.4,16,7,10,9.6,K",
3031
+ TC: `${BLUE_ENSIGN} ${SHIELD},Y`,
3032
+ TD: "VEYR",
3033
+ TG: "HGYGYG r0,0,8.4,8.4,R s4.2,4.2,2.2,W",
3034
+ TJ: "HRWG p8,7.5,12,7.5,11.5,5.8,10,6.6,8.5,5.8,Y",
3035
+ TK: "HN p4,10,16,9,15,11,6,11.5,Y s4,3,0.8,W s7,5,0.8,W s5,7,0.8,W s3,5.5,0.6,W",
3036
+ TL: "HR p0,0,10,7,0,14,Y p0,0,6.7,7,0,14,K s2.4,7,1.3,W",
3037
+ TM: "HG r2.5,0,3,14,A r3.4,0,0.4,14,O r4.2,0,0.4,14,O c9.5,4,2.4,W c10.3,3.6,2.2,G s12,3,0.6,W s12.5,4.6,0.6,W",
3038
+ TN: "HR c10,7,3.5,W c10.4,7,2.6,R c11.1,7,2.1,W s11.2,7,1.2,R",
3039
+ TO: "HR r0,0,8,7,W r3.3,1,1.4,5,R r1.5,2.8,5,1.4,R",
3040
+ TR: "HR c7.5,7,3.5,W c8.4,7,2.8,R s12.3,7,1.5,W",
3041
+ TT: "HR p0,0,5,0,20,10.5,20,14,15,14,0,3.5,W p0,0.7,1,0,4,0,20,11.3,20,13.3,19,14,16,14,0,2.7,K",
3042
+ TV: "HS j0,0,10,7 s13,9,0.7,Y s15,11,0.7,Y s17,8,0.7,Y s12,12,0.7,Y s16,4,0.7,Y s18,11.5,0.7,Y s14,6.5,0.7,Y s18.5,3,0.7,Y s11.5,9.5,0.7,Y",
3043
+ TW: "HR r0,0,10,7,N s5,3.5,2.4,W c5,3.5,1.3,N c5,3.5,1,W",
3044
+ TZ: "HB p0,0,20,0,0,14,G p0,11,15.7,0,20,0,20,3,4.3,14,0,14,Y p0,12.4,17.7,0,20,0,20,1.6,2.3,14,0,14,K",
3045
+ UM: USA,
3046
+ US: USA,
3047
+ UY: "HWBWBWBWBW r0,0,7.78,7.78,W s3.9,3.9,2.6,Y c3.9,3.9,1.5,Y",
3048
+ VA: "VYW p12,4,15,10,14.3,10.3,11.3,4.3,Y p15,4,12,10,12.7,10.3,15.7,4.3,I",
3049
+ VC: "VBYYG p7,7,8.3,4.5,9.6,7,8.3,9.5,G p10.4,7,11.7,4.5,13,7,11.7,9.5,G p8.7,9.5,10,7,11.3,9.5,10,12,G",
3050
+ VG: `${BLUE_ENSIGN} ${SHIELD},G r14.6,4.5,0.8,3.5,W`,
3051
+ VI: "HW p6,5,14,5,12,8,8,8,Y p9,4,11,4,11,10,9,10,Y r9.3,8.4,1.4,2,S",
3052
+ VN: "HR s10,7,3.6,Y",
3053
+ VU: "HRG r0,5.9,20,2.2,Y r0,6.4,20,1.2,K p0,0,10.4,7,0,14,Y p0,1.2,8.6,7,0,12.8,K c3.2,7,1.3,Y",
3054
+ WS: "HR r0,0,10,7,N s5,1.6,0.8,W s3,3.5,0.8,W s7,3,0.8,W s5,5.6,0.9,W s6,4.2,0.5,W",
3055
+ ZA: "HRB p0,0,1.6,0,9.4,4.6,20,4.6,20,9.4,9.4,9.4,1.6,14,0,14,W p0,0.9,8.6,5.6,20,5.6,20,8.4,8.6,8.4,0,13.1,0,11,6.6,7,0,3,G p0,3,6.6,7,0,11,Y p0,4,5,7,0,10,K",
3056
+ ZM: "HG r13,7,2.33,7,R r15.33,7,2.33,7,K r17.67,7,2.33,7,O p14,4,17,3,19,4,16.5,5,O",
3057
+ ZW: "HGYRKRYG p0,0,8.5,7,0,14,K p0,0.6,7.8,7,0,13.4,W s3,7,1.5,R p2.5,6.5,4,5.5,3.6,8,Y"
3058
+ };
3059
+
3060
+ // src/CountryFlag/data/flagDrawings.ts
3061
+ var FLAG_DRAWINGS = { ...FLAG_DRAWINGS_A_TO_L, ...FLAG_DRAWINGS_M_TO_Z };
3062
+
3063
+ // src/CountryFlag/data/flagSpecs.ts
3064
+ var FRENCH = "V BWR";
3065
+ var NORWAY = "N RWB";
3066
+ var FLAG_SPECS = {
3067
+ AE: "H GWK",
3068
+ AF: "V KRG",
3069
+ AM: "H RBO",
3070
+ AR: "H SWS",
3071
+ AT: "H RWR",
3072
+ AX: "N BYR",
3073
+ AZ: "H SRG",
3074
+ BD: "D DR",
3075
+ BE: "V KYR",
3076
+ BG: "H WGR",
3077
+ BL: FRENCH,
3078
+ BO: "H RYG",
3079
+ BV: NORWAY,
3080
+ BY: "H RRG",
3081
+ CH: "P RW",
3082
+ CI: "V OWG",
3083
+ CM: "V GRY",
3084
+ CO: "H YYBR",
3085
+ CR: "H BWRRWB",
3086
+ DE: "H KRY",
3087
+ DK: "N RW",
3088
+ EE: "H BKW",
3089
+ ES: "H RYYR",
3090
+ ET: "H GYR",
3091
+ FI: "N WB",
3092
+ FO: "N WRB",
3093
+ FR: FRENCH,
3094
+ GA: "H GYB",
3095
+ GE: "P WR",
3096
+ GF: FRENCH,
3097
+ GM: "H RBG",
3098
+ GN: "V RYG",
3099
+ GP: FRENCH,
3100
+ GT: "V SWS",
3101
+ HU: "H RWG",
3102
+ ID: "H RW",
3103
+ IE: "V GWO",
3104
+ IR: "H GWR",
3105
+ IS: "N BWR",
3106
+ IT: "V GWR",
3107
+ JP: "D WR",
3108
+ KG: "D RY",
3109
+ LA: "H RNR",
3110
+ LS: "H BWG",
3111
+ LT: "H YGR",
3112
+ LU: "H RWS",
3113
+ LV: "H MWM",
3114
+ MC: "H RW",
3115
+ MF: FRENCH,
3116
+ ML: "V GYR",
3117
+ MN: "V RBR",
3118
+ MQ: FRENCH,
3119
+ MT: "V WR",
3120
+ MU: "H RBYG",
3121
+ MW: "H KRG",
3122
+ NC: FRENCH,
3123
+ NG: "V GWG",
3124
+ NL: "H RWB",
3125
+ NO: NORWAY,
3126
+ PE: "V RWR",
3127
+ PF: FRENCH,
3128
+ PL: "H WR",
3129
+ PM: FRENCH,
3130
+ PT: "V GGRRR",
3131
+ PW: "D SY",
3132
+ RE: FRENCH,
3133
+ RO: "V BYR",
3134
+ RS: "H RBW",
3135
+ RU: "H WBR",
3136
+ RW: "H SSYG",
3137
+ SE: "N BY",
3138
+ SJ: NORWAY,
3139
+ SL: "H GWS",
3140
+ SV: "H BWB",
3141
+ TF: FRENCH,
3142
+ TH: "H RWNNWR",
3143
+ UA: "H BY",
3144
+ UG: "H KYRKYR",
3145
+ UZ: "H SWG",
3146
+ VE: "H YBR",
3147
+ WF: FRENCH,
3148
+ YE: "H RWK",
3149
+ YT: FRENCH
3150
+ };
3151
+
3152
+ // src/CountryFlag/utils/flagPrimitives.ts
3153
+ var FLAG_WIDTH = 20;
3154
+ var FLAG_HEIGHT = 14;
3155
+ var HALF = 2;
3156
+ var STAR_TIPS = 5;
3157
+ var STAR_INNER = 0.4;
3158
+ var DEGREES_HALF_TURN = 180;
3159
+ var STAR_START = -90;
3160
+ var DECIMALS = 100;
3161
+ var JACK_DIAGONAL = 0.12;
3162
+ var JACK_RED_DIAGONAL = 0.05;
3163
+ var JACK_WHITE_CROSS = 3;
3164
+ var JACK_RED_CROSS = 5;
3165
+ function rect(x, y, size, fill) {
3166
+ return { kind: "rect" /* Rect */, x, y, width: size[0], height: size[1], fill };
3167
+ }
3168
+ function field(fill) {
3169
+ return rect(0, 0, [FLAG_WIDTH, FLAG_HEIGHT], fill);
3170
+ }
3171
+ function circle(cx, cy, radius, fill) {
3172
+ return { kind: "circle" /* Circle */, x: cx, y: cy, width: radius * HALF, height: radius * HALF, fill };
3173
+ }
3174
+ function polygon(coords, fill) {
3175
+ const pairs = [];
3176
+ for (let i = 0; i + 1 < coords.length; i += HALF) pairs.push(`${coords[i]},${coords[i + 1]}`);
3177
+ return { kind: "polygon" /* Polygon */, x: 0, y: 0, width: 0, height: 0, fill, points: pairs.join(" ") };
3178
+ }
3179
+ function stripes(fills, vertical) {
3180
+ const step = (vertical ? FLAG_WIDTH : FLAG_HEIGHT) / fills.length;
3181
+ return fills.map((fill, i) => vertical ? rect(i * step, 0, [step, FLAG_HEIGHT], fill) : rect(0, i * step, [FLAG_WIDTH, step], fill));
3182
+ }
3183
+ function round(value) {
3184
+ return Math.round(value * DECIMALS) / DECIMALS;
3185
+ }
3186
+ function star(cx, cy, radius, fill) {
3187
+ const coords = [];
3188
+ for (let i = 0; i < STAR_TIPS * HALF; i++) {
3189
+ const r = i % HALF === 0 ? radius : radius * STAR_INNER;
3190
+ const angle = (STAR_START + i * DEGREES_HALF_TURN / STAR_TIPS) * Math.PI / DEGREES_HALF_TURN;
3191
+ coords.push(round(cx + r * Math.cos(angle)), round(cy + r * Math.sin(angle)));
3192
+ }
3193
+ return polygon(coords, fill);
3194
+ }
3195
+ function diagonals(box, share, fill) {
3196
+ const [x, y, w, h] = box;
3197
+ const dx = w * share;
3198
+ const dy = h * share;
3199
+ const right = x + w;
3200
+ const bottom = y + h;
3201
+ return [
3202
+ polygon([x, y, x + dx, y, right, bottom - dy, right, bottom, right - dx, bottom, x, y + dy], fill),
3203
+ polygon([right, y, right - dx, y, x, bottom - dy, x, bottom, x + dx, bottom, right, y + dy], fill)
3204
+ ];
3205
+ }
3206
+ function cross(box, bar, fill) {
3207
+ const [x, y, w, h] = box;
3208
+ return [rect(x + (w - bar) / HALF, y, [bar, h], fill), rect(x, y + (h - bar) / HALF, [w, bar], fill)];
3209
+ }
3210
+ function unionJack(box, colors) {
3211
+ const [navy, white, red] = colors;
3212
+ const [x, y, w, h] = box;
3213
+ return [
3214
+ rect(x, y, [w, h], navy),
3215
+ ...diagonals(box, JACK_DIAGONAL, white),
3216
+ ...diagonals(box, JACK_RED_DIAGONAL, red),
3217
+ ...cross(box, h / JACK_WHITE_CROSS, white),
3218
+ ...cross(box, h / JACK_RED_CROSS, red)
3219
+ ];
3220
+ }
3221
+
3222
+ // src/CountryFlag/utils/flagDrawing.ts
3223
+ var OP_HORIZONTAL = "H";
3224
+ var OP_VERTICAL = "V";
3225
+ var OP_RECT = "r";
3226
+ var OP_CIRCLE = "c";
3227
+ var OP_POLYGON = "p";
3228
+ var OP_STAR = "s";
3229
+ var OP_JACK = "j";
3230
+ function fillOf(letter) {
3231
+ return FLAG_PALETTE[letter ?? ""] ?? FLAG_FALLBACK_FILL;
3232
+ }
3233
+ function numbers(values) {
3234
+ return values.map(Number);
3235
+ }
3236
+ function drawOp(op) {
3237
+ const kind = op.charAt(0);
3238
+ const body = op.slice(1);
3239
+ if (kind === OP_HORIZONTAL || kind === OP_VERTICAL) return stripes(Array.from(body, fillOf), kind === OP_VERTICAL);
3240
+ const args = body.split(",");
3241
+ const [a = 0, b = 0, c = 0, d = 0] = numbers(args);
3242
+ if (kind === OP_JACK) return unionJack([a, b, c, d], [fillOf("N"), fillOf("W"), fillOf("R")]);
3243
+ const fill = fillOf(args[args.length - 1]);
3244
+ if (kind === OP_RECT) return [rect(a, b, [c, d], fill)];
3245
+ if (kind === OP_CIRCLE) return [circle(a, b, c, fill)];
3246
+ if (kind === OP_STAR) return [star(a, b, c, fill)];
3247
+ if (kind === OP_POLYGON) return [polygon(numbers(args.slice(0, -1)), fill)];
3248
+ return [];
3249
+ }
3250
+ function drawFlag(drawing) {
3251
+ return drawing.split(" ").filter((op) => op !== "").flatMap(drawOp);
3252
+ }
3253
+
3254
+ // src/CountryFlag/utils/flagShapes.ts
3255
+ var CROSS_X = 5.5;
3256
+ var CROSS_Y = 5.5;
3257
+ var CROSS_BAR = 3;
3258
+ var INNER_INSET = 1;
3259
+ var INNER_BAR = 1;
3260
+ var PLUS_ARM_X = 8.5;
3261
+ var PLUS_ARM_Y = 3;
3262
+ var PLUS_SPAN_X = 5;
3263
+ var PLUS_SPAN = 10;
3264
+ var PLUS_ARM_LEN = 8;
3265
+ var DISC_DIAMETER = 8;
3266
+ var HALF2 = 2;
3267
+ function nordic([ground = FLAG_FALLBACK_FILL, cross2 = FLAG_FALLBACK_FILL, inner]) {
3268
+ const shapes = [field(ground), rect(CROSS_X, 0, [CROSS_BAR, FLAG_HEIGHT], cross2), rect(0, CROSS_Y, [FLAG_WIDTH, CROSS_BAR], cross2)];
3269
+ if (inner === void 0) return shapes;
3270
+ return [...shapes, rect(CROSS_X + INNER_INSET, 0, [INNER_BAR, FLAG_HEIGHT], inner), rect(0, CROSS_Y + INNER_INSET, [FLAG_WIDTH, INNER_BAR], inner)];
3271
+ }
3272
+ function centredCross([ground = FLAG_FALLBACK_FILL, cross2 = FLAG_FALLBACK_FILL]) {
3273
+ return [field(ground), rect(PLUS_ARM_X, PLUS_ARM_Y, [CROSS_BAR, PLUS_ARM_LEN], cross2), rect(PLUS_SPAN_X, CROSS_Y, [PLUS_SPAN, CROSS_BAR], cross2)];
3274
+ }
3275
+ function disc([ground = FLAG_FALLBACK_FILL, mark = FLAG_FALLBACK_FILL]) {
3276
+ const circle2 = { kind: "circle" /* Circle */, x: FLAG_WIDTH / HALF2, y: FLAG_HEIGHT / HALF2, width: DISC_DIAMETER, height: DISC_DIAMETER, fill: mark };
3277
+ return [field(ground), circle2];
3278
+ }
3279
+ function isFallbackFlag(code) {
3280
+ const upper = code.toUpperCase();
3281
+ return FLAG_SPECS[upper] === void 0 && FLAG_DRAWINGS[upper] === void 0;
3282
+ }
3283
+ function flagShapes(code) {
3284
+ const upper = code.toUpperCase();
3285
+ const drawing = FLAG_DRAWINGS[upper];
3286
+ if (drawing !== void 0) return drawFlag(drawing);
3287
+ const spec = FLAG_SPECS[upper];
3288
+ if (spec === void 0) return [field(FLAG_FALLBACK_FILL)];
3289
+ const [layout = "", letters = ""] = spec.split(" ");
3290
+ const fills = Array.from(letters, (letter) => FLAG_PALETTE[letter] ?? FLAG_FALLBACK_FILL);
3291
+ if (layout === "V") return stripes(fills, true);
3292
+ if (layout === "N") return nordic(fills);
3293
+ if (layout === "P") return centredCross(fills);
3294
+ if (layout === "D") return disc(fills);
3295
+ return stripes(fills, false);
3296
+ }
3297
+ var EDGE_WIDTH = 0.5;
3298
+ var EDGE_INSET = 0.25;
3299
+ var HALF3 = 2;
3300
+ var VIEW_BOX = `0 0 ${FLAG_WIDTH} ${FLAG_HEIGHT}`;
3301
+ function drawShape(shape, key) {
3302
+ if (shape.kind === "circle" /* Circle */) return /* @__PURE__ */ jsx(Circle, { cx: shape.x, cy: shape.y, fill: shape.fill, r: shape.width / HALF3 }, key);
3303
+ if (shape.kind === "polygon" /* Polygon */) return /* @__PURE__ */ jsx(Polygon, { fill: shape.fill, points: shape.points }, key);
3304
+ return /* @__PURE__ */ jsx(Rect, { fill: shape.fill, height: shape.height, width: shape.width, x: shape.x, y: shape.y }, key);
3305
+ }
3306
+ function CountryFlag({ code, testID }) {
3307
+ return /* @__PURE__ */ jsxs(Svg, { accessibilityElementsHidden: true, "aria-hidden": true, height: FLAG_HEIGHT, importantForAccessibility: "no-hide-descendants", testID, viewBox: VIEW_BOX, width: FLAG_WIDTH, children: [
3308
+ flagShapes(code).map((shape, index) => drawShape(shape, index)),
3309
+ /* @__PURE__ */ jsx(Rect, { fill: "none", height: FLAG_HEIGHT - EDGE_WIDTH, stroke: FLAG_EDGE, strokeWidth: EDGE_WIDTH, width: FLAG_WIDTH - EDGE_WIDTH, x: EDGE_INSET, y: EDGE_INSET })
3310
+ ] });
3311
+ }
3312
+
3313
+ // src/countries/countriesData.ts
3314
+ var COUNTRIES = [
3315
+ { code: "AF", name: "Afghanistan" },
3316
+ { code: "AX", name: "\xC5land Islands" },
3317
+ { code: "AL", name: "Albania" },
3318
+ { code: "DZ", name: "Algeria" },
3319
+ { code: "AS", name: "American Samoa" },
3320
+ { code: "AD", name: "Andorra" },
3321
+ { code: "AO", name: "Angola" },
3322
+ { code: "AI", name: "Anguilla" },
3323
+ { code: "AQ", name: "Antarctica" },
3324
+ { code: "AG", name: "Antigua and Barbuda" },
3325
+ { code: "AR", name: "Argentina" },
3326
+ { code: "AM", name: "Armenia" },
3327
+ { code: "AW", name: "Aruba" },
3328
+ { code: "AU", name: "Australia" },
3329
+ { code: "AT", name: "Austria" },
3330
+ { code: "AZ", name: "Azerbaijan" },
3331
+ { code: "BS", name: "Bahamas" },
3332
+ { code: "BH", name: "Bahrain" },
3333
+ { code: "BD", name: "Bangladesh" },
3334
+ { code: "BB", name: "Barbados" },
3335
+ { code: "BY", name: "Belarus" },
3336
+ { code: "BE", name: "Belgium" },
3337
+ { code: "BZ", name: "Belize" },
3338
+ { code: "BJ", name: "Benin" },
3339
+ { code: "BM", name: "Bermuda" },
3340
+ { code: "BT", name: "Bhutan" },
3341
+ { code: "BO", name: "Bolivia" },
3342
+ { code: "BQ", name: "Bonaire, Sint Eustatius and Saba" },
3343
+ { code: "BA", name: "Bosnia and Herzegovina" },
3344
+ { code: "BW", name: "Botswana" },
3345
+ { code: "BV", name: "Bouvet Island" },
3346
+ { code: "BR", name: "Brazil" },
3347
+ { code: "IO", name: "British Indian Ocean Territory" },
3348
+ { code: "BN", name: "Brunei Darussalam" },
3349
+ { code: "BG", name: "Bulgaria" },
3350
+ { code: "BF", name: "Burkina Faso" },
3351
+ { code: "BI", name: "Burundi" },
3352
+ { code: "CV", name: "Cabo Verde" },
3353
+ { code: "KH", name: "Cambodia" },
3354
+ { code: "CM", name: "Cameroon" },
3355
+ { code: "CA", name: "Canada" },
3356
+ { code: "KY", name: "Cayman Islands" },
3357
+ { code: "CF", name: "Central African Republic" },
3358
+ { code: "TD", name: "Chad" },
3359
+ { code: "CL", name: "Chile" },
3360
+ { code: "CN", name: "China" },
3361
+ { code: "CX", name: "Christmas Island" },
3362
+ { code: "CC", name: "Cocos (Keeling) Islands" },
3363
+ { code: "CO", name: "Colombia" },
3364
+ { code: "KM", name: "Comoros" },
3365
+ { code: "CG", name: "Congo" },
3366
+ { code: "CD", name: "Congo (Democratic Republic)" },
3367
+ { code: "CK", name: "Cook Islands" },
3368
+ { code: "CR", name: "Costa Rica" },
3369
+ { code: "CI", name: "C\xF4te d'Ivoire" },
3370
+ { code: "HR", name: "Croatia" },
3371
+ { code: "CU", name: "Cuba" },
3372
+ { code: "CW", name: "Cura\xE7ao" },
3373
+ { code: "CY", name: "Cyprus" },
3374
+ { code: "CZ", name: "Czechia" },
3375
+ { code: "DK", name: "Denmark" },
3376
+ { code: "DJ", name: "Djibouti" },
3377
+ { code: "DM", name: "Dominica" },
3378
+ { code: "DO", name: "Dominican Republic" },
3379
+ { code: "EC", name: "Ecuador" },
3380
+ { code: "EG", name: "Egypt" },
3381
+ { code: "SV", name: "El Salvador" },
3382
+ { code: "GQ", name: "Equatorial Guinea" },
3383
+ { code: "ER", name: "Eritrea" },
3384
+ { code: "EE", name: "Estonia" },
3385
+ { code: "SZ", name: "Eswatini" },
3386
+ { code: "ET", name: "Ethiopia" },
3387
+ { code: "FK", name: "Falkland Islands" },
3388
+ { code: "FO", name: "Faroe Islands" },
3389
+ { code: "FJ", name: "Fiji" },
3390
+ { code: "FI", name: "Finland" },
3391
+ { code: "FR", name: "France" },
3392
+ { code: "GF", name: "French Guiana" },
3393
+ { code: "PF", name: "French Polynesia" },
3394
+ { code: "TF", name: "French Southern Territories" },
3395
+ { code: "GA", name: "Gabon" },
3396
+ { code: "GM", name: "Gambia" },
3397
+ { code: "GE", name: "Georgia" },
3398
+ { code: "DE", name: "Germany" },
3399
+ { code: "GH", name: "Ghana" },
3400
+ { code: "GI", name: "Gibraltar" },
3401
+ { code: "GR", name: "Greece" },
3402
+ { code: "GL", name: "Greenland" },
3403
+ { code: "GD", name: "Grenada" },
3404
+ { code: "GP", name: "Guadeloupe" },
3405
+ { code: "GU", name: "Guam" },
3406
+ { code: "GT", name: "Guatemala" },
3407
+ { code: "GG", name: "Guernsey" },
3408
+ { code: "GN", name: "Guinea" },
3409
+ { code: "GW", name: "Guinea-Bissau" },
3410
+ { code: "GY", name: "Guyana" },
3411
+ { code: "HT", name: "Haiti" },
3412
+ { code: "HM", name: "Heard Island and McDonald Islands" },
3413
+ { code: "VA", name: "Holy See" },
3414
+ { code: "HN", name: "Honduras" },
3415
+ { code: "HK", name: "Hong Kong" },
3416
+ { code: "HU", name: "Hungary" },
3417
+ { code: "IS", name: "Iceland" },
3418
+ { code: "IN", name: "India" },
3419
+ { code: "ID", name: "Indonesia" },
3420
+ { code: "IR", name: "Iran" },
3421
+ { code: "IQ", name: "Iraq" },
3422
+ { code: "IE", name: "Ireland" },
3423
+ { code: "IM", name: "Isle of Man" },
3424
+ { code: "IL", name: "Israel" },
3425
+ { code: "IT", name: "Italy" },
3426
+ { code: "JM", name: "Jamaica" },
3427
+ { code: "JP", name: "Japan" },
3428
+ { code: "JE", name: "Jersey" },
3429
+ { code: "JO", name: "Jordan" },
3430
+ { code: "KZ", name: "Kazakhstan" },
3431
+ { code: "KE", name: "Kenya" },
3432
+ { code: "KI", name: "Kiribati" },
3433
+ { code: "KP", name: "Korea (North)" },
3434
+ { code: "KR", name: "Korea (South)" },
3435
+ { code: "KW", name: "Kuwait" },
3436
+ { code: "KG", name: "Kyrgyzstan" },
3437
+ { code: "LA", name: "Laos" },
3438
+ { code: "LV", name: "Latvia" },
3439
+ { code: "LB", name: "Lebanon" },
3440
+ { code: "LS", name: "Lesotho" },
3441
+ { code: "LR", name: "Liberia" },
3442
+ { code: "LY", name: "Libya" },
3443
+ { code: "LI", name: "Liechtenstein" },
3444
+ { code: "LT", name: "Lithuania" },
3445
+ { code: "LU", name: "Luxembourg" },
3446
+ { code: "MO", name: "Macao" },
3447
+ { code: "MG", name: "Madagascar" },
3448
+ { code: "MW", name: "Malawi" },
3449
+ { code: "MY", name: "Malaysia" },
3450
+ { code: "MV", name: "Maldives" },
3451
+ { code: "ML", name: "Mali" },
3452
+ { code: "MT", name: "Malta" },
3453
+ { code: "MH", name: "Marshall Islands" },
3454
+ { code: "MQ", name: "Martinique" },
3455
+ { code: "MR", name: "Mauritania" },
3456
+ { code: "MU", name: "Mauritius" },
3457
+ { code: "YT", name: "Mayotte" },
3458
+ { code: "MX", name: "Mexico" },
3459
+ { code: "FM", name: "Micronesia" },
3460
+ { code: "MD", name: "Moldova" },
3461
+ { code: "MC", name: "Monaco" },
3462
+ { code: "MN", name: "Mongolia" },
3463
+ { code: "ME", name: "Montenegro" },
3464
+ { code: "MS", name: "Montserrat" },
3465
+ { code: "MA", name: "Morocco" },
3466
+ { code: "MZ", name: "Mozambique" },
3467
+ { code: "MM", name: "Myanmar" },
3468
+ { code: "NA", name: "Namibia" },
3469
+ { code: "NR", name: "Nauru" },
3470
+ { code: "NP", name: "Nepal" },
3471
+ { code: "NL", name: "Netherlands" },
3472
+ { code: "NC", name: "New Caledonia" },
3473
+ { code: "NZ", name: "New Zealand" },
3474
+ { code: "NI", name: "Nicaragua" },
3475
+ { code: "NE", name: "Niger" },
3476
+ { code: "NG", name: "Nigeria" },
3477
+ { code: "NU", name: "Niue" },
3478
+ { code: "NF", name: "Norfolk Island" },
3479
+ { code: "MK", name: "North Macedonia" },
3480
+ { code: "MP", name: "Northern Mariana Islands" },
3481
+ { code: "NO", name: "Norway" },
3482
+ { code: "OM", name: "Oman" },
3483
+ { code: "PK", name: "Pakistan" },
3484
+ { code: "PW", name: "Palau" },
3485
+ { code: "PS", name: "Palestine" },
3486
+ { code: "PA", name: "Panama" },
3487
+ { code: "PG", name: "Papua New Guinea" },
3488
+ { code: "PY", name: "Paraguay" },
3489
+ { code: "PE", name: "Peru" },
3490
+ { code: "PH", name: "Philippines" },
3491
+ { code: "PN", name: "Pitcairn" },
3492
+ { code: "PL", name: "Poland" },
3493
+ { code: "PT", name: "Portugal" },
3494
+ { code: "PR", name: "Puerto Rico" },
3495
+ { code: "QA", name: "Qatar" },
3496
+ { code: "RE", name: "R\xE9union" },
3497
+ { code: "RO", name: "Romania" },
3498
+ { code: "RU", name: "Russian Federation" },
3499
+ { code: "RW", name: "Rwanda" },
3500
+ { code: "BL", name: "Saint Barth\xE9lemy" },
3501
+ { code: "SH", name: "Saint Helena, Ascension and Tristan da Cunha" },
3502
+ { code: "KN", name: "Saint Kitts and Nevis" },
3503
+ { code: "LC", name: "Saint Lucia" },
3504
+ { code: "MF", name: "Saint Martin (French part)" },
3505
+ { code: "PM", name: "Saint Pierre and Miquelon" },
3506
+ { code: "VC", name: "Saint Vincent and the Grenadines" },
3507
+ { code: "WS", name: "Samoa" },
3508
+ { code: "SM", name: "San Marino" },
3509
+ { code: "ST", name: "Sao Tome and Principe" },
3510
+ { code: "SA", name: "Saudi Arabia" },
3511
+ { code: "SN", name: "Senegal" },
3512
+ { code: "RS", name: "Serbia" },
3513
+ { code: "SC", name: "Seychelles" },
3514
+ { code: "SL", name: "Sierra Leone" },
3515
+ { code: "SG", name: "Singapore" },
3516
+ { code: "SX", name: "Sint Maarten (Dutch part)" },
3517
+ { code: "SK", name: "Slovakia" },
3518
+ { code: "SI", name: "Slovenia" },
3519
+ { code: "SB", name: "Solomon Islands" },
3520
+ { code: "SO", name: "Somalia" },
3521
+ { code: "ZA", name: "South Africa" },
3522
+ { code: "GS", name: "South Georgia and the South Sandwich Islands" },
3523
+ { code: "SS", name: "South Sudan" },
3524
+ { code: "ES", name: "Spain" },
3525
+ { code: "LK", name: "Sri Lanka" },
3526
+ { code: "SD", name: "Sudan" },
3527
+ { code: "SR", name: "Suriname" },
3528
+ { code: "SJ", name: "Svalbard and Jan Mayen" },
3529
+ { code: "SE", name: "Sweden" },
3530
+ { code: "CH", name: "Switzerland" },
3531
+ { code: "SY", name: "Syrian Arab Republic" },
3532
+ { code: "TW", name: "Taiwan" },
3533
+ { code: "TJ", name: "Tajikistan" },
3534
+ { code: "TZ", name: "Tanzania" },
3535
+ { code: "TH", name: "Thailand" },
3536
+ { code: "TL", name: "Timor-Leste" },
3537
+ { code: "TG", name: "Togo" },
3538
+ { code: "TK", name: "Tokelau" },
3539
+ { code: "TO", name: "Tonga" },
3540
+ { code: "TT", name: "Trinidad and Tobago" },
3541
+ { code: "TN", name: "Tunisia" },
3542
+ { code: "TR", name: "T\xFCrkiye" },
3543
+ { code: "TM", name: "Turkmenistan" },
3544
+ { code: "TC", name: "Turks and Caicos Islands" },
3545
+ { code: "TV", name: "Tuvalu" },
3546
+ { code: "UG", name: "Uganda" },
3547
+ { code: "UA", name: "Ukraine" },
3548
+ { code: "AE", name: "United Arab Emirates" },
3549
+ { code: "GB", name: "United Kingdom" },
3550
+ { code: "US", name: "United States" },
3551
+ { code: "UM", name: "United States Minor Outlying Islands" },
3552
+ { code: "UY", name: "Uruguay" },
3553
+ { code: "UZ", name: "Uzbekistan" },
3554
+ { code: "VU", name: "Vanuatu" },
3555
+ { code: "VE", name: "Venezuela" },
3556
+ { code: "VN", name: "Viet Nam" },
3557
+ { code: "VG", name: "Virgin Islands (British)" },
3558
+ { code: "VI", name: "Virgin Islands (U.S.)" },
3559
+ { code: "WF", name: "Wallis and Futuna" },
3560
+ { code: "EH", name: "Western Sahara" },
3561
+ { code: "YE", name: "Yemen" },
3562
+ { code: "ZM", name: "Zambia" },
3563
+ { code: "ZW", name: "Zimbabwe" }
3564
+ ];
3565
+
3566
+ // src/countries/countryOptions.ts
3567
+ var REGIONAL_INDICATOR_A = 127462;
3568
+ var CODE_A = 65;
3569
+ var TWO_LETTERS = /^[A-Z]{2}$/;
3570
+ var KNOWN_CODES = new Set(COUNTRIES.map((country) => country.code));
3571
+ function countryOptions(list = COUNTRIES) {
3572
+ return list.map((country) => ({ label: country.name, value: country.code, detail: country.code }));
3573
+ }
3574
+ function countryFlag(code) {
3575
+ const upper = code.toUpperCase();
3576
+ if (!TWO_LETTERS.test(upper)) return "";
3577
+ return String.fromCodePoint(...Array.from(upper, (letter) => REGIONAL_INDICATOR_A + letter.charCodeAt(0) - CODE_A));
3578
+ }
3579
+ function toCountryValue(input) {
3580
+ const upper = input.trim().toUpperCase();
3581
+ return KNOWN_CODES.has(upper) ? upper : "";
3582
+ }
3583
+ var CODE_FONT = 12;
3584
+ var DEFAULT_OPTIONS = countryOptions();
3585
+ var renderFlag = (option) => /* @__PURE__ */ jsx(CountryFlag, { code: option.value });
3586
+ function CountryField({ value, onChange, accessibilityLabel, accessibilityHint, labels, testID, countries }) {
3587
+ const { theme } = useUi();
3588
+ const { textSecondary } = theme.colors;
3589
+ const options = useMemo(() => countries === void 0 ? DEFAULT_OPTIONS : countryOptions(countries), [countries]);
3590
+ const renderCode = useCallback((option) => /* @__PURE__ */ jsx(Text, { style: [styles24.code, { color: textSecondary }], children: option.detail }), [textSecondary]);
3591
+ return /* @__PURE__ */ jsx(
3592
+ SearchSelect,
3593
+ {
3594
+ accessibilityHint,
3595
+ accessibilityLabel,
3596
+ labels,
3597
+ options,
3598
+ recentKey: "country",
3599
+ renderDetail: renderCode,
3600
+ renderLeading: renderFlag,
3601
+ testID,
3602
+ value: toCountryValue(value),
3603
+ onChange
3604
+ }
3605
+ );
3606
+ }
3607
+ var styles24 = StyleSheet.create({
3608
+ code: { fontSize: CODE_FONT }
3609
+ });
3610
+ function useBlurVerdict(validate) {
3611
+ const [verdict, setVerdict] = useState(null);
3612
+ const onEdit = useCallback(() => setVerdict(null), []);
3613
+ const onLeave = useCallback(() => {
3614
+ const next = validate();
3615
+ setVerdict(next);
3616
+ return next;
3617
+ }, [validate]);
3618
+ return { verdict, onEdit, onLeave };
3619
+ }
3620
+
3621
+ // src/IbanInput/data/ibanCountryLengths.ts
3622
+ var IBAN_LENGTHS = {
3623
+ AD: 24,
3624
+ AE: 23,
3625
+ AL: 28,
3626
+ AT: 20,
3627
+ AZ: 28,
3628
+ BA: 20,
3629
+ BE: 16,
3630
+ BG: 22,
3631
+ BH: 22,
3632
+ BI: 27,
3633
+ BR: 29,
3634
+ BY: 28,
3635
+ CH: 21,
3636
+ CR: 22,
3637
+ CY: 28,
3638
+ CZ: 24,
3639
+ DE: 22,
3640
+ DJ: 27,
3641
+ DK: 18,
3642
+ DO: 28,
3643
+ EE: 20,
3644
+ EG: 29,
3645
+ ES: 24,
3646
+ FI: 18,
3647
+ FK: 18,
3648
+ FO: 18,
3649
+ FR: 27,
3650
+ GB: 22,
3651
+ GE: 22,
3652
+ GI: 23,
3653
+ GL: 18,
3654
+ GR: 27,
3655
+ GT: 28,
3656
+ HN: 28,
3657
+ HR: 21,
3658
+ HU: 28,
3659
+ IE: 22,
3660
+ IL: 23,
3661
+ IQ: 23,
3662
+ IS: 26,
3663
+ IT: 27,
3664
+ JO: 30,
3665
+ KW: 30,
3666
+ KZ: 20,
3667
+ LB: 28,
3668
+ LC: 32,
3669
+ LI: 21,
3670
+ LT: 20,
3671
+ LU: 20,
3672
+ LV: 21,
3673
+ LY: 25,
3674
+ MC: 27,
3675
+ MD: 24,
3676
+ ME: 22,
3677
+ MK: 19,
3678
+ MN: 20,
3679
+ MR: 27,
3680
+ MT: 31,
3681
+ MU: 30,
3682
+ NI: 28,
3683
+ NL: 18,
3684
+ NO: 15,
3685
+ OM: 23,
3686
+ PK: 24,
3687
+ PL: 28,
3688
+ PS: 29,
3689
+ PT: 25,
3690
+ QA: 29,
3691
+ RO: 24,
3692
+ RS: 22,
3693
+ RU: 33,
3694
+ SA: 24,
3695
+ SC: 31,
3696
+ SD: 18,
3697
+ SE: 24,
3698
+ SI: 19,
3699
+ SK: 24,
3700
+ SM: 27,
3701
+ SO: 23,
3702
+ ST: 25,
3703
+ SV: 28,
3704
+ TL: 23,
3705
+ TN: 24,
3706
+ TR: 26,
3707
+ UA: 29,
3708
+ VA: 22,
3709
+ VG: 24,
3710
+ XK: 20,
3711
+ YE: 30
3712
+ };
3713
+ var IBAN_MAX_LENGTH = 34;
3714
+ var IBAN_REGISTERED_COUNTRY_COUNT = Object.keys(IBAN_LENGTHS).length;
3715
+ function ibanLengthFor(country) {
3716
+ return IBAN_LENGTHS[country] ?? null;
3717
+ }
3718
+
3719
+ // src/IbanInput/utils/ibanFormat.ts
3720
+ var NOT_ALPHANUMERIC = /[^A-Za-z0-9]/g;
3721
+ var COUNTRY_PREFIX = /^[A-Z]{2}/;
3722
+ var COUNTRY_LENGTH = 2;
3723
+ var BIC8_LENGTH = 8;
3724
+ var BIC11_LENGTH = 11;
3725
+ var BRANCH_LENGTH = 3;
3726
+ var DEFAULT_GHOST = "0";
3727
+ var DEFAULT_BIC_GHOST = "X";
3728
+ function groupInFours(text) {
3729
+ return text.replace(/(.{4})(?=.)/g, "$1 ");
3730
+ }
3731
+ function cleaned(raw) {
3732
+ return raw.replace(NOT_ALPHANUMERIC, "").toUpperCase();
3733
+ }
3734
+ function draftIban(raw, ghostChar = DEFAULT_GHOST) {
3735
+ const text = cleaned(raw);
3736
+ const country = COUNTRY_PREFIX.test(text) ? text.slice(0, COUNTRY_LENGTH) : "";
3737
+ const expected = country === "" ? null : ibanLengthFor(country);
3738
+ const electronic = text.slice(0, expected ?? IBAN_MAX_LENGTH);
3739
+ const display = groupInFours(electronic);
3740
+ const mask = expected === null ? "" : groupInFours(ghostChar.repeat(expected));
3741
+ return { electronic, display, country, typed: electronic.length, expected, ghost: mask.slice(display.length) };
3742
+ }
3743
+ function ibanCounter(draft) {
3744
+ return draft.expected === null ? null : `${draft.typed} / ${draft.expected}`;
3745
+ }
3746
+ function draftBic(raw, ghostChar = DEFAULT_BIC_GHOST) {
3747
+ const value = cleaned(raw).slice(0, BIC11_LENGTH);
3748
+ const ghost = ghostChar.repeat(Math.max(0, BIC8_LENGTH - value.length));
3749
+ const branchLeft = value.length <= BIC8_LENGTH ? BRANCH_LENGTH : BIC11_LENGTH - value.length;
3750
+ return { value, ghost, branchGhost: ghostChar.repeat(branchLeft) };
3751
+ }
3752
+
3753
+ // src/IbanInput/utils/ibanCaret.ts
3754
+ var GROUP = 4;
3755
+ var ALPHANUMERIC = /[A-Za-z0-9]/;
3756
+ function caretAfterEdit(raw, rawCaret) {
3757
+ const kept = Array.from(raw.slice(0, rawCaret)).filter((char) => ALPHANUMERIC.test(char)).length;
3758
+ const characters = Math.min(kept, draftIban(raw).electronic.length);
3759
+ return characters === 0 ? 0 : characters + Math.floor((characters - 1) / GROUP);
3760
+ }
3761
+ function rawCaretAfterChange(previous, previousCaret, next) {
3762
+ return Math.max(0, Math.min(next.length, previousCaret + next.length - previous.length));
3763
+ }
3764
+
3765
+ // src/IbanInput/hooks/useIbanCaret.ts
3766
+ function useIbanCaret(display) {
3767
+ const [selection, setSelection] = useState({ start: display.length, end: display.length });
3768
+ const onSelectionChange = useCallback((event) => {
3769
+ setSelection(event.nativeEvent.selection);
3770
+ }, []);
3771
+ const placeAfterEdit = useCallback((text) => {
3772
+ const caret = caretAfterEdit(text, rawCaretAfterChange(display, selection.end, text));
3773
+ setSelection({ start: caret, end: caret });
3774
+ }, [display, selection.end]);
3775
+ const clamped = { start: Math.min(selection.start, display.length), end: Math.min(selection.end, display.length) };
3776
+ return { selection: clamped, onSelectionChange, placeAfterEdit };
3777
+ }
3778
+ var FONT_SIZE = 14;
3779
+ var LINE_HEIGHT = 20;
3780
+ var COUNTER_FONT = 12;
3781
+ var BRANCH_OPACITY = 0.5;
3782
+ var GAP2 = 8;
3783
+ var ghostStyles = StyleSheet.create({
3784
+ field: { flex: 1, justifyContent: "center", minHeight: LINE_HEIGHT },
3785
+ mono: { fontFamily: "monospace", fontSize: FONT_SIZE, lineHeight: LINE_HEIGHT },
3786
+ layer: { position: "absolute", left: 0, top: 0, bottom: 0 },
3787
+ hidden: { opacity: 0 },
3788
+ branch: { opacity: BRANCH_OPACITY },
3789
+ input: { padding: 0, borderWidth: 0, minHeight: LINE_HEIGHT },
3790
+ counter: { fontSize: COUNTER_FONT, marginLeft: GAP2 }
3791
+ });
3792
+
3793
+ // src/IbanInput/data/IbanRejection.ts
3794
+ var IbanRejection = /* @__PURE__ */ ((IbanRejection2) => {
3795
+ IbanRejection2["None"] = "None";
3796
+ IbanRejection2["Missing"] = "Missing";
3797
+ IbanRejection2["IllegalCharacter"] = "IllegalCharacter";
3798
+ IbanRejection2["MalformedCountryCode"] = "MalformedCountryCode";
3799
+ IbanRejection2["MalformedCheckDigits"] = "MalformedCheckDigits";
3800
+ IbanRejection2["UnknownCountry"] = "UnknownCountry";
3801
+ IbanRejection2["WrongLengthForCountry"] = "WrongLengthForCountry";
3802
+ IbanRejection2["ChecksumFailed"] = "ChecksumFailed";
3803
+ return IbanRejection2;
3804
+ })(IbanRejection || {});
3805
+
3806
+ // src/IbanInput/utils/iban.ts
3807
+ var COUNTRY_LENGTH2 = 2;
3808
+ var PREFIX_LENGTH = 4;
3809
+ var MODULUS = 97;
3810
+ var VALID_REMAINDER = 1;
3811
+ var LETTER_OFFSET = 10;
3812
+ var DIGIT_SHIFT = 10;
3813
+ var LETTER_SHIFT = 100;
3814
+ var CODE_A2 = 65;
3815
+ var CODE_0 = 48;
3816
+ var LETTER = /^[A-Za-z]$/;
3817
+ var DIGIT = /^[0-9]$/;
3818
+ function refused(rejection, expectedLength = null) {
3819
+ return { rejection, electronic: null, expectedLength };
3820
+ }
3821
+ function stripSeparators(raw) {
3822
+ let out = "";
3823
+ for (const character of raw) {
3824
+ if (character === " ") continue;
3825
+ if (!LETTER.test(character) && !DIGIT.test(character)) return null;
3826
+ out += character.toUpperCase();
3827
+ }
3828
+ return out === "" ? null : out;
3829
+ }
3830
+ function shapeFailure(iban) {
3831
+ if (iban.length <= PREFIX_LENGTH) return refused("MalformedCountryCode" /* MalformedCountryCode */);
3832
+ if (!LETTER.test(iban.charAt(0)) || !LETTER.test(iban.charAt(1))) return refused("MalformedCountryCode" /* MalformedCountryCode */);
3833
+ if (!DIGIT.test(iban.charAt(2)) || !DIGIT.test(iban.charAt(3))) return refused("MalformedCheckDigits" /* MalformedCheckDigits */);
3834
+ const expected = ibanLengthFor(iban.slice(0, COUNTRY_LENGTH2));
3835
+ if (expected === null) return refused("UnknownCountry" /* UnknownCountry */);
3836
+ return iban.length === expected ? null : refused("WrongLengthForCountry" /* WrongLengthForCountry */, expected);
3837
+ }
3838
+ function mod97(iban) {
3839
+ let remainder = 0;
3840
+ for (let index = 0; index < iban.length; index++) {
3841
+ const character = iban.charAt((index + PREFIX_LENGTH) % iban.length);
3842
+ const code = character.charCodeAt(0);
3843
+ remainder = DIGIT.test(character) ? remainder * DIGIT_SHIFT + (code - CODE_0) : remainder * LETTER_SHIFT + (code - CODE_A2 + LETTER_OFFSET);
3844
+ remainder %= MODULUS;
3845
+ }
3846
+ return remainder;
3847
+ }
3848
+ function validateIban(raw) {
3849
+ if (raw === null || raw === void 0 || raw.trim() === "") return refused("Missing" /* Missing */);
3850
+ const normalised = stripSeparators(raw);
3851
+ if (normalised === null) return refused("IllegalCharacter" /* IllegalCharacter */);
3852
+ const failure = shapeFailure(normalised);
3853
+ if (failure !== null) return failure;
3854
+ if (mod97(normalised) !== VALID_REMAINDER) return refused("ChecksumFailed" /* ChecksumFailed */);
3855
+ return { rejection: "None" /* None */, electronic: normalised, expectedLength: null };
3856
+ }
3857
+ function IbanInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID, placeholder }) {
3858
+ const { theme } = useUi();
3859
+ const { colors } = theme;
3860
+ const draft = useMemo(() => draftIban(value), [value]);
3861
+ const validate = useCallback(() => validateIban(value), [value]);
3862
+ const { onEdit, onLeave } = useBlurVerdict(validate);
3863
+ const counter = ibanCounter(draft);
3864
+ const { selection, onSelectionChange, placeAfterEdit } = useIbanCaret(draft.display);
3865
+ const onChangeText = useCallback((text) => {
3866
+ onEdit();
3867
+ onVerdict?.(null);
3868
+ placeAfterEdit(text);
3869
+ onChange(draftIban(text).electronic);
3870
+ }, [onEdit, onVerdict, placeAfterEdit, onChange]);
3871
+ const onBlur = useCallback(() => {
3872
+ const verdict = onLeave();
3873
+ onVerdict?.(value === "" ? null : verdict);
3874
+ }, [onLeave, onVerdict, value]);
3875
+ return /* @__PURE__ */ jsxs(View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: [
3876
+ /* @__PURE__ */ jsxs(View, { style: ghostStyles.field, children: [
3877
+ /* @__PURE__ */ jsxs(Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
3878
+ /* @__PURE__ */ jsx(Text, { style: ghostStyles.hidden, children: draft.display }),
3879
+ /* @__PURE__ */ jsx(Text, { style: { color: colors.textSecondary }, children: draft.ghost })
3880
+ ] }),
3881
+ /* @__PURE__ */ jsx(
3882
+ TextInput,
3883
+ {
3884
+ accessibilityHint,
3885
+ accessibilityLabel,
3886
+ autoCapitalize: "characters",
3887
+ autoComplete: "off",
3888
+ autoCorrect: false,
3889
+ placeholder: draft.display === "" ? placeholder : void 0,
3890
+ placeholderTextColor: colors.textSecondary,
3891
+ selection,
3892
+ spellCheck: false,
3893
+ style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
3894
+ testID,
3895
+ value: draft.display,
3896
+ onBlur,
3897
+ onChangeText,
3898
+ onSelectionChange
3899
+ }
3900
+ )
3901
+ ] }),
3902
+ counter !== null ? /* @__PURE__ */ jsx(Text, { testID: `${testID}-counter`, style: [ghostStyles.counter, { color: colors.textSecondary }], children: counter }) : null
3903
+ ] });
3904
+ }
3905
+
3906
+ // src/IbanInput/data/BicRejection.ts
3907
+ var BicRejection = /* @__PURE__ */ ((BicRejection2) => {
3908
+ BicRejection2["None"] = "None";
3909
+ BicRejection2["Missing"] = "Missing";
3910
+ BicRejection2["IllegalCharacter"] = "IllegalCharacter";
3911
+ BicRejection2["WrongLength"] = "WrongLength";
3912
+ BicRejection2["MalformedInstitution"] = "MalformedInstitution";
3913
+ BicRejection2["MalformedCountry"] = "MalformedCountry";
3914
+ BicRejection2["MalformedLocation"] = "MalformedLocation";
3915
+ return BicRejection2;
3916
+ })(BicRejection || {});
3917
+
3918
+ // src/IbanInput/utils/bic.ts
3919
+ var BIC8_LENGTH2 = 8;
3920
+ var BIC11_LENGTH2 = 11;
3921
+ var COUNTRY_START = 4;
3922
+ var LOCATION_INDEX = 6;
3923
+ var ALPHANUMERIC2 = /^[A-Za-z0-9]*$/;
3924
+ var INSTITUTION = /^[A-Z]{4}/;
3925
+ var COUNTRY = /^[A-Z]{2}$/;
3926
+ var RESERVED_LOCATION = ["0", "1"];
3927
+ var refused2 = (rejection) => ({ rejection, electronic: null });
3928
+ function validateBic(raw) {
3929
+ if (raw === null || raw === void 0 || raw.trim() === "") return refused2("Missing" /* Missing */);
3930
+ const trimmed = raw.trim();
3931
+ if (!ALPHANUMERIC2.test(trimmed)) return refused2("IllegalCharacter" /* IllegalCharacter */);
3932
+ const bic = trimmed.toUpperCase();
3933
+ if (bic.length !== BIC8_LENGTH2 && bic.length !== BIC11_LENGTH2) return refused2("WrongLength" /* WrongLength */);
3934
+ if (!INSTITUTION.test(bic)) return refused2("MalformedInstitution" /* MalformedInstitution */);
3935
+ if (!COUNTRY.test(bic.slice(COUNTRY_START, LOCATION_INDEX))) return refused2("MalformedCountry" /* MalformedCountry */);
3936
+ if (RESERVED_LOCATION.includes(bic.charAt(LOCATION_INDEX))) return refused2("MalformedLocation" /* MalformedLocation */);
3937
+ return { rejection: "None" /* None */, electronic: bic };
3938
+ }
3939
+ function BicInput({ value, onChange, onVerdict, accessibilityLabel, accessibilityHint, testID }) {
3940
+ const { theme } = useUi();
3941
+ const { colors } = theme;
3942
+ const draft = useMemo(() => draftBic(value), [value]);
3943
+ const validate = useCallback(() => validateBic(value), [value]);
3944
+ const { onEdit, onLeave } = useBlurVerdict(validate);
3945
+ const onChangeText = useCallback((text) => {
3946
+ onEdit();
3947
+ onVerdict?.(null);
3948
+ onChange(draftBic(text).value);
3949
+ }, [onEdit, onVerdict, onChange]);
3950
+ const onBlur = useCallback(() => {
3951
+ const verdict = onLeave();
3952
+ onVerdict?.(value === "" ? null : verdict);
3953
+ }, [onLeave, onVerdict, value]);
3954
+ return /* @__PURE__ */ jsx(View, { style: [controlStyles.selectTrigger, { borderColor: colors.border, backgroundColor: colors.surfaceElevated }], children: /* @__PURE__ */ jsxs(View, { style: ghostStyles.field, children: [
3955
+ /* @__PURE__ */ jsxs(Text, { "aria-hidden": true, style: [ghostStyles.mono, ghostStyles.layer], children: [
3956
+ /* @__PURE__ */ jsx(Text, { style: ghostStyles.hidden, children: draft.value }),
3957
+ /* @__PURE__ */ jsx(Text, { style: { color: colors.textSecondary }, children: draft.ghost }),
3958
+ /* @__PURE__ */ jsx(Text, { style: [ghostStyles.branch, { color: colors.textSecondary }], children: draft.branchGhost })
3959
+ ] }),
3960
+ /* @__PURE__ */ jsx(
3961
+ TextInput,
3962
+ {
3963
+ accessibilityHint,
3964
+ accessibilityLabel,
3965
+ autoCapitalize: "characters",
3966
+ autoComplete: "off",
3967
+ autoCorrect: false,
3968
+ spellCheck: false,
3969
+ style: [ghostStyles.mono, ghostStyles.input, { color: colors.text }],
3970
+ testID,
3971
+ value: draft.value,
3972
+ onBlur,
3973
+ onChangeText
3974
+ }
3975
+ )
3976
+ ] }) });
3977
+ }
2475
3978
 
2476
- export { AlignToControl, AnchoredMenu, ChipSelector, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, DateInput, DateRangeControl, DateTimeField, Field, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, INLINE_FIELD_ROW_MIN_WIDTH, InlineFieldRow, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, ResponsiveFormLayout, SelectControl, SelectField, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, controlStyles, groupAriaChecked, inlineFieldRowLayout, isUnmatched, isWideFormLayout, nextHighlight, resolveGroupSelection, resolveStepNeighbours, suggestOptions, toggleGroupSelection, useFocusFirstInvalid, useKeepInView, useRecentValues, useThemedInput };
3979
+ export { AddOnRequest, AlignToControl, AnchoredMenu, BicInput, BicRejection, COUNTRIES, ChipSelector, CountryField, CountryFlag, DEFAULT_MAX_RECENTS, DEFAULT_OPTIONAL_LABEL, DEFAULT_TYPEAHEAD_MAX_SUGGESTIONS, DEFAULT_TYPEAHEAD_MIN_CHARS, DateField, DateInput, DateRangeControl, DateTimeField, FLAG_HEIGHT, FLAG_WIDTH, Field, FixBar, FlagShapeKind, FormActions, FormCell, FormCheckbox, FormField, FormGrid, FormSection, FormStack, FormStatusLine, FormSwitch, IBAN_MAX_LENGTH, IBAN_REGISTERED_COUNTRY_COUNT, INLINE_FIELD_ROW_MIN_WIDTH, IbanInput, IbanRejection, InlineFieldRow, PHONE_MAX_WIDTH, RESPONSIVE_FORM_DEFAULT_BREAKPOINT, ResponsiveFormLayout, SearchSelect, SelectControl, SelectField, SelectSurface, StepperNav, StepperTabs, ThemedTextInput, TypeaheadControl, UploadWithLinkField, buildSearchSelectSections, controlStyles, countryFlag, countryOptions, draftBic, draftIban, findOption, flagShapes, groupAriaChecked, groupInFours, highlightAfterQuery, ibanCounter, ibanLengthFor, inlineFieldRowLayout, isAddOnOpen, isFallbackFlag, isFixBarVisible, isOutside, isUnmatched, isWideFormLayout, moveHighlight, nextHighlight, resolveGroupSelection, resolveSelectMotion, resolveStepNeighbours, suggestOptions, toCountryValue, toggleGroupSelection, useBlurVerdict, useFocusFirstInvalid, useKeepInView, useOutsidePress, useRecentValues, useReducedMotion, useSearchSelectState, useThemedInput, validateBic, validateIban };
2477
3980
  //# sourceMappingURL=index.mjs.map
2478
3981
  //# sourceMappingURL=index.mjs.map