import { type IContainerModel } from '../../../Interfaces/IContainerModel'; import { type ISymbolModel } from '../../../Interfaces/ISymbolModel'; import { ApplyParentTransform, FindContainerById } from '../../../utils/itertools'; import { RestoreX, RestoreY, TransformX, TransformY } from '../../../utils/svg'; export function ApplySymbol(containers: Map, container: IContainerModel, symbol: ISymbolModel): IContainerModel { if (symbol.isVertical) { container.properties.y = TransformY(symbol.offset, symbol.height, symbol.config.PositionReference); container.properties.y = RestoreY(container.properties.y, container.properties.height, container.properties.positionReference); const parent = FindContainerById(containers, container.properties.parentId); let y = 0; if (parent !== undefined && parent !== null) { ([,y] = ApplyParentTransform(containers, parent, 0, container.properties.y)); } container.properties.y = y; return container; } else { container.properties.x = TransformX(symbol.offset, symbol.width, symbol.config.PositionReference); container.properties.x = RestoreX(container.properties.x, container.properties.width, container.properties.positionReference); const parent = FindContainerById(containers, container.properties.parentId); let x = 0; if (parent !== undefined && parent !== null) { ([x] = ApplyParentTransform(containers, parent, container.properties.x, 0)); } container.properties.x = x; return container; } }