{"version":3,"sources":["../../src/utils/mergeArrowOffset.ts"],"sourcesContent":["'use client';\n\nimport type { Offset, OffsetObject } from '../types';\n\n/**\n * Generally when adding an arrow to popper, it's necessary to offset the position of the popper by the\n * height of the arrow. A simple utility to merge a provided offset with an arrow height to return the final offset\n *\n * @internal\n * @param userOffset - The offset provided by the user\n * @param arrowHeight - The height of the arrow in px\n * @returns User offset augmented with arrow height\n */\nexport function mergeArrowOffset(userOffset: Offset | undefined | null, arrowHeight: number): Offset {\n  if (typeof userOffset === 'number') {\n    return addArrowOffset(userOffset, arrowHeight);\n  }\n\n  if (typeof userOffset === 'object' && userOffset !== null) {\n    return addArrowOffset(userOffset, arrowHeight);\n  }\n\n  if (typeof userOffset === 'function') {\n    return offsetParams => {\n      const offset = userOffset(offsetParams);\n      return addArrowOffset(offset, arrowHeight);\n    };\n  }\n\n  return { mainAxis: arrowHeight };\n}\n\nconst addArrowOffset = (offset: OffsetObject | number, arrowHeight: number): OffsetObject => {\n  if (typeof offset === 'number') {\n    return { mainAxis: offset + arrowHeight };\n  }\n\n  return { ...offset, mainAxis: (offset.mainAxis ?? 0) + arrowHeight };\n};\n"],"names":["mergeArrowOffset","userOffset","arrowHeight","addArrowOffset","offsetParams","offset","mainAxis"],"mappings":"AAAA;;;;;+BAagBA;;;;;;AAAT,0BAA0BC,UAAqC,EAAEC,WAAmB;IACzF,IAAI,OAAOD,eAAe,UAAU;QAClC,OAAOE,eAAeF,YAAYC;IACpC;IAEA,IAAI,OAAOD,eAAe,YAAYA,eAAe,MAAM;QACzD,OAAOE,eAAeF,YAAYC;IACpC;IAEA,IAAI,OAAOD,eAAe,YAAY;QACpC,OAAOG,CAAAA;YACL,MAAMC,SAASJ,WAAWG;YAC1B,OAAOD,eAAeE,QAAQH;QAChC;IACF;IAEA,OAAO;QAAEI,UAAUJ;IAAY;AACjC;AAEA,MAAMC,iBAAiB,CAACE,QAA+BH;IACrD,IAAI,OAAOG,WAAW,UAAU;QAC9B,OAAO;YAAEC,UAAUD,SAASH;QAAY;IAC1C;IAEA,OAAO;QAAE,GAAGG,MAAM;QAAEC,UAAWD,CAAAA,OAAOC,QAAQ,KAAI,CAAA,GAAKJ;IAAY;AACrE"}