1"use strict";
2var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3    if (k2 === undefined) k2 = k;
4    var desc = Object.getOwnPropertyDescriptor(m, k);
5    if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6      desc = { enumerable: true, get: function() { return m[k]; } };
7    }
8    Object.defineProperty(o, k2, desc);
9}) : (function(o, m, k, k2) {
10    if (k2 === undefined) k2 = k;
11    o[k2] = m[k];
12}));
13var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) {
14    Object.defineProperty(o, "default", { enumerable: true, value: v });
15}) : function(o, v) {
16    o["default"] = v;
17});
18var __importStar = (this && this.__importStar) || function (mod) {
19    if (mod && mod.__esModule) return mod;
20    var result = {};
21    if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
22    __setModuleDefault(result, mod);
23    return result;
24};
25Object.defineProperty(exports, "__esModule", { value: true });
26exports.LogBoxInspectorSourceMapStatus = void 0;
27/**
28 * Copyright (c) 650 Industries.
29 * Copyright (c) Meta Platforms, Inc. and affiliates.
30 *
31 * This source code is licensed under the MIT license found in the
32 * LICENSE file in the root directory of this source tree.
33 */
34const react_1 = __importStar(require("react"));
35const react_native_1 = require("react-native");
36const LogBoxButton_1 = require("../UI/LogBoxButton");
37const LogBoxStyle = __importStar(require("../UI/LogBoxStyle"));
38function LogBoxInspectorSourceMapStatus(props) {
39    const [state, setState] = (0, react_1.useState)({
40        animation: null,
41        rotate: null,
42    });
43    (0, react_1.useEffect)(() => {
44        if (props.status === 'PENDING') {
45            if (state.animation == null) {
46                const animated = new react_native_1.Animated.Value(0);
47                const animation = react_native_1.Animated.loop(react_native_1.Animated.timing(animated, {
48                    duration: 2000,
49                    easing: react_native_1.Easing.linear,
50                    toValue: 1,
51                    useNativeDriver: true,
52                }));
53                setState({
54                    animation,
55                    rotate: animated.interpolate({
56                        inputRange: [0, 1],
57                        outputRange: ['0deg', '360deg'],
58                    }),
59                });
60                animation.start();
61            }
62        }
63        else {
64            if (state.animation != null) {
65                state.animation.stop();
66                setState({
67                    animation: null,
68                    rotate: null,
69                });
70            }
71        }
72        return () => {
73            if (state.animation != null) {
74                state.animation.stop();
75            }
76        };
77    }, [props.status, state.animation]);
78    let image;
79    let color;
80    switch (props.status) {
81        case 'FAILED':
82            image = require('@expo/metro-runtime/assets/alert-triangle.png');
83            color = LogBoxStyle.getErrorColor(1);
84            break;
85        case 'PENDING':
86            image = require('@expo/metro-runtime/assets/loader.png');
87            color = LogBoxStyle.getWarningColor(1);
88            break;
89    }
90    if (props.status === 'COMPLETE' || image == null) {
91        return null;
92    }
93    return (react_1.default.createElement(LogBoxButton_1.LogBoxButton, { backgroundColor: {
94            default: 'transparent',
95            pressed: LogBoxStyle.getBackgroundColor(1),
96        }, hitSlop: { bottom: 8, left: 8, right: 8, top: 8 }, onPress: props.onPress, style: styles.root },
97        react_1.default.createElement(react_native_1.Animated.Image, { source: image, tintColor: color ?? LogBoxStyle.getTextColor(0.4), style: [
98                styles.image,
99                state.rotate == null || props.status !== 'PENDING'
100                    ? null
101                    : { transform: [{ rotate: state.rotate }] },
102            ] }),
103        react_1.default.createElement(react_native_1.Text, { style: [styles.text, { color }] }, "Source Map")));
104}
105exports.LogBoxInspectorSourceMapStatus = LogBoxInspectorSourceMapStatus;
106const styles = react_native_1.StyleSheet.create({
107    root: {
108        alignItems: 'center',
109        borderRadius: 12,
110        flexDirection: 'row',
111        height: 24,
112        paddingHorizontal: 8,
113    },
114    image: {
115        height: 14,
116        width: 16,
117        marginEnd: 4,
118    },
119    text: {
120        fontSize: 12,
121        includeFontPadding: false,
122        lineHeight: 16,
123    },
124});
125//# sourceMappingURL=LogBoxInspectorSourceMapStatus.js.map