@marktiderman/genesis-ui-native 2.2.0 → 2.3.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (79) hide show
  1. package/README.md +82 -0
  2. package/dist/chunk-7PCWEY6R.js +27 -0
  3. package/dist/chunk-7PCWEY6R.js.map +1 -0
  4. package/dist/chunk-D5RKSPMH.js +24 -0
  5. package/dist/chunk-D5RKSPMH.js.map +1 -0
  6. package/dist/{chunk-5HRGIA6F.js → chunk-EFXCJ5AN.js} +76 -3
  7. package/dist/chunk-EFXCJ5AN.js.map +1 -0
  8. package/dist/{chunk-2WCXMJL6.js → chunk-FIITITXO.js} +67 -108
  9. package/dist/chunk-FIITITXO.js.map +1 -0
  10. package/dist/chunk-H4Q7COTI.js +1587 -0
  11. package/dist/chunk-H4Q7COTI.js.map +1 -0
  12. package/dist/{chunk-TXJT55JC.js → chunk-Q445I7WO.js} +715 -324
  13. package/dist/chunk-Q445I7WO.js.map +1 -0
  14. package/dist/{chunk-ULS7I6ZS.js → chunk-W2UBJ56D.js} +99 -12
  15. package/dist/chunk-W2UBJ56D.js.map +1 -0
  16. package/dist/components/index.d.ts +146 -18
  17. package/dist/components/index.js +6 -4
  18. package/dist/data/index.d.ts +7 -1
  19. package/dist/data/index.js +31 -6
  20. package/dist/data/index.js.map +1 -1
  21. package/dist/hooks/index.js +2 -1
  22. package/dist/icons/lucide.d.ts +7 -0
  23. package/dist/icons/lucide.js +60 -0
  24. package/dist/icons/lucide.js.map +1 -0
  25. package/dist/index.d.ts +3 -2
  26. package/dist/index.js +7 -6
  27. package/dist/layouts/index.d.ts +329 -4
  28. package/dist/layouts/index.js +3 -3
  29. package/dist/native-modules-BGO2MnFF.d.ts +219 -0
  30. package/package.json +34 -5
  31. package/src/__tests__/fake-modules.tsx +134 -0
  32. package/src/__tests__/native-modules-lists.test.tsx +71 -0
  33. package/src/__tests__/native-modules.test.tsx +631 -0
  34. package/src/components/__tests__/refresh-control.test.tsx +35 -0
  35. package/src/components/__tests__/sheet.test.tsx +193 -0
  36. package/src/components/__tests__/toast.test.tsx +15 -0
  37. package/src/components/avatar.tsx +69 -16
  38. package/src/components/date-time-picker.tsx +128 -10
  39. package/src/components/drawer.tsx +158 -68
  40. package/src/components/dropdown-menu.tsx +7 -6
  41. package/src/components/glass-surface.tsx +150 -0
  42. package/src/components/icon.tsx +66 -0
  43. package/src/components/image.tsx +89 -0
  44. package/src/components/index.ts +33 -2
  45. package/src/components/list-item.tsx +29 -9
  46. package/src/components/popover.tsx +12 -9
  47. package/src/components/refresh-control.tsx +11 -45
  48. package/src/components/segmented-control.tsx +7 -1
  49. package/src/components/sheet.tsx +276 -133
  50. package/src/components/skeleton.tsx +75 -53
  51. package/src/components/toast.tsx +185 -87
  52. package/src/data/NativeResourcePage.tsx +48 -3
  53. package/src/data/__tests__/resource-page-offline.test.tsx +47 -0
  54. package/src/hooks/use-reduced-motion.ts +24 -10
  55. package/src/icon-names.ts +62 -0
  56. package/src/icons/lucide.ts +114 -0
  57. package/src/layouts/__tests__/google-sign-in.test.tsx +26 -0
  58. package/src/layouts/__tests__/inbox-page.test.tsx +200 -0
  59. package/src/layouts/__tests__/keyboard-scroll.test.tsx +42 -1
  60. package/src/layouts/__tests__/settings-page-native-look.test.tsx +142 -0
  61. package/src/layouts/__tests__/thread-page.test.tsx +128 -0
  62. package/src/layouts/auth-screen.tsx +6 -3
  63. package/src/layouts/google-sign-in.tsx +42 -0
  64. package/src/layouts/inbox-page.tsx +455 -0
  65. package/src/layouts/index.ts +37 -2
  66. package/src/layouts/keyboard.tsx +61 -9
  67. package/src/layouts/notifications-page.tsx +133 -16
  68. package/src/layouts/settings-page.tsx +117 -14
  69. package/src/layouts/settings-sub-page.tsx +9 -3
  70. package/src/layouts/thread-page.tsx +444 -0
  71. package/src/native-modules.tsx +186 -0
  72. package/dist/chunk-2WCXMJL6.js.map +0 -1
  73. package/dist/chunk-5HRGIA6F.js.map +0 -1
  74. package/dist/chunk-F2TGDKOO.js +0 -43
  75. package/dist/chunk-F2TGDKOO.js.map +0 -1
  76. package/dist/chunk-FZTUSM56.js +0 -935
  77. package/dist/chunk-FZTUSM56.js.map +0 -1
  78. package/dist/chunk-TXJT55JC.js.map +0 -1
  79. package/dist/chunk-ULS7I6ZS.js.map +0 -1
