import { j as r } from "../../node_modules/react/jsx-runtime.mjs";
import P, { useMemo as y } from "react";
import "./index.less.mjs";
import w from "../BitzPageHeader/index.mjs";
import N from "../../node_modules/classnames/index.mjs";
import C from "../../node_modules/antd/es/spin/index.mjs";
import H from "../../node_modules/antd/es/watermark/index.mjs";
import B from "../../node_modules/antd/es/affix/index.mjs";
import R from "../../node_modules/antd/es/tabs/index.mjs";
function S(e) {
  return typeof e == "object" ? e : { spinning: e };
}
const z = ({ tabList: e, tabActiveKey: t, onTabChange: a, hashId: n, tabBarExtraContent: d, tabProps: u, prefixedClassName: x }) => Array.isArray(e) || d ? r.jsx(R, {
  className: `${x}-tabs ${n}`.trim(),
  activeKey: t,
  onChange: (s) => {
    a && a(s);
  },
  tabBarExtraContent: d,
  // @ts-ignore
  items: e == null ? void 0 : e.map((s, m) => {
    var f;
    return {
      label: s.tab,
      ...s,
      key: ((f = s.key) == null ? void 0 : f.toString()) || (m == null ? void 0 : m.toString())
    };
  }),
  ...u,
  children: e == null ? void 0 : e.map((s, m) => r.jsx(R.TabPane, { tab: s.tab, ...s }, s.key || m))
}) : null, M = (e, t, a, n) => !e && !t ? null : r.jsx("div", { className: `${a}-detail ${n}`.trim(), children: r.jsx("div", { className: `${a}-main ${n}`.trim(), children: r.jsxs("div", { className: `${a}-row ${n}`.trim(), children: [e && r.jsx("div", { className: `${a}-content ${n}`.trim(), children: e }), t && r.jsx("div", { className: `${a}-extraContent ${n}`.trim(), children: t })] }) }) }), A = (e) => {
  var j;
  const { title: t, content: a, pageHeaderRender: n, header: d, prefixedClassName: u, extraContent: x, childrenContentStyle: s, style: m, prefixCls: f, hashId: p, value: l, breadcrumbRender: i, ...b } = e, h = () => {
    if (i)
      return i;
  };
  if (n === !1)
    return null;
  if (n)
    return r.jsxs(r.Fragment, { children: [" ", n({ ...e, ...l })] });
  let $ = t;
  !t && t !== !1 && ($ = l.title);
  const g = {
    ...l,
    title: $,
    ...b,
    footer: z({
      ...b,
      hashId: p,
      breadcrumbRender: i,
      prefixedClassName: u
    }),
    ...d
  }, { breadcrumb: o } = g, v = (!o || !(o != null && o.itemRender) && !((j = o == null ? void 0 : o.items) != null && j.length)) && !i;
  return [
    "title",
    "subTitle",
    "extra",
    "tags",
    "footer",
    "avatar",
    "backIcon"
  ].every((c) => !g[c]) && v && !a && !x ? null : r.jsx(w, { ...g, className: `${u}-warp-page-header ${p}`.trim(), breadcrumb: i === !1 ? void 0 : { ...g.breadcrumb, ...l.breadcrumbProps }, breadcrumbRender: h(), prefixCls: f, children: (d == null ? void 0 : d.children) || M(a, x, u, p) });
}, G = (e) => {
  var j;
  const t = "id_asd123", {
    children: a,
    loading: n = !1,
    className: d,
    style: u,
    footer: x,
    affixProps: s,
    // token: propsToken,
    fixedHeader: m,
    breadcrumbRender: f,
    // footerToolBarProps,
    childrenContentStyle: p,
    ...l
  } = e, i = "bitz-page-container", b = y(() => {
    var c;
    return f == !1 ? !1 : f || ((c = l == null ? void 0 : l.header) == null ? void 0 : c.breadcrumbRender);
  }, [f, (j = l == null ? void 0 : l.header) == null ? void 0 : j.breadcrumbRender]), h = A({
    ...l,
    breadcrumbRender: b,
    ghost: !0,
    hashId: t,
    prefixCls: void 0,
    prefixedClassName: i,
    value: {}
  }), $ = y(() => {
    if (P.isValidElement(n))
      return n;
    if (typeof n == "boolean" && !n)
      return null;
    const c = S(n);
    return c.spinning ? r.jsx("div", { style: { paddingBlockStart: 100, textAlign: "center" }, children: r.jsx(C, { size: "large", ...c }) }) : null;
  }, [n]), g = y(() => a ? r.jsx(r.Fragment, { children: r.jsx("div", {
    className: N(`${i}-children-container ${t}`.trim()),
    // 没有 header 存在需要给 container 加上 BlockStart，正常时间不需要
    style: {
      // paddingBlockStart: props?.header ? 0 : token?.layout?.pageContainer?.paddingBlockPageContainerContent,
      ...p
    },
    children: a
  }) }) : null, [a, i, p, t]), o = y(() => {
    const c = $ || g;
    if (e.waterMarkProps) {
      const k = {
        // ...value.waterMarkProps,
        ...e.waterMarkProps
      };
      return r.jsx(H, { ...k, children: c });
    }
    return c;
  }, [e.waterMarkProps, $, g]), v = N(i, t, d, {
    [`${i}-with-footer`]: x,
    [`${i}-with-affix`]: m && h
    // [`${basePageContainer}-stylish`]: !!restProps.stylish,
  });
  return r.jsx("div", { className: "BitzPageContainerBlock", children: r.jsxs("div", { style: u, className: v, children: [m && h ? (
    // 在 hasHeader 且 fixedHeader 的情况下，才需要设置高度
    r.jsx(B, { offsetTop: 1, ...s, className: `${i}-affix ${t}`.trim(), children: r.jsx("div", { className: `${i}-warp ${t}`.trim(), children: h }) })
  ) : h, o && o] }) });
};
export {
  G as default
};
