"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.TextPrimitive = exports.textVariants = exports.Span = exports.Code = exports.Label = exports.Caption = exports.Body = exports.Subtitle = exports.Heading = exports.Text = void 0;
const tslib_1 = require("tslib");
const jsx_runtime_1 = require("react/jsx-runtime");
const class_variance_authority_1 = require("class-variance-authority");
const react_1 = tslib_1.__importStar(require("react"));
const theme_1 = require("../../lib/theme/theme");
const tokens_1 = require("../../lib/theme/tokens");
const zero = tslib_1.__importStar(require("../../ui"));
const text_1 = require("./primitives/text");
Object.defineProperty(exports, "TextPrimitive", { enumerable: true, get: function () { return text_1.TextPrimitive; } });
// Text variants using class-variance-authority pattern
const textVariants = (0, class_variance_authority_1.cva)("", {
    variants: {
        variant: {
            h1: "h1",
            h2: "h2",
            h3: "h3",
            h4: "h4",
            h5: "h5",
            h6: "h6",
            subtitle1: "subtitle1",
            subtitle2: "subtitle2",
            body1: "body1",
            body2: "body2",
            caption: "caption",
            overline: "overline",
        },
        size: {
            xs: "xs",
            sm: "sm",
            base: "base",
            lg: "lg",
            xl: "xl",
            "2xl": "2xl",
            "3xl": "3xl",
            "4xl": "4xl",
        },
        weight: {
            thin: "thin",
            light: "light",
            normal: "normal",
            medium: "medium",
            semibold: "semibold",
            bold: "bold",
            extrabold: "extrabold",
            black: "black",
        },
        color: {
            default: "default",
            muted: "muted",
            primary: "primary",
            secondary: "secondary",
            destructive: "destructive",
            success: "success",
            warning: "warning",
        },
    },
    defaultVariants: {
        variant: "body1",
        size: "base",
        weight: "normal",
        color: "default",
    },
});
exports.textVariants = textVariants;
exports.Text = (0, react_1.forwardRef)(({ variant = undefined, size = undefined, weight = undefined, color = undefined, muted = false, bold = false, italic = false, underline = false, strikethrough = false, uppercase = false, lowercase = false, capitalize = false, center = false, right = false, justify = false, customColor, style, children, ...props }, ref) => {
    const { zero: zt } = (0, theme_1.useTheme)();
    // Override props based on convenience props
    const finalColor = customColor ? customColor : muted ? "muted" : color;
    const finalTransform = uppercase
        ? "uppercase"
        : lowercase
            ? "lowercase"
            : capitalize
                ? "capitalize"
                : "none";
    const finalDecoration = underline && strikethrough
        ? "underline line-through"
        : underline
            ? "underline"
            : strikethrough
                ? "line-through"
                : "none";
    const finalAlign = center
        ? "center"
        : right
            ? "right"
            : justify
                ? "justify"
                : "left";
    // Get variant-specific styles using theme.zero
    const variantStyle = react_1.default.useMemo(() => {
        switch (variant) {
            case "h1":
                return zero.my[6];
            case "h2":
            case "h3":
                return zero.my[4];
            case "h4":
            case "h5":
            case "h6":
            case "subtitle1":
                return zero.my[2];
            case "subtitle2":
            case "caption":
            case "overline":
                return zero.my[1];
            case "body1":
                return zero.my[4];
            case "body2":
                return zero.my[2];
            default:
                return {};
        }
    }, [variant, zt]);
    const styleArr = (Array.isArray(style) ? style : [style || undefined]).filter((s) => s !== undefined);
    const finalWeight = bold ? "bold" : (weight ?? undefined);
    return ((0, jsx_runtime_1.jsx)(text_1.TextPrimitive.Root, { ref: ref, variant: variant || "body1", size: size || "base", weight: finalWeight, color: finalColor || "default", align: finalAlign, transform: finalTransform, decoration: finalDecoration, italic: italic, style: [variantStyle, ...styleArr], ...props, children: children }));
});
exports.Text.displayName = "Text";
// Convenience components for common text elements
exports.Heading = (0, react_1.forwardRef)(({ level = 1, ...props }, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: `h${level}`, ...props })));
exports.Heading.displayName = "Heading";
exports.Subtitle = (0, react_1.forwardRef)(({ level = 1, ...props }, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: level === 1 ? "subtitle1" : "subtitle2", ...props })));
exports.Subtitle.displayName = "Subtitle";
exports.Body = (0, react_1.forwardRef)(({ level = 1, ...props }, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: level === 1 ? "body1" : "body2", ...props })));
exports.Body.displayName = "Body";
exports.Caption = (0, react_1.forwardRef)((props, ref) => (0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: "caption", ...props }));
exports.Caption.displayName = "Caption";
exports.Label = (0, react_1.forwardRef)((props, ref) => ((0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, variant: "subtitle1", weight: "medium", ...props })));
exports.Label.displayName = "Label";
exports.Code = (0, react_1.forwardRef)(({ style, ...props }, ref) => {
    const { zero: zt } = (0, theme_1.useTheme)();
    const codeStyle = react_1.default.useMemo(() => [
        {
            borderRadius: zero.borderRadius.sm,
            fontFamily: tokens_1.fontFamilies.monoRegular,
        },
    ], [zt]);
    // if style is not an array, convert it to an array
    const styleArr = (Array.isArray(style) ? style : [style || undefined]).filter((s) => s !== undefined);
    return (0, jsx_runtime_1.jsx)(exports.Text, { ref: ref, style: [...codeStyle, ...styleArr], ...props });
});
exports.Code.displayName = "Code";
// Span component for inline text styling (inherits from parent)
exports.Span = (0, react_1.forwardRef)(({ children, ...props }, ref) => ((0, jsx_runtime_1.jsx)(text_1.TextPrimitive.Span, { ref: ref, ...props, children: children })));
exports.Span.displayName = "Span";
//# sourceMappingURL=text.js.map