//#region src/utilities/context.d.ts
/**
* Register `value` under `key` on `host`. Calls to {@link getContext} from
* any descendant of `host` (in the DOM tree, including across open shadow
* roots) resolve to this value, unless an inner provider with the same key
* shadows it. Returns `host` so the call can be used inline.
*
* Must be called inside an `effect` / `effectScope` (or a wrapped
* `connectedCallback`). The entry is auto-removed via `onCleanup` when the
* surrounding scope disposes. Passes `null` through unchanged.
*
* @example
* Inline form — `setContext` returns the host so it composes directly:
* ```tsx
* import { signal } from "elements-kit/signals";
* import { setContext } from "elements-kit/utilities/context";
*
* const THEME = Symbol("theme");
*
* function ThemeProvider({ children }: { children: JSX.Element }) {
* const theme = signal<"light" | "dark">("dark");
* return setContext(
{children}
, THEME, theme);
* }
* ```
*
* @example
* Equivalent `ref` form:
* ```tsx
* function ThemeProvider({ children }: { children: JSX.Element }) {
* const theme = signal<"light" | "dark">("dark");
* return (
* setContext(el, THEME, theme)}>
* {children}
*
* );
* }
* ```
*/
declare function setContext(host: H, key: PropertyKey, value: T): H;
/**
* Walk up from `consumer` (across open shadow boundaries via
* `getRootNode().host`) and return the first registered value for `key`,
* or `undefined`.
*
* One-shot — does not subscribe to anything. If `value` is a
* `Signal`/`Computed`, the caller reads it inside their own `effect` for
* reactivity.
*
* @example
* Inside a custom element's `connectedCallback`:
* ```ts
* const theme = getContext<() => "light" | "dark">(this, THEME);
* effect(() => { this.dataset.theme = theme?.() ?? "light"; });
* ```
*
* @example
* From a JSX component — defer the lookup with ``, since `ref`
* runs before the element is inserted:
* ```tsx
* import { signal, type Signal } from "elements-kit/signals";
* import "elements-kit/utilities/dom-lifecycle";
*
* function ThemeConsumer() {
* const theme = signal | undefined>(undefined);
* return (
*
* theme(getContext(el, THEME))}
* />
* {() => theme()?.() ?? "light"}
*
* );
* }
* ```
*/
declare function getContext(consumer: Element, key: PropertyKey): T | undefined;
//#endregion
export { getContext, setContext };