{"version":3,"names":["createContext","createMemo","useContext","createPopupCore","readOption","SNAPSHOT_KEYS","snapshotKeys","TooltipContext","useTooltip","optional","ctx","Error","createTooltip","options","core","open","disabled","onOpenChange","trackCursorAxis","name","disableHoverablePopup","Boolean","delay","closeDelay","api","setOpen","toggle","Provider","props","children","TOOLTIP_SNAPSHOT_KEYS"],"sources":["create-tooltip.tsx"],"sourcesContent":["import type { JSX } from \"@solidjs/web\";\nimport { type Accessor, createContext, createMemo, useContext } from \"solid-js\";\nimport { createPopupCore } from \"../internals/create-popup-core\";\nimport { type MaybeAccessor, readOption } from \"../internals/maybe-accessor\";\nimport {\n\tSNAPSHOT_KEYS,\n\ttype Snapshottable,\n\tsnapshotKeys,\n} from \"../internals/observability/snapshot\";\n\n/**\n * Why the tooltip's open state changed.\n *\n * - `\"trigger-hover\"` — pointer entered / left the trigger.\n * - `\"trigger-focus\"` — keyboard focus moved to / from the trigger.\n * - `\"trigger-press\"` — trigger was pressed (click / Enter / Space).\n * - `\"escape-key\"` — Escape dismissed the tooltip.\n * - `\"outside-press\"` — pointer pressed outside.\n * - `\"imperative\"` — `t.setOpen()` called programmatically.\n */\nexport type TooltipChangeReason =\n\t| \"trigger-hover\"\n\t| \"trigger-focus\"\n\t| \"trigger-press\"\n\t| \"escape-key\"\n\t| \"outside-press\"\n\t| \"imperative\";\n\n/**\n * Options for {@link createTooltip}.\n */\nexport interface CreateTooltipOptions {\n\t/**\n\t * Open state. Consumer-owned signal — the primitive reads through the\n\t * accessor and does NOT keep an internal copy.\n\t */\n\topen: MaybeAccessor<boolean>;\n\t/**\n\t * Whether interaction is suppressed.\n\t * @default false\n\t */\n\tdisabled?: MaybeAccessor<boolean>;\n\t/**\n\t * Pre-change callback. Fired via `runWithOwner(null, ...)` to escape the\n\t * reactive owner.\n\t */\n\tonOpenChange?: (\n\t\topen: boolean,\n\t\tevent: Event,\n\t\treason: TooltipChangeReason,\n\t) => void;\n\t/**\n\t * Axis on which to track the cursor position. `\"none\"` anchors to the\n\t * trigger's bounding box.\n\t * @default \"none\"\n\t */\n\ttrackCursorAxis?: MaybeAccessor<\"none\" | \"x\" | \"y\" | \"both\">;\n\t/**\n\t * When true, the hover-intent `safePolygon` is NOT installed so any\n\t * cursor movement off the trigger closes the tooltip immediately.\n\t * @default false\n\t */\n\tdisableHoverablePopup?: MaybeAccessor<boolean>;\n\t/**\n\t * Delay before opening (ms).\n\t * @default 600\n\t */\n\tdelay?: MaybeAccessor<number>;\n\t/**\n\t * Delay before closing on hover-out (ms).\n\t * @default 300\n\t */\n\tcloseDelay?: MaybeAccessor<number>;\n}\n\n/**\n * Public API returned by {@link createTooltip}.\n */\nexport interface TooltipApi {\n\t/** Reactive accessor for the current open state. */\n\topen: Accessor<boolean>;\n\t/** Whether interaction is suppressed. */\n\tdisabled: Accessor<boolean>;\n\t/** Axis on which cursor tracking is applied. */\n\ttrackCursorAxis: Accessor<\"none\" | \"x\" | \"y\" | \"both\">;\n\t/** Whether the hoverable-popup safe-polygon is disabled. */\n\tdisableHoverablePopup: Accessor<boolean>;\n\t/** Open delay in ms. */\n\tdelay: Accessor<number>;\n\t/** Close delay in ms. */\n\tcloseDelay: Accessor<number>;\n\n\t/** Imperative open setter. */\n\tsetOpen: (next: boolean, event?: Event, reason?: TooltipChangeReason) => void;\n\t/** Flip open (no-op when disabled). */\n\ttoggle: (event?: Event, reason?: TooltipChangeReason) => void;\n\n\t/** Context provider. */\n\tProvider: (props: { children: JSX.Element }) => JSX.Element;\n}\n\nconst TooltipContext = createContext<TooltipApi | null>(null);\n\n/**\n * Read the nearest {@link TooltipApi} provided by `t.Provider`. Throws if\n * used outside a Provider unless `optional` is true.\n */\nexport function useTooltip(): TooltipApi;\nexport function useTooltip(optional: true): TooltipApi | null;\nexport function useTooltip(optional?: boolean): TooltipApi | null {\n\tconst ctx = useContext(TooltipContext);\n\tif (ctx == null && !optional) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: useTooltip() must be called inside a <t.Provider>.\",\n\t\t);\n\t}\n\treturn ctx;\n}\n\n/**\n * Headless primitive for a tooltip compound. Owns logical state — open,\n * disabled, cursor-tracking knobs, hover delays. DOM machinery (floating-ui\n * positioning, portal, animation) lives in `<Tooltip.Root>` which composes\n * this primitive.\n */\nexport function createTooltip(options: CreateTooltipOptions): TooltipApi {\n\tconst core = createPopupCore<TooltipChangeReason>({\n\t\topen: options.open,\n\t\tdisabled: options.disabled,\n\t\tonOpenChange: options.onOpenChange,\n\t});\n\n\tconst trackCursorAxis = createMemo<\"none\" | \"x\" | \"y\" | \"both\">(\n\t\t() =>\n\t\t\t(readOption(options.trackCursorAxis) ?? \"none\") as\n\t\t\t\t| \"none\"\n\t\t\t\t| \"x\"\n\t\t\t\t| \"y\"\n\t\t\t\t| \"both\",\n\t\t{ name: \"tooltip.trackCursorAxis\" },\n\t);\n\n\tconst disableHoverablePopup = createMemo<boolean>(\n\t\t() => Boolean(readOption(options.disableHoverablePopup)),\n\t\t{ name: \"tooltip.disableHoverablePopup\" },\n\t);\n\n\tconst delay = createMemo<number>(() => readOption(options.delay) ?? 600, {\n\t\tname: \"tooltip.delay\",\n\t});\n\n\tconst closeDelay = createMemo<number>(\n\t\t() => readOption(options.closeDelay) ?? 300,\n\t\t{ name: \"tooltip.closeDelay\" },\n\t);\n\n\tconst api: TooltipApi = {\n\t\topen: core.open,\n\t\tdisabled: core.disabled,\n\t\ttrackCursorAxis,\n\t\tdisableHoverablePopup,\n\t\tdelay,\n\t\tcloseDelay,\n\t\tsetOpen: core.setOpen,\n\t\ttoggle: core.toggle,\n\t\tProvider: (props) => (\n\t\t\t<TooltipContext value={api}>{props.children}</TooltipContext>\n\t\t),\n\t};\n\n\t(api as TooltipApi & Snapshottable)[SNAPSHOT_KEYS] = TOOLTIP_SNAPSHOT_KEYS;\n\n\treturn api;\n}\n\nconst TOOLTIP_SNAPSHOT_KEYS = snapshotKeys<TooltipApi>(\n\t\"open\",\n\t\"disabled\",\n\t\"trackCursorAxis\",\n\t\"disableHoverablePopup\",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