import { isVNode as b, createVNode as o, mergeProps as C, createTextVNode as R } from "vue";
import { QuestionCircleOutlined as I } from "@ant-design/icons-vue";
import { Typography as h, Tooltip as S } from "@aplus-frontend/antdv";
import { isFunction as c, isArray as N, isBoolean as x, omit as F, isString as q } from "lodash-unified";
import w from "scroll-into-view-if-needed";
import { getValueStr as P } from "../ap-field/number/helper.mjs";
import "../ap-form/index.mjs";
import { apTableFormItemMap as V, noRenderAsFormItemValueList as v, apTableRenderItemMap as A } from "../ap-table/constants.mjs";
import { objectToString as j, getTableRenderType as M } from "../ap-table/utils.mjs";
import "../utils/index.mjs";
import { isDef as O } from "../utils/is.mjs";
import y from "../ap-form/item/index.vue.mjs";
function g(e) {
  return typeof e == "function" || Object.prototype.toString.call(e) === "[object Object]" && !b(e);
}
function W(e) {
  return V[e];
}
function _(e) {
  if (e.markRequired)
    return !0;
  if (!e.fieldProps)
    return !1;
  const t = c(e.fieldProps) ? e.fieldProps({}) : e.fieldProps;
  return O(t.required) ? t.required : (N(t.rules) ? t.rules : t.rules ? [t.rules] : []).some((i) => i.required);
}
function k(e, t) {
  if (e.valueType === "text" || e.valueType === "textArea")
    return t || "--";
  if (e.valueType === "number") {
    const r = e.fieldProps ? c(e.fieldProps) ? e.fieldProps({}) : e.fieldProps : {};
    return P(t, r) || "--";
  }
  return j(t);
}
function $(e, t = document.body, r = {}) {
  const i = t.querySelectorAll("tr.ant-table-row")[e];
  i && w(i, {
    scrollMode: "if-needed",
    block: "nearest",
    behavior: "smooth",
    ...r
  });
}
function D(e, t, r) {
  return v.includes(e.valueType) ? r : e.copyable || e.ellipsis ? o(h.Paragraph, {
    copyable: e.copyable ? {
      text: t,
      tooltip: !1
    } : !1,
    ellipsis: e.ellipsis ? x(e.ellipsis) ? {
      tooltip: t
    } : {
      ...e.ellipsis,
      tooltip: t
    } : !1,
    content: e.ellipsis ? k(e, t) : r
  }, null) : r;
}
function ee(e, t, r, i, f, s) {
  if (t) {
    if (e.customRenderFormItem) {
      const p = e.customRenderFormItem(e, r.field, t, f);
      return o(y, F(r, ["field"]), g(p) ? p : {
        default: () => [p]
      });
    }
    const a = W(e.valueType);
    if (a)
      return o(a, r, null);
    const l = s?.[e.valueType]?.renderFormItem?.(r.field);
    return l ? o(y, r, g(l) ? l : {
      default: () => [l]
    }) : null;
  }
  let n;
  const u = M(e), d = A[u];
  return d ? n = o(d, C(r.field, {
    mode: "read"
  }), null) : n = s?.[u]?.render?.(i, f, r.field), n ? D(e, i, n) : null;
}
function te(e, t, r, i, f) {
  const s = i?.({
    title: e.title,
    column: e
  }), n = s?.filter((T) => T.type !== /* @__PURE__ */ Symbol.for("v-cmt")) || [];
  if (s && n.length > 0)
    return s;
  const d = _(e), m = q(e.title) ? {
    class: t,
    title: e.title
  } : {}, l = o("div", m, [d ? o("span", {
    class: r
  }, [R("*")]) : null, e.title]), p = e.tooltip ? c(e.tooltip) ? e.tooltip(e) : e.tooltip : null;
  return p ? o("span", {
    style: {
      display: "inline-flex",
      alignItems: "center",
      maxWidth: "100%"
    }
  }, [l, o(S, {
    title: p,
    placement: "bottom"
  }, {
    default: () => [o(I, {
      style: {
        padding: "4px",
        color: f,
        verticalAlign: "middle"
      }
    }, null)]
  })]) : l;
}
export {
  _ as getColumnIsRequired,
  W as getEditableComponent,
  te as getEditableTableTitle,
  ee as getFinalNode,
  k as getRawDisplayValue,
  $ as scrollToRowIndex
};