@@ -0,0 +1,1587 @@
1
+ import { NativeListItem, NativeSectionListHeader, NativeEmptyState, NativeRefreshControl } from './chunk-W2UBJ56D.js';
2
+ import { NativeText, NativeButton, useGenesisModules, NativeBadge, NativeInput } from './chunk-EFXCJ5AN.js';
3
+ import { useThemeMode, useThemeRoles } from './chunk-Z3AQYVUA.js';
4
+ import { cn } from './chunk-OHZD7KRO.js';
5
+ import { ScrollView, View, StatusBar, Pressable, Text, TextInput, Platform, StyleSheet, Alert, KeyboardAvoidingView, RefreshControl, SectionList, ActivityIndicator, FlatList, Image } from 'react-native';
6
+ import { SafeAreaView, SafeAreaInsetsContext } from 'react-native-safe-area-context';
7
+ import { jsx, jsxs, Fragment as Fragment$1 } from 'react/jsx-runtime';
8
+ import { nativeColors } from '@marktiderman/genesis-design-system/tokens/native';
9
+ import { createContext, Fragment, useState, useMemo, createElement, useContext, useCallback, useRef, useEffect } from 'react';
10
+ import { renderSlot } from '@marktiderman/genesis-core/slots';
11
+
12
+ function composeHeaderOptions(props) {
13
+ const {
14
+ headerTitle,
15
+ headerLeft,
16
+ headerRight,
17
+ large,
18
+ scrollEdgeBehavior,
19
+ headerOptions
20
+ } = props;
21
+ const opts = {};
22
+ if (headerTitle !== void 0) opts.title = headerTitle;
23
+ if (headerLeft) opts.headerLeft = headerLeft;
24
+ if (headerRight) opts.headerRight = headerRight;
25
+ if (large) {
26
+ opts.headerLargeTitle = true;
27
+ if (scrollEdgeBehavior === "transparent") {
28
+ opts.headerTransparent = true;
29
+ } else if (scrollEdgeBehavior === "opaque") {
30
+ opts.headerLargeTitleShadowVisible = true;
31
+ }
32
+ }
33
+ if (headerOptions) {
34
+ Object.assign(opts, headerOptions);
35
+ }
36
+ return opts;
37
+ }
38
+ var DEFAULT_EDGES = ["left", "right"];
39
+ var TRANSLUCENT_ANDROID_BAR = { translucent: true, backgroundColor: "transparent" };
40
+ function resolveBarStyle(statusBar, resolvedMode) {
41
+ if (statusBar === "auto") {
42
+ return resolvedMode === "dark" ? "light-content" : "dark-content";
43
+ }
44
+ if (statusBar === "light") return "light-content";
45
+ if (statusBar === "dark") return "dark-content";
46
+ return "default";
47
+ }
48
+ function ScreenContainer({
49
+ children,
50
+ scroll = false,
51
+ safeAreaEdges = DEFAULT_EDGES,
52
+ statusBar = "auto",
53
+ themeMode = "system",
54
+ className,
55
+ contentClassName,
56
+ keyboardShouldPersistTaps = "handled",
57
+ style,
58
+ testID
59
+ }) {
60
+ const osMode = useThemeMode();
61
+ const resolvedMode = themeMode === "system" ? osMode : themeMode;
62
+ const barStyle = resolveBarStyle(statusBar, resolvedMode);
63
+ const body = scroll ? /* @__PURE__ */ jsx(
64
+ ScrollView,
65
+ {
66
+ testID: testID ? `${testID}-scroll` : void 0,
67
+ keyboardShouldPersistTaps,
68
+ contentInsetAdjustmentBehavior: "automatic",
69
+ contentContainerClassName: cn("flex-grow", contentClassName),
70
+ children
71
+ }
72
+ ) : /* @__PURE__ */ jsx(
73
+ View,
74
+ {
75
+ testID: testID ? `${testID}-body` : void 0,
76
+ className: cn("flex-1", contentClassName),
77
+ children
78
+ }
79
+ );
80
+ return /* @__PURE__ */ jsxs(
81
+ SafeAreaView,
82
+ {
83
+ testID: testID ?? "screen-container",
84
+ edges: safeAreaEdges,
85
+ className: cn("flex-1 bg-background", className),
86
+ style,
87
+ children: [
88
+ statusBar !== "hidden" ? /* @__PURE__ */ jsx(
89
+ StatusBar,
90
+ {
91
+ barStyle,
92
+ ...TRANSLUCENT_ANDROID_BAR
93
+ }
94
+ ) : /* @__PURE__ */ jsx(StatusBar, { hidden: true }),
95
+ body
96
+ ]
97
+ }
98
+ );
99
+ }
100
+ function NavBarSaveButton({
101
+ onPress,
102
+ label = "Save",
103
+ disabled,
104
+ loading,
105
+ destructive,
106
+ className,
107
+ testID
108
+ }) {
109
+ const isDisabled = !!disabled || !!loading || !onPress;
110
+ return /* @__PURE__ */ jsx(
111
+ Pressable,
112
+ {
113
+ testID: testID ?? "nav-bar-save-button",
114
+ accessibilityRole: "button",
115
+ accessibilityLabel: label,
116
+ accessibilityState: { disabled: isDisabled, busy: !!loading },
117
+ onPress: isDisabled ? void 0 : onPress,
118
+ disabled: isDisabled,
119
+ className: cn("min-h-[44px] justify-center px-3", className),
120
+ hitSlop: 8,
121
+ children: /* @__PURE__ */ jsx(
122
+ Text,
123
+ {
124
+ className: cn(
125
+ "text-base font-semibold",
126
+ destructive ? "text-destructive" : "text-primary",
127
+ isDisabled && "opacity-40"
128
+ ),
129
+ children: loading ? "\u2026" : label
130
+ }
131
+ )
132
+ }
133
+ );
134
+ }
135
+ function NavBarTitle({
136
+ title,
137
+ subtitle,
138
+ onPress,
139
+ className,
140
+ testID
141
+ }) {
142
+ const inner = /* @__PURE__ */ jsxs(View, { className: cn("items-center justify-center", className), children: [
143
+ /* @__PURE__ */ jsx(
144
+ Text,
145
+ {
146
+ testID: testID ? `${testID}-title` : void 0,
147
+ className: "text-base font-semibold text-foreground",
148
+ numberOfLines: 1,
149
+ children: title
150
+ }
151
+ ),
152
+ subtitle ? /* @__PURE__ */ jsx(
153
+ Text,
154
+ {
155
+ testID: testID ? `${testID}-subtitle` : void 0,
156
+ className: "text-xs text-muted-foreground",
157
+ numberOfLines: 1,
158
+ children: subtitle
159
+ }
160
+ ) : null
161
+ ] });
162
+ if (onPress) {
163
+ return /* @__PURE__ */ jsx(
164
+ Pressable,
165
+ {
166
+ testID: testID ?? "nav-bar-title",
167
+ accessibilityRole: "button",
168
+ accessibilityLabel: subtitle ? `${title}, ${subtitle}` : title,
169
+ onPress,
170
+ hitSlop: 8,
171
+ children: inner
172
+ }
173
+ );
174
+ }
175
+ return /* @__PURE__ */ jsx(View, { testID: testID ?? "nav-bar-title", accessibilityRole: "header", children: inner });
176
+ }
177
+ function NavBarSearchBar({
178
+ value,
179
+ onChangeText,
180
+ placeholder = "Search",
181
+ onSubmit,
182
+ clearable = true,
183
+ className,
184
+ testID
185
+ }) {
186
+ return /* @__PURE__ */ jsxs(
187
+ View,
188
+ {
189
+ testID: testID ?? "nav-bar-search",
190
+ className: cn(
191
+ "min-h-[36px] flex-row items-center rounded-full bg-muted px-3",
192
+ className
193
+ ),
194
+ children: [
195
+ /* @__PURE__ */ jsx(
196
+ TextInput,
197
+ {
198
+ testID: testID ? `${testID}-input` : void 0,
199
+ accessibilityLabel: placeholder,
200
+ value,
201
+ onChangeText,
202
+ onSubmitEditing: onSubmit,
203
+ placeholder,
204
+ placeholderTextColor: nativeColors.neutral[400],
205
+ returnKeyType: "search",
206
+ autoCorrect: false,
207
+ autoCapitalize: "none",
208
+ clearButtonMode: clearable ? "while-editing" : "never",
209
+ className: "flex-1 text-base text-foreground"
210
+ }
211
+ ),
212
+ clearable && value.length > 0 ? /* @__PURE__ */ jsx(
213
+ Pressable,
214
+ {
215
+ testID: testID ? `${testID}-clear` : void 0,
216
+ accessibilityRole: "button",
217
+ accessibilityLabel: "Clear search",
218
+ onPress: () => onChangeText(""),
219
+ hitSlop: 8,
220
+ className: "ml-2 px-1",
221
+ children: /* @__PURE__ */ jsx(Text, { className: "text-base text-muted-foreground", children: "\xD7" })
222
+ }
223
+ ) : null
224
+ ]
225
+ }
226
+ );
227
+ }
228
+ function getSettingsPageStackOptions(props) {
229
+ return composeHeaderOptions({
230
+ headerTitle: props.headerTitle ?? "Settings",
231
+ large: props.large ?? true,
232
+ scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
233
+ headerLeft: props.headerLeft,
234
+ headerRight: props.headerRight,
235
+ headerOptions: props.headerOptions
236
+ });
237
+ }
238
+ function SettingsPage({
239
+ sections,
240
+ dangerousActions,
241
+ className,
242
+ testID = "settings-page",
243
+ children,
244
+ slots = {},
245
+ slotProps = {}
246
+ }) {
247
+ const colors = useThemeRoles();
248
+ const inset = Platform.OS === "ios";
249
+ return /* @__PURE__ */ jsxs(
250
+ ScreenContainer,
251
+ {
252
+ scroll: true,
253
+ safeAreaEdges: ["left", "right", "bottom"],
254
+ testID,
255
+ contentClassName: "pb-8",
256
+ className,
257
+ style: { backgroundColor: colors.groupedBackground },
258
+ children: [
259
+ children ? /* @__PURE__ */ jsx(View, { className: "px-4 pt-2", children }) : null,
260
+ sections.map((section) => /* @__PURE__ */ jsxs(
261
+ View,
262
+ {
263
+ testID: `${testID}-section-${section.id}`,
264
+ className: "mt-6",
265
+ children: [
266
+ section.title ? renderSlot(
267
+ DefaultSectionHeader,
268
+ slots.sectionHeader,
269
+ { title: section.title, testID: `${testID}-section-${section.id}-header` },
270
+ slotProps.sectionHeader
271
+ ) : null,
272
+ /* @__PURE__ */ jsxs(
273
+ View,
274
+ {
275
+ testID: `${testID}-section-${section.id}-group`,
276
+ className: inset ? "overflow-hidden" : "border-y",
277
+ style: [
278
+ { backgroundColor: colors.surface, borderColor: colors.separator },
279
+ inset ? { marginHorizontal: IOS_GROUP_MARGIN, borderRadius: iosGroupRadius() } : null
280
+ ],
281
+ children: [
282
+ section.rows.map((row, rowIndex) => /* @__PURE__ */ jsx(Fragment, { children: renderSlot(
283
+ DefaultRow,
284
+ slots.row,
285
+ { ...row, testID: row.testID ?? `${testID}-row-${row.id}`, isLast: rowIndex === section.rows.length - 1 },
286
+ slotProps.row
287
+ ) }, row.id)),
288
+ section.children
289
+ ]
290
+ }
291
+ ),
292
+ section.footnote ? renderSlot(DefaultFootnote, slots.footnote, { text: section.footnote }, slotProps.footnote) : null
293
+ ]
294
+ },
295
+ section.id
296
+ )),
297
+ dangerousActions && dangerousActions.length > 0 ? renderSlot(
298
+ DefaultDangerousActions,
299
+ slots.dangerousActions,
300
+ {
301
+ actions: dangerousActions.map((action) => ({ ...action, testID: action.testID ?? `${testID}-danger-${slug(action.label)}` })),
302
+ testID: `${testID}-dangerous-actions`
303
+ },
304
+ slotProps.dangerousActions
305
+ ) : null
306
+ ]
307
+ }
308
+ );
309
+ }
310
+ var IOS_GROUP_MARGIN = 16;
311
+ function iosGroupRadius() {
312
+ return Number.parseFloat(String(Platform.Version)) >= 26 ? 26 : 10;
313
+ }
314
+ function iosTrailingSeparatorInset() {
315
+ return Platform.OS === "ios" && Number.parseFloat(String(Platform.Version)) >= 26;
316
+ }
317
+ function DefaultSectionHeader({ title, testID }) {
318
+ const colors = useThemeRoles();
319
+ if (Platform.OS === "ios") {
320
+ return /* @__PURE__ */ jsx(
321
+ NativeText,
322
+ {
323
+ testID,
324
+ accessibilityRole: "header",
325
+ accessibilityLabel: title,
326
+ dynamicTypeRamp: "footnote",
327
+ className: "px-4 pb-1.5 pt-2",
328
+ style: {
329
+ marginHorizontal: IOS_GROUP_MARGIN,
330
+ color: colors.secondaryLabel,
331
+ fontSize: 13,
332
+ lineHeight: 18,
333
+ textTransform: "uppercase"
334
+ },
335
+ children: title
336
+ }
337
+ );
338
+ }
339
+ return /* @__PURE__ */ jsx(
340
+ NativeText,
341
+ {
342
+ testID,
343
+ accessibilityRole: "header",
344
+ className: "px-4 pb-2 pt-4 text-primary",
345
+ style: { fontSize: 14, lineHeight: 20, fontWeight: "500" },
346
+ children: title
347
+ }
348
+ );
349
+ }
350
+ function DefaultRow({ isLast, id: _id, leading, ...row }) {
351
+ const colors = useThemeRoles();
352
+ const [leadingWidth, setLeadingWidth] = useState(0);
353
+ return /* @__PURE__ */ jsxs(Fragment$1, { children: [
354
+ /* @__PURE__ */ jsx(
355
+ NativeListItem,
356
+ {
357
+ testID: row.testID,
358
+ className: "bg-transparent",
359
+ title: row.title,
360
+ subtitle: row.subtitle,
361
+ leading: leading ? /* @__PURE__ */ jsx(View, { onLayout: (event) => setLeadingWidth(event.nativeEvent.layout.width), children: leading }) : void 0,
362
+ trailing: row.trailing,
363
+ showChevron: row.showChevron,
364
+ onPress: row.onPress,
365
+ disabled: row.disabled
366
+ }
367
+ ),
368
+ isLast ? null : /* @__PURE__ */ jsxs(
369
+ View,
370
+ {
371
+ testID: `${row.testID}-separator`,
372
+ accessibilityElementsHidden: true,
373
+ importantForAccessibility: "no-hide-descendants",
374
+ className: "flex-row",
375
+ style: { height: StyleSheet.hairlineWidth },
376
+ children: [
377
+ /* @__PURE__ */ jsx(View, { className: "w-4" }),
378
+ leading ? /* @__PURE__ */ jsx(View, { className: "mr-3", style: { width: leadingWidth } }) : null,
379
+ /* @__PURE__ */ jsx(View, { testID: `${row.testID}-separator-line`, className: "flex-1", style: { backgroundColor: colors.separator } }),
380
+ iosTrailingSeparatorInset() ? /* @__PURE__ */ jsx(View, { className: "w-4" }) : null
381
+ ]
382
+ }
383
+ )
384
+ ] });
385
+ }
386
+ function DefaultFootnote({ text }) {
387
+ const colors = useThemeRoles();
388
+ if (Platform.OS === "ios") {
389
+ return /* @__PURE__ */ jsx(
390
+ NativeText,
391
+ {
392
+ dynamicTypeRamp: "footnote",
393
+ className: "px-4 pt-1.5",
394
+ style: { marginHorizontal: IOS_GROUP_MARGIN, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18 },
395
+ children: text
396
+ }
397
+ );
398
+ }
399
+ return /* @__PURE__ */ jsx(NativeText, { preset: "body-sm", className: "px-4 pt-2", style: { color: colors.secondaryLabel }, children: text });
400
+ }
401
+ function DefaultDangerousActions({ actions, testID }) {
402
+ return /* @__PURE__ */ jsx(View, { testID, className: cn("mt-8 gap-2 px-4"), children: actions.map((action) => /* @__PURE__ */ jsx(
403
+ NativeButton,
404
+ {
405
+ testID: action.testID,
406
+ variant: action.emphasized ? "destructive" : "outline",
407
+ onPress: action.onPress,
408
+ children: action.label
409
+ },
410
+ action.label
411
+ )) });
412
+ }
413
+ function slug(s) {
414
+ return s.toLowerCase().replace(/[^a-z0-9]+/g, "-").replace(/^-|-$/g, "");
415
+ }
416
+ var KEYBOARD_TOOLBAR_HEIGHT = 42;
417
+ var KeyboardScrollContext = createContext(null);
418
+ function KeyboardScrollProvider({
419
+ component,
420
+ toolbar,
421
+ children
422
+ }) {
423
+ const value = useMemo(() => ({ component, toolbar: toolbar ?? null }), [component, toolbar]);
424
+ return createElement(KeyboardScrollContext.Provider, { value }, children);
425
+ }
426
+ function useKeyboardScroll() {
427
+ return useContext(KeyboardScrollContext)?.component ?? null;
428
+ }
429
+ function useKeyboardToolbar() {
430
+ return useContext(KeyboardScrollContext)?.toolbar ?? null;
431
+ }
432
+ function confirmDiscardChanges(proceed) {
433
+ Alert.alert(
434
+ "Discard changes?",
435
+ "You have unsaved changes. Leave this screen and lose them?",
436
+ [
437
+ { text: "Keep editing", style: "cancel" },
438
+ {
439
+ text: "Discard",
440
+ style: "destructive",
441
+ onPress: () => proceed()
442
+ }
443
+ ]
444
+ );
445
+ }
446
+ function getSettingsSubPageStackOptions(props) {
447
+ const {
448
+ headerTitle,
449
+ dirty,
450
+ saving,
451
+ onSave,
452
+ saveLabel = "Save",
453
+ large = false,
454
+ scrollEdgeBehavior,
455
+ headerLeft,
456
+ headerRight,
457
+ headerOptions
458
+ } = props;
459
+ const resolvedHeaderRight = headerRight ?? (onSave ? () => /* @__PURE__ */ jsx(
460
+ NavBarSaveButton,
461
+ {
462
+ label: saveLabel,
463
+ onPress: () => {
464
+ void onSave();
465
+ },
466
+ disabled: !dirty,
467
+ loading: saving
468
+ }
469
+ ) : void 0);
470
+ return composeHeaderOptions({
471
+ headerTitle,
472
+ headerLeft,
473
+ headerRight: resolvedHeaderRight,
474
+ large,
475
+ scrollEdgeBehavior,
476
+ headerOptions
477
+ });
478
+ }
479
+ function SettingsSubPage({
480
+ children,
481
+ onConfirmLeave,
482
+ className,
483
+ testID = "settings-sub-page"
484
+ }) {
485
+ useCallback(
486
+ (proceed) => {
487
+ if (onConfirmLeave === null) {
488
+ proceed();
489
+ return;
490
+ }
491
+ const fn = onConfirmLeave ?? confirmDiscardChanges;
492
+ fn(proceed);
493
+ },
494
+ [onConfirmLeave]
495
+ );
496
+ const KeyboardScroll = useKeyboardScroll();
497
+ const KeyboardToolbar = useKeyboardToolbar();
498
+ if (KeyboardScroll) {
499
+ return /* @__PURE__ */ jsxs(ScreenContainer, { safeAreaEdges: ["left", "right"], testID, children: [
500
+ /* @__PURE__ */ jsx(
501
+ KeyboardScroll,
502
+ {
503
+ testID: `${testID}-keyboard`,
504
+ keyboardShouldPersistTaps: "handled",
505
+ contentInsetAdjustmentBehavior: "automatic",
506
+ bottomOffset: KeyboardToolbar ? 24 + KEYBOARD_TOOLBAR_HEIGHT : 24,
507
+ children: /* @__PURE__ */ jsx(View, { className: cn("p-4", className), children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children }) })
508
+ }
509
+ ),
510
+ KeyboardToolbar ? /* @__PURE__ */ jsx(KeyboardToolbar, {}) : null
511
+ ] });
512
+ }
513
+ return /* @__PURE__ */ jsx(
514
+ KeyboardAvoidingView,
515
+ {
516
+ testID: `${testID}-kav`,
517
+ style: { flex: 1 },
518
+ behavior: Platform.OS === "ios" ? "padding" : void 0,
519
+ children: /* @__PURE__ */ jsx(
520
+ ScreenContainer,
521
+ {
522
+ scroll: true,
523
+ safeAreaEdges: ["left", "right", "bottom"],
524
+ testID,
525
+ contentClassName: cn("p-4", className),
526
+ keyboardShouldPersistTaps: "handled",
527
+ children: /* @__PURE__ */ jsx(View, { testID: `${testID}-form`, className: "gap-4", children })
528
+ }
529
+ )
530
+ }
531
+ );
532
+ }
533
+ function getNotificationsPageStackOptions(props) {
534
+ const {
535
+ headerTitle,
536
+ onMarkAllRead,
537
+ large,
538
+ scrollEdgeBehavior,
539
+ headerLeft,
540
+ headerRight,
541
+ headerOptions
542
+ } = props;
543
+ const resolvedHeaderRight = headerRight ?? (onMarkAllRead ? () => /* @__PURE__ */ jsx(
544
+ Pressable,
545
+ {
546
+ testID: "notifications-mark-all-read",
547
+ accessibilityRole: "button",
548
+ accessibilityLabel: "Mark all read",
549
+ onPress: onMarkAllRead,
550
+ hitSlop: 8,
551
+ className: "min-h-[44px] justify-center px-3",
552
+ children: /* @__PURE__ */ jsx(Text, { className: "text-base text-primary", children: "Mark all read" })
553
+ }
554
+ ) : void 0);
555
+ return composeHeaderOptions({
556
+ headerTitle: headerTitle ?? "Notifications",
557
+ headerLeft,
558
+ headerRight: resolvedHeaderRight,
559
+ large: large ?? true,
560
+ scrollEdgeBehavior: scrollEdgeBehavior ?? "match",
561
+ headerOptions
562
+ });
563
+ }
564
+ function bucketFor(ts, now = /* @__PURE__ */ new Date()) {
565
+ const d = typeof ts === "string" ? new Date(ts) : ts;
566
+ const startOfDay = (date) => {
567
+ const x = new Date(date);
568
+ x.setHours(0, 0, 0, 0);
569
+ return x.getTime();
570
+ };
571
+ const today = startOfDay(now);
572
+ const yesterday = today - 24 * 60 * 60 * 1e3;
573
+ const day = startOfDay(d);
574
+ if (day === today) return "Today";
575
+ if (day === yesterday) return "Yesterday";
576
+ return "Earlier";
577
+ }
578
+ function groupByDate(items, now = /* @__PURE__ */ new Date()) {
579
+ const map = /* @__PURE__ */ new Map();
580
+ for (const item of items) {
581
+ const bucket = bucketFor(item.timestamp, now);
582
+ const arr = map.get(bucket) ?? [];
583
+ arr.push(item);
584
+ map.set(bucket, arr);
585
+ }
586
+ const order = ["Today", "Yesterday", "Earlier"];
587
+ return order.filter((title) => map.has(title)).map((title) => ({
588
+ title,
589
+ data: map.get(title) ?? []
590
+ }));
591
+ }
592
+ function flattenSections(sections) {
593
+ const rows = [];
594
+ const headerIndices = [];
595
+ for (const section of sections) {
596
+ headerIndices.push(rows.length);
597
+ rows.push({ kind: "header", title: section.title });
598
+ section.data.forEach((item, i) => rows.push({ kind: "item", item, last: i === section.data.length - 1 }));
599
+ }
600
+ return { rows, headerIndices };
601
+ }
602
+ function flatRowKey(row) {
603
+ return row.kind === "header" ? `header:${row.title}` : row.item.id;
604
+ }
605
+ function flatRowType(row) {
606
+ return row.kind === "header" ? "header" : row.last ? "item-last" : "item";
607
+ }
608
+ var NO_SLOTS = {};
609
+ function iosCompactNavigationBarHeight(version) {
610
+ const major = typeof version === "number" ? version : parseInt(version, 10);
611
+ return Number.isFinite(major) && major >= 26 ? 54 : 44;
612
+ }
613
+ function defaultStickyHeaderOffset(os, version, safeAreaTop) {
614
+ return os === "ios" ? safeAreaTop + iosCompactNavigationBarHeight(version) : 0;
615
+ }
616
+ function NotificationsPage({
617
+ items,
618
+ refreshing,
619
+ onRefresh,
620
+ emptyState,
621
+ emptyTitle,
622
+ emptyBody,
623
+ className,
624
+ testID = "notifications-page",
625
+ slots = NO_SLOTS,
626
+ slotProps = NO_SLOTS,
627
+ stickyHeaderOffset
628
+ }) {
629
+ const safeTop = useContext(SafeAreaInsetsContext)?.top ?? 0;
630
+ const stickAt = stickyHeaderOffset ?? defaultStickyHeaderOffset(Platform.OS, Platform.Version, safeTop);
631
+ const sections = useMemo(() => groupByDate(items), [items]);
632
+ const { list: FlashList } = useGenesisModules();
633
+ const flat = useMemo(() => flattenSections(sections), [sections]);
634
+ const renderFlatRow = useCallback(
635
+ ({ item: row }) => row.kind === "header" ? renderSlot(DefaultSectionHeader2, slots.sectionHeader, { title: row.title }, slotProps.sectionHeader) : /* @__PURE__ */ jsxs(Fragment$1, { children: [
636
+ renderSlot(DefaultRow2, slots.row, { ...row.item, testID: row.item.testID ?? `${testID}-row-${row.item.id}` }, slotProps.row),
637
+ row.last ? null : /* @__PURE__ */ jsx(RowSeparator, {})
638
+ ] }),
639
+ [slots, slotProps, testID]
640
+ );
641
+ if (items.length === 0) {
642
+ return /* @__PURE__ */ jsx(
643
+ SafeAreaView,
644
+ {
645
+ testID,
646
+ edges: ["left", "right", "bottom"],
647
+ className: cn("flex-1 bg-background", className),
648
+ children: /* @__PURE__ */ jsx(
649
+ ScrollView,
650
+ {
651
+ testID: `${testID}-empty-scroll`,
652
+ contentInsetAdjustmentBehavior: "automatic",
653
+ contentContainerStyle: { flexGrow: 1, justifyContent: "center" },
654
+ refreshControl: onRefresh ? /* @__PURE__ */ jsx(RefreshControl, { testID: `${testID}-refresh`, refreshing: !!refreshing, onRefresh }) : void 0,
655
+ children: emptyState ?? renderSlot(
656
+ DefaultEmpty,
657
+ slots.empty,
658
+ {
659
+ title: emptyTitle ?? "No notifications",
660
+ body: emptyBody ?? "When you get a notification, it'll show up here.",
661
+ testID: `${testID}-empty`
662
+ },
663
+ slotProps.empty
664
+ )
665
+ }
666
+ )
667
+ }
668
+ );
669
+ }
670
+ if (FlashList) {
671
+ return /* @__PURE__ */ jsx(
672
+ SafeAreaView,
673
+ {
674
+ testID,
675
+ edges: ["left", "right", "bottom"],
676
+ className: cn("flex-1 bg-background", className),
677
+ children: /* @__PURE__ */ jsx(
678
+ FlashList,
679
+ {
680
+ testID: `${testID}-list`,
681
+ data: flat.rows,
682
+ keyExtractor: flatRowKey,
683
+ getItemType: flatRowType,
684
+ stickyHeaderIndices: flat.headerIndices,
685
+ stickyHeaderConfig: { offset: stickAt },
686
+ renderItem: renderFlatRow,
687
+ refreshing: onRefresh ? !!refreshing : void 0,
688
+ onRefresh: onRefresh ? () => void onRefresh() : void 0,
689
+ contentContainerStyle: { paddingBottom: 28 }
690
+ }
691
+ )
692
+ }
693
+ );
694
+ }
695
+ return /* @__PURE__ */ jsx(
696
+ SafeAreaView,
697
+ {
698
+ testID,
699
+ edges: ["left", "right", "bottom"],
700
+ className: cn("flex-1 bg-background", className),
701
+ children: /* @__PURE__ */ jsx(
702
+ SectionList,
703
+ {
704
+ testID: `${testID}-list`,
705
+ sections,
706
+ keyExtractor: (item) => item.id,
707
+ renderSectionHeader: ({ section }) => renderSlot(DefaultSectionHeader2, slots.sectionHeader, { title: section.title }, slotProps.sectionHeader),
708
+ renderItem: ({ item }) => renderSlot(DefaultRow2, slots.row, { ...item, testID: item.testID ?? `${testID}-row-${item.id}` }, slotProps.row),
709
+ ItemSeparatorComponent: RowSeparator,
710
+ stickySectionHeadersEnabled: stickAt === 0,
711
+ refreshControl: onRefresh ? /* @__PURE__ */ jsx(
712
+ RefreshControl,
713
+ {
714
+ testID: `${testID}-refresh`,
715
+ refreshing: !!refreshing,
716
+ onRefresh
717
+ }
718
+ ) : void 0,
719
+ contentContainerClassName: "pb-8"
720
+ }
721
+ )
722
+ }
723
+ );
724
+ }
725
+ function RowSeparator() {
726
+ return /* @__PURE__ */ jsx(View, { className: "h-px bg-border ml-4" });
727
+ }
728
+ function DefaultSectionHeader2({ title }) {
729
+ return /* @__PURE__ */ jsx(NativeSectionListHeader, { title });
730
+ }
731
+ function DefaultRow2(item) {
732
+ return /* @__PURE__ */ jsx(
733
+ NativeListItem,
734
+ {
735
+ testID: item.testID,
736
+ title: item.title,
737
+ subtitle: item.body,
738
+ leading: item.leading ?? /* @__PURE__ */ jsx(UnreadDot, { unread: !!item.unread, testID: `${item.testID}-unread` }),
739
+ onPress: item.onPress
740
+ }
741
+ );
742
+ }
743
+ function DefaultEmpty({ title, body, testID }) {
744
+ return /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title, body, testID });
745
+ }
746
+ function UnreadDot({
747
+ unread,
748
+ testID
749
+ }) {
750
+ if (!unread) {
751
+ return /* @__PURE__ */ jsx(View, { className: "h-2 w-2", testID });
752
+ }
753
+ return /* @__PURE__ */ jsx(
754
+ View,
755
+ {
756
+ testID,
757
+ accessibilityLabel: "Unread",
758
+ className: "h-2 w-2 rounded-full bg-primary"
759
+ }
760
+ );
761
+ }
762
+ function getInboxPageStackOptions(props) {
763
+ return composeHeaderOptions({
764
+ headerTitle: props.headerTitle ?? "Inbox",
765
+ large: props.large ?? true,
766
+ scrollEdgeBehavior: props.scrollEdgeBehavior ?? "match",
767
+ headerLeft: props.headerLeft,
768
+ headerRight: props.headerRight,
769
+ headerOptions: props.headerOptions
770
+ });
771
+ }
772
+ var DAY_MS = 24 * 60 * 60 * 1e3;
773
+ function formatInboxTime(date, now) {
774
+ const start = (d) => new Date(d.getFullYear(), d.getMonth(), d.getDate()).getTime();
775
+ const days = Math.round((start(now) - start(date)) / DAY_MS);
776
+ if (days <= 0) return date.toLocaleTimeString(void 0, { hour: "numeric", minute: "2-digit" });
777
+ if (days === 1) return "Yesterday";
778
+ if (days < 7) return date.toLocaleDateString(void 0, { weekday: "long" });
779
+ return date.toLocaleDateString(void 0, { day: "numeric", month: "short", year: date.getFullYear() === now.getFullYear() ? void 0 : "numeric" });
780
+ }
781
+ var ROW_PADDING = 16;
782
+ var LEADING_WIDTH = 18;
783
+ var DEFAULT_AVATAR = 40;
784
+ var AVATAR_GAP = 12;
785
+ var IOS_GROUP_MARGIN2 = 16;
786
+ function iosGroupRadius2() {
787
+ return Number.parseFloat(String(Platform.Version)) >= 26 ? 26 : 10;
788
+ }
789
+ function InboxPage({
790
+ items,
791
+ refreshing,
792
+ onRefresh,
793
+ onEndReached,
794
+ loadingMore = false,
795
+ header,
796
+ sectionTitle,
797
+ emptyTitle,
798
+ emptyBody,
799
+ emptyActionLabel,
800
+ onEmptyAction,
801
+ loading = false,
802
+ error = false,
803
+ errorTitle,
804
+ errorBody,
805
+ formatTime = formatInboxTime,
806
+ now = () => /* @__PURE__ */ new Date(),
807
+ slots = {},
808
+ slotProps = {},
809
+ testID = "inbox-page"
810
+ }) {
811
+ const colors = useThemeRoles();
812
+ const clock = now();
813
+ const rows = items.map((item, index) => ({
814
+ ...item,
815
+ testID: item.testID ?? `${testID}-row-${item.id}`,
816
+ isFirst: index === 0,
817
+ isLast: index === items.length - 1,
818
+ timeLabel: item.timestamp ? formatTime(typeof item.timestamp === "string" ? new Date(item.timestamp) : item.timestamp, clock) : null
819
+ }));
820
+ const headerNode = /* @__PURE__ */ jsxs(View, { children: [
821
+ header ?? renderSlot(EmptyPart, slots.header, { testID: `${testID}-header` }, slotProps.header),
822
+ sectionTitle ? /* @__PURE__ */ jsx(SectionTitle, { title: sectionTitle, testID: `${testID}-section-title` }) : null
823
+ ] });
824
+ const refreshControl = onRefresh ? /* @__PURE__ */ jsx(NativeRefreshControl, { testID: `${testID}-refresh`, refreshing: !!refreshing, onRefresh: () => void onRefresh() }) : void 0;
825
+ if (items.length === 0) {
826
+ return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: /* @__PURE__ */ jsxs(
827
+ ScrollView,
828
+ {
829
+ testID: `${testID}-empty-scroll`,
830
+ contentInsetAdjustmentBehavior: "automatic",
831
+ keyboardShouldPersistTaps: "handled",
832
+ contentContainerStyle: { flexGrow: 1, paddingTop: 8, paddingBottom: 32 },
833
+ refreshControl,
834
+ children: [
835
+ headerNode,
836
+ loading ? /* @__PURE__ */ jsx(View, { testID: `${testID}-loading`, style: { paddingVertical: 32 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { accessibilityLabel: "Loading" }) }) : renderSlot(
837
+ DefaultEmpty2,
838
+ slots.empty,
839
+ error ? {
840
+ title: errorTitle ?? "Couldn't load this",
841
+ body: errorBody ?? "Check your connection, then pull to refresh.",
842
+ actionLabel: onRefresh ? "Try again" : void 0,
843
+ onAction: onRefresh ? () => void onRefresh() : void 0,
844
+ testID: `${testID}-error`
845
+ } : {
846
+ title: emptyTitle ?? "Nothing here yet",
847
+ body: emptyBody ?? "When there's something new, it shows up here.",
848
+ actionLabel: emptyActionLabel,
849
+ onAction: onEmptyAction,
850
+ testID: `${testID}-empty`
851
+ },
852
+ slotProps.empty
853
+ )
854
+ ]
855
+ }
856
+ ) });
857
+ }
858
+ return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: { flex: 1, backgroundColor: colors.groupedBackground }, children: /* @__PURE__ */ jsx(
859
+ FlatList,
860
+ {
861
+ testID: `${testID}-list`,
862
+ data: rows,
863
+ keyExtractor: (row) => row.id,
864
+ contentInsetAdjustmentBehavior: "automatic",
865
+ keyboardShouldPersistTaps: "handled",
866
+ ListHeaderComponent: headerNode,
867
+ ListFooterComponent: renderSlot(DefaultFooter, slots.footer, { loadingMore, testID: `${testID}-footer` }, slotProps.footer),
868
+ contentContainerStyle: { paddingTop: 8, paddingBottom: 32 },
869
+ onEndReached,
870
+ onEndReachedThreshold: 0.5,
871
+ refreshControl,
872
+ renderItem: ({ item: row }) => {
873
+ const content = renderSlot(DefaultRow3, slots.row, row, slotProps.row);
874
+ const actions = row.swipeActions ?? [];
875
+ return /* @__PURE__ */ jsx(Fragment, { children: actions.length && slots.swipeable !== null ? renderSlot(PassThroughSwipeable, slots.swipeable, { actions, testID: `${row.testID}-swipe`, children: content }, slotProps.swipeable) : content });
876
+ }
877
+ }
878
+ ) });
879
+ }
880
+ function EmptyPart(_props) {
881
+ return null;
882
+ }
883
+ function PassThroughSwipeable({ children }) {
884
+ return /* @__PURE__ */ jsx(Fragment$1, { children });
885
+ }
886
+ function SectionTitle({ title, testID }) {
887
+ const colors = useThemeRoles();
888
+ const ios = Platform.OS === "ios";
889
+ return /* @__PURE__ */ jsx(
890
+ NativeText,
891
+ {
892
+ testID,
893
+ accessibilityRole: "header",
894
+ className: ios ? "px-4 pb-1.5 pt-2" : "px-4 pb-2 pt-4 text-primary",
895
+ style: ios ? { marginHorizontal: IOS_GROUP_MARGIN2, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18, textTransform: "uppercase" } : { fontSize: 14, lineHeight: 20, fontWeight: "500" },
896
+ children: title
897
+ }
898
+ );
899
+ }
900
+ function showInboxActions(title, actions, cancelLabel = "Cancel") {
901
+ Alert.alert(title, void 0, [
902
+ ...actions.map((a) => ({ text: a.label, style: a.destructive ? "destructive" : "default", onPress: a.onPress })),
903
+ { text: cancelLabel, style: "cancel" }
904
+ ]);
905
+ }
906
+ function DefaultRow3(row) {
907
+ const colors = useThemeRoles();
908
+ const ios = Platform.OS === "ios";
909
+ const [pressed, setPressed] = useState(false);
910
+ const actions = row.swipeActions ?? [];
911
+ const radius = iosGroupRadius2();
912
+ const unreadLabel = row.unreadCount && row.unreadCount > 0 ? `${row.unreadCount} unread` : row.unread ? "Unread" : null;
913
+ const label = [unreadLabel, row.avatar ? row.avatarLabel : null, row.title, row.timeLabel, row.preview, row.meta].filter(Boolean).join(", ");
914
+ const [avatarWidth, setAvatarWidth] = useState(0);
915
+ const separatorInset = ROW_PADDING + LEADING_WIDTH + (row.avatar ? (avatarWidth || DEFAULT_AVATAR) + AVATAR_GAP : 0);
916
+ return /* @__PURE__ */ jsxs(
917
+ View,
918
+ {
919
+ testID: `${row.testID}-cell`,
920
+ style: [
921
+ { backgroundColor: colors.surface },
922
+ ios ? {
923
+ marginHorizontal: IOS_GROUP_MARGIN2,
924
+ borderTopLeftRadius: row.isFirst ? radius : 0,
925
+ borderTopRightRadius: row.isFirst ? radius : 0,
926
+ borderBottomLeftRadius: row.isLast ? radius : 0,
927
+ borderBottomRightRadius: row.isLast ? radius : 0,
928
+ overflow: "hidden"
929
+ } : null
930
+ ],
931
+ children: [
932
+ /* @__PURE__ */ jsxs(
933
+ Pressable,
934
+ {
935
+ testID: row.testID,
936
+ accessibilityRole: row.onPress ? "button" : void 0,
937
+ accessibilityLabel: label,
938
+ accessibilityActions: actions.map((a) => ({ name: a.id, label: a.label })),
939
+ onAccessibilityAction: (event) => actions.find((a) => a.id === event.nativeEvent.actionName)?.onPress(),
940
+ onPress: row.onPress,
941
+ onLongPress: actions.length ? () => showInboxActions(row.title, actions) : void 0,
942
+ onPressIn: () => setPressed(true),
943
+ onPressOut: () => setPressed(false),
944
+ style: { flexDirection: "row", alignItems: "center", paddingHorizontal: ROW_PADDING, paddingVertical: 11, minHeight: 60, backgroundColor: pressed && row.onPress ? colors.fill : void 0 },
945
+ children: [
946
+ /* @__PURE__ */ jsx(View, { style: { width: LEADING_WIDTH, alignItems: "flex-start" }, children: row.leading ?? (row.unreadCount && row.unreadCount > 0 ? null : /* @__PURE__ */ jsx(UnreadDot2, { unread: !!row.unread, testID: `${row.testID}-unread`, color: colors.tint })) }),
947
+ row.avatar ? /* @__PURE__ */ jsx(
948
+ View,
949
+ {
950
+ testID: `${row.testID}-avatar`,
951
+ accessibilityElementsHidden: true,
952
+ importantForAccessibility: "no-hide-descendants",
953
+ onLayout: (e) => setAvatarWidth(Math.round(e.nativeEvent.layout.width)),
954
+ style: { marginRight: AVATAR_GAP },
955
+ children: row.avatar
956
+ }
957
+ ) : null,
958
+ /* @__PURE__ */ jsxs(View, { style: { flex: 1, minWidth: 0 }, children: [
959
+ /* @__PURE__ */ jsxs(View, { style: { flexDirection: "row", alignItems: "baseline" }, children: [
960
+ /* @__PURE__ */ jsx(
961
+ NativeText,
962
+ {
963
+ numberOfLines: 1,
964
+ style: { flex: 1, color: colors.label, fontSize: 17, lineHeight: 22, fontWeight: row.unread || (row.unreadCount ?? 0) > 0 ? "600" : "400" },
965
+ children: row.title
966
+ }
967
+ ),
968
+ row.timeLabel ? /* @__PURE__ */ jsx(NativeText, { testID: `${row.testID}-time`, style: { marginLeft: 8, color: colors.secondaryLabel, fontSize: 15, lineHeight: 20 }, children: row.timeLabel }) : null
969
+ ] }),
970
+ row.preview ? /* @__PURE__ */ jsx(NativeText, { numberOfLines: 2, style: { marginTop: 2, color: colors.secondaryLabel, fontSize: 15, lineHeight: 20 }, children: row.preview }) : null,
971
+ row.meta ? /* @__PURE__ */ jsx(NativeText, { testID: `${row.testID}-meta`, style: { marginTop: 4, color: colors.tertiaryLabel, fontSize: 13, lineHeight: 18 }, children: row.meta }) : null
972
+ ] }),
973
+ row.unreadCount && row.unreadCount > 0 ? /* @__PURE__ */ jsx(View, { style: { marginLeft: 8 }, children: /* @__PURE__ */ jsx(NativeBadge, { testID: `${row.testID}-count`, children: String(row.unreadCount) }) }) : null,
974
+ row.trailing ? /* @__PURE__ */ jsx(View, { style: { marginLeft: 8 }, children: row.trailing }) : row.onPress ? /* @__PURE__ */ jsx(Chevron, { color: colors.tertiaryLabel }) : null
975
+ ]
976
+ }
977
+ ),
978
+ row.isLast ? null : /* @__PURE__ */ jsxs(View, { accessibilityElementsHidden: true, importantForAccessibility: "no-hide-descendants", style: { flexDirection: "row", height: StyleSheet.hairlineWidth }, children: [
979
+ /* @__PURE__ */ jsx(View, { testID: `${row.testID}-separator-inset`, style: { width: separatorInset } }),
980
+ /* @__PURE__ */ jsx(View, { testID: `${row.testID}-separator-line`, style: { flex: 1, backgroundColor: colors.separator } })
981
+ ] })
982
+ ]
983
+ }
984
+ );
985
+ }
986
+ function Chevron({ color }) {
987
+ return /* @__PURE__ */ jsx(NativeText, { accessibilityElementsHidden: true, importantForAccessibility: "no", style: { marginLeft: 8, color, fontSize: 20, lineHeight: 22 }, children: "\u203A" });
988
+ }
989
+ function UnreadDot2({ unread, testID, color }) {
990
+ if (!unread) return /* @__PURE__ */ jsx(View, { testID, style: { width: 10, height: 10 } });
991
+ return /* @__PURE__ */ jsx(View, { testID, style: { width: 10, height: 10, borderRadius: 5, backgroundColor: color } });
992
+ }
993
+ function DefaultFooter({ loadingMore, testID }) {
994
+ if (!loadingMore) return null;
995
+ return /* @__PURE__ */ jsx(View, { testID, style: { paddingVertical: 16 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { accessibilityLabel: "Loading more" }) });
996
+ }
997
+ function DefaultEmpty2({ title, body, actionLabel, onAction, testID }) {
998
+ return /* @__PURE__ */ jsx(
999
+ NativeEmptyState,
1000
+ {
1001
+ variant: "first-run",
1002
+ title,
1003
+ body,
1004
+ testID,
1005
+ primaryAction: actionLabel && onAction ? /* @__PURE__ */ jsx(NativeButton, { onPress: onAction, testID: `${testID}-action`, children: actionLabel }) : void 0
1006
+ }
1007
+ );
1008
+ }
1009
+ var DEFAULT_LABELS = { you: "You", sending: "Sending", notSent: "Not sent. Tap to retry.", retryHint: "Double tap to send again" };
1010
+ function getThreadPageStackOptions(props) {
1011
+ return composeHeaderOptions({
1012
+ headerTitle: props.headerTitle ?? "Conversation",
1013
+ large: props.large ?? false,
1014
+ scrollEdgeBehavior: props.scrollEdgeBehavior,
1015
+ headerLeft: props.headerLeft,
1016
+ headerRight: props.headerRight,
1017
+ headerOptions: props.headerOptions
1018
+ });
1019
+ }
1020
+ var toDate = (value) => typeof value === "string" ? new Date(value) : value;
1021
+ function defaultTime(date) {
1022
+ return date.toLocaleString(void 0, { month: "short", day: "numeric", hour: "numeric", minute: "2-digit" });
1023
+ }
1024
+ function readReceiptFor(messages, readAt) {
1025
+ if (!readAt) return null;
1026
+ const read = toDate(readAt).getTime();
1027
+ for (let i = messages.length - 1; i >= 0; i--) {
1028
+ const m = messages[i];
1029
+ if (m.mine && m.status !== "sending" && m.status !== "failed" && toDate(m.timestamp).getTime() <= read) return m.id;
1030
+ }
1031
+ return null;
1032
+ }
1033
+ function ThreadPage({
1034
+ messages,
1035
+ composer,
1036
+ closedNotice,
1037
+ header,
1038
+ readAt,
1039
+ readLabel = "Read",
1040
+ hasEarlier = false,
1041
+ onLoadEarlier,
1042
+ loadingEarlier = false,
1043
+ earlierLabel = "Load earlier messages",
1044
+ emptyTitle,
1045
+ emptyBody,
1046
+ formatTime = defaultTime,
1047
+ labels: labelOverrides,
1048
+ slots = {},
1049
+ slotProps = {},
1050
+ testID = "thread-page"
1051
+ }) {
1052
+ const colors = useThemeRoles();
1053
+ const KeyboardScroll = useKeyboardScroll();
1054
+ const scrollRef = useRef(null);
1055
+ const receiptFor = readReceiptFor(messages, readAt);
1056
+ const labels = { ...DEFAULT_LABELS, ...labelOverrides };
1057
+ const newest = messages[messages.length - 1]?.id;
1058
+ useEffect(() => {
1059
+ scrollRef.current?.scrollToEnd?.({ animated: true });
1060
+ }, [newest]);
1061
+ const body = /* @__PURE__ */ jsxs(View, { style: { flexGrow: 1 }, children: [
1062
+ header ?? renderSlot(Nothing, slots.header, { testID: `${testID}-header` }, slotProps.header),
1063
+ hasEarlier && onLoadEarlier ? renderSlot(
1064
+ DefaultEarlier,
1065
+ slots.earlier,
1066
+ { loading: loadingEarlier, onPress: onLoadEarlier, label: earlierLabel, testID: `${testID}-earlier` },
1067
+ slotProps.earlier
1068
+ ) : null,
1069
+ /* @__PURE__ */ jsx(View, { testID: `${testID}-messages`, accessibilityRole: "list", style: { flexGrow: 1, justifyContent: "flex-end", paddingHorizontal: 12, paddingVertical: 8, gap: 6 }, children: messages.length === 0 ? renderSlot(
1070
+ DefaultEmpty3,
1071
+ slots.empty,
1072
+ { title: emptyTitle ?? "No messages yet", body: emptyBody ?? "Write the first one below.", testID: `${testID}-empty` },
1073
+ slotProps.empty
1074
+ ) : messages.map((message) => /* @__PURE__ */ jsxs(View, { children: [
1075
+ renderSlot(
1076
+ DefaultMessage,
1077
+ slots.message,
1078
+ {
1079
+ ...message,
1080
+ testID: `${testID}-message-${message.id}`,
1081
+ timeLabel: formatTime(toDate(message.timestamp)),
1082
+ showReadReceipt: message.id === receiptFor,
1083
+ labels
1084
+ },
1085
+ slotProps.message
1086
+ ),
1087
+ message.attachments?.length ? /* @__PURE__ */ jsx(View, { style: { flexDirection: "row", flexWrap: "wrap", gap: 6, justifyContent: message.mine ? "flex-end" : "flex-start", marginTop: 4 }, children: message.attachments.map((attachment) => /* @__PURE__ */ jsx(View, { children: renderSlot(
1088
+ DefaultAttachment,
1089
+ slots.attachment,
1090
+ { ...attachment, mine: message.mine, testID: `${testID}-attachment-${attachment.id}` },
1091
+ slotProps.attachment
1092
+ ) }, attachment.id)) }) : null,
1093
+ message.id === receiptFor ? renderSlot(DefaultReadReceipt, slots.readReceipt, { label: readLabel, testID: `${testID}-read-receipt` }, slotProps.readReceipt) : null
1094
+ ] }, message.id)) })
1095
+ ] });
1096
+ const footer = composer ? renderSlot(
1097
+ DefaultComposer,
1098
+ slots.composer,
1099
+ {
1100
+ ...composer,
1101
+ testID: `${testID}-composer`,
1102
+ accessory: renderSlot(Nothing, slots.composerAccessory, { testID: `${testID}-composer-accessory` }, slotProps.composerAccessory)
1103
+ },
1104
+ slotProps.composer
1105
+ ) : closedNotice ? /* @__PURE__ */ jsx(NativeText, { testID: `${testID}-closed`, style: { textAlign: "center", padding: 16, color: colors.secondaryLabel, fontSize: 13, lineHeight: 18 }, children: closedNotice }) : null;
1106
+ const page = { flex: 1, backgroundColor: colors.groupedBackground };
1107
+ const onContentSizeChange = () => scrollRef.current?.scrollToEnd?.({ animated: false });
1108
+ if (KeyboardScroll) {
1109
+ return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: page, children: createElement(
1110
+ KeyboardScroll,
1111
+ {
1112
+ ref: scrollRef,
1113
+ testID: `${testID}-keyboard`,
1114
+ keyboardShouldPersistTaps: "handled",
1115
+ contentInsetAdjustmentBehavior: "automatic",
1116
+ contentContainerStyle: { flexGrow: 1 },
1117
+ bottomOffset: 8,
1118
+ onContentSizeChange
1119
+ },
1120
+ body,
1121
+ footer
1122
+ ) });
1123
+ }
1124
+ return /* @__PURE__ */ jsx(SafeAreaView, { testID, edges: ["left", "right", "bottom"], style: page, children: /* @__PURE__ */ jsxs(KeyboardAvoidingView, { testID: `${testID}-kav`, style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : void 0, keyboardVerticalOffset: Platform.OS === "ios" ? 100 : 0, children: [
1125
+ /* @__PURE__ */ jsx(
1126
+ ScrollView,
1127
+ {
1128
+ ref: scrollRef,
1129
+ testID: `${testID}-scroll`,
1130
+ keyboardShouldPersistTaps: "handled",
1131
+ contentInsetAdjustmentBehavior: "automatic",
1132
+ contentContainerStyle: { flexGrow: 1 },
1133
+ onContentSizeChange,
1134
+ children: body
1135
+ }
1136
+ ),
1137
+ footer
1138
+ ] }) });
1139
+ }
1140
+ function Nothing(_props) {
1141
+ return null;
1142
+ }
1143
+ function DefaultEarlier({ loading, onPress, label, testID }) {
1144
+ return /* @__PURE__ */ jsx(View, { style: { alignItems: "center", paddingTop: 8 }, children: /* @__PURE__ */ jsx(NativeButton, { variant: "ghost", size: "sm", onPress, loading, testID, children: label }) });
1145
+ }
1146
+ function DefaultEmpty3({ title, body, testID }) {
1147
+ return /* @__PURE__ */ jsx(NativeEmptyState, { variant: "first-run", title, body, testID });
1148
+ }
1149
+ var MINE_TEXT = { fontSize: 17, lineHeight: 22 };
1150
+ function DefaultMessage(message) {
1151
+ const colors = useThemeRoles();
1152
+ const failed = message.status === "failed";
1153
+ const { labels } = message;
1154
+ const label = [message.mine ? labels.you : message.authorName ?? "", message.body, message.timeLabel, failed ? labels.notSent : message.status === "sending" ? labels.sending : null].filter(Boolean).join(", ");
1155
+ return /* @__PURE__ */ jsxs(View, { style: { alignItems: message.mine ? "flex-end" : "flex-start" }, children: [
1156
+ !message.mine && message.authorName ? /* @__PURE__ */ jsx(NativeText, { style: { marginLeft: 12, marginBottom: 2, color: colors.secondaryLabel, fontSize: 12, lineHeight: 16 }, children: message.authorName }) : null,
1157
+ /* @__PURE__ */ jsx(
1158
+ Pressable,
1159
+ {
1160
+ testID: message.testID,
1161
+ accessible: true,
1162
+ accessibilityLabel: label,
1163
+ accessibilityHint: failed && message.onRetry ? labels.retryHint : void 0,
1164
+ onPress: failed ? message.onRetry : void 0,
1165
+ style: {
1166
+ maxWidth: "80%",
1167
+ paddingHorizontal: 14,
1168
+ paddingVertical: 8,
1169
+ borderRadius: 18,
1170
+ backgroundColor: message.mine ? colors.tint : colors.surface,
1171
+ opacity: message.status === "sending" ? 0.6 : 1
1172
+ },
1173
+ children: /* @__PURE__ */ jsx(NativeText, { className: message.mine ? "text-primary-foreground" : void 0, style: message.mine ? MINE_TEXT : { ...MINE_TEXT, color: colors.label }, children: message.body })
1174
+ }
1175
+ ),
1176
+ /* @__PURE__ */ jsx(
1177
+ NativeText,
1178
+ {
1179
+ testID: `${message.testID}-time`,
1180
+ style: { marginTop: 2, marginHorizontal: 12, color: failed ? colors.destructive : colors.tertiaryLabel, fontSize: 11, lineHeight: 14 },
1181
+ children: failed ? labels.notSent : message.timeLabel
1182
+ }
1183
+ )
1184
+ ] });
1185
+ }
1186
+ function DefaultAttachment({ uri, width, height, accessibilityLabel, onPress, testID }) {
1187
+ const ratio = width && height ? width / height : 0.6;
1188
+ const w = 140;
1189
+ return /* @__PURE__ */ jsx(Pressable, { testID, accessibilityRole: "image", accessibilityLabel: accessibilityLabel ?? "Attachment", onPress, disabled: !onPress, children: /* @__PURE__ */ jsx(Image, { source: { uri }, style: { width: w, height: Math.round(w / ratio), borderRadius: 12 }, resizeMode: "cover" }) });
1190
+ }
1191
+ function DefaultReadReceipt({ label, testID }) {
1192
+ const colors = useThemeRoles();
1193
+ return /* @__PURE__ */ jsx(NativeText, { testID, style: { alignSelf: "flex-end", marginHorizontal: 12, color: colors.secondaryLabel, fontSize: 11, lineHeight: 14 }, children: label });
1194
+ }
1195
+ function DefaultComposer({
1196
+ value,
1197
+ onChangeText,
1198
+ onSend,
1199
+ sending = false,
1200
+ placeholder = "Message",
1201
+ sendLabel = "Send",
1202
+ disabled = false,
1203
+ maxLength,
1204
+ testID,
1205
+ accessory
1206
+ }) {
1207
+ const colors = useThemeRoles();
1208
+ const blank = !value.trim();
1209
+ return /* @__PURE__ */ jsxs(
1210
+ View,
1211
+ {
1212
+ testID,
1213
+ style: { flexDirection: "row", alignItems: "flex-end", gap: 8, paddingHorizontal: 12, paddingTop: 8, paddingBottom: 8, backgroundColor: colors.groupedBackground },
1214
+ children: [
1215
+ accessory,
1216
+ /* @__PURE__ */ jsx(
1217
+ TextInput,
1218
+ {
1219
+ testID: `${testID}-input`,
1220
+ value,
1221
+ onChangeText,
1222
+ placeholder,
1223
+ placeholderTextColor: colors.tertiaryLabel,
1224
+ accessibilityLabel: placeholder,
1225
+ multiline: true,
1226
+ maxLength,
1227
+ editable: !sending,
1228
+ style: {
1229
+ flex: 1,
1230
+ minHeight: 36,
1231
+ maxHeight: 120,
1232
+ paddingHorizontal: 14,
1233
+ paddingTop: 8,
1234
+ paddingBottom: 8,
1235
+ borderRadius: 18,
1236
+ fontSize: 17,
1237
+ color: colors.label,
1238
+ backgroundColor: colors.surface
1239
+ }
1240
+ }
1241
+ ),
1242
+ sending ? /* @__PURE__ */ jsx(View, { style: { height: 36, justifyContent: "center", paddingHorizontal: 8 }, children: /* @__PURE__ */ jsx(ActivityIndicator, { testID: `${testID}-sending`, accessibilityLabel: "Sending" }) }) : /* @__PURE__ */ jsx(NativeButton, { size: "sm", onPress: onSend, disabled: disabled || blank, testID: `${testID}-send`, children: sendLabel })
1243
+ ]
1244
+ }
1245
+ );
1246
+ }
1247
+ function AuthBranding({
1248
+ logo,
1249
+ headline,
1250
+ subhead,
1251
+ className,
1252
+ testID = "auth-branding"
1253
+ }) {
1254
+ return /* @__PURE__ */ jsxs(
1255
+ View,
1256
+ {
1257
+ testID,
1258
+ accessibilityRole: "header",
1259
+ className: cn("items-center gap-3 pb-8", className),
1260
+ children: [
1261
+ logo ? /* @__PURE__ */ jsx(View, { testID: `${testID}-logo`, className: "mb-2", children: logo }) : null,
1262
+ headline ? /* @__PURE__ */ jsx(
1263
+ NativeText,
1264
+ {
1265
+ preset: "h1",
1266
+ testID: `${testID}-headline`,
1267
+ className: "text-center",
1268
+ children: headline
1269
+ }
1270
+ ) : null,
1271
+ subhead ? /* @__PURE__ */ jsx(
1272
+ NativeText,
1273
+ {
1274
+ preset: "body",
1275
+ testID: `${testID}-subhead`,
1276
+ className: "text-center text-muted-foreground",
1277
+ children: subhead
1278
+ }
1279
+ ) : null
1280
+ ]
1281
+ }
1282
+ );
1283
+ }
1284
+ function SocialAuthRow({
1285
+ providers,
1286
+ separator = "or",
1287
+ className,
1288
+ testID = "social-auth-row"
1289
+ }) {
1290
+ if (providers.length === 0) return null;
1291
+ return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
1292
+ /* @__PURE__ */ jsx(View, { className: "gap-2", children: providers.map(
1293
+ (p) => p.render ? /* @__PURE__ */ jsx(Fragment, { children: p.render({ testID: `${testID}-${p.id}`, disabled: p.disabled }) }, p.id) : /* @__PURE__ */ jsx(
1294
+ NativeButton,
1295
+ {
1296
+ testID: `${testID}-${p.id}`,
1297
+ variant: "outline",
1298
+ disabled: p.disabled,
1299
+ onPress: () => {
1300
+ void p.onPress();
1301
+ },
1302
+ children: /* @__PURE__ */ jsxs(View, { className: "flex-row items-center gap-2", children: [
1303
+ p.icon,
1304
+ /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: p.label })
1305
+ ] })
1306
+ },
1307
+ p.id
1308
+ )
1309
+ ) }),
1310
+ separator !== null && separator !== void 0 ? /* @__PURE__ */ jsxs(
1311
+ View,
1312
+ {
1313
+ testID: `${testID}-separator`,
1314
+ className: "my-2 flex-row items-center gap-3",
1315
+ accessibilityElementsHidden: true,
1316
+ children: [
1317
+ /* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" }),
1318
+ /* @__PURE__ */ jsx(Text, { className: "text-xs uppercase tracking-wider text-muted-foreground", children: separator }),
1319
+ /* @__PURE__ */ jsx(View, { className: "h-px flex-1 bg-border" })
1320
+ ]
1321
+ }
1322
+ ) : null
1323
+ ] });
1324
+ }
1325
+ function AuthForm({
1326
+ mode = "password",
1327
+ onSubmit,
1328
+ validate,
1329
+ submitLabel,
1330
+ loading,
1331
+ errorMessage,
1332
+ initialEmail = "",
1333
+ belowFields,
1334
+ className,
1335
+ testID = "auth-form"
1336
+ }) {
1337
+ const [email, setEmail] = useState(initialEmail);
1338
+ const [password, setPassword] = useState("");
1339
+ const [localError, setLocalError] = useState(null);
1340
+ const [submitting, setSubmitting] = useState(false);
1341
+ const passwordRef = useRef(null);
1342
+ const isMagic = mode === "magic-link";
1343
+ const resolvedSubmitLabel = submitLabel ?? (isMagic ? "Send magic link" : "Sign in");
1344
+ const handleSubmit = useCallback(async () => {
1345
+ if (submitting || loading) return;
1346
+ setLocalError(null);
1347
+ const values = {
1348
+ email: email.trim(),
1349
+ password: isMagic ? "" : password
1350
+ };
1351
+ if (validate) {
1352
+ const err = validate(values);
1353
+ if (err) {
1354
+ setLocalError(err);
1355
+ return;
1356
+ }
1357
+ }
1358
+ if (!values.email) {
1359
+ setLocalError("Email is required");
1360
+ return;
1361
+ }
1362
+ if (!isMagic && !values.password) {
1363
+ setLocalError("Password is required");
1364
+ return;
1365
+ }
1366
+ setSubmitting(true);
1367
+ try {
1368
+ await onSubmit(values);
1369
+ } catch (err) {
1370
+ const message = err instanceof Error ? err.message : String(err);
1371
+ setLocalError(message);
1372
+ } finally {
1373
+ setSubmitting(false);
1374
+ }
1375
+ }, [email, password, isMagic, validate, onSubmit, submitting, loading]);
1376
+ const visibleError = errorMessage ?? localError ?? null;
1377
+ return /* @__PURE__ */ jsxs(View, { testID, className: cn("gap-3", className), children: [
1378
+ /* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
1379
+ /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Email" }),
1380
+ /* @__PURE__ */ jsx(
1381
+ NativeInput,
1382
+ {
1383
+ testID: `${testID}-email`,
1384
+ accessibilityLabel: "Email",
1385
+ value: email,
1386
+ onChangeText: setEmail,
1387
+ placeholder: "you@example.com",
1388
+ autoCapitalize: "none",
1389
+ autoCorrect: false,
1390
+ keyboardType: "email-address",
1391
+ textContentType: "emailAddress",
1392
+ autoComplete: "email",
1393
+ returnKeyType: isMagic ? "send" : "next",
1394
+ editable: !loading && !submitting,
1395
+ submitBehavior: isMagic ? "blurAndSubmit" : "submit",
1396
+ onSubmitEditing: isMagic ? handleSubmit : () => passwordRef.current?.focus()
1397
+ }
1398
+ )
1399
+ ] }),
1400
+ isMagic ? null : /* @__PURE__ */ jsxs(View, { className: "gap-1", children: [
1401
+ /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-foreground", children: "Password" }),
1402
+ /* @__PURE__ */ jsx(
1403
+ NativeInput,
1404
+ {
1405
+ ref: passwordRef,
1406
+ testID: `${testID}-password`,
1407
+ accessibilityLabel: "Password",
1408
+ value: password,
1409
+ onChangeText: setPassword,
1410
+ placeholder: "\u2022\u2022\u2022\u2022\u2022\u2022\u2022\u2022",
1411
+ secureTextEntry: true,
1412
+ textContentType: "password",
1413
+ autoComplete: "current-password",
1414
+ autoCapitalize: "none",
1415
+ autoCorrect: false,
1416
+ returnKeyType: "send",
1417
+ editable: !loading && !submitting,
1418
+ onSubmitEditing: handleSubmit
1419
+ }
1420
+ )
1421
+ ] }),
1422
+ belowFields,
1423
+ visibleError ? /* @__PURE__ */ jsx(
1424
+ Text,
1425
+ {
1426
+ testID: `${testID}-error`,
1427
+ accessibilityRole: "alert",
1428
+ className: "text-sm text-destructive",
1429
+ children: visibleError
1430
+ }
1431
+ ) : null,
1432
+ /* @__PURE__ */ jsx(
1433
+ NativeButton,
1434
+ {
1435
+ testID: `${testID}-submit`,
1436
+ onPress: () => {
1437
+ void handleSubmit();
1438
+ },
1439
+ loading: loading || submitting,
1440
+ disabled: loading || submitting,
1441
+ children: resolvedSubmitLabel
1442
+ }
1443
+ )
1444
+ ] });
1445
+ }
1446
+ function ForgotPasswordLink({
1447
+ onPress,
1448
+ label = "Forgot password?",
1449
+ testID = "auth-forgot-password"
1450
+ }) {
1451
+ return /* @__PURE__ */ jsx(
1452
+ Pressable,
1453
+ {
1454
+ testID,
1455
+ accessibilityRole: "link",
1456
+ accessibilityLabel: label,
1457
+ onPress,
1458
+ hitSlop: 8,
1459
+ className: "self-end",
1460
+ children: /* @__PURE__ */ jsx(Text, { className: "text-sm font-medium text-primary", children: label })
1461
+ }
1462
+ );
1463
+ }
1464
+ function AuthScreen({
1465
+ branding,
1466
+ providers: givenProviders,
1467
+ form,
1468
+ onForgotPassword,
1469
+ footer,
1470
+ slots = {},
1471
+ slotProps = {},
1472
+ testID = "auth-screen"
1473
+ }) {
1474
+ const providers = givenProviders?.filter((p) => !!p);
1475
+ warnIfNoAppleSignIn(providers);
1476
+ const forgot = onForgotPassword && (form.mode ?? "password") === "password" ? /* @__PURE__ */ jsx(ForgotPasswordLink, { onPress: onForgotPassword }) : null;
1477
+ const formProps = { ...form, belowFields: form.belowFields ?? forgot, testID: form.testID ?? `${testID}-form` };
1478
+ const KeyboardScroll = useKeyboardScroll();
1479
+ const KeyboardToolbar = useKeyboardToolbar();
1480
+ const content = /* @__PURE__ */ jsxs(Fragment$1, { children: [
1481
+ branding ? renderSlot(AuthBranding, slots.branding, { ...branding, testID: branding.testID ?? `${testID}-branding` }, slotProps.branding) : null,
1482
+ providers?.length ? renderSlot(DefaultSocial, slots.social, { providers, testID: `${testID}-social` }, slotProps.social) : null,
1483
+ renderSlot(AuthForm, slots.form, formProps, slotProps.form),
1484
+ footer ? renderSlot(DefaultFooter2, slots.footer, { children: footer, testID: `${testID}-footer` }, slotProps.footer) : null
1485
+ ] });
1486
+ if (KeyboardScroll) {
1487
+ return /* @__PURE__ */ jsxs(ScreenContainer, { testID, children: [
1488
+ /* @__PURE__ */ jsx(
1489
+ KeyboardScroll,
1490
+ {
1491
+ testID: `${testID}-keyboard`,
1492
+ keyboardShouldPersistTaps: "handled",
1493
+ contentInsetAdjustmentBehavior: "automatic",
1494
+ bottomOffset: KeyboardToolbar ? 24 + KEYBOARD_TOOLBAR_HEIGHT : 24,
1495
+ contentContainerStyle: { flexGrow: 1, justifyContent: "center", gap: 24, paddingHorizontal: 24, paddingVertical: 32 },
1496
+ children: content
1497
+ }
1498
+ ),
1499
+ KeyboardToolbar ? /* @__PURE__ */ jsx(KeyboardToolbar, {}) : null
1500
+ ] });
1501
+ }
1502
+ return /* @__PURE__ */ jsx(KeyboardAvoidingView, { testID: `${testID}-kav`, style: { flex: 1 }, behavior: Platform.OS === "ios" ? "padding" : void 0, children: /* @__PURE__ */ jsx(ScreenContainer, { scroll: true, keyboardShouldPersistTaps: "handled", testID, contentClassName: "flex-grow justify-center gap-6 px-6 py-8", children: content }) });
1503
+ }
1504
+ var warnedNoApple = /* @__PURE__ */ new Set();
1505
+ function warnIfNoAppleSignIn(providers) {
1506
+ const dev = typeof __DEV__ !== "undefined" ? __DEV__ : typeof process !== "undefined" && process.env.NODE_ENV !== "production";
1507
+ if (!dev || Platform.OS !== "ios" || !providers?.length) return;
1508
+ if (providers.some((p) => p.id === "apple")) return;
1509
+ const ids = providers.map((p) => p.id).join(",");
1510
+ if (warnedNoApple.has(ids)) return;
1511
+ warnedNoApple.add(ids);
1512
+ console.warn(
1513
+ `[genesis] AuthScreen offers ${providers.map((p) => p.label).join(", ")} on iOS without Sign in with Apple. App Store Review Guideline 4.8 requires it; add appleProvider({ apple: AppleAuthentication, onPress }) (or any provider with id "apple"). If you did, expo-apple-authentication wasn't passed in.`
1514
+ );
1515
+ }
1516
+ function DefaultSocial({ providers, testID }) {
1517
+ return /* @__PURE__ */ jsx(SocialAuthRow, { providers, testID });
1518
+ }
1519
+ function DefaultFooter2({ children, testID }) {
1520
+ return /* @__PURE__ */ jsx(View, { testID, className: "items-center", children });
1521
+ }
1522
+ function AppleSignInButton({
1523
+ apple,
1524
+ onPress,
1525
+ type = "continue",
1526
+ appearance = "auto",
1527
+ cornerRadius = 10,
1528
+ height = 44,
1529
+ disabled,
1530
+ testID = "apple-sign-in"
1531
+ }) {
1532
+ const mode = useThemeMode();
1533
+ const pending = useRef(false);
1534
+ const [busy, setBusy] = useState(false);
1535
+ if (Platform.OS !== "ios") return null;
1536
+ const press = async () => {
1537
+ if (disabled || pending.current) return;
1538
+ pending.current = true;
1539
+ setBusy(true);
1540
+ try {
1541
+ await onPress();
1542
+ } finally {
1543
+ pending.current = false;
1544
+ setBusy(false);
1545
+ }
1546
+ };
1547
+ const inactive = !!disabled || busy;
1548
+ const { AppleAuthenticationButton, AppleAuthenticationButtonType: Type, AppleAuthenticationButtonStyle: Style } = apple;
1549
+ const buttonType = type === "sign-in" ? Type.SIGN_IN : type === "sign-up" ? Type.SIGN_UP : Type.CONTINUE;
1550
+ const resolved = appearance === "auto" ? mode === "dark" ? "white" : "black" : appearance;
1551
+ const buttonStyle = resolved === "white" ? Style.WHITE : resolved === "white-outline" ? Style.WHITE_OUTLINE : Style.BLACK;
1552
+ return /* @__PURE__ */ jsx(View, { testID: `${testID}-container`, pointerEvents: inactive ? "none" : "auto", style: disabled ? { opacity: 0.5 } : void 0, children: /* @__PURE__ */ jsx(
1553
+ AppleAuthenticationButton,
1554
+ {
1555
+ testID,
1556
+ buttonType,
1557
+ buttonStyle,
1558
+ cornerRadius,
1559
+ style: { width: "100%", height },
1560
+ accessibilityState: { disabled: inactive, busy },
1561
+ onPress: () => {
1562
+ void press();
1563
+ }
1564
+ }
1565
+ ) });
1566
+ }
1567
+ var APPLE_LABELS = { continue: "Continue with Apple", "sign-in": "Sign in with Apple", "sign-up": "Sign up with Apple" };
1568
+ function appleProvider({ apple, label, ...button }) {
1569
+ if (Platform.OS !== "ios" || !apple) return null;
1570
+ return {
1571
+ id: "apple",
1572
+ label: label ?? APPLE_LABELS[button.type ?? "continue"],
1573
+ onPress: button.onPress,
1574
+ disabled: button.disabled,
1575
+ render: ({ testID, disabled }) => /* @__PURE__ */ jsx(AppleSignInButton, { apple, ...button, disabled, testID })
1576
+ };
1577
+ }
1578
+
1579
+ // src/layouts/google-sign-in.tsx
1580
+ function googleProvider({ onPress, label = "Continue with Google", icon, disabled, enabled = true }) {
1581
+ if (!enabled) return null;
1582
+ return { id: "google", label, icon, onPress, disabled };
1583
+ }
1584
+
1585
+ export { AppleSignInButton, AuthBranding, AuthForm, AuthScreen, ForgotPasswordLink, InboxPage, KEYBOARD_TOOLBAR_HEIGHT, KeyboardScrollProvider, NavBarSaveButton, NavBarSearchBar, NavBarTitle, NotificationsPage, ScreenContainer, SettingsPage, SettingsSubPage, SocialAuthRow, ThreadPage, appleProvider, composeHeaderOptions, confirmDiscardChanges, defaultStickyHeaderOffset, formatInboxTime, getInboxPageStackOptions, getNotificationsPageStackOptions, getSettingsPageStackOptions, getSettingsSubPageStackOptions, getThreadPageStackOptions, googleProvider, iosCompactNavigationBarHeight, readReceiptFor, showInboxActions, useKeyboardScroll, useKeyboardToolbar };
1586
+ //# sourceMappingURL=chunk-H4Q7COTI.js.map
1587
+ //# sourceMappingURL=chunk-H4Q7COTI.js.map