{"version":3,"sources":["../src/hooks/usePositioning/utils/offset.ts"],"sourcesContent":["import type { Position, PositioningProps } from '@fluentui/react-positioning';\nimport { POSITIONS } from '../constants';\n\nexport function applyOffset(node: HTMLElement, position: Position, mainAxis: number, crossAxis: number): void {\n  const isBlockMain = position === POSITIONS.above || position === POSITIONS.below;\n\n  if (mainAxis) {\n    const main = `${mainAxis}px`;\n    if (isBlockMain) {\n      node.style.marginBlockStart = main;\n      node.style.marginBlockEnd = main;\n    } else {\n      node.style.marginInlineStart = main;\n      node.style.marginInlineEnd = main;\n    }\n  }\n\n  if (crossAxis) {\n    const cross = `${crossAxis}px`;\n    if (isBlockMain) {\n      node.style.marginInlineStart = cross;\n      node.style.marginInlineEnd = cross;\n    } else {\n      node.style.marginBlockStart = cross;\n      node.style.marginBlockEnd = cross;\n    }\n  }\n}\n\n/**\n * Normalises the `offset` prop into explicit `{ mainAxis, crossAxis }`. The\n * function form (`OffsetFunction`) is not supported under CSS anchor\n * positioning — rect information is not available ahead of layout — and\n * resolves to a zero offset.\n */\nexport function resolveOffset(offset: PositioningProps['offset']): { mainAxis: number; crossAxis: number } {\n  if (typeof offset === 'number') {\n    return { mainAxis: offset, crossAxis: 0 };\n  }\n\n  if (offset && typeof offset === 'object') {\n    return { mainAxis: offset.mainAxis ?? 0, crossAxis: offset.crossAxis ?? 0 };\n  }\n\n  return { mainAxis: 0, crossAxis: 0 };\n}\n"],"names":["applyOffset","resolveOffset","node","position","mainAxis","crossAxis","isBlockMain","POSITIONS","above","below","main","style","marginBlockStart","marginBlockEnd","marginInlineStart","marginInlineEnd","cross","offset"],"mappings":";;;;;;;;;;;IAGgBA,WAAW;eAAXA;;IAgCAC,aAAa;eAAbA;;;2BAlCU;AAEnB,SAASD,YAAYE,IAAiB,EAAEC,QAAkB,EAAEC,QAAgB,EAAEC,SAAiB;IACpG,MAAMC,cAAcH,aAAaI,oBAAS,CAACC,KAAK,IAAIL,aAAaI,oBAAS,CAACE,KAAK;IAEhF,IAAIL,UAAU;QACZ,MAAMM,OAAO,GAAGN,SAAS,EAAE,CAAC;QAC5B,IAAIE,aAAa;YACfJ,KAAKS,KAAK,CAACC,gBAAgB,GAAGF;YAC9BR,KAAKS,KAAK,CAACE,cAAc,GAAGH;QAC9B,OAAO;YACLR,KAAKS,KAAK,CAACG,iBAAiB,GAAGJ;YAC/BR,KAAKS,KAAK,CAACI,eAAe,GAAGL;QAC/B;IACF;IAEA,IAAIL,WAAW;QACb,MAAMW,QAAQ,GAAGX,UAAU,EAAE,CAAC;QAC9B,IAAIC,aAAa;YACfJ,KAAKS,KAAK,CAACG,iBAAiB,GAAGE;YAC/Bd,KAAKS,KAAK,CAACI,eAAe,GAAGC;QAC/B,OAAO;YACLd,KAAKS,KAAK,CAACC,gBAAgB,GAAGI;YAC9Bd,KAAKS,KAAK,CAACE,cAAc,GAAGG;QAC9B;IACF;AACF;AAQO,SAASf,cAAcgB,MAAkC;IAC9D,IAAI,OAAOA,WAAW,UAAU;QAC9B,OAAO;YAAEb,UAAUa;YAAQZ,WAAW;QAAE;IAC1C;IAEA,IAAIY,UAAU,OAAOA,WAAW,UAAU;QACxC,OAAO;YAAEb,UAAUa,OAAOb,QAAQ,IAAI;YAAGC,WAAWY,OAAOZ,SAAS,IAAI;QAAE;IAC5E;IAEA,OAAO;QAAED,UAAU;QAAGC,WAAW;IAAE;AACrC"}