@fluixi-css/core 0.1.0-next.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (389) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +52 -0
  3. package/base.css +4 -0
  4. package/components.css +1 -0
  5. package/dist/base.css +4 -0
  6. package/dist/components.css +1 -0
  7. package/dist/index.css +2 -0
  8. package/dist/package.json +139 -0
  9. package/dist/reset.css +168 -0
  10. package/dist/src/ast.d.ts +298 -0
  11. package/dist/src/ast.js +2240 -0
  12. package/dist/src/ast.js.map +1 -0
  13. package/dist/src/commons/constants.d.ts +1193 -0
  14. package/dist/src/commons/constants.js +1323 -0
  15. package/dist/src/commons/constants.js.map +1 -0
  16. package/dist/src/commons/helper.d.ts +1298 -0
  17. package/dist/src/commons/helper.js +1310 -0
  18. package/dist/src/commons/helper.js.map +1 -0
  19. package/dist/src/commons/index.d.ts +3 -0
  20. package/dist/src/commons/index.js +4 -0
  21. package/dist/src/commons/index.js.map +1 -0
  22. package/dist/src/commons/properties.d.ts +1431 -0
  23. package/dist/src/commons/properties.js +2855 -0
  24. package/dist/src/commons/properties.js.map +1 -0
  25. package/dist/src/commons/types.d.ts +359 -0
  26. package/dist/src/commons/types.js +4 -0
  27. package/dist/src/commons/types.js.map +1 -0
  28. package/dist/src/components/avatar/index.d.ts +19 -0
  29. package/dist/src/components/avatar/index.js +22 -0
  30. package/dist/src/components/avatar/index.js.map +1 -0
  31. package/dist/src/components/button/index.d.ts +48 -0
  32. package/dist/src/components/button/index.js +51 -0
  33. package/dist/src/components/button/index.js.map +1 -0
  34. package/dist/src/components/card/index.d.ts +44 -0
  35. package/dist/src/components/card/index.js +47 -0
  36. package/dist/src/components/card/index.js.map +1 -0
  37. package/dist/src/components/checkbox/index.d.ts +69 -0
  38. package/dist/src/components/checkbox/index.js +80 -0
  39. package/dist/src/components/checkbox/index.js.map +1 -0
  40. package/dist/src/components/daterangepicker/index.d.ts +147 -0
  41. package/dist/src/components/daterangepicker/index.js +150 -0
  42. package/dist/src/components/daterangepicker/index.js.map +1 -0
  43. package/dist/src/components/dialog/index.d.ts +71 -0
  44. package/dist/src/components/dialog/index.js +74 -0
  45. package/dist/src/components/dialog/index.js.map +1 -0
  46. package/dist/src/components/drawer/index.d.ts +26 -0
  47. package/dist/src/components/drawer/index.js +29 -0
  48. package/dist/src/components/drawer/index.js.map +1 -0
  49. package/dist/src/components/dropdown/index.d.ts +101 -0
  50. package/dist/src/components/dropdown/index.js +104 -0
  51. package/dist/src/components/dropdown/index.js.map +1 -0
  52. package/dist/src/components/forms/index.d.ts +58 -0
  53. package/dist/src/components/forms/index.js +62 -0
  54. package/dist/src/components/forms/index.js.map +1 -0
  55. package/dist/src/components/index.d.ts +1228 -0
  56. package/dist/src/components/index.js +64 -0
  57. package/dist/src/components/index.js.map +1 -0
  58. package/dist/src/components/layout/index.d.ts +28 -0
  59. package/dist/src/components/layout/index.js +33 -0
  60. package/dist/src/components/layout/index.js.map +1 -0
  61. package/dist/src/components/list/index.d.ts +65 -0
  62. package/dist/src/components/list/index.js +68 -0
  63. package/dist/src/components/list/index.js.map +1 -0
  64. package/dist/src/components/popover/index.d.ts +79 -0
  65. package/dist/src/components/popover/index.js +82 -0
  66. package/dist/src/components/popover/index.js.map +1 -0
  67. package/dist/src/components/radio/index.d.ts +77 -0
  68. package/dist/src/components/radio/index.js +80 -0
  69. package/dist/src/components/radio/index.js.map +1 -0
  70. package/dist/src/components/select/index.d.ts +102 -0
  71. package/dist/src/components/select/index.js +105 -0
  72. package/dist/src/components/select/index.js.map +1 -0
  73. package/dist/src/components/sidenav/index.d.ts +98 -0
  74. package/dist/src/components/sidenav/index.js +101 -0
  75. package/dist/src/components/sidenav/index.js.map +1 -0
  76. package/dist/src/components/table/index.d.ts +95 -0
  77. package/dist/src/components/table/index.js +98 -0
  78. package/dist/src/components/table/index.js.map +1 -0
  79. package/dist/src/constants.d.ts +3 -0
  80. package/dist/src/constants.js +29 -0
  81. package/dist/src/constants.js.map +1 -0
  82. package/dist/src/css-ast.d.ts +48 -0
  83. package/dist/src/css-ast.js +2 -0
  84. package/dist/src/css-ast.js.map +1 -0
  85. package/dist/src/css-generator.d.ts +29 -0
  86. package/dist/src/css-generator.js +104 -0
  87. package/dist/src/css-generator.js.map +1 -0
  88. package/dist/src/css-helpers.d.ts +76 -0
  89. package/dist/src/css-helpers.js +272 -0
  90. package/dist/src/css-helpers.js.map +1 -0
  91. package/dist/src/css-lexer.d.ts +48 -0
  92. package/dist/src/css-lexer.js +255 -0
  93. package/dist/src/css-lexer.js.map +1 -0
  94. package/dist/src/css-parser.cjs +2047 -0
  95. package/dist/src/css-parser.cjs.map +1 -0
  96. package/dist/src/css-parser.d.ts +100 -0
  97. package/dist/src/css-parser.js +1098 -0
  98. package/dist/src/css-parser.js.map +1 -0
  99. package/dist/src/css-parser.mjs +2028 -0
  100. package/dist/src/css-parser.mjs.map +1 -0
  101. package/dist/src/design-system.d.ts +210 -0
  102. package/dist/src/design-system.js +1034 -0
  103. package/dist/src/design-system.js.map +1 -0
  104. package/dist/src/engine/ast.d.ts +44 -0
  105. package/dist/src/engine/ast.js +92 -0
  106. package/dist/src/engine/ast.js.map +1 -0
  107. package/dist/src/engine/atom.d.ts +74 -0
  108. package/dist/src/engine/atom.js +227 -0
  109. package/dist/src/engine/atom.js.map +1 -0
  110. package/dist/src/engine/compile.d.ts +5 -0
  111. package/dist/src/engine/compile.js +79 -0
  112. package/dist/src/engine/compile.js.map +1 -0
  113. package/dist/src/engine/defaults.d.ts +2 -0
  114. package/dist/src/engine/defaults.js +14 -0
  115. package/dist/src/engine/defaults.js.map +1 -0
  116. package/dist/src/engine/directives.d.ts +2 -0
  117. package/dist/src/engine/directives.js +191 -0
  118. package/dist/src/engine/directives.js.map +1 -0
  119. package/dist/src/engine/index.d.ts +41 -0
  120. package/dist/src/engine/index.js +88 -0
  121. package/dist/src/engine/index.js.map +1 -0
  122. package/dist/src/engine/registry.d.ts +46 -0
  123. package/dist/src/engine/registry.js +49 -0
  124. package/dist/src/engine/registry.js.map +1 -0
  125. package/dist/src/engine/scanner.d.ts +1 -0
  126. package/dist/src/engine/scanner.js +45 -0
  127. package/dist/src/engine/scanner.js.map +1 -0
  128. package/dist/src/engine/source.d.ts +12 -0
  129. package/dist/src/engine/source.js +81 -0
  130. package/dist/src/engine/source.js.map +1 -0
  131. package/dist/src/engine/theme-defaults.d.ts +2 -0
  132. package/dist/src/engine/theme-defaults.js +54 -0
  133. package/dist/src/engine/theme-defaults.js.map +1 -0
  134. package/dist/src/engine/theme-source.d.ts +5 -0
  135. package/dist/src/engine/theme-source.js +71 -0
  136. package/dist/src/engine/theme-source.js.map +1 -0
  137. package/dist/src/engine/theme.d.ts +10 -0
  138. package/dist/src/engine/theme.js +42 -0
  139. package/dist/src/engine/theme.js.map +1 -0
  140. package/dist/src/engine/transform.d.ts +25 -0
  141. package/dist/src/engine/transform.js +91 -0
  142. package/dist/src/engine/transform.js.map +1 -0
  143. package/dist/src/engine/ui-preset.d.ts +4 -0
  144. package/dist/src/engine/ui-preset.js +56 -0
  145. package/dist/src/engine/ui-preset.js.map +1 -0
  146. package/dist/src/engine/utilities/backgrounds.d.ts +2 -0
  147. package/dist/src/engine/utilities/backgrounds.js +32 -0
  148. package/dist/src/engine/utilities/backgrounds.js.map +1 -0
  149. package/dist/src/engine/utilities/borders.d.ts +2 -0
  150. package/dist/src/engine/utilities/borders.js +95 -0
  151. package/dist/src/engine/utilities/borders.js.map +1 -0
  152. package/dist/src/engine/utilities/effects.d.ts +2 -0
  153. package/dist/src/engine/utilities/effects.js +61 -0
  154. package/dist/src/engine/utilities/effects.js.map +1 -0
  155. package/dist/src/engine/utilities/flexgrid.d.ts +2 -0
  156. package/dist/src/engine/utilities/flexgrid.js +125 -0
  157. package/dist/src/engine/utilities/flexgrid.js.map +1 -0
  158. package/dist/src/engine/utilities/index.d.ts +3 -0
  159. package/dist/src/engine/utilities/index.js +20 -0
  160. package/dist/src/engine/utilities/index.js.map +1 -0
  161. package/dist/src/engine/utilities/layout.d.ts +2 -0
  162. package/dist/src/engine/utilities/layout.js +84 -0
  163. package/dist/src/engine/utilities/layout.js.map +1 -0
  164. package/dist/src/engine/utilities/sizing.d.ts +2 -0
  165. package/dist/src/engine/utilities/sizing.js +21 -0
  166. package/dist/src/engine/utilities/sizing.js.map +1 -0
  167. package/dist/src/engine/utilities/spacing.d.ts +2 -0
  168. package/dist/src/engine/utilities/spacing.js +39 -0
  169. package/dist/src/engine/utilities/spacing.js.map +1 -0
  170. package/dist/src/engine/utilities/typography.d.ts +2 -0
  171. package/dist/src/engine/utilities/typography.js +120 -0
  172. package/dist/src/engine/utilities/typography.js.map +1 -0
  173. package/dist/src/engine/utilities/values.d.ts +16 -0
  174. package/dist/src/engine/utilities/values.js +91 -0
  175. package/dist/src/engine/utilities/values.js.map +1 -0
  176. package/dist/src/engine/variants.d.ts +2 -0
  177. package/dist/src/engine/variants.js +99 -0
  178. package/dist/src/engine/variants.js.map +1 -0
  179. package/dist/src/extractor.d.ts +146 -0
  180. package/dist/src/extractor.js +3862 -0
  181. package/dist/src/extractor.js.map +1 -0
  182. package/dist/src/index.cjs +4518 -0
  183. package/dist/src/index.cjs.map +1 -0
  184. package/dist/src/index.d.ts +1 -0
  185. package/dist/src/index.js +9 -0
  186. package/dist/src/index.js.map +1 -0
  187. package/dist/src/index.mjs +4480 -0
  188. package/dist/src/index.mjs.map +1 -0
  189. package/dist/src/keyframes.cjs +367 -0
  190. package/dist/src/keyframes.cjs.map +1 -0
  191. package/dist/src/keyframes.d.ts +27 -0
  192. package/dist/src/keyframes.js +188 -0
  193. package/dist/src/keyframes.js.map +1 -0
  194. package/dist/src/keyframes.mjs +362 -0
  195. package/dist/src/keyframes.mjs.map +1 -0
  196. package/dist/src/logger.d.ts +2 -0
  197. package/dist/src/logger.js +31 -0
  198. package/dist/src/logger.js.map +1 -0
  199. package/dist/src/plugin.cjs +43 -0
  200. package/dist/src/plugin.cjs.map +1 -0
  201. package/dist/src/plugin.d.ts +12 -0
  202. package/dist/src/plugin.js +39 -0
  203. package/dist/src/plugin.js.map +1 -0
  204. package/dist/src/plugin.mjs +41 -0
  205. package/dist/src/plugin.mjs.map +1 -0
  206. package/dist/src/presets-plugins.cjs +99 -0
  207. package/dist/src/presets-plugins.cjs.map +1 -0
  208. package/dist/src/presets-plugins.d.ts +1 -0
  209. package/dist/src/presets-plugins.js +56 -0
  210. package/dist/src/presets-plugins.js.map +1 -0
  211. package/dist/src/presets-plugins.mjs +97 -0
  212. package/dist/src/presets-plugins.mjs.map +1 -0
  213. package/dist/src/state.d.ts +76 -0
  214. package/dist/src/state.js +314 -0
  215. package/dist/src/state.js.map +1 -0
  216. package/dist/src/theme/constants.d.ts +22 -0
  217. package/dist/src/theme/constants.js +17 -0
  218. package/dist/src/theme/constants.js.map +1 -0
  219. package/dist/src/theme/index.d.ts +2 -0
  220. package/dist/src/theme/index.js +48 -0
  221. package/dist/src/theme/index.js.map +1 -0
  222. package/dist/src/theme/types.d.ts +13 -0
  223. package/dist/src/theme/types.js +2 -0
  224. package/dist/src/theme/types.js.map +1 -0
  225. package/dist/src/types/ast.d.ts +23 -0
  226. package/dist/src/types/ast.js +2 -0
  227. package/dist/src/types/ast.js.map +1 -0
  228. package/dist/src/types/base-types.d.ts +53 -0
  229. package/dist/src/types/base-types.js +2 -0
  230. package/dist/src/types/base-types.js.map +1 -0
  231. package/dist/src/types/components-types.d.ts +28 -0
  232. package/dist/src/types/components-types.js +2 -0
  233. package/dist/src/types/components-types.js.map +1 -0
  234. package/dist/src/types/config.d.ts +90 -0
  235. package/dist/src/types/config.js +3 -0
  236. package/dist/src/types/config.js.map +1 -0
  237. package/dist/src/types/css-parser.d.ts +361 -0
  238. package/dist/src/types/css-parser.js +2 -0
  239. package/dist/src/types/css-parser.js.map +1 -0
  240. package/dist/src/types/keyframes-type.d.ts +47 -0
  241. package/dist/src/types/keyframes-type.js +2 -0
  242. package/dist/src/types/keyframes-type.js.map +1 -0
  243. package/dist/src/types/plugin.d.ts +10 -0
  244. package/dist/src/types/plugin.js +2 -0
  245. package/dist/src/types/plugin.js.map +1 -0
  246. package/dist/src/types/screens-types.d.ts +47 -0
  247. package/dist/src/types/screens-types.js +2 -0
  248. package/dist/src/types/screens-types.js.map +1 -0
  249. package/dist/src/types/utilities-types.d.ts +147 -0
  250. package/dist/src/types/utilities-types.js +2 -0
  251. package/dist/src/types/utilities-types.js.map +1 -0
  252. package/dist/src/types.d.ts +77 -0
  253. package/dist/src/types.js +12 -0
  254. package/dist/src/types.js.map +1 -0
  255. package/dist/src/units/constants.d.ts +35 -0
  256. package/dist/src/units/constants.js +9 -0
  257. package/dist/src/units/constants.js.map +1 -0
  258. package/dist/src/units/index.d.ts +15 -0
  259. package/dist/src/units/index.js +7 -0
  260. package/dist/src/units/index.js.map +1 -0
  261. package/dist/src/units/types.d.ts +9 -0
  262. package/dist/src/units/types.js +2 -0
  263. package/dist/src/units/types.js.map +1 -0
  264. package/dist/src/utilities/backgrounds/constants.d.ts +2810 -0
  265. package/dist/src/utilities/backgrounds/constants.js +119 -0
  266. package/dist/src/utilities/backgrounds/constants.js.map +1 -0
  267. package/dist/src/utilities/backgrounds/index.d.ts +1 -0
  268. package/dist/src/utilities/backgrounds/index.js +2 -0
  269. package/dist/src/utilities/backgrounds/index.js.map +1 -0
  270. package/dist/src/utilities/borders/constants.d.ts +10586 -0
  271. package/dist/src/utilities/borders/constants.js +309 -0
  272. package/dist/src/utilities/borders/constants.js.map +1 -0
  273. package/dist/src/utilities/borders/index.d.ts +1 -0
  274. package/dist/src/utilities/borders/index.js +2 -0
  275. package/dist/src/utilities/borders/index.js.map +1 -0
  276. package/dist/src/utilities/breakpoints/constants.d.ts +330 -0
  277. package/dist/src/utilities/breakpoints/constants.js +269 -0
  278. package/dist/src/utilities/breakpoints/constants.js.map +1 -0
  279. package/dist/src/utilities/breakpoints/index.d.ts +2 -0
  280. package/dist/src/utilities/breakpoints/index.js +3 -0
  281. package/dist/src/utilities/breakpoints/index.js.map +1 -0
  282. package/dist/src/utilities/breakpoints/types.d.ts +8 -0
  283. package/dist/src/utilities/breakpoints/types.js +2 -0
  284. package/dist/src/utilities/breakpoints/types.js.map +1 -0
  285. package/dist/src/utilities/colors/base.d.ts +778 -0
  286. package/dist/src/utilities/colors/base.js +872 -0
  287. package/dist/src/utilities/colors/base.js.map +1 -0
  288. package/dist/src/utilities/colors/color.d.ts +1122 -0
  289. package/dist/src/utilities/colors/color.js +957 -0
  290. package/dist/src/utilities/colors/color.js.map +1 -0
  291. package/dist/src/utilities/colors/constants.d.ts +1 -0
  292. package/dist/src/utilities/colors/constants.js +2 -0
  293. package/dist/src/utilities/colors/constants.js.map +1 -0
  294. package/dist/src/utilities/colors/index.d.ts +4 -0
  295. package/dist/src/utilities/colors/index.js +29 -0
  296. package/dist/src/utilities/colors/index.js.map +1 -0
  297. package/dist/src/utilities/colors/types.d.ts +3 -0
  298. package/dist/src/utilities/colors/types.js +2 -0
  299. package/dist/src/utilities/colors/types.js.map +1 -0
  300. package/dist/src/utilities/effects/constants.d.ts +641 -0
  301. package/dist/src/utilities/effects/constants.js +83 -0
  302. package/dist/src/utilities/effects/constants.js.map +1 -0
  303. package/dist/src/utilities/effects/index.d.ts +1 -0
  304. package/dist/src/utilities/effects/index.js +2 -0
  305. package/dist/src/utilities/effects/index.js.map +1 -0
  306. package/dist/src/utilities/filters/constants.d.ts +406 -0
  307. package/dist/src/utilities/filters/constants.js +206 -0
  308. package/dist/src/utilities/filters/constants.js.map +1 -0
  309. package/dist/src/utilities/filters/index.d.ts +1 -0
  310. package/dist/src/utilities/filters/index.js +2 -0
  311. package/dist/src/utilities/filters/index.js.map +1 -0
  312. package/dist/src/utilities/flex/constants.d.ts +934 -0
  313. package/dist/src/utilities/flex/constants.js +221 -0
  314. package/dist/src/utilities/flex/constants.js.map +1 -0
  315. package/dist/src/utilities/flex/index.d.ts +1 -0
  316. package/dist/src/utilities/flex/index.js +2 -0
  317. package/dist/src/utilities/flex/index.js.map +1 -0
  318. package/dist/src/utilities/flex/types.d.ts +0 -0
  319. package/dist/src/utilities/flex/types.js +4 -0
  320. package/dist/src/utilities/flex/types.js.map +1 -0
  321. package/dist/src/utilities/index.d.ts +31338 -0
  322. package/dist/src/utilities/index.js +333 -0
  323. package/dist/src/utilities/index.js.map +1 -0
  324. package/dist/src/utilities/interactivity/constants.d.ts +1244 -0
  325. package/dist/src/utilities/interactivity/constants.js +165 -0
  326. package/dist/src/utilities/interactivity/constants.js.map +1 -0
  327. package/dist/src/utilities/interactivity/index.d.ts +1 -0
  328. package/dist/src/utilities/interactivity/index.js +2 -0
  329. package/dist/src/utilities/interactivity/index.js.map +1 -0
  330. package/dist/src/utilities/layout/constants.d.ts +837 -0
  331. package/dist/src/utilities/layout/constants.js +159 -0
  332. package/dist/src/utilities/layout/constants.js.map +1 -0
  333. package/dist/src/utilities/layout/index.d.ts +1 -0
  334. package/dist/src/utilities/layout/index.js +2 -0
  335. package/dist/src/utilities/layout/index.js.map +1 -0
  336. package/dist/src/utilities/layout/types.d.ts +0 -0
  337. package/dist/src/utilities/layout/types.js +2 -0
  338. package/dist/src/utilities/layout/types.js.map +1 -0
  339. package/dist/src/utilities/sizing/constants.d.ts +989 -0
  340. package/dist/src/utilities/sizing/constants.js +53 -0
  341. package/dist/src/utilities/sizing/constants.js.map +1 -0
  342. package/dist/src/utilities/sizing/index.d.ts +2 -0
  343. package/dist/src/utilities/sizing/index.js +3 -0
  344. package/dist/src/utilities/sizing/index.js.map +1 -0
  345. package/dist/src/utilities/sizing/types.d.ts +10 -0
  346. package/dist/src/utilities/sizing/types.js +2 -0
  347. package/dist/src/utilities/sizing/types.js.map +1 -0
  348. package/dist/src/utilities/spacing/constants.d.ts +1779 -0
  349. package/dist/src/utilities/spacing/constants.js +142 -0
  350. package/dist/src/utilities/spacing/constants.js.map +1 -0
  351. package/dist/src/utilities/spacing/index.d.ts +2 -0
  352. package/dist/src/utilities/spacing/index.js +3 -0
  353. package/dist/src/utilities/spacing/index.js.map +1 -0
  354. package/dist/src/utilities/spacing/types.d.ts +15 -0
  355. package/dist/src/utilities/spacing/types.js +8 -0
  356. package/dist/src/utilities/spacing/types.js.map +1 -0
  357. package/dist/src/utilities/svg/constants.d.ts +1062 -0
  358. package/dist/src/utilities/svg/constants.js +34 -0
  359. package/dist/src/utilities/svg/constants.js.map +1 -0
  360. package/dist/src/utilities/transforms/constants.d.ts +247 -0
  361. package/dist/src/utilities/transforms/constants.js +74 -0
  362. package/dist/src/utilities/transforms/constants.js.map +1 -0
  363. package/dist/src/utilities/transforms/index.d.ts +1 -0
  364. package/dist/src/utilities/transforms/index.js +2 -0
  365. package/dist/src/utilities/transforms/index.js.map +1 -0
  366. package/dist/src/utilities/transitions/constants.d.ts +116 -0
  367. package/dist/src/utilities/transitions/constants.js +91 -0
  368. package/dist/src/utilities/transitions/constants.js.map +1 -0
  369. package/dist/src/utilities/transitions/index.d.ts +1 -0
  370. package/dist/src/utilities/transitions/index.js +2 -0
  371. package/dist/src/utilities/transitions/index.js.map +1 -0
  372. package/dist/src/utilities/typography/constants.d.ts +2401 -0
  373. package/dist/src/utilities/typography/constants.js +401 -0
  374. package/dist/src/utilities/typography/constants.js.map +1 -0
  375. package/dist/src/utilities/typography/index.d.ts +1 -0
  376. package/dist/src/utilities/typography/index.js +2 -0
  377. package/dist/src/utilities/typography/index.js.map +1 -0
  378. package/dist/src/utils.d.ts +18 -0
  379. package/dist/src/utils.js +282 -0
  380. package/dist/src/utils.js.map +1 -0
  381. package/dist/src/watcher.d.ts +15 -0
  382. package/dist/src/watcher.js +62 -0
  383. package/dist/src/watcher.js.map +1 -0
  384. package/dist/tsconfig.tsbuildinfo +1 -0
  385. package/dist/utilities.css +1 -0
  386. package/index.css +2 -0
  387. package/package.json +139 -0
  388. package/reset.css +168 -0
  389. package/utilities.css +1 -0
