@poolse/react-native 2.17.1 → 2.19.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/CHANGELOG.md +44 -0
- package/dist/index.cjs +62 -22
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -26
- package/dist/index.d.ts +0 -26
- package/dist/index.js +62 -22
- package/dist/index.js.map +1 -1
- package/package.json +3 -3
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/theme/default.ts","../src/theme/PoolseTheme.tsx","../src/primitives/userColor.ts","../src/primitives/Avatar.tsx","../src/primitives/icons-data.ts","../src/primitives/PoolseIcon.tsx","../src/MemberList.tsx","../src/internal/useDismissableSheet.ts","../src/GroupDetailsSheet.tsx","../src/ChatHeader.tsx","../src/ConversationList.tsx","../src/internal/uploadContext.tsx","../src/AttachmentPicker.tsx","../src/DaySeparator.tsx","../src/UploadQueueStrip.tsx","../src/internal/safeArea.ts","../src/MessageComposer.tsx","../src/MentionInput.tsx","../src/MessageList.tsx","../src/MessageActions.tsx","../src/AttachmentPreview.tsx","../src/ImageMosaic.tsx","../src/internal/markdown.ts","../src/MessageBubble.tsx","../src/Reactions.tsx","../src/MessageRow.tsx","../src/ThreadView.tsx","../src/UserName.tsx","../src/TypingIndicator.tsx","../src/ConversationView.tsx","../src/internal/UserPickerSheet.tsx","../src/PoolseInbox.tsx","../src/primitives/PoolseLogo.tsx","../src/primitives/index.ts","../src/lifecycle/useAppStateLifecycle.tsx","../src/voice/webrtc-native.ts","../src/VoiceRoomBar.tsx","../src/voice/callTheme.ts","../src/voice/AudioRouteSheet.tsx","../src/voice/CallAvatar.tsx","../src/voice/CallControlButton.tsx","../src/voice/CallParticipantTile.tsx","../src/voice/LocalVideoPip.tsx","../src/voice/CallVideoGrid.tsx","../src/voice/livekit-rn.ts","../src/voice/useCallAudio.ts","../src/voice/useCallDuration.ts","../src/CallScreen.tsx","../src/voice/useVoipCalls.ts"],"names":["createContext","useMemo","useContext","jsxs","View","jsx","Image","Text","StyleSheet","SvgXml","useMembers","usePresence","styles","ActivityIndicator","FlatList","Fragment","useUser","Pressable","useRef","Animated","PanResponder","useConversation","useWindowDimensions","Modal","useMe","useState","useConversations","useAttachmentUpload","useCallback","RNImage","manipulateAsync","SaveFormat","ImagePicker","res","DocumentPicker","ScrollView","Platform","forwardRef","MessageComposer","useEffect","Keyboard","useImperativeHandle","TextInput","useAttachmentUrl","formatBytes","Dimensions","MarkdownIt","createElement","Markdown","radii","Linking","sameDay","useReactions","Clipboard","useThread","KeyboardAvoidingView","Easing","useMessages","useTyping","useRealtimeStatus","AppState","computeGroupPosition","formatDayLabel","PoolseInbox","Svg","Path","Circle","G","usePoolse","useVoiceRoom","ICONS","width","useSafeAreaInsets","useCalls","useCallRoom","visible","StatusBar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,WAAA,GAAc;AAAA,EAClB,KAAA,EAAO,SAAA;AAAA,EACP,WAAA,EAAa,SAAA;AAAA,EACb,SAAA,EAAW,SAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,SAAA;AAAA,EACV,GAAA,EAAK,SAAA;AAAA,EACL,IAAA,EAAM,SAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,SAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,IAAA,EAAM,SAAA;AAAA,EACN,UAAA,EAAY,SAAA;AAAA,EACZ,cAAA,EAAgB,SAAA;AAAA,EAChB,WAAA,EAAa,SAAA;AAAA,EACb,eAAA,EAAiB,SAAA;AAAA,EACjB,UAAA,EAAY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,QAAA,CAAS,MAAA;AAAA,QACjB,gBAAgB,QAAA,CAAS,cAAA;AAAA,QACzB,cAAc,QAAA,CAAS,YAAA;AAAA,QACvB,YAAY,QAAA,CAAS,YAAA;AAAA,QACrB,OAAO,QAAA,CAAS;AAAA,OACjB,CAAA;AAAA,IACH;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,QAAQ,CAAC,CAAA;AAIpB,EAAAA,gBAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAA,CAAW,KAAK,CAAA,EAAG;AACxB,IAAA,KAAA,MAAW,MAAA,IAAU,CAAC,GAAG,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,MAAM,CAAA;AAAA,EACxE,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACZ;AAUA,SAAS,oBAAA,GAAiD;AACxD,EAAA,OAAO,UAAU,SAAA,GAAY,YAAA;AAC/B","file":"index.cjs","sourcesContent":["import type { PoolseRNTheme, ThemeShadows } from './types.js';\n\n// Values mirror the --poolse-* CSS variables in @poolse/react-ui's\n// styles.css :root block. If the brand changes there, change here.\n\nconst lightColors = {\n brand: '#ff5436',\n brandStrong: '#d63415',\n brandSoft: '#ffe9e2',\n onBrand: '#fbf7f4',\n paper: '#fbf7f4',\n surface: '#ffffff',\n surface2: '#f4eee9',\n ink: '#1c1a19',\n ink2: '#6b6560',\n ink3: '#9a938c',\n border: '#eae3dc',\n presence: '#16c172',\n success: '#16a34a',\n warning: '#e08c16',\n error: '#e5484d',\n info: '#3b82f6',\n selfBubble: '#ff5436',\n selfBubbleText: '#fbf7f4',\n otherBubble: '#ffffff',\n otherBubbleText: '#1c1a19',\n unreadPill: '#ff5436',\n unreadPillText: '#fbf7f4',\n};\n\nconst darkColors = {\n brand: '#ff6a4d',\n brandStrong: '#ff8366',\n brandSoft: '#2c1712',\n onBrand: '#fbf7f4',\n paper: '#0e0d10',\n surface: '#16141a',\n surface2: '#201d25',\n ink: '#f6f2ee',\n ink2: '#a8a29b',\n ink3: '#766f68',\n border: '#2a2630',\n presence: '#22d37a',\n success: '#34d399',\n warning: '#fbbf24',\n error: '#f87171',\n info: '#60a5fa',\n selfBubble: '#ff6a4d',\n selfBubbleText: '#fbf7f4',\n otherBubble: '#16141a',\n otherBubbleText: '#f6f2ee',\n unreadPill: '#ff6a4d',\n unreadPillText: '#fbf7f4',\n};\n\nconst type = {\n // RN can't use Bricolage/Hanken/JetBrains without expo-font setup,\n // so we default to the platform sans-serif. Devs override via the\n // theme prop if they ship custom fonts.\n fontDisplay: 'System',\n fontBody: 'System',\n fontMono: 'Menlo',\n bodySize: 15,\n lineHeight: 22,\n weightRegular: '400' as const,\n weightMedium: '500' as const,\n weightSemibold: '600' as const,\n weightBold: '700' as const,\n};\n\nconst radii = {\n sm: 8,\n md: 12,\n lg: 16,\n xl: 24,\n pill: 999,\n bubble: 16,\n};\n\nconst spacing = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 16,\n xl: 24,\n};\n\nconst lightShadows: ThemeShadows = {\n sm: {\n shadowColor: '#1c1a19',\n shadowOpacity: 0.08,\n shadowOffset: { width: 0, height: 1 },\n shadowRadius: 2,\n elevation: 1,\n },\n md: {\n shadowColor: '#1c1a19',\n shadowOpacity: 0.18,\n shadowOffset: { width: 0, height: 10 },\n shadowRadius: 30,\n elevation: 6,\n },\n lg: {\n shadowColor: '#1c1a19',\n shadowOpacity: 0.28,\n shadowOffset: { width: 0, height: 24 },\n shadowRadius: 60,\n elevation: 12,\n },\n};\n\nconst darkShadows: ThemeShadows = {\n sm: {\n shadowColor: '#000000',\n shadowOpacity: 0.4,\n shadowOffset: { width: 0, height: 1 },\n shadowRadius: 2,\n elevation: 1,\n },\n md: {\n shadowColor: '#000000',\n shadowOpacity: 0.55,\n shadowOffset: { width: 0, height: 10 },\n shadowRadius: 30,\n elevation: 6,\n },\n lg: {\n shadowColor: '#000000',\n shadowOpacity: 0.7,\n shadowOffset: { width: 0, height: 24 },\n shadowRadius: 60,\n elevation: 12,\n },\n};\n\nexport const defaultLightTheme: PoolseRNTheme = {\n mode: 'light',\n colors: lightColors,\n type,\n radii,\n spacing,\n shadows: lightShadows,\n};\n\nexport const defaultDarkTheme: PoolseRNTheme = {\n mode: 'dark',\n colors: darkColors,\n type,\n radii,\n spacing,\n shadows: darkShadows,\n};\n","import { createContext, useContext, useMemo, type ReactNode } from 'react';\n\nimport { defaultDarkTheme, defaultLightTheme } from './default.js';\nimport type { PoolseRNTheme, PoolseRNThemeOverrides, ThemeMode } from './types.js';\n\nconst ThemeContext = createContext<PoolseRNTheme | null>(null);\n\nexport interface PoolseThemeProps {\n /**\n * Light or dark base palette. Overrides are merged on top of the\n * chosen base. Defaults to `light` if omitted.\n */\n mode?: ThemeMode;\n /**\n * Partial overrides — only the fields you set replace the defaults.\n * Nested groups (`colors`, `type`, `radii`, `spacing`, `shadows`)\n * deep-merge, so `{ colors: { brand: '#000' } }` keeps every other\n * color from the base theme.\n */\n theme?: PoolseRNThemeOverrides;\n children: ReactNode;\n}\n\nexport function PoolseTheme({ mode, theme, children }: PoolseThemeProps) {\n const resolved = useMemo(() => {\n const base = (mode ?? theme?.mode) === 'dark' ? defaultDarkTheme : defaultLightTheme;\n if (!theme) return base;\n return {\n mode: theme.mode ?? base.mode,\n colors: { ...base.colors, ...theme.colors },\n type: { ...base.type, ...theme.type },\n radii: { ...base.radii, ...theme.radii },\n spacing: { ...base.spacing, ...theme.spacing },\n shadows: {\n sm: { ...base.shadows.sm, ...theme.shadows?.sm },\n md: { ...base.shadows.md, ...theme.shadows?.md },\n lg: { ...base.shadows.lg, ...theme.shadows?.lg },\n },\n } satisfies PoolseRNTheme;\n }, [mode, theme]);\n\n return <ThemeContext.Provider value={resolved}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read the active poolse theme. Falls back to `defaultLightTheme`\n * if no `<PoolseTheme>` ancestor is mounted, so components render\n * sensibly even without explicit wiring.\n */\nexport function usePoolseTheme(): PoolseRNTheme {\n return useContext(ThemeContext) ?? defaultLightTheme;\n}\n","// Mirror of @poolse/react-ui's userColor — deterministic per-user\n// color from the same 8-hue palette.\n\nconst PALETTE = [\n '#6366f1', // indigo\n '#10b981', // emerald\n '#f59e0b', // amber\n '#ec4899', // rose\n '#0ea5e9', // sky\n '#8b5cf6', // violet\n '#14b8a6', // teal\n '#d946ef', // fuchsia\n];\n\nexport function userColor(id: string): string {\n let h = 0;\n for (let i = 0; i < id.length; i++) {\n h = (h * 31 + id.charCodeAt(i)) | 0;\n }\n return PALETTE[Math.abs(h) % PALETTE.length]!;\n}\n","import { Image, StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\nimport { userColor } from './userColor.js';\n\nexport interface AvatarProps {\n /** URL to a profile image. Falls back to initials when omitted. */\n src?: string | null;\n /** Used for initials. */\n name?: string | null;\n /** Stable color seed (typically the user's external_id). */\n seed?: string | null;\n /** Show a green presence dot in the bottom-right corner. */\n online?: boolean;\n /** Size variant. `md` → 40px, `sm` → 28px, `lg` → 56px. */\n size?: 'sm' | 'md' | 'lg';\n}\n\nconst SIZES = { sm: 28, md: 40, lg: 56 } as const;\n\nexport function Avatar({ src, name, seed, online, size = 'md' }: AvatarProps) {\n const theme = usePoolseTheme();\n const dim = SIZES[size];\n const initials = computeInitials(name);\n const tint = seed ? userColor(seed) : theme.colors.brand;\n const fontSize = size === 'sm' ? 11 : size === 'lg' ? 22 : 15;\n\n return (\n <View\n style={[\n styles.root,\n {\n width: dim,\n height: dim,\n borderRadius: dim / 2,\n backgroundColor: tint,\n },\n ]}\n accessibilityRole=\"image\"\n accessibilityLabel={name ?? 'avatar'}\n >\n {src ? (\n <Image\n source={{ uri: src }}\n style={{ width: dim, height: dim, borderRadius: dim / 2 }}\n accessible={false}\n />\n ) : (\n <Text\n style={{\n color: theme.colors.onBrand,\n fontSize,\n fontWeight: '600',\n fontFamily: theme.type.fontBody,\n }}\n >\n {initials}\n </Text>\n )}\n {online ? (\n <View\n style={[\n styles.presence,\n {\n backgroundColor: theme.colors.presence,\n borderColor: theme.colors.surface,\n width: dim * 0.32,\n height: dim * 0.32,\n borderRadius: dim * 0.16,\n },\n ]}\n />\n ) : null}\n </View>\n );\n}\n\nfunction computeInitials(name: string | null | undefined): string {\n if (!name) return '?';\n const parts = name.trim().split(/\\s+/).slice(0, 2);\n return (\n parts\n .map((p) => p.charAt(0).toUpperCase())\n .join('')\n .slice(0, 2) || '?'\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'visible',\n },\n presence: {\n position: 'absolute',\n bottom: 0,\n right: 0,\n borderWidth: 2,\n },\n});\n","// AUTO-GENERATED from poolse-brand-kit/icons/. Do not edit by hand.\n// Run scripts/build-icons.py from the brand kit if the source SVGs change.\n\nexport interface IconDef {\n vb: string;\n d: string;\n}\n\nexport const ICONS = {\n attachment: {\n vb: '0 0 24 24',\n d: '<path d=\"M20 11.6 11.4 20.2a5 5 0 0 1-7.1-7.1l8.7-8.7a3.3 3.3 0 0 1 4.7 4.7l-8.6 8.6a1.65 1.65 0 0 1-2.36-2.32l7.86-7.86\"/>',\n },\n bell: {\n vb: '0 0 24 24',\n d: '<path d=\"M6 9.2a6 6 0 0 1 12 0c0 4.8 1.4 6.3 1.9 6.8H4.1C4.6 15.5 6 14 6 9.2Z\"/><path d=\"M9.6 19.8a2.5 2.5 0 0 0 4.8 0\"/>',\n },\n bluetooth: {\n vb: '0 0 24 24',\n d: '<path d=\"M7.5 7.5 16.5 16.5 12 21V3l4.5 4.5L7.5 16.5\"/>',\n },\n camera: {\n vb: '0 0 24 24',\n d: '<path d=\"M3 8.5a2 2 0 0 1 2-2h2.4l1.4-2h6.4l1.4 2H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-9Z\"/><circle cx=\"12\" cy=\"13\" r=\"3.5\"/>',\n },\n 'camera-flip': {\n vb: '0 0 24 24',\n d: '<path d=\"M3 8.5a2 2 0 0 1 2-2h2.4l1.4-2h6.4l1.4 2H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-9Z\"/><path d=\"M14.6 13a2.6 2.6 0 0 1-4.5 1.8\"/><path d=\"M9.4 13a2.6 2.6 0 0 1 4.5-1.8\"/><path d=\"M13.9 9.6v1.7h-1.7\"/><path d=\"M10.1 16.4v-1.7h1.7\"/>',\n },\n 'check-double': {\n vb: '0 0 24 24',\n d: '<path d=\"M2.5 12.8 6.9 17 15.4 7.6\"/><path d=\"M11.4 16.4 12.3 17.2 21 7.6\"/>',\n },\n check: {\n vb: '0 0 24 24',\n d: '<path d=\"M4.5 12.6 9.4 17.4 19.5 6.6\"/>',\n },\n 'chevron-down': {\n vb: '0 0 24 24',\n d: '<path d=\"M5 9 12 16 19 9\"/>',\n },\n 'chevron-right': {\n vb: '0 0 24 24',\n d: '<path d=\"M9 5 16 12 9 19\"/>',\n },\n 'chevron-up': {\n vb: '0 0 24 24',\n d: '<path d=\"M6 14.5 12 8.5 18 14.5\"/>',\n },\n close: {\n vb: '0 0 24 24',\n d: '<path d=\"M6 6 18 18M18 6 6 18\"/>',\n },\n code: {\n vb: '0 0 24 24',\n d: '<path d=\"M9 7.5 4.5 12 9 16.5\"/><path d=\"M15 7.5 19.5 12 15 16.5\"/><path d=\"M13.2 5 10.8 19\"/>',\n },\n compose: {\n vb: '0 0 24 24',\n d: '<path d=\"M11.5 4H6a2.5 2.5 0 0 0-2.5 2.5V18A2.5 2.5 0 0 0 6 20.5h11.5A2.5 2.5 0 0 0 20 18v-5.5\"/><path d=\"M18.4 2.7a2.05 2.05 0 0 1 2.9 2.9L12 15l-4 1 1-4 9.4-9.3Z\"/>',\n },\n copy: {\n vb: '0 0 24 24',\n d: '<rect x=\"8.4\" y=\"8.4\" width=\"11.2\" height=\"11.2\" rx=\"2.3\"/><path d=\"M5.6 15.6H5A1.6 1.6 0 0 1 3.4 14V5A1.6 1.6 0 0 1 5 3.4h9A1.6 1.6 0 0 1 15.6 5v.6\"/>',\n },\n download: {\n vb: '0 0 24 24',\n d: '<path d=\"M12 3.2v11.6\"/><path d=\"M7.4 10.2 12 14.8 16.6 10.2\"/><path d=\"M4 19.6h16\"/>',\n },\n edit: {\n vb: '0 0 24 24',\n d: '<path d=\"M16.7 3.3a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.7-12.7Z\"/>',\n },\n emoji: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"8.6\"/><circle cx=\"9\" cy=\"10\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"15\" cy=\"10\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/><path d=\"M8.4 14.2a4.6 4.6 0 0 0 7.2 0\"/>',\n },\n headphones: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 14v-2a8 8 0 0 1 16 0v2\"/><path d=\"M4 14h2.6a1.4 1.4 0 0 1 1.4 1.4v3.2A1.4 1.4 0 0 1 6.6 20H5.4A1.4 1.4 0 0 1 4 18.6Z\"/><path d=\"M20 14h-2.6a1.4 1.4 0 0 0-1.4 1.4v3.2A1.4 1.4 0 0 0 17.4 20h1.2A1.4 1.4 0 0 0 20 18.6Z\"/>',\n },\n heart: {\n vb: '0 0 24 24',\n d: '<path d=\"M12 20.3 4.4 12.9a4.6 4.6 0 1 1 6.5-6.5l1.1 1.1 1.1-1.1a4.6 4.6 0 1 1 6.5 6.5L12 20.3Z\"/>',\n },\n image: {\n vb: '0 0 24 24',\n d: '<rect x=\"3.2\" y=\"4.2\" width=\"17.6\" height=\"15.6\" rx=\"2.6\"/><circle cx=\"8.6\" cy=\"9.4\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/><path d=\"M20.8 15.8 16 11 6 19.8\"/>',\n },\n info: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"8.6\"/><path d=\"M12 11v5.2\"/><circle cx=\"12\" cy=\"7.7\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n key: {\n vb: '0 0 24 24',\n d: '<circle cx=\"8\" cy=\"8\" r=\"4.4\"/><path d=\"M11.1 11.1 20 20\"/><path d=\"M16.6 16.6 18.6 14.6M14 14l2-2\"/>',\n },\n link: {\n vb: '0 0 24 24',\n d: '<path d=\"M10.2 13.8a3.5 3.5 0 0 0 5 0l3-3a3.5 3.5 0 0 0-5-5l-1.2 1.2\"/><path d=\"M13.8 10.2a3.5 3.5 0 0 0-5 0l-3 3a3.5 3.5 0 0 0 5 5l1.2-1.2\"/>',\n },\n lock: {\n vb: '0 0 24 24',\n d: '<rect x=\"4.6\" y=\"10.4\" width=\"14.8\" height=\"9.8\" rx=\"2.2\"/><path d=\"M8 10.4V7a4 4 0 0 1 8 0v3.4\"/>',\n },\n message: {\n vb: '0 0 24 24',\n d: '<path d=\"M20.5 11.4c0 4.5-3.9 8.1-8.5 8.1a9 9 0 0 1-3.7-.78L3.5 20.5l1.8-4.6A7.9 7.9 0 0 1 3.5 11.4C3.5 6.9 7.4 3.3 12 3.3s8.5 3.6 8.5 8.1Z\"/>',\n },\n messages: {\n vb: '0 0 24 24',\n d: '<path d=\"M14 9.2a4.7 4.7 0 0 1-4.7 4.7H6.8L3.5 16.4v-2.9A4.7 4.7 0 0 1 6.8 4.5h2.5A4.7 4.7 0 0 1 14 9.2Z\"/><path d=\"M9.4 13.6A4.7 4.7 0 0 0 13.6 16h3.6l3.3 2.5v-2.9a4.7 4.7 0 0 0-2.4-4.1\"/>',\n },\n mic: {\n vb: '0 0 24 24',\n d: '<rect x=\"9\" y=\"2.6\" width=\"6\" height=\"11.2\" rx=\"3\"/><path d=\"M5.6 11.2a6.4 6.4 0 0 0 12.8 0\"/><path d=\"M12 17.6v3.4\"/><path d=\"M8.6 21h6.8\"/>',\n },\n 'mic-off': {\n vb: '0 0 24 24',\n d: '<rect x=\"9\" y=\"2.6\" width=\"6\" height=\"11.2\" rx=\"3\"/><path d=\"M5.6 11.2a6.4 6.4 0 0 0 12.8 0\"/><path d=\"M12 17.6v3.4\"/><path d=\"M8.6 21h6.8\"/><path d=\"M3.6 3.2 20.4 20.8\"/>',\n },\n 'more-h': {\n vb: '0 0 24 24',\n d: '<circle cx=\"5.4\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"18.6\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n 'more-v': {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"5.4\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"18.6\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n phone: {\n vb: '0 0 24 24',\n d: '<path d=\"M6.6 3.5h3l1.5 3.7-1.9 1.4a12.5 12.5 0 0 0 6.2 6.2l1.4-1.9 3.7 1.5v3a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z\"/>',\n },\n 'phone-off': {\n vb: '0 0 24 24',\n d: '<g transform=\"rotate(135 12 12)\"><path d=\"M6.6 3.5h3l1.5 3.7-1.9 1.4a12.5 12.5 0 0 0 6.2 6.2l1.4-1.9 3.7 1.5v3a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z\"/></g>',\n },\n pin: {\n vb: '0 0 24 24',\n d: '<path d=\"M9 3.4h6v1.8l-1 5.6 3 3.2H7l3-3.2-1-5.6V3.4Z\"/><path d=\"M12 17v3.6\"/>',\n },\n plus: {\n vb: '0 0 24 24',\n d: '<path d=\"M12 5v14M5 12h14\"/>',\n },\n presence: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"currentColor\" opacity=\"0.18\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"5\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n pulse: {\n vb: '0 0 24 24',\n d: '<path d=\"M3 13h4.6l2.2-4.6 3.4 9 2.2-4.4H21\"/>',\n },\n reply: {\n vb: '0 0 24 24',\n d: '<path d=\"M9 7 4 12l5 5\"/><path d=\"M4 12h9.5a6.5 6.5 0 0 1 6.5 6.5V20\"/>',\n },\n search: {\n vb: '0 0 24 24',\n d: '<circle cx=\"11\" cy=\"11\" r=\"6.8\"/><path d=\"M20.8 20.8 16 16\"/>',\n },\n 'send-fill': {\n vb: '0 0 24 24',\n d: '<path fill=\"currentColor\" stroke=\"none\" d=\"M21.7 2.3a1 1 0 0 1 .25 1L15.3 21.8a1 1 0 0 1-1.86.06L10.6 14.2 3 11.4a1 1 0 0 1 .06-1.9L20.7 2.05a1 1 0 0 1 1 .25Z\"/>',\n },\n send: {\n vb: '0 0 24 24',\n d: '<path d=\"M21.4 2.6 11 13\"/><path d=\"M21.4 2.6 14.8 21.5a.6.6 0 0 1-1.1.05L11 14l-7.5-2.7a.6.6 0 0 1 .05-1.1L21.4 2.6Z\"/>',\n },\n settings: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"3.1\"/><path d=\"M12 2.6V5M12 19v2.4M4.2 4.2 5.9 5.9M18.1 18.1l1.7 1.7M2.6 12H5M19 12h2.4M4.2 19.8 5.9 18.1M18.1 5.9l1.7-1.7\"/>',\n },\n sliders: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 7h9M17 7h3\"/><circle cx=\"15\" cy=\"7\" r=\"2.1\"/><path d=\"M4 17h3M11 17h9\"/><circle cx=\"9\" cy=\"17\" r=\"2.1\"/>',\n },\n speaker: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 9.5h3.2L12 5.4v13.2L7.2 14.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z\"/><path d=\"M15.6 9.2a4 4 0 0 1 0 5.6\"/><path d=\"M18.2 6.6a7.7 7.7 0 0 1 0 10.8\"/>',\n },\n 'speaker-off': {\n vb: '0 0 24 24',\n d: '<path d=\"M4 9.5h3.2L12 5.4v13.2L7.2 14.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z\"/><path d=\"M16.4 9.6 21.4 14.4\"/><path d=\"M21.4 9.6 16.4 14.4\"/>',\n },\n 'thumbs-up': {\n vb: '0 0 24 24',\n d: '<path d=\"M7 10.4V20H4.2V10.4Z\"/><path d=\"M7 10.4 11 3.2a2 2 0 0 1 1.9 2.2L12.4 9H18a2 2 0 0 1 2 2.4l-1.1 6A2 2 0 0 1 16.9 20H7\"/>',\n },\n trash: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 7h16\"/><path d=\"M9.2 7V5.2A1.8 1.8 0 0 1 11 3.4h2a1.8 1.8 0 0 1 1.8 1.8V7\"/><path d=\"M6.2 7 7.2 19A1.9 1.9 0 0 0 9.1 20.7h5.8A1.9 1.9 0 0 0 16.8 19L17.8 7\"/><path d=\"M10.3 11v5M13.7 11v5\"/>',\n },\n typing: {\n vb: '0 0 24 24',\n d: '<circle cx=\"6\" cy=\"12\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"18\" cy=\"12\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n 'user-plus': {\n vb: '0 0 24 24',\n d: '<circle cx=\"9\" cy=\"8\" r=\"3.8\"/><path d=\"M3 20a6 6 0 0 1 12 0\"/><path d=\"M18 8v6M15 11h6\"/>',\n },\n user: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"8\" r=\"4\"/><path d=\"M4.6 20a7.4 7.4 0 0 1 14.8 0\"/>',\n },\n users: {\n vb: '0 0 24 24',\n d: '<circle cx=\"9\" cy=\"8\" r=\"3.6\"/><path d=\"M2.6 20a6.4 6.4 0 0 1 12.8 0\"/><path d=\"M15.8 4.7a3.6 3.6 0 0 1 0 6.6\"/><path d=\"M17.6 20a6.4 6.4 0 0 0-3.1-5.5\"/>',\n },\n video: {\n vb: '0 0 24 24',\n d: '<rect x=\"2.6\" y=\"6\" width=\"13\" height=\"12\" rx=\"2.4\"/><path d=\"M15.6 11.2 21.4 8v8l-5.8-3.2Z\"/>',\n },\n 'video-off': {\n vb: '0 0 24 24',\n d: '<rect x=\"2.6\" y=\"6\" width=\"13\" height=\"12\" rx=\"2.4\"/><path d=\"M15.6 11.2 21.4 8v8l-5.8-3.2Z\"/><path d=\"M3.6 3.2 20.4 20.8\"/>',\n },\n webhook: {\n vb: '0 0 24 24',\n d: '<circle cx=\"6\" cy=\"6\" r=\"2.6\"/><circle cx=\"18\" cy=\"9\" r=\"2.6\"/><circle cx=\"9.5\" cy=\"18\" r=\"2.6\"/><path d=\"M7.9 7.9 12 12l3.7-1.5\"/><path d=\"M11.6 12.7 9.8 16\"/>',\n },\n} as const satisfies Record<string, IconDef>;\n\nexport type IconName = keyof typeof ICONS;\n","import { SvgXml } from 'react-native-svg';\n\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\nimport { ICONS, type IconName } from './icons-data.js';\n\nexport type { IconName };\n\nexport interface PoolseIconProps {\n /** Icon name — see {@link IconName} for the full list. */\n name: IconName;\n /** Width + height in pixels. Defaults to `20` (matches a body-line). */\n size?: number;\n /** Stroke color. Defaults to the theme's `ink` color. */\n color?: string;\n /** Accessibility label. Defaults to the icon name. */\n label?: string | null;\n}\n\nexport function PoolseIcon({ name, size = 20, color, label }: PoolseIconProps) {\n const theme = usePoolseTheme();\n const def = ICONS[name];\n if (!def) return null;\n const stroke = color ?? theme.colors.ink;\n const xml = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${def.vb}\" fill=\"none\" stroke=\"${stroke}\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${def.d}</svg>`;\n const a11y =\n label === null\n ? { accessibilityRole: 'none' as const }\n : { accessibilityRole: 'image' as const, accessibilityLabel: label ?? name };\n return <SvgXml xml={xml} width={size} height={size} {...a11y} />;\n}\n","import type { MemberRole, Membership, Uuid } from '@poolse/sdk';\nimport { useMembers, usePresence, useUser } from '@poolse/react';\nimport { type ReactNode } from 'react';\nimport { ActivityIndicator, FlatList, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface MemberListProps {\n conversationId: Uuid;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onlineExternalIds?: Set<string>;\n canRemove?: (m: Membership) => boolean;\n renderItem?: (m: Membership) => ReactNode;\n emptyState?: ReactNode | string;\n}\n\nexport function MemberList({\n conversationId,\n labelFor,\n avatarFor,\n onlineExternalIds,\n canRemove,\n renderItem,\n emptyState,\n}: MemberListProps) {\n const theme = usePoolseTheme();\n const { members, loading, error, removeMember } = useMembers(conversationId);\n const { online: presenceOnline } = usePresence(\n onlineExternalIds === undefined ? conversationId : '',\n );\n const effectiveOnline = onlineExternalIds ?? presenceOnline;\n\n if (loading && members.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <ActivityIndicator color={theme.colors.brand} />\n </View>\n );\n }\n\n if (error) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <Text style={{ color: theme.colors.error, fontFamily: theme.type.fontBody }}>\n Failed to load members.\n </Text>\n {error.message ? (\n <Text style={[styles.errorDetail, { color: theme.colors.ink3 }]}>{error.message}</Text>\n ) : null}\n </View>\n );\n }\n\n if (members.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n {typeof emptyState === 'string' || emptyState == null ? (\n <Text style={{ color: theme.colors.ink3, fontFamily: theme.type.fontBody }}>\n {(emptyState as string) ?? 'No members.'}\n </Text>\n ) : (\n emptyState\n )}\n </View>\n );\n }\n\n return (\n <FlatList\n data={members}\n keyExtractor={(m) => m.user_id}\n style={{ backgroundColor: theme.colors.paper }}\n renderItem={({ item }) => {\n if (renderItem) return <>{renderItem(item)}</>;\n const isOnline = effectiveOnline.has(item.external_id);\n const showRemove = canRemove?.(item) ?? false;\n return (\n <MemberRow\n externalId={item.external_id}\n role={item.role}\n online={isOnline}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(showRemove ? { onRemove: () => removeMember(item.external_id) } : {})}\n />\n );\n }}\n />\n );\n}\n\nfunction MemberRow({\n externalId,\n role,\n online,\n labelFor,\n avatarFor,\n onRemove,\n}: {\n externalId: string;\n role: MemberRole;\n online: boolean;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onRemove?: () => void;\n}) {\n const theme = usePoolseTheme();\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n // The previous version used `labelFor?.(id) ?? id` and skipped the\n // resolver entirely when labelFor wasn't passed, defeating the\n // PoolseConfig.userResolver contract for consumers who configured\n // one and expected names + avatars to flow through automatically.\n const resolved = useUser(externalId);\n const name = labelFor?.(externalId) ?? resolved.profile?.displayName ?? externalId;\n const avatarUrl = avatarFor?.(externalId) ?? resolved.profile?.avatarUrl ?? null;\n return (\n <View style={styles.row}>\n <Avatar src={avatarUrl} name={name} seed={externalId} online={online} size=\"md\" />\n <View style={styles.body}>\n <Text\n style={[styles.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {name}\n </Text>\n <Text style={[styles.role, { color: theme.colors.ink3 }]}>{role}</Text>\n </View>\n {onRemove ? (\n <Pressable onPress={onRemove} hitSlop={8} style={styles.removeBtn}>\n <PoolseIcon name=\"close\" size={16} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n placeholder: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 24,\n },\n errorDetail: {\n marginTop: 6,\n fontSize: 11,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingVertical: 8,\n gap: 10,\n },\n body: {\n flex: 1,\n gap: 1,\n },\n name: {\n fontSize: 14,\n fontWeight: '500',\n },\n role: {\n fontSize: 11,\n textTransform: 'capitalize',\n },\n removeBtn: {\n padding: 6,\n },\n});\n","import { useMemo, useRef } from 'react';\nimport { Animated, PanResponder } from 'react-native';\n\ninterface Options {\n /** Called once the dismiss animation completes. */\n onClose: () => void;\n /**\n * Sheet height in pixels — used as the off-screen target when\n * animating dismissal. Pass `Dimensions.get('window').height * 0.85`\n * for a standard 85% bottom sheet.\n */\n sheetHeight: number;\n /**\n * Fraction of sheetHeight the user must drag past to commit\n * dismissal on release. Defaults to 0.22. Quick flicks (high\n * vertical velocity) also commit regardless of distance.\n */\n dismissThreshold?: number;\n}\n\n/**\n * Adds a pull-down-to-dismiss gesture to a bottom sheet. Returns an\n * Animated `translateY` to apply to the sheet's outer wrapper +\n * `panHandlers` to spread on whichever sub-view captures the drag\n * (typically the drag-pill area at the top, OR the whole sheet if\n * you want anywhere-drag to work).\n *\n * Only claims the gesture on clear downward motion; horizontal /\n * upward drags pass through to children (so a FlatList inside the\n * sheet can still scroll normally).\n */\nexport function useDismissableSheet({ onClose, sheetHeight, dismissThreshold = 0.22 }: Options) {\n const translateY = useRef(new Animated.Value(0)).current;\n\n const panResponder = useMemo(\n () =>\n PanResponder.create({\n onMoveShouldSetPanResponder: (_, g) => {\n // Only claim on clear downward intent. Lets the FlatList\n // inside the sheet handle vertical scrolls upward.\n return g.dy > 6 && g.dy > Math.abs(g.dx);\n },\n onPanResponderMove: (_, g) => {\n // Only follow downward drag (positive dy). Upward goes\n // back to 0 — sheet can't be pulled UP past its anchor.\n translateY.setValue(Math.max(0, g.dy));\n },\n onPanResponderRelease: (_, g) => {\n const committed = g.dy > sheetHeight * dismissThreshold || g.vy > 0.6;\n if (committed) {\n // Animate the sheet off-screen, THEN fire onClose. Without\n // this the modal's own slide-out + our reset would fight.\n Animated.timing(translateY, {\n toValue: sheetHeight,\n duration: 180,\n useNativeDriver: true,\n }).start(() => {\n translateY.setValue(0);\n onClose();\n });\n } else {\n Animated.spring(translateY, {\n toValue: 0,\n useNativeDriver: true,\n speed: 22,\n bounciness: 4,\n }).start();\n }\n },\n onPanResponderTerminate: () => {\n Animated.spring(translateY, {\n toValue: 0,\n useNativeDriver: true,\n speed: 22,\n bounciness: 4,\n }).start();\n },\n }),\n [onClose, sheetHeight, dismissThreshold, translateY],\n );\n\n return { translateY, panHandlers: panResponder.panHandlers };\n}\n","import type { Uuid } from '@poolse/sdk';\nimport { useConversation, useMembers } from '@poolse/react';\nimport {\n Animated,\n Modal,\n Pressable,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { MemberList } from './MemberList.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { useDismissableSheet } from './internal/useDismissableSheet.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface GroupDetailsSheetProps {\n visible: boolean;\n onClose: () => void;\n conversationId: Uuid;\n /** Resolve external_id → display name. Same shape as MemberList. */\n labelFor?: (externalId: string) => string;\n /** Resolve external_id → avatar URL. Same shape as MemberList. */\n avatarFor?: (externalId: string) => string | null;\n /**\n * Predicate for the per-row remove button. Defaults to \"never show\"\n * — wire it on the parent for owners/admins. Receives the\n * Membership row so you can scope to roles or exclude self.\n */\n canRemoveMember?: (m: { user_id: string; external_id: string; role: string }) => boolean;\n}\n\n/**\n * Bottom-sheet (85% of screen) that opens when the user taps the\n * group chat header. Shows group name + member count at the top,\n * then a scrollable roster with avatars, display names (resolved\n * through `labelFor` / `userResolver`), role badges, and live\n * presence dots (driven by `MemberList` internally).\n */\nexport function GroupDetailsSheet({\n visible,\n onClose,\n conversationId,\n labelFor,\n avatarFor,\n canRemoveMember,\n}: GroupDetailsSheetProps) {\n const theme = usePoolseTheme();\n const { conversation } = useConversation(conversationId);\n const { members } = useMembers(conversationId);\n const { height: screenHeight } = useWindowDimensions();\n const { translateY, panHandlers } = useDismissableSheet({\n onClose,\n sheetHeight: screenHeight * 0.85,\n });\n\n const title = conversation?.name ?? 'Conversation';\n const subtitle = `${members.length} ${members.length === 1 ? 'member' : 'members'}`;\n\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={onClose}\n statusBarTranslucent\n >\n <View style={styles.modalRoot}>\n <Pressable\n style={styles.backdrop}\n onPress={onClose}\n accessibilityLabel=\"Close group details\"\n />\n\n <Animated.View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.paper,\n borderTopLeftRadius: theme.radii.xl,\n borderTopRightRadius: theme.radii.xl,\n transform: [{ translateY }],\n },\n theme.shadows.lg,\n ]}\n >\n {/* Pan handlers spread on the drag-pill region so list\n scrolling underneath isn't affected. */}\n <View {...panHandlers} style={styles.dragHandle}>\n <View style={[styles.dragPill, { backgroundColor: theme.colors.ink3 }]} />\n </View>\n\n <View style={styles.headerRow}>\n <Pressable\n onPress={onClose}\n hitSlop={16}\n style={[styles.closeBtn, { backgroundColor: theme.colors.surface2 }]}\n accessibilityLabel=\"Close\"\n >\n <PoolseIcon name=\"close\" size={18} color={theme.colors.ink} />\n </Pressable>\n <Text\n style={[\n styles.headerTitle,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n >\n Group details\n </Text>\n </View>\n\n <View style={styles.summary}>\n <Avatar src={null} name={title} seed={conversationId} size=\"lg\" />\n <Text\n style={[\n styles.title,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n numberOfLines={1}\n >\n {title}\n </Text>\n <Text style={[styles.subtitle, { color: theme.colors.ink3 }]}>{subtitle}</Text>\n </View>\n\n <View style={[styles.divider, { backgroundColor: theme.colors.border }]} />\n\n <View style={styles.sectionLabelRow}>\n <Text\n style={[\n styles.sectionLabel,\n { color: theme.colors.ink2, fontFamily: theme.type.fontBody },\n ]}\n >\n Members\n </Text>\n </View>\n\n <View style={{ flex: 1 }}>\n <MemberList\n conversationId={conversationId}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(canRemoveMember ? { canRemove: canRemoveMember } : {})}\n emptyState=\"No members yet.\"\n />\n </View>\n </Animated.View>\n </View>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n modalRoot: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n backdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.4)',\n },\n sheet: {\n height: '85%',\n overflow: 'hidden',\n },\n dragHandle: {\n alignItems: 'center',\n paddingTop: 8,\n paddingBottom: 4,\n },\n dragPill: {\n width: 36,\n height: 4,\n borderRadius: 2,\n opacity: 0.4,\n },\n headerRow: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingTop: 4,\n paddingBottom: 12,\n gap: 10,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n },\n headerTitle: {\n fontSize: 16,\n fontWeight: '600',\n },\n summary: {\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingBottom: 16,\n gap: 8,\n },\n title: {\n fontSize: 20,\n fontWeight: '700',\n },\n subtitle: {\n fontSize: 13,\n },\n divider: {\n height: StyleSheet.hairlineWidth,\n },\n sectionLabelRow: {\n paddingHorizontal: 16,\n paddingTop: 14,\n paddingBottom: 6,\n },\n sectionLabel: {\n fontSize: 11,\n fontWeight: '700',\n letterSpacing: 0.5,\n textTransform: 'uppercase',\n },\n});\n","import type { Uuid } from '@poolse/sdk';\nimport { useConversation, useMe, useMembers, usePresence, useUser } from '@poolse/react';\nimport { useState } from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { GroupDetailsSheet } from './GroupDetailsSheet.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ChatHeaderProps {\n conversationId: Uuid;\n /**\n * Override the title resolver — useful when you want to derive the\n * direct-chat name from your own user directory instead of going\n * through the SDK's `userResolver`. When omitted, falls back to:\n * * direct → the other member's display name (via `useUser`)\n * * group → `conversation.name`\n */\n labelFor?: (externalId: string) => string;\n /** Optional avatar URL resolver for the other party (direct only). */\n avatarFor?: (externalId: string) => string | null;\n /** Right-side icon button — typically opens a member-list sheet. */\n onMembersPress?: () => void;\n /**\n * Tap handler for the whole header. Behavior:\n * * Direct chat → calls this if provided, otherwise no-op.\n * * Group chat → calls this if provided. If omitted, the header\n * opens a built-in group-details sheet showing the member\n * roster with live presence.\n */\n onPress?: () => void;\n /**\n * When provided, renders a back arrow on the LEFT of the header\n * that calls this handler on tap. Used by `<PoolseInbox>` to\n * navigate back to the conversation list; safe to wire from your\n * own navigator too.\n */\n onBack?: () => void;\n}\n\n/**\n * Top-of-chat header bar.\n * * 1:1 direct → other user's display name + avatar + presence dot.\n * * Group → conversation name + \"N members\" + group-tile avatar.\n *\n * Sits above `<MessageList>` inside `<ConversationView>` by default;\n * pass `header={false}` to `<ConversationView>` if you mount your own.\n */\nexport function ChatHeader({\n conversationId,\n labelFor,\n avatarFor,\n onMembersPress,\n onPress,\n onBack,\n}: ChatHeaderProps) {\n const theme = usePoolseTheme();\n const { conversation } = useConversation(conversationId);\n const { members } = useMembers(conversationId);\n const { me } = useMe();\n const { online } = usePresence(conversationId);\n const [detailsOpen, setDetailsOpen] = useState(false);\n\n const isDirect = conversation?.type === 'direct';\n const otherMember = isDirect ? members.find((m) => m.user_id !== me?.id) : null;\n const otherExtId = otherMember?.external_id ?? null;\n // useUser is safe with null — short-circuits to no-op state. Keeps the\n // hook unconditional regardless of conversation type.\n const otherUser = useUser(otherExtId);\n\n if (!conversation) {\n return (\n <View\n style={[\n styles.root,\n {\n backgroundColor: theme.colors.surface,\n borderBottomColor: theme.colors.border,\n },\n ]}\n />\n );\n }\n\n const fallbackName = otherExtId ?? '';\n const directName =\n otherUser.profile?.displayName ??\n (otherExtId ? (labelFor?.(otherExtId) ?? fallbackName) : 'Direct');\n const title = isDirect ? directName : (conversation.name ?? 'Conversation');\n\n const isOnline = isDirect && otherExtId ? online.has(otherExtId) : false;\n const subtitle = isDirect\n ? isOnline\n ? 'Online'\n : null\n : `${members.length} ${members.length === 1 ? 'member' : 'members'}`;\n\n const avatarUrl =\n isDirect && otherExtId\n ? (avatarFor?.(otherExtId) ?? otherUser.profile?.avatarUrl ?? null)\n : null;\n const avatarSeed = isDirect ? (otherExtId ?? conversationId) : conversationId;\n\n // For groups, default tap = open the built-in details sheet.\n // For directs (or when caller supplied onPress), call onPress.\n // A View wrapper is used only when there's no tap target at all\n // (direct chat with no onPress) so we don't render a no-op\n // Pressable that swallows touches.\n const isGroup = !isDirect;\n const headerOnPress = onPress ?? (isGroup ? () => setDetailsOpen(true) : undefined);\n const Wrapper: typeof View | typeof Pressable = headerOnPress ? Pressable : View;\n\n return (\n <>\n <Wrapper\n {...(headerOnPress ? { onPress: headerOnPress } : {})}\n style={[\n styles.root,\n {\n backgroundColor: theme.colors.surface,\n borderBottomColor: theme.colors.border,\n },\n ]}\n >\n {onBack ? (\n <Pressable onPress={onBack} hitSlop={12} style={styles.backBtn} accessibilityLabel=\"Back\">\n <PoolseIcon name=\"reply\" size={20} color={theme.colors.ink} />\n </Pressable>\n ) : null}\n <Avatar src={avatarUrl} name={title} seed={avatarSeed} online={isOnline} size=\"md\" />\n <View style={styles.titleCol}>\n <Text\n style={[styles.title, { color: theme.colors.ink, fontFamily: theme.type.fontDisplay }]}\n numberOfLines={1}\n >\n {title}\n </Text>\n {subtitle ? (\n <Text style={[styles.subtitle, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {subtitle}\n </Text>\n ) : null}\n </View>\n {onMembersPress ? (\n <Pressable\n onPress={onMembersPress}\n hitSlop={12}\n style={styles.actionBtn}\n accessibilityLabel=\"Show members\"\n >\n <PoolseIcon name=\"users\" size={20} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </Wrapper>\n\n {isGroup ? (\n <GroupDetailsSheet\n visible={detailsOpen}\n onClose={() => setDetailsOpen(false)}\n conversationId={conversationId}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n ) : null}\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 14,\n paddingVertical: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 12,\n },\n titleCol: {\n flex: 1,\n gap: 2,\n },\n title: {\n fontSize: 16,\n fontWeight: '600',\n },\n subtitle: {\n fontSize: 12,\n fontWeight: '500',\n },\n actionBtn: {\n width: 36,\n height: 36,\n borderRadius: 18,\n alignItems: 'center',\n justifyContent: 'center',\n },\n backBtn: {\n width: 36,\n height: 36,\n alignItems: 'center',\n justifyContent: 'center',\n marginLeft: -6,\n },\n});\n","import type { Conversation, Uuid } from '@poolse/sdk';\nimport { useConversations, useMe, useUser } from '@poolse/react';\nimport { type ReactNode } from 'react';\nimport {\n ActivityIndicator,\n FlatList,\n Image,\n Pressable,\n StyleSheet,\n Text,\n View,\n} from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ConversationListProps {\n selectedId?: string | null;\n onSelect?: (conv: Conversation) => void;\n /** Optional override for each row's rendering. */\n renderItem?: (conv: Conversation, selected: boolean) => ReactNode;\n /** Custom empty state when there are no conversations. */\n emptyState?: ReactNode | string;\n /** Controlled-mode: skip `useConversations()` and render from these. */\n conversations?: Conversation[];\n loading?: boolean;\n error?: Error | null;\n /** Per-conversation unread counts rendered as a Pulse Coral pill. */\n unreadCounts?: Record<Uuid, number>;\n /**\n * Explicit overrides for direct-chat names + avatars, keyed by the\n * OTHER member's external_id. When omitted, the row falls back to\n * `PoolseConfig.userResolver` and finally to the external_id.\n */\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n}\n\nexport function ConversationList({\n selectedId,\n onSelect,\n renderItem,\n emptyState,\n conversations: controlled,\n loading: controlledLoading,\n error: controlledError,\n unreadCounts,\n labelFor,\n avatarFor,\n}: ConversationListProps) {\n const theme = usePoolseTheme();\n const auto = useConversations();\n const { me } = useMe();\n const meExternalId = me?.external_id ?? null;\n const isControlled = controlled !== undefined;\n const conversations = isControlled ? controlled : auto.conversations;\n const loading = isControlled ? (controlledLoading ?? false) : auto.loading;\n const error = isControlled ? (controlledError ?? null) : auto.error;\n const counts = unreadCounts ?? (isControlled ? undefined : auto.unreadCounts);\n\n if (loading && conversations.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <ActivityIndicator color={theme.colors.brand} />\n </View>\n );\n }\n\n if (error) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <Text style={{ color: theme.colors.error, fontFamily: theme.type.fontBody }}>\n Failed to load conversations.\n </Text>\n </View>\n );\n }\n\n if (conversations.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n {typeof emptyState === 'string' || emptyState == null ? (\n <Text style={{ color: theme.colors.ink3, fontFamily: theme.type.fontBody }}>\n {(emptyState as string) ?? 'No conversations yet.'}\n </Text>\n ) : (\n emptyState\n )}\n </View>\n );\n }\n\n return (\n <FlatList\n data={conversations}\n keyExtractor={(c) => c.id}\n style={{ backgroundColor: theme.colors.paper }}\n renderItem={({ item }) => {\n const selected = selectedId === item.id;\n if (renderItem) {\n return <>{renderItem(item, selected)}</>;\n }\n return (\n <ConversationRow\n conv={item}\n selected={selected}\n meExternalId={meExternalId}\n unread={counts?.[item.id] ?? 0}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(onSelect ? { onSelect } : {})}\n />\n );\n }}\n />\n );\n}\n\nfunction ConversationRow({\n conv,\n selected,\n meExternalId,\n unread,\n labelFor,\n avatarFor,\n onSelect,\n}: {\n conv: Conversation;\n selected: boolean;\n meExternalId: string | null;\n unread: number;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onSelect?: (conv: Conversation) => void;\n}) {\n const theme = usePoolseTheme();\n\n // For direct conversations the row title + avatar come from the OTHER\n // member, NOT the conversation itself (which has `name: null` for\n // directs). Find the counterparty's external_id and resolve via the\n // standard priority: explicit prop > userResolver > external_id.\n const isDirect = conv.type === 'direct';\n const otherExtId =\n isDirect && meExternalId\n ? ((conv.member_external_ids ?? []).find((x) => x !== meExternalId) ?? null)\n : null;\n const resolvedOther = useUser(isDirect ? otherExtId : null);\n\n const title = isDirect\n ? otherExtId\n ? (labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId)\n : 'Direct chat'\n : (conv.name ?? 'Untitled conversation');\n const avatarUrl =\n isDirect && otherExtId\n ? (avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null)\n : null;\n const avatarSeed = isDirect ? (otherExtId ?? conv.id) : conv.id;\n\n return (\n <Pressable\n onPress={() => onSelect?.(conv)}\n style={[\n styles.row,\n {\n backgroundColor: selected ? theme.colors.surface2 : 'transparent',\n },\n ]}\n >\n {avatarUrl ? (\n <Image source={{ uri: avatarUrl }} style={styles.rowAvatar} />\n ) : (\n <Avatar src={null} name={title} seed={avatarSeed} size=\"md\" />\n )}\n <View style={styles.body}>\n <Text\n style={[styles.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {title}\n </Text>\n {conv.last_message_preview ? (\n <Text style={[styles.preview, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {conv.last_message_preview}\n </Text>\n ) : conv.last_message_at ? (\n <Text style={[styles.preview, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {formatRelative(conv.last_message_at)}\n </Text>\n ) : null}\n </View>\n {unread > 0 ? (\n <View style={[styles.unreadPill, { backgroundColor: theme.colors.unreadPill }]}>\n <Text style={[styles.unreadText, { color: theme.colors.unreadPillText }]}>\n {unread > 99 ? '99+' : String(unread)}\n </Text>\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nfunction formatRelative(iso: string): string {\n try {\n const d = new Date(iso);\n const now = Date.now();\n const diff = now - d.getTime();\n if (diff < 60_000) return 'just now';\n if (diff < 3600_000) return `${Math.floor(diff / 60_000)}m`;\n if (diff < 86_400_000) return `${Math.floor(diff / 3600_000)}h`;\n return `${Math.floor(diff / 86_400_000)}d`;\n } catch {\n return '';\n }\n}\n\nconst styles = StyleSheet.create({\n placeholder: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 24,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingVertical: 10,\n gap: 10,\n },\n rowAvatar: {\n width: 40,\n height: 40,\n borderRadius: 20,\n },\n body: {\n flex: 1,\n gap: 2,\n },\n name: {\n fontSize: 15,\n fontWeight: '600',\n },\n preview: {\n fontSize: 12,\n },\n unreadPill: {\n minWidth: 22,\n height: 22,\n borderRadius: 11,\n paddingHorizontal: 6,\n alignItems: 'center',\n justifyContent: 'center',\n },\n unreadText: {\n fontSize: 11,\n fontWeight: '700',\n },\n});\n","import { createContext, useCallback, useContext, useRef, type ReactNode } from 'react';\nimport { useAttachmentUpload } from '@poolse/react';\n\ntype UploadState = ReturnType<typeof useAttachmentUpload>;\n\n/**\n * Shared upload-queue value. The SDK's `useAttachmentUpload` creates\n * a private queue per call site — without a provider, each component\n * (picker / composer / strip) ends up with its own queue and uploads\n * never reach the send-with-attachment_ids path.\n *\n * `setPreview` / `getPreview` are an RN-only side channel: the SDK\n * strips the original local file URI when it converts to a Blob, but\n * the queue strip needs the URI to render an Image thumbnail. The\n * picker stashes it here keyed by filename so the strip can read it\n * back during render.\n */\ninterface UploadContextValue {\n upload: UploadState;\n setPreview: (filename: string, uri: string) => void;\n getPreview: (filename: string) => string | null;\n}\n\nconst UploadCtx = createContext<UploadContextValue | null>(null);\n\nexport function UploadProvider({ children }: { children: ReactNode }) {\n const upload = useAttachmentUpload();\n const previews = useRef<Map<string, string>>(new Map());\n\n const setPreview = useCallback((filename: string, uri: string) => {\n previews.current.set(filename, uri);\n }, []);\n\n const getPreview = useCallback((filename: string) => {\n return previews.current.get(filename) ?? null;\n }, []);\n\n return (\n <UploadCtx.Provider value={{ upload, setPreview, getPreview }}>{children}</UploadCtx.Provider>\n );\n}\n\n/**\n * Read the shared upload state. Falls back to a component-local\n * `useAttachmentUpload` when no provider is mounted so the component\n * still functions standalone (but loses preview thumbnails since\n * setPreview won't propagate).\n */\nexport function useSharedUpload(): UploadState {\n const fromCtx = useContext(UploadCtx);\n const fallback = useAttachmentUpload();\n return fromCtx?.upload ?? fallback;\n}\n\n/**\n * Preview-URI side channel for the queue strip's thumbnails. No-op\n * when no provider is mounted (strip falls back to icon placeholder).\n */\nexport function useUploadPreview() {\n const ctx = useContext(UploadCtx);\n return {\n setPreview: ctx?.setPreview ?? (() => undefined),\n getPreview: ctx?.getPreview ?? (() => null),\n };\n}\n","import { Image as RNImage, Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n// Static imports — Metro's bundle graph can only trace literal\n// `import` / `require` calls. The earlier `new Function('m', 'return\n// import(m)')(name)` trick bypassed Metro entirely, so the picker\n// modules were never bundled even when the consumer installed them.\n//\n// Trade-off: if a consumer mounts <AttachmentPicker> without these\n// modules installed, the bundle fails at build time with a clear\n// \"module not found\" rather than the silent runtime warning we had\n// before. Consumers who don't want attachments at all should pass\n// `attachments={false}` to <ConversationView> so this file is never\n// rendered (and tree-shaking can drop the imports in production\n// builds with a real bundler — Metro doesn't tree-shake but the\n// imports add ~12kb total which is acceptable).\nimport * as ImagePicker from 'expo-image-picker';\nimport * as DocumentPicker from 'expo-document-picker';\nimport { manipulateAsync, SaveFormat } from 'expo-image-manipulator';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { useSharedUpload, useUploadPreview } from './internal/uploadContext.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface AttachmentPickerProps {\n visible: boolean;\n onClose: () => void;\n /**\n * Optional adapter that produces upload inputs from a picked file.\n * Override to plug in custom storage / transcoding. Default reads\n * from `expo-image-picker` / `expo-document-picker`.\n */\n onPickInputs?: (kind: 'image' | 'document' | 'camera') => Promise<\n {\n body: { uri: string; name: string; type: string } | Blob | unknown;\n contentType: string;\n byteSize: number;\n filename?: string;\n }[]\n >;\n /**\n * Show the Camera item alongside Photo and File. Defaults true.\n * Disable if your app explicitly doesn't want camera access (some\n * App Store reviewers require an explicit usage description even\n * for the picker entry). Add `NSCameraUsageDescription` to your\n * iOS Info.plist when leaving this on.\n */\n camera?: boolean;\n}\n\n/**\n * Picker sheet wrapping `expo-image-picker` and `expo-document-picker`.\n * Both must be installed (`npx expo install expo-image-picker\n * expo-document-picker`) when this component is mounted — they're\n * declared as optional peers because consumers who pass\n * `attachments={false}` to ConversationView never render this file.\n */\nexport function AttachmentPicker({\n visible,\n onClose,\n onPickInputs,\n camera = true,\n}: AttachmentPickerProps) {\n const theme = usePoolseTheme();\n // Shared queue (via UploadProvider) so the composer sees these\n // uploads and can include them in the next send. Falls back to a\n // local queue when the picker is mounted outside ConversationView.\n const upload = useSharedUpload();\n const { setPreview } = useUploadPreview();\n\n const pickFromKind = async (kind: 'image' | 'document' | 'camera') => {\n try {\n const adapter = onPickInputs ?? defaultAdapter;\n const inputs = await adapter(kind);\n for (const input of inputs) {\n // Stash the original local URI on the shared context so the\n // UploadQueueStrip can render a real thumbnail. The SDK only\n // sees the Blob from here on out.\n const previewUri = (input as { _previewUri?: string })._previewUri ?? null;\n if (previewUri && input.filename) {\n setPreview(input.filename, previewUri);\n }\n void upload.upload(input as never);\n }\n } catch (err) {\n console.warn('[poolse/picker]', err);\n } finally {\n onClose();\n }\n };\n\n return (\n <Modal visible={visible} transparent animationType=\"slide\" onRequestClose={onClose}>\n <Pressable style={styles.backdrop} onPress={onClose}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderTopLeftRadius: theme.radii.lg,\n borderTopRightRadius: theme.radii.lg,\n },\n theme.shadows.lg,\n ]}\n >\n {camera ? (\n <Pressable style={styles.item} onPress={() => pickFromKind('camera')}>\n <PoolseIcon name=\"camera\" size={20} color={theme.colors.ink2} />\n <Text style={[styles.itemText, { color: theme.colors.ink }]}>Camera</Text>\n </Pressable>\n ) : null}\n <Pressable style={styles.item} onPress={() => pickFromKind('image')}>\n <PoolseIcon name=\"image\" size={20} color={theme.colors.ink2} />\n <Text style={[styles.itemText, { color: theme.colors.ink }]}>Photo or video</Text>\n </Pressable>\n <Pressable style={styles.item} onPress={() => pickFromKind('document')}>\n <PoolseIcon name=\"attachment\" size={20} color={theme.colors.ink2} />\n <Text style={[styles.itemText, { color: theme.colors.ink }]}>File</Text>\n </Pressable>\n <Pressable style={styles.cancel} onPress={onClose}>\n <Text style={[styles.itemText, { color: theme.colors.brand }]}>Cancel</Text>\n </Pressable>\n </View>\n </Pressable>\n </Modal>\n );\n}\n\n// RN gives us a local file URI. The SDK's upload PUTs the `body` raw\n// to a presigned S3/R2 URL — those only accept raw bytes, NOT\n// multipart. If we passed the `{ uri, name, type }` object directly,\n// fetch would serialize it as multipart and the bucket would reject\n// the upload silently. So we read the URI as a Blob first (same shape\n// that `<input type=\"file\">` would give on web) and pass that.\nasync function uriToBlob(uri: string): Promise<Blob> {\n const res = await fetch(uri);\n if (!res.ok && res.status !== 0) {\n throw new Error(`failed to read picked file (HTTP ${res.status})`);\n }\n return res.blob();\n}\n\n// Phone-sized output — the fullscreen viewer on a 3x retina display\n// only needs ~1300px on the long edge, and chat bubbles top out at\n// ~960px. 1600 leaves headroom for pinch-zoom without sending the\n// 4000+ px monsters that some screenshots ship with.\nconst COMPRESSION_LONG_SIDE_PX = 1600;\nconst COMPRESSION_QUALITY = 0.75;\n\nfunction getImageSize(uri: string): Promise<{ width: number; height: number }> {\n return new Promise((resolve, reject) => {\n RNImage.getSize(uri, (width, height) => resolve({ width, height }), reject);\n });\n}\n\n/**\n * Resize → WebP @ 0.75 every image before upload. iOS screenshots\n * can be 8–12 MB PNGs and the fullscreen `<Image>` decode of those\n * blocks the JS thread / silently fails on older devices — clipping\n * the long edge to 1600 keeps the per-message payload under ~250kb\n * for typical photos and is still crisp on every phone display.\n *\n * Never upscales. Falls back to the original blob on any failure so\n * a flaky manipulator pass never blocks a send.\n */\nasync function compressImage({\n uri,\n width,\n height,\n filename,\n}: {\n uri: string;\n width?: number;\n height?: number;\n filename?: string;\n}): Promise<{ blob: Blob; contentType: string; filename: string }> {\n let w = width;\n let h = height;\n if (!w || !h) {\n try {\n const size = await getImageSize(uri);\n w = size.width;\n h = size.height;\n } catch {\n w = 0;\n h = 0;\n }\n }\n const longSide = Math.max(w ?? 0, h ?? 0);\n const scale = longSide > COMPRESSION_LONG_SIDE_PX ? COMPRESSION_LONG_SIDE_PX / longSide : 1;\n const actions =\n scale < 1 && w && h\n ? [{ resize: { width: Math.round(w * scale), height: Math.round(h * scale) } }]\n : [];\n\n const result = await manipulateAsync(uri, actions, {\n compress: COMPRESSION_QUALITY,\n format: SaveFormat.WEBP,\n });\n const blob = await uriToBlob(result.uri);\n const base = (filename ?? `image-${Date.now()}`).replace(/\\.[^.]+$/, '');\n return {\n blob,\n contentType: 'image/webp',\n filename: `${base}.webp`,\n };\n}\n\nasync function assetsToInputs(assets: ReadonlyArray<ImagePicker.ImagePickerAsset>) {\n return Promise.all(\n assets.map(async (asset) => {\n try {\n const compressed = await compressImage({\n uri: asset.uri,\n width: asset.width,\n height: asset.height,\n filename: asset.fileName ?? `image-${Date.now()}`,\n });\n return {\n body: compressed.blob,\n contentType: compressed.contentType,\n byteSize: compressed.blob.size,\n filename: compressed.filename,\n _previewUri: asset.uri,\n };\n } catch (err) {\n console.warn('[poolse/picker] image compression failed, sending original:', err);\n const blob = await uriToBlob(asset.uri);\n const contentType = asset.mimeType ?? blob.type ?? 'image/jpeg';\n return {\n body: blob,\n contentType,\n byteSize: asset.fileSize ?? blob.size,\n filename: asset.fileName ?? `image-${Date.now()}.jpg`,\n _previewUri: asset.uri,\n };\n }\n }),\n );\n}\n\nasync function defaultAdapter(kind: 'image' | 'document' | 'camera') {\n if (kind === 'camera') {\n // Camera permissions are required on both iOS (Info.plist\n // NSCameraUsageDescription) and Android. requestCameraPermissionsAsync\n // shows the system prompt the first time; subsequent calls\n // resolve immediately with the cached answer.\n const perm = await ImagePicker.requestCameraPermissionsAsync();\n if (!perm.granted) {\n console.warn('[poolse/picker] camera permission denied');\n return [];\n }\n const res = await ImagePicker.launchCameraAsync({\n mediaTypes: 'images',\n quality: 1,\n });\n if (res.canceled) return [];\n return assetsToInputs(res.assets);\n }\n if (kind === 'image') {\n const res = await ImagePicker.launchImageLibraryAsync({\n mediaTypes: 'images',\n // Quality 1 — picker hands back the source as-is and we do the\n // compression ourselves below. Letting the picker re-encode\n // first just chains two lossy passes.\n quality: 1,\n });\n if (res.canceled) return [];\n return assetsToInputs(res.assets);\n }\n const res = await DocumentPicker.getDocumentAsync({\n copyToCacheDirectory: true,\n multiple: true,\n });\n if (res.canceled) return [];\n return Promise.all(\n res.assets.map(async (asset) => {\n const isImage = (asset.mimeType ?? '').startsWith('image/');\n if (isImage) {\n try {\n const compressed = await compressImage({\n uri: asset.uri,\n filename: asset.name,\n });\n return {\n body: compressed.blob,\n contentType: compressed.contentType,\n byteSize: compressed.blob.size,\n filename: compressed.filename,\n _previewUri: asset.uri,\n };\n } catch (err) {\n console.warn('[poolse/picker] image compression failed, sending original:', err);\n }\n }\n const blob = await uriToBlob(asset.uri);\n const contentType = asset.mimeType ?? blob.type ?? 'application/octet-stream';\n return {\n body: blob,\n contentType,\n byteSize: asset.size ?? blob.size,\n filename: asset.name,\n _previewUri: asset.uri,\n };\n }),\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.35)',\n justifyContent: 'flex-end',\n },\n sheet: {\n paddingVertical: 8,\n paddingBottom: 24,\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 20,\n paddingVertical: 14,\n gap: 14,\n },\n cancel: {\n paddingHorizontal: 20,\n paddingVertical: 14,\n alignItems: 'center',\n marginTop: 4,\n },\n itemText: {\n fontSize: 15,\n fontWeight: '500',\n },\n});\n","import { StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface DaySeparatorProps {\n label: string;\n}\n\n/**\n * Centered date pill rendered between messages whose `inserted_at`\n * falls on a different calendar day from the previous message. Pair\n * with `formatDayLabel` from `@poolse/react` to compute the label\n * (\"Today\" / \"Yesterday\" / weekday / \"26 May 2024\").\n */\nexport function DaySeparator({ label }: DaySeparatorProps) {\n const theme = usePoolseTheme();\n return (\n <View style={styles.wrap}>\n <View\n style={[\n styles.chip,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: theme.colors.border,\n },\n ]}\n >\n <Text\n style={[\n styles.label,\n {\n color: theme.colors.ink2,\n fontFamily: theme.type.fontBody,\n },\n ]}\n >\n {label}\n </Text>\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignItems: 'center',\n marginVertical: 8,\n },\n chip: {\n paddingHorizontal: 12,\n paddingVertical: 4,\n borderRadius: 999,\n borderWidth: StyleSheet.hairlineWidth,\n },\n label: {\n fontSize: 11,\n fontWeight: '600',\n letterSpacing: 0.3,\n },\n});\n","import { Image, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { useSharedUpload, useUploadPreview } from './internal/uploadContext.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\n/**\n * Horizontal scrolling preview row of pending / in-flight / ready\n * uploads. Image attachments render as 64×64 thumbnails sourced from\n * the original local file URI; file attachments render as a row card\n * with icon + name + size. A small × overlay on each tile lets the\n * user drop the upload before send.\n *\n * Reads queue state from the shared `<UploadProvider>` (mounted by\n * `<ConversationView>`), so the composer's \"ready attachment ids\"\n * pickup and the strip's display always agree.\n */\nexport function UploadQueueStrip() {\n const theme = usePoolseTheme();\n const upload = useSharedUpload();\n const { getPreview } = useUploadPreview();\n\n if (upload.queue.length === 0) return null;\n\n return (\n <ScrollView\n horizontal\n showsHorizontalScrollIndicator={false}\n contentContainerStyle={styles.scroll}\n // overflow:visible (+ explicit paddingTop on the contentContainer)\n // so the X close button can sit at -6/-6 outside the tile without\n // being clipped by the scroll bounds.\n style={[styles.scrollStyle, { marginBottom: 8 }]}\n >\n {upload.queue.map((item) => {\n const isError = item.status === 'error';\n const isUploading = item.status === 'uploading' || item.status === 'pending';\n const isImage = (item.contentType ?? '').startsWith('image/');\n const previewUri = getPreview(item.filename);\n const canTerminate = isUploading || item.status === 'ready' || isError;\n\n const handleClose = () => {\n if (item.status === 'ready' || isError) upload.remove(item.localId);\n else upload.cancel(item.localId);\n };\n\n return (\n <View key={item.localId} style={styles.tileWrap}>\n {isImage && previewUri ? (\n <ImageTile uri={previewUri} uploading={isUploading} error={isError} />\n ) : (\n <FileTile\n filename={item.filename}\n size={item.byteSize}\n uploading={isUploading}\n error={isError}\n />\n )}\n\n {canTerminate ? (\n <Pressable\n onPress={handleClose}\n hitSlop={8}\n // Hardcoded dark dot + white X. Pulling from the\n // theme made the close affordance invisible against\n // light-on-light or dark-on-dark custom palettes\n // (e.g. a white-on-white surface/onBrand pair).\n // This is a thumbnail badge — not chrome — so it\n // should look the same in every theme.\n style={styles.closeBtn}\n accessibilityLabel={isError ? 'Remove failed upload' : 'Cancel upload'}\n >\n <PoolseIcon name=\"close\" size={11} color=\"#fff\" />\n </Pressable>\n ) : null}\n\n {isUploading ? (\n <View style={styles.progressOverlay}>\n <View style={[styles.spinner, { borderColor: theme.colors.onBrand }]} />\n </View>\n ) : null}\n\n {isError ? (\n <View style={[styles.errorOverlay, { backgroundColor: 'rgba(229,72,77,0.85)' }]}>\n <Text style={[styles.errorText, { color: '#fff' }]}>Failed</Text>\n </View>\n ) : null}\n </View>\n );\n })}\n </ScrollView>\n );\n}\n\nfunction ImageTile({ uri, uploading, error }: { uri: string; uploading: boolean; error: boolean }) {\n const theme = usePoolseTheme();\n return (\n <Image\n source={{ uri }}\n style={[\n styles.imageTile,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: error ? theme.colors.error : 'transparent',\n opacity: uploading ? 0.65 : 1,\n },\n ]}\n resizeMode=\"cover\"\n />\n );\n}\n\nfunction FileTile({\n filename,\n size,\n uploading,\n error,\n}: {\n filename: string;\n size: number;\n uploading: boolean;\n error: boolean;\n}) {\n const theme = usePoolseTheme();\n return (\n <View\n style={[\n styles.fileTile,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: error\n ? theme.colors.error\n : uploading\n ? theme.colors.brand\n : theme.colors.border,\n },\n ]}\n >\n <View style={[styles.fileIconBox, { backgroundColor: theme.colors.brandSoft }]}>\n <PoolseIcon name=\"attachment\" size={18} color={theme.colors.brand} />\n </View>\n <View style={styles.fileInfo}>\n <Text\n style={[styles.fileName, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {filename}\n </Text>\n <Text style={[styles.fileSize, { color: theme.colors.ink3 }]}>{formatBytes(size)}</Text>\n </View>\n </View>\n );\n}\n\nfunction formatBytes(n: number): string {\n if (!n || n < 0) return '';\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;\n if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;\n return `${(n / 1024 / 1024 / 1024).toFixed(1)} GB`;\n}\n\nconst TILE = 64;\n\nconst styles = StyleSheet.create({\n scrollStyle: {\n overflow: 'visible',\n },\n scroll: {\n paddingHorizontal: 8,\n // paddingTop creates room for the X to overflow the tile without\n // being clipped on Android (where overflow:visible isn't enough).\n paddingTop: 8,\n gap: 10,\n flexDirection: 'row',\n },\n tileWrap: {\n position: 'relative',\n overflow: 'visible',\n },\n imageTile: {\n width: TILE,\n height: TILE,\n borderRadius: 10,\n borderWidth: 1.5,\n },\n fileTile: {\n height: TILE,\n minWidth: 200,\n maxWidth: 260,\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 10,\n paddingRight: 28,\n borderRadius: 10,\n borderWidth: 1,\n gap: 10,\n },\n fileIconBox: {\n width: 36,\n height: 36,\n borderRadius: 8,\n alignItems: 'center',\n justifyContent: 'center',\n },\n fileInfo: {\n flex: 1,\n gap: 2,\n },\n fileName: {\n fontSize: 13,\n fontWeight: '600',\n },\n fileSize: {\n fontSize: 11,\n },\n closeBtn: {\n // Outside the tile (top-right corner overflowing). Parent\n // scroll container + tileWrap set overflow:visible and the\n // scroll contentContainer has paddingTop:8 so the overflow\n // isn't clipped on Android.\n position: 'absolute',\n top: -6,\n right: -6,\n width: 22,\n height: 22,\n borderRadius: 11,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(40,40,40,0.85)',\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 1 },\n shadowOpacity: 0.3,\n shadowRadius: 2,\n elevation: 3,\n },\n progressOverlay: {\n ...StyleSheet.absoluteFillObject,\n alignItems: 'center',\n justifyContent: 'center',\n pointerEvents: 'none',\n },\n spinner: {\n width: 24,\n height: 24,\n borderRadius: 12,\n borderWidth: 2.5,\n borderTopColor: 'transparent',\n // RN can't loop a rotation purely in StyleSheet, but the static\n // 3/4-circle still reads as \"in progress.\" A real Animated.View\n // rotation lands in a follow-up.\n },\n errorOverlay: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n paddingVertical: 3,\n alignItems: 'center',\n },\n errorText: {\n fontSize: 10,\n fontWeight: '700',\n },\n});\n","import { Platform } from 'react-native';\n\n// Lazy-resolve react-native-safe-area-context. Returns the real\n// hook when available + a SafeAreaProvider is mounted; falls back\n// to platform-typical iOS values otherwise. Used ONLY for computing\n// keyboardVerticalOffset — never for adding safe-area padding to\n// chrome (consumers' root SafeAreaView already handles that, and\n// double-padding caused the earlier 0.1.6 bug).\n\nexport interface EdgeInsets {\n top: number;\n bottom: number;\n left: number;\n right: number;\n}\n\nconst FALLBACK: EdgeInsets = {\n top: Platform.OS === 'ios' ? 50 : 24,\n bottom: Platform.OS === 'ios' ? 34 : 0,\n left: 0,\n right: 0,\n};\n\ntype SafeAreaModule = {\n useSafeAreaInsets?: () => EdgeInsets;\n};\n\nlet realHook: (() => EdgeInsets) | null = null;\ntry {\n // Optional dep — only resolved when the host app installs\n // react-native-safe-area-context. Wrapped in try/catch so the\n // bundle still works without it.\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = require('react-native-safe-area-context') as SafeAreaModule;\n if (mod && typeof mod.useSafeAreaInsets === 'function') {\n realHook = mod.useSafeAreaInsets;\n }\n} catch {\n /* not installed — fallback */\n}\n\nconst useFallback = (): EdgeInsets => FALLBACK;\n\nexport const useSafeInsets: () => EdgeInsets = realHook ?? useFallback;\n","import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { Keyboard, Platform, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';\nimport type { AttachmentUploadInput, Message, Uuid } from '@poolse/sdk';\nimport { useUser } from '@poolse/react';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { UploadQueueStrip } from './UploadQueueStrip.js';\nimport { useSharedUpload } from './internal/uploadContext.js';\nimport { useSafeInsets } from './internal/safeArea.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface MessageComposerProps {\n /**\n * Called when the user taps Send. Second arg carries\n * `quoted_message_id` (when replying) and `attachment_ids`\n * (resolved from the composer's upload queue). Awaited so the\n * composer disables until the send round-trips.\n */\n onSend: (\n body: string,\n opts?: { quoted_message_id?: Uuid; attachment_ids?: Uuid[] },\n ) => Promise<unknown> | void;\n /** Called on every keystroke. Hook to `useTyping().signalTyping`. */\n onTyping?: () => void;\n placeholder?: string;\n disabled?: boolean;\n /** Renders a quote chip above the input; cleared by the caller in `onSend`. */\n replyingTo?: Message | null;\n /** User tapped (x) on the quote chip. */\n onCancelReply?: () => void;\n /** Display label for the quoted sender, keyed by `external_id`. */\n labelFor?: (externalId: string) => string;\n /** Show the paperclip + queue strip. Defaults true. */\n attachments?: boolean;\n /** Tap on the paperclip — wire to `<AttachmentPicker>` from the same package. */\n onAttachPress?: () => void;\n /**\n * Distance from the top of the screen to the top of the\n * KeyboardAvoidingView — typically the height of any navigation\n * header sitting above the chat. Pass this when the iOS keyboard\n * suggestions strip ends up covering the composer (a sign the\n * computed offset is wrong). Defaults to 0; on Android it's\n * ignored.\n */\n keyboardOffset?: number;\n /**\n * When set, the composer enters edit mode: prefills the input with\n * the message body and renders an \"Editing message\" chip above\n * (mirrors `replyingTo`). Tapping Send calls `onSaveEdit(body)`\n * instead of `onSend`; `onCancelEdit` clears the chip and restores\n * the previous draft. Pass `null` (or omit) when not editing.\n */\n editingMessage?: Message | null;\n onCancelEdit?: () => void;\n onSaveEdit?: (body: string) => Promise<unknown> | void;\n}\n\n/**\n * Imperative handle for parents that want to add files to the\n * composer's upload queue externally (drag/drop on a wrapper,\n * deep-link, attachment shortcut).\n */\nexport interface MessageComposerHandle {\n /** Enqueue ready-to-upload inputs. The picker component is the usual caller; this is the escape hatch. */\n addFiles: (inputs: AttachmentUploadInput[]) => void;\n focus: () => void;\n clear: () => void;\n}\n\nexport const MessageComposer = forwardRef<MessageComposerHandle, MessageComposerProps>(\n function MessageComposer(\n {\n onSend,\n onTyping,\n placeholder = 'Type a message…',\n disabled = false,\n replyingTo,\n onCancelReply,\n labelFor,\n attachments = true,\n onAttachPress,\n keyboardOffset: _keyboardOffset = 0,\n editingMessage = null,\n onCancelEdit,\n onSaveEdit,\n },\n ref,\n ) {\n const theme = usePoolseTheme();\n const inputRef = useRef<TextInput>(null);\n const [value, setValue] = useState('');\n const [sending, setSending] = useState(false);\n const [keyboardOpen, setKeyboardOpen] = useState(false);\n const upload = useSharedUpload();\n const insets = useSafeInsets();\n\n useEffect(() => {\n const show = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow',\n () => setKeyboardOpen(true),\n );\n const hide = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide',\n () => setKeyboardOpen(false),\n );\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n addFiles: (inputs) => {\n if (!attachments) return;\n for (const input of inputs) {\n void upload.upload(input);\n }\n },\n focus: () => inputRef.current?.focus(),\n clear: () => setValue(''),\n }),\n [attachments, upload],\n );\n\n const readyAttachmentIds = upload.queue\n .filter((item) => item.status === 'ready' && item.attachment)\n .map((item) => item.attachment!.id);\n const isUploading = upload.queue.some(\n (item) => item.status === 'uploading' || item.status === 'pending',\n );\n\n // Stash the user's in-progress draft when edit mode opens so we\n // can put it back when they cancel. Without this, cancelling\n // would either wipe what they were typing or leave the edited\n // body in the input.\n const previousDraftRef = useRef<string | null>(null);\n const editingIdRef = useRef<string | null>(null);\n useEffect(() => {\n const id = editingMessage?.id ?? null;\n if (id === editingIdRef.current) return;\n if (id) {\n // Entering edit mode for a new message: snapshot whatever\n // the user was drafting, then prefill with the body.\n previousDraftRef.current = value;\n setValue(editingMessage?.body ?? '');\n // Focus so the keyboard pops up and the cursor lands at the\n // end of the prefilled body.\n inputRef.current?.focus();\n } else {\n // Leaving edit mode — restore the prior draft.\n setValue(previousDraftRef.current ?? '');\n previousDraftRef.current = null;\n }\n editingIdRef.current = id;\n // value intentionally omitted: we only want this to fire when\n // the editingMessage identity changes, not on every keystroke.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editingMessage?.id, editingMessage?.body]);\n\n const isEditing = !!editingMessage;\n const editChanged = isEditing && value.trim() !== (editingMessage?.body?.trim() ?? '');\n\n const submitDisabled =\n disabled ||\n sending ||\n isUploading ||\n (isEditing\n ? !editChanged || value.trim().length === 0\n : value.trim().length === 0 && readyAttachmentIds.length === 0);\n\n const handleSend = async () => {\n if (submitDisabled) return;\n // Snapshot + clear synchronously so the input is empty on the\n // next keystroke even if the send round-trip is slow. Otherwise\n // the user types into the still-present old text and the new\n // characters append to the stale message.\n const body = value.trim();\n setSending(true);\n try {\n if (isEditing && onSaveEdit) {\n // Edit mode: don't clear attachments or the reply chip;\n // we're just updating the body. The parent will clear\n // editingMessage on success, which triggers the effect\n // above to restore the prior draft.\n await onSaveEdit(body);\n } else {\n const replyId = replyingTo?.id;\n const attachmentIds = readyAttachmentIds;\n setValue('');\n upload.reset();\n await onSend(body, {\n ...(replyId ? { quoted_message_id: replyId } : {}),\n ...(attachmentIds.length > 0 ? { attachment_ids: attachmentIds } : {}),\n });\n }\n } finally {\n setSending(false);\n }\n };\n\n // No KeyboardAvoidingView here — ConversationView wraps the whole\n // chat surface in a single KAV so the list + composer shift up\n // together. Wrapping only the composer inside a flex:1 parent\n // with no headroom pushed it below the visible area on iPhone\n // home-indicator devices.\n //\n // When the keyboard is closed we add the bottom safe-area inset\n // to keep the send/attach buttons off the home indicator. When\n // it's open the OS bottom inset is irrelevant (keyboard occupies\n // that space) and we collapse back to the base 10px padding to\n // avoid floating the composer above the keyboard.\n const paddingBottom = keyboardOpen ? 10 : Math.max(10, insets.bottom);\n return (\n <View\n style={[\n styles.wrap,\n {\n backgroundColor: theme.colors.surface,\n borderTopColor: theme.colors.border,\n paddingBottom,\n },\n ]}\n >\n {isEditing ? (\n <EditChip\n message={editingMessage!}\n {...(onCancelEdit ? { onCancel: onCancelEdit } : {})}\n />\n ) : replyingTo ? (\n <ReplyChip\n message={replyingTo}\n {...(labelFor ? { labelFor } : {})}\n {...(onCancelReply ? { onCancel: onCancelReply } : {})}\n />\n ) : null}\n\n {attachments && !isEditing ? <UploadQueueStrip /> : null}\n\n <View style={styles.row}>\n {attachments && onAttachPress ? (\n <Pressable\n onPress={onAttachPress}\n hitSlop={8}\n style={styles.iconBtn}\n accessibilityLabel=\"Attach file\"\n >\n <PoolseIcon name=\"attachment\" size={22} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n\n <TextInput\n ref={inputRef}\n value={value}\n onChangeText={(text) => {\n setValue(text);\n onTyping?.();\n }}\n placeholder={placeholder}\n placeholderTextColor={theme.colors.ink3}\n multiline\n editable={!disabled}\n style={[\n styles.input,\n {\n color: theme.colors.ink,\n backgroundColor: theme.colors.surface2,\n borderRadius: theme.radii.lg,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n },\n ]}\n />\n\n <Pressable\n onPress={handleSend}\n disabled={submitDisabled}\n style={[\n styles.sendBtn,\n {\n backgroundColor: submitDisabled ? theme.colors.ink3 : theme.colors.brand,\n opacity: submitDisabled ? 0.6 : 1,\n },\n ]}\n accessibilityLabel=\"Send message\"\n >\n <PoolseIcon name=\"send\" size={18} color={theme.colors.onBrand} />\n </Pressable>\n </View>\n </View>\n );\n },\n);\n\nfunction EditChip({ message, onCancel }: { message: Message; onCancel?: () => void }) {\n const theme = usePoolseTheme();\n return (\n <View\n style={[\n styles.replyChip,\n {\n backgroundColor: theme.colors.surface2,\n borderLeftColor: theme.colors.brand,\n },\n ]}\n >\n <View style={{ flex: 1 }}>\n <Text style={[styles.replyName, { color: theme.colors.brand }]}>Editing message</Text>\n <Text style={[styles.replyBody, { color: theme.colors.ink2 }]} numberOfLines={1}>\n {message.body ?? '…'}\n </Text>\n </View>\n {onCancel ? (\n <Pressable onPress={onCancel} hitSlop={8} style={styles.replyCancel}>\n <PoolseIcon name=\"close\" size={16} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nfunction ReplyChip({\n message,\n labelFor,\n onCancel,\n}: {\n message: Message;\n labelFor?: (externalId: string) => string;\n onCancel?: () => void;\n}) {\n const theme = usePoolseTheme();\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n const resolved = useUser(message.sender_external_id);\n const senderName = message.sender_external_id\n ? (labelFor?.(message.sender_external_id) ??\n resolved.profile?.displayName ??\n message.sender_external_id)\n : 'Unknown';\n return (\n <View\n style={[\n styles.replyChip,\n {\n backgroundColor: theme.colors.surface2,\n borderLeftColor: theme.colors.brand,\n },\n ]}\n >\n <View style={{ flex: 1 }}>\n <Text style={[styles.replyName, { color: theme.colors.brand }]}>\n Replying to {senderName}\n </Text>\n <Text style={[styles.replyBody, { color: theme.colors.ink2 }]} numberOfLines={1}>\n {message.body ?? '…'}\n </Text>\n </View>\n {onCancel ? (\n <Pressable onPress={onCancel} hitSlop={8} style={styles.replyCancel}>\n <PoolseIcon name=\"close\" size={16} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n borderTopWidth: StyleSheet.hairlineWidth,\n paddingTop: 8,\n paddingHorizontal: 12,\n // paddingBottom is applied inline — it follows the keyboard state\n // (10 px while open, max(10, safeBottomInset) while closed) so the\n // send/attach buttons stay clear of the home indicator without\n // double-padding above the keyboard.\n },\n row: {\n flexDirection: 'row',\n alignItems: 'flex-end',\n gap: 8,\n },\n iconBtn: {\n padding: 8,\n justifyContent: 'center',\n alignItems: 'center',\n },\n input: {\n flex: 1,\n minHeight: 40,\n maxHeight: 120,\n paddingHorizontal: 12,\n paddingTop: 10,\n paddingBottom: 10,\n },\n sendBtn: {\n width: 40,\n height: 40,\n borderRadius: 20,\n justifyContent: 'center',\n alignItems: 'center',\n },\n replyChip: {\n flexDirection: 'row',\n alignItems: 'center',\n borderLeftWidth: 3,\n paddingLeft: 10,\n paddingRight: 6,\n paddingVertical: 6,\n marginBottom: 8,\n borderRadius: 6,\n },\n replyName: {\n fontSize: 11,\n fontWeight: '600',\n marginBottom: 2,\n },\n replyBody: {\n fontSize: 12,\n },\n replyCancel: {\n padding: 6,\n },\n});\n","import type { Membership, Uuid } from '@poolse/sdk';\nimport { useMembers } from '@poolse/react';\nimport { useMemo, useState } from 'react';\nimport { FlatList, Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { MessageComposer, type MessageComposerProps } from './MessageComposer.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface MentionInputProps extends Omit<MessageComposerProps, 'onSend'> {\n conversationId: Uuid;\n /** Same callback as MessageComposer.onSend, plus optional mention user_ids. */\n onSend: (\n body: string,\n opts?: {\n quoted_message_id?: Uuid;\n attachment_ids?: Uuid[];\n mentions?: Uuid[];\n },\n ) => Promise<unknown> | void;\n}\n\n/**\n * Composer with an inline `@`-trigger that opens a modal sheet of\n * conversation members. Selecting a member inserts their\n * `external_id` into the text, and the wire `mentions` array (sent\n * to the backend) carries the corresponding internal `user_id`s.\n */\nexport function MentionInput({ conversationId, onSend, ...composerProps }: MentionInputProps) {\n const theme = usePoolseTheme();\n const { members } = useMembers(conversationId);\n const [pickerOpen, setPickerOpen] = useState(false);\n const [pickerQuery, _setPickerQuery] = useState('');\n const [pendingMentionUuids, setPendingMentionUuids] = useState<Uuid[]>([]);\n const [text, setText] = useState('');\n\n const filteredMembers = useMemo(() => {\n if (!pickerQuery) return members;\n const q = pickerQuery.toLowerCase();\n return members.filter((m) => m.external_id.toLowerCase().includes(q));\n }, [members, pickerQuery]);\n\n const handleSend: MessageComposerProps['onSend'] = async (body, opts) => {\n await onSend(body, {\n ...opts,\n ...(pendingMentionUuids.length > 0 ? { mentions: pendingMentionUuids } : {}),\n });\n setPendingMentionUuids([]);\n setText('');\n };\n\n return (\n <>\n <MessageComposer\n {...composerProps}\n onSend={handleSend}\n onTyping={() => {\n composerProps.onTyping?.();\n // Watch for an `@` token to open the picker.\n const lastChar = text.slice(-1);\n if (lastChar === '@') setPickerOpen(true);\n }}\n />\n\n <Modal\n visible={pickerOpen}\n transparent\n animationType=\"slide\"\n onRequestClose={() => setPickerOpen(false)}\n >\n <Pressable style={styles.backdrop} onPress={() => setPickerOpen(false)}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderTopLeftRadius: theme.radii.lg,\n borderTopRightRadius: theme.radii.lg,\n },\n ]}\n >\n <Text\n style={[styles.title, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n >\n Mention a member\n </Text>\n <FlatList\n data={filteredMembers}\n keyExtractor={(m) => m.user_id}\n renderItem={({ item }) => (\n <MentionRow\n member={item}\n onPress={() => {\n setPendingMentionUuids((prev) => [...prev, item.user_id]);\n setText((prev) => `${prev}${item.external_id} `);\n setPickerOpen(false);\n }}\n />\n )}\n />\n </View>\n </Pressable>\n </Modal>\n </>\n );\n}\n\nfunction MentionRow({ member, onPress }: { member: Membership; onPress: () => void }) {\n const theme = usePoolseTheme();\n return (\n <Pressable onPress={onPress} style={styles.row}>\n <Avatar src={null} name={member.external_id} seed={member.external_id} size=\"sm\" />\n <Text style={[styles.rowText, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}>\n {member.external_id}\n </Text>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.35)',\n justifyContent: 'flex-end',\n },\n sheet: {\n maxHeight: '60%',\n paddingVertical: 12,\n },\n title: {\n fontSize: 14,\n fontWeight: '600',\n paddingHorizontal: 16,\n paddingBottom: 8,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingVertical: 10,\n gap: 10,\n },\n rowText: {\n fontSize: 14,\n },\n});\n","import type { Message } from '@poolse/sdk';\nimport {\n ActivityIndicator,\n FlatList,\n type ListRenderItem,\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n Pressable,\n StyleSheet,\n Text,\n View,\n} from 'react-native';\nimport { useCallback, useEffect, useRef, useState, type ReactElement } from 'react';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\n/**\n * Either a real message or a day-separator row. ConversationView\n * builds the list of items (interleaving separators where the day\n * changes) and hands it to MessageList; MessageList just renders.\n */\nexport type MessageListItem =\n | { kind: 'msg'; msg: Message }\n | { kind: 'separator'; id: string; node: ReactElement };\n\nexport interface MessageListProps {\n messages: Message[];\n /**\n * Optional pre-built item list (with day separators interleaved).\n * When omitted, a list with `{ kind: 'msg' }` items is derived\n * from `messages` and rendered without separators.\n */\n items?: MessageListItem[];\n loading?: boolean;\n hasMore?: boolean;\n onLoadMore?: () => void;\n renderItem: (msg: Message, index: number) => ReactElement;\n /** Slot rendered above the latest message (typically the typing indicator). */\n ListHeader?: ReactElement | null;\n /** Slot rendered below the oldest message (rare — typically nothing). */\n ListFooter?: ReactElement | null;\n /** Custom empty state when there are no messages. */\n emptyState?: ReactElement | string;\n /**\n * The current user's id. When provided, MessageList will show a\n * \"↓ N new messages\" jump button at the bottom of the chat\n * whenever new messages from OTHER users arrive while the user is\n * scrolled away from the bottom. Tapping scrolls to the latest.\n */\n meId?: string | null;\n}\n\n// How far above the bottom (in pixels — the list is inverted, so\n// this is contentOffset.y) before we consider the user \"scrolled\n// up\" and start counting new messages.\nconst AT_BOTTOM_THRESHOLD = 32;\n\n/**\n * Inverted FlatList wrapper for chat history. Newest message at the\n * bottom (visually), oldest at the top. Calls `onLoadMore` when the\n * user scrolls near the top edge and `hasMore` is true.\n *\n * Pagination is owned by `useMessages` (hand it `messages` +\n * `hasMore` + `loadMore`); this component just renders + scrolls.\n */\nexport function MessageList({\n messages,\n items,\n loading = false,\n hasMore = false,\n onLoadMore,\n renderItem,\n ListHeader = null,\n ListFooter = null,\n emptyState,\n meId = null,\n}: MessageListProps) {\n const theme = usePoolseTheme();\n const flatListRef = useRef<FlatList<MessageListItem>>(null);\n const [atBottom, setAtBottom] = useState(true);\n const [newCount, setNewCount] = useState(0);\n const lastTailIdRef = useRef<string | null>(null);\n\n // Build the FlatList data — either the caller's prebuilt items\n // (with separators) or a plain msg-only list. FlatList is\n // inverted, so we reverse to put the newest item at the top of\n // `data` (which renders at the visual bottom).\n const sourceItems: MessageListItem[] =\n items ?? messages.map((msg) => ({ kind: 'msg' as const, msg }));\n const data = [...sourceItems].reverse();\n\n // Track tail-message changes to maintain the \"new messages\" badge\n // when the user is scrolled up.\n useEffect(() => {\n const tail = messages[messages.length - 1];\n if (!tail) return;\n const tailId = tail.id;\n if (tailId === lastTailIdRef.current) return;\n const isFirstSet = lastTailIdRef.current === null;\n lastTailIdRef.current = tailId;\n if (atBottom || isFirstSet) {\n setNewCount(0);\n return;\n }\n // Only count incoming messages from other users — self messages\n // would have already triggered a scroll-to-bottom in normal flow.\n if (meId !== null && tail.sender_id === meId) return;\n setNewCount((n) => n + 1);\n }, [messages, atBottom, meId]);\n\n const handleScroll = useCallback((e: NativeSyntheticEvent<NativeScrollEvent>) => {\n const y = e.nativeEvent.contentOffset.y;\n const next = y <= AT_BOTTOM_THRESHOLD;\n setAtBottom((prev) => (prev === next ? prev : next));\n if (next) setNewCount(0);\n }, []);\n\n const scrollToBottom = useCallback(() => {\n flatListRef.current?.scrollToOffset({ offset: 0, animated: true });\n setNewCount(0);\n }, []);\n\n const handleRender: ListRenderItem<MessageListItem> = useCallback(\n ({ item, index }) => {\n if (item.kind === 'separator') return item.node;\n // Index in the original (newest-last) source order. Used by\n // ConversationView's renderItem to pick neighbours for\n // grouping when it doesn't pre-compute groupPosition itself.\n const sourceIndex = data.length - 1 - index;\n return renderItem(item.msg, sourceIndex);\n },\n [renderItem, data.length],\n );\n\n if (loading && messages.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <ActivityIndicator color={theme.colors.brand} />\n </View>\n );\n }\n\n if (messages.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n {typeof emptyState === 'string' ? (\n <Text style={{ color: theme.colors.ink3, fontFamily: theme.type.fontBody }}>\n {emptyState}\n </Text>\n ) : (\n (emptyState ?? null)\n )}\n </View>\n );\n }\n\n return (\n <View style={styles.root}>\n <FlatList\n ref={flatListRef}\n inverted\n data={data}\n keyExtractor={(item) => (item.kind === 'msg' ? item.msg.id : item.id)}\n renderItem={handleRender}\n onEndReached={hasMore ? onLoadMore : undefined}\n onEndReachedThreshold={0.3}\n onScroll={handleScroll}\n scrollEventThrottle={32}\n // `inverted` flips the list, so FlatList's ListHeaderComponent\n // renders at the bottom of the screen (above the latest message,\n // next to the composer) and ListFooterComponent renders at the\n // top (above the oldest message). That matches our prop names.\n ListHeaderComponent={ListHeader}\n ListFooterComponent={\n <View>\n {hasMore && loading ? (\n <ActivityIndicator color={theme.colors.ink3} style={{ marginVertical: 8 }} />\n ) : null}\n {ListFooter}\n </View>\n }\n style={{ backgroundColor: theme.colors.paper }}\n contentContainerStyle={{ paddingVertical: 8 }}\n />\n\n {!atBottom && newCount > 0 ? (\n <Pressable\n onPress={scrollToBottom}\n style={[\n styles.jumpButton,\n {\n backgroundColor: theme.colors.brand,\n },\n theme.shadows.sm,\n ]}\n accessibilityLabel={`${newCount} new ${newCount === 1 ? 'message' : 'messages'}, jump to latest`}\n >\n <PoolseIcon name=\"chevron-down\" size={14} color={theme.colors.onBrand} />\n <Text style={[styles.jumpText, { color: theme.colors.onBrand }]}>\n {newCount} new {newCount === 1 ? 'message' : 'messages'}\n </Text>\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n },\n placeholder: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 24,\n },\n jumpButton: {\n position: 'absolute',\n alignSelf: 'center',\n bottom: 12,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 6,\n paddingHorizontal: 14,\n paddingVertical: 8,\n borderRadius: 999,\n },\n jumpText: {\n fontSize: 13,\n fontWeight: '600',\n },\n});\n","import { Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon, type IconName } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nconst DEFAULT_REACTION_EMOJIS = ['👍', '❤️', '😂', '🎉', '🙏', '🔥'];\n\nexport interface MessageActionsProps {\n visible: boolean;\n onClose: () => void;\n isSelf: boolean;\n /**\n * Quick-reaction emoji row rendered at the top of the sheet. Tap\n * one to fire `onPickReaction(emoji)` and immediately close. When\n * omitted (or `onPickReaction` is omitted) the row is hidden.\n */\n emojis?: string[];\n onPickReaction?: (emoji: string) => void;\n onReply?: () => void;\n onReplyInThread?: () => void;\n onQuote?: () => void;\n onEdit?: () => void;\n onDelete?: () => void;\n onCopy?: () => void;\n}\n\n/**\n * Long-press action menu — modal bottom sheet. Renders a row of\n * quick-react emojis at the top (one tap reacts + closes) plus the\n * action items below. Matches WhatsApp / iMessage's \"long-press\n * shows everything inline\" pattern.\n */\nexport function MessageActions({\n visible,\n onClose,\n isSelf,\n emojis = DEFAULT_REACTION_EMOJIS,\n onPickReaction,\n onReply,\n onReplyInThread,\n onQuote,\n onEdit,\n onDelete,\n onCopy,\n}: MessageActionsProps) {\n const theme = usePoolseTheme();\n const items: Array<{ label: string; icon: IconName; onPress: () => void; danger?: boolean }> = [];\n if (onReply) items.push({ label: 'Reply', icon: 'reply', onPress: onReply });\n if (onQuote) items.push({ label: 'Quote reply', icon: 'reply', onPress: onQuote });\n if (onReplyInThread)\n items.push({ label: 'Reply in thread', icon: 'messages', onPress: onReplyInThread });\n if (onCopy) items.push({ label: 'Copy text', icon: 'copy', onPress: onCopy });\n if (isSelf && onEdit) items.push({ label: 'Edit', icon: 'edit', onPress: onEdit });\n if (isSelf && onDelete)\n items.push({ label: 'Delete', icon: 'trash', onPress: onDelete, danger: true });\n\n const showEmojiRow = !!onPickReaction && emojis.length > 0;\n\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={onClose}>\n <Pressable style={styles.backdrop} onPress={onClose}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderTopLeftRadius: theme.radii.lg,\n borderTopRightRadius: theme.radii.lg,\n },\n theme.shadows.lg,\n ]}\n >\n {showEmojiRow ? (\n <View style={[styles.emojiRow, { borderBottomColor: theme.colors.border }]}>\n {emojis.map((emoji) => (\n <Pressable\n key={emoji}\n onPress={() => {\n onPickReaction(emoji);\n onClose();\n }}\n style={styles.emojiBtn}\n hitSlop={6}\n accessibilityLabel={`React with ${emoji}`}\n >\n <Text style={styles.emoji}>{emoji}</Text>\n </Pressable>\n ))}\n </View>\n ) : null}\n\n {items.map((item) => (\n <Pressable key={item.label} onPress={item.onPress} style={styles.item}>\n <PoolseIcon\n name={item.icon}\n size={18}\n color={item.danger ? theme.colors.error : theme.colors.ink2}\n />\n <Text\n style={[\n styles.itemText,\n {\n color: item.danger ? theme.colors.error : theme.colors.ink,\n fontFamily: theme.type.fontBody,\n },\n ]}\n >\n {item.label}\n </Text>\n </Pressable>\n ))}\n </View>\n </Pressable>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.35)',\n justifyContent: 'flex-end',\n },\n sheet: {\n paddingTop: 8,\n paddingBottom: 24,\n },\n emojiRow: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-around',\n paddingHorizontal: 12,\n paddingVertical: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n marginBottom: 6,\n },\n emojiBtn: {\n paddingHorizontal: 6,\n paddingVertical: 6,\n borderRadius: 999,\n alignItems: 'center',\n justifyContent: 'center',\n },\n emoji: {\n fontSize: 30,\n lineHeight: 36,\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 20,\n paddingVertical: 14,\n gap: 14,\n },\n itemText: {\n fontSize: 15,\n fontWeight: '500',\n },\n});\n","import type { Attachment } from '@poolse/sdk';\nimport { useAttachmentUrl } from '@poolse/react';\nimport { Image, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface AttachmentPreviewProps {\n attachment: Attachment;\n /** Optional tap handler. For images defaults to opening the source URL. */\n onPress?: () => void;\n /** Render at this max width. Defaults to 280. */\n maxWidth?: number;\n}\n\nexport function AttachmentPreview({ attachment, onPress, maxWidth = 280 }: AttachmentPreviewProps) {\n const theme = usePoolseTheme();\n const isImage = (attachment.content_type ?? '').startsWith('image/');\n const { url } = useAttachmentUrl(attachment.id);\n\n if (isImage) {\n return (\n <Pressable onPress={onPress} disabled={!onPress}>\n {url ? (\n <Image\n source={{ uri: url }}\n style={{\n width: maxWidth,\n height: 200,\n borderRadius: theme.radii.md,\n backgroundColor: theme.colors.surface2,\n }}\n resizeMode=\"cover\"\n accessible\n accessibilityLabel={attachment.original_filename ?? 'attachment image'}\n />\n ) : (\n <View\n style={[\n styles.imagePlaceholder,\n {\n width: maxWidth,\n height: 200,\n borderRadius: theme.radii.md,\n backgroundColor: theme.colors.surface2,\n },\n ]}\n />\n )}\n </Pressable>\n );\n }\n\n return (\n <Pressable\n onPress={onPress}\n disabled={!onPress}\n style={[\n styles.fileCard,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: theme.colors.border,\n borderRadius: theme.radii.md,\n },\n ]}\n >\n <PoolseIcon name=\"attachment\" size={18} color={theme.colors.ink2} />\n <View style={{ flex: 1, marginLeft: 8 }}>\n <Text\n style={[styles.fileName, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {attachment.original_filename ?? 'file'}\n </Text>\n <Text style={[styles.fileSize, { color: theme.colors.ink3 }]}>\n {formatBytes(attachment.byte_size)}\n </Text>\n </View>\n </Pressable>\n );\n}\n\nfunction formatBytes(n: number): string {\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;\n if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;\n return `${(n / 1024 / 1024 / 1024).toFixed(1)} GB`;\n}\n\nconst styles = StyleSheet.create({\n imagePlaceholder: {},\n fileCard: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n borderWidth: StyleSheet.hairlineWidth,\n },\n fileName: {\n fontSize: 13,\n fontWeight: '500',\n },\n fileSize: {\n fontSize: 11,\n },\n});\n","import type { Attachment } from '@poolse/sdk';\nimport { useAttachmentUrl } from '@poolse/react';\nimport { useState } from 'react';\nimport { Dimensions, Image, Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ImageMosaicProps {\n images: Attachment[];\n /**\n * Pixel ceiling on the mosaic's width. The mosaic itself fills its\n * parent (`width: '100%'`) and caps at this value, so it always\n * fits inside whatever the bubble's actual content area is at\n * render time — no more hardcoded 280px overflowing on small\n * screens or inside narrow bubbles.\n */\n maxWidth?: number;\n radius?: number;\n}\n\n/**\n * WhatsApp-style multi-image grid for inside the message bubble.\n * Uses flex-based widths (with `%` and `aspectRatio`) so the layout\n * scales to whatever the bubble's content area is — no fixed pixel\n * positioning that can overflow when the bubble is narrower than\n * the configured max.\n *\n * * n = 1 → single tile, 16:10 aspect.\n * * n = 2 → row of 2 squares.\n * * n = 3 → 16:9 hero on top + row of 2 squares below.\n * * n ≥ 4 → 2×2 grid with \"+N more\" overlay on the 4th tile.\n */\nexport function ImageMosaic({ images, maxWidth, radius }: ImageMosaicProps) {\n const theme = usePoolseTheme();\n const r = radius ?? theme.radii.md;\n const [viewerIndex, setViewerIndex] = useState<number | null>(null);\n\n if (images.length === 0) return null;\n\n const visible = images.slice(0, 4);\n const overflow = images.length > 4 ? images.length - 4 : 0;\n const n = visible.length as 1 | 2 | 3 | 4;\n\n return (\n <>\n <View\n style={[\n styles.root,\n {\n borderRadius: r,\n ...(maxWidth ? { maxWidth } : {}),\n },\n ]}\n >\n {n === 1 ? (\n <Tile\n attachment={visible[0]!}\n style={styles.tileFull}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n ) : null}\n\n {n === 2 ? (\n <View style={styles.rowEven}>\n <Tile\n attachment={visible[0]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n <Tile\n attachment={visible[1]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(1)}\n overlay={null}\n />\n </View>\n ) : null}\n\n {n === 3 ? (\n <>\n <Tile\n attachment={visible[0]!}\n style={styles.tileHero}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n <View style={[styles.rowEven, { marginTop: 2 }]}>\n <Tile\n attachment={visible[1]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(1)}\n overlay={null}\n />\n <Tile\n attachment={visible[2]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(2)}\n overlay={null}\n />\n </View>\n </>\n ) : null}\n\n {n === 4 ? (\n <>\n <View style={styles.rowEven}>\n <Tile\n attachment={visible[0]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n <Tile\n attachment={visible[1]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(1)}\n overlay={null}\n />\n </View>\n <View style={[styles.rowEven, { marginTop: 2 }]}>\n <Tile\n attachment={visible[2]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(2)}\n overlay={null}\n />\n <Tile\n attachment={visible[3]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(3)}\n overlay={overflow > 0 ? `+${overflow}` : null}\n />\n </View>\n </>\n ) : null}\n </View>\n\n <Modal\n visible={viewerIndex !== null}\n transparent\n animationType=\"fade\"\n onRequestClose={() => setViewerIndex(null)}\n >\n {viewerIndex !== null ? (\n <FullScreenViewer\n attachment={images[viewerIndex]!}\n onClose={() => setViewerIndex(null)}\n />\n ) : null}\n </Modal>\n </>\n );\n}\n\nfunction Tile({\n attachment,\n style,\n overlay,\n onPress,\n}: {\n attachment: Attachment;\n style: object;\n overlay: string | null;\n onPress: () => void;\n}) {\n const theme = usePoolseTheme();\n const { url } = useAttachmentUrl(attachment.id);\n return (\n <Pressable onPress={onPress} style={[styles.tileBase, style]}>\n {url ? (\n <Image\n source={{ uri: url }}\n style={[styles.tileImage, { backgroundColor: theme.colors.surface2 }]}\n resizeMode=\"cover\"\n accessible\n accessibilityLabel={attachment.original_filename ?? 'image'}\n />\n ) : (\n <View style={[styles.tileImage, { backgroundColor: theme.colors.surface2 }]} />\n )}\n {overlay ? (\n <View style={styles.overflow}>\n <Text style={styles.overflowText}>{overlay}</Text>\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nfunction FullScreenViewer({\n attachment,\n onClose,\n}: {\n attachment: Attachment;\n onClose: () => void;\n}) {\n const { url } = useAttachmentUrl(attachment.id);\n const { width, height } = Dimensions.get('window');\n return (\n <Pressable style={styles.viewer} onPress={onClose}>\n {url ? (\n <Image\n source={{ uri: url }}\n style={{ width, height }}\n resizeMode=\"contain\"\n accessible\n accessibilityLabel={attachment.original_filename ?? 'image'}\n />\n ) : null}\n <Pressable\n onPress={onClose}\n hitSlop={12}\n style={styles.closeBtn}\n accessibilityLabel=\"Close viewer\"\n >\n <PoolseIcon name=\"close\" size={20} color=\"#ffffff\" />\n </Pressable>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n overflow: 'hidden',\n marginBottom: 4,\n },\n rowEven: {\n flexDirection: 'row',\n gap: 2,\n },\n tileBase: {\n overflow: 'hidden',\n },\n // n=1: full bleed at the bubble's available width, 16:10 aspect.\n tileFull: {\n width: '100%',\n aspectRatio: 16 / 10,\n },\n // n=2 / n=4 (per row): two equal squares side-by-side.\n tileHalfSquare: {\n flex: 1,\n aspectRatio: 1,\n },\n // n=3 hero: full-bleed top tile, 16:9.\n tileHero: {\n width: '100%',\n aspectRatio: 16 / 9,\n },\n tileImage: {\n width: '100%',\n height: '100%',\n },\n overflow: {\n position: 'absolute',\n inset: 0,\n backgroundColor: 'rgba(0,0,0,0.55)',\n alignItems: 'center',\n justifyContent: 'center',\n },\n overflowText: {\n color: '#ffffff',\n fontWeight: '700',\n fontSize: 22,\n },\n viewer: {\n flex: 1,\n backgroundColor: '#000000',\n alignItems: 'center',\n justifyContent: 'center',\n },\n closeBtn: {\n position: 'absolute',\n top: 48,\n right: 16,\n padding: 8,\n backgroundColor: 'rgba(0,0,0,0.5)',\n borderRadius: 20,\n },\n});\n","import { createElement, type ReactElement } from 'react';\nimport type { StyleSheet } from 'react-native';\n// Static import — Metro's bundle graph can only trace literal\n// `import` / `require` calls. The earlier try/require trick generated\n// a `require('react-native-markdown-display')` that Metro couldn't\n// resolve from inside our pre-bundled CJS dist, throwing a runtime\n// \"Requiring unknown module\" even when the consumer had the package\n// installed. Hard-importing puts the resolution into the consumer\n// app's normal graph where it works the same way react-native-svg or\n// expo-image-picker do.\n//\n// Trade-off: the package is now a required peer of @poolse/react-native\n// (was optional). Consumers who don't want markdown can pass\n// `markdown={false}` to <ConversationView> — the import stays in the\n// bundle but the component isn't rendered.\nimport Markdown, { MarkdownIt } from 'react-native-markdown-display';\n\n// `react-native-markdown-display` defaults to a stock CommonMark\n// parser, which only treats `[text](url)` and `<url>` as links. Bare\n// URLs in body text (e.g. \"check https://example.com\") stay plain\n// text. Turn on `linkify` so markdown-it autolinks them — matches\n// what react-ui gets via remark-gfm. Built once at module load: the\n// instance is stateless and re-using it avoids re-allocating the\n// parser for every rendered message.\nconst markdownit = MarkdownIt({ typographer: false, linkify: true });\n\nexport interface MarkdownStyleArgs {\n textColor: string;\n linkColor: string;\n fontFamily?: string;\n fontSize: number;\n lineHeight: number;\n onLinkPress: (url: string) => boolean;\n}\n\n/**\n * Render `body` as Markdown into a React element. The style mapping\n * uses the bubble's resolved theme tokens so text color tracks self /\n * other bubble background.\n */\nexport function renderMarkdown(body: string, args: MarkdownStyleArgs): ReactElement {\n const baseText = {\n color: args.textColor,\n fontFamily: args.fontFamily,\n fontSize: args.fontSize,\n lineHeight: args.lineHeight,\n };\n // Match react-ui's GFM defaults — body+inline elements use bubble\n // text color; links pick up the brand-on-bubble color so they\n // remain visible whether the bubble is a self-brand or\n // other-surface variant.\n const style: StyleSheet.NamedStyles<unknown> = {\n body: baseText,\n paragraph: { ...baseText, marginTop: 0, marginBottom: 0 },\n text: baseText,\n strong: { ...baseText, fontWeight: '700' },\n em: { ...baseText, fontStyle: 'italic' },\n s: { ...baseText, textDecorationLine: 'line-through' },\n link: { color: args.linkColor, textDecorationLine: 'underline' },\n code_inline: {\n ...baseText,\n backgroundColor: 'rgba(127,127,127,0.18)',\n borderRadius: 4,\n paddingHorizontal: 4,\n },\n code_block: {\n ...baseText,\n backgroundColor: 'rgba(127,127,127,0.18)',\n padding: 8,\n borderRadius: 6,\n },\n fence: {\n ...baseText,\n backgroundColor: 'rgba(127,127,127,0.18)',\n padding: 8,\n borderRadius: 6,\n },\n bullet_list: { marginTop: 2, marginBottom: 2 },\n ordered_list: { marginTop: 2, marginBottom: 2 },\n list_item: baseText,\n blockquote: {\n ...baseText,\n borderLeftWidth: 3,\n borderLeftColor: args.linkColor,\n paddingLeft: 8,\n marginVertical: 4,\n opacity: 0.85,\n },\n };\n return createElement(Markdown, { style, markdownit, onLinkPress: args.onLinkPress }, body);\n}\n","import type { Message, QuotedMessagePreview, Uuid } from '@poolse/sdk';\nimport { useUser } from '@poolse/react';\nimport { useState, type ReactNode } from 'react';\nimport { Linking, Pressable, StyleSheet, Text, useWindowDimensions, View } from 'react-native';\n\nimport { AttachmentPreview } from './AttachmentPreview.js';\nimport { ImageMosaic } from './ImageMosaic.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { renderMarkdown } from './internal/markdown.js';\nimport { userColor } from './primitives/userColor.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport type BubbleGroupPosition = 'first' | 'middle' | 'last' | 'standalone';\n\nexport interface MessageBubbleProps {\n message: Message;\n /** Used to decide left/right alignment, color, and read-receipt visibility. */\n currentUserId: string | null;\n /** `'sent'` → single tick, `'read'` → double tick (theme.colors.brand). */\n readState?: 'sent' | 'read';\n /** Label resolver keyed by `external_id` — falls back to the externalId itself. */\n labelFor?: (externalId: string) => string;\n /** Quoted-card tap handler. Typically used to scroll the list to the original message. */\n onQuotedClick?: (quotedMessageId: Uuid) => void;\n /** Position in a same-sender cluster — drives tail-corner rendering. */\n groupPosition?: BubbleGroupPosition;\n /** Truncate at this many chars and show a \"Read more\" toggle. Defaults to 0 (off). */\n maxBodyLength?: number;\n /** Show a colored sender label above other-side bubbles. Only meaningful in group chats. */\n showSenderName?: boolean;\n /** Slot for an actions trigger — typically a chevron rendered by `<MessageRow>`. */\n actionsTrigger?: ReactNode;\n /** Render in-bubble attachments (images, file cards). Defaults to true. */\n showAttachments?: boolean;\n /**\n * Render the body as Markdown (bold, italic, code, lists, links).\n * Links open via `Linking.openURL`. Requires\n * `react-native-markdown-display` to be installed in the host app;\n * without it we fall back to plain text. Defaults to true.\n */\n markdown?: boolean;\n}\n\nexport function MessageBubble({\n message,\n currentUserId,\n readState,\n labelFor,\n onQuotedClick,\n groupPosition = 'standalone',\n maxBodyLength = 0,\n showSenderName = false,\n actionsTrigger,\n showAttachments = true,\n markdown = true,\n}: MessageBubbleProps) {\n const theme = usePoolseTheme();\n const { width: screenWidth } = useWindowDimensions();\n const isSelf = currentUserId !== null && message.sender_id === currentUserId;\n const [expanded, setExpanded] = useState(false);\n\n // Pixel-based bubble cap pinned to screen width, not to a\n // percentage of an ambiguously-sized parent. Was '88%' on the\n // wrap which resolves to 88% of the bubbleCol — and bubbleCol's\n // width changes with the row's padding, so bumping row padding\n // shrunk multi-line bubbles disproportionately. With a fixed\n // pixel maxWidth + alignSelf:flex-end, single-line and multi-line\n // both hit the same right edge regardless of nesting.\n const bubbleMaxWidth = Math.floor(screenWidth * 0.78);\n // Image / file preview width is bubble width minus the 28px\n // horizontal padding. Use flex '100%' style with a numeric ceiling\n // so the mosaic adapts to the actual rendered bubble.\n const contentMaxWidth = bubbleMaxWidth - 28;\n\n const sender = useUser(!isSelf ? message.sender_external_id : null);\n const senderFallbackName = message.sender_external_id ?? 'Unknown';\n const senderLabel =\n sender.profile?.displayName ??\n (message.sender_external_id\n ? (labelFor?.(message.sender_external_id) ?? senderFallbackName)\n : senderFallbackName);\n const senderTint = userColor(message.sender_external_id ?? message.sender_id ?? message.id);\n\n const tailCorner = groupPosition === 'last' || groupPosition === 'standalone';\n const bubbleColor = isSelf ? theme.colors.selfBubble : theme.colors.otherBubble;\n const textColor = isSelf ? theme.colors.selfBubbleText : theme.colors.otherBubbleText;\n\n const radii = {\n topLeft: theme.radii.bubble,\n topRight: theme.radii.bubble,\n bottomLeft: theme.radii.bubble,\n bottomRight: theme.radii.bubble,\n };\n if (tailCorner) {\n if (isSelf) radii.bottomRight = 4;\n else radii.bottomLeft = 4;\n }\n\n const body = message.body ?? '';\n const truncated =\n maxBodyLength > 0 && body.length > maxBodyLength && !expanded\n ? body.slice(0, maxBodyLength) + '…'\n : body;\n\n const time = formatTime(message.inserted_at);\n const isDeleted = !!message.deleted_at;\n const isEdited = !!message.edited_at && !isDeleted;\n\n const images = (message.attachments ?? []).filter((a) => isImageContentType(a.content_type));\n const files = (message.attachments ?? []).filter((a) => !isImageContentType(a.content_type));\n const renderAttachments = showAttachments && (images.length > 0 || files.length > 0);\n\n return (\n <View\n style={[\n styles.wrap,\n {\n alignSelf: isSelf ? 'flex-end' : 'flex-start',\n // Pixel maxWidth (not percentage) so single-line and\n // multi-line bubbles land at the same right edge — was\n // 88% of the bubbleCol which produced inconsistent right\n // padding when the row padding changed.\n maxWidth: bubbleMaxWidth,\n },\n ]}\n >\n <View\n style={[\n styles.bubble,\n {\n backgroundColor: bubbleColor,\n borderColor: isSelf ? 'transparent' : theme.colors.border,\n borderWidth: isSelf ? 0 : StyleSheet.hairlineWidth,\n borderTopLeftRadius: radii.topLeft,\n borderTopRightRadius: radii.topRight,\n borderBottomLeftRadius: radii.bottomLeft,\n borderBottomRightRadius: radii.bottomRight,\n // Slightly more breathing room — 14/10 reads tighter and\n // matches the iMessage / WhatsApp bubble density.\n paddingHorizontal: 14,\n paddingVertical: 10,\n // Floor the bubble at a width that always fits the meta row\n // (\"edited HH:MM ✓✓\" → ~110px). Without this, short bodies\n // like \"ok\" produce a bubble too narrow for the meta to lay\n // out, and `edited` or the time gets clipped.\n minWidth: isSelf && isEdited ? 130 : 90,\n },\n theme.shadows.sm,\n ]}\n >\n {showSenderName &&\n !isSelf &&\n (groupPosition === 'first' || groupPosition === 'standalone') ? (\n <Text style={[styles.senderName, { color: senderTint, fontFamily: theme.type.fontBody }]}>\n {senderLabel}\n </Text>\n ) : null}\n\n {message.quoted_message ? (\n <QuotedCard\n quoted={message.quoted_message}\n isSelf={isSelf}\n {...(labelFor ? { labelFor } : {})}\n {...(onQuotedClick ? { onPress: () => onQuotedClick(message.quoted_message!.id) } : {})}\n />\n ) : null}\n\n {renderAttachments && images.length > 0 ? (\n <ImageMosaic images={images} maxWidth={contentMaxWidth} />\n ) : null}\n\n {renderAttachments && files.length > 0 ? (\n <View style={{ gap: theme.spacing.xs, marginBottom: theme.spacing.xs }}>\n {files.map((att) => (\n <AttachmentPreview key={att.id} attachment={att} maxWidth={contentMaxWidth} />\n ))}\n </View>\n ) : null}\n\n {body.length > 0 ? (\n isDeleted ? (\n <Text\n style={[\n styles.body,\n {\n color: theme.colors.ink3,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n lineHeight: theme.type.lineHeight,\n fontStyle: 'italic',\n },\n ]}\n >\n Message deleted\n </Text>\n ) : markdown ? (\n renderMarkdown(truncated, {\n textColor,\n linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n lineHeight: theme.type.lineHeight,\n onLinkPress: (url: string) => {\n void Linking.openURL(url).catch(() => undefined);\n return false;\n },\n })\n ) : (\n <Text\n style={[\n styles.body,\n {\n color: textColor,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n lineHeight: theme.type.lineHeight,\n },\n ]}\n >\n {truncated}\n </Text>\n )\n ) : null}\n\n {maxBodyLength > 0 && body.length > maxBodyLength ? (\n <Pressable onPress={() => setExpanded((e) => !e)}>\n <Text\n style={[\n styles.readMore,\n { color: isSelf ? theme.colors.onBrand : theme.colors.brand },\n ]}\n >\n {expanded ? 'Show less' : 'Read more'}\n </Text>\n </Pressable>\n ) : null}\n\n <View style={styles.metaRow}>\n {isEdited ? (\n <Text\n style={[\n styles.editedTag,\n {\n color: isSelf ? theme.colors.onBrand : theme.colors.ink3,\n opacity: 0.7,\n },\n ]}\n >\n edited\n </Text>\n ) : null}\n <Text\n style={[\n styles.meta,\n {\n color: isSelf ? theme.colors.onBrand : theme.colors.ink3,\n opacity: isSelf ? 0.85 : 1,\n },\n ]}\n >\n {time}\n </Text>\n {isSelf && readState ? (\n <View style={styles.readTick}>\n <PoolseIcon\n name={readState === 'read' ? 'check-double' : 'check'}\n size={13}\n color={theme.colors.onBrand}\n />\n </View>\n ) : null}\n </View>\n\n {actionsTrigger ? <View style={styles.actionsSlot}>{actionsTrigger}</View> : null}\n </View>\n </View>\n );\n}\n\nfunction QuotedCard({\n quoted,\n isSelf,\n labelFor,\n onPress,\n}: {\n quoted: QuotedMessagePreview;\n isSelf: boolean;\n labelFor?: (externalId: string) => string;\n onPress?: () => void;\n}) {\n const theme = usePoolseTheme();\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n const resolved = useUser(quoted.sender_external_id);\n const senderName = quoted.sender_external_id\n ? (labelFor?.(quoted.sender_external_id) ??\n resolved.profile?.displayName ??\n quoted.sender_external_id)\n : 'Unknown';\n const bg = isSelf ? 'rgba(255,255,255,0.18)' : theme.colors.surface2;\n const accent = isSelf ? theme.colors.onBrand : theme.colors.brand;\n const txt = isSelf ? theme.colors.onBrand : theme.colors.ink;\n return (\n <Pressable\n onPress={onPress}\n disabled={!onPress}\n style={[\n styles.quoted,\n {\n backgroundColor: bg,\n borderLeftColor: accent,\n },\n ]}\n >\n <Text style={[styles.quotedSender, { color: accent }]}>{senderName}</Text>\n <Text style={[styles.quotedBody, { color: txt }]} numberOfLines={2}>\n {quoted.body ?? '…'}\n </Text>\n </Pressable>\n );\n}\n\nfunction isImageContentType(ct: string | null | undefined): boolean {\n if (!ct) return false;\n return ct.startsWith('image/');\n}\n\n// HH:MM if same calendar day, \"Yesterday HH:MM\" if yesterday, \"Mon DD\"\n// if older than a week, otherwise weekday abbreviation. Matches the\n// WhatsApp / iMessage convention — short enough to fit in the meta\n// row, long enough to be useful at a glance.\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n const now = new Date();\n const sameDay = isSameDay(d, now);\n const time = d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n if (sameDay) return time;\n\n const yesterday = new Date(now);\n yesterday.setDate(now.getDate() - 1);\n if (isSameDay(d, yesterday)) return `Yesterday ${time}`;\n\n const diffMs = now.getTime() - d.getTime();\n const diffDays = Math.floor(diffMs / 86_400_000);\n if (diffDays < 7) {\n return `${d.toLocaleDateString([], { weekday: 'short' })} ${time}`;\n }\n return d.toLocaleDateString([], { month: 'short', day: 'numeric' });\n } catch {\n return '';\n }\n}\n\nfunction isSameDay(a: Date, b: Date): boolean {\n return (\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n marginBottom: 2,\n },\n bubble: {\n position: 'relative',\n },\n senderName: {\n fontSize: 12,\n fontWeight: '600',\n marginBottom: 2,\n },\n body: {\n flexShrink: 1,\n },\n readMore: {\n fontSize: 12,\n fontWeight: '600',\n marginTop: 4,\n },\n metaRow: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'flex-end',\n marginTop: 6,\n gap: 5,\n flexShrink: 0,\n },\n meta: {\n fontSize: 11,\n fontVariant: ['tabular-nums'],\n includeFontPadding: false,\n },\n editedTag: {\n fontSize: 10,\n fontStyle: 'italic',\n letterSpacing: 0.1,\n },\n readTick: {\n marginLeft: 2,\n marginTop: 1,\n },\n actionsSlot: {\n position: 'absolute',\n top: 4,\n right: 4,\n },\n quoted: {\n borderLeftWidth: 3,\n paddingLeft: 8,\n paddingVertical: 4,\n paddingRight: 6,\n marginBottom: 6,\n borderRadius: 4,\n },\n quotedSender: {\n fontSize: 12,\n fontWeight: '600',\n marginBottom: 2,\n },\n quotedBody: {\n fontSize: 12,\n opacity: 0.85,\n },\n});\n","import type { Uuid } from '@poolse/sdk';\nimport { useReactions } from '@poolse/react';\nimport { Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nconst DEFAULT_EMOJIS = ['👍', '❤️', '😂', '🎉', '🙏', '🔥'];\n\nexport interface ReactionStripProps {\n messageId: Uuid;\n conversationId: Uuid;\n meId: string | null;\n /** Seed map from a known message (e.g. `useMessages`). */\n initialReactions?: Record<string, Uuid[]>;\n}\n\nexport function ReactionStrip({\n messageId,\n conversationId,\n meId,\n initialReactions,\n}: ReactionStripProps) {\n const theme = usePoolseTheme();\n const { reactions, addReaction, removeReaction } = useReactions(messageId, {\n conversationId,\n currentUserId: meId,\n ...(initialReactions ? { initialReactions } : {}),\n });\n const entries = Object.entries(reactions);\n if (entries.length === 0) return null;\n\n return (\n <View style={styles.strip}>\n {entries.map(([emoji, userIds]) => {\n const userArr = Array.isArray(userIds) ? userIds : [];\n const meReacted = meId !== null && userArr.includes(meId);\n return (\n <Pressable\n key={emoji}\n onPress={() => (meReacted ? removeReaction(emoji) : addReaction(emoji))}\n style={[\n styles.chip,\n {\n backgroundColor: meReacted ? theme.colors.brandSoft : theme.colors.surface2,\n borderColor: meReacted ? theme.colors.brand : theme.colors.border,\n borderWidth: meReacted ? 1.5 : 1,\n transform: meReacted ? [{ scale: 1.04 }] : undefined,\n },\n ]}\n >\n <Text style={styles.emoji}>{emoji}</Text>\n <Text\n style={[\n styles.count,\n {\n color: meReacted ? theme.colors.brand : theme.colors.ink2,\n fontWeight: meReacted ? '700' : '600',\n },\n ]}\n >\n {userArr.length}\n </Text>\n </Pressable>\n );\n })}\n </View>\n );\n}\n\nexport interface ReactionPickerProps {\n visible: boolean;\n onClose: () => void;\n onPick: (emoji: string) => void;\n /** Override the default 6-emoji set. */\n emojis?: string[];\n}\n\nexport function ReactionPicker({\n visible,\n onClose,\n onPick,\n emojis = DEFAULT_EMOJIS,\n}: ReactionPickerProps) {\n const theme = usePoolseTheme();\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={onClose}>\n <Pressable style={styles.backdrop} onPress={onClose}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderRadius: theme.radii.lg,\n },\n theme.shadows.lg,\n ]}\n >\n {emojis.map((emoji) => (\n <Pressable\n key={emoji}\n style={styles.emojiBtn}\n onPress={() => {\n onPick(emoji);\n onClose();\n }}\n >\n <Text style={styles.bigEmoji}>{emoji}</Text>\n </Pressable>\n ))}\n </View>\n </Pressable>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n strip: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n gap: 4,\n marginTop: 2,\n },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 9,\n paddingVertical: 4,\n borderRadius: 14,\n gap: 5,\n minHeight: 26,\n // Subtle elevation so chips lift off the surface\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 1 },\n shadowOpacity: 0.06,\n shadowRadius: 2,\n elevation: 1,\n },\n emoji: {\n fontSize: 15,\n lineHeight: 18,\n },\n count: {\n fontSize: 12,\n fontVariant: ['tabular-nums'],\n },\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.4)',\n justifyContent: 'center',\n alignItems: 'center',\n paddingHorizontal: 24,\n },\n sheet: {\n flexDirection: 'row',\n paddingHorizontal: 12,\n paddingVertical: 12,\n gap: 4,\n alignItems: 'center',\n },\n emojiBtn: {\n paddingHorizontal: 8,\n paddingVertical: 6,\n borderRadius: 999,\n alignItems: 'center',\n justifyContent: 'center',\n },\n bigEmoji: {\n fontSize: 32,\n lineHeight: 38,\n },\n});\n","import { Animated, PanResponder, Pressable, StyleSheet, Text, View } from 'react-native';\nimport type { Message, Uuid } from '@poolse/sdk';\nimport { useMemo, useRef, useState } from 'react';\n// Static import — Metro's bundle graph can only trace literal\n// `import` / `require` calls. See ./internal/markdown.ts for the\n// full reasoning. `expo-clipboard` is a required peer dep; consumers\n// who don't want copy can omit the Copy action by not enabling\n// `actions` on <ConversationView>.\nimport * as Clipboard from 'expo-clipboard';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { MessageActions } from './MessageActions.js';\nimport { MessageBubble, type BubbleGroupPosition } from './MessageBubble.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { ReactionStrip } from './Reactions.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\nimport { useReactions, useUser } from '@poolse/react';\n\n// Swipe-to-reply triggers at this much horizontal pull. iOS / WhatsApp\n// use 50–60px; the lower bound feels lighter for one-handed thumb use.\nconst SWIPE_REPLY_THRESHOLD = 50;\n\nexport interface MessageRowProps {\n msg: Message;\n meId: string | null;\n\n // Feature toggles — same set as ConversationView's, but per-row.\n reactions?: boolean;\n attachments?: boolean;\n actions?: boolean;\n /** Pass false in ThreadView since nested threads aren't a thing in v1. */\n threads?: boolean;\n /** WhatsApp-style quote-reply. Defaults true on ConversationView. */\n quotations?: boolean;\n /** Forwarded to `<MessageBubble markdown>`. Defaults true. */\n markdown?: boolean;\n\n readState?: 'sent' | 'read';\n\n /**\n * Whether this row's message is the one currently being edited.\n * Editing happens in the composer (see MessageComposer's\n * `editingMessage` prop); this flag is only used to elevate the\n * row above the dim backdrop ConversationView renders during\n * edit mode.\n */\n isEditing?: boolean;\n /**\n * Long-press → \"Edit\". Omitted entirely (no Edit option in the\n * menu) when the parent has decided this message isn't editable\n * (someone read it, it's deleted, it isn't yours).\n */\n onStartEdit?: () => void;\n onDelete?: () => void;\n onOpenThread?: () => void;\n onQuote?: () => void;\n labelFor?: (externalId: string) => string;\n onQuotedClick?: (quotedMessageId: Uuid) => void;\n groupPosition?: BubbleGroupPosition;\n maxBodyLength?: number;\n /** Show a colored sender label above other-side bubbles. */\n showSenderName?: boolean;\n /** Render an avatar to the LEFT of other-side bubbles. */\n showAvatar?: boolean;\n /** Avatar resolver — same signature as `<MemberList avatarFor>`. */\n avatarFor?: (externalId: string) => string | null;\n}\n\nexport function MessageRow({\n msg,\n meId,\n reactions = true,\n attachments = true,\n actions = true,\n threads = true,\n quotations = true,\n markdown = true,\n readState,\n isEditing = false,\n onStartEdit,\n onDelete,\n onOpenThread,\n onQuote,\n labelFor,\n onQuotedClick,\n groupPosition = 'standalone',\n maxBodyLength = 0,\n showSenderName = false,\n showAvatar = false,\n avatarFor,\n}: MessageRowProps) {\n const theme = usePoolseTheme();\n const isSelf = meId !== null && msg.sender_id === meId;\n const [actionsOpen, setActionsOpen] = useState(false);\n\n // Per-row useReactions subscription so the long-press → React picker\n // and the inline ReactionStrip share the same realtime state. Adds\n // one realtime listener per visible row, which is fine — they're\n // server-filtered by messageId and the FlatList only mounts rows in\n // view. Initial seed comes from msg.reactions so the strip renders\n // immediately without waiting for the first echo.\n const reactionsApi = useReactions(msg.id, {\n conversationId: msg.conversation_id,\n currentUserId: meId,\n ...(msg.reactions ? { initialReactions: msg.reactions } : {}),\n });\n\n // Swipe-to-reply state. The bubble's translateX is driven by a pan\n // gesture; when the user releases past SWIPE_REPLY_THRESHOLD we fire\n // onQuote (which the parent wires to setReplyingTo on the composer).\n // Animation runs on the JS thread because we need to read the value\n // synchronously on release — native driver would prevent that.\n const translateX = useRef(new Animated.Value(0)).current;\n const swipeEnabled = quotations && !!onQuote && !isEditing;\n\n const panResponder = useMemo(\n () =>\n PanResponder.create({\n // Tap / long-press still go to the inner Pressable.\n onStartShouldSetPanResponder: () => false,\n onStartShouldSetPanResponderCapture: () => false,\n // Capture-phase claim: we intercept the gesture BEFORE the\n // child Pressable as soon as the move shows clear horizontal\n // intent. Without capture-phase, the Pressable's touch handling\n // wins first and the pan never starts (this is why self-bubble\n // left swipes felt totally dead — the Pressable was attached\n // to a touch that started with the user's finger over the\n // bubble center, and we never got a turn).\n onMoveShouldSetPanResponder: () => false,\n onMoveShouldSetPanResponderCapture: (_, g) => {\n if (!swipeEnabled) return false;\n // 4px is plenty to disambiguate from an accidental jitter\n // during a tap. `dx > dy` (not `dx > dy * 2`) so a slightly\n // diagonal pull still counts as horizontal — the user isn't\n // going to hold their finger to a perfect axis.\n return Math.abs(g.dx) > 4 && Math.abs(g.dx) > Math.abs(g.dy);\n },\n // Don't surrender the gesture mid-swipe (e.g. parent FlatList\n // asking for it back) — once we're translating the bubble we\n // hold on until release.\n onPanResponderTerminationRequest: () => false,\n // 1:1 finger-follow up to the threshold, then square-root\n // damping past it so the bubble never slides off-screen.\n // Matches iMessage / WhatsApp — feels weightless during the\n // committed range and stiffens once you've already triggered.\n onPanResponderMove: (_, g) => {\n const dx = isSelf ? Math.min(0, g.dx) : Math.max(0, g.dx);\n const abs = Math.abs(dx);\n let translated: number;\n if (abs <= SWIPE_REPLY_THRESHOLD) {\n translated = dx;\n } else {\n const excess = abs - SWIPE_REPLY_THRESHOLD;\n const dampened = SWIPE_REPLY_THRESHOLD + Math.sqrt(excess * 6);\n translated = dx < 0 ? -dampened : dampened;\n }\n translateX.setValue(translated);\n },\n onPanResponderRelease: (_, g) => {\n const past = Math.abs(g.dx) >= SWIPE_REPLY_THRESHOLD;\n if (past && onQuote) onQuote();\n Animated.spring(translateX, {\n toValue: 0,\n useNativeDriver: false,\n speed: 28,\n bounciness: 4,\n }).start();\n },\n onPanResponderTerminate: () => {\n Animated.spring(translateX, {\n toValue: 0,\n useNativeDriver: false,\n speed: 28,\n bounciness: 4,\n }).start();\n },\n }),\n [swipeEnabled, isSelf, onQuote, translateX],\n );\n\n // Reply icon fades + scales in as the bubble drags past ~half the\n // threshold. Sits on the SAME side the swipe is coming FROM (so\n // it's revealed behind the bubble as the bubble slides away).\n const replyIconOpacity = translateX.interpolate({\n inputRange: isSelf\n ? [-SWIPE_REPLY_THRESHOLD, -SWIPE_REPLY_THRESHOLD / 2, 0]\n : [0, SWIPE_REPLY_THRESHOLD / 2, SWIPE_REPLY_THRESHOLD],\n outputRange: isSelf ? [1, 0.3, 0] : [0, 0.3, 1],\n extrapolate: 'clamp',\n });\n const replyIconScale = translateX.interpolate({\n inputRange: isSelf ? [-SWIPE_REPLY_THRESHOLD, 0] : [0, SWIPE_REPLY_THRESHOLD],\n outputRange: isSelf ? [1, 0.5] : [0.5, 1],\n extrapolate: 'clamp',\n });\n\n const showAvatarSlot = showAvatar && !isSelf;\n const showAvatarRender =\n showAvatarSlot && (groupPosition === 'last' || groupPosition === 'standalone');\n // Resolve avatar / label with the same priority as MessageBubble /\n // ChatHeader: explicit prop > SDK userResolver > externalId fallback.\n // Without the useUser fallback, omitting `avatarFor` / `labelFor` on\n // <ConversationView> bypassed the resolver at the row level even\n // when `PoolseConfig.userResolver` was configured.\n const rowSender = useUser(showAvatarSlot ? msg.sender_external_id : null);\n const avatarUrl = msg.sender_external_id\n ? (avatarFor?.(msg.sender_external_id) ?? rowSender.profile?.avatarUrl ?? null)\n : null;\n const senderLabel = msg.sender_external_id\n ? (labelFor?.(msg.sender_external_id) ??\n rowSender.profile?.displayName ??\n msg.sender_external_id)\n : null;\n\n return (\n <View\n style={[\n styles.row,\n { alignSelf: isSelf ? 'flex-end' : 'flex-start' },\n // Lift this row above the dim backdrop the parent renders\n // during edit mode. zIndex covers iOS / web; elevation does\n // the equivalent on Android.\n isEditing ? styles.rowEditing : null,\n ]}\n >\n {showAvatarSlot ? (\n <View style={styles.avatarSlot}>\n {showAvatarRender ? (\n <Avatar\n src={avatarUrl ?? null}\n name={senderLabel}\n seed={msg.sender_external_id ?? null}\n size=\"sm\"\n />\n ) : null}\n </View>\n ) : null}\n\n <View style={styles.bubbleCol}>\n {swipeEnabled ? (\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.replyHint,\n isSelf ? styles.replyHintRight : styles.replyHintLeft,\n {\n opacity: replyIconOpacity,\n transform: [{ scale: replyIconScale }],\n backgroundColor: theme.colors.surface2,\n },\n ]}\n >\n <PoolseIcon name=\"reply\" size={16} color={theme.colors.brand} />\n </Animated.View>\n ) : null}\n\n <Animated.View\n {...(swipeEnabled ? panResponder.panHandlers : {})}\n style={{ transform: [{ translateX }] }}\n >\n <Pressable\n onLongPress={() => {\n if (!actions) return;\n setActionsOpen(true);\n }}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Message actions\"\n >\n <MessageBubble\n message={msg}\n currentUserId={meId}\n {...(readState ? { readState } : {})}\n {...(labelFor ? { labelFor } : {})}\n {...(onQuotedClick ? { onQuotedClick } : {})}\n groupPosition={groupPosition}\n maxBodyLength={maxBodyLength}\n showSenderName={showSenderName}\n showAttachments={attachments}\n markdown={markdown}\n actionsTrigger={\n actions ? (\n <Pressable onPress={() => setActionsOpen(true)} hitSlop={8}>\n <PoolseIcon\n name=\"chevron-down\"\n size={14}\n color={isSelf ? theme.colors.onBrand : theme.colors.ink3}\n />\n </Pressable>\n ) : null\n }\n />\n </Pressable>\n </Animated.View>\n\n {threads && (msg.reply_count ?? 0) > 0 && onOpenThread ? (\n <Pressable onPress={onOpenThread} style={styles.threadPill}>\n <Text style={[styles.threadPillText, { color: theme.colors.brand }]}>\n 💬 {msg.reply_count} {msg.reply_count === 1 ? 'reply' : 'replies'}\n </Text>\n </Pressable>\n ) : null}\n\n {reactions ? (\n <View style={[styles.reactionsRow, { alignSelf: isSelf ? 'flex-end' : 'flex-start' }]}>\n <ReactionStrip\n messageId={msg.id}\n conversationId={msg.conversation_id}\n meId={meId}\n {...(msg.reactions ? { initialReactions: msg.reactions } : {})}\n />\n </View>\n ) : null}\n </View>\n\n {actions && actionsOpen ? (\n <MessageActions\n visible={actionsOpen}\n onClose={() => setActionsOpen(false)}\n isSelf={isSelf}\n {...(reactions\n ? {\n // Inline quick-react row at the top of the sheet —\n // one tap = react + close, no second modal needed.\n onPickReaction: (emoji: string) => {\n void reactionsApi.addReaction(emoji);\n },\n }\n : {})}\n {...(msg.body && !msg.deleted_at\n ? {\n onCopy: () => {\n setActionsOpen(false);\n void Clipboard.setStringAsync(msg.body ?? '');\n },\n }\n : {})}\n {...(onStartEdit\n ? {\n onEdit: () => {\n setActionsOpen(false);\n onStartEdit();\n },\n }\n : {})}\n {...(onDelete\n ? {\n onDelete: () => {\n setActionsOpen(false);\n onDelete();\n },\n }\n : {})}\n {...(onOpenThread\n ? {\n onReplyInThread: () => {\n setActionsOpen(false);\n onOpenThread();\n },\n }\n : {})}\n {...(quotations && onQuote\n ? {\n onQuote: () => {\n setActionsOpen(false);\n onQuote();\n },\n }\n : {})}\n />\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'flex-end',\n // Tighter vertical rhythm — was 2px each side (4px between rows)\n // plus the bubble's 4px marginBottom = 8px. Now 1+1+2 = 4px,\n // closer to iMessage / WhatsApp density.\n marginVertical: 1,\n // 10px on each side — tight enough to use the available width\n // for content, loose enough to keep bubbles off the screen edge\n // on every device.\n paddingHorizontal: 10,\n maxWidth: '95%',\n },\n rowEditing: {\n // Above ConversationView's editBackdrop (zIndex 5). Elevation\n // does the equivalent stacking on Android.\n zIndex: 10,\n elevation: 10,\n },\n avatarSlot: {\n width: 36,\n marginRight: 6,\n },\n bubbleCol: {\n flexShrink: 1,\n position: 'relative',\n },\n replyHint: {\n position: 'absolute',\n top: '50%',\n marginTop: -16,\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: -1,\n },\n replyHintLeft: {\n left: -44,\n },\n replyHintRight: {\n right: -44,\n },\n threadPill: {\n alignSelf: 'flex-start',\n marginTop: 2,\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n threadPillText: {\n fontSize: 11,\n fontWeight: '600',\n },\n reactionsRow: {\n marginTop: 2,\n },\n});\n","import type { Message, Uuid } from '@poolse/sdk';\nimport { useMe, useThread } from '@poolse/react';\nimport { useCallback, useMemo, useState, type ReactElement } from 'react';\nimport {\n Animated,\n KeyboardAvoidingView,\n Modal,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { AttachmentPicker } from './AttachmentPicker.js';\nimport { MessageComposer } from './MessageComposer.js';\nimport { MessageList } from './MessageList.js';\nimport { MessageRow } from './MessageRow.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { UploadProvider } from './internal/uploadContext.js';\nimport { useDismissableSheet } from './internal/useDismissableSheet.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ThreadViewProps {\n visible: boolean;\n onClose: () => void;\n conversationId: Uuid;\n rootMessage: Message;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n}\n\n// Sheet covers the bottom 88% of the screen. The remaining 12% is the\n// pull-down gutter (also the keyboardVerticalOffset for iOS).\nconst SHEET_HEIGHT_FRACTION = 0.88;\n\n/**\n * Bottom-sheet modal for thread replies. Pull the drag handle / header\n * down to dismiss; tap the backdrop or close button too. The composer\n * inside the sheet supports attachments (paperclip → picker, shared\n * upload queue) and the reply rows support reactions, swipe-to-reply,\n * long-press actions, edit, delete — same surface as ConversationView.\n *\n * Keyboard handling: inside a Modal the OS doesn't auto-resize the\n * sheet's children, so the composer needs its own KeyboardAvoidingView\n * with `keyboardVerticalOffset` set to the distance between the screen\n * top and the sheet top (the gutter above the sheet).\n */\nexport function ThreadView({\n visible,\n onClose,\n conversationId,\n rootMessage,\n labelFor,\n avatarFor,\n}: ThreadViewProps) {\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={onClose}\n statusBarTranslucent\n >\n {/* Each open of the thread gets its own UploadProvider so the\n composer's queue is isolated from the parent ConversationView's\n composer queue. */}\n <UploadProvider>\n <ThreadSheet\n onClose={onClose}\n conversationId={conversationId}\n rootMessage={rootMessage}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n </UploadProvider>\n </Modal>\n );\n}\n\nfunction ThreadSheet({\n onClose,\n conversationId,\n rootMessage,\n labelFor,\n avatarFor,\n}: {\n onClose: () => void;\n conversationId: Uuid;\n rootMessage: Message;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n}) {\n const theme = usePoolseTheme();\n const { me } = useMe();\n const meId = me?.id ?? null;\n const {\n replies,\n sendReply,\n edit,\n delete: deleteReply,\n loadMore,\n hasMore,\n } = useThread(conversationId, rootMessage.id);\n const { height: screenHeight } = useWindowDimensions();\n const sheetHeight = Math.round(screenHeight * SHEET_HEIGHT_FRACTION);\n const gutter = screenHeight - sheetHeight;\n const { translateY, panHandlers } = useDismissableSheet({ onClose, sheetHeight });\n\n const [pickerOpen, setPickerOpen] = useState(false);\n const [editingId, setEditingId] = useState<string | null>(null);\n\n const renderReply = useCallback(\n (msg: Message): ReactElement => {\n const isSelf = meId !== null && msg.sender_id === meId;\n const canEdit = isSelf && !msg.deleted_at;\n return (\n <MessageRow\n msg={msg}\n meId={meId}\n // Reactions + actions on by default; nested threads off (you\n // can't thread inside a thread in v1).\n reactions\n attachments\n actions\n threads={false}\n // Quote-to-reply doesn't make sense inside a single-root thread.\n quotations={false}\n isEditing={editingId === msg.id}\n {...(canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {})}\n onDelete={() => {\n void deleteReply(msg.id);\n }}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n );\n },\n [meId, editingId, deleteReply, labelFor, avatarFor],\n );\n\n const editingMessage = useMemo(\n () => (editingId ? (replies.find((m) => m.id === editingId) ?? null) : null),\n [editingId, replies],\n );\n\n const rootRow = useMemo(\n () => (\n <MessageRow\n msg={rootMessage}\n meId={meId}\n reactions\n attachments\n actions={false}\n threads={false}\n quotations={false}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n ),\n [rootMessage, meId, labelFor, avatarFor],\n );\n\n return (\n <View style={styles.modalRoot}>\n <Pressable style={styles.backdrop} onPress={onClose} accessibilityLabel=\"Close thread\" />\n\n <Animated.View\n style={[\n styles.sheet,\n {\n height: sheetHeight,\n backgroundColor: theme.colors.paper,\n borderTopLeftRadius: theme.radii.xl,\n borderTopRightRadius: theme.radii.xl,\n transform: [{ translateY }],\n },\n theme.shadows.lg,\n ]}\n >\n {/* Wrap the header + drag pill in the pan handler so users can\n pull from a comfortable 60-pt-tall strip — the bare 16-pt\n pill on its own was nearly invisible to fingers. */}\n <View {...panHandlers}>\n <View style={styles.dragHandle}>\n <View style={[styles.dragPill, { backgroundColor: theme.colors.ink3 }]} />\n </View>\n\n <View style={[styles.header, { borderBottomColor: theme.colors.border }]}>\n <Pressable\n onPress={onClose}\n hitSlop={16}\n style={[styles.closeBtn, { backgroundColor: theme.colors.surface2 }]}\n accessibilityLabel=\"Close thread\"\n >\n <PoolseIcon name=\"close\" size={18} color={theme.colors.ink} />\n </Pressable>\n <Text\n style={[\n styles.title,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n >\n Thread\n </Text>\n </View>\n </View>\n\n {/* KAV scope: just the scrolling area + composer. Keyboard pushes\n the composer up by the keyboard height minus the gutter\n (since the gutter is already \"free\" space above the sheet\n top). On Android we use `height` behavior — works inside a\n Modal because the modal window itself responds to adjustResize. */}\n <KeyboardAvoidingView\n style={styles.kavBody}\n behavior={Platform.OS === 'ios' ? 'padding' : 'height'}\n keyboardVerticalOffset={Platform.OS === 'ios' ? gutter : 0}\n >\n <View style={[styles.rootPreview, { backgroundColor: theme.colors.surface2 }]}>\n {rootRow}\n </View>\n\n <View style={styles.listWrap}>\n <MessageList\n messages={replies}\n hasMore={hasMore}\n onLoadMore={loadMore}\n renderItem={renderReply}\n />\n </View>\n\n <MessageComposer\n onSend={async (body, opts) => {\n await sendReply({ body, ...opts });\n }}\n placeholder=\"Reply to thread…\"\n attachments\n onAttachPress={() => setPickerOpen(true)}\n editingMessage={editingMessage}\n onCancelEdit={() => setEditingId(null)}\n onSaveEdit={async (body) => {\n if (!editingId) return;\n await edit(editingId, body);\n setEditingId(null);\n }}\n />\n </KeyboardAvoidingView>\n\n <AttachmentPicker visible={pickerOpen} onClose={() => setPickerOpen(false)} />\n </Animated.View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n modalRoot: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n backdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.4)',\n },\n sheet: {\n overflow: 'hidden',\n },\n dragHandle: {\n alignItems: 'center',\n paddingTop: 8,\n paddingBottom: 4,\n },\n dragPill: {\n width: 36,\n height: 4,\n borderRadius: 2,\n opacity: 0.4,\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingTop: 6,\n paddingBottom: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 10,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n },\n title: {\n fontSize: 16,\n fontWeight: '600',\n },\n rootPreview: {\n paddingVertical: 8,\n paddingHorizontal: 8,\n },\n kavBody: {\n flex: 1,\n },\n listWrap: {\n flex: 1,\n },\n});\n","import { Text } from 'react-native';\nimport { useUser } from '@poolse/react';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface UserNameProps {\n /** The user's external_id. Pass null to render the fallback. */\n externalId: string | null | undefined;\n /** Optional fallback when the resolver returns nothing. Defaults to the externalId itself. */\n fallback?: string;\n /** Caller-supplied label override; if it returns a string, it wins. */\n labelFor?: (externalId: string) => string;\n}\n\n/**\n * Display name for a user, looked up via the SDK's `userResolver`\n * with caller-overridable + fallback fallbacks. Renders a `<Text>`.\n */\nexport function UserName({ externalId, fallback, labelFor }: UserNameProps) {\n const theme = usePoolseTheme();\n const name = useDisplayName(externalId, labelFor) ?? fallback ?? externalId ?? '';\n return <Text style={{ color: theme.colors.ink, fontFamily: theme.type.fontBody }}>{name}</Text>;\n}\n\n/**\n * Resolves a user's display name via the 3-tier chain:\n * 1. `labelFor(externalId)` — caller-supplied override\n * 2. SDK `userResolver` (memoized via `useUser`)\n * 3. The externalId itself (so something always renders)\n */\nexport function useDisplayName(\n externalId: string | null | undefined,\n labelFor?: (externalId: string) => string,\n): string {\n const resolved = useUser(externalId ?? null);\n if (!externalId) return '';\n if (labelFor) {\n const override = labelFor(externalId);\n if (override) return override;\n }\n return resolved.profile?.displayName ?? externalId;\n}\n","import { useEffect, useRef } from 'react';\nimport { Animated, StyleSheet, Text, View, Easing } from 'react-native';\n\nimport { useDisplayName } from './UserName.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface TypingIndicatorProps {\n /** Set of `external_id`s currently typing — what `useTyping` returns. */\n typing: Set<string>;\n /**\n * Resolves an `external_id` to a display label. Defaults to the\n * SDK's `userResolver` (and falls back to the external_id itself\n * when the resolver isn't configured).\n */\n labelFor?: (externalId: string) => string;\n}\n\n/**\n * Three animated dots + an inline \"X is typing\" label. Renders a\n * zero-height row when nobody is typing so the list doesn't jump.\n */\nexport function TypingIndicator({ typing, labelFor }: TypingIndicatorProps) {\n const ids = Array.from(typing);\n const isTyping = ids.length > 0;\n\n if (!isTyping) return <View style={{ height: 0 }} />;\n\n return (\n <View style={styles.row}>\n <TypingDots />\n <TypingLabel ids={ids} {...(labelFor ? { labelFor } : {})} />\n </View>\n );\n}\n\nfunction TypingDots() {\n const theme = usePoolseTheme();\n const a = useRef(new Animated.Value(0)).current;\n const b = useRef(new Animated.Value(0)).current;\n const c = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const loop = (val: Animated.Value, delay: number) =>\n Animated.loop(\n Animated.sequence([\n Animated.delay(delay),\n Animated.timing(val, {\n toValue: 1,\n duration: 400,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(val, {\n toValue: 0,\n duration: 400,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ]),\n );\n const animations = [loop(a, 0), loop(b, 150), loop(c, 300)];\n animations.forEach((anim) => anim.start());\n return () => animations.forEach((anim) => anim.stop());\n }, [a, b, c]);\n\n const dot = (val: Animated.Value) => ({\n width: 6,\n height: 6,\n borderRadius: 3,\n backgroundColor: theme.colors.ink3,\n marginHorizontal: 2,\n transform: [\n {\n translateY: val.interpolate({ inputRange: [0, 1], outputRange: [0, -3] }),\n },\n ],\n opacity: val.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1] }),\n });\n\n return (\n <View style={styles.dotsWrap}>\n <Animated.View style={dot(a)} />\n <Animated.View style={dot(b)} />\n <Animated.View style={dot(c)} />\n </View>\n );\n}\n\nfunction TypingLabel({\n ids,\n labelFor,\n}: {\n ids: string[];\n labelFor?: (externalId: string) => string;\n}) {\n const theme = usePoolseTheme();\n const id1 = ids[0] ?? null;\n const id2 = ids[1] ?? null;\n const name1 = useDisplayName(id1, labelFor);\n const name2 = useDisplayName(id2, labelFor);\n\n const text =\n ids.length === 1\n ? `${name1} is typing`\n : ids.length === 2\n ? `${name1} and ${name2} are typing`\n : `${ids.length} people are typing`;\n\n return (\n <Text style={[styles.label, { color: theme.colors.ink2, fontFamily: theme.type.fontBody }]}>\n {text}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingVertical: 6,\n },\n dotsWrap: {\n flexDirection: 'row',\n alignItems: 'flex-end',\n marginRight: 8,\n height: 12,\n },\n label: {\n fontSize: 12,\n },\n});\n","import type { Message, Uuid } from '@poolse/sdk';\nimport {\n computeGroupPosition,\n formatDayLabel,\n sameDay,\n useMe,\n useMembers,\n useMessages,\n useRealtimeStatus,\n useTyping,\n} from '@poolse/react';\nimport { useCallback, useEffect, useMemo, useRef, useState, type ReactElement } from 'react';\nimport {\n AppState,\n KeyboardAvoidingView,\n Platform,\n Pressable,\n StyleSheet,\n View,\n} from 'react-native';\n\nimport { AttachmentPicker } from './AttachmentPicker.js';\nimport { ChatHeader } from './ChatHeader.js';\nimport { DaySeparator } from './DaySeparator.js';\nimport { MentionInput } from './MentionInput.js';\nimport { MessageComposer } from './MessageComposer.js';\nimport { MessageList, type MessageListItem } from './MessageList.js';\nimport { MessageRow } from './MessageRow.js';\nimport { ThreadView } from './ThreadView.js';\nimport { TypingIndicator } from './TypingIndicator.js';\nimport { UploadProvider } from './internal/uploadContext.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\n// Two messages from the same sender within this window collapse\n// into a visual cluster (tight margin, grouped bubble corners).\n// Matches the react-ui default.\nconst GROUPING_WINDOW_MS = 5 * 60 * 1000;\n\nexport interface ConversationViewProps {\n conversationId: Uuid;\n emptyState?: ReactElement | string;\n renderMessage?: (msg: Message, currentUserId: string | null) => ReactElement;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n\n /**\n * Renders the default `<ChatHeader>` at the top of the chat surface.\n * * `true` (default) — auto chat header (other user / group name).\n * * `false` — no header (you supply your own above).\n * * `ReactElement` — custom header node, rendered as-is.\n */\n header?: boolean | ReactElement;\n /** Tap on the header's members icon — typically opens a sheet. */\n onHeaderMembersPress?: () => void;\n /** Tap on the header itself — typically opens a conversation profile. */\n onHeaderPress?: () => void;\n\n // Feature toggles — all default ON, identical names + defaults to web.\n reactions?: boolean;\n mentions?: boolean;\n attachments?: boolean;\n actions?: boolean;\n threads?: boolean;\n quotations?: boolean;\n readReceipts?: boolean;\n /** Render message bodies as Markdown (links, bold, code). Defaults true. */\n markdown?: boolean;\n maxBodyLength?: number;\n\n /** Show sender labels in group chats. `auto` (default), `always`, `never`. */\n senderLabels?: 'auto' | 'always' | 'never';\n /** Show avatars to the left of other-side bubbles in group chats. Same semantics. */\n avatars?: 'auto' | 'always' | 'never';\n\n /**\n * Fires when auto-mark-read commits a new server-side read cursor.\n * Receives the conversation id + the message id that was marked\n * as the last-read. Wire this to `useConversations().markConversationRead(convId, msgId)`\n * so the sidebar / list view's unread badge clears immediately\n * instead of waiting for the next conversations refetch.\n */\n onMarkedRead?: (conversationId: string, messageId: string) => void;\n /**\n * Fires after every successful message send. Wire to the parent's\n * `useConversations().refetch()` so the conversation list shows\n * the fresh `last_message_preview` / `last_message_at` for the\n * conversation you just sent into. `useConversations` creates\n * isolated state per call site, so ConversationView can't refresh\n * a parent hook's state on its own.\n */\n onSent?: (conversationId: string) => void;\n /**\n * keyboardVerticalOffset passed to the internal KeyboardAvoidingView.\n * On iOS this MUST equal the distance from the screen top to the\n * KAV's top (status bar + safe-area-top + any nav header above\n * the chat). `<PoolseInbox>` computes this for you. Standalone\n * consumers pass it manually.\n */\n keyboardOffset?: number;\n}\n\nexport function ConversationView({\n conversationId,\n emptyState,\n renderMessage,\n labelFor,\n avatarFor,\n header = true,\n onHeaderMembersPress,\n onHeaderPress,\n reactions = true,\n mentions = true,\n attachments = true,\n actions = true,\n threads = true,\n quotations = true,\n readReceipts = true,\n markdown = true,\n maxBodyLength = 200,\n senderLabels = 'auto',\n avatars = 'auto',\n onMarkedRead,\n onSent,\n keyboardOffset = 0,\n}: ConversationViewProps) {\n const theme = usePoolseTheme();\n const { me } = useMe();\n const meId = me?.id ?? null;\n\n const {\n messages,\n loading,\n hasMore,\n loadMore,\n send,\n edit,\n delete: deleteMsg,\n markReadUpTo,\n refetch,\n } = useMessages(conversationId);\n const { typing, signalTyping } = useTyping(conversationId);\n const realtimeStatus = useRealtimeStatus();\n\n // Pull the latest page when the app foregrounds or the socket\n // reconnects. While the socket is down (background, network drop)\n // we miss `message:new` pushes; without this the chat shows stale\n // data until the user navigates away and back.\n useEffect(() => {\n const sub = AppState.addEventListener('change', (next) => {\n if (next === 'active') void refetch();\n });\n return () => sub.remove();\n }, [refetch]);\n\n const prevStatusRef = useRef(realtimeStatus);\n useEffect(() => {\n const prev = prevStatusRef.current;\n prevStatusRef.current = realtimeStatus;\n if (\n realtimeStatus === 'connected' &&\n (prev === 'reconnecting' || prev === 'closed' || prev === 'connecting')\n ) {\n void refetch();\n }\n }, [realtimeStatus, refetch]);\n\n const wantsMembers = mentions || senderLabels === 'auto' || avatars === 'auto';\n const { members } = useMembers(wantsMembers ? conversationId : '');\n const isGroupChat = members.length > 2;\n const showSenderLabels = senderLabels === 'always' || (senderLabels === 'auto' && isGroupChat);\n const showAvatars = avatars === 'always' || (avatars === 'auto' && isGroupChat);\n\n const [replyingTo, setReplyingTo] = useState<Message | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [threadRoot, setThreadRoot] = useState<Message | null>(null);\n const [pickerOpen, setPickerOpen] = useState(false);\n\n // messageId → sequence map for read-receipt comparison. Membership\n // only carries `last_read_message_id` (UUID); to know whether\n // member X read message Y we have to translate the read message's\n // id into its sequence and compare against Y's sequence. UUIDs\n // aren't chronological so we have to do this lookup explicitly.\n const sequenceByMessageId = useMemo(() => {\n const m = new Map<string, number>();\n for (const msg of messages) {\n if (typeof msg.sequence === 'number') m.set(msg.id, msg.sequence);\n }\n return m;\n }, [messages]);\n\n // Auto-mark-read: advance the read cursor whenever a confirmed\n // message lands at the tail. Skip optimistic temp messages\n // (no `sequence` yet — server hasn't seen the id) to avoid\n // 404s when send-then-immediately-mark races the round-trip.\n // Wrapping in try/catch lets us survive any other transient\n // membership-write failures without breaking the chat.\n const lastMarkedRef = useRef<string | null>(null);\n useEffect(() => {\n if (!readReceipts) return;\n if (messages.length === 0) return;\n const latest = messages[messages.length - 1];\n if (!latest || !latest.id) return;\n if (latest.id === lastMarkedRef.current) return;\n // Optimistic temp messages don't have a server-assigned sequence.\n // Marking them would 404 (server hasn't processed the send yet);\n // wait for the realtime confirmation to land, which replaces the\n // temp with a real message carrying a real sequence.\n if (typeof latest.sequence !== 'number' || latest.sequence <= 0) return;\n lastMarkedRef.current = latest.id;\n void markReadUpTo(latest.id).catch(() => {\n // Reset so we retry on the next message arrival.\n lastMarkedRef.current = null;\n });\n onMarkedRead?.(conversationId, latest.id);\n }, [messages, meId, readReceipts, markReadUpTo, onMarkedRead, conversationId]);\n\n // Precompute per-message group position (drives the bubble's\n // corner treatment + inter-cluster spacing). Same logic as\n // react-ui's ConversationView; the helpers live in @poolse/react.\n const groupPositionById = useMemo(() => {\n const map = new Map<string, ReturnType<typeof computeGroupPosition>>();\n for (let i = 0; i < messages.length; i++) {\n const msg = messages[i];\n if (!msg) continue;\n const prev = i > 0 ? (messages[i - 1] ?? null) : null;\n const next = i < messages.length - 1 ? (messages[i + 1] ?? null) : null;\n map.set(msg.id, computeGroupPosition(msg, prev, next, GROUPING_WINDOW_MS));\n }\n return map;\n }, [messages]);\n\n const renderItem = useCallback(\n (msg: Message): ReactElement => {\n if (renderMessage) return <>{renderMessage(msg, meId)}</>;\n const readState: 'sent' | 'read' | undefined =\n readReceipts && meId !== null && msg.sender_id === meId\n ? readStateForMessage(msg, members, meId, sequenceByMessageId)\n : undefined;\n // Edit is only offered for own messages no one else has read\n // yet — once someone has \"seen\" it (their last_read_message_id\n // sequence >= this one) WhatsApp-style apps disable editing to\n // prevent conversation rewriting. `readStateForMessage`\n // returns 'sent' in 1:1 chats with no other member, so own\n // messages in fresh threads stay editable.\n const isSelf = meId !== null && msg.sender_id === meId;\n const canEdit = isSelf && !msg.deleted_at && (readState ?? 'sent') === 'sent';\n const groupPosition = groupPositionById.get(msg.id) ?? 'standalone';\n return (\n <MessageRow\n msg={msg}\n meId={meId}\n reactions={reactions}\n attachments={attachments}\n actions={actions}\n threads={threads}\n quotations={quotations}\n {...(readState ? { readState } : {})}\n isEditing={editingId === msg.id}\n {...(canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {})}\n onDelete={() => deleteMsg(msg.id)}\n {...(threads ? { onOpenThread: () => setThreadRoot(msg) } : {})}\n {...(quotations ? { onQuote: () => setReplyingTo(msg) } : {})}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n showSenderName={showSenderLabels}\n showAvatar={showAvatars}\n maxBodyLength={maxBodyLength}\n groupPosition={groupPosition}\n markdown={markdown}\n />\n );\n },\n [\n renderMessage,\n meId,\n readReceipts,\n members,\n reactions,\n attachments,\n actions,\n threads,\n quotations,\n editingId,\n deleteMsg,\n labelFor,\n avatarFor,\n showSenderLabels,\n showAvatars,\n maxBodyLength,\n sequenceByMessageId,\n groupPositionById,\n markdown,\n ],\n );\n\n const editingMessage = useMemo(\n () => (editingId ? (messages.find((m) => m.id === editingId) ?? null) : null),\n [editingId, messages],\n );\n\n // Build the interleaved item list (messages + day separators).\n // Inject a separator BEFORE a message whenever its day differs\n // from the previous message's day.\n const listItems = useMemo<MessageListItem[]>(() => {\n const out: MessageListItem[] = [];\n let prev: Message | null = null;\n for (const msg of messages) {\n if (prev === null || !sameDay(msg.inserted_at, prev.inserted_at)) {\n const label = formatDayLabel(msg.inserted_at);\n out.push({\n kind: 'separator',\n id: `sep-${msg.id}`,\n node: <DaySeparator label={label} />,\n });\n }\n out.push({ kind: 'msg', msg });\n prev = msg;\n }\n return out;\n }, [messages]);\n\n const composerProps = useMemo(\n () => ({\n onSend: async (\n body: string,\n opts?: { quoted_message_id?: Uuid; attachment_ids?: Uuid[]; mentions?: Uuid[] },\n ) => {\n await send({ body, ...opts });\n setReplyingTo(null);\n // Tell the parent so it can refresh ITS useConversations\n // state. useConversations creates isolated state per call\n // site, so a refetch from here wouldn't update PoolseInbox's\n // list — only the parent's own hook instance can.\n onSent?.(conversationId);\n },\n onTyping: signalTyping,\n ...(attachments ? { onAttachPress: () => setPickerOpen(true) } : {}),\n ...(replyingTo ? { replyingTo } : {}),\n onCancelReply: () => setReplyingTo(null),\n ...(labelFor ? { labelFor } : {}),\n attachments,\n keyboardOffset,\n editingMessage,\n onCancelEdit: () => setEditingId(null),\n onSaveEdit: async (body: string) => {\n if (!editingId) return;\n await edit(editingId, body);\n setEditingId(null);\n },\n }),\n [\n send,\n signalTyping,\n attachments,\n replyingTo,\n labelFor,\n keyboardOffset,\n onSent,\n conversationId,\n editingMessage,\n editingId,\n edit,\n ],\n );\n\n const headerNode =\n header === false ? null : header === true ? (\n <ChatHeader\n conversationId={conversationId}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(onHeaderMembersPress ? { onMembersPress: onHeaderMembersPress } : {})}\n {...(onHeaderPress ? { onPress: onHeaderPress } : {})}\n />\n ) : (\n header\n );\n\n return (\n <UploadProvider>\n <KeyboardAvoidingView\n // iOS uses `padding` (the height behavior is documented as\n // only working on absolute-positioned children and is\n // basically a no-op inside flex:1 chains like ours).\n // Padding mode REQUIRES the right keyboardVerticalOffset —\n // the distance from the screen top to the KAV's top.\n // PoolseInbox computes this from the safe-area top + its own\n // ChatHeader height and passes it through; standalone\n // consumers must pass it themselves.\n //\n // Android uses `height` — works there because the layout\n // recomputes from the Android window resize.\n style={[styles.root, { backgroundColor: theme.colors.paper }]}\n behavior={Platform.OS === 'ios' ? 'padding' : 'height'}\n keyboardVerticalOffset={keyboardOffset}\n >\n {headerNode}\n <View style={styles.listWrap}>\n <MessageList\n messages={messages}\n items={listItems}\n meId={meId}\n loading={loading}\n hasMore={hasMore}\n onLoadMore={loadMore}\n renderItem={renderItem}\n ListHeader={<TypingIndicator typing={typing} {...(labelFor ? { labelFor } : {})} />}\n {...(emptyState !== undefined ? { emptyState } : {})}\n />\n {/* WhatsApp-style dim while editing: the overlay covers\n the scroll surface but the row being edited renders\n above it (MessageRow elevates itself when isEditing).\n Tap-outside cancels. */}\n {editingId ? (\n <Pressable\n style={styles.editBackdrop}\n onPress={() => setEditingId(null)}\n accessibilityLabel=\"Cancel editing\"\n />\n ) : null}\n </View>\n\n {mentions ? (\n <MentionInput conversationId={conversationId} {...composerProps} />\n ) : (\n <MessageComposer {...composerProps} />\n )}\n\n {attachments ? (\n <AttachmentPicker visible={pickerOpen} onClose={() => setPickerOpen(false)} />\n ) : null}\n\n {threads && threadRoot ? (\n <ThreadView\n visible\n onClose={() => setThreadRoot(null)}\n conversationId={conversationId}\n rootMessage={threadRoot}\n {...(labelFor ? { labelFor } : {})}\n />\n ) : null}\n </KeyboardAvoidingView>\n </UploadProvider>\n );\n}\n\nfunction readStateForMessage(\n msg: Message,\n members: ReadonlyArray<{ user_id: string; last_read_message_id: string | null }>,\n meId: string,\n sequenceByMessageId: Map<string, number>,\n): 'sent' | 'read' {\n const otherMembers = members.filter((m) => m.user_id !== meId);\n if (otherMembers.length === 0) return 'sent';\n if (typeof msg.sequence !== 'number') return 'sent';\n const mySeq = msg.sequence;\n const anyRead = otherMembers.some((m) => {\n if (!m.last_read_message_id) return false;\n const readSeq = sequenceByMessageId.get(m.last_read_message_id);\n if (readSeq === undefined) return false;\n return readSeq >= mySeq;\n });\n return anyRead ? 'read' : 'sent';\n}\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n },\n listWrap: {\n flex: 1,\n },\n editBackdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.45)',\n // Sit above message rows by default but below any row that\n // explicitly elevates itself (MessageRow bumps zIndex/elevation\n // when isEditing is true).\n zIndex: 5,\n },\n});\n","import { useMemo, useState } from 'react';\nimport {\n Animated,\n FlatList,\n Image,\n Modal,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { Avatar } from '../primitives/Avatar.js';\nimport { PoolseIcon } from '../primitives/PoolseIcon.js';\nimport { useDismissableSheet } from './useDismissableSheet.js';\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\n\nexport interface InboxUser {\n /** The user's external_id (the same id you mint JWTs with). */\n externalId: string;\n /** Display name shown in the picker row. */\n name: string;\n /** Optional avatar URL — falls back to initials if missing. */\n avatarUrl?: string | null;\n /** Optional secondary line (email, role, handle…). */\n subtitle?: string;\n}\n\nexport interface UserPickerSheetProps {\n visible: boolean;\n onClose: () => void;\n users: InboxUser[];\n /** External_ids to hide (usually the caller's own id). */\n excludeIds?: string[];\n /**\n * `single` → direct-chat mode; tap a row, fires onPickDirect, closes.\n * `group` → multi-select with a group-name input + Create button.\n */\n mode: 'single' | 'group';\n onPickDirect?: (externalId: string) => void;\n onCreateGroup?: (name: string, memberExternalIds: string[]) => void;\n /** Optional header slot — title defaults to \"New chat\" / \"New group\". */\n title?: string;\n /** Search input shown when user count ≥ 8. Override to force on/off. */\n searchable?: boolean;\n}\n\n/**\n * Bottom-sheet picker for selecting one or many users from the\n * tenant's user directory. Used by `<PoolseInbox>` for the\n * built-in \"New chat\" / \"New group\" flows. Exported standalone so\n * devs can drive it from their own UI (e.g. a \"Forward to…\" sheet).\n */\nexport function UserPickerSheet({\n visible,\n onClose,\n users,\n excludeIds,\n mode,\n onPickDirect,\n onCreateGroup,\n title,\n searchable,\n}: UserPickerSheetProps) {\n const theme = usePoolseTheme();\n const [query, setQuery] = useState('');\n const [selectedIds, setSelectedIds] = useState<string[]>([]);\n const [groupName, setGroupName] = useState('');\n const { height: screenHeight } = useWindowDimensions();\n const { translateY, panHandlers } = useDismissableSheet({\n onClose: () => {\n // Reset selection state on dismiss so it doesn't survive\n // across opens.\n setQuery('');\n setSelectedIds([]);\n setGroupName('');\n onClose();\n },\n sheetHeight: screenHeight * 0.85,\n });\n\n const excludeSet = useMemo(() => new Set(excludeIds ?? []), [excludeIds]);\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase();\n return users.filter((u) => {\n if (excludeSet.has(u.externalId)) return false;\n if (!q) return true;\n return (\n u.name.toLowerCase().includes(q) ||\n (u.subtitle ?? '').toLowerCase().includes(q) ||\n u.externalId.toLowerCase().includes(q)\n );\n });\n }, [users, query, excludeSet]);\n\n const showSearch = searchable ?? users.length >= 8;\n const isGroup = mode === 'group';\n const heading = title ?? (isGroup ? 'New group' : 'New chat');\n\n const reset = () => {\n setQuery('');\n setSelectedIds([]);\n setGroupName('');\n };\n\n const handleClose = () => {\n reset();\n onClose();\n };\n\n const toggle = (externalId: string) => {\n setSelectedIds((prev) =>\n prev.includes(externalId) ? prev.filter((id) => id !== externalId) : [...prev, externalId],\n );\n };\n\n const canCreate = isGroup && selectedIds.length > 0 && groupName.trim().length > 0;\n\n const handleCreate = () => {\n if (!canCreate) return;\n onCreateGroup?.(groupName.trim(), selectedIds);\n reset();\n onClose();\n };\n\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={handleClose}\n statusBarTranslucent\n >\n <View style={styles.modalRoot}>\n <Pressable style={styles.backdrop} onPress={handleClose} />\n\n <Animated.View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.paper,\n borderTopLeftRadius: theme.radii.xl,\n borderTopRightRadius: theme.radii.xl,\n transform: [{ translateY }],\n },\n theme.shadows.lg,\n ]}\n >\n <View {...panHandlers} style={styles.dragHandle}>\n <View style={[styles.dragPill, { backgroundColor: theme.colors.ink3 }]} />\n </View>\n\n <View style={styles.header}>\n <Pressable\n onPress={handleClose}\n hitSlop={16}\n style={[styles.closeBtn, { backgroundColor: theme.colors.surface2 }]}\n accessibilityLabel=\"Close picker\"\n >\n <PoolseIcon name=\"close\" size={18} color={theme.colors.ink} />\n </Pressable>\n <Text\n style={[\n styles.title,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n numberOfLines={1}\n >\n {heading}\n </Text>\n {isGroup ? (\n <Pressable\n onPress={handleCreate}\n disabled={!canCreate}\n hitSlop={6}\n style={[\n styles.createBtn,\n {\n backgroundColor: canCreate ? theme.colors.brand : theme.colors.surface2,\n opacity: canCreate ? 1 : 0.6,\n },\n ]}\n >\n <Text\n style={{\n color: canCreate ? theme.colors.onBrand : theme.colors.ink3,\n fontWeight: '700',\n fontSize: 13,\n }}\n >\n Create{selectedIds.length > 0 ? ` (${selectedIds.length})` : ''}\n </Text>\n </Pressable>\n ) : null}\n </View>\n\n {isGroup ? (\n <TextInput\n placeholder=\"Group name\"\n placeholderTextColor={theme.colors.ink3}\n value={groupName}\n onChangeText={setGroupName}\n style={[\n styles.groupNameInput,\n {\n color: theme.colors.ink,\n backgroundColor: theme.colors.surface2,\n borderRadius: theme.radii.md,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n },\n ]}\n />\n ) : null}\n\n {showSearch ? (\n <TextInput\n placeholder=\"Search…\"\n placeholderTextColor={theme.colors.ink3}\n value={query}\n onChangeText={setQuery}\n style={[\n styles.searchInput,\n {\n color: theme.colors.ink,\n backgroundColor: theme.colors.surface2,\n borderRadius: theme.radii.md,\n fontFamily: theme.type.fontBody,\n fontSize: 14,\n },\n ]}\n />\n ) : null}\n\n <FlatList\n data={filtered}\n keyExtractor={(u) => u.externalId}\n ListEmptyComponent={\n <View style={styles.empty}>\n <Text style={[styles.emptyText, { color: theme.colors.ink3 }]}>\n {query ? 'No matches.' : 'No users to show.'}\n </Text>\n </View>\n }\n renderItem={({ item }) => (\n <UserRow\n user={item}\n selected={selectedIds.includes(item.externalId)}\n isGroup={isGroup}\n onPress={() => {\n if (isGroup) toggle(item.externalId);\n else {\n onPickDirect?.(item.externalId);\n reset();\n onClose();\n }\n }}\n />\n )}\n />\n </Animated.View>\n </View>\n </Modal>\n );\n}\n\nfunction UserRow({\n user,\n selected,\n isGroup,\n onPress,\n}: {\n user: InboxUser;\n selected: boolean;\n isGroup: boolean;\n onPress: () => void;\n}) {\n const theme = usePoolseTheme();\n return (\n <Pressable\n onPress={onPress}\n style={[\n styles.row,\n {\n backgroundColor: selected ? theme.colors.brandSoft : 'transparent',\n },\n ]}\n >\n {user.avatarUrl ? (\n <Image source={{ uri: user.avatarUrl }} style={styles.avatarImg} />\n ) : (\n <Avatar src={null} name={user.name} seed={user.externalId} size=\"md\" />\n )}\n <View style={styles.body}>\n <Text\n style={[styles.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {user.name}\n </Text>\n {user.subtitle ? (\n <Text style={[styles.subtitle, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {user.subtitle}\n </Text>\n ) : null}\n </View>\n {isGroup ? (\n <View\n style={[\n styles.checkbox,\n {\n borderColor: selected ? theme.colors.brand : theme.colors.border,\n backgroundColor: selected ? theme.colors.brand : 'transparent',\n },\n ]}\n >\n {selected ? <PoolseIcon name=\"check\" size={14} color={theme.colors.onBrand} /> : null}\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n modalRoot: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n backdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.4)',\n },\n sheet: {\n height: '85%',\n overflow: 'hidden',\n },\n dragHandle: {\n alignItems: 'center',\n paddingTop: 8,\n paddingBottom: 4,\n },\n dragPill: {\n width: 36,\n height: 4,\n borderRadius: 2,\n opacity: 0.4,\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingTop: 4,\n paddingBottom: 12,\n gap: 10,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n },\n title: {\n fontSize: 17,\n fontWeight: '700',\n flex: 1,\n },\n createBtn: {\n paddingHorizontal: 14,\n paddingVertical: 7,\n borderRadius: 999,\n },\n groupNameInput: {\n marginHorizontal: 16,\n marginBottom: 8,\n paddingHorizontal: 12,\n paddingVertical: 10,\n fontWeight: '600',\n },\n searchInput: {\n marginHorizontal: 16,\n marginBottom: 8,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingVertical: 10,\n gap: 12,\n },\n avatarImg: {\n width: 40,\n height: 40,\n borderRadius: 20,\n },\n body: {\n flex: 1,\n gap: 2,\n },\n name: {\n fontSize: 15,\n fontWeight: '600',\n },\n subtitle: {\n fontSize: 12,\n },\n checkbox: {\n width: 22,\n height: 22,\n borderRadius: 11,\n borderWidth: 1.5,\n alignItems: 'center',\n justifyContent: 'center',\n },\n empty: {\n paddingVertical: 40,\n alignItems: 'center',\n },\n emptyText: {\n fontSize: 13,\n },\n});\n","import type { Conversation, Uuid } from '@poolse/sdk';\nimport { useConversations, useMe, useUser } from '@poolse/react';\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {\n Animated,\n Easing,\n Image,\n PanResponder,\n Pressable,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { ChatHeader } from './ChatHeader.js';\nimport { ConversationList } from './ConversationList.js';\nimport { ConversationView } from './ConversationView.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { Avatar } from './primitives/Avatar.js';\nimport { UserPickerSheet, type InboxUser } from './internal/UserPickerSheet.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport type { InboxUser } from './internal/UserPickerSheet.js';\n\n// Height of the ChatHeader we render above ConversationView in the\n// detail pane. Hardcoded because ChatHeader has fixed vertical\n// padding (10 + 36 content + 10 ≈ 56). If you change ChatHeader's\n// padding, bump this constant.\nconst CHAT_HEADER_HEIGHT = 56;\n\nexport interface PoolseInboxProps {\n /** Header title above the conversation list. Defaults to \"Chats\". */\n title?: string;\n\n /**\n * The tenant's user directory. When provided, the inbox shows\n * \"New chat\" + \"New group\" buttons in the header. Omit if you\n * don't want the built-in picker UI (e.g. you start chats from\n * elsewhere via the imperative `openDirect()` API).\n */\n users?: InboxUser[];\n\n /** Display-name resolver for sender labels / chat header titles. */\n labelFor?: (externalId: string) => string;\n /** Avatar URL resolver. */\n avatarFor?: (externalId: string) => string | null;\n\n /**\n * Right-side slot in the header — typical use is a logout / settings\n * button. Rendered after the New-chat / New-group buttons.\n */\n renderRightAction?: () => ReactNode;\n\n /**\n * Custom row renderer for the conversation list. Receives the\n * conversation + the caller's external_id (resolved via `useMe`)\n * so you can branch on direct-vs-group display.\n */\n renderConversationRow?: (\n conv: Conversation,\n callerExternalId: string | null,\n selected: boolean,\n ) => ReactNode;\n\n /** Custom empty state when the list is empty. */\n emptyState?: ReactNode | string;\n\n /** Forwarded to `<ConversationView>` — set if you have a nav header above. */\n keyboardOffset?: number;\n}\n\nexport interface PoolseInboxHandle {\n /** Open a known conversation (e.g. from a deep link / push tap). */\n open: (conversationId: Uuid) => void;\n /**\n * Open (or create) a direct conversation with the given external_id.\n * The backend dedupes per pair — returns the existing conversation\n * if one already exists. Use this from a \"Message\" button on your\n * user profile screens.\n */\n openDirect: (externalId: string) => Promise<void>;\n /** Open (or create) a group conversation. */\n openGroup: (name: string, memberExternalIds: string[]) => Promise<void>;\n /** Open the built-in \"new chat\" picker programmatically. */\n promptNewChat: () => void;\n /** Open the built-in \"new group\" picker programmatically. */\n promptNewGroup: () => void;\n /** Pop back to the conversation list. */\n close: () => void;\n}\n\n/**\n * Drop-in inbox screen: scrollable list of conversations + chat\n * detail, with an iOS-style slide animation between them. Manages\n * its own navigation stack (no react-navigation needed). Picker\n * sheets for \"New chat\" / \"New group\" appear when `users` is\n * provided; otherwise the dev wires those flows themselves and\n * uses the imperative ref to open conversations.\n *\n * For the \"Message\" button on a user profile screen, hold a ref to\n * the inbox and call `inboxRef.current?.openDirect(externalId)`.\n */\nexport const PoolseInbox = forwardRef<PoolseInboxHandle, PoolseInboxProps>(\n function PoolseInbox(props, ref) {\n const {\n title = 'Chats',\n users,\n labelFor,\n avatarFor,\n renderRightAction,\n renderConversationRow,\n emptyState,\n keyboardOffset = 0,\n } = props;\n\n const theme = usePoolseTheme();\n const { width: screenWidth } = useWindowDimensions();\n const { me } = useMe();\n const {\n conversations,\n create,\n unreadCounts,\n markConversationRead,\n refetch: refetchConversations,\n } = useConversations();\n const meExternalId = me?.external_id ?? null;\n // KAV.frame.y is measured relative to the SafeAreaView's\n // coordinate space (the SafeAreaView already absorbs the\n // safe-area-top inset). So the only chrome we need to compensate\n // for in keyboardVerticalOffset is our own ChatHeader above the\n // KAV. Adding insets.top on top double-counts and pushes the\n // composer way too far above the keyboard.\n const detailKeyboardOffset = CHAT_HEADER_HEIGHT;\n\n const [activeId, setActiveId] = useState<Uuid | null>(null);\n const [userPickerOpen, setUserPickerOpen] = useState(false);\n const [groupPickerOpen, setGroupPickerOpen] = useState(false);\n\n const slide = useRef(new Animated.Value(0)).current;\n // Flipped to true while the user is dragging the detail pane via\n // the edge-swipe gesture so the activeId-driven timing animation\n // doesn't fight the finger.\n const draggingRef = useRef(false);\n useEffect(() => {\n if (draggingRef.current) return;\n Animated.timing(slide, {\n toValue: activeId ? 1 : 0,\n duration: 280,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n }, [activeId, slide]);\n\n const listTransform = slide.interpolate({\n inputRange: [0, 1],\n outputRange: [0, -Math.round(screenWidth * 0.25)],\n });\n const detailTransform = slide.interpolate({\n inputRange: [0, 1],\n outputRange: [screenWidth, 0],\n });\n\n // ── Edge-swipe-to-dismiss ────────────────────────────────────────\n // A thin invisible strip pinned to the screen's left edge owns a\n // PanResponder that drags the detail pane back to the right. Only\n // arms when:\n // - the detail pane is currently shown (activeId != null), AND\n // - the gesture starts within EDGE_WIDTH of the left screen edge,\n // AND\n // - the first movement is horizontal-dominant + rightward.\n // Those gates keep the strip from eating bubble swipes, vertical\n // scrolls, or back-button taps in the ChatHeader.\n const EDGE_WIDTH = 24;\n const DISMISS_VX_THRESHOLD = 0.4;\n const activeIdRef = useRef(activeId);\n useEffect(() => {\n activeIdRef.current = activeId;\n }, [activeId]);\n const panResponder = useMemo(() => {\n // Commit-vs-snap threshold scales with the screen so the gesture\n // feels right on phone widths AND tablets.\n const dismissDxThreshold = screenWidth * 0.35;\n return PanResponder.create({\n // Never claim the touch on start — that would swallow taps on\n // the back button in the ChatHeader strip.\n onStartShouldSetPanResponder: () => false,\n onStartShouldSetPanResponderCapture: () => false,\n onMoveShouldSetPanResponder: (_e, gs) => {\n if (!activeIdRef.current) return false;\n if (gs.x0 > EDGE_WIDTH) return false;\n return gs.dx > 6 && Math.abs(gs.dx) > Math.abs(gs.dy);\n },\n onMoveShouldSetPanResponderCapture: (_e, gs) => {\n if (!activeIdRef.current) return false;\n if (gs.x0 > EDGE_WIDTH) return false;\n return gs.dx > 6 && Math.abs(gs.dx) > Math.abs(gs.dy);\n },\n onPanResponderGrant: () => {\n draggingRef.current = true;\n slide.stopAnimation();\n },\n onPanResponderMove: (_e, gs) => {\n // Map finger displacement to slide: dx=0 → slide=1\n // (detail fully on); dx=screenWidth → slide=0 (off).\n const dx = Math.max(0, gs.dx);\n const progress = Math.min(1, dx / screenWidth);\n slide.setValue(1 - progress);\n },\n onPanResponderRelease: (_e, gs) => {\n draggingRef.current = false;\n const past = gs.dx > dismissDxThreshold || gs.vx > DISMISS_VX_THRESHOLD;\n if (past) {\n // Let the activeId-effect drive the close animation from\n // wherever the finger left the pane — Animated.timing\n // starts from the current value, so the motion is\n // continuous.\n setActiveId(null);\n } else {\n Animated.timing(slide, {\n toValue: 1,\n duration: 220,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n }\n },\n onPanResponderTerminate: () => {\n // Another responder took over (rare — scroll, dialog).\n // Snap back to \"open\" so the pane doesn't get stuck.\n draggingRef.current = false;\n Animated.timing(slide, {\n toValue: 1,\n duration: 220,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n },\n onPanResponderTerminationRequest: () => false,\n });\n }, [slide, screenWidth]);\n\n const openDirect = useCallback(\n async (externalId: string) => {\n const conv = await create({\n type: 'direct',\n member_external_ids: [externalId],\n });\n setActiveId(conv.id);\n },\n [create],\n );\n\n const openGroup = useCallback(\n async (name: string, memberExternalIds: string[]) => {\n const conv = await create({\n type: 'group',\n name,\n member_external_ids: memberExternalIds,\n });\n setActiveId(conv.id);\n },\n [create],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n open: setActiveId,\n openDirect,\n openGroup,\n promptNewChat: () => setUserPickerOpen(true),\n promptNewGroup: () => setGroupPickerOpen(true),\n close: () => setActiveId(null),\n }),\n [openDirect, openGroup],\n );\n\n const renderRow = useCallback(\n (conv: Conversation, selected: boolean) => {\n if (renderConversationRow) {\n return <>{renderConversationRow(conv, meExternalId, selected)}</>;\n }\n // Live unread count from useConversations — updates immediately\n // when markConversationRead fires, instead of waiting for the\n // next list refetch. Falls back to the server snapshot on the\n // conversation row when the live map doesn't have an entry yet.\n const unread = unreadCounts?.[conv.id] ?? conv.unread_count ?? 0;\n return (\n <DefaultConversationRow\n conv={conv}\n selected={selected}\n meExternalId={meExternalId}\n unread={unread}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n onPress={() => setActiveId(conv.id)}\n />\n );\n },\n [renderConversationRow, meExternalId, labelFor, avatarFor, unreadCounts],\n );\n\n return (\n <View style={[styles.root, { backgroundColor: theme.colors.paper }]}>\n {/* LIST PANE */}\n <Animated.View\n style={[StyleSheet.absoluteFillObject, { transform: [{ translateX: listTransform }] }]}\n pointerEvents={activeId ? 'none' : 'auto'}\n >\n <View\n style={[\n styles.listHeader,\n {\n backgroundColor: theme.colors.surface,\n borderBottomColor: theme.colors.border,\n },\n ]}\n >\n <Text\n style={[\n styles.listTitle,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n >\n {title}\n </Text>\n <View style={styles.headerActions}>\n {users ? (\n <>\n <HeaderIconButton\n icon=\"compose\"\n onPress={() => setUserPickerOpen(true)}\n label=\"New chat\"\n />\n <HeaderIconButton\n icon=\"users\"\n onPress={() => setGroupPickerOpen(true)}\n label=\"New group\"\n />\n </>\n ) : null}\n {renderRightAction?.()}\n </View>\n </View>\n\n <ConversationList\n conversations={conversations}\n renderItem={renderRow}\n {...(emptyState !== undefined ? { emptyState } : {})}\n />\n </Animated.View>\n\n {/* DETAIL PANE — our own ChatHeader (with onBack wired) above\n a ConversationView with header={false} so they don't stack.\n PanResponder lives on this wrapper (not a separate overlay\n strip) so taps fall straight through to the back button /\n attachment / send buttons — the strip approach would have\n stolen the leftmost slice of those tap targets. The gate in\n onMoveShouldSetPanResponderCapture restricts gestures to\n the left edge + horizontal-dominant + rightward, so vertical\n scrolling, swipe-to-reply on bubbles (which lives further\n inside), and button taps stay unaffected. */}\n <Animated.View\n style={[StyleSheet.absoluteFillObject, { transform: [{ translateX: detailTransform }] }]}\n pointerEvents={activeId ? 'auto' : 'none'}\n {...panResponder.panHandlers}\n >\n {activeId ? (\n <View style={{ flex: 1 }}>\n <ChatHeader\n conversationId={activeId}\n onBack={() => setActiveId(null)}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n <ConversationView\n key={activeId}\n conversationId={activeId}\n header={false}\n // Caller override wins; else use safe-area-top + our\n // ChatHeader height as the iOS keyboardVerticalOffset.\n keyboardOffset={keyboardOffset || detailKeyboardOffset}\n onMarkedRead={(convId) => {\n // Optimistic local clear so the badge disappears\n // immediately — server-side cursor was advanced\n // by ConversationView's markReadUpTo.\n markConversationRead(convId);\n }}\n onSent={() => {\n // useConversations is per-call-site state — only\n // OUR refetch updates the list's preview / timestamps.\n void refetchConversations();\n }}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n </View>\n ) : null}\n </Animated.View>\n\n {/* Pickers */}\n {users ? (\n <UserPickerSheet\n visible={userPickerOpen}\n onClose={() => setUserPickerOpen(false)}\n users={users}\n excludeIds={meExternalId ? [meExternalId] : []}\n mode=\"single\"\n onPickDirect={(externalId) => {\n void openDirect(externalId);\n }}\n />\n ) : null}\n\n {users ? (\n <UserPickerSheet\n visible={groupPickerOpen}\n onClose={() => setGroupPickerOpen(false)}\n users={users}\n excludeIds={meExternalId ? [meExternalId] : []}\n mode=\"group\"\n onCreateGroup={(name, ids) => {\n void openGroup(name, ids);\n }}\n />\n ) : null}\n </View>\n );\n },\n);\n\nfunction HeaderIconButton({\n icon,\n onPress,\n label,\n}: {\n icon: 'compose' | 'users';\n onPress: () => void;\n label: string;\n}) {\n const theme = usePoolseTheme();\n return (\n <Pressable\n onPress={onPress}\n hitSlop={10}\n accessibilityLabel={label}\n style={({ pressed }) => [\n styles.iconBtn,\n {\n backgroundColor: pressed ? theme.colors.surface2 : 'transparent',\n },\n ]}\n >\n <PoolseIcon name={icon} size={20} color={theme.colors.ink} />\n </Pressable>\n );\n}\n\nfunction DefaultConversationRow({\n conv,\n selected,\n meExternalId,\n unread,\n labelFor,\n avatarFor,\n onPress,\n}: {\n conv: Conversation;\n selected: boolean;\n meExternalId: string | null;\n unread: number;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onPress: () => void;\n}) {\n const theme = usePoolseTheme();\n\n // For directs, derive display from the OTHER member's external_id\n // (added to Conversation.member_external_ids by the backend). For\n // groups, use the conversation's own name + a group avatar tile.\n const isDirect = conv.type === 'direct';\n const otherExtId =\n isDirect && meExternalId\n ? (conv.member_external_ids ?? []).find((x) => x !== meExternalId)\n : null;\n\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n // Inbox rows are typically the first place an avatar / name shows up\n // for a conversation, so the resolver must run here too — not only\n // inside ConversationView's bubbles.\n const resolvedOther = useUser(isDirect ? (otherExtId ?? null) : null);\n const title = isDirect\n ? otherExtId\n ? (labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId)\n : 'Direct chat'\n : (conv.name ?? 'Untitled group');\n\n const avatarUrl =\n isDirect && otherExtId\n ? (avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null)\n : null;\n const avatarSeed = isDirect ? (otherExtId ?? conv.id) : conv.id;\n\n return (\n <Pressable\n onPress={onPress}\n style={[\n styles.row,\n {\n backgroundColor: selected ? theme.colors.surface2 : 'transparent',\n borderBottomColor: theme.colors.border,\n },\n ]}\n >\n {avatarUrl ? (\n <Image source={{ uri: avatarUrl }} style={styles.rowAvatar} />\n ) : (\n <Avatar src={null} name={title} seed={avatarSeed} size=\"md\" />\n )}\n <View style={styles.rowBody}>\n <Text\n style={[styles.rowTitle, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {title}\n </Text>\n <Text style={[styles.rowSubtitle, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {conv.last_message_preview ??\n (isDirect ? (otherExtId ?? '') : `${(conv.member_external_ids ?? []).length} members`)}\n </Text>\n </View>\n {unread > 0 ? (\n <View style={[styles.unreadPill, { backgroundColor: theme.colors.unreadPill }]}>\n <Text style={[styles.unreadText, { color: theme.colors.unreadPillText }]}>\n {unread > 99 ? '99+' : String(unread)}\n </Text>\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n overflow: 'hidden',\n },\n listHeader: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 14,\n paddingVertical: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 12,\n },\n listTitle: {\n flex: 1,\n fontSize: 20,\n fontWeight: '700',\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n iconBtn: {\n width: 36,\n height: 36,\n borderRadius: 18,\n alignItems: 'center',\n justifyContent: 'center',\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 14,\n paddingVertical: 12,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 12,\n },\n rowAvatar: {\n width: 44,\n height: 44,\n borderRadius: 22,\n },\n rowBody: {\n flex: 1,\n gap: 2,\n },\n rowTitle: {\n fontSize: 15,\n fontWeight: '600',\n },\n rowSubtitle: {\n fontSize: 12,\n },\n unreadPill: {\n minWidth: 22,\n height: 22,\n borderRadius: 11,\n paddingHorizontal: 7,\n alignItems: 'center',\n justifyContent: 'center',\n },\n unreadText: {\n fontSize: 11,\n fontWeight: '700',\n },\n});\n","import { Svg, Path, Circle, G } from 'react-native-svg';\n\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\n\nexport type PoolseLogoVariant = 'lockup' | 'mark' | 'wordmark' | 'mono';\n\nexport interface PoolseLogoProps {\n variant?: PoolseLogoVariant;\n /** Height in pixels — width is computed from the variant's aspect ratio. */\n size?: number;\n /** Mono variant accepts a color override; otherwise the theme drives fills. */\n color?: string;\n label?: string | null;\n}\n\nconst TILE_PATH = 'M50 4 C20 4 4 20 4 50 C4 80 20 96 50 96 C80 96 96 80 96 50 C96 20 80 4 50 4 Z';\nconst PULSE_PATH = 'M16 55 H34 L40 55 L47 30 L54 73 L60 55 H72';\nconst WORDMARK_P_PATH =\n 'M62 -169V258V528H194L196 378L214 376Q223 432 246.0 469.0Q269 506 305.5 524.0Q342 542 389 542Q459 542 509.5 508.0Q560 474 587.0 411.0Q614 348 614 260Q614 182 590.5 120.0Q567 58 519.5 22.0Q472 -14 399 -14Q350 -14 316.0 3.5Q282 21 258.5 55.0Q235 89 219 140H200Q206 113 211.0 85.0Q216 57 219.5 31.0Q223 5 223 -19V-169ZM340 113Q373 113 396.5 131.0Q420 149 433.0 182.0Q446 215 446 259Q446 306 432.5 339.5Q419 373 394.0 391.5Q369 410 336 410Q305 410 283.5 396.5Q262 383 248.5 361.5Q235 340 229.0 316.0Q223 292 223 271V249Q223 230 228.0 211.0Q233 192 243.0 174.5Q253 157 267.0 143.0Q281 129 299.5 121.0Q318 113 340 113Z';\nconst WORDMARK_O_PATH =\n 'M305 -14Q225 -14 163.5 17.0Q102 48 67.0 110.0Q32 172 32 265Q32 358 67.0 419.5Q102 481 164.0 511.5Q226 542 306 542Q386 542 448.0 511.0Q510 480 545.0 418.5Q580 357 580 264Q580 169 544.0 107.0Q508 45 445.5 15.5Q383 -14 305 -14ZM310 103Q346 103 370.0 119.5Q394 136 406.0 170.0Q418 204 418 254Q418 307 405.0 343.5Q392 380 366.5 399.5Q341 419 301 419Q267 419 242.5 402.5Q218 386 206.0 352.0Q194 318 194 267Q194 185 224.5 144.0Q255 103 310 103Z';\nconst WORDMARK_L_PATH = 'M62 0V720H220V0Z';\nconst WORDMARK_S_PATH =\n 'M278 -14Q225 -14 182.0 -4.5Q139 5 107.0 23.0Q75 41 54.5 66.5Q34 92 26 123L146 176Q153 159 170.5 141.5Q188 124 217.5 113.0Q247 102 289 102Q329 102 351.5 113.5Q374 125 374 147Q374 163 361.5 172.5Q349 182 324.0 189.5Q299 197 262 204Q224 212 185.0 222.5Q146 233 112.0 251.5Q78 270 57.5 300.5Q37 331 37 378Q37 427 63.0 463.5Q89 500 140.5 521.0Q192 542 266 542Q332 542 382.0 525.0Q432 508 465.5 476.5Q499 445 512 401L383 355Q378 377 362.5 393.0Q347 409 323.5 417.5Q300 426 268 426Q229 426 207.5 414.0Q186 402 186 382Q186 366 200.5 355.5Q215 345 242.0 338.0Q269 331 306 323Q345 315 383.5 304.5Q422 294 453.5 276.5Q485 259 503.5 230.5Q522 202 522 157Q522 104 494.0 65.5Q466 27 411.5 6.5Q357 -14 278 -14Z';\nconst WORDMARK_E_PATH =\n 'M313 -14Q247 -14 195.0 3.5Q143 21 106.5 55.0Q70 89 51.0 139.0Q32 189 32 254Q32 317 50.5 370.0Q69 423 103.5 461.5Q138 500 188.5 521.0Q239 542 302 542Q366 542 414.5 521.5Q463 501 494.5 461.0Q526 421 541.0 363.5Q556 306 551 232L138 229V313L459 316L402 277Q409 327 396.0 358.5Q383 390 358.0 404.5Q333 419 304 419Q269 419 242.5 400.0Q216 381 201.0 345.0Q186 309 186 257Q186 175 221.5 138.0Q257 101 312 101Q339 101 357.0 108.5Q375 116 386.5 127.5Q398 139 404.5 153.0Q411 167 415 180L555 150Q547 113 529.5 83.0Q512 53 482.5 31.0Q453 9 411.5 -2.5Q370 -14 313 -14Z';\n\nconst VARIANT_VB: Record<\n PoolseLogoVariant,\n { vb: [number, number, number, number]; aspect: number }\n> = {\n lockup: { vb: [0, 0, 454, 100], aspect: 4.54 },\n mark: { vb: [0, 0, 100, 100], aspect: 1 },\n wordmark: { vb: [0, 0, 350, 100], aspect: 3.5 },\n mono: { vb: [0, 0, 454, 100], aspect: 4.54 },\n};\n\nexport function PoolseLogo({ variant = 'lockup', size = 28, color, label }: PoolseLogoProps) {\n const theme = usePoolseTheme();\n const mono = variant === 'mono';\n const monoColor = color ?? theme.colors.ink;\n\n const tileFill = mono ? 'none' : theme.colors.brand;\n const tileStroke = mono ? monoColor : 'transparent';\n const tileStrokeWidth = mono ? 5 : 0;\n const pulseStroke = mono ? monoColor : theme.colors.onBrand;\n const pulseDotFill = mono ? monoColor : theme.colors.onBrand;\n const inkFill = mono ? monoColor : theme.colors.ink;\n const oFill = mono ? monoColor : theme.colors.brand;\n\n const { vb, aspect } = VARIANT_VB[variant];\n const width = size * aspect;\n const showMark = variant === 'lockup' || variant === 'mark' || variant === 'mono';\n const showWordmark = variant === 'lockup' || variant === 'wordmark' || variant === 'mono';\n const wordmarkOffsetX = variant === 'wordmark' ? 0 : 126;\n\n const a11y = label === null ? {} : { accessibilityLabel: label ?? 'poolse' };\n return (\n <Svg viewBox={vb.join(' ')} width={width} height={size} {...a11y}>\n {showMark ? (\n <>\n <Path d={TILE_PATH} fill={tileFill} stroke={tileStroke} strokeWidth={tileStrokeWidth} />\n <Path\n d={PULSE_PATH}\n fill=\"none\"\n stroke={pulseStroke}\n strokeWidth={9}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <Circle cx={72} cy={55} r={6.2} fill={pulseDotFill} />\n </>\n ) : null}\n {showWordmark ? (\n <G transform={`translate(${wordmarkOffsetX},85.0) scale(0.097222 -0.097222)`}>\n <Path d={WORDMARK_P_PATH} fill={inkFill} transform=\"translate(0,0)\" />\n <Path d={WORDMARK_O_PATH} fill={oFill} transform=\"translate(658,0)\" />\n <Path d={WORDMARK_O_PATH} fill={oFill} transform=\"translate(1280,0)\" />\n <Path d={WORDMARK_L_PATH} fill={inkFill} transform=\"translate(1902,0)\" />\n <Path d={WORDMARK_S_PATH} fill={inkFill} transform=\"translate(2195,0)\" />\n <Path d={WORDMARK_E_PATH} fill={inkFill} transform=\"translate(2754,0)\" />\n </G>\n ) : null}\n </Svg>\n );\n}\n","export { PoolseIcon, type PoolseIconProps, type IconName } from './PoolseIcon.js';\nexport { PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant } from './PoolseLogo.js';\nexport { Avatar, type AvatarProps } from './Avatar.js';\nexport { userColor } from './userColor.js';\n\n// Re-exported as a namespace for the public API surface.\nimport { PoolseIcon } from './PoolseIcon.js';\nimport { PoolseLogo } from './PoolseLogo.js';\nimport { Avatar } from './Avatar.js';\n\nexport const primitives = { PoolseIcon, PoolseLogo, Avatar };\n","import { useEffect } from 'react';\nimport { AppState, type AppStateStatus } from 'react-native';\nimport { usePoolse } from '@poolse/react';\n\n/**\n * Closes the SDK WebSocket cleanly when the app backgrounds and\n * reopens it when the app comes back to the foreground. Designed\n * to pair with push-notification delivery on the dev's backend —\n * iOS / Android suspend sockets aggressively, so we don't fight\n * the OS; we let the push wake the app and resync on resume.\n *\n * Mount once near the root of your app:\n *\n * <PoolseProvider config={config}>\n * <AppShell />\n * </PoolseProvider>\n *\n * function AppShell() {\n * useAppStateLifecycle();\n * return ...;\n * }\n */\nexport function useAppStateLifecycle() {\n const poolse = usePoolse();\n\n useEffect(() => {\n let prev: AppStateStatus = AppState.currentState;\n const sub = AppState.addEventListener('change', (next) => {\n const wasActive = prev === 'active';\n const isActive = next === 'active';\n\n if (wasActive && !isActive) {\n // Going to background — close the WS cleanly. The SDK's\n // realtime layer reopens lazily on the next subscription\n // call, so there's nothing to clean up state-side.\n try {\n poolse.realtime?.disconnect?.();\n } catch {\n // Older SDK builds may not expose disconnect; harmless.\n }\n } else if (!wasActive && isActive) {\n // Returning to foreground — the next hook render that\n // touches `realtime.conversation(...)` will reopen the\n // socket. `useMessages`/`useTyping`/`usePresence` all\n // refetch their starting snapshot on remount, so the active\n // conversation lands fresh.\n try {\n poolse.realtime?.connect?.();\n } catch {\n // Same compat note as above.\n }\n }\n\n prev = next;\n });\n\n return () => sub.remove();\n }, [poolse]);\n}\n","/**\n * React Native WebRTC binding, backed by `react-native-webrtc`.\n *\n * The module is passed IN rather than required here, and that is\n * deliberate. Metro resolves dependencies statically, and this package\n * is published through tsup, which rewrites a literal `require(...)`\n * into a `__require(...)` call it cannot see — so bundling\n * `react-native-webrtc` from inside this file never worked. It wasn't\n * merely unavailable in Expo Go; it was absent from every bundle,\n * development builds included, and surfaced as\n * \"Requiring unknown module react-native-webrtc\" at runtime.\n *\n * Importing it in the app fixes that: Metro sees a static import in\n * your source and bundles it. Optionality then lives where it belongs —\n * an app that doesn't want voice simply never imports it, and never\n * installs the native dependency.\n *\n * import * as webrtc from 'react-native-webrtc';\n * <VoiceRoomBar conversationId={id} webrtc={webrtc} />\n *\n * Media streams on native aren't attached to an element the way they\n * are on the web — audio-only calls route to the device's audio session\n * once the peer connection is live, so the sink is a no-op. Video would\n * render the stream through `<RTCView>` via the `toURL()` it exposes.\n */\n\nimport type { VoiceIceServer, VoicePeerConnection, VoiceStream, WebRtcAdapter } from '@poolse/sdk';\n\n/**\n * The shape this binding needs from `react-native-webrtc`. The module's\n * own namespace satisfies it, so `import * as webrtc` type-checks\n * straight through.\n */\nexport interface NativeWebRtcModule {\n RTCPeerConnection: new (...args: never[]) => unknown;\n mediaDevices: { getUserMedia: (...args: never[]) => Promise<unknown> };\n}\n\n/**\n * The precise shape, used internally once the module has been checked.\n *\n * `NativeWebRtcModule` above is deliberately loose. Spelling the real\n * signatures out there does NOT work: `react-native-webrtc` types `sdp`\n * as `string` where the SDK's `VoiceDescription` has `string | undefined`,\n * so `import * as webrtc` fails to satisfy a strict interface and no\n * consumer can pass the module in at all.\n */\ninterface CheckedWebRtc {\n RTCPeerConnection: new (config: { iceServers: VoiceIceServer[] }) => VoicePeerConnection;\n mediaDevices: {\n getUserMedia(constraints: {\n audio: boolean | Record<string, unknown>;\n video: boolean;\n }): Promise<VoiceStream>;\n };\n}\n\n/**\n * True when `mod` looks like a usable `react-native-webrtc`.\n *\n * Guards against a half-linked native module: in a bare Expo Go client\n * the JS may load while the native side is missing, leaving\n * `RTCPeerConnection` undefined.\n */\nexport function isNativeWebRtcAvailable(mod: NativeWebRtcModule | null | undefined): boolean {\n return typeof mod?.RTCPeerConnection === 'function' && mod?.mediaDevices != null;\n}\n\n/**\n * Adapter for `useVoiceRoom`'s `webrtc` option.\n *\n * @param mod the `react-native-webrtc` module, imported by your app.\n * @throws when `mod` isn't a usable binding — check\n * {@link isNativeWebRtcAvailable} first if that's reachable in\n * your UI.\n */\nexport function createNativeWebRtcAdapter(mod: NativeWebRtcModule): WebRtcAdapter {\n if (!isNativeWebRtcAvailable(mod)) {\n throw new Error(\n 'react-native-webrtc is missing or not linked. Install it and rebuild:\\n' +\n ' npx expo install react-native-webrtc\\n' +\n 'It contains native code, so it needs a development build — it will not run in Expo Go.',\n );\n }\n\n // Narrow once, here, rather than making every caller's module match\n // signature-for-signature.\n const rtc = mod as unknown as CheckedWebRtc;\n\n return {\n createPeerConnection(iceServers: VoiceIceServer[]): VoicePeerConnection {\n return new rtc.RTCPeerConnection({ iceServers });\n },\n\n getUserMedia(): Promise<VoiceStream> {\n return rtc.mediaDevices.getUserMedia({\n audio: { echoCancellation: true, noiseSuppression: true },\n video: false,\n });\n },\n\n playRemoteStream(): () => void {\n // Audio-only: the native audio session plays the remote track as\n // soon as it connects, so there's no sink to create or clean up.\n return () => {};\n },\n };\n}\n","import { useVoiceRoom } from '@poolse/react';\nimport type { VoiceParticipant, VoiceStatus } from '@poolse/sdk';\nimport { useEffect, useMemo } from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\nimport {\n createNativeWebRtcAdapter,\n isNativeWebRtcAvailable,\n type NativeWebRtcModule,\n} from './voice/webrtc-native.js';\n\nexport interface VoiceRoomBarProps {\n conversationId: string;\n /**\n * The `react-native-webrtc` module, imported by your app:\n *\n * import * as webrtc from 'react-native-webrtc';\n *\n * Required for audio. Metro only bundles what it can see statically,\n * so this package cannot import it for you — see `voice/webrtc-native`.\n * Omit it and the bar renders its unavailable state, which is what you\n * want in Expo Go.\n */\n webrtc?: NativeWebRtcModule | null;\n /**\n * Called whenever the room's connection state changes.\n *\n * Audio routing is the app's job — speakerphone, the proximity sensor\n * that blanks the screen at your ear, and holding the audio session\n * open all need a native module this package deliberately doesn't\n * depend on. Use this to start and stop it.\n */\n onStatusChange?: (status: VoiceStatus) => void;\n /** Resolves a user id to a display label. Defaults to a short id. */\n labelFor?: (userId: string) => string;\n /**\n * Rendered instead of the join button when `react-native-webrtc`\n * isn't installed. Defaults to an inline explanation.\n */\n unavailableSlot?: React.ReactNode;\n}\n\n/**\n * Discord-style voice bar: one \"Join Voice\" button that expands into a\n * roster of who's in, with a ring around whoever is talking.\n *\n * Drop it above a `<ConversationView>` to give a conversation an\n * always-on voice channel. For ringing a specific person, use\n * `<IncomingCallSheet>` together with `useCalls`.\n */\nexport function VoiceRoomBar({\n conversationId,\n labelFor,\n unavailableSlot,\n webrtc,\n onStatusChange,\n}: VoiceRoomBarProps) {\n const theme = usePoolseTheme();\n const available = isNativeWebRtcAvailable(webrtc);\n\n // Building the adapter throws when the module is missing or unlinked,\n // so only construct it on the path where we know it resolves.\n const opts = useMemo(\n () => (available && webrtc ? { webrtc: createNativeWebRtcAdapter(webrtc) } : {}),\n [available, webrtc],\n );\n\n const { status, participants, muted, join, leave, toggleMute, error } = useVoiceRoom(\n available ? conversationId : null,\n opts,\n );\n\n useEffect(() => {\n onStatusChange?.(status);\n }, [status, onStatusChange]);\n\n const label = labelFor ?? ((id: string) => `User ${id.slice(0, 6)}`);\n const connected = status === 'connected';\n\n if (!available) {\n return (\n <View\n style={[\n styles.bar,\n { backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.border },\n ]}\n >\n {unavailableSlot ?? (\n <Text style={[styles.hint, { color: theme.colors.ink3 }]}>\n Voice needs react-native-webrtc and a development build.\n </Text>\n )}\n </View>\n );\n }\n\n return (\n <View\n style={[\n styles.bar,\n { backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.border },\n ]}\n >\n <View style={styles.row}>\n <View\n style={[\n styles.dot,\n { backgroundColor: connected ? theme.colors.brand : theme.colors.ink3 },\n ]}\n />\n\n {connected ? (\n <>\n <View style={styles.people}>\n {participants.length === 0 ? (\n <Text style={[styles.hint, { color: theme.colors.ink3 }]}>Waiting for others…</Text>\n ) : (\n participants.map((p) => (\n <ParticipantChip key={p.userId} participant={p} label={label(p.userId)} />\n ))\n )}\n </View>\n\n <Pressable\n onPress={toggleMute}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: muted }}\n style={[\n styles.btn,\n {\n borderColor: muted ? theme.colors.brand : theme.colors.border,\n backgroundColor: muted ? theme.colors.brandSoft : theme.colors.paper,\n },\n ]}\n >\n <Text style={{ color: theme.colors.ink2 }}>{muted ? 'Unmute' : 'Mute'}</Text>\n </Pressable>\n\n <Pressable\n onPress={leave}\n accessibilityRole=\"button\"\n style={[styles.btn, { borderColor: theme.colors.error }]}\n >\n <Text style={{ color: theme.colors.error }}>Leave</Text>\n </Pressable>\n </>\n ) : (\n <>\n <Text style={[styles.hint, { color: theme.colors.ink3 }]}>\n {status === 'connecting' ? 'Connecting…' : 'Talk to everyone here'}\n </Text>\n <Pressable\n onPress={() => void join()}\n disabled={status === 'connecting'}\n accessibilityRole=\"button\"\n style={[styles.btn, styles.btnPrimary, { backgroundColor: theme.colors.brand }]}\n >\n <Text style={{ color: theme.colors.onBrand, fontWeight: '600' }}>\n {status === 'connecting' ? 'Joining…' : 'Join Voice'}\n </Text>\n </Pressable>\n </>\n )}\n </View>\n\n {error && <Text style={[styles.error, { color: theme.colors.error }]}>{error.message}</Text>}\n </View>\n );\n}\n\nfunction ParticipantChip({ participant, label }: { participant: VoiceParticipant; label: string }) {\n const theme = usePoolseTheme();\n return (\n <View\n style={[\n styles.chip,\n {\n backgroundColor: theme.colors.paper,\n // The speaking ring is a border colour swap rather than an\n // extra element, so the row never reflows mid-sentence.\n borderColor: participant.speaking ? theme.colors.brand : theme.colors.border,\n opacity: participant.muted ? 0.62 : 1,\n },\n ]}\n >\n <Text style={{ color: theme.colors.ink2, fontSize: 13 }} numberOfLines={1}>\n {label}\n {participant.isSelf ? ' (you)' : ''}\n </Text>\n {participant.muted && (\n <Text style={{ color: theme.colors.error, fontSize: 11, fontWeight: '700' }}>✕</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n bar: { paddingHorizontal: 14, paddingVertical: 8, borderBottomWidth: StyleSheet.hairlineWidth },\n row: { flexDirection: 'row', alignItems: 'center', gap: 8, flexWrap: 'wrap' },\n dot: { width: 8, height: 8, borderRadius: 4 },\n people: { flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1, flexWrap: 'wrap' },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n paddingHorizontal: 10,\n paddingVertical: 4,\n borderRadius: 999,\n borderWidth: 1,\n },\n btn: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 999, borderWidth: 1 },\n btnPrimary: { borderWidth: 0 },\n hint: { fontSize: 13, flexShrink: 1 },\n error: { fontSize: 12, marginTop: 6 },\n});\n","/**\n * The call surface's own palette.\n *\n * Deliberately NOT the app theme. Every serious calling app — phone,\n * FaceTime, WhatsApp, Meet — renders calls dark regardless of the rest\n * of the UI, for three reasons that all apply here:\n *\n * * video is the content, and a light chrome around it washes the\n * picture out,\n * * a call screen is the one surface that routinely opens at 3am,\n * * it takes over the whole screen, so it reads as a mode change\n * rather than as a screen that has lost the app's styling.\n *\n * The brand still shows up — in the accept button and the speaking\n * ring — it just doesn't set the background.\n */\nexport const callColors = {\n /** Behind everything. Near-black, warmed very slightly to match the brand. */\n bg: '#101012',\n /** Behind a participant tile with no video. */\n tile: '#1c1c20',\n /** Scrim under the top/bottom chrome so text stays legible over video. */\n scrim: 'rgba(0,0,0,0.45)',\n\n text: '#ffffff',\n textDim: 'rgba(255,255,255,0.72)',\n textFaint: 'rgba(255,255,255,0.5)',\n\n /** A control that is off / inactive — translucent over whatever is behind. */\n control: 'rgba(255,255,255,0.16)',\n /**\n * A control that is ENGAGED (muted, speaker on, camera off).\n *\n * Inverted rather than tinted: at a glance the user needs to see\n * *which* controls are doing something, and a solid white circle is\n * unmistakable against five translucent ones in a dim room.\n */\n controlActive: '#ffffff',\n controlActiveIcon: '#101012',\n\n danger: '#ef4444',\n accept: '#22c55e',\n onAction: '#ffffff',\n} as const;\n\n/** Control button diameters. Hang-up is bigger; it is the one you reach for. */\nexport const CONTROL_SIZE = 58;\nexport const CONTROL_SIZE_LARGE = 68;\n","import { Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon, type IconName } from '../primitives/PoolseIcon.js';\nimport { callColors } from './callTheme.js';\nimport type { AudioRoute, AudioRouteKind } from './livekit-rn.js';\n\nexport interface AudioRouteSheetProps {\n visible: boolean;\n routes: AudioRoute[];\n /** Platform id of the chosen route, or null while routing is automatic. */\n selectedRouteId: string | null;\n onSelect: (id: string) => void;\n onClose: () => void;\n}\n\nconst ICONS: Record<AudioRouteKind, IconName> = {\n speaker: 'speaker',\n earpiece: 'phone',\n headset: 'headphones',\n bluetooth: 'bluetooth',\n auto: 'phone',\n};\n\n/**\n * Pick where call audio comes out.\n *\n * Only worth showing when there is a real choice — on iOS there are\n * exactly two entries and the system's own picker covers everything\n * else, so `CallScreen` opens that instead. This is the Android\n * surface, where LiveKit enumerates the actual devices.\n */\nexport function AudioRouteSheet({\n visible,\n routes,\n selectedRouteId,\n onSelect,\n onClose,\n}: AudioRouteSheetProps) {\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={onClose}>\n {/* Tapping away closes it, which is what a sheet like this owes\n anyone who opened it by accident mid-call. */}\n <Pressable style={styles.backdrop} onPress={onClose} accessibilityRole=\"button\">\n <Pressable style={styles.sheet} onPress={() => {}}>\n <View style={styles.grabber} />\n <Text style={styles.title}>Audio output</Text>\n\n {routes.map((route) => {\n const selected = route.id === selectedRouteId;\n return (\n <Pressable\n key={route.id}\n onPress={() => {\n onSelect(route.id);\n onClose();\n }}\n accessibilityRole=\"button\"\n accessibilityState={{ selected }}\n style={({ pressed }) => [styles.row, pressed && styles.rowPressed]}\n >\n <PoolseIcon\n name={ICONS[route.kind]}\n size={21}\n color={selected ? callColors.accept : callColors.text}\n label={null}\n />\n <Text style={[styles.label, selected && styles.labelSelected]}>{route.label}</Text>\n {selected && (\n <PoolseIcon name=\"check\" size={19} color={callColors.accept} label=\"selected\" />\n )}\n </Pressable>\n );\n })}\n </Pressable>\n </Pressable>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: { flex: 1, backgroundColor: 'rgba(0,0,0,0.55)', justifyContent: 'flex-end' },\n sheet: {\n backgroundColor: callColors.tile,\n borderTopLeftRadius: 22,\n borderTopRightRadius: 22,\n paddingHorizontal: 12,\n paddingTop: 10,\n paddingBottom: 34,\n gap: 2,\n },\n grabber: {\n alignSelf: 'center',\n width: 38,\n height: 4,\n borderRadius: 2,\n backgroundColor: callColors.textFaint,\n marginBottom: 12,\n },\n title: {\n color: callColors.textDim,\n fontSize: 12.5,\n fontWeight: '600',\n textTransform: 'uppercase',\n letterSpacing: 0.6,\n paddingHorizontal: 12,\n paddingBottom: 8,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 14,\n paddingHorizontal: 12,\n paddingVertical: 15,\n borderRadius: 14,\n },\n rowPressed: { backgroundColor: 'rgba(255,255,255,0.08)' },\n label: { flex: 1, color: callColors.text, fontSize: 16, fontWeight: '500' },\n labelSelected: { color: callColors.accept },\n});\n","import { StyleSheet, Text, View } from 'react-native';\n\nimport { userColor } from '../primitives/userColor.js';\nimport { callColors } from './callTheme.js';\n\nexport interface CallAvatarProps {\n /** Display name; the first letters become the initials. */\n name: string;\n /** Stable colour seed — the poolse user id. */\n seed: string;\n size: number;\n /** Draw the active-speaker ring. */\n speaking?: boolean;\n}\n\n/**\n * The stand-in for a face when a camera is off.\n *\n * Separate from `<Avatar>` rather than a size variant of it: this one\n * scales to a third of the screen, carries the speaking ring, and lives\n * on a dark surface, none of which the list avatar wants.\n *\n * The ring sits OUTSIDE the circle, drawn as a border on a larger box.\n * Growing the avatar itself to show speaking would make everything jump\n * every time somebody starts talking.\n */\nexport function CallAvatar({ name, seed, size, speaking = false }: CallAvatarProps) {\n const ring = Math.max(2, Math.round(size * 0.045));\n const outer = size + ring * 4;\n\n return (\n <View\n style={[\n styles.ring,\n {\n width: outer,\n height: outer,\n borderRadius: outer / 2,\n borderWidth: ring,\n borderColor: speaking ? callColors.accept : 'transparent',\n },\n ]}\n >\n <View\n style={[\n styles.circle,\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor: userColor(seed),\n },\n ]}\n >\n <Text\n style={[styles.initials, { fontSize: Math.round(size * 0.38) }]}\n numberOfLines={1}\n allowFontScaling={false}\n >\n {initialsOf(name)}\n </Text>\n </View>\n </View>\n );\n}\n\n/** Up to two initials, matching how the rest of the SDK derives them. */\nfunction initialsOf(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return '?';\n if (parts.length === 1) return parts[0]!.slice(0, 2).toUpperCase();\n return (parts[0]![0]! + parts[parts.length - 1]![0]!).toUpperCase();\n}\n\nconst styles = StyleSheet.create({\n ring: { alignItems: 'center', justifyContent: 'center' },\n circle: { alignItems: 'center', justifyContent: 'center' },\n initials: { color: '#ffffff', fontWeight: '600' },\n});\n","import { Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon, type IconName } from '../primitives/PoolseIcon.js';\nimport { CONTROL_SIZE, CONTROL_SIZE_LARGE, callColors } from './callTheme.js';\n\nexport interface CallControlButtonProps {\n icon: IconName;\n /** Shown under the button. Omit for the hang-up / answer buttons. */\n label?: string | undefined;\n /**\n * The control is doing something — muted, speaker forced on, camera\n * off. Inverts the button so engaged controls are readable at a\n * glance.\n */\n active?: boolean;\n /** Paints the button a solid colour: the hang-up and answer actions. */\n tone?: 'neutral' | 'danger' | 'accept';\n large?: boolean;\n disabled?: boolean;\n onPress: () => void;\n /**\n * Spoken description. Defaults to `label`, but a toggle needs to say\n * what pressing it will DO, which is rarely what the label says —\n * \"Mute\" under a button that unmutes is exactly backwards for anyone\n * using a screen reader.\n */\n accessibilityLabel?: string | undefined;\n}\n\n/**\n * One round call control.\n *\n * Fixed diameter and a caption underneath, so a row of them lines up on\n * a grid regardless of label length — the thing that makes a control\n * bar look built rather than assembled.\n */\nexport function CallControlButton({\n icon,\n label,\n active = false,\n tone = 'neutral',\n large = false,\n disabled = false,\n onPress,\n accessibilityLabel,\n}: CallControlButtonProps) {\n const size = large ? CONTROL_SIZE_LARGE : CONTROL_SIZE;\n\n const background =\n tone === 'danger'\n ? callColors.danger\n : tone === 'accept'\n ? callColors.accept\n : active\n ? callColors.controlActive\n : callColors.control;\n\n const iconColor =\n tone === 'neutral' && active ? callColors.controlActiveIcon : callColors.onAction;\n\n return (\n <View style={styles.slot}>\n <Pressable\n onPress={onPress}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityState={{ disabled, selected: active }}\n accessibilityLabel={accessibilityLabel ?? label ?? icon}\n hitSlop={8}\n style={({ pressed }) => [\n styles.button,\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor: background,\n // Feedback without a layout shift — scaling a round button\n // inside a fixed slot keeps the row from twitching.\n opacity: disabled ? 0.4 : pressed ? 0.75 : 1,\n },\n ]}\n >\n <PoolseIcon name={icon} size={large ? 30 : 25} color={iconColor} label={null} />\n </Pressable>\n {label ? (\n <Text numberOfLines={1} style={styles.label}>\n {label}\n </Text>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n // Fixed width so captions of different lengths cannot shift the row.\n slot: { width: 76, alignItems: 'center', gap: 7 },\n button: { alignItems: 'center', justifyContent: 'center' },\n label: { color: callColors.textDim, fontSize: 11.5, fontWeight: '500' },\n});\n","import type { CallParticipant } from '@poolse/sdk';\nimport { StyleSheet, Text, View, type ViewStyle } from 'react-native';\n\nimport { PoolseIcon } from '../primitives/PoolseIcon.js';\nimport { CallAvatar } from './CallAvatar.js';\nimport { callColors } from './callTheme.js';\nimport type { CheckedVideoTrack } from './livekit-rn.js';\n\nexport interface CallParticipantTileProps {\n participant: CallParticipant;\n /** Narrowed `@livekit/react-native` VideoTrack, when the app supplied it. */\n VideoTrack?: CheckedVideoTrack | undefined;\n label: (userId: string) => string;\n style?: ViewStyle | ViewStyle[];\n /** Avatar diameter when the camera is off. */\n avatarSize?: number;\n /** Full-bleed tiles drop their rounding and their name chip shrinks. */\n bleed?: boolean;\n /** Hide the name chip — the spotlight draws identity in the header. */\n hideName?: boolean;\n}\n\n/**\n * One person on the call: their video, or their avatar when the camera\n * is off.\n *\n * A camera-off participant still gets a tile. Dropping them would make\n * a five-person call with four cameras off look like a one-person call,\n * and hide the fact that they are there and can hear you.\n */\nexport function CallParticipantTile({\n participant,\n VideoTrack,\n label,\n style,\n avatarSize = 72,\n bleed = false,\n hideName = false,\n}: CallParticipantTileProps) {\n const name = participant.isSelf ? 'You' : (participant.name ?? label(participant.userId));\n const hasVideo = Boolean(participant.videoTrackRef && VideoTrack);\n\n return (\n <View\n style={[\n styles.tile,\n bleed ? styles.bleed : styles.rounded,\n {\n backgroundColor: callColors.tile,\n // A ring rather than a badge: it reads at a glance across a\n // grid, and it doesn't cover anyone's face.\n borderColor: participant.speaking ? callColors.accept : 'transparent',\n },\n style as ViewStyle,\n ]}\n >\n {hasVideo && VideoTrack ? (\n <VideoTrack\n trackRef={participant.videoTrackRef}\n style={StyleSheet.absoluteFillObject as ViewStyle}\n objectFit=\"cover\"\n // Only your own preview is mirrored. Mirroring a remote feed\n // would flip their text and reverse which hand they wave with.\n mirror={participant.isSelf}\n zOrder={participant.isSelf ? 1 : 0}\n />\n ) : (\n <View style={styles.placeholder}>\n <CallAvatar\n name={name}\n seed={participant.userId}\n size={avatarSize}\n speaking={participant.speaking}\n />\n </View>\n )}\n\n {!hideName && (\n <View style={[styles.chip, bleed ? styles.chipBleed : styles.chipTile]}>\n {!participant.micEnabled && (\n // Worth showing even for yourself — it is the answer to\n // \"why can nobody hear me\".\n <PoolseIcon name=\"mic-off\" size={13} color={callColors.text} label=\"muted\" />\n )}\n <Text numberOfLines={1} style={styles.name}>\n {name}\n </Text>\n </View>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n tile: { overflow: 'hidden', justifyContent: 'flex-end', borderWidth: 2 },\n rounded: { borderRadius: 18 },\n bleed: { borderRadius: 0, borderWidth: 0 },\n placeholder: { ...StyleSheet.absoluteFillObject, alignItems: 'center', justifyContent: 'center' },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n alignSelf: 'flex-start',\n borderRadius: 999,\n // Legible over both a bright video frame and a flat placeholder.\n backgroundColor: 'rgba(0,0,0,0.55)',\n },\n chipTile: { margin: 8, paddingHorizontal: 9, paddingVertical: 4.5, maxWidth: '92%' },\n chipBleed: { margin: 14, paddingHorizontal: 11, paddingVertical: 6, maxWidth: '80%' },\n name: { color: callColors.text, fontSize: 12.5, fontWeight: '600', flexShrink: 1 },\n});\n","import type { CallParticipant } from '@poolse/sdk';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { Animated, PanResponder, Pressable, StyleSheet, View, type ViewStyle } from 'react-native';\n\nimport { CallParticipantTile } from './CallParticipantTile.js';\nimport type { CheckedVideoTrack } from './livekit-rn.js';\n\nexport interface LocalVideoPipProps {\n participant: CallParticipant;\n VideoTrack?: CheckedVideoTrack | undefined;\n label: (userId: string) => string;\n /** Area the tile may be dragged within, in pixels. */\n bounds: { width: number; height: number };\n /**\n * Safe-area insets. The tile hugs the edges just inside these, so it\n * clears the notch and the home indicator and nothing else.\n */\n insets?: { top: number; bottom: number };\n /** Tap handler. Wired to the camera flip, matching every other call app. */\n onPress?: (() => void) | undefined;\n}\n\nconst PIP_WIDTH = 108;\nconst PIP_HEIGHT = 152;\nconst MARGIN = 12;\n\n/**\n * The local camera preview, floating over the remote video.\n *\n * Draggable, and it snaps to the nearest corner on release rather than\n * staying wherever the finger stopped. Free positioning sounds more\n * flexible but reads as broken: a tile left at a slight angle to the\n * edge looks dropped rather than placed, and it is the corners people\n * actually want — they move it to uncover a face.\n *\n * Built on `Animated` + `PanResponder` from React Native itself. A\n * gesture library would be smoother, but it would be a new native\n * dependency for every app that installs this SDK, and a call preview\n * is not worth that.\n */\nexport function LocalVideoPip({\n participant,\n VideoTrack,\n label,\n bounds,\n insets,\n onPress,\n}: LocalVideoPipProps) {\n const top = insets?.top ?? 0;\n const bottom = insets?.bottom ?? 0;\n\n // Corner anchors, recomputed when the screen or the chrome changes\n // (rotation, a control bar appearing).\n const corners = useMemo(() => {\n const right = Math.max(MARGIN, bounds.width - PIP_WIDTH - MARGIN);\n const low = Math.max(MARGIN, bounds.height - PIP_HEIGHT - bottom - MARGIN);\n const high = top + MARGIN;\n return [\n { x: MARGIN, y: high },\n { x: right, y: high },\n { x: MARGIN, y: low },\n { x: right, y: low },\n ];\n }, [bounds.width, bounds.height, top, bottom]);\n\n // Top-right to start: it is the corner least likely to cover a face,\n // which sits centre-frame, and it stays clear of the control bar.\n const [corner, setCorner] = useState(1);\n const pan = useRef(new Animated.ValueXY(corners[1]!)).current;\n\n // Read inside the responder without re-creating it — rebuilding the\n // PanResponder mid-gesture drops the drag.\n const cornersRef = useRef(corners);\n cornersRef.current = corners;\n const cornerRef = useRef(corner);\n cornerRef.current = corner;\n const dragged = useRef(false);\n\n // Follow the corners when the stage itself changes — a rotation, or\n // the control bar appearing. Without this the tile keeps the pixel\n // position it had under the old bounds, which after a rotation can be\n // most of the way off screen.\n useEffect(() => {\n if (dragged.current) return;\n const at = corners[corner];\n if (at) pan.setValue(at);\n }, [corners, corner, pan]);\n\n const responder = useMemo(\n () =>\n PanResponder.create({\n // Claim the gesture only once it is clearly a drag. A lower\n // threshold would swallow the taps that flip the camera.\n onMoveShouldSetPanResponder: (_evt, g) => Math.abs(g.dx) > 4 || Math.abs(g.dy) > 4,\n onPanResponderGrant: () => {\n dragged.current = true;\n const at = cornersRef.current[cornerRef.current] ?? cornersRef.current[1]!;\n pan.setOffset({ x: at.x, y: at.y });\n pan.setValue({ x: 0, y: 0 });\n },\n onPanResponderMove: Animated.event([null, { dx: pan.x, dy: pan.y }], {\n useNativeDriver: false,\n }),\n onPanResponderRelease: (_evt, g) => {\n pan.flattenOffset();\n const at = cornersRef.current[cornerRef.current] ?? cornersRef.current[1]!;\n const dropped = { x: at.x + g.dx, y: at.y + g.dy };\n\n // Nearest corner by centre-to-centre distance.\n let best = 0;\n let bestDistance = Number.POSITIVE_INFINITY;\n cornersRef.current.forEach((c, index) => {\n const distance = (c.x - dropped.x) ** 2 + (c.y - dropped.y) ** 2;\n if (distance < bestDistance) {\n bestDistance = distance;\n best = index;\n }\n });\n\n setCorner(best);\n Animated.spring(pan, {\n toValue: cornersRef.current[best]!,\n useNativeDriver: false,\n friction: 8,\n tension: 70,\n }).start(() => {\n dragged.current = false;\n });\n },\n }),\n [pan],\n );\n\n return (\n <Animated.View\n {...responder.panHandlers}\n style={[styles.pip, { transform: pan.getTranslateTransform() }]}\n >\n <Pressable\n // Swallowed if the finger moved: releasing a drag over the tile\n // must not also flip the camera.\n onPress={() => {\n if (dragged.current) return;\n onPress?.();\n }}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Your camera. Drag to move, tap to switch camera.\"\n style={styles.fill}\n >\n <View style={styles.fill}>\n <CallParticipantTile\n participant={participant}\n VideoTrack={VideoTrack}\n label={label}\n avatarSize={48}\n hideName\n // Borderless, and square-cornered, because the rounding and\n // the clipping both belong to the bubble around it. A tile\n // that rounds itself as well leaves a hairline seam where\n // the two radii disagree, and its 2px border — transparent\n // or not — insets the video from the edge it should meet.\n bleed\n style={styles.fill as ViewStyle}\n />\n </View>\n </Pressable>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n pip: {\n position: 'absolute',\n top: 0,\n left: 0,\n width: PIP_WIDTH,\n height: PIP_HEIGHT,\n // Generous enough to read as a bubble rather than a cropped\n // rectangle. The video is clipped to it, so this is the only\n // rounding in play.\n borderRadius: 22,\n overflow: 'hidden',\n // Lifted off the video so it reads as floating rather than inset.\n shadowColor: '#000',\n shadowOpacity: 0.4,\n shadowRadius: 12,\n shadowOffset: { width: 0, height: 4 },\n elevation: 8,\n },\n fill: { flex: 1 },\n});\n","import type { CallParticipant } from '@poolse/sdk';\nimport { useMemo, useState } from 'react';\nimport { ScrollView, StyleSheet, View, type LayoutChangeEvent, type ViewStyle } from 'react-native';\n\nimport { CallParticipantTile } from './CallParticipantTile.js';\nimport { LocalVideoPip } from './LocalVideoPip.js';\nimport type { CheckedVideoTrack, LiveKitReactNativeModule } from './livekit-rn.js';\n\nexport type { LiveKitReactNativeModule };\n\nexport interface CallVideoGridProps {\n participants: CallParticipant[];\n /** `@livekit/react-native`, imported by your app. */\n livekitReactNative?: LiveKitReactNativeModule | null | undefined;\n /** Resolves a user id to a display label. */\n labelFor?: ((userId: string) => string) | undefined;\n /**\n * Tapping the local preview. Wired to the camera flip by\n * `CallScreen`, which is where every other call app puts it.\n */\n onLocalPress?: (() => void) | undefined;\n /**\n * How much chrome sits over the bottom of the stage.\n *\n * Only used to keep the last row of a scrolling group grid clear of\n * the control bar. It deliberately does NOT bound the floating\n * preview — see {@link safeArea}.\n */\n chromeInsets?: { top: number; bottom: number } | undefined;\n /**\n * The screen's safe area, which is what the floating preview is\n * bounded by.\n *\n * Separate from `chromeInsets` on purpose. Bounding the preview by the\n * chrome kept it in a box well inside the screen, floating in the\n * middle of nowhere rather than tucked into a corner — and on a\n * connected video call the chrome is hidden most of the time anyway,\n * so it was reserving space for something that was not there.\n */\n safeArea?: { top: number; bottom: number } | undefined;\n}\n\nconst GAP = 8;\n/** Below this a tile shows a head as a postage stamp, so the grid scrolls instead. */\nconst MIN_TILE_HEIGHT = 132;\n\n/**\n * The stage: everyone on the call, laid out for how many there are.\n *\n * Three layouts, because one grid cannot serve all of them:\n *\n * * **Alone** — you, filling the screen, while the far side connects.\n * * **One other person** — them full-bleed, you in a draggable\n * corner tile. A 1:1 call split into two half-height boxes wastes\n * most of the screen on letterboxing, which is why no calling app\n * does it.\n * * **Three or more** — a real grid, two columns up to six people and\n * three beyond that, scrolling once the tiles would be too small to\n * make out a face.\n *\n * Audio calls land here too. Everyone simply has their camera off, so\n * every tile draws an avatar, and the layout logic does not need to\n * know whether video was ever on the table.\n */\nexport function CallVideoGrid({\n participants,\n livekitReactNative,\n labelFor,\n onLocalPress,\n chromeInsets,\n safeArea,\n}: CallVideoGridProps) {\n const label = labelFor ?? ((id: string) => `User ${id.slice(0, 6)}`);\n const VideoTrack = livekitReactNative?.VideoTrack as CheckedVideoTrack | undefined;\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const onLayout = (event: LayoutChangeEvent) => {\n const { width, height } = event.nativeEvent.layout;\n setSize((current) =>\n current.width === width && current.height === height ? current : { width, height },\n );\n };\n\n const self = participants.find((p) => p.isSelf) ?? null;\n const others = useMemo(() => participants.filter((p) => !p.isSelf), [participants]);\n\n const columns = others.length + 1 <= 6 ? 2 : 3;\n const rows = Math.ceil((others.length + 1) / columns);\n const tileHeight = size.height > 0 ? (size.height - GAP * (rows - 1)) / rows : 0;\n const scrolls = tileHeight > 0 && tileHeight < MIN_TILE_HEIGHT;\n\n if (participants.length === 0) return <View style={styles.stage} onLayout={onLayout} />;\n\n // ── alone, or one other person: spotlight + floating preview ────────\n if (others.length <= 1) {\n const spotlight = others[0] ?? self;\n if (!spotlight) return <View style={styles.stage} onLayout={onLayout} />;\n\n return (\n <View style={styles.stage} onLayout={onLayout}>\n <CallParticipantTile\n participant={spotlight}\n VideoTrack={VideoTrack}\n label={label}\n avatarSize={Math.min(148, Math.max(96, Math.round(size.width * 0.36)))}\n bleed\n // Their name is already in the header; repeating it over the\n // video is noise on a two-person call.\n hideName={others.length === 1}\n style={styles.fill as ViewStyle}\n />\n\n {/* Only once somebody else is here. Your own preview floating\n over your own preview is just a mirror in a mirror. */}\n {self && others.length === 1 && size.width > 0 && (\n <LocalVideoPip\n participant={self}\n VideoTrack={VideoTrack}\n label={label}\n bounds={size}\n insets={safeArea ?? { top: 0, bottom: 0 }}\n onPress={onLocalPress}\n />\n )}\n </View>\n );\n }\n\n // ── three or more: a grid ───────────────────────────────────────────\n // Remote faces lead and you sit last, which is both what people look\n // for first and a stable order — promoting the active speaker would\n // reshuffle the grid every time somebody spoke.\n const tiles = [...others, ...(self ? [self] : [])];\n const width = size.width > 0 ? (size.width - GAP * (columns - 1)) / columns : 0;\n\n const grid = (\n <View style={[styles.grid, scrolls ? styles.gridScrolling : styles.gridFilling]}>\n {tiles.map((participant) => (\n <CallParticipantTile\n key={participant.userId}\n participant={participant}\n VideoTrack={VideoTrack}\n label={label}\n avatarSize={columns === 2 ? 66 : 46}\n style={\n {\n width: width || undefined,\n height: scrolls ? MIN_TILE_HEIGHT : tileHeight || undefined,\n } as ViewStyle\n }\n />\n ))}\n </View>\n );\n\n return (\n <View style={styles.stage} onLayout={onLayout}>\n {scrolls ? (\n <ScrollView\n // Padding rather than `contentInset`, which is iOS-only. The\n // control bar floats over the bottom of the stage, so the last\n // row needs room to clear it on both platforms.\n contentContainerStyle={[\n styles.scroll,\n { paddingBottom: (chromeInsets?.bottom ?? 0) + GAP },\n ]}\n showsVerticalScrollIndicator={false}\n >\n {grid}\n </ScrollView>\n ) : (\n grid\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n stage: { flex: 1, overflow: 'hidden' },\n fill: { ...StyleSheet.absoluteFillObject },\n grid: { flexDirection: 'row', flexWrap: 'wrap', gap: GAP },\n gridFilling: { flex: 1, alignContent: 'center' },\n gridScrolling: { alignContent: 'flex-start' },\n scroll: { paddingVertical: GAP },\n});\n","/**\n * The slice of `@livekit/react-native` this package uses.\n *\n * Passed in by the app rather than imported, for the same reason\n * `react-native-webrtc` is: tsup rewrites `require()` into\n * `__require()`, which Metro cannot follow, so anything this package\n * imports for itself never reaches a React Native bundle.\n *\n * import * as livekitRN from '@livekit/react-native';\n * <CallScreen livekitReactNative={livekitRN} … />\n *\n * Everything past `VideoTrack` is optional so an older version of the\n * module still type-checks — the features degrade rather than failing\n * to compile.\n */\n\nimport type { ComponentType } from 'react';\nimport type { ViewStyle } from 'react-native';\n\n/**\n * The slice of `VideoTrack` actually rendered.\n *\n * `LiveKitReactNativeModule.VideoTrack` is `unknown` because React props\n * are contravariant — declaring the narrow shape there means the real\n * component is not assignable to it and no app can pass the module in.\n * Narrowing happens at the point of use, through this.\n */\nexport type CheckedVideoTrack = ComponentType<{\n trackRef: unknown;\n style?: ViewStyle;\n objectFit?: 'cover' | 'contain';\n mirror?: boolean;\n zOrder?: number;\n}>;\n\n/** What an audio route is, once its platform id has been read. */\nexport type AudioRouteKind = 'speaker' | 'earpiece' | 'headset' | 'bluetooth' | 'auto';\n\nexport interface AudioRoute {\n /** Platform id, passed back to `selectAudioOutput`. */\n id: string;\n kind: AudioRouteKind;\n /** Human label for a picker row. */\n label: string;\n}\n\n/**\n * LiveKit's audio session.\n *\n * The two platforms expose genuinely different things and the shape\n * reflects that rather than papering over it:\n *\n * * **Android** enumerates real devices — `speaker`, `earpiece`,\n * `headset`, `bluetooth` — and `selectAudioOutput` picks one.\n * * **iOS** offers only `default` and `force_speaker`, because AVAudio\n * does not let an app pick a route directly. Anything else (AirPods,\n * a wired headset, AirPlay) goes through the system's own picker,\n * which is what `showAudioRoutePicker` opens.\n */\nexport interface LiveKitAudioSession {\n configureAudio(config: {\n android?: {\n preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n audioTypeOptions?: unknown;\n };\n ios?: { defaultOutput?: 'speaker' | 'earpiece' };\n }): Promise<void>;\n startAudioSession(): Promise<void>;\n stopAudioSession(): Promise<void>;\n getAudioOutputs(): Promise<string[]>;\n selectAudioOutput(deviceId: string): Promise<void>;\n /** iOS 11+. Opens the system route picker (AirPods, AirPlay, …). */\n showAudioRoutePicker?(): Promise<void>;\n}\n\n/** Fires when a headset or Bluetooth device appears or disappears. */\nexport interface AudioDeviceModuleEvents {\n addDevicesUpdatedListener(listener: () => void): void;\n removeDevicesUpdatedListener(listener: () => void): void;\n}\n\nexport interface LiveKitReactNativeModule {\n /**\n * The module's `VideoTrack` component.\n *\n * Typed as `unknown` on purpose. Its real props are far more specific\n * than what this renders with, and React component props are\n * contravariant — declaring the narrow shape here means the real\n * component is not assignable to it and no app can pass the module in.\n * It is narrowed at the point of use.\n */\n VideoTrack: unknown;\n AudioSession?: LiveKitAudioSession | undefined;\n /**\n * Installs LiveKit's iOS audio policy and returns a disposer.\n *\n * Must not be re-run mid-call: it abandons the session activation the\n * previous handlers were holding, which kills audio outright. The\n * speaker preference is therefore captured once, when the call\n * starts, and later changes go through `selectAudioOutput` instead.\n */\n setupIOSAudioManagement?: ((preferSpeakerOutput?: boolean) => () => void) | undefined;\n audioDeviceModuleEvents?: AudioDeviceModuleEvents | undefined;\n}\n\n/** Turn a platform output id into something renderable. */\nexport function describeRoute(id: string): AudioRoute {\n switch (id) {\n case 'speaker':\n case 'force_speaker':\n return { id, kind: 'speaker', label: 'Speaker' };\n case 'earpiece':\n return { id, kind: 'earpiece', label: 'Phone' };\n case 'headset':\n return { id, kind: 'headset', label: 'Headphones' };\n case 'bluetooth':\n return { id, kind: 'bluetooth', label: 'Bluetooth' };\n case 'default':\n // iOS's \"whatever the OS thinks is right\" — the earpiece normally,\n // a headset or AirPods the moment one is connected. Labelled for\n // the common case rather than the mechanism.\n return { id, kind: 'auto', label: 'iPhone' };\n default:\n return { id, kind: 'auto', label: id };\n }\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport { describeRoute, type AudioRoute, type LiveKitReactNativeModule } from './livekit-rn.js';\n\nexport interface UseCallAudioOptions {\n /**\n * True as soon as a call exists — ringing counts.\n *\n * Deliberately not \"connected\": the audio session has to be running\n * before LiveKit's audio engine starts, not after. Start it late and\n * the call connects, the roster is right, video flows, and no audio\n * is published in either direction.\n */\n active: boolean;\n /**\n * Whether the call is carrying video.\n *\n * Decides where audio goes by default — nobody holds a phone to their\n * ear while looking at the screen — and nothing else. Read once, when\n * the call starts; see {@link LiveKitReactNativeModule.setupIOSAudioManagement}\n * for why it cannot be re-applied mid-call.\n */\n video: boolean;\n /** `@livekit/react-native`, imported by your app. */\n livekitReactNative?: LiveKitReactNativeModule | null | undefined;\n}\n\nexport interface CallAudio {\n /** Audio is coming out of the loudspeaker. */\n speakerOn: boolean;\n toggleSpeaker: () => void;\n setSpeaker: (on: boolean) => void;\n /** Every route that can be picked right now. */\n routes: AudioRoute[];\n /**\n * The selected route's platform id, or `null` while routing is\n * automatic — which is the normal state until the user picks\n * something. Automatic means the OS follows the preference order the\n * call was configured with, so plugging in a headset just works.\n */\n selectedRouteId: string | null;\n selectRoute: (id: string) => void;\n /**\n * A headset, AirPods or car kit is connected.\n *\n * Worth surfacing because it changes what the speaker button means:\n * with a headset attached, \"off\" routes to the headset rather than to\n * the earpiece.\n *\n * Android only, and honestly so — iOS reports just `default` and\n * `force_speaker` from `getAudioOutputs`, with no way to ask what\n * `default` currently resolves to. On iOS this stays `false` and the\n * system route picker is the way to see and change the real device.\n */\n externalDevice: boolean;\n /**\n * The system route picker can be opened. iOS only — Android\n * enumerates its devices in {@link routes} instead.\n */\n canPickSystemRoute: boolean;\n openSystemRoutePicker: () => void;\n}\n\nconst IOS_AUTO = 'default';\nconst IOS_SPEAKER = 'force_speaker';\n\n/**\n * Owns the audio session for an SFU-backed call, and the routing on top\n * of it.\n *\n * ## Why this is not `react-native-incall-manager`\n *\n * `registerGlobals()` from `@livekit/react-native` drives AVAudioSession\n * natively off its own audio engine's state. Anything else driving the\n * session at the same time fights it, and the symptom is brutal: the\n * microphone captures nothing, and audio only starts working after some\n * unrelated engine change — turning the camera on, say — makes LiveKit\n * reapply its configuration. So InCallManager is reserved for the\n * peer-to-peer mesh, which has no session management of its own.\n *\n * ## What \"default\" means on each platform\n *\n * Android is handed a `preferredOutputList` and picks the best\n * available device itself, so a connected headset wins without the app\n * detecting anything. iOS is given `defaultOutput`, which LiveKit\n * documents as the output to use *when a wired headset or Bluetooth\n * output is unavailable* — same effect, same reason: an app that forced\n * the speaker on a video call would yank audio out of the user's\n * AirPods every time.\n */\nexport function useCallAudio({\n active,\n video,\n livekitReactNative,\n}: UseCallAudioOptions): CallAudio {\n const session = livekitReactNative?.AudioSession;\n const ios = Platform.OS === 'ios';\n\n const [routes, setRoutes] = useState<AudioRoute[]>([]);\n // Null until the user picks: the platform is already routing by the\n // preference order handed to `configureAudio`, and naming a route\n // here would pin it and defeat the automatic headset switching.\n const [selectedRouteId, setSelectedRouteId] = useState<string | null>(null);\n\n // Captured at call start. Depending on `video` directly would tear the\n // audio session down and rebuild it every time the camera is toggled.\n const preferSpeaker = useRef(video);\n if (!active) preferSpeaker.current = video;\n\n // Whether the user has made an explicit choice on this call. Once they\n // have, nothing derived from the media type may override it — turning\n // the camera on must not move audio off the earpiece they chose.\n const userChose = useRef(false);\n if (!active) userChose.current = false;\n\n const refreshRoutes = useCallback(() => {\n if (!session) return;\n void session\n .getAudioOutputs()\n .then((ids) => setRoutes(ids.map(describeRoute)))\n .catch(() => {\n // An unstarted session, or a platform that refuses to enumerate.\n // The speaker toggle still works; only the picker is poorer for\n // it, which is not worth failing a call over.\n });\n }, [session]);\n\n // ── session lifecycle ────────────────────────────────────────────────\n\n useEffect(() => {\n if (!active || !session) return;\n\n const wantsSpeaker = preferSpeaker.current;\n let disposePolicy: (() => void) | undefined;\n // A call that ends while the session is still starting up would\n // otherwise leave the iOS policy installed forever: cleanup runs\n // before the async body has assigned the disposer, so there is\n // nothing to call. The flag lets the body clean up after itself.\n let released = false;\n\n // Ordering matters: configure, then install the iOS policy, then\n // start. `configureAudio` is documented as having to run before the\n // room connects for it to apply at all.\n void (async () => {\n try {\n await session.configureAudio({\n android: {\n // Best device first. A headset or car kit outranks the\n // built-in outputs either way; the media type only decides\n // which built-in output wins when nothing is plugged in.\n preferredOutputList: wantsSpeaker\n ? ['bluetooth', 'headset', 'speaker', 'earpiece']\n : ['bluetooth', 'headset', 'earpiece', 'speaker'],\n },\n ios: { defaultOutput: wantsSpeaker ? 'speaker' : 'earpiece' },\n });\n } catch {\n // Falls back to LiveKit's own defaults, which are sane.\n }\n\n if (released) return;\n disposePolicy = livekitReactNative?.setupIOSAudioManagement?.(wantsSpeaker);\n\n try {\n await session.startAudioSession();\n } catch {\n // A refused session leaves the call silent rather than failing\n // it outright. Better a call the user can see is broken than one\n // that never rings.\n }\n\n if (released) {\n // Ended mid-start. Undo what we just did rather than leaving a\n // session running for a call that no longer exists.\n void session.stopAudioSession().catch(() => {});\n disposePolicy?.();\n return;\n }\n refreshRoutes();\n })();\n\n return () => {\n released = true;\n // Released deliberately. Holding the session open leaves the\n // device in call mode afterwards, with media apps stuck at call\n // volume and the earpiece still routed.\n void session.stopAudioSession().catch(() => {});\n disposePolicy?.();\n };\n }, [active, session, livekitReactNative, refreshRoutes]);\n\n // A finished call must not hand its routing to the next one.\n useEffect(() => {\n if (active) return;\n setSelectedRouteId(null);\n setRoutes([]);\n }, [active]);\n\n // ── device changes ───────────────────────────────────────────────────\n\n useEffect(() => {\n if (!active) return;\n const events = livekitReactNative?.audioDeviceModuleEvents;\n if (!events) return;\n\n const onChange = () => refreshRoutes();\n try {\n events.addDevicesUpdatedListener(onChange);\n } catch {\n // iOS/macOS only in the current module. Android still refreshes on\n // call start and whenever the picker is opened, which covers the\n // cases a user can actually observe.\n return;\n }\n return () => {\n try {\n events.removeDevicesUpdatedListener(onChange);\n } catch {\n // Nothing registered; nothing to undo.\n }\n };\n }, [active, livekitReactNative, refreshRoutes]);\n\n // ── selection ────────────────────────────────────────────────────────\n\n const selectRoute = useCallback(\n (id: string) => {\n userChose.current = true;\n setSelectedRouteId(id);\n if (!session) return;\n void session.selectAudioOutput(id).catch(() => {\n // The device went away between listing and picking. Re-reading\n // is more useful than reporting it.\n refreshRoutes();\n });\n },\n [session, refreshRoutes],\n );\n\n const externalDevice = useMemo(\n () => routes.some((r) => r.kind === 'headset' || r.kind === 'bluetooth'),\n [routes],\n );\n\n // With no explicit choice, report where the platform was told to send\n // audio by default — except when something is plugged in, which\n // outranks the loudspeaker in every preference order above.\n const speakerOn =\n selectedRouteId === null\n ? preferSpeaker.current && !externalDevice\n : ios\n ? selectedRouteId === IOS_SPEAKER\n : selectedRouteId === 'speaker';\n\n const setSpeaker = useCallback(\n (on: boolean) => {\n if (ios) {\n selectRoute(on ? IOS_SPEAKER : IOS_AUTO);\n return;\n }\n if (on) {\n selectRoute('speaker');\n return;\n }\n // Turning the speaker off on Android has to name a destination.\n // Prefer whatever the user is wearing over the earpiece — pulling\n // audio out of connected AirPods would be the wrong reading of\n // \"not the loudspeaker\".\n const fallback =\n routes.find((r) => r.kind === 'bluetooth') ??\n routes.find((r) => r.kind === 'headset') ??\n routes.find((r) => r.kind === 'earpiece');\n if (fallback) selectRoute(fallback.id);\n },\n [ios, routes, selectRoute],\n );\n\n const toggleSpeaker = useCallback(() => setSpeaker(!speakerOn), [setSpeaker, speakerOn]);\n\n const openSystemRoutePicker = useCallback(() => {\n void session?.showAudioRoutePicker?.().catch(() => {});\n }, [session]);\n\n return {\n speakerOn,\n toggleSpeaker,\n setSpeaker,\n routes,\n selectedRouteId,\n selectRoute,\n externalDevice,\n canPickSystemRoute: ios && typeof session?.showAudioRoutePicker === 'function',\n openSystemRoutePicker,\n };\n}\n","import { useEffect, useRef, useState } from 'react';\n\n/**\n * How long the call has been connected, as `m:ss` (or `h:mm:ss`).\n *\n * Anchored to a timestamp rather than counting ticks: a phone that\n * sleeps or throttles timers would otherwise drift, and a call timer\n * that reads 4:12 after eleven minutes is worse than none. Returns null\n * until the call is actually up, so a ringing call shows its status\n * line instead of `0:00`.\n */\nexport function useCallDuration(connected: boolean): string | null {\n const startedAt = useRef<number | null>(null);\n const [, tick] = useState(0);\n\n if (connected && startedAt.current === null) startedAt.current = Date.now();\n if (!connected && startedAt.current !== null) startedAt.current = null;\n\n useEffect(() => {\n if (!connected) return;\n const id = setInterval(() => tick((n) => n + 1), 1000);\n return () => clearInterval(id);\n }, [connected]);\n\n if (!connected || startedAt.current === null) return null;\n return format(Math.max(0, Math.floor((Date.now() - startedAt.current) / 1000)));\n}\n\nfunction format(total: number): string {\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n const mm = hours > 0 ? String(minutes).padStart(2, '0') : String(minutes);\n return `${hours > 0 ? `${hours}:` : ''}${mm}:${String(seconds).padStart(2, '0')}`;\n}\n","import { useCallRoom, useCalls, useVoiceRoom, type UseCalls } from '@poolse/react';\nimport type { CallParticipant, LiveKitModule, VoiceStatus } from '@poolse/sdk';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { Modal, Pressable, StatusBar, StyleSheet, Text, View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { AudioRouteSheet } from './voice/AudioRouteSheet.js';\nimport { CallAvatar } from './voice/CallAvatar.js';\nimport { CallControlButton } from './voice/CallControlButton.js';\nimport { CallVideoGrid } from './voice/CallVideoGrid.js';\nimport { callColors } from './voice/callTheme.js';\nimport type { LiveKitReactNativeModule } from './voice/livekit-rn.js';\nimport { useCallAudio } from './voice/useCallAudio.js';\nimport { useCallDuration } from './voice/useCallDuration.js';\nimport {\n createNativeWebRtcAdapter,\n isNativeWebRtcAvailable,\n type NativeWebRtcModule,\n} from './voice/webrtc-native.js';\n\nexport interface CallScreenProps {\n /** The signed-in user's id — the topic calls are delivered on. */\n userId: string;\n /** Resolves a user id to a display label. Defaults to a short id. */\n labelFor?: (userId: string) => string;\n /**\n * Escape hatch for apps that already own a `useCalls` instance (for\n * example to place calls from elsewhere in the UI). When omitted the\n * component manages its own.\n */\n calls?: UseCalls;\n /**\n * The `react-native-webrtc` module (or `@livekit/react-native-webrtc`,\n * which is API-compatible), imported by your app.\n *\n * Used for the peer-to-peer fallback when the deployment has no SFU.\n * With an SFU configured, LiveKit owns the peer connection and this is\n * only the safety net.\n */\n webrtc?: NativeWebRtcModule | null;\n /**\n * `livekit-client`, imported by your app. Enables SFU-backed calls,\n * which is what makes video and the mid-call camera toggle possible.\n * Omit it and calls fall back to the peer-to-peer mesh, audio only.\n */\n livekit?: LiveKitModule | null;\n /**\n * `@livekit/react-native`, imported by your app.\n *\n * Required to *render* video, and also carries `AudioSession`, which\n * is what routes a call to the speaker, the earpiece or a headset.\n * Without it a call still connects and carries audio, every tile\n * shows an avatar, and routing falls to whatever the OS picks.\n */\n livekitReactNative?: LiveKitReactNativeModule | null;\n /**\n * Called whenever the call's media connection state changes.\n */\n onStatusChange?: (status: VoiceStatus) => void;\n /**\n * Called when the media transport changes: `'sfu'`, `'mesh'`, or\n * `null` when no call is connected.\n *\n * This decides who owns the iOS audio session, and getting it wrong is\n * silent. `@livekit/react-native`'s `registerGlobals()` configures and\n * activates AVAudioSession natively as its audio engine changes state.\n * An app that ALSO drives the session — `react-native-incall-manager`,\n * typically — fights it: the microphone publishes nothing, and audio\n * only starts working after some unrelated engine change (turning the\n * camera on) makes LiveKit reapply its configuration.\n *\n * So drive InCallManager from this, and only for `'mesh'`. On the SFU\n * path this component already owns the session, through LiveKit.\n */\n onTransportChange?: (transport: 'sfu' | 'mesh' | null) => void;\n /** Called when the call's video state changes. */\n onVideoChange?: (video: boolean) => void;\n /**\n * `react-native-incall-manager`, imported by your app.\n *\n * Only used here for the ring tones — the earpiece purr while an\n * outbound call rings, and the ringtone for an inbound one. Without\n * it a call is completely silent until somebody answers, which reads\n * as the app having failed to place it at all.\n *\n * Injected rather than imported for the same reason every other\n * native module is: Metro only bundles what it can see statically.\n */\n inCallManager?: RingToneModule | null;\n /**\n * Hide this screen while a call is merely ringing in.\n *\n * Set it when `useVoipCalls` is wired: CallKit already shows the\n * system call UI on the lock screen and in the Dynamic Island, and a\n * second in-app sheet on top of it means one tap of Call produces two\n * competing rings. The screen still appears once the call connects, to\n * carry the in-call controls.\n */\n nativeIncomingUi?: boolean;\n}\n\n/** Controls fade out this long after the last touch on a video call. */\nconst CHROME_IDLE_MS = 4500;\n\n/**\n * The slice of `react-native-incall-manager` used for ring tones.\n *\n * Every method optional: older versions lack some, and a missing tone\n * must never take a call down.\n */\nexport interface RingToneModule {\n // Deliberately loose, for the same reason `LiveKitModule` is.\n // Spelling the real signatures out does NOT work: function parameters\n // are contravariant, so any shape differing even slightly from the\n // installed version's — an argument required rather than optional, a\n // `number | number[]` rather than a `number[]` — makes the real module\n // unassignable and no app can pass it in. It also breaks again on the\n // next upstream signature change.\n //\n // Narrowed to `RingTone` at the point of use instead.\n startRingback?: (...args: never[]) => void;\n stopRingback?: (...args: never[]) => void;\n startRingtone?: (...args: never[]) => void;\n stopRingtone?: (...args: never[]) => void;\n}\n\n/** The shape actually called, narrowed once inside the component. */\ntype RingTone = (tone: string) => void;\n\n/**\n * WhatsApp-style call UI: a full-screen sheet that covers the app while\n * a call is ringing or connected, and renders nothing when idle.\n *\n * Mount it once, high in the tree, so a call can arrive on any screen:\n *\n * <PoolseProvider config={config}>\n * <CallScreen\n * userId={me.id}\n * livekit={livekit}\n * livekitReactNative={livekitRN}\n * />\n * <YourApp />\n * </PoolseProvider>\n *\n * ## Two media paths\n *\n * With `livekit` supplied, media rides the SFU: one upload per\n * participant regardless of call size, and the camera and microphone can\n * be switched on and off at any point. Without it — or against a\n * deployment that has no SFU configured — calls fall back to the\n * peer-to-peer mesh, which is audio only.\n *\n * The fallback is automatic and silent by design. A deployment without\n * an SFU is a supported configuration, not a broken one.\n */\nexport function CallScreen({\n userId,\n labelFor,\n calls: callsProp,\n webrtc,\n livekit,\n livekitReactNative,\n onStatusChange,\n onTransportChange,\n onVideoChange,\n inCallManager,\n nativeIncomingUi,\n}: CallScreenProps) {\n const insets = useSafeAreaInsets();\n const ownCalls = useCalls(callsProp ? null : userId);\n const calls = callsProp ?? ownCalls;\n\n const meshAvailable = isNativeWebRtcAvailable(webrtc);\n const opts = useMemo(\n () => (meshAvailable && webrtc ? { webrtc: createNativeWebRtcAdapter(webrtc) } : {}),\n [meshAvailable, webrtc],\n );\n\n /**\n * The conversation whose media should be open.\n *\n * Deliberately includes `ringing-out`, not just `active`. Waiting for\n * an answer before touching the camera meant the caller stared at a\n * blank screen through the entire ring and then watched their own\n * preview pop in a second after the other side picked up — and the\n * microphone was not open either, so the first word of every call was\n * clipped. Joining while it rings means the room is warm the instant\n * they answer, and you can see yourself while you wait.\n *\n * Safe for the alone-detection: a caller sitting in an empty room has\n * never seen a peer, and that is exactly the guard `CallRoom.onAlone`\n * checks before declaring a call abandoned.\n */\n const conversationId =\n calls.phase === 'active'\n ? calls.activeConversationId\n : calls.phase === 'ringing-out'\n ? (calls.outgoing?.conversationId ?? null)\n : null;\n const isVideoCall = calls.media === 'video';\n\n // Both are constructed; only one ends up connected. `useCallRoom`\n // reports `sfuAvailable: false` when the API answers 503, and only\n // then does the mesh join — so a deployment with an SFU never opens a\n // peer connection it will not use.\n const sfu = useCallRoom(livekit ? conversationId : null, {\n livekit: livekit as LiveKitModule,\n video: isVideoCall,\n });\n const mesh = useVoiceRoom(conversationId, opts);\n\n const usingSfu = sfu.sfuAvailable === true;\n const status: VoiceStatus = usingSfu ? toVoiceStatus(sfu.status) : mesh.status;\n const connected = calls.phase === 'active' && status === 'connected';\n\n useEffect(() => {\n const wants = calls.phase === 'active' || calls.phase === 'ringing-out';\n if (!wants || !conversationId) return;\n\n let cancelled = false;\n void (async () => {\n // Try the SFU first when the app supplied LiveKit. A `false` here\n // means the deployment has none, which is the one case the mesh\n // should take over.\n const joined = livekit ? await sfu.join() : false;\n if (cancelled || joined) return;\n if (meshAvailable) await mesh.join();\n })();\n\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [calls.phase, conversationId, livekit, meshAvailable]);\n\n useEffect(() => {\n onStatusChange?.(status);\n }, [status, onStatusChange]);\n\n const transport: 'sfu' | 'mesh' | null =\n status !== 'connected' ? null : usingSfu ? 'sfu' : 'mesh';\n\n useEffect(() => {\n onTransportChange?.(transport);\n }, [transport, onTransportChange]);\n\n // The mesh carries no video, so its calls are always audio.\n const videoOn = usingSfu && sfu.cameraEnabled;\n useEffect(() => {\n onVideoChange?.(videoOn);\n }, [videoOn, onVideoChange]);\n\n // ── audio routing ───────────────────────────────────────────────────\n\n // Armed on the ring, not on connect: LiveKit's audio session has to be\n // running before its engine starts, and replacing its handlers\n // mid-call is unsupported. Mesh calls are excluded because\n // InCallManager owns the session there — see `onTransportChange`.\n const audio = useCallAudio({\n active: calls.phase !== 'idle' && transport !== 'mesh',\n video: isVideoCall,\n livekitReactNative,\n });\n const [routesOpen, setRoutesOpen] = useState(false);\n\n /**\n * The sound of a call in progress.\n *\n * Ringback while an outbound call rings, so the caller can hear that\n * something is happening — silence there is indistinguishable from a\n * call that failed to place. A ringtone for an inbound one, but only\n * when this screen is actually showing it: with CallKit driving the\n * ring, iOS plays the system ringtone and a second tone underneath it\n * is just noise.\n *\n * Stopped in the cleanup rather than on a phase transition, so a call\n * that ends any way at all — answered, declined, cancelled, timed out,\n * crashed out — cannot leave a tone playing.\n */\n const showingIncoming = calls.phase === 'ringing-in' && !nativeIncomingUi;\n useEffect(() => {\n const ringing = calls.phase === 'ringing-out';\n if (!ringing && !showingIncoming) return;\n\n try {\n const start = (ringing ? inCallManager?.startRingback : inCallManager?.startRingtone) as\n | RingTone\n | undefined;\n // `_BUNDLE_` for ringback, not `_DEFAULT_`. On iOS the library\n // resolves `_DEFAULT_` to /Library/Ringtones/Marimba.m4r — an\n // actual iPhone RINGTONE — so the caller heard the sound the\n // callee's phone makes rather than a ringing tone. `_DTMF_` is\n // remapped to `_DEFAULT_` too, so the only correct option is to\n // ship the tone: the app bundles `incallmanager_ringback.mp3`\n // (see the sample's plugins/withRingback.js). Absent that, the\n // library falls back to the ringtone, which is no worse than\n // before.\n start?.(ringing ? '_BUNDLE_' : '_DEFAULT_');\n } catch {\n // A missing tone must never take the call down with it.\n }\n\n return () => {\n try {\n (inCallManager?.stopRingback as (() => void) | undefined)?.();\n (inCallManager?.stopRingtone as (() => void) | undefined)?.();\n } catch {\n // Nothing playing; nothing to stop.\n }\n };\n }, [calls.phase, showingIncoming, inCallManager]);\n\n // ── chrome auto-hide ────────────────────────────────────────────────\n\n const [chromeVisible, setChromeVisible] = useState(true);\n // Bumped on every interaction. Having the effect depend on it is what\n // restarts the countdown — a polled deadline would either fire late or\n // need an interval running for the whole call.\n const [lastWake, setLastWake] = useState(0);\n\n // Only video calls hide their controls — there is nothing to look at\n // underneath an audio call, so hiding them would just lose the\n // buttons.\n const chromeHides = connected && isVideoCall;\n\n useEffect(() => {\n setChromeVisible(true);\n if (!chromeHides) return;\n const timer = setTimeout(() => setChromeVisible(false), CHROME_IDLE_MS);\n return () => clearTimeout(timer);\n }, [chromeHides, lastWake]);\n\n const wakeChrome = useCallback(() => setLastWake(Date.now()), []);\n\n /**\n * Tapping the screen toggles the controls.\n *\n * It used to only ever show them, and then a timer took them away —\n * so there was no way to dismiss the chrome deliberately and get a\n * clean look at the video. Tap to hide, tap to show, and the idle\n * timer stays as a convenience on top rather than as the only way\n * they ever disappear.\n */\n const toggleChrome = useCallback(() => {\n setChromeVisible((visible) => {\n if (visible) return false;\n setLastWake(Date.now());\n return true;\n });\n }, []);\n\n /**\n * Run an action and restart the idle countdown.\n *\n * A child `Pressable` wins the touch outright, so the screen-wide\n * handler never sees a control being tapped — without this, hitting\n * mute at four seconds would watch the controls vanish half a second\n * later.\n */\n const withWake = useCallback(\n (fn: () => void) => () => {\n wakeChrome();\n fn();\n },\n [wakeChrome],\n );\n\n // ── actions ─────────────────────────────────────────────────────────\n\n // `calls.hangUp()` signals the other side and always returns to idle;\n // `reset()` alone only cleared local state, leaving the peer in a call\n // with a screen it had no reason to close.\n const hangUp = useCallback(() => {\n sfu.leave();\n mesh.leave();\n void calls.hangUp();\n }, [sfu, mesh, calls]);\n\n // Everyone else vanished without hanging up — their app was killed or\n // their phone lost signal, so no `call:hangup` will ever arrive. End\n // it here rather than leaving the survivor on a dead call screen.\n const alone = usingSfu ? sfu.alone : mesh.alone;\n\n // Latched, because `hangUp` closes over the room objects and those are\n // rebuilt every render — the effect re-runs constantly, and without a\n // guard it would fire the hang-up repeatedly in the window before the\n // phase actually flips.\n const endedOnEmpty = useRef(false);\n if (calls.phase !== 'active') endedOnEmpty.current = false;\n\n useEffect(() => {\n if (!alone || calls.phase !== 'active' || endedOnEmpty.current) return;\n endedOnEmpty.current = true;\n hangUp();\n }, [alone, calls.phase, hangUp]);\n\n const micOn = usingSfu ? sfu.micEnabled : !mesh.muted;\n const toggleMic = useCallback(() => {\n if (usingSfu) void sfu.toggleMic();\n else mesh.toggleMute();\n }, [usingSfu, sfu, mesh]);\n\n const onSpeakerPress = useCallback(() => {\n // With real devices to choose between, a toggle is the wrong\n // control — it can only ever reach two of them. Android enumerates\n // them, so it gets a picker; iOS hands the job to the system sheet,\n // which is the only way to reach AirPods or AirPlay there.\n if (audio.routes.length > 2) setRoutesOpen(true);\n else if (audio.canPickSystemRoute && audio.externalDevice) audio.openSystemRoutePicker();\n else audio.toggleSpeaker();\n }, [audio]);\n\n // ── presentation ────────────────────────────────────────────────────\n\n const label = useMemo(() => labelFor ?? ((id: string) => `User ${id.slice(0, 6)}`), [labelFor]);\n\n const ringingIn = calls.phase === 'ringing-in';\n const ringingOut = calls.phase === 'ringing-out';\n const ended = calls.phase === 'declined' || calls.phase === 'busy' || calls.phase === 'timed-out';\n const visible = calls.phase !== 'idle' && !(nativeIncomingUi && ringingIn);\n\n const duration = useCallDuration(connected);\n const participants: CallParticipant[] = usingSfu ? sfu.participants : [];\n const others = participants.filter((p) => !p.isSelf);\n const isGroup = others.length > 1 || (calls.outgoing?.calleeUserIds.length ?? 0) > 1;\n\n const peerIds =\n ringingIn && calls.incoming\n ? [calls.incoming.callerUserId]\n : others.length > 0\n ? others.map((p) => p.userId)\n : (calls.outgoing?.calleeUserIds ?? []);\n\n const title =\n peerIds.length === 0\n ? 'Call'\n : peerIds.length <= 2\n ? peerIds.map(label).join(', ')\n : `${label(peerIds[0]!)} and ${peerIds.length - 1} others`;\n\n const subtitle = duration ?? statusLine(calls, status);\n\n // The stage only earns the screen once media is flowing. Before that\n // there is nothing to render but a placeholder, and the identity card\n // says far more.\n const showStage = connected && usingSfu && participants.length > 0;\n\n const error = calls.error ?? (usingSfu ? sfu.error : mesh.error);\n // Only the scrolling group grid uses this — it keeps the last row\n // clear of the control bar. The floating preview is bounded by the\n // safe area instead, so it can sit in a real corner.\n const chromeInsets = {\n top: insets.top + 72,\n bottom: insets.bottom + 150,\n };\n\n return (\n <Modal\n visible={visible}\n animationType=\"slide\"\n transparent={false}\n supportedOrientations={['portrait', 'landscape']}\n onRequestClose={hangUp}\n >\n <StatusBar barStyle=\"light-content\" />\n <Pressable style={styles.screen} onPress={toggleChrome} accessible={false}>\n {showStage ? (\n <CallVideoGrid\n participants={participants}\n livekitReactNative={livekitReactNative}\n labelFor={label}\n onLocalPress={() => void sfu.switchCamera()}\n chromeInsets={chromeInsets}\n safeArea={{ top: insets.top, bottom: insets.bottom }}\n />\n ) : (\n <View style={styles.identity}>\n <CallAvatar\n name={peerIds.length === 1 ? label(peerIds[0]!) : title}\n seed={peerIds[0] ?? 'call'}\n size={132}\n />\n </View>\n )}\n\n {/* ── header ─────────────────────────────────────────────── */}\n {chromeVisible && (\n <View style={[styles.header, { paddingTop: insets.top + 14 }]} pointerEvents=\"box-none\">\n <Text numberOfLines={1} style={styles.title}>\n {title}\n </Text>\n <View style={styles.subtitleRow}>\n {isGroup && showStage && (\n <PoolseIcon name=\"users\" size={14} color={callColors.textDim} label={null} />\n )}\n <Text style={styles.subtitle}>\n {isGroup && showStage ? `${participants.length} · ${subtitle}` : subtitle}\n </Text>\n </View>\n </View>\n )}\n\n {/* ── controls ───────────────────────────────────────────── */}\n {chromeVisible && (\n <View\n style={[styles.controls, { paddingBottom: insets.bottom + 22 }]}\n pointerEvents=\"box-none\"\n >\n {error && <Text style={styles.error}>{error.message}</Text>}\n {!meshAvailable && !livekit && (\n <Text style={styles.error}>No WebRTC module supplied — this call has no audio.</Text>\n )}\n\n {ringingIn ? (\n <View style={styles.row}>\n <CallControlButton\n icon=\"phone-off\"\n tone=\"danger\"\n large\n onPress={() => void calls.decline()}\n accessibilityLabel=\"Decline call\"\n />\n <CallControlButton\n icon={isVideoCall ? 'video' : 'phone'}\n tone=\"accept\"\n large\n onPress={() => void calls.accept()}\n accessibilityLabel=\"Accept call\"\n />\n </View>\n ) : ended ? (\n <View style={styles.row}>\n <CallControlButton\n icon=\"close\"\n onPress={calls.reset}\n label=\"Close\"\n accessibilityLabel=\"Close\"\n />\n </View>\n ) : (\n <>\n <View style={styles.row}>\n <CallControlButton\n icon={micOn ? 'mic' : 'mic-off'}\n label={micOn ? 'Mute' : 'Unmute'}\n active={!micOn}\n onPress={withWake(toggleMic)}\n accessibilityLabel={micOn ? 'Mute microphone' : 'Unmute microphone'}\n />\n <CallControlButton\n icon={speakerIcon(audio)}\n label={speakerLabel(audio)}\n active={audio.speakerOn}\n onPress={withWake(onSpeakerPress)}\n accessibilityLabel=\"Audio output\"\n />\n {/* Only the SFU can add video to a live call — the mesh\n offers once, on peer discovery, and cannot renegotiate. */}\n {usingSfu && (\n <CallControlButton\n icon={videoOn ? 'video' : 'video-off'}\n label=\"Camera\"\n active={!videoOn}\n onPress={withWake(() => void sfu.toggleCamera())}\n accessibilityLabel={videoOn ? 'Turn camera off' : 'Turn camera on'}\n />\n )}\n {usingSfu && videoOn && (\n <CallControlButton\n icon=\"camera-flip\"\n label=\"Flip\"\n onPress={withWake(() => void sfu.switchCamera())}\n accessibilityLabel=\"Switch camera\"\n />\n )}\n </View>\n\n <View style={styles.hangUpRow}>\n <CallControlButton\n icon=\"phone-off\"\n tone=\"danger\"\n large\n onPress={ringingOut ? () => void calls.cancel() : hangUp}\n accessibilityLabel={ringingOut ? 'Cancel call' : 'Hang up'}\n />\n </View>\n </>\n )}\n </View>\n )}\n\n <AudioRouteSheet\n visible={routesOpen}\n routes={audio.routes}\n selectedRouteId={audio.selectedRouteId}\n onSelect={audio.selectRoute}\n onClose={() => setRoutesOpen(false)}\n />\n </Pressable>\n </Modal>\n );\n}\n\nfunction speakerIcon(audio: { speakerOn: boolean; externalDevice: boolean }) {\n if (audio.externalDevice) return 'headphones' as const;\n return audio.speakerOn ? ('speaker' as const) : ('speaker-off' as const);\n}\n\nfunction speakerLabel(audio: { externalDevice: boolean }) {\n return audio.externalDevice ? 'Audio' : 'Speaker';\n}\n\n/** The SFU's lifecycle mapped onto the one the mesh already reports. */\nfunction toVoiceStatus(status: string): VoiceStatus {\n switch (status) {\n case 'connecting':\n return 'connecting';\n case 'connected':\n return 'connected';\n case 'error':\n return 'error';\n default:\n return 'idle';\n }\n}\n\nfunction statusLine(calls: UseCalls, mediaStatus: string): string {\n switch (calls.phase) {\n case 'ringing-in':\n return calls.media === 'video' ? 'Incoming video call' : 'Incoming call';\n case 'ringing-out':\n return 'Ringing…';\n case 'declined':\n return 'Call declined';\n case 'busy':\n return 'Already on another call';\n case 'timed-out':\n return 'No answer';\n case 'active':\n return mediaStatus === 'connected' ? 'Connected' : 'Connecting…';\n default:\n return '';\n }\n}\n\nconst styles = StyleSheet.create({\n screen: { flex: 1, backgroundColor: callColors.bg },\n identity: { flex: 1, alignItems: 'center', justifyContent: 'center' },\n\n header: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n alignItems: 'center',\n gap: 5,\n paddingHorizontal: 24,\n paddingBottom: 18,\n backgroundColor: callColors.scrim,\n },\n title: { color: callColors.text, fontSize: 22, fontWeight: '600', textAlign: 'center' },\n subtitleRow: { flexDirection: 'row', alignItems: 'center', gap: 6 },\n subtitle: { color: callColors.textDim, fontSize: 14.5 },\n\n controls: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n gap: 18,\n paddingTop: 20,\n backgroundColor: callColors.scrim,\n },\n row: { flexDirection: 'row', justifyContent: 'center', flexWrap: 'wrap', rowGap: 16 },\n hangUpRow: { flexDirection: 'row', justifyContent: 'center' },\n error: {\n color: callColors.danger,\n fontSize: 12.5,\n textAlign: 'center',\n paddingHorizontal: 24,\n },\n});\n","import { usePoolse, type UseCalls } from '@poolse/react';\nimport type { CallMedia, IncomingCall } from '@poolse/sdk';\nimport { useEffect, useRef } from 'react';\n\n/**\n * Bridges iOS PushKit + CallKit to poolse calls, and owns the incoming\n * call UI end to end.\n *\n * ## Why this coordinates rather than just forwards\n *\n * A call arrives by two routes: `call:incoming` over the WebSocket when\n * the app is foregrounded, and a VoIP push when it isn't. The server\n * fires both, always — deciding server-side whether a socket is really\n * alive is a race it would lose.\n *\n * Reconciling them is therefore the client's job, and doing it badly is\n * very visible: forward each route to its own UI and one tap of Call\n * shows the callee two rings, an in-app sheet fighting a system call\n * screen.\n *\n * So this hook is the single place a call becomes visible. Both routes\n * feed one map keyed by `callId`, CallKit is the only ring UI, and the\n * native call is torn down whenever the call reaches a terminal state —\n * declined, cancelled, timed out, answered. Pass the same `calls` object\n * to `<CallScreen>` and it stays out of the way while a ring is up.\n *\n * ## The rule Apple enforces\n *\n * Every delivered VoIP push MUST report an incoming call to CallKit,\n * essentially immediately. Miss it and iOS terminates the app; do it\n * repeatedly and the system stops delivering VoIP pushes at all.\n *\n * ## Dependencies\n *\n * `react-native-voip-push-notification` and `react-native-callkeep`,\n * both native and both requiring a development build. Metro only bundles\n * what it can see statically, so YOUR APP imports them and passes them\n * in. The iOS AppDelegate also needs PushKit delegate methods, which\n * Expo does not generate — see the sample's `plugins/withVoipPush.js`.\n *\n * useVoipCalls({\n * voipPush: VoipPushNotification,\n * callKeep: RNCallKeep,\n * calls, // the same useCalls() the UI uses\n * apnsEnvironment: 'sandbox',\n * });\n */\n\n/** The slice of `react-native-voip-push-notification` used here. */\nexport interface VoipPushModule {\n addEventListener(event: string, handler: (payload: unknown) => void): void;\n removeEventListener(event: string): void;\n registerVoipToken(): void;\n /**\n * Releases the native PushKit completion handler for a push.\n *\n * iOS hands `didReceiveIncomingPushWith` a completion block and expects\n * it back once the call has been reported. Never calling it leaves the\n * app looking like it dropped the push, which is one of the ways iOS\n * stops delivering VoIP pushes to an app entirely.\n *\n * Optional because older versions of the module don't expose it.\n */\n onVoipNotificationCompleted?(uuid: string): void;\n}\n\n/** The slice of `react-native-callkeep` used here. */\nexport interface CallKeepModule {\n setup(options: unknown): Promise<unknown>;\n displayIncomingCall(\n uuid: string,\n handle: string,\n localizedCallerName?: string,\n handleType?: string,\n hasVideo?: boolean,\n ): unknown;\n endCall(uuid: string): unknown;\n /** Tell CallKit the call connected. Absent on older versions. */\n setCurrentCallActive?(uuid: string): unknown;\n addEventListener(event: string, handler: (payload: unknown) => void): void;\n removeEventListener(event: string): void;\n}\n\n/** An inbound call, as it arrives inside a VoIP push payload. */\nexport interface VoipIncomingCall {\n callId: string;\n conversationId: string;\n callerUserId: string;\n callerName: string;\n /**\n * What the call opened as.\n *\n * Carried by the push because CallKit fixes the answer button when the\n * call is reported and cannot change it afterwards — waiting for the\n * socket would mean answering a video call through an audio UI.\n */\n media: CallMedia;\n}\n\nexport interface UseVoipCallsOptions {\n voipPush: VoipPushModule;\n callKeep: CallKeepModule;\n /**\n * The `useCalls(...)` instance driving this screen. Supplying it lets\n * the hook answer, decline and dismiss through the same state machine\n * the UI uses, rather than two halves disagreeing about what is\n * happening.\n */\n calls?: UseCalls;\n /** Called when the user answers from the native call UI. */\n onAnswer?: (call: VoipIncomingCall) => void;\n /** Called when the user declines from the native call UI. */\n onDecline?: (call: VoipIncomingCall) => void;\n /** CallKit display name for your app. Shown on the lock screen. */\n appName?: string;\n /**\n * Which APNs environment issued this build's PushKit token — it must\n * match the app's `aps-environment` entitlement.\n *\n * Pass it explicitly. The fallback guesses from `__DEV__`, which\n * describes the JS bundle and NOT the entitlement: an ad-hoc or\n * TestFlight build has `__DEV__ === false` while still carrying the\n * `development` entitlement, so it receives a sandbox token and\n * reports it as production. The server then pushes to the wrong\n * environment, Apple answers BadDeviceToken, and the phone never\n * rings — with nothing in the app to suggest why.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n /**\n * How old a pushed call may be before it is reported and immediately\n * ended, in ms. Defaults to a deliberately generous 120s.\n *\n * The tight value this once used made clock skew between server and\n * handset enough to suppress live calls. The authoritative guard is\n * server-side anyway — accepting an ended call is refused — so this is\n * only here to spare the user a ring for something long dead.\n *\n * PushKit holds a push that lands before the JS bundle is up and\n * replays it on launch, so opening the app can ring you for a call the\n * caller hung up on minutes ago — a ring with nothing live to accept.\n */\n staleAfterMs?: number;\n}\n\n/**\n * Whether a pushed call is old enough to be dismissed straight after\n * being reported.\n *\n * Exported for testing, because getting this wrong is silent and total:\n * too tight a window and clock skew between the server and the handset\n * suppresses live calls with nothing in the app to explain it.\n *\n * Never dismisses on a missing timestamp, and never on a future one —\n * skew runs both ways, and withholding a real call is far worse than\n * ringing once for a dead one.\n */\n/**\n * Whether a call phase means the system call should be torn down.\n *\n * CallKit has no idea what the app is doing, so it holds a call open\n * until told otherwise. Get this wrong in either direction and the phone\n * and the app disagree:\n *\n * * too eager — ending on `active` takes the connected call out of the\n * Dynamic Island and Recents while the user is still talking;\n * * too reluctant — never ending it leaves a call the user hung up\n * still showing on the lock screen, with buttons that do nothing.\n *\n * The ringing phases are excluded because the ring IS the system call,\n * and `active` because a connected call is supposed to exist. Everything\n * else — idle, declined, busy, timed out — is over.\n *\n * `undefined` means no `calls` was supplied, so there is no state\n * machine to read and nothing this can honestly conclude. Tearing a call\n * down on a guess would be worse than leaving it to the app.\n */\nexport function isCallOver(phase: string | undefined): boolean {\n if (phase === undefined) return false;\n return phase !== 'ringing-in' && phase !== 'ringing-out' && phase !== 'active';\n}\n\nexport function isStalePush(\n sentAt: number | undefined,\n now: number,\n staleAfterMs: number,\n): boolean {\n if (typeof sentAt !== 'number' || !Number.isFinite(sentAt)) return false;\n const age = now - sentAt;\n if (age < 0) return false;\n return age > staleAfterMs;\n}\n\ninterface PushPayload {\n call_id?: string;\n conversation_id?: string;\n caller_user_id?: string;\n caller_name?: string;\n media?: string;\n has_video?: boolean;\n sent_at?: number;\n}\n\n/**\n * Registers this device for VoIP pushes and drives the native call UI.\n *\n * Mount once, as high in the signed-in tree as possible. Does nothing on\n * Android, which needs a separate FCM + ConnectionService integration.\n */\nexport function useVoipCalls({\n voipPush,\n callKeep,\n calls,\n onAnswer,\n onDecline,\n appName = 'poolse',\n apnsEnvironment,\n staleAfterMs = 120_000,\n}: UseVoipCallsOptions): void {\n const poolse = usePoolse();\n\n /** Calls currently shown to CallKit, keyed by call id. */\n const shown = useRef<Map<string, VoipIncomingCall>>(new Map());\n\n // Read at event time so a re-render doesn't tear down and re-register\n // the native listeners.\n const handlers = useRef({ onAnswer, onDecline, calls });\n handlers.current = { onAnswer, onDecline, calls };\n\n const staleRef = useRef(staleAfterMs);\n staleRef.current = staleAfterMs;\n\n /**\n * Resolves once CallKit is configured.\n *\n * On a push-launched app the queued push can be replayed before\n * `setup()` finishes, and reporting into an unconfigured CallKit\n * throws — which iOS treats as a push that was never reported, and\n * kills the app for it. Reports are chained on this instead.\n */\n const ready = useRef<Promise<unknown>>(Promise.resolve());\n\n // Which reported calls the user actually answered.\n //\n // A CallKit \"endCall\" means two different things depending on this: a\n // call ended while ringing was refused, one ended after answering was\n // hung up. They travel as different signals, and sending the wrong one\n // leaves the other side thinking the call is still going.\n const answered = useRef(new Set<string>());\n\n /** Take a call down in CallKit — the island stays stuck until we do. */\n const dismiss = useRef((callId: string) => {\n answered.current.delete(callId);\n if (!shown.current.has(callId)) return;\n shown.current.delete(callId);\n try {\n callKeep.endCall(callId);\n } catch {\n // Ending a call CallKit has already forgotten is not an error.\n }\n });\n\n /**\n * Report a call to CallKit.\n *\n * ALWAYS reports, with no early return before\n * `displayIncomingCall`. iOS terminates an app that accepts a VoIP\n * push without reporting a call — so skipping the report to\n * deduplicate, or because the push looked stale, crashes the app\n * instead of quietly ignoring the call.\n *\n * Deduplication needs no help from us: CallKit keys calls by UUID, so\n * reporting the same `callId` twice updates the existing call rather\n * than creating a second one. That is what makes it safe for the\n * socket and the push to both report the same call.\n *\n * A stale call is reported and then immediately ended, which satisfies\n * the contract and still spares the user a ring they cannot answer.\n */\n const present = useRef((call: VoipIncomingCall, sentAt?: number) => {\n shown.current.set(call.callId, call);\n\n const show = () => {\n try {\n callKeep.displayIncomingCall(\n call.callId,\n call.callerUserId,\n call.callerName,\n 'generic',\n call.media === 'video',\n );\n } catch {\n // Never let a reporting failure propagate: an exception here\n // takes the whole app down on a path iOS is already watching.\n }\n };\n\n const done = () => {\n show();\n try {\n // Only after the call is reported. Handing the completion back\n // first would tell iOS we were finished while CallKit still had\n // nothing to show, which is the case it terminates apps over.\n voipPush.onVoipNotificationCompleted?.(call.callId);\n } catch {\n // Same reasoning as above — never throw on this path.\n }\n };\n\n // `.then` on an already-resolved promise still defers a tick, which\n // is immaterial next to the seconds iOS allows — and far cheaper\n // than reporting before CallKit is ready.\n void ready.current.then(done, done);\n\n if (isStalePush(sentAt, Date.now(), staleRef.current)) dismiss.current(call.callId);\n });\n\n useEffect(() => {\n let cancelled = false;\n\n const fromPush = (payload: PushPayload) => {\n const callId = payload.call_id;\n const conversationId = payload.conversation_id;\n if (!callId || !conversationId) return;\n\n present.current(\n {\n callId,\n conversationId,\n callerUserId: payload.caller_user_id ?? '',\n callerName: payload.caller_name ?? 'Incoming call',\n // `has_video` is what older servers sent; `media` supersedes\n // it. Either says video, and the system UI offers video.\n media: payload.media === 'video' || payload.has_video ? 'video' : 'audio',\n },\n payload.sent_at,\n );\n };\n\n ready.current = callKeep\n .setup({\n ios: { appName },\n android: {\n alertTitle: 'Permissions required',\n alertDescription: 'Allow calls from this app',\n cancelButton: 'Cancel',\n okButton: 'ok',\n additionalPermissions: [],\n },\n })\n .catch(() => {\n // A failed setup shouldn't take the app down. Reports still go\n // out afterwards — a rejected setup often still leaves CallKit\n // usable, and not reporting is the one outcome iOS punishes.\n });\n\n // PushKit issues a token on every launch and may rotate it, so\n // register whatever we're given rather than caching.\n voipPush.addEventListener('register', ((token: string) => {\n if (cancelled || !token) return;\n void poolse.devices\n .register({\n token,\n platform: 'ios',\n environment: apnsEnvironment ?? guessApnsEnvironment(),\n })\n .catch(() => {\n // Offline at launch is normal; the next launch re-registers.\n });\n }) as (payload: unknown) => void);\n\n voipPush.addEventListener('notification', ((payload: PushPayload) => {\n fromPush(payload);\n }) as (payload: unknown) => void);\n\n // Pushes that landed while the bundle was still starting are replayed\n // here. Without this a cold-launch call is lost — the very case this\n // exists for — but they are also the likeliest to be stale, so they\n // go through the same age check.\n voipPush.addEventListener('didLoadWithEvents', ((\n events: Array<{ name: string; data: unknown }>,\n ) => {\n for (const event of events ?? []) {\n if (event.name === 'RNVoipPushRemoteNotificationReceivedEvent') {\n fromPush(event.data as PushPayload);\n }\n }\n }) as (payload: unknown) => void);\n\n callKeep.addEventListener('answerCall', (({ callUUID }: { callUUID: string }) => {\n const call = shown.current.get(callUUID);\n\n // Deliberately KEPT in `shown`. Removing it here left nothing to\n // end when the user later hung up, so the system call stayed live\n // on the phone with the app no longer in it.\n answered.current.add(callUUID);\n\n try {\n callKeep.setCurrentCallActive?.(callUUID);\n } catch {\n // Older CallKeep builds lack this; the call still connects.\n }\n\n // The map is empty after a relaunch — iOS can kill and restart the\n // app between reporting the call and the user answering it. Falling\n // back to the hook's own state means answering still works instead\n // of silently doing nothing.\n if (!call) {\n void handlers.current.calls?.accept();\n return;\n }\n\n // Accept through the shared state machine so the in-app UI moves to\n // 'active' too. The explicit argument matters: on a cold launch the\n // hook has no `incoming` state, and the push payload is the only\n // record of what is being answered.\n void handlers.current.calls?.accept({\n callId: call.callId,\n conversationId: call.conversationId,\n callerUserId: call.callerUserId,\n media: call.media,\n });\n handlers.current.onAnswer?.(call);\n }) as (payload: unknown) => void);\n\n callKeep.addEventListener('endCall', (({ callUUID }: { callUUID: string }) => {\n const call = shown.current.get(callUUID);\n const wasAnswered = answered.current.has(callUUID);\n shown.current.delete(callUUID);\n answered.current.delete(callUUID);\n\n // Same relaunch case as answerCall: end whatever the hook thinks\n // is live rather than leaving a call the user has dismissed.\n //\n // An answered call takes the same route: it is no longer an\n // invitation to refuse, so it hangs up like the in-app button and\n // the other side is told the call ended.\n if (!call || wasAnswered) {\n void handlers.current.calls?.hangUp();\n return;\n }\n\n void handlers.current.calls?.decline({\n callId: call.callId,\n conversationId: call.conversationId,\n callerUserId: call.callerUserId,\n media: call.media,\n });\n handlers.current.onDecline?.(call);\n }) as (payload: unknown) => void);\n\n voipPush.registerVoipToken();\n\n return () => {\n cancelled = true;\n voipPush.removeEventListener('register');\n voipPush.removeEventListener('notification');\n voipPush.removeEventListener('didLoadWithEvents');\n callKeep.removeEventListener('answerCall');\n callKeep.removeEventListener('endCall');\n };\n }, [poolse, voipPush, callKeep, appName, apnsEnvironment]);\n\n // ── keep CallKit in step with the call's actual state ───────────────\n\n const incoming: IncomingCall | null = calls?.incoming ?? null;\n const phase = calls?.phase;\n\n // A call that reached us over the socket has to be shown too, or a\n // foregrounded app rings only in-app while the lock screen stays\n // silent — and answering from the island then does nothing.\n useEffect(() => {\n if (phase === 'ringing-in' && incoming) {\n present.current({\n callId: incoming.callId,\n conversationId: incoming.conversationId,\n callerUserId: incoming.callerUserId,\n callerName: incoming.callerUserId,\n media: incoming.media,\n });\n }\n }, [phase, incoming]);\n\n // End the system call once the poolse call is genuinely over — see\n // `isCallOver`.\n useEffect(() => {\n if (!isCallOver(phase)) return;\n for (const callId of [...shown.current.keys()]) dismiss.current(callId);\n }, [phase]);\n}\n\n/**\n * Last-resort guess when `apnsEnvironment` isn't supplied.\n *\n * `__DEV__` reflects the JS bundle, not the `aps-environment`\n * entitlement, and the two disagree for any ad-hoc or TestFlight build.\n * Prefer passing the value explicitly, derived from the same source as\n * the entitlement.\n */\nfunction guessApnsEnvironment(): 'production' | 'sandbox' {\n return __DEV__ ? 'sandbox' : 'production';\n}\n"]}
|
|
1
|
+
{"version":3,"sources":["../src/theme/default.ts","../src/theme/PoolseTheme.tsx","../src/primitives/userColor.ts","../src/primitives/Avatar.tsx","../src/primitives/icons-data.ts","../src/primitives/PoolseIcon.tsx","../src/MemberList.tsx","../src/internal/useDismissableSheet.ts","../src/GroupDetailsSheet.tsx","../src/ChatHeader.tsx","../src/ConversationList.tsx","../src/internal/uploadContext.tsx","../src/AttachmentPicker.tsx","../src/DaySeparator.tsx","../src/UploadQueueStrip.tsx","../src/internal/safeArea.ts","../src/MessageComposer.tsx","../src/MentionInput.tsx","../src/MessageList.tsx","../src/MessageActions.tsx","../src/AttachmentPreview.tsx","../src/ImageMosaic.tsx","../src/internal/markdown.ts","../src/MessageBubble.tsx","../src/Reactions.tsx","../src/MessageRow.tsx","../src/ThreadView.tsx","../src/UserName.tsx","../src/TypingIndicator.tsx","../src/ConversationView.tsx","../src/internal/UserPickerSheet.tsx","../src/PoolseInbox.tsx","../src/primitives/PoolseLogo.tsx","../src/primitives/index.ts","../src/lifecycle/useAppStateLifecycle.tsx","../src/voice/webrtc-native.ts","../src/VoiceRoomBar.tsx","../src/voice/callTheme.ts","../src/voice/AudioRouteSheet.tsx","../src/voice/CallAvatar.tsx","../src/voice/CallControlButton.tsx","../src/voice/CallParticipantTile.tsx","../src/voice/LocalVideoPip.tsx","../src/voice/CallVideoGrid.tsx","../src/voice/livekit-rn.ts","../src/voice/useCallAudio.ts","../src/voice/useCallDuration.ts","../src/CallScreen.tsx","../src/voice/useVoipCalls.ts"],"names":["createContext","useMemo","useContext","jsxs","View","jsx","Image","Text","StyleSheet","SvgXml","useMembers","usePresence","styles","ActivityIndicator","FlatList","Fragment","useUser","Pressable","useRef","Animated","PanResponder","useConversation","useWindowDimensions","Modal","useMe","useState","useConversations","useAttachmentUpload","useCallback","RNImage","manipulateAsync","SaveFormat","ImagePicker","res","DocumentPicker","ScrollView","Platform","forwardRef","MessageComposer","useEffect","Keyboard","useImperativeHandle","TextInput","useAttachmentUrl","formatBytes","Dimensions","MarkdownIt","createElement","Markdown","radii","Linking","sameDay","useReactions","Clipboard","useThread","KeyboardAvoidingView","Easing","useMessages","useTyping","useRealtimeStatus","AppState","computeGroupPosition","formatDayLabel","PoolseInbox","Svg","Path","Circle","G","usePoolse","useVoiceRoom","ICONS","width","useSafeAreaInsets","useCalls","useCallRoom","visible","StatusBar"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAKA,IAAM,WAAA,GAAc;AAAA,EAClB,KAAA,EAAO,SAAA;AAAA,EACP,WAAA,EAAa,SAAA;AAAA,EACb,SAAA,EAAW,SAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,SAAA;AAAA,EACV,GAAA,EAAK,SAAA;AAAA,EACL,IAAA,EAAM,SAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,SAAA;AAAA,EACV,OAAA,EAAS,SAAA;AAAA,EACT,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,IAAA,EAAM,SAAA;AAAA,EACN,UAAA,EAAY,SAAA;AAAA,EACZ,cAAA,EAAgB,SAAA;AAAA,EAChB,WAAA,EAAa,SAAA;AAAA,EACb,eAAA,EAAiB,SAAA;AAAA,EACjB,UAAA,EAAY,SAAA;AAAA,EACZ,cAAA,EAAgB;AAClB,CAAA;AAEA,IAAM,UAAA,GAAa;AAAA,EACjB,KAAA,EAAO,SAAA;AAAA,EACP,WAAA,EAAa,SAAA;AAAA,EACb,SAAA,EAAW,SAAA;AAAA,EACX,OAAA,EAAS,SAAA;AAAA,EACT,KAAA,EAAO,SAAA;AAAA,EACP,OAAA,EAAS,SAAA;AAAA,EACT,QAAA,EAAU,SAAA;AAAA,EACV,GAAA,EAAK,SAAA;AAAA,EACL,IAAA,EAAM,SAAA;AAAA,EACN,IAAA,EAAM,SAAA;AAAA,EACN,MAAA,EAAQ,SAAA;AAAA,EACR,QAAA,EAAU,SAA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A,IACxC,CAAA;AAAA,EACF,GAAG,CAAC,MAAA,EAAQ,UAAU,QAAA,EAAU,OAAA,EAAS,eAAe,CAAC,CAAA;AAIzD,EAAA,MAAM,QAAA,GAAgC,OAAO,QAAA,IAAY,IAAA;AACzD,EAAA,MAAM,QAAQ,KAAA,EAAO,KAAA;AAKrB,EAAAA,gBAAU,MAAM;AACd,IAAA,IAAI,KAAA,KAAU,gBAAgB,QAAA,EAAU;AACtC,MAAA,OAAA,CAAQ,OAAA,CAAQ;AAAA,QACd,QAAQ,QAAA,CAAS,MAAA;AAAA,QACjB,gBAAgB,QAAA,CAAS,cAAA;AAAA,QACzB,cAAc,QAAA,CAAS,YAAA;AAAA,QACvB,YAAY,QAAA,CAAS,YAAA;AAAA,QACrB,OAAO,QAAA,CAAS;AAAA,OACjB,CAAA;AAAA,IACH;AAAA,EACF,CAAA,EAAG,CAAC,KAAA,EAAO,QAAQ,CAAC,CAAA;AAIpB,EAAAA,gBAAU,MAAM;AACd,IAAA,IAAI,CAAC,UAAA,CAAW,KAAK,CAAA,EAAG;AACxB,IAAA,KAAA,MAAW,MAAA,IAAU,CAAC,GAAG,KAAA,CAAM,OAAA,CAAQ,MAAM,CAAA,EAAG,OAAA,CAAQ,OAAA,CAAQ,MAAM,CAAA;AAAA,EACxE,CAAA,EAAG,CAAC,KAAK,CAAC,CAAA;AACZ;AAUA,SAAS,oBAAA,GAAiD;AACxD,EAAA,OAAO,UAAU,SAAA,GAAY,YAAA;AAC/B","file":"index.cjs","sourcesContent":["import type { PoolseRNTheme, ThemeShadows } from './types.js';\n\n// Values mirror the --poolse-* CSS variables in @poolse/react-ui's\n// styles.css :root block. If the brand changes there, change here.\n\nconst lightColors = {\n brand: '#ff5436',\n brandStrong: '#d63415',\n brandSoft: '#ffe9e2',\n onBrand: '#fbf7f4',\n paper: '#fbf7f4',\n surface: '#ffffff',\n surface2: '#f4eee9',\n ink: '#1c1a19',\n ink2: '#6b6560',\n ink3: '#9a938c',\n border: '#eae3dc',\n presence: '#16c172',\n success: '#16a34a',\n warning: '#e08c16',\n error: '#e5484d',\n info: '#3b82f6',\n selfBubble: '#ff5436',\n selfBubbleText: '#fbf7f4',\n otherBubble: '#ffffff',\n otherBubbleText: '#1c1a19',\n unreadPill: '#ff5436',\n unreadPillText: '#fbf7f4',\n};\n\nconst darkColors = {\n brand: '#ff6a4d',\n brandStrong: '#ff8366',\n brandSoft: '#2c1712',\n onBrand: '#fbf7f4',\n paper: '#0e0d10',\n surface: '#16141a',\n surface2: '#201d25',\n ink: '#f6f2ee',\n ink2: '#a8a29b',\n ink3: '#766f68',\n border: '#2a2630',\n presence: '#22d37a',\n success: '#34d399',\n warning: '#fbbf24',\n error: '#f87171',\n info: '#60a5fa',\n selfBubble: '#ff6a4d',\n selfBubbleText: '#fbf7f4',\n otherBubble: '#16141a',\n otherBubbleText: '#f6f2ee',\n unreadPill: '#ff6a4d',\n unreadPillText: '#fbf7f4',\n};\n\nconst type = {\n // RN can't use Bricolage/Hanken/JetBrains without expo-font setup,\n // so we default to the platform sans-serif. Devs override via the\n // theme prop if they ship custom fonts.\n fontDisplay: 'System',\n fontBody: 'System',\n fontMono: 'Menlo',\n bodySize: 15,\n lineHeight: 22,\n weightRegular: '400' as const,\n weightMedium: '500' as const,\n weightSemibold: '600' as const,\n weightBold: '700' as const,\n};\n\nconst radii = {\n sm: 8,\n md: 12,\n lg: 16,\n xl: 24,\n pill: 999,\n bubble: 16,\n};\n\nconst spacing = {\n xs: 4,\n sm: 8,\n md: 12,\n lg: 16,\n xl: 24,\n};\n\nconst lightShadows: ThemeShadows = {\n sm: {\n shadowColor: '#1c1a19',\n shadowOpacity: 0.08,\n shadowOffset: { width: 0, height: 1 },\n shadowRadius: 2,\n elevation: 1,\n },\n md: {\n shadowColor: '#1c1a19',\n shadowOpacity: 0.18,\n shadowOffset: { width: 0, height: 10 },\n shadowRadius: 30,\n elevation: 6,\n },\n lg: {\n shadowColor: '#1c1a19',\n shadowOpacity: 0.28,\n shadowOffset: { width: 0, height: 24 },\n shadowRadius: 60,\n elevation: 12,\n },\n};\n\nconst darkShadows: ThemeShadows = {\n sm: {\n shadowColor: '#000000',\n shadowOpacity: 0.4,\n shadowOffset: { width: 0, height: 1 },\n shadowRadius: 2,\n elevation: 1,\n },\n md: {\n shadowColor: '#000000',\n shadowOpacity: 0.55,\n shadowOffset: { width: 0, height: 10 },\n shadowRadius: 30,\n elevation: 6,\n },\n lg: {\n shadowColor: '#000000',\n shadowOpacity: 0.7,\n shadowOffset: { width: 0, height: 24 },\n shadowRadius: 60,\n elevation: 12,\n },\n};\n\nexport const defaultLightTheme: PoolseRNTheme = {\n mode: 'light',\n colors: lightColors,\n type,\n radii,\n spacing,\n shadows: lightShadows,\n};\n\nexport const defaultDarkTheme: PoolseRNTheme = {\n mode: 'dark',\n colors: darkColors,\n type,\n radii,\n spacing,\n shadows: darkShadows,\n};\n","import { createContext, useContext, useMemo, type ReactNode } from 'react';\n\nimport { defaultDarkTheme, defaultLightTheme } from './default.js';\nimport type { PoolseRNTheme, PoolseRNThemeOverrides, ThemeMode } from './types.js';\n\nconst ThemeContext = createContext<PoolseRNTheme | null>(null);\n\nexport interface PoolseThemeProps {\n /**\n * Light or dark base palette. Overrides are merged on top of the\n * chosen base. Defaults to `light` if omitted.\n */\n mode?: ThemeMode;\n /**\n * Partial overrides — only the fields you set replace the defaults.\n * Nested groups (`colors`, `type`, `radii`, `spacing`, `shadows`)\n * deep-merge, so `{ colors: { brand: '#000' } }` keeps every other\n * color from the base theme.\n */\n theme?: PoolseRNThemeOverrides;\n children: ReactNode;\n}\n\nexport function PoolseTheme({ mode, theme, children }: PoolseThemeProps) {\n const resolved = useMemo(() => {\n const base = (mode ?? theme?.mode) === 'dark' ? defaultDarkTheme : defaultLightTheme;\n if (!theme) return base;\n return {\n mode: theme.mode ?? base.mode,\n colors: { ...base.colors, ...theme.colors },\n type: { ...base.type, ...theme.type },\n radii: { ...base.radii, ...theme.radii },\n spacing: { ...base.spacing, ...theme.spacing },\n shadows: {\n sm: { ...base.shadows.sm, ...theme.shadows?.sm },\n md: { ...base.shadows.md, ...theme.shadows?.md },\n lg: { ...base.shadows.lg, ...theme.shadows?.lg },\n },\n } satisfies PoolseRNTheme;\n }, [mode, theme]);\n\n return <ThemeContext.Provider value={resolved}>{children}</ThemeContext.Provider>;\n}\n\n/**\n * Read the active poolse theme. Falls back to `defaultLightTheme`\n * if no `<PoolseTheme>` ancestor is mounted, so components render\n * sensibly even without explicit wiring.\n */\nexport function usePoolseTheme(): PoolseRNTheme {\n return useContext(ThemeContext) ?? defaultLightTheme;\n}\n","// Mirror of @poolse/react-ui's userColor — deterministic per-user\n// color from the same 8-hue palette.\n\nconst PALETTE = [\n '#6366f1', // indigo\n '#10b981', // emerald\n '#f59e0b', // amber\n '#ec4899', // rose\n '#0ea5e9', // sky\n '#8b5cf6', // violet\n '#14b8a6', // teal\n '#d946ef', // fuchsia\n];\n\nexport function userColor(id: string): string {\n let h = 0;\n for (let i = 0; i < id.length; i++) {\n h = (h * 31 + id.charCodeAt(i)) | 0;\n }\n return PALETTE[Math.abs(h) % PALETTE.length]!;\n}\n","import { Image, StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\nimport { userColor } from './userColor.js';\n\nexport interface AvatarProps {\n /** URL to a profile image. Falls back to initials when omitted. */\n src?: string | null;\n /** Used for initials. */\n name?: string | null;\n /** Stable color seed (typically the user's external_id). */\n seed?: string | null;\n /** Show a green presence dot in the bottom-right corner. */\n online?: boolean;\n /** Size variant. `md` → 40px, `sm` → 28px, `lg` → 56px. */\n size?: 'sm' | 'md' | 'lg';\n}\n\nconst SIZES = { sm: 28, md: 40, lg: 56 } as const;\n\nexport function Avatar({ src, name, seed, online, size = 'md' }: AvatarProps) {\n const theme = usePoolseTheme();\n const dim = SIZES[size];\n const initials = computeInitials(name);\n const tint = seed ? userColor(seed) : theme.colors.brand;\n const fontSize = size === 'sm' ? 11 : size === 'lg' ? 22 : 15;\n\n return (\n <View\n style={[\n styles.root,\n {\n width: dim,\n height: dim,\n borderRadius: dim / 2,\n backgroundColor: tint,\n },\n ]}\n accessibilityRole=\"image\"\n accessibilityLabel={name ?? 'avatar'}\n >\n {src ? (\n <Image\n source={{ uri: src }}\n style={{ width: dim, height: dim, borderRadius: dim / 2 }}\n accessible={false}\n />\n ) : (\n <Text\n style={{\n color: theme.colors.onBrand,\n fontSize,\n fontWeight: '600',\n fontFamily: theme.type.fontBody,\n }}\n >\n {initials}\n </Text>\n )}\n {online ? (\n <View\n style={[\n styles.presence,\n {\n backgroundColor: theme.colors.presence,\n borderColor: theme.colors.surface,\n width: dim * 0.32,\n height: dim * 0.32,\n borderRadius: dim * 0.16,\n },\n ]}\n />\n ) : null}\n </View>\n );\n}\n\nfunction computeInitials(name: string | null | undefined): string {\n if (!name) return '?';\n const parts = name.trim().split(/\\s+/).slice(0, 2);\n return (\n parts\n .map((p) => p.charAt(0).toUpperCase())\n .join('')\n .slice(0, 2) || '?'\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n alignItems: 'center',\n justifyContent: 'center',\n overflow: 'visible',\n },\n presence: {\n position: 'absolute',\n bottom: 0,\n right: 0,\n borderWidth: 2,\n },\n});\n","// AUTO-GENERATED from poolse-brand-kit/icons/. Do not edit by hand.\n// Run scripts/build-icons.py from the brand kit if the source SVGs change.\n\nexport interface IconDef {\n vb: string;\n d: string;\n}\n\nexport const ICONS = {\n attachment: {\n vb: '0 0 24 24',\n d: '<path d=\"M20 11.6 11.4 20.2a5 5 0 0 1-7.1-7.1l8.7-8.7a3.3 3.3 0 0 1 4.7 4.7l-8.6 8.6a1.65 1.65 0 0 1-2.36-2.32l7.86-7.86\"/>',\n },\n bell: {\n vb: '0 0 24 24',\n d: '<path d=\"M6 9.2a6 6 0 0 1 12 0c0 4.8 1.4 6.3 1.9 6.8H4.1C4.6 15.5 6 14 6 9.2Z\"/><path d=\"M9.6 19.8a2.5 2.5 0 0 0 4.8 0\"/>',\n },\n bluetooth: {\n vb: '0 0 24 24',\n d: '<path d=\"M7.5 7.5 16.5 16.5 12 21V3l4.5 4.5L7.5 16.5\"/>',\n },\n camera: {\n vb: '0 0 24 24',\n d: '<path d=\"M3 8.5a2 2 0 0 1 2-2h2.4l1.4-2h6.4l1.4 2H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-9Z\"/><circle cx=\"12\" cy=\"13\" r=\"3.5\"/>',\n },\n 'camera-flip': {\n vb: '0 0 24 24',\n d: '<path d=\"M3 8.5a2 2 0 0 1 2-2h2.4l1.4-2h6.4l1.4 2H19a2 2 0 0 1 2 2v9a2 2 0 0 1-2 2H5a2 2 0 0 1-2-2v-9Z\"/><path d=\"M14.6 13a2.6 2.6 0 0 1-4.5 1.8\"/><path d=\"M9.4 13a2.6 2.6 0 0 1 4.5-1.8\"/><path d=\"M13.9 9.6v1.7h-1.7\"/><path d=\"M10.1 16.4v-1.7h1.7\"/>',\n },\n 'check-double': {\n vb: '0 0 24 24',\n d: '<path d=\"M2.5 12.8 6.9 17 15.4 7.6\"/><path d=\"M11.4 16.4 12.3 17.2 21 7.6\"/>',\n },\n check: {\n vb: '0 0 24 24',\n d: '<path d=\"M4.5 12.6 9.4 17.4 19.5 6.6\"/>',\n },\n 'chevron-down': {\n vb: '0 0 24 24',\n d: '<path d=\"M5 9 12 16 19 9\"/>',\n },\n 'chevron-right': {\n vb: '0 0 24 24',\n d: '<path d=\"M9 5 16 12 9 19\"/>',\n },\n 'chevron-up': {\n vb: '0 0 24 24',\n d: '<path d=\"M6 14.5 12 8.5 18 14.5\"/>',\n },\n close: {\n vb: '0 0 24 24',\n d: '<path d=\"M6 6 18 18M18 6 6 18\"/>',\n },\n code: {\n vb: '0 0 24 24',\n d: '<path d=\"M9 7.5 4.5 12 9 16.5\"/><path d=\"M15 7.5 19.5 12 15 16.5\"/><path d=\"M13.2 5 10.8 19\"/>',\n },\n compose: {\n vb: '0 0 24 24',\n d: '<path d=\"M11.5 4H6a2.5 2.5 0 0 0-2.5 2.5V18A2.5 2.5 0 0 0 6 20.5h11.5A2.5 2.5 0 0 0 20 18v-5.5\"/><path d=\"M18.4 2.7a2.05 2.05 0 0 1 2.9 2.9L12 15l-4 1 1-4 9.4-9.3Z\"/>',\n },\n copy: {\n vb: '0 0 24 24',\n d: '<rect x=\"8.4\" y=\"8.4\" width=\"11.2\" height=\"11.2\" rx=\"2.3\"/><path d=\"M5.6 15.6H5A1.6 1.6 0 0 1 3.4 14V5A1.6 1.6 0 0 1 5 3.4h9A1.6 1.6 0 0 1 15.6 5v.6\"/>',\n },\n download: {\n vb: '0 0 24 24',\n d: '<path d=\"M12 3.2v11.6\"/><path d=\"M7.4 10.2 12 14.8 16.6 10.2\"/><path d=\"M4 19.6h16\"/>',\n },\n edit: {\n vb: '0 0 24 24',\n d: '<path d=\"M16.7 3.3a2.1 2.1 0 0 1 3 3L7 19l-4 1 1-4 12.7-12.7Z\"/>',\n },\n emoji: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"8.6\"/><circle cx=\"9\" cy=\"10\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"15\" cy=\"10\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/><path d=\"M8.4 14.2a4.6 4.6 0 0 0 7.2 0\"/>',\n },\n headphones: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 14v-2a8 8 0 0 1 16 0v2\"/><path d=\"M4 14h2.6a1.4 1.4 0 0 1 1.4 1.4v3.2A1.4 1.4 0 0 1 6.6 20H5.4A1.4 1.4 0 0 1 4 18.6Z\"/><path d=\"M20 14h-2.6a1.4 1.4 0 0 0-1.4 1.4v3.2A1.4 1.4 0 0 0 17.4 20h1.2A1.4 1.4 0 0 0 20 18.6Z\"/>',\n },\n heart: {\n vb: '0 0 24 24',\n d: '<path d=\"M12 20.3 4.4 12.9a4.6 4.6 0 1 1 6.5-6.5l1.1 1.1 1.1-1.1a4.6 4.6 0 1 1 6.5 6.5L12 20.3Z\"/>',\n },\n image: {\n vb: '0 0 24 24',\n d: '<rect x=\"3.2\" y=\"4.2\" width=\"17.6\" height=\"15.6\" rx=\"2.6\"/><circle cx=\"8.6\" cy=\"9.4\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/><path d=\"M20.8 15.8 16 11 6 19.8\"/>',\n },\n info: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"8.6\"/><path d=\"M12 11v5.2\"/><circle cx=\"12\" cy=\"7.7\" r=\"1\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n key: {\n vb: '0 0 24 24',\n d: '<circle cx=\"8\" cy=\"8\" r=\"4.4\"/><path d=\"M11.1 11.1 20 20\"/><path d=\"M16.6 16.6 18.6 14.6M14 14l2-2\"/>',\n },\n link: {\n vb: '0 0 24 24',\n d: '<path d=\"M10.2 13.8a3.5 3.5 0 0 0 5 0l3-3a3.5 3.5 0 0 0-5-5l-1.2 1.2\"/><path d=\"M13.8 10.2a3.5 3.5 0 0 0-5 0l-3 3a3.5 3.5 0 0 0 5 5l1.2-1.2\"/>',\n },\n lock: {\n vb: '0 0 24 24',\n d: '<rect x=\"4.6\" y=\"10.4\" width=\"14.8\" height=\"9.8\" rx=\"2.2\"/><path d=\"M8 10.4V7a4 4 0 0 1 8 0v3.4\"/>',\n },\n message: {\n vb: '0 0 24 24',\n d: '<path d=\"M20.5 11.4c0 4.5-3.9 8.1-8.5 8.1a9 9 0 0 1-3.7-.78L3.5 20.5l1.8-4.6A7.9 7.9 0 0 1 3.5 11.4C3.5 6.9 7.4 3.3 12 3.3s8.5 3.6 8.5 8.1Z\"/>',\n },\n messages: {\n vb: '0 0 24 24',\n d: '<path d=\"M14 9.2a4.7 4.7 0 0 1-4.7 4.7H6.8L3.5 16.4v-2.9A4.7 4.7 0 0 1 6.8 4.5h2.5A4.7 4.7 0 0 1 14 9.2Z\"/><path d=\"M9.4 13.6A4.7 4.7 0 0 0 13.6 16h3.6l3.3 2.5v-2.9a4.7 4.7 0 0 0-2.4-4.1\"/>',\n },\n mic: {\n vb: '0 0 24 24',\n d: '<rect x=\"9\" y=\"2.6\" width=\"6\" height=\"11.2\" rx=\"3\"/><path d=\"M5.6 11.2a6.4 6.4 0 0 0 12.8 0\"/><path d=\"M12 17.6v3.4\"/><path d=\"M8.6 21h6.8\"/>',\n },\n 'mic-off': {\n vb: '0 0 24 24',\n d: '<rect x=\"9\" y=\"2.6\" width=\"6\" height=\"11.2\" rx=\"3\"/><path d=\"M5.6 11.2a6.4 6.4 0 0 0 12.8 0\"/><path d=\"M12 17.6v3.4\"/><path d=\"M8.6 21h6.8\"/><path d=\"M3.6 3.2 20.4 20.8\"/>',\n },\n 'more-h': {\n vb: '0 0 24 24',\n d: '<circle cx=\"5.4\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"18.6\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n 'more-v': {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"5.4\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"18.6\" r=\"1.6\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n phone: {\n vb: '0 0 24 24',\n d: '<path d=\"M6.6 3.5h3l1.5 3.7-1.9 1.4a12.5 12.5 0 0 0 6.2 6.2l1.4-1.9 3.7 1.5v3a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z\"/>',\n },\n 'phone-off': {\n vb: '0 0 24 24',\n d: '<g transform=\"rotate(135 12 12)\"><path d=\"M6.6 3.5h3l1.5 3.7-1.9 1.4a12.5 12.5 0 0 0 6.2 6.2l1.4-1.9 3.7 1.5v3a2 2 0 0 1-2.2 2A16.8 16.8 0 0 1 4.6 5.7a2 2 0 0 1 2-2.2Z\"/></g>',\n },\n pin: {\n vb: '0 0 24 24',\n d: '<path d=\"M9 3.4h6v1.8l-1 5.6 3 3.2H7l3-3.2-1-5.6V3.4Z\"/><path d=\"M12 17v3.6\"/>',\n },\n plus: {\n vb: '0 0 24 24',\n d: '<path d=\"M12 5v14M5 12h14\"/>',\n },\n presence: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"9\" fill=\"currentColor\" opacity=\"0.18\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"5\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n pulse: {\n vb: '0 0 24 24',\n d: '<path d=\"M3 13h4.6l2.2-4.6 3.4 9 2.2-4.4H21\"/>',\n },\n reply: {\n vb: '0 0 24 24',\n d: '<path d=\"M9 7 4 12l5 5\"/><path d=\"M4 12h9.5a6.5 6.5 0 0 1 6.5 6.5V20\"/>',\n },\n search: {\n vb: '0 0 24 24',\n d: '<circle cx=\"11\" cy=\"11\" r=\"6.8\"/><path d=\"M20.8 20.8 16 16\"/>',\n },\n 'send-fill': {\n vb: '0 0 24 24',\n d: '<path fill=\"currentColor\" stroke=\"none\" d=\"M21.7 2.3a1 1 0 0 1 .25 1L15.3 21.8a1 1 0 0 1-1.86.06L10.6 14.2 3 11.4a1 1 0 0 1 .06-1.9L20.7 2.05a1 1 0 0 1 1 .25Z\"/>',\n },\n send: {\n vb: '0 0 24 24',\n d: '<path d=\"M21.4 2.6 11 13\"/><path d=\"M21.4 2.6 14.8 21.5a.6.6 0 0 1-1.1.05L11 14l-7.5-2.7a.6.6 0 0 1 .05-1.1L21.4 2.6Z\"/>',\n },\n settings: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"12\" r=\"3.1\"/><path d=\"M12 2.6V5M12 19v2.4M4.2 4.2 5.9 5.9M18.1 18.1l1.7 1.7M2.6 12H5M19 12h2.4M4.2 19.8 5.9 18.1M18.1 5.9l1.7-1.7\"/>',\n },\n sliders: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 7h9M17 7h3\"/><circle cx=\"15\" cy=\"7\" r=\"2.1\"/><path d=\"M4 17h3M11 17h9\"/><circle cx=\"9\" cy=\"17\" r=\"2.1\"/>',\n },\n speaker: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 9.5h3.2L12 5.4v13.2L7.2 14.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z\"/><path d=\"M15.6 9.2a4 4 0 0 1 0 5.6\"/><path d=\"M18.2 6.6a7.7 7.7 0 0 1 0 10.8\"/>',\n },\n 'speaker-off': {\n vb: '0 0 24 24',\n d: '<path d=\"M4 9.5h3.2L12 5.4v13.2L7.2 14.5H4a1 1 0 0 1-1-1v-3a1 1 0 0 1 1-1Z\"/><path d=\"M16.4 9.6 21.4 14.4\"/><path d=\"M21.4 9.6 16.4 14.4\"/>',\n },\n 'thumbs-up': {\n vb: '0 0 24 24',\n d: '<path d=\"M7 10.4V20H4.2V10.4Z\"/><path d=\"M7 10.4 11 3.2a2 2 0 0 1 1.9 2.2L12.4 9H18a2 2 0 0 1 2 2.4l-1.1 6A2 2 0 0 1 16.9 20H7\"/>',\n },\n trash: {\n vb: '0 0 24 24',\n d: '<path d=\"M4 7h16\"/><path d=\"M9.2 7V5.2A1.8 1.8 0 0 1 11 3.4h2a1.8 1.8 0 0 1 1.8 1.8V7\"/><path d=\"M6.2 7 7.2 19A1.9 1.9 0 0 0 9.1 20.7h5.8A1.9 1.9 0 0 0 16.8 19L17.8 7\"/><path d=\"M10.3 11v5M13.7 11v5\"/>',\n },\n typing: {\n vb: '0 0 24 24',\n d: '<circle cx=\"6\" cy=\"12\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"12\" cy=\"12\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/><circle cx=\"18\" cy=\"12\" r=\"1.7\" fill=\"currentColor\" stroke=\"none\"/>',\n },\n 'user-plus': {\n vb: '0 0 24 24',\n d: '<circle cx=\"9\" cy=\"8\" r=\"3.8\"/><path d=\"M3 20a6 6 0 0 1 12 0\"/><path d=\"M18 8v6M15 11h6\"/>',\n },\n user: {\n vb: '0 0 24 24',\n d: '<circle cx=\"12\" cy=\"8\" r=\"4\"/><path d=\"M4.6 20a7.4 7.4 0 0 1 14.8 0\"/>',\n },\n users: {\n vb: '0 0 24 24',\n d: '<circle cx=\"9\" cy=\"8\" r=\"3.6\"/><path d=\"M2.6 20a6.4 6.4 0 0 1 12.8 0\"/><path d=\"M15.8 4.7a3.6 3.6 0 0 1 0 6.6\"/><path d=\"M17.6 20a6.4 6.4 0 0 0-3.1-5.5\"/>',\n },\n video: {\n vb: '0 0 24 24',\n d: '<rect x=\"2.6\" y=\"6\" width=\"13\" height=\"12\" rx=\"2.4\"/><path d=\"M15.6 11.2 21.4 8v8l-5.8-3.2Z\"/>',\n },\n 'video-off': {\n vb: '0 0 24 24',\n d: '<rect x=\"2.6\" y=\"6\" width=\"13\" height=\"12\" rx=\"2.4\"/><path d=\"M15.6 11.2 21.4 8v8l-5.8-3.2Z\"/><path d=\"M3.6 3.2 20.4 20.8\"/>',\n },\n webhook: {\n vb: '0 0 24 24',\n d: '<circle cx=\"6\" cy=\"6\" r=\"2.6\"/><circle cx=\"18\" cy=\"9\" r=\"2.6\"/><circle cx=\"9.5\" cy=\"18\" r=\"2.6\"/><path d=\"M7.9 7.9 12 12l3.7-1.5\"/><path d=\"M11.6 12.7 9.8 16\"/>',\n },\n} as const satisfies Record<string, IconDef>;\n\nexport type IconName = keyof typeof ICONS;\n","import { SvgXml } from 'react-native-svg';\n\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\nimport { ICONS, type IconName } from './icons-data.js';\n\nexport type { IconName };\n\nexport interface PoolseIconProps {\n /** Icon name — see {@link IconName} for the full list. */\n name: IconName;\n /** Width + height in pixels. Defaults to `20` (matches a body-line). */\n size?: number;\n /** Stroke color. Defaults to the theme's `ink` color. */\n color?: string;\n /** Accessibility label. Defaults to the icon name. */\n label?: string | null;\n}\n\nexport function PoolseIcon({ name, size = 20, color, label }: PoolseIconProps) {\n const theme = usePoolseTheme();\n const def = ICONS[name];\n if (!def) return null;\n const stroke = color ?? theme.colors.ink;\n const xml = `<svg xmlns=\"http://www.w3.org/2000/svg\" viewBox=\"${def.vb}\" fill=\"none\" stroke=\"${stroke}\" stroke-width=\"1.8\" stroke-linecap=\"round\" stroke-linejoin=\"round\">${def.d}</svg>`;\n const a11y =\n label === null\n ? { accessibilityRole: 'none' as const }\n : { accessibilityRole: 'image' as const, accessibilityLabel: label ?? name };\n return <SvgXml xml={xml} width={size} height={size} {...a11y} />;\n}\n","import type { MemberRole, Membership, Uuid } from '@poolse/sdk';\nimport { useMembers, usePresence, useUser } from '@poolse/react';\nimport { type ReactNode } from 'react';\nimport { ActivityIndicator, FlatList, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface MemberListProps {\n conversationId: Uuid;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onlineExternalIds?: Set<string>;\n canRemove?: (m: Membership) => boolean;\n renderItem?: (m: Membership) => ReactNode;\n emptyState?: ReactNode | string;\n}\n\nexport function MemberList({\n conversationId,\n labelFor,\n avatarFor,\n onlineExternalIds,\n canRemove,\n renderItem,\n emptyState,\n}: MemberListProps) {\n const theme = usePoolseTheme();\n const { members, loading, error, removeMember } = useMembers(conversationId);\n const { online: presenceOnline } = usePresence(\n onlineExternalIds === undefined ? conversationId : '',\n );\n const effectiveOnline = onlineExternalIds ?? presenceOnline;\n\n if (loading && members.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <ActivityIndicator color={theme.colors.brand} />\n </View>\n );\n }\n\n if (error) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <Text style={{ color: theme.colors.error, fontFamily: theme.type.fontBody }}>\n Failed to load members.\n </Text>\n {error.message ? (\n <Text style={[styles.errorDetail, { color: theme.colors.ink3 }]}>{error.message}</Text>\n ) : null}\n </View>\n );\n }\n\n if (members.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n {typeof emptyState === 'string' || emptyState == null ? (\n <Text style={{ color: theme.colors.ink3, fontFamily: theme.type.fontBody }}>\n {(emptyState as string) ?? 'No members.'}\n </Text>\n ) : (\n emptyState\n )}\n </View>\n );\n }\n\n return (\n <FlatList\n data={members}\n keyExtractor={(m) => m.user_id}\n style={{ backgroundColor: theme.colors.paper }}\n renderItem={({ item }) => {\n if (renderItem) return <>{renderItem(item)}</>;\n const isOnline = effectiveOnline.has(item.external_id);\n const showRemove = canRemove?.(item) ?? false;\n return (\n <MemberRow\n externalId={item.external_id}\n role={item.role}\n online={isOnline}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(showRemove ? { onRemove: () => removeMember(item.external_id) } : {})}\n />\n );\n }}\n />\n );\n}\n\nfunction MemberRow({\n externalId,\n role,\n online,\n labelFor,\n avatarFor,\n onRemove,\n}: {\n externalId: string;\n role: MemberRole;\n online: boolean;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onRemove?: () => void;\n}) {\n const theme = usePoolseTheme();\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n // The previous version used `labelFor?.(id) ?? id` and skipped the\n // resolver entirely when labelFor wasn't passed, defeating the\n // PoolseConfig.userResolver contract for consumers who configured\n // one and expected names + avatars to flow through automatically.\n const resolved = useUser(externalId);\n const name = labelFor?.(externalId) ?? resolved.profile?.displayName ?? externalId;\n const avatarUrl = avatarFor?.(externalId) ?? resolved.profile?.avatarUrl ?? null;\n return (\n <View style={styles.row}>\n <Avatar src={avatarUrl} name={name} seed={externalId} online={online} size=\"md\" />\n <View style={styles.body}>\n <Text\n style={[styles.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {name}\n </Text>\n <Text style={[styles.role, { color: theme.colors.ink3 }]}>{role}</Text>\n </View>\n {onRemove ? (\n <Pressable onPress={onRemove} hitSlop={8} style={styles.removeBtn}>\n <PoolseIcon name=\"close\" size={16} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n placeholder: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 24,\n },\n errorDetail: {\n marginTop: 6,\n fontSize: 11,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingVertical: 8,\n gap: 10,\n },\n body: {\n flex: 1,\n gap: 1,\n },\n name: {\n fontSize: 14,\n fontWeight: '500',\n },\n role: {\n fontSize: 11,\n textTransform: 'capitalize',\n },\n removeBtn: {\n padding: 6,\n },\n});\n","import { useMemo, useRef } from 'react';\nimport { Animated, PanResponder } from 'react-native';\n\ninterface Options {\n /** Called once the dismiss animation completes. */\n onClose: () => void;\n /**\n * Sheet height in pixels — used as the off-screen target when\n * animating dismissal. Pass `Dimensions.get('window').height * 0.85`\n * for a standard 85% bottom sheet.\n */\n sheetHeight: number;\n /**\n * Fraction of sheetHeight the user must drag past to commit\n * dismissal on release. Defaults to 0.22. Quick flicks (high\n * vertical velocity) also commit regardless of distance.\n */\n dismissThreshold?: number;\n}\n\n/**\n * Adds a pull-down-to-dismiss gesture to a bottom sheet. Returns an\n * Animated `translateY` to apply to the sheet's outer wrapper +\n * `panHandlers` to spread on whichever sub-view captures the drag\n * (typically the drag-pill area at the top, OR the whole sheet if\n * you want anywhere-drag to work).\n *\n * Only claims the gesture on clear downward motion; horizontal /\n * upward drags pass through to children (so a FlatList inside the\n * sheet can still scroll normally).\n */\nexport function useDismissableSheet({ onClose, sheetHeight, dismissThreshold = 0.22 }: Options) {\n const translateY = useRef(new Animated.Value(0)).current;\n\n const panResponder = useMemo(\n () =>\n PanResponder.create({\n onMoveShouldSetPanResponder: (_, g) => {\n // Only claim on clear downward intent. Lets the FlatList\n // inside the sheet handle vertical scrolls upward.\n return g.dy > 6 && g.dy > Math.abs(g.dx);\n },\n onPanResponderMove: (_, g) => {\n // Only follow downward drag (positive dy). Upward goes\n // back to 0 — sheet can't be pulled UP past its anchor.\n translateY.setValue(Math.max(0, g.dy));\n },\n onPanResponderRelease: (_, g) => {\n const committed = g.dy > sheetHeight * dismissThreshold || g.vy > 0.6;\n if (committed) {\n // Animate the sheet off-screen, THEN fire onClose. Without\n // this the modal's own slide-out + our reset would fight.\n Animated.timing(translateY, {\n toValue: sheetHeight,\n duration: 180,\n useNativeDriver: true,\n }).start(() => {\n translateY.setValue(0);\n onClose();\n });\n } else {\n Animated.spring(translateY, {\n toValue: 0,\n useNativeDriver: true,\n speed: 22,\n bounciness: 4,\n }).start();\n }\n },\n onPanResponderTerminate: () => {\n Animated.spring(translateY, {\n toValue: 0,\n useNativeDriver: true,\n speed: 22,\n bounciness: 4,\n }).start();\n },\n }),\n [onClose, sheetHeight, dismissThreshold, translateY],\n );\n\n return { translateY, panHandlers: panResponder.panHandlers };\n}\n","import type { Uuid } from '@poolse/sdk';\nimport { useConversation, useMembers } from '@poolse/react';\nimport {\n Animated,\n Modal,\n Pressable,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { MemberList } from './MemberList.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { useDismissableSheet } from './internal/useDismissableSheet.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface GroupDetailsSheetProps {\n visible: boolean;\n onClose: () => void;\n conversationId: Uuid;\n /** Resolve external_id → display name. Same shape as MemberList. */\n labelFor?: (externalId: string) => string;\n /** Resolve external_id → avatar URL. Same shape as MemberList. */\n avatarFor?: (externalId: string) => string | null;\n /**\n * Predicate for the per-row remove button. Defaults to \"never show\"\n * — wire it on the parent for owners/admins. Receives the\n * Membership row so you can scope to roles or exclude self.\n */\n canRemoveMember?: (m: { user_id: string; external_id: string; role: string }) => boolean;\n}\n\n/**\n * Bottom-sheet (85% of screen) that opens when the user taps the\n * group chat header. Shows group name + member count at the top,\n * then a scrollable roster with avatars, display names (resolved\n * through `labelFor` / `userResolver`), role badges, and live\n * presence dots (driven by `MemberList` internally).\n */\nexport function GroupDetailsSheet({\n visible,\n onClose,\n conversationId,\n labelFor,\n avatarFor,\n canRemoveMember,\n}: GroupDetailsSheetProps) {\n const theme = usePoolseTheme();\n const { conversation } = useConversation(conversationId);\n const { members } = useMembers(conversationId);\n const { height: screenHeight } = useWindowDimensions();\n const { translateY, panHandlers } = useDismissableSheet({\n onClose,\n sheetHeight: screenHeight * 0.85,\n });\n\n const title = conversation?.name ?? 'Conversation';\n const subtitle = `${members.length} ${members.length === 1 ? 'member' : 'members'}`;\n\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={onClose}\n statusBarTranslucent\n >\n <View style={styles.modalRoot}>\n <Pressable\n style={styles.backdrop}\n onPress={onClose}\n accessibilityLabel=\"Close group details\"\n />\n\n <Animated.View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.paper,\n borderTopLeftRadius: theme.radii.xl,\n borderTopRightRadius: theme.radii.xl,\n transform: [{ translateY }],\n },\n theme.shadows.lg,\n ]}\n >\n {/* Pan handlers spread on the drag-pill region so list\n scrolling underneath isn't affected. */}\n <View {...panHandlers} style={styles.dragHandle}>\n <View style={[styles.dragPill, { backgroundColor: theme.colors.ink3 }]} />\n </View>\n\n <View style={styles.headerRow}>\n <Pressable\n onPress={onClose}\n hitSlop={16}\n style={[styles.closeBtn, { backgroundColor: theme.colors.surface2 }]}\n accessibilityLabel=\"Close\"\n >\n <PoolseIcon name=\"close\" size={18} color={theme.colors.ink} />\n </Pressable>\n <Text\n style={[\n styles.headerTitle,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n >\n Group details\n </Text>\n </View>\n\n <View style={styles.summary}>\n <Avatar src={null} name={title} seed={conversationId} size=\"lg\" />\n <Text\n style={[\n styles.title,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n numberOfLines={1}\n >\n {title}\n </Text>\n <Text style={[styles.subtitle, { color: theme.colors.ink3 }]}>{subtitle}</Text>\n </View>\n\n <View style={[styles.divider, { backgroundColor: theme.colors.border }]} />\n\n <View style={styles.sectionLabelRow}>\n <Text\n style={[\n styles.sectionLabel,\n { color: theme.colors.ink2, fontFamily: theme.type.fontBody },\n ]}\n >\n Members\n </Text>\n </View>\n\n <View style={{ flex: 1 }}>\n <MemberList\n conversationId={conversationId}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(canRemoveMember ? { canRemove: canRemoveMember } : {})}\n emptyState=\"No members yet.\"\n />\n </View>\n </Animated.View>\n </View>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n modalRoot: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n backdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.4)',\n },\n sheet: {\n height: '85%',\n overflow: 'hidden',\n },\n dragHandle: {\n alignItems: 'center',\n paddingTop: 8,\n paddingBottom: 4,\n },\n dragPill: {\n width: 36,\n height: 4,\n borderRadius: 2,\n opacity: 0.4,\n },\n headerRow: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingTop: 4,\n paddingBottom: 12,\n gap: 10,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n },\n headerTitle: {\n fontSize: 16,\n fontWeight: '600',\n },\n summary: {\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingBottom: 16,\n gap: 8,\n },\n title: {\n fontSize: 20,\n fontWeight: '700',\n },\n subtitle: {\n fontSize: 13,\n },\n divider: {\n height: StyleSheet.hairlineWidth,\n },\n sectionLabelRow: {\n paddingHorizontal: 16,\n paddingTop: 14,\n paddingBottom: 6,\n },\n sectionLabel: {\n fontSize: 11,\n fontWeight: '700',\n letterSpacing: 0.5,\n textTransform: 'uppercase',\n },\n});\n","import type { Uuid } from '@poolse/sdk';\nimport { useConversation, useMe, useMembers, usePresence, useUser } from '@poolse/react';\nimport { useState } from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { GroupDetailsSheet } from './GroupDetailsSheet.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ChatHeaderProps {\n conversationId: Uuid;\n /**\n * Override the title resolver — useful when you want to derive the\n * direct-chat name from your own user directory instead of going\n * through the SDK's `userResolver`. When omitted, falls back to:\n * * direct → the other member's display name (via `useUser`)\n * * group → `conversation.name`\n */\n labelFor?: (externalId: string) => string;\n /** Optional avatar URL resolver for the other party (direct only). */\n avatarFor?: (externalId: string) => string | null;\n /** Right-side icon button — typically opens a member-list sheet. */\n onMembersPress?: () => void;\n /**\n * Tap handler for the whole header. Behavior:\n * * Direct chat → calls this if provided, otherwise no-op.\n * * Group chat → calls this if provided. If omitted, the header\n * opens a built-in group-details sheet showing the member\n * roster with live presence.\n */\n onPress?: () => void;\n /**\n * When provided, renders a back arrow on the LEFT of the header\n * that calls this handler on tap. Used by `<PoolseInbox>` to\n * navigate back to the conversation list; safe to wire from your\n * own navigator too.\n */\n onBack?: () => void;\n}\n\n/**\n * Top-of-chat header bar.\n * * 1:1 direct → other user's display name + avatar + presence dot.\n * * Group → conversation name + \"N members\" + group-tile avatar.\n *\n * Sits above `<MessageList>` inside `<ConversationView>` by default;\n * pass `header={false}` to `<ConversationView>` if you mount your own.\n */\nexport function ChatHeader({\n conversationId,\n labelFor,\n avatarFor,\n onMembersPress,\n onPress,\n onBack,\n}: ChatHeaderProps) {\n const theme = usePoolseTheme();\n const { conversation } = useConversation(conversationId);\n const { members } = useMembers(conversationId);\n const { me } = useMe();\n const { online } = usePresence(conversationId);\n const [detailsOpen, setDetailsOpen] = useState(false);\n\n const isDirect = conversation?.type === 'direct';\n const otherMember = isDirect ? members.find((m) => m.user_id !== me?.id) : null;\n const otherExtId = otherMember?.external_id ?? null;\n // useUser is safe with null — short-circuits to no-op state. Keeps the\n // hook unconditional regardless of conversation type.\n const otherUser = useUser(otherExtId);\n\n if (!conversation) {\n return (\n <View\n style={[\n styles.root,\n {\n backgroundColor: theme.colors.surface,\n borderBottomColor: theme.colors.border,\n },\n ]}\n />\n );\n }\n\n const fallbackName = otherExtId ?? '';\n const directName =\n otherUser.profile?.displayName ??\n (otherExtId ? (labelFor?.(otherExtId) ?? fallbackName) : 'Direct');\n const title = isDirect ? directName : (conversation.name ?? 'Conversation');\n\n const isOnline = isDirect && otherExtId ? online.has(otherExtId) : false;\n const subtitle = isDirect\n ? isOnline\n ? 'Online'\n : null\n : `${members.length} ${members.length === 1 ? 'member' : 'members'}`;\n\n const avatarUrl =\n isDirect && otherExtId\n ? (avatarFor?.(otherExtId) ?? otherUser.profile?.avatarUrl ?? null)\n : null;\n const avatarSeed = isDirect ? (otherExtId ?? conversationId) : conversationId;\n\n // For groups, default tap = open the built-in details sheet.\n // For directs (or when caller supplied onPress), call onPress.\n // A View wrapper is used only when there's no tap target at all\n // (direct chat with no onPress) so we don't render a no-op\n // Pressable that swallows touches.\n const isGroup = !isDirect;\n const headerOnPress = onPress ?? (isGroup ? () => setDetailsOpen(true) : undefined);\n const Wrapper: typeof View | typeof Pressable = headerOnPress ? Pressable : View;\n\n return (\n <>\n <Wrapper\n {...(headerOnPress ? { onPress: headerOnPress } : {})}\n style={[\n styles.root,\n {\n backgroundColor: theme.colors.surface,\n borderBottomColor: theme.colors.border,\n },\n ]}\n >\n {onBack ? (\n <Pressable onPress={onBack} hitSlop={12} style={styles.backBtn} accessibilityLabel=\"Back\">\n <PoolseIcon name=\"reply\" size={20} color={theme.colors.ink} />\n </Pressable>\n ) : null}\n <Avatar src={avatarUrl} name={title} seed={avatarSeed} online={isOnline} size=\"md\" />\n <View style={styles.titleCol}>\n <Text\n style={[styles.title, { color: theme.colors.ink, fontFamily: theme.type.fontDisplay }]}\n numberOfLines={1}\n >\n {title}\n </Text>\n {subtitle ? (\n <Text style={[styles.subtitle, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {subtitle}\n </Text>\n ) : null}\n </View>\n {onMembersPress ? (\n <Pressable\n onPress={onMembersPress}\n hitSlop={12}\n style={styles.actionBtn}\n accessibilityLabel=\"Show members\"\n >\n <PoolseIcon name=\"users\" size={20} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </Wrapper>\n\n {isGroup ? (\n <GroupDetailsSheet\n visible={detailsOpen}\n onClose={() => setDetailsOpen(false)}\n conversationId={conversationId}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n ) : null}\n </>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 14,\n paddingVertical: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 12,\n },\n titleCol: {\n flex: 1,\n gap: 2,\n },\n title: {\n fontSize: 16,\n fontWeight: '600',\n },\n subtitle: {\n fontSize: 12,\n fontWeight: '500',\n },\n actionBtn: {\n width: 36,\n height: 36,\n borderRadius: 18,\n alignItems: 'center',\n justifyContent: 'center',\n },\n backBtn: {\n width: 36,\n height: 36,\n alignItems: 'center',\n justifyContent: 'center',\n marginLeft: -6,\n },\n});\n","import type { Conversation, Uuid } from '@poolse/sdk';\nimport { useConversations, useMe, useUser } from '@poolse/react';\nimport { type ReactNode } from 'react';\nimport {\n ActivityIndicator,\n FlatList,\n Image,\n Pressable,\n StyleSheet,\n Text,\n View,\n} from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ConversationListProps {\n selectedId?: string | null;\n onSelect?: (conv: Conversation) => void;\n /** Optional override for each row's rendering. */\n renderItem?: (conv: Conversation, selected: boolean) => ReactNode;\n /** Custom empty state when there are no conversations. */\n emptyState?: ReactNode | string;\n /** Controlled-mode: skip `useConversations()` and render from these. */\n conversations?: Conversation[];\n loading?: boolean;\n error?: Error | null;\n /** Per-conversation unread counts rendered as a Pulse Coral pill. */\n unreadCounts?: Record<Uuid, number>;\n /**\n * Explicit overrides for direct-chat names + avatars, keyed by the\n * OTHER member's external_id. When omitted, the row falls back to\n * `PoolseConfig.userResolver` and finally to the external_id.\n */\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n}\n\nexport function ConversationList({\n selectedId,\n onSelect,\n renderItem,\n emptyState,\n conversations: controlled,\n loading: controlledLoading,\n error: controlledError,\n unreadCounts,\n labelFor,\n avatarFor,\n}: ConversationListProps) {\n const theme = usePoolseTheme();\n const auto = useConversations();\n const { me } = useMe();\n const meExternalId = me?.external_id ?? null;\n const isControlled = controlled !== undefined;\n const conversations = isControlled ? controlled : auto.conversations;\n const loading = isControlled ? (controlledLoading ?? false) : auto.loading;\n const error = isControlled ? (controlledError ?? null) : auto.error;\n const counts = unreadCounts ?? (isControlled ? undefined : auto.unreadCounts);\n\n if (loading && conversations.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <ActivityIndicator color={theme.colors.brand} />\n </View>\n );\n }\n\n if (error) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <Text style={{ color: theme.colors.error, fontFamily: theme.type.fontBody }}>\n Failed to load conversations.\n </Text>\n </View>\n );\n }\n\n if (conversations.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n {typeof emptyState === 'string' || emptyState == null ? (\n <Text style={{ color: theme.colors.ink3, fontFamily: theme.type.fontBody }}>\n {(emptyState as string) ?? 'No conversations yet.'}\n </Text>\n ) : (\n emptyState\n )}\n </View>\n );\n }\n\n return (\n <FlatList\n data={conversations}\n keyExtractor={(c) => c.id}\n style={{ backgroundColor: theme.colors.paper }}\n renderItem={({ item }) => {\n const selected = selectedId === item.id;\n if (renderItem) {\n return <>{renderItem(item, selected)}</>;\n }\n return (\n <ConversationRow\n conv={item}\n selected={selected}\n meExternalId={meExternalId}\n unread={counts?.[item.id] ?? 0}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(onSelect ? { onSelect } : {})}\n />\n );\n }}\n />\n );\n}\n\nfunction ConversationRow({\n conv,\n selected,\n meExternalId,\n unread,\n labelFor,\n avatarFor,\n onSelect,\n}: {\n conv: Conversation;\n selected: boolean;\n meExternalId: string | null;\n unread: number;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onSelect?: (conv: Conversation) => void;\n}) {\n const theme = usePoolseTheme();\n\n // For direct conversations the row title + avatar come from the OTHER\n // member, NOT the conversation itself (which has `name: null` for\n // directs). Find the counterparty's external_id and resolve via the\n // standard priority: explicit prop > userResolver > external_id.\n const isDirect = conv.type === 'direct';\n const otherExtId =\n isDirect && meExternalId\n ? ((conv.member_external_ids ?? []).find((x) => x !== meExternalId) ?? null)\n : null;\n const resolvedOther = useUser(isDirect ? otherExtId : null);\n\n const title = isDirect\n ? otherExtId\n ? (labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId)\n : 'Direct chat'\n : (conv.name ?? 'Untitled conversation');\n const avatarUrl =\n isDirect && otherExtId\n ? (avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null)\n : null;\n const avatarSeed = isDirect ? (otherExtId ?? conv.id) : conv.id;\n\n return (\n <Pressable\n onPress={() => onSelect?.(conv)}\n style={[\n styles.row,\n {\n backgroundColor: selected ? theme.colors.surface2 : 'transparent',\n },\n ]}\n >\n {avatarUrl ? (\n <Image source={{ uri: avatarUrl }} style={styles.rowAvatar} />\n ) : (\n <Avatar src={null} name={title} seed={avatarSeed} size=\"md\" />\n )}\n <View style={styles.body}>\n <Text\n style={[styles.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {title}\n </Text>\n {conv.last_message_preview ? (\n <Text style={[styles.preview, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {conv.last_message_preview}\n </Text>\n ) : conv.last_message_at ? (\n <Text style={[styles.preview, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {formatRelative(conv.last_message_at)}\n </Text>\n ) : null}\n </View>\n {unread > 0 ? (\n <View style={[styles.unreadPill, { backgroundColor: theme.colors.unreadPill }]}>\n <Text style={[styles.unreadText, { color: theme.colors.unreadPillText }]}>\n {unread > 99 ? '99+' : String(unread)}\n </Text>\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nfunction formatRelative(iso: string): string {\n try {\n const d = new Date(iso);\n const now = Date.now();\n const diff = now - d.getTime();\n if (diff < 60_000) return 'just now';\n if (diff < 3600_000) return `${Math.floor(diff / 60_000)}m`;\n if (diff < 86_400_000) return `${Math.floor(diff / 3600_000)}h`;\n return `${Math.floor(diff / 86_400_000)}d`;\n } catch {\n return '';\n }\n}\n\nconst styles = StyleSheet.create({\n placeholder: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 24,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingVertical: 10,\n gap: 10,\n },\n rowAvatar: {\n width: 40,\n height: 40,\n borderRadius: 20,\n },\n body: {\n flex: 1,\n gap: 2,\n },\n name: {\n fontSize: 15,\n fontWeight: '600',\n },\n preview: {\n fontSize: 12,\n },\n unreadPill: {\n minWidth: 22,\n height: 22,\n borderRadius: 11,\n paddingHorizontal: 6,\n alignItems: 'center',\n justifyContent: 'center',\n },\n unreadText: {\n fontSize: 11,\n fontWeight: '700',\n },\n});\n","import { createContext, useCallback, useContext, useRef, type ReactNode } from 'react';\nimport { useAttachmentUpload } from '@poolse/react';\n\ntype UploadState = ReturnType<typeof useAttachmentUpload>;\n\n/**\n * Shared upload-queue value. The SDK's `useAttachmentUpload` creates\n * a private queue per call site — without a provider, each component\n * (picker / composer / strip) ends up with its own queue and uploads\n * never reach the send-with-attachment_ids path.\n *\n * `setPreview` / `getPreview` are an RN-only side channel: the SDK\n * strips the original local file URI when it converts to a Blob, but\n * the queue strip needs the URI to render an Image thumbnail. The\n * picker stashes it here keyed by filename so the strip can read it\n * back during render.\n */\ninterface UploadContextValue {\n upload: UploadState;\n setPreview: (filename: string, uri: string) => void;\n getPreview: (filename: string) => string | null;\n}\n\nconst UploadCtx = createContext<UploadContextValue | null>(null);\n\nexport function UploadProvider({ children }: { children: ReactNode }) {\n const upload = useAttachmentUpload();\n const previews = useRef<Map<string, string>>(new Map());\n\n const setPreview = useCallback((filename: string, uri: string) => {\n previews.current.set(filename, uri);\n }, []);\n\n const getPreview = useCallback((filename: string) => {\n return previews.current.get(filename) ?? null;\n }, []);\n\n return (\n <UploadCtx.Provider value={{ upload, setPreview, getPreview }}>{children}</UploadCtx.Provider>\n );\n}\n\n/**\n * Read the shared upload state. Falls back to a component-local\n * `useAttachmentUpload` when no provider is mounted so the component\n * still functions standalone (but loses preview thumbnails since\n * setPreview won't propagate).\n */\nexport function useSharedUpload(): UploadState {\n const fromCtx = useContext(UploadCtx);\n const fallback = useAttachmentUpload();\n return fromCtx?.upload ?? fallback;\n}\n\n/**\n * Preview-URI side channel for the queue strip's thumbnails. No-op\n * when no provider is mounted (strip falls back to icon placeholder).\n */\nexport function useUploadPreview() {\n const ctx = useContext(UploadCtx);\n return {\n setPreview: ctx?.setPreview ?? (() => undefined),\n getPreview: ctx?.getPreview ?? (() => null),\n };\n}\n","import { Image as RNImage, Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n// Static imports — Metro's bundle graph can only trace literal\n// `import` / `require` calls. The earlier `new Function('m', 'return\n// import(m)')(name)` trick bypassed Metro entirely, so the picker\n// modules were never bundled even when the consumer installed them.\n//\n// Trade-off: if a consumer mounts <AttachmentPicker> without these\n// modules installed, the bundle fails at build time with a clear\n// \"module not found\" rather than the silent runtime warning we had\n// before. Consumers who don't want attachments at all should pass\n// `attachments={false}` to <ConversationView> so this file is never\n// rendered (and tree-shaking can drop the imports in production\n// builds with a real bundler — Metro doesn't tree-shake but the\n// imports add ~12kb total which is acceptable).\nimport * as ImagePicker from 'expo-image-picker';\nimport * as DocumentPicker from 'expo-document-picker';\nimport { manipulateAsync, SaveFormat } from 'expo-image-manipulator';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { useSharedUpload, useUploadPreview } from './internal/uploadContext.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface AttachmentPickerProps {\n visible: boolean;\n onClose: () => void;\n /**\n * Optional adapter that produces upload inputs from a picked file.\n * Override to plug in custom storage / transcoding. Default reads\n * from `expo-image-picker` / `expo-document-picker`.\n */\n onPickInputs?: (kind: 'image' | 'document' | 'camera') => Promise<\n {\n body: { uri: string; name: string; type: string } | Blob | unknown;\n contentType: string;\n byteSize: number;\n filename?: string;\n }[]\n >;\n /**\n * Show the Camera item alongside Photo and File. Defaults true.\n * Disable if your app explicitly doesn't want camera access (some\n * App Store reviewers require an explicit usage description even\n * for the picker entry). Add `NSCameraUsageDescription` to your\n * iOS Info.plist when leaving this on.\n */\n camera?: boolean;\n}\n\n/**\n * Picker sheet wrapping `expo-image-picker` and `expo-document-picker`.\n * Both must be installed (`npx expo install expo-image-picker\n * expo-document-picker`) when this component is mounted — they're\n * declared as optional peers because consumers who pass\n * `attachments={false}` to ConversationView never render this file.\n */\nexport function AttachmentPicker({\n visible,\n onClose,\n onPickInputs,\n camera = true,\n}: AttachmentPickerProps) {\n const theme = usePoolseTheme();\n // Shared queue (via UploadProvider) so the composer sees these\n // uploads and can include them in the next send. Falls back to a\n // local queue when the picker is mounted outside ConversationView.\n const upload = useSharedUpload();\n const { setPreview } = useUploadPreview();\n\n const pickFromKind = async (kind: 'image' | 'document' | 'camera') => {\n try {\n const adapter = onPickInputs ?? defaultAdapter;\n const inputs = await adapter(kind);\n for (const input of inputs) {\n // Stash the original local URI on the shared context so the\n // UploadQueueStrip can render a real thumbnail. The SDK only\n // sees the Blob from here on out.\n const previewUri = (input as { _previewUri?: string })._previewUri ?? null;\n if (previewUri && input.filename) {\n setPreview(input.filename, previewUri);\n }\n void upload.upload(input as never);\n }\n } catch (err) {\n console.warn('[poolse/picker]', err);\n } finally {\n onClose();\n }\n };\n\n return (\n <Modal visible={visible} transparent animationType=\"slide\" onRequestClose={onClose}>\n <Pressable style={styles.backdrop} onPress={onClose}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderTopLeftRadius: theme.radii.lg,\n borderTopRightRadius: theme.radii.lg,\n },\n theme.shadows.lg,\n ]}\n >\n {camera ? (\n <Pressable style={styles.item} onPress={() => pickFromKind('camera')}>\n <PoolseIcon name=\"camera\" size={20} color={theme.colors.ink2} />\n <Text style={[styles.itemText, { color: theme.colors.ink }]}>Camera</Text>\n </Pressable>\n ) : null}\n <Pressable style={styles.item} onPress={() => pickFromKind('image')}>\n <PoolseIcon name=\"image\" size={20} color={theme.colors.ink2} />\n <Text style={[styles.itemText, { color: theme.colors.ink }]}>Photo or video</Text>\n </Pressable>\n <Pressable style={styles.item} onPress={() => pickFromKind('document')}>\n <PoolseIcon name=\"attachment\" size={20} color={theme.colors.ink2} />\n <Text style={[styles.itemText, { color: theme.colors.ink }]}>File</Text>\n </Pressable>\n <Pressable style={styles.cancel} onPress={onClose}>\n <Text style={[styles.itemText, { color: theme.colors.brand }]}>Cancel</Text>\n </Pressable>\n </View>\n </Pressable>\n </Modal>\n );\n}\n\n// RN gives us a local file URI. The SDK's upload PUTs the `body` raw\n// to a presigned S3/R2 URL — those only accept raw bytes, NOT\n// multipart. If we passed the `{ uri, name, type }` object directly,\n// fetch would serialize it as multipart and the bucket would reject\n// the upload silently. So we read the URI as a Blob first (same shape\n// that `<input type=\"file\">` would give on web) and pass that.\nasync function uriToBlob(uri: string): Promise<Blob> {\n const res = await fetch(uri);\n if (!res.ok && res.status !== 0) {\n throw new Error(`failed to read picked file (HTTP ${res.status})`);\n }\n return res.blob();\n}\n\n// Phone-sized output — the fullscreen viewer on a 3x retina display\n// only needs ~1300px on the long edge, and chat bubbles top out at\n// ~960px. 1600 leaves headroom for pinch-zoom without sending the\n// 4000+ px monsters that some screenshots ship with.\nconst COMPRESSION_LONG_SIDE_PX = 1600;\nconst COMPRESSION_QUALITY = 0.75;\n\nfunction getImageSize(uri: string): Promise<{ width: number; height: number }> {\n return new Promise((resolve, reject) => {\n RNImage.getSize(uri, (width, height) => resolve({ width, height }), reject);\n });\n}\n\n/**\n * Resize → WebP @ 0.75 every image before upload. iOS screenshots\n * can be 8–12 MB PNGs and the fullscreen `<Image>` decode of those\n * blocks the JS thread / silently fails on older devices — clipping\n * the long edge to 1600 keeps the per-message payload under ~250kb\n * for typical photos and is still crisp on every phone display.\n *\n * Never upscales. Falls back to the original blob on any failure so\n * a flaky manipulator pass never blocks a send.\n */\nasync function compressImage({\n uri,\n width,\n height,\n filename,\n}: {\n uri: string;\n width?: number;\n height?: number;\n filename?: string;\n}): Promise<{ blob: Blob; contentType: string; filename: string }> {\n let w = width;\n let h = height;\n if (!w || !h) {\n try {\n const size = await getImageSize(uri);\n w = size.width;\n h = size.height;\n } catch {\n w = 0;\n h = 0;\n }\n }\n const longSide = Math.max(w ?? 0, h ?? 0);\n const scale = longSide > COMPRESSION_LONG_SIDE_PX ? COMPRESSION_LONG_SIDE_PX / longSide : 1;\n const actions =\n scale < 1 && w && h\n ? [{ resize: { width: Math.round(w * scale), height: Math.round(h * scale) } }]\n : [];\n\n const result = await manipulateAsync(uri, actions, {\n compress: COMPRESSION_QUALITY,\n format: SaveFormat.WEBP,\n });\n const blob = await uriToBlob(result.uri);\n const base = (filename ?? `image-${Date.now()}`).replace(/\\.[^.]+$/, '');\n return {\n blob,\n contentType: 'image/webp',\n filename: `${base}.webp`,\n };\n}\n\nasync function assetsToInputs(assets: ReadonlyArray<ImagePicker.ImagePickerAsset>) {\n return Promise.all(\n assets.map(async (asset) => {\n try {\n const compressed = await compressImage({\n uri: asset.uri,\n width: asset.width,\n height: asset.height,\n filename: asset.fileName ?? `image-${Date.now()}`,\n });\n return {\n body: compressed.blob,\n contentType: compressed.contentType,\n byteSize: compressed.blob.size,\n filename: compressed.filename,\n _previewUri: asset.uri,\n };\n } catch (err) {\n console.warn('[poolse/picker] image compression failed, sending original:', err);\n const blob = await uriToBlob(asset.uri);\n const contentType = asset.mimeType ?? blob.type ?? 'image/jpeg';\n return {\n body: blob,\n contentType,\n byteSize: asset.fileSize ?? blob.size,\n filename: asset.fileName ?? `image-${Date.now()}.jpg`,\n _previewUri: asset.uri,\n };\n }\n }),\n );\n}\n\nasync function defaultAdapter(kind: 'image' | 'document' | 'camera') {\n if (kind === 'camera') {\n // Camera permissions are required on both iOS (Info.plist\n // NSCameraUsageDescription) and Android. requestCameraPermissionsAsync\n // shows the system prompt the first time; subsequent calls\n // resolve immediately with the cached answer.\n const perm = await ImagePicker.requestCameraPermissionsAsync();\n if (!perm.granted) {\n console.warn('[poolse/picker] camera permission denied');\n return [];\n }\n const res = await ImagePicker.launchCameraAsync({\n mediaTypes: 'images',\n quality: 1,\n });\n if (res.canceled) return [];\n return assetsToInputs(res.assets);\n }\n if (kind === 'image') {\n const res = await ImagePicker.launchImageLibraryAsync({\n mediaTypes: 'images',\n // Quality 1 — picker hands back the source as-is and we do the\n // compression ourselves below. Letting the picker re-encode\n // first just chains two lossy passes.\n quality: 1,\n });\n if (res.canceled) return [];\n return assetsToInputs(res.assets);\n }\n const res = await DocumentPicker.getDocumentAsync({\n copyToCacheDirectory: true,\n multiple: true,\n });\n if (res.canceled) return [];\n return Promise.all(\n res.assets.map(async (asset) => {\n const isImage = (asset.mimeType ?? '').startsWith('image/');\n if (isImage) {\n try {\n const compressed = await compressImage({\n uri: asset.uri,\n filename: asset.name,\n });\n return {\n body: compressed.blob,\n contentType: compressed.contentType,\n byteSize: compressed.blob.size,\n filename: compressed.filename,\n _previewUri: asset.uri,\n };\n } catch (err) {\n console.warn('[poolse/picker] image compression failed, sending original:', err);\n }\n }\n const blob = await uriToBlob(asset.uri);\n const contentType = asset.mimeType ?? blob.type ?? 'application/octet-stream';\n return {\n body: blob,\n contentType,\n byteSize: asset.size ?? blob.size,\n filename: asset.name,\n _previewUri: asset.uri,\n };\n }),\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.35)',\n justifyContent: 'flex-end',\n },\n sheet: {\n paddingVertical: 8,\n paddingBottom: 24,\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 20,\n paddingVertical: 14,\n gap: 14,\n },\n cancel: {\n paddingHorizontal: 20,\n paddingVertical: 14,\n alignItems: 'center',\n marginTop: 4,\n },\n itemText: {\n fontSize: 15,\n fontWeight: '500',\n },\n});\n","import { StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface DaySeparatorProps {\n label: string;\n}\n\n/**\n * Centered date pill rendered between messages whose `inserted_at`\n * falls on a different calendar day from the previous message. Pair\n * with `formatDayLabel` from `@poolse/react` to compute the label\n * (\"Today\" / \"Yesterday\" / weekday / \"26 May 2024\").\n */\nexport function DaySeparator({ label }: DaySeparatorProps) {\n const theme = usePoolseTheme();\n return (\n <View style={styles.wrap}>\n <View\n style={[\n styles.chip,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: theme.colors.border,\n },\n ]}\n >\n <Text\n style={[\n styles.label,\n {\n color: theme.colors.ink2,\n fontFamily: theme.type.fontBody,\n },\n ]}\n >\n {label}\n </Text>\n </View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n alignItems: 'center',\n marginVertical: 8,\n },\n chip: {\n paddingHorizontal: 12,\n paddingVertical: 4,\n borderRadius: 999,\n borderWidth: StyleSheet.hairlineWidth,\n },\n label: {\n fontSize: 11,\n fontWeight: '600',\n letterSpacing: 0.3,\n },\n});\n","import { Image, Pressable, ScrollView, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { useSharedUpload, useUploadPreview } from './internal/uploadContext.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\n/**\n * Horizontal scrolling preview row of pending / in-flight / ready\n * uploads. Image attachments render as 64×64 thumbnails sourced from\n * the original local file URI; file attachments render as a row card\n * with icon + name + size. A small × overlay on each tile lets the\n * user drop the upload before send.\n *\n * Reads queue state from the shared `<UploadProvider>` (mounted by\n * `<ConversationView>`), so the composer's \"ready attachment ids\"\n * pickup and the strip's display always agree.\n */\nexport function UploadQueueStrip() {\n const theme = usePoolseTheme();\n const upload = useSharedUpload();\n const { getPreview } = useUploadPreview();\n\n if (upload.queue.length === 0) return null;\n\n return (\n <ScrollView\n horizontal\n showsHorizontalScrollIndicator={false}\n contentContainerStyle={styles.scroll}\n // overflow:visible (+ explicit paddingTop on the contentContainer)\n // so the X close button can sit at -6/-6 outside the tile without\n // being clipped by the scroll bounds.\n style={[styles.scrollStyle, { marginBottom: 8 }]}\n >\n {upload.queue.map((item) => {\n const isError = item.status === 'error';\n const isUploading = item.status === 'uploading' || item.status === 'pending';\n const isImage = (item.contentType ?? '').startsWith('image/');\n const previewUri = getPreview(item.filename);\n const canTerminate = isUploading || item.status === 'ready' || isError;\n\n const handleClose = () => {\n if (item.status === 'ready' || isError) upload.remove(item.localId);\n else upload.cancel(item.localId);\n };\n\n return (\n <View key={item.localId} style={styles.tileWrap}>\n {isImage && previewUri ? (\n <ImageTile uri={previewUri} uploading={isUploading} error={isError} />\n ) : (\n <FileTile\n filename={item.filename}\n size={item.byteSize}\n uploading={isUploading}\n error={isError}\n />\n )}\n\n {canTerminate ? (\n <Pressable\n onPress={handleClose}\n hitSlop={8}\n // Hardcoded dark dot + white X. Pulling from the\n // theme made the close affordance invisible against\n // light-on-light or dark-on-dark custom palettes\n // (e.g. a white-on-white surface/onBrand pair).\n // This is a thumbnail badge — not chrome — so it\n // should look the same in every theme.\n style={styles.closeBtn}\n accessibilityLabel={isError ? 'Remove failed upload' : 'Cancel upload'}\n >\n <PoolseIcon name=\"close\" size={11} color=\"#fff\" />\n </Pressable>\n ) : null}\n\n {isUploading ? (\n <View style={styles.progressOverlay}>\n <View style={[styles.spinner, { borderColor: theme.colors.onBrand }]} />\n </View>\n ) : null}\n\n {isError ? (\n <View style={[styles.errorOverlay, { backgroundColor: 'rgba(229,72,77,0.85)' }]}>\n <Text style={[styles.errorText, { color: '#fff' }]}>Failed</Text>\n </View>\n ) : null}\n </View>\n );\n })}\n </ScrollView>\n );\n}\n\nfunction ImageTile({ uri, uploading, error }: { uri: string; uploading: boolean; error: boolean }) {\n const theme = usePoolseTheme();\n return (\n <Image\n source={{ uri }}\n style={[\n styles.imageTile,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: error ? theme.colors.error : 'transparent',\n opacity: uploading ? 0.65 : 1,\n },\n ]}\n resizeMode=\"cover\"\n />\n );\n}\n\nfunction FileTile({\n filename,\n size,\n uploading,\n error,\n}: {\n filename: string;\n size: number;\n uploading: boolean;\n error: boolean;\n}) {\n const theme = usePoolseTheme();\n return (\n <View\n style={[\n styles.fileTile,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: error\n ? theme.colors.error\n : uploading\n ? theme.colors.brand\n : theme.colors.border,\n },\n ]}\n >\n <View style={[styles.fileIconBox, { backgroundColor: theme.colors.brandSoft }]}>\n <PoolseIcon name=\"attachment\" size={18} color={theme.colors.brand} />\n </View>\n <View style={styles.fileInfo}>\n <Text\n style={[styles.fileName, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {filename}\n </Text>\n <Text style={[styles.fileSize, { color: theme.colors.ink3 }]}>{formatBytes(size)}</Text>\n </View>\n </View>\n );\n}\n\nfunction formatBytes(n: number): string {\n if (!n || n < 0) return '';\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;\n if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;\n return `${(n / 1024 / 1024 / 1024).toFixed(1)} GB`;\n}\n\nconst TILE = 64;\n\nconst styles = StyleSheet.create({\n scrollStyle: {\n overflow: 'visible',\n },\n scroll: {\n paddingHorizontal: 8,\n // paddingTop creates room for the X to overflow the tile without\n // being clipped on Android (where overflow:visible isn't enough).\n paddingTop: 8,\n gap: 10,\n flexDirection: 'row',\n },\n tileWrap: {\n position: 'relative',\n overflow: 'visible',\n },\n imageTile: {\n width: TILE,\n height: TILE,\n borderRadius: 10,\n borderWidth: 1.5,\n },\n fileTile: {\n height: TILE,\n minWidth: 200,\n maxWidth: 260,\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 10,\n paddingRight: 28,\n borderRadius: 10,\n borderWidth: 1,\n gap: 10,\n },\n fileIconBox: {\n width: 36,\n height: 36,\n borderRadius: 8,\n alignItems: 'center',\n justifyContent: 'center',\n },\n fileInfo: {\n flex: 1,\n gap: 2,\n },\n fileName: {\n fontSize: 13,\n fontWeight: '600',\n },\n fileSize: {\n fontSize: 11,\n },\n closeBtn: {\n // Outside the tile (top-right corner overflowing). Parent\n // scroll container + tileWrap set overflow:visible and the\n // scroll contentContainer has paddingTop:8 so the overflow\n // isn't clipped on Android.\n position: 'absolute',\n top: -6,\n right: -6,\n width: 22,\n height: 22,\n borderRadius: 11,\n alignItems: 'center',\n justifyContent: 'center',\n backgroundColor: 'rgba(40,40,40,0.85)',\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 1 },\n shadowOpacity: 0.3,\n shadowRadius: 2,\n elevation: 3,\n },\n progressOverlay: {\n ...StyleSheet.absoluteFillObject,\n alignItems: 'center',\n justifyContent: 'center',\n pointerEvents: 'none',\n },\n spinner: {\n width: 24,\n height: 24,\n borderRadius: 12,\n borderWidth: 2.5,\n borderTopColor: 'transparent',\n // RN can't loop a rotation purely in StyleSheet, but the static\n // 3/4-circle still reads as \"in progress.\" A real Animated.View\n // rotation lands in a follow-up.\n },\n errorOverlay: {\n position: 'absolute',\n bottom: 0,\n left: 0,\n right: 0,\n paddingVertical: 3,\n alignItems: 'center',\n },\n errorText: {\n fontSize: 10,\n fontWeight: '700',\n },\n});\n","import { Platform } from 'react-native';\n\n// Lazy-resolve react-native-safe-area-context. Returns the real\n// hook when available + a SafeAreaProvider is mounted; falls back\n// to platform-typical iOS values otherwise. Used ONLY for computing\n// keyboardVerticalOffset — never for adding safe-area padding to\n// chrome (consumers' root SafeAreaView already handles that, and\n// double-padding caused the earlier 0.1.6 bug).\n\nexport interface EdgeInsets {\n top: number;\n bottom: number;\n left: number;\n right: number;\n}\n\nconst FALLBACK: EdgeInsets = {\n top: Platform.OS === 'ios' ? 50 : 24,\n bottom: Platform.OS === 'ios' ? 34 : 0,\n left: 0,\n right: 0,\n};\n\ntype SafeAreaModule = {\n useSafeAreaInsets?: () => EdgeInsets;\n};\n\nlet realHook: (() => EdgeInsets) | null = null;\ntry {\n // Optional dep — only resolved when the host app installs\n // react-native-safe-area-context. Wrapped in try/catch so the\n // bundle still works without it.\n // eslint-disable-next-line @typescript-eslint/no-require-imports\n const mod = require('react-native-safe-area-context') as SafeAreaModule;\n if (mod && typeof mod.useSafeAreaInsets === 'function') {\n realHook = mod.useSafeAreaInsets;\n }\n} catch {\n /* not installed — fallback */\n}\n\nconst useFallback = (): EdgeInsets => FALLBACK;\n\nexport const useSafeInsets: () => EdgeInsets = realHook ?? useFallback;\n","import { forwardRef, useEffect, useImperativeHandle, useRef, useState } from 'react';\nimport { Keyboard, Platform, Pressable, StyleSheet, Text, TextInput, View } from 'react-native';\nimport type { AttachmentUploadInput, Message, Uuid } from '@poolse/sdk';\nimport { useUser } from '@poolse/react';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { UploadQueueStrip } from './UploadQueueStrip.js';\nimport { useSharedUpload } from './internal/uploadContext.js';\nimport { useSafeInsets } from './internal/safeArea.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface MessageComposerProps {\n /**\n * Called when the user taps Send. Second arg carries\n * `quoted_message_id` (when replying) and `attachment_ids`\n * (resolved from the composer's upload queue). Awaited so the\n * composer disables until the send round-trips.\n */\n onSend: (\n body: string,\n opts?: { quoted_message_id?: Uuid; attachment_ids?: Uuid[] },\n ) => Promise<unknown> | void;\n /** Called on every keystroke. Hook to `useTyping().signalTyping`. */\n onTyping?: () => void;\n placeholder?: string;\n disabled?: boolean;\n /** Renders a quote chip above the input; cleared by the caller in `onSend`. */\n replyingTo?: Message | null;\n /** User tapped (x) on the quote chip. */\n onCancelReply?: () => void;\n /** Display label for the quoted sender, keyed by `external_id`. */\n labelFor?: (externalId: string) => string;\n /** Show the paperclip + queue strip. Defaults true. */\n attachments?: boolean;\n /** Tap on the paperclip — wire to `<AttachmentPicker>` from the same package. */\n onAttachPress?: () => void;\n /**\n * Distance from the top of the screen to the top of the\n * KeyboardAvoidingView — typically the height of any navigation\n * header sitting above the chat. Pass this when the iOS keyboard\n * suggestions strip ends up covering the composer (a sign the\n * computed offset is wrong). Defaults to 0; on Android it's\n * ignored.\n */\n keyboardOffset?: number;\n /**\n * When set, the composer enters edit mode: prefills the input with\n * the message body and renders an \"Editing message\" chip above\n * (mirrors `replyingTo`). Tapping Send calls `onSaveEdit(body)`\n * instead of `onSend`; `onCancelEdit` clears the chip and restores\n * the previous draft. Pass `null` (or omit) when not editing.\n */\n editingMessage?: Message | null;\n onCancelEdit?: () => void;\n onSaveEdit?: (body: string) => Promise<unknown> | void;\n}\n\n/**\n * Imperative handle for parents that want to add files to the\n * composer's upload queue externally (drag/drop on a wrapper,\n * deep-link, attachment shortcut).\n */\nexport interface MessageComposerHandle {\n /** Enqueue ready-to-upload inputs. The picker component is the usual caller; this is the escape hatch. */\n addFiles: (inputs: AttachmentUploadInput[]) => void;\n focus: () => void;\n clear: () => void;\n}\n\nexport const MessageComposer = forwardRef<MessageComposerHandle, MessageComposerProps>(\n function MessageComposer(\n {\n onSend,\n onTyping,\n placeholder = 'Type a message…',\n disabled = false,\n replyingTo,\n onCancelReply,\n labelFor,\n attachments = true,\n onAttachPress,\n keyboardOffset: _keyboardOffset = 0,\n editingMessage = null,\n onCancelEdit,\n onSaveEdit,\n },\n ref,\n ) {\n const theme = usePoolseTheme();\n const inputRef = useRef<TextInput>(null);\n const [value, setValue] = useState('');\n const [sending, setSending] = useState(false);\n const [keyboardOpen, setKeyboardOpen] = useState(false);\n const upload = useSharedUpload();\n const insets = useSafeInsets();\n\n useEffect(() => {\n const show = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillShow' : 'keyboardDidShow',\n () => setKeyboardOpen(true),\n );\n const hide = Keyboard.addListener(\n Platform.OS === 'ios' ? 'keyboardWillHide' : 'keyboardDidHide',\n () => setKeyboardOpen(false),\n );\n return () => {\n show.remove();\n hide.remove();\n };\n }, []);\n\n useImperativeHandle(\n ref,\n () => ({\n addFiles: (inputs) => {\n if (!attachments) return;\n for (const input of inputs) {\n void upload.upload(input);\n }\n },\n focus: () => inputRef.current?.focus(),\n clear: () => setValue(''),\n }),\n [attachments, upload],\n );\n\n const readyAttachmentIds = upload.queue\n .filter((item) => item.status === 'ready' && item.attachment)\n .map((item) => item.attachment!.id);\n const isUploading = upload.queue.some(\n (item) => item.status === 'uploading' || item.status === 'pending',\n );\n\n // Stash the user's in-progress draft when edit mode opens so we\n // can put it back when they cancel. Without this, cancelling\n // would either wipe what they were typing or leave the edited\n // body in the input.\n const previousDraftRef = useRef<string | null>(null);\n const editingIdRef = useRef<string | null>(null);\n useEffect(() => {\n const id = editingMessage?.id ?? null;\n if (id === editingIdRef.current) return;\n if (id) {\n // Entering edit mode for a new message: snapshot whatever\n // the user was drafting, then prefill with the body.\n previousDraftRef.current = value;\n setValue(editingMessage?.body ?? '');\n // Focus so the keyboard pops up and the cursor lands at the\n // end of the prefilled body.\n inputRef.current?.focus();\n } else {\n // Leaving edit mode — restore the prior draft.\n setValue(previousDraftRef.current ?? '');\n previousDraftRef.current = null;\n }\n editingIdRef.current = id;\n // value intentionally omitted: we only want this to fire when\n // the editingMessage identity changes, not on every keystroke.\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [editingMessage?.id, editingMessage?.body]);\n\n const isEditing = !!editingMessage;\n const editChanged = isEditing && value.trim() !== (editingMessage?.body?.trim() ?? '');\n\n const submitDisabled =\n disabled ||\n sending ||\n isUploading ||\n (isEditing\n ? !editChanged || value.trim().length === 0\n : value.trim().length === 0 && readyAttachmentIds.length === 0);\n\n const handleSend = async () => {\n if (submitDisabled) return;\n // Snapshot + clear synchronously so the input is empty on the\n // next keystroke even if the send round-trip is slow. Otherwise\n // the user types into the still-present old text and the new\n // characters append to the stale message.\n const body = value.trim();\n setSending(true);\n try {\n if (isEditing && onSaveEdit) {\n // Edit mode: don't clear attachments or the reply chip;\n // we're just updating the body. The parent will clear\n // editingMessage on success, which triggers the effect\n // above to restore the prior draft.\n await onSaveEdit(body);\n } else {\n const replyId = replyingTo?.id;\n const attachmentIds = readyAttachmentIds;\n setValue('');\n upload.reset();\n await onSend(body, {\n ...(replyId ? { quoted_message_id: replyId } : {}),\n ...(attachmentIds.length > 0 ? { attachment_ids: attachmentIds } : {}),\n });\n }\n } finally {\n setSending(false);\n }\n };\n\n // No KeyboardAvoidingView here — ConversationView wraps the whole\n // chat surface in a single KAV so the list + composer shift up\n // together. Wrapping only the composer inside a flex:1 parent\n // with no headroom pushed it below the visible area on iPhone\n // home-indicator devices.\n //\n // When the keyboard is closed we add the bottom safe-area inset\n // to keep the send/attach buttons off the home indicator. When\n // it's open the OS bottom inset is irrelevant (keyboard occupies\n // that space) and we collapse back to the base 10px padding to\n // avoid floating the composer above the keyboard.\n const paddingBottom = keyboardOpen ? 10 : Math.max(10, insets.bottom);\n return (\n <View\n style={[\n styles.wrap,\n {\n backgroundColor: theme.colors.surface,\n borderTopColor: theme.colors.border,\n paddingBottom,\n },\n ]}\n >\n {isEditing ? (\n <EditChip\n message={editingMessage!}\n {...(onCancelEdit ? { onCancel: onCancelEdit } : {})}\n />\n ) : replyingTo ? (\n <ReplyChip\n message={replyingTo}\n {...(labelFor ? { labelFor } : {})}\n {...(onCancelReply ? { onCancel: onCancelReply } : {})}\n />\n ) : null}\n\n {attachments && !isEditing ? <UploadQueueStrip /> : null}\n\n <View style={styles.row}>\n {attachments && onAttachPress ? (\n <Pressable\n onPress={onAttachPress}\n hitSlop={8}\n style={styles.iconBtn}\n accessibilityLabel=\"Attach file\"\n >\n <PoolseIcon name=\"attachment\" size={22} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n\n <TextInput\n ref={inputRef}\n value={value}\n onChangeText={(text) => {\n setValue(text);\n onTyping?.();\n }}\n placeholder={placeholder}\n placeholderTextColor={theme.colors.ink3}\n multiline\n editable={!disabled}\n style={[\n styles.input,\n {\n color: theme.colors.ink,\n backgroundColor: theme.colors.surface2,\n borderRadius: theme.radii.lg,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n },\n ]}\n />\n\n <Pressable\n onPress={handleSend}\n disabled={submitDisabled}\n style={[\n styles.sendBtn,\n {\n backgroundColor: submitDisabled ? theme.colors.ink3 : theme.colors.brand,\n opacity: submitDisabled ? 0.6 : 1,\n },\n ]}\n accessibilityLabel=\"Send message\"\n >\n <PoolseIcon name=\"send\" size={18} color={theme.colors.onBrand} />\n </Pressable>\n </View>\n </View>\n );\n },\n);\n\nfunction EditChip({ message, onCancel }: { message: Message; onCancel?: () => void }) {\n const theme = usePoolseTheme();\n return (\n <View\n style={[\n styles.replyChip,\n {\n backgroundColor: theme.colors.surface2,\n borderLeftColor: theme.colors.brand,\n },\n ]}\n >\n <View style={{ flex: 1 }}>\n <Text style={[styles.replyName, { color: theme.colors.brand }]}>Editing message</Text>\n <Text style={[styles.replyBody, { color: theme.colors.ink2 }]} numberOfLines={1}>\n {message.body ?? '…'}\n </Text>\n </View>\n {onCancel ? (\n <Pressable onPress={onCancel} hitSlop={8} style={styles.replyCancel}>\n <PoolseIcon name=\"close\" size={16} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nfunction ReplyChip({\n message,\n labelFor,\n onCancel,\n}: {\n message: Message;\n labelFor?: (externalId: string) => string;\n onCancel?: () => void;\n}) {\n const theme = usePoolseTheme();\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n const resolved = useUser(message.sender_external_id);\n const senderName = message.sender_external_id\n ? (labelFor?.(message.sender_external_id) ??\n resolved.profile?.displayName ??\n message.sender_external_id)\n : 'Unknown';\n return (\n <View\n style={[\n styles.replyChip,\n {\n backgroundColor: theme.colors.surface2,\n borderLeftColor: theme.colors.brand,\n },\n ]}\n >\n <View style={{ flex: 1 }}>\n <Text style={[styles.replyName, { color: theme.colors.brand }]}>\n Replying to {senderName}\n </Text>\n <Text style={[styles.replyBody, { color: theme.colors.ink2 }]} numberOfLines={1}>\n {message.body ?? '…'}\n </Text>\n </View>\n {onCancel ? (\n <Pressable onPress={onCancel} hitSlop={8} style={styles.replyCancel}>\n <PoolseIcon name=\"close\" size={16} color={theme.colors.ink2} />\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n borderTopWidth: StyleSheet.hairlineWidth,\n paddingTop: 8,\n paddingHorizontal: 12,\n // paddingBottom is applied inline — it follows the keyboard state\n // (10 px while open, max(10, safeBottomInset) while closed) so the\n // send/attach buttons stay clear of the home indicator without\n // double-padding above the keyboard.\n },\n row: {\n flexDirection: 'row',\n alignItems: 'flex-end',\n gap: 8,\n },\n iconBtn: {\n padding: 8,\n justifyContent: 'center',\n alignItems: 'center',\n },\n input: {\n flex: 1,\n minHeight: 40,\n maxHeight: 120,\n paddingHorizontal: 12,\n paddingTop: 10,\n paddingBottom: 10,\n },\n sendBtn: {\n width: 40,\n height: 40,\n borderRadius: 20,\n justifyContent: 'center',\n alignItems: 'center',\n },\n replyChip: {\n flexDirection: 'row',\n alignItems: 'center',\n borderLeftWidth: 3,\n paddingLeft: 10,\n paddingRight: 6,\n paddingVertical: 6,\n marginBottom: 8,\n borderRadius: 6,\n },\n replyName: {\n fontSize: 11,\n fontWeight: '600',\n marginBottom: 2,\n },\n replyBody: {\n fontSize: 12,\n },\n replyCancel: {\n padding: 6,\n },\n});\n","import type { Membership, Uuid } from '@poolse/sdk';\nimport { useMembers } from '@poolse/react';\nimport { useMemo, useState } from 'react';\nimport { FlatList, Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { MessageComposer, type MessageComposerProps } from './MessageComposer.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface MentionInputProps extends Omit<MessageComposerProps, 'onSend'> {\n conversationId: Uuid;\n /** Same callback as MessageComposer.onSend, plus optional mention user_ids. */\n onSend: (\n body: string,\n opts?: {\n quoted_message_id?: Uuid;\n attachment_ids?: Uuid[];\n mentions?: Uuid[];\n },\n ) => Promise<unknown> | void;\n}\n\n/**\n * Composer with an inline `@`-trigger that opens a modal sheet of\n * conversation members. Selecting a member inserts their\n * `external_id` into the text, and the wire `mentions` array (sent\n * to the backend) carries the corresponding internal `user_id`s.\n */\nexport function MentionInput({ conversationId, onSend, ...composerProps }: MentionInputProps) {\n const theme = usePoolseTheme();\n const { members } = useMembers(conversationId);\n const [pickerOpen, setPickerOpen] = useState(false);\n const [pickerQuery, _setPickerQuery] = useState('');\n const [pendingMentionUuids, setPendingMentionUuids] = useState<Uuid[]>([]);\n const [text, setText] = useState('');\n\n const filteredMembers = useMemo(() => {\n if (!pickerQuery) return members;\n const q = pickerQuery.toLowerCase();\n return members.filter((m) => m.external_id.toLowerCase().includes(q));\n }, [members, pickerQuery]);\n\n const handleSend: MessageComposerProps['onSend'] = async (body, opts) => {\n await onSend(body, {\n ...opts,\n ...(pendingMentionUuids.length > 0 ? { mentions: pendingMentionUuids } : {}),\n });\n setPendingMentionUuids([]);\n setText('');\n };\n\n return (\n <>\n <MessageComposer\n {...composerProps}\n onSend={handleSend}\n onTyping={() => {\n composerProps.onTyping?.();\n // Watch for an `@` token to open the picker.\n const lastChar = text.slice(-1);\n if (lastChar === '@') setPickerOpen(true);\n }}\n />\n\n <Modal\n visible={pickerOpen}\n transparent\n animationType=\"slide\"\n onRequestClose={() => setPickerOpen(false)}\n >\n <Pressable style={styles.backdrop} onPress={() => setPickerOpen(false)}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderTopLeftRadius: theme.radii.lg,\n borderTopRightRadius: theme.radii.lg,\n },\n ]}\n >\n <Text\n style={[styles.title, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n >\n Mention a member\n </Text>\n <FlatList\n data={filteredMembers}\n keyExtractor={(m) => m.user_id}\n renderItem={({ item }) => (\n <MentionRow\n member={item}\n onPress={() => {\n setPendingMentionUuids((prev) => [...prev, item.user_id]);\n setText((prev) => `${prev}${item.external_id} `);\n setPickerOpen(false);\n }}\n />\n )}\n />\n </View>\n </Pressable>\n </Modal>\n </>\n );\n}\n\nfunction MentionRow({ member, onPress }: { member: Membership; onPress: () => void }) {\n const theme = usePoolseTheme();\n return (\n <Pressable onPress={onPress} style={styles.row}>\n <Avatar src={null} name={member.external_id} seed={member.external_id} size=\"sm\" />\n <Text style={[styles.rowText, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}>\n {member.external_id}\n </Text>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.35)',\n justifyContent: 'flex-end',\n },\n sheet: {\n maxHeight: '60%',\n paddingVertical: 12,\n },\n title: {\n fontSize: 14,\n fontWeight: '600',\n paddingHorizontal: 16,\n paddingBottom: 8,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingVertical: 10,\n gap: 10,\n },\n rowText: {\n fontSize: 14,\n },\n});\n","import type { Message } from '@poolse/sdk';\nimport {\n ActivityIndicator,\n FlatList,\n type ListRenderItem,\n type NativeScrollEvent,\n type NativeSyntheticEvent,\n Pressable,\n StyleSheet,\n Text,\n View,\n} from 'react-native';\nimport { useCallback, useEffect, useRef, useState, type ReactElement } from 'react';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\n/**\n * Either a real message or a day-separator row. ConversationView\n * builds the list of items (interleaving separators where the day\n * changes) and hands it to MessageList; MessageList just renders.\n */\nexport type MessageListItem =\n | { kind: 'msg'; msg: Message }\n | { kind: 'separator'; id: string; node: ReactElement };\n\nexport interface MessageListProps {\n messages: Message[];\n /**\n * Optional pre-built item list (with day separators interleaved).\n * When omitted, a list with `{ kind: 'msg' }` items is derived\n * from `messages` and rendered without separators.\n */\n items?: MessageListItem[];\n loading?: boolean;\n hasMore?: boolean;\n onLoadMore?: () => void;\n renderItem: (msg: Message, index: number) => ReactElement;\n /** Slot rendered above the latest message (typically the typing indicator). */\n ListHeader?: ReactElement | null;\n /** Slot rendered below the oldest message (rare — typically nothing). */\n ListFooter?: ReactElement | null;\n /** Custom empty state when there are no messages. */\n emptyState?: ReactElement | string;\n /**\n * The current user's id. When provided, MessageList will show a\n * \"↓ N new messages\" jump button at the bottom of the chat\n * whenever new messages from OTHER users arrive while the user is\n * scrolled away from the bottom. Tapping scrolls to the latest.\n */\n meId?: string | null;\n}\n\n// How far above the bottom (in pixels — the list is inverted, so\n// this is contentOffset.y) before we consider the user \"scrolled\n// up\" and start counting new messages.\nconst AT_BOTTOM_THRESHOLD = 32;\n\n/**\n * Inverted FlatList wrapper for chat history. Newest message at the\n * bottom (visually), oldest at the top. Calls `onLoadMore` when the\n * user scrolls near the top edge and `hasMore` is true.\n *\n * Pagination is owned by `useMessages` (hand it `messages` +\n * `hasMore` + `loadMore`); this component just renders + scrolls.\n */\nexport function MessageList({\n messages,\n items,\n loading = false,\n hasMore = false,\n onLoadMore,\n renderItem,\n ListHeader = null,\n ListFooter = null,\n emptyState,\n meId = null,\n}: MessageListProps) {\n const theme = usePoolseTheme();\n const flatListRef = useRef<FlatList<MessageListItem>>(null);\n const [atBottom, setAtBottom] = useState(true);\n const [newCount, setNewCount] = useState(0);\n const lastTailIdRef = useRef<string | null>(null);\n\n // Build the FlatList data — either the caller's prebuilt items\n // (with separators) or a plain msg-only list. FlatList is\n // inverted, so we reverse to put the newest item at the top of\n // `data` (which renders at the visual bottom).\n const sourceItems: MessageListItem[] =\n items ?? messages.map((msg) => ({ kind: 'msg' as const, msg }));\n const data = [...sourceItems].reverse();\n\n // Track tail-message changes to maintain the \"new messages\" badge\n // when the user is scrolled up.\n useEffect(() => {\n const tail = messages[messages.length - 1];\n if (!tail) return;\n const tailId = tail.id;\n if (tailId === lastTailIdRef.current) return;\n const isFirstSet = lastTailIdRef.current === null;\n lastTailIdRef.current = tailId;\n if (atBottom || isFirstSet) {\n setNewCount(0);\n return;\n }\n // Only count incoming messages from other users — self messages\n // would have already triggered a scroll-to-bottom in normal flow.\n if (meId !== null && tail.sender_id === meId) return;\n setNewCount((n) => n + 1);\n }, [messages, atBottom, meId]);\n\n const handleScroll = useCallback((e: NativeSyntheticEvent<NativeScrollEvent>) => {\n const y = e.nativeEvent.contentOffset.y;\n const next = y <= AT_BOTTOM_THRESHOLD;\n setAtBottom((prev) => (prev === next ? prev : next));\n if (next) setNewCount(0);\n }, []);\n\n const scrollToBottom = useCallback(() => {\n flatListRef.current?.scrollToOffset({ offset: 0, animated: true });\n setNewCount(0);\n }, []);\n\n const handleRender: ListRenderItem<MessageListItem> = useCallback(\n ({ item, index }) => {\n if (item.kind === 'separator') return item.node;\n // Index in the original (newest-last) source order. Used by\n // ConversationView's renderItem to pick neighbours for\n // grouping when it doesn't pre-compute groupPosition itself.\n const sourceIndex = data.length - 1 - index;\n return renderItem(item.msg, sourceIndex);\n },\n [renderItem, data.length],\n );\n\n if (loading && messages.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n <ActivityIndicator color={theme.colors.brand} />\n </View>\n );\n }\n\n if (messages.length === 0) {\n return (\n <View style={[styles.placeholder, { backgroundColor: theme.colors.paper }]}>\n {typeof emptyState === 'string' ? (\n <Text style={{ color: theme.colors.ink3, fontFamily: theme.type.fontBody }}>\n {emptyState}\n </Text>\n ) : (\n (emptyState ?? null)\n )}\n </View>\n );\n }\n\n return (\n <View style={styles.root}>\n <FlatList\n ref={flatListRef}\n inverted\n data={data}\n keyExtractor={(item) => (item.kind === 'msg' ? item.msg.id : item.id)}\n renderItem={handleRender}\n onEndReached={hasMore ? onLoadMore : undefined}\n onEndReachedThreshold={0.3}\n onScroll={handleScroll}\n scrollEventThrottle={32}\n // `inverted` flips the list, so FlatList's ListHeaderComponent\n // renders at the bottom of the screen (above the latest message,\n // next to the composer) and ListFooterComponent renders at the\n // top (above the oldest message). That matches our prop names.\n ListHeaderComponent={ListHeader}\n ListFooterComponent={\n <View>\n {hasMore && loading ? (\n <ActivityIndicator color={theme.colors.ink3} style={{ marginVertical: 8 }} />\n ) : null}\n {ListFooter}\n </View>\n }\n style={{ backgroundColor: theme.colors.paper }}\n contentContainerStyle={{ paddingVertical: 8 }}\n />\n\n {!atBottom && newCount > 0 ? (\n <Pressable\n onPress={scrollToBottom}\n style={[\n styles.jumpButton,\n {\n backgroundColor: theme.colors.brand,\n },\n theme.shadows.sm,\n ]}\n accessibilityLabel={`${newCount} new ${newCount === 1 ? 'message' : 'messages'}, jump to latest`}\n >\n <PoolseIcon name=\"chevron-down\" size={14} color={theme.colors.onBrand} />\n <Text style={[styles.jumpText, { color: theme.colors.onBrand }]}>\n {newCount} new {newCount === 1 ? 'message' : 'messages'}\n </Text>\n </Pressable>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n },\n placeholder: {\n flex: 1,\n alignItems: 'center',\n justifyContent: 'center',\n padding: 24,\n },\n jumpButton: {\n position: 'absolute',\n alignSelf: 'center',\n bottom: 12,\n flexDirection: 'row',\n alignItems: 'center',\n gap: 6,\n paddingHorizontal: 14,\n paddingVertical: 8,\n borderRadius: 999,\n },\n jumpText: {\n fontSize: 13,\n fontWeight: '600',\n },\n});\n","import { Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon, type IconName } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nconst DEFAULT_REACTION_EMOJIS = ['👍', '❤️', '😂', '🎉', '🙏', '🔥'];\n\nexport interface MessageActionsProps {\n visible: boolean;\n onClose: () => void;\n isSelf: boolean;\n /**\n * Quick-reaction emoji row rendered at the top of the sheet. Tap\n * one to fire `onPickReaction(emoji)` and immediately close. When\n * omitted (or `onPickReaction` is omitted) the row is hidden.\n */\n emojis?: string[];\n onPickReaction?: (emoji: string) => void;\n onReply?: () => void;\n onReplyInThread?: () => void;\n onQuote?: () => void;\n onEdit?: () => void;\n onDelete?: () => void;\n onCopy?: () => void;\n}\n\n/**\n * Long-press action menu — modal bottom sheet. Renders a row of\n * quick-react emojis at the top (one tap reacts + closes) plus the\n * action items below. Matches WhatsApp / iMessage's \"long-press\n * shows everything inline\" pattern.\n */\nexport function MessageActions({\n visible,\n onClose,\n isSelf,\n emojis = DEFAULT_REACTION_EMOJIS,\n onPickReaction,\n onReply,\n onReplyInThread,\n onQuote,\n onEdit,\n onDelete,\n onCopy,\n}: MessageActionsProps) {\n const theme = usePoolseTheme();\n const items: Array<{ label: string; icon: IconName; onPress: () => void; danger?: boolean }> = [];\n if (onReply) items.push({ label: 'Reply', icon: 'reply', onPress: onReply });\n if (onQuote) items.push({ label: 'Quote reply', icon: 'reply', onPress: onQuote });\n if (onReplyInThread)\n items.push({ label: 'Reply in thread', icon: 'messages', onPress: onReplyInThread });\n if (onCopy) items.push({ label: 'Copy text', icon: 'copy', onPress: onCopy });\n if (isSelf && onEdit) items.push({ label: 'Edit', icon: 'edit', onPress: onEdit });\n if (isSelf && onDelete)\n items.push({ label: 'Delete', icon: 'trash', onPress: onDelete, danger: true });\n\n const showEmojiRow = !!onPickReaction && emojis.length > 0;\n\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={onClose}>\n <Pressable style={styles.backdrop} onPress={onClose}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderTopLeftRadius: theme.radii.lg,\n borderTopRightRadius: theme.radii.lg,\n },\n theme.shadows.lg,\n ]}\n >\n {showEmojiRow ? (\n <View style={[styles.emojiRow, { borderBottomColor: theme.colors.border }]}>\n {emojis.map((emoji) => (\n <Pressable\n key={emoji}\n onPress={() => {\n onPickReaction(emoji);\n onClose();\n }}\n style={styles.emojiBtn}\n hitSlop={6}\n accessibilityLabel={`React with ${emoji}`}\n >\n <Text style={styles.emoji}>{emoji}</Text>\n </Pressable>\n ))}\n </View>\n ) : null}\n\n {items.map((item) => (\n <Pressable key={item.label} onPress={item.onPress} style={styles.item}>\n <PoolseIcon\n name={item.icon}\n size={18}\n color={item.danger ? theme.colors.error : theme.colors.ink2}\n />\n <Text\n style={[\n styles.itemText,\n {\n color: item.danger ? theme.colors.error : theme.colors.ink,\n fontFamily: theme.type.fontBody,\n },\n ]}\n >\n {item.label}\n </Text>\n </Pressable>\n ))}\n </View>\n </Pressable>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.35)',\n justifyContent: 'flex-end',\n },\n sheet: {\n paddingTop: 8,\n paddingBottom: 24,\n },\n emojiRow: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-around',\n paddingHorizontal: 12,\n paddingVertical: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n marginBottom: 6,\n },\n emojiBtn: {\n paddingHorizontal: 6,\n paddingVertical: 6,\n borderRadius: 999,\n alignItems: 'center',\n justifyContent: 'center',\n },\n emoji: {\n fontSize: 30,\n lineHeight: 36,\n },\n item: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 20,\n paddingVertical: 14,\n gap: 14,\n },\n itemText: {\n fontSize: 15,\n fontWeight: '500',\n },\n});\n","import type { Attachment } from '@poolse/sdk';\nimport { useAttachmentUrl } from '@poolse/react';\nimport { Image, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface AttachmentPreviewProps {\n attachment: Attachment;\n /** Optional tap handler. For images defaults to opening the source URL. */\n onPress?: () => void;\n /** Render at this max width. Defaults to 280. */\n maxWidth?: number;\n}\n\nexport function AttachmentPreview({ attachment, onPress, maxWidth = 280 }: AttachmentPreviewProps) {\n const theme = usePoolseTheme();\n const isImage = (attachment.content_type ?? '').startsWith('image/');\n const { url } = useAttachmentUrl(attachment.id);\n\n if (isImage) {\n return (\n <Pressable onPress={onPress} disabled={!onPress}>\n {url ? (\n <Image\n source={{ uri: url }}\n style={{\n width: maxWidth,\n height: 200,\n borderRadius: theme.radii.md,\n backgroundColor: theme.colors.surface2,\n }}\n resizeMode=\"cover\"\n accessible\n accessibilityLabel={attachment.original_filename ?? 'attachment image'}\n />\n ) : (\n <View\n style={[\n styles.imagePlaceholder,\n {\n width: maxWidth,\n height: 200,\n borderRadius: theme.radii.md,\n backgroundColor: theme.colors.surface2,\n },\n ]}\n />\n )}\n </Pressable>\n );\n }\n\n return (\n <Pressable\n onPress={onPress}\n disabled={!onPress}\n style={[\n styles.fileCard,\n {\n backgroundColor: theme.colors.surface2,\n borderColor: theme.colors.border,\n borderRadius: theme.radii.md,\n },\n ]}\n >\n <PoolseIcon name=\"attachment\" size={18} color={theme.colors.ink2} />\n <View style={{ flex: 1, marginLeft: 8 }}>\n <Text\n style={[styles.fileName, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {attachment.original_filename ?? 'file'}\n </Text>\n <Text style={[styles.fileSize, { color: theme.colors.ink3 }]}>\n {formatBytes(attachment.byte_size)}\n </Text>\n </View>\n </Pressable>\n );\n}\n\nfunction formatBytes(n: number): string {\n if (n < 1024) return `${n} B`;\n if (n < 1024 * 1024) return `${(n / 1024).toFixed(1)} KB`;\n if (n < 1024 * 1024 * 1024) return `${(n / 1024 / 1024).toFixed(1)} MB`;\n return `${(n / 1024 / 1024 / 1024).toFixed(1)} GB`;\n}\n\nconst styles = StyleSheet.create({\n imagePlaceholder: {},\n fileCard: {\n flexDirection: 'row',\n alignItems: 'center',\n padding: 8,\n borderWidth: StyleSheet.hairlineWidth,\n },\n fileName: {\n fontSize: 13,\n fontWeight: '500',\n },\n fileSize: {\n fontSize: 11,\n },\n});\n","import type { Attachment } from '@poolse/sdk';\nimport { useAttachmentUrl } from '@poolse/react';\nimport { useState } from 'react';\nimport { Dimensions, Image, Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ImageMosaicProps {\n images: Attachment[];\n /**\n * Pixel ceiling on the mosaic's width. The mosaic itself fills its\n * parent (`width: '100%'`) and caps at this value, so it always\n * fits inside whatever the bubble's actual content area is at\n * render time — no more hardcoded 280px overflowing on small\n * screens or inside narrow bubbles.\n */\n maxWidth?: number;\n radius?: number;\n}\n\n/**\n * WhatsApp-style multi-image grid for inside the message bubble.\n * Uses flex-based widths (with `%` and `aspectRatio`) so the layout\n * scales to whatever the bubble's content area is — no fixed pixel\n * positioning that can overflow when the bubble is narrower than\n * the configured max.\n *\n * * n = 1 → single tile, 16:10 aspect.\n * * n = 2 → row of 2 squares.\n * * n = 3 → 16:9 hero on top + row of 2 squares below.\n * * n ≥ 4 → 2×2 grid with \"+N more\" overlay on the 4th tile.\n */\nexport function ImageMosaic({ images, maxWidth, radius }: ImageMosaicProps) {\n const theme = usePoolseTheme();\n const r = radius ?? theme.radii.md;\n const [viewerIndex, setViewerIndex] = useState<number | null>(null);\n\n if (images.length === 0) return null;\n\n const visible = images.slice(0, 4);\n const overflow = images.length > 4 ? images.length - 4 : 0;\n const n = visible.length as 1 | 2 | 3 | 4;\n\n return (\n <>\n <View\n style={[\n styles.root,\n {\n borderRadius: r,\n ...(maxWidth ? { maxWidth } : {}),\n },\n ]}\n >\n {n === 1 ? (\n <Tile\n attachment={visible[0]!}\n style={styles.tileFull}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n ) : null}\n\n {n === 2 ? (\n <View style={styles.rowEven}>\n <Tile\n attachment={visible[0]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n <Tile\n attachment={visible[1]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(1)}\n overlay={null}\n />\n </View>\n ) : null}\n\n {n === 3 ? (\n <>\n <Tile\n attachment={visible[0]!}\n style={styles.tileHero}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n <View style={[styles.rowEven, { marginTop: 2 }]}>\n <Tile\n attachment={visible[1]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(1)}\n overlay={null}\n />\n <Tile\n attachment={visible[2]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(2)}\n overlay={null}\n />\n </View>\n </>\n ) : null}\n\n {n === 4 ? (\n <>\n <View style={styles.rowEven}>\n <Tile\n attachment={visible[0]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(0)}\n overlay={null}\n />\n <Tile\n attachment={visible[1]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(1)}\n overlay={null}\n />\n </View>\n <View style={[styles.rowEven, { marginTop: 2 }]}>\n <Tile\n attachment={visible[2]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(2)}\n overlay={null}\n />\n <Tile\n attachment={visible[3]!}\n style={styles.tileHalfSquare}\n onPress={() => setViewerIndex(3)}\n overlay={overflow > 0 ? `+${overflow}` : null}\n />\n </View>\n </>\n ) : null}\n </View>\n\n <Modal\n visible={viewerIndex !== null}\n transparent\n animationType=\"fade\"\n onRequestClose={() => setViewerIndex(null)}\n >\n {viewerIndex !== null ? (\n <FullScreenViewer\n attachment={images[viewerIndex]!}\n onClose={() => setViewerIndex(null)}\n />\n ) : null}\n </Modal>\n </>\n );\n}\n\nfunction Tile({\n attachment,\n style,\n overlay,\n onPress,\n}: {\n attachment: Attachment;\n style: object;\n overlay: string | null;\n onPress: () => void;\n}) {\n const theme = usePoolseTheme();\n const { url } = useAttachmentUrl(attachment.id);\n return (\n <Pressable onPress={onPress} style={[styles.tileBase, style]}>\n {url ? (\n <Image\n source={{ uri: url }}\n style={[styles.tileImage, { backgroundColor: theme.colors.surface2 }]}\n resizeMode=\"cover\"\n accessible\n accessibilityLabel={attachment.original_filename ?? 'image'}\n />\n ) : (\n <View style={[styles.tileImage, { backgroundColor: theme.colors.surface2 }]} />\n )}\n {overlay ? (\n <View style={styles.overflow}>\n <Text style={styles.overflowText}>{overlay}</Text>\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nfunction FullScreenViewer({\n attachment,\n onClose,\n}: {\n attachment: Attachment;\n onClose: () => void;\n}) {\n const { url } = useAttachmentUrl(attachment.id);\n const { width, height } = Dimensions.get('window');\n return (\n <Pressable style={styles.viewer} onPress={onClose}>\n {url ? (\n <Image\n source={{ uri: url }}\n style={{ width, height }}\n resizeMode=\"contain\"\n accessible\n accessibilityLabel={attachment.original_filename ?? 'image'}\n />\n ) : null}\n <Pressable\n onPress={onClose}\n hitSlop={12}\n style={styles.closeBtn}\n accessibilityLabel=\"Close viewer\"\n >\n <PoolseIcon name=\"close\" size={20} color=\"#ffffff\" />\n </Pressable>\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n width: '100%',\n overflow: 'hidden',\n marginBottom: 4,\n },\n rowEven: {\n flexDirection: 'row',\n gap: 2,\n },\n tileBase: {\n overflow: 'hidden',\n },\n // n=1: full bleed at the bubble's available width, 16:10 aspect.\n tileFull: {\n width: '100%',\n aspectRatio: 16 / 10,\n },\n // n=2 / n=4 (per row): two equal squares side-by-side.\n tileHalfSquare: {\n flex: 1,\n aspectRatio: 1,\n },\n // n=3 hero: full-bleed top tile, 16:9.\n tileHero: {\n width: '100%',\n aspectRatio: 16 / 9,\n },\n tileImage: {\n width: '100%',\n height: '100%',\n },\n overflow: {\n position: 'absolute',\n inset: 0,\n backgroundColor: 'rgba(0,0,0,0.55)',\n alignItems: 'center',\n justifyContent: 'center',\n },\n overflowText: {\n color: '#ffffff',\n fontWeight: '700',\n fontSize: 22,\n },\n viewer: {\n flex: 1,\n backgroundColor: '#000000',\n alignItems: 'center',\n justifyContent: 'center',\n },\n closeBtn: {\n position: 'absolute',\n top: 48,\n right: 16,\n padding: 8,\n backgroundColor: 'rgba(0,0,0,0.5)',\n borderRadius: 20,\n },\n});\n","import { createElement, type ReactElement } from 'react';\nimport type { StyleSheet } from 'react-native';\n// Static import — Metro's bundle graph can only trace literal\n// `import` / `require` calls. The earlier try/require trick generated\n// a `require('react-native-markdown-display')` that Metro couldn't\n// resolve from inside our pre-bundled CJS dist, throwing a runtime\n// \"Requiring unknown module\" even when the consumer had the package\n// installed. Hard-importing puts the resolution into the consumer\n// app's normal graph where it works the same way react-native-svg or\n// expo-image-picker do.\n//\n// Trade-off: the package is now a required peer of @poolse/react-native\n// (was optional). Consumers who don't want markdown can pass\n// `markdown={false}` to <ConversationView> — the import stays in the\n// bundle but the component isn't rendered.\nimport Markdown, { MarkdownIt } from 'react-native-markdown-display';\n\n// `react-native-markdown-display` defaults to a stock CommonMark\n// parser, which only treats `[text](url)` and `<url>` as links. Bare\n// URLs in body text (e.g. \"check https://example.com\") stay plain\n// text. Turn on `linkify` so markdown-it autolinks them — matches\n// what react-ui gets via remark-gfm. Built once at module load: the\n// instance is stateless and re-using it avoids re-allocating the\n// parser for every rendered message.\nconst markdownit = MarkdownIt({ typographer: false, linkify: true });\n\nexport interface MarkdownStyleArgs {\n textColor: string;\n linkColor: string;\n fontFamily?: string;\n fontSize: number;\n lineHeight: number;\n onLinkPress: (url: string) => boolean;\n}\n\n/**\n * Render `body` as Markdown into a React element. The style mapping\n * uses the bubble's resolved theme tokens so text color tracks self /\n * other bubble background.\n */\nexport function renderMarkdown(body: string, args: MarkdownStyleArgs): ReactElement {\n const baseText = {\n color: args.textColor,\n fontFamily: args.fontFamily,\n fontSize: args.fontSize,\n lineHeight: args.lineHeight,\n };\n // Match react-ui's GFM defaults — body+inline elements use bubble\n // text color; links pick up the brand-on-bubble color so they\n // remain visible whether the bubble is a self-brand or\n // other-surface variant.\n const style: StyleSheet.NamedStyles<unknown> = {\n body: baseText,\n paragraph: { ...baseText, marginTop: 0, marginBottom: 0 },\n text: baseText,\n strong: { ...baseText, fontWeight: '700' },\n em: { ...baseText, fontStyle: 'italic' },\n s: { ...baseText, textDecorationLine: 'line-through' },\n link: { color: args.linkColor, textDecorationLine: 'underline' },\n code_inline: {\n ...baseText,\n backgroundColor: 'rgba(127,127,127,0.18)',\n borderRadius: 4,\n paddingHorizontal: 4,\n },\n code_block: {\n ...baseText,\n backgroundColor: 'rgba(127,127,127,0.18)',\n padding: 8,\n borderRadius: 6,\n },\n fence: {\n ...baseText,\n backgroundColor: 'rgba(127,127,127,0.18)',\n padding: 8,\n borderRadius: 6,\n },\n bullet_list: { marginTop: 2, marginBottom: 2 },\n ordered_list: { marginTop: 2, marginBottom: 2 },\n list_item: baseText,\n blockquote: {\n ...baseText,\n borderLeftWidth: 3,\n borderLeftColor: args.linkColor,\n paddingLeft: 8,\n marginVertical: 4,\n opacity: 0.85,\n },\n };\n return createElement(Markdown, { style, markdownit, onLinkPress: args.onLinkPress }, body);\n}\n","import type { Message, QuotedMessagePreview, Uuid } from '@poolse/sdk';\nimport { useUser } from '@poolse/react';\nimport { useState, type ReactNode } from 'react';\nimport { Linking, Pressable, StyleSheet, Text, useWindowDimensions, View } from 'react-native';\n\nimport { AttachmentPreview } from './AttachmentPreview.js';\nimport { ImageMosaic } from './ImageMosaic.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { renderMarkdown } from './internal/markdown.js';\nimport { userColor } from './primitives/userColor.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport type BubbleGroupPosition = 'first' | 'middle' | 'last' | 'standalone';\n\nexport interface MessageBubbleProps {\n message: Message;\n /** Used to decide left/right alignment, color, and read-receipt visibility. */\n currentUserId: string | null;\n /** `'sent'` → single tick, `'read'` → double tick (theme.colors.brand). */\n readState?: 'sent' | 'read';\n /** Label resolver keyed by `external_id` — falls back to the externalId itself. */\n labelFor?: (externalId: string) => string;\n /** Quoted-card tap handler. Typically used to scroll the list to the original message. */\n onQuotedClick?: (quotedMessageId: Uuid) => void;\n /** Position in a same-sender cluster — drives tail-corner rendering. */\n groupPosition?: BubbleGroupPosition;\n /** Truncate at this many chars and show a \"Read more\" toggle. Defaults to 0 (off). */\n maxBodyLength?: number;\n /** Show a colored sender label above other-side bubbles. Only meaningful in group chats. */\n showSenderName?: boolean;\n /** Slot for an actions trigger — typically a chevron rendered by `<MessageRow>`. */\n actionsTrigger?: ReactNode;\n /** Render in-bubble attachments (images, file cards). Defaults to true. */\n showAttachments?: boolean;\n /**\n * Render the body as Markdown (bold, italic, code, lists, links).\n * Links open via `Linking.openURL`. Requires\n * `react-native-markdown-display` to be installed in the host app;\n * without it we fall back to plain text. Defaults to true.\n */\n markdown?: boolean;\n}\n\nexport function MessageBubble({\n message,\n currentUserId,\n readState,\n labelFor,\n onQuotedClick,\n groupPosition = 'standalone',\n maxBodyLength = 0,\n showSenderName = false,\n actionsTrigger,\n showAttachments = true,\n markdown = true,\n}: MessageBubbleProps) {\n const theme = usePoolseTheme();\n const { width: screenWidth } = useWindowDimensions();\n const isSelf = currentUserId !== null && message.sender_id === currentUserId;\n const [expanded, setExpanded] = useState(false);\n\n // Pixel-based bubble cap pinned to screen width, not to a\n // percentage of an ambiguously-sized parent. Was '88%' on the\n // wrap which resolves to 88% of the bubbleCol — and bubbleCol's\n // width changes with the row's padding, so bumping row padding\n // shrunk multi-line bubbles disproportionately. With a fixed\n // pixel maxWidth + alignSelf:flex-end, single-line and multi-line\n // both hit the same right edge regardless of nesting.\n const bubbleMaxWidth = Math.floor(screenWidth * 0.78);\n // Image / file preview width is bubble width minus the 28px\n // horizontal padding. Use flex '100%' style with a numeric ceiling\n // so the mosaic adapts to the actual rendered bubble.\n const contentMaxWidth = bubbleMaxWidth - 28;\n\n const sender = useUser(!isSelf ? message.sender_external_id : null);\n const senderFallbackName = message.sender_external_id ?? 'Unknown';\n const senderLabel =\n sender.profile?.displayName ??\n (message.sender_external_id\n ? (labelFor?.(message.sender_external_id) ?? senderFallbackName)\n : senderFallbackName);\n const senderTint = userColor(message.sender_external_id ?? message.sender_id ?? message.id);\n\n const tailCorner = groupPosition === 'last' || groupPosition === 'standalone';\n const bubbleColor = isSelf ? theme.colors.selfBubble : theme.colors.otherBubble;\n const textColor = isSelf ? theme.colors.selfBubbleText : theme.colors.otherBubbleText;\n\n const radii = {\n topLeft: theme.radii.bubble,\n topRight: theme.radii.bubble,\n bottomLeft: theme.radii.bubble,\n bottomRight: theme.radii.bubble,\n };\n if (tailCorner) {\n if (isSelf) radii.bottomRight = 4;\n else radii.bottomLeft = 4;\n }\n\n const body = message.body ?? '';\n const truncated =\n maxBodyLength > 0 && body.length > maxBodyLength && !expanded\n ? body.slice(0, maxBodyLength) + '…'\n : body;\n\n const time = formatTime(message.inserted_at);\n const isDeleted = !!message.deleted_at;\n const isEdited = !!message.edited_at && !isDeleted;\n\n const images = (message.attachments ?? []).filter((a) => isImageContentType(a.content_type));\n const files = (message.attachments ?? []).filter((a) => !isImageContentType(a.content_type));\n const renderAttachments = showAttachments && (images.length > 0 || files.length > 0);\n\n return (\n <View\n style={[\n styles.wrap,\n {\n alignSelf: isSelf ? 'flex-end' : 'flex-start',\n // Pixel maxWidth (not percentage) so single-line and\n // multi-line bubbles land at the same right edge — was\n // 88% of the bubbleCol which produced inconsistent right\n // padding when the row padding changed.\n maxWidth: bubbleMaxWidth,\n },\n ]}\n >\n <View\n style={[\n styles.bubble,\n {\n backgroundColor: bubbleColor,\n borderColor: isSelf ? 'transparent' : theme.colors.border,\n borderWidth: isSelf ? 0 : StyleSheet.hairlineWidth,\n borderTopLeftRadius: radii.topLeft,\n borderTopRightRadius: radii.topRight,\n borderBottomLeftRadius: radii.bottomLeft,\n borderBottomRightRadius: radii.bottomRight,\n // Slightly more breathing room — 14/10 reads tighter and\n // matches the iMessage / WhatsApp bubble density.\n paddingHorizontal: 14,\n paddingVertical: 10,\n // Floor the bubble at a width that always fits the meta row\n // (\"edited HH:MM ✓✓\" → ~110px). Without this, short bodies\n // like \"ok\" produce a bubble too narrow for the meta to lay\n // out, and `edited` or the time gets clipped.\n minWidth: isSelf && isEdited ? 130 : 90,\n },\n theme.shadows.sm,\n ]}\n >\n {showSenderName &&\n !isSelf &&\n (groupPosition === 'first' || groupPosition === 'standalone') ? (\n <Text style={[styles.senderName, { color: senderTint, fontFamily: theme.type.fontBody }]}>\n {senderLabel}\n </Text>\n ) : null}\n\n {message.quoted_message ? (\n <QuotedCard\n quoted={message.quoted_message}\n isSelf={isSelf}\n {...(labelFor ? { labelFor } : {})}\n {...(onQuotedClick ? { onPress: () => onQuotedClick(message.quoted_message!.id) } : {})}\n />\n ) : null}\n\n {renderAttachments && images.length > 0 ? (\n <ImageMosaic images={images} maxWidth={contentMaxWidth} />\n ) : null}\n\n {renderAttachments && files.length > 0 ? (\n <View style={{ gap: theme.spacing.xs, marginBottom: theme.spacing.xs }}>\n {files.map((att) => (\n <AttachmentPreview key={att.id} attachment={att} maxWidth={contentMaxWidth} />\n ))}\n </View>\n ) : null}\n\n {body.length > 0 ? (\n isDeleted ? (\n <Text\n style={[\n styles.body,\n {\n color: theme.colors.ink3,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n lineHeight: theme.type.lineHeight,\n fontStyle: 'italic',\n },\n ]}\n >\n Message deleted\n </Text>\n ) : markdown ? (\n renderMarkdown(truncated, {\n textColor,\n linkColor: isSelf ? theme.colors.onBrand : theme.colors.brand,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n lineHeight: theme.type.lineHeight,\n onLinkPress: (url: string) => {\n void Linking.openURL(url).catch(() => undefined);\n return false;\n },\n })\n ) : (\n <Text\n style={[\n styles.body,\n {\n color: textColor,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n lineHeight: theme.type.lineHeight,\n },\n ]}\n >\n {truncated}\n </Text>\n )\n ) : null}\n\n {maxBodyLength > 0 && body.length > maxBodyLength ? (\n <Pressable onPress={() => setExpanded((e) => !e)}>\n <Text\n style={[\n styles.readMore,\n { color: isSelf ? theme.colors.onBrand : theme.colors.brand },\n ]}\n >\n {expanded ? 'Show less' : 'Read more'}\n </Text>\n </Pressable>\n ) : null}\n\n <View style={styles.metaRow}>\n {isEdited ? (\n <Text\n style={[\n styles.editedTag,\n {\n color: isSelf ? theme.colors.onBrand : theme.colors.ink3,\n opacity: 0.7,\n },\n ]}\n >\n edited\n </Text>\n ) : null}\n <Text\n style={[\n styles.meta,\n {\n color: isSelf ? theme.colors.onBrand : theme.colors.ink3,\n opacity: isSelf ? 0.85 : 1,\n },\n ]}\n >\n {time}\n </Text>\n {isSelf && readState ? (\n <View style={styles.readTick}>\n <PoolseIcon\n name={readState === 'read' ? 'check-double' : 'check'}\n size={13}\n color={theme.colors.onBrand}\n />\n </View>\n ) : null}\n </View>\n\n {actionsTrigger ? <View style={styles.actionsSlot}>{actionsTrigger}</View> : null}\n </View>\n </View>\n );\n}\n\nfunction QuotedCard({\n quoted,\n isSelf,\n labelFor,\n onPress,\n}: {\n quoted: QuotedMessagePreview;\n isSelf: boolean;\n labelFor?: (externalId: string) => string;\n onPress?: () => void;\n}) {\n const theme = usePoolseTheme();\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n const resolved = useUser(quoted.sender_external_id);\n const senderName = quoted.sender_external_id\n ? (labelFor?.(quoted.sender_external_id) ??\n resolved.profile?.displayName ??\n quoted.sender_external_id)\n : 'Unknown';\n const bg = isSelf ? 'rgba(255,255,255,0.18)' : theme.colors.surface2;\n const accent = isSelf ? theme.colors.onBrand : theme.colors.brand;\n const txt = isSelf ? theme.colors.onBrand : theme.colors.ink;\n return (\n <Pressable\n onPress={onPress}\n disabled={!onPress}\n style={[\n styles.quoted,\n {\n backgroundColor: bg,\n borderLeftColor: accent,\n },\n ]}\n >\n <Text style={[styles.quotedSender, { color: accent }]}>{senderName}</Text>\n <Text style={[styles.quotedBody, { color: txt }]} numberOfLines={2}>\n {quoted.body ?? '…'}\n </Text>\n </Pressable>\n );\n}\n\nfunction isImageContentType(ct: string | null | undefined): boolean {\n if (!ct) return false;\n return ct.startsWith('image/');\n}\n\n// HH:MM if same calendar day, \"Yesterday HH:MM\" if yesterday, \"Mon DD\"\n// if older than a week, otherwise weekday abbreviation. Matches the\n// WhatsApp / iMessage convention — short enough to fit in the meta\n// row, long enough to be useful at a glance.\nfunction formatTime(iso: string): string {\n try {\n const d = new Date(iso);\n const now = new Date();\n const sameDay = isSameDay(d, now);\n const time = d.toLocaleTimeString([], { hour: 'numeric', minute: '2-digit' });\n if (sameDay) return time;\n\n const yesterday = new Date(now);\n yesterday.setDate(now.getDate() - 1);\n if (isSameDay(d, yesterday)) return `Yesterday ${time}`;\n\n const diffMs = now.getTime() - d.getTime();\n const diffDays = Math.floor(diffMs / 86_400_000);\n if (diffDays < 7) {\n return `${d.toLocaleDateString([], { weekday: 'short' })} ${time}`;\n }\n return d.toLocaleDateString([], { month: 'short', day: 'numeric' });\n } catch {\n return '';\n }\n}\n\nfunction isSameDay(a: Date, b: Date): boolean {\n return (\n a.getFullYear() === b.getFullYear() &&\n a.getMonth() === b.getMonth() &&\n a.getDate() === b.getDate()\n );\n}\n\nconst styles = StyleSheet.create({\n wrap: {\n marginBottom: 2,\n },\n bubble: {\n position: 'relative',\n },\n senderName: {\n fontSize: 12,\n fontWeight: '600',\n marginBottom: 2,\n },\n body: {\n flexShrink: 1,\n },\n readMore: {\n fontSize: 12,\n fontWeight: '600',\n marginTop: 4,\n },\n metaRow: {\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'flex-end',\n marginTop: 6,\n gap: 5,\n flexShrink: 0,\n },\n meta: {\n fontSize: 11,\n fontVariant: ['tabular-nums'],\n includeFontPadding: false,\n },\n editedTag: {\n fontSize: 10,\n fontStyle: 'italic',\n letterSpacing: 0.1,\n },\n readTick: {\n marginLeft: 2,\n marginTop: 1,\n },\n actionsSlot: {\n position: 'absolute',\n top: 4,\n right: 4,\n },\n quoted: {\n borderLeftWidth: 3,\n paddingLeft: 8,\n paddingVertical: 4,\n paddingRight: 6,\n marginBottom: 6,\n borderRadius: 4,\n },\n quotedSender: {\n fontSize: 12,\n fontWeight: '600',\n marginBottom: 2,\n },\n quotedBody: {\n fontSize: 12,\n opacity: 0.85,\n },\n});\n","import type { Uuid } from '@poolse/sdk';\nimport { useReactions } from '@poolse/react';\nimport { Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nconst DEFAULT_EMOJIS = ['👍', '❤️', '😂', '🎉', '🙏', '🔥'];\n\nexport interface ReactionStripProps {\n messageId: Uuid;\n conversationId: Uuid;\n meId: string | null;\n /** Seed map from a known message (e.g. `useMessages`). */\n initialReactions?: Record<string, Uuid[]>;\n}\n\nexport function ReactionStrip({\n messageId,\n conversationId,\n meId,\n initialReactions,\n}: ReactionStripProps) {\n const theme = usePoolseTheme();\n const { reactions, addReaction, removeReaction } = useReactions(messageId, {\n conversationId,\n currentUserId: meId,\n ...(initialReactions ? { initialReactions } : {}),\n });\n const entries = Object.entries(reactions);\n if (entries.length === 0) return null;\n\n return (\n <View style={styles.strip}>\n {entries.map(([emoji, userIds]) => {\n const userArr = Array.isArray(userIds) ? userIds : [];\n const meReacted = meId !== null && userArr.includes(meId);\n return (\n <Pressable\n key={emoji}\n onPress={() => (meReacted ? removeReaction(emoji) : addReaction(emoji))}\n style={[\n styles.chip,\n {\n backgroundColor: meReacted ? theme.colors.brandSoft : theme.colors.surface2,\n borderColor: meReacted ? theme.colors.brand : theme.colors.border,\n borderWidth: meReacted ? 1.5 : 1,\n transform: meReacted ? [{ scale: 1.04 }] : undefined,\n },\n ]}\n >\n <Text style={styles.emoji}>{emoji}</Text>\n <Text\n style={[\n styles.count,\n {\n color: meReacted ? theme.colors.brand : theme.colors.ink2,\n fontWeight: meReacted ? '700' : '600',\n },\n ]}\n >\n {userArr.length}\n </Text>\n </Pressable>\n );\n })}\n </View>\n );\n}\n\nexport interface ReactionPickerProps {\n visible: boolean;\n onClose: () => void;\n onPick: (emoji: string) => void;\n /** Override the default 6-emoji set. */\n emojis?: string[];\n}\n\nexport function ReactionPicker({\n visible,\n onClose,\n onPick,\n emojis = DEFAULT_EMOJIS,\n}: ReactionPickerProps) {\n const theme = usePoolseTheme();\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={onClose}>\n <Pressable style={styles.backdrop} onPress={onClose}>\n <View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.surface,\n borderRadius: theme.radii.lg,\n },\n theme.shadows.lg,\n ]}\n >\n {emojis.map((emoji) => (\n <Pressable\n key={emoji}\n style={styles.emojiBtn}\n onPress={() => {\n onPick(emoji);\n onClose();\n }}\n >\n <Text style={styles.bigEmoji}>{emoji}</Text>\n </Pressable>\n ))}\n </View>\n </Pressable>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n strip: {\n flexDirection: 'row',\n flexWrap: 'wrap',\n gap: 4,\n marginTop: 2,\n },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 9,\n paddingVertical: 4,\n borderRadius: 14,\n gap: 5,\n minHeight: 26,\n // Subtle elevation so chips lift off the surface\n shadowColor: '#000',\n shadowOffset: { width: 0, height: 1 },\n shadowOpacity: 0.06,\n shadowRadius: 2,\n elevation: 1,\n },\n emoji: {\n fontSize: 15,\n lineHeight: 18,\n },\n count: {\n fontSize: 12,\n fontVariant: ['tabular-nums'],\n },\n backdrop: {\n flex: 1,\n backgroundColor: 'rgba(0,0,0,0.4)',\n justifyContent: 'center',\n alignItems: 'center',\n paddingHorizontal: 24,\n },\n sheet: {\n flexDirection: 'row',\n paddingHorizontal: 12,\n paddingVertical: 12,\n gap: 4,\n alignItems: 'center',\n },\n emojiBtn: {\n paddingHorizontal: 8,\n paddingVertical: 6,\n borderRadius: 999,\n alignItems: 'center',\n justifyContent: 'center',\n },\n bigEmoji: {\n fontSize: 32,\n lineHeight: 38,\n },\n});\n","import { Animated, PanResponder, Pressable, StyleSheet, Text, View } from 'react-native';\nimport type { Message, Uuid } from '@poolse/sdk';\nimport { useMemo, useRef, useState } from 'react';\n// Static import — Metro's bundle graph can only trace literal\n// `import` / `require` calls. See ./internal/markdown.ts for the\n// full reasoning. `expo-clipboard` is a required peer dep; consumers\n// who don't want copy can omit the Copy action by not enabling\n// `actions` on <ConversationView>.\nimport * as Clipboard from 'expo-clipboard';\n\nimport { Avatar } from './primitives/Avatar.js';\nimport { MessageActions } from './MessageActions.js';\nimport { MessageBubble, type BubbleGroupPosition } from './MessageBubble.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { ReactionStrip } from './Reactions.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\nimport { useReactions, useUser } from '@poolse/react';\n\n// Swipe-to-reply triggers at this much horizontal pull. iOS / WhatsApp\n// use 50–60px; the lower bound feels lighter for one-handed thumb use.\nconst SWIPE_REPLY_THRESHOLD = 50;\n\nexport interface MessageRowProps {\n msg: Message;\n meId: string | null;\n\n // Feature toggles — same set as ConversationView's, but per-row.\n reactions?: boolean;\n attachments?: boolean;\n actions?: boolean;\n /** Pass false in ThreadView since nested threads aren't a thing in v1. */\n threads?: boolean;\n /** WhatsApp-style quote-reply. Defaults true on ConversationView. */\n quotations?: boolean;\n /** Forwarded to `<MessageBubble markdown>`. Defaults true. */\n markdown?: boolean;\n\n readState?: 'sent' | 'read';\n\n /**\n * Whether this row's message is the one currently being edited.\n * Editing happens in the composer (see MessageComposer's\n * `editingMessage` prop); this flag is only used to elevate the\n * row above the dim backdrop ConversationView renders during\n * edit mode.\n */\n isEditing?: boolean;\n /**\n * Long-press → \"Edit\". Omitted entirely (no Edit option in the\n * menu) when the parent has decided this message isn't editable\n * (someone read it, it's deleted, it isn't yours).\n */\n onStartEdit?: () => void;\n onDelete?: () => void;\n onOpenThread?: () => void;\n onQuote?: () => void;\n labelFor?: (externalId: string) => string;\n onQuotedClick?: (quotedMessageId: Uuid) => void;\n groupPosition?: BubbleGroupPosition;\n maxBodyLength?: number;\n /** Show a colored sender label above other-side bubbles. */\n showSenderName?: boolean;\n /** Render an avatar to the LEFT of other-side bubbles. */\n showAvatar?: boolean;\n /** Avatar resolver — same signature as `<MemberList avatarFor>`. */\n avatarFor?: (externalId: string) => string | null;\n}\n\nexport function MessageRow({\n msg,\n meId,\n reactions = true,\n attachments = true,\n actions = true,\n threads = true,\n quotations = true,\n markdown = true,\n readState,\n isEditing = false,\n onStartEdit,\n onDelete,\n onOpenThread,\n onQuote,\n labelFor,\n onQuotedClick,\n groupPosition = 'standalone',\n maxBodyLength = 0,\n showSenderName = false,\n showAvatar = false,\n avatarFor,\n}: MessageRowProps) {\n const theme = usePoolseTheme();\n const isSelf = meId !== null && msg.sender_id === meId;\n const [actionsOpen, setActionsOpen] = useState(false);\n\n // Per-row useReactions subscription so the long-press → React picker\n // and the inline ReactionStrip share the same realtime state. Adds\n // one realtime listener per visible row, which is fine — they're\n // server-filtered by messageId and the FlatList only mounts rows in\n // view. Initial seed comes from msg.reactions so the strip renders\n // immediately without waiting for the first echo.\n const reactionsApi = useReactions(msg.id, {\n conversationId: msg.conversation_id,\n currentUserId: meId,\n ...(msg.reactions ? { initialReactions: msg.reactions } : {}),\n });\n\n // Swipe-to-reply state. The bubble's translateX is driven by a pan\n // gesture; when the user releases past SWIPE_REPLY_THRESHOLD we fire\n // onQuote (which the parent wires to setReplyingTo on the composer).\n // Animation runs on the JS thread because we need to read the value\n // synchronously on release — native driver would prevent that.\n const translateX = useRef(new Animated.Value(0)).current;\n const swipeEnabled = quotations && !!onQuote && !isEditing;\n\n const panResponder = useMemo(\n () =>\n PanResponder.create({\n // Tap / long-press still go to the inner Pressable.\n onStartShouldSetPanResponder: () => false,\n onStartShouldSetPanResponderCapture: () => false,\n // Capture-phase claim: we intercept the gesture BEFORE the\n // child Pressable as soon as the move shows clear horizontal\n // intent. Without capture-phase, the Pressable's touch handling\n // wins first and the pan never starts (this is why self-bubble\n // left swipes felt totally dead — the Pressable was attached\n // to a touch that started with the user's finger over the\n // bubble center, and we never got a turn).\n onMoveShouldSetPanResponder: () => false,\n onMoveShouldSetPanResponderCapture: (_, g) => {\n if (!swipeEnabled) return false;\n // 4px is plenty to disambiguate from an accidental jitter\n // during a tap. `dx > dy` (not `dx > dy * 2`) so a slightly\n // diagonal pull still counts as horizontal — the user isn't\n // going to hold their finger to a perfect axis.\n return Math.abs(g.dx) > 4 && Math.abs(g.dx) > Math.abs(g.dy);\n },\n // Don't surrender the gesture mid-swipe (e.g. parent FlatList\n // asking for it back) — once we're translating the bubble we\n // hold on until release.\n onPanResponderTerminationRequest: () => false,\n // 1:1 finger-follow up to the threshold, then square-root\n // damping past it so the bubble never slides off-screen.\n // Matches iMessage / WhatsApp — feels weightless during the\n // committed range and stiffens once you've already triggered.\n onPanResponderMove: (_, g) => {\n const dx = isSelf ? Math.min(0, g.dx) : Math.max(0, g.dx);\n const abs = Math.abs(dx);\n let translated: number;\n if (abs <= SWIPE_REPLY_THRESHOLD) {\n translated = dx;\n } else {\n const excess = abs - SWIPE_REPLY_THRESHOLD;\n const dampened = SWIPE_REPLY_THRESHOLD + Math.sqrt(excess * 6);\n translated = dx < 0 ? -dampened : dampened;\n }\n translateX.setValue(translated);\n },\n onPanResponderRelease: (_, g) => {\n const past = Math.abs(g.dx) >= SWIPE_REPLY_THRESHOLD;\n if (past && onQuote) onQuote();\n Animated.spring(translateX, {\n toValue: 0,\n useNativeDriver: false,\n speed: 28,\n bounciness: 4,\n }).start();\n },\n onPanResponderTerminate: () => {\n Animated.spring(translateX, {\n toValue: 0,\n useNativeDriver: false,\n speed: 28,\n bounciness: 4,\n }).start();\n },\n }),\n [swipeEnabled, isSelf, onQuote, translateX],\n );\n\n // Reply icon fades + scales in as the bubble drags past ~half the\n // threshold. Sits on the SAME side the swipe is coming FROM (so\n // it's revealed behind the bubble as the bubble slides away).\n const replyIconOpacity = translateX.interpolate({\n inputRange: isSelf\n ? [-SWIPE_REPLY_THRESHOLD, -SWIPE_REPLY_THRESHOLD / 2, 0]\n : [0, SWIPE_REPLY_THRESHOLD / 2, SWIPE_REPLY_THRESHOLD],\n outputRange: isSelf ? [1, 0.3, 0] : [0, 0.3, 1],\n extrapolate: 'clamp',\n });\n const replyIconScale = translateX.interpolate({\n inputRange: isSelf ? [-SWIPE_REPLY_THRESHOLD, 0] : [0, SWIPE_REPLY_THRESHOLD],\n outputRange: isSelf ? [1, 0.5] : [0.5, 1],\n extrapolate: 'clamp',\n });\n\n const showAvatarSlot = showAvatar && !isSelf;\n const showAvatarRender =\n showAvatarSlot && (groupPosition === 'last' || groupPosition === 'standalone');\n // Resolve avatar / label with the same priority as MessageBubble /\n // ChatHeader: explicit prop > SDK userResolver > externalId fallback.\n // Without the useUser fallback, omitting `avatarFor` / `labelFor` on\n // <ConversationView> bypassed the resolver at the row level even\n // when `PoolseConfig.userResolver` was configured.\n const rowSender = useUser(showAvatarSlot ? msg.sender_external_id : null);\n const avatarUrl = msg.sender_external_id\n ? (avatarFor?.(msg.sender_external_id) ?? rowSender.profile?.avatarUrl ?? null)\n : null;\n const senderLabel = msg.sender_external_id\n ? (labelFor?.(msg.sender_external_id) ??\n rowSender.profile?.displayName ??\n msg.sender_external_id)\n : null;\n\n return (\n <View\n style={[\n styles.row,\n { alignSelf: isSelf ? 'flex-end' : 'flex-start' },\n // Lift this row above the dim backdrop the parent renders\n // during edit mode. zIndex covers iOS / web; elevation does\n // the equivalent on Android.\n isEditing ? styles.rowEditing : null,\n ]}\n >\n {showAvatarSlot ? (\n <View style={styles.avatarSlot}>\n {showAvatarRender ? (\n <Avatar\n src={avatarUrl ?? null}\n name={senderLabel}\n seed={msg.sender_external_id ?? null}\n size=\"sm\"\n />\n ) : null}\n </View>\n ) : null}\n\n <View style={styles.bubbleCol}>\n {swipeEnabled ? (\n <Animated.View\n pointerEvents=\"none\"\n style={[\n styles.replyHint,\n isSelf ? styles.replyHintRight : styles.replyHintLeft,\n {\n opacity: replyIconOpacity,\n transform: [{ scale: replyIconScale }],\n backgroundColor: theme.colors.surface2,\n },\n ]}\n >\n <PoolseIcon name=\"reply\" size={16} color={theme.colors.brand} />\n </Animated.View>\n ) : null}\n\n <Animated.View\n {...(swipeEnabled ? panResponder.panHandlers : {})}\n style={{ transform: [{ translateX }] }}\n >\n <Pressable\n onLongPress={() => {\n if (!actions) return;\n setActionsOpen(true);\n }}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Message actions\"\n >\n <MessageBubble\n message={msg}\n currentUserId={meId}\n {...(readState ? { readState } : {})}\n {...(labelFor ? { labelFor } : {})}\n {...(onQuotedClick ? { onQuotedClick } : {})}\n groupPosition={groupPosition}\n maxBodyLength={maxBodyLength}\n showSenderName={showSenderName}\n showAttachments={attachments}\n markdown={markdown}\n actionsTrigger={\n actions ? (\n <Pressable onPress={() => setActionsOpen(true)} hitSlop={8}>\n <PoolseIcon\n name=\"chevron-down\"\n size={14}\n color={isSelf ? theme.colors.onBrand : theme.colors.ink3}\n />\n </Pressable>\n ) : null\n }\n />\n </Pressable>\n </Animated.View>\n\n {threads && (msg.reply_count ?? 0) > 0 && onOpenThread ? (\n <Pressable onPress={onOpenThread} style={styles.threadPill}>\n <Text style={[styles.threadPillText, { color: theme.colors.brand }]}>\n 💬 {msg.reply_count} {msg.reply_count === 1 ? 'reply' : 'replies'}\n </Text>\n </Pressable>\n ) : null}\n\n {reactions ? (\n <View style={[styles.reactionsRow, { alignSelf: isSelf ? 'flex-end' : 'flex-start' }]}>\n <ReactionStrip\n messageId={msg.id}\n conversationId={msg.conversation_id}\n meId={meId}\n {...(msg.reactions ? { initialReactions: msg.reactions } : {})}\n />\n </View>\n ) : null}\n </View>\n\n {actions && actionsOpen ? (\n <MessageActions\n visible={actionsOpen}\n onClose={() => setActionsOpen(false)}\n isSelf={isSelf}\n {...(reactions\n ? {\n // Inline quick-react row at the top of the sheet —\n // one tap = react + close, no second modal needed.\n onPickReaction: (emoji: string) => {\n void reactionsApi.addReaction(emoji);\n },\n }\n : {})}\n {...(msg.body && !msg.deleted_at\n ? {\n onCopy: () => {\n setActionsOpen(false);\n void Clipboard.setStringAsync(msg.body ?? '');\n },\n }\n : {})}\n {...(onStartEdit\n ? {\n onEdit: () => {\n setActionsOpen(false);\n onStartEdit();\n },\n }\n : {})}\n {...(onDelete\n ? {\n onDelete: () => {\n setActionsOpen(false);\n onDelete();\n },\n }\n : {})}\n {...(onOpenThread\n ? {\n onReplyInThread: () => {\n setActionsOpen(false);\n onOpenThread();\n },\n }\n : {})}\n {...(quotations && onQuote\n ? {\n onQuote: () => {\n setActionsOpen(false);\n onQuote();\n },\n }\n : {})}\n />\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'flex-end',\n // Tighter vertical rhythm — was 2px each side (4px between rows)\n // plus the bubble's 4px marginBottom = 8px. Now 1+1+2 = 4px,\n // closer to iMessage / WhatsApp density.\n marginVertical: 1,\n // 10px on each side — tight enough to use the available width\n // for content, loose enough to keep bubbles off the screen edge\n // on every device.\n paddingHorizontal: 10,\n maxWidth: '95%',\n },\n rowEditing: {\n // Above ConversationView's editBackdrop (zIndex 5). Elevation\n // does the equivalent stacking on Android.\n zIndex: 10,\n elevation: 10,\n },\n avatarSlot: {\n width: 36,\n marginRight: 6,\n },\n bubbleCol: {\n flexShrink: 1,\n position: 'relative',\n },\n replyHint: {\n position: 'absolute',\n top: '50%',\n marginTop: -16,\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n zIndex: -1,\n },\n replyHintLeft: {\n left: -44,\n },\n replyHintRight: {\n right: -44,\n },\n threadPill: {\n alignSelf: 'flex-start',\n marginTop: 2,\n paddingHorizontal: 8,\n paddingVertical: 3,\n },\n threadPillText: {\n fontSize: 11,\n fontWeight: '600',\n },\n reactionsRow: {\n marginTop: 2,\n },\n});\n","import type { Message, Uuid } from '@poolse/sdk';\nimport { useMe, useThread } from '@poolse/react';\nimport { useCallback, useMemo, useState, type ReactElement } from 'react';\nimport {\n Animated,\n KeyboardAvoidingView,\n Modal,\n Platform,\n Pressable,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { AttachmentPicker } from './AttachmentPicker.js';\nimport { MessageComposer } from './MessageComposer.js';\nimport { MessageList } from './MessageList.js';\nimport { MessageRow } from './MessageRow.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { UploadProvider } from './internal/uploadContext.js';\nimport { useDismissableSheet } from './internal/useDismissableSheet.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface ThreadViewProps {\n visible: boolean;\n onClose: () => void;\n conversationId: Uuid;\n rootMessage: Message;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n}\n\n// Sheet covers the bottom 88% of the screen. The remaining 12% is the\n// pull-down gutter (also the keyboardVerticalOffset for iOS).\nconst SHEET_HEIGHT_FRACTION = 0.88;\n\n/**\n * Bottom-sheet modal for thread replies. Pull the drag handle / header\n * down to dismiss; tap the backdrop or close button too. The composer\n * inside the sheet supports attachments (paperclip → picker, shared\n * upload queue) and the reply rows support reactions, swipe-to-reply,\n * long-press actions, edit, delete — same surface as ConversationView.\n *\n * Keyboard handling: inside a Modal the OS doesn't auto-resize the\n * sheet's children, so the composer needs its own KeyboardAvoidingView\n * with `keyboardVerticalOffset` set to the distance between the screen\n * top and the sheet top (the gutter above the sheet).\n */\nexport function ThreadView({\n visible,\n onClose,\n conversationId,\n rootMessage,\n labelFor,\n avatarFor,\n}: ThreadViewProps) {\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={onClose}\n statusBarTranslucent\n >\n {/* Each open of the thread gets its own UploadProvider so the\n composer's queue is isolated from the parent ConversationView's\n composer queue. */}\n <UploadProvider>\n <ThreadSheet\n onClose={onClose}\n conversationId={conversationId}\n rootMessage={rootMessage}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n </UploadProvider>\n </Modal>\n );\n}\n\nfunction ThreadSheet({\n onClose,\n conversationId,\n rootMessage,\n labelFor,\n avatarFor,\n}: {\n onClose: () => void;\n conversationId: Uuid;\n rootMessage: Message;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n}) {\n const theme = usePoolseTheme();\n const { me } = useMe();\n const meId = me?.id ?? null;\n const {\n replies,\n sendReply,\n edit,\n delete: deleteReply,\n loadMore,\n hasMore,\n } = useThread(conversationId, rootMessage.id);\n const { height: screenHeight } = useWindowDimensions();\n const sheetHeight = Math.round(screenHeight * SHEET_HEIGHT_FRACTION);\n const gutter = screenHeight - sheetHeight;\n const { translateY, panHandlers } = useDismissableSheet({ onClose, sheetHeight });\n\n const [pickerOpen, setPickerOpen] = useState(false);\n const [editingId, setEditingId] = useState<string | null>(null);\n\n const renderReply = useCallback(\n (msg: Message): ReactElement => {\n const isSelf = meId !== null && msg.sender_id === meId;\n const canEdit = isSelf && !msg.deleted_at;\n return (\n <MessageRow\n msg={msg}\n meId={meId}\n // Reactions + actions on by default; nested threads off (you\n // can't thread inside a thread in v1).\n reactions\n attachments\n actions\n threads={false}\n // Quote-to-reply doesn't make sense inside a single-root thread.\n quotations={false}\n isEditing={editingId === msg.id}\n {...(canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {})}\n onDelete={() => {\n void deleteReply(msg.id);\n }}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n );\n },\n [meId, editingId, deleteReply, labelFor, avatarFor],\n );\n\n const editingMessage = useMemo(\n () => (editingId ? (replies.find((m) => m.id === editingId) ?? null) : null),\n [editingId, replies],\n );\n\n const rootRow = useMemo(\n () => (\n <MessageRow\n msg={rootMessage}\n meId={meId}\n reactions\n attachments\n actions={false}\n threads={false}\n quotations={false}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n ),\n [rootMessage, meId, labelFor, avatarFor],\n );\n\n return (\n <View style={styles.modalRoot}>\n <Pressable style={styles.backdrop} onPress={onClose} accessibilityLabel=\"Close thread\" />\n\n <Animated.View\n style={[\n styles.sheet,\n {\n height: sheetHeight,\n backgroundColor: theme.colors.paper,\n borderTopLeftRadius: theme.radii.xl,\n borderTopRightRadius: theme.radii.xl,\n transform: [{ translateY }],\n },\n theme.shadows.lg,\n ]}\n >\n {/* Wrap the header + drag pill in the pan handler so users can\n pull from a comfortable 60-pt-tall strip — the bare 16-pt\n pill on its own was nearly invisible to fingers. */}\n <View {...panHandlers}>\n <View style={styles.dragHandle}>\n <View style={[styles.dragPill, { backgroundColor: theme.colors.ink3 }]} />\n </View>\n\n <View style={[styles.header, { borderBottomColor: theme.colors.border }]}>\n <Pressable\n onPress={onClose}\n hitSlop={16}\n style={[styles.closeBtn, { backgroundColor: theme.colors.surface2 }]}\n accessibilityLabel=\"Close thread\"\n >\n <PoolseIcon name=\"close\" size={18} color={theme.colors.ink} />\n </Pressable>\n <Text\n style={[\n styles.title,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n >\n Thread\n </Text>\n </View>\n </View>\n\n {/* KAV scope: just the scrolling area + composer. Keyboard pushes\n the composer up by the keyboard height minus the gutter\n (since the gutter is already \"free\" space above the sheet\n top). On Android we use `height` behavior — works inside a\n Modal because the modal window itself responds to adjustResize. */}\n <KeyboardAvoidingView\n style={styles.kavBody}\n behavior={Platform.OS === 'ios' ? 'padding' : 'height'}\n keyboardVerticalOffset={Platform.OS === 'ios' ? gutter : 0}\n >\n <View style={[styles.rootPreview, { backgroundColor: theme.colors.surface2 }]}>\n {rootRow}\n </View>\n\n <View style={styles.listWrap}>\n <MessageList\n messages={replies}\n hasMore={hasMore}\n onLoadMore={loadMore}\n renderItem={renderReply}\n />\n </View>\n\n <MessageComposer\n onSend={async (body, opts) => {\n await sendReply({ body, ...opts });\n }}\n placeholder=\"Reply to thread…\"\n attachments\n onAttachPress={() => setPickerOpen(true)}\n editingMessage={editingMessage}\n onCancelEdit={() => setEditingId(null)}\n onSaveEdit={async (body) => {\n if (!editingId) return;\n await edit(editingId, body);\n setEditingId(null);\n }}\n />\n </KeyboardAvoidingView>\n\n <AttachmentPicker visible={pickerOpen} onClose={() => setPickerOpen(false)} />\n </Animated.View>\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n modalRoot: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n backdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.4)',\n },\n sheet: {\n overflow: 'hidden',\n },\n dragHandle: {\n alignItems: 'center',\n paddingTop: 8,\n paddingBottom: 4,\n },\n dragPill: {\n width: 36,\n height: 4,\n borderRadius: 2,\n opacity: 0.4,\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingTop: 6,\n paddingBottom: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 10,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n },\n title: {\n fontSize: 16,\n fontWeight: '600',\n },\n rootPreview: {\n paddingVertical: 8,\n paddingHorizontal: 8,\n },\n kavBody: {\n flex: 1,\n },\n listWrap: {\n flex: 1,\n },\n});\n","import { Text } from 'react-native';\nimport { useUser } from '@poolse/react';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface UserNameProps {\n /** The user's external_id. Pass null to render the fallback. */\n externalId: string | null | undefined;\n /** Optional fallback when the resolver returns nothing. Defaults to the externalId itself. */\n fallback?: string;\n /** Caller-supplied label override; if it returns a string, it wins. */\n labelFor?: (externalId: string) => string;\n}\n\n/**\n * Display name for a user, looked up via the SDK's `userResolver`\n * with caller-overridable + fallback fallbacks. Renders a `<Text>`.\n */\nexport function UserName({ externalId, fallback, labelFor }: UserNameProps) {\n const theme = usePoolseTheme();\n const name = useDisplayName(externalId, labelFor) ?? fallback ?? externalId ?? '';\n return <Text style={{ color: theme.colors.ink, fontFamily: theme.type.fontBody }}>{name}</Text>;\n}\n\n/**\n * Resolves a user's display name via the 3-tier chain:\n * 1. `labelFor(externalId)` — caller-supplied override\n * 2. SDK `userResolver` (memoized via `useUser`)\n * 3. The externalId itself (so something always renders)\n */\nexport function useDisplayName(\n externalId: string | null | undefined,\n labelFor?: (externalId: string) => string,\n): string {\n const resolved = useUser(externalId ?? null);\n if (!externalId) return '';\n if (labelFor) {\n const override = labelFor(externalId);\n if (override) return override;\n }\n return resolved.profile?.displayName ?? externalId;\n}\n","import { useEffect, useRef } from 'react';\nimport { Animated, StyleSheet, Text, View, Easing } from 'react-native';\n\nimport { useDisplayName } from './UserName.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport interface TypingIndicatorProps {\n /** Set of `external_id`s currently typing — what `useTyping` returns. */\n typing: Set<string>;\n /**\n * Resolves an `external_id` to a display label. Defaults to the\n * SDK's `userResolver` (and falls back to the external_id itself\n * when the resolver isn't configured).\n */\n labelFor?: (externalId: string) => string;\n}\n\n/**\n * Three animated dots + an inline \"X is typing\" label. Renders a\n * zero-height row when nobody is typing so the list doesn't jump.\n */\nexport function TypingIndicator({ typing, labelFor }: TypingIndicatorProps) {\n const ids = Array.from(typing);\n const isTyping = ids.length > 0;\n\n if (!isTyping) return <View style={{ height: 0 }} />;\n\n return (\n <View style={styles.row}>\n <TypingDots />\n <TypingLabel ids={ids} {...(labelFor ? { labelFor } : {})} />\n </View>\n );\n}\n\nfunction TypingDots() {\n const theme = usePoolseTheme();\n const a = useRef(new Animated.Value(0)).current;\n const b = useRef(new Animated.Value(0)).current;\n const c = useRef(new Animated.Value(0)).current;\n\n useEffect(() => {\n const loop = (val: Animated.Value, delay: number) =>\n Animated.loop(\n Animated.sequence([\n Animated.delay(delay),\n Animated.timing(val, {\n toValue: 1,\n duration: 400,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n Animated.timing(val, {\n toValue: 0,\n duration: 400,\n easing: Easing.inOut(Easing.ease),\n useNativeDriver: true,\n }),\n ]),\n );\n const animations = [loop(a, 0), loop(b, 150), loop(c, 300)];\n animations.forEach((anim) => anim.start());\n return () => animations.forEach((anim) => anim.stop());\n }, [a, b, c]);\n\n const dot = (val: Animated.Value) => ({\n width: 6,\n height: 6,\n borderRadius: 3,\n backgroundColor: theme.colors.ink3,\n marginHorizontal: 2,\n transform: [\n {\n translateY: val.interpolate({ inputRange: [0, 1], outputRange: [0, -3] }),\n },\n ],\n opacity: val.interpolate({ inputRange: [0, 1], outputRange: [0.5, 1] }),\n });\n\n return (\n <View style={styles.dotsWrap}>\n <Animated.View style={dot(a)} />\n <Animated.View style={dot(b)} />\n <Animated.View style={dot(c)} />\n </View>\n );\n}\n\nfunction TypingLabel({\n ids,\n labelFor,\n}: {\n ids: string[];\n labelFor?: (externalId: string) => string;\n}) {\n const theme = usePoolseTheme();\n const id1 = ids[0] ?? null;\n const id2 = ids[1] ?? null;\n const name1 = useDisplayName(id1, labelFor);\n const name2 = useDisplayName(id2, labelFor);\n\n const text =\n ids.length === 1\n ? `${name1} is typing`\n : ids.length === 2\n ? `${name1} and ${name2} are typing`\n : `${ids.length} people are typing`;\n\n return (\n <Text style={[styles.label, { color: theme.colors.ink2, fontFamily: theme.type.fontBody }]}>\n {text}\n </Text>\n );\n}\n\nconst styles = StyleSheet.create({\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingVertical: 6,\n },\n dotsWrap: {\n flexDirection: 'row',\n alignItems: 'flex-end',\n marginRight: 8,\n height: 12,\n },\n label: {\n fontSize: 12,\n },\n});\n","import type { Message, Uuid } from '@poolse/sdk';\nimport {\n computeGroupPosition,\n formatDayLabel,\n sameDay,\n useMe,\n useMembers,\n useMessages,\n useRealtimeStatus,\n useTyping,\n} from '@poolse/react';\nimport { useCallback, useEffect, useMemo, useRef, useState, type ReactElement } from 'react';\nimport {\n AppState,\n KeyboardAvoidingView,\n Platform,\n Pressable,\n StyleSheet,\n View,\n} from 'react-native';\n\nimport { AttachmentPicker } from './AttachmentPicker.js';\nimport { ChatHeader } from './ChatHeader.js';\nimport { DaySeparator } from './DaySeparator.js';\nimport { MentionInput } from './MentionInput.js';\nimport { MessageComposer } from './MessageComposer.js';\nimport { MessageList, type MessageListItem } from './MessageList.js';\nimport { MessageRow } from './MessageRow.js';\nimport { ThreadView } from './ThreadView.js';\nimport { TypingIndicator } from './TypingIndicator.js';\nimport { UploadProvider } from './internal/uploadContext.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\n// Two messages from the same sender within this window collapse\n// into a visual cluster (tight margin, grouped bubble corners).\n// Matches the react-ui default.\nconst GROUPING_WINDOW_MS = 5 * 60 * 1000;\n\nexport interface ConversationViewProps {\n conversationId: Uuid;\n emptyState?: ReactElement | string;\n renderMessage?: (msg: Message, currentUserId: string | null) => ReactElement;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n\n /**\n * Renders the default `<ChatHeader>` at the top of the chat surface.\n * * `true` (default) — auto chat header (other user / group name).\n * * `false` — no header (you supply your own above).\n * * `ReactElement` — custom header node, rendered as-is.\n */\n header?: boolean | ReactElement;\n /** Tap on the header's members icon — typically opens a sheet. */\n onHeaderMembersPress?: () => void;\n /** Tap on the header itself — typically opens a conversation profile. */\n onHeaderPress?: () => void;\n\n // Feature toggles — all default ON, identical names + defaults to web.\n reactions?: boolean;\n mentions?: boolean;\n attachments?: boolean;\n actions?: boolean;\n threads?: boolean;\n quotations?: boolean;\n readReceipts?: boolean;\n /** Render message bodies as Markdown (links, bold, code). Defaults true. */\n markdown?: boolean;\n maxBodyLength?: number;\n\n /** Show sender labels in group chats. `auto` (default), `always`, `never`. */\n senderLabels?: 'auto' | 'always' | 'never';\n /** Show avatars to the left of other-side bubbles in group chats. Same semantics. */\n avatars?: 'auto' | 'always' | 'never';\n\n /**\n * Fires when auto-mark-read commits a new server-side read cursor.\n * Receives the conversation id + the message id that was marked\n * as the last-read. Wire this to `useConversations().markConversationRead(convId, msgId)`\n * so the sidebar / list view's unread badge clears immediately\n * instead of waiting for the next conversations refetch.\n */\n onMarkedRead?: (conversationId: string, messageId: string) => void;\n /**\n * Fires after every successful message send. Wire to the parent's\n * `useConversations().refetch()` so the conversation list shows\n * the fresh `last_message_preview` / `last_message_at` for the\n * conversation you just sent into. `useConversations` creates\n * isolated state per call site, so ConversationView can't refresh\n * a parent hook's state on its own.\n */\n onSent?: (conversationId: string) => void;\n /**\n * keyboardVerticalOffset passed to the internal KeyboardAvoidingView.\n * On iOS this MUST equal the distance from the screen top to the\n * KAV's top (status bar + safe-area-top + any nav header above\n * the chat). `<PoolseInbox>` computes this for you. Standalone\n * consumers pass it manually.\n */\n keyboardOffset?: number;\n}\n\nexport function ConversationView({\n conversationId,\n emptyState,\n renderMessage,\n labelFor,\n avatarFor,\n header = true,\n onHeaderMembersPress,\n onHeaderPress,\n reactions = true,\n mentions = true,\n attachments = true,\n actions = true,\n threads = true,\n quotations = true,\n readReceipts = true,\n markdown = true,\n maxBodyLength = 200,\n senderLabels = 'auto',\n avatars = 'auto',\n onMarkedRead,\n onSent,\n keyboardOffset = 0,\n}: ConversationViewProps) {\n const theme = usePoolseTheme();\n const { me } = useMe();\n const meId = me?.id ?? null;\n\n const {\n messages,\n loading,\n hasMore,\n loadMore,\n send,\n edit,\n delete: deleteMsg,\n markReadUpTo,\n refetch,\n } = useMessages(conversationId);\n const { typing, signalTyping } = useTyping(conversationId);\n const realtimeStatus = useRealtimeStatus();\n\n // Pull the latest page when the app foregrounds or the socket\n // reconnects. While the socket is down (background, network drop)\n // we miss `message:new` pushes; without this the chat shows stale\n // data until the user navigates away and back.\n useEffect(() => {\n const sub = AppState.addEventListener('change', (next) => {\n if (next === 'active') void refetch();\n });\n return () => sub.remove();\n }, [refetch]);\n\n const prevStatusRef = useRef(realtimeStatus);\n useEffect(() => {\n const prev = prevStatusRef.current;\n prevStatusRef.current = realtimeStatus;\n if (\n realtimeStatus === 'connected' &&\n (prev === 'reconnecting' || prev === 'closed' || prev === 'connecting')\n ) {\n void refetch();\n }\n }, [realtimeStatus, refetch]);\n\n const wantsMembers = mentions || senderLabels === 'auto' || avatars === 'auto';\n const { members } = useMembers(wantsMembers ? conversationId : '');\n const isGroupChat = members.length > 2;\n const showSenderLabels = senderLabels === 'always' || (senderLabels === 'auto' && isGroupChat);\n const showAvatars = avatars === 'always' || (avatars === 'auto' && isGroupChat);\n\n const [replyingTo, setReplyingTo] = useState<Message | null>(null);\n const [editingId, setEditingId] = useState<string | null>(null);\n const [threadRoot, setThreadRoot] = useState<Message | null>(null);\n const [pickerOpen, setPickerOpen] = useState(false);\n\n // messageId → sequence map for read-receipt comparison. Membership\n // only carries `last_read_message_id` (UUID); to know whether\n // member X read message Y we have to translate the read message's\n // id into its sequence and compare against Y's sequence. UUIDs\n // aren't chronological so we have to do this lookup explicitly.\n const sequenceByMessageId = useMemo(() => {\n const m = new Map<string, number>();\n for (const msg of messages) {\n if (typeof msg.sequence === 'number') m.set(msg.id, msg.sequence);\n }\n return m;\n }, [messages]);\n\n // Auto-mark-read: advance the read cursor whenever a confirmed\n // message lands at the tail. Skip optimistic temp messages\n // (no `sequence` yet — server hasn't seen the id) to avoid\n // 404s when send-then-immediately-mark races the round-trip.\n // Wrapping in try/catch lets us survive any other transient\n // membership-write failures without breaking the chat.\n const lastMarkedRef = useRef<string | null>(null);\n useEffect(() => {\n if (!readReceipts) return;\n if (messages.length === 0) return;\n const latest = messages[messages.length - 1];\n if (!latest || !latest.id) return;\n if (latest.id === lastMarkedRef.current) return;\n // Optimistic temp messages don't have a server-assigned sequence.\n // Marking them would 404 (server hasn't processed the send yet);\n // wait for the realtime confirmation to land, which replaces the\n // temp with a real message carrying a real sequence.\n if (typeof latest.sequence !== 'number' || latest.sequence <= 0) return;\n lastMarkedRef.current = latest.id;\n void markReadUpTo(latest.id).catch(() => {\n // Reset so we retry on the next message arrival.\n lastMarkedRef.current = null;\n });\n onMarkedRead?.(conversationId, latest.id);\n }, [messages, meId, readReceipts, markReadUpTo, onMarkedRead, conversationId]);\n\n // Precompute per-message group position (drives the bubble's\n // corner treatment + inter-cluster spacing). Same logic as\n // react-ui's ConversationView; the helpers live in @poolse/react.\n const groupPositionById = useMemo(() => {\n const map = new Map<string, ReturnType<typeof computeGroupPosition>>();\n for (let i = 0; i < messages.length; i++) {\n const msg = messages[i];\n if (!msg) continue;\n const prev = i > 0 ? (messages[i - 1] ?? null) : null;\n const next = i < messages.length - 1 ? (messages[i + 1] ?? null) : null;\n map.set(msg.id, computeGroupPosition(msg, prev, next, GROUPING_WINDOW_MS));\n }\n return map;\n }, [messages]);\n\n const renderItem = useCallback(\n (msg: Message): ReactElement => {\n if (renderMessage) return <>{renderMessage(msg, meId)}</>;\n const readState: 'sent' | 'read' | undefined =\n readReceipts && meId !== null && msg.sender_id === meId\n ? readStateForMessage(msg, members, meId, sequenceByMessageId)\n : undefined;\n // Edit is only offered for own messages no one else has read\n // yet — once someone has \"seen\" it (their last_read_message_id\n // sequence >= this one) WhatsApp-style apps disable editing to\n // prevent conversation rewriting. `readStateForMessage`\n // returns 'sent' in 1:1 chats with no other member, so own\n // messages in fresh threads stay editable.\n const isSelf = meId !== null && msg.sender_id === meId;\n const canEdit = isSelf && !msg.deleted_at && (readState ?? 'sent') === 'sent';\n const groupPosition = groupPositionById.get(msg.id) ?? 'standalone';\n return (\n <MessageRow\n msg={msg}\n meId={meId}\n reactions={reactions}\n attachments={attachments}\n actions={actions}\n threads={threads}\n quotations={quotations}\n {...(readState ? { readState } : {})}\n isEditing={editingId === msg.id}\n {...(canEdit ? { onStartEdit: () => setEditingId(msg.id) } : {})}\n onDelete={() => deleteMsg(msg.id)}\n {...(threads ? { onOpenThread: () => setThreadRoot(msg) } : {})}\n {...(quotations ? { onQuote: () => setReplyingTo(msg) } : {})}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n showSenderName={showSenderLabels}\n showAvatar={showAvatars}\n maxBodyLength={maxBodyLength}\n groupPosition={groupPosition}\n markdown={markdown}\n />\n );\n },\n [\n renderMessage,\n meId,\n readReceipts,\n members,\n reactions,\n attachments,\n actions,\n threads,\n quotations,\n editingId,\n deleteMsg,\n labelFor,\n avatarFor,\n showSenderLabels,\n showAvatars,\n maxBodyLength,\n sequenceByMessageId,\n groupPositionById,\n markdown,\n ],\n );\n\n const editingMessage = useMemo(\n () => (editingId ? (messages.find((m) => m.id === editingId) ?? null) : null),\n [editingId, messages],\n );\n\n // Build the interleaved item list (messages + day separators).\n // Inject a separator BEFORE a message whenever its day differs\n // from the previous message's day.\n const listItems = useMemo<MessageListItem[]>(() => {\n const out: MessageListItem[] = [];\n let prev: Message | null = null;\n for (const msg of messages) {\n if (prev === null || !sameDay(msg.inserted_at, prev.inserted_at)) {\n const label = formatDayLabel(msg.inserted_at);\n out.push({\n kind: 'separator',\n id: `sep-${msg.id}`,\n node: <DaySeparator label={label} />,\n });\n }\n out.push({ kind: 'msg', msg });\n prev = msg;\n }\n return out;\n }, [messages]);\n\n const composerProps = useMemo(\n () => ({\n onSend: async (\n body: string,\n opts?: { quoted_message_id?: Uuid; attachment_ids?: Uuid[]; mentions?: Uuid[] },\n ) => {\n await send({ body, ...opts });\n setReplyingTo(null);\n // Tell the parent so it can refresh ITS useConversations\n // state. useConversations creates isolated state per call\n // site, so a refetch from here wouldn't update PoolseInbox's\n // list — only the parent's own hook instance can.\n onSent?.(conversationId);\n },\n onTyping: signalTyping,\n ...(attachments ? { onAttachPress: () => setPickerOpen(true) } : {}),\n ...(replyingTo ? { replyingTo } : {}),\n onCancelReply: () => setReplyingTo(null),\n ...(labelFor ? { labelFor } : {}),\n attachments,\n keyboardOffset,\n editingMessage,\n onCancelEdit: () => setEditingId(null),\n onSaveEdit: async (body: string) => {\n if (!editingId) return;\n await edit(editingId, body);\n setEditingId(null);\n },\n }),\n [\n send,\n signalTyping,\n attachments,\n replyingTo,\n labelFor,\n keyboardOffset,\n onSent,\n conversationId,\n editingMessage,\n editingId,\n edit,\n ],\n );\n\n const headerNode =\n header === false ? null : header === true ? (\n <ChatHeader\n conversationId={conversationId}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n {...(onHeaderMembersPress ? { onMembersPress: onHeaderMembersPress } : {})}\n {...(onHeaderPress ? { onPress: onHeaderPress } : {})}\n />\n ) : (\n header\n );\n\n return (\n <UploadProvider>\n <KeyboardAvoidingView\n // iOS uses `padding` (the height behavior is documented as\n // only working on absolute-positioned children and is\n // basically a no-op inside flex:1 chains like ours).\n // Padding mode REQUIRES the right keyboardVerticalOffset —\n // the distance from the screen top to the KAV's top.\n // PoolseInbox computes this from the safe-area top + its own\n // ChatHeader height and passes it through; standalone\n // consumers must pass it themselves.\n //\n // Android uses `height` — works there because the layout\n // recomputes from the Android window resize.\n style={[styles.root, { backgroundColor: theme.colors.paper }]}\n behavior={Platform.OS === 'ios' ? 'padding' : 'height'}\n keyboardVerticalOffset={keyboardOffset}\n >\n {headerNode}\n <View style={styles.listWrap}>\n <MessageList\n messages={messages}\n items={listItems}\n meId={meId}\n loading={loading}\n hasMore={hasMore}\n onLoadMore={loadMore}\n renderItem={renderItem}\n ListHeader={<TypingIndicator typing={typing} {...(labelFor ? { labelFor } : {})} />}\n {...(emptyState !== undefined ? { emptyState } : {})}\n />\n {/* WhatsApp-style dim while editing: the overlay covers\n the scroll surface but the row being edited renders\n above it (MessageRow elevates itself when isEditing).\n Tap-outside cancels. */}\n {editingId ? (\n <Pressable\n style={styles.editBackdrop}\n onPress={() => setEditingId(null)}\n accessibilityLabel=\"Cancel editing\"\n />\n ) : null}\n </View>\n\n {mentions ? (\n <MentionInput conversationId={conversationId} {...composerProps} />\n ) : (\n <MessageComposer {...composerProps} />\n )}\n\n {attachments ? (\n <AttachmentPicker visible={pickerOpen} onClose={() => setPickerOpen(false)} />\n ) : null}\n\n {threads && threadRoot ? (\n <ThreadView\n visible\n onClose={() => setThreadRoot(null)}\n conversationId={conversationId}\n rootMessage={threadRoot}\n {...(labelFor ? { labelFor } : {})}\n />\n ) : null}\n </KeyboardAvoidingView>\n </UploadProvider>\n );\n}\n\nfunction readStateForMessage(\n msg: Message,\n members: ReadonlyArray<{ user_id: string; last_read_message_id: string | null }>,\n meId: string,\n sequenceByMessageId: Map<string, number>,\n): 'sent' | 'read' {\n const otherMembers = members.filter((m) => m.user_id !== meId);\n if (otherMembers.length === 0) return 'sent';\n if (typeof msg.sequence !== 'number') return 'sent';\n const mySeq = msg.sequence;\n const anyRead = otherMembers.some((m) => {\n if (!m.last_read_message_id) return false;\n const readSeq = sequenceByMessageId.get(m.last_read_message_id);\n if (readSeq === undefined) return false;\n return readSeq >= mySeq;\n });\n return anyRead ? 'read' : 'sent';\n}\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n },\n listWrap: {\n flex: 1,\n },\n editBackdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.45)',\n // Sit above message rows by default but below any row that\n // explicitly elevates itself (MessageRow bumps zIndex/elevation\n // when isEditing is true).\n zIndex: 5,\n },\n});\n","import { useMemo, useState } from 'react';\nimport {\n Animated,\n FlatList,\n Image,\n Modal,\n Pressable,\n StyleSheet,\n Text,\n TextInput,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { Avatar } from '../primitives/Avatar.js';\nimport { PoolseIcon } from '../primitives/PoolseIcon.js';\nimport { useDismissableSheet } from './useDismissableSheet.js';\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\n\nexport interface InboxUser {\n /** The user's external_id (the same id you mint JWTs with). */\n externalId: string;\n /** Display name shown in the picker row. */\n name: string;\n /** Optional avatar URL — falls back to initials if missing. */\n avatarUrl?: string | null;\n /** Optional secondary line (email, role, handle…). */\n subtitle?: string;\n}\n\nexport interface UserPickerSheetProps {\n visible: boolean;\n onClose: () => void;\n users: InboxUser[];\n /** External_ids to hide (usually the caller's own id). */\n excludeIds?: string[];\n /**\n * `single` → direct-chat mode; tap a row, fires onPickDirect, closes.\n * `group` → multi-select with a group-name input + Create button.\n */\n mode: 'single' | 'group';\n onPickDirect?: (externalId: string) => void;\n onCreateGroup?: (name: string, memberExternalIds: string[]) => void;\n /** Optional header slot — title defaults to \"New chat\" / \"New group\". */\n title?: string;\n /** Search input shown when user count ≥ 8. Override to force on/off. */\n searchable?: boolean;\n}\n\n/**\n * Bottom-sheet picker for selecting one or many users from the\n * tenant's user directory. Used by `<PoolseInbox>` for the\n * built-in \"New chat\" / \"New group\" flows. Exported standalone so\n * devs can drive it from their own UI (e.g. a \"Forward to…\" sheet).\n */\nexport function UserPickerSheet({\n visible,\n onClose,\n users,\n excludeIds,\n mode,\n onPickDirect,\n onCreateGroup,\n title,\n searchable,\n}: UserPickerSheetProps) {\n const theme = usePoolseTheme();\n const [query, setQuery] = useState('');\n const [selectedIds, setSelectedIds] = useState<string[]>([]);\n const [groupName, setGroupName] = useState('');\n const { height: screenHeight } = useWindowDimensions();\n const { translateY, panHandlers } = useDismissableSheet({\n onClose: () => {\n // Reset selection state on dismiss so it doesn't survive\n // across opens.\n setQuery('');\n setSelectedIds([]);\n setGroupName('');\n onClose();\n },\n sheetHeight: screenHeight * 0.85,\n });\n\n const excludeSet = useMemo(() => new Set(excludeIds ?? []), [excludeIds]);\n const filtered = useMemo(() => {\n const q = query.trim().toLowerCase();\n return users.filter((u) => {\n if (excludeSet.has(u.externalId)) return false;\n if (!q) return true;\n return (\n u.name.toLowerCase().includes(q) ||\n (u.subtitle ?? '').toLowerCase().includes(q) ||\n u.externalId.toLowerCase().includes(q)\n );\n });\n }, [users, query, excludeSet]);\n\n const showSearch = searchable ?? users.length >= 8;\n const isGroup = mode === 'group';\n const heading = title ?? (isGroup ? 'New group' : 'New chat');\n\n const reset = () => {\n setQuery('');\n setSelectedIds([]);\n setGroupName('');\n };\n\n const handleClose = () => {\n reset();\n onClose();\n };\n\n const toggle = (externalId: string) => {\n setSelectedIds((prev) =>\n prev.includes(externalId) ? prev.filter((id) => id !== externalId) : [...prev, externalId],\n );\n };\n\n const canCreate = isGroup && selectedIds.length > 0 && groupName.trim().length > 0;\n\n const handleCreate = () => {\n if (!canCreate) return;\n onCreateGroup?.(groupName.trim(), selectedIds);\n reset();\n onClose();\n };\n\n return (\n <Modal\n visible={visible}\n transparent\n animationType=\"slide\"\n onRequestClose={handleClose}\n statusBarTranslucent\n >\n <View style={styles.modalRoot}>\n <Pressable style={styles.backdrop} onPress={handleClose} />\n\n <Animated.View\n style={[\n styles.sheet,\n {\n backgroundColor: theme.colors.paper,\n borderTopLeftRadius: theme.radii.xl,\n borderTopRightRadius: theme.radii.xl,\n transform: [{ translateY }],\n },\n theme.shadows.lg,\n ]}\n >\n <View {...panHandlers} style={styles.dragHandle}>\n <View style={[styles.dragPill, { backgroundColor: theme.colors.ink3 }]} />\n </View>\n\n <View style={styles.header}>\n <Pressable\n onPress={handleClose}\n hitSlop={16}\n style={[styles.closeBtn, { backgroundColor: theme.colors.surface2 }]}\n accessibilityLabel=\"Close picker\"\n >\n <PoolseIcon name=\"close\" size={18} color={theme.colors.ink} />\n </Pressable>\n <Text\n style={[\n styles.title,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n numberOfLines={1}\n >\n {heading}\n </Text>\n {isGroup ? (\n <Pressable\n onPress={handleCreate}\n disabled={!canCreate}\n hitSlop={6}\n style={[\n styles.createBtn,\n {\n backgroundColor: canCreate ? theme.colors.brand : theme.colors.surface2,\n opacity: canCreate ? 1 : 0.6,\n },\n ]}\n >\n <Text\n style={{\n color: canCreate ? theme.colors.onBrand : theme.colors.ink3,\n fontWeight: '700',\n fontSize: 13,\n }}\n >\n Create{selectedIds.length > 0 ? ` (${selectedIds.length})` : ''}\n </Text>\n </Pressable>\n ) : null}\n </View>\n\n {isGroup ? (\n <TextInput\n placeholder=\"Group name\"\n placeholderTextColor={theme.colors.ink3}\n value={groupName}\n onChangeText={setGroupName}\n style={[\n styles.groupNameInput,\n {\n color: theme.colors.ink,\n backgroundColor: theme.colors.surface2,\n borderRadius: theme.radii.md,\n fontFamily: theme.type.fontBody,\n fontSize: theme.type.bodySize,\n },\n ]}\n />\n ) : null}\n\n {showSearch ? (\n <TextInput\n placeholder=\"Search…\"\n placeholderTextColor={theme.colors.ink3}\n value={query}\n onChangeText={setQuery}\n style={[\n styles.searchInput,\n {\n color: theme.colors.ink,\n backgroundColor: theme.colors.surface2,\n borderRadius: theme.radii.md,\n fontFamily: theme.type.fontBody,\n fontSize: 14,\n },\n ]}\n />\n ) : null}\n\n <FlatList\n data={filtered}\n keyExtractor={(u) => u.externalId}\n ListEmptyComponent={\n <View style={styles.empty}>\n <Text style={[styles.emptyText, { color: theme.colors.ink3 }]}>\n {query ? 'No matches.' : 'No users to show.'}\n </Text>\n </View>\n }\n renderItem={({ item }) => (\n <UserRow\n user={item}\n selected={selectedIds.includes(item.externalId)}\n isGroup={isGroup}\n onPress={() => {\n if (isGroup) toggle(item.externalId);\n else {\n onPickDirect?.(item.externalId);\n reset();\n onClose();\n }\n }}\n />\n )}\n />\n </Animated.View>\n </View>\n </Modal>\n );\n}\n\nfunction UserRow({\n user,\n selected,\n isGroup,\n onPress,\n}: {\n user: InboxUser;\n selected: boolean;\n isGroup: boolean;\n onPress: () => void;\n}) {\n const theme = usePoolseTheme();\n return (\n <Pressable\n onPress={onPress}\n style={[\n styles.row,\n {\n backgroundColor: selected ? theme.colors.brandSoft : 'transparent',\n },\n ]}\n >\n {user.avatarUrl ? (\n <Image source={{ uri: user.avatarUrl }} style={styles.avatarImg} />\n ) : (\n <Avatar src={null} name={user.name} seed={user.externalId} size=\"md\" />\n )}\n <View style={styles.body}>\n <Text\n style={[styles.name, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {user.name}\n </Text>\n {user.subtitle ? (\n <Text style={[styles.subtitle, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {user.subtitle}\n </Text>\n ) : null}\n </View>\n {isGroup ? (\n <View\n style={[\n styles.checkbox,\n {\n borderColor: selected ? theme.colors.brand : theme.colors.border,\n backgroundColor: selected ? theme.colors.brand : 'transparent',\n },\n ]}\n >\n {selected ? <PoolseIcon name=\"check\" size={14} color={theme.colors.onBrand} /> : null}\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n modalRoot: {\n flex: 1,\n justifyContent: 'flex-end',\n },\n backdrop: {\n ...StyleSheet.absoluteFillObject,\n backgroundColor: 'rgba(0,0,0,0.4)',\n },\n sheet: {\n height: '85%',\n overflow: 'hidden',\n },\n dragHandle: {\n alignItems: 'center',\n paddingTop: 8,\n paddingBottom: 4,\n },\n dragPill: {\n width: 36,\n height: 4,\n borderRadius: 2,\n opacity: 0.4,\n },\n header: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 12,\n paddingTop: 4,\n paddingBottom: 12,\n gap: 10,\n },\n closeBtn: {\n width: 32,\n height: 32,\n borderRadius: 16,\n alignItems: 'center',\n justifyContent: 'center',\n },\n title: {\n fontSize: 17,\n fontWeight: '700',\n flex: 1,\n },\n createBtn: {\n paddingHorizontal: 14,\n paddingVertical: 7,\n borderRadius: 999,\n },\n groupNameInput: {\n marginHorizontal: 16,\n marginBottom: 8,\n paddingHorizontal: 12,\n paddingVertical: 10,\n fontWeight: '600',\n },\n searchInput: {\n marginHorizontal: 16,\n marginBottom: 8,\n paddingHorizontal: 12,\n paddingVertical: 8,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 16,\n paddingVertical: 10,\n gap: 12,\n },\n avatarImg: {\n width: 40,\n height: 40,\n borderRadius: 20,\n },\n body: {\n flex: 1,\n gap: 2,\n },\n name: {\n fontSize: 15,\n fontWeight: '600',\n },\n subtitle: {\n fontSize: 12,\n },\n checkbox: {\n width: 22,\n height: 22,\n borderRadius: 11,\n borderWidth: 1.5,\n alignItems: 'center',\n justifyContent: 'center',\n },\n empty: {\n paddingVertical: 40,\n alignItems: 'center',\n },\n emptyText: {\n fontSize: 13,\n },\n});\n","import type { Conversation, Uuid } from '@poolse/sdk';\nimport { useConversations, useMe, useUser } from '@poolse/react';\nimport {\n forwardRef,\n useCallback,\n useEffect,\n useImperativeHandle,\n useMemo,\n useRef,\n useState,\n type ReactNode,\n} from 'react';\nimport {\n Animated,\n Easing,\n Image,\n PanResponder,\n Pressable,\n StyleSheet,\n Text,\n useWindowDimensions,\n View,\n} from 'react-native';\n\nimport { ChatHeader } from './ChatHeader.js';\nimport { ConversationList } from './ConversationList.js';\nimport { ConversationView } from './ConversationView.js';\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { Avatar } from './primitives/Avatar.js';\nimport { UserPickerSheet, type InboxUser } from './internal/UserPickerSheet.js';\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\n\nexport type { InboxUser } from './internal/UserPickerSheet.js';\n\n// Height of the ChatHeader we render above ConversationView in the\n// detail pane. Hardcoded because ChatHeader has fixed vertical\n// padding (10 + 36 content + 10 ≈ 56). If you change ChatHeader's\n// padding, bump this constant.\nconst CHAT_HEADER_HEIGHT = 56;\n\nexport interface PoolseInboxProps {\n /** Header title above the conversation list. Defaults to \"Chats\". */\n title?: string;\n\n /**\n * The tenant's user directory. When provided, the inbox shows\n * \"New chat\" + \"New group\" buttons in the header. Omit if you\n * don't want the built-in picker UI (e.g. you start chats from\n * elsewhere via the imperative `openDirect()` API).\n */\n users?: InboxUser[];\n\n /** Display-name resolver for sender labels / chat header titles. */\n labelFor?: (externalId: string) => string;\n /** Avatar URL resolver. */\n avatarFor?: (externalId: string) => string | null;\n\n /**\n * Right-side slot in the header — typical use is a logout / settings\n * button. Rendered after the New-chat / New-group buttons.\n */\n renderRightAction?: () => ReactNode;\n\n /**\n * Custom row renderer for the conversation list. Receives the\n * conversation + the caller's external_id (resolved via `useMe`)\n * so you can branch on direct-vs-group display.\n */\n renderConversationRow?: (\n conv: Conversation,\n callerExternalId: string | null,\n selected: boolean,\n ) => ReactNode;\n\n /** Custom empty state when the list is empty. */\n emptyState?: ReactNode | string;\n\n /** Forwarded to `<ConversationView>` — set if you have a nav header above. */\n keyboardOffset?: number;\n}\n\nexport interface PoolseInboxHandle {\n /** Open a known conversation (e.g. from a deep link / push tap). */\n open: (conversationId: Uuid) => void;\n /**\n * Open (or create) a direct conversation with the given external_id.\n * The backend dedupes per pair — returns the existing conversation\n * if one already exists. Use this from a \"Message\" button on your\n * user profile screens.\n */\n openDirect: (externalId: string) => Promise<void>;\n /** Open (or create) a group conversation. */\n openGroup: (name: string, memberExternalIds: string[]) => Promise<void>;\n /** Open the built-in \"new chat\" picker programmatically. */\n promptNewChat: () => void;\n /** Open the built-in \"new group\" picker programmatically. */\n promptNewGroup: () => void;\n /** Pop back to the conversation list. */\n close: () => void;\n}\n\n/**\n * Drop-in inbox screen: scrollable list of conversations + chat\n * detail, with an iOS-style slide animation between them. Manages\n * its own navigation stack (no react-navigation needed). Picker\n * sheets for \"New chat\" / \"New group\" appear when `users` is\n * provided; otherwise the dev wires those flows themselves and\n * uses the imperative ref to open conversations.\n *\n * For the \"Message\" button on a user profile screen, hold a ref to\n * the inbox and call `inboxRef.current?.openDirect(externalId)`.\n */\nexport const PoolseInbox = forwardRef<PoolseInboxHandle, PoolseInboxProps>(\n function PoolseInbox(props, ref) {\n const {\n title = 'Chats',\n users,\n labelFor,\n avatarFor,\n renderRightAction,\n renderConversationRow,\n emptyState,\n keyboardOffset = 0,\n } = props;\n\n const theme = usePoolseTheme();\n const { width: screenWidth } = useWindowDimensions();\n const { me } = useMe();\n const {\n conversations,\n create,\n unreadCounts,\n markConversationRead,\n refetch: refetchConversations,\n } = useConversations();\n const meExternalId = me?.external_id ?? null;\n // KAV.frame.y is measured relative to the SafeAreaView's\n // coordinate space (the SafeAreaView already absorbs the\n // safe-area-top inset). So the only chrome we need to compensate\n // for in keyboardVerticalOffset is our own ChatHeader above the\n // KAV. Adding insets.top on top double-counts and pushes the\n // composer way too far above the keyboard.\n const detailKeyboardOffset = CHAT_HEADER_HEIGHT;\n\n const [activeId, setActiveId] = useState<Uuid | null>(null);\n const [userPickerOpen, setUserPickerOpen] = useState(false);\n const [groupPickerOpen, setGroupPickerOpen] = useState(false);\n\n const slide = useRef(new Animated.Value(0)).current;\n // Flipped to true while the user is dragging the detail pane via\n // the edge-swipe gesture so the activeId-driven timing animation\n // doesn't fight the finger.\n const draggingRef = useRef(false);\n useEffect(() => {\n if (draggingRef.current) return;\n Animated.timing(slide, {\n toValue: activeId ? 1 : 0,\n duration: 280,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n }, [activeId, slide]);\n\n const listTransform = slide.interpolate({\n inputRange: [0, 1],\n outputRange: [0, -Math.round(screenWidth * 0.25)],\n });\n const detailTransform = slide.interpolate({\n inputRange: [0, 1],\n outputRange: [screenWidth, 0],\n });\n\n // ── Edge-swipe-to-dismiss ────────────────────────────────────────\n // A thin invisible strip pinned to the screen's left edge owns a\n // PanResponder that drags the detail pane back to the right. Only\n // arms when:\n // - the detail pane is currently shown (activeId != null), AND\n // - the gesture starts within EDGE_WIDTH of the left screen edge,\n // AND\n // - the first movement is horizontal-dominant + rightward.\n // Those gates keep the strip from eating bubble swipes, vertical\n // scrolls, or back-button taps in the ChatHeader.\n const EDGE_WIDTH = 24;\n const DISMISS_VX_THRESHOLD = 0.4;\n const activeIdRef = useRef(activeId);\n useEffect(() => {\n activeIdRef.current = activeId;\n }, [activeId]);\n const panResponder = useMemo(() => {\n // Commit-vs-snap threshold scales with the screen so the gesture\n // feels right on phone widths AND tablets.\n const dismissDxThreshold = screenWidth * 0.35;\n return PanResponder.create({\n // Never claim the touch on start — that would swallow taps on\n // the back button in the ChatHeader strip.\n onStartShouldSetPanResponder: () => false,\n onStartShouldSetPanResponderCapture: () => false,\n onMoveShouldSetPanResponder: (_e, gs) => {\n if (!activeIdRef.current) return false;\n if (gs.x0 > EDGE_WIDTH) return false;\n return gs.dx > 6 && Math.abs(gs.dx) > Math.abs(gs.dy);\n },\n onMoveShouldSetPanResponderCapture: (_e, gs) => {\n if (!activeIdRef.current) return false;\n if (gs.x0 > EDGE_WIDTH) return false;\n return gs.dx > 6 && Math.abs(gs.dx) > Math.abs(gs.dy);\n },\n onPanResponderGrant: () => {\n draggingRef.current = true;\n slide.stopAnimation();\n },\n onPanResponderMove: (_e, gs) => {\n // Map finger displacement to slide: dx=0 → slide=1\n // (detail fully on); dx=screenWidth → slide=0 (off).\n const dx = Math.max(0, gs.dx);\n const progress = Math.min(1, dx / screenWidth);\n slide.setValue(1 - progress);\n },\n onPanResponderRelease: (_e, gs) => {\n draggingRef.current = false;\n const past = gs.dx > dismissDxThreshold || gs.vx > DISMISS_VX_THRESHOLD;\n if (past) {\n // Let the activeId-effect drive the close animation from\n // wherever the finger left the pane — Animated.timing\n // starts from the current value, so the motion is\n // continuous.\n setActiveId(null);\n } else {\n Animated.timing(slide, {\n toValue: 1,\n duration: 220,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n }\n },\n onPanResponderTerminate: () => {\n // Another responder took over (rare — scroll, dialog).\n // Snap back to \"open\" so the pane doesn't get stuck.\n draggingRef.current = false;\n Animated.timing(slide, {\n toValue: 1,\n duration: 220,\n easing: Easing.out(Easing.cubic),\n useNativeDriver: true,\n }).start();\n },\n onPanResponderTerminationRequest: () => false,\n });\n }, [slide, screenWidth]);\n\n const openDirect = useCallback(\n async (externalId: string) => {\n const conv = await create({\n type: 'direct',\n member_external_ids: [externalId],\n });\n setActiveId(conv.id);\n },\n [create],\n );\n\n const openGroup = useCallback(\n async (name: string, memberExternalIds: string[]) => {\n const conv = await create({\n type: 'group',\n name,\n member_external_ids: memberExternalIds,\n });\n setActiveId(conv.id);\n },\n [create],\n );\n\n useImperativeHandle(\n ref,\n () => ({\n open: setActiveId,\n openDirect,\n openGroup,\n promptNewChat: () => setUserPickerOpen(true),\n promptNewGroup: () => setGroupPickerOpen(true),\n close: () => setActiveId(null),\n }),\n [openDirect, openGroup],\n );\n\n const renderRow = useCallback(\n (conv: Conversation, selected: boolean) => {\n if (renderConversationRow) {\n return <>{renderConversationRow(conv, meExternalId, selected)}</>;\n }\n // Live unread count from useConversations — updates immediately\n // when markConversationRead fires, instead of waiting for the\n // next list refetch. Falls back to the server snapshot on the\n // conversation row when the live map doesn't have an entry yet.\n const unread = unreadCounts?.[conv.id] ?? conv.unread_count ?? 0;\n return (\n <DefaultConversationRow\n conv={conv}\n selected={selected}\n meExternalId={meExternalId}\n unread={unread}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n onPress={() => setActiveId(conv.id)}\n />\n );\n },\n [renderConversationRow, meExternalId, labelFor, avatarFor, unreadCounts],\n );\n\n return (\n <View style={[styles.root, { backgroundColor: theme.colors.paper }]}>\n {/* LIST PANE */}\n <Animated.View\n style={[StyleSheet.absoluteFillObject, { transform: [{ translateX: listTransform }] }]}\n pointerEvents={activeId ? 'none' : 'auto'}\n >\n <View\n style={[\n styles.listHeader,\n {\n backgroundColor: theme.colors.surface,\n borderBottomColor: theme.colors.border,\n },\n ]}\n >\n <Text\n style={[\n styles.listTitle,\n { color: theme.colors.ink, fontFamily: theme.type.fontDisplay },\n ]}\n >\n {title}\n </Text>\n <View style={styles.headerActions}>\n {users ? (\n <>\n <HeaderIconButton\n icon=\"compose\"\n onPress={() => setUserPickerOpen(true)}\n label=\"New chat\"\n />\n <HeaderIconButton\n icon=\"users\"\n onPress={() => setGroupPickerOpen(true)}\n label=\"New group\"\n />\n </>\n ) : null}\n {renderRightAction?.()}\n </View>\n </View>\n\n <ConversationList\n conversations={conversations}\n renderItem={renderRow}\n {...(emptyState !== undefined ? { emptyState } : {})}\n />\n </Animated.View>\n\n {/* DETAIL PANE — our own ChatHeader (with onBack wired) above\n a ConversationView with header={false} so they don't stack.\n PanResponder lives on this wrapper (not a separate overlay\n strip) so taps fall straight through to the back button /\n attachment / send buttons — the strip approach would have\n stolen the leftmost slice of those tap targets. The gate in\n onMoveShouldSetPanResponderCapture restricts gestures to\n the left edge + horizontal-dominant + rightward, so vertical\n scrolling, swipe-to-reply on bubbles (which lives further\n inside), and button taps stay unaffected. */}\n <Animated.View\n style={[StyleSheet.absoluteFillObject, { transform: [{ translateX: detailTransform }] }]}\n pointerEvents={activeId ? 'auto' : 'none'}\n {...panResponder.panHandlers}\n >\n {activeId ? (\n <View style={{ flex: 1 }}>\n <ChatHeader\n conversationId={activeId}\n onBack={() => setActiveId(null)}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n <ConversationView\n key={activeId}\n conversationId={activeId}\n header={false}\n // Caller override wins; else use safe-area-top + our\n // ChatHeader height as the iOS keyboardVerticalOffset.\n keyboardOffset={keyboardOffset || detailKeyboardOffset}\n onMarkedRead={(convId) => {\n // Optimistic local clear so the badge disappears\n // immediately — server-side cursor was advanced\n // by ConversationView's markReadUpTo.\n markConversationRead(convId);\n }}\n onSent={() => {\n // useConversations is per-call-site state — only\n // OUR refetch updates the list's preview / timestamps.\n void refetchConversations();\n }}\n {...(labelFor ? { labelFor } : {})}\n {...(avatarFor ? { avatarFor } : {})}\n />\n </View>\n ) : null}\n </Animated.View>\n\n {/* Pickers */}\n {users ? (\n <UserPickerSheet\n visible={userPickerOpen}\n onClose={() => setUserPickerOpen(false)}\n users={users}\n excludeIds={meExternalId ? [meExternalId] : []}\n mode=\"single\"\n onPickDirect={(externalId) => {\n void openDirect(externalId);\n }}\n />\n ) : null}\n\n {users ? (\n <UserPickerSheet\n visible={groupPickerOpen}\n onClose={() => setGroupPickerOpen(false)}\n users={users}\n excludeIds={meExternalId ? [meExternalId] : []}\n mode=\"group\"\n onCreateGroup={(name, ids) => {\n void openGroup(name, ids);\n }}\n />\n ) : null}\n </View>\n );\n },\n);\n\nfunction HeaderIconButton({\n icon,\n onPress,\n label,\n}: {\n icon: 'compose' | 'users';\n onPress: () => void;\n label: string;\n}) {\n const theme = usePoolseTheme();\n return (\n <Pressable\n onPress={onPress}\n hitSlop={10}\n accessibilityLabel={label}\n style={({ pressed }) => [\n styles.iconBtn,\n {\n backgroundColor: pressed ? theme.colors.surface2 : 'transparent',\n },\n ]}\n >\n <PoolseIcon name={icon} size={20} color={theme.colors.ink} />\n </Pressable>\n );\n}\n\nfunction DefaultConversationRow({\n conv,\n selected,\n meExternalId,\n unread,\n labelFor,\n avatarFor,\n onPress,\n}: {\n conv: Conversation;\n selected: boolean;\n meExternalId: string | null;\n unread: number;\n labelFor?: (externalId: string) => string;\n avatarFor?: (externalId: string) => string | null;\n onPress: () => void;\n}) {\n const theme = usePoolseTheme();\n\n // For directs, derive display from the OTHER member's external_id\n // (added to Conversation.member_external_ids by the backend). For\n // groups, use the conversation's own name + a group avatar tile.\n const isDirect = conv.type === 'direct';\n const otherExtId =\n isDirect && meExternalId\n ? (conv.member_external_ids ?? []).find((x) => x !== meExternalId)\n : null;\n\n // Priority: explicit prop > SDK userResolver > externalId fallback.\n // Inbox rows are typically the first place an avatar / name shows up\n // for a conversation, so the resolver must run here too — not only\n // inside ConversationView's bubbles.\n const resolvedOther = useUser(isDirect ? (otherExtId ?? null) : null);\n const title = isDirect\n ? otherExtId\n ? (labelFor?.(otherExtId) ?? resolvedOther.profile?.displayName ?? otherExtId)\n : 'Direct chat'\n : (conv.name ?? 'Untitled group');\n\n const avatarUrl =\n isDirect && otherExtId\n ? (avatarFor?.(otherExtId) ?? resolvedOther.profile?.avatarUrl ?? null)\n : null;\n const avatarSeed = isDirect ? (otherExtId ?? conv.id) : conv.id;\n\n return (\n <Pressable\n onPress={onPress}\n style={[\n styles.row,\n {\n backgroundColor: selected ? theme.colors.surface2 : 'transparent',\n borderBottomColor: theme.colors.border,\n },\n ]}\n >\n {avatarUrl ? (\n <Image source={{ uri: avatarUrl }} style={styles.rowAvatar} />\n ) : (\n <Avatar src={null} name={title} seed={avatarSeed} size=\"md\" />\n )}\n <View style={styles.rowBody}>\n <Text\n style={[styles.rowTitle, { color: theme.colors.ink, fontFamily: theme.type.fontBody }]}\n numberOfLines={1}\n >\n {title}\n </Text>\n <Text style={[styles.rowSubtitle, { color: theme.colors.ink3 }]} numberOfLines={1}>\n {conv.last_message_preview ??\n (isDirect ? (otherExtId ?? '') : `${(conv.member_external_ids ?? []).length} members`)}\n </Text>\n </View>\n {unread > 0 ? (\n <View style={[styles.unreadPill, { backgroundColor: theme.colors.unreadPill }]}>\n <Text style={[styles.unreadText, { color: theme.colors.unreadPillText }]}>\n {unread > 99 ? '99+' : String(unread)}\n </Text>\n </View>\n ) : null}\n </Pressable>\n );\n}\n\nconst styles = StyleSheet.create({\n root: {\n flex: 1,\n overflow: 'hidden',\n },\n listHeader: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 14,\n paddingVertical: 10,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 12,\n },\n listTitle: {\n flex: 1,\n fontSize: 20,\n fontWeight: '700',\n },\n headerActions: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 4,\n },\n iconBtn: {\n width: 36,\n height: 36,\n borderRadius: 18,\n alignItems: 'center',\n justifyContent: 'center',\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n paddingHorizontal: 14,\n paddingVertical: 12,\n borderBottomWidth: StyleSheet.hairlineWidth,\n gap: 12,\n },\n rowAvatar: {\n width: 44,\n height: 44,\n borderRadius: 22,\n },\n rowBody: {\n flex: 1,\n gap: 2,\n },\n rowTitle: {\n fontSize: 15,\n fontWeight: '600',\n },\n rowSubtitle: {\n fontSize: 12,\n },\n unreadPill: {\n minWidth: 22,\n height: 22,\n borderRadius: 11,\n paddingHorizontal: 7,\n alignItems: 'center',\n justifyContent: 'center',\n },\n unreadText: {\n fontSize: 11,\n fontWeight: '700',\n },\n});\n","import { Svg, Path, Circle, G } from 'react-native-svg';\n\nimport { usePoolseTheme } from '../theme/PoolseTheme.js';\n\nexport type PoolseLogoVariant = 'lockup' | 'mark' | 'wordmark' | 'mono';\n\nexport interface PoolseLogoProps {\n variant?: PoolseLogoVariant;\n /** Height in pixels — width is computed from the variant's aspect ratio. */\n size?: number;\n /** Mono variant accepts a color override; otherwise the theme drives fills. */\n color?: string;\n label?: string | null;\n}\n\nconst TILE_PATH = 'M50 4 C20 4 4 20 4 50 C4 80 20 96 50 96 C80 96 96 80 96 50 C96 20 80 4 50 4 Z';\nconst PULSE_PATH = 'M16 55 H34 L40 55 L47 30 L54 73 L60 55 H72';\nconst WORDMARK_P_PATH =\n 'M62 -169V258V528H194L196 378L214 376Q223 432 246.0 469.0Q269 506 305.5 524.0Q342 542 389 542Q459 542 509.5 508.0Q560 474 587.0 411.0Q614 348 614 260Q614 182 590.5 120.0Q567 58 519.5 22.0Q472 -14 399 -14Q350 -14 316.0 3.5Q282 21 258.5 55.0Q235 89 219 140H200Q206 113 211.0 85.0Q216 57 219.5 31.0Q223 5 223 -19V-169ZM340 113Q373 113 396.5 131.0Q420 149 433.0 182.0Q446 215 446 259Q446 306 432.5 339.5Q419 373 394.0 391.5Q369 410 336 410Q305 410 283.5 396.5Q262 383 248.5 361.5Q235 340 229.0 316.0Q223 292 223 271V249Q223 230 228.0 211.0Q233 192 243.0 174.5Q253 157 267.0 143.0Q281 129 299.5 121.0Q318 113 340 113Z';\nconst WORDMARK_O_PATH =\n 'M305 -14Q225 -14 163.5 17.0Q102 48 67.0 110.0Q32 172 32 265Q32 358 67.0 419.5Q102 481 164.0 511.5Q226 542 306 542Q386 542 448.0 511.0Q510 480 545.0 418.5Q580 357 580 264Q580 169 544.0 107.0Q508 45 445.5 15.5Q383 -14 305 -14ZM310 103Q346 103 370.0 119.5Q394 136 406.0 170.0Q418 204 418 254Q418 307 405.0 343.5Q392 380 366.5 399.5Q341 419 301 419Q267 419 242.5 402.5Q218 386 206.0 352.0Q194 318 194 267Q194 185 224.5 144.0Q255 103 310 103Z';\nconst WORDMARK_L_PATH = 'M62 0V720H220V0Z';\nconst WORDMARK_S_PATH =\n 'M278 -14Q225 -14 182.0 -4.5Q139 5 107.0 23.0Q75 41 54.5 66.5Q34 92 26 123L146 176Q153 159 170.5 141.5Q188 124 217.5 113.0Q247 102 289 102Q329 102 351.5 113.5Q374 125 374 147Q374 163 361.5 172.5Q349 182 324.0 189.5Q299 197 262 204Q224 212 185.0 222.5Q146 233 112.0 251.5Q78 270 57.5 300.5Q37 331 37 378Q37 427 63.0 463.5Q89 500 140.5 521.0Q192 542 266 542Q332 542 382.0 525.0Q432 508 465.5 476.5Q499 445 512 401L383 355Q378 377 362.5 393.0Q347 409 323.5 417.5Q300 426 268 426Q229 426 207.5 414.0Q186 402 186 382Q186 366 200.5 355.5Q215 345 242.0 338.0Q269 331 306 323Q345 315 383.5 304.5Q422 294 453.5 276.5Q485 259 503.5 230.5Q522 202 522 157Q522 104 494.0 65.5Q466 27 411.5 6.5Q357 -14 278 -14Z';\nconst WORDMARK_E_PATH =\n 'M313 -14Q247 -14 195.0 3.5Q143 21 106.5 55.0Q70 89 51.0 139.0Q32 189 32 254Q32 317 50.5 370.0Q69 423 103.5 461.5Q138 500 188.5 521.0Q239 542 302 542Q366 542 414.5 521.5Q463 501 494.5 461.0Q526 421 541.0 363.5Q556 306 551 232L138 229V313L459 316L402 277Q409 327 396.0 358.5Q383 390 358.0 404.5Q333 419 304 419Q269 419 242.5 400.0Q216 381 201.0 345.0Q186 309 186 257Q186 175 221.5 138.0Q257 101 312 101Q339 101 357.0 108.5Q375 116 386.5 127.5Q398 139 404.5 153.0Q411 167 415 180L555 150Q547 113 529.5 83.0Q512 53 482.5 31.0Q453 9 411.5 -2.5Q370 -14 313 -14Z';\n\nconst VARIANT_VB: Record<\n PoolseLogoVariant,\n { vb: [number, number, number, number]; aspect: number }\n> = {\n lockup: { vb: [0, 0, 454, 100], aspect: 4.54 },\n mark: { vb: [0, 0, 100, 100], aspect: 1 },\n wordmark: { vb: [0, 0, 350, 100], aspect: 3.5 },\n mono: { vb: [0, 0, 454, 100], aspect: 4.54 },\n};\n\nexport function PoolseLogo({ variant = 'lockup', size = 28, color, label }: PoolseLogoProps) {\n const theme = usePoolseTheme();\n const mono = variant === 'mono';\n const monoColor = color ?? theme.colors.ink;\n\n const tileFill = mono ? 'none' : theme.colors.brand;\n const tileStroke = mono ? monoColor : 'transparent';\n const tileStrokeWidth = mono ? 5 : 0;\n const pulseStroke = mono ? monoColor : theme.colors.onBrand;\n const pulseDotFill = mono ? monoColor : theme.colors.onBrand;\n const inkFill = mono ? monoColor : theme.colors.ink;\n const oFill = mono ? monoColor : theme.colors.brand;\n\n const { vb, aspect } = VARIANT_VB[variant];\n const width = size * aspect;\n const showMark = variant === 'lockup' || variant === 'mark' || variant === 'mono';\n const showWordmark = variant === 'lockup' || variant === 'wordmark' || variant === 'mono';\n const wordmarkOffsetX = variant === 'wordmark' ? 0 : 126;\n\n const a11y = label === null ? {} : { accessibilityLabel: label ?? 'poolse' };\n return (\n <Svg viewBox={vb.join(' ')} width={width} height={size} {...a11y}>\n {showMark ? (\n <>\n <Path d={TILE_PATH} fill={tileFill} stroke={tileStroke} strokeWidth={tileStrokeWidth} />\n <Path\n d={PULSE_PATH}\n fill=\"none\"\n stroke={pulseStroke}\n strokeWidth={9}\n strokeLinecap=\"round\"\n strokeLinejoin=\"round\"\n />\n <Circle cx={72} cy={55} r={6.2} fill={pulseDotFill} />\n </>\n ) : null}\n {showWordmark ? (\n <G transform={`translate(${wordmarkOffsetX},85.0) scale(0.097222 -0.097222)`}>\n <Path d={WORDMARK_P_PATH} fill={inkFill} transform=\"translate(0,0)\" />\n <Path d={WORDMARK_O_PATH} fill={oFill} transform=\"translate(658,0)\" />\n <Path d={WORDMARK_O_PATH} fill={oFill} transform=\"translate(1280,0)\" />\n <Path d={WORDMARK_L_PATH} fill={inkFill} transform=\"translate(1902,0)\" />\n <Path d={WORDMARK_S_PATH} fill={inkFill} transform=\"translate(2195,0)\" />\n <Path d={WORDMARK_E_PATH} fill={inkFill} transform=\"translate(2754,0)\" />\n </G>\n ) : null}\n </Svg>\n );\n}\n","export { PoolseIcon, type PoolseIconProps, type IconName } from './PoolseIcon.js';\nexport { PoolseLogo, type PoolseLogoProps, type PoolseLogoVariant } from './PoolseLogo.js';\nexport { Avatar, type AvatarProps } from './Avatar.js';\nexport { userColor } from './userColor.js';\n\n// Re-exported as a namespace for the public API surface.\nimport { PoolseIcon } from './PoolseIcon.js';\nimport { PoolseLogo } from './PoolseLogo.js';\nimport { Avatar } from './Avatar.js';\n\nexport const primitives = { PoolseIcon, PoolseLogo, Avatar };\n","import { useEffect } from 'react';\nimport { AppState, type AppStateStatus } from 'react-native';\nimport { usePoolse } from '@poolse/react';\n\n/**\n * Closes the SDK WebSocket cleanly when the app backgrounds and\n * reopens it when the app comes back to the foreground. Designed\n * to pair with push-notification delivery on the dev's backend —\n * iOS / Android suspend sockets aggressively, so we don't fight\n * the OS; we let the push wake the app and resync on resume.\n *\n * Mount once near the root of your app:\n *\n * <PoolseProvider config={config}>\n * <AppShell />\n * </PoolseProvider>\n *\n * function AppShell() {\n * useAppStateLifecycle();\n * return ...;\n * }\n */\nexport function useAppStateLifecycle() {\n const poolse = usePoolse();\n\n useEffect(() => {\n let prev: AppStateStatus = AppState.currentState;\n const sub = AppState.addEventListener('change', (next) => {\n const wasActive = prev === 'active';\n const isActive = next === 'active';\n\n if (wasActive && !isActive) {\n // Going to background — close the WS cleanly. The SDK's\n // realtime layer reopens lazily on the next subscription\n // call, so there's nothing to clean up state-side.\n try {\n poolse.realtime?.disconnect?.();\n } catch {\n // Older SDK builds may not expose disconnect; harmless.\n }\n } else if (!wasActive && isActive) {\n // Returning to foreground — the next hook render that\n // touches `realtime.conversation(...)` will reopen the\n // socket. `useMessages`/`useTyping`/`usePresence` all\n // refetch their starting snapshot on remount, so the active\n // conversation lands fresh.\n try {\n poolse.realtime?.connect?.();\n } catch {\n // Same compat note as above.\n }\n }\n\n prev = next;\n });\n\n return () => sub.remove();\n }, [poolse]);\n}\n","/**\n * React Native WebRTC binding, backed by `react-native-webrtc`.\n *\n * The module is passed IN rather than required here, and that is\n * deliberate. Metro resolves dependencies statically, and this package\n * is published through tsup, which rewrites a literal `require(...)`\n * into a `__require(...)` call it cannot see — so bundling\n * `react-native-webrtc` from inside this file never worked. It wasn't\n * merely unavailable in Expo Go; it was absent from every bundle,\n * development builds included, and surfaced as\n * \"Requiring unknown module react-native-webrtc\" at runtime.\n *\n * Importing it in the app fixes that: Metro sees a static import in\n * your source and bundles it. Optionality then lives where it belongs —\n * an app that doesn't want voice simply never imports it, and never\n * installs the native dependency.\n *\n * import * as webrtc from 'react-native-webrtc';\n * <VoiceRoomBar conversationId={id} webrtc={webrtc} />\n *\n * Media streams on native aren't attached to an element the way they\n * are on the web — audio-only calls route to the device's audio session\n * once the peer connection is live, so the sink is a no-op. Video would\n * render the stream through `<RTCView>` via the `toURL()` it exposes.\n */\n\nimport type { VoiceIceServer, VoicePeerConnection, VoiceStream, WebRtcAdapter } from '@poolse/sdk';\n\n/**\n * The shape this binding needs from `react-native-webrtc`. The module's\n * own namespace satisfies it, so `import * as webrtc` type-checks\n * straight through.\n */\nexport interface NativeWebRtcModule {\n RTCPeerConnection: new (...args: never[]) => unknown;\n mediaDevices: { getUserMedia: (...args: never[]) => Promise<unknown> };\n}\n\n/**\n * The precise shape, used internally once the module has been checked.\n *\n * `NativeWebRtcModule` above is deliberately loose. Spelling the real\n * signatures out there does NOT work: `react-native-webrtc` types `sdp`\n * as `string` where the SDK's `VoiceDescription` has `string | undefined`,\n * so `import * as webrtc` fails to satisfy a strict interface and no\n * consumer can pass the module in at all.\n */\ninterface CheckedWebRtc {\n RTCPeerConnection: new (config: { iceServers: VoiceIceServer[] }) => VoicePeerConnection;\n mediaDevices: {\n getUserMedia(constraints: {\n audio: boolean | Record<string, unknown>;\n video: boolean;\n }): Promise<VoiceStream>;\n };\n}\n\n/**\n * True when `mod` looks like a usable `react-native-webrtc`.\n *\n * Guards against a half-linked native module: in a bare Expo Go client\n * the JS may load while the native side is missing, leaving\n * `RTCPeerConnection` undefined.\n */\nexport function isNativeWebRtcAvailable(mod: NativeWebRtcModule | null | undefined): boolean {\n return typeof mod?.RTCPeerConnection === 'function' && mod?.mediaDevices != null;\n}\n\n/**\n * Adapter for `useVoiceRoom`'s `webrtc` option.\n *\n * @param mod the `react-native-webrtc` module, imported by your app.\n * @throws when `mod` isn't a usable binding — check\n * {@link isNativeWebRtcAvailable} first if that's reachable in\n * your UI.\n */\nexport function createNativeWebRtcAdapter(mod: NativeWebRtcModule): WebRtcAdapter {\n if (!isNativeWebRtcAvailable(mod)) {\n throw new Error(\n 'react-native-webrtc is missing or not linked. Install it and rebuild:\\n' +\n ' npx expo install react-native-webrtc\\n' +\n 'It contains native code, so it needs a development build — it will not run in Expo Go.',\n );\n }\n\n // Narrow once, here, rather than making every caller's module match\n // signature-for-signature.\n const rtc = mod as unknown as CheckedWebRtc;\n\n return {\n createPeerConnection(iceServers: VoiceIceServer[]): VoicePeerConnection {\n return new rtc.RTCPeerConnection({ iceServers });\n },\n\n getUserMedia(): Promise<VoiceStream> {\n return rtc.mediaDevices.getUserMedia({\n audio: { echoCancellation: true, noiseSuppression: true },\n video: false,\n });\n },\n\n playRemoteStream(): () => void {\n // Audio-only: the native audio session plays the remote track as\n // soon as it connects, so there's no sink to create or clean up.\n return () => {};\n },\n };\n}\n","import { useVoiceRoom } from '@poolse/react';\nimport type { VoiceParticipant, VoiceStatus } from '@poolse/sdk';\nimport { useEffect, useMemo } from 'react';\nimport { Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { usePoolseTheme } from './theme/PoolseTheme.js';\nimport {\n createNativeWebRtcAdapter,\n isNativeWebRtcAvailable,\n type NativeWebRtcModule,\n} from './voice/webrtc-native.js';\n\nexport interface VoiceRoomBarProps {\n conversationId: string;\n /**\n * The `react-native-webrtc` module, imported by your app:\n *\n * import * as webrtc from 'react-native-webrtc';\n *\n * Required for audio. Metro only bundles what it can see statically,\n * so this package cannot import it for you — see `voice/webrtc-native`.\n * Omit it and the bar renders its unavailable state, which is what you\n * want in Expo Go.\n */\n webrtc?: NativeWebRtcModule | null;\n /**\n * Called whenever the room's connection state changes.\n *\n * Audio routing is the app's job — speakerphone, the proximity sensor\n * that blanks the screen at your ear, and holding the audio session\n * open all need a native module this package deliberately doesn't\n * depend on. Use this to start and stop it.\n */\n onStatusChange?: (status: VoiceStatus) => void;\n /** Resolves a user id to a display label. Defaults to a short id. */\n labelFor?: (userId: string) => string;\n /**\n * Rendered instead of the join button when `react-native-webrtc`\n * isn't installed. Defaults to an inline explanation.\n */\n unavailableSlot?: React.ReactNode;\n}\n\n/**\n * Discord-style voice bar: one \"Join Voice\" button that expands into a\n * roster of who's in, with a ring around whoever is talking.\n *\n * Drop it above a `<ConversationView>` to give a conversation an\n * always-on voice channel. For ringing a specific person, use\n * `<IncomingCallSheet>` together with `useCalls`.\n */\nexport function VoiceRoomBar({\n conversationId,\n labelFor,\n unavailableSlot,\n webrtc,\n onStatusChange,\n}: VoiceRoomBarProps) {\n const theme = usePoolseTheme();\n const available = isNativeWebRtcAvailable(webrtc);\n\n // Building the adapter throws when the module is missing or unlinked,\n // so only construct it on the path where we know it resolves.\n const opts = useMemo(\n () => (available && webrtc ? { webrtc: createNativeWebRtcAdapter(webrtc) } : {}),\n [available, webrtc],\n );\n\n const { status, participants, muted, join, leave, toggleMute, error } = useVoiceRoom(\n available ? conversationId : null,\n opts,\n );\n\n useEffect(() => {\n onStatusChange?.(status);\n }, [status, onStatusChange]);\n\n const label = labelFor ?? ((id: string) => `User ${id.slice(0, 6)}`);\n const connected = status === 'connected';\n\n if (!available) {\n return (\n <View\n style={[\n styles.bar,\n { backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.border },\n ]}\n >\n {unavailableSlot ?? (\n <Text style={[styles.hint, { color: theme.colors.ink3 }]}>\n Voice needs react-native-webrtc and a development build.\n </Text>\n )}\n </View>\n );\n }\n\n return (\n <View\n style={[\n styles.bar,\n { backgroundColor: theme.colors.surface, borderBottomColor: theme.colors.border },\n ]}\n >\n <View style={styles.row}>\n <View\n style={[\n styles.dot,\n { backgroundColor: connected ? theme.colors.brand : theme.colors.ink3 },\n ]}\n />\n\n {connected ? (\n <>\n <View style={styles.people}>\n {participants.length === 0 ? (\n <Text style={[styles.hint, { color: theme.colors.ink3 }]}>Waiting for others…</Text>\n ) : (\n participants.map((p) => (\n <ParticipantChip key={p.userId} participant={p} label={label(p.userId)} />\n ))\n )}\n </View>\n\n <Pressable\n onPress={toggleMute}\n accessibilityRole=\"button\"\n accessibilityState={{ selected: muted }}\n style={[\n styles.btn,\n {\n borderColor: muted ? theme.colors.brand : theme.colors.border,\n backgroundColor: muted ? theme.colors.brandSoft : theme.colors.paper,\n },\n ]}\n >\n <Text style={{ color: theme.colors.ink2 }}>{muted ? 'Unmute' : 'Mute'}</Text>\n </Pressable>\n\n <Pressable\n onPress={leave}\n accessibilityRole=\"button\"\n style={[styles.btn, { borderColor: theme.colors.error }]}\n >\n <Text style={{ color: theme.colors.error }}>Leave</Text>\n </Pressable>\n </>\n ) : (\n <>\n <Text style={[styles.hint, { color: theme.colors.ink3 }]}>\n {status === 'connecting' ? 'Connecting…' : 'Talk to everyone here'}\n </Text>\n <Pressable\n onPress={() => void join()}\n disabled={status === 'connecting'}\n accessibilityRole=\"button\"\n style={[styles.btn, styles.btnPrimary, { backgroundColor: theme.colors.brand }]}\n >\n <Text style={{ color: theme.colors.onBrand, fontWeight: '600' }}>\n {status === 'connecting' ? 'Joining…' : 'Join Voice'}\n </Text>\n </Pressable>\n </>\n )}\n </View>\n\n {error && <Text style={[styles.error, { color: theme.colors.error }]}>{error.message}</Text>}\n </View>\n );\n}\n\nfunction ParticipantChip({ participant, label }: { participant: VoiceParticipant; label: string }) {\n const theme = usePoolseTheme();\n return (\n <View\n style={[\n styles.chip,\n {\n backgroundColor: theme.colors.paper,\n // The speaking ring is a border colour swap rather than an\n // extra element, so the row never reflows mid-sentence.\n borderColor: participant.speaking ? theme.colors.brand : theme.colors.border,\n opacity: participant.muted ? 0.62 : 1,\n },\n ]}\n >\n <Text style={{ color: theme.colors.ink2, fontSize: 13 }} numberOfLines={1}>\n {label}\n {participant.isSelf ? ' (you)' : ''}\n </Text>\n {participant.muted && (\n <Text style={{ color: theme.colors.error, fontSize: 11, fontWeight: '700' }}>✕</Text>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n bar: { paddingHorizontal: 14, paddingVertical: 8, borderBottomWidth: StyleSheet.hairlineWidth },\n row: { flexDirection: 'row', alignItems: 'center', gap: 8, flexWrap: 'wrap' },\n dot: { width: 8, height: 8, borderRadius: 4 },\n people: { flexDirection: 'row', alignItems: 'center', gap: 6, flexShrink: 1, flexWrap: 'wrap' },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n paddingHorizontal: 10,\n paddingVertical: 4,\n borderRadius: 999,\n borderWidth: 1,\n },\n btn: { paddingHorizontal: 12, paddingVertical: 6, borderRadius: 999, borderWidth: 1 },\n btnPrimary: { borderWidth: 0 },\n hint: { fontSize: 13, flexShrink: 1 },\n error: { fontSize: 12, marginTop: 6 },\n});\n","/**\n * The call surface's own palette.\n *\n * Deliberately NOT the app theme. Every serious calling app — phone,\n * FaceTime, WhatsApp, Meet — renders calls dark regardless of the rest\n * of the UI, for three reasons that all apply here:\n *\n * * video is the content, and a light chrome around it washes the\n * picture out,\n * * a call screen is the one surface that routinely opens at 3am,\n * * it takes over the whole screen, so it reads as a mode change\n * rather than as a screen that has lost the app's styling.\n *\n * The brand still shows up — in the accept button and the speaking\n * ring — it just doesn't set the background.\n */\nexport const callColors = {\n /** Behind everything. Near-black, warmed very slightly to match the brand. */\n bg: '#101012',\n /** Behind a participant tile with no video. */\n tile: '#1c1c20',\n /** Scrim under the top/bottom chrome so text stays legible over video. */\n scrim: 'rgba(0,0,0,0.45)',\n\n text: '#ffffff',\n textDim: 'rgba(255,255,255,0.72)',\n textFaint: 'rgba(255,255,255,0.5)',\n\n /** A control that is off / inactive — translucent over whatever is behind. */\n control: 'rgba(255,255,255,0.16)',\n /**\n * A control that is ENGAGED (muted, speaker on, camera off).\n *\n * Inverted rather than tinted: at a glance the user needs to see\n * *which* controls are doing something, and a solid white circle is\n * unmistakable against five translucent ones in a dim room.\n */\n controlActive: '#ffffff',\n controlActiveIcon: '#101012',\n\n danger: '#ef4444',\n accept: '#22c55e',\n onAction: '#ffffff',\n} as const;\n\n/** Control button diameters. Hang-up is bigger; it is the one you reach for. */\nexport const CONTROL_SIZE = 58;\nexport const CONTROL_SIZE_LARGE = 68;\n","import { Modal, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon, type IconName } from '../primitives/PoolseIcon.js';\nimport { callColors } from './callTheme.js';\nimport type { AudioRoute, AudioRouteKind } from './livekit-rn.js';\n\nexport interface AudioRouteSheetProps {\n visible: boolean;\n routes: AudioRoute[];\n /** Platform id of the chosen route, or null while routing is automatic. */\n selectedRouteId: string | null;\n onSelect: (id: string) => void;\n onClose: () => void;\n}\n\nconst ICONS: Record<AudioRouteKind, IconName> = {\n speaker: 'speaker',\n earpiece: 'phone',\n headset: 'headphones',\n bluetooth: 'bluetooth',\n auto: 'phone',\n};\n\n/**\n * Pick where call audio comes out.\n *\n * Only worth showing when there is a real choice — on iOS there are\n * exactly two entries and the system's own picker covers everything\n * else, so `CallScreen` opens that instead. This is the Android\n * surface, where LiveKit enumerates the actual devices.\n */\nexport function AudioRouteSheet({\n visible,\n routes,\n selectedRouteId,\n onSelect,\n onClose,\n}: AudioRouteSheetProps) {\n return (\n <Modal visible={visible} transparent animationType=\"fade\" onRequestClose={onClose}>\n {/* Tapping away closes it, which is what a sheet like this owes\n anyone who opened it by accident mid-call. */}\n <Pressable style={styles.backdrop} onPress={onClose} accessibilityRole=\"button\">\n <Pressable style={styles.sheet} onPress={() => {}}>\n <View style={styles.grabber} />\n <Text style={styles.title}>Audio output</Text>\n\n {routes.map((route) => {\n const selected = route.id === selectedRouteId;\n return (\n <Pressable\n key={route.id}\n onPress={() => {\n onSelect(route.id);\n onClose();\n }}\n accessibilityRole=\"button\"\n accessibilityState={{ selected }}\n style={({ pressed }) => [styles.row, pressed && styles.rowPressed]}\n >\n <PoolseIcon\n name={ICONS[route.kind]}\n size={21}\n color={selected ? callColors.accept : callColors.text}\n label={null}\n />\n <Text style={[styles.label, selected && styles.labelSelected]}>{route.label}</Text>\n {selected && (\n <PoolseIcon name=\"check\" size={19} color={callColors.accept} label=\"selected\" />\n )}\n </Pressable>\n );\n })}\n </Pressable>\n </Pressable>\n </Modal>\n );\n}\n\nconst styles = StyleSheet.create({\n backdrop: { flex: 1, backgroundColor: 'rgba(0,0,0,0.55)', justifyContent: 'flex-end' },\n sheet: {\n backgroundColor: callColors.tile,\n borderTopLeftRadius: 22,\n borderTopRightRadius: 22,\n paddingHorizontal: 12,\n paddingTop: 10,\n paddingBottom: 34,\n gap: 2,\n },\n grabber: {\n alignSelf: 'center',\n width: 38,\n height: 4,\n borderRadius: 2,\n backgroundColor: callColors.textFaint,\n marginBottom: 12,\n },\n title: {\n color: callColors.textDim,\n fontSize: 12.5,\n fontWeight: '600',\n textTransform: 'uppercase',\n letterSpacing: 0.6,\n paddingHorizontal: 12,\n paddingBottom: 8,\n },\n row: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 14,\n paddingHorizontal: 12,\n paddingVertical: 15,\n borderRadius: 14,\n },\n rowPressed: { backgroundColor: 'rgba(255,255,255,0.08)' },\n label: { flex: 1, color: callColors.text, fontSize: 16, fontWeight: '500' },\n labelSelected: { color: callColors.accept },\n});\n","import { StyleSheet, Text, View } from 'react-native';\n\nimport { userColor } from '../primitives/userColor.js';\nimport { callColors } from './callTheme.js';\n\nexport interface CallAvatarProps {\n /** Display name; the first letters become the initials. */\n name: string;\n /** Stable colour seed — the poolse user id. */\n seed: string;\n size: number;\n /** Draw the active-speaker ring. */\n speaking?: boolean;\n}\n\n/**\n * The stand-in for a face when a camera is off.\n *\n * Separate from `<Avatar>` rather than a size variant of it: this one\n * scales to a third of the screen, carries the speaking ring, and lives\n * on a dark surface, none of which the list avatar wants.\n *\n * The ring sits OUTSIDE the circle, drawn as a border on a larger box.\n * Growing the avatar itself to show speaking would make everything jump\n * every time somebody starts talking.\n */\nexport function CallAvatar({ name, seed, size, speaking = false }: CallAvatarProps) {\n const ring = Math.max(2, Math.round(size * 0.045));\n const outer = size + ring * 4;\n\n return (\n <View\n style={[\n styles.ring,\n {\n width: outer,\n height: outer,\n borderRadius: outer / 2,\n borderWidth: ring,\n borderColor: speaking ? callColors.accept : 'transparent',\n },\n ]}\n >\n <View\n style={[\n styles.circle,\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor: userColor(seed),\n },\n ]}\n >\n <Text\n style={[styles.initials, { fontSize: Math.round(size * 0.38) }]}\n numberOfLines={1}\n allowFontScaling={false}\n >\n {initialsOf(name)}\n </Text>\n </View>\n </View>\n );\n}\n\n/** Up to two initials, matching how the rest of the SDK derives them. */\nfunction initialsOf(name: string): string {\n const parts = name.trim().split(/\\s+/).filter(Boolean);\n if (parts.length === 0) return '?';\n if (parts.length === 1) return parts[0]!.slice(0, 2).toUpperCase();\n return (parts[0]![0]! + parts[parts.length - 1]![0]!).toUpperCase();\n}\n\nconst styles = StyleSheet.create({\n ring: { alignItems: 'center', justifyContent: 'center' },\n circle: { alignItems: 'center', justifyContent: 'center' },\n initials: { color: '#ffffff', fontWeight: '600' },\n});\n","import { Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { PoolseIcon, type IconName } from '../primitives/PoolseIcon.js';\nimport { CONTROL_SIZE, CONTROL_SIZE_LARGE, callColors } from './callTheme.js';\n\nexport interface CallControlButtonProps {\n icon: IconName;\n /** Shown under the button. Omit for the hang-up / answer buttons. */\n label?: string | undefined;\n /**\n * The control is doing something — muted, speaker forced on, camera\n * off. Inverts the button so engaged controls are readable at a\n * glance.\n */\n active?: boolean;\n /** Paints the button a solid colour: the hang-up and answer actions. */\n tone?: 'neutral' | 'danger' | 'accept';\n large?: boolean;\n disabled?: boolean;\n onPress: () => void;\n /**\n * Spoken description. Defaults to `label`, but a toggle needs to say\n * what pressing it will DO, which is rarely what the label says —\n * \"Mute\" under a button that unmutes is exactly backwards for anyone\n * using a screen reader.\n */\n accessibilityLabel?: string | undefined;\n}\n\n/**\n * One round call control.\n *\n * Fixed diameter and a caption underneath, so a row of them lines up on\n * a grid regardless of label length — the thing that makes a control\n * bar look built rather than assembled.\n */\nexport function CallControlButton({\n icon,\n label,\n active = false,\n tone = 'neutral',\n large = false,\n disabled = false,\n onPress,\n accessibilityLabel,\n}: CallControlButtonProps) {\n const size = large ? CONTROL_SIZE_LARGE : CONTROL_SIZE;\n\n const background =\n tone === 'danger'\n ? callColors.danger\n : tone === 'accept'\n ? callColors.accept\n : active\n ? callColors.controlActive\n : callColors.control;\n\n const iconColor =\n tone === 'neutral' && active ? callColors.controlActiveIcon : callColors.onAction;\n\n return (\n <View style={styles.slot}>\n <Pressable\n onPress={onPress}\n disabled={disabled}\n accessibilityRole=\"button\"\n accessibilityState={{ disabled, selected: active }}\n accessibilityLabel={accessibilityLabel ?? label ?? icon}\n hitSlop={8}\n style={({ pressed }) => [\n styles.button,\n {\n width: size,\n height: size,\n borderRadius: size / 2,\n backgroundColor: background,\n // Feedback without a layout shift — scaling a round button\n // inside a fixed slot keeps the row from twitching.\n opacity: disabled ? 0.4 : pressed ? 0.75 : 1,\n },\n ]}\n >\n <PoolseIcon name={icon} size={large ? 30 : 25} color={iconColor} label={null} />\n </Pressable>\n {label ? (\n <Text numberOfLines={1} style={styles.label}>\n {label}\n </Text>\n ) : null}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n // Fixed width so captions of different lengths cannot shift the row.\n slot: { width: 76, alignItems: 'center', gap: 7 },\n button: { alignItems: 'center', justifyContent: 'center' },\n label: { color: callColors.textDim, fontSize: 11.5, fontWeight: '500' },\n});\n","import type { CallParticipant } from '@poolse/sdk';\nimport { StyleSheet, Text, View, type ViewStyle } from 'react-native';\n\nimport { PoolseIcon } from '../primitives/PoolseIcon.js';\nimport { CallAvatar } from './CallAvatar.js';\nimport { callColors } from './callTheme.js';\nimport type { CheckedVideoTrack } from './livekit-rn.js';\n\nexport interface CallParticipantTileProps {\n participant: CallParticipant;\n /** Narrowed `@livekit/react-native` VideoTrack, when the app supplied it. */\n VideoTrack?: CheckedVideoTrack | undefined;\n label: (userId: string) => string;\n style?: ViewStyle | ViewStyle[];\n /** Avatar diameter when the camera is off. */\n avatarSize?: number;\n /** Full-bleed tiles drop their rounding and their name chip shrinks. */\n bleed?: boolean;\n /** Hide the name chip — the spotlight draws identity in the header. */\n hideName?: boolean;\n}\n\n/**\n * One person on the call: their video, or their avatar when the camera\n * is off.\n *\n * A camera-off participant still gets a tile. Dropping them would make\n * a five-person call with four cameras off look like a one-person call,\n * and hide the fact that they are there and can hear you.\n */\nexport function CallParticipantTile({\n participant,\n VideoTrack,\n label,\n style,\n avatarSize = 72,\n bleed = false,\n hideName = false,\n}: CallParticipantTileProps) {\n const name = participant.isSelf ? 'You' : (participant.name ?? label(participant.userId));\n const hasVideo = Boolean(participant.videoTrackRef && VideoTrack);\n\n return (\n <View\n style={[\n styles.tile,\n bleed ? styles.bleed : styles.rounded,\n {\n backgroundColor: callColors.tile,\n // A ring rather than a badge: it reads at a glance across a\n // grid, and it doesn't cover anyone's face.\n borderColor: participant.speaking ? callColors.accept : 'transparent',\n },\n style as ViewStyle,\n ]}\n >\n {hasVideo && VideoTrack ? (\n <VideoTrack\n trackRef={participant.videoTrackRef}\n style={StyleSheet.absoluteFillObject as ViewStyle}\n objectFit=\"cover\"\n // Only your own preview is mirrored. Mirroring a remote feed\n // would flip their text and reverse which hand they wave with.\n mirror={participant.isSelf}\n zOrder={participant.isSelf ? 1 : 0}\n />\n ) : (\n <View style={styles.placeholder}>\n <CallAvatar\n name={name}\n seed={participant.userId}\n size={avatarSize}\n speaking={participant.speaking}\n />\n </View>\n )}\n\n {!hideName && (\n <View style={[styles.chip, bleed ? styles.chipBleed : styles.chipTile]}>\n {!participant.micEnabled && (\n // Worth showing even for yourself — it is the answer to\n // \"why can nobody hear me\".\n <PoolseIcon name=\"mic-off\" size={13} color={callColors.text} label=\"muted\" />\n )}\n <Text numberOfLines={1} style={styles.name}>\n {name}\n </Text>\n </View>\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n tile: { overflow: 'hidden', justifyContent: 'flex-end', borderWidth: 2 },\n rounded: { borderRadius: 18 },\n bleed: { borderRadius: 0, borderWidth: 0 },\n placeholder: { ...StyleSheet.absoluteFillObject, alignItems: 'center', justifyContent: 'center' },\n chip: {\n flexDirection: 'row',\n alignItems: 'center',\n gap: 5,\n alignSelf: 'flex-start',\n borderRadius: 999,\n // Legible over both a bright video frame and a flat placeholder.\n backgroundColor: 'rgba(0,0,0,0.55)',\n },\n chipTile: { margin: 8, paddingHorizontal: 9, paddingVertical: 4.5, maxWidth: '92%' },\n chipBleed: { margin: 14, paddingHorizontal: 11, paddingVertical: 6, maxWidth: '80%' },\n name: { color: callColors.text, fontSize: 12.5, fontWeight: '600', flexShrink: 1 },\n});\n","import type { CallParticipant } from '@poolse/sdk';\nimport { useEffect, useMemo, useRef, useState } from 'react';\nimport { Animated, PanResponder, Pressable, StyleSheet, View, type ViewStyle } from 'react-native';\n\nimport { CallParticipantTile } from './CallParticipantTile.js';\nimport type { CheckedVideoTrack } from './livekit-rn.js';\n\nexport interface LocalVideoPipProps {\n participant: CallParticipant;\n VideoTrack?: CheckedVideoTrack | undefined;\n label: (userId: string) => string;\n /** Area the tile may be dragged within, in pixels. */\n bounds: { width: number; height: number };\n /**\n * Safe-area insets. The tile hugs the edges just inside these, so it\n * clears the notch and the home indicator and nothing else.\n */\n insets?: { top: number; bottom: number };\n /** Tap handler. Wired to the camera flip, matching every other call app. */\n onPress?: (() => void) | undefined;\n}\n\nconst PIP_WIDTH = 108;\nconst PIP_HEIGHT = 152;\nconst MARGIN = 12;\n\n/**\n * The local camera preview, floating over the remote video.\n *\n * Draggable, and it snaps to the nearest corner on release rather than\n * staying wherever the finger stopped. Free positioning sounds more\n * flexible but reads as broken: a tile left at a slight angle to the\n * edge looks dropped rather than placed, and it is the corners people\n * actually want — they move it to uncover a face.\n *\n * Built on `Animated` + `PanResponder` from React Native itself. A\n * gesture library would be smoother, but it would be a new native\n * dependency for every app that installs this SDK, and a call preview\n * is not worth that.\n */\nexport function LocalVideoPip({\n participant,\n VideoTrack,\n label,\n bounds,\n insets,\n onPress,\n}: LocalVideoPipProps) {\n const top = insets?.top ?? 0;\n const bottom = insets?.bottom ?? 0;\n\n // Corner anchors, recomputed when the screen or the chrome changes\n // (rotation, a control bar appearing).\n const corners = useMemo(() => {\n const right = Math.max(MARGIN, bounds.width - PIP_WIDTH - MARGIN);\n const low = Math.max(MARGIN, bounds.height - PIP_HEIGHT - bottom - MARGIN);\n const high = top + MARGIN;\n return [\n { x: MARGIN, y: high },\n { x: right, y: high },\n { x: MARGIN, y: low },\n { x: right, y: low },\n ];\n }, [bounds.width, bounds.height, top, bottom]);\n\n // Top-right to start: it is the corner least likely to cover a face,\n // which sits centre-frame, and it stays clear of the control bar.\n const [corner, setCorner] = useState(1);\n const pan = useRef(new Animated.ValueXY(corners[1]!)).current;\n\n // Read inside the responder without re-creating it — rebuilding the\n // PanResponder mid-gesture drops the drag.\n const cornersRef = useRef(corners);\n cornersRef.current = corners;\n const cornerRef = useRef(corner);\n cornerRef.current = corner;\n const dragged = useRef(false);\n\n // Follow the corners when the stage itself changes — a rotation, or\n // the control bar appearing. Without this the tile keeps the pixel\n // position it had under the old bounds, which after a rotation can be\n // most of the way off screen.\n useEffect(() => {\n if (dragged.current) return;\n const at = corners[corner];\n if (at) pan.setValue(at);\n }, [corners, corner, pan]);\n\n const responder = useMemo(\n () =>\n PanResponder.create({\n // Claim the gesture only once it is clearly a drag. A lower\n // threshold would swallow the taps that flip the camera.\n onMoveShouldSetPanResponder: (_evt, g) => Math.abs(g.dx) > 4 || Math.abs(g.dy) > 4,\n onPanResponderGrant: () => {\n dragged.current = true;\n const at = cornersRef.current[cornerRef.current] ?? cornersRef.current[1]!;\n pan.setOffset({ x: at.x, y: at.y });\n pan.setValue({ x: 0, y: 0 });\n },\n onPanResponderMove: Animated.event([null, { dx: pan.x, dy: pan.y }], {\n useNativeDriver: false,\n }),\n onPanResponderRelease: (_evt, g) => {\n pan.flattenOffset();\n const at = cornersRef.current[cornerRef.current] ?? cornersRef.current[1]!;\n const dropped = { x: at.x + g.dx, y: at.y + g.dy };\n\n // Nearest corner by centre-to-centre distance.\n let best = 0;\n let bestDistance = Number.POSITIVE_INFINITY;\n cornersRef.current.forEach((c, index) => {\n const distance = (c.x - dropped.x) ** 2 + (c.y - dropped.y) ** 2;\n if (distance < bestDistance) {\n bestDistance = distance;\n best = index;\n }\n });\n\n setCorner(best);\n Animated.spring(pan, {\n toValue: cornersRef.current[best]!,\n useNativeDriver: false,\n friction: 8,\n tension: 70,\n }).start(() => {\n dragged.current = false;\n });\n },\n }),\n [pan],\n );\n\n return (\n <Animated.View\n {...responder.panHandlers}\n style={[styles.pip, { transform: pan.getTranslateTransform() }]}\n >\n <Pressable\n // Swallowed if the finger moved: releasing a drag over the tile\n // must not also flip the camera.\n onPress={() => {\n if (dragged.current) return;\n onPress?.();\n }}\n accessibilityRole=\"button\"\n accessibilityLabel=\"Your camera. Drag to move, tap to switch camera.\"\n style={styles.fill}\n >\n <View style={styles.fill}>\n <CallParticipantTile\n participant={participant}\n VideoTrack={VideoTrack}\n label={label}\n avatarSize={48}\n hideName\n // Borderless, and square-cornered, because the rounding and\n // the clipping both belong to the bubble around it. A tile\n // that rounds itself as well leaves a hairline seam where\n // the two radii disagree, and its 2px border — transparent\n // or not — insets the video from the edge it should meet.\n bleed\n style={styles.fill as ViewStyle}\n />\n </View>\n </Pressable>\n </Animated.View>\n );\n}\n\nconst styles = StyleSheet.create({\n pip: {\n position: 'absolute',\n top: 0,\n left: 0,\n width: PIP_WIDTH,\n height: PIP_HEIGHT,\n // Generous enough to read as a bubble rather than a cropped\n // rectangle. The video is clipped to it, so this is the only\n // rounding in play.\n borderRadius: 22,\n overflow: 'hidden',\n // Lifted off the video so it reads as floating rather than inset.\n shadowColor: '#000',\n shadowOpacity: 0.4,\n shadowRadius: 12,\n shadowOffset: { width: 0, height: 4 },\n elevation: 8,\n },\n fill: { flex: 1 },\n});\n","import type { CallParticipant } from '@poolse/sdk';\nimport { useMemo, useState } from 'react';\nimport { ScrollView, StyleSheet, View, type LayoutChangeEvent, type ViewStyle } from 'react-native';\n\nimport { CallParticipantTile } from './CallParticipantTile.js';\nimport { LocalVideoPip } from './LocalVideoPip.js';\nimport type { CheckedVideoTrack, LiveKitReactNativeModule } from './livekit-rn.js';\n\nexport type { LiveKitReactNativeModule };\n\nexport interface CallVideoGridProps {\n participants: CallParticipant[];\n /** `@livekit/react-native`, imported by your app. */\n livekitReactNative?: LiveKitReactNativeModule | null | undefined;\n /** Resolves a user id to a display label. */\n labelFor?: ((userId: string) => string) | undefined;\n /**\n * Tapping the local preview. Wired to the camera flip by\n * `CallScreen`, which is where every other call app puts it.\n */\n onLocalPress?: (() => void) | undefined;\n /**\n * How much chrome sits over the bottom of the stage.\n *\n * Only used to keep the last row of a scrolling group grid clear of\n * the control bar. It deliberately does NOT bound the floating\n * preview — see {@link safeArea}.\n */\n chromeInsets?: { top: number; bottom: number } | undefined;\n /**\n * The screen's safe area, which is what the floating preview is\n * bounded by.\n *\n * Separate from `chromeInsets` on purpose. Bounding the preview by the\n * chrome kept it in a box well inside the screen, floating in the\n * middle of nowhere rather than tucked into a corner — and on a\n * connected video call the chrome is hidden most of the time anyway,\n * so it was reserving space for something that was not there.\n */\n safeArea?: { top: number; bottom: number } | undefined;\n}\n\nconst GAP = 8;\n/** Below this a tile shows a head as a postage stamp, so the grid scrolls instead. */\nconst MIN_TILE_HEIGHT = 132;\n\n/**\n * The stage: everyone on the call, laid out for how many there are.\n *\n * Three layouts, because one grid cannot serve all of them:\n *\n * * **Alone** — you, filling the screen, while the far side connects.\n * * **One other person** — them full-bleed, you in a draggable\n * corner tile. A 1:1 call split into two half-height boxes wastes\n * most of the screen on letterboxing, which is why no calling app\n * does it.\n * * **Three or more** — a real grid, two columns up to six people and\n * three beyond that, scrolling once the tiles would be too small to\n * make out a face.\n *\n * Audio calls land here too. Everyone simply has their camera off, so\n * every tile draws an avatar, and the layout logic does not need to\n * know whether video was ever on the table.\n */\nexport function CallVideoGrid({\n participants,\n livekitReactNative,\n labelFor,\n onLocalPress,\n chromeInsets,\n safeArea,\n}: CallVideoGridProps) {\n const label = labelFor ?? ((id: string) => `User ${id.slice(0, 6)}`);\n const VideoTrack = livekitReactNative?.VideoTrack as CheckedVideoTrack | undefined;\n const [size, setSize] = useState({ width: 0, height: 0 });\n\n const onLayout = (event: LayoutChangeEvent) => {\n const { width, height } = event.nativeEvent.layout;\n setSize((current) =>\n current.width === width && current.height === height ? current : { width, height },\n );\n };\n\n const self = participants.find((p) => p.isSelf) ?? null;\n const others = useMemo(() => participants.filter((p) => !p.isSelf), [participants]);\n\n const columns = others.length + 1 <= 6 ? 2 : 3;\n const rows = Math.ceil((others.length + 1) / columns);\n const tileHeight = size.height > 0 ? (size.height - GAP * (rows - 1)) / rows : 0;\n const scrolls = tileHeight > 0 && tileHeight < MIN_TILE_HEIGHT;\n\n if (participants.length === 0) return <View style={styles.stage} onLayout={onLayout} />;\n\n // ── alone, or one other person: spotlight + floating preview ────────\n if (others.length <= 1) {\n const spotlight = others[0] ?? self;\n if (!spotlight) return <View style={styles.stage} onLayout={onLayout} />;\n\n return (\n <View style={styles.stage} onLayout={onLayout}>\n <CallParticipantTile\n participant={spotlight}\n VideoTrack={VideoTrack}\n label={label}\n avatarSize={Math.min(148, Math.max(96, Math.round(size.width * 0.36)))}\n bleed\n // Their name is already in the header; repeating it over the\n // video is noise on a two-person call.\n hideName={others.length === 1}\n style={styles.fill as ViewStyle}\n />\n\n {/* Only once somebody else is here. Your own preview floating\n over your own preview is just a mirror in a mirror. */}\n {self && others.length === 1 && size.width > 0 && (\n <LocalVideoPip\n participant={self}\n VideoTrack={VideoTrack}\n label={label}\n bounds={size}\n insets={safeArea ?? { top: 0, bottom: 0 }}\n onPress={onLocalPress}\n />\n )}\n </View>\n );\n }\n\n // ── three or more: a grid ───────────────────────────────────────────\n // Remote faces lead and you sit last, which is both what people look\n // for first and a stable order — promoting the active speaker would\n // reshuffle the grid every time somebody spoke.\n const tiles = [...others, ...(self ? [self] : [])];\n const width = size.width > 0 ? (size.width - GAP * (columns - 1)) / columns : 0;\n\n const grid = (\n <View style={[styles.grid, scrolls ? styles.gridScrolling : styles.gridFilling]}>\n {tiles.map((participant) => (\n <CallParticipantTile\n key={participant.userId}\n participant={participant}\n VideoTrack={VideoTrack}\n label={label}\n avatarSize={columns === 2 ? 66 : 46}\n style={\n {\n width: width || undefined,\n height: scrolls ? MIN_TILE_HEIGHT : tileHeight || undefined,\n } as ViewStyle\n }\n />\n ))}\n </View>\n );\n\n return (\n <View style={styles.stage} onLayout={onLayout}>\n {scrolls ? (\n <ScrollView\n // Padding rather than `contentInset`, which is iOS-only. The\n // control bar floats over the bottom of the stage, so the last\n // row needs room to clear it on both platforms.\n contentContainerStyle={[\n styles.scroll,\n { paddingBottom: (chromeInsets?.bottom ?? 0) + GAP },\n ]}\n showsVerticalScrollIndicator={false}\n >\n {grid}\n </ScrollView>\n ) : (\n grid\n )}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n stage: { flex: 1, overflow: 'hidden' },\n fill: { ...StyleSheet.absoluteFillObject },\n grid: { flexDirection: 'row', flexWrap: 'wrap', gap: GAP },\n gridFilling: { flex: 1, alignContent: 'center' },\n gridScrolling: { alignContent: 'flex-start' },\n scroll: { paddingVertical: GAP },\n});\n","/**\n * The slice of `@livekit/react-native` this package uses.\n *\n * Passed in by the app rather than imported, for the same reason\n * `react-native-webrtc` is: tsup rewrites `require()` into\n * `__require()`, which Metro cannot follow, so anything this package\n * imports for itself never reaches a React Native bundle.\n *\n * import * as livekitRN from '@livekit/react-native';\n * <CallScreen livekitReactNative={livekitRN} … />\n *\n * Everything past `VideoTrack` is optional so an older version of the\n * module still type-checks — the features degrade rather than failing\n * to compile.\n */\n\nimport type { ComponentType } from 'react';\nimport type { ViewStyle } from 'react-native';\n\n/**\n * The slice of `VideoTrack` actually rendered.\n *\n * `LiveKitReactNativeModule.VideoTrack` is `unknown` because React props\n * are contravariant — declaring the narrow shape there means the real\n * component is not assignable to it and no app can pass the module in.\n * Narrowing happens at the point of use, through this.\n */\nexport type CheckedVideoTrack = ComponentType<{\n trackRef: unknown;\n style?: ViewStyle;\n objectFit?: 'cover' | 'contain';\n mirror?: boolean;\n zOrder?: number;\n}>;\n\n/** What an audio route is, once its platform id has been read. */\nexport type AudioRouteKind = 'speaker' | 'earpiece' | 'headset' | 'bluetooth' | 'auto';\n\nexport interface AudioRoute {\n /** Platform id, passed back to `selectAudioOutput`. */\n id: string;\n kind: AudioRouteKind;\n /** Human label for a picker row. */\n label: string;\n}\n\n/**\n * LiveKit's audio session.\n *\n * The two platforms expose genuinely different things and the shape\n * reflects that rather than papering over it:\n *\n * * **Android** enumerates real devices — `speaker`, `earpiece`,\n * `headset`, `bluetooth` — and `selectAudioOutput` picks one.\n * * **iOS** offers only `default` and `force_speaker`, because AVAudio\n * does not let an app pick a route directly. Anything else (AirPods,\n * a wired headset, AirPlay) goes through the system's own picker,\n * which is what `showAudioRoutePicker` opens.\n */\nexport interface LiveKitAudioSession {\n configureAudio(config: {\n android?: {\n preferredOutputList?: ('speaker' | 'earpiece' | 'headset' | 'bluetooth')[];\n audioTypeOptions?: unknown;\n };\n ios?: { defaultOutput?: 'speaker' | 'earpiece' };\n }): Promise<void>;\n startAudioSession(): Promise<void>;\n stopAudioSession(): Promise<void>;\n getAudioOutputs(): Promise<string[]>;\n selectAudioOutput(deviceId: string): Promise<void>;\n /** iOS 11+. Opens the system route picker (AirPods, AirPlay, …). */\n showAudioRoutePicker?(): Promise<void>;\n}\n\n/** Fires when a headset or Bluetooth device appears or disappears. */\nexport interface AudioDeviceModuleEvents {\n addDevicesUpdatedListener(listener: () => void): void;\n removeDevicesUpdatedListener(listener: () => void): void;\n}\n\nexport interface LiveKitReactNativeModule {\n /**\n * The module's `VideoTrack` component.\n *\n * Typed as `unknown` on purpose. Its real props are far more specific\n * than what this renders with, and React component props are\n * contravariant — declaring the narrow shape here means the real\n * component is not assignable to it and no app can pass the module in.\n * It is narrowed at the point of use.\n */\n VideoTrack: unknown;\n AudioSession?: LiveKitAudioSession | undefined;\n /**\n * Installs LiveKit's iOS audio policy and returns a disposer.\n *\n * Must not be re-run mid-call: it abandons the session activation the\n * previous handlers were holding, which kills audio outright. The\n * speaker preference is therefore captured once, when the call\n * starts, and later changes go through `selectAudioOutput` instead.\n */\n setupIOSAudioManagement?: ((preferSpeakerOutput?: boolean) => () => void) | undefined;\n audioDeviceModuleEvents?: AudioDeviceModuleEvents | undefined;\n}\n\n/** Turn a platform output id into something renderable. */\nexport function describeRoute(id: string): AudioRoute {\n switch (id) {\n case 'speaker':\n case 'force_speaker':\n return { id, kind: 'speaker', label: 'Speaker' };\n case 'earpiece':\n return { id, kind: 'earpiece', label: 'Phone' };\n case 'headset':\n return { id, kind: 'headset', label: 'Headphones' };\n case 'bluetooth':\n return { id, kind: 'bluetooth', label: 'Bluetooth' };\n case 'default':\n // iOS's \"whatever the OS thinks is right\" — the earpiece normally,\n // a headset or AirPods the moment one is connected. Labelled for\n // the common case rather than the mechanism.\n return { id, kind: 'auto', label: 'iPhone' };\n default:\n return { id, kind: 'auto', label: id };\n }\n}\n","import { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport { describeRoute, type AudioRoute, type LiveKitReactNativeModule } from './livekit-rn.js';\n\nexport interface UseCallAudioOptions {\n /**\n * True as soon as a call exists — ringing counts.\n *\n * Deliberately not \"connected\": the audio session has to be running\n * before LiveKit's audio engine starts, not after. Start it late and\n * the call connects, the roster is right, video flows, and no audio\n * is published in either direction.\n */\n active: boolean;\n /**\n * Whether the call is carrying video.\n *\n * Decides where audio goes by default — nobody holds a phone to their\n * ear while looking at the screen — and nothing else. Read once, when\n * the call starts; see {@link LiveKitReactNativeModule.setupIOSAudioManagement}\n * for why it cannot be re-applied mid-call.\n */\n video: boolean;\n /** `@livekit/react-native`, imported by your app. */\n livekitReactNative?: LiveKitReactNativeModule | null | undefined;\n}\n\nexport interface CallAudio {\n /** Audio is coming out of the loudspeaker. */\n speakerOn: boolean;\n toggleSpeaker: () => void;\n setSpeaker: (on: boolean) => void;\n /** Every route that can be picked right now. */\n routes: AudioRoute[];\n /**\n * The selected route's platform id, or `null` while routing is\n * automatic — which is the normal state until the user picks\n * something. Automatic means the OS follows the preference order the\n * call was configured with, so plugging in a headset just works.\n */\n selectedRouteId: string | null;\n selectRoute: (id: string) => void;\n /**\n * A headset, AirPods or car kit is connected.\n *\n * Worth surfacing because it changes what the speaker button means:\n * with a headset attached, \"off\" routes to the headset rather than to\n * the earpiece.\n *\n * Android only, and honestly so — iOS reports just `default` and\n * `force_speaker` from `getAudioOutputs`, with no way to ask what\n * `default` currently resolves to. On iOS this stays `false` and the\n * system route picker is the way to see and change the real device.\n */\n externalDevice: boolean;\n /**\n * The system route picker can be opened. iOS only — Android\n * enumerates its devices in {@link routes} instead.\n */\n canPickSystemRoute: boolean;\n openSystemRoutePicker: () => void;\n}\n\nconst IOS_AUTO = 'default';\nconst IOS_SPEAKER = 'force_speaker';\n\n/**\n * Owns the audio session for an SFU-backed call, and the routing on top\n * of it.\n *\n * ## Why this is not `react-native-incall-manager`\n *\n * `registerGlobals()` from `@livekit/react-native` drives AVAudioSession\n * natively off its own audio engine's state. Anything else driving the\n * session at the same time fights it, and the symptom is brutal: the\n * microphone captures nothing, and audio only starts working after some\n * unrelated engine change — turning the camera on, say — makes LiveKit\n * reapply its configuration. So InCallManager is reserved for the\n * peer-to-peer mesh, which has no session management of its own.\n *\n * ## What \"default\" means on each platform\n *\n * Android is handed a `preferredOutputList` and picks the best\n * available device itself, so a connected headset wins without the app\n * detecting anything. iOS is given `defaultOutput`, which LiveKit\n * documents as the output to use *when a wired headset or Bluetooth\n * output is unavailable* — same effect, same reason: an app that forced\n * the speaker on a video call would yank audio out of the user's\n * AirPods every time.\n */\nexport function useCallAudio({\n active,\n video,\n livekitReactNative,\n}: UseCallAudioOptions): CallAudio {\n const session = livekitReactNative?.AudioSession;\n const ios = Platform.OS === 'ios';\n\n const [routes, setRoutes] = useState<AudioRoute[]>([]);\n // Null until the user picks: the platform is already routing by the\n // preference order handed to `configureAudio`, and naming a route\n // here would pin it and defeat the automatic headset switching.\n const [selectedRouteId, setSelectedRouteId] = useState<string | null>(null);\n\n // Captured at call start. Depending on `video` directly would tear the\n // audio session down and rebuild it every time the camera is toggled.\n const preferSpeaker = useRef(video);\n if (!active) preferSpeaker.current = video;\n\n // Whether the user has made an explicit choice on this call. Once they\n // have, nothing derived from the media type may override it — turning\n // the camera on must not move audio off the earpiece they chose.\n const userChose = useRef(false);\n if (!active) userChose.current = false;\n\n const refreshRoutes = useCallback(() => {\n if (!session) return;\n void session\n .getAudioOutputs()\n .then((ids) => setRoutes(ids.map(describeRoute)))\n .catch(() => {\n // An unstarted session, or a platform that refuses to enumerate.\n // The speaker toggle still works; only the picker is poorer for\n // it, which is not worth failing a call over.\n });\n }, [session]);\n\n // ── session lifecycle ────────────────────────────────────────────────\n\n useEffect(() => {\n if (!active || !session) return;\n\n const wantsSpeaker = preferSpeaker.current;\n let disposePolicy: (() => void) | undefined;\n // A call that ends while the session is still starting up would\n // otherwise leave the iOS policy installed forever: cleanup runs\n // before the async body has assigned the disposer, so there is\n // nothing to call. The flag lets the body clean up after itself.\n let released = false;\n\n // Ordering matters: configure, then install the iOS policy, then\n // start. `configureAudio` is documented as having to run before the\n // room connects for it to apply at all.\n void (async () => {\n try {\n await session.configureAudio({\n android: {\n // Best device first. A headset or car kit outranks the\n // built-in outputs either way; the media type only decides\n // which built-in output wins when nothing is plugged in.\n preferredOutputList: wantsSpeaker\n ? ['bluetooth', 'headset', 'speaker', 'earpiece']\n : ['bluetooth', 'headset', 'earpiece', 'speaker'],\n },\n ios: { defaultOutput: wantsSpeaker ? 'speaker' : 'earpiece' },\n });\n } catch {\n // Falls back to LiveKit's own defaults, which are sane.\n }\n\n if (released) return;\n disposePolicy = livekitReactNative?.setupIOSAudioManagement?.(wantsSpeaker);\n\n try {\n await session.startAudioSession();\n } catch {\n // A refused session leaves the call silent rather than failing\n // it outright. Better a call the user can see is broken than one\n // that never rings.\n }\n\n if (released) {\n // Ended mid-start. Undo what we just did rather than leaving a\n // session running for a call that no longer exists.\n void session.stopAudioSession().catch(() => {});\n disposePolicy?.();\n return;\n }\n refreshRoutes();\n })();\n\n return () => {\n released = true;\n // Released deliberately. Holding the session open leaves the\n // device in call mode afterwards, with media apps stuck at call\n // volume and the earpiece still routed.\n void session.stopAudioSession().catch(() => {});\n disposePolicy?.();\n };\n }, [active, session, livekitReactNative, refreshRoutes]);\n\n // A finished call must not hand its routing to the next one.\n useEffect(() => {\n if (active) return;\n setSelectedRouteId(null);\n setRoutes([]);\n }, [active]);\n\n // ── device changes ───────────────────────────────────────────────────\n\n useEffect(() => {\n if (!active) return;\n const events = livekitReactNative?.audioDeviceModuleEvents;\n if (!events) return;\n\n const onChange = () => refreshRoutes();\n try {\n events.addDevicesUpdatedListener(onChange);\n } catch {\n // iOS/macOS only in the current module. Android still refreshes on\n // call start and whenever the picker is opened, which covers the\n // cases a user can actually observe.\n return;\n }\n return () => {\n try {\n events.removeDevicesUpdatedListener(onChange);\n } catch {\n // Nothing registered; nothing to undo.\n }\n };\n }, [active, livekitReactNative, refreshRoutes]);\n\n // ── selection ────────────────────────────────────────────────────────\n\n const selectRoute = useCallback(\n (id: string) => {\n userChose.current = true;\n setSelectedRouteId(id);\n if (!session) return;\n void session.selectAudioOutput(id).catch(() => {\n // The device went away between listing and picking. Re-reading\n // is more useful than reporting it.\n refreshRoutes();\n });\n },\n [session, refreshRoutes],\n );\n\n const externalDevice = useMemo(\n () => routes.some((r) => r.kind === 'headset' || r.kind === 'bluetooth'),\n [routes],\n );\n\n // With no explicit choice, report where the platform was told to send\n // audio by default — except when something is plugged in, which\n // outranks the loudspeaker in every preference order above.\n const speakerOn =\n selectedRouteId === null\n ? preferSpeaker.current && !externalDevice\n : ios\n ? selectedRouteId === IOS_SPEAKER\n : selectedRouteId === 'speaker';\n\n const setSpeaker = useCallback(\n (on: boolean) => {\n if (ios) {\n selectRoute(on ? IOS_SPEAKER : IOS_AUTO);\n return;\n }\n if (on) {\n selectRoute('speaker');\n return;\n }\n // Turning the speaker off on Android has to name a destination.\n // Prefer whatever the user is wearing over the earpiece — pulling\n // audio out of connected AirPods would be the wrong reading of\n // \"not the loudspeaker\".\n const fallback =\n routes.find((r) => r.kind === 'bluetooth') ??\n routes.find((r) => r.kind === 'headset') ??\n routes.find((r) => r.kind === 'earpiece');\n if (fallback) selectRoute(fallback.id);\n },\n [ios, routes, selectRoute],\n );\n\n const toggleSpeaker = useCallback(() => setSpeaker(!speakerOn), [setSpeaker, speakerOn]);\n\n const openSystemRoutePicker = useCallback(() => {\n void session?.showAudioRoutePicker?.().catch(() => {});\n }, [session]);\n\n return {\n speakerOn,\n toggleSpeaker,\n setSpeaker,\n routes,\n selectedRouteId,\n selectRoute,\n externalDevice,\n canPickSystemRoute: ios && typeof session?.showAudioRoutePicker === 'function',\n openSystemRoutePicker,\n };\n}\n","import { useEffect, useRef, useState } from 'react';\n\n/**\n * How long the call has been connected, as `m:ss` (or `h:mm:ss`).\n *\n * Anchored to a timestamp rather than counting ticks: a phone that\n * sleeps or throttles timers would otherwise drift, and a call timer\n * that reads 4:12 after eleven minutes is worse than none. Returns null\n * until the call is actually up, so a ringing call shows its status\n * line instead of `0:00`.\n */\nexport function useCallDuration(connected: boolean): string | null {\n const startedAt = useRef<number | null>(null);\n const [, tick] = useState(0);\n\n if (connected && startedAt.current === null) startedAt.current = Date.now();\n if (!connected && startedAt.current !== null) startedAt.current = null;\n\n useEffect(() => {\n if (!connected) return;\n const id = setInterval(() => tick((n) => n + 1), 1000);\n return () => clearInterval(id);\n }, [connected]);\n\n if (!connected || startedAt.current === null) return null;\n return format(Math.max(0, Math.floor((Date.now() - startedAt.current) / 1000)));\n}\n\nfunction format(total: number): string {\n const hours = Math.floor(total / 3600);\n const minutes = Math.floor((total % 3600) / 60);\n const seconds = total % 60;\n const mm = hours > 0 ? String(minutes).padStart(2, '0') : String(minutes);\n return `${hours > 0 ? `${hours}:` : ''}${mm}:${String(seconds).padStart(2, '0')}`;\n}\n","import { useCallRoom, useCalls, useVoiceRoom, type UseCalls } from '@poolse/react';\nimport type { CallParticipant, LiveKitModule, VoiceStatus } from '@poolse/sdk';\nimport { useCallback, useEffect, useMemo, useRef, useState } from 'react';\nimport { Modal, Pressable, StatusBar, StyleSheet, Text, View } from 'react-native';\nimport { useSafeAreaInsets } from 'react-native-safe-area-context';\n\nimport { PoolseIcon } from './primitives/PoolseIcon.js';\nimport { AudioRouteSheet } from './voice/AudioRouteSheet.js';\nimport { CallAvatar } from './voice/CallAvatar.js';\nimport { CallControlButton } from './voice/CallControlButton.js';\nimport { CallVideoGrid } from './voice/CallVideoGrid.js';\nimport { callColors } from './voice/callTheme.js';\nimport type { LiveKitReactNativeModule } from './voice/livekit-rn.js';\nimport { useCallAudio } from './voice/useCallAudio.js';\nimport { useCallDuration } from './voice/useCallDuration.js';\nimport {\n createNativeWebRtcAdapter,\n isNativeWebRtcAvailable,\n type NativeWebRtcModule,\n} from './voice/webrtc-native.js';\n\nexport interface CallScreenProps {\n /** The signed-in user's id — the topic calls are delivered on. */\n userId: string;\n /** Resolves a user id to a display label. Defaults to a short id. */\n labelFor?: (userId: string) => string;\n /**\n * Escape hatch for apps that already own a `useCalls` instance (for\n * example to place calls from elsewhere in the UI). When omitted the\n * component manages its own.\n */\n calls?: UseCalls;\n /**\n * The `react-native-webrtc` module (or `@livekit/react-native-webrtc`,\n * which is API-compatible), imported by your app.\n *\n * Used for the peer-to-peer fallback when the deployment has no SFU.\n * With an SFU configured, LiveKit owns the peer connection and this is\n * only the safety net.\n */\n webrtc?: NativeWebRtcModule | null;\n /**\n * `livekit-client`, imported by your app. Enables SFU-backed calls,\n * which is what makes video and the mid-call camera toggle possible.\n * Omit it and calls fall back to the peer-to-peer mesh, audio only.\n */\n livekit?: LiveKitModule | null;\n /**\n * `@livekit/react-native`, imported by your app.\n *\n * Required to *render* video, and also carries `AudioSession`, which\n * is what routes a call to the speaker, the earpiece or a headset.\n * Without it a call still connects and carries audio, every tile\n * shows an avatar, and routing falls to whatever the OS picks.\n */\n livekitReactNative?: LiveKitReactNativeModule | null;\n /**\n * Called whenever the call's media connection state changes.\n */\n onStatusChange?: (status: VoiceStatus) => void;\n /**\n * Called when the media transport changes: `'sfu'`, `'mesh'`, or\n * `null` when no call is connected.\n *\n * This decides who owns the iOS audio session, and getting it wrong is\n * silent. `@livekit/react-native`'s `registerGlobals()` configures and\n * activates AVAudioSession natively as its audio engine changes state.\n * An app that ALSO drives the session — `react-native-incall-manager`,\n * typically — fights it: the microphone publishes nothing, and audio\n * only starts working after some unrelated engine change (turning the\n * camera on) makes LiveKit reapply its configuration.\n *\n * So drive InCallManager from this, and only for `'mesh'`. On the SFU\n * path this component already owns the session, through LiveKit.\n */\n onTransportChange?: (transport: 'sfu' | 'mesh' | null) => void;\n /** Called when the call's video state changes. */\n onVideoChange?: (video: boolean) => void;\n /**\n * `react-native-incall-manager`, imported by your app.\n *\n * Only used here for the ring tones — the earpiece purr while an\n * outbound call rings, and the ringtone for an inbound one. Without\n * it a call is completely silent until somebody answers, which reads\n * as the app having failed to place it at all.\n *\n * Injected rather than imported for the same reason every other\n * native module is: Metro only bundles what it can see statically.\n */\n inCallManager?: RingToneModule | null;\n /**\n * Hide this screen while a call is merely ringing in.\n *\n * Set it when `useVoipCalls` is wired: CallKit already shows the\n * system call UI on the lock screen and in the Dynamic Island, and a\n * second in-app sheet on top of it means one tap of Call produces two\n * competing rings. The screen still appears once the call connects, to\n * carry the in-call controls.\n */\n nativeIncomingUi?: boolean;\n}\n\n/** Controls fade out this long after the last touch on a video call. */\nconst CHROME_IDLE_MS = 4500;\n\n/**\n * The slice of `react-native-incall-manager` used for ring tones.\n *\n * Every method optional: older versions lack some, and a missing tone\n * must never take a call down.\n */\nexport interface RingToneModule {\n // Deliberately loose, for the same reason `LiveKitModule` is.\n // Spelling the real signatures out does NOT work: function parameters\n // are contravariant, so any shape differing even slightly from the\n // installed version's — an argument required rather than optional, a\n // `number | number[]` rather than a `number[]` — makes the real module\n // unassignable and no app can pass it in. It also breaks again on the\n // next upstream signature change.\n //\n // Narrowed to `RingTone` at the point of use instead.\n startRingback?: (...args: never[]) => void;\n stopRingback?: (...args: never[]) => void;\n startRingtone?: (...args: never[]) => void;\n stopRingtone?: (...args: never[]) => void;\n}\n\n/** The shape actually called, narrowed once inside the component. */\ntype RingTone = (tone: string) => void;\n\n/**\n * WhatsApp-style call UI: a full-screen sheet that covers the app while\n * a call is ringing or connected, and renders nothing when idle.\n *\n * Mount it once, high in the tree, so a call can arrive on any screen:\n *\n * <PoolseProvider config={config}>\n * <CallScreen\n * userId={me.id}\n * livekit={livekit}\n * livekitReactNative={livekitRN}\n * />\n * <YourApp />\n * </PoolseProvider>\n *\n * ## Two media paths\n *\n * With `livekit` supplied, media rides the SFU: one upload per\n * participant regardless of call size, and the camera and microphone can\n * be switched on and off at any point. Without it — or against a\n * deployment that has no SFU configured — calls fall back to the\n * peer-to-peer mesh, which is audio only.\n *\n * The fallback is automatic and silent by design. A deployment without\n * an SFU is a supported configuration, not a broken one.\n */\n/** How long a finished call stays on screen before closing itself. */\nconst ENDED_LINGER_MS = 2500;\n\n/**\n * Phases that mean the call is finished and the screen is only\n * reporting the outcome. Shared by the render branch and the\n * self-dismiss timer so the two can never disagree about what \"over\"\n * means.\n */\nfunction isOver(phase: string): boolean {\n return phase === 'declined' || phase === 'busy' || phase === 'timed-out';\n}\n\nexport function CallScreen({\n userId,\n labelFor,\n calls: callsProp,\n webrtc,\n livekit,\n livekitReactNative,\n onStatusChange,\n onTransportChange,\n onVideoChange,\n inCallManager,\n nativeIncomingUi,\n}: CallScreenProps) {\n const insets = useSafeAreaInsets();\n const ownCalls = useCalls(callsProp ? null : userId);\n const calls = callsProp ?? ownCalls;\n\n const meshAvailable = isNativeWebRtcAvailable(webrtc);\n const opts = useMemo(\n () => (meshAvailable && webrtc ? { webrtc: createNativeWebRtcAdapter(webrtc) } : {}),\n [meshAvailable, webrtc],\n );\n\n /**\n * The conversation whose media should be open.\n *\n * Deliberately includes `ringing-out`, not just `active`. Waiting for\n * an answer before touching the camera meant the caller stared at a\n * blank screen through the entire ring and then watched their own\n * preview pop in a second after the other side picked up — and the\n * microphone was not open either, so the first word of every call was\n * clipped. Joining while it rings means the room is warm the instant\n * they answer, and you can see yourself while you wait.\n *\n * Safe for the alone-detection: a caller sitting in an empty room has\n * never seen a peer, and that is exactly the guard `CallRoom.onAlone`\n * checks before declaring a call abandoned.\n */\n const conversationId =\n calls.phase === 'active'\n ? calls.activeConversationId\n : calls.phase === 'ringing-out'\n ? (calls.outgoing?.conversationId ?? null)\n : null;\n const isVideoCall = calls.media === 'video';\n\n // Both are constructed; only one ends up connected. `useCallRoom`\n // reports `sfuAvailable: false` when the API answers 503, and only\n // then does the mesh join — so a deployment with an SFU never opens a\n // peer connection it will not use.\n const sfu = useCallRoom(livekit ? conversationId : null, {\n livekit: livekit as LiveKitModule,\n video: isVideoCall,\n });\n const mesh = useVoiceRoom(conversationId, opts);\n\n const usingSfu = sfu.sfuAvailable === true;\n const status: VoiceStatus = usingSfu ? toVoiceStatus(sfu.status) : mesh.status;\n const connected = calls.phase === 'active' && status === 'connected';\n\n useEffect(() => {\n const wants = calls.phase === 'active' || calls.phase === 'ringing-out';\n if (!wants || !conversationId) return;\n\n let cancelled = false;\n void (async () => {\n // Try the SFU first when the app supplied LiveKit. A `false` here\n // means the deployment has none, which is the one case the mesh\n // should take over.\n const joined = livekit ? await sfu.join() : false;\n if (cancelled || joined) return;\n if (meshAvailable) await mesh.join();\n })();\n\n return () => {\n cancelled = true;\n };\n // eslint-disable-next-line react-hooks/exhaustive-deps\n }, [calls.phase, conversationId, livekit, meshAvailable]);\n\n useEffect(() => {\n onStatusChange?.(status);\n }, [status, onStatusChange]);\n\n const transport: 'sfu' | 'mesh' | null =\n status !== 'connected' ? null : usingSfu ? 'sfu' : 'mesh';\n\n useEffect(() => {\n onTransportChange?.(transport);\n }, [transport, onTransportChange]);\n\n // The mesh carries no video, so its calls are always audio.\n const videoOn = usingSfu && sfu.cameraEnabled;\n useEffect(() => {\n onVideoChange?.(videoOn);\n }, [videoOn, onVideoChange]);\n\n // ── audio routing ───────────────────────────────────────────────────\n\n // Armed on the ring, not on connect: LiveKit's audio session has to be\n // running before its engine starts, and replacing its handlers\n // mid-call is unsupported. Mesh calls are excluded because\n // InCallManager owns the session there — see `onTransportChange`.\n const audio = useCallAudio({\n active: calls.phase !== 'idle' && transport !== 'mesh',\n video: isVideoCall,\n livekitReactNative,\n });\n const [routesOpen, setRoutesOpen] = useState(false);\n\n /**\n * The sound of a call in progress.\n *\n * Ringback while an outbound call rings, so the caller can hear that\n * something is happening — silence there is indistinguishable from a\n * call that failed to place. A ringtone for an inbound one, but only\n * when this screen is actually showing it: with CallKit driving the\n * ring, iOS plays the system ringtone and a second tone underneath it\n * is just noise.\n *\n * Stopped in the cleanup rather than on a phase transition, so a call\n * that ends any way at all — answered, declined, cancelled, timed out,\n * crashed out — cannot leave a tone playing.\n */\n const showingIncoming = calls.phase === 'ringing-in' && !nativeIncomingUi;\n useEffect(() => {\n const ringing = calls.phase === 'ringing-out';\n if (!ringing && !showingIncoming) return;\n\n try {\n const start = (ringing ? inCallManager?.startRingback : inCallManager?.startRingtone) as\n | RingTone\n | undefined;\n // `_BUNDLE_` for ringback, not `_DEFAULT_`. On iOS the library\n // resolves `_DEFAULT_` to /Library/Ringtones/Marimba.m4r — an\n // actual iPhone RINGTONE — so the caller heard the sound the\n // callee's phone makes rather than a ringing tone. `_DTMF_` is\n // remapped to `_DEFAULT_` too, so the only correct option is to\n // ship the tone: the app bundles `incallmanager_ringback.mp3`\n // (see the sample's plugins/withRingback.js). Absent that, the\n // library falls back to the ringtone, which is no worse than\n // before.\n start?.(ringing ? '_BUNDLE_' : '_DEFAULT_');\n } catch {\n // A missing tone must never take the call down with it.\n }\n\n return () => {\n try {\n (inCallManager?.stopRingback as (() => void) | undefined)?.();\n (inCallManager?.stopRingtone as (() => void) | undefined)?.();\n } catch {\n // Nothing playing; nothing to stop.\n }\n };\n }, [calls.phase, showingIncoming, inCallManager]);\n\n // ── chrome auto-hide ────────────────────────────────────────────────\n\n const [chromeVisible, setChromeVisible] = useState(true);\n // Bumped on every interaction. Having the effect depend on it is what\n // restarts the countdown — a polled deadline would either fire late or\n // need an interval running for the whole call.\n const [lastWake, setLastWake] = useState(0);\n\n // Only video calls hide their controls — there is nothing to look at\n // underneath an audio call, so hiding them would just lose the\n // buttons.\n const chromeHides = connected && isVideoCall;\n\n useEffect(() => {\n setChromeVisible(true);\n if (!chromeHides) return;\n const timer = setTimeout(() => setChromeVisible(false), CHROME_IDLE_MS);\n return () => clearTimeout(timer);\n }, [chromeHides, lastWake]);\n\n const wakeChrome = useCallback(() => setLastWake(Date.now()), []);\n\n /**\n * Tapping the screen toggles the controls.\n *\n * It used to only ever show them, and then a timer took them away —\n * so there was no way to dismiss the chrome deliberately and get a\n * clean look at the video. Tap to hide, tap to show, and the idle\n * timer stays as a convenience on top rather than as the only way\n * they ever disappear.\n */\n const toggleChrome = useCallback(() => {\n setChromeVisible((visible) => {\n if (visible) return false;\n setLastWake(Date.now());\n return true;\n });\n }, []);\n\n /**\n * Run an action and restart the idle countdown.\n *\n * A child `Pressable` wins the touch outright, so the screen-wide\n * handler never sees a control being tapped — without this, hitting\n * mute at four seconds would watch the controls vanish half a second\n * later.\n */\n const withWake = useCallback(\n (fn: () => void) => () => {\n wakeChrome();\n fn();\n },\n [wakeChrome],\n );\n\n // ── actions ─────────────────────────────────────────────────────────\n\n // `calls.hangUp()` signals the other side and always returns to idle;\n // `reset()` alone only cleared local state, leaving the peer in a call\n // with a screen it had no reason to close.\n const hangUp = useCallback(() => {\n sfu.leave();\n mesh.leave();\n void calls.hangUp();\n }, [sfu, mesh, calls]);\n\n // Everyone else vanished without hanging up — their app was killed or\n // their phone lost signal, so no `call:hangup` will ever arrive. End\n // it here rather than leaving the survivor on a dead call screen.\n const alone = usingSfu ? sfu.alone : mesh.alone;\n\n // Latched, because `hangUp` closes over the room objects and those are\n // rebuilt every render — the effect re-runs constantly, and without a\n // guard it would fire the hang-up repeatedly in the window before the\n // phase actually flips.\n const endedOnEmpty = useRef(false);\n if (calls.phase !== 'active') endedOnEmpty.current = false;\n\n useEffect(() => {\n if (!alone || calls.phase !== 'active' || endedOnEmpty.current) return;\n endedOnEmpty.current = true;\n hangUp();\n }, [alone, calls.phase, hangUp]);\n\n /**\n * Close a finished call by itself.\n *\n * \"Declined\", \"Busy\" and \"No answer\" are the end of the story, and\n * leaving them behind a Close button meant every unanswered call\n * ended with the caller dismissing a dialog nobody reads. Long enough\n * to read the word, short enough that it never feels stuck — and the\n * button stays, so a person who looks down mid-countdown still has\n * something to tap.\n */\n useEffect(() => {\n if (!isOver(calls.phase)) return;\n const timer = setTimeout(calls.reset, ENDED_LINGER_MS);\n return () => clearTimeout(timer);\n }, [calls.phase, calls.reset]);\n\n const micOn = usingSfu ? sfu.micEnabled : !mesh.muted;\n const toggleMic = useCallback(() => {\n if (usingSfu) void sfu.toggleMic();\n else mesh.toggleMute();\n }, [usingSfu, sfu, mesh]);\n\n const onSpeakerPress = useCallback(() => {\n // With real devices to choose between, a toggle is the wrong\n // control — it can only ever reach two of them. Android enumerates\n // them, so it gets a picker; iOS hands the job to the system sheet,\n // which is the only way to reach AirPods or AirPlay there.\n if (audio.routes.length > 2) setRoutesOpen(true);\n else if (audio.canPickSystemRoute && audio.externalDevice) audio.openSystemRoutePicker();\n else audio.toggleSpeaker();\n }, [audio]);\n\n // ── presentation ────────────────────────────────────────────────────\n\n const label = useMemo(() => labelFor ?? ((id: string) => `User ${id.slice(0, 6)}`), [labelFor]);\n\n const ringingIn = calls.phase === 'ringing-in';\n const ringingOut = calls.phase === 'ringing-out';\n const ended = isOver(calls.phase);\n const visible = calls.phase !== 'idle' && !(nativeIncomingUi && ringingIn);\n\n const duration = useCallDuration(connected);\n const participants: CallParticipant[] = usingSfu ? sfu.participants : [];\n const others = participants.filter((p) => !p.isSelf);\n const isGroup = others.length > 1 || (calls.outgoing?.calleeUserIds.length ?? 0) > 1;\n\n const peerIds =\n ringingIn && calls.incoming\n ? [calls.incoming.callerUserId]\n : others.length > 0\n ? others.map((p) => p.userId)\n : (calls.outgoing?.calleeUserIds ?? []);\n\n const title =\n peerIds.length === 0\n ? 'Call'\n : peerIds.length <= 2\n ? peerIds.map(label).join(', ')\n : `${label(peerIds[0]!)} and ${peerIds.length - 1} others`;\n\n const subtitle = duration ?? statusLine(calls, status);\n\n // The stage only earns the screen once media is flowing. Before that\n // there is nothing to render but a placeholder, and the identity card\n // says far more.\n const showStage = connected && usingSfu && participants.length > 0;\n\n const error = calls.error ?? (usingSfu ? sfu.error : mesh.error);\n // Only the scrolling group grid uses this — it keeps the last row\n // clear of the control bar. The floating preview is bounded by the\n // safe area instead, so it can sit in a real corner.\n const chromeInsets = {\n top: insets.top + 72,\n bottom: insets.bottom + 150,\n };\n\n return (\n <Modal\n visible={visible}\n animationType=\"slide\"\n transparent={false}\n supportedOrientations={['portrait', 'landscape']}\n onRequestClose={hangUp}\n >\n <StatusBar barStyle=\"light-content\" />\n <Pressable style={styles.screen} onPress={toggleChrome} accessible={false}>\n {showStage ? (\n <CallVideoGrid\n participants={participants}\n livekitReactNative={livekitReactNative}\n labelFor={label}\n onLocalPress={() => void sfu.switchCamera()}\n chromeInsets={chromeInsets}\n safeArea={{ top: insets.top, bottom: insets.bottom }}\n />\n ) : (\n <View style={styles.identity}>\n <CallAvatar\n name={peerIds.length === 1 ? label(peerIds[0]!) : title}\n seed={peerIds[0] ?? 'call'}\n size={132}\n />\n </View>\n )}\n\n {/* ── header ─────────────────────────────────────────────── */}\n {chromeVisible && (\n <View style={[styles.header, { paddingTop: insets.top + 14 }]} pointerEvents=\"box-none\">\n <Text numberOfLines={1} style={styles.title}>\n {title}\n </Text>\n <View style={styles.subtitleRow}>\n {isGroup && showStage && (\n <PoolseIcon name=\"users\" size={14} color={callColors.textDim} label={null} />\n )}\n <Text style={styles.subtitle}>\n {isGroup && showStage ? `${participants.length} · ${subtitle}` : subtitle}\n </Text>\n </View>\n </View>\n )}\n\n {/* ── controls ───────────────────────────────────────────── */}\n {chromeVisible && (\n <View\n style={[styles.controls, { paddingBottom: insets.bottom + 22 }]}\n pointerEvents=\"box-none\"\n >\n {error && <Text style={styles.error}>{error.message}</Text>}\n {!meshAvailable && !livekit && (\n <Text style={styles.error}>No WebRTC module supplied — this call has no audio.</Text>\n )}\n\n {ringingIn ? (\n <View style={styles.row}>\n <CallControlButton\n icon=\"phone-off\"\n tone=\"danger\"\n large\n onPress={() => void calls.decline()}\n accessibilityLabel=\"Decline call\"\n />\n <CallControlButton\n icon={isVideoCall ? 'video' : 'phone'}\n tone=\"accept\"\n large\n onPress={() => void calls.accept()}\n accessibilityLabel=\"Accept call\"\n />\n </View>\n ) : ended ? (\n <View style={styles.row}>\n <CallControlButton\n icon=\"close\"\n onPress={calls.reset}\n label=\"Close\"\n accessibilityLabel=\"Close\"\n />\n </View>\n ) : (\n <>\n <View style={styles.row}>\n <CallControlButton\n icon={micOn ? 'mic' : 'mic-off'}\n label={micOn ? 'Mute' : 'Unmute'}\n active={!micOn}\n onPress={withWake(toggleMic)}\n accessibilityLabel={micOn ? 'Mute microphone' : 'Unmute microphone'}\n />\n <CallControlButton\n icon={speakerIcon(audio)}\n label={speakerLabel(audio)}\n active={audio.speakerOn}\n onPress={withWake(onSpeakerPress)}\n accessibilityLabel=\"Audio output\"\n />\n {/* Only the SFU can add video to a live call — the mesh\n offers once, on peer discovery, and cannot renegotiate. */}\n {usingSfu && (\n <CallControlButton\n icon={videoOn ? 'video' : 'video-off'}\n label=\"Camera\"\n active={!videoOn}\n onPress={withWake(() => void sfu.toggleCamera())}\n accessibilityLabel={videoOn ? 'Turn camera off' : 'Turn camera on'}\n />\n )}\n {usingSfu && videoOn && (\n <CallControlButton\n icon=\"camera-flip\"\n label=\"Flip\"\n onPress={withWake(() => void sfu.switchCamera())}\n accessibilityLabel=\"Switch camera\"\n />\n )}\n </View>\n\n <View style={styles.hangUpRow}>\n <CallControlButton\n icon=\"phone-off\"\n tone=\"danger\"\n large\n onPress={ringingOut ? () => void calls.cancel() : hangUp}\n accessibilityLabel={ringingOut ? 'Cancel call' : 'Hang up'}\n />\n </View>\n </>\n )}\n </View>\n )}\n\n <AudioRouteSheet\n visible={routesOpen}\n routes={audio.routes}\n selectedRouteId={audio.selectedRouteId}\n onSelect={audio.selectRoute}\n onClose={() => setRoutesOpen(false)}\n />\n </Pressable>\n </Modal>\n );\n}\n\nfunction speakerIcon(audio: { speakerOn: boolean; externalDevice: boolean }) {\n if (audio.externalDevice) return 'headphones' as const;\n return audio.speakerOn ? ('speaker' as const) : ('speaker-off' as const);\n}\n\nfunction speakerLabel(audio: { externalDevice: boolean }) {\n return audio.externalDevice ? 'Audio' : 'Speaker';\n}\n\n/** The SFU's lifecycle mapped onto the one the mesh already reports. */\nfunction toVoiceStatus(status: string): VoiceStatus {\n switch (status) {\n case 'connecting':\n return 'connecting';\n case 'connected':\n return 'connected';\n case 'error':\n return 'error';\n default:\n return 'idle';\n }\n}\n\nfunction statusLine(calls: UseCalls, mediaStatus: string): string {\n switch (calls.phase) {\n case 'ringing-in':\n return calls.media === 'video' ? 'Incoming video call' : 'Incoming call';\n case 'ringing-out':\n return 'Ringing…';\n case 'declined':\n return 'Call declined';\n case 'busy':\n return 'Already on another call';\n case 'timed-out':\n return 'No answer';\n case 'active':\n return mediaStatus === 'connected' ? 'Connected' : 'Connecting…';\n default:\n return '';\n }\n}\n\nconst styles = StyleSheet.create({\n screen: { flex: 1, backgroundColor: callColors.bg },\n identity: { flex: 1, alignItems: 'center', justifyContent: 'center' },\n\n header: {\n position: 'absolute',\n top: 0,\n left: 0,\n right: 0,\n alignItems: 'center',\n gap: 5,\n paddingHorizontal: 24,\n paddingBottom: 18,\n backgroundColor: callColors.scrim,\n },\n title: { color: callColors.text, fontSize: 22, fontWeight: '600', textAlign: 'center' },\n subtitleRow: { flexDirection: 'row', alignItems: 'center', gap: 6 },\n subtitle: { color: callColors.textDim, fontSize: 14.5 },\n\n controls: {\n position: 'absolute',\n left: 0,\n right: 0,\n bottom: 0,\n alignItems: 'center',\n gap: 18,\n paddingTop: 20,\n backgroundColor: callColors.scrim,\n },\n row: { flexDirection: 'row', justifyContent: 'center', flexWrap: 'wrap', rowGap: 16 },\n hangUpRow: { flexDirection: 'row', justifyContent: 'center' },\n error: {\n color: callColors.danger,\n fontSize: 12.5,\n textAlign: 'center',\n paddingHorizontal: 24,\n },\n});\n","import { useMe, usePoolse, type UseCalls } from '@poolse/react';\nimport type { CallMedia, IncomingCall } from '@poolse/sdk';\nimport { useEffect, useRef, useState } from 'react';\n\n/**\n * Bridges iOS PushKit + CallKit to poolse calls, and owns the incoming\n * call UI end to end.\n *\n * ## Why this coordinates rather than just forwards\n *\n * A call arrives by two routes: `call:incoming` over the WebSocket when\n * the app is foregrounded, and a VoIP push when it isn't. The server\n * fires both, always — deciding server-side whether a socket is really\n * alive is a race it would lose.\n *\n * Reconciling them is therefore the client's job, and doing it badly is\n * very visible: forward each route to its own UI and one tap of Call\n * shows the callee two rings, an in-app sheet fighting a system call\n * screen.\n *\n * So this hook is the single place a call becomes visible. Both routes\n * feed one map keyed by `callId`, CallKit is the only ring UI, and the\n * native call is torn down whenever the call reaches a terminal state —\n * declined, cancelled, timed out, answered. Pass the same `calls` object\n * to `<CallScreen>` and it stays out of the way while a ring is up.\n *\n * ## The rule Apple enforces\n *\n * Every delivered VoIP push MUST report an incoming call to CallKit,\n * essentially immediately. Miss it and iOS terminates the app; do it\n * repeatedly and the system stops delivering VoIP pushes at all.\n *\n * ## Dependencies\n *\n * `react-native-voip-push-notification` and `react-native-callkeep`,\n * both native and both requiring a development build. Metro only bundles\n * what it can see statically, so YOUR APP imports them and passes them\n * in. The iOS AppDelegate also needs PushKit delegate methods, which\n * Expo does not generate — see the sample's `plugins/withVoipPush.js`.\n *\n * useVoipCalls({\n * voipPush: VoipPushNotification,\n * callKeep: RNCallKeep,\n * calls, // the same useCalls() the UI uses\n * apnsEnvironment: 'sandbox',\n * });\n */\n\n/** The slice of `react-native-voip-push-notification` used here. */\nexport interface VoipPushModule {\n addEventListener(event: string, handler: (payload: unknown) => void): void;\n removeEventListener(event: string): void;\n registerVoipToken(): void;\n /**\n * Releases the native PushKit completion handler for a push.\n *\n * iOS hands `didReceiveIncomingPushWith` a completion block and expects\n * it back once the call has been reported. Never calling it leaves the\n * app looking like it dropped the push, which is one of the ways iOS\n * stops delivering VoIP pushes to an app entirely.\n *\n * Optional because older versions of the module don't expose it.\n */\n onVoipNotificationCompleted?(uuid: string): void;\n}\n\n/** The slice of `react-native-callkeep` used here. */\nexport interface CallKeepModule {\n setup(options: unknown): Promise<unknown>;\n displayIncomingCall(\n uuid: string,\n handle: string,\n localizedCallerName?: string,\n handleType?: string,\n hasVideo?: boolean,\n ): unknown;\n endCall(uuid: string): unknown;\n /** Tell CallKit the call connected. Absent on older versions. */\n setCurrentCallActive?(uuid: string): unknown;\n addEventListener(event: string, handler: (payload: unknown) => void): void;\n removeEventListener(event: string): void;\n}\n\n/** An inbound call, as it arrives inside a VoIP push payload. */\nexport interface VoipIncomingCall {\n callId: string;\n conversationId: string;\n callerUserId: string;\n callerName: string;\n /**\n * What the call opened as.\n *\n * Carried by the push because CallKit fixes the answer button when the\n * call is reported and cannot change it afterwards — waiting for the\n * socket would mean answering a video call through an audio UI.\n */\n media: CallMedia;\n}\n\nexport interface UseVoipCallsOptions {\n voipPush: VoipPushModule;\n callKeep: CallKeepModule;\n /**\n * The `useCalls(...)` instance driving this screen. Supplying it lets\n * the hook answer, decline and dismiss through the same state machine\n * the UI uses, rather than two halves disagreeing about what is\n * happening.\n */\n calls?: UseCalls;\n /** Called when the user answers from the native call UI. */\n onAnswer?: (call: VoipIncomingCall) => void;\n /** Called when the user declines from the native call UI. */\n onDecline?: (call: VoipIncomingCall) => void;\n /** CallKit display name for your app. Shown on the lock screen. */\n appName?: string;\n /**\n * Which APNs environment issued this build's PushKit token — it must\n * match the app's `aps-environment` entitlement.\n *\n * Pass it explicitly. The fallback guesses from `__DEV__`, which\n * describes the JS bundle and NOT the entitlement: an ad-hoc or\n * TestFlight build has `__DEV__ === false` while still carrying the\n * `development` entitlement, so it receives a sandbox token and\n * reports it as production. The server then pushes to the wrong\n * environment, Apple answers BadDeviceToken, and the phone never\n * rings — with nothing in the app to suggest why.\n */\n apnsEnvironment?: 'production' | 'sandbox';\n /**\n * How old a pushed call may be before it is reported and immediately\n * ended, in ms. Defaults to a deliberately generous 120s.\n *\n * The tight value this once used made clock skew between server and\n * handset enough to suppress live calls. The authoritative guard is\n * server-side anyway — accepting an ended call is refused — so this is\n * only here to spare the user a ring for something long dead.\n *\n * PushKit holds a push that lands before the JS bundle is up and\n * replays it on launch, so opening the app can ring you for a call the\n * caller hung up on minutes ago — a ring with nothing live to accept.\n */\n staleAfterMs?: number;\n}\n\n/**\n * Whether a pushed call is old enough to be dismissed straight after\n * being reported.\n *\n * Exported for testing, because getting this wrong is silent and total:\n * too tight a window and clock skew between the server and the handset\n * suppresses live calls with nothing in the app to explain it.\n *\n * Never dismisses on a missing timestamp, and never on a future one —\n * skew runs both ways, and withholding a real call is far worse than\n * ringing once for a dead one.\n */\n/**\n * Whether a call phase means the system call should be torn down.\n *\n * CallKit has no idea what the app is doing, so it holds a call open\n * until told otherwise. Get this wrong in either direction and the phone\n * and the app disagree:\n *\n * * too eager — ending on `active` takes the connected call out of the\n * Dynamic Island and Recents while the user is still talking;\n * * too reluctant — never ending it leaves a call the user hung up\n * still showing on the lock screen, with buttons that do nothing.\n *\n * The ringing phases are excluded because the ring IS the system call,\n * and `active` because a connected call is supposed to exist. Everything\n * else — idle, declined, busy, timed out — is over.\n *\n * `undefined` means no `calls` was supplied, so there is no state\n * machine to read and nothing this can honestly conclude. Tearing a call\n * down on a guess would be worse than leaving it to the app.\n */\nexport function isCallOver(phase: string | undefined): boolean {\n if (phase === undefined) return false;\n return phase !== 'ringing-in' && phase !== 'ringing-out' && phase !== 'active';\n}\n\nexport function isStalePush(\n sentAt: number | undefined,\n now: number,\n staleAfterMs: number,\n): boolean {\n if (typeof sentAt !== 'number' || !Number.isFinite(sentAt)) return false;\n const age = now - sentAt;\n if (age < 0) return false;\n return age > staleAfterMs;\n}\n\nexport interface PushPayload {\n /**\n * Which half of a call's life this push is about.\n *\n * Absent on servers that predate the field, and absence means a ring —\n * that was the only kind of call push there was.\n */\n event?: 'incoming' | 'ended';\n call_id?: string;\n conversation_id?: string;\n caller_user_id?: string;\n caller_name?: string;\n media?: string;\n has_video?: boolean;\n /** Only on `ended`: why, so CallKit's Recents entry tells the truth. */\n reason?: string;\n sent_at?: number;\n}\n\n/** What a VoIP push is asking this device to do. */\nexport type PushIntent =\n | { kind: 'ring'; call: VoipIncomingCall; sentAt: number | undefined }\n | { kind: 'teardown'; callId: string }\n | { kind: 'ignore' };\n\n/**\n * Decide what a VoIP push means, before any of it touches CallKit.\n *\n * Pure and exported so the decision can be tested on its own. The\n * consequences of getting it wrong are not symmetrical: reading a ring\n * as a teardown loses the call silently, while reading a teardown as a\n * ring leaves a phone ringing for a call nobody is on.\n *\n * A payload with no `event` is a ring, because for a while that was the\n * only kind of push there was and those servers are still out there.\n */\nexport function readPush(payload: PushPayload): PushIntent {\n const callId = payload.call_id;\n if (!callId) return { kind: 'ignore' };\n\n if (payload.event === 'ended') return { kind: 'teardown', callId };\n\n // A ring needs somewhere to answer into; a teardown does not, which is\n // why this check sits below rather than above.\n const conversationId = payload.conversation_id;\n if (!conversationId) return { kind: 'ignore' };\n\n return {\n kind: 'ring',\n sentAt: payload.sent_at,\n call: {\n callId,\n conversationId,\n callerUserId: payload.caller_user_id ?? '',\n callerName: payload.caller_name ?? 'Incoming call',\n // `has_video` is what older servers sent; `media` supersedes it.\n // Either saying video means the system UI offers video.\n media: payload.media === 'video' || payload.has_video ? 'video' : 'audio',\n },\n };\n}\n\n/**\n * Registers this device for VoIP pushes and drives the native call UI.\n *\n * Mount once, as high in the signed-in tree as possible. Does nothing on\n * Android, which needs a separate FCM + ConnectionService integration.\n */\nexport function useVoipCalls({\n voipPush,\n callKeep,\n calls,\n onAnswer,\n onDecline,\n appName = 'poolse',\n apnsEnvironment,\n staleAfterMs = 120_000,\n}: UseVoipCallsOptions): void {\n const poolse = usePoolse();\n\n /** Calls currently shown to CallKit, keyed by call id. */\n const shown = useRef<Map<string, VoipIncomingCall>>(new Map());\n\n /**\n * This device's PushKit token, once iOS has issued one.\n *\n * State rather than a ref: registering it depends on the session\n * arriving, which can happen either side of the token, so both have to\n * be able to trigger the attempt.\n */\n const [voipToken, setVoipToken] = useState<string | null>(null);\n\n /**\n * Who is signed in, if anyone yet.\n *\n * A device row belongs to a user, so there is nothing to register\n * until this resolves — and on a cold launch it resolves well after\n * PushKit hands over the token.\n */\n const { me } = useMe();\n\n /** The `${userId}:${token}` pair already sent, so it is sent once. */\n const registered = useRef<string | null>(null);\n\n // Read at event time so a re-render doesn't tear down and re-register\n // the native listeners.\n const handlers = useRef({ onAnswer, onDecline, calls });\n handlers.current = { onAnswer, onDecline, calls };\n\n const staleRef = useRef(staleAfterMs);\n staleRef.current = staleAfterMs;\n\n /**\n * Resolves once CallKit is configured.\n *\n * On a push-launched app the queued push can be replayed before\n * `setup()` finishes, and reporting into an unconfigured CallKit\n * throws — which iOS treats as a push that was never reported, and\n * kills the app for it. Reports are chained on this instead.\n */\n const ready = useRef<Promise<unknown>>(Promise.resolve());\n\n // Which reported calls the user actually answered.\n //\n // A CallKit \"endCall\" means two different things depending on this: a\n // call ended while ringing was refused, one ended after answering was\n // hung up. They travel as different signals, and sending the wrong one\n // leaves the other side thinking the call is still going.\n const answered = useRef(new Set<string>());\n\n /** Take a call down in CallKit — the island stays stuck until we do. */\n const dismiss = useRef((callId: string) => {\n answered.current.delete(callId);\n if (!shown.current.has(callId)) return;\n shown.current.delete(callId);\n try {\n callKeep.endCall(callId);\n } catch {\n // Ending a call CallKit has already forgotten is not an error.\n }\n });\n\n /**\n * Report a call to CallKit.\n *\n * ALWAYS reports, with no early return before\n * `displayIncomingCall`. iOS terminates an app that accepts a VoIP\n * push without reporting a call — so skipping the report to\n * deduplicate, or because the push looked stale, crashes the app\n * instead of quietly ignoring the call.\n *\n * Deduplication needs no help from us: CallKit keys calls by UUID, so\n * reporting the same `callId` twice updates the existing call rather\n * than creating a second one. That is what makes it safe for the\n * socket and the push to both report the same call.\n *\n * A stale call is reported and then immediately ended, which satisfies\n * the contract and still spares the user a ring they cannot answer.\n */\n const present = useRef((call: VoipIncomingCall, sentAt?: number) => {\n shown.current.set(call.callId, call);\n\n const show = () => {\n try {\n callKeep.displayIncomingCall(\n call.callId,\n call.callerUserId,\n call.callerName,\n 'generic',\n call.media === 'video',\n );\n } catch {\n // Never let a reporting failure propagate: an exception here\n // takes the whole app down on a path iOS is already watching.\n }\n };\n\n const done = () => {\n show();\n try {\n // Only after the call is reported. Handing the completion back\n // first would tell iOS we were finished while CallKit still had\n // nothing to show, which is the case it terminates apps over.\n voipPush.onVoipNotificationCompleted?.(call.callId);\n } catch {\n // Same reasoning as above — never throw on this path.\n }\n };\n\n // `.then` on an already-resolved promise still defers a tick, which\n // is immaterial next to the seconds iOS allows — and far cheaper\n // than reporting before CallKit is ready.\n void ready.current.then(done, done);\n\n if (isStalePush(sentAt, Date.now(), staleRef.current)) dismiss.current(call.callId);\n });\n\n /**\n * Register the device once BOTH the token and the user exist.\n *\n * Re-runs when either arrives, in whichever order, and again if the\n * signed-in user changes — a handset handed to somebody else must ring\n * for them and not for whoever had it before.\n */\n useEffect(() => {\n const userId = me?.id;\n if (!voipToken || !userId) return;\n\n const pair = `${userId}:${voipToken}`;\n if (registered.current === pair) return;\n\n void poolse.devices\n .register({\n token: voipToken,\n platform: 'ios',\n environment: apnsEnvironment ?? guessApnsEnvironment(),\n })\n .then(() => {\n registered.current = pair;\n })\n .catch(() => {\n // Offline, or the session is not usable yet. Deliberately does\n // NOT mark the pair as registered, so the next render that\n // changes either half tries again.\n });\n }, [poolse, voipToken, me?.id, apnsEnvironment]);\n\n useEffect(() => {\n let cancelled = false;\n\n const fromPush = (payload: PushPayload) => {\n const intent = readPush(payload);\n\n if (intent.kind === 'ignore') return;\n\n // The call is over and this device may only just have woken up to\n // hear it. Tear the ring down rather than starting one.\n //\n // The completion handler still has to go back to iOS, and the call\n // still has to be reported before it can be ended — both happen\n // natively, in the AppDelegate, because a push that reports\n // nothing is the one thing iOS punishes. All that is left here is\n // the app's own state.\n if (intent.kind === 'teardown') {\n dismiss.current(intent.callId);\n handlers.current.calls?.dropped(intent.callId);\n return;\n }\n\n present.current(intent.call, intent.sentAt);\n\n // Tell the state machine as well as CallKit.\n //\n // Reporting the ring to iOS is not enough: every signal that ENDS\n // a call — the caller hanging up, the call being answered\n // elsewhere — is matched against the hook's own `incoming`, and a\n // pushed call never set it. So a caller who gave up left the\n // callee's phone ringing on, because nothing on this side could\n // tell that `call:cancelled` was about the call CallKit was\n // showing.\n handlers.current.calls?.ring({\n callId: intent.call.callId,\n conversationId: intent.call.conversationId,\n callerUserId: intent.call.callerUserId,\n media: intent.call.media,\n });\n };\n\n ready.current = callKeep\n .setup({\n ios: { appName },\n android: {\n alertTitle: 'Permissions required',\n alertDescription: 'Allow calls from this app',\n cancelButton: 'Cancel',\n okButton: 'ok',\n additionalPermissions: [],\n },\n })\n .catch(() => {\n // A failed setup shouldn't take the app down. Reports still go\n // out afterwards — a rejected setup often still leaves CallKit\n // usable, and not reporting is the one outcome iOS punishes.\n });\n\n // PushKit issues a token on every launch and may rotate it, so\n // register whatever we're given rather than caching.\n // Captured, NOT registered here. PushKit issues the token moments\n // after launch, which can easily be before the host app has a\n // session — and registering needs one, because it is an\n // authenticated call. Sending it straight away meant a silent 401,\n // no device row, and therefore no push for any call at all. The\n // effect below sends it once there is somebody to register it for.\n voipPush.addEventListener('register', ((token: string) => {\n if (cancelled || !token) return;\n setVoipToken(token);\n }) as (payload: unknown) => void);\n\n voipPush.addEventListener('notification', ((payload: PushPayload) => {\n fromPush(payload);\n }) as (payload: unknown) => void);\n\n // Pushes that landed while the bundle was still starting are replayed\n // here. Without this a cold-launch call is lost — the very case this\n // exists for — but they are also the likeliest to be stale, so they\n // go through the same age check.\n voipPush.addEventListener('didLoadWithEvents', ((\n events: Array<{ name: string; data: unknown }>,\n ) => {\n for (const event of events ?? []) {\n if (event.name === 'RNVoipPushRemoteNotificationReceivedEvent') {\n fromPush(event.data as PushPayload);\n }\n }\n }) as (payload: unknown) => void);\n\n callKeep.addEventListener('answerCall', (({ callUUID }: { callUUID: string }) => {\n const call = shown.current.get(callUUID);\n\n // Deliberately KEPT in `shown`. Removing it here left nothing to\n // end when the user later hung up, so the system call stayed live\n // on the phone with the app no longer in it.\n answered.current.add(callUUID);\n\n try {\n callKeep.setCurrentCallActive?.(callUUID);\n } catch {\n // Older CallKeep builds lack this; the call still connects.\n }\n\n // The map is empty after a relaunch — iOS can kill and restart the\n // app between reporting the call and the user answering it. Falling\n // back to the hook's own state means answering still works instead\n // of silently doing nothing.\n if (!call) {\n void handlers.current.calls?.accept();\n return;\n }\n\n // Accept through the shared state machine so the in-app UI moves to\n // 'active' too. The explicit argument matters: on a cold launch the\n // hook has no `incoming` state, and the push payload is the only\n // record of what is being answered.\n void handlers.current.calls?.accept({\n callId: call.callId,\n conversationId: call.conversationId,\n callerUserId: call.callerUserId,\n media: call.media,\n });\n handlers.current.onAnswer?.(call);\n }) as (payload: unknown) => void);\n\n callKeep.addEventListener('endCall', (({ callUUID }: { callUUID: string }) => {\n const call = shown.current.get(callUUID);\n const wasAnswered = answered.current.has(callUUID);\n shown.current.delete(callUUID);\n answered.current.delete(callUUID);\n\n // Same relaunch case as answerCall: end whatever the hook thinks\n // is live rather than leaving a call the user has dismissed.\n //\n // An answered call takes the same route: it is no longer an\n // invitation to refuse, so it hangs up like the in-app button and\n // the other side is told the call ended.\n if (!call || wasAnswered) {\n void handlers.current.calls?.hangUp();\n return;\n }\n\n void handlers.current.calls?.decline({\n callId: call.callId,\n conversationId: call.conversationId,\n callerUserId: call.callerUserId,\n media: call.media,\n });\n handlers.current.onDecline?.(call);\n }) as (payload: unknown) => void);\n\n voipPush.registerVoipToken();\n\n return () => {\n cancelled = true;\n voipPush.removeEventListener('register');\n voipPush.removeEventListener('notification');\n voipPush.removeEventListener('didLoadWithEvents');\n callKeep.removeEventListener('answerCall');\n callKeep.removeEventListener('endCall');\n };\n }, [poolse, voipPush, callKeep, appName, apnsEnvironment]);\n\n // ── keep CallKit in step with the call's actual state ───────────────\n\n const incoming: IncomingCall | null = calls?.incoming ?? null;\n const phase = calls?.phase;\n\n // A call that reached us over the socket has to be shown too, or a\n // foregrounded app rings only in-app while the lock screen stays\n // silent — and answering from the island then does nothing.\n useEffect(() => {\n if (phase === 'ringing-in' && incoming) {\n present.current({\n callId: incoming.callId,\n conversationId: incoming.conversationId,\n callerUserId: incoming.callerUserId,\n callerName: incoming.callerUserId,\n media: incoming.media,\n });\n }\n }, [phase, incoming]);\n\n // End the system call once the poolse call is genuinely over — see\n // `isCallOver`.\n useEffect(() => {\n if (!isCallOver(phase)) return;\n for (const callId of [...shown.current.keys()]) dismiss.current(callId);\n }, [phase]);\n}\n\n/**\n * Last-resort guess when `apnsEnvironment` isn't supplied.\n *\n * `__DEV__` reflects the JS bundle, not the `aps-environment`\n * entitlement, and the two disagree for any ad-hoc or TestFlight build.\n * Prefer passing the value explicitly, derived from the same source as\n * the entitlement.\n */\nfunction guessApnsEnvironment(): 'production' | 'sandbox' {\n return __DEV__ ? 'sandbox' : 'production';\n}\n"]}
|