import { TransformOption } from '../types' ; import { setMetadata } from '../lib/metadata' ; export const positionValues = [ 'top' , 'right top' , 'right' , 'right bottom' , 'bottom' , 'left bottom' , 'left' , 'left top' , 'north' , 'northeast' , 'east' , 'southeast' , 'south' , 'southwest' , 'west' , 'northwest' , 'center' , 'centre' , 'entropy' , 'attention' ] as const ; export const positionShorthands = [ 'top' , 'right top' , 'right' , 'right bottom' , 'bottom' , 'left bottom' , 'left' , 'left top' ] ; export type PositionValue = typeof positionValues [ number ] ; export interface PositionOptions { position : PositionValue ; } export const getPosition = ( config , image ) => { let position = undefined ; if ( config . position && positionValues . includes ( config . position ) ) { position = config . position ; } else { position = Object . keys ( config ) . find ( ( k ) : k is PositionValue => positionShorthands . includes ( k ) && config [ k ] === '' ) ; } if ( ! position ) return ; setMetadata ( image , 'position' , position ) ; return position ; } ;