{"version":3,"names":["createContext","createSignal","onCleanup","untrack","useContext","createChangeEventDetails","REASONS","createStableCallback","useIsoLayoutEffect","Timeout","useTimeout","getDelay","FloatingDelayGroupContext","hasProvider","timeoutMs","delayRef","current","initialDelayRef","timeout","currentIdRef","currentContextRef","FloatingDelayGroup","props","delay","value","children","useDelayGroup","context","options","open","store","rootStore","groupContext","isInstantPhase","setIsInstantPhaseSignal","ownedWrite","setIsInstantPhase","floatingId","useState","snapshot","unset","undefined","closingId","start","state","clear","prevContext","prevId","onOpenChange","setOpen","close","none"],"sources":["floating-delay-group.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\n/**\n * Stage 5.3 port of Base UI React's `FloatingDelayGroup`\n * (`packages/react/src/floating-ui-react/components/FloatingDelayGroup.tsx`).\n *\n * Coordinates hover-open/close delays across sibling floating surfaces so\n * that rapidly moving between grouped tooltips skips the normal open delay:\n * the next member opens immediately while any group member's close window\n * (or the explicit `timeoutMs`) is still open.\n *\n * ### React → Solid deviations\n *\n * - `React.useRef` → plain `MutableRef<T>` objects. The ref plumbing mirrors\n *   the React source exactly: `delayRef`, `initialDelayRef`, `currentIdRef`,\n *   and `currentContextRef` are shared by identity with consumer components\n *   via context so that sibling `useDelayGroup` calls all observe the same\n *   mutable state.\n * - `React.useState(false)` for the instant-phase flag is a `createSignal`\n *   pair (`isInstantPhase` / `setIsInstantPhase`) so the returned bag can\n *   track reactively.\n * - `React.useMemo` over the context value is dropped — Solid component\n *   bodies run once, and the contained refs already have stable identity,\n *   so the object literal is created once per `FloatingDelayGroup` mount.\n * - `useIsoLayoutEffect(cb, [...deps])` pairs become the Solid split\n *   compute/apply form. The dependency set that \"opens a new member\" is\n *   replicated by reading `store.useState('floatingId')` +\n *   `options.open` in the compute phase; the apply phase mirrors the\n *   React effect body line-for-line.\n * - Timeout management uses `useTimeout()` for automatic `onCleanup` —\n *   matches the React source's `useTimeout()` helper 1:1.\n *\n * ### Reason strings\n *\n * Pre-empted closes (when switching members) emit `REASONS.none`, matching\n * the React source literal (`createChangeEventDetails(REASONS.none)`).\n */\n\nimport {\n\tcreateContext,\n\tcreateSignal,\n\tonCleanup,\n\tuntrack,\n\tuseContext,\n} from \"solid-js\";\nimport {\n\ttype BaseUIChangeEventDetails,\n\tcreateChangeEventDetails,\n\tREASONS,\n} from \"../../change-event-details\";\nimport { createStableCallback } from \"../../stable-callback\";\nimport { useIsoLayoutEffect } from \"../../use-iso-layout-effect\";\nimport { Timeout, useTimeout } from \"../../use-timeout\";\nimport { getDelay } from \"../hooks/use-hover-shared\";\nimport type {\n\tDelay,\n\tFloatingContext,\n\tFloatingRootContext,\n\tMutableRef,\n} from \"../types\";\n\n// ---------------------------------------------------------------------------\n// Context\n// ---------------------------------------------------------------------------\n\ntype GroupCurrentContext = {\n\tonOpenChange: (\n\t\topen: boolean,\n\t\teventDetails: BaseUIChangeEventDetails<string>,\n\t) => void;\n\tsetIsInstantPhase: (value: boolean) => void;\n} | null;\n\ninterface FloatingDelayGroupContextValue {\n\thasProvider: boolean;\n\ttimeoutMs: number;\n\tdelayRef: MutableRef<Delay>;\n\tinitialDelayRef: MutableRef<Delay>;\n\ttimeout: Timeout;\n\tcurrentIdRef: MutableRef<string | null>;\n\tcurrentContextRef: MutableRef<GroupCurrentContext>;\n}\n\nconst FloatingDelayGroupContext = createContext<FloatingDelayGroupContextValue>(\n\t{\n\t\thasProvider: false,\n\t\ttimeoutMs: 0,\n\t\tdelayRef: { current: 0 },\n\t\tinitialDelayRef: { current: 0 },\n\t\ttimeout: new Timeout(),\n\t\tcurrentIdRef: { current: null },\n\t\tcurrentContextRef: { current: null },\n\t},\n);\n\n// ---------------------------------------------------------------------------\n// Component\n// ---------------------------------------------------------------------------\n\nexport interface FloatingDelayGroupProps {\n\tchildren?: JSX.Element;\n\t/**\n\t * The delay to use for the group when it's not in the instant phase.\n\t */\n\tdelay: Delay;\n\t/**\n\t * An optional explicit timeout to use for the group, which represents\n\t * when grouping logic will no longer be active after the close delay\n\t * completes. Useful when grouping should \"last\" longer than the close\n\t * delay, e.g. when there is no close delay at all.\n\t */\n\ttimeoutMs?: number | undefined;\n}\n\n/**\n * Provides context for a group of floating elements that should share a\n * `delay`. Sibling members consume the group via `useDelayGroup(context)`\n * and will skip their open delay if another group member has opened\n * recently (within the close delay or `timeoutMs` window).\n *\n * @see https://floating-ui.com/docs/FloatingDelayGroup\n * @internal\n */\nexport function FloatingDelayGroup(\n\tprops: FloatingDelayGroupProps,\n): JSX.Element {\n\tconst timeoutMs = () => props.timeoutMs ?? 0;\n\n\t// Body-time snapshots — `delayRef.current` is mutated reactively by the\n\t// `delay` setter on the returned bag, and `initialDelayRef` is the\n\t// stable initial value (matches React's `useRef(props.delay)` semantics).\n\tconst delayRef: MutableRef<Delay> = { current: untrack(() => props.delay) };\n\tconst initialDelayRef: MutableRef<Delay> = {\n\t\tcurrent: untrack(() => props.delay),\n\t};\n\tconst currentIdRef: MutableRef<string | null> = { current: null };\n\tconst currentContextRef: MutableRef<GroupCurrentContext> = { current: null };\n\tconst timeout = useTimeout();\n\n\tconst value: FloatingDelayGroupContextValue = {\n\t\thasProvider: true,\n\t\tdelayRef,\n\t\tinitialDelayRef,\n\t\tcurrentIdRef,\n\t\tcurrentContextRef,\n\t\ttimeout,\n\t\tget timeoutMs() {\n\t\t\treturn timeoutMs();\n\t\t},\n\t};\n\n\treturn (\n\t\t<FloatingDelayGroupContext value={value}>\n\t\t\t{props.children}\n\t\t</FloatingDelayGroupContext>\n\t);\n}\n\n// ---------------------------------------------------------------------------\n// useDelayGroup — sibling registration hook\n// ---------------------------------------------------------------------------\n\nexport interface UseDelayGroupOptions {\n\t/**\n\t * Whether the trigger this hook is used in has opened the tooltip.\n\t */\n\topen: boolean;\n}\n\nexport interface UseDelayGroupReturn {\n\t/**\n\t * The delay reference object. Shared across all group members so that\n\t * hovering the next member picks up the instant-phase `open: 0`\n\t * without waiting for prop propagation.\n\t */\n\tdelayRef: MutableRef<Delay>;\n\t/**\n\t * Whether animations should be removed because the group is in the\n\t * instant switch-between-members phase.\n\t */\n\tisInstantPhase: boolean;\n\t/**\n\t * Whether a `<FloatingDelayGroup>` provider is present above the caller.\n\t */\n\thasProvider: boolean;\n}\n\n/**\n * Registers the caller into the nearest `<FloatingDelayGroup>`. Returns\n * the shared `delayRef`, a flag marking the instant (inter-member)\n * phase, and whether a provider is present. Call inside a component that\n * participates in hover-delay coordination (e.g. Tooltip.Root).\n *\n * Accepts either a `FloatingRootContext` (the store itself) or a\n * `FloatingContext` (with `.rootStore`). The React source uses the same\n * dual-input shape so consumers pass whichever they have on hand.\n *\n * @see https://floating-ui.com/docs/FloatingDelayGroup\n * @internal\n */\nexport function useDelayGroup(\n\tcontext: FloatingRootContext | FloatingContext,\n\toptions: UseDelayGroupOptions = { open: false },\n): UseDelayGroupReturn {\n\tconst store = \"rootStore\" in context ? context.rootStore : context;\n\n\tconst groupContext = useContext(FloatingDelayGroupContext);\n\tconst {\n\t\tcurrentIdRef,\n\t\tdelayRef,\n\t\tinitialDelayRef,\n\t\tcurrentContextRef,\n\t\thasProvider,\n\t\ttimeout,\n\t} = groupContext;\n\n\tconst [isInstantPhase, setIsInstantPhaseSignal] = createSignal(false, {\n\t\townedWrite: true,\n\t});\n\n\t// Stabilize so previous member can synchronously flip our phase when\n\t// control passes to a new member mid-effect (React relies on a stable\n\t// state setter; Solid's setter is already stable but we wrap for the\n\t// identity-parity the shared `currentContextRef` requires).\n\tconst setIsInstantPhase = createStableCallback<(value: boolean) => void>(\n\t\t() => (value: boolean) => setIsInstantPhaseSignal(value),\n\t);\n\n\t// Effect #1: when this member is currently the group owner and its `open`\n\t// flag flips to false, schedule (or immediately perform) the unset — if\n\t// `timeoutMs` is configured, the group stays \"warm\" for the extra window.\n\tuseIsoLayoutEffect(\n\t\t() => ({\n\t\t\tfloatingId: store.useState(\"floatingId\"),\n\t\t\topen: options.open,\n\t\t\ttimeoutMs: groupContext.timeoutMs,\n\t\t}),\n\t\t(snapshot) => {\n\t\t\tconst { floatingId, open, timeoutMs } = snapshot;\n\n\t\t\tfunction unset() {\n\t\t\t\tsetIsInstantPhaseSignal(false);\n\t\t\t\tcurrentContextRef.current?.setIsInstantPhase(false);\n\t\t\t\tcurrentIdRef.current = null;\n\t\t\t\tcurrentContextRef.current = null;\n\t\t\t\tdelayRef.current = initialDelayRef.current;\n\t\t\t}\n\n\t\t\tif (!currentIdRef.current) {\n\t\t\t\treturn undefined;\n\t\t\t}\n\n\t\t\tif (!open && currentIdRef.current === floatingId) {\n\t\t\t\tsetIsInstantPhaseSignal(false);\n\n\t\t\t\tif (timeoutMs) {\n\t\t\t\t\tconst closingId = floatingId;\n\t\t\t\t\ttimeout.start(timeoutMs, () => {\n\t\t\t\t\t\t// If another member has taken over the group, skip resetting.\n\t\t\t\t\t\tif (\n\t\t\t\t\t\t\tstore.state.open ||\n\t\t\t\t\t\t\t(currentIdRef.current && currentIdRef.current !== closingId)\n\t\t\t\t\t\t) {\n\t\t\t\t\t\t\treturn;\n\t\t\t\t\t\t}\n\t\t\t\t\t\tunset();\n\t\t\t\t\t});\n\t\t\t\t\t// Matches React's `return () => timeout.clear()` — if the\n\t\t\t\t\t// effect re-runs before the timeout fires (or the scope is\n\t\t\t\t\t// disposed), cancel the pending reset.\n\t\t\t\t\treturn () => {\n\t\t\t\t\t\ttimeout.clear();\n\t\t\t\t\t};\n\t\t\t\t}\n\n\t\t\t\tunset();\n\t\t\t}\n\t\t\treturn undefined;\n\t\t},\n\t);\n\n\t// Effect #2: when this member opens, claim the group. If a different\n\t// member was the previous owner, flip both into instant phase and force\n\t// the old owner to close synchronously with `REASONS.none`.\n\tuseIsoLayoutEffect(\n\t\t() => ({\n\t\t\tfloatingId: store.useState(\"floatingId\"),\n\t\t\topen: options.open,\n\t\t}),\n\t\t(snapshot) => {\n\t\t\tconst { floatingId, open } = snapshot;\n\n\t\t\tif (!open) {\n\t\t\t\treturn;\n\t\t\t}\n\n\t\t\tconst prevContext = currentContextRef.current;\n\t\t\tconst prevId = currentIdRef.current;\n\n\t\t\t// A new tooltip is opening, so cancel any pending timeout that\n\t\t\t// would reset the group's delay back to the initial value.\n\t\t\ttimeout.clear();\n\t\t\tcurrentContextRef.current = {\n\t\t\t\tonOpenChange: store.setOpen,\n\t\t\t\tsetIsInstantPhase,\n\t\t\t};\n\t\t\tcurrentIdRef.current = floatingId ?? null;\n\t\t\tdelayRef.current = {\n\t\t\t\topen: 0,\n\t\t\t\tclose: getDelay(initialDelayRef.current, \"close\"),\n\t\t\t};\n\n\t\t\tif (prevId !== null && prevId !== floatingId) {\n\t\t\t\tsetIsInstantPhaseSignal(true);\n\t\t\t\tprevContext?.setIsInstantPhase(true);\n\t\t\t\tprevContext?.onOpenChange(\n\t\t\t\t\tfalse,\n\t\t\t\t\tcreateChangeEventDetails(\n\t\t\t\t\t\tREASONS.none,\n\t\t\t\t\t) as BaseUIChangeEventDetails<string>,\n\t\t\t\t);\n\t\t\t} else {\n\t\t\t\tsetIsInstantPhaseSignal(false);\n\t\t\t\tprevContext?.setIsInstantPhase(false);\n\t\t\t}\n\t\t},\n\t);\n\n\t// Effect #3: on unmount, clear our slot in `currentContextRef` so the\n\t// previous-owner branch above doesn't reach into a disposed member.\n\t// Matches React's `useIsoLayoutEffect(() => () => { ... }, [])`.\n\tonCleanup(() => {\n\t\tcurrentContextRef.current = null;\n\t});\n\n\treturn {\n\t\tget hasProvider() {\n\t\t\treturn hasProvider;\n\t\t},\n\t\tget delayRef() {\n\t\t\treturn delayRef;\n\t\t},\n\t\tget isInstantPhase() {\n\t\t\treturn isInstantPhase();\n\t\t},\n\t};\n}\n"],"mappings":"AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAEA,SACCA,aAAa,EACbC,YAAY,EACZC,SAAS,EACTC,OAAO,EACPC,UAAU,QACJ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