{"version":3,"names":["isElement","useBaseUiId","FloatingRootStore","useFloatingParentNodeId","PopupTriggerMap","useFloatingRootContext","options","open","onOpenChange","elements","floatingId","nested","process","env","NODE_ENV","optionDomReference","reference","console","error","store","transitionStatus","undefined","referenceElement","floatingElement","floating","triggerElements","syncOnly","context"],"sources":["use-floating-root-context.ts"],"sourcesContent":["/**\n * Stage 3 port of Base UI React's `useFloatingRootContext` hook.\n *\n * React source:\n *   `base-ui/packages/react/src/floating-ui-react/hooks/useFloatingRootContext.ts`\n *   `base-ui/packages/react/src/floating-ui-react/components/FloatingRootStore.ts`\n *\n * Stage 2 landed an inline `Stage2RootStore` shim that implemented the\n * minimal subset of the React store contract that `useFloating` reads.\n * Stage 3 replaces that shim with the real `FloatingRootStore`\n * (see `components/floating-root-store.ts`). The public return shape of\n * this hook is unchanged — callers keep reading `store.useState('...')`,\n * `store.sync('...')`, `store.setOpen(...)`, and\n * `store.context.{events,dataRef,triggerElements,nested}`.\n *\n * ### Behavior deltas vs the Stage-2 shim\n *\n * - `setOpen` now emits `openchange` on the internal events bus and\n *   performs the hover-vs-click `syncOpenEvent` bookkeeping before\n *   forwarding to `onOpenChange`. The shim skipped both.\n * - `nested` is now seeded from `useFloatingParentNodeId()` (returns\n *   `null` when no `FloatingTree` is mounted above — which is the same\n *   default the shim hard-coded).\n * - `useState('referenceElement')` prefers `positionReference` over the\n *   raw `referenceElement` slot to match React's selector. In practice\n *   `useFloating` already threads `positionReference` through its own\n *   state signal, so call sites see the same values either way.\n */\nimport { isElement } from \"@floating-ui/utils/dom\";\nimport { useBaseUiId } from \"../../base-ui-id\";\nimport type { BaseUIChangeEventDetails } from \"../../change-event-details\";\nimport { FloatingRootStore } from \"../components/floating-root-store\";\nimport { useFloatingParentNodeId } from \"../components/floating-tree\";\nimport { PopupTriggerMap } from \"../popup-trigger-map\";\nimport type { ReferenceType } from \"../types\";\n\nexport interface UseFloatingRootContextOptions {\n\topen?: boolean | undefined;\n\tonOpenChange?(\n\t\topen: boolean,\n\t\teventDetails: BaseUIChangeEventDetails<string>,\n\t): void;\n\telements?:\n\t\t| {\n\t\t\t\treference?: ReferenceType | null | undefined;\n\t\t\t\tfloating?: HTMLElement | null | undefined;\n\t\t  }\n\t\t| undefined;\n}\n\n/**\n * Creates a minimal root context for a floating element.\n *\n * Consumers pass the current `open` state, an `onOpenChange` callback, and\n * optionally pre-registered `elements`. The returned store exposes a\n * reactive view of those values plus context (dataRef / events / nested /\n * triggerElements).\n */\nexport function useFloatingRootContext(\n\toptions: UseFloatingRootContextOptions,\n): FloatingRootStore {\n\tconst { open = false, onOpenChange, elements } = options;\n\n\tconst floatingId = useBaseUiId();\n\tconst nested = useFloatingParentNodeId() != null;\n\n\tif (process.env.NODE_ENV !== \"production\") {\n\t\tconst optionDomReference = elements?.reference;\n\t\tif (optionDomReference && !isElement(optionDomReference)) {\n\t\t\tconsole.error(\n\t\t\t\t\"Cannot pass a virtual element to the `elements.reference` option,\",\n\t\t\t\t\"as it must be a real DOM element. Use `context.setPositionReference()`\",\n\t\t\t\t\"instead.\",\n\t\t\t);\n\t\t}\n\t}\n\n\tconst store = new FloatingRootStore({\n\t\topen,\n\t\ttransitionStatus: undefined,\n\t\tonOpenChange,\n\t\treferenceElement: elements?.reference ?? null,\n\t\tfloatingElement: elements?.floating ?? null,\n\t\ttriggerElements: new PopupTriggerMap(),\n\t\tfloatingId,\n\t\tsyncOnly: false,\n\t\tnested,\n\t});\n\n\t// React's hook runs a `useIsoLayoutEffect` on [open, floatingId,\n\t// elements.reference, elements.floating, store] to sync partial state\n\t// into the store. In Solid, component bodies don't re-run — call\n\t// sites that want reactivity wrap this hook's inputs in reactive\n\t// accessors themselves. The hook therefore performs a one-shot\n\t// initialization and exposes `store.update(...)` for callers that\n\t// need to sync on their own cadence.\n\t//\n\t// `useFloating` (the sibling Stage 2 hook) consumes the store's\n\t// `useSyncedValue` methods from inside a `createEffect`, so the\n\t// reactive path is preserved for its caller.\n\tstore.context.onOpenChange = onOpenChange;\n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