"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
    return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.BFUIProvider = exports.useBFUI = exports.BFUIContext = void 0;
const jsx_runtime_1 = require("react/jsx-runtime");
const react_1 = require("react");
const react_2 = require("@chakra-ui/react");
const theme_js_1 = __importDefault(require("./theme.js"));
const defaultTheme = {
    colors: {
        surface: {
            bg: '#ffffff',
            bgDark: '#1a202c'
        },
        text: {
            primary: '#1a202c',
            primaryDark: '#f7fafc',
            body: '#4a5568',
            bodyDark: '#a0aec0'
        },
        border: {
            default: '#e2e8f0',
            defaultDark: '#2d3748'
        }
    },
    spacing: {
        1: '0.25rem',
        2: '0.5rem',
        3: '0.75rem',
        4: '1rem',
        6: '1.5rem'
    },
    radii: {
        sm: '0.25rem',
        md: '0.375rem',
        lg: '0.5rem'
    },
    shadows: {
        sm: '0 1px 2px 0 rgba(0, 0, 0, 0.05)',
        md: '0 4px 6px -1px rgba(0, 0, 0, 0.1)',
        lg: '0 10px 15px -3px rgba(0, 0, 0, 0.1)'
    },
    typography: {
        fontSizes: {
            base: '1rem',
            lg: '1.125rem',
            xl: '1.25rem'
        },
        fontWeights: {
            normal: 400,
            medium: 500,
            semibold: 600,
            bold: 700
        }
    },
    transitions: {
        default: 'all 0.2s ease'
    }
};
exports.BFUIContext = (0, react_1.createContext)({
    theme: defaultTheme,
    components: {}
});
const useBFUI = () => {
    const context = (0, react_1.useContext)(exports.BFUIContext);
    if (!context) {
        throw new Error('useBFUI must be used within a BFUIProvider');
    }
    return context;
};
exports.useBFUI = useBFUI;
const BFUIProvider = ({ theme = {}, components = {}, children }) => {
    const mergedTheme = (0, react_1.useMemo)(() => ({
        ...defaultTheme,
        ...theme,
        colors: {
            ...defaultTheme.colors,
            ...theme.colors
        },
        spacing: {
            ...defaultTheme.spacing,
            ...theme.spacing
        },
        radii: {
            ...defaultTheme.radii,
            ...theme.radii
        },
        shadows: {
            ...defaultTheme.shadows,
            ...theme.shadows
        },
        typography: {
            ...defaultTheme.typography,
            ...theme.typography,
            fontSizes: {
                ...defaultTheme.typography.fontSizes,
                ...theme.typography?.fontSizes
            },
            fontWeights: {
                ...defaultTheme.typography.fontWeights,
                ...theme.typography?.fontWeights
            }
        },
        transitions: {
            ...defaultTheme.transitions,
            ...theme.transitions
        }
    }), [theme]);
    const value = (0, react_1.useMemo)(() => ({
        theme: mergedTheme,
        components
    }), [mergedTheme, components]);
    return ((0, jsx_runtime_1.jsxs)(react_2.ChakraProvider, { theme: theme_js_1.default, children: [(0, jsx_runtime_1.jsx)(react_2.CSSReset, {}), (0, jsx_runtime_1.jsx)(exports.BFUIContext.Provider, { value: value, children: children })] }));
};
exports.BFUIProvider = BFUIProvider;
//# sourceMappingURL=BFUIProvider.js.map