export const getDiscoveryPanelCollapseState = ({ currentScrollTop = 0, lastScrollTop = 0, isCollapsed = false, threshold = 16, directionThreshold = 2, allowExpand = true, }) => { const current = Math.max(Number(currentScrollTop) || 0, 0); const last = Math.max(Number(lastScrollTop) || 0, 0); const delta = current - last; if (delta > directionThreshold && current > threshold) { return true; } if (allowExpand && delta < -directionThreshold) { return false; } return isCollapsed; }; export const canExpandDiscoveryPanelFromScroll = ({ isTouching = false, touchDirection = "", lastDownGestureAt = 0, now = Date.now(), gestureRetainMs = 800, }) => { if (isTouching) { return touchDirection === "down"; } const lastDownAt = Math.max(Number(lastDownGestureAt) || 0, 0); if (!lastDownAt) { return false; } const currentTime = Math.max(Number(now) || 0, 0); return currentTime - lastDownAt <= gestureRetainMs; };