@styleframe/core 3.0.1 → 3.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1,812 +1,967 @@
1
- function C(e) {
1
+ function M(e) {
2
2
  return typeof e == "object" && e !== null;
3
3
  }
4
- function h(e, r) {
5
- return C(e) && "type" in e && e.type === r;
4
+ function b(e, t) {
5
+ return M(e) && "type" in e && e.type === t;
6
6
  }
7
7
  function G(e) {
8
- return h(e, "variable");
8
+ return b(e, "variable");
9
9
  }
10
10
  function j(e) {
11
- return h(e, "reference");
11
+ return b(e, "reference");
12
12
  }
13
- function je(e) {
14
- return h(e, "selector");
13
+ function Fe(e) {
14
+ return b(e, "selector");
15
15
  }
16
- function ve(e) {
17
- return h(e, "at-rule");
16
+ function te(e) {
17
+ return b(e, "at-rule");
18
18
  }
19
- function we(e) {
20
- return h(e, "utility");
19
+ function _e(e) {
20
+ return b(e, "utility");
21
21
  }
22
- function I(e) {
23
- return h(e, "modifier");
22
+ function ne(e) {
23
+ return b(e, "modifier");
24
24
  }
25
- function E(e) {
26
- return h(e, "css");
25
+ function N(e) {
26
+ return b(e, "css");
27
27
  }
28
- function ke(e) {
29
- return h(e, "theme");
28
+ function Se(e) {
29
+ return b(e, "theme");
30
30
  }
31
- function V(e) {
32
- return h(e, "root");
31
+ function $(e) {
32
+ return b(e, "root");
33
33
  }
34
- function Ve(e) {
35
- return h(e, "recipe");
34
+ function Te(e) {
35
+ return b(e, "recipe");
36
36
  }
37
- function z(e) {
37
+ function re(e) {
38
38
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
39
39
  }
40
- function D(e) {
41
- return z(e) || j(e) || E(e) || Array.isArray(e) && e.every(D);
42
- }
43
- function Y(e) {
44
- return C(e) && "children" in e && "declarations" in e && "variables" in e;
45
- }
46
- function Re(e) {
47
- return C(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && V(e.root);
40
+ function B(e) {
41
+ return re(e) || j(e) || N(e) || Array.isArray(e) && e.every(B);
48
42
  }
49
- function Z(e) {
50
- let r = 5381;
51
- for (let n = 0; n < e.length; n++)
52
- r = (r << 5) + r + e.charCodeAt(n) & 4294967295;
53
- return (r >>> 0).toString(16).padStart(7, "0").slice(0, 7);
43
+ function Ce(e) {
44
+ return M(e) && "id" in e && "children" in e && "declarations" in e && "variables" in e;
54
45
  }
55
- function P(e) {
56
- const r = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: n = (c) => c, namespace: t } = r, i = Array.isArray(t) ? t : t ? [t] : [];
57
- return (c) => {
58
- let s = c, a;
59
- if (typeof s == "string" && s[0] === "@") {
60
- const o = s.slice(1), f = i.find(
61
- (y) => o === y || o.startsWith(`${y}.`)
46
+ function ie(e) {
47
+ return M(e) && "children" in e && "declarations" in e && "variables" in e;
48
+ }
49
+ function se(e) {
50
+ return typeof e == "string" && e.startsWith("@");
51
+ }
52
+ function Ne(e) {
53
+ return M(e) && "id" in e && "root" in e && "variable" in e && "selector" in e && "recipe" in e && typeof e.id == "string" && $(e.root);
54
+ }
55
+ function oe(e) {
56
+ let t = 5381;
57
+ for (let r = 0; r < e.length; r++)
58
+ t = (t << 5) + t + e.charCodeAt(r) & 4294967295;
59
+ return (t >>> 0).toString(16).padStart(7, "0").slice(0, 7);
60
+ }
61
+ function q(e) {
62
+ const t = typeof e == "function" ? { replacer: e } : e ?? {}, { replacer: r = (o) => o, namespace: n } = t, s = Array.isArray(n) ? n : n ? [n] : [];
63
+ return (o) => {
64
+ let i = o, f;
65
+ if (typeof i == "string" && i[0] === "@") {
66
+ const c = i.slice(1), a = s.find(
67
+ (d) => c === d || c.startsWith(`${d}.`)
62
68
  );
63
69
  let l, u;
64
- f ? (l = o, u = o.startsWith(`${f}.`) ? o.slice(f.length + 1) : o) : i.length > 0 ? (l = `${i[0]}.${o}`, u = o) : (l = o, u = o), a = n(u), s = {
70
+ a ? (l = c, u = c.startsWith(`${a}.`) ? c.slice(a.length + 1) : c) : s.length > 0 ? (l = `${s[0]}.${c}`, u = c) : (l = c, u = c), f = r(u), i = {
65
71
  type: "reference",
66
72
  name: l
67
73
  };
68
- } else if (j(s)) {
69
- let o = s.name;
70
- for (const f of i)
71
- if (o.startsWith(`${f}.`)) {
72
- o = o.slice(f.length + 1);
74
+ } else if (j(i)) {
75
+ let c = i.name;
76
+ for (const a of s)
77
+ if (c.startsWith(`${a}.`)) {
78
+ c = c.slice(a.length + 1);
73
79
  break;
74
80
  }
75
- a = n(o);
81
+ f = r(c);
76
82
  } else {
77
- const o = String(c).trim();
78
- /\s/.test(o) ? a = Z(o) : a = `[${o}]`;
83
+ const c = String(o).trim();
84
+ /\s/.test(c) ? f = oe(c) : f = `[${c}]`;
79
85
  }
80
86
  return {
81
- [a]: s
82
- };
83
- };
84
- }
85
- function J(e, r) {
86
- return function(t, ...i) {
87
- return {
88
- type: "css",
89
- value: t.reduce((s, a, o) => (s.push(a), o < i.length && s.push(i[o]), s), [])
87
+ [f]: i
90
88
  };
91
89
  };
92
90
  }
93
- function K(e, r) {
94
- return function(t, i, c) {
95
- const s = {
96
- type: "at-rule",
97
- identifier: t,
98
- rule: i,
99
- declarations: {},
100
- variables: [],
101
- children: []
102
- }, a = v(s, r);
103
- return typeof c == "function" ? s.declarations = c(a) ?? {} : c && (s.declarations = c), R(s.declarations, a), e.children.push(s), s;
104
- };
91
+ const Be = ({
92
+ name: e,
93
+ value: t,
94
+ modifiers: r
95
+ }) => `_${[
96
+ ...r,
97
+ e,
98
+ ...t === "default" ? [] : [t]
99
+ ].filter(Boolean).join(":")}`, _ = /@([\w.-]+)/g;
100
+ function z(e) {
101
+ const t = [];
102
+ let r = 0, n;
103
+ for (_.lastIndex = 0; (n = _.exec(e)) !== null; )
104
+ t.push(e.slice(r, n.index)), t.push({ type: "reference", name: n[1] }), r = _.lastIndex;
105
+ return t.push(e.slice(r)), t;
106
+ }
107
+ function ce(e, t, r) {
108
+ let n = t;
109
+ for (; n; ) {
110
+ if (n.variables.some((s) => s.name === e))
111
+ return !0;
112
+ if (n.parentId)
113
+ n = r._registry.get(n.parentId);
114
+ else
115
+ break;
116
+ }
117
+ return !1;
105
118
  }
106
- function Q(e, r) {
107
- const n = K(e, r);
108
- return function(i, c) {
109
- return n("media", i, c);
110
- };
119
+ function fe(e, t, r) {
120
+ if (!ce(e, t, r))
121
+ throw new Error(
122
+ `[styleframe] Variable "${e}" is not defined. Check that the variable exists before referencing it with "@${e}".`
123
+ );
111
124
  }
112
- function X(e, r) {
113
- const n = K(e, r);
114
- return function(i, c) {
115
- return n("keyframes", i, c);
125
+ function I(e, t) {
126
+ return function(n) {
127
+ if (typeof n != "string" || !n.includes("@"))
128
+ return n;
129
+ if (se(n) && /^@[\w.-]+$/.test(n)) {
130
+ const i = n.slice(1);
131
+ return fe(i, e, t), { type: "reference", name: i };
132
+ }
133
+ const s = z(n);
134
+ return s.some((i) => j(i)) ? { type: "css", value: s } : n;
116
135
  };
117
136
  }
118
- function ee(e, r) {
119
- return function(t, i) {
120
- return G(t) ? {
121
- type: "reference",
122
- name: t.name,
123
- fallback: i
124
- } : {
137
+ function X(e, t) {
138
+ return function(n, s) {
139
+ const o = I(e, t), i = s != null ? o(s) : s;
140
+ if (G(n))
141
+ return {
142
+ type: "reference",
143
+ name: n.name,
144
+ fallback: i
145
+ };
146
+ if (n == null)
147
+ throw new Error(
148
+ `[styleframe] ref() received ${String(n)}. This usually means you're referencing a variable that doesn't exist.`
149
+ );
150
+ return {
125
151
  type: "reference",
126
- name: t,
152
+ name: n,
127
153
  fallback: i
128
154
  };
129
155
  };
130
156
  }
131
- function te(e, r) {
132
- return function(t, i) {
133
- const c = {
134
- type: "selector",
135
- query: t,
136
- declarations: {},
137
- variables: [],
138
- children: []
139
- }, s = v(c, r);
140
- return typeof i == "function" ? c.declarations = i(s) ?? {} : Y(i) ? (c.variables = i.variables, c.declarations = i.declarations, c.children = i.children) : c.declarations = i, R(c.declarations, s), e.children.push(c), c;
141
- };
142
- }
143
- function ne(e, r) {
144
- return function(t, i, c = {
145
- default: !1
146
- }) {
147
- const s = typeof t == "string" ? t : t.name, a = e.variables.find(
148
- (f) => f.name === s
149
- );
150
- if (c.default && a)
151
- return a;
152
- if (a)
153
- return a.value = i, a;
154
- const o = {
155
- type: "variable",
156
- name: s,
157
- value: i
157
+ function ae(e, t) {
158
+ const r = X(e, t);
159
+ return function(s, ...o) {
160
+ return {
161
+ type: "css",
162
+ value: s.reduce((f, c, a) => {
163
+ if (f.push(...z(c)), a < o.length) {
164
+ const l = o[a];
165
+ G(l) ? f.push(r(l)) : te(l) ? f.push(l.rule) : f.push(l);
166
+ }
167
+ return f;
168
+ }, [])
158
169
  };
159
- return e.variables.push(o), o;
160
170
  };
161
171
  }
162
- function v(e, r) {
163
- const n = ne(e), t = te(e, r), i = K(e, r), c = X(r, r), s = Q(e, r), a = ee(), o = J();
164
- return {
165
- variable: n,
166
- selector: t,
167
- keyframes: c,
168
- atRule: i,
169
- media: s,
170
- ref: a,
171
- css: o
172
- };
173
- }
174
- function R(e, r) {
175
- for (const n in e)
176
- if (n.startsWith("@")) {
177
- const t = e[n];
178
- if (typeof t == "object" && t !== null && !D(t)) {
179
- const i = n.replace(/^@(\w+).*/, "$1"), c = n.replace(`@${i}`, "").trim();
180
- r.atRule(i, c, t), delete e[n];
181
- }
182
- } else if (/^[.&:]/.test(n) || /^\d+%$/.test(n) || n === "from" || n === "to") {
183
- const t = e[n];
184
- typeof t == "object" && (r.selector(n, t), delete e[n]);
185
- }
186
- for (const n in e) {
187
- const t = e[n];
188
- typeof t == "string" && t[0] === "@" && (e[n] = r.ref(t.slice(1)));
189
- }
190
- return e;
191
- }
192
- function $e(e) {
172
+ function Pe(e) {
193
173
  return e.charAt(0).toUpperCase() + e.slice(1);
194
174
  }
195
- function A(e) {
175
+ function Ke(e) {
176
+ return `.${e.replace(/[[\].#()%,:/]/g, "\\$&")}`;
177
+ }
178
+ function v(e) {
196
179
  if (e instanceof Buffer)
197
180
  return Buffer.from(e);
198
- const r = e.constructor;
199
- return new r(
181
+ const t = e.constructor;
182
+ return new t(
200
183
  e.buffer.slice(0),
201
184
  e.byteOffset,
202
185
  e.byteLength / e.BYTES_PER_ELEMENT || 1
203
186
  );
204
187
  }
205
- function re(e) {
188
+ function ue(e) {
206
189
  if (e = e || {}, e.circular)
207
- return ie(e);
208
- const r = /* @__PURE__ */ new Map();
209
- if (r.set(Date, (s) => new Date(s)), r.set(
190
+ return le(e);
191
+ const t = /* @__PURE__ */ new Map();
192
+ if (t.set(Date, (i) => new Date(i)), t.set(
210
193
  Map,
211
- (s, a) => new Map(t(Array.from(s), a))
212
- ), r.set(
194
+ (i, f) => new Map(n(Array.from(i), f))
195
+ ), t.set(
213
196
  Set,
214
- (s, a) => new Set(t(Array.from(s), a))
197
+ (i, f) => new Set(n(Array.from(i), f))
215
198
  ), e.constructorHandlers)
216
- for (const s of e.constructorHandlers)
217
- r.set(s[0], s[1]);
218
- let n;
219
- return e.proto ? c : i;
220
- function t(s, a) {
221
- const o = Object.keys(s), f = Array.from({ length: o.length });
222
- for (let l = 0; l < o.length; l++) {
223
- const u = o[l], y = s[u];
224
- typeof y != "object" || y === null ? f[u] = y : y.constructor !== Object && (n = r.get(y.constructor)) ? f[u] = n(y, a) : ArrayBuffer.isView(y) ? f[u] = A(y) : f[u] = a(y);
199
+ for (const i of e.constructorHandlers)
200
+ t.set(i[0], i[1]);
201
+ let r;
202
+ return e.proto ? o : s;
203
+ function n(i, f) {
204
+ const c = Object.keys(i), a = Array.from({ length: c.length });
205
+ for (let l = 0; l < c.length; l++) {
206
+ const u = c[l], d = i[u];
207
+ typeof d != "object" || d === null ? a[u] = d : d.constructor !== Object && (r = t.get(d.constructor)) ? a[u] = r(d, f) : ArrayBuffer.isView(d) ? a[u] = v(d) : a[u] = f(d);
225
208
  }
226
- return f;
209
+ return a;
227
210
  }
228
- function i(s) {
229
- if (typeof s != "object" || s === null) return s;
230
- if (Array.isArray(s)) return t(s, i);
231
- if (s.constructor !== Object && (n = r.get(s.constructor)))
232
- return n(s, i);
233
- const a = {};
234
- for (const o in s) {
235
- if (Object.hasOwnProperty.call(s, o) === !1) continue;
236
- const f = s[o];
237
- typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, i) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = i(f);
211
+ function s(i) {
212
+ if (typeof i != "object" || i === null) return i;
213
+ if (Array.isArray(i)) return n(i, s);
214
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
215
+ return r(i, s);
216
+ const f = {};
217
+ for (const c in i) {
218
+ if (Object.hasOwnProperty.call(i, c) === !1) continue;
219
+ const a = i[c];
220
+ typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, s) : ArrayBuffer.isView(a) ? f[c] = v(a) : f[c] = s(a);
238
221
  }
239
- return a;
222
+ return f;
240
223
  }
241
- function c(s) {
242
- if (typeof s != "object" || s === null) return s;
243
- if (Array.isArray(s)) return t(s, c);
244
- if (s.constructor !== Object && (n = r.get(s.constructor)))
245
- return n(s, c);
246
- const a = {};
247
- for (const o in s) {
248
- const f = s[o];
249
- typeof f != "object" || f === null ? a[o] = f : f.constructor !== Object && (n = r.get(f.constructor)) ? a[o] = n(f, c) : ArrayBuffer.isView(f) ? a[o] = A(f) : a[o] = c(f);
224
+ function o(i) {
225
+ if (typeof i != "object" || i === null) return i;
226
+ if (Array.isArray(i)) return n(i, o);
227
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
228
+ return r(i, o);
229
+ const f = {};
230
+ for (const c in i) {
231
+ const a = i[c];
232
+ typeof a != "object" || a === null ? f[c] = a : a.constructor !== Object && (r = t.get(a.constructor)) ? f[c] = r(a, o) : ArrayBuffer.isView(a) ? f[c] = v(a) : f[c] = o(a);
250
233
  }
251
- return a;
234
+ return f;
252
235
  }
253
236
  }
254
- function ie(e) {
255
- const r = [], n = [], t = /* @__PURE__ */ new Map();
256
- if (t.set(Date, (o) => new Date(o)), t.set(
237
+ function le(e) {
238
+ const t = [], r = [], n = /* @__PURE__ */ new Map();
239
+ if (n.set(Date, (c) => new Date(c)), n.set(
257
240
  Map,
258
- (o, f) => new Map(c(Array.from(o), f))
259
- ), t.set(
241
+ (c, a) => new Map(o(Array.from(c), a))
242
+ ), n.set(
260
243
  Set,
261
- (o, f) => new Set(c(Array.from(o), f))
244
+ (c, a) => new Set(o(Array.from(c), a))
262
245
  ), e.constructorHandlers)
263
- for (const o of e.constructorHandlers)
264
- t.set(o[0], o[1]);
265
- let i;
266
- return e.proto ? a : s;
267
- function c(o, f) {
268
- const l = Object.keys(o), u = Array.from({ length: l.length });
269
- for (let y = 0; y < l.length; y++) {
270
- const p = l[y], d = o[p];
271
- if (typeof d != "object" || d === null)
272
- u[p] = d;
273
- else if (d.constructor !== Object && (i = t.get(d.constructor)))
274
- u[p] = i(d, f);
275
- else if (ArrayBuffer.isView(d))
276
- u[p] = A(d);
246
+ for (const c of e.constructorHandlers)
247
+ n.set(c[0], c[1]);
248
+ let s;
249
+ return e.proto ? f : i;
250
+ function o(c, a) {
251
+ const l = Object.keys(c), u = Array.from({ length: l.length });
252
+ for (let d = 0; d < l.length; d++) {
253
+ const y = l[d], m = c[y];
254
+ if (typeof m != "object" || m === null)
255
+ u[y] = m;
256
+ else if (m.constructor !== Object && (s = n.get(m.constructor)))
257
+ u[y] = s(m, a);
258
+ else if (ArrayBuffer.isView(m))
259
+ u[y] = v(m);
277
260
  else {
278
- const w = r.indexOf(d);
279
- w !== -1 ? u[p] = n[w] : u[p] = f(d);
261
+ const p = t.indexOf(m);
262
+ p !== -1 ? u[y] = r[p] : u[y] = a(m);
280
263
  }
281
264
  }
282
265
  return u;
283
266
  }
284
- function s(o) {
285
- if (typeof o != "object" || o === null) return o;
286
- if (Array.isArray(o)) return c(o, s);
287
- if (o.constructor !== Object && (i = t.get(o.constructor)))
288
- return i(o, s);
289
- const f = {};
290
- r.push(o), n.push(f);
291
- for (const l in o) {
292
- if (Object.hasOwnProperty.call(o, l) === !1) continue;
293
- const u = o[l];
267
+ function i(c) {
268
+ if (typeof c != "object" || c === null) return c;
269
+ if (Array.isArray(c)) return o(c, i);
270
+ if (c.constructor !== Object && (s = n.get(c.constructor)))
271
+ return s(c, i);
272
+ const a = {};
273
+ t.push(c), r.push(a);
274
+ for (const l in c) {
275
+ if (Object.hasOwnProperty.call(c, l) === !1) continue;
276
+ const u = c[l];
294
277
  if (typeof u != "object" || u === null)
295
- f[l] = u;
296
- else if (u.constructor !== Object && (i = t.get(u.constructor)))
297
- f[l] = i(u, s);
278
+ a[l] = u;
279
+ else if (u.constructor !== Object && (s = n.get(u.constructor)))
280
+ a[l] = s(u, i);
298
281
  else if (ArrayBuffer.isView(u))
299
- f[l] = A(u);
282
+ a[l] = v(u);
300
283
  else {
301
- const y = r.indexOf(u);
302
- y !== -1 ? f[l] = n[y] : f[l] = s(u);
284
+ const d = t.indexOf(u);
285
+ d !== -1 ? a[l] = r[d] : a[l] = i(u);
303
286
  }
304
287
  }
305
- return r.pop(), n.pop(), f;
288
+ return t.pop(), r.pop(), a;
306
289
  }
307
- function a(o) {
308
- if (typeof o != "object" || o === null) return o;
309
- if (Array.isArray(o)) return c(o, a);
310
- if (o.constructor !== Object && (i = t.get(o.constructor)))
311
- return i(o, a);
312
- const f = {};
313
- r.push(o), n.push(f);
314
- for (const l in o) {
315
- const u = o[l];
290
+ function f(c) {
291
+ if (typeof c != "object" || c === null) return c;
292
+ if (Array.isArray(c)) return o(c, f);
293
+ if (c.constructor !== Object && (s = n.get(c.constructor)))
294
+ return s(c, f);
295
+ const a = {};
296
+ t.push(c), r.push(a);
297
+ for (const l in c) {
298
+ const u = c[l];
316
299
  if (typeof u != "object" || u === null)
317
- f[l] = u;
318
- else if (u.constructor !== Object && (i = t.get(u.constructor)))
319
- f[l] = i(u, a);
300
+ a[l] = u;
301
+ else if (u.constructor !== Object && (s = n.get(u.constructor)))
302
+ a[l] = s(u, f);
320
303
  else if (ArrayBuffer.isView(u))
321
- f[l] = A(u);
304
+ a[l] = v(u);
322
305
  else {
323
- const y = r.indexOf(u);
324
- y !== -1 ? f[l] = n[y] : f[l] = a(u);
306
+ const d = t.indexOf(u);
307
+ d !== -1 ? a[l] = r[d] : a[l] = f(u);
325
308
  }
326
309
  }
327
- return r.pop(), n.pop(), f;
310
+ return t.pop(), r.pop(), a;
328
311
  }
329
312
  }
330
- const F = re();
331
- function se(e, r = 8) {
332
- const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
333
- let t = "";
334
- for (let i = 0; i < r; i++) {
335
- const c = Math.floor(Math.random() * n.length);
336
- t += n[c];
313
+ const R = ue();
314
+ function w(e, t = 8) {
315
+ const r = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
316
+ let n = "";
317
+ for (let s = 0; s < t; s++) {
318
+ const o = Math.floor(Math.random() * r.length);
319
+ n += r[o];
337
320
  }
338
- return e ? `${e}${t}` : t;
339
- }
340
- function Oe(e, r) {
341
- const n = e.variables.find((t) => t.name === r);
342
- if (!n)
343
- throw new Error(`Variable "${r}" not found`);
344
- return n;
345
- }
346
- function Me(e, r) {
347
- const n = e.utilities.find((t) => t.name === r);
348
- if (!n)
349
- throw new Error(`Utility "${r}" not found`);
350
- return n;
351
- }
352
- function oe(e, r) {
353
- const n = e.modifiers.find(
354
- (t) => t.key.includes(r)
321
+ return e ? `${e}${n}` : n;
322
+ }
323
+ function Ue(e, t) {
324
+ const r = e.variables.find((n) => n.name === t);
325
+ if (!r)
326
+ throw new Error(`Variable "${t}" not found`);
327
+ return r;
328
+ }
329
+ function Ie(e, t) {
330
+ const r = e.utilities.find((n) => n.name === t);
331
+ if (!r)
332
+ throw new Error(`Utility "${t}" not found`);
333
+ return r;
334
+ }
335
+ function de(e, t) {
336
+ const r = e.modifiers.find(
337
+ (n) => n.key.includes(t)
355
338
  );
356
- if (!n)
357
- throw new Error(`Modifier "${r}" not found`);
358
- return n;
359
- }
360
- function S(e, r) {
361
- if (e === r) return !0;
362
- if (typeof e != typeof r) return !1;
363
- if (e === null || r === null) return e === r;
364
- if (typeof e != "object" || typeof r != "object") return !1;
365
- if (Array.isArray(e) && Array.isArray(r))
366
- return e.length !== r.length ? !1 : e.every((n, t) => S(n, r[t]));
367
- if ("type" in e && "type" in r) {
368
- if (e.type !== r.type) return !1;
369
- if (j(e) && j(r))
370
- return e.name === r.name && S(e.fallback, r.fallback);
371
- if (E(e) && E(r))
372
- return S(e.value, r.value);
339
+ if (!r)
340
+ throw new Error(`Modifier "${t}" not found`);
341
+ return r;
342
+ }
343
+ function S(e, t) {
344
+ if (e === t) return !0;
345
+ if (typeof e != typeof t) return !1;
346
+ if (e === null || t === null) return e === t;
347
+ if (typeof e != "object" || typeof t != "object") return !1;
348
+ if (Array.isArray(e) && Array.isArray(t))
349
+ return e.length !== t.length ? !1 : e.every((r, n) => S(r, t[n]));
350
+ if ("type" in e && "type" in t) {
351
+ if (e.type !== t.type) return !1;
352
+ if (j(e) && j(t))
353
+ return e.name === t.name && S(e.fallback, t.fallback);
354
+ if (N(e) && N(t))
355
+ return S(e.value, t.value);
373
356
  }
374
357
  return !1;
375
358
  }
376
- const H = "__licenseRequired";
377
- function ce(e) {
378
- T(e) || Object.defineProperty(e, H, {
359
+ const Y = "__licenseRequired";
360
+ function ye(e) {
361
+ P(e) || Object.defineProperty(e, Y, {
379
362
  value: !0,
380
363
  writable: !1,
381
364
  configurable: !1,
382
365
  enumerable: !0
383
366
  });
384
367
  }
385
- function T(e) {
386
- return Object.prototype.hasOwnProperty.call(e, H);
368
+ function P(e) {
369
+ return Object.prototype.hasOwnProperty.call(e, Y);
387
370
  }
388
- function fe(e, r) {
389
- const n = [...e];
390
- for (const t of r) {
391
- const i = n.find(
392
- (c) => c.name === t.name
371
+ function me(e, t) {
372
+ const r = [...e];
373
+ for (const n of t) {
374
+ const s = r.find(
375
+ (o) => o.name === n.name
393
376
  );
394
- i ? i.value = t.value : n.push(t);
377
+ s ? s.value = n.value : r.push(n);
395
378
  }
396
- return n;
379
+ return r;
397
380
  }
398
- function ae(e, r) {
399
- const n = [...e];
400
- for (const t of r) {
401
- const i = n.find(
402
- (c) => c.name === t.name
381
+ function pe(e, t) {
382
+ const r = [...e];
383
+ for (const n of t) {
384
+ const s = r.find(
385
+ (o) => o.name === n.name
403
386
  );
404
- i ? Object.assign(
405
- i,
406
- W(i, t)
407
- ) : n.push(t);
387
+ s ? Object.assign(
388
+ s,
389
+ Z(s, n)
390
+ ) : r.push(n);
408
391
  }
409
- return n;
392
+ return r;
410
393
  }
411
- function W(e, r) {
394
+ function Z(e, t) {
412
395
  return Object.keys(e).reduce(
413
- (n, t) => (t === "variables" ? n.variables = fe(e.variables, r.variables) : t === "declarations" ? n.declarations = { ...e.declarations, ...r.declarations } : t === "themes" && V(n) && V(e) && V(r) ? n.themes = ae(e.themes, r.themes) : Array.isArray(e[t]) && (n[t] = e[t].concat(
414
- r[t]
415
- )), n),
396
+ (r, n) => (n === "variables" ? r.variables = me(e.variables, t.variables) : n === "declarations" ? r.declarations = { ...e.declarations, ...t.declarations } : n === "themes" && $(r) && $(e) && $(t) ? r.themes = pe(e.themes, t.themes) : Array.isArray(e[n]) && (r[n] = e[n].concat(
397
+ t[n]
398
+ )), r),
416
399
  {
417
400
  ...e,
418
- ...r
401
+ ...t
419
402
  }
420
403
  );
421
404
  }
422
- function Fe(e, ...r) {
423
- return r.reduce((n, t) => {
424
- const i = {
425
- ...n,
426
- root: W(n.root, t.root)
405
+ function K(e, t) {
406
+ for (const r of e)
407
+ "id" in r && typeof r.id == "string" && (t._registry.set(r.id, r), "children" in r && K(r.children, t));
408
+ }
409
+ function he(e) {
410
+ e._registry = /* @__PURE__ */ new Map(), e._registry.set(e.id, e), K(e.children, e);
411
+ for (const t of e.themes)
412
+ e._registry.set(t.id, t), K(t.children, e);
413
+ }
414
+ function De(e, ...t) {
415
+ return t.reduce((r, n) => {
416
+ const s = {
417
+ ...r,
418
+ root: Z(r.root, n.root)
427
419
  };
428
- return (T(n) || T(t)) && ce(i), i;
420
+ return he(s.root), (P(r) || P(n)) && ye(s), s;
429
421
  }, e);
430
422
  }
431
- function ue(e) {
432
- const r = [];
433
- function n(t, i) {
434
- i.length > 0 && r.push([...i].sort());
435
- for (let c = t; c < e.length; c++) {
436
- const s = e[c];
437
- if (s)
438
- if (s.length === 1 && s[0])
439
- n(c + 1, [...i, s[0]]);
423
+ function D(e, t) {
424
+ return function(n, s, o) {
425
+ const i = {
426
+ type: "at-rule",
427
+ id: w("ar-"),
428
+ parentId: e.id,
429
+ identifier: n,
430
+ rule: s,
431
+ declarations: {},
432
+ variables: [],
433
+ children: []
434
+ };
435
+ t._registry.set(i.id, i);
436
+ const f = V(i, t);
437
+ return typeof o == "function" ? i.declarations = o(f) ?? {} : o && (i.declarations = o), x(
438
+ i.declarations,
439
+ f,
440
+ i,
441
+ t
442
+ ), e.children.push(i), i;
443
+ };
444
+ }
445
+ function ge(e, t) {
446
+ const r = D(e, t);
447
+ return function(s, o) {
448
+ return r("media", s, o);
449
+ };
450
+ }
451
+ function be(e, t) {
452
+ const r = D(e, t);
453
+ return function(s, o) {
454
+ return r("keyframes", s, o);
455
+ };
456
+ }
457
+ function Ae(e, t) {
458
+ return function(n, s) {
459
+ const o = {
460
+ type: "selector",
461
+ id: w("sel-"),
462
+ parentId: e.id,
463
+ query: n,
464
+ declarations: {},
465
+ variables: [],
466
+ children: []
467
+ };
468
+ t._registry.set(o.id, o);
469
+ const i = V(o, t);
470
+ return typeof s == "function" ? o.declarations = s(i) ?? {} : ie(s) ? (o.variables = s.variables, o.declarations = s.declarations, o.children = s.children) : o.declarations = s, x(
471
+ o.declarations,
472
+ i,
473
+ o,
474
+ t
475
+ ), e.children.push(o), o;
476
+ };
477
+ }
478
+ function we(e, t) {
479
+ return function(n, s, o = {
480
+ default: !1
481
+ }) {
482
+ const i = typeof n == "string" ? n : n.name, c = I(e, t)(s), a = e.variables.find(
483
+ (u) => u.name === i
484
+ );
485
+ if (o.default && a)
486
+ return a;
487
+ if (a)
488
+ return a.value = c, a;
489
+ const l = {
490
+ type: "variable",
491
+ id: w("var-"),
492
+ parentId: e.id,
493
+ name: i,
494
+ value: c
495
+ };
496
+ return e.variables.push(l), l;
497
+ };
498
+ }
499
+ function V(e, t) {
500
+ const r = we(e, t), n = Ae(e, t), s = D(e, t), o = be(t, t), i = ge(e, t), f = X(t, t), c = ae(t, t);
501
+ return {
502
+ variable: r,
503
+ selector: n,
504
+ keyframes: o,
505
+ atRule: s,
506
+ media: i,
507
+ ref: f,
508
+ css: c
509
+ };
510
+ }
511
+ function x(e, t, r, n) {
512
+ for (const o in e)
513
+ if (o.startsWith("@")) {
514
+ const i = e[o];
515
+ if (typeof i == "object" && i !== null && !B(i)) {
516
+ const f = o.replace(/^@(\w+).*/, "$1"), c = o.replace(`@${f}`, "").trim();
517
+ t.atRule(f, c, i), delete e[o];
518
+ }
519
+ } else if (/^[.&:]/.test(o) || /^\d+%$/.test(o) || o === "from" || o === "to") {
520
+ const i = e[o];
521
+ typeof i == "object" && (t.selector(o, i), delete e[o]);
522
+ }
523
+ const s = I(r, n);
524
+ for (const o in e) {
525
+ const i = e[o];
526
+ if (B(i)) {
527
+ const f = s(i);
528
+ f !== i && (e[o] = f);
529
+ }
530
+ }
531
+ return e;
532
+ }
533
+ function je(e) {
534
+ const t = [];
535
+ function r(n, s) {
536
+ s.length > 0 && t.push([...s].sort());
537
+ for (let o = n; o < e.length; o++) {
538
+ const i = e[o];
539
+ if (i)
540
+ if (i.length === 1 && i[0])
541
+ r(o + 1, [...s, i[0]]);
440
542
  else
441
- for (const a of s)
442
- n(c + 1, [...i, a]);
543
+ for (const f of i)
544
+ r(o + 1, [...s, f]);
443
545
  }
444
546
  }
445
- return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
547
+ return r(0, []), t.sort((n, s) => n.length !== s.length ? n.length - s.length : n.join(",").localeCompare(s.join(",")));
446
548
  }
447
- function le(e, r, n) {
448
- const t = {
549
+ function ve(e, t, r) {
550
+ const n = {
449
551
  ...e,
450
- modifiers: [...n.keys()]
451
- }, i = v(t, r);
452
- for (const c of n.values())
453
- c.factory({
454
- ...i,
455
- declarations: F(t.declarations),
456
- variables: F(t.variables),
457
- children: F(t.children)
458
- }), R(t.declarations, i);
459
- return t;
460
- }
461
- function ye(e, r) {
462
- return function(t, i) {
463
- const c = {
552
+ id: w("ut-"),
553
+ parentId: e.parentId,
554
+ declarations: { ...e.declarations },
555
+ variables: [...e.variables],
556
+ children: [...e.children],
557
+ modifiers: [...r.keys()]
558
+ };
559
+ t._registry.set(n.id, n);
560
+ const s = V(n, t);
561
+ if (r.size > 0) {
562
+ const o = R(e.declarations);
563
+ let i = !1;
564
+ for (const f of r.values()) {
565
+ const c = f.factory({
566
+ ...s,
567
+ declarations: R(o),
568
+ variables: R(n.variables),
569
+ children: R(n.children)
570
+ });
571
+ c && (i || (n.declarations = {}, i = !0), Object.assign(n.declarations, c), x(
572
+ n.declarations,
573
+ s,
574
+ n,
575
+ t
576
+ ));
577
+ }
578
+ }
579
+ return n;
580
+ }
581
+ function Ve(e, t) {
582
+ return function(n, s) {
583
+ const o = {
464
584
  type: "modifier",
465
- key: Array.isArray(t) ? t : [t],
466
- factory: i
585
+ key: Array.isArray(n) ? n : [n],
586
+ factory: s
467
587
  };
468
- return r.modifiers.push(c), c;
588
+ return t.modifiers.push(o), o;
469
589
  };
470
590
  }
471
- function de() {
472
- return {
591
+ function ke() {
592
+ const e = {
473
593
  type: "root",
594
+ id: w("rt-"),
474
595
  declarations: {},
475
596
  utilities: [],
476
597
  modifiers: [],
477
598
  recipes: [],
478
599
  variables: [],
479
600
  children: [],
480
- themes: []
601
+ themes: [],
602
+ _registry: /* @__PURE__ */ new Map()
481
603
  };
482
- }
483
- function me(e, r) {
484
- const n = P({ namespace: e });
485
- return (t) => {
486
- if (typeof t == "string" && t[0] === "@") {
487
- const i = t.slice(1), c = e.find(
488
- (s) => i === s || i.startsWith(`${s}.`)
604
+ return e._registry.set(e.id, e), e;
605
+ }
606
+ function Re(e, t) {
607
+ const r = q({ namespace: e });
608
+ return (n) => {
609
+ if (typeof n == "string" && n[0] === "@") {
610
+ const s = n.slice(1), o = e.find(
611
+ (i) => s === i || s.startsWith(`${i}.`)
489
612
  );
490
- if (c) {
491
- const s = i.slice(c.length + 1) || i;
492
- if (r.variables.some((a) => a.name === i))
613
+ if (o) {
614
+ const i = s.slice(o.length + 1) || s;
615
+ if (t.variables.some((f) => f.name === s))
493
616
  return {
494
- [s]: {
617
+ [i]: {
495
618
  type: "reference",
496
- name: i
619
+ name: s
497
620
  }
498
621
  };
499
622
  } else
500
- for (const s of e) {
501
- const a = `${s}.${i}`;
502
- if (r.variables.some((o) => o.name === a))
623
+ for (const i of e) {
624
+ const f = `${i}.${s}`;
625
+ if (t.variables.some((c) => c.name === f))
503
626
  return {
504
- [i]: {
627
+ [s]: {
505
628
  type: "reference",
506
- name: a
629
+ name: f
507
630
  }
508
631
  };
509
632
  }
510
- return n(t);
633
+ return r(n);
511
634
  }
512
- return n(t);
635
+ return r(n);
513
636
  };
514
637
  }
515
- function pe(e, r) {
516
- return function(t, i, c = {}) {
517
- const s = {
638
+ function $e(e, t) {
639
+ return function(n, s, o = {}) {
640
+ const i = t.utilities.find((c) => c.name === n);
641
+ if (i)
642
+ return i.create;
643
+ const f = {
518
644
  type: "utility",
519
- name: t,
520
- factory: i,
645
+ name: n,
646
+ factory: s,
521
647
  values: [],
522
- autogenerate: c.autogenerate ?? (Array.isArray(c.namespace) ? me(c.namespace, r) : P(
523
- c.namespace ? { namespace: c.namespace } : void 0
648
+ autogenerate: o.autogenerate ?? (Array.isArray(o.namespace) ? Re(o.namespace, t) : q(
649
+ o.namespace ? { namespace: o.namespace } : void 0
524
650
  )),
525
- namespace: c.namespace,
526
- create: (a, o = []) => {
527
- let f = a;
528
- if (Array.isArray(a)) {
529
- f = {};
530
- for (const l of a) {
531
- const u = s.autogenerate(l);
532
- f = {
533
- ...f,
534
- ...u
651
+ namespace: o.namespace,
652
+ create: (c, a = []) => {
653
+ let l = c;
654
+ if (Array.isArray(c)) {
655
+ l = {};
656
+ for (const u of c) {
657
+ const d = f.autogenerate(u);
658
+ l = {
659
+ ...l,
660
+ ...d
535
661
  };
536
662
  }
537
663
  }
538
- for (const [l, u] of Object.entries(f)) {
539
- let y = u;
540
- if (s.namespace && j(u))
541
- if (r.variables.some((g) => g.name === u.name))
542
- y = u;
664
+ for (const [u, d] of Object.entries(l)) {
665
+ let y = d;
666
+ if (typeof d == "string" && d[0] === "@") {
667
+ const h = d.slice(1);
668
+ !Array.isArray(l) && h in l && (y = l[h]);
669
+ }
670
+ if (f.namespace && j(d))
671
+ if (t.variables.some((h) => h.name === d.name))
672
+ y = d;
543
673
  else {
544
- const g = Array.isArray(s.namespace) ? s.namespace : [s.namespace];
545
- let $ = !1;
546
- for (const O of g) {
547
- const m = `${O}.${l}`;
548
- if (m !== u.name && r.variables.some((b) => b.name === m)) {
674
+ const h = Array.isArray(f.namespace) ? f.namespace : [f.namespace];
675
+ let E = !1;
676
+ for (const O of h) {
677
+ const g = `${O}.${u}`;
678
+ if (g !== d.name && t.variables.some((A) => A.name === g)) {
549
679
  y = {
550
680
  type: "reference",
551
- name: m
552
- }, $ = !0;
681
+ name: g
682
+ }, E = !0;
553
683
  break;
554
684
  }
555
685
  }
556
- $ || (y = l);
686
+ E || (y = u);
557
687
  }
558
- const p = s.values.find(
559
- (g) => g.key === l && g.modifiers.length === 0
560
- ), d = {
688
+ const m = f.values.find(
689
+ (h) => h.key === u && h.modifiers.length === 0
690
+ ), p = {
561
691
  type: "utility",
562
- name: t,
563
- value: l,
692
+ id: w("ut-"),
693
+ parentId: e.id,
694
+ name: n,
695
+ value: u,
564
696
  declarations: {},
565
697
  variables: [],
566
698
  children: [],
567
699
  modifiers: []
568
- }, w = v(
569
- d,
570
- r
700
+ };
701
+ t._registry.set(p.id, p);
702
+ const W = V(
703
+ p,
704
+ t
571
705
  );
572
- if (d.declarations = i({
573
- ...w,
706
+ if (p.declarations = s({
707
+ ...W,
574
708
  value: y
575
- }) ?? {}, R(d.declarations, w), p || (s.values.push({
576
- key: l,
709
+ }) ?? {}, x(
710
+ p.declarations,
711
+ W,
712
+ p,
713
+ t
714
+ ), m || (f.values.push({
715
+ key: u,
577
716
  value: y,
578
717
  modifiers: []
579
- }), e.children.push(d)), o && o.length > 0) {
580
- const g = o.map((m) => m.key), O = ue(g).filter((m) => !s.values.find(
581
- (b) => b.key === l && b.modifiers.length === m.length && b.modifiers.every((k) => m.includes(k))
582
- )).reduce((m, b) => {
718
+ }), e.children.push(p)), a && a.length > 0) {
719
+ const h = a.map((g) => g.key), O = je(h).filter((g) => !f.values.find(
720
+ (A) => A.key === u && A.modifiers.length === g.length && A.modifiers.every((k) => g.includes(k))
721
+ )).reduce((g, A) => {
583
722
  const k = /* @__PURE__ */ new Map();
584
- for (const U of b) {
585
- const M = o.find(
586
- (q) => q.key.includes(U)
723
+ for (const H of A) {
724
+ const F = a.find(
725
+ (ee) => ee.key.includes(H)
587
726
  );
588
- M && I(M) && k.set(U, M);
727
+ F && ne(F) && k.set(H, F);
589
728
  }
590
- return s.values.push({
591
- key: l,
729
+ return f.values.push({
730
+ key: u,
592
731
  value: y,
593
- modifiers: b
594
- }), m.push(le(d, r, k)), m;
732
+ modifiers: A
733
+ }), g.push(ve(p, t, k)), g;
595
734
  }, []);
596
735
  e.children.push(...O);
597
736
  }
598
737
  }
599
738
  }
600
739
  };
601
- return r.utilities.push(s), s.create;
740
+ return t.utilities.push(f), f.create;
602
741
  };
603
742
  }
604
- function he(e, r) {
605
- return function(t, i) {
606
- const c = r.themes.find((o) => o.name === t), s = c ?? {
743
+ function Me(e, t) {
744
+ return function(n, s) {
745
+ const o = t.themes.find((c) => c.name === n), i = o ?? {
607
746
  type: "theme",
608
- name: t,
747
+ id: w("th-"),
748
+ parentId: t.id,
749
+ name: n,
609
750
  declarations: {},
610
751
  variables: [],
611
752
  children: []
612
753
  };
613
- c || r.themes.push(s);
614
- const a = v(s, r);
615
- return i && i(a), s;
754
+ o || (t._registry.set(i.id, i), t.themes.push(i));
755
+ const f = V(i, t);
756
+ return s && s(f), i;
616
757
  };
617
758
  }
618
- function ge(e, r) {
619
- return function(t) {
620
- const i = {
759
+ function xe(e, t) {
760
+ return function(n) {
761
+ const s = {
621
762
  type: "recipe",
622
- ...t
763
+ ...n
623
764
  };
624
- return i._runtime = be(i, r), Ae(i, r), r.recipes.push(i), i;
765
+ return s._runtime = Ee(s, t), Oe(s, t), t.recipes.push(s), s;
625
766
  };
626
767
  }
627
- function _(e, r) {
628
- const n = e.autogenerate(r);
629
- return Object.keys(n)[0] ?? "default";
630
- }
631
- function N(e, r) {
632
- const n = {};
633
- for (const [t, i] of Object.entries(e))
634
- if (L(i)) {
635
- const c = {};
636
- for (const [s, a] of Object.entries(i)) {
637
- const o = B(r, s);
638
- o ? c[s] = _(
639
- o,
640
- a
641
- ) : console.warn(
642
- `[styleframe] Utility "${s}" not found in registry. Skipping runtime generation for this declaration.`
768
+ function L(e, t) {
769
+ const r = e.autogenerate(t);
770
+ return Object.keys(r)[0] ?? "default";
771
+ }
772
+ function T(e, t) {
773
+ const r = {};
774
+ for (const [n, s] of Object.entries(e))
775
+ if (J(s)) {
776
+ const o = {};
777
+ for (const [i, f] of Object.entries(s)) {
778
+ const c = U(t, i);
779
+ if (!c)
780
+ throw new Error(
781
+ `[styleframe] Utility "${i}" not found in registry. Make sure the utility is registered before using it in a recipe.`
782
+ );
783
+ o[i] = L(
784
+ c,
785
+ f
643
786
  );
644
787
  }
645
- n[t] = c;
646
- } else if (typeof i == "boolean")
647
- n[t] = i;
788
+ r[Q(n)] = o;
789
+ } else if (typeof s == "boolean")
790
+ r[n] = s;
648
791
  else {
649
- const c = B(r, t);
650
- c ? n[t] = _(c, i) : console.warn(
651
- `[styleframe] Utility "${t}" not found in registry. Skipping runtime generation for this declaration.`
652
- );
792
+ const o = U(t, n);
793
+ if (!o)
794
+ throw new Error(
795
+ `[styleframe] Utility "${n}" not found in registry. Make sure the utility is registered before using it in a recipe.`
796
+ );
797
+ r[n] = L(o, s);
653
798
  }
654
- return n;
655
- }
656
- function be(e, r) {
657
- const n = {};
658
- if (e.base && (n.base = N(e.base, r)), e.variants) {
659
- const t = {};
660
- for (const [i, c] of Object.entries(e.variants)) {
661
- const s = {};
662
- for (const [a, o] of Object.entries(
663
- c
799
+ return r;
800
+ }
801
+ function Ee(e, t) {
802
+ const r = {};
803
+ if (e.base && (r.base = T(e.base, t)), e.variants) {
804
+ const n = {};
805
+ for (const [s, o] of Object.entries(e.variants)) {
806
+ const i = {};
807
+ for (const [f, c] of Object.entries(
808
+ o
664
809
  ))
665
- o == null ? s[a] = null : s[a] = N(
666
- o,
667
- r
810
+ c == null ? i[f] = null : i[f] = T(
811
+ c,
812
+ t
668
813
  );
669
- t[i] = s;
814
+ n[s] = i;
670
815
  }
671
- n.variants = t;
816
+ r.variants = n;
672
817
  }
673
- return e.defaultVariants && (n.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (n.compoundVariants = e.compoundVariants.map((t) => ({
674
- match: { ...t.match },
675
- css: N(t.css, r)
676
- }))), n;
818
+ return e.defaultVariants && (r.defaultVariants = { ...e.defaultVariants }), e.compoundVariants && (r.compoundVariants = e.compoundVariants.map((n) => ({
819
+ match: { ...n.match },
820
+ css: T(n.css, t)
821
+ }))), r;
677
822
  }
678
- function L(e) {
823
+ function J(e) {
679
824
  return !j(e) && typeof e == "object" && e !== null;
680
825
  }
681
- function x(e, r) {
682
- const n = (t, i, c) => {
683
- let s = r.get(t);
684
- s || (s = [], r.set(t, s)), s.push({ value: i, modifiers: c });
826
+ function Q(e) {
827
+ return e.startsWith("&::") ? e.slice(3) : e.startsWith("&:") ? e.slice(2) : e;
828
+ }
829
+ function C(e, t) {
830
+ const r = (n, s, o) => {
831
+ let i = t.get(n);
832
+ i || (i = [], t.set(n, i)), i.push({ value: s, modifiers: o });
685
833
  };
686
- for (const [t, i] of Object.entries(e))
687
- if (L(i)) {
688
- const c = t.split(":");
689
- for (const [s, a] of Object.entries(i))
690
- n(s, a, c);
834
+ for (const [n, s] of Object.entries(e))
835
+ if (J(s)) {
836
+ const o = Q(n).split(":");
837
+ for (const [i, f] of Object.entries(s))
838
+ r(i, f, o);
691
839
  } else
692
- n(t, i, []);
840
+ r(n, s, []);
693
841
  }
694
- function B(e, r) {
695
- const n = e.utilities.find((i) => i.name === r);
696
- if (n)
697
- return n;
698
- const t = r.replace(/[A-Z]/g, (i) => `-${i.toLowerCase()}`);
699
- return e.utilities.find((i) => i.name === t);
842
+ function U(e, t) {
843
+ const r = e.utilities.find((s) => s.name === t);
844
+ if (r)
845
+ return r;
846
+ const n = t.replace(/[A-Z]/g, (s) => `-${s.toLowerCase()}`);
847
+ return e.utilities.find((s) => s.name === n);
700
848
  }
701
- function Ae(e, r) {
702
- const n = /* @__PURE__ */ new Map();
703
- if (e.base && x(e.base, n), e.variants)
704
- for (const i of Object.values(e.variants))
705
- for (const c of Object.values(i))
706
- x(
707
- c,
708
- n
849
+ function Oe(e, t) {
850
+ const r = /* @__PURE__ */ new Map();
851
+ if (e.base && C(e.base, r), e.variants)
852
+ for (const s of Object.values(e.variants))
853
+ for (const o of Object.values(s))
854
+ C(
855
+ o,
856
+ r
709
857
  );
710
858
  if (e.compoundVariants)
711
- for (const i of e.compoundVariants)
712
- i.css && x(i.css, n);
713
- const t = /* @__PURE__ */ new Map();
714
- for (const [i, c] of n) {
715
- const s = B(r, i);
716
- if (!s) {
717
- console.warn(
718
- `[styleframe] Utility "${i}" not found in registry. Skipping.`
859
+ for (const s of e.compoundVariants)
860
+ s.css && C(s.css, r);
861
+ const n = /* @__PURE__ */ new Map();
862
+ for (const [s, o] of r) {
863
+ const i = U(t, s);
864
+ if (!i)
865
+ throw new Error(
866
+ `[styleframe] Utility "${s}" not found in registry. Make sure the utility is registered before using it in a recipe.`
719
867
  );
720
- continue;
721
- }
722
- for (const a of c) {
723
- const o = [];
724
- for (const f of a.modifiers) {
725
- if (!t.has(f))
868
+ for (const f of o) {
869
+ const c = [];
870
+ for (const a of f.modifiers) {
871
+ if (!n.has(a))
726
872
  try {
727
- t.set(f, oe(r, f));
873
+ n.set(a, de(t, a));
728
874
  } catch {
729
- console.warn(
730
- `[styleframe] Modifier "${f}" not found in registry. Skipping modifier for utility "${i}".`
731
- ), t.set(f, null);
875
+ throw new Error(
876
+ `[styleframe] Modifier "${a}" not found in registry. Make sure the modifier is registered before using it in a recipe.`
877
+ );
732
878
  }
733
- const l = t.get(f);
734
- l && o.push(l);
879
+ const l = n.get(a);
880
+ l && c.push(l);
735
881
  }
736
- s.create(
737
- [a.value],
738
- o.length > 0 ? o : void 0
882
+ i.create(
883
+ [f.value],
884
+ c.length > 0 ? c : void 0
739
885
  );
740
886
  }
741
887
  }
742
888
  }
743
- function Se(e) {
744
- const r = se("sf-"), n = de(), t = { ...e }, i = pe(n, n), c = ye(n, n), s = ge(n, n), a = he(n, n), { variable: o, selector: f, atRule: l, keyframes: u, media: y, ref: p, css: d } = v(n, n);
889
+ function We(e) {
890
+ const t = w("sf-"), r = ke(), n = { ...e }, s = $e(r, r), o = Ve(r, r), i = xe(r, r), f = Me(r, r), { variable: c, selector: a, atRule: l, keyframes: u, media: d, ref: y, css: m } = V(r, r);
745
891
  return {
746
- id: r,
747
- root: n,
748
- variable: o,
749
- selector: f,
750
- utility: i,
751
- modifier: c,
752
- recipe: s,
753
- theme: a,
892
+ id: t,
893
+ root: r,
894
+ variable: c,
895
+ selector: a,
896
+ utility: s,
897
+ modifier: o,
898
+ recipe: i,
899
+ theme: f,
754
900
  atRule: l,
755
901
  keyframes: u,
756
- media: y,
757
- ref: p,
758
- css: d,
759
- options: t
902
+ media: d,
903
+ ref: y,
904
+ css: m,
905
+ options: n
760
906
  };
761
907
  }
762
908
  export {
763
- le as applyModifiers,
764
- $e as capitalizeFirst,
765
- ue as combineKeys,
766
- K as createAtRuleFunction,
767
- J as createCssFunction,
768
- v as createDeclarationsCallbackContext,
769
- X as createKeyframesFunction,
770
- Q as createMediaFunction,
771
- ye as createModifierFunction,
772
- ge as createRecipeFunction,
773
- ee as createRefFunction,
774
- de as createRoot,
775
- te as createSelectorFunction,
776
- he as createThemeFunction,
777
- pe as createUtilityFunction,
778
- ne as createVariableFunction,
779
- F as deepClone,
780
- se as generateRandomId,
781
- be as generateRecipeRuntime,
782
- oe as getModifier,
783
- Me as getUtility,
784
- Oe as getVariable,
785
- Z as hashValue,
786
- ve as isAtRule,
787
- E as isCSS,
788
- Y as isContainer,
789
- I as isModifier,
790
- C as isObject,
791
- z as isPrimitiveTokenValue,
792
- Ve as isRecipe,
909
+ ve as applyModifiers,
910
+ Pe as capitalizeFirst,
911
+ Ke as classNameToCssSelector,
912
+ je as combineKeys,
913
+ D as createAtRuleFunction,
914
+ ae as createCssFunction,
915
+ V as createDeclarationsCallbackContext,
916
+ be as createKeyframesFunction,
917
+ ge as createMediaFunction,
918
+ Ve as createModifierFunction,
919
+ I as createPropertyValueResolver,
920
+ xe as createRecipeFunction,
921
+ X as createRefFunction,
922
+ ke as createRoot,
923
+ Ae as createSelectorFunction,
924
+ Me as createThemeFunction,
925
+ $e as createUtilityFunction,
926
+ we as createVariableFunction,
927
+ R as deepClone,
928
+ Be as defaultUtilitySelectorFn,
929
+ ce as findVariableInScope,
930
+ w as generateRandomId,
931
+ Ee as generateRecipeRuntime,
932
+ de as getModifier,
933
+ Ie as getUtility,
934
+ Ue as getVariable,
935
+ oe as hashValue,
936
+ te as isAtRule,
937
+ N as isCSS,
938
+ Ce as isContainer,
939
+ ie as isContainerInput,
940
+ se as isKeyReferenceValue,
941
+ ne as isModifier,
942
+ M as isObject,
943
+ re as isPrimitiveTokenValue,
944
+ Te as isRecipe,
793
945
  j as isRef,
794
- V as isRoot,
795
- je as isSelector,
796
- Re as isStyleframe,
797
- ke as isTheme,
798
- h as isToken,
946
+ $ as isRoot,
947
+ Fe as isSelector,
948
+ Ne as isStyleframe,
949
+ Se as isTheme,
950
+ b as isToken,
799
951
  S as isTokenEqual,
800
- D as isTokenValue,
801
- we as isUtility,
952
+ B as isTokenValue,
953
+ _e as isUtility,
802
954
  G as isVariable,
803
- Fe as merge,
804
- W as mergeContainers,
805
- ae as mergeThemesArray,
806
- fe as mergeVariablesArray,
807
- R as parseDeclarationsBlock,
808
- Ae as processRecipeUtilities,
809
- re as rfdc,
810
- Se as styleframe,
811
- P as transformUtilityKey
955
+ De as merge,
956
+ Z as mergeContainers,
957
+ pe as mergeThemesArray,
958
+ me as mergeVariablesArray,
959
+ z as parseAtReferences,
960
+ x as parseDeclarationsBlock,
961
+ Oe as processRecipeUtilities,
962
+ he as rebuildRegistry,
963
+ ue as rfdc,
964
+ We as styleframe,
965
+ q as transformUtilityKey,
966
+ fe as validateReference
812
967
  };