@styleframe/loader 1.0.3 → 2.0.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.
package/dist/index.cjs CHANGED
@@ -1,165 +1,165 @@
1
1
  (function(global, factory) {
2
- typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("node:fs/promises"), require("node:path"), require("c12")) : typeof define === "function" && define.amd ? define(["exports", "node:fs/promises", "node:path", "c12"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.loader = {}, global.promises, global.path, global.c12));
3
- })(this, (function(exports2, promises, path, c12) {
2
+ typeof exports === "object" && typeof module !== "undefined" ? factory(exports, require("node:fs/promises"), require("node:path"), require("@styleframe/license"), require("c12")) : typeof define === "function" && define.amd ? define(["exports", "node:fs/promises", "node:path", "@styleframe/license", "c12"], factory) : (global = typeof globalThis !== "undefined" ? globalThis : global || self, factory(global.loader = {}, global.promises, global.path, global.license, global.c12));
3
+ })(this, (function(exports2, promises, path, license, c12) {
4
4
  "use strict";
5
- const N$1 = ["charset", "import", "namespace"], E$1 = ["layer"], V$1 = ({ name: e }) => `[data-theme="${e}"]`, _$1 = ({
5
+ const N = ["charset", "import", "namespace"], R$1 = ["layer"], D$1 = ({ name: e }) => `[data-theme="${e}"]`, I = ({
6
6
  name: e,
7
7
  value: t,
8
- modifiers: s
9
- }) => `._${[...s, e, t].filter(Boolean).join("\\:")}`, O$1 = ({ name: e }) => e;
10
- function D$1(e, t) {
8
+ modifiers: r
9
+ }) => `._${[...r, e, t].filter(Boolean).join("\\:")}`, w = ({ name: e }) => e;
10
+ function L(e, t) {
11
11
  return `@${e}${t ? " " : ""}${t}`;
12
12
  }
13
- const B$1 = /\d/, L$1 = ["-", "_", "/", "."];
14
- function M$1(e = "") {
15
- if (!B$1.test(e))
13
+ const P$1 = /\d/, M$1 = ["-", "_", "/", "."];
14
+ function $$1(e = "") {
15
+ if (!P$1.test(e))
16
16
  return e !== e.toLowerCase();
17
17
  }
18
- function U(e, t) {
19
- const s = L$1, r = [];
18
+ function U$1(e, t) {
19
+ const r = M$1, n = [];
20
20
  if (!e || typeof e != "string")
21
- return r;
22
- let c = "", l, u;
23
- for (const i of e) {
24
- const n = s.includes(i);
25
- if (n === true) {
26
- r.push(c), c = "", l = void 0;
21
+ return n;
22
+ let u = "", a, i;
23
+ for (const s of e) {
24
+ const o = r.includes(s);
25
+ if (o === true) {
26
+ n.push(u), u = "", a = void 0;
27
27
  continue;
28
28
  }
29
- const o = M$1(i);
30
- if (u === false) {
31
- if (l === false && o === true) {
32
- r.push(c), c = i, l = o;
29
+ const c = $$1(s);
30
+ if (i === false) {
31
+ if (a === false && c === true) {
32
+ n.push(u), u = s, a = c;
33
33
  continue;
34
34
  }
35
- if (l === true && o === false && c.length > 1) {
36
- const f = c.at(-1);
37
- r.push(c.slice(0, Math.max(0, c.length - 1))), c = f + i, l = o;
35
+ if (a === true && c === false && u.length > 1) {
36
+ const f = u.at(-1);
37
+ n.push(u.slice(0, Math.max(0, u.length - 1))), u = f + s, a = c;
38
38
  continue;
39
39
  }
40
40
  }
41
- c += i, l = o, u = n;
41
+ u += s, a = c, i = o;
42
42
  }
43
- return r.push(c), r;
43
+ return n.push(u), n;
44
44
  }
45
- function P(e, t) {
46
- return e ? (Array.isArray(e) ? e : U(e)).map((s) => s.toLowerCase()).join("-") : "";
45
+ function _$1(e, t) {
46
+ return e ? (Array.isArray(e) ? e : U$1(e)).map((r) => r.toLowerCase()).join("-") : "";
47
47
  }
48
48
  function k$1(e) {
49
49
  return ` ${e}`;
50
50
  }
51
- function x(e) {
51
+ function V(e) {
52
52
  return e.split(`
53
53
  `).map((t) => k$1(t)).join(`
54
54
  `);
55
55
  }
56
- function z$1(e) {
57
- return P(e);
56
+ function x(e) {
57
+ return _$1(e);
58
58
  }
59
- function H$1(e) {
60
- return z$1(e);
59
+ function K$1(e) {
60
+ return x(e);
61
61
  }
62
- function T$1(e, t) {
63
- return `${e.startsWith("--") ? e : H$1(e)}: ${t};`;
62
+ function B$1(e, t) {
63
+ return `${e.startsWith("--") ? e : K$1(e)}: ${t};`;
64
64
  }
65
- function I$1(e) {
65
+ function q$1(e) {
66
66
  return `{${e.length > 0 ? `
67
- ` : ""}${e.map((t) => `${x(`${t}`)}
67
+ ` : ""}${e.map((t) => `${V(`${t}`)}
68
68
  `).join("")}}`;
69
69
  }
70
- function $$1(e) {
70
+ function O$1(e) {
71
71
  return `--${(e.startsWith("--") ? e.slice(2) : e).replace(/[^a-zA-Z0-9_\-\u0080-\uFFFF]/g, "-") || "unknown-variable"}`;
72
72
  }
73
- function K$1(e, t) {
74
- return T$1($$1(e), t);
73
+ function z$1(e, t) {
74
+ return B$1(O$1(e), t);
75
75
  }
76
- function Q(e, t) {
77
- return `var(${$$1(e)}${t ? `, ${t}` : ""})`;
76
+ function H$1(e, t) {
77
+ return `var(${O$1(e)}${t ? `, ${t}` : ""})`;
78
78
  }
79
79
  function C$1(e, t) {
80
- return `${e} ${I$1(t)}`;
80
+ return `${e} ${q$1(t)}`;
81
81
  }
82
- function W$1(e) {
83
- return function(s, r) {
84
- return Object.entries(s).map(([c, l]) => T$1(c, e(l, r)));
82
+ function Q$1(e) {
83
+ return function(r, n) {
84
+ return Object.entries(r).map(([u, a]) => B$1(u, e(a, n)));
85
85
  };
86
86
  }
87
- function w$1(e) {
88
- return function(s, r) {
89
- const l = (r.variables?.name ?? O$1)({ name: s.name });
90
- return K$1(l, e(s.value, r));
87
+ function E$1(e) {
88
+ return function(r, n) {
89
+ const a = (n.variables?.name ?? w)({ name: r.name });
90
+ return z$1(a, e(r.value, n));
91
91
  };
92
92
  }
93
- function A(e) {
94
- const t = w$1(e), s = W$1(e);
95
- return function(c, l, u) {
96
- const { variables: i, declarations: n, children: o } = l, f = c === ":root", a = (i ?? []).map(
97
- (g2) => t(g2, u)
98
- ), m2 = s(
99
- n ?? {},
100
- u
101
- ), b2 = (o ?? []).map(
102
- (g2) => e(g2, u)
103
- ), p2 = a.length > 0, h = m2.length > 0, S2 = b2.length > 0;
104
- return f ? `${p2 || h ? C$1(c, [
105
- ...a,
106
- ...p2 && h ? [""] : [],
93
+ function S$1(e) {
94
+ const t = E$1(e), r = Q$1(e);
95
+ return function(u, a, i) {
96
+ const { variables: s, declarations: o, children: c } = a, f = u === ":root", l = (s ?? []).map(
97
+ (A2) => t(A2, i)
98
+ ), m2 = r(
99
+ o ?? {},
100
+ i
101
+ ), y = (c ?? []).map(
102
+ (A2) => e(A2, i)
103
+ ), d = l.length > 0, h = m2.length > 0, v = y.length > 0;
104
+ return f ? `${d || h ? C$1(u, [
105
+ ...l,
106
+ ...d && h ? [""] : [],
107
107
  ...m2
108
- ]) : ""}${S2 && (p2 || h) ? `
108
+ ]) : ""}${v && (d || h) ? `
109
109
 
110
- ` : ""}${b2.join(`
110
+ ` : ""}${y.join(`
111
111
 
112
- `)}` : C$1(c, [
113
- ...a,
114
- ...p2 && (S2 || h) ? [""] : [],
112
+ `)}` : C$1(u, [
113
+ ...l,
114
+ ...d && (v || h) ? [""] : [],
115
115
  ...m2,
116
- ...h && S2 ? [""] : [],
117
- ...b2.flatMap(
118
- (g2, F2) => F2 === b2.length - 1 ? [g2] : [g2, ""]
116
+ ...h && v ? [""] : [],
117
+ ...y.flatMap(
118
+ (A2, F2) => F2 === y.length - 1 ? [A2] : [A2, ""]
119
119
  )
120
120
  ]);
121
121
  };
122
122
  }
123
123
  function Z(e) {
124
- const t = A(e);
125
- return function(r, c) {
126
- const l = N$1.includes(r.identifier), u = E$1.includes(
127
- r.identifier
128
- ), i = Object.keys(r.declarations).length > 0, n = r.variables.length > 0, o = r.children.length > 0, f = D$1(r.identifier, r.rule);
129
- return l || u && !(i || n || o) ? `${f};` : t(f, r, c);
124
+ const t = S$1(e);
125
+ return function(n, u) {
126
+ const a = N.includes(n.identifier), i = R$1.includes(
127
+ n.identifier
128
+ ), s = Object.keys(n.declarations).length > 0, o = n.variables.length > 0, c = n.children.length > 0, f = L(n.identifier, n.rule);
129
+ return a || i && !(s || o || c) ? `${f};` : t(f, n, u);
130
130
  };
131
131
  }
132
- function q$1(e) {
132
+ function W$1(e) {
133
133
  return typeof e == "object" && e !== null;
134
134
  }
135
- function d(e, t) {
136
- return q$1(e) && "type" in e && e.type === t;
135
+ function b$1(e, t) {
136
+ return W$1(e) && "type" in e && e.type === t;
137
137
  }
138
- function G(e) {
139
- return d(e, "variable");
138
+ function J$1(e) {
139
+ return b$1(e, "variable");
140
140
  }
141
- function J(e) {
142
- return d(e, "reference");
141
+ function G$1(e) {
142
+ return b$1(e, "reference");
143
143
  }
144
144
  function Y$1(e) {
145
- return d(e, "selector");
145
+ return b$1(e, "selector");
146
146
  }
147
- function X(e) {
148
- return d(e, "at-rule");
147
+ function X$1(e) {
148
+ return b$1(e, "at-rule");
149
149
  }
150
150
  function ee(e) {
151
- return d(e, "utility");
151
+ return b$1(e, "utility");
152
152
  }
153
153
  function te(e) {
154
- return d(e, "css");
155
- }
156
- function re(e) {
157
- return d(e, "theme");
154
+ return b$1(e, "css");
158
155
  }
159
156
  function ne(e) {
160
- return d(e, "root");
157
+ return b$1(e, "theme");
161
158
  }
162
- function j$1(e) {
159
+ function re(e) {
160
+ return b$1(e, "root");
161
+ }
162
+ function g$1(e) {
163
163
  if (e instanceof Buffer)
164
164
  return Buffer.from(e);
165
165
  const t = e.constructor;
@@ -169,157 +169,157 @@
169
169
  e.byteLength / e.BYTES_PER_ELEMENT || 1
170
170
  );
171
171
  }
172
- function oe$1(e) {
172
+ function oe(e) {
173
173
  if (e = e || {}, e.circular)
174
- return ue(e);
174
+ return ce(e);
175
175
  const t = /* @__PURE__ */ new Map();
176
- if (t.set(Date, (u) => new Date(u)), t.set(
176
+ if (t.set(Date, (i) => new Date(i)), t.set(
177
177
  Map,
178
- (u, i) => new Map(r(Array.from(u), i))
178
+ (i, s) => new Map(n(Array.from(i), s))
179
179
  ), t.set(
180
180
  Set,
181
- (u, i) => new Set(r(Array.from(u), i))
181
+ (i, s) => new Set(n(Array.from(i), s))
182
182
  ), e.constructorHandlers)
183
- for (const u of e.constructorHandlers)
184
- t.set(u[0], u[1]);
185
- let s;
186
- return e.proto ? l : c;
187
- function r(u, i) {
188
- const n = Object.keys(u), o = Array.from({ length: n.length });
189
- for (let f = 0; f < n.length; f++) {
190
- const a = n[f], m2 = u[a];
191
- typeof m2 != "object" || m2 === null ? o[a] = m2 : m2.constructor !== Object && (s = t.get(m2.constructor)) ? o[a] = s(m2, i) : ArrayBuffer.isView(m2) ? o[a] = j$1(m2) : o[a] = i(m2);
183
+ for (const i of e.constructorHandlers)
184
+ t.set(i[0], i[1]);
185
+ let r;
186
+ return e.proto ? a : u;
187
+ function n(i, s) {
188
+ const o = Object.keys(i), c = Array.from({ length: o.length });
189
+ for (let f = 0; f < o.length; f++) {
190
+ const l = o[f], m2 = i[l];
191
+ typeof m2 != "object" || m2 === null ? c[l] = m2 : m2.constructor !== Object && (r = t.get(m2.constructor)) ? c[l] = r(m2, s) : ArrayBuffer.isView(m2) ? c[l] = g$1(m2) : c[l] = s(m2);
192
192
  }
193
- return o;
193
+ return c;
194
194
  }
195
- function c(u) {
196
- if (typeof u != "object" || u === null) return u;
197
- if (Array.isArray(u)) return r(u, c);
198
- if (u.constructor !== Object && (s = t.get(u.constructor)))
199
- return s(u, c);
200
- const i = {};
201
- for (const n in u) {
202
- if (Object.hasOwnProperty.call(u, n) === false) continue;
203
- const o = u[n];
204
- typeof o != "object" || o === null ? i[n] = o : o.constructor !== Object && (s = t.get(o.constructor)) ? i[n] = s(o, c) : ArrayBuffer.isView(o) ? i[n] = j$1(o) : i[n] = c(o);
195
+ function u(i) {
196
+ if (typeof i != "object" || i === null) return i;
197
+ if (Array.isArray(i)) return n(i, u);
198
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
199
+ return r(i, u);
200
+ const s = {};
201
+ for (const o in i) {
202
+ if (Object.hasOwnProperty.call(i, o) === false) continue;
203
+ const c = i[o];
204
+ typeof c != "object" || c === null ? s[o] = c : c.constructor !== Object && (r = t.get(c.constructor)) ? s[o] = r(c, u) : ArrayBuffer.isView(c) ? s[o] = g$1(c) : s[o] = u(c);
205
205
  }
206
- return i;
206
+ return s;
207
207
  }
208
- function l(u) {
209
- if (typeof u != "object" || u === null) return u;
210
- if (Array.isArray(u)) return r(u, l);
211
- if (u.constructor !== Object && (s = t.get(u.constructor)))
212
- return s(u, l);
213
- const i = {};
214
- for (const n in u) {
215
- const o = u[n];
216
- typeof o != "object" || o === null ? i[n] = o : o.constructor !== Object && (s = t.get(o.constructor)) ? i[n] = s(o, l) : ArrayBuffer.isView(o) ? i[n] = j$1(o) : i[n] = l(o);
208
+ function a(i) {
209
+ if (typeof i != "object" || i === null) return i;
210
+ if (Array.isArray(i)) return n(i, a);
211
+ if (i.constructor !== Object && (r = t.get(i.constructor)))
212
+ return r(i, a);
213
+ const s = {};
214
+ for (const o in i) {
215
+ const c = i[o];
216
+ typeof c != "object" || c === null ? s[o] = c : c.constructor !== Object && (r = t.get(c.constructor)) ? s[o] = r(c, a) : ArrayBuffer.isView(c) ? s[o] = g$1(c) : s[o] = a(c);
217
217
  }
218
- return i;
218
+ return s;
219
219
  }
220
220
  }
221
- function ue(e) {
222
- const t = [], s = [], r = /* @__PURE__ */ new Map();
223
- if (r.set(Date, (n) => new Date(n)), r.set(
221
+ function ce(e) {
222
+ const t = [], r = [], n = /* @__PURE__ */ new Map();
223
+ if (n.set(Date, (o) => new Date(o)), n.set(
224
224
  Map,
225
- (n, o) => new Map(l(Array.from(n), o))
226
- ), r.set(
225
+ (o, c) => new Map(a(Array.from(o), c))
226
+ ), n.set(
227
227
  Set,
228
- (n, o) => new Set(l(Array.from(n), o))
228
+ (o, c) => new Set(a(Array.from(o), c))
229
229
  ), e.constructorHandlers)
230
- for (const n of e.constructorHandlers)
231
- r.set(n[0], n[1]);
232
- let c;
233
- return e.proto ? i : u;
234
- function l(n, o) {
235
- const f = Object.keys(n), a = Array.from({ length: f.length });
230
+ for (const o of e.constructorHandlers)
231
+ n.set(o[0], o[1]);
232
+ let u;
233
+ return e.proto ? s : i;
234
+ function a(o, c) {
235
+ const f = Object.keys(o), l = Array.from({ length: f.length });
236
236
  for (let m2 = 0; m2 < f.length; m2++) {
237
- const b2 = f[m2], p2 = n[b2];
238
- if (typeof p2 != "object" || p2 === null)
239
- a[b2] = p2;
240
- else if (p2.constructor !== Object && (c = r.get(p2.constructor)))
241
- a[b2] = c(p2, o);
242
- else if (ArrayBuffer.isView(p2))
243
- a[b2] = j$1(p2);
237
+ const y = f[m2], d = o[y];
238
+ if (typeof d != "object" || d === null)
239
+ l[y] = d;
240
+ else if (d.constructor !== Object && (u = n.get(d.constructor)))
241
+ l[y] = u(d, c);
242
+ else if (ArrayBuffer.isView(d))
243
+ l[y] = g$1(d);
244
244
  else {
245
- const h = t.indexOf(p2);
246
- h !== -1 ? a[b2] = s[h] : a[b2] = o(p2);
245
+ const h = t.indexOf(d);
246
+ h !== -1 ? l[y] = r[h] : l[y] = c(d);
247
247
  }
248
248
  }
249
- return a;
249
+ return l;
250
250
  }
251
- function u(n) {
252
- if (typeof n != "object" || n === null) return n;
253
- if (Array.isArray(n)) return l(n, u);
254
- if (n.constructor !== Object && (c = r.get(n.constructor)))
255
- return c(n, u);
256
- const o = {};
257
- t.push(n), s.push(o);
258
- for (const f in n) {
259
- if (Object.hasOwnProperty.call(n, f) === false) continue;
260
- const a = n[f];
261
- if (typeof a != "object" || a === null)
262
- o[f] = a;
263
- else if (a.constructor !== Object && (c = r.get(a.constructor)))
264
- o[f] = c(a, u);
265
- else if (ArrayBuffer.isView(a))
266
- o[f] = j$1(a);
251
+ function i(o) {
252
+ if (typeof o != "object" || o === null) return o;
253
+ if (Array.isArray(o)) return a(o, i);
254
+ if (o.constructor !== Object && (u = n.get(o.constructor)))
255
+ return u(o, i);
256
+ const c = {};
257
+ t.push(o), r.push(c);
258
+ for (const f in o) {
259
+ if (Object.hasOwnProperty.call(o, f) === false) continue;
260
+ const l = o[f];
261
+ if (typeof l != "object" || l === null)
262
+ c[f] = l;
263
+ else if (l.constructor !== Object && (u = n.get(l.constructor)))
264
+ c[f] = u(l, i);
265
+ else if (ArrayBuffer.isView(l))
266
+ c[f] = g$1(l);
267
267
  else {
268
- const m2 = t.indexOf(a);
269
- m2 !== -1 ? o[f] = s[m2] : o[f] = u(a);
268
+ const m2 = t.indexOf(l);
269
+ m2 !== -1 ? c[f] = r[m2] : c[f] = i(l);
270
270
  }
271
271
  }
272
- return t.pop(), s.pop(), o;
272
+ return t.pop(), r.pop(), c;
273
273
  }
274
- function i(n) {
275
- if (typeof n != "object" || n === null) return n;
276
- if (Array.isArray(n)) return l(n, i);
277
- if (n.constructor !== Object && (c = r.get(n.constructor)))
278
- return c(n, i);
279
- const o = {};
280
- t.push(n), s.push(o);
281
- for (const f in n) {
282
- const a = n[f];
283
- if (typeof a != "object" || a === null)
284
- o[f] = a;
285
- else if (a.constructor !== Object && (c = r.get(a.constructor)))
286
- o[f] = c(a, i);
287
- else if (ArrayBuffer.isView(a))
288
- o[f] = j$1(a);
274
+ function s(o) {
275
+ if (typeof o != "object" || o === null) return o;
276
+ if (Array.isArray(o)) return a(o, s);
277
+ if (o.constructor !== Object && (u = n.get(o.constructor)))
278
+ return u(o, s);
279
+ const c = {};
280
+ t.push(o), r.push(c);
281
+ for (const f in o) {
282
+ const l = o[f];
283
+ if (typeof l != "object" || l === null)
284
+ c[f] = l;
285
+ else if (l.constructor !== Object && (u = n.get(l.constructor)))
286
+ c[f] = u(l, s);
287
+ else if (ArrayBuffer.isView(l))
288
+ c[f] = g$1(l);
289
289
  else {
290
- const m2 = t.indexOf(a);
291
- m2 !== -1 ? o[f] = s[m2] : o[f] = i(a);
290
+ const m2 = t.indexOf(l);
291
+ m2 !== -1 ? c[f] = r[m2] : c[f] = s(l);
292
292
  }
293
293
  }
294
- return t.pop(), s.pop(), o;
294
+ return t.pop(), r.pop(), c;
295
295
  }
296
296
  }
297
- oe$1();
298
- function ce(e) {
299
- return function(s, r) {
300
- return s.value.map((c) => e(c, r)).join("").trim();
297
+ oe();
298
+ function ue$1(e) {
299
+ return function(r, n) {
300
+ return r.value.map((u) => e(u, n)).join("").trim();
301
301
  };
302
302
  }
303
- function se(e) {
304
- return function(s, r) {
305
- return s != null ? `${s}` : "";
303
+ function ie(e) {
304
+ return function(r, n) {
305
+ return r != null ? `${r}` : "";
306
306
  };
307
307
  }
308
- function ie(e) {
309
- return function(s, r) {
310
- const l = (r.variables?.name ?? O$1)({ name: s.name });
311
- return Q(
312
- l,
313
- s.fallback ? e(s.fallback, r) : void 0
308
+ function se(e) {
309
+ return function(r, n) {
310
+ const a = (n.variables?.name ?? w)({ name: r.name });
311
+ return H$1(
312
+ a,
313
+ r.fallback ? e(r.fallback, n) : void 0
314
314
  );
315
315
  };
316
316
  }
317
317
  function ae(e) {
318
- const t = A(e);
319
- return function(r, c) {
320
- return r.themes.reduce(
321
- (l, u) => (l.push(e(u, c)), l),
322
- [t(":root", r, c)]
318
+ const t = S$1(e);
319
+ return function(n, u) {
320
+ return n.themes.reduce(
321
+ (a, i) => (a.push(e(i, u)), a),
322
+ [t(":root", n, u)]
323
323
  // Default theme (root)
324
324
  ).join(`
325
325
 
@@ -327,58 +327,58 @@
327
327
  };
328
328
  }
329
329
  function le(e) {
330
- const t = A(e);
331
- return function(r, c) {
332
- return t(r.query, r, c);
330
+ const t = S$1(e);
331
+ return function(n, u) {
332
+ return t(n.query, n, u);
333
333
  };
334
334
  }
335
335
  function fe(e) {
336
- const t = A(e);
337
- return function(r, c) {
338
- const u = (c.theme?.selector ?? V$1)({ name: r.name });
339
- return t(u, r, c);
336
+ const t = S$1(e);
337
+ return function(n, u) {
338
+ const i = (u.theme?.selector ?? D$1)({ name: n.name });
339
+ return t(i, n, u);
340
340
  };
341
341
  }
342
342
  function me(e) {
343
- const t = A(e);
344
- return function(r, c) {
345
- const l = [], i = (c.utilities?.selector ?? _$1)({
346
- name: r.name,
347
- value: r.value,
348
- modifiers: r.modifiers
343
+ const t = S$1(e);
344
+ return function(n, u) {
345
+ const a = [], s = (u.utilities?.selector ?? I)({
346
+ name: n.name,
347
+ value: n.value,
348
+ modifiers: n.modifiers
349
349
  });
350
- return l.push(t(i, r, c)), l.join(`
350
+ return a.push(t(s, n, u)), a.join(`
351
351
 
352
352
  `);
353
353
  };
354
354
  }
355
- function y(e, t) {
356
- const s = ae(y), r = le(y), c = me(y), l = Z(y), u = fe(y), i = w$1(y), n = ie(y), o = ce(y), f = se();
355
+ function p$1(e, t) {
356
+ const r = ae(p$1), n = le(p$1), u = me(p$1), a = Z(p$1), i = fe(p$1), s = E$1(p$1), o = se(p$1), c = ue$1(p$1), f = ie();
357
357
  switch (true) {
358
358
  case Y$1(e):
359
- return r(e, t);
359
+ return n(e, t);
360
360
  case ee(e):
361
- return c(e, t);
362
- case X(e):
363
- return l(e, t);
364
- case ne(e):
365
- return s(e, t);
366
- case re(e):
367
361
  return u(e, t);
368
- case G(e):
362
+ case X$1(e):
363
+ return a(e, t);
364
+ case re(e):
365
+ return r(e, t);
366
+ case ne(e):
369
367
  return i(e, t);
370
- case J(e):
371
- return n(e, t);
372
- case te(e):
368
+ case J$1(e):
369
+ return s(e, t);
370
+ case G$1(e):
373
371
  return o(e, t);
372
+ case te(e):
373
+ return c(e, t);
374
374
  default:
375
375
  return f(e, t);
376
376
  }
377
377
  }
378
- function R$1(e, t) {
378
+ function T$1(e, t) {
379
379
  switch (true) {
380
380
  case Array.isArray(e):
381
- return e.map((s) => R$1(s)).join(`
381
+ return e.map((r) => T$1(r)).join(`
382
382
  `);
383
383
  // case isRecipe(instance):
384
384
  // return consumeRecipe(instance, options);
@@ -387,26 +387,132 @@
387
387
  return "";
388
388
  }
389
389
  }
390
- function v(e, t = "") {
390
+ const de = `-----BEGIN PUBLIC KEY-----
391
+ MIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAs7zAFssgxOMPeo80iig4
392
+ qSSshgNOLnW1gd4tPUrsezndaUrAKlsAys6XD8kuF+bBEIR0uFNSgKlqINLjWM1n
393
+ BiTUzCctodyRaq6/tyFSoPLD35iblkwtfxKPM42lAJZsyTu9qoBr8MJyXmhDLuqA
394
+ dQ8di7mQHz+mCy96jQR4lFSDfHMgl27qaAh5VboTBRxgZliN8D5Fl590QkS94wAj
395
+ hC7NbH+hPcGc/qIaZSjZfyZeBIZS74qJkrzjEA7/pukROD8UQUrQ512HHZ6XlgMn
396
+ 4bWT2K9CpWbbhsKFTecCHuxlmPkFJNMuvAb/LdP08BSnpntlyAJcQeBrna2qBen+
397
+ GwIDAQAB
398
+ -----END PUBLIC KEY-----`, ye = "__licenseRequired", pe = "__licenseValidated";
399
+ async function he(e) {
400
+ const t = e.replace(/-----BEGIN PUBLIC KEY-----/, "").replace(/-----END PUBLIC KEY-----/, "").replace(/\s/g, ""), r = Uint8Array.from(atob(t), (n) => n.charCodeAt(0));
401
+ return await crypto.subtle.importKey(
402
+ "spki",
403
+ r,
404
+ {
405
+ name: "RSASSA-PKCS1-v1_5",
406
+ hash: "SHA-256"
407
+ },
408
+ true,
409
+ ["verify"]
410
+ );
411
+ }
412
+ async function be({
413
+ payload: e,
414
+ signature: t
415
+ }) {
416
+ const r = new TextEncoder().encode(e), n = Uint8Array.from(
417
+ atob(t),
418
+ (a) => a.charCodeAt(0)
419
+ ), u = await he(de);
420
+ if (!await crypto.subtle.verify(
421
+ { name: "RSASSA-PKCS1-v1_5" },
422
+ u,
423
+ n,
424
+ r
425
+ ))
426
+ throw new Error(
427
+ "License validation failed: Invalid signature detected. The license may have been modified or corrupted."
428
+ );
429
+ return JSON.parse(e);
430
+ }
431
+ function Ae(e) {
432
+ return Object.prototype.hasOwnProperty.call(e, ye);
433
+ }
434
+ async function ge(e) {
435
+ const t = Object.getOwnPropertyDescriptor(
436
+ e,
437
+ pe
438
+ );
439
+ if (!t?.value)
440
+ return {
441
+ key: "",
442
+ instanceId: "",
443
+ environment: "",
444
+ valid: false
445
+ };
446
+ const r = t.value;
447
+ if (typeof r != "object" || r === null || !("payload" in r) || !("signature" in r) || typeof r.payload != "string" || typeof r.signature != "string")
448
+ return {
449
+ key: "",
450
+ instanceId: "",
451
+ environment: "",
452
+ valid: false
453
+ };
454
+ try {
455
+ return await be(
456
+ r
457
+ );
458
+ } catch {
459
+ return {
460
+ key: "",
461
+ instanceId: "",
462
+ environment: "",
463
+ valid: false
464
+ };
465
+ }
466
+ }
467
+ function Se(e) {
468
+ const t = Math.floor(Math.random() * 100);
469
+ e.root.children.push({
470
+ type: "selector",
471
+ query: `html:nth-of-type(${t}n+1)::after`,
472
+ variables: [],
473
+ children: [],
474
+ declarations: {
475
+ content: '"Styleframe Pro: Development Mode – License required for production use"',
476
+ zIndex: 99999,
477
+ position: "fixed",
478
+ display: "block !important",
479
+ opacity: "1 !important",
480
+ bottom: 0,
481
+ left: 0,
482
+ background: "rgba(0, 0, 0, 0.5)",
483
+ color: "white",
484
+ fontSize: "12px",
485
+ lineHeight: "1",
486
+ padding: "0.5rem",
487
+ fontFamily: "sans-serif"
488
+ }
489
+ });
490
+ }
491
+ function j(e, t = "") {
391
492
  return {
392
493
  name: e,
393
494
  content: t
394
495
  };
395
496
  }
396
- function be(e, {
497
+ async function Ce(e, {
397
498
  type: t = "all",
398
- consumers: s = { css: y, ts: R$1 }
499
+ consumers: r = { css: p$1, ts: T$1 }
399
500
  } = {}) {
400
- const r = { files: [] }, c = e.options, { recipes: l, ...u } = e.root;
501
+ const n = { files: [] }, u = e.options;
502
+ if (Ae(e)) {
503
+ const s = await ge(e);
504
+ (!s.valid || s.instanceId !== e.id) && Se(e);
505
+ }
506
+ const { recipes: a, ...i } = e.root;
401
507
  if (t === "all" || t === "css") {
402
- const i = v("index.css", s.css(u, c));
403
- r.files.push(i);
508
+ const s = j("index.css", r.css(i, u));
509
+ n.files.push(s);
404
510
  }
405
511
  if (t === "all" || t === "ts") {
406
- const i = v("index.ts", s.ts([], c));
407
- r.files.push(i);
512
+ const s = j("index.ts", r.ts([], u));
513
+ n.files.push(s);
408
514
  }
409
- return r;
515
+ return console.log(n.files), n;
410
516
  }
411
517
  async function directoryExists(path2) {
412
518
  try {
@@ -417,7 +523,12 @@
417
523
  }
418
524
  }
419
525
  async function build(instance, { clean = true, outputDir = "./styleframe", transpiler } = {}) {
420
- const output = be(instance, transpiler);
526
+ await license.validateInstanceLicense(instance, {
527
+ licenseKey: license.getLicenseKeyFromEnv() || "",
528
+ environment: process.env.NODE_ENV || "development",
529
+ isBuild: true
530
+ });
531
+ const output = await Ce(instance, transpiler);
421
532
  const outputDirExists = await directoryExists(outputDir);
422
533
  if (clean && outputDirExists) {
423
534
  await promises.rm(outputDir, { recursive: true });
@@ -432,310 +543,319 @@
432
543
  await promises.writeFile(filePath, file.content);
433
544
  }
434
545
  }
435
- function M(e, t) {
436
- return function(n, ...o) {
546
+ function k(e, r) {
547
+ return function(t, ...i) {
437
548
  return {
438
549
  type: "css",
439
- value: n.reduce((i, u, c) => (i.push(u), c < o.length && i.push(o[c]), i), [])
550
+ value: t.reduce((o, u, c) => (o.push(u), c < i.length && o.push(i[c]), o), [])
440
551
  };
441
552
  };
442
553
  }
443
- function V(e) {
554
+ function M(e) {
444
555
  return typeof e == "object" && e !== null;
445
556
  }
446
- function p(e, t) {
447
- return V(e) && "type" in e && e.type === t;
557
+ function p(e, r) {
558
+ return M(e) && "type" in e && e.type === r;
448
559
  }
449
- function k(e) {
560
+ function B(e) {
450
561
  return p(e, "variable");
451
562
  }
452
- function O(e) {
563
+ function F(e) {
453
564
  return p(e, "reference");
454
565
  }
455
- function B(e) {
566
+ function T(e) {
456
567
  return p(e, "css");
457
568
  }
458
- function F(e) {
569
+ function _(e) {
459
570
  return typeof e == "string" || typeof e == "number" || typeof e == "boolean" || e === null;
460
571
  }
461
- function R(e) {
462
- return F(e) || O(e) || B(e) || Array.isArray(e) && e.every(R);
572
+ function O(e) {
573
+ return _(e) || F(e) || T(e) || Array.isArray(e) && e.every(O);
463
574
  }
464
- function T(e) {
465
- return V(e) && "children" in e && "declarations" in e && "variables" in e;
575
+ function C(e) {
576
+ return M(e) && "children" in e && "declarations" in e && "variables" in e;
466
577
  }
467
- function w(e, t) {
468
- return function(n, o, s) {
469
- const i = {
578
+ function R(e, r) {
579
+ return function(t, i, s) {
580
+ const o = {
470
581
  type: "at-rule",
471
- identifier: n,
472
- rule: o,
582
+ identifier: t,
583
+ rule: i,
473
584
  declarations: {},
474
585
  variables: [],
475
586
  children: []
476
- }, u = b(i, t);
477
- return typeof s == "function" ? i.declarations = s(u) ?? {} : s && (i.declarations = s), g(i.declarations, u), e.children.push(i), i;
587
+ }, u = b(o, r);
588
+ return typeof s == "function" ? o.declarations = s(u) ?? {} : s && (o.declarations = s), g(o.declarations, u), e.children.push(o), o;
478
589
  };
479
590
  }
480
- function C(e, t) {
481
- const r = w(e, t);
482
- return function(o, s) {
483
- return r("media", o, s);
591
+ function S(e, r) {
592
+ const n = R(e, r);
593
+ return function(i, s) {
594
+ return n("media", i, s);
484
595
  };
485
596
  }
486
- function _(e, t) {
487
- const r = w(e, t);
488
- return function(o, s) {
489
- return r("keyframes", o, s);
597
+ function E(e, r) {
598
+ const n = R(e, r);
599
+ return function(i, s) {
600
+ return n("keyframes", i, s);
490
601
  };
491
602
  }
492
- function S(e, t) {
493
- return function(n, o) {
494
- return k(n) ? {
603
+ function P(e, r) {
604
+ return function(t, i) {
605
+ return B(t) ? {
495
606
  type: "reference",
496
- name: n.name,
497
- fallback: o
607
+ name: t.name,
608
+ fallback: i
498
609
  } : {
499
610
  type: "reference",
500
- name: n,
501
- fallback: o
611
+ name: t,
612
+ fallback: i
502
613
  };
503
614
  };
504
615
  }
505
- function E(e, t) {
506
- return function(n, o) {
616
+ function D(e, r) {
617
+ return function(t, i) {
507
618
  const s = {
508
619
  type: "selector",
509
- query: n,
620
+ query: t,
510
621
  declarations: {},
511
622
  variables: [],
512
623
  children: []
513
- }, i = b(s, t);
514
- return typeof o == "function" ? s.declarations = o(i) ?? {} : T(o) ? (s.variables = o.variables, s.declarations = o.declarations, s.children = o.children) : s.declarations = o, g(s.declarations, i), e.children.push(s), s;
624
+ }, o = b(s, r);
625
+ 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;
515
626
  };
516
627
  }
517
- function D(e, t) {
518
- return function(n, o, s = {
628
+ function H(e, r) {
629
+ return function(t, i, s = {
519
630
  default: false
520
631
  }) {
521
- const i = typeof n == "string" ? n : n.name, u = e.variables.find(
522
- (f) => f.name === i
632
+ const o = typeof t == "string" ? t : t.name, u = e.variables.find(
633
+ (f) => f.name === o
523
634
  );
524
635
  if (s.default && u)
525
636
  return u;
526
637
  if (u)
527
- return u.value = o, u;
638
+ return u.value = i, u;
528
639
  const c = {
529
640
  type: "variable",
530
- name: i,
531
- value: o
641
+ name: o,
642
+ value: i
532
643
  };
533
644
  return e.variables.push(c), c;
534
645
  };
535
646
  }
536
- function b(e, t) {
537
- const r = D(e), n = E(e, t), o = w(e, t), s = _(t, t), i = C(e, t), u = S(), c = M();
647
+ function b(e, r) {
648
+ const n = H(e), t = D(e, r), i = R(e, r), s = E(r, r), o = S(e, r), u = P(), c = k();
538
649
  return {
539
- variable: r,
540
- selector: n,
650
+ variable: n,
651
+ selector: t,
541
652
  keyframes: s,
542
- atRule: o,
543
- media: i,
653
+ atRule: i,
654
+ media: o,
544
655
  ref: u,
545
656
  css: c
546
657
  };
547
658
  }
548
- function g(e, t) {
549
- for (const r in e)
550
- if (r.startsWith("@")) {
551
- const n = e[r];
552
- if (typeof n == "object" && n !== null && !R(n)) {
553
- const o = r.replace(/^@(\w+).*/, "$1"), s = r.replace(`@${o}`, "").trim();
554
- t.atRule(o, s, n), delete e[r];
659
+ function g(e, r) {
660
+ for (const n in e)
661
+ if (n.startsWith("@")) {
662
+ const t = e[n];
663
+ if (typeof t == "object" && t !== null && !O(t)) {
664
+ const i = n.replace(/^@(\w+).*/, "$1"), s = n.replace(`@${i}`, "").trim();
665
+ r.atRule(i, s, t), delete e[n];
555
666
  }
556
- } else if (/^[.&:]/.test(r)) {
557
- const n = e[r];
558
- typeof n == "object" && (t.selector(r, n), delete e[r]);
667
+ } else if (/^[.&:]/.test(n)) {
668
+ const t = e[n];
669
+ typeof t == "object" && (r.selector(n, t), delete e[n]);
559
670
  }
560
671
  return e;
561
672
  }
562
673
  function m(e) {
563
674
  if (e instanceof Buffer)
564
675
  return Buffer.from(e);
565
- const t = e.constructor;
566
- return new t(
676
+ const r = e.constructor;
677
+ return new r(
567
678
  e.buffer.slice(0),
568
679
  e.byteOffset,
569
680
  e.byteLength / e.BYTES_PER_ELEMENT || 1
570
681
  );
571
682
  }
572
- function H(e) {
683
+ function K(e) {
573
684
  if (e = e || {}, e.circular)
574
- return K(e);
575
- const t = /* @__PURE__ */ new Map();
576
- if (t.set(Date, (i) => new Date(i)), t.set(
685
+ return U(e);
686
+ const r = /* @__PURE__ */ new Map();
687
+ if (r.set(Date, (o) => new Date(o)), r.set(
577
688
  Map,
578
- (i, u) => new Map(n(Array.from(i), u))
579
- ), t.set(
689
+ (o, u) => new Map(t(Array.from(o), u))
690
+ ), r.set(
580
691
  Set,
581
- (i, u) => new Set(n(Array.from(i), u))
692
+ (o, u) => new Set(t(Array.from(o), u))
582
693
  ), e.constructorHandlers)
583
- for (const i of e.constructorHandlers)
584
- t.set(i[0], i[1]);
585
- let r;
586
- return e.proto ? s : o;
587
- function n(i, u) {
588
- const c = Object.keys(i), f = Array.from({ length: c.length });
694
+ for (const o of e.constructorHandlers)
695
+ r.set(o[0], o[1]);
696
+ let n;
697
+ return e.proto ? s : i;
698
+ function t(o, u) {
699
+ const c = Object.keys(o), f = Array.from({ length: c.length });
589
700
  for (let a = 0; a < c.length; a++) {
590
- const l = c[a], y2 = i[l];
591
- typeof y2 != "object" || y2 === null ? f[l] = y2 : y2.constructor !== Object && (r = t.get(y2.constructor)) ? f[l] = r(y2, u) : ArrayBuffer.isView(y2) ? f[l] = m(y2) : f[l] = u(y2);
701
+ const l = c[a], y = o[l];
702
+ 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);
592
703
  }
593
704
  return f;
594
705
  }
595
- function o(i) {
596
- if (typeof i != "object" || i === null) return i;
597
- if (Array.isArray(i)) return n(i, o);
598
- if (i.constructor !== Object && (r = t.get(i.constructor)))
599
- return r(i, o);
706
+ function i(o) {
707
+ if (typeof o != "object" || o === null) return o;
708
+ if (Array.isArray(o)) return t(o, i);
709
+ if (o.constructor !== Object && (n = r.get(o.constructor)))
710
+ return n(o, i);
600
711
  const u = {};
601
- for (const c in i) {
602
- if (Object.hasOwnProperty.call(i, c) === false) continue;
603
- const f = i[c];
604
- typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f, o) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = o(f);
712
+ for (const c in o) {
713
+ if (Object.hasOwnProperty.call(o, c) === false) continue;
714
+ const f = o[c];
715
+ 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);
605
716
  }
606
717
  return u;
607
718
  }
608
- function s(i) {
609
- if (typeof i != "object" || i === null) return i;
610
- if (Array.isArray(i)) return n(i, s);
611
- if (i.constructor !== Object && (r = t.get(i.constructor)))
612
- return r(i, s);
719
+ function s(o) {
720
+ if (typeof o != "object" || o === null) return o;
721
+ if (Array.isArray(o)) return t(o, s);
722
+ if (o.constructor !== Object && (n = r.get(o.constructor)))
723
+ return n(o, s);
613
724
  const u = {};
614
- for (const c in i) {
615
- const f = i[c];
616
- typeof f != "object" || f === null ? u[c] = f : f.constructor !== Object && (r = t.get(f.constructor)) ? u[c] = r(f, s) : ArrayBuffer.isView(f) ? u[c] = m(f) : u[c] = s(f);
725
+ for (const c in o) {
726
+ const f = o[c];
727
+ 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);
617
728
  }
618
729
  return u;
619
730
  }
620
731
  }
621
- function K(e) {
622
- const t = [], r = [], n = /* @__PURE__ */ new Map();
623
- if (n.set(Date, (c) => new Date(c)), n.set(
732
+ function U(e) {
733
+ const r = [], n = [], t = /* @__PURE__ */ new Map();
734
+ if (t.set(Date, (c) => new Date(c)), t.set(
624
735
  Map,
625
736
  (c, f) => new Map(s(Array.from(c), f))
626
- ), n.set(
737
+ ), t.set(
627
738
  Set,
628
739
  (c, f) => new Set(s(Array.from(c), f))
629
740
  ), e.constructorHandlers)
630
741
  for (const c of e.constructorHandlers)
631
- n.set(c[0], c[1]);
632
- let o;
633
- return e.proto ? u : i;
742
+ t.set(c[0], c[1]);
743
+ let i;
744
+ return e.proto ? u : o;
634
745
  function s(c, f) {
635
746
  const a = Object.keys(c), l = Array.from({ length: a.length });
636
- for (let y2 = 0; y2 < a.length; y2++) {
637
- const h = a[y2], d2 = c[h];
638
- if (typeof d2 != "object" || d2 === null)
639
- l[h] = d2;
640
- else if (d2.constructor !== Object && (o = n.get(d2.constructor)))
641
- l[h] = o(d2, f);
642
- else if (ArrayBuffer.isView(d2))
643
- l[h] = m(d2);
747
+ for (let y = 0; y < a.length; y++) {
748
+ const h = a[y], d = c[h];
749
+ if (typeof d != "object" || d === null)
750
+ l[h] = d;
751
+ else if (d.constructor !== Object && (i = t.get(d.constructor)))
752
+ l[h] = i(d, f);
753
+ else if (ArrayBuffer.isView(d))
754
+ l[h] = m(d);
644
755
  else {
645
- const v2 = t.indexOf(d2);
646
- v2 !== -1 ? l[h] = r[v2] : l[h] = f(d2);
756
+ const v = r.indexOf(d);
757
+ v !== -1 ? l[h] = n[v] : l[h] = f(d);
647
758
  }
648
759
  }
649
760
  return l;
650
761
  }
651
- function i(c) {
762
+ function o(c) {
652
763
  if (typeof c != "object" || c === null) return c;
653
- if (Array.isArray(c)) return s(c, i);
654
- if (c.constructor !== Object && (o = n.get(c.constructor)))
655
- return o(c, i);
764
+ if (Array.isArray(c)) return s(c, o);
765
+ if (c.constructor !== Object && (i = t.get(c.constructor)))
766
+ return i(c, o);
656
767
  const f = {};
657
- t.push(c), r.push(f);
768
+ r.push(c), n.push(f);
658
769
  for (const a in c) {
659
770
  if (Object.hasOwnProperty.call(c, a) === false) continue;
660
771
  const l = c[a];
661
772
  if (typeof l != "object" || l === null)
662
773
  f[a] = l;
663
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
664
- f[a] = o(l, i);
774
+ else if (l.constructor !== Object && (i = t.get(l.constructor)))
775
+ f[a] = i(l, o);
665
776
  else if (ArrayBuffer.isView(l))
666
777
  f[a] = m(l);
667
778
  else {
668
- const y2 = t.indexOf(l);
669
- y2 !== -1 ? f[a] = r[y2] : f[a] = i(l);
779
+ const y = r.indexOf(l);
780
+ y !== -1 ? f[a] = n[y] : f[a] = o(l);
670
781
  }
671
782
  }
672
- return t.pop(), r.pop(), f;
783
+ return r.pop(), n.pop(), f;
673
784
  }
674
785
  function u(c) {
675
786
  if (typeof c != "object" || c === null) return c;
676
787
  if (Array.isArray(c)) return s(c, u);
677
- if (c.constructor !== Object && (o = n.get(c.constructor)))
678
- return o(c, u);
788
+ if (c.constructor !== Object && (i = t.get(c.constructor)))
789
+ return i(c, u);
679
790
  const f = {};
680
- t.push(c), r.push(f);
791
+ r.push(c), n.push(f);
681
792
  for (const a in c) {
682
793
  const l = c[a];
683
794
  if (typeof l != "object" || l === null)
684
795
  f[a] = l;
685
- else if (l.constructor !== Object && (o = n.get(l.constructor)))
686
- f[a] = o(l, u);
796
+ else if (l.constructor !== Object && (i = t.get(l.constructor)))
797
+ f[a] = i(l, u);
687
798
  else if (ArrayBuffer.isView(l))
688
799
  f[a] = m(l);
689
800
  else {
690
- const y2 = t.indexOf(l);
691
- y2 !== -1 ? f[a] = r[y2] : f[a] = u(l);
801
+ const y = r.indexOf(l);
802
+ y !== -1 ? f[a] = n[y] : f[a] = u(l);
692
803
  }
693
804
  }
694
- return t.pop(), r.pop(), f;
805
+ return r.pop(), n.pop(), f;
695
806
  }
696
807
  }
697
- const j = H();
698
- function $(e) {
699
- const t = [];
700
- function r(n, o) {
701
- o.length > 0 && t.push([...o].sort());
702
- for (let s = n; s < e.length; s++) {
703
- const i = e[s];
704
- if (i)
705
- if (i.length === 1 && i[0])
706
- r(s + 1, [...o, i[0]]);
808
+ const A = K();
809
+ function $(e, r = 8) {
810
+ const n = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789";
811
+ let t = "";
812
+ for (let i = 0; i < r; i++) {
813
+ const s = Math.floor(Math.random() * n.length);
814
+ t += n[s];
815
+ }
816
+ return e ? `${e}${t}` : t;
817
+ }
818
+ function q(e) {
819
+ const r = [];
820
+ function n(t, i) {
821
+ i.length > 0 && r.push([...i].sort());
822
+ for (let s = t; s < e.length; s++) {
823
+ const o = e[s];
824
+ if (o)
825
+ if (o.length === 1 && o[0])
826
+ n(s + 1, [...i, o[0]]);
707
827
  else
708
- for (const u of i)
709
- r(s + 1, [...o, u]);
828
+ for (const u of o)
829
+ n(s + 1, [...i, u]);
710
830
  }
711
831
  }
712
- return r(0, []), t.sort((n, o) => n.length !== o.length ? n.length - o.length : n.join(",").localeCompare(o.join(",")));
832
+ return n(0, []), r.sort((t, i) => t.length !== i.length ? t.length - i.length : t.join(",").localeCompare(i.join(",")));
713
833
  }
714
- function L(e, t, r) {
715
- const n = {
834
+ function z(e, r, n) {
835
+ const t = {
716
836
  ...e,
717
- modifiers: [...r.keys()]
718
- }, o = b(n, t);
719
- for (const s of r.values())
837
+ modifiers: [...n.keys()]
838
+ }, i = b(t, r);
839
+ for (const s of n.values())
720
840
  s.factory({
721
- ...o,
722
- declarations: j(n.declarations),
723
- variables: j(n.variables),
724
- children: j(n.children)
725
- }), g(n.declarations, o);
726
- return n;
727
- }
728
- function N(e, t) {
729
- return function(n, o) {
841
+ ...i,
842
+ declarations: A(t.declarations),
843
+ variables: A(t.variables),
844
+ children: A(t.children)
845
+ }), g(t.declarations, i);
846
+ return t;
847
+ }
848
+ function W(e, r) {
849
+ return function(t, i) {
730
850
  const s = {
731
851
  type: "modifier",
732
- key: Array.isArray(n) ? n : [n],
733
- factory: o
852
+ key: Array.isArray(t) ? t : [t],
853
+ factory: i
734
854
  };
735
- return t.modifiers.push(s), s;
855
+ return r.modifiers.push(s), s;
736
856
  };
737
857
  }
738
- function z() {
858
+ function Y() {
739
859
  return {
740
860
  type: "root",
741
861
  declarations: {},
@@ -747,31 +867,31 @@
747
867
  themes: []
748
868
  };
749
869
  }
750
- function I(e, t, r) {
751
- const n = t.map((s) => s.key);
752
- return $(n).map((s) => {
753
- const i = /* @__PURE__ */ new Map();
870
+ function G(e, r, n) {
871
+ const t = r.map((s) => s.key);
872
+ return q(t).map((s) => {
873
+ const o = /* @__PURE__ */ new Map();
754
874
  for (const u of s) {
755
- const c = t.find(
875
+ const c = r.find(
756
876
  (f) => f.key.includes(u)
757
877
  );
758
- c && i.set(u, c);
878
+ c && o.set(u, c);
759
879
  }
760
- return L(e, r, i);
880
+ return z(e, n, o);
761
881
  });
762
882
  }
763
- function W(e, t) {
764
- return function(n, o) {
883
+ function J(e, r) {
884
+ return function(t, i) {
765
885
  const s = {
766
886
  type: "utility",
767
- name: n,
768
- factory: o
887
+ name: t,
888
+ factory: i
769
889
  };
770
- return t.utilities.push(s), (i, u = []) => {
771
- for (const [c, f] of Object.entries(i)) {
890
+ return r.utilities.push(s), (o, u = []) => {
891
+ for (const [c, f] of Object.entries(o)) {
772
892
  const a = {
773
893
  type: "utility",
774
- name: n,
894
+ name: t,
775
895
  value: c,
776
896
  declarations: {},
777
897
  variables: [],
@@ -779,60 +899,61 @@
779
899
  modifiers: []
780
900
  }, l = b(
781
901
  a,
782
- t
902
+ r
783
903
  );
784
- a.declarations = o({
904
+ a.declarations = i({
785
905
  ...l,
786
906
  value: f
787
907
  }) ?? {}, g(a.declarations, l), e.children.push(a), u.length > 0 && e.children.push(
788
- ...I(a, u, t)
908
+ ...G(a, u, r)
789
909
  );
790
910
  }
791
911
  };
792
912
  };
793
913
  }
794
- function Y(e, t) {
795
- return function(n, o) {
796
- const s = t.themes.find((c) => c.name === n), i = s ?? {
914
+ function Q(e, r) {
915
+ return function(t, i) {
916
+ const s = r.themes.find((c) => c.name === t), o = s ?? {
797
917
  type: "theme",
798
- name: n,
918
+ name: t,
799
919
  declarations: {},
800
920
  variables: [],
801
921
  children: []
802
922
  };
803
- s || t.themes.push(i);
804
- const u = b(i, t);
805
- return o && o(u), i;
923
+ s || r.themes.push(o);
924
+ const u = b(o, r);
925
+ return i && i(u), o;
806
926
  };
807
927
  }
808
- function q(e, t) {
809
- return function(n, o, s, i) {
928
+ function X(e, r) {
929
+ return function(t, i, s, o) {
810
930
  const u = {
811
931
  type: "recipe",
812
- name: n,
813
- defaults: o,
932
+ name: t,
933
+ defaults: i,
814
934
  variants: s,
815
- ...i
935
+ ...o
816
936
  };
817
- return t.recipes.push(u), u;
937
+ return r.recipes.push(u), u;
818
938
  };
819
939
  }
820
- function oe(e) {
821
- const t = z(), r = { ...e }, n = W(t, t), o = N(t, t), s = q(t, t), i = Y(t, t), { variable: u, selector: c, atRule: f, keyframes: a, media: l, ref: y2, css: h } = b(t, t);
940
+ function ue(e) {
941
+ 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);
822
942
  return {
823
- root: t,
824
- variable: u,
825
- selector: c,
826
- utility: n,
827
- modifier: o,
828
- recipe: s,
829
- theme: i,
830
- atRule: f,
831
- keyframes: a,
832
- media: l,
833
- ref: y2,
834
- css: h,
835
- options: r
943
+ id: r,
944
+ root: n,
945
+ variable: c,
946
+ selector: f,
947
+ utility: i,
948
+ modifier: s,
949
+ recipe: o,
950
+ theme: u,
951
+ atRule: a,
952
+ keyframes: l,
953
+ media: y,
954
+ ref: h,
955
+ css: d,
956
+ options: t
836
957
  };
837
958
  }
838
959
  async function loadConfiguration({
@@ -842,7 +963,7 @@
842
963
  const { config } = await c12.loadConfig({
843
964
  cwd,
844
965
  name,
845
- defaults: oe()
966
+ defaults: ue()
846
967
  });
847
968
  return config;
848
969
  }