: str_replace(): Passing null to parameter #2 ($replace) of type array|string is deprecated in
const alignmentSides = getAlignmentSides(currentPlacement, rects, await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating)));
// Make `computeCoords` start from the right place.
if (placement !== currentPlacement) {
placement: placements$1[0]
const currentOverflows = [overflow[getSide(currentPlacement)], overflow[alignmentSides[0]], overflow[alignmentSides[1]]];
const allOverflows = [...(((_middlewareData$autoP2 = middlewareData.autoPlacement) == null ? void 0 : _middlewareData$autoP2.overflows) || []), {
placement: currentPlacement,
overflows: currentOverflows
const nextPlacement = placements$1[currentIndex + 1];
// There are more placements to check.
const placementsSortedByMostSpace = allOverflows.map(d => {
const alignment = getAlignment(d.placement);
return [d.placement, alignment && crossAxis ?
// Check along the mainAxis and main crossAxis side.
d.overflows.slice(0, 2).reduce((acc, v) => acc + v, 0) :
// Check only the mainAxis.
d.overflows[0], d.overflows];
}).sort((a, b) => a[1] - b[1]);
const placementsThatFitOnEachSide = placementsSortedByMostSpace.filter(d => d[2].slice(0,
// Aligned placements should not check their opposite crossAxis
getAlignment(d[0]) ? 2 : 3).every(v => v <= 0));
const resetPlacement = ((_placementsThatFitOnE = placementsThatFitOnEachSide[0]) == null ? void 0 : _placementsThatFitOnE[0]) || placementsSortedByMostSpace[0][0];
if (resetPlacement !== placement) {
placement: resetPlacement
* Optimizes the visibility of the floating element by flipping the `placement`
* in order to keep it in view when the preferred placement(s) will overflow the
* clipping boundary. Alternative to `autoPlacement`.
* @see https://floating-ui.com/docs/flip
const flip = function (options) {
if (options === void 0) {
var _middlewareData$arrow, _middlewareData$flip;
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = true,
fallbackPlacements: specifiedFallbackPlacements,
fallbackStrategy = 'bestFit',
fallbackAxisSideDirection = 'none',
} = floating_ui_utils_evaluate(options, state);
// If a reset by the arrow was caused due to an alignment offset being
// added, we should skip any logic now since `flip()` has already done its
// https://github.com/floating-ui/floating-ui/issues/2549#issuecomment-1719601643
if ((_middlewareData$arrow = middlewareData.arrow) != null && _middlewareData$arrow.alignmentOffset) {
const side = floating_ui_utils_getSide(placement);
const isBasePlacement = floating_ui_utils_getSide(initialPlacement) === initialPlacement;
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
const fallbackPlacements = specifiedFallbackPlacements || (isBasePlacement || !flipAlignment ? [getOppositePlacement(initialPlacement)] : getExpandedPlacements(initialPlacement));
if (!specifiedFallbackPlacements && fallbackAxisSideDirection !== 'none') {
fallbackPlacements.push(...getOppositeAxisPlacements(initialPlacement, flipAlignment, fallbackAxisSideDirection, rtl));
const placements = [initialPlacement, ...fallbackPlacements];
const overflow = await detectOverflow(state, detectOverflowOptions);
let overflowsData = ((_middlewareData$flip = middlewareData.flip) == null ? void 0 : _middlewareData$flip.overflows) || [];
overflows.push(overflow[side]);
const sides = floating_ui_utils_getAlignmentSides(placement, rects, rtl);
overflows.push(overflow[sides[0]], overflow[sides[1]]);
overflowsData = [...overflowsData, {
// One or more sides is overflowing.
if (!overflows.every(side => side <= 0)) {
var _middlewareData$flip2, _overflowsData$filter;
const nextIndex = (((_middlewareData$flip2 = middlewareData.flip) == null ? void 0 : _middlewareData$flip2.index) || 0) + 1;
const nextPlacement = placements[nextIndex];
// Try next placement and re-run the lifecycle.
// First, find the candidates that fit on the mainAxis side of overflow,
// then find the placement that fits the best on the main crossAxis side.
let resetPlacement = (_overflowsData$filter = overflowsData.filter(d => d.overflows[0] <= 0).sort((a, b) => a.overflows[1] - b.overflows[1])[0]) == null ? void 0 : _overflowsData$filter.placement;
switch (fallbackStrategy) {
var _overflowsData$map$so;
const placement = (_overflowsData$map$so = overflowsData.map(d => [d.placement, d.overflows.filter(overflow => overflow > 0).reduce((acc, overflow) => acc + overflow, 0)]).sort((a, b) => a[1] - b[1])[0]) == null ? void 0 : _overflowsData$map$so[0];
resetPlacement = placement;
resetPlacement = initialPlacement;
if (placement !== resetPlacement) {
placement: resetPlacement
function getSideOffsets(overflow, rect) {
top: overflow.top - rect.height,
right: overflow.right - rect.width,
bottom: overflow.bottom - rect.height,
left: overflow.left - rect.width
function isAnySideFullyClipped(overflow) {
return sides.some(side => overflow[side] >= 0);
* Provides data to hide the floating element in applicable situations, such as
* when it is not in the same clipping context as the reference element.
* @see https://floating-ui.com/docs/hide
const hide = function (options) {
if (options === void 0) {
strategy = 'referenceHidden',
} = evaluate(options, state);
const overflow = await detectOverflow(state, {
...detectOverflowOptions,
elementContext: 'reference'
const offsets = getSideOffsets(overflow, rects.reference);
referenceHiddenOffsets: offsets,
referenceHidden: isAnySideFullyClipped(offsets)
const overflow = await detectOverflow(state, {
...detectOverflowOptions,
const offsets = getSideOffsets(overflow, rects.floating);
escaped: isAnySideFullyClipped(offsets)
function getBoundingRect(rects) {
const minX = min(...rects.map(rect => rect.left));
const minY = min(...rects.map(rect => rect.top));
const maxX = max(...rects.map(rect => rect.right));
const maxY = max(...rects.map(rect => rect.bottom));
function getRectsByLine(rects) {
const sortedRects = rects.slice().sort((a, b) => a.y - b.y);
for (let i = 0; i < sortedRects.length; i++) {
const rect = sortedRects[i];
if (!prevRect || rect.y - prevRect.y > prevRect.height / 2) {
groups[groups.length - 1].push(rect);
return groups.map(rect => rectToClientRect(getBoundingRect(rect)));
* Provides improved positioning for inline reference elements that can span
* over multiple lines, such as hyperlinks or range selections.
* @see https://floating-ui.com/docs/inline
const inline = function (options) {
if (options === void 0) {
// A MouseEvent's client{X,Y} coords can be up to 2 pixels off a
// ClientRect's bounds, despite the event listener being triggered. A
// padding of 2 seems to handle this issue.
} = evaluate(options, state);
const nativeClientRects = Array.from((await (platform.getClientRects == null ? void 0 : platform.getClientRects(elements.reference))) || []);
const clientRects = getRectsByLine(nativeClientRects);
const fallback = rectToClientRect(getBoundingRect(nativeClientRects));
const paddingObject = getPaddingObject(padding);
function getBoundingClientRect() {
// There are two rects and they are disjoined.
if (clientRects.length === 2 && clientRects[0].left > clientRects[1].right && x != null && y != null) {
// Find the first rect in which the point is fully inside.
return clientRects.find(rect => x > rect.left - paddingObject.left && x < rect.right + paddingObject.right && y > rect.top - paddingObject.top && y < rect.bottom + paddingObject.bottom) || fallback;
// There are 2 or more connected rects.
if (clientRects.length >= 2) {
if (getSideAxis(placement) === 'y') {
const firstRect = clientRects[0];
const lastRect = clientRects[clientRects.length - 1];
const isTop = getSide(placement) === 'top';
const top = firstRect.top;
const bottom = lastRect.bottom;
const left = isTop ? firstRect.left : lastRect.left;
const right = isTop ? firstRect.right : lastRect.right;
const width = right - left;
const height = bottom - top;
const isLeftSide = getSide(placement) === 'left';
const maxRight = max(...clientRects.map(rect => rect.right));
const minLeft = min(...clientRects.map(rect => rect.left));
const measureRects = clientRects.filter(rect => isLeftSide ? rect.left === minLeft : rect.right === maxRight);
const top = measureRects[0].top;
const bottom = measureRects[measureRects.length - 1].bottom;
const width = right - left;
const height = bottom - top;
const resetRects = await platform.getElementRects({
floating: elements.floating,
if (rects.reference.x !== resetRects.reference.x || rects.reference.y !== resetRects.reference.y || rects.reference.width !== resetRects.reference.width || rects.reference.height !== resetRects.reference.height) {
// For type backwards-compatibility, the `OffsetOptions` type was also
async function convertValueToCoords(state, options) {
const rtl = await (platform.isRTL == null ? void 0 : platform.isRTL(elements.floating));
const side = floating_ui_utils_getSide(placement);
const alignment = floating_ui_utils_getAlignment(placement);
const isVertical = floating_ui_utils_getSideAxis(placement) === 'y';
const mainAxisMulti = ['left', 'top'].includes(side) ? -1 : 1;
const crossAxisMulti = rtl && isVertical ? -1 : 1;
const rawValue = floating_ui_utils_evaluate(options, state);
// eslint-disable-next-line prefer-const
} = typeof rawValue === 'number' ? {
if (alignment && typeof alignmentAxis === 'number') {
crossAxis = alignment === 'end' ? alignmentAxis * -1 : alignmentAxis;
x: crossAxis * crossAxisMulti,
y: mainAxis * mainAxisMulti
x: mainAxis * mainAxisMulti,
y: crossAxis * crossAxisMulti
* Modifies the placement by translating the floating element along the
* A number (shorthand for `mainAxis` or distance), or an axes configuration
* @see https://floating-ui.com/docs/offset
const offset = function (options) {
if (options === void 0) {
const diffCoords = await convertValueToCoords(state, options);
* Optimizes the visibility of the floating element by shifting it in order to
* keep it in view when it will overflow the clipping boundary.
* @see https://floating-ui.com/docs/shift
const shift = function (options) {
if (options === void 0) {
mainAxis: checkMainAxis = true,
crossAxis: checkCrossAxis = false,
} = floating_ui_utils_evaluate(options, state);
const overflow = await detectOverflow(state, detectOverflowOptions);
const crossAxis = floating_ui_utils_getSideAxis(floating_ui_utils_getSide(placement));
const mainAxis = getOppositeAxis(crossAxis);
let mainAxisCoord = coords[mainAxis];
let crossAxisCoord = coords[crossAxis];
const minSide = mainAxis === 'y' ? 'top' : 'left';
const maxSide = mainAxis === 'y' ? 'bottom' : 'right';
const min = mainAxisCoord + overflow[minSide];
const max = mainAxisCoord - overflow[maxSide];
mainAxisCoord = clamp(min, mainAxisCoord, max);
const minSide = crossAxis === 'y' ? 'top' : 'left';
const maxSide = crossAxis === 'y' ? 'bottom' : 'right';
const min = crossAxisCoord + overflow[minSide];