'use strict';

Object.defineProperty(exports, '__esModule', { value: true });

var vue = require('vue');
require('../../../components/config-provider/src/context/index.cjs');
require('../../cssinjs/index.cjs');
var index$1 = require('../../style/index.cjs');
var internal = require('../internal.cjs');
var statistic = require('./statistic.cjs');
var context = require('../../../components/config-provider/src/context/context.cjs');
var index = require('../../cssinjs/hooks/useStyleRegister/index.cjs');

function genComponentStyleHook(component, styleFn, getDefaultToken) {
  return (_prefixCls) => {
    const prefixCls = vue.computed(() => _prefixCls == null ? void 0 : _prefixCls.value);
    const [theme, token, hashId] = internal.useToken();
    const { getPrefixCls, iconPrefixCls } = context.useConfigContextInject();
    const rootPrefixCls = vue.computed(() => getPrefixCls());
    const sharedInfo = vue.computed(() => {
      return {
        theme: theme.value,
        token: token.value,
        hashId: hashId.value,
        path: ["Shared", rootPrefixCls.value]
      };
    });
    index.default(sharedInfo, () => [
      {
        // Link
        "&": index$1.genLinkStyle(token.value)
      }
    ]);
    const componentInfo = vue.computed(() => {
      return {
        theme: theme.value,
        token: token.value,
        hashId: hashId.value,
        path: [component, prefixCls.value, iconPrefixCls.value]
      };
    });
    return [
      index.default(componentInfo, () => {
        const { token: proxyToken, flush } = statistic.default(token.value);
        const defaultComponentToken = typeof getDefaultToken === "function" ? getDefaultToken(proxyToken) : getDefaultToken;
        const mergedComponentToken = { ...defaultComponentToken, ...token.value[component] };
        const componentCls = `.${prefixCls.value}`;
        const mergedToken = statistic.merge(
          proxyToken,
          {
            componentCls,
            prefixCls: prefixCls.value,
            iconCls: `.${iconPrefixCls.value}`,
            antCls: `.${rootPrefixCls.value}`
          },
          mergedComponentToken
        );
        const styleInterpolation = styleFn(mergedToken, {
          hashId: hashId.value,
          prefixCls: prefixCls.value,
          rootPrefixCls: rootPrefixCls.value,
          iconPrefixCls: iconPrefixCls.value,
          overrideComponentToken: token.value[component]
        });
        flush(component, mergedComponentToken);
        return [index$1.genCommonStyle(token.value, prefixCls.value), styleInterpolation];
      }),
      hashId
    ];
  };
}

exports.default = genComponentStyleHook;
//# sourceMappingURL=genComponentStyleHook.cjs.map