@@ -0,0 +1,2028 @@
1
+ function _arrayLikeToArray(r, a) {
2
+ (null == a || a > r.length) && (a = r.length);
3
+ for (var e = 0, n = Array(a); e < a; e++) n[e] = r[e];
4
+ return n;
5
+ }
6
+ function _arrayWithoutHoles(r) {
7
+ if (Array.isArray(r)) return _arrayLikeToArray(r);
8
+ }
9
+ function _classCallCheck(a, n) {
10
+ if (!(a instanceof n)) throw new TypeError("Cannot call a class as a function");
11
+ }
12
+ function _defineProperties(e, r) {
13
+ for (var t = 0; t < r.length; t++) {
14
+ var o = r[t];
15
+ o.enumerable = o.enumerable || false, o.configurable = true, "value" in o && (o.writable = true), Object.defineProperty(e, _toPropertyKey(o.key), o);
16
+ }
17
+ }
18
+ function _createClass(e, r, t) {
19
+ return r && _defineProperties(e.prototype, r), t && _defineProperties(e, t), Object.defineProperty(e, "prototype", {
20
+ writable: false
21
+ }), e;
22
+ }
23
+ function _createForOfIteratorHelper(r, e) {
24
+ var t = "undefined" != typeof Symbol && r[Symbol.iterator] || r["@@iterator"];
25
+ if (!t) {
26
+ if (Array.isArray(r) || (t = _unsupportedIterableToArray(r)) || e) {
27
+ t && (r = t);
28
+ var n = 0,
29
+ F = function () {};
30
+ return {
31
+ s: F,
32
+ n: function () {
33
+ return n >= r.length ? {
34
+ done: true
35
+ } : {
36
+ done: false,
37
+ value: r[n++]
38
+ };
39
+ },
40
+ e: function (r) {
41
+ throw r;
42
+ },
43
+ f: F
44
+ };
45
+ }
46
+ throw new TypeError("Invalid attempt to iterate non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
47
+ }
48
+ var o,
49
+ a = true,
50
+ u = false;
51
+ return {
52
+ s: function () {
53
+ t = t.call(r);
54
+ },
55
+ n: function () {
56
+ var r = t.next();
57
+ return a = r.done, r;
58
+ },
59
+ e: function (r) {
60
+ u = true, o = r;
61
+ },
62
+ f: function () {
63
+ try {
64
+ a || null == t.return || t.return();
65
+ } finally {
66
+ if (u) throw o;
67
+ }
68
+ }
69
+ };
70
+ }
71
+ function _defineProperty(e, r, t) {
72
+ return (r = _toPropertyKey(r)) in e ? Object.defineProperty(e, r, {
73
+ value: t,
74
+ enumerable: true,
75
+ configurable: true,
76
+ writable: true
77
+ }) : e[r] = t, e;
78
+ }
79
+ function _iterableToArray(r) {
80
+ if ("undefined" != typeof Symbol && null != r[Symbol.iterator] || null != r["@@iterator"]) return Array.from(r);
81
+ }
82
+ function _nonIterableSpread() {
83
+ throw new TypeError("Invalid attempt to spread non-iterable instance.\nIn order to be iterable, non-array objects must have a [Symbol.iterator]() method.");
84
+ }
85
+ function ownKeys(e, r) {
86
+ var t = Object.keys(e);
87
+ if (Object.getOwnPropertySymbols) {
88
+ var o = Object.getOwnPropertySymbols(e);
89
+ r && (o = o.filter(function (r) {
90
+ return Object.getOwnPropertyDescriptor(e, r).enumerable;
91
+ })), t.push.apply(t, o);
92
+ }
93
+ return t;
94
+ }
95
+ function _objectSpread2(e) {
96
+ for (var r = 1; r < arguments.length; r++) {
97
+ var t = null != arguments[r] ? arguments[r] : {};
98
+ r % 2 ? ownKeys(Object(t), true).forEach(function (r) {
99
+ _defineProperty(e, r, t[r]);
100
+ }) : Object.getOwnPropertyDescriptors ? Object.defineProperties(e, Object.getOwnPropertyDescriptors(t)) : ownKeys(Object(t)).forEach(function (r) {
101
+ Object.defineProperty(e, r, Object.getOwnPropertyDescriptor(t, r));
102
+ });
103
+ }
104
+ return e;
105
+ }
106
+ function _toConsumableArray(r) {
107
+ return _arrayWithoutHoles(r) || _iterableToArray(r) || _unsupportedIterableToArray(r) || _nonIterableSpread();
108
+ }
109
+ function _toPrimitive(t, r) {
110
+ if ("object" != typeof t || !t) return t;
111
+ var e = t[Symbol.toPrimitive];
112
+ if (void 0 !== e) {
113
+ var i = e.call(t, r);
114
+ if ("object" != typeof i) return i;
115
+ throw new TypeError("@@toPrimitive must return a primitive value.");
116
+ }
117
+ return ("string" === r ? String : Number)(t);
118
+ }
119
+ function _toPropertyKey(t) {
120
+ var i = _toPrimitive(t, "string");
121
+ return "symbol" == typeof i ? i : i + "";
122
+ }
123
+ function _unsupportedIterableToArray(r, a) {
124
+ if (r) {
125
+ if ("string" == typeof r) return _arrayLikeToArray(r, a);
126
+ var t = {}.toString.call(r).slice(8, -1);
127
+ return "Object" === t && r.constructor && (t = r.constructor.name), "Map" === t || "Set" === t ? Array.from(r) : "Arguments" === t || /^(?:Ui|I)nt(?:8|16|32)(?:Clamped)?Array$/.test(t) ? _arrayLikeToArray(r, a) : void 0;
128
+ }
129
+ }
130
+
131
+ /**
132
+ * CSS Generator — converts a CSS AST back to a CSS string.
133
+ *
134
+ * Supports:
135
+ * - Pretty-printing with configurable indent / newline
136
+ * - Minification (all whitespace removed except mandatory single spaces)
137
+ * - Optional comment suppression
138
+ * - Per-node middleware (onRule, onAtRule, onDeclaration, onComment, onKeyframe)
139
+ * called *after* serialization so you can post-process individual nodes
140
+ */
141
+
142
+ var CssGenerator = /*#__PURE__*/function () {
143
+ function CssGenerator() {
144
+ var _opts$minify, _opts$newline, _opts$indent, _opts$comments;
145
+ var opts = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
146
+ _classCallCheck(this, CssGenerator);
147
+ this.opts = opts;
148
+ var min = (_opts$minify = opts.minify) !== null && _opts$minify !== void 0 ? _opts$minify : false;
149
+ this.nl = min ? '' : (_opts$newline = opts.newline) !== null && _opts$newline !== void 0 ? _opts$newline : '\n';
150
+ this.sp = min ? '' : ' ';
151
+ this.ind = min ? '' : (_opts$indent = opts.indent) !== null && _opts$indent !== void 0 ? _opts$indent : ' ';
152
+ this.showComments = (_opts$comments = opts.comments) !== null && _opts$comments !== void 0 ? _opts$comments : true;
153
+ }
154
+ return _createClass(CssGenerator, [{
155
+ key: "generate",
156
+ value: function generate(node) {
157
+ var depth = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 0;
158
+ switch (node.type) {
159
+ case 'stylesheet':
160
+ return this.genSheet(node, depth);
161
+ case 'rule':
162
+ return this.genRule(node, depth);
163
+ case 'atrule':
164
+ return this.genAtRule(node, depth);
165
+ case 'declaration':
166
+ return this.genDecl(node, depth);
167
+ case 'comment':
168
+ return this.showComments ? this.genComment(node, depth) : '';
169
+ case 'keyframe':
170
+ return this.genKeyframe(node, depth);
171
+ default:
172
+ return '';
173
+ }
174
+ }
175
+ }, {
176
+ key: "pad",
177
+ value: function pad(depth) {
178
+ return this.opts.minify ? '' : this.ind.repeat(depth);
179
+ }
180
+ }, {
181
+ key: "genSheet",
182
+ value: function genSheet(ss, depth) {
183
+ var _this = this;
184
+ return ss.children.map(function (c) {
185
+ return _this.generate(c, depth);
186
+ }).filter(function (s) {
187
+ return s.length > 0;
188
+ }).join(this.opts.minify ? '' : this.nl + this.nl);
189
+ }
190
+ }, {
191
+ key: "genRule",
192
+ value: function genRule(rule, depth) {
193
+ var _rule$rawSelector, _rule$children;
194
+ var pad = this.pad(depth);
195
+ var ipad = this.pad(depth + 1);
196
+ var sel = (_rule$rawSelector = rule.rawSelector) !== null && _rule$rawSelector !== void 0 ? _rule$rawSelector : rule.selectors.map(function (s) {
197
+ return s.value;
198
+ }).join(",".concat(this.sp));
199
+ var body = '';
200
+ var _iterator = _createForOfIteratorHelper(rule.declarations),
201
+ _step;
202
+ try {
203
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
204
+ var d = _step.value;
205
+ body += ipad + this.genDecl(d, 0) + this.nl;
206
+ }
207
+ } catch (err) {
208
+ _iterator.e(err);
209
+ } finally {
210
+ _iterator.f();
211
+ }
212
+ if ((_rule$children = rule.children) !== null && _rule$children !== void 0 && _rule$children.length) {
213
+ var _iterator2 = _createForOfIteratorHelper(rule.children),
214
+ _step2;
215
+ try {
216
+ for (_iterator2.s(); !(_step2 = _iterator2.n()).done;) {
217
+ var child = _step2.value;
218
+ var str = this.generate(child, depth + 1);
219
+ if (str) body += str + this.nl;
220
+ }
221
+ } catch (err) {
222
+ _iterator2.e(err);
223
+ } finally {
224
+ _iterator2.f();
225
+ }
226
+ }
227
+ var css = "".concat(pad).concat(sel).concat(this.sp, "{").concat(this.nl).concat(body).concat(pad, "}");
228
+ return this.opts.onRule ? this.opts.onRule(rule, css) : css;
229
+ }
230
+ }, {
231
+ key: "genAtRule",
232
+ value: function genAtRule(ar, depth) {
233
+ var _ref, _ar$preludeText, _ar$prelude;
234
+ var pad = this.pad(depth);
235
+ var prelude = (_ref = (_ar$preludeText = ar.preludeText) !== null && _ar$preludeText !== void 0 ? _ar$preludeText : (_ar$prelude = ar.prelude) === null || _ar$prelude === void 0 ? void 0 : _ar$prelude.map(function (v) {
236
+ return String(v.value);
237
+ }).join(' ')) !== null && _ref !== void 0 ? _ref : '';
238
+ var head = "@".concat(ar.name).concat(prelude ? ' ' + prelude : '');
239
+ if (!ar.block) {
240
+ var _css = "".concat(pad).concat(head, ";");
241
+ return this.opts.onAtRule ? this.opts.onAtRule(ar, _css) : _css;
242
+ }
243
+ var body = '';
244
+ var _iterator3 = _createForOfIteratorHelper(ar.block.children),
245
+ _step3;
246
+ try {
247
+ for (_iterator3.s(); !(_step3 = _iterator3.n()).done;) {
248
+ var child = _step3.value;
249
+ var str = this.generate(child, depth + 1);
250
+ if (str) body += str + this.nl;
251
+ }
252
+ } catch (err) {
253
+ _iterator3.e(err);
254
+ } finally {
255
+ _iterator3.f();
256
+ }
257
+ var css = "".concat(pad).concat(head).concat(this.sp, "{").concat(this.nl).concat(body).concat(pad, "}");
258
+ return this.opts.onAtRule ? this.opts.onAtRule(ar, css) : css;
259
+ }
260
+ }, {
261
+ key: "genDecl",
262
+ value: function genDecl(d, depth) {
263
+ var _d$rawValue;
264
+ var pad = this.pad(depth);
265
+ var value = (_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : d.value.map(function (v) {
266
+ return String(v.value);
267
+ }).join(' ');
268
+ var imp = d.important ? ' !important' : '';
269
+ var css = "".concat(pad).concat(d.property, ":").concat(this.sp).concat(value).concat(imp, ";");
270
+ return this.opts.onDeclaration ? this.opts.onDeclaration(d, css) : css;
271
+ }
272
+ }, {
273
+ key: "genComment",
274
+ value: function genComment(c, depth) {
275
+ var css = "".concat(this.pad(depth), "/*").concat(c.value, "*/");
276
+ return this.opts.onComment ? this.opts.onComment(c, css) : css;
277
+ }
278
+ }, {
279
+ key: "genKeyframe",
280
+ value: function genKeyframe(kf, depth) {
281
+ var _this2 = this;
282
+ var pad = this.pad(depth);
283
+ var ipad = this.pad(depth + 1);
284
+ var body = kf.declarations.map(function (d) {
285
+ return ipad + _this2.genDecl(d, 0) + _this2.nl;
286
+ }).join('');
287
+ var css = "".concat(pad).concat(kf.selector).concat(this.sp, "{").concat(this.nl).concat(body).concat(pad, "}");
288
+ return this.opts.onKeyframe ? this.opts.onKeyframe(kf, css) : css;
289
+ }
290
+ }]);
291
+ }();
292
+
293
+ // ─── Convenience function ─────────────────────────────────────────────────────
294
+
295
+ /** Serialize a CSS AST node back to a CSS string. */
296
+ function stringify(node, options) {
297
+ return new CssGenerator(options).generate(node);
298
+ }
299
+
300
+ /**
301
+ * CSS AST helper / factory functions.
302
+ *
303
+ * Thin wrappers that construct typed AST nodes so callers don't have to
304
+ * spell out `type: 'rule'` etc. everywhere.
305
+ *
306
+ * All parameters that could be omitted are optional and default to sensible
307
+ * empty values so that helpers compose naturally:
308
+ *
309
+ * import { rule, decl, atRule } from './css-helpers';
310
+ *
311
+ * const node = rule('.btn', [
312
+ * decl('color', 'red'),
313
+ * decl('font-size', '1rem'),
314
+ * ]);
315
+ */
316
+
317
+ // ─── Location ─────────────────────────────────────────────────────────────────
318
+
319
+ function locationPos(line, column, offset) {
320
+ return {
321
+ line: line,
322
+ column: column,
323
+ offset: offset
324
+ };
325
+ }
326
+ function location(start, end, source) {
327
+ return {
328
+ start: start,
329
+ end: end,
330
+ source: source
331
+ };
332
+ }
333
+
334
+ // ─── Selector ─────────────────────────────────────────────────────────────────
335
+
336
+ function selector(value, loc) {
337
+ return {
338
+ type: 'selector',
339
+ value: value,
340
+ loc: loc
341
+ };
342
+ }
343
+
344
+ // ─── Declaration ──────────────────────────────────────────────────────────────
345
+
346
+ /**
347
+ * Build a `CssDeclaration` node.
348
+ *
349
+ * @param property CSS property name (e.g. `'color'`, `'--my-var'`)
350
+ * @param rawValue Raw value string (e.g. `'red'`, `'1px solid #000'`)
351
+ * @param important Whether the declaration carries `!important`
352
+ * @param value Parsed `CssValue[]` tokens — defaults to empty (lazy parse)
353
+ * @param loc Optional source location
354
+ */
355
+ function decl(property, rawValue) {
356
+ var important = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : false;
357
+ var value = arguments.length > 3 && arguments[3] !== undefined ? arguments[3] : [];
358
+ var loc = arguments.length > 4 ? arguments[4] : undefined;
359
+ return {
360
+ type: 'declaration',
361
+ property: property,
362
+ rawValue: rawValue,
363
+ value: value,
364
+ important: important,
365
+ loc: loc
366
+ };
367
+ }
368
+
369
+ /** Alias for {@link decl} with a name that mirrors the AST interface. */
370
+ function declaration(property, value, important, rawValue, loc) {
371
+ return {
372
+ type: 'declaration',
373
+ property: property,
374
+ value: value,
375
+ rawValue: rawValue,
376
+ important: important,
377
+ loc: loc
378
+ };
379
+ }
380
+
381
+ // ─── Rule ─────────────────────────────────────────────────────────────────────
382
+
383
+ /**
384
+ * Build a `CssRule` node.
385
+ *
386
+ * @param rawSelector Raw selector string (e.g. `'.btn:hover'`)
387
+ * @param declarations Array of declarations
388
+ * @param children Optional nested rules / at-rules (CSS nesting)
389
+ * @param loc Optional source location
390
+ */
391
+ function rule(rawSelector) {
392
+ var declarations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
393
+ var children = arguments.length > 2 ? arguments[2] : undefined;
394
+ var loc = arguments.length > 3 ? arguments[3] : undefined;
395
+ var selectors = rawSelector.split(',').map(function (s) {
396
+ return selector(s.trim());
397
+ });
398
+ var node = {
399
+ type: 'rule',
400
+ rawSelector: rawSelector,
401
+ selectors: selectors,
402
+ declarations: declarations,
403
+ loc: loc
404
+ };
405
+ if (children !== null && children !== void 0 && children.length) node.children = children;
406
+ return node;
407
+ }
408
+
409
+ // ─── At-rule ──────────────────────────────────────────────────────────────────
410
+
411
+ /**
412
+ * Build a `CssAtRule` node.
413
+ *
414
+ * @param name At-rule name without `@` (e.g. `'media'`, `'keyframes'`)
415
+ * @param preludeText Raw prelude text (e.g. `'screen and (max-width: 600px)'`)
416
+ * @param children Block children (rules, declarations, keyframes…)
417
+ * @param loc Optional source location
418
+ */
419
+ function atRule(name) {
420
+ var preludeText = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : '';
421
+ var children = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : [];
422
+ var loc = arguments.length > 3 ? arguments[3] : undefined;
423
+ var node = {
424
+ type: 'atrule',
425
+ name: name,
426
+ preludeText: preludeText,
427
+ prelude: [],
428
+ loc: loc
429
+ };
430
+ if (children.length) {
431
+ node.block = {
432
+ type: 'block',
433
+ children: children
434
+ };
435
+ }
436
+ return node;
437
+ }
438
+
439
+ // ─── Comment ──────────────────────────────────────────────────────────────────
440
+
441
+ function comment(value, loc) {
442
+ return {
443
+ type: 'comment',
444
+ value: value,
445
+ style: value.includes('\n') ? 'multi-line' : 'single-line',
446
+ loc: loc
447
+ };
448
+ }
449
+
450
+ // ─── Keyframe ─────────────────────────────────────────────────────────────────
451
+
452
+ function keyframe(selectorText) {
453
+ var declarations = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : [];
454
+ var loc = arguments.length > 2 ? arguments[2] : undefined;
455
+ return {
456
+ type: 'keyframe',
457
+ selector: selectorText,
458
+ declarations: declarations,
459
+ loc: loc
460
+ };
461
+ }
462
+
463
+ // ─── Stylesheet ───────────────────────────────────────────────────────────────
464
+
465
+ function stylesheet() {
466
+ var children = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : [];
467
+ return {
468
+ type: 'stylesheet',
469
+ children: children,
470
+ imports: [],
471
+ namespaces: [],
472
+ mediaQueries: [],
473
+ keyframes: [],
474
+ fontFaces: [],
475
+ layers: [],
476
+ containers: [],
477
+ supports: [],
478
+ documents: [],
479
+ pages: [],
480
+ counterStyles: [],
481
+ fontFeatureValues: [],
482
+ viewports: [],
483
+ charsets: []
484
+ };
485
+ }
486
+
487
+ // ─── Clone ────────────────────────────────────────────────────────────────────
488
+
489
+ /** Shallow-clone any CSS AST node (one level deep). */
490
+ function cloneNode(node) {
491
+ return _objectSpread2({}, node);
492
+ }
493
+
494
+ /** Deep-clone a CSS AST node tree. */
495
+ function cloneNodeDeep(node) {
496
+ var shallow = _objectSpread2({}, node);
497
+ if (shallow.declarations) {
498
+ shallow.declarations = shallow.declarations.map(function (d) {
499
+ return _objectSpread2({}, d);
500
+ });
501
+ }
502
+ if (shallow.children) {
503
+ shallow.children = shallow.children.map(function (c) {
504
+ return cloneNodeDeep(c);
505
+ });
506
+ }
507
+ if (shallow.block) {
508
+ shallow.block = _objectSpread2(_objectSpread2({}, shallow.block), {}, {
509
+ children: shallow.block.children.map(function (c) {
510
+ return cloneNodeDeep(c);
511
+ })
512
+ });
513
+ }
514
+ if (shallow.selectors) {
515
+ shallow.selectors = shallow.selectors.map(function (s) {
516
+ return _objectSpread2({}, s);
517
+ });
518
+ }
519
+ if (shallow.keyframes) {
520
+ shallow.keyframes = shallow.keyframes.map(function (kf) {
521
+ return _objectSpread2(_objectSpread2({}, kf), {}, {
522
+ declarations: kf.declarations.map(function (d) {
523
+ return _objectSpread2({}, d);
524
+ })
525
+ });
526
+ });
527
+ }
528
+ return shallow;
529
+ }
530
+
531
+ // ─── Walk ─────────────────────────────────────────────────────────────────────
532
+
533
+ /**
534
+ * Depth-first traversal of a CSS AST.
535
+ *
536
+ * The visitor may mutate, replace, or remove nodes via the `WalkContext`:
537
+ *
538
+ * ```ts
539
+ * walk(ast, {
540
+ * rule(node, ctx) {
541
+ * if (node.rawSelector === '.old') ctx.replace(rule('.new', node.declarations));
542
+ * },
543
+ * declaration(node, ctx) {
544
+ * if (node.property === 'color') ctx.remove();
545
+ * },
546
+ * });
547
+ * ```
548
+ *
549
+ * To stop the entire traversal early call `ctx.stop()`.
550
+ */
551
+ function walk(node, visitor) {
552
+ var state = {
553
+ stopped: false
554
+ };
555
+ _walk(node, visitor, null, 0, 0, state);
556
+ }
557
+ function _walk(node, visitor, parent, index, depth, state) {
558
+ var _visitor$stylesheet, _visitor$rule, _visitor$atrule, _visitor$declaration, _visitor$comment, _visitor$keyframe, _visitor$enter, _visitor$leave2;
559
+ if (state.stopped) return;
560
+
561
+ // ── Build mutation context ────────────────────────────────────────────────
562
+ var pendingAction = null;
563
+ var ctx = {
564
+ parent: parent,
565
+ index: index,
566
+ depth: depth,
567
+ stop: function stop() {
568
+ state.stopped = true;
569
+ },
570
+ remove: function remove() {
571
+ pendingAction = 'remove';
572
+ },
573
+ replace: function replace(n) {
574
+ pendingAction = {
575
+ type: 'replace',
576
+ node: n
577
+ };
578
+ }
579
+ };
580
+
581
+ // ── Dispatch typed visitor ────────────────────────────────────────────────
582
+ switch (node.type) {
583
+ case 'stylesheet':
584
+ (_visitor$stylesheet = visitor.stylesheet) === null || _visitor$stylesheet === void 0 || _visitor$stylesheet.call(visitor, node, ctx);
585
+ break;
586
+ case 'rule':
587
+ (_visitor$rule = visitor.rule) === null || _visitor$rule === void 0 || _visitor$rule.call(visitor, node, ctx);
588
+ break;
589
+ case 'atrule':
590
+ (_visitor$atrule = visitor.atrule) === null || _visitor$atrule === void 0 || _visitor$atrule.call(visitor, node, ctx);
591
+ break;
592
+ case 'declaration':
593
+ (_visitor$declaration = visitor.declaration) === null || _visitor$declaration === void 0 || _visitor$declaration.call(visitor, node, ctx);
594
+ break;
595
+ case 'comment':
596
+ (_visitor$comment = visitor.comment) === null || _visitor$comment === void 0 || _visitor$comment.call(visitor, node, ctx);
597
+ break;
598
+ case 'keyframe':
599
+ (_visitor$keyframe = visitor.keyframe) === null || _visitor$keyframe === void 0 || _visitor$keyframe.call(visitor, node, ctx);
600
+ break;
601
+ }
602
+ if (!state.stopped) (_visitor$enter = visitor.enter) === null || _visitor$enter === void 0 || _visitor$enter.call(visitor, node, ctx);
603
+
604
+ // ── Apply replace / remove before descending ──────────────────────────────
605
+ if (pendingAction !== null) {
606
+ var _visitor$leave;
607
+ applyMutation(pendingAction, parent, index);
608
+ // After removal/replacement, don't descend into the original node
609
+ if (!state.stopped) (_visitor$leave = visitor.leave) === null || _visitor$leave === void 0 || _visitor$leave.call(visitor, node, ctx);
610
+ return;
611
+ }
612
+ if (state.stopped) return;
613
+
614
+ // ── Descend ───────────────────────────────────────────────────────────────
615
+ var children = getChildren(node);
616
+ for (var i = 0; i < children.length; i++) {
617
+ if (state.stopped) break;
618
+ _walk(children[i], visitor, node, i, depth + 1, state);
619
+ // After a walk the array may have mutated (remove/replace); adjust index
620
+ // by checking length (children is a live reference to the original array)
621
+ }
622
+ if (!state.stopped) (_visitor$leave2 = visitor.leave) === null || _visitor$leave2 === void 0 || _visitor$leave2.call(visitor, node, ctx);
623
+ }
624
+ function getChildren(node) {
625
+ switch (node.type) {
626
+ case 'stylesheet':
627
+ {
628
+ var ss = node;
629
+ return ss.children;
630
+ }
631
+ case 'rule':
632
+ {
633
+ var r = node;
634
+ var out = _toConsumableArray(r.declarations);
635
+ if (r.children) out.push.apply(out, _toConsumableArray(r.children));
636
+ return out;
637
+ }
638
+ case 'atrule':
639
+ {
640
+ var ar = node;
641
+ return ar.block ? ar.block.children : [];
642
+ }
643
+ default:
644
+ return [];
645
+ }
646
+ }
647
+ function applyMutation(action, parent, index) {
648
+ if (!parent) return;
649
+ var arr = getMutableChildArray(parent, index);
650
+ if (!arr) return;
651
+ if (action === 'remove') {
652
+ arr.splice(index, 1);
653
+ } else {
654
+ var n = Array.isArray(action.node) ? action.node : [action.node];
655
+ arr.splice.apply(arr, [index, 1].concat(_toConsumableArray(n)));
656
+ }
657
+ }
658
+ function getMutableChildArray(parent, index) {
659
+ switch (parent.type) {
660
+ case 'stylesheet':
661
+ return parent.children;
662
+ case 'rule':
663
+ {
664
+ var r = parent;
665
+ // index < declarations.length → declaration, else → nested child
666
+ if (index < r.declarations.length) return r.declarations;
667
+ if (r.children) return r.children;
668
+ return null;
669
+ }
670
+ case 'atrule':
671
+ {
672
+ var ar = parent;
673
+ return ar.block ? ar.block.children : null;
674
+ }
675
+ default:
676
+ return null;
677
+ }
678
+ }
679
+
680
+ // ─── Charcode constants (avoids string allocation on hot paths) ───────────────
681
+ var CC_TAB = 9,
682
+ CC_LF = 10,
683
+ CC_CR = 13,
684
+ CC_FF = 12,
685
+ CC_SPACE = 32;
686
+ var CC_DQUOTE = 34,
687
+ CC_HASH = 35,
688
+ CC_AMP = 38,
689
+ CC_SQUOTE = 39;
690
+ var CC_LPAREN = 40,
691
+ CC_RPAREN = 41,
692
+ CC_STAR = 42,
693
+ CC_PLUS = 43;
694
+ var CC_COMMA = 44,
695
+ CC_MINUS = 45,
696
+ CC_DOT = 46,
697
+ CC_SLASH = 47;
698
+ var CC_COLON = 58,
699
+ CC_SEMI = 59,
700
+ CC_GT = 62;
701
+ var CC_AT = 64,
702
+ CC_LBRACK = 91,
703
+ CC_BSLASH = 92,
704
+ CC_RBRACK = 93;
705
+ var CC_UNDER = 95,
706
+ CC_LBRACE = 123,
707
+ CC_RBRACE = 125,
708
+ CC_TILDE = 126;
709
+
710
+ // ─── Character predicates (charcode-based, no regex) ─────────────────────────
711
+
712
+ function isWS(c) {
713
+ return c === CC_SPACE || c === CC_TAB || c === CC_LF || c === CC_CR || c === CC_FF;
714
+ }
715
+ function isDigit(c) {
716
+ return c >= 48 && c <= 57;
717
+ }
718
+ function isAlpha(c) {
719
+ return c >= 65 && c <= 90 || c >= 97 && c <= 122;
720
+ }
721
+ function isHex(c) {
722
+ return isDigit(c) || c >= 65 && c <= 70 || c >= 97 && c <= 102;
723
+ }
724
+ /**
725
+ * CSS ident-start: letter | underscore | non-ASCII | hyphen.
726
+ * A leading hyphen is valid (vendor prefixes, custom properties).
727
+ */
728
+ function isNameStart(c) {
729
+ return isAlpha(c) || c === CC_UNDER || c === CC_MINUS || c > 127;
730
+ }
731
+ /** CSS ident-char: ident-start | digit */
732
+ function isNameChar(c) {
733
+ return isAlpha(c) || isDigit(c) || c === CC_UNDER || c === CC_MINUS || c > 127;
734
+ }
735
+
736
+ // ─── Block context ────────────────────────────────────────────────────────────
737
+
738
+ /**
739
+ * Determines what may legally appear inside a block:
740
+ * stylesheet – top-level: rules + at-rules
741
+ * mixed – @media/@supports/@container/@layer: rules + at-rules
742
+ * rule – inside a style rule: declarations + optional CSS nesting
743
+ * keyframes – inside @keyframes: keyframe stops (from/to/%)
744
+ * declarations– @font-face/@page/etc.: declarations only
745
+ */
746
+
747
+ // ─── CssParser ────────────────────────────────────────────────────────────────
748
+
749
+ var CssParser = /*#__PURE__*/function () {
750
+ function CssParser() {
751
+ var options = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : {};
752
+ _classCallCheck(this, CssParser);
753
+ _defineProperty(this, "input", '');
754
+ _defineProperty(this, "pos", 0);
755
+ _defineProperty(this, "length", 0);
756
+ _defineProperty(this, "line", 1);
757
+ _defineProperty(this, "col", 1);
758
+ _defineProperty(this, "errors", []);
759
+ _defineProperty(this, "warnings", []);
760
+ _defineProperty(this, "stats", CssParser.emptyStats());
761
+ this.options = _objectSpread2({
762
+ parseAtrulePrelude: true,
763
+ parseValue: true,
764
+ parseCustomProperty: true,
765
+ parseRulePrelude: true,
766
+ parseSelector: true,
767
+ includeComments: true,
768
+ includeSourceMaps: true,
769
+ includeSpecificity: true,
770
+ includeVendorPrefixes: true,
771
+ onError: function onError() {/* noop */},
772
+ onWarning: function onWarning() {/* noop */},
773
+ maxDepth: 100,
774
+ maxNodes: 100000,
775
+ enableNesting: true,
776
+ enableCustomProperties: true,
777
+ enableLogicalProperties: true,
778
+ enableContainerQueries: true,
779
+ enableLayerQueries: true,
780
+ enableSupportsQueries: true,
781
+ // middleware — undefined by default (fast path skips them)
782
+ onRule: undefined,
783
+ onAtRule: undefined,
784
+ onDeclaration: undefined,
785
+ onComment: undefined,
786
+ onKeyframe: undefined
787
+ }, options);
788
+ }
789
+
790
+ // ── Public API ────────────────────────────────────────────────────────────
791
+ return _createClass(CssParser, [{
792
+ key: "parse",
793
+ value: function parse(css) {
794
+ var t0 = typeof performance !== 'undefined' ? performance.now() : Date.now();
795
+ this.reset(css);
796
+ var sheet = this.parseStylesheet();
797
+ this.stats.parseTime = (typeof performance !== 'undefined' ? performance.now() : Date.now()) - t0;
798
+ return sheet;
799
+ }
800
+ }, {
801
+ key: "getErrors",
802
+ value: function getErrors() {
803
+ return _toConsumableArray(this.errors);
804
+ }
805
+ }, {
806
+ key: "getWarnings",
807
+ value: function getWarnings() {
808
+ return _toConsumableArray(this.warnings);
809
+ }
810
+ }, {
811
+ key: "getStats",
812
+ value: function getStats() {
813
+ return _objectSpread2({}, this.stats);
814
+ }
815
+ }, {
816
+ key: "toLegacyFormat",
817
+ value: function toLegacyFormat(stylesheet) {
818
+ var _this = this;
819
+ return stylesheet.children.map(function (c) {
820
+ return _this.toLegacyNode(c);
821
+ }).filter(Boolean);
822
+ }
823
+
824
+ // ── Reset ─────────────────────────────────────────────────────────────────
825
+ }, {
826
+ key: "reset",
827
+ value: function reset(css) {
828
+ this.input = css;
829
+ this.pos = 0;
830
+ this.length = css.length;
831
+ this.line = 1;
832
+ this.col = 1;
833
+ this.errors = [];
834
+ this.warnings = [];
835
+ this.stats = CssParser.emptyStats();
836
+ }
837
+ }, {
838
+ key: "parseStylesheet",
839
+ value:
840
+ // ── Stylesheet ────────────────────────────────────────────────────────────
841
+
842
+ function parseStylesheet() {
843
+ var locStart = this.locPos();
844
+ var ss = {
845
+ type: 'stylesheet',
846
+ source: this.input,
847
+ children: [],
848
+ charset: undefined,
849
+ imports: [],
850
+ namespaces: [],
851
+ mediaQueries: [],
852
+ keyframes: [],
853
+ fontFaces: [],
854
+ layers: [],
855
+ containers: [],
856
+ supports: [],
857
+ documents: [],
858
+ pages: [],
859
+ counterStyles: [],
860
+ fontFeatureValues: [],
861
+ viewports: [],
862
+ charsets: []
863
+ };
864
+ while (this.pos < this.length) {
865
+ this.skipWS();
866
+ if (this.pos >= this.length) break;
867
+ var node = this.parseTopNode();
868
+ if (node) {
869
+ ss.children.push(node);
870
+ this.categorize(ss, node);
871
+ this.stats.totalNodes++;
872
+ }
873
+ }
874
+ if (this.options.includeSourceMaps) {
875
+ ss.loc = {
876
+ start: locStart,
877
+ end: this.locPos(),
878
+ source: this.input
879
+ };
880
+ }
881
+ return ss;
882
+ }
883
+
884
+ // ── Top-level node dispatch ───────────────────────────────────────────────
885
+ }, {
886
+ key: "parseTopNode",
887
+ value: function parseTopNode() {
888
+ var c = this.peek();
889
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
890
+ var comment = this.parseComment();
891
+ return this.options.includeComments ? comment : null;
892
+ }
893
+ if (c === CC_AT) return this.parseAtRule();
894
+ // Skip stray closing braces that can appear in malformed CSS
895
+ if (c === CC_RBRACE) {
896
+ this.advance();
897
+ return null;
898
+ }
899
+ return this.parseRule();
900
+ }
901
+
902
+ // ── Block-level node dispatch ─────────────────────────────────────────────
903
+ }, {
904
+ key: "parseBlockNode",
905
+ value: function parseBlockNode(mode) {
906
+ this.skipWS();
907
+ if (this.pos >= this.length || this.peek() === CC_RBRACE) return null;
908
+ var c = this.peek();
909
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
910
+ var comment = this.parseComment();
911
+ return this.options.includeComments ? comment : null;
912
+ }
913
+ if (c === CC_AT) return this.parseAtRule();
914
+ switch (mode) {
915
+ case 'keyframes':
916
+ return this.parseKeyframeStop();
917
+ case 'declarations':
918
+ return this.parseDeclaration();
919
+ case 'mixed':
920
+ case 'stylesheet':
921
+ if (c === CC_RBRACE) return null;
922
+ return this.parseRule();
923
+ case 'rule':
924
+ default:
925
+ // Unambiguous nesting-selector starters
926
+ if (this.isNestingStart(c)) return this.parseRule();
927
+ // Lookahead: first unescaped { at depth 0 → rule, ; or } → declaration
928
+ if (this.lookaheadIsRule()) return this.parseRule();
929
+ // console.log('parse block', c, mode);
930
+ return this.parseDeclaration();
931
+ }
932
+ }
933
+
934
+ // ── At-rule ───────────────────────────────────────────────────────────────
935
+ }, {
936
+ key: "parseAtRule",
937
+ value: function parseAtRule() {
938
+ if (this.peek() !== CC_AT) return null;
939
+ var locStart = this.locPos();
940
+ this.advance(); // '@'
941
+
942
+ var name = this.readIdent();
943
+ if (!name) {
944
+ this.recoverPast(CC_SEMI, CC_RBRACE);
945
+ return null;
946
+ }
947
+ this.skipWS();
948
+ var preludeText = this.readPrelude();
949
+ this.skipWS();
950
+ var baseName = name.replace(/^-(webkit|moz|ms|o)-/, '');
951
+ var ar = {
952
+ type: 'atrule',
953
+ name: name,
954
+ preludeText: preludeText,
955
+ prelude: this.options.parseAtrulePrelude ? this.tokenizeValue(preludeText) : []
956
+ };
957
+ if (this.options.includeVendorPrefixes) {
958
+ var vp = name.match(/^-(webkit|moz|ms|o)-/);
959
+ if (vp) ar.vendorPrefix = vp[0];
960
+ }
961
+ if (this.peek() === CC_LBRACE) {
962
+ var mode = this.modeForAtRule(baseName);
963
+ var blockStart = this.locPos();
964
+ var children = this.parseBlockChildren(mode);
965
+ var blockEnd = this.locPos();
966
+ ar.block = _objectSpread2({
967
+ type: 'block',
968
+ children: children
969
+ }, this.options.includeSourceMaps ? {
970
+ loc: {
971
+ start: blockStart,
972
+ end: blockEnd
973
+ }
974
+ } : {});
975
+
976
+ // Populate keyframes shortcut
977
+ if (baseName === 'keyframes') {
978
+ ar.keyframes = children.filter(function (n) {
979
+ return n.type === 'keyframe';
980
+ });
981
+ }
982
+ } else if (this.peek() === CC_SEMI) {
983
+ this.advance();
984
+ }
985
+ this.stats.totalAtRules++;
986
+ if (this.options.includeSourceMaps) {
987
+ ar.loc = {
988
+ start: locStart,
989
+ end: this.locPos(),
990
+ source: this.input
991
+ };
992
+ }
993
+ if (this.options.onAtRule) {
994
+ var result = this.options.onAtRule(ar);
995
+ if (result === null) return null;
996
+ if (result) return result;
997
+ }
998
+ return ar;
999
+ }
1000
+ }, {
1001
+ key: "modeForAtRule",
1002
+ value: function modeForAtRule(baseName) {
1003
+ // AWC encodes comments as @comment-XXXXXXXX { --rule-...: "..."; }
1004
+ // which contain only declarations — must NOT use mixed/rule mode or
1005
+ // readUntilLBrace() will consume past the closing } and corrupt state.
1006
+ if (baseName.startsWith('comment')) return 'declarations';
1007
+ switch (baseName) {
1008
+ case 'keyframes':
1009
+ return 'keyframes';
1010
+ case 'font-face':
1011
+ case 'page':
1012
+ case 'counter-style':
1013
+ case 'viewport':
1014
+ case 'theme':
1015
+ case 'utility':
1016
+ return 'declarations';
1017
+ case 'media':
1018
+ case 'supports':
1019
+ case 'container':
1020
+ case 'layer':
1021
+ case 'document':
1022
+ default:
1023
+ return 'mixed';
1024
+ }
1025
+ }
1026
+
1027
+ // ── Regular rule ──────────────────────────────────────────────────────────
1028
+ }, {
1029
+ key: "parseRule",
1030
+ value: function parseRule() {
1031
+ var locStart = this.locPos();
1032
+ var rawSelector = this.readUntilLBrace().trim();
1033
+ if (!rawSelector || this.peek() !== CC_LBRACE) {
1034
+ // Malformed — skip to closing brace
1035
+ if (this.peek() === CC_LBRACE) {
1036
+ this.skipBalancedBraces();
1037
+ }
1038
+ return null;
1039
+ }
1040
+ var mode = this.options.enableNesting ? 'rule' : 'declarations';
1041
+ var children = this.parseBlockChildren(mode);
1042
+ var declarations = [];
1043
+ var nested = [];
1044
+ var _iterator = _createForOfIteratorHelper(children),
1045
+ _step;
1046
+ try {
1047
+ for (_iterator.s(); !(_step = _iterator.n()).done;) {
1048
+ var child = _step.value;
1049
+ var t = child.type;
1050
+ if (t === 'declaration') declarations.push(child);else if (t === 'rule') nested.push(child);else if (t === 'atrule') nested.push(child);
1051
+ }
1052
+ } catch (err) {
1053
+ _iterator.e(err);
1054
+ } finally {
1055
+ _iterator.f();
1056
+ }
1057
+ var selectors = this.parseSelectorList(rawSelector);
1058
+ this.stats.totalRules++;
1059
+ this.stats.totalSelectors += selectors.length;
1060
+ var rule = {
1061
+ type: 'rule',
1062
+ rawSelector: rawSelector,
1063
+ selectors: selectors,
1064
+ declarations: declarations
1065
+ };
1066
+ if (nested.length > 0) rule.children = nested;
1067
+ if (this.options.includeSpecificity) {
1068
+ rule.specificity = this.calcSpecificity(rawSelector);
1069
+ }
1070
+ if (this.options.includeSourceMaps) {
1071
+ rule.loc = {
1072
+ start: locStart,
1073
+ end: this.locPos(),
1074
+ source: this.input
1075
+ };
1076
+ }
1077
+ if (this.options.onRule) {
1078
+ var result = this.options.onRule(rule);
1079
+ if (result === null) return null;
1080
+ if (result) return result;
1081
+ }
1082
+ return rule;
1083
+ }
1084
+
1085
+ // ── Keyframe stop (from / to / <percentage>) ──────────────────────────────
1086
+ }, {
1087
+ key: "parseKeyframeStop",
1088
+ value: function parseKeyframeStop() {
1089
+ var locStart = this.locPos();
1090
+ var selector = this.readUntilLBrace().trim();
1091
+ if (!selector || this.peek() !== CC_LBRACE) return null;
1092
+ var children = this.parseBlockChildren('declarations');
1093
+ var declarations = children.filter(function (n) {
1094
+ return n.type === 'declaration';
1095
+ });
1096
+ var kf = _objectSpread2({
1097
+ type: 'keyframe',
1098
+ selector: selector,
1099
+ declarations: declarations
1100
+ }, this.options.includeSourceMaps ? {
1101
+ loc: {
1102
+ start: locStart,
1103
+ end: this.locPos()
1104
+ }
1105
+ } : {});
1106
+ if (this.options.onKeyframe) {
1107
+ var result = this.options.onKeyframe(kf);
1108
+ if (result === null) return null;
1109
+ if (result) return result;
1110
+ }
1111
+ return kf;
1112
+ }
1113
+
1114
+ // ── Block (consumes { … }) ────────────────────────────────────────────────
1115
+ }, {
1116
+ key: "parseBlockChildren",
1117
+ value: function parseBlockChildren(mode) {
1118
+ if (this.peek() !== CC_LBRACE) return [];
1119
+ this.advance(); // '{'
1120
+
1121
+ var children = [];
1122
+ while (this.pos < this.length) {
1123
+ this.skipWS();
1124
+ if (this.pos >= this.length || this.peek() === CC_RBRACE) break;
1125
+ var prevPos = this.pos;
1126
+ var node = this.parseBlockNode(mode);
1127
+ // Guard against infinite loop: if nothing was consumed, force-advance
1128
+ if (this.pos === prevPos) {
1129
+ this.advance();
1130
+ continue;
1131
+ }
1132
+ if (node) {
1133
+ children.push(node);
1134
+ this.stats.totalNodes++;
1135
+ }
1136
+ }
1137
+ if (this.pos < this.length && this.peek() === CC_RBRACE) this.advance(); // '}'
1138
+ return children;
1139
+ }
1140
+
1141
+ // ── Declaration ───────────────────────────────────────────────────────────
1142
+ }, {
1143
+ key: "parseDeclaration",
1144
+ value: function parseDeclaration() {
1145
+ var locStart = this.locPos();
1146
+
1147
+ // Property name (supports --custom-props and -vendor-prefixed)
1148
+ var property = this.readIdent();
1149
+ if (!property) {
1150
+ this.recoverTo(CC_SEMI, CC_RBRACE);
1151
+ return null;
1152
+ }
1153
+ this.skipWS();
1154
+ if (this.peek() !== CC_COLON) {
1155
+ this.recoverTo(CC_SEMI, CC_RBRACE);
1156
+ return null;
1157
+ }
1158
+ this.advance(); // ':'
1159
+ this.skipWS();
1160
+ var rawFull = this.readRawValue();
1161
+
1162
+ // Strip !important
1163
+ var rawValue = rawFull;
1164
+ var important = false;
1165
+ var impMatch = rawFull.match(/\s*!important\s*$/i);
1166
+ if (impMatch) {
1167
+ important = true;
1168
+ rawValue = rawFull.slice(0, rawFull.length - impMatch[0].length).trimEnd();
1169
+ }
1170
+ this.skipWS();
1171
+ if (this.pos < this.length && this.peek() === CC_SEMI) this.advance();
1172
+ this.stats.totalDeclarations++;
1173
+ var decl = {
1174
+ type: 'declaration',
1175
+ property: property,
1176
+ rawValue: rawValue,
1177
+ value: this.options.parseValue ? this.tokenizeValue(rawValue) : [],
1178
+ important: important
1179
+ };
1180
+ if (this.options.enableCustomProperties && property.startsWith('--')) {
1181
+ decl.customProperty = true;
1182
+ }
1183
+ if (this.options.includeVendorPrefixes) {
1184
+ var vp = property.match(/^-(webkit|moz|ms|o)-/);
1185
+ if (vp) decl.vendorPrefix = vp[0];
1186
+ }
1187
+ if (this.options.includeSourceMaps) {
1188
+ decl.loc = {
1189
+ start: locStart,
1190
+ end: this.locPos(),
1191
+ source: this.input
1192
+ };
1193
+ }
1194
+ if (this.options.onDeclaration) {
1195
+ var result = this.options.onDeclaration(decl);
1196
+ if (result === null) return null;
1197
+ if (result) return result;
1198
+ }
1199
+ return decl;
1200
+ }
1201
+
1202
+ // ── Comment ───────────────────────────────────────────────────────────────
1203
+ }, {
1204
+ key: "parseComment",
1205
+ value: function parseComment() {
1206
+ var locStart = this.locPos();
1207
+ this.advance(); // '/'
1208
+ this.advance(); // '*'
1209
+ var start = this.pos;
1210
+ while (this.pos < this.length - 1) {
1211
+ if (this.peek() === CC_STAR && this.peek(1) === CC_SLASH) {
1212
+ var _value = this.input.slice(start, this.pos);
1213
+ this.advance();
1214
+ this.advance(); // '*/'
1215
+ this.stats.totalComments++;
1216
+ var _c = _objectSpread2({
1217
+ type: 'comment',
1218
+ value: _value,
1219
+ style: _value.includes('\n') ? 'multi-line' : 'single-line'
1220
+ }, this.options.includeSourceMaps ? {
1221
+ loc: {
1222
+ start: locStart,
1223
+ end: this.locPos()
1224
+ }
1225
+ } : {});
1226
+ if (this.options.onComment) {
1227
+ var result = this.options.onComment(_c);
1228
+ if (result === null) return null;
1229
+ if (result) return result;
1230
+ }
1231
+ return _c;
1232
+ }
1233
+ this.advance();
1234
+ }
1235
+
1236
+ // Unterminated comment
1237
+ var value = this.input.slice(start);
1238
+ this.pos = this.length;
1239
+ this.stats.totalComments++;
1240
+ var c = {
1241
+ type: 'comment',
1242
+ value: value,
1243
+ style: 'multi-line'
1244
+ };
1245
+ if (this.options.onComment) {
1246
+ var _result = this.options.onComment(c);
1247
+ if (_result === null) return null;
1248
+ if (_result) return _result;
1249
+ }
1250
+ return c;
1251
+ }
1252
+
1253
+ // ── Selectors ─────────────────────────────────────────────────────────────
1254
+
1255
+ /**
1256
+ * Splits a raw selector string on commas (respecting parentheses depth)
1257
+ * and returns one CssSelector per part.
1258
+ */
1259
+ }, {
1260
+ key: "parseSelectorList",
1261
+ value: function parseSelectorList(raw) {
1262
+ var parts = [];
1263
+ var depth = 0,
1264
+ start = 0;
1265
+ for (var i = 0; i < raw.length; i++) {
1266
+ var c = raw.charCodeAt(i);
1267
+ if (c === CC_LPAREN || c === CC_LBRACK) depth++;else if (c === CC_RPAREN || c === CC_RBRACK) depth--;else if (c === CC_COMMA && depth === 0) {
1268
+ parts.push(raw.slice(start, i).trim());
1269
+ start = i + 1;
1270
+ }
1271
+ }
1272
+ parts.push(raw.slice(start).trim());
1273
+ return parts.filter(function (p) {
1274
+ return p.length > 0;
1275
+ }).map(function (p) {
1276
+ return {
1277
+ type: 'selector',
1278
+ value: p
1279
+ };
1280
+ });
1281
+ }
1282
+
1283
+ /**
1284
+ * Simple specificity scorer — counts IDs, classes/attributes/pseudos, elements.
1285
+ */
1286
+ }, {
1287
+ key: "calcSpecificity",
1288
+ value: function calcSpecificity(sel) {
1289
+ var ids = 0,
1290
+ classes = 0,
1291
+ elements = 0;
1292
+ var i = 0;
1293
+ while (i < sel.length) {
1294
+ var c = sel.charCodeAt(i);
1295
+ if (c === CC_HASH) {
1296
+ ids++;
1297
+ i++;
1298
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1299
+ } else if (c === CC_DOT) {
1300
+ classes++;
1301
+ i++;
1302
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1303
+ } else if (c === CC_LBRACK) {
1304
+ classes++;
1305
+ while (i < sel.length && sel.charCodeAt(i) !== CC_RBRACK) i++;
1306
+ i++;
1307
+ } else if (c === CC_COLON) {
1308
+ if (sel.charCodeAt(i + 1) === CC_COLON) {
1309
+ elements++;
1310
+ i += 2;
1311
+ } else {
1312
+ // :not(), :is(), :has() — don't double-count the wrapper
1313
+ classes++;
1314
+ i++;
1315
+ }
1316
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1317
+ // skip argument parens
1318
+ if (i < sel.length && sel.charCodeAt(i) === CC_LPAREN) {
1319
+ var d = 1;
1320
+ i++;
1321
+ while (i < sel.length && d > 0) {
1322
+ if (sel.charCodeAt(i) === CC_LPAREN) d++;else if (sel.charCodeAt(i) === CC_RPAREN) d--;
1323
+ i++;
1324
+ }
1325
+ }
1326
+ } else if (isAlpha(c) || c === CC_UNDER) {
1327
+ elements++;
1328
+ while (i < sel.length && isNameChar(sel.charCodeAt(i))) i++;
1329
+ } else {
1330
+ i++;
1331
+ }
1332
+ }
1333
+ return {
1334
+ ids: ids,
1335
+ classes: classes,
1336
+ elements: elements,
1337
+ total: ids * 100 + classes * 10 + elements
1338
+ };
1339
+ }
1340
+
1341
+ // ── Value tokenizer ───────────────────────────────────────────────────────
1342
+
1343
+ /**
1344
+ * Tokenises a raw CSS value string into a flat array of CssValue tokens.
1345
+ * Handles: strings, colors (#hex), numbers/dimensions/percentages,
1346
+ * functions (recursive), identifiers, operators, commas.
1347
+ */
1348
+ }, {
1349
+ key: "tokenizeValue",
1350
+ value: function tokenizeValue(raw) {
1351
+ var tokens = [];
1352
+ var i = 0;
1353
+ var len = raw.length;
1354
+ while (i < len) {
1355
+ var c = raw.charCodeAt(i);
1356
+
1357
+ // Whitespace — skip (no whitespace tokens)
1358
+ if (isWS(c)) {
1359
+ i++;
1360
+ continue;
1361
+ }
1362
+
1363
+ // Quoted string
1364
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1365
+ var q = c;
1366
+ i++;
1367
+ var s = i;
1368
+ while (i < len && raw.charCodeAt(i) !== q) {
1369
+ if (raw.charCodeAt(i) === CC_BSLASH) i++;
1370
+ i++;
1371
+ }
1372
+ tokens.push({
1373
+ type: 'string',
1374
+ value: raw.slice(s, i)
1375
+ });
1376
+ i++; // closing quote
1377
+ continue;
1378
+ }
1379
+
1380
+ // Hex color (#rrggbb / #rgb / #rrggbbaa / #rgba)
1381
+ if (c === CC_HASH) {
1382
+ var _s = i++;
1383
+ while (i < len && isHex(raw.charCodeAt(i))) i++;
1384
+ tokens.push({
1385
+ type: 'color',
1386
+ value: raw.slice(_s, i)
1387
+ });
1388
+ continue;
1389
+ }
1390
+
1391
+ // Number / dimension / percentage
1392
+ // Handles: 10, 1.5, .5, 1e3, +10px, -2em, 50%
1393
+ var isNumStart = isDigit(c) || c === CC_DOT && isDigit(raw.charCodeAt(i + 1)) || (c === CC_PLUS || c === CC_MINUS) && (isDigit(raw.charCodeAt(i + 1)) || raw.charCodeAt(i + 1) === CC_DOT && isDigit(raw.charCodeAt(i + 2)));
1394
+ if (isNumStart) {
1395
+ var _s2 = i;
1396
+ if (c === CC_PLUS || c === CC_MINUS) i++;
1397
+ while (i < len && isDigit(raw.charCodeAt(i))) i++;
1398
+ if (i < len && raw.charCodeAt(i) === CC_DOT) {
1399
+ i++;
1400
+ while (i < len && isDigit(raw.charCodeAt(i))) i++;
1401
+ }
1402
+ // Exponent
1403
+ if (i < len && (raw.charCodeAt(i) === 101 || raw.charCodeAt(i) === 69)) {
1404
+ i++;
1405
+ if (i < len && (raw.charCodeAt(i) === CC_PLUS || raw.charCodeAt(i) === CC_MINUS)) i++;
1406
+ while (i < len && isDigit(raw.charCodeAt(i))) i++;
1407
+ }
1408
+ var num = parseFloat(raw.slice(_s2, i));
1409
+ // Unit / percentage
1410
+ var us = i;
1411
+ while (i < len && (isAlpha(raw.charCodeAt(i)) || raw.charCodeAt(i) === CC_UNDER)) i++;
1412
+ if (i < len && raw[i] === '%') i++;
1413
+ var unit = raw.slice(us, i);
1414
+ if (unit === '%') tokens.push({
1415
+ type: 'percentage',
1416
+ value: num
1417
+ });else if (unit) tokens.push({
1418
+ type: 'dimension',
1419
+ value: num,
1420
+ unit: unit
1421
+ });else tokens.push({
1422
+ type: 'number',
1423
+ value: num
1424
+ });
1425
+ continue;
1426
+ }
1427
+
1428
+ // Identifier or function call
1429
+ if (isNameStart(c)) {
1430
+ var _s3 = i;
1431
+ while (i < len && isNameChar(raw.charCodeAt(i))) i++;
1432
+ var name = raw.slice(_s3, i);
1433
+ if (i < len && raw.charCodeAt(i) === CC_LPAREN) {
1434
+ i++; // '('
1435
+ var as_ = i;
1436
+ var depth = 1;
1437
+ while (i < len && depth > 0) {
1438
+ var ch = raw.charCodeAt(i);
1439
+ if (ch === CC_LPAREN) depth++;else if (ch === CC_RPAREN) depth--;
1440
+ i++;
1441
+ }
1442
+ var argStr = raw.slice(as_, i - 1);
1443
+ var args = name.toLowerCase() === 'url' ? [{
1444
+ type: 'string',
1445
+ value: argStr.replace(/^['"]|['"]$/g, '')
1446
+ }] : this.tokenizeValue(argStr);
1447
+ tokens.push({
1448
+ type: 'function',
1449
+ name: name,
1450
+ value: "".concat(name, "(").concat(argStr, ")"),
1451
+ args: args
1452
+ });
1453
+ } else {
1454
+ tokens.push({
1455
+ type: 'identifier',
1456
+ value: name
1457
+ });
1458
+ }
1459
+ continue;
1460
+ }
1461
+
1462
+ // Comma
1463
+ if (c === CC_COMMA) {
1464
+ tokens.push({
1465
+ type: 'comma',
1466
+ value: ','
1467
+ });
1468
+ i++;
1469
+ continue;
1470
+ }
1471
+
1472
+ // Operator or any other character
1473
+ tokens.push({
1474
+ type: 'operator',
1475
+ value: raw[i]
1476
+ });
1477
+ i++;
1478
+ }
1479
+ this.stats.totalValues += tokens.length;
1480
+ return tokens;
1481
+ }
1482
+
1483
+ // ── Scanner primitives ────────────────────────────────────────────────────
1484
+ }, {
1485
+ key: "peek",
1486
+ value: function peek() {
1487
+ var offset = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 0;
1488
+ return this.input.charCodeAt(this.pos + offset);
1489
+ }
1490
+ }, {
1491
+ key: "advance",
1492
+ value: function advance() {
1493
+ if (this.pos < this.length) {
1494
+ if (this.input.charCodeAt(this.pos) === CC_LF) {
1495
+ this.line++;
1496
+ this.col = 1;
1497
+ } else this.col++;
1498
+ this.pos++;
1499
+ }
1500
+ }
1501
+ }, {
1502
+ key: "skipWS",
1503
+ value: function skipWS() {
1504
+ while (this.pos < this.length && isWS(this.peek())) this.advance();
1505
+ }
1506
+
1507
+ /**
1508
+ * Read a CSS identifier (supports `--custom-props` and `-vendor-prefix`).
1509
+ * Returns empty string if the current position isn't the start of an ident.
1510
+ */
1511
+ }, {
1512
+ key: "readIdent",
1513
+ value: function readIdent() {
1514
+ if (this.pos >= this.length) return '';
1515
+ var c = this.peek();
1516
+ // Allow backslash-escape as a valid ident start (e.g. \/ in custom props)
1517
+ if (!isNameStart(c) && c !== CC_BSLASH) return '';
1518
+ var start = this.pos;
1519
+ while (this.pos < this.length) {
1520
+ var ch = this.peek();
1521
+ if (ch === CC_BSLASH) {
1522
+ // CSS escape sequence: consume backslash + following char/codepoint
1523
+ // Preserve raw text (including the backslash) so the generator
1524
+ // can emit valid CSS unchanged.
1525
+ this.advance(); // consume '\'
1526
+ if (this.pos >= this.length) break;
1527
+ var next = this.peek();
1528
+ if (isHex(next)) {
1529
+ // 1–6 hex digits
1530
+ var hexLen = 0;
1531
+ while (this.pos < this.length && isHex(this.peek()) && hexLen < 6) {
1532
+ this.advance();
1533
+ hexLen++;
1534
+ }
1535
+ // optional single whitespace after hex escape
1536
+ if (this.pos < this.length && isWS(this.peek())) this.advance();
1537
+ } else if (next === CC_LF || next === CC_CR || next === CC_FF) {
1538
+ // newline inside escape — skip
1539
+ this.advance();
1540
+ } else {
1541
+ // e.g. \/ — consume the escaped character
1542
+ this.advance();
1543
+ }
1544
+ } else if (isNameChar(ch)) {
1545
+ this.advance();
1546
+ } else {
1547
+ break;
1548
+ }
1549
+ }
1550
+ return this.input.slice(start, this.pos);
1551
+ }
1552
+
1553
+ /**
1554
+ * Read at-rule prelude: raw text from current position up to (but not
1555
+ * including) the next `{` or `;` at depth 0.
1556
+ * Parentheses, brackets, strings and comments are respected.
1557
+ */
1558
+ }, {
1559
+ key: "readPrelude",
1560
+ value: function readPrelude() {
1561
+ var start = this.pos;
1562
+ var depth = 0;
1563
+ while (this.pos < this.length) {
1564
+ var c = this.peek();
1565
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1566
+ this.skipString(c);
1567
+ continue;
1568
+ }
1569
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
1570
+ this.skipMLComment();
1571
+ continue;
1572
+ }
1573
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1574
+ depth++;
1575
+ this.advance();
1576
+ continue;
1577
+ }
1578
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1579
+ depth--;
1580
+ this.advance();
1581
+ continue;
1582
+ }
1583
+ if (depth === 0 && (c === CC_LBRACE || c === CC_SEMI)) break;
1584
+ this.advance();
1585
+ }
1586
+ return this.input.slice(start, this.pos).trim();
1587
+ }
1588
+
1589
+ /**
1590
+ * Read a declaration value: raw text up to `;` or `}` at depth 0.
1591
+ */
1592
+ }, {
1593
+ key: "readRawValue",
1594
+ value: function readRawValue() {
1595
+ var start = this.pos;
1596
+ var depth = 0;
1597
+ while (this.pos < this.length) {
1598
+ var c = this.peek();
1599
+ // Backslash escape: consume '\' + next char as a unit.
1600
+ // This prevents '\"' from being misread as a string delimiter,
1601
+ // '\;' from prematurely terminating the value, and '\(' from
1602
+ // incorrectly incrementing paren depth.
1603
+ if (c === CC_BSLASH) {
1604
+ this.advance(); // consume '\'
1605
+ if (this.pos < this.length) this.advance(); // consume escaped char
1606
+ continue;
1607
+ }
1608
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1609
+ this.skipString(c);
1610
+ continue;
1611
+ }
1612
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
1613
+ this.skipMLComment();
1614
+ continue;
1615
+ }
1616
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1617
+ depth++;
1618
+ this.advance();
1619
+ continue;
1620
+ }
1621
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1622
+ depth--;
1623
+ this.advance();
1624
+ continue;
1625
+ }
1626
+ if (depth === 0 && (c === CC_SEMI || c === CC_RBRACE)) break;
1627
+ this.advance();
1628
+ }
1629
+ return this.input.slice(start, this.pos).trim();
1630
+ }
1631
+
1632
+ /**
1633
+ * Read a selector (rule prelude): raw text up to the first `{` at depth 0.
1634
+ * Parentheses, brackets, strings and comments are respected.
1635
+ */
1636
+ }, {
1637
+ key: "readUntilLBrace",
1638
+ value: function readUntilLBrace() {
1639
+ var start = this.pos;
1640
+ var depth = 0;
1641
+ while (this.pos < this.length) {
1642
+ var c = this.peek();
1643
+ // Backslash escape: consume '\' + next char as a unit.
1644
+ // Prevents '\{' from falsely terminating the selector,
1645
+ // and '\"' from being misread as a string delimiter.
1646
+ if (c === CC_BSLASH) {
1647
+ this.advance(); // consume '\'
1648
+ if (this.pos < this.length) this.advance(); // consume escaped char
1649
+ continue;
1650
+ }
1651
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1652
+ this.skipString(c);
1653
+ continue;
1654
+ }
1655
+ if (c === CC_SLASH && this.peek(1) === CC_STAR) {
1656
+ this.skipMLComment();
1657
+ continue;
1658
+ }
1659
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1660
+ depth++;
1661
+ this.advance();
1662
+ continue;
1663
+ }
1664
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1665
+ depth--;
1666
+ this.advance();
1667
+ continue;
1668
+ }
1669
+ if (depth === 0 && c === CC_LBRACE) break;
1670
+ this.advance();
1671
+ }
1672
+ return this.input.slice(start, this.pos);
1673
+ }
1674
+
1675
+ /** Skip a quoted string starting at the current position (quote char given). */
1676
+ }, {
1677
+ key: "skipString",
1678
+ value: function skipString(quote) {
1679
+ this.advance(); // opening quote
1680
+ while (this.pos < this.length) {
1681
+ var c = this.peek();
1682
+ if (c === CC_BSLASH) {
1683
+ this.advance();
1684
+ this.advance();
1685
+ continue;
1686
+ }
1687
+ if (c === quote) {
1688
+ this.advance();
1689
+ return;
1690
+ }
1691
+ if (c === CC_LF) return; // unterminated → stop
1692
+ this.advance();
1693
+ }
1694
+ }
1695
+
1696
+ /** Skip a block comment (slash-star ... star-slash) starting at current position. */
1697
+ }, {
1698
+ key: "skipMLComment",
1699
+ value: function skipMLComment() {
1700
+ this.advance();
1701
+ this.advance(); // '/' '*'
1702
+ while (this.pos < this.length - 1) {
1703
+ if (this.peek() === CC_STAR && this.peek(1) === CC_SLASH) {
1704
+ this.advance();
1705
+ this.advance();
1706
+ return;
1707
+ }
1708
+ this.advance();
1709
+ }
1710
+ this.pos = this.length;
1711
+ }
1712
+
1713
+ /** Skip a balanced `{ … }` block (including the opening brace). */
1714
+ }, {
1715
+ key: "skipBalancedBraces",
1716
+ value: function skipBalancedBraces() {
1717
+ if (this.peek() !== CC_LBRACE) return;
1718
+ var depth = 0;
1719
+ while (this.pos < this.length) {
1720
+ var c = this.peek();
1721
+ if (c === CC_LBRACE) depth++;else if (c === CC_RBRACE) {
1722
+ depth--;
1723
+ if (depth === 0) {
1724
+ this.advance();
1725
+ return;
1726
+ }
1727
+ }
1728
+ this.advance();
1729
+ }
1730
+ }
1731
+
1732
+ /**
1733
+ * Lookahead: scan forward from current position and return true if
1734
+ * an unescaped `{` at depth 0 is found before any `;` or `}`.
1735
+ * Used in `rule` block mode to distinguish declarations from nested rules.
1736
+ */
1737
+ }, {
1738
+ key: "lookaheadIsRule",
1739
+ value: function lookaheadIsRule() {
1740
+ var i = this.pos,
1741
+ depth = 0;
1742
+ while (i < this.length) {
1743
+ var c = this.input.charCodeAt(i);
1744
+ if (c === CC_DQUOTE || c === CC_SQUOTE) {
1745
+ var q = c;
1746
+ i++;
1747
+ while (i < this.length && this.input.charCodeAt(i) !== q) {
1748
+ if (this.input.charCodeAt(i) === CC_BSLASH) i++;
1749
+ i++;
1750
+ }
1751
+ i++;
1752
+ continue;
1753
+ }
1754
+ if (c === CC_LPAREN || c === CC_LBRACK) {
1755
+ depth++;
1756
+ i++;
1757
+ continue;
1758
+ }
1759
+ if (c === CC_RPAREN || c === CC_RBRACK) {
1760
+ depth--;
1761
+ i++;
1762
+ continue;
1763
+ }
1764
+ if (depth === 0) {
1765
+ if (c === CC_LBRACE) return true;
1766
+ if (c === CC_SEMI || c === CC_RBRACE) return false;
1767
+ }
1768
+ i++;
1769
+ }
1770
+ return false;
1771
+ }
1772
+
1773
+ /**
1774
+ * Characters that unambiguously start a CSS nesting selector
1775
+ * (can never be the start of a property name).
1776
+ */
1777
+ }, {
1778
+ key: "isNestingStart",
1779
+ value: function isNestingStart(c) {
1780
+ return c === CC_AMP // & nesting selector
1781
+ || c === CC_DOT // . class
1782
+ || c === CC_HASH // # id
1783
+ || c === CC_LBRACK // [ attribute
1784
+ || c === 42 // * universal
1785
+ || c === CC_GT // > child combinator
1786
+ || c === CC_PLUS // + adjacent sibling
1787
+ || c === CC_TILDE // ~ general sibling
1788
+ || c === CC_COLON; // : pseudo-class / ::pseudo-element
1789
+ }
1790
+
1791
+ /** Advance past chars until one of the given charcodes (exclusive). */
1792
+ }, {
1793
+ key: "recoverTo",
1794
+ value: function recoverTo() {
1795
+ for (var _len = arguments.length, stops = new Array(_len), _key = 0; _key < _len; _key++) {
1796
+ stops[_key] = arguments[_key];
1797
+ }
1798
+ while (this.pos < this.length && !stops.includes(this.peek())) this.advance();
1799
+ }
1800
+
1801
+ /** Advance past chars until one of the given charcodes, then advance one more. */
1802
+ }, {
1803
+ key: "recoverPast",
1804
+ value: function recoverPast() {
1805
+ this.recoverTo.apply(this, arguments);
1806
+ if (this.pos < this.length) this.advance();
1807
+ }
1808
+
1809
+ // ── Location helpers ──────────────────────────────────────────────────────
1810
+ }, {
1811
+ key: "locPos",
1812
+ value: function locPos() {
1813
+ return {
1814
+ line: this.line,
1815
+ column: this.col,
1816
+ offset: this.pos
1817
+ };
1818
+ }
1819
+
1820
+ // ── Stylesheet categorizer ────────────────────────────────────────────────
1821
+ }, {
1822
+ key: "categorize",
1823
+ value: function categorize(ss, node) {
1824
+ var _ar$preludeText, _ar$preludeText2;
1825
+ if (node.type !== 'atrule') return;
1826
+ var ar = node;
1827
+ var base = ar.name.replace(/^-(webkit|moz|ms|o)-/, '');
1828
+ switch (base) {
1829
+ case 'import':
1830
+ ss.imports.push(ar);
1831
+ break;
1832
+ case 'media':
1833
+ ss.mediaQueries.push({
1834
+ type: 'media-query',
1835
+ media: (_ar$preludeText = ar.preludeText) !== null && _ar$preludeText !== void 0 ? _ar$preludeText : '',
1836
+ features: [],
1837
+ loc: ar.loc
1838
+ });
1839
+ break;
1840
+ case 'namespace':
1841
+ ss.namespaces.push(ar);
1842
+ break;
1843
+ case 'keyframes':
1844
+ ss.keyframes.push(ar);
1845
+ break;
1846
+ case 'font-face':
1847
+ ss.fontFaces.push(ar);
1848
+ break;
1849
+ case 'layer':
1850
+ {
1851
+ var layerRule = ar;
1852
+ // preludeText holds the layer name (e.g. "atomic" for "@layer atomic { … }")
1853
+ if (ar.preludeText) layerRule.layerName = ar.preludeText.trim();
1854
+ ss.layers.push(layerRule);
1855
+ break;
1856
+ }
1857
+ case 'container':
1858
+ {
1859
+ var containerRule = ar;
1860
+ if (ar.preludeText) {
1861
+ // "@container main (width > 600px)" → name is the first token
1862
+ var parts = ar.preludeText.trim().match(/^([\w-]+)?\s*(.*)/);
1863
+ if (parts !== null && parts !== void 0 && parts[1]) containerRule.containerName = parts[1];
1864
+ if (parts !== null && parts !== void 0 && parts[2]) containerRule.containerQuery = parts[2].trim();
1865
+ }
1866
+ ss.containers.push(containerRule);
1867
+ break;
1868
+ }
1869
+ case 'supports':
1870
+ ss.supports.push(ar);
1871
+ break;
1872
+ case 'document':
1873
+ ss.documents.push(ar);
1874
+ break;
1875
+ case 'page':
1876
+ ss.pages.push(ar);
1877
+ break;
1878
+ case 'counter-style':
1879
+ ss.counterStyles.push(ar);
1880
+ break;
1881
+ case 'font-feature-values':
1882
+ ss.fontFeatureValues.push(ar);
1883
+ break;
1884
+ case 'viewport':
1885
+ ss.viewports.push(ar);
1886
+ break;
1887
+ case 'charset':
1888
+ ss.charsets.push(ar);
1889
+ ss.charset = (_ar$preludeText2 = ar.preludeText) === null || _ar$preludeText2 === void 0 ? void 0 : _ar$preludeText2.replace(/^['"]|['"]$/g, '');
1890
+ break;
1891
+ }
1892
+ }
1893
+
1894
+ // ── Legacy format ─────────────────────────────────────────────────────────
1895
+ }, {
1896
+ key: "toLegacyNode",
1897
+ value: function toLegacyNode(node) {
1898
+ var _this2 = this;
1899
+ switch (node.type) {
1900
+ case 'rule':
1901
+ {
1902
+ var _r$rawSelector;
1903
+ var r = node;
1904
+ var name = (_r$rawSelector = r.rawSelector) !== null && _r$rawSelector !== void 0 ? _r$rawSelector : r.selectors.map(function (s) {
1905
+ return s.value;
1906
+ }).join(', ');
1907
+ return {
1908
+ kind: 'rule',
1909
+ name: name,
1910
+ value: r.declarations.map(function (d) {
1911
+ var _d$rawValue;
1912
+ return "".concat(d.property, ": ").concat((_d$rawValue = d.rawValue) !== null && _d$rawValue !== void 0 ? _d$rawValue : d.value.map(function (v) {
1913
+ return String(v.value);
1914
+ }).join(' ')).concat(d.important ? ' !important' : '');
1915
+ }).join('; '),
1916
+ important: false,
1917
+ children: r.declarations.map(function (d) {
1918
+ return _this2.toLegacyNode(d);
1919
+ }).filter(Boolean),
1920
+ loc: r.loc,
1921
+ node: 'rule',
1922
+ cssNode: {},
1923
+ parents: [],
1924
+ selectors: r.selectors.map(function (s) {
1925
+ return {
1926
+ kind: 'rule',
1927
+ name: s.value,
1928
+ value: s.value,
1929
+ loc: s.loc,
1930
+ node: 'selector',
1931
+ cssNode: {},
1932
+ parents: []
1933
+ };
1934
+ })
1935
+ };
1936
+ }
1937
+ case 'atrule':
1938
+ {
1939
+ var _ref, _ar$preludeText3, _ar$prelude, _ar$block$children, _ar$block;
1940
+ var ar = node;
1941
+ return {
1942
+ kind: 'atrule',
1943
+ name: ar.name,
1944
+ value: (_ref = (_ar$preludeText3 = ar.preludeText) !== null && _ar$preludeText3 !== void 0 ? _ar$preludeText3 : (_ar$prelude = ar.prelude) === null || _ar$prelude === void 0 ? void 0 : _ar$prelude.map(function (v) {
1945
+ return String(v.value);
1946
+ }).join(' ')) !== null && _ref !== void 0 ? _ref : '',
1947
+ important: false,
1948
+ children: ((_ar$block$children = (_ar$block = ar.block) === null || _ar$block === void 0 ? void 0 : _ar$block.children) !== null && _ar$block$children !== void 0 ? _ar$block$children : []).map(function (c) {
1949
+ return _this2.toLegacyNode(c);
1950
+ }).filter(Boolean),
1951
+ loc: ar.loc,
1952
+ node: 'atrule',
1953
+ cssNode: {},
1954
+ parents: []
1955
+ };
1956
+ }
1957
+ case 'declaration':
1958
+ {
1959
+ var _d$rawValue2;
1960
+ var d = node;
1961
+ return {
1962
+ kind: 'decl',
1963
+ name: d.property,
1964
+ value: (_d$rawValue2 = d.rawValue) !== null && _d$rawValue2 !== void 0 ? _d$rawValue2 : d.value.map(function (v) {
1965
+ return String(v.value);
1966
+ }).join(' '),
1967
+ important: d.important,
1968
+ children: [],
1969
+ loc: d.loc,
1970
+ node: 'declaration',
1971
+ cssNode: {},
1972
+ parents: []
1973
+ };
1974
+ }
1975
+ case 'comment':
1976
+ {
1977
+ var c = node;
1978
+ return {
1979
+ kind: 'comment',
1980
+ name: undefined,
1981
+ value: c.value,
1982
+ important: false,
1983
+ children: [],
1984
+ loc: c.loc,
1985
+ node: 'comment',
1986
+ cssNode: {},
1987
+ parents: []
1988
+ };
1989
+ }
1990
+ default:
1991
+ return null;
1992
+ }
1993
+ }
1994
+ }], [{
1995
+ key: "emptyStats",
1996
+ value: function emptyStats() {
1997
+ return {
1998
+ totalNodes: 0,
1999
+ totalRules: 0,
2000
+ totalDeclarations: 0,
2001
+ totalAtRules: 0,
2002
+ totalComments: 0,
2003
+ totalSelectors: 0,
2004
+ totalValues: 0,
2005
+ parseTime: 0,
2006
+ memoryUsage: 0,
2007
+ errors: 0,
2008
+ warnings: 0
2009
+ };
2010
+ }
2011
+ }]);
2012
+ }();
2013
+
2014
+ // ─── Public parse helpers ─────────────────────────────────────────────────────
2015
+
2016
+ /** Parse a CSS string into a stylesheet AST. */
2017
+ function parseCss(css, options) {
2018
+ return new CssParser(options).parse(css);
2019
+ }
2020
+
2021
+ /** Parse CSS and convert to the legacy AstNode[] format. */
2022
+ function parseCssToLegacy(css, options) {
2023
+ var parser = new CssParser(options);
2024
+ return parser.toLegacyFormat(parser.parse(css));
2025
+ }
2026
+
2027
+ export { CssGenerator, CssParser, atRule, cloneNode, cloneNodeDeep, comment, decl, declaration, keyframe, location, locationPos, parseCss, parseCssToLegacy, rule, selector, stringify, stylesheet, walk };
2028
+ //# sourceMappingURL=css-parser.mjs.map