1import React from 'react';
2import { Platform } from 'react-native';
3import { LogBoxLog } from './LogBoxLog';
4// Context provider for Array<LogBoxLog>
5export const LogContext = React.createContext(null);
6export function useLogs() {
7    const logs = React.useContext(LogContext);
8    if (!logs) {
9        if (Platform.OS === 'web' && typeof window !== 'undefined') {
10            // Logbox data that is pre-fetched on the dev server and rendered here.
11            const expoCliStaticErrorElement = document.getElementById('_expo-static-error');
12            if (expoCliStaticErrorElement?.textContent) {
13                const raw = JSON.parse(expoCliStaticErrorElement.textContent);
14                return {
15                    ...raw,
16                    logs: raw.logs.map((raw) => new LogBoxLog(raw)),
17                };
18            }
19        }
20        throw new Error('useLogs must be used within a LogProvider');
21    }
22    return logs;
23}
24export function useSelectedLog() {
25    const { selectedLogIndex, logs } = useLogs();
26    return logs[selectedLogIndex];
27}
28//# sourceMappingURL=LogContext.js.map