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