{"version":3,"sources":["../../src/utils/writeContainerupdates.ts"],"sourcesContent":["import type { Placement, MiddlewareData, Strategy, Coords } from '@floating-ui/dom';\nimport {\n  DATA_POSITIONING_ESCAPED,\n  DATA_POSITIONING_HIDDEN,\n  DATA_POSITIONING_INTERSECTING,\n  DATA_POSITIONING_PLACEMENT,\n} from '../constants';\n\n/**\n * Writes all container element position updates after the position is computed\n */\nexport function writeContainerUpdates(options: {\n  container: HTMLElement | null;\n  placement: Placement;\n  middlewareData: MiddlewareData;\n  /**\n   * Layer acceleration can disable subpixel rendering which causes slightly\n   * blurry text on low PPI displays, so we want to use 2D transforms\n   * instead\n   */\n  lowPPI: boolean;\n  strategy: Strategy;\n  coordinates: Coords;\n  useTransform?: boolean;\n}): void {\n  const { container, placement, middlewareData, strategy, lowPPI, coordinates, useTransform = true } = options;\n  if (!container) {\n    return;\n  }\n  container.setAttribute(DATA_POSITIONING_PLACEMENT, placement);\n  container.removeAttribute(DATA_POSITIONING_INTERSECTING);\n  if (middlewareData.intersectionObserver.intersecting) {\n    container.setAttribute(DATA_POSITIONING_INTERSECTING, '');\n  }\n\n  container.removeAttribute(DATA_POSITIONING_ESCAPED);\n  if (middlewareData.hide?.escaped) {\n    container.setAttribute(DATA_POSITIONING_ESCAPED, '');\n  }\n\n  container.removeAttribute(DATA_POSITIONING_HIDDEN);\n  if (middlewareData.hide?.referenceHidden) {\n    container.setAttribute(DATA_POSITIONING_HIDDEN, '');\n  }\n\n  // Round so that the coordinates land on device pixels.\n  // This prevents blurriness in cases where the browser doesn't apply pixel snapping, such as when other effects like\n  // `backdrop-filter: blur()` are applied to the container, and the browser is zoomed in.\n  // See https://github.com/microsoft/fluentui/issues/26764 for more info.\n  const devicePixelRatio = container.ownerDocument.defaultView?.devicePixelRatio || 1;\n  const x = Math.round(coordinates.x * devicePixelRatio) / devicePixelRatio;\n  const y = Math.round(coordinates.y * devicePixelRatio) / devicePixelRatio;\n\n  Object.assign(container.style, {\n    position: strategy,\n  });\n\n  if (useTransform) {\n    Object.assign(container.style, {\n      transform: lowPPI ? `translate(${x}px, ${y}px)` : `translate3d(${x}px, ${y}px, 0)`,\n    });\n    return;\n  }\n\n  Object.assign(container.style, {\n    left: `${x}px`,\n    top: `${y}px`,\n  });\n}\n"],"names":["DATA_POSITIONING_ESCAPED","DATA_POSITIONING_HIDDEN","DATA_POSITIONING_INTERSECTING","DATA_POSITIONING_PLACEMENT","writeContainerUpdates","options","container","placement","middlewareData","strategy","lowPPI","coordinates","useTransform","setAttribute","removeAttribute","intersectionObserver","intersecting","hide","escaped","referenceHidden","devicePixelRatio","ownerDocument","defaultView","x","Math","round","y","Object","assign","style","position","transform","left","top"],"mappings":";;;;+BAWgBI;;;;;;2BALT,kBAAe;AAKf,+BAA+BC,OAarC;IACC,MAAM,EAAEC,SAAS,EAAEC,SAAS,EAAEC,cAAc,EAAEC,QAAQ,EAAEC,MAAM,EAAEC,WAAW,EAAEC,eAAe,IAAI,EAAE,GAAGP;IACrG,IAAI,CAACC,WAAW;QACd;IACF;IACAA,UAAUO,YAAY,CAACV,qCAAAA,EAA4BI;IACnDD,UAAUQ,eAAe,CAACZ,wCAAAA;IAC1B,IAAIM,eAAeO,oBAAoB,CAACC,YAAY,EAAE;QACpDV,UAAUO,YAAY,CAACX,wCAAAA,EAA+B;IACxD;IAEAI,UAAUQ,eAAe,CAACd,mCAAAA;IAC1B,IAAIQ,eAAeS,IAAI,EAAEC,SAAS;QAChCZ,UAAUO,YAAY,CAACb,mCAAAA,EAA0B;IACnD;IAEAM,UAAUQ,eAAe,CAACb,kCAAAA;IAC1B,IAAIO,eAAeS,IAAI,EAAEE,iBAAiB;QACxCb,UAAUO,YAAY,CAACZ,kCAAAA,EAAyB;IAClD;IAEA,uDAAuD;IACvD,oHAAoH;IACpH,wFAAwF;IACxF,wEAAwE;IACxE,MAAMmB,mBAAmBd,UAAUe,aAAa,CAACC,WAAW,EAAEF,oBAAoB;IAClF,MAAMG,IAAIC,KAAKC,KAAK,CAACd,YA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