behemoth-cli
Version:
🌍 BEHEMOTH CLIv3.760.4 - Level 50+ POST-SINGULARITY Intelligence Trading AI
37 lines • 2.43 kB
JavaScript
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
import React, { useState } from 'react';
import { Box, Text } from 'ink';
import DataPoint from './DataPoint.js';
// @ts-ignore - chartscii might not have types
import Chartscii from 'chartscii';
const CliResponse = React.memo(({ response }) => {
const { header, sections, footer } = response;
const [collapsedSections, setCollapsedSections] = useState(new Array(sections?.length || 0).fill(false));
const toggleSection = (index) => {
setCollapsedSections(prev => {
const newState = [...prev];
newState[index] = !newState[index];
return newState;
});
};
const colorMap = {
bull: 'green',
bear: 'red',
neutral: 'gray',
warning: 'yellow',
accent: 'blue',
primary: 'cyan',
cosmic: 'magenta',
};
const titleColor = colorMap[header.color || 'primary'] || 'cyan';
return (_jsxs(Box, { borderStyle: "round", borderColor: titleColor, flexDirection: "column", paddingX: 1, marginY: 1, children: [_jsx(Box, { justifyContent: "center", width: "100%", children: _jsx(Text, { color: titleColor, bold: true, children: `${header.emoji} ${header.title}` }) }), sections?.map((section, sIndex) => {
const isCollapsed = collapsedSections[sIndex];
return (_jsxs(Box, { flexDirection: "column", marginTop: 1, paddingTop: 1, children: [_jsx(Box
// @ts-ignore
, {
// @ts-ignore
onPress: () => toggleSection(sIndex), children: _jsxs(Text, { bold: true, underline: true, children: [section.title, " ", isCollapsed ? '[+]' : '[-]'] }) }), !isCollapsed && (_jsxs(Box, { flexDirection: "column", paddingLeft: 2, children: [section.data?.map((dp, dpIndex) => (_jsx(DataPoint, { dataPoint: dp, colorMap: colorMap }, dpIndex))), section.content && _jsx(Text, { children: section.content }), section.chart && (_jsx(Box, { marginTop: 1, children: _jsx(Text, { children: new Chartscii(section.chart.data, section.chart.options).create() }) }))] }))] }, sIndex));
}), footer && (_jsx(Box, { marginTop: 1, justifyContent: "flex-end", children: _jsxs(Text, { dimColor: true, children: ["\uD83D\uDCE1 Source: ", footer.source] }) }))] }));
});
export default CliResponse;
//# sourceMappingURL=CliResponse.js.map