{"version":3,"file":"calculateWithQuadValue.cjs","sources":["../../../../../src/core/mixins/utils/position/calculateWithQuadValue.ts"],"sourcesContent":["import { type PointData, type Size } from 'pixi.js';\nimport { type ComputedLayout, type NumberValue, type PositionKeyword, type PositionSpecifier } from '../../../types';\nimport { getNumberFromStyle, getTypeFromStyle } from '../../../utils/getNumberFromStyle';\nimport { type ObjectPositionValue } from '../calculatePositionSpecifier';\nimport { calculateWithDoubleValue } from './calculateWithDoubleValue';\n\n/**\n * Calculates the offset along an axis based on a keyword and value\n * Used for computing position adjustments from values like \"left 10px\" or \"bottom 20%\"\n *\n * @param keyword - The positioning keyword (left, right, top, bottom)\n * @param value - The numeric value of the offset\n * @param type - The type of value (percentage, pixel, etc)\n * @param bounds - The relevant dimension (width or height) to calculate percentage values\n * @returns The calculated offset value\n */\nfunction calculateAxisOffset(keyword: PositionKeyword, value: number, type: string, bounds: number): number {\n    const isNegativeOffset = keyword === 'right' || keyword === 'bottom';\n    const offset = type === 'percentage' ? value * bounds : value;\n\n    return isNegativeOffset ? -offset : offset;\n}\n\n/**\n * Calculates position when four values are provided (e.g., \"top 10px right 20px\")\n * Handles CSS object-position with format: <keyword> <offset> <keyword> <offset>\n *\n * @param tokens - Array of four position tokens\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 calculateWithQuadValue(\n    tokens: PositionSpecifier[],\n    computedLayout: ComputedLayout,\n    visualBounds: Size,\n): PointData {\n    const [first, second, third, fourth] = tokens as [\n        ObjectPositionValue,\n        NumberValue,\n        ObjectPositionValue,\n        NumberValue,\n    ];\n\n    const firstType = getTypeFromStyle(first);\n    const secondType = getTypeFromStyle(second);\n    const thirdType = getTypeFromStyle(third);\n    const fourthType = getTypeFromStyle(fourth);\n\n    if (secondType === 'keyword' || fourthType === 'keyword') {\n        throw new Error('Invalid objectPosition value: second and fourth values must be numbers or percentages');\n    }\n    if (firstType !== 'keyword' || thirdType !== 'keyword') {\n        throw new Error('Invalid objectPosition value: first and third values must be keywords');\n    }\n\n    const basePosition = calculateWithDoubleValue([first, third], computedLayout, visualBounds);\n    const result = { ...basePosition };\n\n    const secondValue = getNumberFromStyle(second);\n    const fourthValue = getNumberFromStyle(fourth);\n\n    // Process first pair (first + second)\n    if (first === 'left' || first === 'right') {\n        result.x = basePosition.x + calculateAxisOffset(first, secondValue, secondType, visualBounds.width);\n    } else if (first === 'top' || first === 'bottom') {\n        result.y = basePosition.y + calculateAxisOffset(first, secondValue, secondType, visualBounds.height);\n    }\n\n    // Process second pair (third + fourth)\n    if (third === 'left' || third === 'right') {\n        result.x = basePosition.x + calculateAxisOffset(third, fourthValue, fourthType, visualBounds.width);\n    } else if (third === 'top' || third === 'bottom') {\n        result.y = basePosition.y + calculateAxisOffset(third, fourthValue, fourthType, visualBounds.height);\n    }\n\n    return result;\n}\n"],"names":["getTypeFromStyle","calculateWithDoubleValue","getNumberFromStyle"],"mappings":";;;;AAgBA,SAAS,oBAAoB,SAA0B,OAAe,MAAc,QAAwB;AAClG,QAAA,mBAAmB,YAAY,WAAW,YAAY;AAC5D,QAAM,SAAS,SAAS,eAAe,QAAQ,SAAS;AAEjD,SAAA,mBAAmB,CAAC,SAAS;AACxC;AAWgB,SAAA,uBACZ,QACA,gBACA,cACS;AACT,QAAM,CAAC,OAAO,QAAQ,OAAO,MAAM,IAAI;AAOjC,QAAA,YAAYA,oCAAiB,KAAK;AAClC,QAAA,aAAaA,oCAAiB,MAAM;AACpC,QAAA,YAAYA,oCAAiB,KAAK;AAClC,QAAA,aAAaA,oCAAiB,MAAM;AAEtC,MAAA,eAAe,aAAa,eAAe,WAAW;AAChD,UAAA,IAAI,MAAM,uFAAuF;AAAA,EAAA;AAEvG,MAAA,cAAc,aAAa,cAAc,WAAW;AAC9C,UAAA,IAAI,MAAM,uEAAuE;AAAA,EAAA;AAG3F,QAAM,eAAeC,yBAAAA,yBAAyB,CAAC,OAAO,KAAK,GAAG,gBAAgB,YA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