{"version":3,"names":["createContext","useContext","AccordionRootContext","useAccordionRootContext","context","Error"],"sources":["accordion-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type { TextDirection } from \"../direction-provider/direction-provider-context.ts\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tREASONS,\n} from \"../internals/change-event-details\";\nimport type { Orientation } from \"../internals/types\";\n\n/**\n * Change-event reason namespace for `<Accordion.Root>`. Matches Base UI\n * React's union.\n */\nexport type AccordionRootChangeEventReason =\n\t| typeof REASONS.triggerPress\n\t| typeof REASONS.none;\n\nexport type AccordionRootChangeEventDetails =\n\tBaseUIChangeEventDetails<AccordionRootChangeEventReason>;\n\n/**\n * Accordion supports a single scalar value (single-expand) or an array\n * (multi-expand). Internally we always store an array — a single-expand value\n * is represented as either `[]` or `[currentlyOpen]`. The public surface\n * follows React's convention of `Value[]`.\n */\nexport type AccordionValue<Value = unknown> = Value[];\n\n/**\n * Public state surface for the root — flows through `data-*` projection.\n * Matches Base UI React's `AccordionRootState`.\n */\nexport interface AccordionRootState<Value = unknown> {\n\t/** Currently-open item values (always an array internally). */\n\tvalue: AccordionValue<Value>;\n\t/** Whether the accordion ignores user interaction. */\n\tdisabled: boolean;\n\t/** Visual orientation — controls arrow key direction. */\n\torientation: Orientation;\n}\n\n/**\n * Context shape shared across `<Accordion.Root>`, `<Accordion.Item>`,\n * `<Accordion.Trigger>` and `<Accordion.Panel>`. Accessor-heavy so descendants\n * stay reactive without re-deriving.\n *\n * `accordionItemRefs` is a plain array (owned by `<CompositeList>`) because\n * the trigger's keyboard handler reads it synchronously inside event handlers.\n */\nexport interface AccordionRootContextValue<Value = unknown> {\n\t/** Plain array of registered item elements, in DOM order. */\n\taccordionItemRefs: Array<HTMLElement | null>;\n\t/** Current text direction (threaded through for RTL arrow-key swap). */\n\tdirection: Accessor<TextDirection>;\n\t/** Whether the root (and by extension every item) is disabled. */\n\tdisabled: Accessor<boolean>;\n\t/**\n\t * Imperative value-change entry point. Called by an item on toggle; the\n\t * root applies single/multi semantics internally.\n\t */\n\thandleValueChange: (\n\t\tnewValue: unknown,\n\t\tnextOpen: boolean,\n\t\teventDetails: AccordionRootChangeEventDetails,\n\t) => void;\n\t/** Whether panels use `hidden=\"until-found\"`. */\n\thiddenUntilFound: Accessor<boolean>;\n\t/** Whether panels stay mounted when closed. */\n\tkeepMounted: Accessor<boolean>;\n\t/** Whether arrow navigation between triggers loops at the extents. */\n\tloopFocus: Accessor<boolean>;\n\t/** Current orientation. */\n\torientation: Accessor<Orientation>;\n\t/** Root's projected state (for `data-*`). */\n\tstate: Accessor<AccordionRootState<Value>>;\n\t/** Currently-open item values. */\n\tvalue: Accessor<AccordionValue<Value>>;\n}\n\n/**\n * Context for the accordion compound. `createContext<T | null>(null)` +\n * `== null` sentinel — Solid 2's `useContext` throws\n * `ContextNotFoundError` when the default is `undefined`, which would shadow\n * the intended Base UI error message below.\n */\nexport const AccordionRootContext =\n\tcreateContext<AccordionRootContextValue<unknown> | null>(null);\n\nexport function useAccordionRootContext<\n\tValue = unknown,\n>(): AccordionRootContextValue<Value> {\n\tconst context = useContext(AccordionRootContext);\n\tif (context == null) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: AccordionRootContext is missing. Accordion parts must be placed within <Accordion.Root>.\",\n\t\t);\n\t}\n\treturn context as AccordionRootContextValue<Value>;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAQnE;AACA;AACA;AACA;;AAQA;AACA;AACA;AACA;AACA;AACA;;AAGA;AACA;AACA;AACA;;AAUA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AA+BA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,oBAAoB,GAChCF,aAAa,CAA4C,IAAI,CAAC;AAE/D,OAAO,SAASG,uBAAuBA,CAAA,EAED;EACrC,MAAMC,OAAO,GAAGH,UAAU,CAACC,oBAAoB,CAAC;EAChD,IAAIE,OAAO,IAAI,IAAI,EAAE;IACpB,MAAM,IAAIC,KAAK,CACd,mGACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}