import { isEmpty as i, isArray as u } from "lodash-unified";
import { formatterMap as l } from "./formatter/index.mjs";
function y(e, r) {
  const t = l[r.valueType];
  return t ? t(e, r.extraProps || {}) : e.value;
}
function p(e, r) {
  if (r.isShowEmptyPlaceholder === !1)
    return !1;
  switch (r.valueType) {
    case "text":
    case "number":
    case "dateRange":
    case "date":
      return e == null || e === "";
    case "array":
    case "attachment":
      return i(e);
    default:
      return !e;
  }
}
function g(e = {}, r) {
  return r.fromGlobal ? {
    ...e,
    downloadFile(t, n) {
      return r.fromGlobal?.([{ fileName: n, objectName: t }]);
    }
  } : !e?.downloadFile && r.fromConfig ? {
    ...e,
    downloadFile: r.fromConfig
  } : e;
}
function k(e, r = {}, t) {
  const n = r;
  return e?.forEach((f) => {
    const a = c(f), o = s(f, t);
    a && n[a] === void 0 && o && (n[a] = o.default);
  }), n;
}
function s(e, r) {
  if (e.valueType === "empty") return;
  const t = e.mask !== void 0 ? e.mask : r;
  if (!t) return;
  const n = {
    default: !1,
    hideIcon: !1,
    renderMask() {
      return "****";
    }
  };
  return t === !0 ? n : {
    ...n,
    ...t
  };
}
function c(e) {
  return u(e.field) ? e.field.join(".") : e.field;
}
export {
  k as genDefaultMaskStatus,
  s as getMaskConfigBySchema,
  c as getSchemaKey,
  p as isEmptyWithType,
  g as mixinsAttachmentExtraProps,
  y as transformValue
};
