import { RawValueSignature } from '@specifyapp/specify-design-token-format'; import { aliasOfResolvableAlias } from '../utils/aliasOfResolvedStatefulAlias.js'; import { colorToStyleDictionary } from './color.js'; import { borderStyleToStyleDictionary } from './borderStyle.js'; import { sizeToStyleDictionary } from './size.js'; import { throwOnUnexpectedUnresolvable } from '../../../utils/throwOnUnexpectedUnresolvable.js'; export const borderToStyleDictionary = ( value: RawValueSignature<'border'>, ): | { color?: string; style: ReturnType | string; width: string; } | string | undefined => { const style = value.style .mapPrimitiveValue(borderStyleToStyleDictionary) .mapUnresolvableValueLevelAlias(throwOnUnexpectedUnresolvable) .mapResolvableValueLevelAlias(aliasOfResolvableAlias) .unwrap(); const width = value.width .mapPrimitiveValue(sizeToStyleDictionary) .mapUnresolvableValueLevelAlias(throwOnUnexpectedUnresolvable) .mapResolvableValueLevelAlias(aliasOfResolvableAlias) .unwrap(); const color = value.color .mapPrimitiveValue(colorToStyleDictionary) .mapUnresolvableValueLevelAlias(throwOnUnexpectedUnresolvable) .mapResolvableValueLevelAlias(aliasOfResolvableAlias) .unwrap(); return { style, width, ...(color ? { color } : {}), }; };