/**
 * Port of Base UI React's `usePositioner`
 * (`packages/react/src/utils/usePositioner.tsx`).
 *
 * React's version calls `useRenderElement` internally and returns a JSX
 * element; the Solid port is more idiomatic as a helper that returns a
 * composable prop bag which consumers feed into `renderElement` themselves.
 * This keeps the compound positioners (popover, tooltip, menu, select, …)
 * in control of their context providers, `<Show>` gating, and portal
 * placement, without having to unwrap anything from this hook.
 *
 * ## React → Solid deviations
 *
 * - Returns a `UsePositionerReturn` object of accessors instead of a JSX
 *   element. Consumers spread `.props` into their `renderElement` call and
 *   apply `.style` reactively via a getter.
 * - The `inert` / `hidden` flags collapse into the returned style /
 *   HTML-props bag, matching how the React source sets them.
 * - `transitionStatus` is accepted as an accessor; when it is `"starting"`
 *   we emit `transition: none` to disable the initial mount transition
 *   (mirrors React's `getDisabledMountTransitionStyles`).
 */

function resolve(input) {
  if (input === undefined) return undefined;
  return typeof input === "function" ? input() : input;
}

/**
 * Produce the shared prop bag + style for a popup positioner element. This
 * hook owns the common role/hidden/style/inert-aware shape that every Base
 * UI popup positioner renders; consumers layer their component-specific
 * props on top via `renderElement`'s `props` array.
 *
 * Safe to call outside of a tracking context — the returned object exposes
 * getters, so reactive reads only happen at access time (e.g. inside a
 * `renderElement` props-array entry).
 */
export function usePositioner(options) {
  const getStyle = () => {
    const base = {
      ...options.styles()
    };
    if (resolve(options.inert)) {
      base.pointerEvents = "none";
    }
    if (options.transitionStatus() === "starting") {
      // Disables the initial mount transition to avoid a visual "pop" when
      // the element paints for the first time. Matches React's
      // `getDisabledMountTransitionStyles`.
      base.transition = "none";
    }
    return base;
  };
  const getHidden = () => resolve(options.hidden) || undefined;
  return {
    get style() {
      return getStyle();
    },
    get hidden() {
      return getHidden();
    },
    get props() {
      return {
        role: "presentation",
        hidden: getHidden(),
        get style() {
          return getStyle();
        }
      };
    }
  };
}
//# sourceMappingURL=use-positioner.jsx.map
