import { j as t } from "../../node_modules/react/jsx-runtime.mjs";
import { useMemo as m } from "react";
import A from "../../node_modules/rc-resize-observer/es/index.mjs";
import M from "./QueryFilterContent.mjs";
import O from "../../hooks/useMergedState.mjs";
import P from "./QueryFilterMobile.mjs";
import x from "../../node_modules/antd/es/form/index.mjs";
import B from "../../node_modules/lodash-es/isArray.mjs";
import b from "../../node_modules/antd/es/grid/col.mjs";
import E from "../../node_modules/antd/es/grid/row.mjs";
const G = {
  xs: 513,
  sm: 513,
  md: 785,
  lg: 992,
  xl: 1057,
  xxl: 1 / 0
}, g = {
  vertical: [
    // [breakpoint, cols, layout]
    [513, 1, "vertical"],
    [785, 2, "vertical"],
    [1057, 3, "vertical"],
    [1 / 0, 4, "vertical"]
  ],
  default: [
    [513, 1, "vertical"],
    [701, 2, "vertical"],
    [1062, 3, "horizontal"],
    [1352, 3, "horizontal"],
    [1 / 0, 4, "horizontal"]
  ]
}, Q = (s, d, r) => {
  if (r && typeof r == "number")
    return {
      span: r,
      layout: s
    };
  const l = ((r ? ["xs", "sm", "md", "lg", "xl", "xxl"].map((e) => [G[e], 24 / r[e], "horizontal"]) : g[s || "default"]) || g.default).find((e) => d < e[0] + 16);
  return {
    span: 24 / l[1],
    layout: l[2]
  };
};
var z;
const H = (z = document == null ? void 0 : document.body) == null ? void 0 : z.clientWidth, V = (s) => {
  const { collapsed: d, onCollapse: r, defaultCollapsed: v = !0, searchGutter: l = 24, children: e, style: o, layout: y, span: C, defaultColsNumber: u, labelWidth: n = "80", showHiddenNum: j = !1, ignoreRules: F, split: N, preserve: f = !0, onReset: c, onFinish: w } = s, [a] = x.useForm(), [p, S] = O(() => typeof (o == null ? void 0 : o.width) == "number" ? o == null ? void 0 : o.width : H), i = m(() => Q(y, p + 16, C), [y, p, C]), I = m(() => u !== void 0 ? u - 1 : Math.max(1, 24 / i.span - 1), [u, i.span]), W = m(() => {
    if (n && i.layout !== "vertical" && n !== "auto")
      return {
        labelCol: {
          flex: `0 0 ${n}px`
        },
        wrapperCol: {
          style: {
            maxWidth: `calc(100% - ${n}px)`
          }
        },
        style: {
          flexWrap: "nowrap"
        }
      };
  }, [i.layout, n]), R = m(() => B(e) ? e : [e], [e]);
  return t.jsx(A, { onResize: (h) => {
    p !== h.width && h.width > 17 && S(h.width);
  }, children: t.jsxs(E, { children: [t.jsx(b, { md: 24, sm: 0, xs: 0, children: t.jsx(x, { preserve: f, form: a, layout: i.layout, ...W, children: t.jsx(M, { onFinish: w, defaultCollapsed: v, collapsed: d, onCollapse: r, searchGutter: l, spanSize: i, items: R, split: N, ignoreRules: F, showLength: I, showHiddenNum: j, form: a, baseClassName: "bitz", preserve: f, onReset: c }) }) }), t.jsx(b, { md: 0, sm: 24, xs: 24, children: t.jsx(x, { onReset: c, preserve: f, form: a, layout: "vertical", children: t.jsx(P, { onFinish: w, form: a, items: R, onReset: c }) }) })] }) }, "resize-observer");
};
export {
  V as default
};
