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,eAAe,EAAE,WAAW,CAAC,kBAAkB,EAAE;QACjD,IAAI,EAAE,CAAC;QACP,iBAAiB,EAAE,EAAE;KACtB;CACF,CAAC,CAAC","sourcesContent":["/**\n * Copyright (c) 650 Industries.\n * Copyright (c) Meta Platforms, Inc. and affiliates.\n *\n * This source code is licensed under the MIT license found in the\n * LICENSE file in the root directory of this source tree.\n */\nimport React, { useEffect } from 'react';\nimport { Image, Pressable, StyleSheet, Text, View } from 'react-native';\n\nimport { ErrorToastMessage } from './ErrorToastMessage';\nimport * as LogBoxData from '../Data/LogBoxData';\nimport { LogBoxLog } from '../Data/LogBoxLog';\nimport * as LogBoxStyle from '../UI/LogBoxStyle';\n\ntype Props = {\n  log: LogBoxLog;\n  totalLogCount: number;\n  level: 'warn' | 'error';\n  onPressOpen: () => void;\n  onPressDismiss: () => void;\n};\n\nfunction useSymbolicatedLog(log: LogBoxLog) {\n  // Eagerly symbolicate so the stack is available when pressing to inspect.\n  useEffect(() => {\n    LogBoxData.symbolicateLogLazy('stack', log);\n    LogBoxData.symbolicateLogLazy('component', log);\n  }, [log]);\n}\n\nexport function ErrorToast(props: Props) {\n  const { totalLogCount, level, log } = props;\n\n  useSymbolicatedLog(log);\n\n  return (\n    <View style={toastStyles.container}>\n      <Pressable style={{ flex: 1 }} onPress={props.onPressOpen}>\n        {({\n          /** @ts-expect-error: react-native types are broken. */\n          hovered,\n          pressed,\n        }) => (\n          <View\n            style={[\n              toastStyles.press,\n              {\n                // @ts-expect-error: web-only type\n                transitionDuration: '150ms',\n                backgroundColor: pressed\n                  ? '#323232'\n                  : hovered\n                  ? '#111111'\n                  : LogBoxStyle.getBackgroundColor(),\n              },\n            ]}>\n            <Count count={totalLogCount} level={level} />\n            <ErrorToastMessage message={log.message} />\n            <Dismiss onPress={props.onPressDismiss} />\n          </View>\n        )}\n      </Pressable>\n    </View>\n  );\n}\n\nfunction Count({ count, level }: { count: number; level: Props['level'] }) {\n  return (\n    <View style={[countStyles.inside, countStyles[level]]}>\n      <Text style={countStyles.text}>{count <= 1 ? '!' : count}</Text>\n    </View>\n  );\n}\n\nfunction Dismiss({ onPress }: { onPress: () => void }) {\n  return (\n    <Pressable\n      style={{\n        marginLeft: 5,\n      }}\n      hitSlop={{\n        top: 12,\n        right: 10,\n        bottom: 12,\n        left: 10,\n      }}\n      onPress={onPress}>\n      {({\n        /** @ts-expect-error: react-native types are broken. */\n        hovered,\n        pressed,\n      }) => (\n        <View\n          style={[dismissStyles.press, hovered && { opacity: 0.8 }, pressed && { opacity: 0.5 }]}>\n          <Image\n            source={require('@expo/metro-runtime/assets/close.png')}\n            style={dismissStyles.image}\n          />\n        </View>\n      )}\n    </Pressable>\n  );\n}\n\nconst countStyles = StyleSheet.create({\n  warn: {\n    backgroundColor: LogBoxStyle.getWarningColor(1),\n  },\n  error: {\n    backgroundColor: LogBoxStyle.getErrorColor(1),\n  },\n  log: {\n    backgroundColor: LogBoxStyle.getLogColor(1),\n  },\n  inside: {\n    marginRight: 8,\n    minWidth: 22,\n    aspectRatio: 1,\n    paddingHorizontal: 4,\n    borderRadius: 11,\n    justifyContent: 'center',\n    alignItems: 'center',\n  },\n  text: {\n    color: LogBoxStyle.getTextColor(1),\n    fontSize: 14,\n    lineHeight: 18,\n    textAlign: 'center',\n    fontWeight: '600',\n    textShadow: `0px 0px 3px ${LogBoxStyle.getBackgroundColor(0.8)}`,\n  },\n});\n\nconst dismissStyles = StyleSheet.create({\n  press: {\n    backgroundColor: '#323232',\n    height: 20,\n    width: 20,\n    borderRadius: 25,\n    alignItems: 'center',\n    justifyContent: 'center',\n  },\n  image: {\n    height: 8,\n    width: 8,\n  },\n});\n\nconst toastStyles = StyleSheet.create({\n  container: {\n    height: 48,\n    justifyContent: 'center',\n    marginBottom: 4,\n  },\n  press: {\n    borderWidth: 1,\n    borderRadius: 8,\n    overflow: 'hidden',\n    flexDirection: 'row',\n    alignItems: 'center',\n    borderColor: '#323232',\n    backgroundColor: LogBoxStyle.getBackgroundColor(),\n    flex: 1,\n    paddingHorizontal: 12,\n  },\n});\n"]}