@greensight/gts 1.0.0-beta.11 → 1.0.0-beta.12

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/index.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  var ue = Object.defineProperty;
2
- var de = (r, e, o) => e in r ? ue(r, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : r[e] = o;
3
- var w = (r, e, o) => de(r, typeof e != "symbol" ? e + "" : e, o);
2
+ var de = (t, e, o) => e in t ? ue(t, e, { enumerable: !0, configurable: !0, writable: !0, value: o }) : t[e] = o;
3
+ var w = (t, e, o) => de(t, typeof e != "symbol" ? e + "" : e, o);
4
4
  import k from "path";
5
5
  import { tsImport as ye } from "ts-import";
6
6
  import { existsSync as M } from "node:fs";
@@ -13,10 +13,10 @@ const p = class p {
13
13
  return C(p.baseDir, e);
14
14
  }
15
15
  static resolveWritePath(e, o) {
16
- const t = C(p.baseDir, o ?? "");
16
+ const r = C(p.baseDir, o ?? "");
17
17
  return {
18
- targetDir: t,
19
- targetPath: C(t, e)
18
+ targetDir: r,
19
+ targetPath: C(r, e)
20
20
  };
21
21
  }
22
22
  static handleReadError(e, o) {
@@ -25,51 +25,51 @@ const p = class p {
25
25
  );
26
26
  }
27
27
  static async read(e, o = "utf8") {
28
- const t = p.resolveReadPath(e);
28
+ const r = p.resolveReadPath(e);
29
29
  try {
30
- return await V(t, { encoding: o });
31
- } catch (n) {
32
- p.handleReadError(n, t);
30
+ return await V(r, { encoding: o });
31
+ } catch (s) {
32
+ p.handleReadError(s, r);
33
33
  }
34
34
  }
35
35
  static async readBuffer(e) {
36
36
  const o = p.resolveReadPath(e);
37
37
  try {
38
38
  return await V(o);
39
- } catch (t) {
40
- p.handleReadError(t, o);
39
+ } catch (r) {
40
+ p.handleReadError(r, o);
41
41
  }
42
42
  }
43
43
  static async readJson(e) {
44
44
  const o = p.resolveReadPath(e);
45
45
  try {
46
- const t = await V(o, { encoding: "utf8" });
46
+ const r = await V(o, { encoding: "utf8" });
47
47
  try {
48
- return JSON.parse(t);
49
- } catch (n) {
50
- throw new Error(`Failed to parse JSON from "${o}": ${n.message}`);
48
+ return JSON.parse(r);
49
+ } catch (s) {
50
+ throw new Error(`Failed to parse JSON from "${o}": ${s.message}`);
51
51
  }
52
- } catch (t) {
53
- p.handleReadError(t, o);
52
+ } catch (r) {
53
+ p.handleReadError(r, o);
54
54
  }
55
55
  }
56
- static async write(e, o = "", t = {}) {
57
- const { directory: n, overwrite: s = !0 } = t, { targetDir: a, targetPath: i } = p.resolveWritePath(e, n);
58
- if (!s && M(i))
56
+ static async write(e, o = "", r = {}) {
57
+ const { directory: s, overwrite: n = !0 } = r, { targetDir: a, targetPath: i } = p.resolveWritePath(e, s);
58
+ if (!n && M(i))
59
59
  throw new Error(`File ${i} already exists`);
60
60
  return await fe(a, { recursive: !0 }), await ge(i, o, { encoding: "utf8" }), i;
61
61
  }
62
- static async writeWithExtension(e, o, t = "", n) {
63
- const s = o.startsWith(".") ? o : `.${o}`, a = `${e}${s}`;
64
- return p.write(a, t, n);
62
+ static async writeWithExtension(e, o, r = "", s) {
63
+ const n = o.startsWith(".") ? o : `.${o}`, a = `${e}${n}`;
64
+ return p.write(a, r, s);
65
65
  }
66
66
  static exists(e) {
67
67
  const o = p.resolveReadPath(e);
68
68
  return M(o);
69
69
  }
70
70
  static async delete(e, o) {
71
- const { targetPath: t } = p.resolveWritePath(e, o);
72
- M(t) && await pe(t, { recursive: !0, force: !0 });
71
+ const { targetPath: r } = p.resolveWritePath(e, o);
72
+ M(r) && await pe(r, { recursive: !0, force: !0 });
73
73
  }
74
74
  };
75
75
  w(p, "baseDir", process.cwd());
@@ -95,15 +95,15 @@ const $ = class $ {
95
95
  };
96
96
  w($, "configFileName", "gts.config.ts");
97
97
  let v = $;
98
- const he = (r) => {
98
+ const he = (t) => {
99
99
  const e = new URLSearchParams();
100
- return Object.keys(r).forEach((o) => {
101
- Array.isArray(r[o]) ? r[o].forEach((t) => e.append(`${o}[]`, t)) : e.append(o, r[o]);
100
+ return Object.keys(t).forEach((o) => {
101
+ Array.isArray(t[o]) ? t[o].forEach((r) => e.append(`${o}[]`, r)) : e.append(o, t[o]);
102
102
  }), e;
103
- }, me = (r, e = 50) => {
103
+ }, me = (t, e = 50) => {
104
104
  const o = [];
105
- for (let t = 0; t < r.length; t += e)
106
- o.push(r.slice(t, t + e));
105
+ for (let r = 0; r < t.length; r += e)
106
+ o.push(t.slice(r, r + e));
107
107
  return o;
108
108
  };
109
109
  class O {
@@ -119,35 +119,35 @@ class O {
119
119
  static async returnJSON(e) {
120
120
  const o = await e.json();
121
121
  if (!e.ok) {
122
- let t = "Request failed";
123
- throw new Error(t);
122
+ let r = "Request failed";
123
+ throw new Error(r);
124
124
  }
125
125
  return o;
126
126
  }
127
- async performControlledRequest(e, { params: o = {}, timeout: t = 3e4, abortController: n = new AbortController() } = {}) {
127
+ async performControlledRequest(e, { params: o = {}, timeout: r = 3e4, abortController: s = new AbortController() } = {}) {
128
128
  var m;
129
129
  if (!this.figmaToken || !this.fileId)
130
130
  throw new Error("figmaToken and fileId are required in gts.config.ts");
131
- const s = Object.entries(o).reduce((g, [h, b]) => typeof b < "u" ? { ...g, [h]: b } : g, {}), a = `https://api.figma.com/v1${e}${s && Object.keys(s).length ? `?${he(s)}` : ""}`;
131
+ const n = Object.entries(o).reduce((g, [h, b]) => typeof b < "u" ? { ...g, [h]: b } : g, {}), a = `https://api.figma.com/v1${e}${n && Object.keys(n).length ? `?${he(n)}` : ""}`;
132
132
  console.log("endpoinWithParams=", a);
133
- const i = setTimeout(() => n.abort(), t), l = {
133
+ const i = setTimeout(() => s.abort(), r), l = {
134
134
  "Content-Type": "application/json",
135
135
  ...this.figmaToken && { "X-Figma-Token": this.figmaToken }
136
136
  }, c = {
137
137
  method: "GET",
138
138
  headers: l,
139
- signal: n.signal
139
+ signal: s.signal
140
140
  }, u = performance.now(), d = await fetch(`${a}`, c);
141
141
  clearTimeout(i);
142
142
  const f = performance.now() - u;
143
143
  return (m = this.onTimeMeasureHandler) == null || m.call(this, a, l, f), d;
144
144
  }
145
145
  async request(e, o) {
146
- var n;
147
- const t = await this.performControlledRequest(e, {
146
+ var s;
147
+ const r = await this.performControlledRequest(e, {
148
148
  ...o
149
149
  });
150
- return (n = t.headers.get("content-type")) != null && n.includes("application/json") ? O.returnJSON(t) : t;
150
+ return (s = r.headers.get("content-type")) != null && s.includes("application/json") ? O.returnJSON(r) : r;
151
151
  }
152
152
  async getComponents() {
153
153
  return this.request(`/files/${this.fileId}/components`);
@@ -157,55 +157,55 @@ class O {
157
157
  }
158
158
  async getNodes(e) {
159
159
  const o = me(e).map(
160
- (s) => this.request(`/files/${this.fileId}/nodes`, { params: { ids: s.join(",") } })
161
- ), t = await Promise.all(o);
160
+ (n) => this.request(`/files/${this.fileId}/nodes`, { params: { ids: n.join(",") } })
161
+ ), r = await Promise.all(o);
162
162
  return {
163
- ...t[0],
164
- nodes: t.reduce((s, a) => ({ ...s, ...a.nodes }), {})
163
+ ...r[0],
164
+ nodes: r.reduce((n, a) => ({ ...n, ...a.nodes }), {})
165
165
  };
166
166
  }
167
167
  }
168
- const q = (r, e) => {
168
+ const q = (t, e) => {
169
169
  const o = Array.isArray(e) ? e : e.split(".");
170
- let t = r;
171
- for (const n of o) {
172
- if (t == null || typeof t != "object") return;
173
- t = t[n];
170
+ let r = t;
171
+ for (const s of o) {
172
+ if (r == null || typeof r != "object") return;
173
+ r = r[s];
174
174
  }
175
- return t;
176
- }, H = (r, e) => {
177
- if (!e || typeof e != "object") return r;
178
- if (!r || typeof r != "object") return e;
179
- const o = { ...r };
180
- for (const t in e)
181
- e.hasOwnProperty(t) && (typeof e[t] == "object" && e[t] !== null && typeof o[t] == "object" && o[t] !== null ? o[t] = H(o[t], e[t]) : o[t] = e[t]);
175
+ return r;
176
+ }, H = (t, e) => {
177
+ if (!e || typeof e != "object") return t;
178
+ if (!t || typeof t != "object") return e;
179
+ const o = { ...t };
180
+ for (const r in e)
181
+ e.hasOwnProperty(r) && (typeof e[r] == "object" && e[r] !== null && typeof o[r] == "object" && o[r] !== null ? o[r] = H(o[r], e[r]) : o[r] = e[r]);
182
182
  return o;
183
183
  };
184
- function x(r, e) {
185
- if (r === e)
184
+ function x(t, e) {
185
+ if (t === e)
186
186
  return !0;
187
- if (r == null || e == null)
188
- return r === e;
189
- if (typeof r != typeof e)
187
+ if (t == null || e == null)
188
+ return t === e;
189
+ if (typeof t != typeof e)
190
190
  return !1;
191
- if (r instanceof Date && e instanceof Date)
192
- return r.getTime() === e.getTime();
193
- if (r instanceof RegExp && e instanceof RegExp)
194
- return r.toString() === e.toString();
195
- if (Array.isArray(r) && Array.isArray(e)) {
196
- if (r.length !== e.length)
191
+ if (t instanceof Date && e instanceof Date)
192
+ return t.getTime() === e.getTime();
193
+ if (t instanceof RegExp && e instanceof RegExp)
194
+ return t.toString() === e.toString();
195
+ if (Array.isArray(t) && Array.isArray(e)) {
196
+ if (t.length !== e.length)
197
197
  return !1;
198
- for (let o = 0; o < r.length; o++)
199
- if (!x(r[o], e[o]))
198
+ for (let o = 0; o < t.length; o++)
199
+ if (!x(t[o], e[o]))
200
200
  return !1;
201
201
  return !0;
202
202
  }
203
- if (typeof r == "object" && typeof e == "object") {
204
- const o = Object.keys(r), t = Object.keys(e);
205
- if (o.length !== t.length)
203
+ if (typeof t == "object" && typeof e == "object") {
204
+ const o = Object.keys(t), r = Object.keys(e);
205
+ if (o.length !== r.length)
206
206
  return !1;
207
- for (const n of o)
208
- if (!t.includes(n) || !x(r[n], e[n]))
207
+ for (const s of o)
208
+ if (!r.includes(s) || !x(t[s], e[s]))
209
209
  return !1;
210
210
  return !0;
211
211
  }
@@ -235,9 +235,9 @@ class be {
235
235
  /** to camelCase */
236
236
  normalizeKey(e) {
237
237
  const o = e.trim();
238
- return o && o.replace(/[-_\s]+/g, " ").split(" ").filter((t) => t.length).map((t, n) => {
239
- const s = t.charAt(0), a = t.slice(1);
240
- return n === 0 ? t : s.toUpperCase() + a;
238
+ return o && o.replace(/[-_\s]+/g, " ").split(" ").filter((r) => r.length).map((r, s) => {
239
+ const n = r.charAt(0), a = r.slice(1);
240
+ return s === 0 ? r : n.toUpperCase() + a;
241
241
  }).join("");
242
242
  }
243
243
  /**
@@ -245,10 +245,10 @@ class be {
245
245
  */
246
246
  parseVariableString(e) {
247
247
  if (typeof e != "string") return e;
248
- const o = /^\{(.+)\}$/, t = e.match(o);
249
- if (t) {
250
- const n = t[1].trim();
251
- return `{${this.normalizeKey(n)}}`;
248
+ const o = /^\{(.+)\}$/, r = e.match(o);
249
+ if (r) {
250
+ const s = r[1].trim();
251
+ return `{${this.normalizeKey(s)}}`;
252
252
  }
253
253
  return e;
254
254
  }
@@ -257,57 +257,57 @@ class be {
257
257
  */
258
258
  createVariableFileList(e) {
259
259
  return Object.entries(e).flatMap(
260
- ([o, t]) => Object.entries(t.modes).flatMap(
261
- ([n, s]) => s.map((a) => ({
260
+ ([o, r]) => Object.entries(r.modes).flatMap(
261
+ ([s, n]) => n.map((a) => ({
262
262
  fileName: a,
263
- modeName: this.normalizeKey(n.trim()),
263
+ modeName: this.normalizeKey(s.trim()),
264
264
  collectionName: o
265
265
  }))
266
266
  )
267
267
  );
268
268
  }
269
269
  parseValue(e) {
270
- return e && (typeof e == "string" ? this.parseVariableString(e) : typeof e != "object" ? e : Array.isArray(e) ? e.map((o) => this.parseValue(o)) : Object.entries(e).reduce((o, [t, n]) => ({ ...o, [t]: this.parseValue(n) }), {}));
270
+ return e && (typeof e == "string" ? this.parseVariableString(e) : typeof e != "object" ? e : Array.isArray(e) ? e.map((o) => this.parseValue(o)) : Object.entries(e).reduce((o, [r, s]) => ({ ...o, [r]: this.parseValue(s) }), {}));
271
271
  }
272
272
  getTokensFromFile(e, o) {
273
- return Object.entries(e).reduce((t, [n, s]) => "$type" in s && "$value" in s ? {
274
- ...t,
275
- [this.normalizeKey(n)]: {
276
- type: s.$type,
277
- description: s.$description,
278
- value: o ? { [this.normalizeKey(o)]: this.parseValue(s.$value) } : this.parseValue(s.$value)
273
+ return Object.entries(e).reduce((r, [s, n]) => "$type" in n && "$value" in n ? {
274
+ ...r,
275
+ [this.normalizeKey(s)]: {
276
+ type: n.$type,
277
+ description: n.$description,
278
+ value: o ? { [this.normalizeKey(o)]: this.parseValue(n.$value) } : this.parseValue(n.$value)
279
279
  }
280
- } : { ...t, [this.normalizeKey(n)]: this.getTokensFromFile(s, o) }, {});
280
+ } : { ...r, [this.normalizeKey(s)]: this.getTokensFromFile(n, o) }, {});
281
281
  }
282
- processTokensFile(e, o, t) {
283
- const n = this.normalizeKey(t), s = this.getTokensFromFile(e, o);
284
- return { [n]: s };
282
+ processTokensFile(e, o, r) {
283
+ const s = this.normalizeKey(r), n = this.getTokensFromFile(e, o);
284
+ return { [s]: n };
285
285
  }
286
286
  /**
287
287
  * Loads all variable files in parallel and returns processed results
288
288
  */
289
289
  async loadVariableFiles(e) {
290
290
  return Promise.all(
291
- e.map(async ({ fileName: o, modeName: t, collectionName: n }) => {
291
+ e.map(async ({ fileName: o, modeName: r, collectionName: s }) => {
292
292
  try {
293
- const s = k.join(this.tokensDir, o), a = await y.readJson(s);
294
- return this.processTokensFile(a, t, n);
295
- } catch (s) {
296
- return console.warn(`Failed to load variable file: ${k.join(this.tokensDir, o)}`, s), {};
293
+ const n = k.join(this.tokensDir, o), a = await y.readJson(n);
294
+ return this.processTokensFile(a, r, s);
295
+ } catch (n) {
296
+ return console.warn(`Failed to load variable file: ${k.join(this.tokensDir, o)}`, n), {};
297
297
  }
298
298
  })
299
299
  );
300
300
  }
301
301
  mergeVariables(e) {
302
- return e.reduce((o, t) => H(o, t), {});
302
+ return e.reduce((o, r) => H(o, r), {});
303
303
  }
304
304
  /**
305
305
  * Loads and processes all token variables from manifest collections
306
306
  */
307
307
  async loadTokenVariables(e) {
308
308
  try {
309
- const o = this.createVariableFileList(e), t = await this.loadVariableFiles(o);
310
- return this.mergeVariables(t);
309
+ const o = this.createVariableFileList(e), r = await this.loadVariableFiles(o);
310
+ return this.mergeVariables(r);
311
311
  } catch (o) {
312
312
  throw new Error(`Failed to load token variables from ${this.tokensDir}: ${o}`);
313
313
  }
@@ -317,9 +317,9 @@ class be {
317
317
  */
318
318
  createStyleFileList(e) {
319
319
  return Object.entries(e).flatMap(
320
- ([o, t]) => (t == null ? void 0 : t.map((n) => ({
320
+ ([o, r]) => (r == null ? void 0 : r.map((s) => ({
321
321
  styleType: o,
322
- fileName: n
322
+ fileName: s
323
323
  }))) || []
324
324
  );
325
325
  }
@@ -328,16 +328,16 @@ class be {
328
328
  */
329
329
  async loadStyleFiles(e) {
330
330
  return (await Promise.all(
331
- e.map(async ({ styleType: t, fileName: n }) => {
331
+ e.map(async ({ styleType: r, fileName: s }) => {
332
332
  try {
333
- const s = k.join(this.tokensDir, n), a = await y.readJson(s);
334
- return { styleType: t, styleTokens: a };
335
- } catch (s) {
336
- return console.warn(`Failed to load style file: ${k.join(this.tokensDir, n)}`, s), { styleType: t, styleTokens: {} };
333
+ const n = k.join(this.tokensDir, s), a = await y.readJson(n);
334
+ return { styleType: r, styleTokens: a };
335
+ } catch (n) {
336
+ return console.warn(`Failed to load style file: ${k.join(this.tokensDir, s)}`, n), { styleType: r, styleTokens: {} };
337
337
  }
338
338
  })
339
339
  )).reduce(
340
- (t, n) => ({ ...t, [n.styleType]: this.getTokensFromFile(n.styleTokens, "") }),
340
+ (r, s) => ({ ...r, [s.styleType]: this.getTokensFromFile(s.styleTokens, "") }),
341
341
  {
342
342
  ...K
343
343
  }
@@ -398,9 +398,9 @@ class be {
398
398
  */
399
399
  resolveVariableValue(e) {
400
400
  if (typeof e == "object")
401
- return Object.keys(e).reduce((o, t) => {
402
- const n = e[t], s = this.resolveVariableValueString(n, t);
403
- return s && (o[t] = s), o;
401
+ return Object.keys(e).reduce((o, r) => {
402
+ const s = e[r], n = this.resolveVariableValueString(s, r);
403
+ return n && (o[r] = n), o;
404
404
  }, {});
405
405
  }
406
406
  /**
@@ -411,9 +411,9 @@ class be {
411
411
  */
412
412
  resolveVariableValueString(e, o) {
413
413
  if (!this.isVariableReference(e)) return e;
414
- const t = this.getVariablePath(e), n = this.getToken(t, o);
415
- if (n)
416
- return this.resolveVariableValueString(n, o);
414
+ const r = this.getVariablePath(e), s = this.getToken(r, o);
415
+ if (s)
416
+ return this.resolveVariableValueString(s, o);
417
417
  }
418
418
  /**
419
419
  * Gets a nested token value by path, similar to lodash.get
@@ -423,13 +423,13 @@ class be {
423
423
  getToken(e, o) {
424
424
  if (!this.loaded || !this.variables)
425
425
  throw new Error("Tokens not loaded. Call load() first.");
426
- for (const t of Object.values(this.variables)) {
427
- const n = q(t, e);
428
- if (n != null && n.value && typeof n.value == "object") {
429
- if (o) return n.value[o];
426
+ for (const r of Object.values(this.variables)) {
427
+ const s = q(r, e);
428
+ if (s != null && s.value && typeof s.value == "object") {
429
+ if (o) return s.value[o];
430
430
  {
431
- const s = Object.keys(n.value)[0];
432
- return n.value[s];
431
+ const n = Object.keys(s.value)[0];
432
+ return s.value[n];
433
433
  }
434
434
  }
435
435
  }
@@ -441,41 +441,44 @@ const It = async () => {
441
441
  throw new Error(
442
442
  'Failed to load gts.config.ts. Run "npx gts-init" to create it, or ensure the file exists and default-exports a valid configuration.'
443
443
  );
444
- const { figmaToken: o, fileId: t, modules: n, manifest: s } = e, a = new O(o, t), i = new be(s);
445
- s && y.exists(s) && await i.load(), await Promise.all(n.map((l) => l.executor({ figmaApiClient: a, tokenManagerClient: i })));
444
+ const { figmaToken: o, fileId: r, modules: s, manifest: n } = e, a = new O(o, r), i = new be(n);
445
+ n && y.exists(n) && await i.load(), await Promise.all(s.map((l) => l.executor({ figmaApiClient: a, tokenManagerClient: i })));
446
446
  }, zt = async () => {
447
447
  await v.create(), console.log("\x1B[32m%s\x1B[0m", "✔️ Configuration file created gts.config.ts");
448
- }, we = ["xxxl", "xxl", "xl", "lg", "md", "sm", "xs", "xxs", "xxxs"], ke = (r) => parseInt(r.value, 10), $e = (r) => r.reduce(
448
+ }, we = ["xxxl", "xxl", "xl", "lg", "md", "sm", "xs", "xxs", "xxxs"], ke = (t) => parseInt(t.value, 10), $e = (t) => t.reduce(
449
449
  (e, o) => ({
450
450
  ...e,
451
451
  [o.name]: ke(o)
452
452
  }),
453
453
  {}
454
- ), Se = async (r, e) => {
455
- await y.delete(r, e);
456
- }, Te = async (r, e, o) => {
457
- await y.write(r, e, { directory: o });
458
- }, F = async (r, e, o) => {
459
- await Se(r, o), await Te(r, e, o);
460
- }, je = (r) => {
461
- const e = r.map(({ name: o, value: t }) => ` --${o}: ${t};`);
454
+ ), Se = async (t, e) => {
455
+ await y.delete(t, e);
456
+ }, Te = async (t, e, o) => {
457
+ await y.write(t, e, { directory: o });
458
+ }, F = async (t, e, o) => {
459
+ await Se(t, o), await Te(t, e, o);
460
+ }, je = (t) => {
461
+ const e = t.map(({ name: o, value: r }) => ` --${o}: ${r};`);
462
462
  return e.length ? `.breakpoint-variables {
463
463
  ${e.join(`
464
464
  `)}
465
465
  }
466
466
  ` : "";
467
- }, ve = (r) => {
468
- var t;
469
- const e = r.map(({ name: n, value: s }) => ` ${n}: ${s}`), o = (t = r.at(-1)) == null ? void 0 : t.name;
467
+ }, ve = (t) => {
468
+ var s;
469
+ const e = t.map(({ name: n, value: a }) => ` ${n}: ${a}`), o = (s = t.at(-1)) == null ? void 0 : s.name, r = t.map(({ name: n, value: a }) => `$${n}: ${a};`).join(`
470
+ `);
470
471
  return !e.length || !o ? "" : `$breakpointList: (
471
472
  ${e.join(`,
472
473
  `)}
473
474
  );
474
475
 
475
476
  $defaultBreakpoint: '${o}';
477
+
478
+ ${r}
476
479
  `;
477
- }, Ne = (r) => [
478
- `const breakpoints = ${JSON.stringify(r, null, 4)} as const;`,
480
+ }, Ne = (t) => [
481
+ `const breakpoints = ${JSON.stringify(t, null, 4)} as const;`,
479
482
  "",
480
483
  "const BREAKPOINTS_NAMES = Object.keys(breakpoints);",
481
484
  "",
@@ -486,87 +489,87 @@ $defaultBreakpoint: '${o}';
486
489
  "export type { BreakpointsKeysType, AllowMedia };",
487
490
  ""
488
491
  ].join(`
489
- `), Me = async ({ breakpointTokens: r, dir: e }) => {
490
- const o = $e(r), t = je(r), n = ve(r), s = Ne(o);
492
+ `), Me = async ({ breakpointTokens: t, dir: e }) => {
493
+ const o = $e(t), r = je(t), s = ve(t), n = Ne(o);
491
494
  await Promise.all([
492
- F("styles.css", t, e),
493
- F("styles.scss", n, e),
494
- F("index.ts", s, e)
495
+ F("styles.css", r, e),
496
+ F("styles.scss", s, e),
497
+ F("index.ts", n, e)
495
498
  ]);
496
- }, Ve = (r, e) => {
497
- const o = Object.keys(r).filter((s) => !isNaN(Number(s))).sort((s, a) => Number(s) - Number(a));
499
+ }, Ve = (t, e) => {
500
+ const o = Object.keys(t).filter((n) => !isNaN(Number(n))).sort((n, a) => Number(n) - Number(a));
498
501
  if (o.length > e.length)
499
502
  throw new Error(
500
503
  `Not enough breakpoint names provided. Found ${o.length} breakpoints in data, but only ${e.length} names specified: ${e.join(", ")}`
501
504
  );
502
- const n = Object.keys(r).filter((s) => isNaN(Number(s)));
503
- if (n.length > 0)
505
+ const s = Object.keys(t).filter((n) => isNaN(Number(n)));
506
+ if (s.length > 0)
504
507
  throw new Error(
505
- `Found non-numeric breakpoint keys in grid data: ${n.join(", ")}. All breakpoint keys must be numeric values.`
508
+ `Found non-numeric breakpoint keys in grid data: ${s.join(", ")}. All breakpoint keys must be numeric values.`
506
509
  );
507
- return o.map((s, a) => ({
508
- name: e[e.length - 1 - a] || `bp-${s}`,
509
- value: s
510
+ return o.map((n, a) => ({
511
+ name: e[e.length - 1 - a] || `bp-${n}`,
512
+ value: n
510
513
  }));
511
514
  }, Gt = ({
512
- input: r = {},
515
+ input: t = {},
513
516
  output: { dir: e }
514
517
  }) => ({
515
518
  name: "breakpoints/tokenManager",
516
519
  executor: async ({ tokenManagerClient: o }) => {
517
520
  try {
518
521
  console.log("[breakpoints/tokenManager] Generating breakpoints from TokenManager...");
519
- const { names: t = we } = r;
522
+ const { names: r = we } = t;
520
523
  if (!o.isLoaded())
521
524
  throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
522
- const n = o.getStyles();
523
- if (!n.grid)
525
+ const s = o.getStyles();
526
+ if (!s.grid)
524
527
  throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");
525
528
  console.log("[breakpoints/tokenManager] Extracting breakpoints from grid styles...");
526
- const s = Ve(n.grid, t);
527
- if (!s.length) {
529
+ const n = Ve(s.grid, r);
530
+ if (!n.length) {
528
531
  console.warn("[breakpoints/tokenManager] No breakpoints found in grid styles.");
529
532
  return;
530
533
  }
531
534
  console.log(
532
- `[breakpoints/tokenManager] Found ${s.length} breakpoints: ${s.map((a) => a.name).join(", ")}`
535
+ `[breakpoints/tokenManager] Found ${n.length} breakpoints: ${n.map((a) => a.name).join(", ")}`
533
536
  ), console.log(`[breakpoints/tokenManager] Writing files to ${e}...`), await Me({
534
- breakpointTokens: s,
537
+ breakpointTokens: n,
535
538
  dir: e
536
539
  }), console.log("[breakpoints/tokenManager] ✅ Successfully generated breakpoint files");
537
- } catch (t) {
538
- const n = t instanceof Error ? t.message : String(t);
539
- throw console.error("[breakpoints/tokenManager] ❌ Failed to generate breakpoints:", n), t instanceof Error && t.stack && console.error("[breakpoints/tokenManager] Stack trace:", t.stack), t;
540
+ } catch (r) {
541
+ const s = r instanceof Error ? r.message : String(r);
542
+ throw console.error("[breakpoints/tokenManager] ❌ Failed to generate breakpoints:", s), r instanceof Error && r.stack && console.error("[breakpoints/tokenManager] Stack trace:", r.stack), r;
540
543
  }
541
544
  }
542
- }), Ce = "styles.css", Fe = "index.ts", A = (r, e) => {
545
+ }), Ce = "styles.css", Fe = "index.ts", A = (t, e) => {
543
546
  if (!e.length) return "";
544
- const o = e.map((t) => ` ${t}`).join(`
547
+ const o = e.map((r) => ` ${r}`).join(`
545
548
  `);
546
- return `${r} {
549
+ return `${t} {
547
550
  ${o}
548
551
  }`;
549
- }, xe = (r) => `.${r.replace(/\s+/g, "-").toLowerCase()}`, Z = (r) => `--cl-${r}`, Pe = (r) => r.reduce(
552
+ }, xe = (t) => `.${t.replace(/\s+/g, "-").toLowerCase()}`, Z = (t) => `--cl-${t}`, Pe = (t) => t.reduce(
550
553
  (e, o) => {
551
- const t = Z(o.name);
552
- return typeof o.value == "object" ? Object.entries(o.value).forEach(([n, s]) => {
553
- e[n] || (e[n] = []), e[n].push(`${t}: ${s};`);
554
- }) : e.root.push(`${t}: ${o.value};`), e;
554
+ const r = Z(o.name);
555
+ return typeof o.value == "object" ? Object.entries(o.value).forEach(([s, n]) => {
556
+ e[s] || (e[s] = []), e[s].push(`${r}: ${n};`);
557
+ }) : e.root.push(`${r}: ${o.value};`), e;
555
558
  },
556
559
  { root: [] }
557
- ), Oe = (r) => {
558
- const e = A(".color-variables", r.root), o = Object.entries(r).reduce((t, [n, s]) => {
559
- if (n === "root" || !s.length) return t;
560
- const a = A(xe(`${n}-color-variables`), s);
561
- return a && t.push(a), t;
560
+ ), Oe = (t) => {
561
+ const e = A(".color-variables", t.root), o = Object.entries(t).reduce((r, [s, n]) => {
562
+ if (s === "root" || !n.length) return r;
563
+ const a = A(xe(`${s}-color-variables`), n);
564
+ return a && r.push(a), r;
562
565
  }, []).join(`
563
566
 
564
567
  `);
565
568
  return [e, o].filter(Boolean).join(`
566
569
 
567
570
  `);
568
- }, Ee = (r) => `${`const colors = {
569
- ${r.map((t) => ` '${t.name}': 'var(${Z(t.name)})'`).join(`,
571
+ }, Ee = (t) => `${`const colors = {
572
+ ${t.map((r) => ` '${r.name}': 'var(${Z(r.name)})'`).join(`,
570
573
  `)}
571
574
  } as const;`}
572
575
 
@@ -574,75 +577,75 @@ type ColorsKeysType = keyof typeof colors;
574
577
 
575
578
  export { colors, type ColorsKeysType };
576
579
  `, Be = async ({
577
- tsContent: r,
580
+ tsContent: t,
578
581
  cssContent: e,
579
582
  dir: o
580
583
  }) => {
581
584
  await y.delete(o);
582
- const t = y.write(Fe, r, { directory: o }), n = y.write(Ce, e, { directory: o });
583
- await Promise.all([t, n]);
584
- }, Ke = async ({ colorTokens: r, dir: e }) => {
585
- const o = Pe(r), t = Oe(o), n = Ee(r);
586
- await Be({ tsContent: n, cssContent: t, dir: e });
587
- }, N = (r) => r.reduce((e, o) => {
588
- const t = Number((o.position * 100).toFixed(1));
589
- return [...e, `${o.color}${t > 0 && t < 100 ? ` ${t}%` : ""}`];
590
- }, []).join(", "), Ae = (r) => {
591
- const e = N(r.stops);
592
- return `linear-gradient(${r.angle}deg, ${e})`;
593
- }, Re = (r) => `radial-gradient(circle, ${N(r.stops)})`, De = (r) => {
594
- const e = N(r.stops);
595
- return `conic-gradient(from ${r.angle}deg, ${e})`;
596
- }, Ue = (r) => {
597
- const e = N(r.stops);
598
- return `linear-gradient(${r.angle}deg, ${e})`;
599
- }, R = (r) => typeof r == "string" ? r : r.type === "linear" ? Ae(r) : r.type === "radial" ? Re(r) : r.type === "conic" ? De(r) : r.type === "diamond" ? Ue(r) : "", Q = (r, e) => Object.keys(r).reduce(
600
- (o, t) => {
601
- const n = r[t], s = e ? `${e}-${t}` : t;
602
- if (n && typeof n == "object" && "type" in n && "value" in n) {
603
- const i = Object.keys(n.value), l = i.length > 1 ? n.value : n.value[i[0]], c = typeof l == "object" ? Object.keys(l).reduce(
585
+ const r = y.write(Fe, t, { directory: o }), s = y.write(Ce, e, { directory: o });
586
+ await Promise.all([r, s]);
587
+ }, Ke = async ({ colorTokens: t, dir: e }) => {
588
+ const o = Pe(t), r = Oe(o), s = Ee(t);
589
+ await Be({ tsContent: s, cssContent: r, dir: e });
590
+ }, N = (t) => t.reduce((e, o) => {
591
+ const r = Number((o.position * 100).toFixed(1));
592
+ return [...e, `${o.color}${r > 0 && r < 100 ? ` ${r}%` : ""}`];
593
+ }, []).join(", "), Ae = (t) => {
594
+ const e = N(t.stops);
595
+ return `linear-gradient(${t.angle}deg, ${e})`;
596
+ }, Re = (t) => `radial-gradient(circle, ${N(t.stops)})`, De = (t) => {
597
+ const e = N(t.stops);
598
+ return `conic-gradient(from ${t.angle}deg, ${e})`;
599
+ }, Ue = (t) => {
600
+ const e = N(t.stops);
601
+ return `linear-gradient(${t.angle}deg, ${e})`;
602
+ }, R = (t) => typeof t == "string" ? t : t.type === "linear" ? Ae(t) : t.type === "radial" ? Re(t) : t.type === "conic" ? De(t) : t.type === "diamond" ? Ue(t) : "", Q = (t, e) => Object.keys(t).reduce(
603
+ (o, r) => {
604
+ const s = t[r], n = e ? `${e}-${r}` : r;
605
+ if (s && typeof s == "object" && "type" in s && "value" in s) {
606
+ const i = Object.keys(s.value), l = i.length > 1 ? s.value : s.value[i[0]], c = typeof l == "object" ? Object.keys(l).reduce(
604
607
  (d, f) => ({
605
608
  ...d,
606
609
  [f]: R(l[f])
607
610
  }),
608
611
  {}
609
- ) : R(l), u = { [s]: c };
612
+ ) : R(l), u = { [n]: c };
610
613
  return { ...o, ...u };
611
614
  }
612
- const a = Q(n, s);
615
+ const a = Q(s, n);
613
616
  return { ...o, ...a };
614
617
  },
615
618
  {}
616
- ), X = (r, e) => Object.keys(r).reduce((o, t) => {
617
- const n = r[t];
618
- if (n.type && n.type !== "color") return o;
619
- if (n.type && n.value) {
620
- const a = typeof n.value == "string" ? e.resolveVariableValueString(n.value, t) : e.resolveVariableValue(n.value);
621
- return a ? { ...o, [t]: { ...n, value: a } } : o;
619
+ ), X = (t, e) => Object.keys(t).reduce((o, r) => {
620
+ const s = t[r];
621
+ if (s.type && s.type !== "color") return o;
622
+ if (s.type && s.value) {
623
+ const a = typeof s.value == "string" ? e.resolveVariableValueString(s.value, r) : e.resolveVariableValue(s.value);
624
+ return a ? { ...o, [r]: { ...s, value: a } } : o;
622
625
  }
623
- const s = X(n, e);
624
- return s ? { ...o, [t]: s } : o;
625
- }, {}), Jt = ({ input: r = {}, output: { dir: e } }) => ({
626
+ const n = X(s, e);
627
+ return n ? { ...o, [r]: n } : o;
628
+ }, {}), Jt = ({ input: t = {}, output: { dir: e } }) => ({
626
629
  name: "colors/tokenManager",
627
630
  executor: async ({ tokenManagerClient: o }) => {
628
631
  try {
629
632
  console.log("[colors/tokenManager] Generating colors from TokenManager...");
630
- const { includeVariables: t, includeStyles: n = !0 } = r;
631
- if (!(t != null && t.length) && !n)
633
+ const { includeVariables: r, includeStyles: s = !0 } = t;
634
+ if (!(r != null && r.length) && !s)
632
635
  throw new Error("Either includeVariables or includeStyles must be enabled");
633
636
  if (!o.isLoaded())
634
637
  throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
635
- const s = [], a = o.getVariables();
636
- if (n) {
638
+ const n = [], a = o.getVariables();
639
+ if (s) {
637
640
  const l = o.getStyles();
638
- console.log("[colors/tokenManager] Processing styles for colors..."), l.color && s.push(l.color);
641
+ console.log("[colors/tokenManager] Processing styles for colors..."), l.color && n.push(l.color);
639
642
  }
640
- if (t != null && t.length) {
641
- console.log(`[colors/tokenManager] Processing ${t.length} variable groups...`);
642
- const l = t.map((c) => a[c]).filter(Boolean);
643
- s.push(...l);
643
+ if (r != null && r.length) {
644
+ console.log(`[colors/tokenManager] Processing ${r.length} variable groups...`);
645
+ const l = r.map((c) => a[c]).filter(Boolean);
646
+ n.push(...l);
644
647
  }
645
- const i = s.map((l) => X(l, o)).flatMap(
648
+ const i = n.map((l) => X(l, o)).flatMap(
646
649
  (l) => Object.entries(Q(l, "")).reduce(
647
650
  (c, [u, d]) => [...c, { name: u, value: d }],
648
651
  []
@@ -656,119 +659,119 @@ export { colors, type ColorsKeysType };
656
659
  colorTokens: i,
657
660
  dir: e
658
661
  }), console.log("[colors/tokenManager] ✅ Successfully generated color files");
659
- } catch (t) {
660
- const n = t instanceof Error ? t.message : String(t);
661
- throw console.error("[colors/tokenManager] ❌ Failed to generate colors:", n), t instanceof Error && t.stack && console.error("[colors/tokenManager] Stack trace:", t.stack), t;
662
+ } catch (r) {
663
+ const s = r instanceof Error ? r.message : String(r);
664
+ throw console.error("[colors/tokenManager] ❌ Failed to generate colors:", s), r instanceof Error && r.stack && console.error("[colors/tokenManager] Stack trace:", r.stack), r;
662
665
  }
663
666
  }
664
- }), Le = (r) => ` @media (width <= ${r.breakpoint}px) {
667
+ }), Le = (t) => ` @media (width <= ${t.breakpoint}px) {
665
668
  .container {
666
- padding-left: ${r.offset};
667
- padding-right: ${r.offset};
669
+ padding-left: ${t.offset};
670
+ padding-right: ${t.offset};
668
671
  }
669
672
 
670
673
  .containerTablet {
671
- padding-left: ${r.offset};
672
- padding-right: ${r.offset};
674
+ padding-left: ${t.offset};
675
+ padding-right: ${t.offset};
673
676
  }
674
- }`, We = (r, e) => {
675
- const o = e || "components", t = r.map((n) => Le(n)).join(`
677
+ }`, We = (t, e) => {
678
+ const o = e || "components", r = t.map((s) => Le(s)).join(`
676
679
 
677
680
  `);
678
681
  return `@layer ${o} {
679
- ${t}
682
+ ${r}
680
683
  }`;
681
684
  }, Ie = () => `import styles from './styles.module.css';
682
685
 
683
686
  export const containerClassName = styles.container;
684
687
  export const containerTabletClassName = styles.containerTablet;
685
- `, D = async (r, e, o) => {
686
- await y.delete(r, o), await y.write(r, e, { directory: o });
687
- }, ze = async ({ containerTokens: r, dir: e, layer: o }) => {
688
- const t = We(r, o), n = Ie();
689
- await D("styles.module.css", t, e), await D("index.ts", n, e);
690
- }, Ge = (r) => {
691
- const e = r.trim().toLowerCase();
688
+ `, D = async (t, e, o) => {
689
+ await y.delete(t, o), await y.write(t, e, { directory: o });
690
+ }, ze = async ({ containerTokens: t, dir: e, layer: o }) => {
691
+ const r = We(t, o), s = Ie();
692
+ await D("styles.module.css", r, e), await D("index.ts", s, e);
693
+ }, Ge = (t) => {
694
+ const e = t.trim().toLowerCase();
692
695
  return e === "0" || e === "0px";
693
- }, Je = (r, e) => Object.keys(r).filter((s) => !isNaN(Number(s))).sort((s, a) => Number(a) - Number(s)).reduce((s, a) => {
694
- const i = r[a];
696
+ }, Je = (t, e) => Object.keys(t).filter((n) => !isNaN(Number(n))).sort((n, a) => Number(a) - Number(n)).reduce((n, a) => {
697
+ const i = t[a];
695
698
  if (!i || !("value" in i) || !Array.isArray(i.value))
696
- return s;
699
+ return n;
697
700
  const l = i.value.find((u) => u.pattern === "columns");
698
701
  if (!(l != null && l.offset))
699
- return s;
702
+ return n;
700
703
  const c = e.resolveVariableValueString(l.offset);
701
- return !c || typeof c != "string" || Ge(c) ? s : [
702
- ...s,
704
+ return !c || typeof c != "string" || Ge(c) ? n : [
705
+ ...n,
703
706
  {
704
707
  breakpoint: Number(a),
705
708
  offset: c
706
709
  }
707
710
  ];
708
- }, []).reduce((s, a) => {
709
- const i = s[s.length - 1];
710
- return i && x(i.offset, a.offset) || s.push(a), s;
711
+ }, []).reduce((n, a) => {
712
+ const i = n[n.length - 1];
713
+ return i && x(i.offset, a.offset) || n.push(a), n;
711
714
  }, []), qt = ({
712
- input: r = {},
715
+ input: t = {},
713
716
  output: { dir: e }
714
717
  }) => ({
715
718
  name: "container/tokenManager",
716
719
  executor: async ({ tokenManagerClient: o }) => {
717
720
  try {
718
721
  console.log("[container/tokenManager] Generating container styles...");
719
- const { layer: t } = r;
722
+ const { layer: r } = t;
720
723
  if (!o.isLoaded())
721
724
  throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
722
725
  console.log("[container/tokenManager] Extracting container tokens...");
723
- const n = o.getStyles();
724
- if (!n.grid)
726
+ const s = o.getStyles();
727
+ if (!s.grid)
725
728
  throw new Error("No grid styles found in TokenManager. Grid tokens must be loaded.");
726
- const s = Je(n.grid, o);
727
- if (!s.length) {
729
+ const n = Je(s.grid, o);
730
+ if (!n.length) {
728
731
  console.warn("[container/tokenManager] No container tokens found.");
729
732
  return;
730
733
  }
731
734
  console.log(
732
- `[container/tokenManager] Found ${s.length} container tokens: ${s.map((a) => a.breakpoint).join(", ")}`
735
+ `[container/tokenManager] Found ${n.length} container tokens: ${n.map((a) => a.breakpoint).join(", ")}`
733
736
  ), console.log(`[container/tokenManager] Writing files to ${e}...`), await ze({
734
- containerTokens: s,
737
+ containerTokens: n,
735
738
  dir: e,
736
- layer: t
739
+ layer: r
737
740
  }), console.log("[container/tokenManager] ✅ Successfully generated container files");
738
- } catch (t) {
739
- const n = t instanceof Error ? t.message : String(t);
740
- throw console.error("[container/tokenManager] ❌ Failed to generate container:", n), t instanceof Error && t.stack && console.error("[container/tokenManager] Stack trace:", t.stack), t;
741
+ } catch (r) {
742
+ const s = r instanceof Error ? r.message : String(r);
743
+ throw console.error("[container/tokenManager] ❌ Failed to generate container:", s), r instanceof Error && r.stack && console.error("[container/tokenManager] Stack trace:", r.stack), r;
741
744
  }
742
745
  }
743
- }), qe = "styles.css", He = "index.ts", U = (r, e) => {
746
+ }), qe = "styles.css", He = "index.ts", U = (t, e) => {
744
747
  if (!e.length) return "";
745
- const o = e.map((t) => ` ${t}`).join(`
748
+ const o = e.map((r) => ` ${r}`).join(`
746
749
  `);
747
- return `${r} {
750
+ return `${t} {
748
751
  ${o}
749
752
  }`;
750
- }, Ze = (r) => `.${r.replace(/\s+/g, "-").toLowerCase()}`, Y = (r) => `--${r}`, Qe = ({ offsetX: r, offsetY: e, blur: o, spread: t, color: n }) => `${r} ${e} ${o} ${t} ${n}`, Xe = (r) => r.reduce(
753
+ }, Ze = (t) => `.${t.replace(/\s+/g, "-").toLowerCase()}`, Y = (t) => `--${t}`, Qe = ({ offsetX: t, offsetY: e, blur: o, spread: r, color: s }) => `${t} ${e} ${o} ${r} ${s}`, Xe = (t) => t.reduce(
751
754
  (e, o) => {
752
- const t = Y(o.name);
753
- return typeof o.value != "object" ? (e.root.push(`${t}: ${o.value};`), e) : Object.entries(o.value).reduce((n, [s, a]) => {
754
- const i = n[s] ?? [];
755
- return { ...n, [s]: [...i, `${t}: ${a};`] };
755
+ const r = Y(o.name);
756
+ return typeof o.value != "object" ? (e.root.push(`${r}: ${o.value};`), e) : Object.entries(o.value).reduce((s, [n, a]) => {
757
+ const i = s[n] ?? [];
758
+ return { ...s, [n]: [...i, `${r}: ${a};`] };
756
759
  }, e);
757
760
  },
758
761
  { root: [] }
759
- ), Ye = (r) => {
760
- const e = U(".shadow-variables", r.root), o = Object.entries(r).reduce((t, [n, s]) => {
761
- if (n === "root" || !s.length) return t;
762
- const a = U(Ze(`${n}-shadow-variables`), s);
763
- return a && t.push(a), t;
762
+ ), Ye = (t) => {
763
+ const e = U(".shadow-variables", t.root), o = Object.entries(t).reduce((r, [s, n]) => {
764
+ if (s === "root" || !n.length) return r;
765
+ const a = U(Ze(`${s}-shadow-variables`), n);
766
+ return a && r.push(a), r;
764
767
  }, []).join(`
765
768
 
766
769
  `);
767
770
  return [e, o].filter(Boolean).join(`
768
771
 
769
772
  `);
770
- }, _e = (r) => `${`const shadows = {
771
- ${r.map((t) => ` '${t.name}': 'var(${Y(t.name)})'`).join(`,
773
+ }, _e = (t) => `${`const shadows = {
774
+ ${t.map((r) => ` '${r.name}': 'var(${Y(r.name)})'`).join(`,
772
775
  `)}
773
776
  } as const;`}
774
777
 
@@ -776,93 +779,93 @@ type ShadowsKeysType = keyof typeof shadows;
776
779
 
777
780
  export { shadows, type ShadowsKeysType };
778
781
  `, et = async ({
779
- tsContent: r,
782
+ tsContent: t,
780
783
  cssContent: e,
781
784
  dir: o
782
785
  }) => {
783
786
  await y.delete(o);
784
- const t = y.write(He, r, { directory: o }), n = y.write(qe, e, { directory: o });
785
- await Promise.all([t, n]);
786
- }, tt = async ({ shadowTokens: r, dir: e }) => {
787
- const o = Xe(r), t = Ye(o), n = _e(r);
788
- await et({ tsContent: n, cssContent: t, dir: e });
789
- }, _ = (r, e) => Object.keys(r).reduce(
790
- (o, t) => {
791
- const n = r[t], s = e ? `${e}-${t}` : t;
792
- if (n && typeof n == "object" && "type" in n && "value" in n) {
787
+ const r = y.write(He, t, { directory: o }), s = y.write(qe, e, { directory: o });
788
+ await Promise.all([r, s]);
789
+ }, tt = async ({ shadowTokens: t, dir: e }) => {
790
+ const o = Xe(t), r = Ye(o), s = _e(t);
791
+ await et({ tsContent: s, cssContent: r, dir: e });
792
+ }, _ = (t, e) => Object.keys(t).reduce(
793
+ (o, r) => {
794
+ const s = t[r], n = e ? `${e}-${r}` : r;
795
+ if (s && typeof s == "object" && "type" in s && "value" in s) {
793
796
  const i = {
794
- [s]: n.value.map(Qe).join(", ")
797
+ [n]: s.value.map(Qe).join(", ")
795
798
  };
796
799
  return { ...o, ...i };
797
800
  }
798
- const a = _(n, s);
801
+ const a = _(s, n);
799
802
  return { ...o, ...a };
800
803
  },
801
804
  {}
802
- ), Ht = ({ input: r = {}, output: { dir: e } }) => ({
805
+ ), Ht = ({ input: t = {}, output: { dir: e } }) => ({
803
806
  name: "shadows/tokenManager",
804
807
  executor: async ({ tokenManagerClient: o }) => {
805
808
  try {
806
809
  console.log("[shadows/tokenManager] Generating shadows from TokenManager...");
807
- const { includeStyles: t = !0 } = r;
808
- if (!t)
810
+ const { includeStyles: r = !0 } = t;
811
+ if (!r)
809
812
  throw new Error("includeStyles must be enabled for shadows generation");
810
813
  if (!o.isLoaded())
811
814
  throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
812
- const n = [];
813
- if (t) {
815
+ const s = [];
816
+ if (r) {
814
817
  const a = o.getStyles();
815
- console.log("[shadows/tokenManager] Processing styles for shadows..."), a.effect && n.push(a.effect);
818
+ console.log("[shadows/tokenManager] Processing styles for shadows..."), a.effect && s.push(a.effect);
816
819
  }
817
- const s = n.flatMap(
820
+ const n = s.flatMap(
818
821
  (a) => Object.entries(_(a, "")).reduce(
819
822
  (i, [l, c]) => [...i, { name: l, value: c }],
820
823
  []
821
824
  )
822
825
  );
823
- if (s.length === 0) {
826
+ if (n.length === 0) {
824
827
  console.warn("[shadows/tokenManager] No shadow tokens generated");
825
828
  return;
826
829
  }
827
- console.log(`[shadows/tokenManager] Generated ${s.length} shadow tokens`), console.log(`[shadows/tokenManager] Writing files to ${e}...`), await tt({
828
- shadowTokens: s,
830
+ console.log(`[shadows/tokenManager] Generated ${n.length} shadow tokens`), console.log(`[shadows/tokenManager] Writing files to ${e}...`), await tt({
831
+ shadowTokens: n,
829
832
  dir: e
830
833
  }), console.log("[shadows/tokenManager] ✅ Successfully generated shadow files");
831
- } catch (t) {
832
- const n = t instanceof Error ? t.message : String(t);
833
- throw console.error("[shadows/tokenManager] ❌ Failed to generate shadows:", n), t instanceof Error && t.stack && console.error("[shadows/tokenManager] Stack trace:", t.stack), t;
834
+ } catch (r) {
835
+ const s = r instanceof Error ? r.message : String(r);
836
+ throw console.error("[shadows/tokenManager] ❌ Failed to generate shadows:", s), r instanceof Error && r.stack && console.error("[shadows/tokenManager] Stack trace:", r.stack), r;
834
837
  }
835
838
  }
836
- }), rt = "styles.module.css", ot = "index.ts", nt = "typography.ts", L = "sans-serif", W = (r, e) => {
839
+ }), rt = "styles.module.css", ot = "index.ts", st = "typography.ts", L = "sans-serif", W = (t, e) => {
837
840
  if (!e.length) return "";
838
- const o = e.map((t) => ` ${t}`).join(`
841
+ const o = e.map((r) => ` ${r}`).join(`
839
842
  `);
840
- return `${r} {
843
+ return `${t} {
841
844
  ${o}
842
845
  }`;
843
- }, ee = (r, e) => {
844
- if (typeof r != "string") return r;
845
- const o = e[r] ?? r;
846
+ }, ee = (t, e) => {
847
+ if (typeof t != "string") return t;
848
+ const o = e[t] ?? t;
846
849
  return o.trim().toLowerCase().endsWith(L) ? o : `${o}, ${L}`;
847
- }, I = (r, e) => typeof r.fontFamily != "string" ? r : {
848
- ...r,
849
- fontFamily: ee(r.fontFamily, e)
850
- }, T = (r, e) => {
850
+ }, I = (t, e) => typeof t.fontFamily != "string" ? t : {
851
+ ...t,
852
+ fontFamily: ee(t.fontFamily, e)
853
+ }, T = (t, e) => {
851
854
  const o = {};
852
- return Object.entries(r).forEach(([t, n]) => {
853
- const s = t === "fontFamily" ? ee(n, e) : n, a = t.replace(/([A-Z])/g, "-$1");
854
- o[a] = s;
855
+ return Object.entries(t).forEach(([r, s]) => {
856
+ const n = r === "fontFamily" ? ee(s, e) : s, a = r.replace(/([A-Z])/g, "-$1");
857
+ o[a] = n;
855
858
  }), o;
856
- }, st = (r, e, o) => {
857
- const t = Object.keys(r.breakpoints), n = T(r.base, o);
858
- return t.reduce(
859
- (s, a, i) => {
860
- const l = T(r.breakpoints[a], o);
861
- return i ? [...s, { breakpoint: Number(e[a]), css: l }] : [
859
+ }, nt = (t, e, o) => {
860
+ const r = Object.keys(t.breakpoints), s = T(t.base, o);
861
+ return r.reduce(
862
+ (n, a, i) => {
863
+ const l = T(t.breakpoints[a], o);
864
+ return i ? [...n, { breakpoint: Number(e[a]), css: l }] : [
862
865
  {
863
866
  breakpoint: null,
864
867
  css: {
865
- ...n,
868
+ ...s,
866
869
  ...l
867
870
  }
868
871
  }
@@ -871,78 +874,78 @@ ${o}
871
874
  [
872
875
  {
873
876
  breakpoint: null,
874
- css: n
877
+ css: s
875
878
  }
876
879
  ]
877
880
  );
878
881
  }, te = () => ({
879
882
  base: {},
880
883
  breakpoints: {}
881
- }), P = (r, e, o, t) => {
882
- Object.keys(t).length && (r.breakpoints[e] || (r.breakpoints[e] = {}), r.breakpoints[e][o] = {
883
- ...r.breakpoints[e][o],
884
- ...t
884
+ }), P = (t, e, o, r) => {
885
+ Object.keys(r).length && (t.breakpoints[e] || (t.breakpoints[e] = {}), t.breakpoints[e][o] = {
886
+ ...t.breakpoints[e][o],
887
+ ...r
885
888
  });
886
- }, j = (r, e, o, t) => {
887
- st(e.value, o, t).forEach(({ breakpoint: s, css: a }) => {
888
- if (s === null) {
889
- r.base[e.name] = a;
889
+ }, j = (t, e, o, r) => {
890
+ nt(e.value, o, r).forEach(({ breakpoint: n, css: a }) => {
891
+ if (n === null) {
892
+ t.base[e.name] = a;
890
893
  return;
891
894
  }
892
- P(r, s, e.name, a);
895
+ P(t, n, e.name, a);
893
896
  });
894
- }, re = (r) => {
895
- const e = z(r.base), o = Object.keys(r.breakpoints).map(Number).sort((t, n) => n - t).reduce((t, n) => {
896
- const s = r.breakpoints[n];
897
- return t + `@media (max-width: ${n}px) { ${z(s)} }`;
897
+ }, re = (t) => {
898
+ const e = z(t.base), o = Object.keys(t.breakpoints).map(Number).sort((r, s) => s - r).reduce((r, s) => {
899
+ const n = t.breakpoints[s];
900
+ return r + `@media (max-width: ${s}px) { ${z(n)} }`;
898
901
  }, "");
899
902
  return e + o;
900
- }, at = (r, e, o) => {
901
- const t = r.reduce((n, s) => (j(n, s, e, o), n), te());
902
- return re(t);
903
- }, z = (r) => Object.keys(r).reduce((e, o) => {
904
- const t = r[o], n = Object.keys(t).map((s) => `${s}: ${t[s]}`).join(";");
905
- return e + `.typo-${o} { ${n} }`;
906
- }, ""), G = (r) => {
907
- if (typeof r == "number") return Number.isFinite(r) ? r : null;
908
- const e = Number.parseFloat(r);
903
+ }, at = (t, e, o) => {
904
+ const r = t.reduce((s, n) => (j(s, n, e, o), s), te());
905
+ return re(r);
906
+ }, z = (t) => Object.keys(t).reduce((e, o) => {
907
+ const r = t[o], s = Object.keys(r).map((n) => `${n}: ${r[n]}`).join(";");
908
+ return e + `.typo-${o} { ${s} }`;
909
+ }, ""), G = (t) => {
910
+ if (typeof t == "number") return Number.isFinite(t) ? t : null;
911
+ const e = Number.parseFloat(t);
909
912
  return Number.isFinite(e) ? e : null;
910
- }, J = (r) => {
911
- if (typeof r == "number") return r / 16;
912
- const e = r.trim().toLowerCase();
913
+ }, J = (t) => {
914
+ if (typeof t == "number") return t / 16;
915
+ const e = t.trim().toLowerCase();
913
916
  if (e.endsWith("rem")) return G(e);
914
917
  if (e.endsWith("px")) {
915
918
  const o = G(e);
916
919
  return o === null ? null : o / 16;
917
920
  }
918
921
  return null;
919
- }, it = (r) => {
920
- const { minValueRem: e, maxValueRem: o, minVwRem: t, maxVwRem: n } = r, s = o - e;
921
- return `calc(${e}rem + ((100vw - ${t}rem) / (${n}rem - ${t}rem)) * ${s}rem)`;
922
- }, lt = (r, e, o, t) => {
923
- const n = ["font-size", "line-height"], s = Object.entries(e.value.breakpoints).map(([g, h]) => {
922
+ }, it = (t) => {
923
+ const { minValueRem: e, maxValueRem: o, minVwRem: r, maxVwRem: s } = t, n = o - e;
924
+ return `calc(${e}rem + ((100vw - ${r}rem) / (${s}rem - ${r}rem)) * ${n}rem)`;
925
+ }, lt = (t, e, o, r) => {
926
+ const s = ["font-size", "line-height"], n = Object.entries(e.value.breakpoints).map(([g, h]) => {
924
927
  const b = Number.parseInt(o[g], 10);
925
928
  return { breakpointName: g, width: b, typography: h };
926
929
  }).filter((g) => Number.isFinite(g.width)).sort((g, h) => h.width - g.width);
927
- if (s.length < 2) {
928
- j(r, e, o, t);
930
+ if (n.length < 2) {
931
+ j(t, e, o, r);
929
932
  return;
930
933
  }
931
- const a = s[0], i = s[s.length - 1];
934
+ const a = n[0], i = n[n.length - 1];
932
935
  if (a.width <= i.width) {
933
- j(r, e, o, t);
936
+ j(t, e, o, r);
934
937
  return;
935
938
  }
936
- const l = T(e.value.base, t), c = T(a.typography, t), u = T(i.typography, t), d = a.width / 16, f = i.width / 16;
939
+ const l = T(e.value.base, r), c = T(a.typography, r), u = T(i.typography, r), d = a.width / 16, f = i.width / 16;
937
940
  if (d === f) {
938
- j(r, e, o, t);
941
+ j(t, e, o, r);
939
942
  return;
940
943
  }
941
- r.base[e.name] = {
944
+ t.base[e.name] = {
942
945
  ...l,
943
946
  ...c
944
947
  };
945
- const m = n.reduce((g, h) => {
948
+ const m = s.reduce((g, h) => {
946
949
  const b = c[h], S = u[h];
947
950
  if (b === void 0 || S === void 0 || b === S)
948
951
  return g;
@@ -952,12 +955,12 @@ ${o}
952
955
  [h]: it({ minValueRem: B, maxValueRem: E, minVwRem: f, maxVwRem: d })
953
956
  };
954
957
  }, {});
955
- P(r, a.width, e.name, m), P(r, i.width, e.name, u);
956
- }, ct = (r, e, o, t) => {
957
- if (!t) return at(r, e, o);
958
- const n = r.reduce((s, a) => (lt(s, a, e, o), s), te());
959
- return re(n);
960
- }, ut = (r) => r.length ? `import styles from './styles.module.css';
958
+ P(t, a.width, e.name, m), P(t, i.width, e.name, u);
959
+ }, ct = (t, e, o, r) => {
960
+ if (!r) return at(t, e, o);
961
+ const s = t.reduce((n, a) => (lt(n, a, e, o), n), te());
962
+ return re(s);
963
+ }, ut = (t) => t.length ? `import styles from './styles.module.css';
961
964
  import { typography } from './typography';
962
965
 
963
966
  type TypographyKeysType = keyof typeof typography;
@@ -965,19 +968,19 @@ type TypographyKeysType = keyof typeof typography;
965
968
  const getTypographyClass = (typographyKey: TypographyKeysType) => styles[\`typo-\${typographyKey}\`];
966
969
 
967
970
  export { typography, getTypographyClass, type TypographyKeysType };
968
- ` : "", dt = (r, e) => r.length ? `const typography = {
969
- ${r.map((t) => {
970
- const n = I(t.value.base, e), s = Object.entries(t.value.breakpoints).reduce(
971
+ ` : "", dt = (t, e) => t.length ? `const typography = {
972
+ ${t.map((r) => {
973
+ const s = I(r.value.base, e), n = Object.entries(r.value.breakpoints).reduce(
971
974
  (a, [i, l]) => ({
972
975
  ...a,
973
976
  [i]: I(l, e)
974
977
  }),
975
978
  {}
976
979
  );
977
- return ` '${t.name}': {
978
- base: ${JSON.stringify(n, null, 8).replace(/\n/g, `
980
+ return ` '${r.name}': {
981
+ base: ${JSON.stringify(s, null, 8).replace(/\n/g, `
979
982
  `)},
980
- breakpoints: ${JSON.stringify(s, null, 8).replace(/\n/g, `
983
+ breakpoints: ${JSON.stringify(n, null, 8).replace(/\n/g, `
981
984
  `)}
982
985
  }`;
983
986
  }).join(`,
@@ -986,30 +989,30 @@ ${r.map((t) => {
986
989
 
987
990
  export { typography };
988
991
  ` : "", yt = async ({
989
- indexTSContent: r,
992
+ indexTSContent: t,
990
993
  typographyTSContent: e,
991
994
  cssContent: o,
992
- dir: t
995
+ dir: r
993
996
  }) => {
994
- await y.delete(t);
995
- const n = y.write(ot, r, { directory: t }), s = y.write(nt, e, { directory: t }), a = y.write(rt, o, { directory: t });
996
- await Promise.all([n, s, a]);
997
+ await y.delete(r);
998
+ const s = y.write(ot, t, { directory: r }), n = y.write(st, e, { directory: r }), a = y.write(rt, o, { directory: r });
999
+ await Promise.all([s, n, a]);
997
1000
  }, ft = async ({
998
- typographyTokens: r,
1001
+ typographyTokens: t,
999
1002
  dir: e,
1000
1003
  breakpoints: o,
1001
- fontFamily: t,
1002
- fluid: n
1004
+ fontFamily: r,
1005
+ fluid: s
1003
1006
  }) => {
1004
- const s = ct(r, o, t, n), a = dt(r, t), i = ut(r);
1005
- await yt({ indexTSContent: i, typographyTSContent: a, cssContent: s, dir: e });
1006
- }, oe = (r, e, o) => Object.keys(r).reduce((t, n) => {
1007
- const s = r[n];
1008
- if (typeof s != "object" || Array.isArray(s)) return t;
1009
- if (!("type" in s) || !("value" in s))
1010
- return { ...t, [n]: oe(s, e, o) };
1011
- if (s.type !== "typography") return t;
1012
- const a = s.value, i = Object.entries(a).reduce(
1007
+ const n = ct(t, o, r, s), a = dt(t, r), i = ut(t);
1008
+ await yt({ indexTSContent: i, typographyTSContent: a, cssContent: n, dir: e });
1009
+ }, oe = (t, e, o) => Object.keys(t).reduce((r, s) => {
1010
+ const n = t[s];
1011
+ if (typeof n != "object" || Array.isArray(n)) return r;
1012
+ if (!("type" in n) || !("value" in n))
1013
+ return { ...r, [s]: oe(n, e, o) };
1014
+ if (n.type !== "typography") return r;
1015
+ const a = n.value, i = Object.entries(a).reduce(
1013
1016
  (l, [c, u]) => {
1014
1017
  const d = Object.keys(o.breakpoints);
1015
1018
  if (d.length)
@@ -1025,19 +1028,19 @@ export { typography };
1025
1028
  },
1026
1029
  { base: {}, breakpoints: {} }
1027
1030
  );
1028
- return { ...t, [n]: { type: "typography", value: i } };
1029
- }, {}), ne = (r, e) => Object.keys(r).reduce((o, t) => {
1030
- const n = e ? `${e}-${t}` : t, s = r[t];
1031
- if (!("type" in s) || !("value" in s))
1032
- return { ...o, ...ne(s, n) };
1033
- const a = s.value;
1034
- return { ...o, [n]: a };
1035
- }, {}), Zt = ({ input: r, output: { dir: e } }) => ({
1031
+ return { ...r, [s]: { type: "typography", value: i } };
1032
+ }, {}), se = (t, e) => Object.keys(t).reduce((o, r) => {
1033
+ const s = e ? `${e}-${r}` : r, n = t[r];
1034
+ if (!("type" in n) || !("value" in n))
1035
+ return { ...o, ...se(n, s) };
1036
+ const a = n.value;
1037
+ return { ...o, [s]: a };
1038
+ }, {}), Zt = ({ input: t, output: { dir: e } }) => ({
1036
1039
  name: "typography/tokenManager",
1037
1040
  executor: async ({ tokenManagerClient: o }) => {
1038
1041
  try {
1039
1042
  console.log("[typography/tokenManager] Generating typography from TokenManager...");
1040
- const { breakpoints: t, fontFamily: n } = r, s = r.fluid ?? !0;
1043
+ const { breakpoints: r, fontFamily: s } = t, n = t.fluid ?? !0;
1041
1044
  if (!o.isLoaded())
1042
1045
  throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
1043
1046
  const a = [], i = o.getStyles();
@@ -1045,10 +1048,10 @@ export { typography };
1045
1048
  const l = a.reduce(
1046
1049
  (u, d) => ({
1047
1050
  ...u,
1048
- ...oe(d, o, { breakpoints: r.breakpoints })
1051
+ ...oe(d, o, { breakpoints: t.breakpoints })
1049
1052
  }),
1050
1053
  {}
1051
- ), c = Object.entries(ne(l)).map(
1054
+ ), c = Object.entries(se(l)).map(
1052
1055
  ([u, d]) => ({ name: u, value: d })
1053
1056
  );
1054
1057
  if (c.length === 0) {
@@ -1058,41 +1061,41 @@ export { typography };
1058
1061
  console.log(`[typography/tokenManager] Generated ${c.length} typography tokens`), console.log(`[typography/tokenManager] Writing files to ${e}...`), await ft({
1059
1062
  typographyTokens: c,
1060
1063
  dir: e,
1061
- breakpoints: t,
1062
- fontFamily: n || {},
1063
- fluid: s
1064
+ breakpoints: r,
1065
+ fontFamily: s || {},
1066
+ fluid: n
1064
1067
  }), console.log("[typography/tokenManager] ✅ Successfully generated typography files");
1065
- } catch (t) {
1066
- const n = t instanceof Error ? t.message : String(t);
1067
- throw console.error("[typography/tokenManager] ❌ Failed to generate typography:", n), t instanceof Error && t.stack && console.error("[typography/tokenManager] Stack trace:", t.stack), t;
1068
+ } catch (r) {
1069
+ const s = r instanceof Error ? r.message : String(r);
1070
+ throw console.error("[typography/tokenManager] ❌ Failed to generate typography:", s), r instanceof Error && r.stack && console.error("[typography/tokenManager] Stack trace:", r.stack), r;
1068
1071
  }
1069
1072
  }
1070
- }), gt = (r) => typeof r == "object" && r !== null && "type" in r && "value" in r, pt = (r) => typeof r == "object" && r !== null && !Array.isArray(r), se = (r) => r.trim().split(".").map((e) => e.trim()).filter(Boolean), ht = (r, e) => {
1071
- const o = se(e);
1073
+ }), gt = (t) => typeof t == "object" && t !== null && "type" in t && "value" in t, pt = (t) => typeof t == "object" && t !== null && !Array.isArray(t), ne = (t) => t.trim().split(".").map((e) => e.trim()).filter(Boolean), ht = (t, e) => {
1074
+ const o = ne(e);
1072
1075
  if (!o.length)
1073
1076
  throw new Error("variablePath must contain at least one segment");
1074
- const t = q(r, o);
1075
- if (t === void 0)
1077
+ const r = q(t, o);
1078
+ if (r === void 0)
1076
1079
  throw new Error(`Variables subtree not found at path: ${o.join(".")}`);
1077
- return t;
1078
- }, ae = (r, e, o) => {
1079
- if (!r) return [];
1080
- if (gt(r)) {
1081
- if (r.type !== "dimension") return [];
1082
- const t = r.value, n = Object.keys(t).reduce((s, a) => {
1083
- const i = t[a], l = o.resolveVariableValueString(i, a);
1084
- return { ...s, [a]: l ?? i };
1080
+ return r;
1081
+ }, ae = (t, e, o) => {
1082
+ if (!t) return [];
1083
+ if (gt(t)) {
1084
+ if (t.type !== "dimension") return [];
1085
+ const r = t.value, s = Object.keys(r).reduce((n, a) => {
1086
+ const i = r[a], l = o.resolveVariableValueString(i, a);
1087
+ return { ...n, [a]: l ?? i };
1085
1088
  }, {});
1086
- return [{ flatName: e, resolvedByMode: n }];
1089
+ return [{ flatName: e, resolvedByMode: s }];
1087
1090
  }
1088
- return pt(r) ? Object.keys(r).flatMap((t) => {
1089
- const n = r[t], s = e ? `${e}-${t}` : t;
1090
- return ae(n, s, o);
1091
+ return pt(t) ? Object.keys(t).flatMap((r) => {
1092
+ const s = t[r], n = e ? `${e}-${r}` : r;
1093
+ return ae(s, n, o);
1091
1094
  }) : [];
1092
- }, mt = (r, e) => ae(r, "", e), bt = (r, e) => typeof e == "string" ? r === e : e.test(r), wt = (r, e) => e != null && e.length ? r.filter(
1093
- (o) => e.some((t) => bt(o.flatName, t))
1094
- ) : r, kt = (r) => Object.keys(r).map((e) => ({ mode: e, widthPx: Number.parseInt(r[e], 10) })).filter((e) => Number.isFinite(e.widthPx)).sort((e, o) => o.widthPx - e.widthPx), ie = (r) => {
1095
- const e = se(r);
1095
+ }, mt = (t, e) => ae(t, "", e), bt = (t, e) => typeof e == "string" ? t === e : e.test(t), wt = (t, e) => e != null && e.length ? t.filter(
1096
+ (o) => e.some((r) => bt(o.flatName, r))
1097
+ ) : t, kt = (t) => Object.keys(t).map((e) => ({ mode: e, widthPx: Number.parseInt(t[e], 10) })).filter((e) => Number.isFinite(e.widthPx)).sort((e, o) => o.widthPx - e.widthPx), ie = (t) => {
1098
+ const e = ne(t);
1096
1099
  if (!e.length)
1097
1100
  throw new Error("variablePath must contain at least one segment");
1098
1101
  const o = e[e.length - 1];
@@ -1100,63 +1103,63 @@ export { typography };
1100
1103
  variablesClassName: `${o}-variables`,
1101
1104
  variableNamePrefix: o
1102
1105
  };
1103
- }, $t = (r, e) => {
1104
- const t = ie(r.variablePath).variableNamePrefix, n = e.variablesClassName ?? `${t}-variables`;
1106
+ }, $t = (t, e) => {
1107
+ const r = ie(t.variablePath).variableNamePrefix, s = e.variablesClassName ?? `${r}-variables`;
1105
1108
  return {
1106
- variableNamePrefix: t,
1107
- variablesClassName: n
1109
+ variableNamePrefix: r,
1110
+ variablesClassName: s
1108
1111
  };
1109
- }, le = (r, e) => `${ie(r).variableNamePrefix}-${e}`, Qt = (r, e) => `--${le(r, e)}`, St = (r) => `--${r}`, ce = (r, e, o) => {
1110
- const t = le(r.variablePath, o);
1112
+ }, le = (t, e) => `${ie(t).variableNamePrefix}-${e}`, Qt = (t, e) => `--${le(t, e)}`, St = (t) => `--${t}`, ce = (t, e, o) => {
1113
+ const r = le(t.variablePath, o);
1111
1114
  if (!e.parseCssVariableName)
1112
- return t;
1113
- const n = e.parseCssVariableName({
1114
- variablePath: r.variablePath,
1115
+ return r;
1116
+ const s = e.parseCssVariableName({
1117
+ variablePath: t.variablePath,
1115
1118
  flatName: o,
1116
- defaultName: t
1119
+ defaultName: r
1117
1120
  });
1118
- return n.trim() ? n : t;
1119
- }, Tt = (r, e) => Object.keys(e).reduce(
1120
- (o, t) => {
1121
- const n = Number(t);
1122
- return { ...o, [n]: { ...o[n], ...e[n] } };
1121
+ return s.trim() ? s : r;
1122
+ }, Tt = (t, e) => Object.keys(e).reduce(
1123
+ (o, r) => {
1124
+ const s = Number(r);
1125
+ return { ...o, [s]: { ...o[s], ...e[s] } };
1123
1126
  },
1124
- { ...r }
1125
- ), jt = (r, e, o) => {
1126
- const { breakpoints: t } = e, n = ce(e, o, r.flatName), s = St(n), a = kt(t);
1127
- if (Object.keys(t).length === 0 || a.length === 0) {
1128
- const u = Object.values(r.resolvedByMode)[0] ?? "";
1129
- return { base: { [s]: u }, byBreakpoint: {} };
1127
+ { ...t }
1128
+ ), jt = (t, e, o) => {
1129
+ const { breakpoints: r } = e, s = ce(e, o, t.flatName), n = St(s), a = kt(r);
1130
+ if (Object.keys(r).length === 0 || a.length === 0) {
1131
+ const u = Object.values(t.resolvedByMode)[0] ?? "";
1132
+ return { base: { [n]: u }, byBreakpoint: {} };
1130
1133
  }
1131
- const i = a.filter((u) => u.mode in r.resolvedByMode);
1134
+ const i = a.filter((u) => u.mode in t.resolvedByMode);
1132
1135
  if (i.length === 0) {
1133
- const u = Object.values(r.resolvedByMode)[0] ?? "";
1134
- return { base: { [s]: u }, byBreakpoint: {} };
1136
+ const u = Object.values(t.resolvedByMode)[0] ?? "";
1137
+ return { base: { [n]: u }, byBreakpoint: {} };
1135
1138
  }
1136
1139
  if (i.length === 1) {
1137
- const u = i[0], d = r.resolvedByMode[u.mode] ?? "";
1138
- return { base: { [s]: d }, byBreakpoint: {} };
1140
+ const u = i[0], d = t.resolvedByMode[u.mode] ?? "";
1141
+ return { base: { [n]: d }, byBreakpoint: {} };
1139
1142
  }
1140
- const l = r.resolvedByMode[i[0].mode] ?? "", c = i.slice(1).reduce((u, d, f) => {
1141
- const m = i[f].mode, g = r.resolvedByMode[m], h = r.resolvedByMode[d.mode];
1143
+ const l = t.resolvedByMode[i[0].mode] ?? "", c = i.slice(1).reduce((u, d, f) => {
1144
+ const m = i[f].mode, g = t.resolvedByMode[m], h = t.resolvedByMode[d.mode];
1142
1145
  if (h === void 0 || h === g) return u;
1143
1146
  const b = d.widthPx, S = u[b] ?? {};
1144
- return { ...u, [b]: { ...S, [s]: h } };
1147
+ return { ...u, [b]: { ...S, [n]: h } };
1145
1148
  }, {});
1146
- return { base: { [s]: l }, byBreakpoint: c };
1147
- }, vt = (r, e, o) => r.reduce(
1148
- (t, n) => {
1149
- const { base: s, byBreakpoint: a } = jt(n, e, o);
1149
+ return { base: { [n]: l }, byBreakpoint: c };
1150
+ }, vt = (t, e, o) => t.reduce(
1151
+ (r, s) => {
1152
+ const { base: n, byBreakpoint: a } = jt(s, e, o);
1150
1153
  return {
1151
- base: { ...t.base, ...s },
1152
- breakpoints: Tt(t.breakpoints, a)
1154
+ base: { ...r.base, ...n },
1155
+ breakpoints: Tt(r.breakpoints, a)
1153
1156
  };
1154
1157
  },
1155
1158
  { base: {}, breakpoints: {} }
1156
- ), Nt = (r, e, o) => {
1157
- if (!r.length) return "";
1158
- const { variablesClassName: t } = $t(e, o), n = vt(r, e, o), s = Object.keys(n.base).map((l) => ` ${l}: ${n.base[l]};`), a = W(`.${t}`, s), i = Object.keys(n.breakpoints).map(Number).sort((l, c) => c - l).map((l) => {
1159
- const c = n.breakpoints[l], u = Object.keys(c).map((f) => ` ${f}: ${c[f]};`), d = W(`.${t}`, u);
1159
+ ), Nt = (t, e, o) => {
1160
+ if (!t.length) return "";
1161
+ const { variablesClassName: r } = $t(e, o), s = vt(t, e, o), n = Object.keys(s.base).map((l) => ` ${l}: ${s.base[l]};`), a = W(`.${r}`, n), i = Object.keys(s.breakpoints).map(Number).sort((l, c) => c - l).map((l) => {
1162
+ const c = s.breakpoints[l], u = Object.keys(c).map((f) => ` ${f}: ${c[f]};`), d = W(`.${r}`, u);
1160
1163
  return `@media (max-width: ${l}px) {
1161
1164
  ${d}
1162
1165
  }`;
@@ -1166,48 +1169,48 @@ ${d}
1166
1169
  return i ? `${a}
1167
1170
 
1168
1171
  ${i}` : a;
1169
- }, Mt = (r) => {
1170
- const e = r.split("-").map((o) => o.trim()).filter(Boolean);
1171
- return e[e.length - 1] ?? r;
1172
- }, Vt = (r, e, o) => {
1173
- const t = Mt(o);
1172
+ }, Mt = (t) => {
1173
+ const e = t.split("-").map((o) => o.trim()).filter(Boolean);
1174
+ return e[e.length - 1] ?? t;
1175
+ }, Vt = (t, e, o) => {
1176
+ const r = Mt(o);
1174
1177
  if (!e.parseUtilityKey)
1175
- return t;
1176
- const n = e.parseUtilityKey({
1177
- variablePath: r.variablePath,
1178
+ return r;
1179
+ const s = e.parseUtilityKey({
1180
+ variablePath: t.variablePath,
1178
1181
  flatName: o,
1179
- defaultKey: t
1182
+ defaultKey: r
1180
1183
  });
1181
- return n.trim() ? n : t;
1182
- }, Ct = /^[A-Za-z_$][A-Za-z0-9_$]*$/, Ft = (r) => {
1183
- var t;
1184
- const o = ((t = r.utilityKeysTypeName) == null ? void 0 : t.trim()) || "UtilitiesKeysType";
1184
+ return s.trim() ? s : r;
1185
+ }, Ct = /^[A-Za-z_$][A-Za-z0-9_$]*$/, Ft = (t) => {
1186
+ var r;
1187
+ const o = ((r = t.utilityKeysTypeName) == null ? void 0 : r.trim()) || "UtilitiesKeysType";
1185
1188
  if (!Ct.test(o))
1186
1189
  throw new Error(
1187
1190
  `Invalid utilityKeysTypeName: "${o}". Expected a valid TypeScript identifier.`
1188
1191
  );
1189
1192
  return o;
1190
- }, xt = (r, e, o) => r.reduce((t, n) => {
1191
- const s = Vt(e, o, n.flatName), a = t[s];
1192
- if (a && a !== n.flatName)
1193
+ }, xt = (t, e, o) => t.reduce((r, s) => {
1194
+ const n = Vt(e, o, s.flatName), a = r[n];
1195
+ if (a && a !== s.flatName)
1193
1196
  throw new Error(
1194
- `Utility key collision: "${s}" is generated for both "${a}" and "${n.flatName}"`
1197
+ `Utility key collision: "${n}" is generated for both "${a}" and "${s.flatName}"`
1195
1198
  );
1196
1199
  return {
1197
- ...t,
1198
- [s]: n.flatName
1200
+ ...r,
1201
+ [n]: s.flatName
1199
1202
  };
1200
- }, {}), Pt = (r, e, o) => {
1203
+ }, {}), Pt = (t, e, o) => {
1201
1204
  var c;
1202
- const t = xt(r, e, o), n = Object.keys(t).reduce((u, d) => {
1203
- const f = t[d];
1205
+ const r = xt(t, e, o), s = Object.keys(r).reduce((u, d) => {
1206
+ const f = r[d];
1204
1207
  return {
1205
1208
  ...u,
1206
1209
  [d]: ce(e, o, f)
1207
1210
  };
1208
- }, {}), s = JSON.stringify(n, null, 4), i = ((c = o.getUtilityCssVarFunctionName) == null ? void 0 : c.trim()) || "getUtilityCssVar", l = Ft(o);
1211
+ }, {}), n = JSON.stringify(s, null, 4), i = ((c = o.getUtilityCssVarFunctionName) == null ? void 0 : c.trim()) || "getUtilityCssVar", l = Ft(o);
1209
1212
  return [
1210
- `const utilityVariableNameByKey = ${s} as const;`,
1213
+ `const utilityVariableNameByKey = ${n} as const;`,
1211
1214
  "",
1212
1215
  `type ${l} = keyof typeof utilityVariableNameByKey;`,
1213
1216
  "",
@@ -1226,39 +1229,39 @@ ${i}` : a;
1226
1229
  ].join(`
1227
1230
  `);
1228
1231
  }, Ot = "styles.css", Et = "index.ts", Bt = async ({
1229
- dir: r,
1232
+ dir: t,
1230
1233
  globalCss: e,
1231
1234
  indexTs: o
1232
1235
  }) => {
1233
- await y.delete(r), await Promise.all([
1234
- y.write(Ot, e, { directory: r }),
1235
- y.write(Et, o, { directory: r })
1236
+ await y.delete(t), await Promise.all([
1237
+ y.write(Ot, e, { directory: t }),
1238
+ y.write(Et, o, { directory: t })
1236
1239
  ]);
1237
1240
  }, Kt = async ({
1238
- tokens: r,
1241
+ tokens: t,
1239
1242
  input: e,
1240
1243
  output: o
1241
1244
  }) => {
1242
- const { dir: t } = o, n = Nt(r, e, o), s = Pt(r, e, o);
1243
- await Bt({ dir: t, globalCss: n, indexTs: s });
1244
- }, Xt = ({ input: r, output: e }) => ({
1245
+ const { dir: r } = o, s = Nt(t, e, o), n = Pt(t, e, o);
1246
+ await Bt({ dir: r, globalCss: s, indexTs: n });
1247
+ }, Xt = ({ input: t, output: e }) => ({
1245
1248
  name: "utilities/tokenManager",
1246
1249
  executor: async ({ tokenManagerClient: o }) => {
1247
- var t;
1250
+ var r;
1248
1251
  try {
1249
1252
  if (console.log("[utilities/tokenManager] Generating utility classes from TokenManager..."), !o.isLoaded())
1250
1253
  throw new Error("TokenManager is not loaded. Tokens must be loaded before using this module.");
1251
- const n = o.getVariables(), s = ht(n, r.variablePath), a = mt(s, o), i = wt(a, r.include);
1254
+ const s = o.getVariables(), n = ht(s, t.variablePath), a = mt(n, o), i = wt(a, t.include);
1252
1255
  if (!i.length) {
1253
- a.length && ((t = r.include) != null && t.length) ? console.warn(
1254
- `[utilities/tokenManager] No tokens left after include filter (${a.length} at path "${r.variablePath}")`
1255
- ) : console.warn(`[utilities/tokenManager] No dimension tokens found at path "${r.variablePath}"`);
1256
+ a.length && ((r = t.include) != null && r.length) ? console.warn(
1257
+ `[utilities/tokenManager] No tokens left after include filter (${a.length} at path "${t.variablePath}")`
1258
+ ) : console.warn(`[utilities/tokenManager] No dimension tokens found at path "${t.variablePath}"`);
1256
1259
  return;
1257
1260
  }
1258
- console.log(`[utilities/tokenManager] Resolved ${i.length} utility token(s)`), console.log(`[utilities/tokenManager] Writing files to ${e.dir}...`), await Kt({ tokens: i, input: r, output: e }), console.log("[utilities/tokenManager] ✅ Successfully generated utility files");
1259
- } catch (n) {
1260
- const s = n instanceof Error ? n.message : String(n);
1261
- throw console.error("[utilities/tokenManager] ❌ Failed to generate utilities:", s), n instanceof Error && n.stack && console.error("[utilities/tokenManager] Stack trace:", n.stack), n;
1261
+ console.log(`[utilities/tokenManager] Resolved ${i.length} utility token(s)`), console.log(`[utilities/tokenManager] Writing files to ${e.dir}...`), await Kt({ tokens: i, input: t, output: e }), console.log("[utilities/tokenManager] ✅ Successfully generated utility files");
1262
+ } catch (s) {
1263
+ const n = s instanceof Error ? s.message : String(s);
1264
+ throw console.error("[utilities/tokenManager] ❌ Failed to generate utilities:", n), s instanceof Error && s.stack && console.error("[utilities/tokenManager] Stack trace:", s.stack), s;
1262
1265
  }
1263
1266
  }
1264
1267
  });