const arbitraryValueRegex = /^\[(.+)\]$/ ; const fractionRegex = /^\d+\/\d+$/ ; const stringLengths = new Set ( [ 'px' , 'full' , 'screen' ] ) ; const tshirtUnitRegex = /^(\d+)?(xs|sm|md|lg|xl)$/ ; const lengthUnitRegex = /\d+(%|px|em|rem|vh|vw|pt|pc|in|cm|mm|cap|ch|ex|lh|rlh|vi|vb|vmin|vmax)/ ; const shadowRegex = /^-?((\d+)?\.?(\d+)[a-z]+|0)_-?((\d+)?\.?(\d+)[a-z]+|0)/ ; export function isLength ( classPart ) { return ( ! Number . isNaN ( Number ( classPart ) ) || stringLengths . has ( classPart ) || fractionRegex . test ( classPart ) || isArbitraryLength ( classPart ) ) ; } export function isArbitraryLength ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; if ( arbitraryValue ) { return arbitraryValue . startsWith ( 'length:' ) || lengthUnitRegex . test ( arbitraryValue ) ; } return false ; } export function isArbitrarySize ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; return arbitraryValue ? arbitraryValue . startsWith ( 'size:' ) : false ; } export function isArbitraryPosition ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; return arbitraryValue ? arbitraryValue . startsWith ( 'position:' ) : false ; } export function isArbitraryUrl ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; return arbitraryValue ? arbitraryValue . startsWith ( 'url(' ) || arbitraryValue . startsWith ( 'url:' ) : false ; } export function isArbitraryWeight ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; return arbitraryValue ? ! Number . isNaN ( Number ( arbitraryValue ) ) || arbitraryValue . startsWith ( 'weight:' ) : false ; } export function isInteger ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; if ( arbitraryValue ) { return Number . isInteger ( Number ( arbitraryValue ) ) ; } return Number . isInteger ( Number ( classPart ) ) ; } export function isArbitraryValue ( classPart ) { return arbitraryValueRegex . test ( classPart ) ; } export function isAny ( ) { return true ; } export function isTshirtSize ( classPart ) { return tshirtUnitRegex . test ( classPart ) ; } export function isArbitraryShadow ( classPart ) { const arbitraryValue = arbitraryValueRegex . exec ( classPart ) ?. [ 1 ] ; if ( arbitraryValue ) { return shadowRegex . test ( arbitraryValue ) ; } return false ; }