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