@tenphi/tasty 3.11.1 → 3.12.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (53) hide show
  1. package/dist/{babel-types-BKDTT4--.d.ts → babel-types-docs8f4c.d.ts} +2 -2
  2. package/dist/chunks/{build-config-5d8WlQbq.js → build-config-DmSCYjYl.js} +5 -5
  3. package/dist/chunks/{build-config-5d8WlQbq.js.map → build-config-DmSCYjYl.js.map} +1 -1
  4. package/dist/chunks/{collector-CjCak4iE.js → collector-8w5r-xFl.js} +4 -4
  5. package/dist/chunks/{collector-CjCak4iE.js.map → collector-8w5r-xFl.js.map} +1 -1
  6. package/dist/chunks/{config-engine-uOFYZidB.js → config-engine-DjRv6Axa.js} +5 -5
  7. package/dist/chunks/config-engine-DjRv6Axa.js.map +1 -0
  8. package/dist/chunks/{css-definitions-ubrHP97m.js → css-definitions-_UidGa56.js} +3 -3
  9. package/dist/chunks/{css-definitions-ubrHP97m.js.map → css-definitions-_UidGa56.js.map} +1 -1
  10. package/dist/chunks/{debug-CJ31U_WE.js → debug-B6dZq3uH.js} +4 -4
  11. package/dist/chunks/{debug-CJ31U_WE.js.map → debug-B6dZq3uH.js.map} +1 -1
  12. package/dist/chunks/{dsl-DYSJc1-T.js → dsl-rgu6XQcD.js} +42 -39
  13. package/dist/chunks/dsl-rgu6XQcD.js.map +1 -0
  14. package/dist/chunks/{react-runtime-CyyCI02N.js → react-runtime-DS1cEAMK.js} +5 -5
  15. package/dist/chunks/{react-runtime-CyyCI02N.js.map → react-runtime-DS1cEAMK.js.map} +1 -1
  16. package/dist/chunks/{runtime-engine-BQmOu5-W.js → runtime-engine-DFCZN1nF.js} +6 -6
  17. package/dist/chunks/runtime-engine-DFCZN1nF.js.map +1 -0
  18. package/dist/chunks/{runtime-state-DEsyUMU-.js → runtime-state-C8MzPjBR.js} +2 -2
  19. package/dist/chunks/{runtime-state-DEsyUMU-.js.map → runtime-state-C8MzPjBR.js.map} +1 -1
  20. package/dist/chunks/{style-engine-BX2LshDZ.js → style-engine-DoGrZPBB.js} +155 -45
  21. package/dist/chunks/style-engine-DoGrZPBB.js.map +1 -0
  22. package/dist/chunks/{zero-engine-Dw0P4yGM.js → zero-engine-CiVidroC.js} +5 -5
  23. package/dist/chunks/{zero-engine-Dw0P4yGM.js.map → zero-engine-CiVidroC.js.map} +1 -1
  24. package/dist/{config-CcxqSZI2.d.ts → config-DDY7NlZ1.d.ts} +7 -8
  25. package/dist/core/index.d.ts +2 -2
  26. package/dist/core/index.js +7 -7
  27. package/dist/{index--GdqCPlp.d.ts → index-DOxyS72p.d.ts} +3 -3
  28. package/dist/index.d.ts +2 -2
  29. package/dist/index.js +8 -8
  30. package/dist/ssr/astro.js +2 -2
  31. package/dist/ssr/index.js +2 -2
  32. package/dist/ssr/next-config.d.ts +1 -1
  33. package/dist/ssr/next-config.js +3 -3
  34. package/dist/ssr/next.js +3 -3
  35. package/dist/zero/babel.d.ts +9 -3
  36. package/dist/zero/babel.js +8 -8
  37. package/dist/zero/babel.js.map +1 -1
  38. package/dist/zero/index.d.ts +3 -2
  39. package/dist/zero/index.js +5 -4
  40. package/dist/zero/index.js.map +1 -1
  41. package/dist/zero/next.d.ts +1 -1
  42. package/docs/ai-agents.md +3 -0
  43. package/docs/configuration.md +12 -10
  44. package/docs/dsl.md +71 -43
  45. package/docs/pipeline.md +1 -1
  46. package/docs/react-api.md +7 -3
  47. package/docs/styles.md +4 -0
  48. package/docs/tasty-static.md +21 -7
  49. package/package.json +30 -31
  50. package/dist/chunks/config-engine-uOFYZidB.js.map +0 -1
  51. package/dist/chunks/dsl-DYSJc1-T.js.map +0 -1
  52. package/dist/chunks/runtime-engine-BQmOu5-W.js.map +0 -1
  53. package/dist/chunks/style-engine-BX2LshDZ.js.map +0 -1
@@ -1,4 +1,4 @@
1
- import { P as DEFAULT_PROPERTIES, R as indexPropertiesByName } from "./css-definitions-ubrHP97m.js";
1
+ import { P as DEFAULT_PROPERTIES, R as indexPropertiesByName } from "./css-definitions-_UidGa56.js";
2
2
  //#region src/config-resources.ts
3
3
  let runtimeConfig = null;
4
4
  let globalFontFace = null;
