var __create = Object.create;
var __defProp = Object.defineProperty;
var __defProps = Object.defineProperties;
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
var __getOwnPropDescs = Object.getOwnPropertyDescriptors;
var __getOwnPropNames = Object.getOwnPropertyNames;
var __getOwnPropSymbols = Object.getOwnPropertySymbols;
var __getProtoOf = Object.getPrototypeOf;
var __hasOwnProp = Object.prototype.hasOwnProperty;
var __propIsEnum = Object.prototype.propertyIsEnumerable;
var __defNormalProp = (obj, key, value) => key in obj ? __defProp(obj, key, { enumerable: true, configurable: true, writable: true, value }) : obj[key] = value;
var __spreadValues = (a, b) => {
  for (var prop in b || (b = {}))
    if (__hasOwnProp.call(b, prop))
      __defNormalProp(a, prop, b[prop]);
  if (__getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(b)) {
      if (__propIsEnum.call(b, prop))
        __defNormalProp(a, prop, b[prop]);
    }
  return a;
};
var __spreadProps = (a, b) => __defProps(a, __getOwnPropDescs(b));
var __objRest = (source, exclude) => {
  var target = {};
  for (var prop in source)
    if (__hasOwnProp.call(source, prop) && exclude.indexOf(prop) < 0)
      target[prop] = source[prop];
  if (source != null && __getOwnPropSymbols)
    for (var prop of __getOwnPropSymbols(source)) {
      if (exclude.indexOf(prop) < 0 && __propIsEnum.call(source, prop))
        target[prop] = source[prop];
    }
  return target;
};
var __export = (target, all) => {
  for (var name in all)
    __defProp(target, name, { get: all[name], enumerable: true });
};
var __copyProps = (to, from, except, desc) => {
  if (from && typeof from === "object" || typeof from === "function") {
    for (let key of __getOwnPropNames(from))
      if (!__hasOwnProp.call(to, key) && key !== except)
        __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
  }
  return to;
};
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
  // If the importer is in node compatibility mode or this is not an ESM
  // file that has been converted to a CommonJS file using a Babel-
  // compatible transform (i.e. "__esModule" has not been set), then set
  // "default" to the CommonJS "module.exports" for node compatibility.
  isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
  mod
));
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
var stdin_exports = {};
__export(stdin_exports, {
  PageContainer: () => PageContainer,
  ProBreadcrumb: () => ProBreadcrumb,
  ProPageHeader: () => ProPageHeader,
  pageContainerProps: () => pageContainerProps,
  pageHeaderTabConfigProps: () => pageHeaderTabConfigProps
});
module.exports = __toCommonJS(stdin_exports);
var import_vue = require("vue");
var import_pro_provider = __toESM(require("@antdv/pro-provider"));
var import_pro_utils = require("@antdv/pro-utils");
var import_ant_design_vue = require("ant-design-vue");
var import_Breadcrumb = require("ant-design-vue/es/breadcrumb/Breadcrumb");
var import_context = require("ant-design-vue/lib/config-provider/context");
var import_lodash_es = require("lodash-es");
var import_vue2 = require("vue");
var import_RouteContext = require("../../context/RouteContext");
var import_FooterToolbar = require("../FooterToolbar");
var import_GridContent = require("../GridContent");
var import_PageHeader = require("../PageHeader");
var import_PageLoading = require("../PageLoading");
var import_WaterMark = require("../WaterMark");
var import_style = require("./style");
var import_stylish = require("./style/stylish");
const pageHeaderTabConfigProps = {
  /** @name tabs 的列表 */
  tabList: (0, import_pro_utils.arrayType)(),
  /** @name tabActiveKey 当前选中 tab 的 key */
  tabActiveKey: (0, import_pro_utils.oneOfType)([String, Number]),
  /** @name tab 修改时触发 */
  onTabChange: (0, import_pro_utils.funcType)(),
  /** @name tab 上额外的区域 */
  tabBarExtraContent: (0, import_pro_utils.vNodeType)(),
  /** @name tabs 的其他配置 */
  tabProps: (0, import_pro_utils.objectType)(),
  /**
   * @deprecated 请使用 fixedHeader
   * @name fixHeader 固定 PageHeader 到页面顶部
   */
  fixHeader: Boolean,
  /** @name fixedHeader 固定 PageHeader 到页面顶部 */
  fixedHeader: Boolean
};
const pageContainerProps = __spreadValues(__spreadValues({
  title: (0, import_pro_utils.oneOfType)([Array, Boolean]).def(void 0),
  content: (0, import_pro_utils.vNodeType)(),
  extraContent: (0, import_pro_utils.vNodeType)(),
  prefixCls: String,
  footer: (0, import_pro_utils.arrayType)(),
  /**
   * @name token 自定义的 token
   */
  token: (0, import_pro_utils.objectType)(),
  /**
   * 与 antd 完全相同
   *
   * @name PageHeader 的配置
   */
  header: (0, import_pro_utils.objectType)(),
  /** @name pageHeaderRender 自定义 pageHeader */
  pageHeaderRender: (0, import_pro_utils.oneOfType)([Function, Boolean]).def(void 0),
  /**
   * 与 antd 完全相同
   *
   * @name affixProps 固钉的配置
   */
  affixProps: (0, import_pro_utils.objectType)(),
  /**
   * 只加载内容区域
   *
   * @name loading 是否加载
   */
  loading: (0, import_pro_utils.oneOfType)([Boolean, Object, Array]).def(false),
  /**
   * 自定义 breadcrumb,
   * @name breadcrumbRender 返回false不展示
   */
  breadcrumbRender: (0, import_pro_utils.oneOfType)([Object, Boolean]).def(void 0),
  /** @name WaterMarkProps 水印的配置 */
  waterMarkProps: (0, import_pro_utils.objectType)(),
  /** @name BreadcrumbProps 配置面包屑 */
  breadcrumb: (0, import_pro_utils.objectType)(),
  children: (0, import_pro_utils.vNodeType)(),
  stylish: (0, import_pro_utils.objectType)(),
  footerStylish: (0, import_pro_utils.objectType)(),
  footerToolBarProps: (0, import_pro_utils.objectType)()
}, pageHeaderTabConfigProps), (0, import_lodash_es.omit)(import_PageHeader.pageHeaderProps, ["title", "footer", "breadcrumbRender", "prefixCls", "children", "breadcrumb"]));
function genLoading(spinProps) {
  if (typeof spinProps === "object") return spinProps;
  return {
    spinning: spinProps
  };
}
function renderFooter({
  tabList,
  tabActiveKey,
  onTabChange,
  hashId,
  tabBarExtraContent,
  tabProps,
  prefixedClassName
}) {
  if (Array.isArray(tabList) || tabBarExtraContent) {
    return (0, import_vue.createVNode)(import_ant_design_vue.Tabs, (0, import_vue.mergeProps)({
      "class": `${prefixedClassName}-tabs ${hashId}`.trim(),
      "activeKey": tabActiveKey,
      "onChange": (key) => {
        if (onTabChange) {
          onTabChange(key);
        }
      },
      "tabBarExtraContent": tabBarExtraContent
    }, tabProps), {
      default: () => [tabList == null ? void 0 : tabList.map((item, index) => {
        return (0, import_vue.createVNode)(import_ant_design_vue.Tabs.TabPane, (0, import_vue.mergeProps)({
          "key": item.key || index,
          "tab": item.tab
        }, item), null);
      })]
    });
  }
  return null;
}
function renderPageHeader(content, extraContent, prefixedClassName, hashId) {
  if (!content && !extraContent) {
    return null;
  }
  return (0, import_vue.createVNode)("div", {
    "class": `${prefixedClassName}-detail ${hashId}`.trim()
  }, [(0, import_vue.createVNode)("div", {
    "class": `${prefixedClassName}-main ${hashId}`.trim()
  }, [(0, import_vue.createVNode)("div", {
    "class": `${prefixedClassName}-row ${hashId}`.trim()
  }, [content && (0, import_vue.createVNode)("div", {
    "class": `${prefixedClassName}-content ${hashId}`.trim()
  }, [content]), extraContent && (0, import_vue.createVNode)("div", {
    "class": `${prefixedClassName}-extraContent ${hashId}`.trim()
  }, [extraContent])])])]);
}
const ProBreadcrumb = (0, import_vue2.defineComponent)({
  name: "ProBreadcrumb",
  props: (0, import_Breadcrumb.breadcrumbProps)(),
  setup(props) {
    const {
      breadcrumb,
      breadcrumbProps: breadcrumbPropsContext
    } = import_RouteContext.RouteContext.useContext();
    return () => {
      return (0, import_vue.createVNode)("div", {
        "style": {
          height: "100%",
          display: "flex",
          alignItems: "center"
        }
      }, [(0, import_vue.createVNode)(import_ant_design_vue.Breadcrumb, (0, import_vue.mergeProps)(breadcrumb, breadcrumbPropsContext, props), null)]);
    };
  }
});
function memoRenderPageHeader(props) {
  var _b;
  const _a = props, {
    title,
    content,
    pageHeaderRender,
    header,
    prefixedClassName,
    extraContent,
    childrenContentStyle,
    style,
    prefixCls,
    hashId,
    value,
    breadcrumbRender
  } = _a, restProps = __objRest(_a, [
    "title",
    "content",
    "pageHeaderRender",
    "header",
    "prefixedClassName",
    "extraContent",
    "childrenContentStyle",
    "style",
    "prefixCls",
    "hashId",
    "value",
    "breadcrumbRender"
  ]);
  const getBreadcrumbRender = () => {
    if (!breadcrumbRender) {
      return void 0;
    }
    return breadcrumbRender;
  };
  if (pageHeaderRender === false) {
    return null;
  }
  if (pageHeaderRender) {
    return (0, import_vue.createVNode)(import_vue.Fragment, null, [" ", pageHeaderRender(props)]);
  }
  let pageHeaderTitle = title;
  if (!title && title !== false) {
    pageHeaderTitle = value.title;
  }
  const getPageHeaderProps = __spreadValues(__spreadProps(__spreadValues(__spreadProps(__spreadValues({}, value), {
    title: pageHeaderTitle
  }), restProps), {
    footer: renderFooter(__spreadProps(__spreadValues({}, restProps), {
      hashId,
      breadcrumbRender,
      prefixedClassName
    }))
  }), header);
  const {
    breadcrumb
  } = getPageHeaderProps;
  const noHasBreadCrumb = (!breadcrumb || !(breadcrumb == null ? void 0 : breadcrumb.itemRender) && !((_b = breadcrumb == null ? void 0 : breadcrumb.routes) == null ? void 0 : _b.length)) && !breadcrumbRender;
  if (["title", "subTitle", "extra", "tags", "footer", "avatar", "backIcon"].every((item) => !getPageHeaderProps[item]) && noHasBreadCrumb && !content && !extraContent) {
    return null;
  }
  return (0, import_vue.createVNode)(import_PageHeader.PageHeader, (0, import_vue.mergeProps)(getPageHeaderProps, {
    "className": `${prefixedClassName}-warp-page-header ${hashId}`.trim(),
    "breadcrumb": breadcrumbRender === false ? void 0 : __spreadValues(__spreadValues({}, getPageHeaderProps.breadcrumb), value.breadcrumbProps),
    "breadcrumbRender": getBreadcrumbRender(),
    "prefixCls": prefixCls
  }), {
    default: () => [(header == null ? void 0 : header.children) || renderPageHeader(content, extraContent, prefixedClassName, hashId)]
  });
}
const PageContainerBase = (0, import_vue2.defineComponent)({
  name: "PageContainerBase",
  inheritAttrs: false,
  props: pageContainerProps,
  slots: Object,
  setup(props, {
    slots,
    attrs
  }) {
    const value = import_RouteContext.RouteContext.useContext();
    const {
      token
    } = import_pro_provider.default.useContext();
    const {
      getPrefixCls
    } = (0, import_context.useConfigContextInject)();
    const prefixCls = props.prefixCls || getPrefixCls("pro");
    const basePageContainer = (0, import_vue2.computed)(() => `${prefixCls}-page-container`);
    const {
      wrapSSR,
      hashId
    } = (0, import_style.useStyle)(basePageContainer, props.token);
    const stylish = (0, import_stylish.useStylish)((0, import_vue2.computed)(() => `${basePageContainer.value}.${basePageContainer.value}-stylish`), {
      stylish: props.stylish
    });
    (0, import_vue2.onMounted)(() => {
      var _a;
      if (value && (value == null ? void 0 : value.setHasPageContainer)) {
        (_a = value.setHasPageContainer) == null ? void 0 : _a.call(value, (num) => num + 1);
      }
    });
    (0, import_vue2.onUnmounted)(() => {
      var _a;
      if (value && (value == null ? void 0 : value.setHasPageContainer)) {
        (_a = value.setHasPageContainer) == null ? void 0 : _a.call(value, (num) => num - 1);
      }
    });
    const memoBreadcrumbRender = (0, import_vue2.computed)(() => {
      var _a;
      if (props.breadcrumbRender === false) return false;
      return props.breadcrumbRender || ((_a = props == null ? void 0 : props.header) == null ? void 0 : _a.breadcrumbRender);
    });
    return () => {
      var _a, _b, _c, _e, _f;
      const _d = props, {
        children = (_a = slots.default) == null ? void 0 : _a.call(slots),
        loading = (_b = slots.loading) == null ? void 0 : _b.call(slots),
        className,
        footer = (_c = slots.footer) == null ? void 0 : _c.call(slots),
        affixProps,
        token: propsToken,
        fixedHeader,
        breadcrumbRender,
        footerToolBarProps,
        childrenContentStyle
      } = _d, restProps = __objRest(_d, [
        "children",
        "loading",
        "className",
        "footer",
        "affixProps",
        "token",
        "fixedHeader",
        "breadcrumbRender",
        "footerToolBarProps",
        "childrenContentStyle"
      ]);
      const pageHeaderDom = memoRenderPageHeader(__spreadProps(__spreadValues({}, (0, import_pro_utils.omitUndefined)(restProps)), {
        breadcrumbRender: memoBreadcrumbRender.value,
        ghost: true,
        hashId: hashId.value,
        prefixCls: void 0,
        prefixedClassName: basePageContainer.value,
        value
      }));
      const renderLoadingDom = () => {
        if ((0, import_pro_utils.isValidElement)(props.loading)) {
          return props.loading;
        }
        if (typeof props.loading === "boolean" && !props.loading) {
          return null;
        }
        const spinProps = genLoading(props.loading);
        return spinProps.spinning ? (0, import_vue.createVNode)(import_PageLoading.PageLoading, spinProps, null) : null;
      };
      const loadingDom = renderLoadingDom();
      const content = children ? (0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)("div", {
        "class": (0, import_pro_utils.classNames)(hashId.value, `${basePageContainer.value}-children-container`, {
          [`${basePageContainer.value}-children-container-no-header`]: !pageHeaderDom
        }),
        "style": props.childrenContentStyle
      }, [children])]) : null;
      const renderContentDom = () => {
        const dom = loadingDom || content;
        if (props.waterMarkProps || value.waterMarkProps) {
          const getWaterMarkProps = __spreadValues(__spreadValues({}, value.waterMarkProps), props.waterMarkProps);
          return (0, import_vue.createVNode)(import_WaterMark.WaterMark, getWaterMarkProps, {
            default: () => [dom]
          });
        }
        return dom;
      };
      const contentDom = renderContentDom();
      const containerClassName = (0, import_pro_utils.classNames)(basePageContainer.value, hashId.value, className, {
        [`${basePageContainer.value}-with-footer`]: footer,
        [`${basePageContainer.value}-with-affix`]: fixedHeader && pageHeaderDom,
        [`${basePageContainer.value}-stylish`]: !!restProps.stylish
      });
      return wrapSSR(stylish.wrapSSR((0, import_vue.createVNode)(import_vue.Fragment, null, [(0, import_vue.createVNode)("div", {
        "style": attrs.style,
        "class": containerClassName
      }, [fixedHeader && pageHeaderDom ? (
        // 在 hasHeader 且 fixedHeader 的情况下，才需要设置高度
        (0, import_vue.createVNode)(import_ant_design_vue.Affix, (0, import_vue.mergeProps)({
          "offsetTop": value.hasHeader && fixedHeader ? (_f = (_e = token == null ? void 0 : token.layout) == null ? void 0 : _e.header) == null ? void 0 : _f.heightLayoutHeader : 1
        }, (0, import_lodash_es.omit)(affixProps, ["target"]), {
          "target": (affixProps == null ? void 0 : affixProps.target) || (() => window),
          "class": `${basePageContainer.value}-affix ${hashId.value}`.trim()
        }), {
          default: () => [(0, import_vue.createVNode)("div", {
            "class": `${basePageContainer.value}-warp ${hashId.value}`.trim()
          }, [pageHeaderDom])]
        })
      ) : pageHeaderDom, contentDom && (0, import_vue.createVNode)(import_GridContent.GridContent, null, {
        default: () => [contentDom]
      })]), footer && (0, import_vue.createVNode)(import_FooterToolbar.FooterToolbar, (0, import_vue.mergeProps)({
        "stylish": restProps.footerStylish,
        "prefixCls": prefixCls
      }, footerToolBarProps), {
        default: () => [footer]
      })])));
    };
  }
});
const PageContainer = (0, import_vue2.defineComponent)({
  name: "PageContainer",
  props: pageContainerProps,
  setup(props, {
    slots
  }) {
    return () => (0, import_vue.createVNode)(import_pro_provider.ProConfigProvider, {
      "needDeps": true
    }, {
      default: () => [(0, import_vue.createVNode)(PageContainerBase, props, slots)]
    });
  }
});
const ProPageHeader = (0, import_vue2.defineComponent)({
  name: "ProPageHeader",
  inheritAttrs: false,
  props: __spreadProps(__spreadValues({}, pageContainerProps), {
    prefixedClassName: (0, import_pro_utils.stringType)().isRequired
  }),
  setup(props, {
    attrs
  }) {
    const value = import_RouteContext.RouteContext.useContext();
    return () => memoRenderPageHeader(__spreadProps(__spreadValues({}, props), {
      hashId: "",
      style: attrs.style,
      value
    }));
  }
});
