{"version":3,"file":"space.mjs","names":[],"sources":["../../src/utils/space.ts"],"sourcesContent":["/**\n * The argument value for the `space()` utility function.\n *\n * When this is a number or a numeric string, it will be interpreted as a\n * multiplier for the grid base value (4px). For example, `space( 2 )` will be 8px.\n *\n * Otherwise, it will be interpreted as a literal CSS length value. For example,\n * `space( 'auto' )` will be 'auto', and `space( '2px' )` will be 2px.\n */\nexport type SpaceInput = number | string;\n\nconst GRID_BASE = '4px';\n\n/**\n * A function that handles numbers, numeric strings, and unit values.\n *\n * When given a number or a numeric string, it will return the grid-based\n * value as a factor of GRID_BASE, defined above.\n *\n * When given a unit value or one of the named CSS values like `auto`,\n * it will simply return the value back.\n *\n * @param value A number, numeric string, or a unit value.\n */\nexport function space( value?: SpaceInput ): string | undefined {\n\tif ( typeof value === 'undefined' ) {\n\t\treturn undefined;\n\t}\n\n\t// Handle empty strings, if it's the number 0 this still works.\n\tif ( ! value ) {\n\t\treturn '0';\n\t}\n\n\tconst asInt = typeof value === 'number' ? value : Number( value );\n\n\t// Test if the input has a unit, was NaN, or was one of the named CSS values (like `auto`), in which case just use that value.\n\tif (\n\t\t( typeof window !== 'undefined' &&\n\t\t\twindow.CSS?.supports?.( 'margin', value.toString() ) ) ||\n\t\tNumber.isNaN( asInt )\n\t) {\n\t\treturn value.toString();\n\t}\n\n\treturn `calc(${ GRID_BASE } * ${ value })`;\n}\n"],"mappings":";AAWA,MAAM,YAAY;;;;;;;;;;;;AAalB,SAAgB,MAAO,OAAyC;CAC/D,IAAK,OAAO,UAAU,aACrB;CAID,IAAK,CAAE,OACN,OAAO;CAGR,MAAM,QAAQ,OAAO,UAAU,WAAW,QAAQ,OAAQ,KAAM;CAGhE,IACG,OAAO,WAAW,eACnB,OAAO,KAAK,WAAY,UAAU,MAAM,SAAS,CAAE,KACpD,OAAO,MAAO,KAAM,GAEpB,OAAO,MAAM,SAAS;CAGvB,OAAO,QAAS,UAAW,KAAM,MAAO;AACzC"}