@greensight/gts 1.0.0-beta.2 → 1.0.0-beta.4

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