// Base validation rule configurations shared across platforms
//TODO segregation of units
const WEB_SIZES = [
    // Absolute Lengths
    "px", "cm", "mm", "Q", "in", "pc", "pt",
    // Font-Relative (Local)
    "em", "ex", "ch", "cap", "ic", "lh",
    // Font-Relative (Root)
    "rem", "rex", "rch", "rcap", "ric", "rlh",
    // Standard Viewport
    "vw", "vh", "vi", "vb", "vmin", "vmax",
    // Small Viewport (UA UI expanded)
    "svw", "svh", "svi", "svb", "svmin", "svmax",
    // Large Viewport (UA UI retracted)
    "lvw", "lvh", "lvi", "lvb", "lvmin", "lvmax",
    // Dynamic Viewport (UA UI changes)
    "dvw", "dvh", "dvi", "dvb", "dvmin", "dvmax",
    // Container Query Units
    "cqw", "cqh", "cqi", "cqb", "cqmin", "cqmax",
    // Percentage & Layout
    "%", "fr"
];
const MOBILE_SIZES = ['px', 'vh', 'vw'];
export const BASE_SUBTYPE_CONFIGS = {
    "border-style": {
        type: "allowed-list",
        native_mobile: {
            allowed: ["solid", "dashed", "dotted"]
        },
        web: {
            allowed: ["none", "hidden", "dotted", "dashed", "solid", "double", "groove", "ridge", "inset", "outset"]
        }
    },
    "border-width": {
        type: "multi-size",
        allowMultiValue: true,
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true,
            allowedKeywords: []
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true,
            allowedKeywords: ["thin", "medium", "thick"]
        }
    },
    // "box-shadow": {
    //     type: "custom",
    //     customDescription: {
    //         native_mobile: '[inset] <x> <y> [blur≥0] [spread] [color] — px or 0; color: #hex, rgb(), rgba(), named; comma-separate multiple shadows',
    //         web: '[inset] <x> <y> [blur≥0] [spread] [color] — CSS units or 0; color: #hex, rgb(), rgba(), hsl(), hsla(), named; "none" also valid'
    //     }
    // },
    // "elevation": {
    //     type: "custom",
    //     customDescription: {
    //         native_mobile: '[inset] <x> <y> [blur≥0] [spread] [color] — px or 0; color: #hex, rgb(), rgba(), named; comma-separate multiple shadows',
    //         web: '[inset] <x> <y> [blur≥0] [spread] [color] — CSS units or 0; color: #hex, rgb(), rgba(), hsl(), hsla(), named; "none" also valid'
    //     }
    // },
    "font-family": {
        type: "custom",
        customDescription: {
            native_mobile: "only one font name",
            web: "valid font family name or comma-separated font stack"
        },
        native_mobile: {
            allowMultipleFonts: false,
            separator: null,
            maxFonts: 1,
            allowGenericFallbacks: false
        },
        web: {
            allowMultipleFonts: true,
            separator: ",",
            maxFonts: null,
            allowGenericFallbacks: true
        }
    },
    "font-size": {
        type: "size",
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true,
            allowedKeywords: []
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true,
            allowedKeywords: ["xx-small", "x-small", "small", "medium", "large", "x-large", "xx-large", "smaller", "larger"]
        }
    },
    "font-weight": {
        type: "range-with-keywords",
        range: [100, 900],
        stepSize: 100,
        native_mobile: {
            keywords: ["normal", "bold"]
        },
        web: {
            keywords: ["normal", "bold", "bolder", "lighter"]
        }
    },
    "icon-size": {
        type: "size",
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true
        }
    },
    "letter-spacing": {
        type: "size",
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true,
            allowNegative: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true,
            allowedKeywords: ['normal'],
            allowNegative: true
        }
    },
    "line-height": {
        type: "size",
        customDescription: {
            native_mobile: "line height should be in px or unitless, greater than font-size for mobile"
        },
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true,
            allowedKeywords: ['normal']
        }
    },
    "opacity": {
        type: "range",
        min: 0,
        max: 1,
        percentMin: 0,
        percentMax: 100
    },
    "radius": {
        type: "multi-size",
        allowMultiValue: true,
        allowPercent: true,
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true
        }
    },
    "space": {
        type: "multi-size",
        allowMultiValue: true,
        allowAuto: true,
        allowPercent: true,
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true
        }
    },
    "margin": {
        type: "multi-size",
        allowMultiValue: true,
        allowAuto: true,
        allowNegative: true,
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true
        }
    },
    "spacer": {
        type: "size",
        native_mobile: {
            allowedUnits: MOBILE_SIZES,
            allowUnitless: true
        },
        web: {
            allowedUnits: WEB_SIZES,
            allowUnitless: true
        }
    }
};
/**
 * Generate platform-specific rule configuration
 * @param {string} subtype - The subtype name
 * @param {string} platform - Platform ('native_mobile' or 'web')
 * @returns {Object} Platform-specific rule configuration
 */
export function getPlatformRule(subtype, platform) {
    const baseConfig = BASE_SUBTYPE_CONFIGS[subtype];
    if (!baseConfig)
        return null;
    // Merge base config with platform-specific overrides
    const platformConfig = baseConfig[platform] || {};
    const rule = { ...baseConfig, ...platformConfig };
    // Handle platform-specific custom descriptions
    if (rule.customDescription && typeof rule.customDescription === 'object') {
        rule.customDescription = rule.customDescription[platform] || rule.customDescription;
    }
    // Remove platform-specific sections from the final rule
    delete rule.native_mobile;
    delete rule.web;
    delete rule.validator;
    return rule;
}
/**
 * Generate platform-specific validation rules from BASE_SUBTYPE_CONFIGS.
 * @param {string} platform - 'native_mobile' or 'web'
 * @param {Object} validators - Validator functions (see COMMON_VALIDATORS in utils.js)
 * @returns {Object} Rules indexed by subtype, each with a .validate function
 */
export function generatePlatformRules(platform, validators) {
    const rules = {};
    Object.keys(BASE_SUBTYPE_CONFIGS).forEach(subtype => {
        const rule = getPlatformRule(subtype, platform);
        if (!rule)
            return;
        rule.validate = resolveRuleValidator(rule.type, subtype, platform, validators);
        rules[subtype] = rule;
    });
    return rules;
}
/**
 * Resolve an executable validator function from rule type + subtype.
 */
export function resolveRuleValidator(type, subtype, platform, validators) {
    const platformDefaults = {
        native_mobile: MOBILE_SIZES,
        web: WEB_SIZES
    };
    const defaultUnits = platformDefaults[platform];
    switch (type) {
        case "allowed-list":
            return (value, rule) => validators.validateFromAllowedList(value, rule.allowed);
        case "size":
            return (value, rule) => validators.validatePlatformSizeValue(value, rule, defaultUnits);
        case "multi-size":
            return (value, rule) => validators.validatePlatformSpaceValue(value, rule, defaultUnits);
        case "string":
            return validators.validateFontFamily;
        case "range":
            return validators.validateOpacity;
        case "range-with-keywords":
            return platform === 'native_mobile'
                ? (value, rule) => validators.validateFontWeight(value, rule, true)
                : validators.validateFontWeight;
        case "custom":
            if (subtype === "font-family") {
                return (value, rule) => validators.validateFontFamily(value, rule);
            }
            if (subtype === "box-shadow" || subtype === "elevation") {
                return validators.validateBoxShadow;
            }
            return null;
        default:
            return null;
    }
}
//# sourceMappingURL=constants.js.map