boss-css 0.0.14 → 0.0.16

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.
Files changed (165) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +146 -1
  3. package/dist/ai/server.cjs +1 -0
  4. package/dist/ai/server.mjs +1 -0
  5. package/dist/ai/skills.cjs +3 -0
  6. package/dist/ai/skills.mjs +3 -0
  7. package/dist/cli/tasks/init.cjs +54 -30
  8. package/dist/cli/tasks/init.mjs +54 -30
  9. package/dist/cli/templates/init.cjs +5 -5
  10. package/dist/cli/templates/init.mjs +5 -5
  11. package/dist/devtools-app/index.mjs +320 -0
  12. package/dist/devtools-app/monaco/vs/_commonjsHelpers-CT9FvmAN.js +1 -0
  13. package/dist/devtools-app/monaco/vs/abap-D-t0cyap.js +1 -0
  14. package/dist/devtools-app/monaco/vs/apex-CcIm7xu6.js +1 -0
  15. package/dist/devtools-app/monaco/vs/assets/css.worker-HnVq6Ewq.js +93 -0
  16. package/dist/devtools-app/monaco/vs/assets/editor.worker-Be8ye1pW.js +26 -0
  17. package/dist/devtools-app/monaco/vs/assets/html.worker-B51mlPHg.js +470 -0
  18. package/dist/devtools-app/monaco/vs/assets/json.worker-DKiEKt88.js +58 -0
  19. package/dist/devtools-app/monaco/vs/assets/ts.worker-CMbG-7ft.js +67731 -0
  20. package/dist/devtools-app/monaco/vs/azcli-BA0tQDCg.js +1 -0
  21. package/dist/devtools-app/monaco/vs/basic-languages/monaco.contribution.js +1 -0
  22. package/dist/devtools-app/monaco/vs/bat-C397hTD6.js +1 -0
  23. package/dist/devtools-app/monaco/vs/bicep-DF5aW17k.js +2 -0
  24. package/dist/devtools-app/monaco/vs/cameligo-plsz8qhj.js +1 -0
  25. package/dist/devtools-app/monaco/vs/clojure-Y2auQMzK.js +1 -0
  26. package/dist/devtools-app/monaco/vs/coffee-Bu45yuWE.js +1 -0
  27. package/dist/devtools-app/monaco/vs/cpp-CkKPQIni.js +1 -0
  28. package/dist/devtools-app/monaco/vs/csharp-CX28MZyh.js +1 -0
  29. package/dist/devtools-app/monaco/vs/csp-D8uWnyxW.js +1 -0
  30. package/dist/devtools-app/monaco/vs/css-CaeNmE3S.js +3 -0
  31. package/dist/devtools-app/monaco/vs/cssMode-CjiAH6dQ.js +1 -0
  32. package/dist/devtools-app/monaco/vs/cypher-DVThT8BS.js +1 -0
  33. package/dist/devtools-app/monaco/vs/dart-CmGfCvrO.js +1 -0
  34. package/dist/devtools-app/monaco/vs/dockerfile-CZqqYdch.js +1 -0
  35. package/dist/devtools-app/monaco/vs/ecl-30fUercY.js +1 -0
  36. package/dist/devtools-app/monaco/vs/editor/editor.main.css +1 -0
  37. package/dist/devtools-app/monaco/vs/editor/editor.main.js +5 -0
  38. package/dist/devtools-app/monaco/vs/editor.api-CalNCsUg.js +903 -0
  39. package/dist/devtools-app/monaco/vs/elixir-xjPaIfzF.js +1 -0
  40. package/dist/devtools-app/monaco/vs/flow9-DqtmStfK.js +1 -0
  41. package/dist/devtools-app/monaco/vs/freemarker2-Cz_sV6Md.js +3 -0
  42. package/dist/devtools-app/monaco/vs/fsharp-BOMdg4U1.js +1 -0
  43. package/dist/devtools-app/monaco/vs/go-D_hbi-Jt.js +1 -0
  44. package/dist/devtools-app/monaco/vs/graphql-CKUU4kLG.js +1 -0
  45. package/dist/devtools-app/monaco/vs/handlebars-OwglfO-1.js +1 -0
  46. package/dist/devtools-app/monaco/vs/hcl-DTaboeZW.js +1 -0
  47. package/dist/devtools-app/monaco/vs/html-Pa1xEWsY.js +1 -0
  48. package/dist/devtools-app/monaco/vs/htmlMode-Bz67EXwp.js +1 -0
  49. package/dist/devtools-app/monaco/vs/ini-CsNwO04R.js +1 -0
  50. package/dist/devtools-app/monaco/vs/java-CI4ZMsH9.js +1 -0
  51. package/dist/devtools-app/monaco/vs/javascript-PczUCGdz.js +1 -0
  52. package/dist/devtools-app/monaco/vs/jsonMode-DULH5oaX.js +7 -0
  53. package/dist/devtools-app/monaco/vs/julia-BwzEvaQw.js +1 -0
  54. package/dist/devtools-app/monaco/vs/kotlin-IUYPiTV8.js +1 -0
  55. package/dist/devtools-app/monaco/vs/language/css/monaco.contribution.js +1 -0
  56. package/dist/devtools-app/monaco/vs/language/html/monaco.contribution.js +1 -0
  57. package/dist/devtools-app/monaco/vs/language/json/monaco.contribution.js +1 -0
  58. package/dist/devtools-app/monaco/vs/language/typescript/monaco.contribution.js +1 -0
  59. package/dist/devtools-app/monaco/vs/less-C0eDYdqa.js +2 -0
  60. package/dist/devtools-app/monaco/vs/lexon-iON-Kj97.js +1 -0
  61. package/dist/devtools-app/monaco/vs/liquid-DqKjdPGy.js +1 -0
  62. package/dist/devtools-app/monaco/vs/loader.js +1368 -0
  63. package/dist/devtools-app/monaco/vs/lspLanguageFeatures-kM9O9rjY.js +4 -0
  64. package/dist/devtools-app/monaco/vs/lua-DtygF91M.js +1 -0
  65. package/dist/devtools-app/monaco/vs/m3-CsR4AuFi.js +1 -0
  66. package/dist/devtools-app/monaco/vs/markdown-C_rD0bIw.js +1 -0
  67. package/dist/devtools-app/monaco/vs/mdx-DEWtB1K5.js +1 -0
  68. package/dist/devtools-app/monaco/vs/mips-CiYP61RB.js +1 -0
  69. package/dist/devtools-app/monaco/vs/monaco.contribution-D2OdxNBt.js +1 -0
  70. package/dist/devtools-app/monaco/vs/monaco.contribution-DO3azKX8.js +1 -0
  71. package/dist/devtools-app/monaco/vs/monaco.contribution-EcChJV6a.js +1 -0
  72. package/dist/devtools-app/monaco/vs/monaco.contribution-qLAYrEOP.js +1 -0
  73. package/dist/devtools-app/monaco/vs/msdax-C38-sJlp.js +1 -0
  74. package/dist/devtools-app/monaco/vs/mysql-CdtbpvbG.js +1 -0
  75. package/dist/devtools-app/monaco/vs/nls.messages-loader.js +1 -0
  76. package/dist/devtools-app/monaco/vs/nls.messages.cs.js.js +17 -0
  77. package/dist/devtools-app/monaco/vs/nls.messages.de.js.js +17 -0
  78. package/dist/devtools-app/monaco/vs/nls.messages.es.js.js +17 -0
  79. package/dist/devtools-app/monaco/vs/nls.messages.fr.js.js +15 -0
  80. package/dist/devtools-app/monaco/vs/nls.messages.it.js.js +15 -0
  81. package/dist/devtools-app/monaco/vs/nls.messages.ja.js.js +17 -0
  82. package/dist/devtools-app/monaco/vs/nls.messages.js.js +10 -0
  83. package/dist/devtools-app/monaco/vs/nls.messages.ko.js.js +25 -0
  84. package/dist/devtools-app/monaco/vs/nls.messages.pl.js.js +17 -0
  85. package/dist/devtools-app/monaco/vs/nls.messages.pt-br.js.js +6 -0
  86. package/dist/devtools-app/monaco/vs/nls.messages.ru.js.js +17 -0
  87. package/dist/devtools-app/monaco/vs/nls.messages.tr.js.js +15 -0
  88. package/dist/devtools-app/monaco/vs/nls.messages.zh-cn.js.js +17 -0
  89. package/dist/devtools-app/monaco/vs/nls.messages.zh-tw.js.js +15 -0
  90. package/dist/devtools-app/monaco/vs/objective-c-CntZFaHX.js +1 -0
  91. package/dist/devtools-app/monaco/vs/pascal-r6kuqfl_.js +1 -0
  92. package/dist/devtools-app/monaco/vs/pascaligo-BiXoTmXh.js +1 -0
  93. package/dist/devtools-app/monaco/vs/perl-DABw_TcH.js +1 -0
  94. package/dist/devtools-app/monaco/vs/pgsql-me_jFXeX.js +1 -0
  95. package/dist/devtools-app/monaco/vs/php-D_kh-9LK.js +1 -0
  96. package/dist/devtools-app/monaco/vs/pla-VfZjczW0.js +1 -0
  97. package/dist/devtools-app/monaco/vs/postiats-BBSzz8Pk.js +1 -0
  98. package/dist/devtools-app/monaco/vs/powerquery-Dt-g_2cc.js +1 -0
  99. package/dist/devtools-app/monaco/vs/powershell-B-7ap1zc.js +1 -0
  100. package/dist/devtools-app/monaco/vs/protobuf-BmtuEB1A.js +2 -0
  101. package/dist/devtools-app/monaco/vs/pug-BRpRNeEb.js +1 -0
  102. package/dist/devtools-app/monaco/vs/python-Cr0UkIbn.js +1 -0
  103. package/dist/devtools-app/monaco/vs/qsharp-BzsFaUU9.js +1 -0
  104. package/dist/devtools-app/monaco/vs/r-f8dDdrp4.js +1 -0
  105. package/dist/devtools-app/monaco/vs/razor-BYAHOTkz.js +1 -0
  106. package/dist/devtools-app/monaco/vs/redis-fvZQY4PI.js +1 -0
  107. package/dist/devtools-app/monaco/vs/redshift-45Et0LQi.js +1 -0
  108. package/dist/devtools-app/monaco/vs/restructuredtext-C7UUFKFD.js +1 -0
  109. package/dist/devtools-app/monaco/vs/ruby-CZO8zYTz.js +1 -0
  110. package/dist/devtools-app/monaco/vs/rust-Bfetafyc.js +1 -0
  111. package/dist/devtools-app/monaco/vs/sb-3GYllVck.js +1 -0
  112. package/dist/devtools-app/monaco/vs/scala-foMgrKo1.js +1 -0
  113. package/dist/devtools-app/monaco/vs/scheme-CHdMtr7p.js +1 -0
  114. package/dist/devtools-app/monaco/vs/scss-C1cmLt9V.js +3 -0
  115. package/dist/devtools-app/monaco/vs/shell-ClXCKCEW.js +1 -0
  116. package/dist/devtools-app/monaco/vs/solidity-MZ6ExpPy.js +1 -0
  117. package/dist/devtools-app/monaco/vs/sophia-DWkuSsPQ.js +1 -0
  118. package/dist/devtools-app/monaco/vs/sparql-AUGFYSyk.js +1 -0
  119. package/dist/devtools-app/monaco/vs/sql-32GpJSV2.js +1 -0
  120. package/dist/devtools-app/monaco/vs/st-CuDFIVZ_.js +1 -0
  121. package/dist/devtools-app/monaco/vs/swift-n-2HociN.js +3 -0
  122. package/dist/devtools-app/monaco/vs/systemverilog-Ch4vA8Yt.js +1 -0
  123. package/dist/devtools-app/monaco/vs/tcl-D74tq1nH.js +1 -0
  124. package/dist/devtools-app/monaco/vs/tsMode-CZz1Umrk.js +11 -0
  125. package/dist/devtools-app/monaco/vs/twig-C6taOxMV.js +1 -0
  126. package/dist/devtools-app/monaco/vs/typescript-DfOrAzoV.js +1 -0
  127. package/dist/devtools-app/monaco/vs/typespec-D-PIh9Xw.js +1 -0
  128. package/dist/devtools-app/monaco/vs/vb-Dyb2648j.js +1 -0
  129. package/dist/devtools-app/monaco/vs/wgsl-BhLXMOR0.js +298 -0
  130. package/dist/devtools-app/monaco/vs/workers-DcJshg-q.js +1 -0
  131. package/dist/devtools-app/monaco/vs/xml-CdsdnY8S.js +1 -0
  132. package/dist/devtools-app/monaco/vs/yaml-DYGvmE88.js +1 -0
  133. package/dist/eslint-plugin/index.cjs +5 -2
  134. package/dist/eslint-plugin/index.mjs +5 -2
  135. package/dist/eslint-plugin/rules/prefer-unitless-values.cjs +217 -0
  136. package/dist/eslint-plugin/rules/prefer-unitless-values.mjs +217 -0
  137. package/dist/eslint-plugin/utils/api.cjs +3 -4
  138. package/dist/eslint-plugin/utils/api.mjs +2 -2
  139. package/dist/native/server.cjs +4 -4
  140. package/dist/native/server.mjs +4 -4
  141. package/dist/parser/jsx/extractCode.cjs +3 -2
  142. package/dist/parser/jsx/extractCode.mjs +3 -2
  143. package/dist/parser/jsx/extractProps.cjs +7 -1
  144. package/dist/parser/jsx/extractProps.mjs +7 -1
  145. package/dist/parser/jsx/server.cjs +13 -7
  146. package/dist/parser/jsx/server.mjs +13 -7
  147. package/dist/prop/at/shared.cjs +3 -3
  148. package/dist/prop/at/shared.mjs +3 -3
  149. package/dist/tasks/postcss.cjs +16 -5
  150. package/dist/tasks/postcss.mjs +16 -5
  151. package/dist/transform/cache.cjs +0 -3
  152. package/dist/transform/cache.mjs +0 -2
  153. package/dist/use/token/browser.cjs +17 -9
  154. package/dist/use/token/browser.mjs +18 -10
  155. package/dist/use/token/normalize.cjs +474 -0
  156. package/dist/use/token/normalize.mjs +473 -0
  157. package/dist/use/token/propMap.cjs +34 -5
  158. package/dist/use/token/propMap.mjs +34 -6
  159. package/dist/use/token/runtime-only.cjs +36 -47
  160. package/dist/use/token/runtime-only.mjs +37 -48
  161. package/dist/use/token/server.cjs +82 -15
  162. package/dist/use/token/server.mjs +83 -17
  163. package/dist/use/token/vars.cjs +14 -2
  164. package/dist/use/token/vars.mjs +15 -2
  165. package/package.json +13 -13
