// Helpers for keeping a field selected while the user interacts with a User
// Manual "Show me" control. A field blur normally clears the focused field,
// which removes the `.focused-field` anchor and the field action buttons that
// field-gated Show me reveals need to highlight. These helpers let the blur
// guard recognize that the blur was caused by a Show me interaction.
// How long after a pointer-down on a "Show me" control we still treat a field
// blur as "focus moved to Show me". A pointer-down reliably precedes the blur in
// every path (synchronous side-panel inputs and the async iframe inline editing
// bridge), so this is more robust than sampling `document.activeElement`, which
// is not yet the button when a mouse blur fires.
export const MANUAL_SHOW_ME_BLUR_GRACE_MS = 350;
const MANUAL_SHOW_ME_SELECTOR = "[data-manual-show-me]";
/** Whether an event target is (or is inside) a User Manual "Show me" control. */
export function isManualShowMeTarget(target) {
    const element = target instanceof Element ? target : null;
    return !!element?.closest(MANUAL_SHOW_ME_SELECTOR);
}
/**
 * Decide whether a field blur was caused by interacting with a "Show me"
 * control, so the focused field should be kept.
 *
 * A mouse blur fires before the clicked button becomes `document.activeElement`,
 * so we also accept a recent pointer-down on a control. Keyboard activation
 * leaves the control as the active element, which the first check covers.
 */
export function isManualShowMeFocusTransfer(params) {
    const graceMs = params.graceMs ?? MANUAL_SHOW_ME_BLUR_GRACE_MS;
    const activeInShowMe = !!params.activeElement?.closest?.(MANUAL_SHOW_ME_SELECTOR);
    const recentPointerDown = params.now - params.lastPointerDownAt < graceMs;
    return activeInShowMe || recentPointerDown;
}
//# sourceMappingURL=manualShowMeFocus.js.map