import { defineComponent as x, useTemplateRef as y, ref as v, shallowRef as G, onMounted as R, openBlock as b, createBlock as P, unref as S, normalizeProps as k, guardReactiveProps as A, withCtx as M, createElementVNode as T, normalizeStyle as _, renderSlot as $ } from "vue";
import { isNil as f } from "lodash-unified";
import { APConfigProvider as z } from "../../config-provider/index.mjs";
import { useGlobalConfig as B } from "../../config-provider/hooks/use-global-config.mjs";
import { globalConfigCached as h } from "../../config-provider/config-provider.mjs";
const U = /* @__PURE__ */ x({
  __name: "index",
  props: {
    minHeight: { default: 150 },
    maxHeight: { default: "unset" }
  },
  emits: ["heightChange"],
  setup(n, { emit: u }) {
    const m = B(), d = h.value.agGrid, a = n, p = u, r = y("wrapperContainer"), l = v(s(a.minHeight)), g = (e) => {
      const o = r.value?.clientHeight, t = r.value?.querySelector(
        ".ag-body.ag-layout-normal"
      )?.clientHeight;
      let i = 0;
      !o || !t ? i = 0 : i = o - t;
      const w = e + i, c = Math.max(w, a.minHeight);
      l.value = `${c}px`, p("heightChange", c);
    }, H = (e) => {
      if (!e) return;
      const o = e.getDisplayedRowCount();
      if (o > 0) {
        const t = e.getDisplayedRowAtIndex(o - 1);
        if (t && !f(t.rowTop) && !f(t.rowHeight)) {
          const i = t.rowTop + t.rowHeight;
          g(i);
        }
      } else
        g(150);
    }, C = G({
      agGrid: {
        ...m.value?.agGrid,
        onModelUpdated: H
      }
    });
    R(() => {
      h.value.agGrid = d;
    });
    function s(e) {
      return typeof e == "number" && e ? `${e}px` : e.toString();
    }
    return (e, o) => (b(), P(S(z), k(A(C.value)), {
      default: M(() => [
        T("div", {
          ref_key: "wrapperContainer",
          ref: r,
          style: _({
            height: l.value,
            maxHeight: n.maxHeight && s(n.maxHeight)
          })
        }, [
          $(e.$slots, "default")
        ], 4)
      ]),
      _: 3
    }, 16));
  }
});
export {
  U as default
};
