1*a5fb1ba8SEvan Bacon"use strict";
2*a5fb1ba8SEvan Baconvar __importDefault = (this && this.__importDefault) || function (mod) {
3*a5fb1ba8SEvan Bacon    return (mod && mod.__esModule) ? mod : { "default": mod };
4*a5fb1ba8SEvan Bacon};
5*a5fb1ba8SEvan BaconObject.defineProperty(exports, "__esModule", { value: true });
6*a5fb1ba8SEvan Baconexports.useSelectedLog = exports.useLogs = exports.LogContext = void 0;
7*a5fb1ba8SEvan Baconconst react_1 = __importDefault(require("react"));
8*a5fb1ba8SEvan Baconconst react_native_1 = require("react-native");
9*a5fb1ba8SEvan Baconconst LogBoxLog_1 = require("./LogBoxLog");
1026ad19fcSEvan Bacon// Context provider for Array<LogBoxLog>
11*a5fb1ba8SEvan Baconexports.LogContext = react_1.default.createContext(null);
12*a5fb1ba8SEvan Baconfunction useLogs() {
13*a5fb1ba8SEvan Bacon    const logs = react_1.default.useContext(exports.LogContext);
1426ad19fcSEvan Bacon    if (!logs) {
15*a5fb1ba8SEvan Bacon        if (react_native_1.Platform.OS === 'web' && typeof window !== 'undefined') {
1626ad19fcSEvan Bacon            // Logbox data that is pre-fetched on the dev server and rendered here.
1726ad19fcSEvan Bacon            const expoCliStaticErrorElement = document.getElementById('_expo-static-error');
1826ad19fcSEvan Bacon            if (expoCliStaticErrorElement?.textContent) {
1926ad19fcSEvan Bacon                const raw = JSON.parse(expoCliStaticErrorElement.textContent);
2026ad19fcSEvan Bacon                return {
2126ad19fcSEvan Bacon                    ...raw,
22*a5fb1ba8SEvan Bacon                    logs: raw.logs.map((raw) => new LogBoxLog_1.LogBoxLog(raw)),
2326ad19fcSEvan Bacon                };
2426ad19fcSEvan Bacon            }
2526ad19fcSEvan Bacon        }
2626ad19fcSEvan Bacon        throw new Error('useLogs must be used within a LogProvider');
2726ad19fcSEvan Bacon    }
2826ad19fcSEvan Bacon    return logs;
2926ad19fcSEvan Bacon}
30*a5fb1ba8SEvan Baconexports.useLogs = useLogs;
31*a5fb1ba8SEvan Baconfunction useSelectedLog() {
3226ad19fcSEvan Bacon    const { selectedLogIndex, logs } = useLogs();
3326ad19fcSEvan Bacon    return logs[selectedLogIndex];
3426ad19fcSEvan Bacon}
35*a5fb1ba8SEvan Baconexports.useSelectedLog = useSelectedLog;
3626ad19fcSEvan Bacon//# sourceMappingURL=LogContext.js.map