const require_runtime = require("../../_virtual/_rolldown/runtime.js");
const require_TopologyIcons = require("./icons/TopologyIcons.js");
let react = require("react");
react = require_runtime.__toESM(react);
let _pisell_utils = require("@pisell/utils");
let classnames = require("classnames");
classnames = require_runtime.__toESM(classnames);
require("./TopologyDeviceCard.less");
//#region src/plus/pisellTopology/TopologyDeviceCard.tsx
const PREFIX = "pisell-topology-device-card";
const I18N_STATUS = "pisell-topology.device-status";
function statusLabel(status) {
	const key = `${I18N_STATUS}.${status}`;
	const text = _pisell_utils.locales.getText(key);
	return text !== key ? text : status;
}
/** 拓扑图元卡片：左上状态、中部图标、底部名称 + IP */
function TopologyDeviceCard(props) {
	var _item$elementKind, _TOPOLOGY_KIND_ICONS$, _item$_sceneElement, _item$name, _device$name, _device$model, _device$status, _device$ip;
	const { item, device } = props;
	const kind = (_item$elementKind = item.elementKind) !== null && _item$elementKind !== void 0 ? _item$elementKind : "";
	const Icon = (_TOPOLOGY_KIND_ICONS$ = require_TopologyIcons.TOPOLOGY_KIND_ICONS[kind]) !== null && _TOPOLOGY_KIND_ICONS$ !== void 0 ? _TOPOLOGY_KIND_ICONS$ : require_TopologyIcons.TopologyRouterIcon;
	/**
	* Ghost：sceneElement 是已保存的，但当前 device 接口里没匹配到这个 recordId。
	* 这里走两条线：
	* - 卡片整体加 `--ghost` 类，渲染灰色虚框 + 低透明
	* - 状态徽标改用「已下线 / removed」文案
	*/
	const recordId = ((_item$_sceneElement = item._sceneElement) === null || _item$_sceneElement === void 0 || (_item$_sceneElement = _item$_sceneElement.dataBinding) === null || _item$_sceneElement === void 0 ? void 0 : _item$_sceneElement.recordId) != null ? String(item._sceneElement.dataBinding.recordId) : void 0;
	const isGhost = recordId != null && device == null;
	const title = ((_item$name = item.name) === null || _item$name === void 0 ? void 0 : _item$name.trim()) || (device === null || device === void 0 || (_device$name = device.name) === null || _device$name === void 0 ? void 0 : _device$name.trim()) || (device === null || device === void 0 || (_device$model = device.model) === null || _device$model === void 0 ? void 0 : _device$model.trim()) || (isGhost ? recordId : kind);
	const status = isGhost ? "unknown" : (_device$status = device === null || device === void 0 ? void 0 : device.status) !== null && _device$status !== void 0 ? _device$status : "online";
	const ip = device === null || device === void 0 || (_device$ip = device.ip) === null || _device$ip === void 0 ? void 0 : _device$ip.trim();
	const statusText = isGhost ? _pisell_utils.locales.getText("pisell-topology.device-status.removed") : statusLabel(status);
	return /* @__PURE__ */ react.default.createElement("div", { className: (0, classnames.default)(PREFIX, { [`${PREFIX}--ghost`]: isGhost }) }, /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__main` }, /* @__PURE__ */ react.default.createElement("span", { className: (0, classnames.default)(`${PREFIX}__status`, isGhost ? `${PREFIX}__status--removed` : `${PREFIX}__status--${status}`) }, statusText), /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__icon` }, /* @__PURE__ */ react.default.createElement(Icon, null))), /* @__PURE__ */ react.default.createElement("div", { className: `${PREFIX}__footer` }, /* @__PURE__ */ react.default.createElement("div", {
		className: `${PREFIX}__name`,
		title
	}, title), ip ? /* @__PURE__ */ react.default.createElement("div", {
		className: `${PREFIX}__ip`,
		title: ip
	}, ip) : null));
}
//#endregion
exports.TopologyDeviceCard = TopologyDeviceCard;
