const require_runtime = require("../../../_virtual/_rolldown/runtime.js");
const require_index = require("../../../locales/index.js");
const require_types = require("../types.js");
let react = require("react");
react = require_runtime.__toESM(react);
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./index.less");
//#region src/components/hardwareErrorTip/logCard/index.tsx
const LOG_LEVEL_MAP = {
	0: "debug",
	1: "info",
	2: "error"
};
const LOG_LEVEL_COLORS = {
	debug: "#666",
	info: "#1890ff",
	error: "#ff4d4f"
};
const DEVICE_TYPE_MAP = {
	printer: require_index.getText("pisell2.text.hardware-error.device.printer"),
	barcode_scanner: require_index.getText("pisell2.text.hardware-error.device.barcode-scanner"),
	cds: require_index.getText("pisell2.text.hardware-error.device.cds"),
	kds: require_index.getText("pisell2.text.hardware-error.device.kds"),
	display: require_index.getText("pisell2.text.hardware-error.device.display"),
	card_reader: require_index.getText("pisell2.text.hardware-error.device.card-reader"),
	till: require_index.getText("pisell2.text.hardware-error.device.till"),
	scale: require_index.getText("pisell2.text.hardware-error.device.scale")
};
const LogCard = (props) => {
	const { data } = props;
	const logLevel = LOG_LEVEL_MAP[data.log_level];
	const logLevelColor = LOG_LEVEL_COLORS[logLevel];
	const deviceTypeName = DEVICE_TYPE_MAP[data.device.device_type] || data.device.device_type;
	const formatTime = (timeStr) => {
		try {
			return new Date(timeStr).toLocaleString("zh-CN", {
				year: "numeric",
				month: "2-digit",
				day: "2-digit",
				hour: "2-digit",
				minute: "2-digit",
				second: "2-digit",
				fractionalSecondDigits: 3
			});
		} catch (_unused) {
			return timeStr;
		}
	};
	const formatLogLevel = (level) => {
		return {
			0: "DEBUG",
			1: "INFO",
			2: "ERROR"
		}[level];
	};
	const formatData = (dataStr) => {
		if (!dataStr) return null;
		try {
			const parsed = JSON.parse(dataStr);
			return JSON.stringify(parsed, null, 2);
		} catch (_unused2) {
			return dataStr;
		}
	};
	return /* @__PURE__ */ react.default.createElement("div", {
		className: (0, classnames.default)(`${require_types.prefix}-log-card`, logLevel),
		style: { borderLeftColor: logLevelColor }
	}, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-log-card-header` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-log-card-time` }, formatTime(data.time)), /* @__PURE__ */ react.default.createElement("div", {
		className: `${require_types.prefix}-log-card-level`,
		style: { color: logLevelColor }
	}, formatLogLevel(data.log_level)), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-log-card-device-id` }, data.device.device_idfa)), /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-log-card-content` }, /* @__PURE__ */ react.default.createElement("div", { className: `${require_types.prefix}-log-card-service` }, "[", deviceTypeName, "] ", data.message), data.data && /* @__PURE__ */ react.default.createElement("div", { className: `pisell-lowcode-log-card-data` }, /* @__PURE__ */ react.default.createElement("pre", null, formatData(data.data)))));
};
//#endregion
exports.default = LogCard;
