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

/**
 * Context value published by `<Fieldset.Root>`.
 *
 * `<Fieldset.Root>` exposes:
 *
 *   - `disabled` — reactive bit that descendant control parts merge with
 *     their own `disabled` prop (matches React Base UI).
 *   - `legendId` / `setLegendId` — the `<Fieldset.Legend>` id registration
 *     pair, so the root can wire `aria-labelledby`. These mirror the
 *     `useRegisteredLabelId` pattern used across other tier-1 roots
 *     (progress / meter) and are `undefined` on the NOOP context value.
 *
 * Mirrors Base UI React's
 * `packages/react/src/fieldset/root/FieldsetRootContext.ts`.
 */

export const NOOP_FIELDSET_CONTEXT = {
  disabled: () => false,
  present: false
};

/**
 * Context carrying `<Fieldset.Root>` state. Provided via
 * `<FieldsetContext value={...}>` (Solid 2's context-as-provider pattern).
 */
export const FieldsetContext = createContext(NOOP_FIELDSET_CONTEXT);

/**
 * Read the current `<Fieldset.Root>` context. Returns {@link NOOP_FIELDSET_CONTEXT}
 * when no fieldset is present — callers can branch on `.present` if they
 * need to know whether a real fieldset wraps them.
 */
export function useFieldsetContext() {
  return useContext(FieldsetContext);
}
//# sourceMappingURL=fieldset-context.jsx.map
