/**
 * Context shape for `<Dialog.Root>` — consumed by every dialog sub-part.
 *
 * Mirrors Base UI React's `DialogRootContext` (`packages/react/src/dialog/
 * root/DialogRootContext.ts`). The Solid port exposes every reactive field
 * as an `Accessor<T>` so consumers can subscribe without wrapping.
 *
 * Context uses the `createContext<T | null>(null)` + `== null` sentinel
 * pattern — `<Dialog.Root>` wraps the subtree and every part
 * reads through `useDialogRootContext()`, which throws if no provider is
 * present (unless `optional: true` is passed).
 */

import { createContext, useContext } from "solid-js";

/**
 * Modal kind for `<Dialog.Root>`:
 *
 * - `true` (default): focus-trap + scroll-lock + outside pointer block.
 * - `false`: none of the above (dialog is dismissable via the backdrop
 *   click path but keyboard focus isn't trapped).
 * - `"trap-focus"`: focus is trapped but scroll isn't locked and outside
 *   pointer interactions remain enabled.
 */

/** Change-event reason union for `<Dialog.Root>`. */

/**
 * `BaseUIChangeEventDetails` extended with the React Dialog-specific
 * `preventUnmountOnClose()` hook. When called from inside `onOpenChange`,
 * the dialog stays mounted after `open=false` — useful for consumers
 * controlling unmount timing through an external animation library.
 */

/**
 * Shared state surfaced on the dialog root context. Every field is a
 * signal/accessor except imperative writers.
 */

/**
 * Context — `null` is the sentinel for "no provider". We don't use
 * `undefined` here.
 */
export const DialogRootContext = createContext(null);

/**
 * Read the current `<Dialog.Root>` context. Throws unless `optional` is
 * `true`. Mirrors Base UI React's `useDialogRootContext` overloads.
 */

export function useDialogRootContext(optional) {
  const context = useContext(DialogRootContext);
  if (context == null && !optional) {
    throw new Error("Base UI: DialogRootContext is missing. Dialog parts must be placed within <Dialog.Root>.");
  }
  return context;
}

/**
 * Drawer detection context. Set to `true` by `<Drawer.Root>` (not yet
 * ported), read here by `<Dialog.Root>` to decide whether to count this
 * dialog as a drawer for the nested-open bookkeeping. Ships now so the
 * counting paths compose cleanly when drawer lands later.
 */
export const IsDrawerContext = createContext(false);
//# sourceMappingURL=dialog-root-context.jsx.map
