{"version":3,"names":["createContext","createUniqueId","useContext","useIsoLayoutEffect","FloatingTreeStore","FloatingNodeContext","FloatingTreeContext","useFloatingParentNodeId","ctx","id","useFloatingTree","externalTree","contextTree","useFloatingNodeId","tree","parentId","undefined","node","addNode","removeNode","FloatingNode","props","value","children","FloatingTree"],"sources":["floating-tree.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\n/**\n * Stage 3 port of Base UI React's `FloatingTree`\n * (`packages/react/src/floating-ui-react/components/FloatingTree.tsx`).\n *\n * Supplies two contexts used by nested floating surfaces that are not DOM\n * descendants of their parent:\n *\n *  - `FloatingNodeContext`  — the parent node for the subtree (id + parentId).\n *  - `FloatingTreeContext`  — the shared `FloatingTreeStore` that tracks\n *    every node in the subtree.\n *\n * Consumers use these to look up siblings / parents for dismiss bubbling,\n * virtual focus navigation between nested menus, and cross-tree events.\n *\n * Port notes:\n * - React's `useRefWithInit(() => externalTree ?? new FloatingTreeStore())`\n *   pattern becomes a plain singleton assignment during setup (Solid\n *   components only \"render\" once, so `new FloatingTreeStore()` in the\n *   body runs exactly once per `FloatingTree` mount).\n * - `useFloatingNodeId` registers the node via `useIsoLayoutEffect` in\n *   React; the Solid port uses `useIsoLayoutEffect` (from\n *   `src/internals/use-iso-layout-effect.ts`, which aliases\n *   `createRenderEffect`). Cleanup runs via `onCleanup` inside the effect\n *   body.\n * - `FloatingNode` creates a per-render memo for its context value in\n *   React; Solid provides the value via a plain object since the\n *   component body doesn't re-run.\n */\nimport { createContext, createUniqueId, useContext } from \"solid-js\";\nimport { useIsoLayoutEffect } from \"../../use-iso-layout-effect\";\nimport type { FloatingNodeType } from \"../types\";\nimport { FloatingTreeStore } from \"./floating-tree-store\";\n\nconst FloatingNodeContext = createContext<FloatingNodeType | null>(null);\nconst FloatingTreeContext = createContext<FloatingTreeStore | null>(null);\n\n/**\n * Returns the parent node id for nested floating elements, if available.\n * Returns `null` for top-level floating elements.\n */\nexport function useFloatingParentNodeId(): string | null {\n\tconst ctx = useContext(FloatingNodeContext);\n\treturn ctx?.id ?? null;\n}\n\n/**\n * Returns the nearest floating tree context, if available.\n */\nexport function useFloatingTree(\n\texternalTree?: FloatingTreeStore,\n): FloatingTreeStore | null {\n\tconst contextTree = useContext(FloatingTreeContext);\n\treturn externalTree ?? contextTree;\n}\n\n/**\n * Registers a node into the `FloatingTree`, returning its id. If no tree is\n * mounted above, the id is still returned but no registration happens.\n *\n * @see https://floating-ui.com/docs/FloatingTree\n */\nexport function useFloatingNodeId(\n\texternalTree?: FloatingTreeStore,\n): string | undefined {\n\tconst id = createUniqueId();\n\tconst tree = useFloatingTree(externalTree);\n\tconst parentId = useFloatingParentNodeId();\n\n\tuseIsoLayoutEffect(\n\t\t() => undefined,\n\t\t() => {\n\t\t\tif (!id) {\n\t\t\t\treturn;\n\t\t\t}\n\t\t\tconst node: FloatingNodeType = { id, parentId };\n\t\t\ttree?.addNode(node);\n\t\t\treturn () => {\n\t\t\t\ttree?.removeNode(node);\n\t\t\t};\n\t\t},\n\t);\n\n\treturn id;\n}\n\nexport interface FloatingNodeProps {\n\tchildren?: JSX.Element;\n\tid: string | undefined;\n}\n\n/**\n * Provides parent node context for nested floating elements.\n * @see https://floating-ui.com/docs/FloatingTree\n * @internal\n */\nexport function FloatingNode(props: FloatingNodeProps): JSX.Element {\n\tconst parentId = useFloatingParentNodeId();\n\n\t// Matches React's `useMemo(() => ({ id, parentId }), [id, parentId])` —\n\t// a getter object keeps the `id` field reactive if callers pass a\n\t// signal-driven `props.id`.\n\tconst value: FloatingNodeType = {\n\t\tget id() {\n\t\t\treturn props.id;\n\t\t},\n\t\tparentId,\n\t};\n\n\treturn (\n\t\t<FloatingNodeContext value={value}>{props.children}</FloatingNodeContext>\n\t);\n}\n\nexport interface FloatingTreeProps {\n\tchildren?: JSX.Element;\n\texternalTree?: FloatingTreeStore | undefined;\n}\n\n/**\n * Provides context for nested floating elements when they are not children\n * of each other on the DOM.\n *\n * Not necessary in all cases — only required when there must be explicit\n * communication between parent and child floating elements, including:\n *\n *  - The `bubbles` option in `useDismiss()`.\n *  - Nested virtual list navigation.\n *  - Nested floating elements that each open on hover.\n *  - Custom communication between parent and child floating elements.\n *\n * @see https://floating-ui.com/docs/FloatingTree\n * @internal\n */\nexport function FloatingTree(props: FloatingTreeProps): JSX.Element {\n\t// One-shot store instantiation — Solid component bodies only execute\n\t// once per mount so this matches React's `useRefWithInit` exactly.\n\tconst tree = props.externalTree ?? new FloatingTreeStore();\n\n\treturn (\n\t\t<FloatingTreeContext value={tree}>{props.children}</FloatingTreeContext>\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,SAASA,aAAa,EAAEC,cAAc,EAAEC,UAAU,QAAQ,UAAU;AACpE,SAASC,kBAAkB,QAAQ,6BAA6B;AAEhE,SAASC,iBAAiB,QAAQ,uBAAuB;AAEzD,MAAMC,mBAAmB,GAAGL,aAAa,CAA0B,IAAI,CAAC;AACxE,MAAMM,mBAAmB,GAAGN,aAAa,CAA2B,IAAI,CAAC;;AAEzE;AACA;AACA;AACA;AACA,OAAO,SAASO,uBAAuBA,CAAA,EAAkB;EACxD,MAAMC,GAAG,GAAGN,UAAU,CAACG,mBAAmB,CAAC;EAC3C,OAAOG,GAAG,EAAEC,EAAE,IAAI,IAAI;AACvB;;AAEA;AACA;AACA;AACA,OAAO,SAASC,eAAeA,CAC9BC,YAAgC,EACL;EAC3B,MAAMC,WAAW,GAAGV,UAAU,CAACI,mBAAmB,CAAC;EACnD,OAAOK,YAAY,IAAIC,WAAW;AACnC;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,iBAAiBA,CAChCF,YAAgC,EACX;EACrB,MAAMF,EAAE,GAAGR,cAAc,CAAC,CAAC;EAC3B,MAAMa,IAAI,GAAGJ,eAAe,CAACC,YAAY,CA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