var __create = Object.create;
var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/pisellTopology/TopologyDeviceCard.tsx
var TopologyDeviceCard_exports = {};
__export(TopologyDeviceCard_exports, {
  TopologyDeviceCard: () => TopologyDeviceCard
});
module.exports = __toCommonJS(TopologyDeviceCard_exports);
var import_react = __toESM(require("react"));
var import_classnames = __toESM(require("classnames"));
var import_utils = require("@pisell/utils");
var import_TopologyIcons = require("./icons/TopologyIcons");
var import_TopologyDeviceCard = require("./TopologyDeviceCard.less");
var PREFIX = "pisell-topology-device-card";
var I18N_STATUS = "pisell-topology.device-status";
function statusLabel(status) {
  const key = `${I18N_STATUS}.${status}`;
  const text = import_utils.locales.getText(key);
  return text !== key ? text : status;
}
function TopologyDeviceCard(props) {
  var _a, _b, _c, _d, _e, _f;
  const { item, device } = props;
  const kind = item.elementKind ?? "";
  const Icon = import_TopologyIcons.TOPOLOGY_KIND_ICONS[kind] ?? import_TopologyIcons.TopologyRouterIcon;
  const recordId = ((_b = (_a = item._sceneElement) == null ? void 0 : _a.dataBinding) == null ? void 0 : _b.recordId) != null ? String(item._sceneElement.dataBinding.recordId) : void 0;
  const isGhost = recordId != null && device == null;
  const title = ((_c = item.name) == null ? void 0 : _c.trim()) || ((_d = device == null ? void 0 : device.name) == null ? void 0 : _d.trim()) || ((_e = device == null ? void 0 : device.model) == null ? void 0 : _e.trim()) || (isGhost ? recordId : kind);
  const status = isGhost ? "unknown" : (device == null ? void 0 : device.status) ?? "online";
  const ip = (_f = device == null ? void 0 : device.ip) == null ? void 0 : _f.trim();
  const statusText = isGhost ? import_utils.locales.getText("pisell-topology.device-status.removed") : statusLabel(status);
  return /* @__PURE__ */ import_react.default.createElement("div", { className: (0, import_classnames.default)(PREFIX, { [`${PREFIX}--ghost`]: isGhost }) }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__main` }, /* @__PURE__ */ import_react.default.createElement(
    "span",
    {
      className: (0, import_classnames.default)(
        `${PREFIX}__status`,
        isGhost ? `${PREFIX}__status--removed` : `${PREFIX}__status--${status}`
      )
    },
    statusText
  ), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__icon` }, /* @__PURE__ */ import_react.default.createElement(Icon, null))), /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__footer` }, /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__name`, title }, title), ip ? /* @__PURE__ */ import_react.default.createElement("div", { className: `${PREFIX}__ip`, title: ip }, ip) : null));
}
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  TopologyDeviceCard
});
