{"version":3,"names":["createMemo","mergeElementStyles","composeClasses","legacy","attrs","undefined","resolveClassStyle","props","getState","resolved","state","classValue","class","styleValue","style","attrsValue","legacyClass","legacyStyle","data-style-src"],"sources":["resolve-class-style.ts"],"sourcesContent":["import { createMemo } from \"solid-js\";\nimport { mergeElementStyles } from \"./merge-root-props\";\nimport type { ElementClass, ElementStyle, StylingAttrs } from \"./types\";\n/**\n * Helper for the wave-3 `as=`/`dynamic()` element migration: resolve `class` / `style`\n * from a Base UI component's `props` against the live state accessor and\n * return a plain object with reactive getters suitable for `mergeRootProps`.\n *\n * Both keys may be raw values OR functions of state — the functions are\n * called inside the getter so they re-run on every reactive dependency\n * change. Returning `undefined` is fine; `mergeRootProps` treats undefined\n * as \"absent\" so internal defaults still win.\n */\n\nexport interface ClassStyleSource<State> {\n\tclass?: ElementClass | ((state: State) => ElementClass) | undefined;\n\tstyle?: ElementStyle | ((state: State) => ElementStyle) | undefined;\n\tattrs?:\n\t\t| StylingAttrs\n\t\t| ((state: State) => StylingAttrs | undefined)\n\t\t| undefined;\n}\n\nfunction composeClasses(\n\tlegacy: ElementClass,\n\tattrs: ElementClass,\n): ElementClass {\n\tif (legacy === undefined || legacy === false) return attrs;\n\tif (attrs === undefined || attrs === false) return legacy;\n\treturn [legacy, attrs];\n}\n\nexport function resolveClassStyle<State>(\n\tprops: ClassStyleSource<State>,\n\tgetState: () => State,\n): {\n\tclass: ElementClass;\n\tstyle: ElementStyle;\n\t\"data-style-src\": string | undefined;\n} {\n\t// Resolve all state-aware styling inputs in one computation. Reading any\n\t// output observes the same state snapshot and does not independently invoke\n\t// class/style/attrs callbacks.\n\tconst resolved = createMemo(() => {\n\t\tconst state = getState();\n\t\tconst classValue = props.class;\n\t\tconst styleValue = props.style;\n\t\tconst attrsValue = props.attrs;\n\t\tconst legacyClass =\n\t\t\ttypeof classValue === \"function\" ? classValue(state) : classValue;\n\t\tconst legacyStyle =\n\t\t\ttypeof styleValue === \"function\" ? styleValue(state) : styleValue;\n\t\tconst attrs =\n\t\t\ttypeof attrsValue === \"function\" ? attrsValue(state) : attrsValue;\n\n\t\treturn {\n\t\t\tclass: composeClasses(legacyClass, attrs?.class),\n\t\t\tstyle: mergeElementStyles(legacyStyle, attrs?.style),\n\t\t\t\"data-style-src\": attrs?.[\"data-style-src\"],\n\t\t};\n\t});\n\n\treturn {\n\t\tget class(): ElementClass {\n\t\t\treturn resolved().class;\n\t\t},\n\t\tget style(): ElementStyle {\n\t\t\treturn resolved().style;\n\t\t},\n\t\tget \"data-style-src\"(): string | undefined {\n\t\t\treturn resolved()[\"data-style-src\"];\n\t\t},\n\t};\n}\n"],"mappings":"AAAA,SAASA,UAAU,QAAQ,UAAU;AACrC,SAASC,kBAAkB,QAAQ,oBAAoB;;AAEvD;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;;AAWA,SAASC,cAAcA,CACtBC,MAAoB,EACpBC,KAAmB,EACJ;EACf,IAAID,MAAM,KAAKE,SAAS,IAAIF,MAAM,KAAK,KAAK,EAAE,OAAOC,KAAK;EAC1D,IAAIA,KAAK,KAAKC,SAAS,IAAID,KAAK,KAAK,KAAK,EAAE,OAAOD,MAAM;EACzD,OAAO,CAACA,MAAM,EAAEC,KAAK,CAAC;AACvB;AAEA,OAAO,SAASE,iBAAiBA,CAChCC,KAA8B,EAC9BC,QAAqB,EAKpB;EACD;EACA;EACA;EACA,MAAMC,QAAQ,GAAGT,UAAU,CAAC,MAAM;IACjC,MAAMU,KAAK,GAAGF,QAAQ,CAAC,CAAC;IACxB,MAAMG,UAAU,GAAGJ,KAAK,CAACK,KAAK;IAC9B,MAAMC,UAAU,GAAGN,KAAK,CAACO,KAAK;IAC9B,MAAMC,UAAU,GAAGR,KAAK,CAACH,KAAK;IAC9B,MAAMY,WAAW,GAChB,OAAOL,UAAU,KAAK,UAAU,GAAGA,UAAU,CAACD,KAAK,CAAC,GAAGC,UAAU;IAClE,MAAMM,WAAW,GAChB,OAAOJ,UAAU,KAAK,UAAU,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