{"version":3,"names":["onCleanup","untrack","useBaseUiId","useLabelableContext","useLabel","params","context","idOverride","id","source","Symbol","registerLabelId","undefined","controlId"],"sources":["use-label.ts"],"sourcesContent":["import { onCleanup, untrack } from \"solid-js\";\nimport { useBaseUiId } from \"../base-ui-id\";\nimport { useLabelableContext } from \"./labelable-context\";\n\nexport interface UseLabelParameters {\n\t/**\n\t * Explicit id override for the label. When omitted, {@link useBaseUiId}\n\t * generates a stable id for the component's lifetime.\n\t */\n\tid?: string | undefined;\n\t/**\n\t * Fallback control id used when no labelable context is present (or the\n\t * context hasn't seen a control registration yet). Consumers typically\n\t * pass the id they'd have used for their own control so `htmlFor` still\n\t * lines up in the no-provider case.\n\t */\n\tfallbackControlId?: string | null | undefined;\n}\n\nexport interface UseLabelReturnValue {\n\t/**\n\t * The id assigned to the label element. Read once during setup — the value\n\t * is stable for the component's lifetime (matching React's `useBaseUiId`).\n\t */\n\tid: string;\n\t/**\n\t * The id of the control this label is associated with, if any. Reactive —\n\t * tracks context registrations. `undefined` when nothing has registered,\n\t * `null` when the association is implicit, a string otherwise.\n\t */\n\tcontrolId: () => string | null | undefined;\n}\n\n/**\n * Register a label id with the surrounding `<LabelableProvider>` and pull the\n * control id back out so the caller can render `htmlFor` / click handlers.\n *\n * Lifecycle (mirrors `use-registered-label-id.ts` but against the multi-label\n * registry):\n *\n * - On setup, generates (or accepts an override for) an id via\n *   {@link useBaseUiId} and registers it under a per-call `Symbol()` source\n *   key. No `ref<symbol>` dance — the symbol is a plain local binding.\n * - On cleanup (component disposed), unregisters the id so the context's\n *   `aria-labelledby` composition drops this label cleanly.\n * - Returns the generated id plus a reactive `controlId` accessor that\n *   reflects the currently-registered control id.\n *\n * Note the relationship to `src/internals/use-registered-label-id.ts`: that\n * hook is the **tier-1 single-label** path already used by progress/meter.\n * This hook is the **tier-2 multi-label** superset. Both are kept alive on\n * purpose — tier-1 consumers don't need a full LabelableProvider.\n */\nexport function useLabel(params: UseLabelParameters = {}): UseLabelReturnValue {\n\tconst context = useLabelableContext();\n\n\t// `untrack` silences the STRICT_READ_UNTRACKED warning (RFC 08) for the\n\t// one-time prop read. The id is consumed exactly once by `useBaseUiId` —\n\t// later changes to `params.id` are deliberately ignored (matches React's\n\t// stable-id behavior via `useBaseUiId`).\n\tconst idOverride = untrack(() => params.id);\n\tconst id = useBaseUiId(idOverride);\n\n\t// One-shot source key per `useLabel` call. A plain `const source = Symbol()`\n\t// is enough — the binding outlives setup via closure and is consulted at\n\t// cleanup time.\n\tconst source = Symbol(\"labelable-label\");\n\n\t// Register synchronously during setup so the context's `getLabelIds()` is\n\t// populated by the time downstream JSX reads it (same-frame). The\n\t// underlying signal opts into `ownedWrite`, so this owned-scope call is\n\t// permitted.\n\tcontext.registerLabelId(source, id);\n\n\tonCleanup(() => {\n\t\tcontext.registerLabelId(source, undefined);\n\t});\n\n\tconst controlId = (): string | null | undefined => context.controlId();\n\n\treturn { id, controlId };\n}\n"],"mappings":"AAAA,SAASA,SAAS,EAAEC,OAAO,QAAQ,UAAU;AAC7C,SAASC,WAAW,QAAQ,eAAe;AAC3C,SAASC,mBAAmB,QAAQ,qBAAqB;AA+BzD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,QAAQA,CAACC,MAA0B,GAAG,CAAC,CAAC,EAAuB;EAC9E,MAAMC,OAAO,GAAGH,mBAAmB,CAAC,CAAC;;EAErC;EACA;EACA;EACA;EACA,MAAMI,UAAU,GAAGN,OAAO,CAAC,MAAMI,MAAM,CAACG,EAAE,CAAC;EAC3C,MAAMA,EAAE,GAAGN,WAAW,CAACK,UAAU,CAAC;;EAElC;EACA;EACA;EACA,MAAME,MAAM,GAAGC,MAAM,CAAC,iBAAiB,CAAC;;EAExC;EACA;EACA;EACA;EACAJ,OAAO,CAACK,eAAe,CAACF,MAAM,EAAED,EAAE,CAAC;EAEnCR,SAAS,CAAC,MAAM;IACfM,OAAO,CAACK,eAAe,CAACF,MAAM,EAAEG,SAAS,CAAC;EAC3C,CAAC,CAAC;EAEF,MAAMC,SAAS,GAAGA,CAAA,KAAiCP,OAAO,CAACO,SAAS,CAAC,CAAC;EAEtE,OAAO;IAAEL,EAAE;IAAEK;EAAU,CAAC;AACzB","ignoreList":[]}