'use strict'; const isKey = (x, k) => !!x && k in x; const mapFalsyToUndefined = (obj) => Object.fromEntries( Object.entries(obj).map(([key, value]) => [key, value || void 0]) ); function sva(config) { const { base = {}, variants = {}, compoundVariants = [], defaultVariants = {} } = config; return (variantProps) => { const { styles = {}, ...props } = variantProps || {}; const resolvedStyles = { ...base, ...styles }; for (const variant of Object.keys(defaultVariants)) { const variantValue = defaultVariants[variant]; if (variantValue && variants[variant]) { Object.assign(resolvedStyles, variants[variant][variantValue]); } } for (const variant of Object.keys(props)) { if (!isKey(variants, variant)) continue; const variantValue = props[variant]; if (variantValue && variants[variant]) { Object.assign(resolvedStyles, variants[variant][variantValue]); } } for (const compound of compoundVariants) { const matches = Object.keys(compound).every((key) => { if (key === "styles" || compound[key] === "*") return true; return isKey(props, key) && props[key] === compound[key]; }); if (matches) { Object.assign(resolvedStyles, compound.styles); } } return JSON.parse( JSON.stringify(mapFalsyToUndefined(resolvedStyles)) ); }; } exports.sva = sva;