@@ -149,4 +149,4 @@ function getRegisteredSSRCollector() {
149
149
  //#endregion
150
150
  export { mergeGlobalKeyframes as _, getEffectivePropertiesByName as a, resetConfigResources as b, getGlobalFontFaces as c, getGlobalStyles as d, getRuntimeConfigState as f, mergeGlobalFunctions as g, mergeGlobalFontFaces as h, getEffectiveProperties as i, getGlobalFunctions as l, mergeGlobalCounterStyles as m, registerSSRCollectorGetter as n, getGlobalConfigTokens as o, mergeGlobalConfigTokens as p, registerSSRCollectorGetterGlobal as r, getGlobalCounterStyles as s, getRegisteredSSRCollector as t, getGlobalKeyframes as u, mergeGlobalProperties as v, setRuntimeConfigState as x, mergeGlobalStyles as y };
151
151
 
152
- //# sourceMappingURL=runtime-state-DEsyUMU-.js.map
152
+ //# sourceMappingURL=runtime-state-C8MzPjBR.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"runtime-state-DEsyUMU-.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { DeclaredPropertyEntry } from './properties';\nimport { indexPropertiesByName } from './properties';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\nlet globalKeyframes: Record<string, KeyframesSteps> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\nconst GTKEY_KEYFRAMES = '__tasty_cfg_keyframes__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nlet effectivePropertyIndex: {\n source: Record<string, PropertyDefinition> | null | undefined;\n index: ReadonlyMap<string, DeclaredPropertyEntry>;\n} | null = null;\n\n/**\n * The effective properties (Tasty's defaults and `configure({ properties })`)\n * keyed by the custom property each one registers — see\n * `indexPropertiesByName()`. Rebuilt only when `configure({ properties })`\n * replaces the set.\n */\nexport function getEffectivePropertiesByName(): ReadonlyMap<\n string,\n DeclaredPropertyEntry\n> {\n const source =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n\n if (effectivePropertyIndex && effectivePropertyIndex.source === source) {\n return effectivePropertyIndex.index;\n }\n\n const index = indexPropertiesByName(getEffectiveProperties());\n effectivePropertyIndex = { source, index };\n return index;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\n/**\n * Get global keyframes configuration.\n * Returns null if no keyframes configured (fast path for zero-overhead).\n */\nexport function getGlobalKeyframes(): Record<string, KeyframesSteps> | null {\n return (\n globalKeyframes ??\n getFromGlobalThis<Record<string, KeyframesSteps>>(GTKEY_KEYFRAMES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function mergeGlobalKeyframes(\n keyframes: Record<string, KeyframesSteps>,\n): void {\n globalKeyframes = { ...(getGlobalKeyframes() ?? {}), ...keyframes };\n setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n globalKeyframes = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n delete globalState[GTKEY_KEYFRAMES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":";;AA2BA,IAAI,gBAA2C;AAC/C,IAAI,iBAAuD;AAC3D,IAAI,qBAAqE;AACzE,IAAI,iBAA4D;AAChE,IAAI,mBAA8D;AAClE,IAAI,qBAA0C;AAC9C,IAAI,eAA8C;AAClD,IAAI,kBAAyD;AAE7D,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC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AM,SAAU,WAAuC;CAEvD,OAAO,SAAS,OAAO,IAAI;AAC7B"}
1
+ {"version":3,"file":"runtime-state-C8MzPjBR.js","names":[],"sources":["../../src/config-resources.ts","../../src/ssr/ssr-collector-ref.ts"],"sourcesContent":["/**\n * DOM-free storage for configured CSS resources shared by the browser runtime\n * and server collectors.\n *\n * Astro can evaluate middleware and application code in separate module\n * graphs, so resources used by SSR are mirrored on globalThis. Keeping this\n * state outside config.ts lets server-only entrypoints read it without loading\n * StyleInjector and the rest of the browser runtime.\n */\n\nimport type {\n CounterStyleDescriptors,\n FontFaceInput,\n FunctionDefinition,\n KeyframesSteps,\n PropertyDefinition,\n} from './injector/types';\nimport type { DeclaredPropertyEntry } from './properties';\nimport { indexPropertiesByName } from './properties';\nimport { DEFAULT_PROPERTIES } from './properties/defaults';\nimport type { ConfigTokens, Styles } from './styles/types';\n\ninterface RuntimeConfigState {\n namePrefix?: string;\n nonce?: string;\n}\n\nlet runtimeConfig: RuntimeConfigState | null = null;\nlet globalFontFace: Record<string, FontFaceInput> | null = null;\nlet globalCounterStyle: Record<string, CounterStyleDescriptors> | null = null;\nlet globalFunction: Record<string, FunctionDefinition> | null = null;\nlet globalProperties: Record<string, PropertyDefinition> | null = null;\nlet globalConfigTokens: ConfigTokens | null = null;\nlet globalStyles: Record<string, Styles> | null = null;\nlet globalKeyframes: Record<string, KeyframesSteps> | null = null;\n\nconst GTKEY_TOKENS = '__tasty_cfg_tokens__';\nconst GTKEY_FONT_FACE = '__tasty_cfg_font_face__';\nconst GTKEY_COUNTER_STYLE = '__tasty_cfg_counter_style__';\nconst GTKEY_FUNCTION = '__tasty_cfg_function__';\nconst GTKEY_PROPERTIES = '__tasty_cfg_properties__';\nconst GTKEY_GLOBAL_STYLES = '__tasty_cfg_global_styles__';\nconst GTKEY_KEYFRAMES = '__tasty_cfg_keyframes__';\n\nfunction setOnGlobalThis(key: string, value: unknown): void {\n (globalThis as Record<string, unknown>)[key] = value;\n}\n\nfunction getFromGlobalThis<T>(key: string): T | undefined {\n return (globalThis as Record<string, unknown>)[key] as T | undefined;\n}\n\nexport function getRuntimeConfigState(): RuntimeConfigState | null {\n return runtimeConfig;\n}\n\nexport function setRuntimeConfigState(config: RuntimeConfigState): void {\n runtimeConfig = config;\n}\n\nexport function getEffectiveProperties(): Record<string, PropertyDefinition> {\n const properties =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n return properties\n ? { ...DEFAULT_PROPERTIES, ...properties }\n : DEFAULT_PROPERTIES;\n}\n\nlet effectivePropertyIndex: {\n source: Record<string, PropertyDefinition> | null | undefined;\n index: ReadonlyMap<string, DeclaredPropertyEntry>;\n} | null = null;\n\n/**\n * The effective properties (Tasty's defaults and `configure({ properties })`)\n * keyed by the custom property each one registers — see\n * `indexPropertiesByName()`. Rebuilt only when `configure({ properties })`\n * replaces the set.\n */\nexport function getEffectivePropertiesByName(): ReadonlyMap<\n string,\n DeclaredPropertyEntry\n> {\n const source =\n globalProperties ??\n getFromGlobalThis<Record<string, PropertyDefinition>>(GTKEY_PROPERTIES);\n\n if (effectivePropertyIndex && effectivePropertyIndex.source === source) {\n return effectivePropertyIndex.index;\n }\n\n const index = indexPropertiesByName(getEffectiveProperties());\n effectivePropertyIndex = { source, index };\n return index;\n}\n\nexport function getGlobalFontFaces(): Record<string, FontFaceInput> | null {\n return (\n globalFontFace ??\n getFromGlobalThis<Record<string, FontFaceInput>>(GTKEY_FONT_FACE) ??\n null\n );\n}\n\nexport function getGlobalCounterStyles(): Record<\n string,\n CounterStyleDescriptors\n> | null {\n return (\n globalCounterStyle ??\n getFromGlobalThis<Record<string, CounterStyleDescriptors>>(\n GTKEY_COUNTER_STYLE,\n ) ??\n null\n );\n}\n\nexport function getGlobalFunctions(): Record<\n string,\n FunctionDefinition\n> | null {\n return (\n globalFunction ??\n getFromGlobalThis<Record<string, FunctionDefinition>>(GTKEY_FUNCTION) ??\n null\n );\n}\n\nexport function getGlobalConfigTokens(): ConfigTokens | null {\n return (\n globalConfigTokens ?? getFromGlobalThis<ConfigTokens>(GTKEY_TOKENS) ?? null\n );\n}\n\nexport function getGlobalStyles(): Record<string, Styles> | null {\n return (\n globalStyles ??\n getFromGlobalThis<Record<string, Styles>>(GTKEY_GLOBAL_STYLES) ??\n null\n );\n}\n\n/**\n * Get global keyframes configuration.\n * Returns null if no keyframes configured (fast path for zero-overhead).\n */\nexport function getGlobalKeyframes(): Record<string, KeyframesSteps> | null {\n return (\n globalKeyframes ??\n getFromGlobalThis<Record<string, KeyframesSteps>>(GTKEY_KEYFRAMES) ??\n null\n );\n}\n\nexport function mergeGlobalProperties(\n properties: Record<string, PropertyDefinition>,\n): void {\n globalProperties = {\n ...(globalProperties ?? getFromGlobalThis(GTKEY_PROPERTIES) ?? {}),\n ...properties,\n };\n setOnGlobalThis(GTKEY_PROPERTIES, globalProperties);\n}\n\nexport function mergeGlobalFontFaces(\n fontFaces: Record<string, FontFaceInput>,\n): void {\n globalFontFace = { ...(getGlobalFontFaces() ?? {}), ...fontFaces };\n setOnGlobalThis(GTKEY_FONT_FACE, globalFontFace);\n}\n\nexport function mergeGlobalCounterStyles(\n counterStyles: Record<string, CounterStyleDescriptors>,\n): void {\n globalCounterStyle = {\n ...(getGlobalCounterStyles() ?? {}),\n ...counterStyles,\n };\n setOnGlobalThis(GTKEY_COUNTER_STYLE, globalCounterStyle);\n}\n\nexport function mergeGlobalFunctions(\n functions: Record<string, FunctionDefinition>,\n): void {\n globalFunction = { ...(getGlobalFunctions() ?? {}), ...functions };\n setOnGlobalThis(GTKEY_FUNCTION, globalFunction);\n}\n\nexport function mergeGlobalConfigTokens(styles: ConfigTokens): void {\n globalConfigTokens = globalConfigTokens\n ? { ...globalConfigTokens, ...styles }\n : styles;\n setOnGlobalThis(GTKEY_TOKENS, globalConfigTokens);\n}\n\nexport function mergeGlobalStyles(styles: Record<string, Styles>): void {\n if (globalStyles) {\n for (const [selector, selectorStyles] of Object.entries(styles)) {\n globalStyles[selector] = globalStyles[selector]\n ? { ...globalStyles[selector], ...selectorStyles }\n : selectorStyles;\n }\n } else {\n globalStyles = { ...styles };\n }\n setOnGlobalThis(GTKEY_GLOBAL_STYLES, globalStyles);\n}\n\nexport function mergeGlobalKeyframes(\n keyframes: Record<string, KeyframesSteps>,\n): void {\n globalKeyframes = { ...(getGlobalKeyframes() ?? {}), ...keyframes };\n setOnGlobalThis(GTKEY_KEYFRAMES, globalKeyframes);\n}\n\nexport function resetConfigResources(): void {\n runtimeConfig = null;\n globalProperties = null;\n globalFontFace = null;\n globalCounterStyle = null;\n globalFunction = null;\n globalConfigTokens = null;\n globalStyles = null;\n globalKeyframes = null;\n\n const globalState = globalThis as Record<string, unknown>;\n delete globalState[GTKEY_TOKENS];\n delete globalState[GTKEY_FONT_FACE];\n delete globalState[GTKEY_COUNTER_STYLE];\n delete globalState[GTKEY_FUNCTION];\n delete globalState[GTKEY_PROPERTIES];\n delete globalState[GTKEY_GLOBAL_STYLES];\n delete globalState[GTKEY_KEYFRAMES];\n}\n","/**\n * Global reference to the SSR collector getter function.\n *\n * This indirection avoids importing 'node:async_hooks' in the browser bundle.\n * The SSR entry point sets this ref when loaded on the server. The useStyles\n * hook calls it if set; on the client it stays null and is never called.\n *\n * Uses a module-level variable as the primary mechanism. In Next.js App\n * Router the RSC and SSR module graphs load separate copies of this module,\n * so the getter registered by TastyRegistry (SSR layer) is invisible to\n * server components (RSC layer) — which correctly fall through to inline\n * RSC styles.\n *\n * A globalThis fallback (`registerSSRCollectorGetterGlobal`) is provided\n * for frameworks like Astro where middleware and page components live in\n * different module graphs and must share the getter across them.\n */\n\nimport type { ServerStyleCollector } from './collector';\n\ntype SSRCollectorGetter = () => ServerStyleCollector | null;\n\nconst GETTER_KEY = '__tasty_ssr_collector_getter__';\n\nlet _getSSRCollector: SSRCollectorGetter | null = null;\n\n/**\n * Register the collector getter in the current module graph only.\n * Used by Next.js TastyRegistry.\n */\nexport function registerSSRCollectorGetter(fn: SSRCollectorGetter): void {\n _getSSRCollector = fn;\n}\n\n/**\n * Register the collector getter on globalThis so it is visible across\n * separate module graphs (e.g. Astro middleware ↔ page components).\n */\nexport function registerSSRCollectorGetterGlobal(fn: SSRCollectorGetter): void {\n (globalThis as Record<string, unknown>)[GETTER_KEY] = fn;\n}\n\n/**\n * Retrieve the SSR collector: module-level first, globalThis fallback.\n */\nexport function getRegisteredSSRCollector(): ServerStyleCollector | null {\n if (_getSSRCollector) return _getSSRCollector();\n const getter = (globalThis as Record<string, unknown>)[GETTER_KEY] as\n SSRCollectorGetter | undefined;\n return getter ? getter() : null;\n}\n"],"mappings":";;AA2BA,IAAI,gBAA2C;AAC/C,IAAI,iBAAuD;AAC3D,IAAI,qBAAqE;AACzE,IAAI,iBAA4D;AAChE,IAAI,mBAA8D;AAClE,IAAI,qBAA0C;AAC9C,IAAI,eAA8C;AAClD,IAAI,kBAAyD;AAE7D,MAAM,eAAe;AACrB,MAAM,kBAAkB;AACxB,MAAM,sBAAsB;AAC5B,MAAM,iBAAiB;AACvB,MAAM,mBAAmB;AACzB,MAAM,sBAAsB;AAC5B,MAAM,kBAAkB;AAExB,SAAS,gBAAgB,KAAa,OAAsB;CAC1D,WAAwC,OAAO;AACjD;AAEA,SAAS,kBAAqB,KAA4B;CACxD,OAAQ,WAAuC;AACjD;AAEA,SAAgB,wBAAmD;CACjE,OAAO;AACT;AAEA,SAAgB,sBAAsB,QAAkC;CACtE,gBAAgB;AAClB;AAEA,SAAgB,yBAA6D;CAC3E,MAAM,aACJ,oBACA,kBAAsD,gBAAgB;CACxE,OAAO,aACH;EAAE,GAAG;EAAoB,GAAG;CAAW,IACvC;AACN;AAEA,IAAI,yBAGO;AAQX,SAAgB,+BAGd;CACA,MAAM,SACJ,oBACA,kBAAsD,gBAAgB;CAExE,IAAI,0BAA0B,uBAAuB,WAAW,QAC9D,OAAO,uBAAuB;CAGhC,MAAM,QAAQ,sBAAsB,uBAAuB,CAAC;CAC5D,yBAAyB;EAAE;EAAQ;CAAM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AAE,GAAG,OAAO;CAE7B,gBAAgB,qBAAqB,YAAY;AACnD;AAEA,SAAgB,qBACd,WACM;CACN,kBAAkB;EAAE,GAAI,mBAAmB,KAAK,CAAC;EAAI,GAAG;CAAU;CAClE,gBAAgB,iBAAiB,eAAe;AAClD;AAEA,SAAgB,uBAA6B;CAC3C,gBAAgB;CAChB,mBAAmB;CACnB,iBAAiB;CACjB,qBAAqB;CACrB,iBAAiB;CACjB,qBAAqB;CACrB,eAAe;CACf,kBAAkB;CAElB,MAAM,cAAc;CACpB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;CACnB,OAAO,YAAY;AACrB;;;ACpNA,MAAM,aAAa;AAEnB,IAAI,mBAA8C;AAMlD,SAAgB,2BAA2B,IAA8B;CACvE,mBAAmB;AACrB;AAMA,SAAgB,iCAAiC,IAA8B;CAC7E,WAAwC,cAAc;AACxD;AAKA,SAAgB,4BAAyD;CACvE,IAAI,kBAAkB,OAAO,iBAAiB;CAC9C,MAAM,SAAU,WAAuC;CAEvD,OAAO,SAAS,OAAO,IAAI;AAC7B"}
@@ -1,4 +1,4 @@
1
- import { M as toSnakeCase, N as CSS_WIDE_KEYWORDS, T as makeEmptyDetails, _ as stringifyStyles, c as getGlobalParser, d as parseColor, f as parseStyle, h as resolveCustomProperties, i as DIRECTIONS, j as normalizeDslName, u as normalizeColorTokenValue, w as Lru } from "./dsl-DYSJc1-T.js";
1
+ import { A as isColorKeyword, M as normalizeDslName, N as toSnakeCase, P as CSS_WIDE_KEYWORDS, T as makeEmptyDetails, _ as stringifyStyles, c as getGlobalParser, d as parseColor, f as parseStyle, h as resolveCustomProperties, i as DIRECTIONS, u as normalizeColorTokenValue, w as Lru } from "./dsl-rgu6XQcD.js";
2
2
  import { a as warnOnceDev, i as warn, n as isSelector, o as isDevEnv } from "./shared-utils-y-HjvPN4.js";
3
3
  //#region src/config-state.ts
4
4
  let stylesGenerated = false;
@@ -462,6 +462,9 @@ function extractCSSWideKeyword(group) {
462
462
  if (group.values.length !== 1 || group.colors.length > 0) return null;
463
463
  return CSS_WIDE_KEYWORDS.has(group.values[0]) ? group.values[0] : null;
464
464
  }
465
+ function isUnset(value) {
466
+ return value == null || value === false;
467
+ }
465
468
  const RE_VAR_REFERENCE = /^var\(/;
466
469
  function assignLineSlots(values, styleKeyword, colorToken) {
467
470
  if (styleKeyword && colorToken) return {
@@ -601,7 +604,7 @@ const STRETCH_FALLBACKS = [
601
604
  "stretch"
602
605
  ];
603
606
  function parseDimensionValue(val) {
604
- if (val == null) return null;
607
+ if (isUnset(val)) return null;
605
608
  if (typeof val === "number") return `${val}px`;
606
609
  if (val === true) return "initial";
607
610
  return parseStyle(String(val)).groups[0]?.values[0] || null;
@@ -610,8 +613,8 @@ function dimensionStyle(name) {
610
613
  const minStyle = `min-${name}`;
611
614
  const maxStyle = `max-${name}`;
612
615
  return ({ value, min, max }) => {
613
- if (value == null && min == null && max == null) return null;
614
- if (value != null && typeof value === "string" && CSS_WIDE_KEYWORDS.has(value)) {
616
+ if (isUnset(value) && isUnset(min) && isUnset(max)) return null;
617
+ if (typeof value === "string" && CSS_WIDE_KEYWORDS.has(value)) {
615
618
  const styles = {
616
619
  [name]: value,
617
620
  [minStyle]: value,
@@ -640,7 +643,7 @@ function dimensionStyle(name) {
640
643
  [minStyle]: "initial",
641
644
  [maxStyle]: "initial"
642
645
  };
643
- if (value != null) {
646
+ if (!isUnset(value)) {
644
647
  let val = value;
645
648
  if (typeof val === "number") val = `${val}px`;
646
649
  val = String(val);
@@ -972,11 +975,11 @@ function optimizeShorthand(property, dirs) {
972
975
  }
973
976
  function processDirectionalStyle(config, props) {
974
977
  const { main, top, right, bottom, left } = props;
975
- if (main == null && top == null && right == null && bottom == null && left == null) return null;
978
+ if (isUnset(main) && isUnset(top) && isUnset(right) && isUnset(bottom) && isUnset(left)) return null;
976
979
  const { property, defaultValue, trueValue, defaultInit, individualOnly, directionProperty, spanModifiers } = config;
977
980
  const dirProp = directionProperty ?? ((dir) => `${property}-${dir}`);
978
981
  if (individualOnly) {
979
- if (main == null) {
982
+ if (isUnset(main)) {
980
983
  const result = {};
981
984
  if (top != null) {
982
985
  const val = parseSingleValue(top, defaultValue, trueValue);
@@ -1004,7 +1007,7 @@ function processDirectionalStyle(config, props) {
1004
1007
  left: defaultInit
1005
1008
  };
1006
1009
  let useLonghand = false;
1007
- if (main != null) {
1010
+ if (!isUnset(main)) {
1008
1011
  if (typeof main === "number") dirs.top = dirs.right = dirs.bottom = dirs.left = `${main}px`;
1009
1012
  else {
1010
1013
  const strMain = main === true ? trueValue : String(main);
@@ -1265,7 +1268,7 @@ function outlineStyle({ outline, outlineOffset }) {
1265
1268
  }
1266
1269
  }
1267
1270
  }
1268
- if (outlineOffset != null && result["outline-offset"] === void 0) {
1271
+ if (outlineOffset != null && typeof outlineOffset !== "boolean" && result["outline-offset"] === void 0) {
1269
1272
  const offsetValue = typeof outlineOffset === "number" ? `${outlineOffset}px` : outlineOffset;
1270
1273
  result["outline-offset"] = parseStyle(offsetValue).groups[0]?.values[0] || resolveCustomProperties(offsetValue);
1271
1274
  }
@@ -1402,7 +1405,8 @@ function presetStyle({ preset, fontSize, lineHeight, textTransform, letterSpacin
1402
1405
  const modPart = parts[1];
1403
1406
  const nameTokens = namePart?.all ?? [];
1404
1407
  const isModOnly = nameTokens.length > 0 && nameTokens.every((t) => PRESET_MODIFIERS.has(t));
1405
- const nameToken = namePart?.mods[0] ?? namePart?.values[0] ?? "";
1408
+ const nameMods = namePart?.mods ?? [];
1409
+ const nameToken = nameTokens.find((token) => nameMods.includes(token) || isColorKeyword(token)) ?? namePart?.values[0] ?? "";
1406
1410
  const name = isModOnly || isTokenNameReference("preset", nameToken) ? "inherit" : nameToken || "inherit";
1407
1411
  const modTokens = isModOnly ? nameTokens : modPart?.all ?? [];
1408
1412
  const isStrong = modTokens.includes("strong") || modTokens.includes("bold");
@@ -1740,7 +1744,8 @@ function getTiming(name) {
1740
1744
  }
1741
1745
  function transitionStyle({ transition }) {
1742
1746
  if (!transition) return null;
1743
- if (CSS_WIDE_KEYWORDS.has(transition)) return { transition };
1747
+ const keyword = String(transition).trim().toLowerCase();
1748
+ if (keyword === "none" || CSS_WIDE_KEYWORDS.has(keyword)) return { transition: keyword };
1744
1749
  const processed = parseStyle(transition);
1745
1750
  const map = {};
1746
1751
  const named = /* @__PURE__ */ new Set();
@@ -2044,6 +2049,48 @@ function rootStateIndex(selector) {
2044
2049
  if (!isRoot) return -1;
2045
2050
  return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2046
2051
  }
2052
+ function pseudoElementIndex(selector) {
2053
+ let pseudoElementAt = -1;
2054
+ let newCompound = false;
2055
+ let squareDepth = 0;
2056
+ let parenDepth = 0;
2057
+ let quote = "";
2058
+ for (let i = 0; i < selector.length; i++) {
2059
+ const char = selector[i];
2060
+ if (quote) {
2061
+ if (char === "\\") i++;
2062
+ else if (char === quote) quote = "";
2063
+ continue;
2064
+ }
2065
+ if (char === "/" && selector[i + 1] === "*") {
2066
+ const end = selector.indexOf("*/", i + 2);
2067
+ if (end === -1) break;
2068
+ i = end + 1;
2069
+ continue;
2070
+ }
2071
+ if (squareDepth === 0 && parenDepth === 0) {
2072
+ if (/[\s>+~,]/.test(char)) {
2073
+ newCompound = true;
2074
+ continue;
2075
+ }
2076
+ if (newCompound) {
2077
+ pseudoElementAt = -1;
2078
+ newCompound = false;
2079
+ }
2080
+ if (pseudoElementAt === -1 && char === ":") {
2081
+ const name = /^:[\w-]+/.exec(selector.slice(i))?.[0] ?? "";
2082
+ if (selector[i + 1] === ":" || LEGACY_PSEUDO_ELEMENT_RE.test(name)) pseudoElementAt = i;
2083
+ }
2084
+ }
2085
+ if (char === "\\") i++;
2086
+ else if (char === "\"" || char === "'") quote = char;
2087
+ else if (char === "[") squareDepth++;
2088
+ else if (char === "]") squareDepth = Math.max(0, squareDepth - 1);
2089
+ else if (char === "(") parenDepth++;
2090
+ else if (char === ")") parenDepth = Math.max(0, parenDepth - 1);
2091
+ }
2092
+ return pseudoElementAt === -1 ? selector.length : pseudoElementAt;
2093
+ }
2047
2094
  function splitSelectorsSafely(selectorList) {
2048
2095
  if (!selectorList.includes(",")) {
2049
2096
  const selector = selectorList.trim();
@@ -4615,6 +4662,35 @@ function clearParseCache() {
4615
4662
  parseCache.clear();
4616
4663
  }
4617
4664
  //#endregion
4665
+ //#region src/pipeline/pseudo-element-states.ts
4666
+ const QUOTED_RE = /"(?:[^"\\]|\\.)*"|'(?:[^'\\]|\\.)*'/g;
4667
+ const STRUCTURAL_PSEUDO_RE = /:(?:root|empty|scope|has|(?:first|last|only)-(?:child|of-type)|nth-(?:last-)?(?:child|of-type))(?![\w-])/i;
4668
+ function leafMismatch(node) {
4669
+ if (node.kind !== "state") return null;
4670
+ if (node.type === "modifier") return "modifiers";
4671
+ if (node.type !== "pseudo") return null;
4672
+ const selector = node.pseudo.replace(QUOTED_RE, "\"\"");
4673
+ if (STRUCTURAL_PSEUDO_RE.test(selector)) return "position in the DOM tree";
4674
+ if (selector.includes("[")) return "attributes";
4675
+ if (selector.includes(".") || selector.includes("#")) return "classes or ids";
4676
+ return null;
4677
+ }
4678
+ function pseudoElementMismatch(condition, target) {
4679
+ const walk = (node, describesTarget) => {
4680
+ if (node.kind === "compound") {
4681
+ for (const child of node.children) {
4682
+ const found = walk(child, describesTarget);
4683
+ if (found) return found;
4684
+ }
4685
+ return null;
4686
+ }
4687
+ if (node.kind !== "state") return null;
4688
+ if (node.type === "own") return target.own || target.root ? walk(node.innerCondition, true) : null;
4689
+ return describesTarget ? leafMismatch(node) : null;
4690
+ };
4691
+ return walk(condition, target.root);
4692
+ }
4693
+ //#endregion
4618
4694
  //#region src/pipeline/index.ts
4619
4695
  const RE_UPPER_CASE = /[A-Z]/;
4620
4696
  const pipelineCache = new Lru(5e3);
@@ -4624,9 +4700,9 @@ function hasPipelineCacheEntry(cacheKey) {
4624
4700
  function clearPipelineCache() {
4625
4701
  pipelineCache.clear();
4626
4702
  }
4627
- function runPipeline(styles, parserContext) {
4703
+ function runPipeline(styles, parserContext, pseudoElementRoot = false) {
4628
4704
  const allRules = [];
4629
- processStyles(styles, "", parserContext, allRules);
4705
+ processStyles(styles, "", parserContext, allRules, pseudoElementRoot);
4630
4706
  const seen = /* @__PURE__ */ new Set();
4631
4707
  const normal = [];
4632
4708
  const starting = [];
@@ -4642,7 +4718,7 @@ function stableSortByOrder(rules) {
4642
4718
  if (rules.length <= 1) return rules;
4643
4719
  return [...rules].sort((a, b) => (a.order ?? 0) - (b.order ?? 0));
4644
4720
  }
4645
- function processStyles(styles, selectorSuffix, parserContext, allRules) {
4721
+ function processStyles(styles, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4646
4722
  const keys = Object.keys(styles);
4647
4723
  const selectorKeys = [];
4648
4724
  const styleKeys = [];
@@ -4658,10 +4734,10 @@ function processStyles(styles, selectorSuffix, parserContext, allRules) {
4658
4734
  }
4659
4735
  styleKeys.push(key);
4660
4736
  }
4661
- processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules);
4662
- processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules);
4737
+ processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot);
4738
+ processHandlerQueue(buildHandlerQueue(styleKeys, styles), selectorSuffix, parserContext, allRules, pseudoElementRoot);
4663
4739
  }
4664
- function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules) {
4740
+ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4665
4741
  for (const key of selectorKeys) {
4666
4742
  const nestedStyles = styles[key];
4667
4743
  if (!nestedStyles || typeof nestedStyles !== "object") continue;
@@ -4678,30 +4754,34 @@ function processNestedSelectors(styles, selectorKeys, selectorSuffix, parserCont
4678
4754
  ...subLocalStates
4679
4755
  } : parserContext.localPredefinedStates
4680
4756
  };
4681
- for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules);
4757
+ for (const suffix of suffixes) processStyles(cleanedStyles, selectorSuffix + suffix, subContext, allRules, pseudoElementRoot);
4682
4758
  }
4683
4759
  }
4684
- function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules) {
4760
+ function processHandlerQueue(handlerQueue, selectorSuffix, parserContext, allRules, pseudoElementRoot) {
4761
+ const target = {
4762
+ own: pseudoElementIndex(selectorSuffix) < selectorSuffix.length,
4763
+ root: pseudoElementRoot
4764
+ };
4685
4765
  for (const { handler, styleMap, hasStateMap } of handlerQueue) {
4686
4766
  const lookupStyles = handler.__lookupStyles;
4687
- const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext), lookupStyles) : [{
4767
+ const mergedRules = mergeByValue(invokeHandler(handler, hasStateMap ? computeStateCombinations(buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target), lookupStyles) : [{
4688
4768
  condition: trueCondition(),
4689
4769
  values: styleMap,
4690
4770
  order: 0
4691
4771
  }], selectorSuffix));
4692
4772
  for (const rule of mergedRules) {
4693
- const cssRules = materializeComputedRule(rule);
4773
+ const cssRules = materializeComputedRule(rule, pseudoElementRoot);
4694
4774
  allRules.push(...cssRules);
4695
4775
  }
4696
4776
  }
4697
4777
  }
4698
- function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
4778
+ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext, target) {
4699
4779
  const exclusiveByStyle = /* @__PURE__ */ new Map();
4700
4780
  for (const styleName of lookupStyles) {
4701
4781
  const value = styleMap[styleName];
4702
4782
  if (value === void 0) continue;
4703
4783
  if (isValueMapping(value)) {
4704
- const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
4784
+ const fullyExpanded = expandExclusiveOrs(buildExclusiveConditions(expandOrConditions(mergeEntriesByValue(parseStyleEntries(styleName, extractCompoundStates(target.own || target.root ? dropPseudoElementMismatches(styleName, value, parserContext, target) : value), (stateKey) => parseStateKey(stateKey, { context: parserContext }))))));
4705
4785
  exclusiveByStyle.set(styleName, fullyExpanded);
4706
4786
  } else exclusiveByStyle.set(styleName, [{
4707
4787
  styleKey: styleName,
@@ -4714,6 +4794,18 @@ function buildExclusivesForHandler(lookupStyles, styleMap, parserContext) {
4714
4794
  }
4715
4795
  return exclusiveByStyle;
4716
4796
  }
4797
+ function dropPseudoElementMismatches(styleName, valueMap, parserContext, target) {
4798
+ let kept;
4799
+ for (const stateKey of Object.keys(valueMap)) {
4800
+ if (stateKey === "" || stateKey === "_" || isMisusedFallbackKey(stateKey)) continue;
4801
+ const mismatch = pseudoElementMismatch(parseStateKey(stateKey, { context: parserContext }), target);
4802
+ if (!mismatch) continue;
4803
+ emitWarning("PSEUDO_ELEMENT_STATE_IGNORED", `State "${stateKey}" (in "${styleName}") applies to a pseudo-element, which has no ${mismatch}, so it can never match. The state has been ignored. To condition on the element the pseudo-element belongs to, write it in the selector before the pseudo-element.`);
4804
+ kept ??= { ...valueMap };
4805
+ delete kept[stateKey];
4806
+ }
4807
+ return kept ?? valueMap;
4808
+ }
4717
4809
  function invokeHandler(handler, stateSnapshots, selectorSuffix) {
4718
4810
  const computedRules = [];
4719
4811
  for (const snapshot of stateSnapshots) {
@@ -5044,20 +5136,23 @@ function mergeByValue(rules) {
5044
5136
  }
5045
5137
  return merged;
5046
5138
  }
5047
- function buildSelectorFromVariant(variant, selectorSuffix) {
5048
- let selector = "";
5139
+ function buildSelectorFromVariant(variant, selectorSuffix, pseudoElementRoot) {
5049
5140
  let rootSegment = branchToCSS([...variant.modifierConditions, ...variant.pseudoConditions]);
5050
5141
  for (const group of variant.selectorGroups) rootSegment += selectorGroupToCSS(group);
5051
- selector += wrapWhere(rootSegment);
5052
- if (variant.parentGroups.length > 0) selector += parentGroupsToCSS(variant.parentGroups);
5142
+ const parents = variant.parentGroups.length > 0 ? parentGroupsToCSS(variant.parentGroups) : "";
5143
+ const pseudoElementAt = pseudoElementRoot ? parents.length : 0;
5144
+ let selector = pseudoElementRoot ? parents + wrapWhere(rootSegment) : wrapWhere(rootSegment) + parents;
5053
5145
  selector += selectorSuffix;
5054
5146
  const ownOptimized = optimizeGroups(variant.ownGroups);
5055
5147
  let ownSegment = "";
5056
5148
  for (const group of ownOptimized) ownSegment += selectorGroupToCSS(group);
5057
5149
  selector += wrapWhere(ownSegment);
5058
- return selector;
5150
+ return {
5151
+ selector,
5152
+ pseudoElementAt
5153
+ };
5059
5154
  }
5060
- function materializeComputedRule(rule) {
5155
+ function materializeComputedRule(rule, pseudoElementRoot) {
5061
5156
  const components = conditionToCSS(rule.condition);
5062
5157
  if (components.isImpossible || components.variants.length === 0) return [];
5063
5158
  const declarations = Object.entries(rule.declarations).map(([prop, value]) => Array.isArray(value) ? value.map((v) => `${prop}: ${v};`).join(" ") : `${prop}: ${value};`).join(" ");
@@ -5080,12 +5175,13 @@ function materializeComputedRule(rule) {
5080
5175
  }
5081
5176
  const rules = [];
5082
5177
  for (const [, group] of byAtRules) {
5083
- const selectorFragments = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix));
5178
+ const built = mergeVariantsIntoSelectorGroups(group.variants).map((v) => buildSelectorFromVariant(v, rule.selectorSuffix, pseudoElementRoot));
5084
5179
  const cssRule = {
5085
- selector: selectorFragments.length === 1 ? selectorFragments[0] : selectorFragments,
5180
+ selector: built.length === 1 ? built[0].selector : built.map((b) => b.selector),
5086
5181
  declarations,
5087
5182
  order: rule.order
5088
5183
  };
5184
+ if (pseudoElementRoot) cssRule.pseudoElementAt = built.map((b) => b.pseudoElementAt);
5089
5185
  if (group.atRules.length > 0) cssRule.atRules = group.atRules;
5090
5186
  if (group.rootPrefix) {
5091
5187
  cssRule.rootPrefix = group.rootPrefix;
@@ -5113,23 +5209,33 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
5113
5209
  if (pipelineCacheKey) rules = pipelineCache.get(pipelineCacheKey);
5114
5210
  if (!rules && !styles) return directSelector ? [] : { rules: [] };
5115
5211
  const cacheKey = pipelineCacheKey || stringifyStyles(styles);
5116
- if (!rules) rules = pipelineCache.get(cacheKey);
5117
- if (!rules) {
5118
- rules = runPipeline(styles, createStateParserContext(styles));
5119
- pipelineCache.set(cacheKey, rules);
5120
- }
5212
+ const rulesFor = (pseudoElementRoot) => {
5213
+ const key = pseudoElementRoot ? `${cacheKey}\0::` : cacheKey;
5214
+ let cached = pipelineCache.get(key);
5215
+ if (!cached) {
5216
+ cached = runPipeline(styles, createStateParserContext(styles), pseudoElementRoot);
5217
+ pipelineCache.set(key, cached);
5218
+ }
5219
+ return cached;
5220
+ };
5121
5221
  if (directSelector) {
5122
5222
  const shouldDouble = options?.doubleSelector ?? false;
5123
5223
  const items = splitSelectorsSafely(classNameOrSelector);
5124
- const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => ({
5125
- base,
5126
- rootAt: rootStateIndex(base)
5127
- }));
5128
- return mergeStyleResults(rules.map((rule) => {
5224
+ const bases = (items.length > 0 ? items : [classNameOrSelector]).map((base) => {
5225
+ const at = pseudoElementIndex(base);
5226
+ return {
5227
+ head: base.slice(0, at),
5228
+ pseudoElement: base.slice(at),
5229
+ rootAt: rootStateIndex(base)
5230
+ };
5231
+ });
5232
+ const toResults = (groupRules, group) => groupRules.map((rule) => {
5129
5233
  const result = {
5130
- selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part) => bases.map(({ base, rootAt }) => {
5234
+ selector: (Array.isArray(rule.selector) ? rule.selector : rule.selector ? [rule.selector] : [""]).flatMap((part, index) => group.map(({ head, pseudoElement, rootAt }) => {
5131
5235
  const joinsRoot = rule.rootState !== void 0 && rootAt !== -1;
5132
- let sel = joinsRoot ? `${base.slice(0, rootAt)}${wrapWhere(rule.rootState)}${base.slice(rootAt)}${part}` : `${base}${part}`;
5236
+ const base = joinsRoot ? `${head.slice(0, rootAt)}${wrapWhere(rule.rootState)}${head.slice(rootAt)}` : head;
5237
+ const at = rule.pseudoElementAt?.[index] ?? 0;
5238
+ let sel = pseudoElement ? `${base}${part.slice(0, at)}${pseudoElement}${part.slice(at)}` : `${base}${part}`;
5133
5239
  if (shouldDouble && sel.startsWith(".")) {
5134
5240
  const classMatch = sel.match(/^\.[a-zA-Z_-][a-zA-Z0-9_-]*/);
5135
5241
  if (classMatch) sel = classMatch[0] + sel;
@@ -5142,8 +5248,12 @@ function renderStyles(styles, classNameOrSelector, options, pipelineCacheKey) {
5142
5248
  if (rule.atRules && rule.atRules.length > 0) result.atRules = rule.atRules;
5143
5249
  if (rule.startingStyle) result.startingStyle = true;
5144
5250
  return result;
5145
- }));
5251
+ });
5252
+ const plain = bases.filter((base) => !base.pseudoElement);
5253
+ const pseudo = bases.filter((base) => base.pseudoElement);
5254
+ return mergeStyleResults([...plain.length > 0 ? toResults(rulesFor(false), plain) : [], ...pseudo.length > 0 ? toResults(rulesFor(true), pseudo) : []]);
5146
5255
  }
5256
+ rules ??= rulesFor(false);
5147
5257
  return { rules: rules.map((r) => ({
5148
5258
  selector: Array.isArray(r.selector) ? r.selector.join("|||") : r.selector,
5149
5259
  declarations: r.declarations,
@@ -5463,4 +5573,4 @@ function renderStylesForChunk(styles, chunkName, styleKeys, pipelineCacheKey) {
5463
5573
  //#endregion
5464
5574
  export { styleHandlers as A, STYLE_TO_CHUNK as B, camelToKebab as C, normalizeHandlerDefinition as D, defineHandler as E, DIMENSION_CHUNK_STYLES as F, setGlobalPredefinedStates as G, clearGlobalPredefinedStates as H, DISPLAY_CHUNK_STYLES as I, markStylesGeneratedState as J, hasStylesGenerated as K, FONT_CHUNK_STYLES as L, createStyle as M, APPEARANCE_CHUNK_STYLES as N, registerHandler as O, CHUNK_NAMES as P, LAYOUT_CHUNK_STYLES as R, parseStateKey as S, STYLE_HANDLER_MAP as T, createStateParserContext as U, resetStyleChunks as V, getGlobalPredefinedStates as W, resetStylesGeneratedState as X, resetGlobalPolyfillsState as Y, setGlobalPolyfillsState as Z, POSITION_STYLES as _, registerBaseStyleProps as a, renderStyles as b, BLOCK_INNER_STYLES as c, COLOR_STYLES as d, CONTAINER_STYLES as f, OUTER_STYLES as g, INNER_STYLES as h, baseStylePropsRegistry as i, scanAnimationNames as j, resetHandlers as k, BLOCK_OUTER_STYLES as l, FLOW_STYLES as m, generateChunkCacheKey as n, resetBaseStyleProps as o, DIMENSION_STYLES as p, isFunctionsPolyfillEnabled as q, categorizeStyleKeys as r, BASE_STYLES as s, renderStylesForChunk as t, BLOCK_STYLES as u, TEXT_STYLES as v, splitSelectorsSafely as w, clearParseCache as x, clearPipelineCache as y, POSITION_CHUNK_STYLES as z };
5465
5575
 
5466
- //# sourceMappingURL=style-engine-BX2LshDZ.js.map
5576
+ //# sourceMappingURL=style-engine-DoGrZPBB.js.map