{"version":3,"names":["createContext","useContext","SliderRootContext","useSliderRootContext","context","Error"],"sources":["slider-root-context.ts"],"sourcesContent":["import { type Accessor, createContext, useContext } from \"solid-js\";\nimport type {\n\tBaseUIChangeEventDetails,\n\tBaseUIGenericEventDetails,\n\tREASONS,\n} from \"../internals/change-event-details\";\nimport type { CompositeMetadata } from \"../internals/composite/composite-context.ts\";\nimport type { FieldRootState } from \"../internals/field-constants\";\nimport type { ThumbCollisionBehavior } from \"../internals/slider-utils/resolve-thumb-collision.ts\";\nimport type { Orientation } from \"../internals/types\";\n\n/**\n * Custom event-details properties carried on every slider `onValueChange`.\n */\nexport interface SliderRootChangeEventCustomProperties {\n\tactiveThumbIndex: number;\n}\n\nexport type SliderRootChangeEventReason =\n\t| typeof REASONS.inputChange\n\t| typeof REASONS.trackPress\n\t| typeof REASONS.drag\n\t| typeof REASONS.keyboard\n\t| typeof REASONS.none;\n\nexport type SliderRootChangeEventDetails = BaseUIChangeEventDetails<\n\tSliderRootChangeEventReason,\n\tSliderRootChangeEventCustomProperties\n>;\n\nexport type SliderRootCommitEventReason = SliderRootChangeEventReason;\nexport type SliderRootCommitEventDetails =\n\tBaseUIGenericEventDetails<SliderRootCommitEventReason>;\n\n/**\n * State surface projected to `data-*` and visible to `class` / `style` /\n * `render` callbacks across every slider part.\n */\nexport interface SliderRootState extends FieldRootState {\n\tactiveThumbIndex: number;\n\tdisabled: boolean;\n\tdragging: boolean;\n\tmax: number;\n\tmin: number;\n\tminStepsBetweenValues: number;\n\torientation: Orientation;\n\tstep: number;\n\tvalues: readonly number[];\n}\n\n/**\n * Per-thumb metadata carried through the CompositeList. The `inputId` lets\n * `<Slider.Value>` build a space-separated `htmlFor` list.\n */\nexport interface ThumbMetadata {\n\tinputId: string | undefined;\n}\n\n/**\n * Two-element tuple capturing the pixel-percent position of the first and\n * last thumb relative to the control's `getBoundingClientRect()`. Each slot\n * is `undefined` until the corresponding thumb has been measured. Only used\n * when `thumbAlignment !== 'center'` — center-mode sliders derive positions\n * from value math and skip the ResizeObserver pipeline entirely.\n */\nexport type IndicatorPosition = readonly [\n\tnumber | undefined,\n\tnumber | undefined,\n];\n\n/**\n * Value handed down by `<Slider.Root>` to its compound parts. Reactive reads\n * are `Accessor<T>` so descendants can subscribe precisely.\n *\n * The `inset` / `renderBeforeHydration` / `indicatorPosition` /\n * `setIndicatorPosition` fields match React's edge-alignment context surface.\n * The only piece still deferred is the pre-hydration `<script>` injected by\n * React's `prehydrationScript.min.ts`.\n */\nexport interface SliderRootContextValue {\n\tactive: Accessor<number>;\n\tlastUsedThumbIndex: Accessor<number>;\n\tcontrolRef: { current: HTMLElement | null };\n\tthumbRefs: { current: Array<HTMLElement | null> };\n\tdragging: Accessor<boolean>;\n\tsetDragging: (next: boolean) => void;\n\tdisabled: Accessor<boolean>;\n\tformatOptions: Accessor<Intl.NumberFormatOptions | undefined>;\n\tlocale: Accessor<Intl.LocalesArgument | undefined>;\n\tlargeStep: Accessor<number>;\n\tstep: Accessor<number>;\n\tmin: Accessor<number>;\n\tmax: Accessor<number>;\n\tminStepsBetweenValues: Accessor<number>;\n\torientation: Accessor<Orientation>;\n\tthumbCollisionBehavior: Accessor<ThumbCollisionBehavior>;\n\tform: Accessor<string | undefined>;\n\tname: Accessor<string | undefined>;\n\tvalues: Accessor<readonly number[]>;\n\tstate: Accessor<SliderRootState>;\n\tlabelId: Accessor<string | undefined>;\n\trootLabelId: Accessor<string | undefined>;\n\tsetLabelId: (id: string | undefined) => void;\n\tsetActive: (index: number) => void;\n\thandleInputChange: (\n\t\tvalueInput: number,\n\t\tindex: number,\n\t\tevent: KeyboardEvent | Event,\n\t) => void;\n\tsetValue: (\n\t\tnewValue: number | number[],\n\t\tdetails?: SliderRootChangeEventDetails,\n\t) => void;\n\tonValueCommitted: (\n\t\tvalue: number | readonly number[],\n\t\tdetails: SliderRootCommitEventDetails,\n\t) => void;\n\tregisterThumbMap: (\n\t\tmap: Map<Element, CompositeMetadata<ThumbMetadata> | null>,\n\t) => void;\n\tthumbMap: Accessor<Map<Element, CompositeMetadata<ThumbMetadata> | null>>;\n\t// Refs used by pointer-drag plumbing across parts.\n\tpressedInputRef: { current: HTMLInputElement | null };\n\tpressedThumbCenterOffsetRef: { current: number | null };\n\tpressedThumbIndexRef: { current: number };\n\tpressedValuesRef: { current: readonly number[] | null };\n\tlastChangedValueRef: { current: number | readonly number[] | null };\n\tlastChangeReasonRef: { current: SliderRootChangeEventReason };\n\t// Field bridge — children use these to commit validation.\n\tcommitValidation: (value: unknown, revalidate?: boolean) => Promise<void>;\n\tregisterFieldControlRef: (element: HTMLElement | null) => void;\n\t// Edge-alignment pipeline. `inset` is `true` when `thumbAlignment` is\n\t// `\"edge\"` or `\"edge-client-only\"`; `renderBeforeHydration` is `true` only\n\t// for `\"edge\"`. The latter is dormant until the SSR prehydration `<script>`\n\t// is wired but is plumbed now so SSR work is\n\t// purely additive.\n\tinset: Accessor<boolean>;\n\trenderBeforeHydration: Accessor<boolean>;\n\tindicatorPosition: Accessor<IndicatorPosition>;\n\tsetIndicatorPosition: (\n\t\tupdater: (prev: IndicatorPosition) => IndicatorPosition,\n\t) => void;\n}\n\n/**\n * Slider root context. `createContext<T | null>(null)` + `== null` sentinel\n * — Solid 2's `useContext` throws `ContextNotFoundError` when\n * the default is `undefined`, which would shadow the intended Base UI error\n * message below.\n */\nexport const SliderRootContext = createContext<SliderRootContextValue | null>(\n\tnull,\n);\n\nexport function useSliderRootContext(): SliderRootContextValue {\n\tconst context = useContext(SliderRootContext);\n\tif (context == null) {\n\t\tthrow new Error(\n\t\t\t\"Base UI: SliderRootContext is missing. Slider parts must be placed within <Slider.Root>.\",\n\t\t);\n\t}\n\treturn context;\n}\n"],"mappings":"AAAA,SAAwBA,aAAa,EAAEC,UAAU,QAAQ,UAAU;;AAWnE;AACA;AACA;;AAqBA;AACA;AACA;AACA;;AAaA;AACA;AACA;AACA;;AAKA;AACA;AACA;AACA;AACA;AACA;AACA;;AAMA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAkEA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,MAAMC,iBAAiB,GAAGF,aAAa,CAC7C,IACD,CAAC;AAED,OAAO,SAASG,oBAAoBA,CAAA,EAA2B;EAC9D,MAAMC,OAAO,GAAGH,UAAU,CAACC,iBAAiB,CAAC;EAC7C,IAAIE,OAAO,IAAI,IAAI,EAAE;IACpB,MAAM,IAAIC,KAAK,CACd,0FACD,CAAC;EACF;EACA,OAAOD,OAAO;AACf","ignoreList":[]}