import { get } from "lodash-es";
export const joinObject = (obj, attribute, separator = ",") => {
  if (!Array.isArray(obj)) {
    return obj != null ? obj.toString() : "";
  }
  return obj.map((item) => {
    if (item && typeof item === "object") {
      if (attribute) {
        const val = get(item, attribute);
        if (val !== void 0) return val;
      }
      if (item.label !== void 0) return item.label;
      if (item.value !== void 0) return item.value;
      return item.toString();
    } else {
      return item != null ? item.toString() : "";
    }
  }).join(separator);
};
