'use strict';

var vue = require('vue');
var useConfigInject = require('../../config-provider/src/hooks/useConfigInject.cjs');
var index = require('../style/index.cjs');
var props = require('./props.cjs');
var injectionKey = require('./injectionKey.cjs');

function generator({
  suffixCls,
  tagName,
  name
}) {
  return (BasicComponent) => {
    const Adapter = /* @__PURE__ */ vue.defineComponent({
      compatConfig: {
        MODE: 3
      },
      name,
      props: props.layoutProps(),
      setup(props, {
        slots
      }) {
        const {
          prefixCls
        } = useConfigInject.default(suffixCls, props);
        return () => {
          const basicComponentProps = {
            ...props,
            prefixCls: prefixCls.value,
            tagName
          };
          return vue.createVNode(BasicComponent, basicComponentProps, slots);
        };
      }
    });
    return Adapter;
  };
}
const Basic = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  props: props.layoutProps(),
  setup(props, {
    slots
  }) {
    return () => vue.createVNode(props.tagName, {
      class: props.prefixCls
    }, slots);
  }
});
const BasicLayout = /* @__PURE__ */ vue.defineComponent({
  compatConfig: {
    MODE: 3
  },
  inheritAttrs: false,
  props: props.layoutProps(),
  setup(props, {
    slots,
    attrs
  }) {
    const {
      prefixCls,
      direction
    } = useConfigInject.default("", props);
    const [wrapSSR, hashId] = index.default(prefixCls);
    const siders = vue.ref([]);
    const siderHookProvider = {
      addSider: (id) => {
        siders.value = [...siders.value, id];
      },
      removeSider: (id) => {
        siders.value = siders.value.filter((currentId) => currentId !== id);
      }
    };
    vue.provide(injectionKey.SiderHookProviderKey, siderHookProvider);
    const divCls = vue.computed(() => {
      const {
        hasSider
      } = props;
      return {
        [hashId.value]: true,
        [`${props.prefixCls}`]: true,
        [`${props.prefixCls}-has-sider`]: typeof hasSider === "boolean" ? hasSider : siders.value.length > 0,
        [`${props.prefixCls}-rtl`]: direction.value === "rtl"
      };
    });
    return () => {
      const {
        tagName
      } = props;
      return wrapSSR(vue.createVNode(tagName, {
        ...attrs,
        class: [divCls.value, attrs.class]
      }, slots));
    };
  }
});
const Layout = generator({
  suffixCls: "layout",
  tagName: "section",
  name: "ALayout"
})(BasicLayout);
const Header = generator({
  suffixCls: "layout-header",
  tagName: "header",
  name: "ALayoutHeader"
})(Basic);
const Footer = generator({
  suffixCls: "layout-footer",
  tagName: "footer",
  name: "ALayoutFooter"
})(Basic);
const Content = generator({
  suffixCls: "layout-content",
  tagName: "main",
  name: "ALayoutContent"
})(Basic);

exports.Content = Content;
exports.Footer = Footer;
exports.Header = Header;
exports.Layout = Layout;
//# sourceMappingURL=Layout.cjs.map
