{"version":3,"names":["mergePropsN","ACTIVE_KEY","FOCUSABLE_ATTRIBUTE","SELECTED_KEY","stripItemScopeKeys","source","out","key","Object","keys","resolvePropsFor","entry","elementKey","userProps","undefined","propsOrGetter","resolved","useInteractions","propsList","mergeFor","seed","isItem","sources","push","i","length","getReferenceProps","getFloatingProps","tabIndex","getItemProps","getTriggerProps"],"sources":["use-interactions.ts"],"sourcesContent":["/**\n * Stage 4.1 port of Base UI React's `useInteractions` hook.\n *\n * React source:\n *   `base-ui/packages/react/src/floating-ui-react/hooks/useInteractions.ts`.\n *\n * Merges the prop bags produced by individual interaction hooks (`useHover`,\n * `useFocus`, `useClick`, `useDismiss`, `useListNavigation`, `useRole`, ...)\n * into three prop-getters (`getReferenceProps`, `getFloatingProps`,\n * `getItemProps`) plus a fourth `getTriggerProps` that Base UI's fork adds\n * for separate trigger/reference handling.\n *\n * ### React → Solid deviations\n *\n * 1. React memoises each getter with `useCallback` keyed on per-element\n *    `propsList` slices so the identity is stable across renders. Solid\n *    components don't re-run their bodies, so the returned getters are\n *    plain functions — identity is stable for the lifetime of the call\n *    site already.\n *\n * 2. React's hand-rolled `mergeProps` loop duplicates the merge semantics\n *    that `mergePropsN` (`src/internals/merge-props-n.ts`) already\n *    implements for the rest of the Solid port: event handlers chain\n *    instead of overwriting, `class` / `style` compose, right-most\n *    non-`undefined` wins for scalars. The port delegates to\n *    `mergePropsN` instead of reimplementing. One consequence: the\n *    `preventBaseUIHandler()` chain-short-circuit that `mergePropsN`\n *    arms on the event is automatically honored here too (React's\n *    source has no equivalent — it returns the first non-undefined\n *    result from the handler array, which is a different contract).\n *\n * 3. React's `for…in` enumeration of source objects in `mergeProps`\n *    walks prototype-inherited keys; Solid's `mergePropsN` walks\n *    `Object.keys` only. Hook-produced bags are plain objects in both\n *    ports, so the distinction doesn't matter in practice.\n *\n * 4. React uses `React.HTMLProps<Element>` for the user-prop parameter\n *    type. The Solid port accepts `ElementPropsBag` from `../types`,\n *    which is `JSX.HTMLAttributes<any> & Record<string, unknown>` —\n *    the same loose bag already used for inter-hook prop passing.\n */\n\nimport { mergePropsN, type PropsLike } from \"../../merge-props-n\";\nimport type {\n\tElementProps,\n\tElementPropsBag,\n\tExtendedUserProps,\n} from \"../types\";\nimport {\n\tACTIVE_KEY,\n\tFOCUSABLE_ATTRIBUTE,\n\tSELECTED_KEY,\n} from \"../utils/constants\";\n\nexport type { ExtendedUserProps };\n\nexport interface UseInteractionsReturn {\n\tgetReferenceProps: (userProps?: ElementPropsBag) => PropsLike;\n\tgetFloatingProps: (userProps?: ElementPropsBag) => PropsLike;\n\tgetItemProps: (\n\t\tuserProps?: Omit<ElementPropsBag, \"selected\" | \"active\"> &\n\t\t\tExtendedUserProps,\n\t) => PropsLike;\n\tgetTriggerProps: (userProps?: ElementPropsBag) => PropsLike;\n}\n\ntype InteractionEntry = ElementProps | false | null | undefined;\n\n/**\n * Strip the `item`-scope-only `active` / `selected` keys from a prop bag —\n * they are used to parameterise item getter callbacks, not to be forwarded\n * as DOM attributes.\n */\nfunction stripItemScopeKeys(\n\tsource: PropsLike | undefined,\n): PropsLike | undefined {\n\tif (!source) return source;\n\tif (!(ACTIVE_KEY in source) && !(SELECTED_KEY in source)) return source;\n\tconst out: Record<string, unknown> = {};\n\tfor (const key of Object.keys(source)) {\n\t\tif (key === ACTIVE_KEY || key === SELECTED_KEY) continue;\n\t\tout[key] = (source as Record<string, unknown>)[key];\n\t}\n\treturn out;\n}\n\n/**\n * Resolve the per-element prop bag out of an interaction-hook return. For\n * `item`-scope, the bag can be a function that receives the user props\n * (including `active` / `selected`) and returns the concrete DOM props;\n * React's source invokes it lazily inside `mergeProps`. We do the same.\n */\nfunction resolvePropsFor<Key extends keyof ElementProps>(\n\tentry: InteractionEntry,\n\telementKey: Key,\n\tuserProps: ElementPropsBag | undefined,\n): PropsLike | undefined {\n\tif (!entry) return undefined;\n\tconst propsOrGetter = entry[elementKey];\n\tif (propsOrGetter == null) return undefined;\n\tif (typeof propsOrGetter === \"function\") {\n\t\tif (!userProps) return undefined;\n\t\tconst resolved = propsOrGetter(userProps as ExtendedUserProps);\n\t\treturn resolved as PropsLike | undefined;\n\t}\n\treturn propsOrGetter as PropsLike;\n}\n\n/**\n * Merges an array of interaction-hook prop bags into the four prop-getters\n * consumed by Base UI's floating surfaces. Each getter runs `mergePropsN`\n * at call time, so event-handler chaining and `preventBaseUIHandler` work\n * consistently with the rest of the Solid internals.\n */\nexport function useInteractions(\n\tpropsList: Array<InteractionEntry> = [],\n): UseInteractionsReturn {\n\tfunction mergeFor<Key extends keyof ElementProps>(\n\t\telementKey: Key,\n\t\tuserProps: ElementPropsBag | undefined,\n\t\tseed?: PropsLike,\n\t): PropsLike {\n\t\tconst isItem = elementKey === \"item\";\n\t\tconst sources: Array<PropsLike | undefined> = [];\n\t\tif (seed) sources.push(seed);\n\t\tfor (let i = 0; i < propsList.length; i += 1) {\n\t\t\tconst resolved = resolvePropsFor(propsList[i], elementKey, userProps);\n\t\t\tsources.push(isItem ? stripItemScopeKeys(resolved) : resolved);\n\t\t}\n\t\tsources.push(isItem ? stripItemScopeKeys(userProps) : userProps);\n\t\treturn mergePropsN(sources);\n\t}\n\n\tfunction getReferenceProps(userProps?: ElementPropsBag): PropsLike {\n\t\treturn mergeFor(\"reference\", userProps);\n\t}\n\n\tfunction getFloatingProps(userProps?: ElementPropsBag): PropsLike {\n\t\t// `tabIndex: -1` + `data-quoin-focusable` seed the floating element\n\t\t// as focusable-but-not-tabbable; later sources may override either.\n\t\tconst seed: PropsLike = {\n\t\t\ttabIndex: -1,\n\t\t\t[FOCUSABLE_ATTRIBUTE]: \"\",\n\t\t};\n\t\treturn mergeFor(\"floating\", userProps, seed);\n\t}\n\n\tfunction getItemProps(\n\t\tuserProps?: Omit<ElementPropsBag, \"selected\" | \"active\"> &\n\t\t\tExtendedUserProps,\n\t): PropsLike {\n\t\treturn mergeFor(\"item\", userProps as ElementPropsBag | undefined);\n\t}\n\n\tfunction getTriggerProps(userProps?: ElementPropsBag): PropsLike {\n\t\treturn mergeFor(\"trigger\", userProps);\n\t}\n\n\treturn {\n\t\tgetReferenceProps,\n\t\tgetFloatingProps,\n\t\tgetItemProps,\n\t\tgetTriggerProps,\n\t};\n}\n"],"mappings":"AAAA;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;AACA;AACA;AACA;AACA;AACA;;AAEA,SAASA,WAAW,QAAwB,qBAAqB;AAMjE,SACCC,UAAU,EACVC,mBAAmB,EACnBC,YAAY,QACN,oBAAoB;AAgB3B;AACA;AACA;AACA;AACA;AACA,SAASC,kBAAkBA,CAC1BC,MAA6B,EACL;EACxB,IAAI,CAACA,MAAM,EAAE,OAAOA,MAAM;EAC1B,IAAI,EAAEJ,UAAU,IAAII,MAAM,CAAC,IAAI,EAAEF,YAAY,IAAIE,MAAM,CAAC,EAAE,OAAOA,MAAM;EACvE,MAAMC,GAA4B,GAAG,CAAC,CAAC;EACvC,KAAK,MAAMC,GAAG,IAAIC,MAAM,CAACC,IAAI,CAACJ,MAAM,CAAC,EAAE;IACtC,IAAIE,GAAG,KAAKN,UAAU,IAAIM,GAAG,KAAKJ,YAAY,EAAE;IAChDG,GAAG,CAACC,GAAG,CAAC,GAAIF,MAAM,CAA6BE,GAAG,CAAC;EACpD;EACA,OAAOD,GAAG;AACX;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA,SAASI,eAAeA,CACvBC,KAAuB,EACvBC,UAAe,EACfC,SAAsC,EACd;EACxB,IAAI,CAACF,KAAK,EAAE,OAAOG,SAAS;EAC5B,MAAMC,aAAa,GAAGJ,KAAK,CAACC,UAAU,CAAC;EACvC,IAAIG,aAAa,IAAI,IAAI,EAAE,OAAOD,SAAS;EAC3C,IAAI,OAAOC,aAAa,KAAK,UAAU,EAAE;IACxC,IAAI,CA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