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