"use client"; /** * Arrow-fullscreen progress store — 1:1 port of the original module 1111 * (arrowFullscreenProgressStore): * * The WebGL hyperspace model (cursor.glb stripes) reports its normalized * scale progress t (restScale→peak) every frame via `setDampedScaleT`. * DOM consumers (header text color, the hyper-space section itself) read a * boolean "past threshold" through `useArrowFullscreenPastThreshold`, whose * subscription only notifies when the boolean flips — so 60fps store writes * never re-render the header. * * Threshold semantics (original `r(mode, snapshot, e)`): "gte" → * snapshot >= threshold. Server snapshot: 0 >= threshold. */ import { useCallback, useSyncExternalStore } from "react"; type Listener = () => void; let value = 0; const listeners = new Set(); function notify() { for (const cb of listeners) cb(); } export const arrowFullscreenProgressStore = { getSnapshot: () => value, subscribe(cb: Listener) { listeners.add(cb); return () => { listeners.delete(cb); }; }, setDampedScaleT(t: number) { const next = Math.min(1, Math.max(0, t)); if (0.001 >= Math.abs(next - value)) return; value = next; notify(); }, reset() { if (value !== 0) { value = 0; notify(); } }, }; export function readArrowFullscreenPastThreshold(threshold = 0.5): boolean { return arrowFullscreenProgressStore.getSnapshot() >= threshold; } export function useArrowFullscreenPastThreshold(threshold = 0.5): boolean { return useSyncExternalStore( arrowFullscreenProgressStore.subscribe, useCallback( () => arrowFullscreenProgressStore.getSnapshot() >= threshold, [threshold] ), useCallback(() => 0 >= threshold, [threshold]) ); } /** * Original constant ARROW_FULLSCREEN_DOM_COLOR_TRANSITION — every DOM * element whose color follows the arrow fullscreen state carries this. */ export const ARROW_FULLSCREEN_DOM_COLOR_TRANSITION = "transition-colors duration-300 ease-out motion-reduce:transition-none";