{"version":3,"file":"calculateWithDoubleValue.cjs","sources":["../../../../../src/core/mixins/utils/position/calculateWithDoubleValue.ts"],"sourcesContent":["import { type PointData, type Size } from 'pixi.js';\nimport { type ComputedLayout, type NumberValue, type PositionSpecifier } from '../../../types';\nimport { getNumberFromStyle, getTypeFromStyle } from '../../../utils/getNumberFromStyle';\nimport { type ObjectPositionValue } from '../calculatePositionSpecifier';\n\n/**\n * Calculates the position for a centered element along the specified dimension\n *\n * @param dimension - Which dimension to calculate ('width' or 'height')\n * @param computedLayout - The computed layout from Yoga\n * @param visualBounds - The visual bounds of the element being positioned\n * @returns The coordinate value that centers the element\n */\nfunction calculateCenterPosition(\n    dimension: 'width' | 'height',\n    computedLayout: ComputedLayout,\n    visualBounds: Size,\n): number {\n    return (computedLayout[dimension] - visualBounds[dimension]) / 2;\n}\n\n/**\n * Calculates position for numeric values (px, %, etc)\n *\n * @param value - The position value to process\n * @param valueType - Type of the value ('percentage', 'pixel', etc)\n * @param dimension - Which dimension to calculate ('width' or 'height')\n * @param computedLayout - The computed layout from Yoga\n * @param visualBounds - The visual bounds of the element being positioned\n * @returns The calculated coordinate value\n */\nfunction calculateNonKeywordPosition(\n    value: ObjectPositionValue,\n    valueType: string,\n    dimension: 'width' | 'height',\n    computedLayout: ComputedLayout,\n    visualBounds: Size,\n): number {\n    const multiple = valueType === 'percentage' ? computedLayout[dimension] - visualBounds[dimension] : 1;\n\n    return getNumberFromStyle(value as NumberValue) * multiple;\n}\n\n/**\n * Calculates position when two values are provided (e.g., \"top center\", \"10% 20px\")\n * This implements CSS object-position behavior with two values\n *\n * @param tokens - Array of position tokens (should be exactly two)\n * @param computedLayout - The computed layout from Yoga\n * @param visualBounds - The visual bounds of the element being positioned\n * @returns Object with x and y coordinates for positioning\n */\nexport function calculateWithDoubleValue(\n    tokens: PositionSpecifier[],\n    computedLayout: ComputedLayout,\n    visualBounds: Size,\n): PointData {\n    const [first, second] = tokens as [ObjectPositionValue, ObjectPositionValue];\n    const firstType = getTypeFromStyle(first);\n    const secondType = getTypeFromStyle(second);\n    const result = { x: undefined, y: undefined } as unknown as PointData;\n\n    // Process first value\n    switch (first) {\n        case 'top':\n            result.y = 0;\n            break;\n        case 'bottom':\n            result.y = computedLayout.height - visualBounds.height;\n            break;\n        case 'center':\n            if (second === 'left' || second === 'right') {\n                result.y = calculateCenterPosition('height', computedLayout, visualBounds);\n            } else {\n                result.x = calculateCenterPosition('width', computedLayout, visualBounds);\n            }\n            break;\n        case 'left':\n            result.x = 0;\n            break;\n        case 'right':\n            result.x = computedLayout.width - visualBounds.width;\n            break;\n        default: {\n            const dimension = second === 'top' || second === 'bottom' || secondType !== 'keyword' ? 'width' : 'height';\n            const target = dimension === 'width' ? 'x' : 'y';\n\n            result[target] = calculateNonKeywordPosition(first, firstType, dimension, computedLayout, visualBounds);\n        }\n    }\n\n    // Process second value\n    switch (second) {\n        case 'top':\n            result.y = 0;\n            break;\n        case 'bottom':\n            result.y = computedLayout.height - visualBounds.height;\n            break;\n        case 'center':\n            if (result.y === undefined) {\n                result.y = calculateCenterPosition('height', computedLayout, visualBounds);\n            } else {\n                result.x = calculateCenterPosition('width', computedLayout, visualBounds);\n            }\n            break;\n        case 'left':\n            result.x = 0;\n            break;\n        case 'right':\n            result.x = computedLayout.width - visualBounds.width;\n            break;\n        default: {\n            const target = result.y === undefined ? 'y' : 'x';\n            const dimension = target === 'y' ? 'height' : 'width';\n\n            result[target] = calculateNonKeywordPosition(second, secondType, dimension, computedLayout, visualBounds);\n        }\n    }\n\n    return result;\n}\n"],"names":["getNumberFromStyle","getTypeFromStyle"],"mappings":";;;AAaA,SAAS,wBACL,WACA,gBACA,cACM;AACN,UAAQ,eAAe,SAAS,IAAI,aAAa,SAAS,KAAK;AACnE;AAYA,SAAS,4BACL,OACA,WACA,WACA,gBACA,cACM;AACA,QAAA,WAAW,cAAc,eAAe,eAAe,SAAS,IAAI,aAAa,SAAS,IAAI;AAE7F,SAAAA,mBAAA,mBAAmB,KAAoB,IAAI;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