import { defineComponent as N, useSlots as T, createVNode as n, createTextVNode as D, Fragment as V, shallowRef as w, watch as E, openBlock as k, createElementBlock as A, normalizeStyle as B, normalizeClass as I, unref as s, mergeProps as R } from "vue";
import { Descriptions as j } from "@aplus-frontend/antdv";
import { get as f } from "lodash-unified";
import "../../config-provider/index.mjs";
import "./help-message/index.vue.mjs";
import { mixinsAttachmentExtraProps as z, transformValue as F, isEmptyWithType as G } from "./helper.mjs";
import M from "./style/index.mjs";
import { useGlobalConfig as c } from "../../config-provider/hooks/use-global-config.mjs";
import { useNamespace as L } from "../../config-provider/hooks/use-namespace.mjs";
import O from "./help-message/index.vue2.mjs";
const _ = /* @__PURE__ */ N({
  name: "ApDescriptions",
  __name: "ap-descriptions",
  props: {
    descriptionsProps: {},
    schemas: {},
    dataSource: {},
    style: {
      type: [Boolean, null, String, Object, Array]
    },
    className: {}
  },
  setup(l) {
    const o = l, d = c("apDescriptions"), y = c("downloadCenterTriggerConfig"), {
      b: m,
      be: i
    } = L("ap-descriptions"), b = M("ap-descriptions"), g = T(), S = (e = {}) => {
      let r = "";
      return o.descriptionsProps?.layout === "vertical" && (r = "start"), {
        justifyContent: r,
        ...e
      };
    }, a = (e) => {
      const r = f(o.dataSource, e.field);
      if (e.customRender)
        return e.customRender(o.dataSource);
      e.valueType === "attachment" && (e.extraProps = z(e.extraProps, {
        fromConfig: d.value?.downloadFile,
        fromGlobal: y.value?.trigger
      }));
      const t = e.format ? e.format(r, o.dataSource || {}) : r;
      return F({
        value: t,
        record: o.dataSource
      }, e);
    }, v = (e) => e.valueType === "text" && !!e.extraProps?.ellipsis, x = (e, r) => {
      if (e.visible != null) {
        if (typeof e.visible == "boolean")
          return e.visible;
        if (typeof e.visible == "function")
          return e.visible({
            record: r || {},
            schema: e
          });
      }
      return !0;
    }, C = (e, r, t) => e.valueType === "empty" ? null : G(f(t, e.field), e) ? n("span", null, [D("--")]) : e.contentSlotName ? g?.[e.contentSlotName]?.({
      index: r,
      record: t,
      item: a(e)
    }) : n(V, null, [e.prefix, a(e), e.suffix && n("span", {
      class: i("content", "suffix")
    }, [e.suffix])]), P = (e = [], r) => e.filter((t) => x(t, r)).map((t, u) => ({
      label: t.label && n(O, {
        helpMessage: t.helpMessage,
        label: t.label
      }, null),
      span: t.span,
      style: t.style,
      contentStyle: t.contentStyle,
      labelStyle: t.labelStyle,
      key: t.field?.toString() || "empty" + u,
      class: v(t) ? i("item", "ellipsis") : "",
      children: C(t, u, r)
    })), p = w([]);
    return E([() => o.schemas, () => o.dataSource], () => {
      p.value = P(o.schemas, o.dataSource);
    }, {
      immediate: !0,
      deep: !0
    }), (e, r) => (k(), A("div", {
      class: I([l.className, s(m)(), s(b)]),
      style: B(l.style)
    }, [n(s(j), R(l.descriptionsProps, {
      "label-style": S({
        ...l.descriptionsProps?.labelStyle || {}
      }),
      items: p.value
    }), null, 16, ["label-style", "items"])], 6));
  }
});
export {
  _ as default
};