@@ -1,5 +1,5 @@
1
1
  import { createTokenVars } from "./vars.mjs";
2
- import { getTokenGroupForProp, setTokenPropGroups } from "./propMap.mjs";
2
+ import { getTokenGroupsForProp, setTokenPropGroups } from "./propMap.mjs";
3
3
 
4
4
  //#region src/use/token/browser.ts
5
5
  let currentApi = null;
@@ -50,27 +50,35 @@ const isTokenFn = (value) => {
50
50
  const onBrowserObjectStart = (api, { input }) => {
51
51
  const isClassnameFirst = api.strategy === "classname-first";
52
52
  const mutableInput = input;
53
+ const prefix = api.selectorPrefix ?? "";
54
+ const toTokenVar = (path) => `var(--${prefix}${path.replace(/\./g, "-")})`;
53
55
  for (const prop in mutableInput) {
54
56
  const value = mutableInput[prop];
55
57
  if (isTokenFn(value)) {
56
58
  const path = value().replace("$$.token.", "");
57
59
  if (isClassnameFirst) mutableInput[prop] = path.split(".").slice(1).join(".");
58
- else mutableInput[prop] = `var(--${path.replace(/\./g, "-")})`;
60
+ else mutableInput[prop] = toTokenVar(path);
59
61
  } else if (typeof value === "string" && value.startsWith("$$.token.")) {
60
62
  const path = value.replace("$$.token.", "");
61
63
  if (isClassnameFirst) mutableInput[prop] = path.split(".").slice(1).join(".");
62
- else mutableInput[prop] = `var(--${path.replace(/\./g, "-")})`;
64
+ else mutableInput[prop] = toTokenVar(path);
63
65
  } else if (typeof prop === "string") {
64
66
  const rawValue = mutableInput[prop];
65
67
  if (typeof rawValue !== "string") continue;
66
68
  const dashProp = api.camelCaseToDash?.(prop) ?? prop;
67
- const groupName = [
68
- getTokenGroupForProp(prop),
69
- getTokenGroupForProp(dashProp),
70
- prop,
71
- dashProp
72
- ].filter(Boolean).find((group) => tokenPaths.has(`${group}.${rawValue}`));
73
- if (groupName && !isClassnameFirst) mutableInput[prop] = `var(--${groupName}-${rawValue.replace("$$.token.", "").replace(/\./g, "-")})`;
69
+ const groupCandidates = [];
70
+ const seen = /* @__PURE__ */ new Set();
71
+ const addCandidate = (group) => {
72
+ if (!group || seen.has(group)) return;
73
+ seen.add(group);
74
+ groupCandidates.push(group);
75
+ };
76
+ for (const group of getTokenGroupsForProp(prop)) addCandidate(group);
77
+ for (const group of getTokenGroupsForProp(dashProp)) addCandidate(group);
78
+ addCandidate(prop);
79
+ addCandidate(dashProp);
80
+ const groupName = groupCandidates.find((group) => tokenPaths.has(`${group}.${rawValue}`));
81
+ if (groupName && !isClassnameFirst) mutableInput[prop] = toTokenVar(`${groupName}.${rawValue.replace("$$.token.", "")}`);
74
82
  }
75
83
  }
76
84
  };
@@ -0,0 +1,474 @@
1
+
2
+ //#region src/use/token/normalize.ts
3
+ const isPlainObject = (value) => {
4
+ return Boolean(value && typeof value === "object" && !Array.isArray(value));
5
+ };
6
+ const hasDtcgValue = (value) => {
7
+ return isPlainObject(value) && Object.prototype.hasOwnProperty.call(value, "$value");
8
+ };
9
+ const hasValueEntry = (value) => {
10
+ return isPlainObject(value) && Object.prototype.hasOwnProperty.call(value, "value") && !Object.prototype.hasOwnProperty.call(value, "unit");
11
+ };
12
+ const hasRefEntry = (value) => {
13
+ return isPlainObject(value) && typeof value.$ref === "string";
14
+ };
15
+ const decodeJsonPointer = (segment) => segment.replace(/~1/g, "/").replace(/~0/g, "~");
16
+ const resolveJsonPointer = (root, pointer) => {
17
+ if (!pointer.startsWith("#/")) return void 0;
18
+ const parts = pointer.slice(2).split("/").map(decodeJsonPointer);
19
+ let current = root;
20
+ for (const part of parts) {
21
+ if (Array.isArray(current)) {
22
+ const index = Number(part);
23
+ if (!Number.isInteger(index) || index < 0 || index >= current.length) return void 0;
24
+ current = current[index];
25
+ continue;
26
+ }
27
+ if (!isPlainObject(current)) return void 0;
28
+ current = current[part];
29
+ }
30
+ return current;
31
+ };
32
+ const resolvePath = (root, path) => {
33
+ const parts = path.split(".").filter(Boolean);
34
+ let current = root;
35
+ for (const part of parts) {
36
+ if (!isPlainObject(current)) return void 0;
37
+ current = current[part];
38
+ }
39
+ return current;
40
+ };
41
+ const resolveTokenValueReference = (root, path) => {
42
+ const node = resolvePath(root, path);
43
+ if (!node) return void 0;
44
+ if (hasDtcgValue(node)) return node.$value;
45
+ if (hasValueEntry(node)) return node.value;
46
+ return node;
47
+ };
48
+ const applyRef = (root, ref) => {
49
+ if (ref.startsWith("#/")) return resolveJsonPointer(root, ref);
50
+ const match = ref.match(/^\{(.+)\}$/);
51
+ if (match) return resolveTokenValueReference(root, match[1]);
52
+ return resolveTokenValueReference(root, ref);
53
+ };
54
+ const mergeGroups = (base, next) => {
55
+ const result = { ...base };
56
+ for (const [key, value] of Object.entries(next)) {
57
+ if (key === "$extends" || key === "$ref") continue;
58
+ const existing = result[key];
59
+ const existingIsToken = hasDtcgValue(existing);
60
+ const nextIsToken = hasDtcgValue(value);
61
+ if (!existing || existingIsToken || nextIsToken) {
62
+ result[key] = value;
63
+ continue;
64
+ }
65
+ if (isPlainObject(existing) && isPlainObject(value)) result[key] = mergeGroups(existing, value);
66
+ else result[key] = value;
67
+ }
68
+ return result;
69
+ };
70
+ const resolveGroupExtends = (node, root, stack) => {
71
+ if (!isPlainObject(node) || hasDtcgValue(node)) return node;
72
+ const extendsValue = node.$extends ?? node.$ref;
73
+ const extendRefs = Array.isArray(extendsValue) ? extendsValue : extendsValue ? [extendsValue] : [];
74
+ let merged = {};
75
+ for (const ref of extendRefs) {
76
+ if (typeof ref !== "string") continue;
77
+ if (stack.has(ref)) continue;
78
+ const target = ref.startsWith("#/") ? resolveJsonPointer(root, ref) : resolvePath(root, ref.replace(/^\{|\}$/g, ""));
79
+ if (!isPlainObject(target)) continue;
80
+ stack.add(ref);
81
+ const resolvedTarget = resolveGroupExtends(target, root, stack);
82
+ stack.delete(ref);
83
+ if (isPlainObject(resolvedTarget)) merged = mergeGroups(merged, resolvedTarget);
84
+ }
85
+ const resolvedNode = {};
86
+ for (const [key, value] of Object.entries(node)) {
87
+ if (key === "$extends" || key === "$ref") continue;
88
+ resolvedNode[key] = resolveGroupExtends(value, root, stack);
89
+ }
90
+ return mergeGroups(merged, resolvedNode);
91
+ };
92
+ const tokenRefPattern = /\{([^}]+)\}/g;
93
+ const resolveReferences = (node, root, stack) => {
94
+ if (typeof node === "string") {
95
+ const matches = Array.from(node.matchAll(tokenRefPattern));
96
+ if (!matches.length) return node;
97
+ if (matches.length === 1 && matches[0][0] === node) {
98
+ const refPath = matches[0][1];
99
+ if (stack.has(refPath)) return node;
100
+ const refValue = resolveTokenValueReference(root, refPath);
101
+ if (refValue === void 0) return node;
102
+ stack.add(refPath);
103
+ const resolved = resolveReferences(refValue, root, stack);
104
+ stack.delete(refPath);
105
+ return resolved;
106
+ }
107
+ let nextValue = node;
108
+ for (const match of matches) {
109
+ const refPath = match[1];
110
+ if (stack.has(refPath)) continue;
111
+ const refValue = resolveTokenValueReference(root, refPath);
112
+ if (refValue === void 0) continue;
113
+ stack.add(refPath);
114
+ const resolved = resolveReferences(refValue, root, stack);
115
+ stack.delete(refPath);
116
+ nextValue = nextValue.replace(match[0], String(resolved));
117
+ }
118
+ return nextValue;
119
+ }
120
+ if (Array.isArray(node)) return node.map((entry) => resolveReferences(entry, root, stack));
121
+ if (!isPlainObject(node)) return node;
122
+ if (hasRefEntry(node)) {
123
+ const resolved = applyRef(root, node.$ref);
124
+ if (resolved === void 0) return node;
125
+ return resolveReferences(resolved, root, stack);
126
+ }
127
+ if (hasDtcgValue(node)) {
128
+ const nextValue = resolveReferences(node.$value, root, stack);
129
+ return {
130
+ ...node,
131
+ $value: nextValue
132
+ };
133
+ }
134
+ if (hasValueEntry(node)) {
135
+ const nextValue = resolveReferences(node.value, root, stack);
136
+ return {
137
+ ...node,
138
+ value: nextValue
139
+ };
140
+ }
141
+ const result = {};
142
+ for (const [key, value] of Object.entries(node)) result[key] = resolveReferences(value, root, stack);
143
+ return result;
144
+ };
145
+ const getTokenPathFromRef = (ref) => {
146
+ if (ref.startsWith("#/")) {
147
+ const parts = ref.slice(2).split("/").map(decodeJsonPointer);
148
+ if (!parts.length) return null;
149
+ const valueIndex = parts.indexOf("$value");
150
+ const typeIndex = parts.indexOf("$type");
151
+ const stopIndex = valueIndex >= 0 ? valueIndex : typeIndex >= 0 ? typeIndex : parts.length;
152
+ const tokenParts = parts.slice(0, stopIndex);
153
+ return tokenParts.length ? tokenParts.join(".") : null;
154
+ }
155
+ const match = ref.match(/^\{(.+)\}$/);
156
+ if (match) return match[1];
157
+ return ref;
158
+ };
159
+ const getAliasPath = (node) => {
160
+ const value = hasDtcgValue(node) ? node.$value : hasValueEntry(node) ? node.value : void 0;
161
+ if (typeof value === "string") {
162
+ if (value.startsWith("#/")) return getTokenPathFromRef(value);
163
+ const match = value.match(/^\{(.+)\}$/);
164
+ return match ? match[1] : null;
165
+ }
166
+ if (isPlainObject(value) && hasRefEntry(value)) return getTokenPathFromRef(value.$ref);
167
+ if (hasRefEntry(node)) return getTokenPathFromRef(node.$ref);
168
+ return null;
169
+ };
170
+ const buildTokenMaps = (root) => {
171
+ const typeMap = /* @__PURE__ */ new Map();
172
+ const nodeMap = /* @__PURE__ */ new Map();
173
+ const walk = (node, path, inheritedType) => {
174
+ if (!isPlainObject(node)) return;
175
+ const nodeType = typeof node.$type === "string" ? node.$type : inheritedType;
176
+ const hasOnlyMetaKeys = Object.keys(node).every((key) => key.startsWith("$"));
177
+ if ((hasDtcgValue(node) || hasValueEntry(node) || hasRefEntry(node) && hasOnlyMetaKeys) && path.length) {
178
+ const pathKey = path.join(".");
179
+ typeMap.set(pathKey, nodeType);
180
+ nodeMap.set(pathKey, node);
181
+ }
182
+ for (const [key, value] of Object.entries(node)) {
183
+ if (key.startsWith("$")) continue;
184
+ walk(value, [...path, key], nodeType);
185
+ }
186
+ };
187
+ walk(root, []);
188
+ for (let iteration = 0; iteration < 6; iteration += 1) {
189
+ let changed = false;
190
+ for (const [path, node] of nodeMap.entries()) {
191
+ if (typeMap.get(path)) continue;
192
+ const aliasPath = getAliasPath(node);
193
+ if (!aliasPath) continue;
194
+ const aliasType = typeMap.get(aliasPath);
195
+ if (aliasType) {
196
+ typeMap.set(path, aliasType);
197
+ changed = true;
198
+ }
199
+ }
200
+ if (!changed) break;
201
+ }
202
+ return {
203
+ typeMap,
204
+ nodeMap
205
+ };
206
+ };
207
+ const isValueUnitObject = (value) => Object.prototype.hasOwnProperty.call(value, "value") && Object.prototype.hasOwnProperty.call(value, "unit");
208
+ const normalizeValueUnit = (value, unit) => {
209
+ if (typeof value === "number" || typeof value === "string") return `${value}${typeof unit === "string" ? unit : unit == null ? "" : String(unit)}`;
210
+ return value;
211
+ };
212
+ const normalizeFontFamilyToken = (value) => {
213
+ const trimmed = value.trim();
214
+ if (trimmed.startsWith("\"") && trimmed.endsWith("\"") || trimmed.startsWith("'") && trimmed.endsWith("'")) return trimmed;
215
+ const needsQuotes = /\s/.test(trimmed);
216
+ const escaped = trimmed.replace(/"/g, "\\\"");
217
+ return needsQuotes ? `"${escaped}"` : escaped;
218
+ };
219
+ const fontWeightMap = {
220
+ thin: 100,
221
+ hairline: 100,
222
+ "extra-light": 200,
223
+ "ultra-light": 200,
224
+ light: 300,
225
+ normal: 400,
226
+ regular: 400,
227
+ book: 400,
228
+ medium: 500,
229
+ "semi-bold": 600,
230
+ "demi-bold": 600,
231
+ bold: 700,
232
+ "extra-bold": 800,
233
+ "ultra-bold": 800,
234
+ black: 900,
235
+ heavy: 900,
236
+ "extra-black": 950,
237
+ "ultra-black": 950
238
+ };
239
+ const normalizeFontWeight = (value) => {
240
+ if (typeof value === "number") return value;
241
+ if (typeof value === "string") {
242
+ const trimmed = value.trim();
243
+ if (/^\d+$/.test(trimmed)) return trimmed;
244
+ return fontWeightMap[trimmed.toLowerCase().replace(/_/g, "-").replace(/\s+/g, "-")] ?? trimmed;
245
+ }
246
+ return value;
247
+ };
248
+ const parseHexColor = (input) => {
249
+ const raw = input.startsWith("#") ? input.slice(1) : input;
250
+ if (![
251
+ 3,
252
+ 4,
253
+ 6,
254
+ 8
255
+ ].includes(raw.length)) return null;
256
+ const expand = (value) => value.split("").map((ch) => ch + ch).join("");
257
+ const hex = raw.length <= 4 ? expand(raw) : raw;
258
+ const hasAlpha = hex.length === 8;
259
+ const r = parseInt(hex.slice(0, 2), 16);
260
+ const g = parseInt(hex.slice(2, 4), 16);
261
+ const b = parseInt(hex.slice(4, 6), 16);
262
+ const a = hasAlpha ? parseInt(hex.slice(6, 8), 16) / 255 : null;
263
+ if ([
264
+ r,
265
+ g,
266
+ b
267
+ ].some(Number.isNaN)) return null;
268
+ return {
269
+ r,
270
+ g,
271
+ b,
272
+ a
273
+ };
274
+ };
275
+ const normalizeColor = (value) => {
276
+ if (typeof value === "string") return value;
277
+ if (!isPlainObject(value)) return value;
278
+ if (typeof value.hex === "string") {
279
+ const parsed = parseHexColor(value.hex);
280
+ const alpha = typeof value.alpha === "number" ? value.alpha : null;
281
+ if (parsed) {
282
+ const alphaValue = alpha ?? parsed.a;
283
+ if (alphaValue != null && alphaValue >= 0 && alphaValue <= 1) return `rgb(${parsed.r} ${parsed.g} ${parsed.b} / ${alphaValue})`;
284
+ }
285
+ return value.hex;
286
+ }
287
+ if (Array.isArray(value.components)) {
288
+ const components = value.components;
289
+ const colorSpace = typeof value.colorSpace === "string" ? value.colorSpace : "srgb";
290
+ let alpha = typeof value.alpha === "number" ? value.alpha : void 0;
291
+ if (alpha === void 0 && components.length >= 4 && typeof components[3] === "number") alpha = components[3];
292
+ const normalized = components.map((component) => {
293
+ if (component === "none") return "none";
294
+ if (typeof component === "number") return component;
295
+ const numeric = Number(component);
296
+ return Number.isNaN(numeric) ? null : numeric;
297
+ });
298
+ if (normalized.some((component) => component === null)) return value;
299
+ const sanitized = normalized;
300
+ if (colorSpace === "srgb" || colorSpace === "srgb-linear") {
301
+ const numeric = sanitized.slice(0, 3);
302
+ const usesNormalized = numeric.every((component) => component === "none" || component >= 0 && component <= 1);
303
+ const rgb = numeric.map((component) => {
304
+ if (component === "none") return "none";
305
+ return usesNormalized ? Math.round(component * 255) : Math.round(component);
306
+ });
307
+ if (alpha != null && alpha >= 0 && alpha <= 1) return `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]} / ${alpha})`;
308
+ return `rgb(${rgb[0]} ${rgb[1]} ${rgb[2]})`;
309
+ }
310
+ const colorArgs = sanitized.slice(0, 3).map((component) => String(component)).join(" ");
311
+ if (alpha != null && alpha >= 0 && alpha <= 1) return `color(${colorSpace} ${colorArgs} / ${alpha})`;
312
+ return `color(${colorSpace} ${colorArgs})`;
313
+ }
314
+ return value;
315
+ };
316
+ const normalizeCubicBezier = (value) => {
317
+ if (Array.isArray(value)) {
318
+ const numeric = value.filter((component) => typeof component === "number");
319
+ if (numeric.length >= 4) return `cubic-bezier(${numeric.slice(0, 4).join(", ")})`;
320
+ }
321
+ if (typeof value === "string") return value;
322
+ return value;
323
+ };
324
+ const normalizeStrokeStyle = (value) => {
325
+ if (typeof value === "string") return value;
326
+ if (isPlainObject(value)) {
327
+ if (Array.isArray(value.dashArray) || value.dashArray != null) return "dashed";
328
+ return "solid";
329
+ }
330
+ return value;
331
+ };
332
+ const normalizeShadowItem = (value, normalize) => {
333
+ const inset = value.inset ? "inset" : null;
334
+ const offsetX = normalize(value.offsetX, "dimension") ?? "0";
335
+ const offsetY = normalize(value.offsetY, "dimension") ?? "0";
336
+ const blur = normalize(value.blur, "dimension");
337
+ const spread = normalize(value.spread, "dimension");
338
+ const color = normalize(value.color, "color");
339
+ const parts = [
340
+ inset,
341
+ offsetX,
342
+ offsetY
343
+ ].filter(Boolean).map(String);
344
+ const blurValue = blur ?? (spread != null ? "0" : null);
345
+ if (blurValue != null) parts.push(String(blurValue));
346
+ if (spread != null) parts.push(String(spread));
347
+ if (color != null) parts.push(String(color));
348
+ return parts.join(" ");
349
+ };
350
+ const normalizeGradientStops = (value) => {
351
+ if (Array.isArray(value)) {
352
+ const stops = [];
353
+ for (const entry of value) if (Array.isArray(entry)) stops.push(...entry);
354
+ else stops.push(entry);
355
+ return stops;
356
+ }
357
+ return [value];
358
+ };
359
+ const normalizeGradientPosition = (value) => {
360
+ if (typeof value === "number") {
361
+ const clamped = Math.min(Math.max(value, 0), 1);
362
+ return `${Math.round(clamped * 1e4) / 100}%`;
363
+ }
364
+ if (typeof value === "string") return value;
365
+ if (isPlainObject(value) && isValueUnitObject(value)) return normalizeValueUnit(value.value, value.unit);
366
+ return value;
367
+ };
368
+ const normalizeTokenValue = (value, type) => {
369
+ if (hasDtcgValue(value)) {
370
+ const nestedType = typeof value.$type === "string" ? value.$type : type;
371
+ return normalizeTokenValue(value.$value, nestedType);
372
+ }
373
+ if (hasValueEntry(value)) {
374
+ const nestedType = typeof value.$type === "string" ? value.$type : type;
375
+ return normalizeTokenValue(value.value, nestedType);
376
+ }
377
+ if (type === "color") return normalizeColor(value);
378
+ if (type === "dimension" || type === "duration") {
379
+ if (isPlainObject(value) && isValueUnitObject(value)) return normalizeValueUnit(value.value, value.unit);
380
+ return value;
381
+ }
382
+ if (type === "fontFamily") {
383
+ if (Array.isArray(value)) return value.map((entry) => normalizeFontFamilyToken(String(entry))).join(", ");
384
+ if (typeof value === "string") {
385
+ if (value.includes(",")) return value.split(",").map((entry) => normalizeFontFamilyToken(entry.trim())).join(", ");
386
+ return normalizeFontFamilyToken(value);
387
+ }
388
+ return value;
389
+ }
390
+ if (type === "fontWeight") return normalizeFontWeight(value);
391
+ if (type === "cubicBezier") return normalizeCubicBezier(value);
392
+ if (type === "strokeStyle") return normalizeStrokeStyle(value);
393
+ if (type === "border") {
394
+ if (!isPlainObject(value)) return value;
395
+ return [
396
+ normalizeTokenValue(value.width, "dimension"),
397
+ normalizeTokenValue(value.style, "strokeStyle"),
398
+ normalizeTokenValue(value.color, "color")
399
+ ].filter((v) => v != null && v !== "").map(String).join(" ");
400
+ }
401
+ if (type === "transition") {
402
+ if (!isPlainObject(value)) return value;
403
+ return [
404
+ normalizeTokenValue(value.duration, "duration"),
405
+ normalizeTokenValue(value.timingFunction, "cubicBezier"),
406
+ normalizeTokenValue(value.delay, "duration")
407
+ ].filter((v) => v != null && v !== "").map(String).join(" ");
408
+ }
409
+ if (type === "shadow") {
410
+ if (Array.isArray(value)) return normalizeGradientStops(value).map((item) => isPlainObject(item) ? normalizeShadowItem(item, normalizeTokenValue) : String(item)).filter(Boolean).join(", ");
411
+ if (!isPlainObject(value)) return value;
412
+ return normalizeShadowItem(value, normalizeTokenValue);
413
+ }
414
+ if (type === "gradient") return `linear-gradient(${normalizeGradientStops(value).map((stop) => {
415
+ if (typeof stop === "string") return stop;
416
+ if (!isPlainObject(stop)) return String(stop);
417
+ return [normalizeTokenValue(stop.color, "color"), normalizeGradientPosition(stop.position)].filter((v) => v != null && v !== "").map(String).join(" ");
418
+ }).filter(Boolean).join(", ")})`;
419
+ if (type === "typography") {
420
+ if (!isPlainObject(value)) return value;
421
+ const fontWeight = normalizeTokenValue(value.fontWeight, "fontWeight");
422
+ const fontSize = normalizeTokenValue(value.fontSize, "dimension");
423
+ const lineHeight = normalizeTokenValue(value.lineHeight, "number");
424
+ const fontFamily = normalizeTokenValue(value.fontFamily, "fontFamily");
425
+ const parts = [];
426
+ if (fontWeight != null && fontWeight !== "") parts.push(String(fontWeight));
427
+ if (fontSize != null && fontSize !== "") if (lineHeight != null && lineHeight !== "") parts.push(`${fontSize}/${lineHeight}`);
428
+ else parts.push(String(fontSize));
429
+ if (fontFamily != null && fontFamily !== "") parts.push(String(fontFamily));
430
+ return parts.join(" ");
431
+ }
432
+ if (isPlainObject(value) && isValueUnitObject(value)) return normalizeValueUnit(value.value, value.unit);
433
+ if (isPlainObject(value) && typeof value.hex === "string" && Object.keys(value).length <= 3) return normalizeColor(value);
434
+ if (Array.isArray(value)) return value.map((entry) => normalizeTokenValue(entry));
435
+ if (isPlainObject(value)) {
436
+ const result = {};
437
+ for (const [key, entry] of Object.entries(value)) {
438
+ if (key.startsWith("$")) continue;
439
+ result[key] = normalizeTokenValue(entry);
440
+ }
441
+ return result;
442
+ }
443
+ return value;
444
+ };
445
+ const normalizeNode = (node, context) => {
446
+ const pathKey = context.path.join(".");
447
+ const mappedType = pathKey ? context.typeMap.get(pathKey) : void 0;
448
+ if (mappedType && !hasDtcgValue(node) && !hasValueEntry(node)) return normalizeTokenValue(node, mappedType);
449
+ if (Array.isArray(node)) return node.map((entry) => normalizeNode(entry, context));
450
+ if (!isPlainObject(node)) return node;
451
+ if (hasDtcgValue(node) || hasValueEntry(node)) return normalizeTokenValue(hasDtcgValue(node) ? node.$value : node.value, (typeof node.$type === "string" ? node.$type : void 0) ?? context.type ?? mappedType);
452
+ const nodeType = typeof node.$type === "string" ? node.$type : context.type;
453
+ const result = {};
454
+ for (const [key, value] of Object.entries(node)) {
455
+ if (key.startsWith("$")) continue;
456
+ result[key] = normalizeNode(value, {
457
+ type: nodeType,
458
+ path: [...context.path, key],
459
+ typeMap: context.typeMap
460
+ });
461
+ }
462
+ return result;
463
+ };
464
+ const normalizeTokens = (input) => {
465
+ const extended = resolveGroupExtends(input, input, /* @__PURE__ */ new Set());
466
+ const { typeMap } = buildTokenMaps(extended);
467
+ return normalizeNode(resolveReferences(extended, extended, /* @__PURE__ */ new Set()), {
468
+ path: [],
469
+ typeMap
470
+ });
471
+ };
472
+
473
+ //#endregion
474
+ exports.normalizeTokens = normalizeTokens;