{"version":3,"names":["isMouseLikePointerType","resolveValue","value","pointerType","getDelay","prop","result","getRestMs","isClickLikeOpenEvent","openEventType","interactedInside"],"sources":["use-hover-shared.ts"],"sourcesContent":["/**\n * Stage 4.4 port of Base UI React's `useHoverShared` helpers.\n *\n * React source:\n *   `base-ui/packages/react/src/floating-ui-react/hooks/useHoverShared.ts`\n *\n * Central home for:\n *\n *   - `HandleClose` / `HandleCloseContext` / `HandleCloseOptions` types\n *     consumed by `safePolygon` and the hover cluster. These originally\n *     lived in a local placeholder inside `safe-polygon.ts` (Stage 1\n *     deviation, see `remaining-work.md` note) and are now re-homed here.\n *   - `getDelay` / `getRestMs` scalar resolvers (accept either a raw\n *     value or a getter function).\n *   - `isClickLikeOpenEvent` — shared hover-vs-click disambiguation.\n *   - `SafePolygonOptions` re-export for consumers that reference the\n *     option bag name alone.\n *\n * The types stay framework-agnostic so `safe-polygon.ts` (which runs\n * pure geometry) can consume them without pulling in Solid runtime\n * code. `safe-polygon.ts` imports the types from this module — hover\n * hook files also import runtime helpers from here, which is why the\n * dependency direction is `safe-polygon → use-hover-shared` (types\n * only) and `use-hover-* → use-hover-shared` + `use-hover-* →\n * safe-polygon` (runtime + types). That avoids the circular reference\n * Stage 1 worked around with placeholder declarations.\n */\n\nimport type { ExtendedElements, FloatingTreeType, Placement } from \"../types\";\nimport { isMouseLikePointerType } from \"../utils/event\";\n\n// ---------------------------------------------------------------------------\n// Types — moved out of `safe-polygon.ts` to resolve the Stage-1 deferral.\n// ---------------------------------------------------------------------------\n\nexport interface HandleCloseOptions {\n\tblockPointerEvents?: boolean | undefined;\n\tgetScope?: (() => HTMLElement | SVGSVGElement | null) | undefined;\n}\n\nexport interface HandleCloseContext {\n\tx: number | null;\n\ty: number | null;\n\tplacement: Placement | null;\n\telements: Pick<ExtendedElements, \"domReference\" | \"floating\">;\n\tonClose: () => void;\n\tnodeId?: string | undefined;\n\ttree?: FloatingTreeType | null | undefined;\n\tleave?: boolean | undefined;\n}\n\nexport type HandleCloseContextBase = Omit<\n\tHandleCloseContext,\n\t\"onClose\" | \"tree\" | \"x\" | \"y\"\n>;\n\nexport interface HandleClose {\n\t(context: HandleCloseContext): (event: MouseEvent) => void;\n\t__options?: HandleCloseOptions | undefined;\n}\n\n/**\n * Option bag accepted by the `safePolygon` factory. Matches\n * `HandleCloseOptions` shape 1:1 — the alias exists purely so\n * call-sites that reference `SafePolygonOptions` by name in the React\n * source keep working.\n */\nexport type SafePolygonOptions = HandleCloseOptions;\n\n// ---------------------------------------------------------------------------\n// Scalar resolvers\n// ---------------------------------------------------------------------------\n\ntype HoverDelay = number | Partial<{ open: number; close: number }>;\n\nfunction resolveValue<T>(\n\tvalue: T | (() => T) | undefined,\n\tpointerType?: PointerEvent[\"pointerType\"],\n): T | 0 | undefined {\n\tif (pointerType != null && !isMouseLikePointerType(pointerType)) {\n\t\treturn 0;\n\t}\n\n\tif (typeof value === \"function\") {\n\t\treturn (value as () => T)();\n\t}\n\n\treturn value;\n}\n\nexport function getDelay(\n\tvalue: HoverDelay | (() => HoverDelay) | undefined,\n\tprop: \"open\" | \"close\",\n\tpointerType?: PointerEvent[\"pointerType\"],\n): number | undefined {\n\tconst result = resolveValue(value, pointerType);\n\tif (typeof result === \"number\") {\n\t\treturn result;\n\t}\n\n\treturn result?.[prop];\n}\n\nexport function getRestMs(value: number | (() => number)): number {\n\tif (typeof value === \"function\") {\n\t\treturn value();\n\t}\n\treturn value;\n}\n\n/**\n * `true` when the current open event was a click-style interaction (or when\n * a `pointerdown` inside the floating element promoted the surface to\n * \"click-owned\" via `interactedInside`).\n */\nexport function isClickLikeOpenEvent(\n\topenEventType: string | undefined,\n\tinteractedInside: boolean,\n): boolean {\n\treturn (\n\t\tinteractedInside ||\n\t\topenEventType === \"click\" ||\n\t\topenEventType === \"mousedown\"\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;;AAGA,SAASA,sBAAsB,QAAQ,gBAAgB;;AAEvD;AACA;AACA;;AA4BA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;;AAIA,SAASC,YAAYA,CACpBC,KAAgC,EAChCC,WAAyC,EACrB;EACpB,IAAIA,WAAW,IAAI,IAAI,IAAI,CAACH,sBAAsB,CAACG,WAAW,CAAC,EAAE;IAChE,OAAO,CAAC;EACT;EAEA,IAAI,OAAOD,KAAK,KAAK,UAAU,EAAE;IAChC,OAAQA,KAAK,CAAa,CAAC;EAC5B;EAEA,OAAOA,KAAK;AACb;AAEA,OAAO,SAASE,QAAQA,CACvBF,KAAkD,EAClDG,IAAsB,EACtBF,WAAyC,EACpB;EACrB,MAAMG,MAAM,GAAGL,YAAY,CAACC,KAAK,EAAEC,WAAW,CAAC;EAC/C,IAAI,OAAOG,MAAM,KAAK,QAAQ,EAAE;IAC/B,OAAOA,MAAM;EACd;EAEA,OAAOA,MAAM,GAAGD,IAAI,CAAC;AACtB;AAEA,OAAO,SAASE,SAASA,CAACL,KAA8B,EAAU;EACjE,IAAI,OAAOA,KAAK,KAAK,UAAU,EAAE;IAChC,OAAOA,KAAK,CAAC,CAAC;EACf;EACA,OAAOA,KAAK;AACb;;AAEA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASM,oBAAoBA,CACnCC,aAAiC,EACjCC,gBAAyB,EACf;EACV,OACCA,gBAAgB,IAChBD,aAAa,KAAK,OAAO,IACzBA,aAAa,KAAK,WAAW;AAE/B","ignoreList":[]}