var __defProp = Object.defineProperty;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropNames = Object.getOwnPropertyNames;
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 __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);

// src/plus/saasDevice/appPeripheral/utils.ts
var utils_exports = {};
__export(utils_exports, {
  BRAND_OPTION_SEPARATOR: () => BRAND_OPTION_SEPARATOR,
  CONNECTION_TYPE_OPTIONS: () => CONNECTION_TYPE_OPTIONS,
  DEVICE_ICON_COLOR: () => DEVICE_ICON_COLOR,
  createDeviceRow: () => createDeviceRow,
  flattenDeviceModels: () => flattenDeviceModels,
  getBrandCodeFromOptionValue: () => getBrandCodeFromOptionValue,
  getBrandOptionValue: () => getBrandOptionValue,
  getConnectionTypeLabel: () => getConnectionTypeLabel,
  getModelConnectionTypes: () => getModelConnectionTypes,
  isProfileRequired: () => isProfileRequired
});
module.exports = __toCommonJS(utils_exports);
var DEVICE_ICON_COLOR = {
  smart: "#1677ff",
  dumb: "#faad14",
  integrated: "#389e0d"
};
var CONNECTION_TYPE_OPTIONS = [
  { label: "USB", value: "usb" },
  { label: "Ethernet", value: "ethernet" },
  { label: "WiFi", value: "wifi" },
  { label: "Bluetooth", value: "bluetooth" },
  { label: "Serial", value: "serial" }
];
var BRAND_OPTION_SEPARATOR = "__";
var getBrandOptionValue = (brand) => `${brand.id}${BRAND_OPTION_SEPARATOR}${brand.code}`;
var getBrandCodeFromOptionValue = (value) => value == null ? void 0 : value.split(BRAND_OPTION_SEPARATOR).slice(1).join(BRAND_OPTION_SEPARATOR);
var getModelConnectionTypes = (model) => {
  var _a;
  const connections = (_a = model.data) == null ? void 0 : _a.connection_types;
  return Array.isArray(connections) ? connections.map((item) => String(item || "").trim()).filter(Boolean) : [];
};
var getConnectionTypeLabel = (value) => {
  var _a;
  if (!value) return "-";
  const normalizedValue = value.toLowerCase().trim();
  return ((_a = CONNECTION_TYPE_OPTIONS.find((option) => option.value === normalizedValue)) == null ? void 0 : _a.label) || value;
};
var isProfileRequired = (model) => {
  var _a, _b;
  return Boolean((_b = (_a = model == null ? void 0 : model.data) == null ? void 0 : _a.profile_structure) == null ? void 0 : _b.required);
};
var flattenDeviceModels = (types) => {
  const modelMap = /* @__PURE__ */ new Map();
  types.forEach((type) => {
    (type.active_models || []).forEach((model) => {
      if (!modelMap.has(model.code)) {
        modelMap.set(model.code, { ...model, type: model.type || type });
      }
    });
  });
  return Array.from(modelMap.values());
};
var createDeviceRow = (item, translation) => {
  var _a, _b, _c;
  const name = translation(item.name);
  const typeName = translation((_a = item.type) == null ? void 0 : _a.name) || item.type_code;
  const modelName = translation((_b = item.model) == null ? void 0 : _b.name) || item.model_code;
  const link = item.link || "unlinked";
  const profileName = translation((_c = item.profile) == null ? void 0 : _c.name) || (item.profile_id ? String(item.profile_id) : "-");
  return {
    id: item.id,
    name,
    typeName,
    modelName,
    profileName,
    link,
    status: link === "linked" ? item.status || "offline" : "unknown",
    typeCode: item.type_code,
    modelCode: item.model_code,
    _raw: item
  };
};
// Annotate the CommonJS export names for ESM import in node:
0 && (module.exports = {
  BRAND_OPTION_SEPARATOR,
  CONNECTION_TYPE_OPTIONS,
  DEVICE_ICON_COLOR,
  createDeviceRow,
  flattenDeviceModels,
  getBrandCodeFromOptionValue,
  getBrandOptionValue,
  getConnectionTypeLabel,
  getModelConnectionTypes,
  isProfileRequired
});
