{"version":3,"names":["dynamic","omit","untrack","userRef","useLabel","mergeRootProps","resolveClassStyle","useRegisteredLabelId","useSliderRootContext","sliderDataAttrs","SliderLabel","props","context","rootLabelId","setLabelId","id","handleClick","event","control","controlRef","current","target","closest","inputs","querySelectorAll","length","focus","preventScroll","userClassStyle","state","userProps","internalSlot","onClick","merged","Tag","as"],"sources":["slider-label.tsx"],"sourcesContent":["import type { JSX, ValidComponent } from \"@solidjs/web\";\nimport { dynamic } from \"@solidjs/web\";\nimport { omit, untrack } from \"solid-js\";\nimport { userRef } from \"../../internals/compose-refs\";\nimport { useLabel } from \"../../internals/labelable-provider/use-label.ts\";\nimport { mergeRootProps } from \"../../internals/merge-root-props\";\nimport { resolveClassStyle } from \"../../internals/resolve-class-style\";\nimport type { BaseUIComponentProps } from \"../../internals/types\";\nimport { useRegisteredLabelId } from \"../../internals/use-registered-label-id\";\nimport {\n\ttype SliderRootState,\n\tuseSliderRootContext,\n} from \"../slider-root-context.ts\";\nimport { sliderDataAttrs } from \"../utils/state-attrs.ts\";\n\nexport type SliderLabelState = SliderRootState;\n\nexport interface SliderLabelProps\n\textends Omit<BaseUIComponentProps<\"div\", SliderLabelState>, \"id\"> {\n\t/** Tag/component to render. Defaults to `\"div\"`. */\n\tas?: ValidComponent;\n}\n\n/**\n * Accessible label automatically associated with the slider root (via\n * `aria-labelledby`) and thumb inputs (via the labelable provider). Renders\n * a `<div>` (or `as` override).\n *\n * Registers its id twice — once on the root's label id setter (so the root's\n * `aria-labelledby` picks it up in the `resolveAriaLabelledBy` chain), and\n * once into the labelable provider (so nested thumb `<input>`s discover it\n * through `useAriaLabelledBy`). Matches React's double-registration setup.\n *\n * Clicking the label focuses the lone thumb's `<input type=\"range\">` when the\n * slider is not a range (there is exactly one `input[type=\"range\"]` inside\n * `controlRef`). For range sliders this is intentionally a no-op — there's no\n * single correct focus target. Matches React `SliderLabel.tsx:29-49`.\n *\n * §1 wave 3: replaces `renderElement` with `dynamic(() => props.as ?? \"div\")`.\n */\nexport function SliderLabel(props: SliderLabelProps): JSX.Element {\n\tconst context = useSliderRootContext();\n\n\t// Register with the parent root's label id setter — drives its\n\t// `resolveAriaLabelledBy` fallback chain. The override `id` is handled\n\t// through `useRegisteredLabelId`, which also generates an id when absent.\n\tconst rootLabelId = useRegisteredLabelId(\n\t\tuntrack(() => context.rootLabelId()),\n\t\tcontext.setLabelId,\n\t);\n\n\t// Register with the labelable provider so thumb inputs pick this up via\n\t// `useAriaLabelledBy`. The `id` returned here is the same id we just\n\t// registered with the root — we pass it as an override so both registries\n\t// see the same value.\n\tconst { id } = useLabel({ id: rootLabelId });\n\n\tfunction handleClick(event: MouseEvent): void {\n\t\t// Only focus when there's exactly one thumb input inside the control.\n\t\t// Range sliders have multiple inputs and there's no sensible default.\n\t\tconst control = context.controlRef.current;\n\t\tif (!control) return;\n\t\tconst target = event.target as Element | null;\n\t\tif (\n\t\t\ttarget != null &&\n\t\t\ttarget.closest(\"button,input,select,textarea\") != null\n\t\t) {\n\t\t\treturn;\n\t\t}\n\t\tconst inputs = control.querySelectorAll<HTMLInputElement>(\n\t\t\t'input[type=\"range\"]',\n\t\t);\n\t\tif (inputs.length === 1) {\n\t\t\tinputs[0]?.focus({ preventScroll: true });\n\t\t}\n\t}\n\n\t// Resolve `class`/`style` here so function values (stateful styling) are\n\t// invoked with the slider state instead of being spread to the DOM raw.\n\tconst userClassStyle = resolveClassStyle(props, () => context.state());\n\tconst userProps = omit(\n\t\tprops as Record<string, unknown>,\n\t\t\"as\",\n\t\t\"id\",\n\t\t\"class\",\n\t\t\"style\",\n\t\t\"attrs\",\n\t);\n\n\tconst internalSlot = {\n\t\tid,\n\t\tonClick: handleClick,\n\t};\n\n\tlet merged: Record<string, unknown> = mergeRootProps(\n\t\tinternalSlot,\n\t\tsliderDataAttrs(context.state),\n\t);\n\tmerged = mergeRootProps(merged, userClassStyle);\n\tmerged = mergeRootProps(merged, userProps);\n\n\tconst Tag = dynamic(() => props.as ?? \"div\");\n\treturn <Tag {...merged} ref={userRef(props)} />;\n}\n\nexport namespace SliderLabel {\n\texport type State = SliderLabelState;\n\texport type Props = SliderLabelProps;\n}\n"],"mappings":"AACA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,IAAI,EAAEC,OAAO,QAAQ,UAAU;AACxC,SAASC,OAAO,QAAQ,8BAA8B;AACtD,SAASC,QAAQ,QAAQ,iDAAiD;AAC1E,SAASC,cAAc,QAAQ,kCAAkC;AACjE,SAASC,iBAAiB,QAAQ,qCAAqC;AAEvE,SAASC,oBAAoB,QAAQ,yCAAyC;AAC9E,SAECC,oBAAoB,QACd,2BAA2B;AAClC,SAASC,eAAe,QAAQ,yBAAyB;AAUzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,WAAWA,CAACC,KAAuB,EAAe;EACjE,MAAMC,OAAO,GAAGJ,oBAAoB,CAAC,CAAC;;EAEtC;EACA;EACA;EACA,MAAMK,WAAW,GAAGN,oBAAoB,CACvCL,OAAO,CAAC,MAAMU,OAAO,CAACC,WAAW,CAAC,CAAC,CAAC,EACpCD,OAAO,CAACE,UACT,CAAC;;EAED;EACA;EACA;EACA;EACA,MAAM;IAAEC;EAAG,CAAC,GAAGX,QAAQ,CAAC;IAAEW,EAAE,EAAEF;EAAY,CAAC,CAAC;EAE5C,SAASG,WAAWA,CAACC,KAAiB,EAAQ;IAC7C;IACA;IACA,MAAMC,OAAO,GAAGN,OAAO,CAACO,UAAU,CAACC,OAAO;IAC1C,IAAI,CAACF,OAAO,EAAE;IACd,MAAMG,MAAM,GAAGJ,KAAK,CAACI,MAAwB;IAC7C,IACCA,MAAM,IAAI,IAAI,IACdA,MAAM,CAACC,OAAO,CAAC,8BAA8B,CAAC,IAAI,IAAI,EACrD;MACD;IACD;IACA,MAAMC,MAAM,GAAGL,OAAO,CAACM,gBAAgB,CACtC,qBACD,CAAC;IACD,IAAID,MAAM,CAACE,MAAM,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