@bamboocss/generator 1.55.8 → 1.56.1

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 (3) hide show
  1. package/dist/index.cjs +44 -594
  2. package/dist/index.mjs +44 -594
  3. package/package.json +7 -7
package/dist/index.mjs CHANGED
@@ -25,7 +25,6 @@ function generateConditions(ctx) {
25
25
 
26
26
  export type ConditionalValue<V> =
27
27
  | V
28
- | Array<V | null>
29
28
  | {
30
29
  [K in keyof Conditions]?: ConditionalValue<V>
31
30
  }
@@ -185,190 +184,34 @@ function generateMergeCssFn(ctx) {
185
184
  }
186
185
  //#endregion
187
186
  //#region src/artifacts/js/cva.ts
187
+ /**
188
+ * The runtime `cva` a compiled build keeps: a callable that throws, and `splitVariantProps`.
189
+ *
190
+ * The Vite compiler rewrites every call into the classes it selects and erases the recipe, so
191
+ * nothing else on the returned object is reachable. It used to carry a whole engine anyway —
192
+ * `resolve`, `raw`, `merge`/`composeRecipes`, `getCompoundVariantCss`, `variantMap`, `config` —
193
+ * and every read of those fails the build with `runtime-binding`, so none of it could run in a
194
+ * build that succeeded. It also kept `mergeCss` and the shorthand table alive in every bundle
195
+ * that imported `cva`.
196
+ *
197
+ * `splitVariantProps` stays because it is the one member the compiler lowers rather than
198
+ * rejects: `b.splitVariantProps(p)` becomes `splitProps(p, [...keys])`, and a call site it
199
+ * could not lower still has a working method behind it.
200
+ */
188
201
  function generateCvaFn(ctx) {
189
- const { utility, hash, prefix } = ctx;
190
- const withPrefix = prefix.className ? `(className) => className ? ${JSON.stringify(prefix.className)} + '-' + className : ${JSON.stringify(prefix.className)}` : `(className) => className`;
191
202
  return {
192
203
  js: outdent`
193
- ${ctx.file.import("cloneStyles, compact, getRecipeIdentity, mergeProps, memo, splitProps, toHash, uniq, uncompiledStyle", "../helpers")}
194
- ${ctx.file.import("mergeCss", "./merge-css")}
195
- ${ctx.file.import("cx", "./cx")}
196
-
197
- // What \`createCss\` does to a class name, for the recipe path: prefix it, and hash it
198
- // when \`hash.className\` is set. The build applies the same two steps to the rules it
199
- // emits — see \`checkNamingAgreement\`, which compares the results.
200
- const withPrefix = ${withPrefix}
201
- export const formatRecipeClass = ${hash.className ? `(className) => withPrefix((${utility.toHash})([className], toHash))` : `withPrefix`}
202
-
203
- const defaults = (conf) => ({
204
- base: {},
205
- variants: {},
206
- defaultVariants: {},
207
- compoundVariants: [],
208
- ...conf,
209
- })
204
+ ${ctx.file.import("splitProps, uncompiledStyle", "../helpers")}
210
205
 
211
206
  export function cva(config) {
212
- const { base, variants, defaultVariants, compoundVariants } = defaults(config)
213
- const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
214
-
215
- // Derived from the config, because the build derives it from the same config while
216
- // emitting the stylesheet and the two never meet. \`className\` when the author set
217
- // one, a hash of the styles otherwise.
218
- const name = getRecipeIdentity(config)
219
-
220
- function resolve(props = {}) {
221
- const computedVariants = getVariantProps(props)
222
- let variantCss = { ...base }
223
- for (const [key, value] of Object.entries(computedVariants)) {
224
- if (variants[key]?.[value]) {
225
- variantCss = mergeCss(variantCss, variants[key][value])
226
- }
227
- }
228
- // A recipe with no compound variants has nothing left to merge, and the merge is
229
- // not free just because its second operand is empty: \`mergeCss\` is memoized on its
230
- // arguments, so the call hashes the whole accumulated style object before finding
231
- // there is nothing to do. Most recipes declare no compound variants at all, so
232
- // this is the common shape rather than a special case.
233
- if (compoundVariants.length === 0) return variantCss
234
-
235
- const compoundVariantCss = getCompoundVariantCss(compoundVariants, computedVariants)
236
- return mergeCss(variantCss, compoundVariantCss)
237
- }
238
-
239
- // \`raw\` runs per element per render — the JSX factory calls it to build the styles it
240
- // merges with style props — and \`resolve\` is not cheap: a \`mergeCss\` per active variant
241
- // plus a scan of every compound variant. Memoizing it keys that work on the variant
242
- // props rather than repeating it for every element that shares them.
243
- //
244
- // \`raw\` still clones what it returns. The memoized object is shared, so handing it to a
245
- // caller that mutated it would poison every later call.
246
- //
247
- // A recipe whose variants are all boolean could index an array instead of hashing, and
248
- // that was built and measured: +25% to +35% on \`raw()\`. It is not here because the
249
- // trade is bad. Correctness needs the selection read from own enumerable keys only, and
250
- // every variant to carry a boolean default so the merge order is pinned — and once that
251
- // gate is honest, no \`cva\`/\`sva\` call site in this repo passes it, because real recipes
252
- // mix a string variant in. The cost is unconditional: +289 B gzipped on that module for
253
- // every consumer, qualifying or not.
254
- const resolveVariants = memo(resolve)
255
-
256
- // The class names the build emitted rules for: the recipe's own class, plus one per
257
- // selected variant. Not \`css(resolve(props))\` — that would name classes by property,
258
- // and the stylesheet names this recipe's rules semantically, in the \`recipes\` layer.
259
- //
260
- // Compound variants are absent on purpose. Their rule selects on the variant classes
261
- // already in this list — \`.btn--size_sm.btn--tone_a\` — so it applies without anything
262
- // being added here, and adding a class for it would name a rule that does not exist.
263
- function cvaFn(_props) {
264
- return uncompiledStyle('cva')
265
- }
266
-
267
- const variantKeys = Object.keys(variants)
207
+ const variantKeys = Object.keys(config?.variants ?? {})
268
208
 
269
- function splitVariantProps(props) {
270
- return splitProps(props, variantKeys)
271
- }
272
-
273
- const variantMap = Object.fromEntries(Object.entries(variants).map(([key, value]) => [key, Object.keys(value)]))
274
-
275
- const self = Object.assign(memo(cvaFn), {
276
- __cva__: true,
277
- variantMap,
278
- raw: (...args) => cloneStyles(resolveVariants(...args)),
279
- config,
280
- // Composed against \`self\`, not against this closure, so \`a.merge(b).merge(c)\`
281
- // composes the *result* with \`c\` rather than recomposing \`a\` with \`c\` and
282
- // dropping \`b\`.
283
- merge: (other) => composeRecipes(self, other),
284
- splitVariantProps,
285
- getVariantProps
286
- })
287
-
288
- return self
289
- }
290
-
291
- /**
292
- * Compose two recipes into one.
293
- *
294
- * The class names come from both parents joined, not from a merged config. A recipe's
295
- * classes are named from the config the *build* saw, and the build only ever sees the
296
- * literal \`cva(...)\` call sites — a config synthesised here at runtime has no rules
297
- * behind it, so naming classes off it returned classes that styled nothing. This is the
298
- * shape \`mergeRecipes\` already uses for config recipes.
299
- *
300
- * The selection is resolved once and handed to both parents. Passing the raw props
301
- * instead let each parent apply *its own* defaults, so \`m()\` and
302
- * \`m(m.getVariantProps())\` disagreed and \`raw()\` contradicted the \`config\` the same
303
- * object publishes.
304
- *
305
- * \`raw\` still deep-merges, so per-property override survives where it can be expressed:
306
- * \`css(a.merge(b).raw(props))\` resolves before any class name exists. Through the class
307
- * path both parents land in the \`recipes\` layer, so a collision there is decided by
308
- * stylesheet order rather than by which parent came second.
309
- */
310
- function composeRecipes(left, right) {
311
- const leftConfig = defaults(left.config)
312
- const rightConfig = defaults(right.config)
313
- const variantKeys = uniq(Object.keys(left.variantMap), Object.keys(right.variantMap))
314
-
315
- const config = {
316
- base: mergeCss(leftConfig.base, rightConfig.base),
317
- variants: Object.fromEntries(
318
- variantKeys.map((key) => [key, mergeCss(leftConfig.variants[key], rightConfig.variants[key])]),
319
- ),
320
- defaultVariants: mergeProps(leftConfig.defaultVariants, rightConfig.defaultVariants),
321
- compoundVariants: [...leftConfig.compoundVariants, ...rightConfig.compoundVariants],
322
- }
323
-
324
- const select = (props) => ({ ...config.defaultVariants, ...compact(props) })
325
-
326
- const composed = Object.assign(
327
- memo((props) => {
328
- const selection = select(props)
329
- return cx(left(selection), right(selection))
330
- }),
331
- {
332
- __cva__: true,
333
- variantMap: Object.fromEntries(variantKeys.map((key) => [key, Object.keys(config.variants[key] ?? {})])),
334
- raw: (props) => {
335
- const selection = select(props)
336
- return cloneStyles(mergeCss(left.raw(selection), right.raw(selection)))
337
- },
338
- config,
339
- merge: (other) => composeRecipes(composed, other),
340
- splitVariantProps: (props) => splitProps(props, variantKeys),
341
- getVariantProps: select,
209
+ return Object.assign((_props) => uncompiledStyle('cva'), {
210
+ splitVariantProps(props) {
211
+ return splitProps(props, variantKeys)
342
212
  },
343
- )
344
-
345
- return composed
346
- }
347
-
348
- export function getCompoundVariantCss(compoundVariants, variantMap) {
349
- let result = {}
350
- compoundVariants.forEach((compoundVariant) => {
351
- const isMatching = Object.entries(compoundVariant).every(([key, value]) => {
352
- if (key === 'css') return true
353
-
354
- const values = Array.isArray(value) ? value : [value]
355
- return values.some((value) => variantMap[key] === value)
356
- })
357
-
358
- if (isMatching) {
359
- result = mergeCss(result, compoundVariant.css)
360
- }
361
213
  })
362
-
363
- return result
364
- }
365
-
366
- export function assertCompoundVariant(name, compoundVariants, variants, prop) {
367
- if (compoundVariants.length > 0 && typeof variants?.[prop] === 'object') {
368
- throw new Error(\`[recipe:\${name}:\${prop}] Conditions are not supported when using compound variants.\`)
369
- }
370
214
  }
371
-
372
215
  `,
373
216
  dts: outdent`
374
217
  ${ctx.file.importType("RecipeCreatorFn", "../types/recipe")}
@@ -513,7 +356,7 @@ function generateCx(ctx) {
513
356
  }
514
357
  //#endregion
515
358
  //#region src/artifacts/generated/helpers.mjs.json
516
- var content$7 = "//#region src/assert.ts\nfunction isObject(value) {\n return typeof value === \"object\" && value != null && !Array.isArray(value);\n}\nconst isObjectOrArray = (obj) => typeof obj === \"object\" && obj !== null;\n//#endregion\n//#region src/error.ts\nvar BambooError = class extends Error {\n code;\n hint;\n constructor(code, message, opts) {\n super(message, { cause: opts?.cause });\n this.code = `ERR_BAMBOO_${code}`;\n this.hint = opts?.hint;\n }\n};\n//#endregion\n//#region src/hash.ts\nfunction toChar(code) {\n return String.fromCharCode(code + (code > 25 ? 39 : 97));\n}\nfunction toName(code) {\n let name = \"\";\n let x;\n for (x = Math.abs(code); x > 52; x = x / 52 | 0) name = toChar(x % 52) + name;\n return toChar(x % 52) + name;\n}\nfunction toPhash(h, x) {\n let i = x.length;\n while (i) h = h * 33 ^ x.charCodeAt(--i);\n return h;\n}\nfunction toHash(value) {\n return toName(toPhash(5381, value) >>> 0);\n}\n//#endregion\n//#region src/memo.ts\n/**\n* Bounded argument memo used by the generated runtime (`css`, patterns, `cva`, recipes).\n*\n* Two regimes, picked per call:\n*\n* - Arguments that are flat (objects of primitives) take a cheap structural hash\n* and are confirmed with an exact comparison, so a hash collision can never\n* serve the wrong result. This is the shape `css({ ... })` has.\n* - Anything nested falls back to `JSON.stringify`, which V8 does faster than a\n* JS walk.\n*\n* The second point is the counter-intuitive one, and it has been measured rather\n* than assumed. Extending the structural hash to recurse — so nested styles could\n* take the fast path too — is *slower*, because it trades one native serialization\n* for two JS walks (hash, then the deep equality that confirms it). Over 10k\n* iterations per shape:\n*\n* shape stringify recursive hash + deep equal\n* flat 1.06ms 2.09ms\n* _hover 1.00ms 2.16ms\n* responsive 1.23ms 2.15ms\n* realistic 2.32ms 5.84ms\n* nested 3 deep 1.22ms 2.35ms\n*\n* So a nested `css()` call costing several times a flat one is not a defect here.\n* It is the floor for a value-keyed memo in JS, and the way to avoid it is to not\n* make the call — see the build-time fold in `@bamboocss/vite`.\n*\n* Both regimes key on *values*, never on object identity: mutating a style object\n* between calls changes its hash, so the next call misses and recomputes rather\n* than serving a stale class. Keying nested arguments on the identity of the inner\n* objects would skip serialization entirely, but it cannot detect a mutation, and\n* \"same object, different contents\" is exactly what a style object built per render\n* looks like.\n*\n* Both caches are bounded. An unbounded memo is a leak in any long-lived process\n* (SSR), where the set of distinct style objects grows without limit.\n*/\n/**\n* Distinct hashes held per memoized function before the cache rotates.\n*\n* This bounds *buckets*, not entries: a bucket keeps up to `MAX_BUCKET` colliding\n* argument lists, so the ceiling is `MAX_ENTRIES * MAX_BUCKET` live entries, and\n* twice that across both generations, since the previous one is retained until the\n* next rotation. Collisions are rare in practice, so the realistic figure is close\n* to `MAX_ENTRIES` — but the worst case is what matters when sizing a long-lived\n* process, so state it plainly.\n*\n* Rotation beats evicting the oldest key: single-key eviction is worst-case for a\n* working set that cycles, because it drops exactly the entry about to be needed.\n* Measured on a cycling set of 20k styles, one-at-a-time eviction cost ~719ns/op\n* against ~189ns unbounded, while rotation holds ~274ns. On realistic skewed\n* access rotation is at or below the unbounded cost.\n*/\nconst MAX_ENTRIES = 1e3;\n/** Entries kept per hash bucket, to bound the cost of a collision scan. */\nconst MAX_BUCKET = 8;\n/**\n* DJB2 over the arguments' own keys and primitive values.\n* Returns `null` for anything nested, which routes the call to the string key.\n*/\nconst flatHashOrNull = (args) => {\n let h = 5381;\n for (let a = 0; a < args.length; a++) {\n const obj = args[a];\n if (obj === null || typeof obj !== \"object\") {\n const t = typeof obj;\n if (t === \"string\") for (let i = 0; i < obj.length; i++) h = h * 33 ^ obj.charCodeAt(i);\n else if (t === \"number\") h = h * 33 ^ (obj | 0);\n else if (t === \"boolean\") h = h * 33 ^ (obj ? 991 : 997);\n else h = h * 33 ^ 3;\n continue;\n }\n if (Array.isArray(obj)) return null;\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) return null;\n for (const k in obj) {\n const v = obj[k];\n const tv = typeof v;\n if (v !== null && tv === \"object\") return null;\n for (let i = 0; i < k.length; i++) h = h * 33 ^ k.charCodeAt(i);\n if (tv === \"string\") for (let i = 0; i < v.length; i++) h = h * 33 ^ v.charCodeAt(i);\n else if (tv === \"number\") h = h * 33 ^ (v | 0);\n else if (tv === \"boolean\") h = h * 33 ^ (v ? 991 : 997);\n else h = h * 33 ^ 2;\n }\n }\n return h >>> 0;\n};\n/**\n* Value snapshot of the arguments, taken once at insert.\n*\n* The cache must not hold the caller's objects: a style object can capture a much\n* larger graph, and keeping it alive until the cache rotates changes GC behaviour\n* for code that never asked to be cached. Only the flat path reaches here, so a\n* shallow copy contains primitives only and retains nothing.\n*\n* Comparing against a copy also removes the last way a mutation could be missed.\n* Were the caller's own object stored, `oa === ob` would short-circuit the value\n* comparison, and a mutation that happened to preserve the hash would return the\n* stale entry. Against a copy that check can only ever be true for equal\n* primitives.\n*/\nconst snapshotArgs = (args) => {\n const values = [];\n const counts = [];\n for (let i = 0; i < args.length; i++) {\n const o = args[i];\n if (o !== null && typeof o === \"object\") {\n const copy = Array.isArray(o) ? [] : {};\n let n = 0;\n for (const k in o) {\n copy[k] = o[k];\n n++;\n }\n values.push(copy);\n counts.push(n);\n } else {\n values.push(o);\n counts.push(0);\n }\n }\n return {\n values,\n counts\n };\n};\n/**\n* Exact match, so a `flatHashOrNull` collision is resolved rather than trusted.\n* `bCounts` is the cached side's key count; comparing against it avoids the\n* `Object.keys()` allocation this would otherwise make on every cache hit.\n*/\nconst flatArgsEqual = (a, b, bCounts) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const oa = a[i];\n const ob = b[i];\n if (oa === ob) continue;\n if (oa === null || ob === null || typeof oa !== \"object\" || typeof ob !== \"object\") return false;\n if (Array.isArray(oa) !== Array.isArray(ob)) return false;\n let n = 0;\n for (const k in oa) {\n if (oa[k] !== ob[k]) return false;\n n++;\n }\n if (n !== bCounts[i]) return false;\n }\n return true;\n};\nconst memo = (fn) => {\n let buckets = /* @__PURE__ */ new Map();\n let priorBuckets = /* @__PURE__ */ new Map();\n let strings = /* @__PURE__ */ new Map();\n let priorStrings = /* @__PURE__ */ new Map();\n /**\n * One scalar argument, keyed directly.\n *\n * This is the shape of the hottest callers — `isCssProperty(prop)` runs per prop\n * per render — and a plain map lookup beats hashing, bucket scanning and\n * snapshotting for it. Distinct types stay distinct keys, so `1` and `'1'` do not\n * share an entry.\n */\n let scalars = /* @__PURE__ */ new Map();\n let priorScalars = /* @__PURE__ */ new Map();\n const scan = (bucket, args) => {\n if (bucket) for (let i = 0; i < bucket.length; i++) {\n const entry = bucket[i];\n if (flatArgsEqual(args, entry.values, entry.counts)) return entry;\n }\n };\n const get = (...args) => {\n if (args.length === 1) {\n const only = args[0];\n if (only === null || typeof only !== \"object\") {\n if (scalars.has(only)) return scalars.get(only);\n if (priorScalars.has(only)) {\n const promoted = priorScalars.get(only);\n scalars.set(only, promoted);\n return promoted;\n }\n const out = fn(only);\n scalars.set(only, out);\n if (scalars.size > MAX_ENTRIES) {\n priorScalars = scalars;\n scalars = /* @__PURE__ */ new Map();\n }\n return out;\n }\n }\n const hash = flatHashOrNull(args);\n if (hash !== null) {\n let bucket = buckets.get(hash);\n const hit = scan(bucket, args);\n if (hit) return hit.out;\n const priorHit = scan(priorBuckets.get(hash), args);\n if (priorHit) {\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push(priorHit);\n if (bucket.length > MAX_BUCKET) bucket.shift();\n return priorHit.out;\n }\n const snap = snapshotArgs(args);\n const out = fn(...args);\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push({\n values: snap.values,\n counts: snap.counts,\n out\n });\n if (bucket.length > MAX_BUCKET) bucket.shift();\n if (buckets.size > MAX_ENTRIES) {\n priorBuckets = buckets;\n buckets = /* @__PURE__ */ new Map();\n }\n return out;\n }\n const key = JSON.stringify(args);\n if (strings.has(key)) return strings.get(key);\n if (priorStrings.has(key)) {\n const promoted = priorStrings.get(key);\n strings.set(key, promoted);\n return promoted;\n }\n const out = fn(...args);\n strings.set(key, out);\n if (strings.size > MAX_ENTRIES) {\n priorStrings = strings;\n strings = /* @__PURE__ */ new Map();\n }\n return out;\n };\n return get;\n};\n//#endregion\n//#region src/merge-props.ts\nconst MERGE_OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\nfunction mergeProps(...sources) {\n return sources.reduce((prev, obj) => {\n if (!obj) return prev;\n Object.keys(obj).forEach((key) => {\n if (MERGE_OMIT.has(key)) return;\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) prev[key] = mergeProps(prevValue, value);\n else prev[key] = value;\n });\n return prev;\n }, {});\n}\n//#endregion\n//#region src/walk-object.ts\nconst isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObjectOrArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop, child) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) return predicate(value, path);\n const next = inner(child, childPath);\n if (isNotNullish(next)) result[key] = next;\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (Array.isArray(obj)) return obj.map((value) => fn(value));\n if (!isObject(obj)) return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n//#endregion\n//#region src/normalize-style-object.ts\n/**\n* Whether walking the object would only rebuild it.\n*\n* Normalizing does two things: it renames a shorthand to its longhand and drops nullish\n* leaves. A flat object of plain values written in longhand needs neither, and that is most\n* of what `css()` is handed — but it still paid for a full rebuild plus a path array per key.\n*\n* Every clause has to be exact, since a false positive returns an object the walk would have\n* changed. Nullish is one of them: a leaf the walk removes must not survive, or a later merge\n* would see it override the value beneath it. The array check is another, and it is on the\n* container as well as the values — `stop` is handed the container, so an array arriving at\n* the top level has to reach the walk to be rejected rather than being returned as it came.\n*\n* `for...in` reads inherited keys the walk ignores, which is safe in the only direction it can\n* be wrong — an extra key can send this to the slow path, never past it.\n*\n* It does read every value, as `compactStyles` and the argument memo already do, so an\n* accessor prop is read once more than before. Style props are values by the time they get\n* here and reading one has no effect, but it is the reason this cannot be reordered to read\n* lazily.\n*/\nfunction needsNoNormalizing(styles, resolveShorthand) {\n if (Array.isArray(styles)) return false;\n for (const key in styles) {\n const value = styles[key];\n if (value == null || typeof value === \"object\") return false;\n if (resolveShorthand !== void 0 && resolveShorthand(key) !== key) return false;\n }\n return true;\n}\n/**\n* The result may be the argument itself rather than a fresh object, so callers have to treat\n* it as read-only. Every one of them does today: merging accumulates into its own object and\n* the two `raw()` helpers clone at the boundary.\n*\n* An array is not a style value. It used to be read as one value per breakpoint, which meant\n* a font stack written the way CSS writes one — `['Inter', 'sans-serif']` — silently became\n* `Inter` at base and `sans-serif` at `sm`. The type no longer admits an array, so reaching\n* this throw takes a cast or untyped javascript; it says which property, since the walk knows\n* the path and the caller usually does not.\n*/\nfunction normalizeStyleObject(styles, context, shorthand = true) {\n const { utility } = context;\n const { hasShorthand, resolveShorthand } = utility;\n if (needsNoNormalizing(styles, shorthand && hasShorthand ? resolveShorthand : void 0)) return styles;\n return walkObject(styles, (value, path) => {\n if (Array.isArray(value)) throw new BambooError(\"INVALID_STYLE_VALUE\", `An array is not a style value${path.length ? `: \"${path.join(\".\")}\"` : \"\"}.`, { hint: \"Write a responsive value as a condition object, e.g. { base: \\\"medium\\\", lg: \\\"bold\\\" }.\" });\n return value;\n }, {\n stop: (value) => Array.isArray(value),\n getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0\n });\n}\n//#endregion\n//#region src/classname.ts\n/**\n* Whether a style object carries anything `compact` would have kept.\n*\n* The question `compactStyles` asks is only ever \"is this empty once undefined values are\n* dropped\", but it used to answer it by building the compacted object and then a key array\n* for it, then throwing both away. `Object.keys` enumerates exactly what `compact`'s\n* `Object.entries` did — own, enumerable, string-keyed — so this is the same predicate\n* without the two allocations, and it stops at the first value that settles it.\n*/\nfunction hasDefinedValue(style) {\n const keys = Object.keys(style);\n for (let i = 0; i < keys.length; i++) if (style[keys[i]] !== void 0) return true;\n return false;\n}\n/**\n* An array is not a style argument.\n*\n* `css([a, b])` used to mean `css(a, b)`, flattened here one level. Two spellings of one\n* call is the redundancy; the array one also cost a `flat()` allocation on every merge to\n* serve a shape almost nothing wrote, and read as a responsive array everywhere that had\n* not been taught to flatten it first.\n*\n* It throws rather than being filtered out as a non-object, which is what dropping the\n* `flat()` alone would have done — silently returning no class at all.\n*/\nfunction compactStyles(...styles) {\n return styles.filter((style) => {\n if (Array.isArray(style)) throw new BambooError(\"INVALID_STYLE_ARGUMENT\", \"An array is not a style argument.\", { hint: \"Spread it instead, e.g. css(...styles) rather than css(styles).\" });\n return isObject(style) && hasDefinedValue(style);\n });\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1) return allStyles;\n return allStyles.map((style) => normalizeStyleObject(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n return {\n mergeCss: memo(mergeCss),\n mergeCssUncached: mergeCss\n };\n}\n//#endregion\n//#region src/clone-styles.ts\nconst OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\n/**\n* Independent copy of a style object, nested condition blocks included.\n*\n* Merged style objects are cached, so anything handed to user code has to be\n* copied first: a caller mutating what it received would otherwise change what\n* every later caller reads back. `css.raw()` and `cva.raw()` are those boundaries.\n*\n* Kept separate from `mergeProps` deliberately. Merging is on the hot path — it\n* runs on every `css()` cache miss and on every render of a pattern component\n* under `jsxStyleProps: 'minimal'` — and copying there charges every caller for a\n* guarantee only the two `raw()` helpers need. Measured on a realistic style\n* object (5 base properties, 4 condition blocks) that was roughly twice the cost\n* of merging alone.\n*/\nfunction cloneStyles(styles) {\n if (Array.isArray(styles)) return styles.map((value) => cloneStyles(value));\n if (!isObject(styles)) return styles;\n const out = {};\n for (const key of Object.keys(styles)) {\n if (OMIT.has(key)) continue;\n out[key] = cloneStyles(styles[key]);\n }\n return out;\n}\n//#endregion\n//#region src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value]) => value !== void 0));\n}\n//#endregion\n//#region src/recipe-identity.ts\n/**\n* The fields that decide what CSS a recipe produces. Anything else is metadata.\n*\n* `slots` and `scopeRoots` count. They do not change a declaration, but they change the\n* *shape* of what is emitted — which slots exist, and whether a slot's variants become\n* `@scope` rules or a class of its own. Two `sva`s differing only in `scopeRoots` hashed to\n* one name, and since an inline recipe is registered once, whichever was extracted first\n* decided the emission for both; the other's runtime then asked for classes no rule\n* existed under. \"Same styles, different DOM topology\" is exactly what `scopeRoots` is for,\n* so it is the collision most likely to happen.\n*/\nconst STYLE_FIELDS = [\n \"base\",\n \"variants\",\n \"compoundVariants\",\n \"defaultVariants\",\n \"slots\",\n \"scopeRoots\"\n];\n/**\n* A serialization that depends on the config's *content* and not on how it was written.\n*\n* Object keys are sorted, so reordering two variants in the source does not rename every\n* class the recipe emits. Arrays keep their order, because `compoundVariants` is precedence\n* ordered and two orderings are two different recipes.\n*\n* A function serializes to `null` rather than to its source. `JSON.stringify` already drops\n* them, and stringifying instead would key the name on whether the bundle was minified —\n* the same build-dependent divergence that `cx` was changed to avoid. Nothing that survives\n* static extraction is a function, so there is no real config this loses information about.\n*/\n/**\n* Runs of whitespace inside a declaration value, collapsed to one space.\n*\n* The build never sees the value as written. `maybe-box-node` reads every string literal\n* through `trimWhitespace`, so `'calc(100vh - 16px)'` is `'calc(100vh - 16px)'` by the time\n* a recipe config reaches the encoder — the two produce identical CSS, and the stylesheet\n* emits one rule for both.\n*\n* The browser holds the config as authored. Without this, the two sides hashed different\n* objects and derived different names, so the element asked for a class the stylesheet did\n* not carry and rendered with *none* of the recipe's styles. Silent, and invisible to a\n* dead-rule check: the extra name leaves no unused rule behind, because the collapsed config\n* is byte-identical to one that was already emitted.\n*\n* The regex is `trimWhitespace`'s, deliberately. A second spelling of \"the same value\" is a\n* second thing to keep in agreement, which is the defect this is fixing.\n*/\nconst collapseWhitespace = (value) => value.replaceAll(/\\s+/g, \" \");\nconst stable = (value) => {\n if (typeof value === \"string\") return JSON.stringify(collapseWhitespace(value));\n if (value === null || typeof value !== \"object\") return JSON.stringify(value) ?? \"null\";\n if (Array.isArray(value)) return `[${value.map(stable).join(\",\")}]`;\n const source = value;\n return `{${Object.keys(source).sort().filter((key) => source[key] !== void 0 && source[key] !== null).map((key) => `${JSON.stringify(key)}:${stable(source[key])}`).join(\",\")}}`;\n};\n/**\n* The name an inline `cva`/`sva` emits its classes under — `button--size_sm`, where this\n* returns the `button`.\n*\n* A config recipe gets its name from the key it is declared under. An inline one has no\n* such key, and the two places that need the name never meet: the build derives it while\n* emitting the stylesheet, the runtime derives it again in the browser. So it has to come\n* from something both of them see, which leaves the config object itself.\n*\n* Deriving it from the *binding* — `const button = cva(...)` — was the obvious alternative\n* and does not work. Only the build can see that binding; handing it to the runtime means\n* rewriting the call, and then a pipeline without that transform names classes differently\n* from one with it. An optional `className` gets the same readable output with none of\n* that, because it travels inside the config to both sides.\n*\n* `className` is the field a config recipe already names itself with, and it means the same\n* thing here — the prefix every class the recipe emits is built from. An inline recipe that\n* declares one is indistinguishable in the stylesheet from a recipe declared in config.\n*/\nconst getRecipeIdentity = (config, prefix = \"cva\") => {\n const declared = config?.className;\n if (typeof declared === \"string\" && declared) return declared;\n const styles = {};\n for (const field of STYLE_FIELDS) {\n const value = config?.[field];\n if (value !== void 0) styles[field] = value;\n }\n return `${prefix}_${toHash(stable(styles))}`;\n};\n//#endregion\n//#region src/is-css-function.ts\nconst fnRegExp = new RegExp(`^(${[\n \"min\",\n \"max\",\n \"clamp\",\n \"calc\"\n].join(\"|\")})\\\\(.*\\\\)`);\nconst isCssFunction = (v) => typeof v === \"string\" && fnRegExp.test(v);\n//#endregion\n//#region src/is-css-unit.ts\nconst lengthUnitsPattern = `(?:${\"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%\".split(\",\").join(\"|\")})`;\nconst lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);\nconst isCssUnit = (v) => typeof v === \"string\" && lengthRegExp.test(v);\n//#endregion\n//#region src/is-css-var.ts\nconst isCssVar = (v) => typeof v === \"string\" && /^var\\(--.+\\)$/.test(v);\n//#endregion\n//#region src/pattern-fns.ts\nconst createPatternFns = (token) => ({\n map: mapObject,\n isCssFunction,\n isCssVar,\n isCssUnit,\n token\n});\nconst getPatternStyles = (pattern, styles) => {\n if (!pattern?.defaultValues) return styles;\n const defaults = typeof pattern.defaultValues === \"function\" ? pattern.defaultValues(styles) : pattern.defaultValues;\n return Object.assign({}, defaults, compact(styles));\n};\n//#endregion\n//#region src/slot.ts\nconst getSlotRecipes = (recipe = {}) => {\n const init = (slot) => ({\n className: [recipe.className, slot].filter(Boolean).join(\"__\"),\n base: recipe.base?.[slot] ?? {},\n variants: {},\n defaultVariants: recipe.defaultVariants ?? {},\n compoundVariants: recipe.compoundVariants ? getSlotCompoundVariant(recipe.compoundVariants, slot) : []\n });\n const recipeParts = (recipe.slots ?? []).map((slot) => [slot, init(slot)]);\n for (const [variantsKey, variantsSpec] of Object.entries(recipe.variants ?? {})) for (const [variantKey, variantSpec] of Object.entries(variantsSpec)) recipeParts.forEach(([slot, slotRecipe]) => {\n slotRecipe.variants[variantsKey] ??= {};\n slotRecipe.variants[variantsKey][variantKey] = variantSpec[slot] ?? {};\n });\n return Object.fromEntries(recipeParts);\n};\nconst getSlotCompoundVariant = (compoundVariants, slotName) => compoundVariants.filter((compoundVariant) => compoundVariant?.css?.[slotName]).map((compoundVariant) => ({\n ...compoundVariant,\n css: compoundVariant.css[slotName]\n}));\n//#endregion\n//#region src/split-props.ts\n/**\n* Move one key into a bucket, keeping whatever about it is observable.\n*\n* Shared by both paths below so there is one implementation of the descriptor rules rather\n* than two to keep in step. The rules themselves are documented on `splitProps`.\n*/\nconst copyKey = (props, target, key) => {\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n if (!descriptor) return false;\n if (\"get\" in descriptor || \"set\" in descriptor || !descriptor.enumerable || key === \"__proto__\") Object.defineProperty(target, key, descriptor);\n else target[key] = descriptor.value;\n return true;\n};\n/**\n* One array group, which is what every call site in this project passes — a recipe's\n* `variantKeys`.\n*\n* The general path below is built for several groups that may be predicates, and pays for\n* that shape on every call: a closure per group, a `map` and a `concat` to assemble the\n* result, and a branch per group to tell an array from a predicate. None of it is reachable\n* with one array group.\n*\n* What it does *not* skip is the part that looks skippable. `own` stays, because membership\n* has to be answered from `ownKeys` rather than by asking the object: on a proxy — which is\n* what Solid's `mergeProps` hands over — every question is a trap, and a recipe naming eight\n* variants would otherwise fire eight traps to learn what one `ownKeys` already said. And\n* the two passes stay separate, because the group bucket is in *group* order while the rest\n* bucket is in *props* order, and that ordering reaches the emitted CSS.\n*/\nconst splitOneGroup = (props, allKeys, group) => {\n const own = new Set(allKeys);\n const taken = /* @__PURE__ */ new Set();\n const picked = {};\n for (let i = 0; i < group.length; i++) {\n const key = group[i];\n if (taken.has(key) || !own.has(key)) continue;\n if (copyKey(props, picked, key)) taken.add(key);\n }\n const rest = {};\n for (let i = 0; i < allKeys.length; i++) {\n const key = allKeys[i];\n if (taken.has(key)) continue;\n copyKey(props, rest, key);\n }\n return [picked, rest];\n};\n/**\n* Deal a props object into one bucket per key group, plus a final bucket for the rest.\n* A key goes to the first group that claims it.\n*\n* ## Why the descriptor is read per key rather than in bulk\n*\n* This used to call `Object.getOwnPropertyDescriptors` for the whole object and\n* `defineProperty` for every key it moved. Copying plain values instead is 2.4–2.9x faster\n* on the shapes that allow it, but it is only correct where props are data — and they are\n* not always. Solid compiles props to accessors, so reading one eagerly runs whatever it\n* wraps: splitting a component's props would construct its children before the surrounding\n* provider exists.\n*\n* So the descriptor is fetched per key, and the value path is taken only when it changes\n* nothing observable. An accessor keeps its laziness, a non-enumerable key keeps its\n* invisibility, and `__proto__` is defined rather than assigned so it stays an own\n* property instead of reaching the prototype setter.\n*\n* The one thing the value path drops is `writable`/`configurable`, so a bucket key taken\n* from frozen props is writable where it used to be frozen. Nothing here relies on that,\n* and preserving it would mean `defineProperty` on the common path — the cost this exists\n* to avoid. Keys that take the descriptor path keep theirs, so a bucket can be\n* inconsistent in that one respect.\n*\n* Key order within a bucket is preserved exactly. It is not cosmetic: `cva` merges\n* variant props in iteration order, and the parser reads the rest bucket as the style\n* props it encodes, so order reaches the emitted CSS.\n*/\nfunction splitProps(props, ...keys) {\n const allKeys = Object.getOwnPropertyNames(props);\n if (keys.length === 1 && Array.isArray(keys[0])) return splitOneGroup(props, allKeys, keys[0]);\n const own = new Set(allKeys);\n const taken = /* @__PURE__ */ new Set();\n const split = (group) => {\n const clone = {};\n for (let i = 0; i < group.length; i++) {\n const key = group[i];\n if (taken.has(key) || !own.has(key)) continue;\n if (copyKey(props, clone, key)) taken.add(key);\n }\n return clone;\n };\n /**\n * The predicate is called with the key alone.\n *\n * Handing it to `filter` passes `(key, index, allKeys)`. A one-parameter predicate cannot\n * see the extras, but a memoized one reads its whole argument list — and the predicates\n * that arrive here are memoized, `isCssProperty` among them. So the memo hashed the entire\n * key array once per prop, and keyed its cache on it: two elements with different prop sets\n * shared no entry even for the same prop name.\n *\n * Worth ~9.7x on that path, and nothing at all on a plain predicate — which is why the\n * bench below it needs a memoized case to see this at all.\n *\n * A loop rather than `filter((k) => key(k))` because the wrapper allocates a closure per\n * group. The two measure the same to within noise; the loop just does not need one.\n */\n const matching = (predicate) => {\n const group = [];\n for (let i = 0; i < allKeys.length; i++) {\n const key = allKeys[i];\n if (predicate(key)) group.push(key);\n }\n return group;\n };\n return keys.map((key) => split(Array.isArray(key) ? key : matching(key))).concat(split(allKeys));\n}\n//#endregion\n//#region src/uniq.ts\nconst uniq = (...items) => {\n const set = items.reduce((acc, currItems) => {\n if (currItems) currItems.forEach((item) => acc.add(item));\n return acc;\n }, /* @__PURE__ */ new Set([]));\n return Array.from(set);\n};\n//#endregion\nexport { cloneStyles, compact, createMergeCss, createPatternFns, getPatternStyles, getRecipeIdentity, getSlotCompoundVariant, getSlotRecipes, memo, mergeProps, splitProps, toHash, uniq };\n";
359
+ var content$7 = "//#region src/assert.ts\nfunction isObject(value) {\n return typeof value === \"object\" && value != null && !Array.isArray(value);\n}\nconst isObjectOrArray = (obj) => typeof obj === \"object\" && obj !== null;\n//#endregion\n//#region src/error.ts\nvar BambooError = class extends Error {\n code;\n hint;\n constructor(code, message, opts) {\n super(message, { cause: opts?.cause });\n this.code = `ERR_BAMBOO_${code}`;\n this.hint = opts?.hint;\n }\n};\n//#endregion\n//#region src/memo.ts\n/**\n* Bounded argument memo used by the generated runtime (`css`, patterns, `cva`, recipes).\n*\n* Two regimes, picked per call:\n*\n* - Arguments that are flat (objects of primitives) take a cheap structural hash\n* and are confirmed with an exact comparison, so a hash collision can never\n* serve the wrong result. This is the shape `css({ ... })` has.\n* - Anything nested falls back to `JSON.stringify`, which V8 does faster than a\n* JS walk.\n*\n* The second point is the counter-intuitive one, and it has been measured rather\n* than assumed. Extending the structural hash to recurse — so nested styles could\n* take the fast path too — is *slower*, because it trades one native serialization\n* for two JS walks (hash, then the deep equality that confirms it). Over 10k\n* iterations per shape:\n*\n* shape stringify recursive hash + deep equal\n* flat 1.06ms 2.09ms\n* _hover 1.00ms 2.16ms\n* responsive 1.23ms 2.15ms\n* realistic 2.32ms 5.84ms\n* nested 3 deep 1.22ms 2.35ms\n*\n* So a nested `css()` call costing several times a flat one is not a defect here.\n* It is the floor for a value-keyed memo in JS, and the way to avoid it is to not\n* make the call — see the build-time fold in `@bamboocss/vite`.\n*\n* Both regimes key on *values*, never on object identity: mutating a style object\n* between calls changes its hash, so the next call misses and recomputes rather\n* than serving a stale class. Keying nested arguments on the identity of the inner\n* objects would skip serialization entirely, but it cannot detect a mutation, and\n* \"same object, different contents\" is exactly what a style object built per render\n* looks like.\n*\n* Both caches are bounded. An unbounded memo is a leak in any long-lived process\n* (SSR), where the set of distinct style objects grows without limit.\n*/\n/**\n* Distinct hashes held per memoized function before the cache rotates.\n*\n* This bounds *buckets*, not entries: a bucket keeps up to `MAX_BUCKET` colliding\n* argument lists, so the ceiling is `MAX_ENTRIES * MAX_BUCKET` live entries, and\n* twice that across both generations, since the previous one is retained until the\n* next rotation. Collisions are rare in practice, so the realistic figure is close\n* to `MAX_ENTRIES` — but the worst case is what matters when sizing a long-lived\n* process, so state it plainly.\n*\n* Rotation beats evicting the oldest key: single-key eviction is worst-case for a\n* working set that cycles, because it drops exactly the entry about to be needed.\n* Measured on a cycling set of 20k styles, one-at-a-time eviction cost ~719ns/op\n* against ~189ns unbounded, while rotation holds ~274ns. On realistic skewed\n* access rotation is at or below the unbounded cost.\n*/\nconst MAX_ENTRIES = 1e3;\n/** Entries kept per hash bucket, to bound the cost of a collision scan. */\nconst MAX_BUCKET = 8;\n/**\n* DJB2 over the arguments' own keys and primitive values.\n* Returns `null` for anything nested, which routes the call to the string key.\n*/\nconst flatHashOrNull = (args) => {\n let h = 5381;\n for (let a = 0; a < args.length; a++) {\n const obj = args[a];\n if (obj === null || typeof obj !== \"object\") {\n const t = typeof obj;\n if (t === \"string\") for (let i = 0; i < obj.length; i++) h = h * 33 ^ obj.charCodeAt(i);\n else if (t === \"number\") h = h * 33 ^ (obj | 0);\n else if (t === \"boolean\") h = h * 33 ^ (obj ? 991 : 997);\n else h = h * 33 ^ 3;\n continue;\n }\n if (Array.isArray(obj)) return null;\n const proto = Object.getPrototypeOf(obj);\n if (proto !== Object.prototype && proto !== null) return null;\n for (const k in obj) {\n const v = obj[k];\n const tv = typeof v;\n if (v !== null && tv === \"object\") return null;\n for (let i = 0; i < k.length; i++) h = h * 33 ^ k.charCodeAt(i);\n if (tv === \"string\") for (let i = 0; i < v.length; i++) h = h * 33 ^ v.charCodeAt(i);\n else if (tv === \"number\") h = h * 33 ^ (v | 0);\n else if (tv === \"boolean\") h = h * 33 ^ (v ? 991 : 997);\n else h = h * 33 ^ 2;\n }\n }\n return h >>> 0;\n};\n/**\n* Value snapshot of the arguments, taken once at insert.\n*\n* The cache must not hold the caller's objects: a style object can capture a much\n* larger graph, and keeping it alive until the cache rotates changes GC behaviour\n* for code that never asked to be cached. Only the flat path reaches here, so a\n* shallow copy contains primitives only and retains nothing.\n*\n* Comparing against a copy also removes the last way a mutation could be missed.\n* Were the caller's own object stored, `oa === ob` would short-circuit the value\n* comparison, and a mutation that happened to preserve the hash would return the\n* stale entry. Against a copy that check can only ever be true for equal\n* primitives.\n*/\nconst snapshotArgs = (args) => {\n const values = [];\n const counts = [];\n for (let i = 0; i < args.length; i++) {\n const o = args[i];\n if (o !== null && typeof o === \"object\") {\n const copy = Array.isArray(o) ? [] : {};\n let n = 0;\n for (const k in o) {\n copy[k] = o[k];\n n++;\n }\n values.push(copy);\n counts.push(n);\n } else {\n values.push(o);\n counts.push(0);\n }\n }\n return {\n values,\n counts\n };\n};\n/**\n* Exact match, so a `flatHashOrNull` collision is resolved rather than trusted.\n* `bCounts` is the cached side's key count; comparing against it avoids the\n* `Object.keys()` allocation this would otherwise make on every cache hit.\n*/\nconst flatArgsEqual = (a, b, bCounts) => {\n if (a.length !== b.length) return false;\n for (let i = 0; i < a.length; i++) {\n const oa = a[i];\n const ob = b[i];\n if (oa === ob) continue;\n if (oa === null || ob === null || typeof oa !== \"object\" || typeof ob !== \"object\") return false;\n if (Array.isArray(oa) !== Array.isArray(ob)) return false;\n let n = 0;\n for (const k in oa) {\n if (oa[k] !== ob[k]) return false;\n n++;\n }\n if (n !== bCounts[i]) return false;\n }\n return true;\n};\nconst memo = (fn) => {\n let buckets = /* @__PURE__ */ new Map();\n let priorBuckets = /* @__PURE__ */ new Map();\n let strings = /* @__PURE__ */ new Map();\n let priorStrings = /* @__PURE__ */ new Map();\n /**\n * One scalar argument, keyed directly.\n *\n * This is the shape of the hottest callers — `isCssProperty(prop)` runs per prop\n * per render — and a plain map lookup beats hashing, bucket scanning and\n * snapshotting for it. Distinct types stay distinct keys, so `1` and `'1'` do not\n * share an entry.\n */\n let scalars = /* @__PURE__ */ new Map();\n let priorScalars = /* @__PURE__ */ new Map();\n const scan = (bucket, args) => {\n if (bucket) for (let i = 0; i < bucket.length; i++) {\n const entry = bucket[i];\n if (flatArgsEqual(args, entry.values, entry.counts)) return entry;\n }\n };\n const get = (...args) => {\n if (args.length === 1) {\n const only = args[0];\n if (only === null || typeof only !== \"object\") {\n if (scalars.has(only)) return scalars.get(only);\n if (priorScalars.has(only)) {\n const promoted = priorScalars.get(only);\n scalars.set(only, promoted);\n return promoted;\n }\n const out = fn(only);\n scalars.set(only, out);\n if (scalars.size > MAX_ENTRIES) {\n priorScalars = scalars;\n scalars = /* @__PURE__ */ new Map();\n }\n return out;\n }\n }\n const hash = flatHashOrNull(args);\n if (hash !== null) {\n let bucket = buckets.get(hash);\n const hit = scan(bucket, args);\n if (hit) return hit.out;\n const priorHit = scan(priorBuckets.get(hash), args);\n if (priorHit) {\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push(priorHit);\n if (bucket.length > MAX_BUCKET) bucket.shift();\n return priorHit.out;\n }\n const snap = snapshotArgs(args);\n const out = fn(...args);\n if (!bucket) {\n bucket = [];\n buckets.set(hash, bucket);\n }\n bucket.push({\n values: snap.values,\n counts: snap.counts,\n out\n });\n if (bucket.length > MAX_BUCKET) bucket.shift();\n if (buckets.size > MAX_ENTRIES) {\n priorBuckets = buckets;\n buckets = /* @__PURE__ */ new Map();\n }\n return out;\n }\n const key = JSON.stringify(args);\n if (strings.has(key)) return strings.get(key);\n if (priorStrings.has(key)) {\n const promoted = priorStrings.get(key);\n strings.set(key, promoted);\n return promoted;\n }\n const out = fn(...args);\n strings.set(key, out);\n if (strings.size > MAX_ENTRIES) {\n priorStrings = strings;\n strings = /* @__PURE__ */ new Map();\n }\n return out;\n };\n return get;\n};\n//#endregion\n//#region src/merge-props.ts\nconst MERGE_OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\nfunction mergeProps(...sources) {\n return sources.reduce((prev, obj) => {\n if (!obj) return prev;\n Object.keys(obj).forEach((key) => {\n if (MERGE_OMIT.has(key)) return;\n const prevValue = prev[key];\n const value = obj[key];\n if (isObject(prevValue) && isObject(value)) prev[key] = mergeProps(prevValue, value);\n else prev[key] = value;\n });\n return prev;\n }, {});\n}\n//#endregion\n//#region src/walk-object.ts\nconst isNotNullish = (element) => element != null;\nfunction walkObject(target, predicate, options = {}) {\n const { stop, getKey } = options;\n function inner(value, path = []) {\n if (isObjectOrArray(value)) {\n const result = {};\n for (const [prop, child] of Object.entries(value)) {\n const key = getKey?.(prop, child) ?? prop;\n const childPath = [...path, key];\n if (stop?.(value, childPath)) return predicate(value, path);\n const next = inner(child, childPath);\n if (isNotNullish(next)) result[key] = next;\n }\n return result;\n }\n return predicate(value, path);\n }\n return inner(target);\n}\nfunction mapObject(obj, fn) {\n if (Array.isArray(obj)) return obj.map((value) => fn(value));\n if (!isObject(obj)) return fn(obj);\n return walkObject(obj, (value) => fn(value));\n}\n//#endregion\n//#region src/normalize-style-object.ts\n/**\n* Whether walking the object would only rebuild it.\n*\n* Normalizing does two things: it renames a shorthand to its longhand and drops nullish\n* leaves. A flat object of plain values written in longhand needs neither, and that is most\n* of what `css()` is handed — but it still paid for a full rebuild plus a path array per key.\n*\n* Every clause has to be exact, since a false positive returns an object the walk would have\n* changed. Nullish is one of them: a leaf the walk removes must not survive, or a later merge\n* would see it override the value beneath it. The array check is another, and it is on the\n* container as well as the values — `stop` is handed the container, so an array arriving at\n* the top level has to reach the walk to be rejected rather than being returned as it came.\n*\n* `for...in` reads inherited keys the walk ignores, which is safe in the only direction it can\n* be wrong — an extra key can send this to the slow path, never past it.\n*\n* It does read every value, as `compactStyles` and the argument memo already do, so an\n* accessor prop is read once more than before. Style props are values by the time they get\n* here and reading one has no effect, but it is the reason this cannot be reordered to read\n* lazily.\n*/\nfunction needsNoNormalizing(styles, resolveShorthand) {\n if (Array.isArray(styles)) return false;\n for (const key in styles) {\n const value = styles[key];\n if (value == null || typeof value === \"object\") return false;\n if (resolveShorthand !== void 0 && resolveShorthand(key) !== key) return false;\n }\n return true;\n}\n/**\n* The result may be the argument itself rather than a fresh object, so callers have to treat\n* it as read-only. Every one of them does today: merging accumulates into its own object and\n* the two `raw()` helpers clone at the boundary.\n*\n* An array is not a style value. It used to be read as one value per breakpoint, which meant\n* a font stack written the way CSS writes one — `['Inter', 'sans-serif']` — silently became\n* `Inter` at base and `sans-serif` at `sm`. The type no longer admits an array, so reaching\n* this throw takes a cast or untyped javascript; it says which property, since the walk knows\n* the path and the caller usually does not.\n*/\nfunction normalizeStyleObject(styles, context, shorthand = true) {\n const { utility } = context;\n const { hasShorthand, resolveShorthand } = utility;\n if (needsNoNormalizing(styles, shorthand && hasShorthand ? resolveShorthand : void 0)) return styles;\n return walkObject(styles, (value, path) => {\n if (Array.isArray(value)) throw new BambooError(\"INVALID_STYLE_VALUE\", `An array is not a style value${path.length ? `: \"${path.join(\".\")}\"` : \"\"}.`, { hint: \"Write a responsive value as a condition object, e.g. { base: \\\"medium\\\", lg: \\\"bold\\\" }.\" });\n return value;\n }, {\n stop: (value) => Array.isArray(value),\n getKey: shorthand ? (prop) => hasShorthand ? resolveShorthand(prop) : prop : void 0\n });\n}\n//#endregion\n//#region src/classname.ts\n/**\n* Whether a style object carries anything `compact` would have kept.\n*\n* The question `compactStyles` asks is only ever \"is this empty once undefined values are\n* dropped\", but it used to answer it by building the compacted object and then a key array\n* for it, then throwing both away. `Object.keys` enumerates exactly what `compact`'s\n* `Object.entries` did — own, enumerable, string-keyed — so this is the same predicate\n* without the two allocations, and it stops at the first value that settles it.\n*/\nfunction hasDefinedValue(style) {\n const keys = Object.keys(style);\n for (let i = 0; i < keys.length; i++) if (style[keys[i]] !== void 0) return true;\n return false;\n}\n/**\n* An array is not a style argument.\n*\n* `css([a, b])` used to mean `css(a, b)`, flattened here one level. Two spellings of one\n* call is the redundancy; the array one also cost a `flat()` allocation on every merge to\n* serve a shape almost nothing wrote, and read as a responsive array everywhere that had\n* not been taught to flatten it first.\n*\n* It throws rather than being filtered out as a non-object, which is what dropping the\n* `flat()` alone would have done — silently returning no class at all.\n*/\nfunction compactStyles(...styles) {\n return styles.filter((style) => {\n if (Array.isArray(style)) throw new BambooError(\"INVALID_STYLE_ARGUMENT\", \"An array is not a style argument.\", { hint: \"Spread it instead, e.g. css(...styles) rather than css(styles).\" });\n return isObject(style) && hasDefinedValue(style);\n });\n}\nfunction createMergeCss(context) {\n function resolve(styles) {\n const allStyles = compactStyles(...styles);\n if (allStyles.length === 1) return allStyles;\n return allStyles.map((style) => normalizeStyleObject(style, context));\n }\n function mergeCss(...styles) {\n return mergeProps(...resolve(styles));\n }\n return {\n mergeCss: memo(mergeCss),\n mergeCssUncached: mergeCss\n };\n}\n//#endregion\n//#region src/clone-styles.ts\nconst OMIT = new Set([\n \"__proto__\",\n \"constructor\",\n \"prototype\"\n]);\n/**\n* Independent copy of a style object, nested condition blocks included.\n*\n* Merged style objects are cached, so anything handed to user code has to be\n* copied first: a caller mutating what it received would otherwise change what\n* every later caller reads back. `css.raw()` and `cva.raw()` are those boundaries.\n*\n* Kept separate from `mergeProps` deliberately. Merging is on the hot path — it\n* runs on every `css()` cache miss and on every render of a pattern component\n* under `jsxStyleProps: 'minimal'` — and copying there charges every caller for a\n* guarantee only the two `raw()` helpers need. Measured on a realistic style\n* object (5 base properties, 4 condition blocks) that was roughly twice the cost\n* of merging alone.\n*/\nfunction cloneStyles(styles) {\n if (Array.isArray(styles)) return styles.map((value) => cloneStyles(value));\n if (!isObject(styles)) return styles;\n const out = {};\n for (const key of Object.keys(styles)) {\n if (OMIT.has(key)) continue;\n out[key] = cloneStyles(styles[key]);\n }\n return out;\n}\n//#endregion\n//#region src/compact.ts\nfunction compact(value) {\n return Object.fromEntries(Object.entries(value ?? {}).filter(([_, value]) => value !== void 0));\n}\n//#endregion\n//#region src/is-css-function.ts\nconst fnRegExp = new RegExp(`^(${[\n \"min\",\n \"max\",\n \"clamp\",\n \"calc\"\n].join(\"|\")})\\\\(.*\\\\)`);\nconst isCssFunction = (v) => typeof v === \"string\" && fnRegExp.test(v);\n//#endregion\n//#region src/is-css-unit.ts\nconst lengthUnitsPattern = `(?:${\"cm,mm,Q,in,pc,pt,px,em,ex,ch,rem,lh,rlh,vw,vh,vmin,vmax,vb,vi,svw,svh,lvw,lvh,dvw,dvh,cqw,cqh,cqi,cqb,cqmin,cqmax,%\".split(\",\").join(\"|\")})`;\nconst lengthRegExp = new RegExp(`^[+-]?[0-9]*.?[0-9]+(?:[eE][+-]?[0-9]+)?${lengthUnitsPattern}$`);\nconst isCssUnit = (v) => typeof v === \"string\" && lengthRegExp.test(v);\n//#endregion\n//#region src/is-css-var.ts\nconst isCssVar = (v) => typeof v === \"string\" && /^var\\(--.+\\)$/.test(v);\n//#endregion\n//#region src/pattern-fns.ts\nconst createPatternFns = (token) => ({\n map: mapObject,\n isCssFunction,\n isCssVar,\n isCssUnit,\n token\n});\nconst getPatternStyles = (pattern, styles) => {\n if (!pattern?.defaultValues) return styles;\n const defaults = typeof pattern.defaultValues === \"function\" ? pattern.defaultValues(styles) : pattern.defaultValues;\n return Object.assign({}, defaults, compact(styles));\n};\n//#endregion\n//#region src/split-props.ts\n/**\n* Move one key into a bucket, keeping whatever about it is observable.\n*\n* Shared by both paths below so there is one implementation of the descriptor rules rather\n* than two to keep in step. The rules themselves are documented on `splitProps`.\n*/\nconst copyKey = (props, target, key) => {\n const descriptor = Object.getOwnPropertyDescriptor(props, key);\n if (!descriptor) return false;\n if (\"get\" in descriptor || \"set\" in descriptor || !descriptor.enumerable || key === \"__proto__\") Object.defineProperty(target, key, descriptor);\n else target[key] = descriptor.value;\n return true;\n};\n/**\n* One array group, which is what every call site in this project passes — a recipe's\n* `variantKeys`.\n*\n* The general path below is built for several groups that may be predicates, and pays for\n* that shape on every call: a closure per group, a `map` and a `concat` to assemble the\n* result, and a branch per group to tell an array from a predicate. None of it is reachable\n* with one array group.\n*\n* What it does *not* skip is the part that looks skippable. `own` stays, because membership\n* has to be answered from `ownKeys` rather than by asking the object: on a proxy — which is\n* what Solid's `mergeProps` hands over — every question is a trap, and a recipe naming eight\n* variants would otherwise fire eight traps to learn what one `ownKeys` already said. And\n* the two passes stay separate, because the group bucket is in *group* order while the rest\n* bucket is in *props* order, and that ordering reaches the emitted CSS.\n*/\nconst splitOneGroup = (props, allKeys, group) => {\n const own = new Set(allKeys);\n const taken = /* @__PURE__ */ new Set();\n const picked = {};\n for (let i = 0; i < group.length; i++) {\n const key = group[i];\n if (taken.has(key) || !own.has(key)) continue;\n if (copyKey(props, picked, key)) taken.add(key);\n }\n const rest = {};\n for (let i = 0; i < allKeys.length; i++) {\n const key = allKeys[i];\n if (taken.has(key)) continue;\n copyKey(props, rest, key);\n }\n return [picked, rest];\n};\n/**\n* Deal a props object into one bucket per key group, plus a final bucket for the rest.\n* A key goes to the first group that claims it.\n*\n* ## Why the descriptor is read per key rather than in bulk\n*\n* This used to call `Object.getOwnPropertyDescriptors` for the whole object and\n* `defineProperty` for every key it moved. Copying plain values instead is 2.4–2.9x faster\n* on the shapes that allow it, but it is only correct where props are data — and they are\n* not always. Solid compiles props to accessors, so reading one eagerly runs whatever it\n* wraps: splitting a component's props would construct its children before the surrounding\n* provider exists.\n*\n* So the descriptor is fetched per key, and the value path is taken only when it changes\n* nothing observable. An accessor keeps its laziness, a non-enumerable key keeps its\n* invisibility, and `__proto__` is defined rather than assigned so it stays an own\n* property instead of reaching the prototype setter.\n*\n* The one thing the value path drops is `writable`/`configurable`, so a bucket key taken\n* from frozen props is writable where it used to be frozen. Nothing here relies on that,\n* and preserving it would mean `defineProperty` on the common path — the cost this exists\n* to avoid. Keys that take the descriptor path keep theirs, so a bucket can be\n* inconsistent in that one respect.\n*\n* Key order within a bucket is preserved exactly. It is not cosmetic: `cva` merges\n* variant props in iteration order, and the parser reads the rest bucket as the style\n* props it encodes, so order reaches the emitted CSS.\n*/\nfunction splitProps(props, ...keys) {\n const allKeys = Object.getOwnPropertyNames(props);\n if (keys.length === 1 && Array.isArray(keys[0])) return splitOneGroup(props, allKeys, keys[0]);\n const own = new Set(allKeys);\n const taken = /* @__PURE__ */ new Set();\n const split = (group) => {\n const clone = {};\n for (let i = 0; i < group.length; i++) {\n const key = group[i];\n if (taken.has(key) || !own.has(key)) continue;\n if (copyKey(props, clone, key)) taken.add(key);\n }\n return clone;\n };\n /**\n * The predicate is called with the key alone.\n *\n * Handing it to `filter` passes `(key, index, allKeys)`. A one-parameter predicate cannot\n * see the extras, but a memoized one reads its whole argument list — and the predicates\n * that arrive here are memoized, `isCssProperty` among them. So the memo hashed the entire\n * key array once per prop, and keyed its cache on it: two elements with different prop sets\n * shared no entry even for the same prop name.\n *\n * Worth ~9.7x on that path, and nothing at all on a plain predicate — which is why the\n * bench below it needs a memoized case to see this at all.\n *\n * A loop rather than `filter((k) => key(k))` because the wrapper allocates a closure per\n * group. The two measure the same to within noise; the loop just does not need one.\n */\n const matching = (predicate) => {\n const group = [];\n for (let i = 0; i < allKeys.length; i++) {\n const key = allKeys[i];\n if (predicate(key)) group.push(key);\n }\n return group;\n };\n return keys.map((key) => split(Array.isArray(key) ? key : matching(key))).concat(split(allKeys));\n}\n//#endregion\nexport { cloneStyles, createMergeCss, createPatternFns, getPatternStyles, splitProps };\n";
517
360
  //#endregion
518
361
  //#region src/artifacts/js/helpers.ts
519
362
  function generateHelpers() {
@@ -751,66 +594,10 @@ function generateMixinsSpec$1(theme) {
751
594
  }
752
595
  //#endregion
753
596
  //#region src/artifacts/js/recipe.ts
754
- const stringify$2 = (value) => JSON.stringify(value, null, 2);
755
597
  const hasOwn = (obj, key) => {
756
598
  if (!obj) return false;
757
599
  return Object.prototype.hasOwnProperty.call(obj, key);
758
600
  };
759
- function generateCreateRecipe(ctx) {
760
- const { recipes, prefix, hash, utility } = ctx;
761
- if (recipes.isEmpty()) return;
762
- return {
763
- name: "create-recipe",
764
- dts: "",
765
- js: outdent`
766
- ${ctx.file.import(hash.className ? "compact, splitProps, toHash, uniq, uncompiledStyle" : "compact, splitProps, uniq, uncompiledStyle", "../helpers")}
767
-
768
- const withPrefix = ${prefix.className ? `(className) => className ? ${JSON.stringify(prefix.className)} + '-' + className : ${JSON.stringify(prefix.className)}` : `(className) => className`}
769
- export const formatRecipeClass = ${hash.className ? `(className) => withPrefix((${utility.toHash})([className], toHash))` : `withPrefix`}
770
-
771
- export const createRecipe = (name, defaultVariants, _compoundVariants, _variantMap) => {
772
- const getVariantProps = (variants) => {
773
- return {
774
- [name]: '__ignore__',
775
- ...defaultVariants,
776
- ...compact(variants),
777
- };
778
- };
779
-
780
- const recipeFn = (_variants) => uncompiledStyle(name)
781
-
782
- return {
783
- recipeFn,
784
- getVariantProps,
785
- __getCompoundVariantCss__: (_variants) => uncompiledStyle(name),
786
- }
787
- }
788
-
789
- export const mergeRecipes = (recipeA, recipeB) => {
790
- if (recipeA && !recipeB) return recipeA
791
- if (!recipeA && recipeB) return recipeB
792
-
793
- const recipeFn = (..._args) => uncompiledStyle(recipeA.__name__ || 'recipe')
794
- const variantKeys = uniq(Object.keys(recipeA.variantMap), Object.keys(recipeB.variantMap))
795
- const variantMap = variantKeys.reduce((acc, key) => {
796
- acc[key] = uniq(recipeA.variantMap[key], recipeB.variantMap[key])
797
- return acc
798
- }, {})
799
-
800
- return Object.assign(recipeFn, {
801
- __recipe__: true,
802
- __name__: \`$\{recipeA.__name__} \${recipeB.__name__}\`,
803
- raw: (props) => props,
804
- variantMap,
805
- splitVariantProps(props) {
806
- return splitProps(props, variantKeys)
807
- },
808
- })
809
- }
810
- }
811
- `
812
- };
813
- }
814
601
  function generateRecipes(ctx, filters) {
815
602
  const { recipes } = ctx;
816
603
  if (recipes.isEmpty()) return;
@@ -824,117 +611,19 @@ function generateRecipes(ctx, filters) {
824
611
  else defaultValue = JSON.stringify(defaultValue);
825
612
  return ctx.file.jsDocComment("", { default: defaultValue });
826
613
  };
827
- const slotNames = Recipes.isSlotRecipeConfig(config) ? config.slots : [];
828
- const anchorSlotNames = Recipes.isSlotRecipeConfig(config) ? Recipes.getScopeRoots(config) : [];
829
614
  return {
830
615
  name: dashName,
831
- js: match(config).when(Recipes.isSlotRecipeConfig, (config) => {
832
- const anchors = Recipes.getScopeRoots(config);
833
- /**
834
- * Which slots each variant writes styles for.
835
- *
836
- * A scope reaches every slot inside an anchor's subtree. A slot under no anchor at
837
- * all is not reached, and nothing here can detect that — reachability is a fact
838
- * about the DOM. This is what says which slots a variant has to get to, so the
839
- * component layer can thread the ones a scope cannot.
840
- */
841
- const slotsAffectedBy = Object.fromEntries(Object.entries(config.variants ?? {}).map(([variant, values]) => [variant, Array.from(new Set(Object.values(values ?? {}).flatMap((slotStyles) => Object.keys(slotStyles ?? {}))))]));
842
- return outdent`
843
- ${ctx.file.import("compact, getSlotCompoundVariant, memo, splitProps", "../helpers")}
844
- ${ctx.file.import("createRecipe, formatRecipeClass", "./create-recipe")}
845
-
846
- const ${baseName}DefaultVariants = ${stringify$2(defaultVariants ?? {})}
847
- const ${baseName}CompoundVariants = ${stringify$2(compoundVariants ?? [])}
848
-
849
- // Formatted, not raw. A scoped slot's class is a constant that never passes through
850
- // \`createCss\`, so \`hash.className\` and \`prefix\` have to be applied here to match
851
- // the rule the stylesheet emits.
852
- const ${baseName}SlotNames = ${stringify$2(config.slots.map((slot) => [slot, `${config.className}__${slot}`]))}.map(
853
- ([slotName, className]) => [slotName, formatRecipeClass(className)],
854
- )
855
- ${anchors.length ? outdent`
856
- /**
857
- * Only the anchors take variants: ${anchors.map((slot) => `\`${baseName}.${slot}\``).join(", ")}.
858
- * Every other slot's variant styles are emitted as rules scoped by a class an anchor
859
- * carries, so that slot's class is a constant and nothing has to reach it at runtime.
860
- */
861
- const ${baseName}Anchors = ${JSON.stringify(anchors)}
862
- const ${baseName}AnchorFns = /* @__PURE__ */ ${baseName}Anchors.map((slotName) => [slotName, createRecipe(\`${config.className}__\${slotName}\`, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName), ${stringify$2(variantKeyMap)})])
863
- const ${baseName}StaticSlots = /* @__PURE__ */ Object.fromEntries(
864
- ${baseName}SlotNames.filter(([slotName]) => !${baseName}Anchors.includes(slotName)),
865
- )
866
-
867
- const ${baseName}Fn = memo((props = {}) => ({
868
- ...${baseName}StaticSlots,
869
- ...Object.fromEntries(${baseName}AnchorFns.map(([slotName, anchorFn]) => [slotName, anchorFn.recipeFn(props)])),
870
- }))` : outdent`
871
- /**
872
- * Raw, not the formatted name. \`createRecipe\` routes what it is given through
873
- * \`createCss\`, which applies \`hash.className\` and \`prefix.className\` itself — so
874
- * passing the already formatted \`slotKey\` applied both a second time. The runtime
875
- * asked for \`toHash(toHash(name))\` while the stylesheet emitted \`toHash(name)\`, and
876
- * every slot on such a recipe rendered unstyled.
877
- *
878
- * Invisible only when neither \`hash\` nor \`prefix\` is set, where both applications
879
- * are identities. A prefixed build was equally broken — \`bam-bam-menu__trigger\`
880
- * against a stylesheet emitting \`.bam-menu__trigger\` — which is easy to miss, since
881
- * the obvious reading is that this is a hashing problem.
882
- */
883
- const ${baseName}SlotFns = /* @__PURE__ */ ${baseName}SlotNames.map(([slotName]) => [slotName, createRecipe(\`${config.className}__\${slotName}\`, ${baseName}DefaultVariants, getSlotCompoundVariant(${baseName}CompoundVariants, slotName), ${stringify$2(variantKeyMap)})])
884
-
885
- const ${baseName}Fn = memo((props = {}) => {
886
- return Object.fromEntries(${baseName}SlotFns.map(([slotName, slotFn]) => [slotName, slotFn.recipeFn(props)]))
887
- })`}
888
-
889
- const ${baseName}VariantKeys = ${stringify$2(Object.keys(variantKeyMap))}
890
- const getVariantProps = (variants) => ({ ...${baseName}DefaultVariants, ...compact(variants) })
891
-
892
- export const ${baseName} = /* @__PURE__ */ Object.assign(${baseName}Fn, {
893
- __recipe__: false,
894
- __name__: '${baseName}',
895
- raw: (props) => props,
896
- /** Each slot's constant class, for targeting a slot in the DOM. */
897
- classNameMap: /* @__PURE__ */ Object.fromEntries(${baseName}SlotNames),
898
- /** The slots that enclose other slots, and so anchor their variant rules. */
899
- scopeRoots: ${JSON.stringify(anchors)},
900
- variantMap: ${stringify$2(variantKeyMap)},
901
- /** Which slots each variant actually reaches, for a slot a scope cannot get to. */
902
- slotsAffectedBy: ${stringify$2(slotsAffectedBy)},
903
- splitVariantProps(props) {
904
- return splitProps(props, ${baseName}VariantKeys)
905
- },
906
- getVariantProps,
907
- ${anchors.length ? outdent`
908
- ...Object.fromEntries(${baseName}AnchorFns.map(([slotName, anchorFn]) => [slotName, anchorFn.recipeFn])),
909
- ...${baseName}StaticSlots,
910
- ` : ""}
911
- })
912
- `;
913
- }).otherwise((config) => outdent`
914
- ${ctx.file.import("memo, splitProps", "../helpers")}
915
- ${ctx.file.import("createRecipe, mergeRecipes", "./create-recipe")}
916
-
917
- const ${baseName}VariantMap = ${stringify$2(variantKeyMap)}
918
-
919
- const ${baseName}Fn = /* @__PURE__ */ createRecipe('${config.className}', ${stringify$2(defaultVariants ?? {})}, ${stringify$2(compoundVariants ?? [])}, ${baseName}VariantMap)
616
+ js: outdent`
617
+ ${ctx.file.import("splitProps, uncompiledStyle", "../helpers")}
920
618
 
921
- const ${baseName}VariantKeys = Object.keys(${baseName}VariantMap)
619
+ const ${baseName}VariantKeys = ${JSON.stringify(Object.keys(variantKeyMap))}
922
620
 
923
- export const ${baseName} = /* @__PURE__ */ Object.assign(memo(${baseName}Fn.recipeFn), {
924
- __recipe__: true,
925
- __name__: '${baseName}',
926
- __getCompoundVariantCss__: ${baseName}Fn.__getCompoundVariantCss__,
927
- raw: (props) => props,
928
- variantMap: ${baseName}VariantMap,
929
- merge(recipe) {
930
- return mergeRecipes(this, recipe)
931
- },
621
+ export const ${baseName} = /* @__PURE__ */ Object.assign((_props) => uncompiledStyle(${JSON.stringify(config.className)}), {
932
622
  splitVariantProps(props) {
933
623
  return splitProps(props, ${baseName}VariantKeys)
934
624
  },
935
- getVariantProps: ${baseName}Fn.getVariantProps,
936
625
  })
937
- `),
626
+ `,
938
627
  dts: outdent`
939
628
  ${ctx.file.importType("ConditionalValue", "../types/index")}
940
629
  ${ctx.file.importType("DistributiveOmit, Pretty", "../types/system-types")}
@@ -947,10 +636,6 @@ function generateRecipes(ctx, filters) {
947
636
  }).join("\n")}
948
637
  }
949
638
 
950
- type ${upperName}VariantMap = {
951
- [key in keyof ${upperName}Variant]: Array<${upperName}Variant[key]>
952
- }
953
-
954
639
  ${Recipes.isSlotRecipeConfig(config) ? `type ${upperName}Slot = ${unionType(config.slots)}` : ""}
955
640
 
956
641
  export type ${upperName}VariantProps = {
@@ -961,18 +646,7 @@ function generateRecipes(ctx, filters) {
961
646
  ${Recipes.isSlotRecipeConfig(config) ? `__slot: ${upperName}Slot` : ""}
962
647
  __type: ${upperName}VariantProps
963
648
  (props?: ${upperName}VariantProps): ${Recipes.isSlotRecipeConfig(config) ? `Pretty<Record<${upperName}Slot, string>>` : "string"}
964
- raw: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
965
- /** Each variant and the values it accepts. \`Object.keys\` it for the variant names. */
966
- variantMap: ${upperName}VariantMap
967
649
  splitVariantProps<Props extends ${upperName}VariantProps>(props: Props): [${upperName}VariantProps, Pretty<DistributiveOmit<Props, keyof ${upperName}VariantProps>>]
968
- getVariantProps: (props?: ${upperName}VariantProps) => ${upperName}VariantProps
969
- ${Recipes.isSlotRecipeConfig(config) ? outdent`
970
- /** Which slots each variant writes styles for. */
971
- slotsAffectedBy: Record<keyof ${upperName}Variant, ${upperName}Slot[]>` : ""}
972
- ${anchorSlotNames.length ? outdent`
973
- /** The slots that take variants — every other one is scoped by a class an anchor carries. */
974
- ${anchorSlotNames.map((slot) => `${slot}: (props?: ${upperName}VariantProps) => string`).join("\n")}
975
- ${slotNames.filter((slot) => !anchorSlotNames.includes(slot)).map((slot) => `${slot}: string`).join("\n")}` : ""}
976
650
  }
977
651
 
978
652
  ${ctx.file.jsDocComment(description, { deprecated })}
@@ -983,241 +657,35 @@ function generateRecipes(ctx, filters) {
983
657
  }
984
658
  //#endregion
985
659
  //#region src/artifacts/js/sva.ts
660
+ /**
661
+ * The runtime `sva` a compiled build keeps: a callable that throws, and `splitVariantProps`.
662
+ *
663
+ * See `generateCvaFn`. The slot recipe carried the same unreachable engine, plus
664
+ * `classNameMap`, `slotsAffectedBy` and `scopeRoots` for `auditSlotScopes` — which took the
665
+ * recipe object as an argument, and passing it is itself a `runtime-binding`, so the audit
666
+ * could not be called from any build that compiled. It is removed with them. The Vite compiler
667
+ * returns complete atom strings for every slot and emits no `@scope` rules, so there is no
668
+ * unreachable-slot failure left for it to report.
669
+ */
986
670
  function generateSvaFn(ctx) {
987
671
  return {
988
672
  js: outdent`
989
- ${ctx.file.import("compact, getRecipeIdentity, getSlotRecipes, memo, splitProps, uncompiledStyle", "../helpers")}
990
- ${ctx.file.import("cva, formatRecipeClass", "./cva")}
991
- ${ctx.file.import("cx", "./cx")}
673
+ ${ctx.file.import("splitProps, uncompiledStyle", "../helpers")}
992
674
 
993
675
  export function sva(config) {
994
- // Named before the split, so each slot's class is \`name__slot\`. Left to
995
- // \`getSlotRecipes\`, a config with no \`className\` gives every slot the bare slot name
996
- // — \`root\` — which every other anonymous recipe with a \`root\` slot would share. The
997
- // build injects the identity at the same point, for the same reason.
998
- const name = getRecipeIdentity(config, 'sva')
999
- const withName = { ...config, className: config.className ?? name }
1000
-
1001
- const slots = Object.entries(getSlotRecipes(withName)).map(([slot, slotCva]) => [slot, cva(slotCva)])
1002
- const defaultVariants = config.defaultVariants ?? {}
1003
-
1004
- // Populated whether or not the author set a \`className\`. Every slot recipe is given
1005
- // one before the split — the identity when the config declares none — so the guard
1006
- // that used to sit here left an anonymous \`sva\` reporting no slot classes despite
1007
- // emitting them.
1008
- // Formatted, like the classes \`svaFn\` returns. Left raw, this reported the name the
1009
- // element does *not* carry under \`hash\` or \`prefix\` — and \`auditSlotScopes\` builds
1010
- // its selectors from this map, so the diagnostic went silent in exactly the configs
1011
- // where a naming bug is likeliest.
1012
- const classNameMap = slots.reduce((acc, [slot, cvaFn]) => {
1013
- acc[slot] = formatRecipeClass(cvaFn.config.className)
1014
- return acc
1015
- }, {})
1016
-
1017
- // The slots that enclose other slots, matching \`Recipes.getScopeRoots\`. Their variant
1018
- // styles anchor \`@scope\` rules for every other slot, so only they take variants — a
1019
- // variant class on any other slot would name a rule that was never emitted.
1020
- //
1021
- // A list, because a component can span a portal and so occupy more than one subtree.
1022
- const declaredSlots = config.slots ?? []
1023
- const anchors = config.scopeRoots
1024
- ? config.scopeRoots.filter((slot) => declaredSlots.includes(slot))
1025
- : declaredSlots.includes('root') ? ['root'] : []
1026
-
1027
- // \`classNameMap[slot]\` used to be joined on here, because the slot's classes were
1028
- // atomic and nothing else carried the name to target it in the DOM. The slot's cva is
1029
- // now named \`name__slot\` and returns that as its base class, so joining it again
1030
- // would just repeat it.
1031
- function svaFn(_props) {
1032
- return uncompiledStyle('sva')
1033
- }
1034
-
1035
- function raw(props) {
1036
- const result = slots.map(([slot, cvaFn]) => [slot, cvaFn.raw(props)])
1037
- return Object.fromEntries(result)
1038
- }
1039
-
1040
- const variants = config.variants ?? {};
1041
- const variantKeys = Object.keys(variants);
1042
-
1043
- function splitVariantProps(props) {
1044
- return splitProps(props, variantKeys);
1045
- }
1046
- const getVariantProps = (variants) => ({ ...defaultVariants, ...compact(variants) })
1047
-
1048
- const variantMap = Object.fromEntries(
1049
- Object.entries(variants).map(([key, value]) => [key, Object.keys(value)])
1050
- );
1051
-
1052
- // Which slots each variant writes styles for.
1053
- //
1054
- // A scope reaches every slot inside an anchor's subtree. A slot under no anchor is
1055
- // not reached, and nothing at build time can detect that — reachability is a fact
1056
- // about the DOM. This is what says which slots a variant has to get to, so the
1057
- // component layer can thread the ones a scope cannot. Config slot recipes have always
1058
- // exposed it; an inline \`sva\` had no way to answer the question at all.
1059
- const slotsAffectedBy = Object.fromEntries(
1060
- Object.entries(variants).map(([variant, values]) => [
1061
- variant,
1062
- [...new Set(Object.values(values ?? {}).flatMap((slotStyles) => Object.keys(slotStyles ?? {})))],
1063
- ])
1064
- );
1065
-
1066
- return Object.assign(memo(svaFn), {
1067
- __cva__: false,
1068
- raw,
1069
- config,
1070
- variantMap,
1071
- classNameMap,
1072
- /** The slots that enclose other slots, and so anchor their variant rules. */
1073
- scopeRoots: anchors,
1074
- slotsAffectedBy,
1075
- splitVariantProps,
1076
- getVariantProps,
1077
- })
1078
- }
1079
-
1080
- /**
1081
- * Report slots whose variant styles can never reach them.
1082
- *
1083
- * A scoped slot is styled through an \`@scope\` rule opened at an anchor, so it has to be
1084
- * rendered inside one. A slot moved out of every anchor's subtree — through a portal,
1085
- * with no second anchor named in \`scopeRoots\` — keeps its base styles and silently
1086
- * loses its variant styles. That renders *nearly* right, which is harder to notice than
1087
- * a total failure, and no build step can catch it: whether one element is inside another
1088
- * is a fact about the DOM.
1089
- *
1090
- * Checks for the anchor's *base* class rather than its variant class. An anchor always
1091
- * carries the base one; the variant class is absent whenever no variant is selected, and
1092
- * matching on it would report a slot that is correctly placed and simply unstyled.
1093
- *
1094
- * Development only — call it behind \`process.env.NODE_ENV !== 'production'\` so bundlers
1095
- * drop it, along with this function, from your production build.
1096
- *
1097
- * \`\`\`js
1098
- * import { auditSlotScopes, select } from '../styled-system/css'
1099
- *
1100
- * if (process.env.NODE_ENV !== 'production') auditSlotScopes([select], { observe: true })
1101
- * \`\`\`
1102
- */
1103
- export function auditSlotScopes(recipes, options = {}) {
1104
- const { root = typeof document === 'undefined' ? undefined : document, observe = false, onReport } = options
1105
- if (!root) return () => {}
1106
-
1107
- const escape = (value) =>
1108
- typeof CSS !== 'undefined' && CSS.escape ? CSS.escape(value) : value.replace(/[^\\w-]/g, '\\\\$&')
1109
-
1110
- const audit = () => {
1111
- const found = []
676
+ const variantKeys = Object.keys(config?.variants ?? {})
1112
677
 
1113
- for (const recipe of recipes) {
1114
- const anchors = recipe?.scopeRoots ?? []
1115
- // Nothing is scoped, so every slot carries its own variant class and none of them
1116
- // depends on where it is rendered.
1117
- if (!anchors.length) continue
1118
-
1119
- const classNameMap = recipe.classNameMap ?? {}
1120
- const anchorSelector = anchors
1121
- .map((slot) => classNameMap[slot])
1122
- .filter(Boolean)
1123
- .map((className) => '.' + escape(className))
1124
- .join(', ')
1125
- if (!anchorSelector) continue
1126
-
1127
- const scoped = new Set(Object.values(recipe.slotsAffectedBy ?? {}).flat())
1128
-
1129
- for (const slot of scoped) {
1130
- if (anchors.includes(slot)) continue
1131
-
1132
- const className = classNameMap[slot]
1133
- if (!className) continue
1134
-
1135
- for (const element of root.querySelectorAll('.' + escape(className))) {
1136
- if (element.closest(anchorSelector)) continue
1137
- found.push({ recipe: recipe.__name__, slot, className, element, anchors })
1138
- }
1139
- }
1140
- }
1141
-
1142
- if (!found.length) return found
1143
-
1144
- if (onReport) {
1145
- onReport(found)
1146
- } else {
1147
- for (const problem of found) {
1148
- console.warn(
1149
- \`[bamboo] \${problem.recipe ?? 'slot recipe'}: the \\\`\${problem.slot}\\\` slot is rendered outside every \` +
1150
- \`anchor (\${problem.anchors.join(', ')}), so its variant styles cannot reach it. \` +
1151
- \`Add the enclosing slot to \\\`scopeRoots\\\`, or deliver the variant to this slot by hand.\`,
1152
- problem.element,
1153
- )
1154
- }
1155
- }
1156
-
1157
- return found
1158
- }
1159
-
1160
- audit()
1161
-
1162
- if (!observe || typeof MutationObserver === 'undefined') return () => {}
1163
-
1164
- // Portaled content mounts after the first sweep, which is exactly the case this
1165
- // exists to catch, so a one-shot pass would miss it.
1166
- let queued = false
1167
- const observer = new MutationObserver(() => {
1168
- if (queued) return
1169
- queued = true
1170
- queueMicrotask(() => {
1171
- queued = false
1172
- audit()
1173
- })
678
+ return Object.assign((_props) => uncompiledStyle('sva'), {
679
+ splitVariantProps(props) {
680
+ return splitProps(props, variantKeys)
681
+ },
1174
682
  })
1175
- observer.observe(root === document ? document.documentElement : root, { childList: true, subtree: true })
1176
-
1177
- return () => observer.disconnect()
1178
683
  }
1179
684
  `,
1180
685
  dts: outdent`
1181
686
  ${ctx.file.importType("SlotRecipeCreatorFn", "../types/recipe")}
1182
687
 
1183
688
  export declare const sva: SlotRecipeCreatorFn
1184
-
1185
- export interface SlotScopeProblem {
1186
- /** The recipe the slot belongs to, when it has a name. */
1187
- recipe?: string
1188
- /** The slot whose variant styles cannot reach it. */
1189
- slot: string
1190
- /** The constant class that slot carries. */
1191
- className: string
1192
- /** The element found outside every anchor. */
1193
- element: Element
1194
- /** The anchors that were looked for. */
1195
- anchors: string[]
1196
- }
1197
-
1198
- export interface AuditSlotScopesOptions {
1199
- /** Where to look. Defaults to \`document\`. */
1200
- root?: ParentNode
1201
- /** Re-check as the DOM changes, for content that mounts through a portal. */
1202
- observe?: boolean
1203
- /** Handle the findings yourself instead of warning to the console. */
1204
- onReport?: (problems: SlotScopeProblem[]) => void
1205
- }
1206
-
1207
- /**
1208
- * Report slots whose variant styles can never reach them, in development.
1209
- *
1210
- * A scoped slot is styled through an \`@scope\` rule opened at an anchor, so it has to be
1211
- * rendered inside one. A slot moved out of every anchor's subtree keeps its base styles
1212
- * and silently loses its variant styles — which no build step can catch, because whether
1213
- * one element is inside another is a fact about the DOM.
1214
- *
1215
- * Returns a function that stops observing.
1216
- */
1217
- export declare function auditSlotScopes(
1218
- recipes: ReadonlyArray<unknown>,
1219
- options?: AuditSlotScopesOptions,
1220
- ): () => void
1221
689
  `
1222
690
  };
1223
691
  }
@@ -2059,7 +1527,7 @@ var comments = {
2059
1527
  var content$4 = "import type { CssProperty, SystemStyleObject } from './system-types'\nimport type { TokenCategory } from '../tokens'\n\ntype Primitive = string | number | boolean | null | undefined\ntype LiteralUnion<T, K extends Primitive = string> = T | (K & Record<never, never>)\n\nexport type PatternProperty =\n | { type: 'property'; value: CssProperty; description?: string }\n | { type: 'enum'; value: string[]; description?: string }\n | { type: 'token'; value: TokenCategory; property?: CssProperty; description?: string }\n | { type: 'string' | 'boolean' | 'number'; description?: string }\n\nexport interface PatternHelpers {\n map: (value: any, fn: (value: string) => string | undefined) => any\n /**\n * The css variable reference for a token path, or `fallback` when the path names no token.\n *\n * `token('spacing.4', '4')` is `var(--spacing-4)` where that token exists and `'4'` where it\n * does not — so a pattern can accept either a token name or a raw css value without knowing\n * the theme.\n */\n token: (path: string, fallback?: string) => string | undefined\n isCssUnit: (value: any) => boolean\n isCssVar: (value: any) => boolean\n isCssFunction: (value: any) => boolean\n}\n\nexport interface PatternProperties {\n [key: string]: PatternProperty\n}\n\ntype InferProps<T> = Record<LiteralUnion<keyof T>, any>\n\nexport type PatternDefaultValue<T> = Partial<InferProps<T>>\n\nexport type PatternDefaultValueFn<T> = (props: InferProps<T>) => PatternDefaultValue<T>\n\nexport interface PatternConfig<T extends PatternProperties = PatternProperties> {\n /**\n * The description of the pattern. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The properties of the pattern.\n */\n properties?: T\n /**\n * The default values of the pattern.\n */\n defaultValues?: PatternDefaultValue<T> | PatternDefaultValueFn<T>\n /**\n * The css object this pattern will generate.\n */\n transform?: (props: InferProps<T>, helpers: PatternHelpers) => SystemStyleObject\n /**\n * Whether the pattern is deprecated.\n */\n deprecated?: boolean | string\n /**\n * Which css properties this pattern accepts alongside its own `properties`.\n *\n * - `all` accepts any css property.\n * - `none` accepts only the pattern's declared `properties`.\n * - `{ except }` accepts any css property but the ones listed.\n *\n * One option because these were two — `strict: true` for \"none\" and an `@experimental`\n * `blocklist` for \"all but these\" — and the pair had an unrepresentable combination that\n * silently did nothing: the blocklist is applied only to the type that lists css\n * properties, which `strict: true` does not emit, so setting both dropped the blocklist.\n *\n * Types only. Nothing strips a blocked property at runtime — one passed anyway reaches\n * `transform` and emits css.\n *\n * @default 'all'\n */\n cssProps?: 'all' | 'none' | { except: LiteralUnion<CssProperty>[] }\n}\n";
2060
1528
  //#endregion
2061
1529
  //#region src/artifacts/generated/recipe.d.ts.json
2062
- var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\ntype RecipeVariantMap<T extends RecipeVariantRecord> = {\n [K in keyof T]: Array<keyof T[K]>\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n /** Each variant and the values it accepts. `Object.keys` it for the variant names. */\n variantMap: RecipeVariantMap<T>\n raw: (props?: RecipeSelection<T>) => SystemStyleObject\n config: RecipeConfig<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe identity\n * is not style identity, so identical declarations share one class across recipes.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>, RecipeConfigMeta {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.recipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\nexport interface SlotRecipeRuntimeFn<\n S extends string,\n T extends SlotRecipeVariantRecord<S>,\n> extends SlotRecipeVariantFn<S, T> {\n raw: (props?: RecipeSelection<T>) => Record<S, SystemStyleObject>\n /** Each variant and the values it accepts. `Object.keys` it for the variant names. */\n variantMap: RecipeVariantMap<T>\n /** The config this recipe was created from. */\n config: SlotRecipeDefinition<S, T>\n /** Each slot's constant class, for targeting a slot in the DOM. */\n classNameMap: Partial<Record<S, string>>\n /**\n * Which slots each variant writes styles for.\n *\n * A variant's styles reach a slot through a scope opened at an anchor, which covers every\n * slot in that anchor's subtree. A slot under no anchor — moved out by a portal, with no\n * second anchor named in `scopeRoots` — is not reached, and nothing at build time can\n * detect that. This says which slots a variant has to get to, so whatever a scope cannot\n * reach can be threaded by hand.\n */\n slotsAffectedBy: Record<keyof T, S[]>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n getVariantProps: (props?: RecipeSelection<T>) => RecipeSelection<T>\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> {\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.slotRecipes`, where it is the key it is\n * declared under. Optional for an inline `sva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe and slot\n * identity do not enter generated class names.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * The slots that enclose other slots in extraction-only named-rule output.\n *\n * The Vite compiler returns selected atoms directly for every slot and ignores this field.\n * In extraction-only output, a slot recipe's variants are chosen once at the top, but the slots that react to them\n * are authored by the consumer somewhere below. Naming the enclosing slots lets the build\n * emit their variant styles as rules scoped by a class those slots already carry, so\n * nothing has to be delivered to a slot at runtime and every other slot's class is a\n * constant.\n *\n * A list, because a portal is a real discontinuity in the tree and no CSS mechanism\n * crosses one. A `<Select>` occupies two disjoint subtrees — the trigger side under\n * `root`, the listbox side under a portaled `positioner` — and a variant writes styles\n * into both. One anchor can only ever reach one of them.\n *\n * ```ts\n * scopeRoots: ['root', 'positioner']\n * ```\n *\n * Each named slot takes variant props; every other slot's class is a constant. The build\n * emits each non-anchor slot's variant rules under *every* anchor, and only the anchor\n * that is genuinely an ancestor matches — so the DOM shape never has to be declared.\n *\n * Defaults to `['root']` when a slot by that name exists. Set `[]` to turn scoping off\n * and give every slot a variant class of its own, which is what a recipe whose slots are\n * siblings wants.\n *\n * A slot under *no* anchor is still unreachable, and nothing at build time can detect\n * that — reachability is a fact about the DOM. `recipe.slotsAffectedBy` says which slots\n * a variant writes to, for whatever still needs threading by hand.\n */\n scopeRoots?: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> &\n RecipeConfigMeta & {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.slotRecipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n }\n";
1530
+ var content$3 = "import type { RecipeRule } from './static-css'\nimport type { SystemStyleObject, DistributiveOmit, Pretty } from './system-types'\n\ntype StringToBoolean<T> = T extends 'true' | 'false' ? boolean : T\n\nexport type RecipeVariantRecord = Record<any, Record<any, SystemStyleObject>>\n\nexport type RecipeSelection<T extends RecipeVariantRecord> = keyof any extends keyof T\n ? {}\n : {\n [K in keyof T]?: StringToBoolean<keyof T[K]> | undefined\n }\n\nexport type RecipeVariantFn<T extends RecipeVariantRecord> = (props?: RecipeSelection<T>) => string\n\n/**\n * Extract the variant as optional props from a `cva` function.\n * Intended to be used with a JSX component, prefer `RecipeVariant` for a more strict type.\n */\nexport type RecipeVariantProps<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Pretty<Parameters<T>[0]>\n\n/**\n * Extract the variants from a `cva` function.\n */\nexport type RecipeVariant<\n T extends RecipeVariantFn<RecipeVariantRecord> | SlotRecipeVariantFn<string, SlotRecipeVariantRecord<string>>,\n> = Exclude<Pretty<Required<RecipeVariantProps<T>>>, undefined>\n\n/* -----------------------------------------------------------------------------\n * Recipe / Standard\n * -----------------------------------------------------------------------------*/\n\n/**\n * What a compiled build lets you do with a recipe: call it, or split its variant props.\n *\n * Nothing else is declared, because nothing else compiles. The compiler rewrites a call into\n * the classes it selects and erases the recipe, so any other read of the binding — `raw`,\n * `variantMap`, `config`, `merge`, `getVariantProps` — would see a value that is no longer\n * there, and fails the build with `runtime-binding` or `raw-call`. Declaring them only let\n * that failure type-check.\n */\nexport interface RecipeRuntimeFn<T extends RecipeVariantRecord> extends RecipeVariantFn<T> {\n __type: RecipeSelection<T>\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\ntype OneOrMore<T> = T | Array<T>\n\nexport type RecipeCompoundSelection<T> = {\n [K in keyof T]?: OneOrMore<StringToBoolean<keyof T[K]>> | undefined\n}\n\nexport type RecipeCompoundVariant<T> = T & {\n css: SystemStyleObject\n}\n\nexport interface RecipeDefinition<T extends RecipeVariantRecord = RecipeVariantRecord> {\n /**\n * The base styles of the recipe.\n */\n base?: SystemStyleObject\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.recipes`, where it is the key it is declared\n * under. Optional for an inline `cva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe identity\n * is not style identity, so identical declarations share one class across recipes.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<RecipeCompoundVariant<RecipeCompoundSelection<T>>>[]\n}\n\nexport type RecipeCreatorFn = <T extends RecipeVariantRecord>(config: RecipeDefinition<T>) => RecipeRuntimeFn<T>\n\ninterface RecipeConfigMeta {\n /**\n * The description of the recipe. This will be used in the JSDoc comment.\n */\n description?: string\n /**\n * The jsx elements to track for this recipe. Can be string or Regexp.\n *\n * @default capitalize(recipe.name)\n * @example ['Button', 'Link', /Button$/]\n */\n jsx?: Array<string | RegExp>\n /**\n * Variants to pre-generate, will be include in the final `config.staticCss`\n */\n staticCss?: RecipeRule[]\n}\n\nexport interface RecipeConfig<T extends RecipeVariantRecord = RecipeVariantRecord>\n extends RecipeDefinition<T>, RecipeConfigMeta {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.recipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n}\n\n/* -----------------------------------------------------------------------------\n * Recipe / Slot\n * -----------------------------------------------------------------------------*/\n\ntype SlotRecord<S extends string, T> = Partial<Record<S, T>>\n\nexport type SlotRecipeVariantRecord<S extends string> = Record<any, Record<any, SlotRecord<S, SystemStyleObject>>>\n\nexport type SlotRecipeVariantFn<S extends string, T extends RecipeVariantRecord> = (\n props?: RecipeSelection<T>,\n) => SlotRecord<S, string>\n\n/**\n * A slot recipe as a compiled build allows it: call it, or split its variant props. See\n * `RecipeRuntimeFn` for why nothing else is declared.\n */\nexport interface SlotRecipeRuntimeFn<\n S extends string,\n T extends SlotRecipeVariantRecord<S>,\n> extends SlotRecipeVariantFn<S, T> {\n splitVariantProps<Props extends RecipeSelection<T>>(\n props: Props,\n ): [RecipeSelection<T>, Pretty<DistributiveOmit<Props, keyof T>>]\n}\n\nexport type SlotRecipeCompoundVariant<S extends string, T> = T & {\n css: SlotRecord<S, SystemStyleObject>\n}\n\nexport interface SlotRecipeDefinition<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> {\n /**\n * Semantic recipe name used by extraction-only integrations.\n *\n * Required for a recipe declared in `theme.slotRecipes`, where it is the key it is\n * declared under. Optional for an inline `sva`.\n *\n * The Vite compiler ignores this field when allocating declaration atoms: recipe and slot\n * identity do not enter generated class names.\n */\n className?: string\n /**\n * Whether the recipe is deprecated.\n */\n deprecated?: boolean | string\n /**\n * The parts/slots of the recipe.\n */\n slots: S[] | Readonly<S[]>\n /**\n * Accepted and ignored.\n *\n * Older extraction-only releases scoped a slot's variant styles with `@scope` rules anchored\n * at the slots named here. The Vite compiler returns complete atoms for every selected slot\n * and emits no `@scope`, so this has no effect on output; it is still accepted so existing\n * configs keep loading.\n *\n * @deprecated Has no effect on compiled output.\n */\n scopeRoots?: S[] | Readonly<S[]>\n /**\n * The base styles of the recipe.\n */\n base?: SlotRecord<S, SystemStyleObject>\n /**\n * The multi-variant styles of the recipe.\n */\n variants?: T\n /**\n * The default variants of the recipe.\n */\n defaultVariants?: RecipeSelection<T>\n /**\n * The styles to apply when a combination of variants is selected.\n */\n compoundVariants?: Pretty<SlotRecipeCompoundVariant<S, RecipeCompoundSelection<T>>>[]\n}\n\nexport type SlotRecipeCreatorFn = <S extends string, T extends SlotRecipeVariantRecord<S>>(\n config: SlotRecipeDefinition<S, T>,\n) => SlotRecipeRuntimeFn<S, T>\n\nexport type SlotRecipeConfig<\n S extends string = string,\n T extends SlotRecipeVariantRecord<S> = SlotRecipeVariantRecord<S>,\n> = SlotRecipeDefinition<S, T> &\n RecipeConfigMeta & {\n /**\n * Required extraction metadata for a configured recipe: the key under which it is\n * declared in `theme.slotRecipes`. The Vite compiler does not use it as style identity.\n */\n className: string\n }\n";
2063
1531
  //#endregion
2064
1532
  //#region src/artifacts/generated/selectors.d.ts.json
2065
1533
  var content$2 = "import type { Pseudos } from './csstype'\n\ntype AriaAttributes =\n | '[aria-disabled]'\n | '[aria-hidden]'\n | '[aria-invalid]'\n | '[aria-readonly]'\n | '[aria-required]'\n | '[aria-selected]'\n | '[aria-checked]'\n | '[aria-expanded]'\n | '[aria-pressed]'\n | `[aria-current=${'page' | 'step' | 'location' | 'date' | 'time'}]`\n | '[aria-invalid]'\n | `[aria-sort=${'ascending' | 'descending'}]`\n\ntype DataAttributes =\n | '[data-selected]'\n | '[data-highlighted]'\n | '[data-hover]'\n | '[data-active]'\n | '[data-checked]'\n | '[data-disabled]'\n | '[data-readonly]'\n | '[data-focus]'\n | '[data-focus-visible]'\n | '[data-focus-visible-added]'\n | '[data-invalid]'\n | '[data-pressed]'\n | '[data-expanded]'\n | '[data-grabbed]'\n | '[data-dragged]'\n | '[data-orientation=horizontal]'\n | '[data-orientation=vertical]'\n | '[data-in-range]'\n | '[data-out-of-range]'\n | '[data-placeholder-shown]'\n | `[data-part=${string}]`\n | `[data-attr=${string}]`\n | `[data-placement=${string}]`\n | `[data-theme=${string}]`\n | `[data-size=${string}]`\n | `[data-state=${string}]`\n | '[data-empty]'\n | '[data-loading]'\n | '[data-loaded]'\n | '[data-enter]'\n | '[data-entering]'\n | '[data-exited]'\n | '[data-exiting]'\n\ntype AttributeSelector = `&${Pseudos | DataAttributes | AriaAttributes}`\ntype ParentSelector = `${DataAttributes | AriaAttributes} &`\n\ntype AtRuleType = 'media' | 'layer' | 'container' | 'supports' | 'page' | 'scope' | 'starting-style'\n\nexport type AnySelector = `${string}&` | `&${string}` | `@${AtRuleType}${string}`\nexport type Selectors = AttributeSelector | ParentSelector\n";
@@ -3089,22 +2557,6 @@ function setupCx(ctx) {
3089
2557
  }]
3090
2558
  };
3091
2559
  }
3092
- function setupCreateRecipe(ctx) {
3093
- if (ctx.recipes.isEmpty()) return;
3094
- const createRecipe = generateCreateRecipe(ctx);
3095
- if (!createRecipe) return;
3096
- return {
3097
- id: "create-recipe",
3098
- dir: ctx.paths.recipe,
3099
- files: [{
3100
- file: ctx.file.ext(createRecipe.name),
3101
- code: createRecipe.js
3102
- }, {
3103
- file: ctx.file.extDts(createRecipe.name),
3104
- code: createRecipe.dts
3105
- }]
3106
- };
3107
- }
3108
2560
  function setupRecipesIndex(ctx) {
3109
2561
  if (ctx.recipes.isEmpty()) return;
3110
2562
  const fileNames = ctx.recipes.details.map((recipe) => recipe.dashName);
@@ -3187,7 +2639,7 @@ function setupCssIndex(ctx) {
3187
2639
  ${ctx.file.reExport("css, fallback, viewTransition", "./css")}
3188
2640
  ${ctx.file.reExport("cx", "./cx")}
3189
2641
  ${ctx.file.reExport("cva", "./cva")}
3190
- ${ctx.file.reExport("sva, auditSlotScopes", "./sva")}
2642
+ ${ctx.file.reExport("sva", "./sva")}
3191
2643
 
3192
2644
  // Written by the source transform, never by hand. They are exported here because the
3193
2645
  // transform adds them to whatever \`styled-system/css\` import the file already has, so
@@ -3204,8 +2656,7 @@ function setupCssIndex(ctx) {
3204
2656
  ${ctx.file.reExportDts("cx", "./cx")}
3205
2657
  ${ctx.file.reExportDts("cva", "./cva")}
3206
2658
  ${ctx.file.exportType("RecipeVariant, RecipeVariantProps", "./cva")}
3207
- ${ctx.file.reExportDts("sva, auditSlotScopes", "./sva")}
3208
- ${ctx.file.exportType("SlotScopeProblem, AuditSlotScopesOptions", "./sva")}
2659
+ ${ctx.file.reExportDts("sva", "./sva")}
3209
2660
  `
3210
2661
  };
3211
2662
  return {
@@ -3279,7 +2730,6 @@ const entries = [
3279
2730
  ["cva", setupCva],
3280
2731
  ["sva", setupSva],
3281
2732
  ["cx", setupCx],
3282
- ["create-recipe", setupCreateRecipe],
3283
2733
  ["recipes-index", setupRecipesIndex],
3284
2734
  ["recipes", setupRecipes],
3285
2735
  ["patterns-index", setupPatternsIndex],