function extractCustomFieldEntries(item) {
  const out = {};
  if (!item || typeof item !== "object") return out;
  const normalizeValue = (value) => {
    if (Array.isArray(value)) return value;
    if (typeof value !== "string") return value;
    const trimmed = value.trim();
    if (trimmed.startsWith("{") && trimmed.endsWith("}")) {
      const inner = trimmed.slice(1, -1).trim();
      if (!inner) return [];
      return inner.split(/[\s,]+/).map((entry) => entry.trim()).filter(Boolean);
    }
    return trimmed;
  };
  const assign = (rawKey, rawValue) => {
    if (typeof rawKey !== "string") return;
    const trimmed = rawKey.trim();
    if (!trimmed) return;
    out[`cf_${trimmed}`] = normalizeValue(rawValue);
  };
  const assignObject = (source) => {
    if (!source || typeof source !== "object" || Array.isArray(source)) return;
    for (const [key, value] of Object.entries(source)) {
      assign(key, value);
    }
  };
  const assignEntries = (source) => {
    if (!Array.isArray(source)) return;
    for (const entry of source) {
      if (!entry || typeof entry !== "object") continue;
      const key = typeof entry.key === "string" ? entry.key : null;
      if (!key) continue;
      assign(key, "value" in entry ? entry.value : void 0);
    }
  };
  for (const [rawKey, rawValue] of Object.entries(item)) {
    if (rawKey.startsWith("cf_")) {
      if (rawKey.endsWith("__is_multi")) continue;
      out[rawKey] = normalizeValue(rawValue);
    } else if (rawKey.startsWith("cf:")) {
      assign(rawKey.slice(3), rawValue);
    }
  }
  assignObject(item.customValues);
  assignObject(item.custom_values);
  assignObject(item.customFields);
  assignObject(item.custom_fields);
  assignEntries(item.customFields);
  assignEntries(item.custom_fields);
  return out;
}
export {
  extractCustomFieldEntries
};
//# sourceMappingURL=custom-fields-client.js.map
