import { merge } from "@tachybase/schema";
import { useStyleRegister } from "@ant-design/cssinjs";
import { useConfig, usePrefixCls, useToken } from "./hooks/index.mjs";
const genCommonStyle = (token, componentPrefixCls)=>{
    const { fontFamily, fontSize } = token;
    const rootPrefixSelector = '[class^="'.concat(componentPrefixCls, '"], [class*=" ').concat(componentPrefixCls, '"]');
    return {
        [rootPrefixSelector]: {
            fontFamily,
            fontSize,
            boxSizing: 'border-box',
            '&::before, &::after': {
                boxSizing: 'border-box'
            },
            [rootPrefixSelector]: {
                boxSizing: 'border-box',
                '&::before, &::after': {
                    boxSizing: 'border-box'
                }
            }
        }
    };
};
const genStyleHook = (component, styleFn)=>(props)=>{
        const { theme, token, hashId } = useToken();
        const { getPrefixCls, iconPrefixCls } = useConfig();
        const prefixCls = usePrefixCls(component);
        const rootPrefixCls = getPrefixCls();
        const wrapSSR = useStyleRegister({
            theme: theme,
            token,
            hashId,
            path: [
                'formily-antd',
                component,
                prefixCls,
                iconPrefixCls
            ]
        }, ()=>{
            const componentCls = ".".concat(prefixCls);
            const mergedToken = merge(token, {
                componentCls,
                prefixCls,
                iconCls: ".".concat(iconPrefixCls),
                antCls: ".".concat(rootPrefixCls)
            });
            const styleInterpolation = styleFn(mergedToken, props, {
                hashId,
                prefixCls,
                rootPrefixCls,
                iconPrefixCls
            });
            return [
                genCommonStyle(token, prefixCls),
                styleInterpolation
            ];
        });
        return {
            wrapSSR,
            hashId,
            componentCls: prefixCls,
            rootPrefixCls
        };
    };
export { genCommonStyle, genStyleHook };
