@fluentic/style 0.1.0-beta.3 → 0.1.0-beta.5

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 (430) hide show
  1. package/CHANGELOG.md +55 -1
  2. package/README.md +10 -9
  3. package/atomic/className.ts +12 -12
  4. package/atomic/debug/className/className.ts +10 -15
  5. package/atomic/element.ts +1 -1
  6. package/atomic/rule.ts +8 -5
  7. package/atomic/scope.ts +19 -0
  8. package/atomic/theme.ts +41 -2
  9. package/atomic/token.ts +4 -3
  10. package/atomic/utils/{css.ts → cssIdent.ts} +0 -20
  11. package/atomic/utils/cssVar.ts +19 -0
  12. package/atomic/utils/debug.ts +1 -1
  13. package/atomic/utils/selector.ts +14 -1
  14. package/builder/classname/class_name_builder.ts +68 -24
  15. package/builder/classname/fns.ts +2 -2
  16. package/builder/classname/types.ts +7 -0
  17. package/builder/data/const.ts +7 -1
  18. package/builder/data/create.ts +42 -0
  19. package/builder/data/data.ts +20 -1
  20. package/builder/data/index.ts +0 -1
  21. package/builder/data/is.ts +23 -0
  22. package/builder/data/merge/scope.ts +20 -19
  23. package/builder/data/merge/style.ts +71 -21
  24. package/builder/data/state.ts +16 -2
  25. package/builder/extract/index.ts +1 -0
  26. package/builder/extract/sheet.ts +26 -0
  27. package/builder/extract/token.ts +30 -14
  28. package/builder/extract/utils.ts +2 -0
  29. package/builder/extract/withTokens.ts +2 -1
  30. package/builder/selector_override.noop.ts +11 -0
  31. package/builder/selector_override.ts +30 -0
  32. package/builder/selector_override_core.ts +66 -0
  33. package/builder/style_builder.ts +127 -3
  34. package/builder/style_data.ts +24 -0
  35. package/builder/style_fns.ts +24 -24
  36. package/builder/token/data.ts +30 -0
  37. package/builder/token/index.ts +3 -0
  38. package/builder/token/name.ts +54 -0
  39. package/builder/token/symbols.ts +6 -0
  40. package/builder/types/alias.ts +34 -6
  41. package/builder/types/fns.ts +13 -5
  42. package/builder/types/types.ts +32 -2
  43. package/builder/utils.ts +1 -0
  44. package/compiler/compiler/compiler.ts +4 -7
  45. package/compiler/compiler/constants.ts +6 -0
  46. package/compiler/compiler/index.ts +1 -0
  47. package/compiler/compiler/types.ts +2 -0
  48. package/compiler/cssProp.ts +35 -0
  49. package/compiler/index.ts +1 -0
  50. package/compiler/transform/cssProp/index.ts +1 -0
  51. package/compiler/transform/cssProp/plugin.ts +129 -0
  52. package/compiler/transform/debug/plugin.ts +85 -1
  53. package/compiler/transform/debug/transform.ts +2 -1
  54. package/compiler/transform/evaluator/evaluator.ts +106 -30
  55. package/compiler/transform/evaluator/tracer.ts +30 -2
  56. package/compiler/transform/extract/chain/chain.ts +541 -63
  57. package/compiler/transform/extract/chain/extract_chain.ts +12 -4
  58. package/compiler/transform/extract/chain/types.ts +1 -1
  59. package/compiler/transform/extract/plugin.ts +20 -4
  60. package/compiler/transform/extract/transform.ts +2 -1
  61. package/compiler/transform/extract/utils/replacement.ts +52 -2
  62. package/compiler/transform/extract/utils/state.ts +2 -0
  63. package/compiler/transform/extract/utils/theme.ts +6 -6
  64. package/compiler/transform/index.ts +1 -0
  65. package/compiler/transform/syntax/isStaticStyleValue.ts +15 -9
  66. package/compiler/transform/syntax/static_ids.ts +1 -1
  67. package/compiler/utils/constants.ts +8 -1
  68. package/compiler/utils/imports.ts +11 -1
  69. package/config/build.ts +1 -8
  70. package/config/config/css.ts +1 -0
  71. package/config/config/debug.ts +11 -0
  72. package/css/index.ts +2 -0
  73. package/css/sheet.ts +119 -0
  74. package/css/styleTarget.ts +251 -0
  75. package/dialect/namedTokens.ts +22 -5
  76. package/dist/adapter/preact.js +2 -0
  77. package/dist/adapter/react.js +2 -0
  78. package/dist/adapter/solid.js +2 -0
  79. package/dist/className-hiAsQ9V6.js +303 -0
  80. package/dist/className-hiAsQ9V6.js.map +1 -0
  81. package/dist/{style-Bw5ka-Nq.js → combine-Ca6LfFxv.js} +427 -722
  82. package/dist/combine-Ca6LfFxv.js.map +1 -0
  83. package/dist/compiler/index.mjs +2 -2
  84. package/dist/{compiler-D5v5tJXI.mjs → compiler-OgDBuqfs.mjs} +1635 -607
  85. package/dist/compiler-OgDBuqfs.mjs.map +1 -0
  86. package/dist/config/index.js +2 -2
  87. package/dist/config-B-KbXpIh.js +6 -0
  88. package/dist/{config-OXHoDUIo.js.map → config-B-KbXpIh.js.map} +1 -1
  89. package/dist/config-Barf8f4B.js +35 -0
  90. package/dist/config-Barf8f4B.js.map +1 -0
  91. package/dist/{config-BEvP7108.js → config-BtANtGAh.js} +4 -6
  92. package/dist/config-BtANtGAh.js.map +1 -0
  93. package/dist/config-CsB4MuFI.js +6 -0
  94. package/dist/config-CsB4MuFI.js.map +1 -0
  95. package/dist/config-DOWSNV8w.js +1 -0
  96. package/dist/{config-FIfi5aJ8.js → config-t76UljYv.js} +9 -7
  97. package/dist/config-t76UljYv.js.map +1 -0
  98. package/dist/createTransformElement-DDqld3RF.js +34 -0
  99. package/dist/createTransformElement-DDqld3RF.js.map +1 -0
  100. package/dist/css-CZwrac6F.js +3923 -0
  101. package/dist/css-CZwrac6F.js.map +1 -0
  102. package/dist/{global-zaCE-g1C.js → css-GtUPEO9U.js} +16 -3
  103. package/dist/css-GtUPEO9U.js.map +1 -0
  104. package/dist/css-YfHN_8Nk.js +479 -0
  105. package/dist/css-YfHN_8Nk.js.map +1 -0
  106. package/dist/css-a9O5so0b.js +1246 -0
  107. package/dist/css-a9O5so0b.js.map +1 -0
  108. package/dist/css.js +2 -2
  109. package/dist/{css_extra-DeTuIlcO.js → css_extra-BiG57TKN.js} +2 -2
  110. package/dist/{css_extra-DQdCrYoC.js.map → css_extra-BiG57TKN.js.map} +1 -1
  111. package/dist/{css_extra-DQdCrYoC.js → css_extra-CXXZAylc.js} +2 -2
  112. package/dist/{css_extra-DeTuIlcO.js.map → css_extra-CXXZAylc.js.map} +1 -1
  113. package/dist/data-CzHJg147.js +763 -0
  114. package/dist/data-CzHJg147.js.map +1 -0
  115. package/dist/{debug-D96KGgpH.js → debug-DkrxyknP.js} +80 -4
  116. package/dist/debug-DkrxyknP.js.map +1 -0
  117. package/dist/{runtime-BKChZZ2-.js → debug-DycdGrul.js} +20 -27
  118. package/dist/debug-DycdGrul.js.map +1 -0
  119. package/dist/dev/rsc.js +6 -9
  120. package/dist/dev/rsc.js.map +1 -1
  121. package/dist/{dev-fOtWB5K3.js → dev-z4laBwlS.js} +7 -6
  122. package/dist/{dev-fOtWB5K3.js.map → dev-z4laBwlS.js.map} +1 -1
  123. package/dist/dev.js +1 -1
  124. package/dist/dialect/extracted/index.js +1 -1
  125. package/dist/dialect/index.js +1 -1
  126. package/dist/{elementMarker-CvqqIb7J.js → elementMarker-CqhU_l_m.js} +95 -9
  127. package/dist/elementMarker-CqhU_l_m.js.map +1 -0
  128. package/dist/entry/dev/adapter/preact.js +12 -0
  129. package/dist/entry/dev/adapter/preact.js.map +1 -0
  130. package/dist/entry/dev/adapter/react.js +12 -0
  131. package/dist/entry/dev/adapter/react.js.map +1 -0
  132. package/dist/entry/dev/adapter/solid.js +12 -0
  133. package/dist/entry/dev/adapter/solid.js.map +1 -0
  134. package/dist/entry/dev/css.js +3 -3
  135. package/dist/entry/dev/jsx-dev-runtime.js +2 -2
  136. package/dist/entry/dev/jsx-runtime.js +2 -2
  137. package/dist/entry/dev.js +13 -12
  138. package/dist/entry/prod/adapter/preact.js +12 -0
  139. package/dist/entry/prod/adapter/preact.js.map +1 -0
  140. package/dist/entry/prod/adapter/react.js +12 -0
  141. package/dist/entry/prod/adapter/react.js.map +1 -0
  142. package/dist/entry/prod/adapter/solid.js +12 -0
  143. package/dist/entry/prod/adapter/solid.js.map +1 -0
  144. package/dist/entry/prod/css.js +3 -3
  145. package/dist/entry/prod/extract.js +240 -3
  146. package/dist/entry/prod/extract.js.map +1 -0
  147. package/dist/entry/prod/jsx-dev-runtime.js +2 -2
  148. package/dist/entry/prod/jsx-runtime.js +2 -2
  149. package/dist/entry/prod/runtime.js +3 -4
  150. package/dist/entry/prod.js +85 -1201
  151. package/dist/entry/prod.js.map +1 -1
  152. package/dist/entry/rsc-dev/adapter/preact.js +12 -0
  153. package/dist/entry/rsc-dev/adapter/preact.js.map +1 -0
  154. package/dist/entry/rsc-dev/adapter/react.js +12 -0
  155. package/dist/entry/rsc-dev/adapter/react.js.map +1 -0
  156. package/dist/entry/rsc-dev/adapter/solid.js +12 -0
  157. package/dist/entry/rsc-dev/adapter/solid.js.map +1 -0
  158. package/dist/entry/rsc-dev/css.js +3 -3
  159. package/dist/entry/rsc-dev/dev.js +6 -10
  160. package/dist/entry/rsc-dev/dev.js.map +1 -1
  161. package/dist/entry/rsc-dev/jsx-dev-runtime.js +2 -2
  162. package/dist/entry/rsc-dev/jsx-runtime.js +2 -2
  163. package/dist/entry/rsc-dev.js +323 -615
  164. package/dist/entry/rsc-dev.js.map +1 -1
  165. package/dist/entry/rsc-prod/adapter/preact.js +2 -0
  166. package/dist/entry/rsc-prod/adapter/react.js +2 -0
  167. package/dist/entry/rsc-prod/adapter/solid.js +2 -0
  168. package/dist/entry/rsc-prod/css.js +9 -3
  169. package/dist/entry/rsc-prod/css.js.map +1 -0
  170. package/dist/entry/rsc-prod/jsx-dev-runtime.js +2 -2
  171. package/dist/entry/rsc-prod/jsx-runtime.js +2 -2
  172. package/dist/entry/rsc-prod/runtime.js +3 -4
  173. package/dist/entry/rsc-prod.js +241 -10
  174. package/dist/entry/rsc-prod.js.map +1 -0
  175. package/dist/{styleStore-ydQcDBD4.js → env-Db2cRt-h.js} +1256 -355
  176. package/dist/env-Db2cRt-h.js.map +1 -0
  177. package/dist/{jsx-A4cK517J.js → getClassName-DKtQl5ZX.js} +5 -11
  178. package/dist/getClassName-DKtQl5ZX.js.map +1 -0
  179. package/dist/{utils-hoYnMiA7.js → getClassName-DaZF5nfJ.js} +28 -65
  180. package/dist/getClassName-DaZF5nfJ.js.map +1 -0
  181. package/dist/getClassName-a6p2uMFM.js +536 -0
  182. package/dist/getClassName-a6p2uMFM.js.map +1 -0
  183. package/dist/{getClassName-oiQ8CnkS.js → getClassName-aD9zqg9U.js} +56 -14
  184. package/dist/getClassName-aD9zqg9U.js.map +1 -0
  185. package/dist/global-zYTvWskP.js +10 -0
  186. package/dist/{global-Cul1dX8k.js.map → global-zYTvWskP.js.map} +1 -1
  187. package/dist/{hash-Bycpk3MR.js → hash-BOlQThNz.js} +48 -4
  188. package/dist/hash-BOlQThNz.js.map +1 -0
  189. package/dist/index.js +10 -10
  190. package/dist/jsx/jsx-dev-runtime.js +2 -2
  191. package/dist/jsx/jsx-dev-runtime.server.js +1 -1
  192. package/dist/jsx/jsx-runtime.js +2 -2
  193. package/dist/jsx/jsx-runtime.server.js +1 -1
  194. package/dist/jsx-C2pnWLcb.js +39 -0
  195. package/dist/jsx-C2pnWLcb.js.map +1 -0
  196. package/dist/{jsx_dev_runtime-BQcRzl5D.js → jsx_dev_runtime-kSrmu6b1.js} +2 -3
  197. package/dist/{jsx_dev_runtime-BQcRzl5D.js.map → jsx_dev_runtime-kSrmu6b1.js.map} +1 -1
  198. package/dist/{jsx_runtime-BXcbW8Yp.js → jsx_runtime-BgK90E2O.js} +2 -3
  199. package/dist/{jsx_runtime-BXcbW8Yp.js.map → jsx_runtime-BgK90E2O.js.map} +1 -1
  200. package/dist/{jsx_runtime-B9KEoAQN.js → jsx_runtime-XJSHujgI.js} +2 -2
  201. package/dist/{jsx_runtime-B9KEoAQN.js.map → jsx_runtime-XJSHujgI.js.map} +1 -1
  202. package/dist/{loader-BAth2yZ1.mjs → loader-DHvgp0fK.mjs} +3 -3
  203. package/dist/{loader-BAth2yZ1.mjs.map → loader-DHvgp0fK.mjs.map} +1 -1
  204. package/dist/{misc-DFBKJGLT.mjs → misc-BuSLnvx0.mjs} +4 -4
  205. package/dist/misc-BuSLnvx0.mjs.map +1 -0
  206. package/dist/{namedTokens-BUa6raTb.js → namedTokens-D3tt-joz.js} +8 -6
  207. package/dist/namedTokens-D3tt-joz.js.map +1 -0
  208. package/dist/plugin/farm/index.mjs +4 -3
  209. package/dist/plugin/farm/index.mjs.map +1 -1
  210. package/dist/plugin/nextjs/index.mjs +5 -5
  211. package/dist/plugin/nextjs/index.mjs.map +1 -1
  212. package/dist/plugin/nextjs/loader.mjs +4 -4
  213. package/dist/plugin/parcel/index.cjs +2 -0
  214. package/dist/plugin/parcel/index.mjs +3 -1
  215. package/dist/plugin/parcel/optimizer.cjs +3 -2
  216. package/dist/plugin/parcel/optimizer.cjs.map +1 -1
  217. package/dist/plugin/parcel/optimizer.mjs +3 -2
  218. package/dist/plugin/parcel/optimizer.mjs.map +1 -1
  219. package/dist/plugin/parcel/resolver.cjs +1 -1
  220. package/dist/plugin/parcel/resolver.mjs +2 -2
  221. package/dist/plugin/parcel/runtime.cjs +1 -1
  222. package/dist/plugin/parcel/runtime.mjs +1 -1
  223. package/dist/plugin/parcel/transformer.cjs +1 -1
  224. package/dist/plugin/parcel/transformer.mjs +2 -2
  225. package/dist/plugin/rspack/index.mjs +3 -2
  226. package/dist/plugin/rspack/index.mjs.map +1 -1
  227. package/dist/plugin/vite/index.mjs +6 -6
  228. package/dist/plugin/vite/index.mjs.map +1 -1
  229. package/dist/plugin/webpack/index.mjs +3 -2
  230. package/dist/plugin/webpack/loader.mjs +2 -2
  231. package/dist/presets/tailwind/index.js +9 -7
  232. package/dist/presets/tailwind/index.js.map +1 -1
  233. package/dist/{assert-BGdigdr5.js → presets-DSanixJV.js} +106 -2
  234. package/dist/presets-DSanixJV.js.map +1 -0
  235. package/dist/{registry-CiwvMfx8.mjs → registry-r3BKWqpI.mjs} +2 -2
  236. package/dist/{registry-CiwvMfx8.mjs.map → registry-r3BKWqpI.mjs.map} +1 -1
  237. package/dist/resolveClassNameRuntime-D5a37GNr.js +63 -0
  238. package/dist/resolveClassNameRuntime-D5a37GNr.js.map +1 -0
  239. package/dist/{rules-DlXcch7-.js → rules-B0_rKPfB.js} +598 -132
  240. package/dist/rules-B0_rKPfB.js.map +1 -0
  241. package/dist/scope-BSuRLice.js +601 -0
  242. package/dist/scope-BSuRLice.js.map +1 -0
  243. package/dist/selector/index.js +1 -2
  244. package/dist/server.js +15 -13
  245. package/dist/server.js.map +1 -1
  246. package/dist/{shared-yDD0nfm1.cjs → shared-8_Msr7Q5.cjs} +1630 -597
  247. package/dist/shared-8_Msr7Q5.cjs.map +1 -0
  248. package/dist/{shared-x59dI2NW.mjs → shared-BGO_05rW.mjs} +4 -4
  249. package/dist/{shared-x59dI2NW.mjs.map → shared-BGO_05rW.mjs.map} +1 -1
  250. package/dist/sheet-BpLZIIuO.js +7 -0
  251. package/dist/{sheet-B-uJfHRY.js.map → sheet-BpLZIIuO.js.map} +1 -1
  252. package/dist/{sidecar-CJ6i4wmn.mjs → sidecar-Bu2x35JE.mjs} +3 -3
  253. package/dist/{sidecar-CJ6i4wmn.mjs.map → sidecar-Bu2x35JE.mjs.map} +1 -1
  254. package/dist/{styleStore-DJ0Msgkh.js → styleStore-BDy5TH6N.js} +5 -6
  255. package/dist/{styleStore-DJ0Msgkh.js.map → styleStore-BDy5TH6N.js.map} +1 -1
  256. package/dist/styleStore-DX3z_UVK.js +51 -0
  257. package/dist/styleStore-DX3z_UVK.js.map +1 -0
  258. package/dist/token-BsW_S8fN.js +138 -0
  259. package/dist/token-BsW_S8fN.js.map +1 -0
  260. package/dist/{trace-D8j96G57.js → trace-BdKEpgME.js} +2 -2
  261. package/dist/{trace-D8j96G57.js.map → trace-BdKEpgME.js.map} +1 -1
  262. package/dist/{trace-CO36aenp.js → trace-DcuMxR45.js} +3 -3
  263. package/dist/{trace-CO36aenp.js.map → trace-DcuMxR45.js.map} +1 -1
  264. package/dist/{transform-BTJOg8Hg.js → transform-BkrLIiIR.js} +2 -2
  265. package/dist/{transform-BTJOg8Hg.js.map → transform-BkrLIiIR.js.map} +1 -1
  266. package/dist/{style-DFFK06Of.js → types-BEUgXuu2.js} +356 -129
  267. package/dist/types-BEUgXuu2.js.map +1 -0
  268. package/dist/{utils-D2fygyTm.mjs → utils-BPDxr-oc.mjs} +4 -4
  269. package/dist/{utils-D2fygyTm.mjs.map → utils-BPDxr-oc.mjs.map} +1 -1
  270. package/dist/utils-CLnpwhJd.js +83 -0
  271. package/dist/utils-CLnpwhJd.js.map +1 -0
  272. package/dist/utils-CUl1BU40.js +72 -0
  273. package/dist/utils-CUl1BU40.js.map +1 -0
  274. package/dist/{utils-DTXCTUlS.mjs → utils-DZjLTV4D.mjs} +3 -3
  275. package/dist/{utils-DTXCTUlS.mjs.map → utils-DZjLTV4D.mjs.map} +1 -1
  276. package/dist/utils-okFWrQsg.js +41 -0
  277. package/dist/utils-okFWrQsg.js.map +1 -0
  278. package/dist/{utils-DVFxZnVC.js → utils-sBVZEq4u.js} +190 -144
  279. package/dist/utils-sBVZEq4u.js.map +1 -0
  280. package/dist/utils.js +4 -4
  281. package/dist/utils.js.map +1 -1
  282. package/dist/value-CpJpQ00y.js +145 -0
  283. package/dist/value-CpJpQ00y.js.map +1 -0
  284. package/dist/{webpack-BOU7_xld.mjs → webpack-DTKgR-HY.mjs} +5 -5
  285. package/dist/webpack-DTKgR-HY.mjs.map +1 -0
  286. package/entry/dev/adapter/preact.ts +8 -0
  287. package/entry/dev/adapter/react.ts +8 -0
  288. package/entry/dev/adapter/solid.ts +8 -0
  289. package/entry/prod/adapter/preact.ts +8 -0
  290. package/entry/prod/adapter/react.ts +8 -0
  291. package/entry/prod/adapter/solid.ts +8 -0
  292. package/entry/prod/config_debug.ts +2 -0
  293. package/entry/prod/index.ts +1 -1
  294. package/entry/prod/runtime.ts +3 -1
  295. package/entry/rsc_dev/adapter/preact.ts +1 -0
  296. package/entry/rsc_dev/adapter/react.ts +1 -0
  297. package/entry/rsc_dev/adapter/solid.ts +1 -0
  298. package/entry/rsc_prod/adapter/preact.ts +1 -0
  299. package/entry/rsc_prod/adapter/react.ts +1 -0
  300. package/entry/rsc_prod/adapter/solid.ts +1 -0
  301. package/entry/rsc_prod/config_debug.ts +6 -0
  302. package/entry/rsc_prod/index.ts +1 -1
  303. package/entry/shared/config_debug.ts +9 -0
  304. package/entry/shared/config_dev.ts +9 -7
  305. package/jsx/types/index.ts +3 -0
  306. package/jsx/types/preact.ts +14 -0
  307. package/jsx/{types.ts → types/react.ts} +2 -2
  308. package/jsx/types/solid.ts +32 -0
  309. package/package.json +78 -12
  310. package/plugin/bundler/farm/plugin.ts +2 -0
  311. package/plugin/bundler/parcel/optimizer.ts +1 -0
  312. package/plugin/bundler/parcel/plugin.ts +2 -0
  313. package/plugin/bundler/rspack/plugin.ts +1 -0
  314. package/plugin/bundler/vite/plugin.ts +3 -8
  315. package/plugin/bundler/vite/state.ts +2 -2
  316. package/plugin/bundler/webpack/plugin.ts +2 -1
  317. package/plugin/nextjs/plugin.ts +3 -0
  318. package/plugin/utils/compiler.ts +2 -0
  319. package/plugin/utils/runtimeEntry.ts +2 -2
  320. package/presets/tailwind/style/transform.ts +9 -3
  321. package/runtime/adapter/utils.ts +94 -0
  322. package/runtime/core/cache/combine.ts +76 -28
  323. package/runtime/core/cache/combineRuntime.ts +4 -0
  324. package/runtime/core/cache/index.ts +2 -1
  325. package/runtime/core/cache/item.ts +32 -13
  326. package/runtime/core/cache/itemWithResolver.ts +44 -0
  327. package/runtime/core/cache/pool.ts +15 -30
  328. package/runtime/core/cache/prop.ts +10 -8
  329. package/runtime/core/cache/result.ts +2 -2
  330. package/runtime/core/cache/stateItem.ts +16 -1
  331. package/runtime/core/cache/token.ts +20 -0
  332. package/runtime/core/cache/tokenValues.ts +19 -11
  333. package/runtime/core/combinedStyle.ts +4 -4
  334. package/runtime/extract/combineStyle.ts +211 -0
  335. package/runtime/extract/getClassName.ts +54 -17
  336. package/runtime/extract/index.ts +3 -1
  337. package/runtime/extract/token.ts +41 -0
  338. package/runtime/extract/tokenResolver.ts +17 -0
  339. package/runtime/sheet/rule.ts +3 -10
  340. package/runtime/style/scope.ts +0 -24
  341. package/runtime/style/style.ts +181 -6
  342. package/runtime/types.ts +3 -3
  343. package/style/classname.ts +12 -6
  344. package/style/important.ts +19 -0
  345. package/style/index.ts +2 -0
  346. package/style/style.ts +17 -5
  347. package/style/theme.ts +0 -1
  348. package/style/token.ts +26 -21
  349. package/style/tokens.ts +18 -12
  350. package/style/transform.ts +1 -1
  351. package/style/types.ts +6 -4
  352. package/style/utils/expose.ts +4 -3
  353. package/style/value.ts +26 -11
  354. package/style/valueRef.ts +1 -1
  355. package/style/weight.ts +21 -0
  356. package/utils/global.ts +1 -3
  357. package/utils/symbol.ts +3 -0
  358. package/dist/assert-BGdigdr5.js.map +0 -1
  359. package/dist/className-CKo4TxuT.js +0 -144
  360. package/dist/className-CKo4TxuT.js.map +0 -1
  361. package/dist/className-ZJ5pBA-o.js +0 -263
  362. package/dist/className-ZJ5pBA-o.js.map +0 -1
  363. package/dist/compiler-D5v5tJXI.mjs.map +0 -1
  364. package/dist/config-BEvP7108.js.map +0 -1
  365. package/dist/config-B_cbG3S6.js +0 -1
  366. package/dist/config-FIfi5aJ8.js.map +0 -1
  367. package/dist/config-OXHoDUIo.js +0 -6
  368. package/dist/css-CELBp6Gu.js +0 -58
  369. package/dist/css-CELBp6Gu.js.map +0 -1
  370. package/dist/css-DcuJ_jSH.js +0 -243
  371. package/dist/css-DcuJ_jSH.js.map +0 -1
  372. package/dist/css-dPoZJDQH.js +0 -807
  373. package/dist/css-dPoZJDQH.js.map +0 -1
  374. package/dist/css-oOt6ZR54.js +0 -237
  375. package/dist/css-oOt6ZR54.js.map +0 -1
  376. package/dist/data-CeYstKMP.js +0 -482
  377. package/dist/data-CeYstKMP.js.map +0 -1
  378. package/dist/debug-D96KGgpH.js.map +0 -1
  379. package/dist/dev-p8tW7X-A.js +0 -81
  380. package/dist/dev-p8tW7X-A.js.map +0 -1
  381. package/dist/elementMarker-CvqqIb7J.js.map +0 -1
  382. package/dist/extract-CzWJeQi8.js +0 -121
  383. package/dist/extract-CzWJeQi8.js.map +0 -1
  384. package/dist/extract-DeOytHKW.js +0 -2
  385. package/dist/getClassName-oiQ8CnkS.js.map +0 -1
  386. package/dist/global-Cul1dX8k.js +0 -14
  387. package/dist/global-zaCE-g1C.js.map +0 -1
  388. package/dist/hash-Bycpk3MR.js.map +0 -1
  389. package/dist/jsx-A4cK517J.js.map +0 -1
  390. package/dist/jsx-Ba-XV33u.js +0 -39
  391. package/dist/jsx-Ba-XV33u.js.map +0 -1
  392. package/dist/layer-CbQzwZF-.js +0 -94
  393. package/dist/layer-CbQzwZF-.js.map +0 -1
  394. package/dist/misc-DFBKJGLT.mjs.map +0 -1
  395. package/dist/namedTokens-BUa6raTb.js.map +0 -1
  396. package/dist/presets-BhXa232U.js +0 -108
  397. package/dist/presets-BhXa232U.js.map +0 -1
  398. package/dist/property-CF6JgpTq.js +0 -406
  399. package/dist/property-CF6JgpTq.js.map +0 -1
  400. package/dist/rules-DlXcch7-.js.map +0 -1
  401. package/dist/runtime-BKChZZ2-.js.map +0 -1
  402. package/dist/shared-yDD0nfm1.cjs.map +0 -1
  403. package/dist/sheet-B-uJfHRY.js +0 -7
  404. package/dist/style-91J0B5ef.js +0 -771
  405. package/dist/style-91J0B5ef.js.map +0 -1
  406. package/dist/style-Bw5ka-Nq.js.map +0 -1
  407. package/dist/style-DFFK06Of.js.map +0 -1
  408. package/dist/style-pz8e5To1.js +0 -5
  409. package/dist/styleStore-ydQcDBD4.js.map +0 -1
  410. package/dist/token-CKXUECuU.js +0 -76
  411. package/dist/token-CKXUECuU.js.map +0 -1
  412. package/dist/token-DTOyFLmp.js +0 -58
  413. package/dist/token-DTOyFLmp.js.map +0 -1
  414. package/dist/token-DT_sCPtm.js +0 -298
  415. package/dist/token-DT_sCPtm.js.map +0 -1
  416. package/dist/utils-Bmw655wa.js +0 -170
  417. package/dist/utils-Bmw655wa.js.map +0 -1
  418. package/dist/utils-DVFxZnVC.js.map +0 -1
  419. package/dist/utils-hoYnMiA7.js.map +0 -1
  420. package/dist/value-D-ZcRzLA.js +0 -42
  421. package/dist/value-D-ZcRzLA.js.map +0 -1
  422. package/dist/value-DvFkGBy2.js +0 -1029
  423. package/dist/value-DvFkGBy2.js.map +0 -1
  424. package/dist/value-dG9LK0Gq.js +0 -85
  425. package/dist/value-dG9LK0Gq.js.map +0 -1
  426. package/dist/valueRef-CsLVJwjA.js +0 -16
  427. package/dist/valueRef-CsLVJwjA.js.map +0 -1
  428. package/dist/webpack-BOU7_xld.mjs.map +0 -1
  429. package/dist/withTokens-LRidu3Vc.js +0 -95
  430. package/dist/withTokens-LRidu3Vc.js.map +0 -1
@@ -0,0 +1,3923 @@
1
+ import { A as TOKEN_ID, B as BUILDER_TYPE, C as getCssVar, E as getStyleTokenName, F as BUILDER_SCOPE, G as globalData, H as RUNTIME_CONFIG, I as BUILDER_SCOPE_ID, K as symbol, L as BUILDER_SELECTOR, M as TOKEN_OVERRIDE, O as isStyleTokenData, P as BUILDER_CALLSITE, R as BUILDER_SLOT_ID, S as escapeCssValue, T as getStyleTokenId, U as SIDECAR_URL_GLOBAL_SYMBOL, V as SHEET_SELECTOR_ANCHOR, W as getCacheTTL, a as mergeResolvedStyle, c as getStylePropCacheValue, d as getResolvedStyleItemTokenValues, f as isResolvedStyleItem$1, g as isExtractedTokenBoundData, h as getExtractedTokenBoundData, i as mergeResolvedClassName, j as TOKEN_NAME, k as isStyleTokenOverrideData, m as setResolvedStyleItemTokenValues, n as finishClassNameResult, p as markResolvedStyleItem, s as walkRecursiveItems, t as createClassNameResult, w as getCssVarRawFallback, z as BUILDER_STATE } from "./className-hiAsQ9V6.js";
2
+ //#region config/constants.ts
3
+ const LayerPlaceholder = "$layer";
4
+ //#endregion
5
+ //#region config/config/css.ts
6
+ const CSS_CONFIG_DEFAULT = {
7
+ layer: true,
8
+ layers: [LayerPlaceholder],
9
+ layerNamespace: "css"
10
+ };
11
+ const CSS_CONFIG = globalData("config.css", () => ({ ...CSS_CONFIG_DEFAULT }));
12
+ //#endregion
13
+ //#region config/build.ts
14
+ const BUILD_CONFIG = globalData("config.build", () => ({ current: null }));
15
+ function setBuildConfig(config) {
16
+ BUILD_CONFIG.current = config;
17
+ RUNTIME_CONFIG.isHoist = config.hoist;
18
+ if (config.css) {
19
+ const { debugClassName: _debugClassName, ...css } = config.css;
20
+ Object.assign(CSS_CONFIG, css);
21
+ }
22
+ }
23
+ //#endregion
24
+ //#region config/config/debug.ts
25
+ const DEFAULT_DEBUG_CONFIG = {
26
+ isDebugClassNameEnabled: false,
27
+ isDebugClassNameConfigured: false,
28
+ maxPropertyLength: 24,
29
+ maxValueLength: 8,
30
+ maxSelectorLength: 8,
31
+ maxParentSelectorLength: 8,
32
+ maxAtRuleLength: 10
33
+ };
34
+ const DEBUG_CONFIG = globalData("config.debug", () => ({ ...DEFAULT_DEBUG_CONFIG }));
35
+ function setDebugClassNameEnabled(value) {
36
+ DEBUG_CONFIG.isDebugClassNameEnabled = value;
37
+ DEBUG_CONFIG.isDebugClassNameConfigured = true;
38
+ }
39
+ function setDebugClassNameDefault(value) {
40
+ if (DEBUG_CONFIG.isDebugClassNameConfigured) return;
41
+ DEBUG_CONFIG.isDebugClassNameEnabled = value;
42
+ }
43
+ function setBuildDebugClassName(value, fallback) {
44
+ if (typeof value === "boolean") setDebugClassNameEnabled(value);
45
+ else setDebugClassNameDefault(fallback);
46
+ }
47
+ //#endregion
48
+ //#region entry/shared/prod.ts
49
+ RUNTIME_CONFIG.isPlugin = true;
50
+ RUNTIME_CONFIG.isExtracted = true;
51
+ //#endregion
52
+ //#region config/configure.ts
53
+ function configureStyleRuntime(options = {}) {
54
+ if (options.css) {
55
+ checkBuildConfig("css");
56
+ const { debugClassName, ...css } = options.css;
57
+ Object.assign(CSS_CONFIG, css);
58
+ if (typeof debugClassName === "boolean") setDebugClassNameEnabled(debugClassName);
59
+ }
60
+ if (options.cacheTTL !== void 0) RUNTIME_CONFIG.runtimeCacheTTL = getCacheTTL(options.cacheTTL);
61
+ }
62
+ function checkBuildConfig(field) {
63
+ if (!BUILD_CONFIG.current) return;
64
+ throw new Error(`Configure "${field}" via plugin options.`);
65
+ }
66
+ //#endregion
67
+ //#region utils/hash.ts
68
+ function hashString(str) {
69
+ let hash = 2166136261;
70
+ for (let i = 0; i < str.length; i++) hash = Math.imul(hash ^ str.charCodeAt(i), 16777619);
71
+ return (hash >>> 0).toString(36).padEnd(7, "0");
72
+ }
73
+ function normalizeHashLength(length) {
74
+ return Number.isFinite(length) ? Math.max(1, Math.floor(length)) : 7;
75
+ }
76
+ //#endregion
77
+ //#region utils/object.ts
78
+ function hasOwn(target, field) {
79
+ return Object.prototype.hasOwnProperty.call(target, field);
80
+ }
81
+ //#endregion
82
+ //#region config/config/dev.ts
83
+ const DEV_CONFIG_DEFAULT = {
84
+ isDev: false,
85
+ isCheckSelectorEnabled: true,
86
+ isSourcemapEnabled: true,
87
+ isLocalClassNameEnabled: true,
88
+ sheetMaxRules: 1e3,
89
+ sheetStyleTagNonce: null,
90
+ hashLength: null,
91
+ stylePriorityMode: "sort",
92
+ sourcemapLocationMode: "style",
93
+ isElementClassNameEnabled: true
94
+ };
95
+ globalData("config.dev.isDev", () => ({ isDev: false }));
96
+ const DEV_CONFIG = globalData("config.dev", () => ({ ...DEV_CONFIG_DEFAULT }));
97
+ globalData("config.dev.plugin", () => ({ config: null }));
98
+ globalData("config.dev.base", () => ({ config: null }));
99
+ globalData("config.dev.utils", () => ({ config: null }));
100
+ //#endregion
101
+ //#region style/important.ts
102
+ const STYLE_IMPORTANT = symbol("style.important");
103
+ function importantValue(value) {
104
+ return {
105
+ [STYLE_IMPORTANT]: true,
106
+ value
107
+ };
108
+ }
109
+ function isStyleImportantValue(value) {
110
+ return !!value && typeof value === "object" && value[STYLE_IMPORTANT] === true;
111
+ }
112
+ //#endregion
113
+ //#region style/weight.ts
114
+ const STYLE_WEIGHT = symbol("style.weight");
115
+ function weightValue(value, weight) {
116
+ return {
117
+ [STYLE_WEIGHT]: true,
118
+ value,
119
+ weight
120
+ };
121
+ }
122
+ function isStyleWeightValue(value) {
123
+ return !!value && typeof value === "object" && value[STYLE_WEIGHT] === true;
124
+ }
125
+ //#endregion
126
+ //#region utils/trace.ts
127
+ const FN_MARKER = "$fn_";
128
+ function traceMarker(fn, name) {
129
+ Object.defineProperty(fn, "name", {
130
+ value: FN_MARKER + name,
131
+ configurable: true
132
+ });
133
+ }
134
+ const CALLSITE_REGEX = /(.+):(\d+):(\d+)$/;
135
+ function traceCallsite() {
136
+ const lines = (traceAdjustError(/* @__PURE__ */ new Error()).stack || "").split("\n");
137
+ const parsedFrames = lines.slice(1).map(parseStackFrame).filter((frame) => frame !== null);
138
+ if (!parsedFrames.length) return null;
139
+ const targetFrame = parsedFrames.find((frame) => !isInternalCallsite(frame.filePath)) ?? parsedFrames[0];
140
+ return {
141
+ stack: [lines[0] || "Error", createStackFrameLine(targetFrame)].join("\n"),
142
+ filePath: targetFrame.filePath,
143
+ sourceUrl: targetFrame.sourceUrl,
144
+ line: targetFrame.line,
145
+ column: targetFrame.column
146
+ };
147
+ }
148
+ function parseStackFrame(lineText) {
149
+ const match = getStackFrameLocationText(lineText).match(CALLSITE_REGEX);
150
+ if (!match) return null;
151
+ const rawFilePath = normalizeCallsiteSourceUrl(match[1]);
152
+ return {
153
+ filePath: normalizeCallsiteFilePath(rawFilePath),
154
+ sourceUrl: isFetchableCallsiteSourceUrl(rawFilePath) ? rawFilePath : void 0,
155
+ line: parseInt(match[2], 10),
156
+ column: parseInt(match[3], 10)
157
+ };
158
+ }
159
+ function getStackFrameLocationText(lineText) {
160
+ let frame = lineText.trim().replace(/^at\s+/, "");
161
+ if (frame.endsWith(")")) {
162
+ const parenIndex = frame.lastIndexOf("(");
163
+ if (parenIndex !== -1) frame = frame.slice(parenIndex + 1, -1);
164
+ }
165
+ return frame;
166
+ }
167
+ function normalizeCallsiteSourceUrl(source) {
168
+ let filePath = source.trim();
169
+ try {
170
+ filePath = decodeURI(filePath);
171
+ } catch {}
172
+ if (filePath.startsWith("source:///at ") || filePath.startsWith("source:///at%20")) filePath = filePath.slice(10);
173
+ const strayAtMatch = filePath.match(/(?:^|\/)at\s+([a-zA-Z][a-zA-Z\d+.-]*:\/\/.+|\/.+)$/);
174
+ return strayAtMatch ? strayAtMatch[1] : filePath.replace(/^at\s+/, "");
175
+ }
176
+ function normalizeCallsiteFilePath(filePath) {
177
+ filePath = normalizeCallsiteSourceUrl(filePath);
178
+ const queryIndex = findFirstIndex(filePath, ["?", "#"]);
179
+ if (queryIndex !== -1) filePath = filePath.substring(0, queryIndex);
180
+ filePath = filePath.replace(/^file:\/\/\/?/, "");
181
+ if (filePath.startsWith("/@fs/")) filePath = "/" + filePath.slice(5);
182
+ const webpackInternalMatch = filePath.match(/^webpack-internal:\/\/\/(?:\([^)]+\)\/)?(.+)$/);
183
+ if (webpackInternalMatch) filePath = webpackInternalMatch[1];
184
+ const webpackSourceMatch = filePath.match(/^webpack:\/\/[^/]+\/(.+)$/);
185
+ if (webpackSourceMatch) filePath = webpackSourceMatch[1];
186
+ return filePath;
187
+ }
188
+ function isFetchableCallsiteSourceUrl(filePath) {
189
+ return /^https?:\/\//.test(filePath) || filePath.startsWith("/");
190
+ }
191
+ function findFirstIndex(text, needles) {
192
+ let index = -1;
193
+ for (const needle of needles) {
194
+ const next = text.indexOf(needle);
195
+ if (next !== -1 && (index === -1 || next < index)) index = next;
196
+ }
197
+ return index;
198
+ }
199
+ function createStackFrameLine(frame) {
200
+ return ` at ${frame.filePath}:${frame.line}:${frame.column}`;
201
+ }
202
+ function isInternalCallsite(filePath) {
203
+ const normalized = filePath.replace(/\\/g, "/");
204
+ return normalized.startsWith("node:") || normalized.startsWith("internal/") || normalized.includes("/node_modules/") || normalized.includes("/packages/style/dist/") || normalized.includes("/packages/style/builder/") || normalized.includes("/packages/style/runtime/") || normalized.includes("/packages/style/utils/trace.");
205
+ }
206
+ function traceError(message, options = {}) {
207
+ const error = new Error(message || "");
208
+ error.name = options.name || "StyleError";
209
+ if (typeof options.stack === "string") {
210
+ error.stack = options.stack;
211
+ return error;
212
+ }
213
+ return traceAdjustError(error, options);
214
+ }
215
+ function traceAdjustError(error, options = {}) {
216
+ const offset = options.offset ?? 0;
217
+ const stack = error.stack;
218
+ if (!stack) return error;
219
+ const lines = stack.split("\n");
220
+ const markerIndex = lines.findIndex((line) => line.includes(FN_MARKER));
221
+ if (markerIndex === -1) return error;
222
+ const traced = new Error(error.message);
223
+ traced.name = error.name;
224
+ const frameStartIndex = Math.max(markerIndex + 1 + offset, 1);
225
+ let frames = lines.slice(frameStartIndex);
226
+ if (options.limit) frames = frames.slice(0, options.limit);
227
+ traced.stack = [lines[0], ...frames].join("\n");
228
+ return traced;
229
+ }
230
+ //#endregion
231
+ //#region builder/data/create.ts
232
+ function createStyleData(callsite) {
233
+ return {
234
+ [BUILDER_TYPE]: 1,
235
+ [BUILDER_STATE]: {
236
+ items: [],
237
+ lookup: {}
238
+ },
239
+ [BUILDER_CALLSITE]: callsite
240
+ };
241
+ }
242
+ function createSheetData(callsite) {
243
+ return {
244
+ [BUILDER_TYPE]: 9,
245
+ [BUILDER_STATE]: {
246
+ items: [],
247
+ lookup: {}
248
+ },
249
+ [BUILDER_CALLSITE]: callsite
250
+ };
251
+ }
252
+ function createSlotData(callsite, slotId) {
253
+ return {
254
+ [BUILDER_TYPE]: 2,
255
+ [BUILDER_STATE]: {
256
+ items: [],
257
+ lookup: {}
258
+ },
259
+ [BUILDER_CALLSITE]: callsite,
260
+ [BUILDER_SLOT_ID]: slotId
261
+ };
262
+ }
263
+ function createSlotOverrideData(callsite, slotId) {
264
+ return {
265
+ [BUILDER_TYPE]: 3,
266
+ [BUILDER_STATE]: {
267
+ items: [],
268
+ lookup: {}
269
+ },
270
+ [BUILDER_CALLSITE]: callsite,
271
+ [BUILDER_SLOT_ID]: slotId
272
+ };
273
+ }
274
+ function createSelectorOverrideData(callsite, selectors) {
275
+ return {
276
+ [BUILDER_TYPE]: 8,
277
+ [BUILDER_STATE]: {
278
+ items: [],
279
+ lookup: {}
280
+ },
281
+ [BUILDER_CALLSITE]: callsite,
282
+ [BUILDER_SELECTOR]: selectors
283
+ };
284
+ }
285
+ function createSelectorData(callsite, selectors) {
286
+ return {
287
+ [BUILDER_TYPE]: 7,
288
+ [BUILDER_STATE]: {
289
+ items: [],
290
+ lookup: {}
291
+ },
292
+ [BUILDER_CALLSITE]: callsite,
293
+ [BUILDER_SELECTOR]: selectors
294
+ };
295
+ }
296
+ function createScopeData(callsite) {
297
+ return {
298
+ [BUILDER_TYPE]: 4,
299
+ [BUILDER_STATE]: {
300
+ items: [],
301
+ lookup: {}
302
+ },
303
+ [BUILDER_CALLSITE]: callsite
304
+ };
305
+ }
306
+ function createScopeTargetData(scope, slot) {
307
+ return {
308
+ [BUILDER_TYPE]: 5,
309
+ [BUILDER_SCOPE]: scope,
310
+ [BUILDER_SCOPE_ID]: slot[BUILDER_SLOT_ID]
311
+ };
312
+ }
313
+ function createThemeData(callsite, id, className, tokens) {
314
+ return {
315
+ [BUILDER_TYPE]: 6,
316
+ [BUILDER_STATE]: {
317
+ items: [],
318
+ lookup: {}
319
+ },
320
+ [BUILDER_CALLSITE]: callsite,
321
+ id,
322
+ className,
323
+ tokens
324
+ };
325
+ }
326
+ function isDebugData(value) {
327
+ if (!value || typeof value !== "object") return false;
328
+ const data = value;
329
+ return data.$$debug === true && Array.isArray(data.loc) && Array.isArray(data.label);
330
+ }
331
+ function getDebugCallsiteId(debug) {
332
+ const label = debug.label[0] || debug.label[1];
333
+ if (!label) return null;
334
+ const hash = debug.sourceUrl + "\n" + debug.loc[0] + ":" + debug.loc[1] + "\n" + (debug.label[1] || label);
335
+ return label + "_" + hashString(hash);
336
+ }
337
+ function getTraceCallsiteId(callsite) {
338
+ return hashString(callsite.filePath + "\n" + callsite.line + ":" + callsite.column);
339
+ }
340
+ function getDebugCallsite(debug) {
341
+ return createDebugCallsite(debug.loc, debug);
342
+ }
343
+ function getDebugFieldCallsite(debug, field) {
344
+ if (!debug) return null;
345
+ const loc = getDebugFieldLoc(debug, field);
346
+ return loc ? createDebugCallsite(loc, debug) : null;
347
+ }
348
+ function getDebugFieldVarName(debug, field) {
349
+ return debug?.vars?.[field] ?? null;
350
+ }
351
+ function getDebugFieldLoc(debug, field) {
352
+ const loc = debug?.fields?.[field];
353
+ if (!loc) return null;
354
+ if (Array.isArray(loc)) return loc;
355
+ return loc[DEV_CONFIG.sourcemapLocationMode === "value" ? 1 : 0] ?? loc[0] ?? loc[1] ?? null;
356
+ }
357
+ function createDebugCallsite(loc, debug) {
358
+ const [line, column] = loc;
359
+ const sourceUrl = loc[3] ?? debug.sourceUrl;
360
+ const sourceContent = loc[4] ?? debug.code;
361
+ return {
362
+ stack: `Error\n at ${sourceUrl}:${line}:${column}`,
363
+ filePath: sourceUrl,
364
+ sourceUrl,
365
+ sourceContent,
366
+ line,
367
+ column
368
+ };
369
+ }
370
+ //#endregion
371
+ //#region builder/data/is.ts
372
+ function getSlotId(data) {
373
+ return data[BUILDER_SLOT_ID];
374
+ }
375
+ function getScopeTargetSlotId(data) {
376
+ return data[BUILDER_SCOPE_ID];
377
+ }
378
+ function getScopeTargetScope(data) {
379
+ return data[BUILDER_SCOPE];
380
+ }
381
+ function getSelectorSelectors(data) {
382
+ return data[BUILDER_SELECTOR];
383
+ }
384
+ function isStyleData(value) {
385
+ return getBuilderType(value) === 1;
386
+ }
387
+ function isSlotData(value) {
388
+ return getBuilderType(value) === 2;
389
+ }
390
+ function isSlotOverrideData(value) {
391
+ return getBuilderType(value) === 3;
392
+ }
393
+ function isSelectorData(value) {
394
+ return getBuilderType(value) === 7;
395
+ }
396
+ function isSelectorOverrideData(value) {
397
+ return getBuilderType(value) === 8;
398
+ }
399
+ function isSheetData(value) {
400
+ return getBuilderType(value) === 9;
401
+ }
402
+ function isScopeData(value) {
403
+ return getBuilderType(value) === 4;
404
+ }
405
+ function isScopeTargetData(value) {
406
+ return getBuilderType(value) === 5;
407
+ }
408
+ function isThemeData(value) {
409
+ return getBuilderType(value) === 6;
410
+ }
411
+ function getBuilderType(value) {
412
+ if (!value || typeof value !== "object" && typeof value !== "function") return null;
413
+ return value[BUILDER_TYPE];
414
+ }
415
+ //#endregion
416
+ //#region atomic/utils/format.ts
417
+ const TOKEN_REGEX = /\(([a-zA-Z][a-zA-Z0-9]*)(?::([0-9]+)(!)?)?\)/g;
418
+ const OPTIONAL_REGEX = /\[([^[\]]*)\]/g;
419
+ const HASH_TOKEN = "$hash";
420
+ function createNameFormatter(keys) {
421
+ const keySet = new Set(keys);
422
+ const cache = /* @__PURE__ */ new Map();
423
+ function getFormatFn(format) {
424
+ if (typeof format === "function") return format;
425
+ let fn = cache.get(format);
426
+ if (!fn) {
427
+ fn = compileFormat(format, keySet);
428
+ cache.set(format, fn);
429
+ }
430
+ return fn;
431
+ }
432
+ return function format(format, hash, info) {
433
+ const name = getFormatFn(format)(info);
434
+ if (!hash) return name;
435
+ if (name.includes(HASH_TOKEN)) return name.replace(HASH_TOKEN, hash);
436
+ return name ? name + "--" + hash : hash;
437
+ };
438
+ }
439
+ function compileFormat(format, keySet) {
440
+ const segments = compileSegments(format, keySet);
441
+ return (info) => {
442
+ let name = "";
443
+ for (const segment of segments) {
444
+ const text = formatSegment(info, segment);
445
+ if (text === null) {
446
+ if (!segment.optional) return "";
447
+ continue;
448
+ }
449
+ name += text;
450
+ }
451
+ return name;
452
+ };
453
+ }
454
+ function compileSegments(format, keySet) {
455
+ const segments = [];
456
+ let lastIndex = 0;
457
+ for (const match of format.matchAll(OPTIONAL_REGEX)) {
458
+ const index = match.index ?? 0;
459
+ if (index > lastIndex) segments.push({
460
+ optional: false,
461
+ parts: compileParts(format.slice(lastIndex, index), keySet)
462
+ });
463
+ segments.push({
464
+ optional: true,
465
+ parts: compileParts(match[1], keySet)
466
+ });
467
+ lastIndex = index + match[0].length;
468
+ }
469
+ if (lastIndex < format.length) segments.push({
470
+ optional: false,
471
+ parts: compileParts(format.slice(lastIndex), keySet)
472
+ });
473
+ return segments;
474
+ }
475
+ function compileParts(segment, keySet) {
476
+ const parts = [];
477
+ let lastIndex = 0;
478
+ for (const match of segment.matchAll(TOKEN_REGEX)) {
479
+ const index = match.index ?? 0;
480
+ const key = match[1];
481
+ if (!keySet.has(key)) continue;
482
+ if (index > lastIndex) parts.push({
483
+ type: "text",
484
+ value: segment.slice(lastIndex, index)
485
+ });
486
+ parts.push({
487
+ type: "token",
488
+ key,
489
+ maxLength: match[2] ? Number(match[2]) : null,
490
+ truncate: Boolean(match[3])
491
+ });
492
+ lastIndex = index + match[0].length;
493
+ }
494
+ if (lastIndex < segment.length) parts.push({
495
+ type: "text",
496
+ value: segment.slice(lastIndex)
497
+ });
498
+ return parts;
499
+ }
500
+ function formatSegment(info, segment) {
501
+ let text = "";
502
+ for (const part of segment.parts) {
503
+ if (part.type === "text") {
504
+ text += part.value;
505
+ continue;
506
+ }
507
+ const value = formatTokenValue(info[part.key], part.maxLength, part.truncate);
508
+ if (value === null) {
509
+ if (segment.optional) return null;
510
+ continue;
511
+ }
512
+ text += value;
513
+ }
514
+ return text;
515
+ }
516
+ function formatTokenValue(value, maxLength, truncate) {
517
+ if (!value) return null;
518
+ if (!maxLength) return value;
519
+ if (!Number.isFinite(maxLength) || maxLength < 0 || value.length <= maxLength) return value;
520
+ return truncate ? value.slice(0, maxLength) : null;
521
+ }
522
+ const formatClassName = createNameFormatter([
523
+ "atRule",
524
+ "scopeSelector",
525
+ "property",
526
+ "selector",
527
+ "value"
528
+ ]);
529
+ const formatTransformClassName = createNameFormatter(["className"]);
530
+ function getDebugClassName(format, hash, info) {
531
+ return formatClassName(format || "[(atRule)-][(scopeSelector)-](property)[-(selector)][-(value)]--$hash", hash, info);
532
+ }
533
+ function getDebugSheetClassName(format, hash, info) {
534
+ return formatClassName(format || "sheet-(property)[-(value)]--$hash", hash, info);
535
+ }
536
+ function getDebugTransformClassName(format, hash, info) {
537
+ return formatTransformClassName(format || "(className)--$hash", hash, info);
538
+ }
539
+ //#endregion
540
+ //#region atomic/utils/cssIdent.ts
541
+ function escapeCssIdent(ident) {
542
+ let result = "";
543
+ for (let i = 0; i < ident.length; i++) {
544
+ const char = ident.charAt(i);
545
+ const code = ident.charCodeAt(i);
546
+ const nextCode = ident.charCodeAt(i + 1);
547
+ if (code === 0) {
548
+ result += "�";
549
+ continue;
550
+ }
551
+ if (code >= 1 && code <= 31 || code === 127 || i === 0 && code >= 48 && code <= 57 || i === 1 && code >= 48 && code <= 57 && ident.charCodeAt(0) === 45) {
552
+ result += "\\" + code.toString(16) + " ";
553
+ continue;
554
+ }
555
+ if (i === 0 && code === 45 && ident.length === 1) {
556
+ result += "\\-";
557
+ continue;
558
+ }
559
+ if (code >= 55296 && code <= 56319 && nextCode >= 56320 && nextCode <= 57343) {
560
+ result += char + ident.charAt(++i);
561
+ continue;
562
+ }
563
+ if (code >= 128 || code === 45 || code === 95 || code >= 48 && code <= 57 || code >= 65 && code <= 90 || code >= 97 && code <= 122) {
564
+ result += char;
565
+ continue;
566
+ }
567
+ result += "\\" + char;
568
+ }
569
+ return result;
570
+ }
571
+ function sanitizeCssIdentName(value, fallback = "") {
572
+ return value.replace(/[^a-zA-Z0-9_-]+/g, "-").replace(/^-+|-+$/g, "") || fallback;
573
+ }
574
+ //#endregion
575
+ //#region atomic/utils/debug.ts
576
+ function normalizeDebugKeywordValue(value) {
577
+ const normalized = value.trim().toLowerCase();
578
+ return /^[a-z][a-z0-9-]*$/.test(normalized) ? normalized : null;
579
+ }
580
+ function sanitizeDebugName(value) {
581
+ if (!value) return "";
582
+ return sanitizeCssIdentName(value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").toLowerCase(), "");
583
+ }
584
+ function normalizePropertyName(property) {
585
+ return property.trim().replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
586
+ }
587
+ function sanitizeDebugPropertyName(property) {
588
+ let name = property;
589
+ if (name.charCodeAt(0) === 45 && name.charCodeAt(1) === 45) name = name.slice(2);
590
+ return name.replace(/[^a-z0-9_-]+/g, "-").replace(/[-_]+/g, "-").replace(/^-+|-+$/g, "");
591
+ }
592
+ //#endregion
593
+ //#region atomic/debug/value.ts
594
+ function getDebugValueName(value) {
595
+ if (!value) return {
596
+ value: null,
597
+ arbitraryValue: null
598
+ };
599
+ const normalized = value.trim().toLowerCase();
600
+ if (!normalized) return {
601
+ value: null,
602
+ arbitraryValue: null
603
+ };
604
+ if (normalized.startsWith("url") || normalized.includes("gradient") || normalized.startsWith("image") || normalized.startsWith("calc(") || normalized.startsWith("var(") || normalized.startsWith("env(") || normalized.startsWith("rgb") || normalized.startsWith("hsl")) return {
605
+ value: null,
606
+ arbitraryValue: null
607
+ };
608
+ if (/^[a-z][a-z0-9-]*$/.test(normalized)) return {
609
+ value: normalized,
610
+ arbitraryValue: null
611
+ };
612
+ const name = normalized.replace(/px/g, "").replace(/rem/g, "rem").replace(/em/g, "em").replace(/%/g, "pct").replace(/fr/g, "fr").replace(/[,()"'#]/g, "-").replace(/\s+/g, "-").replace(/[^a-z0-9._%-]+/g, "-").replace(/[-_]+/g, "-").replace(/^-+|-+$/g, "");
613
+ if (!name) return {
614
+ value: null,
615
+ arbitraryValue: null
616
+ };
617
+ return {
618
+ value: null,
619
+ arbitraryValue: name
620
+ };
621
+ }
622
+ //#endregion
623
+ //#region atomic/debug/property/data.ts
624
+ const PROPERTY_ALIASES = {
625
+ "border-radius": "radius",
626
+ "flex-direction": "flex",
627
+ "font-style": "font",
628
+ "font-weight": "font",
629
+ "grid-template-columns": "grid-cols",
630
+ "grid-template-rows": "grid-rows",
631
+ "align-items": "items",
632
+ "justify-content": "justify",
633
+ "z-index": "zindex",
634
+ "pointer-events": "pointer"
635
+ };
636
+ const KEYWORD_VALUE_PROPERTIES = new Set([
637
+ "align-content",
638
+ "align-items",
639
+ "align-self",
640
+ "background-repeat",
641
+ "background-size",
642
+ "border-collapse",
643
+ "border-style",
644
+ "box-sizing",
645
+ "clear",
646
+ "cursor",
647
+ "display",
648
+ "flex-direction",
649
+ "flex-wrap",
650
+ "float",
651
+ "font-weight",
652
+ "font-style",
653
+ "justify-content",
654
+ "justify-items",
655
+ "justify-self",
656
+ "list-style-position",
657
+ "list-style-type",
658
+ "object-fit",
659
+ "object-position",
660
+ "overflow",
661
+ "overflow-x",
662
+ "overflow-y",
663
+ "pointer-events",
664
+ "place-content",
665
+ "place-items",
666
+ "place-self",
667
+ "position",
668
+ "resize",
669
+ "table-layout",
670
+ "text-align",
671
+ "text-decoration-line",
672
+ "text-transform",
673
+ "user-select",
674
+ "vertical-align",
675
+ "visibility",
676
+ "white-space"
677
+ ]);
678
+ const ARBITRARY_VALUE_PROPERTIES = new Set(["font-weight"]);
679
+ //#endregion
680
+ //#region atomic/debug/property/property.ts
681
+ function getDebugPropertyName(property, value) {
682
+ if (!property) return null;
683
+ const normalized = normalizePropertyName(property);
684
+ const name = PROPERTY_ALIASES[normalized] || sanitizeDebugPropertyName(normalized);
685
+ if (!name) return null;
686
+ return {
687
+ property: name,
688
+ ...withKeywordValueFallback(normalized, value, withArbitraryValueFallback(normalized, getDebugValueName(value)))
689
+ };
690
+ }
691
+ function withArbitraryValueFallback(property, valueName) {
692
+ if (!valueName.arbitraryValue || ARBITRARY_VALUE_PROPERTIES.has(property)) return valueName;
693
+ return {
694
+ value: valueName.value,
695
+ arbitraryValue: null
696
+ };
697
+ }
698
+ function withKeywordValueFallback(property, value, valueName) {
699
+ if (valueName.value || valueName.arbitraryValue) return valueName;
700
+ if (!KEYWORD_VALUE_PROPERTIES.has(property)) return valueName;
701
+ const normalized = normalizeDebugKeywordValue(value);
702
+ if (!normalized) return valueName;
703
+ return {
704
+ value: normalized,
705
+ arbitraryValue: null
706
+ };
707
+ }
708
+ //#endregion
709
+ //#region atomic/debug/selector.ts
710
+ function getDebugSelectorName(selector) {
711
+ if (!selector) return null;
712
+ const normalized = selector.trim().toLowerCase();
713
+ if (/^[a-z0-9]+$/.test(normalized)) return null;
714
+ return validateName(normalized.replace(/\$\$/g, "args").replace(/\$/g, "arg").replace(/\.\.\./g, "merge").replace(/:not\(/g, "not-").replace(/:(is|where|has)\(/g, "$1-").replace(/:nth-(child|of-type)\(/g, "nth-").replace(/[.#]/g, "-").replace(/[[\]()]/g, "-").replace(/:+/g, "-").replace(/\s+/g, "-").replace(/[^a-z0-9_-]+/g, "-").replace(/[-_]+/g, "-").replace(/^-+|-+$/g, ""));
715
+ }
716
+ function getDebugAtRuleName(selector) {
717
+ if (!selector || Array.isArray(selector) && selector.length === 0) return null;
718
+ return validateName((Array.isArray(selector) ? selector.map(parseAtRule).filter(Boolean).join("-") : parseAtRule(selector)).replace(/[-_]+/g, "-").replace(/^-+|-+$/g, ""));
719
+ }
720
+ function compressQuery(query) {
721
+ return query.trim().toLowerCase().replace(/prefers-color-scheme\s*:\s*dark/g, "dark").replace(/prefers-color-scheme\s*:\s*light/g, "light").replace(/min-width\s*:\s*/g, "min-").replace(/max-width\s*:\s*/g, "max-").replace(/min-height\s*:\s*/g, "minh-").replace(/max-height\s*:\s*/g, "maxh-").replace(/inline-size/g, "inline").replace(/\b(and|or|only|not)\b/g, "").replace(/>=/g, "-gte-").replace(/<=/g, "-lte-").replace(/>/g, "-gt-").replace(/</g, "-lt-").replace(/[():=\s]+/g, "-").replace(/[-_]+/g, "-").replace(/^-+|-+$/g, "");
722
+ }
723
+ function validateName(name) {
724
+ if (!name || name === "selector" || name.length < 2) return null;
725
+ return name;
726
+ }
727
+ function parseAtRule(rule) {
728
+ const normalized = rule.trim().toLowerCase();
729
+ if (normalized.startsWith("@media")) return compressQuery(normalized.slice(6));
730
+ if (normalized.startsWith("@container")) return compressQuery(normalized.slice(10));
731
+ if (normalized.startsWith("@supports")) return compressQuery(normalized.slice(9));
732
+ return compressQuery(normalized);
733
+ }
734
+ function getScopeClassName(className, scopeClassNameFormat) {
735
+ return formatScopeClassName$1(scopeClassNameFormat || "-(className)", { className });
736
+ }
737
+ function formatScopeClassName$1(format, info) {
738
+ if (typeof format === "function") return format(info);
739
+ return format.replace(/\[|\]/g, "").replace(/\(className\)/g, info.className);
740
+ }
741
+ //#endregion
742
+ //#region atomic/utils/hash.ts
743
+ const POOLED_HASH_STATE = globalData("atomic.hashPool", () => ({
744
+ byValue: /* @__PURE__ */ new Map(),
745
+ byHash: /* @__PURE__ */ new Map(),
746
+ usedByLength: []
747
+ }));
748
+ function getIdentifierSafeHash(value, startLength = 7) {
749
+ return getPooledHash(value, startLength);
750
+ }
751
+ function getPooledHash(value, startLength) {
752
+ const normalizedStartLength = normalizeHashLength(startLength);
753
+ const valueKey = normalizedStartLength + "\0" + value;
754
+ const existing = POOLED_HASH_STATE.byValue.get(valueKey);
755
+ if (existing) return existing;
756
+ let length = normalizedStartLength;
757
+ while (true) {
758
+ if (getPooledHashUsedCount(length) >= getIdentifierSafeHashPoolSize(length)) {
759
+ length++;
760
+ continue;
761
+ }
762
+ for (let index = 0; index < getIdentifierSafeHashPoolSize(length); index++) {
763
+ const hash = getPooledHashCandidate(value, length, index);
764
+ const owner = POOLED_HASH_STATE.byHash.get(hash);
765
+ if (owner !== void 0 && owner !== valueKey) continue;
766
+ POOLED_HASH_STATE.byValue.set(valueKey, hash);
767
+ POOLED_HASH_STATE.byHash.set(hash, valueKey);
768
+ POOLED_HASH_STATE.usedByLength[length] = getPooledHashUsedCount(length) + 1;
769
+ return hash;
770
+ }
771
+ length++;
772
+ }
773
+ }
774
+ function getPooledHashCandidate(value, length, index) {
775
+ return getIdentifierSafeHashValue(hashString(index === 0 ? value : value + "::" + index)).slice(0, length);
776
+ }
777
+ function getPooledHashUsedCount(length) {
778
+ return POOLED_HASH_STATE.usedByLength[length] ?? 0;
779
+ }
780
+ function getIdentifierSafeHashPoolSize(length) {
781
+ if (length <= 0) return 0;
782
+ return 26 * 36 ** (length - 1);
783
+ }
784
+ function getIdentifierSafeHashValue(hash) {
785
+ const first = hash.charCodeAt(0);
786
+ if (first < 48 || first > 57) return hash;
787
+ return String.fromCharCode(97 + first - 48) + hash.slice(1);
788
+ }
789
+ //#endregion
790
+ //#region atomic/utils/selector.ts
791
+ function getSelectorText$1(selector) {
792
+ return stripSheetSelectorAnchor(Array.isArray(selector) ? selector[0] : selector);
793
+ }
794
+ function getSelectorHash(selector) {
795
+ return Array.isArray(selector) ? selector.join("|") : selector;
796
+ }
797
+ function getSelectorPriority$1(selector) {
798
+ if (!selector) return 0;
799
+ return Array.isArray(selector) ? selector[1] : 0;
800
+ }
801
+ function hasSheetSelectorAnchor(selector) {
802
+ return (selector ? Array.isArray(selector) ? selector[0] : selector : "").startsWith(SHEET_SELECTOR_ANCHOR);
803
+ }
804
+ function stripSheetSelectorAnchor(selector) {
805
+ return selector.startsWith("\0sheet") ? selector.slice(SHEET_SELECTOR_ANCHOR.length) : selector;
806
+ }
807
+ //#endregion
808
+ //#region atomic/className.ts
809
+ function getAtomicClassName(property, priority, important, value, selector, parentSelector, atRule, callsite, localClassName, debugClassName, classNameFormat, transformClassName, transformClassNameFormat, sheetClassNameFormat = null, hashLength = null) {
810
+ let hash = property;
811
+ hash += "\n" + (priority || "");
812
+ if (important) hash += "\nimportant";
813
+ hash += "\n" + value;
814
+ hash += "\n" + (selector ? getSelectorHash(selector) : "");
815
+ hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
816
+ hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
817
+ hash += "\n" + getCallsiteHash(callsite, localClassName);
818
+ hash = getIdentifierSafeHash(hash, hashLength ?? getRuntimeClassNameHashLength(debugClassName));
819
+ if (!debugClassName) return hash;
820
+ if (transformClassName) return getDebugTransformClassName(transformClassNameFormat, hash, { className: transformClassName });
821
+ const propertyName = getDebugPropertyName(property, value);
822
+ const isSheetClassName = hasSheetSelectorAnchor(selector);
823
+ return (isSheetClassName ? getDebugSheetClassName : getDebugClassName)(isSheetClassName ? sheetClassNameFormat : classNameFormat, hash, {
824
+ atRule: atRule ? getDebugAtRuleName(atRule.map(getSelectorText$1)) : null,
825
+ scopeSelector: parentSelector ? getDebugSelectorName(getSelectorText$1(parentSelector)) : null,
826
+ selector: selector ? getDebugSelectorName(getSelectorText$1(selector)) : null,
827
+ property: propertyName ? propertyName.property : property,
828
+ value: propertyName ? propertyName.value ?? propertyName.arbitraryValue : null
829
+ });
830
+ }
831
+ function getRuntimeClassNameHashLength(debugClassName) {
832
+ if (debugClassName && DEV_CONFIG.isDev) return DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3;
833
+ return CSS_CONFIG.hashLength ?? 7;
834
+ }
835
+ function getClassNameDedupe(property, priority, important, selector, parentSelector, atRule) {
836
+ let hash = property;
837
+ hash += "\n" + (priority || "");
838
+ if (important) hash += "\nimportant";
839
+ hash += "\n" + (selector ? getSelectorHash(selector) : "");
840
+ hash += "\n" + (parentSelector ? getSelectorHash(parentSelector) : "");
841
+ hash += "\n" + (atRule ? atRule.map(getSelectorHash).join("\n") : "");
842
+ return hashString(hash);
843
+ }
844
+ function getCallsiteHash(callsite, localClassName) {
845
+ if (!localClassName || !callsite) return "";
846
+ return callsite.filePath + "\n" + callsite.line + ":" + callsite.column;
847
+ }
848
+ //#endregion
849
+ //#region builder/token/name.ts
850
+ function getStyleTokenNameFromId(id) {
851
+ if (!id) return null;
852
+ const parts = id.split("--");
853
+ const first = normalizeStyleTokenName(parts[0]);
854
+ if (!first) return parts.length > 1 ? normalizeStyleTokenName(parts.slice(1).join("--")) : null;
855
+ return normalizeStyleTokenName([first, ...parts.slice(1)].join("--"));
856
+ }
857
+ function getChildStyleTokenName(name, child) {
858
+ const childName = normalizeStyleTokenName(child);
859
+ if (!childName) return normalizeStyleTokenName(name);
860
+ const parentName = normalizeStyleTokenName(name);
861
+ return parentName ? parentName + "--" + childName : childName;
862
+ }
863
+ function normalizeStyleTokenName(value) {
864
+ if (!value) return null;
865
+ value = value.trim();
866
+ if (!value) return null;
867
+ if (/^\d+$/.test(value)) return null;
868
+ if (isGeneratedTokenHash(value)) return null;
869
+ value = stripGenericTokenPrefix(value);
870
+ if (!value) return null;
871
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
872
+ if (stableSuffix?.[1] && isGeneratedTokenHash(value.slice(-7))) return normalizeStyleTokenName(stableSuffix[1]);
873
+ return value;
874
+ }
875
+ function isGeneratedTokenHash(value) {
876
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
877
+ }
878
+ function stripGenericTokenPrefix(value) {
879
+ const parts = value.split("--");
880
+ while (parts[0] === "token" || parts[0] === "tokens") parts.shift();
881
+ return parts.join("--");
882
+ }
883
+ //#endregion
884
+ //#region style/token.ts
885
+ const TOKEN_DEBUG = symbol("style:token.debug");
886
+ const idCounter$6 = globalData("style.token.idCounter", () => ({ value: 0 }));
887
+ function resetStyleTokenIdCounter() {
888
+ idCounter$6.value = 0;
889
+ }
890
+ function createStyleToken(value, stableId, debugName) {
891
+ const token = (value, debug) => {
892
+ return createStyleTokenOverride(token, value, debug);
893
+ };
894
+ token[TOKEN_ID] = stableId || String(idCounter$6.value++);
895
+ token[TOKEN_NAME] = debugName === void 0 ? getStyleTokenNameFromId(stableId) : normalizeStyleTokenName(debugName);
896
+ if (isStyleTokenData(value)) {
897
+ token.value = value.value;
898
+ token.ref = value;
899
+ } else {
900
+ token.value = value;
901
+ token.ref = null;
902
+ }
903
+ return token;
904
+ }
905
+ function createStyleTokenOverride(token, value, debug) {
906
+ const override = isStyleTokenData(value) ? {
907
+ [TOKEN_ID]: getStyleTokenId(token),
908
+ [TOKEN_OVERRIDE]: true,
909
+ [TOKEN_NAME]: getStyleTokenName(token),
910
+ value: value.value,
911
+ ref: value
912
+ } : {
913
+ [TOKEN_ID]: getStyleTokenId(token),
914
+ [TOKEN_OVERRIDE]: true,
915
+ [TOKEN_NAME]: getStyleTokenName(token),
916
+ value,
917
+ ref: null
918
+ };
919
+ if (debug) Object.defineProperty(override, TOKEN_DEBUG, {
920
+ configurable: true,
921
+ enumerable: false,
922
+ value: debug
923
+ });
924
+ return override;
925
+ }
926
+ function getStyleTokenOverrideDebug(token) {
927
+ return token[TOKEN_DEBUG] ?? null;
928
+ }
929
+ //#endregion
930
+ //#region builder/data/merge/utils.ts
931
+ function cloneData(data, source, debug, merge = true) {
932
+ const runtimeType = DEV_CONFIG.isDev ? debug ? -2 : -1 : -3;
933
+ const state = data[BUILDER_STATE];
934
+ state.items = merge ? source[BUILDER_STATE].items.slice() : [];
935
+ state.lookup = Object.assign(Object.create(null), merge ? source[BUILDER_STATE].lookup : null);
936
+ const lookup = state.lookup;
937
+ return [
938
+ runtimeType,
939
+ data,
940
+ state.items,
941
+ lookup
942
+ ];
943
+ }
944
+ function logInvalidData(message, data) {
945
+ console.log(traceError(message), "data:", data);
946
+ }
947
+ //#endregion
948
+ //#region builder/data/merge/scope.ts
949
+ function mergeScopeData(scope, callsite, items, debug, parentSelector, scopeAtRule) {
950
+ if (!items) return scope;
951
+ const sourceItems = Array.isArray(items) ? items : [items];
952
+ const [runtimeType, data, styles, lookup] = cloneData(scope, scope, debug);
953
+ let source;
954
+ let item;
955
+ let lookupIndex;
956
+ let weight;
957
+ let important;
958
+ let value;
959
+ let atRule;
960
+ let dedupe;
961
+ let className;
962
+ let itemDebug;
963
+ let itemCallsite;
964
+ for (let i = 0, len = sourceItems.length; i < len; i++) {
965
+ source = sourceItems[i];
966
+ if (!source) continue;
967
+ if (isStyleTokenOverrideData(source)) {
968
+ addTokenOverride$1(source, styles, lookup);
969
+ continue;
970
+ }
971
+ if (isScopeData(source)) {
972
+ const scopeItems = source[BUILDER_STATE].items;
973
+ for (let j = 0, len = scopeItems.length; j < len; j++) {
974
+ item = scopeItems[j];
975
+ if (isStyleTokenOverrideData(item)) {
976
+ addTokenOverride$1(item, styles, lookup);
977
+ continue;
978
+ }
979
+ if (Array.isArray(item) || item.type !== 4) {
980
+ logInvalidData("invalid scope data", {
981
+ source,
982
+ item
983
+ });
984
+ continue;
985
+ }
986
+ const sourceScopeItem = item;
987
+ atRule = scopeAtRule ? sourceScopeItem.atRule ? [scopeAtRule].concat(sourceScopeItem.atRule) : [scopeAtRule] : sourceScopeItem.atRule;
988
+ const scopeItem = {
989
+ ...sourceScopeItem,
990
+ runtime: runtimeType,
991
+ atRule,
992
+ parentSelector: parentSelector ?? sourceScopeItem.parentSelector
993
+ };
994
+ itemDebug = getMergedScopeDebug(debug, scopeItem);
995
+ itemCallsite = getDebugFieldCallsite(itemDebug ?? null, scopeItem.property) ?? callsite ?? scopeItem.callsite;
996
+ value = scopeItem.value;
997
+ weight = scopeItem.weight;
998
+ important = scopeItem.important;
999
+ dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule);
1000
+ className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, scopeItem.parentSelector, scopeItem.atRule, itemCallsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
1001
+ scopeItem.dedupe = dedupe;
1002
+ scopeItem.className = className;
1003
+ scopeItem.callsite = itemCallsite;
1004
+ scopeItem.debug = itemDebug ?? null;
1005
+ scopeItem.debugField = itemDebug ? scopeItem.property : null;
1006
+ const lookupKey = getScopeLookupKey(scopeItem.slotId, dedupe);
1007
+ lookupIndex = lookup[lookupKey];
1008
+ if (typeof lookupIndex === "number") styles[lookupIndex] = scopeItem;
1009
+ else lookup[lookupKey] = styles.push(scopeItem) - 1;
1010
+ }
1011
+ continue;
1012
+ }
1013
+ if (!isSlotOverrideData(source)) {
1014
+ logInvalidData("invalid scope data", { source });
1015
+ continue;
1016
+ }
1017
+ const slotId = source[BUILDER_SLOT_ID];
1018
+ const overrideItems = source[BUILDER_STATE].items;
1019
+ for (let j = 0, len = overrideItems.length; j < len; j++) {
1020
+ item = overrideItems[j];
1021
+ if (Array.isArray(item) || isStyleTokenOverrideData(item) || item.type !== 3) {
1022
+ logInvalidData("invalid scope data", {
1023
+ source,
1024
+ item
1025
+ });
1026
+ continue;
1027
+ }
1028
+ const overrideItem = item;
1029
+ atRule = scopeAtRule ? overrideItem.atRule ? [scopeAtRule].concat(overrideItem.atRule) : [scopeAtRule] : overrideItem.atRule;
1030
+ const scopeItem = {
1031
+ type: 4,
1032
+ slotId,
1033
+ runtime: runtimeType,
1034
+ dedupe: "",
1035
+ className: "",
1036
+ property: overrideItem.property,
1037
+ weight: overrideItem.weight,
1038
+ important: overrideItem.important,
1039
+ value: overrideItem.value,
1040
+ transformClassName: overrideItem.transformClassName,
1041
+ token: overrideItem.token,
1042
+ selector: overrideItem.selector,
1043
+ atRule,
1044
+ callsite: overrideItem.callsite ?? callsite,
1045
+ debug: overrideItem.debug,
1046
+ debugField: overrideItem.debugField,
1047
+ parentSelector
1048
+ };
1049
+ value = scopeItem.value;
1050
+ weight = scopeItem.weight;
1051
+ important = scopeItem.important;
1052
+ dedupe = getClassNameDedupe(scopeItem.property, weight, important, scopeItem.selector, parentSelector, scopeItem.atRule);
1053
+ className = getAtomicClassName(scopeItem.property, weight, important, value, scopeItem.selector, parentSelector, scopeItem.atRule, scopeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, scopeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
1054
+ scopeItem.dedupe = dedupe;
1055
+ scopeItem.className = className;
1056
+ const lookupKey = getScopeLookupKey(slotId, dedupe);
1057
+ lookupIndex = lookup[lookupKey];
1058
+ if (typeof lookupIndex === "number") styles[lookupIndex] = scopeItem;
1059
+ else lookup[lookupKey] = styles.push(scopeItem) - 1;
1060
+ }
1061
+ }
1062
+ return data;
1063
+ }
1064
+ function addTokenOverride$1(item, styles, lookup) {
1065
+ const lookupKey = getTokenLookupKey(getStyleTokenId(item));
1066
+ const lookupIndex = lookup[lookupKey];
1067
+ if (typeof lookupIndex === "number") styles[lookupIndex] = item;
1068
+ else lookup[lookupKey] = styles.push(item) - 1;
1069
+ }
1070
+ function getMergedScopeDebug(debug, item) {
1071
+ if (!debug) return item.debug;
1072
+ if (debug.fields?.[item.property]) return debug;
1073
+ const valueLoc = getRuntimeScopeItemValueLoc(item);
1074
+ if (!valueLoc) return debug;
1075
+ return {
1076
+ ...debug,
1077
+ fields: {
1078
+ ...debug.fields,
1079
+ [item.property]: {
1080
+ [0]: debug.loc,
1081
+ [1]: valueLoc
1082
+ }
1083
+ }
1084
+ };
1085
+ }
1086
+ function getRuntimeScopeItemValueLoc(item) {
1087
+ if (item.debug && item.debugField) {
1088
+ const loc = item.debug.fields?.[item.debugField];
1089
+ if (Array.isArray(loc)) return withDebugSource$1(loc, item.debug.sourceUrl, item.debug.code);
1090
+ if (loc) {
1091
+ const valueLoc = loc[1] ?? loc[0] ?? null;
1092
+ return valueLoc ? withDebugSource$1(valueLoc, item.debug.sourceUrl, item.debug.code) : null;
1093
+ }
1094
+ }
1095
+ return item.callsite ? [
1096
+ item.callsite.line,
1097
+ item.callsite.column,
1098
+ void 0,
1099
+ item.callsite.sourceUrl,
1100
+ item.callsite.sourceContent
1101
+ ] : null;
1102
+ }
1103
+ function withDebugSource$1(loc, sourceUrl, sourceContent) {
1104
+ return loc[3] ? loc : [
1105
+ loc[0],
1106
+ loc[1],
1107
+ loc[2],
1108
+ sourceUrl,
1109
+ sourceContent
1110
+ ];
1111
+ }
1112
+ function getScopeLookupKey(slotId, dedupe) {
1113
+ return slotId + "\0" + dedupe;
1114
+ }
1115
+ function getTokenLookupKey(tokenId) {
1116
+ return "token\0" + tokenId;
1117
+ }
1118
+ const formatTokenName = createNameFormatter(["name"]);
1119
+ function getTokenVarName(token, format) {
1120
+ const id = getStyleTokenId(token);
1121
+ const debugName = getStyleTokenName(token);
1122
+ return "--" + formatTokenName(format || "token[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: debugName });
1123
+ }
1124
+ function getTokenVar(token, format) {
1125
+ return getTokenVarFallback(token, format);
1126
+ }
1127
+ function getTokenOverrideValue(token, format) {
1128
+ return token.ref ? getTokenVar(token.ref, format) : token.value;
1129
+ }
1130
+ function getTokenVarFallback(token, tokenNameFormat) {
1131
+ const varName = getTokenVarName(token, tokenNameFormat);
1132
+ if (token.ref) return getCssVarRawFallback(varName, getTokenVarFallback(token.ref, tokenNameFormat));
1133
+ return getCssVar(varName, String(token.value ?? ""));
1134
+ }
1135
+ //#endregion
1136
+ //#region atomic/value/unitless.ts
1137
+ const UnitlessProperties = [
1138
+ "animationIterationCount",
1139
+ "aspectRatio",
1140
+ "borderImageOutset",
1141
+ "borderImageSlice",
1142
+ "borderImageWidth",
1143
+ "boxFlex",
1144
+ "boxFlexGroup",
1145
+ "boxOrdinalGroup",
1146
+ "columnCount",
1147
+ "columns",
1148
+ "fillOpacity",
1149
+ "flex",
1150
+ "flexGrow",
1151
+ "flexNegative",
1152
+ "flexOrder",
1153
+ "flexPositive",
1154
+ "flexShrink",
1155
+ "floodOpacity",
1156
+ "fontWeight",
1157
+ "gridArea",
1158
+ "gridColumn",
1159
+ "gridColumnEnd",
1160
+ "gridColumnSpan",
1161
+ "gridColumnStart",
1162
+ "gridRow",
1163
+ "gridRowEnd",
1164
+ "gridRowSpan",
1165
+ "gridRowStart",
1166
+ "imageOrientation",
1167
+ "lineClamp",
1168
+ "lineHeight",
1169
+ "opacity",
1170
+ "order",
1171
+ "orphans",
1172
+ "scale",
1173
+ "stopOpacity",
1174
+ "strokeDasharray",
1175
+ "strokeDashoffset",
1176
+ "strokeMiterlimit",
1177
+ "strokeOpacity",
1178
+ "strokeWidth",
1179
+ "tabSize",
1180
+ "widows",
1181
+ "zIndex",
1182
+ "zoom"
1183
+ ];
1184
+ //#endregion
1185
+ //#region atomic/value/value.ts
1186
+ const CSS_NUMBER_VALUE = /^-?(\d+\.?\d*|\.\d+)$/;
1187
+ const UNITLESS = new Set(UnitlessProperties);
1188
+ function getCssPropertyValue(property, value) {
1189
+ if (!value || !shouldAppendCssPx(property)) return value;
1190
+ if (CSS_NUMBER_VALUE.test(value)) return value + "px";
1191
+ return value;
1192
+ }
1193
+ function shouldAppendCssPx(property) {
1194
+ return !UNITLESS.has(property);
1195
+ }
1196
+ //#endregion
1197
+ //#region style/transform.ts
1198
+ const CLASS_NAME_VALUE = symbol("transform.classNameValue");
1199
+ function classNameValue(value, className) {
1200
+ return {
1201
+ [CLASS_NAME_VALUE]: true,
1202
+ value,
1203
+ className
1204
+ };
1205
+ }
1206
+ function isClassNameValue(value) {
1207
+ return !!value && typeof value === "object" && value[CLASS_NAME_VALUE] === true && typeof value.className === "string";
1208
+ }
1209
+ function styleTransform(options) {
1210
+ return options;
1211
+ }
1212
+ function classNameTransform(options) {
1213
+ return options;
1214
+ }
1215
+ //#endregion
1216
+ //#region style/valueRef.ts
1217
+ const AT_RULE_REF = symbol("atRule.ref");
1218
+ function createAtRuleRef(data) {
1219
+ return {
1220
+ [AT_RULE_REF]: true,
1221
+ ...data
1222
+ };
1223
+ }
1224
+ function isAtRuleRef(value) {
1225
+ return !!value && typeof value === "object" && value[AT_RULE_REF] === true;
1226
+ }
1227
+ //#endregion
1228
+ //#region builder/data/merge/style.ts
1229
+ function mergeBuilderData(create, callsite, source, style, debug, selector, atRule, type) {
1230
+ if (!style) return source;
1231
+ const [runtimeType, data, styles, lookup] = cloneData(create(callsite, source), source, debug);
1232
+ const slotId = isSlotData(source) || isSlotOverrideData(source) ? source[BUILDER_SLOT_ID] : null;
1233
+ const items = [];
1234
+ let item;
1235
+ let itemData;
1236
+ let valueRaw;
1237
+ let value;
1238
+ let weight;
1239
+ let important;
1240
+ let itemCallsite;
1241
+ let className;
1242
+ let dedupe;
1243
+ let token;
1244
+ let ref;
1245
+ let variableName;
1246
+ let transformClassName;
1247
+ let lookupIndex;
1248
+ if (isStyleData(style)) {
1249
+ const stylesItems = style[BUILDER_STATE].items;
1250
+ for (let i = 0, len = stylesItems.length; i < len; i++) {
1251
+ item = stylesItems[i];
1252
+ if (Array.isArray(item) || isStyleTokenOverrideData(item) || item.type !== 1) {
1253
+ logInvalidData("invalid style data", {
1254
+ item,
1255
+ style
1256
+ });
1257
+ continue;
1258
+ }
1259
+ if (atRule) item = Object.assign({}, item, { atRule: item.atRule ? atRule.concat(item.atRule) : atRule });
1260
+ if (selector) item = Object.assign({}, item, { selector: item.selector ? combineSelectors(selector, item.selector) : selector });
1261
+ if (type === 2 && slotId !== null) item = Object.assign({}, item, {
1262
+ type: 2,
1263
+ slotId
1264
+ });
1265
+ else if (type === 3 && slotId !== null) item = Object.assign({}, item, {
1266
+ type: 3,
1267
+ slotId
1268
+ });
1269
+ else if (type === 8) item = Object.assign({}, item, { type: 1 });
1270
+ const itemDebug = getMergedStyleDebug(debug, item);
1271
+ const debugCallsite = getDebugFieldCallsite(itemDebug, item.property);
1272
+ if (debugCallsite) item = Object.assign({}, item, {
1273
+ callsite: debugCallsite,
1274
+ debug: itemDebug,
1275
+ debugField: item.property
1276
+ });
1277
+ items.push(item);
1278
+ }
1279
+ } else for (const property in style) {
1280
+ valueRaw = style[property];
1281
+ [valueRaw, weight, important] = unwrapAuthoredStyleValue(valueRaw);
1282
+ transformClassName = null;
1283
+ if (isClassNameValue(valueRaw)) {
1284
+ transformClassName = valueRaw.className;
1285
+ valueRaw = valueRaw.value;
1286
+ }
1287
+ ref = isAtRuleRef(valueRaw) ? valueRaw : null;
1288
+ if (ref) valueRaw = ref.value;
1289
+ token = isStyleTokenData(valueRaw) ? valueRaw : null;
1290
+ variableName = getDebugFieldVarName(debug, property);
1291
+ value = variableName && token ? getCssVarRawFallback(variableName, getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null)) : token ? getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null) : String(valueRaw ?? "");
1292
+ itemCallsite = getDebugFieldCallsite(debug, property) ?? callsite;
1293
+ itemData = {
1294
+ runtime: runtimeType,
1295
+ debug,
1296
+ debugField: property,
1297
+ dedupe: "",
1298
+ className: "",
1299
+ property,
1300
+ weight,
1301
+ important,
1302
+ value,
1303
+ transformClassName,
1304
+ variable: ref ? [3, ref] : variableName && token ? [
1305
+ 1,
1306
+ variableName,
1307
+ valueRaw,
1308
+ shouldAppendCssPx(property) ? 1 : void 0
1309
+ ] : ref ? [3, ref] : void 0,
1310
+ token,
1311
+ selector,
1312
+ atRule,
1313
+ callsite: itemCallsite
1314
+ };
1315
+ if (type === 1 || type === 8) {
1316
+ items.push({
1317
+ ...itemData,
1318
+ type: 1
1319
+ });
1320
+ continue;
1321
+ }
1322
+ if (slotId === null) {
1323
+ logInvalidData("invalid style data", {
1324
+ property,
1325
+ style
1326
+ });
1327
+ continue;
1328
+ }
1329
+ if (type === 2) {
1330
+ items.push({
1331
+ ...itemData,
1332
+ type: 2,
1333
+ slotId
1334
+ });
1335
+ continue;
1336
+ }
1337
+ if (type === 3) {
1338
+ items.push({
1339
+ ...itemData,
1340
+ type: 3,
1341
+ slotId
1342
+ });
1343
+ continue;
1344
+ }
1345
+ logInvalidData("invalid style data", {
1346
+ property,
1347
+ style
1348
+ });
1349
+ }
1350
+ if (!items.length) return data;
1351
+ for (let i = 0, len = items.length; i < len; i++) {
1352
+ item = items[i];
1353
+ if (Array.isArray(item) || isStyleTokenOverrideData(item)) {
1354
+ logInvalidData("invalid style data", {
1355
+ item,
1356
+ style
1357
+ });
1358
+ continue;
1359
+ }
1360
+ const runtimeItem = item;
1361
+ value = runtimeItem.value;
1362
+ weight = runtimeItem.weight;
1363
+ important = runtimeItem.important;
1364
+ dedupe = getClassNameDedupe(runtimeItem.property, weight, important, runtimeItem.selector, null, runtimeItem.atRule);
1365
+ className = getAtomicClassName(runtimeItem.property, weight, important, value, runtimeItem.selector, null, runtimeItem.atRule, runtimeItem.callsite, DEV_CONFIG.isLocalClassNameEnabled, DEBUG_CONFIG.isDebugClassNameEnabled, CSS_CONFIG.classNameFormat ?? null, runtimeItem.transformClassName ?? null, CSS_CONFIG.transformClassNameFormat ?? null, CSS_CONFIG.sheetClassNameFormat ?? null);
1366
+ runtimeItem.dedupe = dedupe;
1367
+ runtimeItem.className = className;
1368
+ lookupIndex = lookup[dedupe];
1369
+ if (typeof lookupIndex === "number") styles[lookupIndex] = runtimeItem;
1370
+ else lookup[dedupe] = styles.push(runtimeItem) - 1;
1371
+ }
1372
+ return data;
1373
+ }
1374
+ function unwrapAuthoredStyleValue(value) {
1375
+ let weight = null;
1376
+ let important = false;
1377
+ while (true) {
1378
+ if (isStyleImportantValue(value)) {
1379
+ important = true;
1380
+ value = value.value;
1381
+ continue;
1382
+ }
1383
+ if (isStyleWeightValue(value)) {
1384
+ weight = value.weight;
1385
+ value = value.value;
1386
+ continue;
1387
+ }
1388
+ break;
1389
+ }
1390
+ return [
1391
+ value,
1392
+ weight,
1393
+ important
1394
+ ];
1395
+ }
1396
+ function combineSelectors(parent, child) {
1397
+ const parentText = getSelectorText(parent);
1398
+ const childText = getSelectorText(child);
1399
+ const priority = Math.max(getSelectorPriority(parent), getSelectorPriority(child));
1400
+ const selector = parentText + childText;
1401
+ return priority > 0 ? [selector, priority] : selector;
1402
+ }
1403
+ function getSelectorText(selector) {
1404
+ return Array.isArray(selector) ? selector[0] : selector;
1405
+ }
1406
+ function getSelectorPriority(selector) {
1407
+ return Array.isArray(selector) ? selector[1] : 0;
1408
+ }
1409
+ function getMergedStyleDebug(debug, item) {
1410
+ if (!debug) return null;
1411
+ if (debug.fields?.[item.property]) return debug;
1412
+ const valueLoc = getMergedItemValueLoc(item);
1413
+ if (!valueLoc) return debug;
1414
+ return {
1415
+ ...debug,
1416
+ fields: {
1417
+ ...debug.fields,
1418
+ [item.property]: {
1419
+ [0]: withDebugSource(debug.loc, debug),
1420
+ [1]: valueLoc
1421
+ }
1422
+ }
1423
+ };
1424
+ }
1425
+ function getMergedItemValueLoc(item) {
1426
+ if (item.debug && item.debugField) {
1427
+ const loc = item.debug.fields?.[item.debugField];
1428
+ if (Array.isArray(loc)) return withDebugSource(loc, item.debug);
1429
+ if (loc) {
1430
+ const traceLoc = loc[1] ?? loc[0] ?? null;
1431
+ return traceLoc ? withDebugSource(traceLoc, item.debug) : null;
1432
+ }
1433
+ }
1434
+ return item.callsite ? [
1435
+ item.callsite.line,
1436
+ item.callsite.column,
1437
+ void 0,
1438
+ item.callsite.sourceUrl,
1439
+ item.callsite.sourceContent
1440
+ ] : null;
1441
+ }
1442
+ function withDebugSource(loc, debug) {
1443
+ return loc[3] ? loc : [
1444
+ loc[0],
1445
+ loc[1],
1446
+ loc[2],
1447
+ debug.sourceUrl,
1448
+ debug.code
1449
+ ];
1450
+ }
1451
+ //#endregion
1452
+ //#region builder/data/selector.ts
1453
+ const SELECTOR_MEDIA = "@media";
1454
+ const SELECTOR_CONTAINER = "@container";
1455
+ function normalizeSelectorArg(arg) {
1456
+ return arg.includes("\n") ? arg.replace(/\n/g, "") : arg;
1457
+ }
1458
+ //#endregion
1459
+ //#region builder/style_data.ts
1460
+ const mergeStyleCreate = (callsite) => {
1461
+ return createStyleData(callsite);
1462
+ };
1463
+ const mergeStyleData = createMerge(mergeStyleCreate, 1);
1464
+ const mergeSheetCreate = (callsite) => {
1465
+ return createSheetData(callsite);
1466
+ };
1467
+ const mergeSheetData = createMerge(mergeSheetCreate, 1);
1468
+ const mergeSlotCreate = (callsite, data) => {
1469
+ return createSlotData(callsite, data[BUILDER_SLOT_ID]);
1470
+ };
1471
+ const mergeSlotData = createMerge(mergeSlotCreate, 2);
1472
+ const mergeSlotOverrideCreate = (callsite, data) => {
1473
+ return createSlotOverrideData(callsite, data[BUILDER_SLOT_ID]);
1474
+ };
1475
+ const mergeSlotOverrideData = createMerge(mergeSlotOverrideCreate, 3);
1476
+ const mergeSelectorOverrideCreate = (callsite, data) => {
1477
+ return createSelectorOverrideData(callsite, data[BUILDER_SELECTOR]);
1478
+ };
1479
+ const mergeSelectorOverrideData = createMerge(mergeSelectorOverrideCreate, 8);
1480
+ function createMerge(create, type) {
1481
+ return (data, callsite, style, debug, selector, atRule) => {
1482
+ return mergeBuilderData(create, callsite, data, style, debug, selector, atRule, type);
1483
+ };
1484
+ }
1485
+ //#endregion
1486
+ //#region builder/utils.ts
1487
+ const FnPrefixStyle = "style.";
1488
+ const FnPrefixSlot = "slot.";
1489
+ const FnPrefixScope = "scope.";
1490
+ const FnPrefixSelector = "selector.";
1491
+ function runtimeCallsite() {
1492
+ return traceCallsite();
1493
+ }
1494
+ function resolveCallsite(debug) {
1495
+ return debug ? getDebugCallsite(debug) : runtimeCallsite();
1496
+ }
1497
+ function transformStyle(style, transform) {
1498
+ return transform ? transform.transform(style) : style;
1499
+ }
1500
+ //#endregion
1501
+ //#region atomic/layer/layer.ts
1502
+ function compareLayerPriority(p1, p2) {
1503
+ return p1[0] - p2[0] || p1[1] - p2[1] || p1[2] - p2[2] || p1[3] - p2[3] || p1[4] - p2[4] || p1[5] - p2[5] || p1[6] - p2[6];
1504
+ }
1505
+ function createLayerNamePool() {
1506
+ const lookup = /* @__PURE__ */ new Map();
1507
+ const getLayerId = (priority) => {
1508
+ const key = priority.join("|");
1509
+ let name = lookup.get(key);
1510
+ if (name) return name;
1511
+ name = "p" + hashString(key);
1512
+ lookup.set(key, name);
1513
+ return name;
1514
+ };
1515
+ const getLayerName = (layerNamespace, priority) => {
1516
+ const layerId = getLayerId(priority);
1517
+ return layerNamespace ? layerNamespace + "." + layerId : layerId;
1518
+ };
1519
+ return {
1520
+ getLayerName,
1521
+ getLayerId
1522
+ };
1523
+ }
1524
+ function createLayerPool(layerNamespace) {
1525
+ const namePool = createLayerNamePool();
1526
+ const priorities = /* @__PURE__ */ new Map();
1527
+ const getName = (priority) => {
1528
+ const key = priority.join("|");
1529
+ if (!priorities.has(key)) priorities.set(key, priority);
1530
+ return namePool.getLayerName(layerNamespace, priority);
1531
+ };
1532
+ const getNames = () => {
1533
+ return Array.from(priorities.values()).sort(compareLayerPriority).map((priority) => namePool.getLayerName(layerNamespace, priority));
1534
+ };
1535
+ return {
1536
+ getName,
1537
+ getNames
1538
+ };
1539
+ }
1540
+ function flattenCssLayers(layers, layerNames) {
1541
+ const names = typeof layerNames === "string" ? [layerNames] : layerNames;
1542
+ return layers.flatMap((layer) => layer === "$layer" ? names : layer).filter(Boolean);
1543
+ }
1544
+ //#endregion
1545
+ //#region atomic/layer/types.ts
1546
+ const LayerDefaultLayers = [LayerPlaceholder];
1547
+ const LayerDefaultPriority = [
1548
+ 0,
1549
+ 0,
1550
+ 0,
1551
+ 0,
1552
+ 0,
1553
+ 0,
1554
+ 0
1555
+ ];
1556
+ const LayerMediaPriorities = {
1557
+ base: 0,
1558
+ media: 1,
1559
+ priorityMedia: 2
1560
+ };
1561
+ const LayerSelectorPriorities = {
1562
+ base: 0,
1563
+ parentSelector: 1,
1564
+ selector: 2,
1565
+ prioritySelector: 3
1566
+ };
1567
+ const LayerPropertyPriorities = {
1568
+ shorthand: 0,
1569
+ intermediate: 1,
1570
+ longhand: 2
1571
+ };
1572
+ //#endregion
1573
+ //#region atomic/layer/utils.ts
1574
+ function getLayerOrderCss(layers, layerNames) {
1575
+ const names = flattenCssLayers(layers, layerNames);
1576
+ if (!names.length) return "";
1577
+ return "@layer " + names.join(", ") + ";";
1578
+ }
1579
+ function getLayerBlockCss(layerName, css) {
1580
+ return "@layer " + layerName + " {" + css + "}";
1581
+ }
1582
+ //#endregion
1583
+ //#region atomic/property/types.ts
1584
+ const LONGHAND = LayerPropertyPriorities.longhand;
1585
+ const SHORTHAND = LayerPropertyPriorities.shorthand;
1586
+ const INTERMEDIATE = LayerPropertyPriorities.intermediate;
1587
+ //#endregion
1588
+ //#region atomic/property/type_maps.ts
1589
+ const animation = {
1590
+ animation: SHORTHAND,
1591
+ animationComposition: LONGHAND,
1592
+ animationDelay: LONGHAND,
1593
+ animationDirection: LONGHAND,
1594
+ animationDuration: LONGHAND,
1595
+ animationFillMode: LONGHAND,
1596
+ animationIterationCount: LONGHAND,
1597
+ animationName: LONGHAND,
1598
+ animationPlayState: LONGHAND,
1599
+ animationRange: INTERMEDIATE,
1600
+ animationRangeEnd: LONGHAND,
1601
+ animationRangeStart: LONGHAND,
1602
+ animationTimeline: LONGHAND,
1603
+ animationTimingFunction: LONGHAND
1604
+ };
1605
+ const background = {
1606
+ background: SHORTHAND,
1607
+ backgroundAttachment: LONGHAND,
1608
+ backgroundBlendMode: LONGHAND,
1609
+ backgroundClip: LONGHAND,
1610
+ backgroundColor: LONGHAND,
1611
+ backgroundImage: LONGHAND,
1612
+ backgroundOrigin: LONGHAND,
1613
+ backgroundPosition: INTERMEDIATE,
1614
+ backgroundPositionX: LONGHAND,
1615
+ backgroundPositionY: LONGHAND,
1616
+ backgroundRepeat: INTERMEDIATE,
1617
+ backgroundSize: LONGHAND
1618
+ };
1619
+ const border = {
1620
+ border: SHORTHAND,
1621
+ borderBlock: INTERMEDIATE,
1622
+ borderBlockColor: INTERMEDIATE,
1623
+ borderBlockEnd: INTERMEDIATE,
1624
+ borderBlockEndColor: LONGHAND,
1625
+ borderBlockEndStyle: LONGHAND,
1626
+ borderBlockEndWidth: LONGHAND,
1627
+ borderBlockStart: INTERMEDIATE,
1628
+ borderBlockStartColor: LONGHAND,
1629
+ borderBlockStartStyle: LONGHAND,
1630
+ borderBlockStartWidth: LONGHAND,
1631
+ borderBlockStyle: INTERMEDIATE,
1632
+ borderBlockWidth: INTERMEDIATE,
1633
+ borderBottom: INTERMEDIATE,
1634
+ borderBottomColor: LONGHAND,
1635
+ borderBottomLeftRadius: LONGHAND,
1636
+ borderBottomRightRadius: LONGHAND,
1637
+ borderBottomStyle: LONGHAND,
1638
+ borderBottomWidth: LONGHAND,
1639
+ borderColor: INTERMEDIATE,
1640
+ borderImage: INTERMEDIATE,
1641
+ borderImageOutset: LONGHAND,
1642
+ borderImageRepeat: LONGHAND,
1643
+ borderImageSlice: LONGHAND,
1644
+ borderImageSource: LONGHAND,
1645
+ borderImageWidth: LONGHAND,
1646
+ borderInline: INTERMEDIATE,
1647
+ borderInlineColor: INTERMEDIATE,
1648
+ borderInlineEnd: INTERMEDIATE,
1649
+ borderInlineEndColor: LONGHAND,
1650
+ borderInlineEndStyle: LONGHAND,
1651
+ borderInlineEndWidth: LONGHAND,
1652
+ borderInlineStart: INTERMEDIATE,
1653
+ borderInlineStartColor: LONGHAND,
1654
+ borderInlineStartStyle: LONGHAND,
1655
+ borderInlineStartWidth: LONGHAND,
1656
+ borderInlineStyle: INTERMEDIATE,
1657
+ borderInlineWidth: INTERMEDIATE,
1658
+ borderLeft: INTERMEDIATE,
1659
+ borderLeftColor: LONGHAND,
1660
+ borderLeftStyle: LONGHAND,
1661
+ borderLeftWidth: LONGHAND,
1662
+ borderRadius: SHORTHAND,
1663
+ borderEndEndRadius: LONGHAND,
1664
+ borderEndStartRadius: LONGHAND,
1665
+ borderRight: INTERMEDIATE,
1666
+ borderRightColor: LONGHAND,
1667
+ borderRightStyle: LONGHAND,
1668
+ borderRightWidth: LONGHAND,
1669
+ borderSpacing: SHORTHAND,
1670
+ borderStartEndRadius: LONGHAND,
1671
+ borderStartStartRadius: LONGHAND,
1672
+ borderStyle: INTERMEDIATE,
1673
+ borderTop: INTERMEDIATE,
1674
+ borderTopColor: LONGHAND,
1675
+ borderTopLeftRadius: LONGHAND,
1676
+ borderTopRightRadius: LONGHAND,
1677
+ borderTopStyle: LONGHAND,
1678
+ borderTopWidth: LONGHAND,
1679
+ borderWidth: INTERMEDIATE
1680
+ };
1681
+ const columns = {
1682
+ columns: SHORTHAND,
1683
+ columnCount: LONGHAND,
1684
+ columnRule: INTERMEDIATE,
1685
+ columnRuleColor: LONGHAND,
1686
+ columnRuleStyle: LONGHAND,
1687
+ columnRuleWidth: LONGHAND,
1688
+ columnWidth: LONGHAND
1689
+ };
1690
+ const containIntrinsicSize = {
1691
+ containIntrinsicSize: SHORTHAND,
1692
+ containIntrinsicBlockSize: LONGHAND,
1693
+ containIntrinsicHeight: LONGHAND,
1694
+ containIntrinsicInlineSize: LONGHAND,
1695
+ containIntrinsicWidth: LONGHAND
1696
+ };
1697
+ const container = {
1698
+ container: SHORTHAND,
1699
+ containerName: LONGHAND,
1700
+ containerType: LONGHAND
1701
+ };
1702
+ const flex = {
1703
+ flex: SHORTHAND,
1704
+ flexBasis: LONGHAND,
1705
+ flexDirection: LONGHAND,
1706
+ flexFlow: INTERMEDIATE,
1707
+ flexGrow: LONGHAND,
1708
+ flexShrink: LONGHAND,
1709
+ flexWrap: LONGHAND
1710
+ };
1711
+ const font = {
1712
+ font: SHORTHAND,
1713
+ fontFamily: LONGHAND,
1714
+ fontFeatureSettings: LONGHAND,
1715
+ fontKerning: LONGHAND,
1716
+ fontLanguageOverride: LONGHAND,
1717
+ fontOpticalSizing: LONGHAND,
1718
+ fontPalette: LONGHAND,
1719
+ fontSize: LONGHAND,
1720
+ fontSizeAdjust: LONGHAND,
1721
+ fontStretch: LONGHAND,
1722
+ fontStyle: LONGHAND,
1723
+ fontSynthesis: INTERMEDIATE,
1724
+ fontSynthesisSmallCaps: LONGHAND,
1725
+ fontSynthesisStyle: LONGHAND,
1726
+ fontSynthesisWeight: LONGHAND,
1727
+ fontVariant: INTERMEDIATE,
1728
+ fontVariantAlternates: LONGHAND,
1729
+ fontVariantCaps: LONGHAND,
1730
+ fontVariantEastAsian: LONGHAND,
1731
+ fontVariantEmoji: LONGHAND,
1732
+ fontVariantLigatures: LONGHAND,
1733
+ fontVariantNumeric: LONGHAND,
1734
+ fontVariantPosition: LONGHAND,
1735
+ fontVariationSettings: LONGHAND,
1736
+ fontWeight: LONGHAND,
1737
+ lineHeight: LONGHAND
1738
+ };
1739
+ const gap = {
1740
+ gap: SHORTHAND,
1741
+ columnGap: LONGHAND,
1742
+ rowGap: LONGHAND
1743
+ };
1744
+ const grid = {
1745
+ grid: SHORTHAND,
1746
+ gridArea: INTERMEDIATE,
1747
+ gridAutoColumns: LONGHAND,
1748
+ gridAutoFlow: LONGHAND,
1749
+ gridAutoRows: LONGHAND,
1750
+ gridColumn: INTERMEDIATE,
1751
+ gridColumnEnd: LONGHAND,
1752
+ gridColumnStart: LONGHAND,
1753
+ gridRow: INTERMEDIATE,
1754
+ gridRowEnd: LONGHAND,
1755
+ gridRowStart: LONGHAND,
1756
+ gridTemplate: INTERMEDIATE,
1757
+ gridTemplateAreas: LONGHAND,
1758
+ gridTemplateColumns: LONGHAND,
1759
+ gridTemplateRows: LONGHAND
1760
+ };
1761
+ const inset = {
1762
+ inset: SHORTHAND,
1763
+ insetBlock: INTERMEDIATE,
1764
+ insetBlockEnd: LONGHAND,
1765
+ insetBlockStart: LONGHAND,
1766
+ insetInline: INTERMEDIATE,
1767
+ insetInlineEnd: LONGHAND,
1768
+ insetInlineStart: LONGHAND,
1769
+ bottom: LONGHAND,
1770
+ left: LONGHAND,
1771
+ right: LONGHAND,
1772
+ top: LONGHAND
1773
+ };
1774
+ const listStyle = {
1775
+ listStyle: SHORTHAND,
1776
+ listStyleImage: LONGHAND,
1777
+ listStylePosition: LONGHAND,
1778
+ listStyleType: LONGHAND
1779
+ };
1780
+ const margin = {
1781
+ margin: SHORTHAND,
1782
+ marginBlock: INTERMEDIATE,
1783
+ marginBlockEnd: LONGHAND,
1784
+ marginBlockStart: LONGHAND,
1785
+ marginBottom: LONGHAND,
1786
+ marginInline: INTERMEDIATE,
1787
+ marginInlineEnd: LONGHAND,
1788
+ marginInlineStart: LONGHAND,
1789
+ marginLeft: LONGHAND,
1790
+ marginRight: LONGHAND,
1791
+ marginTop: LONGHAND
1792
+ };
1793
+ const mask = {
1794
+ mask: SHORTHAND,
1795
+ maskBorder: INTERMEDIATE,
1796
+ maskBorderMode: LONGHAND,
1797
+ maskBorderOutset: LONGHAND,
1798
+ maskBorderRepeat: LONGHAND,
1799
+ maskBorderSlice: LONGHAND,
1800
+ maskBorderSource: LONGHAND,
1801
+ maskBorderWidth: LONGHAND,
1802
+ maskClip: LONGHAND,
1803
+ maskComposite: LONGHAND,
1804
+ maskImage: LONGHAND,
1805
+ maskMode: LONGHAND,
1806
+ maskOrigin: LONGHAND,
1807
+ maskPosition: LONGHAND,
1808
+ maskRepeat: LONGHAND,
1809
+ maskSize: LONGHAND,
1810
+ maskType: LONGHAND,
1811
+ WebkitMask: SHORTHAND,
1812
+ WebkitMaskBoxImage: INTERMEDIATE,
1813
+ WebkitMaskBoxImageOutset: LONGHAND,
1814
+ WebkitMaskBoxImageRepeat: LONGHAND,
1815
+ WebkitMaskBoxImageSlice: LONGHAND,
1816
+ WebkitMaskBoxImageSource: LONGHAND,
1817
+ WebkitMaskBoxImageWidth: LONGHAND,
1818
+ WebkitMaskClip: LONGHAND,
1819
+ WebkitMaskComposite: LONGHAND,
1820
+ WebkitMaskImage: LONGHAND,
1821
+ WebkitMaskOrigin: LONGHAND,
1822
+ WebkitMaskPosition: LONGHAND,
1823
+ WebkitMaskPositionX: LONGHAND,
1824
+ WebkitMaskPositionY: LONGHAND,
1825
+ WebkitMaskRepeat: LONGHAND,
1826
+ WebkitMaskRepeatX: LONGHAND,
1827
+ WebkitMaskRepeatY: LONGHAND,
1828
+ WebkitMaskSize: LONGHAND
1829
+ };
1830
+ const offset = {
1831
+ offset: SHORTHAND,
1832
+ offsetAnchor: LONGHAND,
1833
+ offsetDistance: LONGHAND,
1834
+ offsetPath: LONGHAND,
1835
+ offsetPosition: LONGHAND,
1836
+ offsetRotate: LONGHAND
1837
+ };
1838
+ const outline = {
1839
+ outline: SHORTHAND,
1840
+ outlineColor: LONGHAND,
1841
+ outlineOffset: LONGHAND,
1842
+ outlineStyle: LONGHAND,
1843
+ outlineWidth: LONGHAND
1844
+ };
1845
+ const overflow = {
1846
+ overflow: SHORTHAND,
1847
+ overflowBlock: LONGHAND,
1848
+ overflowClipMargin: SHORTHAND,
1849
+ overflowInline: LONGHAND,
1850
+ overflowWrap: LONGHAND,
1851
+ overflowX: LONGHAND,
1852
+ overflowY: LONGHAND
1853
+ };
1854
+ const overscrollBehavior = {
1855
+ overscrollBehavior: SHORTHAND,
1856
+ overscrollBehaviorBlock: LONGHAND,
1857
+ overscrollBehaviorInline: LONGHAND,
1858
+ overscrollBehaviorX: LONGHAND,
1859
+ overscrollBehaviorY: LONGHAND
1860
+ };
1861
+ const padding = {
1862
+ padding: SHORTHAND,
1863
+ paddingBlock: INTERMEDIATE,
1864
+ paddingBlockEnd: LONGHAND,
1865
+ paddingBlockStart: LONGHAND,
1866
+ paddingBottom: LONGHAND,
1867
+ paddingInline: INTERMEDIATE,
1868
+ paddingInlineEnd: LONGHAND,
1869
+ paddingInlineStart: LONGHAND,
1870
+ paddingLeft: LONGHAND,
1871
+ paddingRight: LONGHAND,
1872
+ paddingTop: LONGHAND
1873
+ };
1874
+ const place = {
1875
+ placeContent: SHORTHAND,
1876
+ alignContent: LONGHAND,
1877
+ justifyContent: LONGHAND,
1878
+ placeItems: SHORTHAND,
1879
+ alignItems: LONGHAND,
1880
+ justifyItems: LONGHAND,
1881
+ placeSelf: SHORTHAND,
1882
+ alignSelf: LONGHAND,
1883
+ justifySelf: LONGHAND
1884
+ };
1885
+ const scrollMargin = {
1886
+ scrollMargin: SHORTHAND,
1887
+ scrollMarginBlock: INTERMEDIATE,
1888
+ scrollMarginBlockEnd: LONGHAND,
1889
+ scrollMarginBlockStart: LONGHAND,
1890
+ scrollMarginBottom: LONGHAND,
1891
+ scrollMarginInline: INTERMEDIATE,
1892
+ scrollMarginInlineEnd: LONGHAND,
1893
+ scrollMarginInlineStart: LONGHAND,
1894
+ scrollMarginLeft: LONGHAND,
1895
+ scrollMarginRight: LONGHAND,
1896
+ scrollMarginTop: LONGHAND
1897
+ };
1898
+ const scrollPadding = {
1899
+ scrollPadding: SHORTHAND,
1900
+ scrollPaddingBlock: INTERMEDIATE,
1901
+ scrollPaddingBlockEnd: LONGHAND,
1902
+ scrollPaddingBlockStart: LONGHAND,
1903
+ scrollPaddingBottom: LONGHAND,
1904
+ scrollPaddingInline: INTERMEDIATE,
1905
+ scrollPaddingInlineEnd: LONGHAND,
1906
+ scrollPaddingInlineStart: LONGHAND,
1907
+ scrollPaddingLeft: LONGHAND,
1908
+ scrollPaddingRight: LONGHAND,
1909
+ scrollPaddingTop: LONGHAND
1910
+ };
1911
+ const scrollTimeline = {
1912
+ scrollTimeline: SHORTHAND,
1913
+ scrollTimelineAxis: LONGHAND,
1914
+ scrollTimelineName: LONGHAND
1915
+ };
1916
+ const text = {
1917
+ textDecoration: SHORTHAND,
1918
+ textDecorationColor: LONGHAND,
1919
+ textDecorationLine: LONGHAND,
1920
+ textDecorationSkip: LONGHAND,
1921
+ textDecorationSkipInk: LONGHAND,
1922
+ textDecorationStyle: LONGHAND,
1923
+ textDecorationThickness: LONGHAND,
1924
+ textEmphasis: SHORTHAND,
1925
+ textEmphasisColor: LONGHAND,
1926
+ textEmphasisPosition: LONGHAND,
1927
+ textEmphasisStyle: LONGHAND
1928
+ };
1929
+ const transition = {
1930
+ transition: SHORTHAND,
1931
+ transitionBehavior: LONGHAND,
1932
+ transitionDelay: LONGHAND,
1933
+ transitionDuration: LONGHAND,
1934
+ transitionProperty: LONGHAND,
1935
+ transitionTimingFunction: LONGHAND
1936
+ };
1937
+ const viewTimeline = {
1938
+ viewTimeline: SHORTHAND,
1939
+ viewTimelineAxis: LONGHAND,
1940
+ viewTimelineInset: LONGHAND,
1941
+ viewTimelineName: LONGHAND
1942
+ };
1943
+ const whiteSpace = {
1944
+ whiteSpace: SHORTHAND,
1945
+ whiteSpaceCollapse: LONGHAND
1946
+ };
1947
+ //#endregion
1948
+ //#region atomic/property/presets.ts
1949
+ const DefaultPropertyTypes = {
1950
+ ...animation,
1951
+ ...background,
1952
+ ...border,
1953
+ ...columns,
1954
+ ...containIntrinsicSize,
1955
+ ...container,
1956
+ ...flex,
1957
+ ...font,
1958
+ ...gap,
1959
+ ...grid,
1960
+ ...inset,
1961
+ ...listStyle,
1962
+ ...margin,
1963
+ ...mask,
1964
+ ...offset,
1965
+ ...outline,
1966
+ ...overflow,
1967
+ ...overscrollBehavior,
1968
+ ...padding,
1969
+ ...place,
1970
+ ...scrollMargin,
1971
+ ...scrollPadding,
1972
+ ...scrollTimeline,
1973
+ ...text,
1974
+ ...transition,
1975
+ ...viewTimeline,
1976
+ ...whiteSpace
1977
+ };
1978
+ function getPropertyPriority(property) {
1979
+ return DefaultPropertyTypes[property] ?? 0;
1980
+ }
1981
+ function getCssPropertyName(property) {
1982
+ return property.replace(/^(webkit|moz|ms|o)([A-Z])/g, (_, prefix, c) => `-${prefix}-${c.toLowerCase()}`).replace(/[A-Z]/g, (c) => "-" + c.toLowerCase());
1983
+ }
1984
+ //#endregion
1985
+ //#region atomic/atRule/utils.ts
1986
+ function createAtRuleNameFormatter(defaultFormat, prefix) {
1987
+ const formatter = createNameFormatter(["name"]);
1988
+ return (format, id, info) => {
1989
+ const hash = getIdentifierSafeHash(id, CSS_CONFIG.hashLength);
1990
+ const name = formatter(format || defaultFormat, hash, info);
1991
+ if (!prefix) return name;
1992
+ return name.startsWith(prefix) ? name : prefix + name;
1993
+ };
1994
+ }
1995
+ function buildNamedAtRuleCss(atRule, name, descriptors, tokens, tokenLookup, tokenNameFormat) {
1996
+ return `@${atRule} ${name} {${buildAtRuleDeclarationCss(descriptors, tokens, tokenLookup, tokenNameFormat, true)}}`;
1997
+ }
1998
+ function buildAtRuleDeclarationCss(style, tokens, tokenLookup, tokenNameFormat, rawValue, shouldInclude) {
1999
+ let css = "";
2000
+ for (const property in style) {
2001
+ if (shouldInclude && !shouldInclude(property)) continue;
2002
+ let value = style[property];
2003
+ if (Array.isArray(value) && value.length === 2 && typeof value[0] === "number") value = value[1];
2004
+ if (isStyleTokenData(value)) {
2005
+ const tokenId = getStyleTokenId(value);
2006
+ if (!tokenLookup.has(tokenId)) {
2007
+ tokenLookup.add(tokenId);
2008
+ tokens.push(value);
2009
+ }
2010
+ css += `${getCssPropertyName(property)}: ${getTokenVar(value, tokenNameFormat)};`;
2011
+ continue;
2012
+ }
2013
+ const valueString = String(value ?? "");
2014
+ css += `${getCssPropertyName(property)}: ${rawValue ? valueString : getCssPropertyValue(property, valueString)};`;
2015
+ }
2016
+ return css;
2017
+ }
2018
+ //#endregion
2019
+ //#region atomic/atRule/counterStyle.ts
2020
+ const COUNTER_STYLE_AT_RULE = "counter-style";
2021
+ const formatCounterStyleName = createAtRuleNameFormatter("counter-style[-(name)]-$hash");
2022
+ function buildCounterStyleCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
2023
+ name = formatCounterStyleName(format, id, { name });
2024
+ const css = buildNamedAtRuleCss(COUNTER_STYLE_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
2025
+ return {
2026
+ name,
2027
+ css
2028
+ };
2029
+ }
2030
+ //#endregion
2031
+ //#region config/config/css_extra.ts
2032
+ const CSS_EXTRA_CONFIG_DEFAULT = { namedRuleFormat: {} };
2033
+ const CSS_EXTRA_CONFIG = globalData("config.cssExtra", () => ({ ...CSS_EXTRA_CONFIG_DEFAULT }));
2034
+ //#endregion
2035
+ //#region utils/id.ts
2036
+ function createIdCounter(name) {
2037
+ return globalData("idCounter." + name, () => ({ value: 0 }));
2038
+ }
2039
+ function getId(idCounter, stableId) {
2040
+ return stableId || {
2041
+ name: null,
2042
+ id: String(idCounter.value++)
2043
+ };
2044
+ }
2045
+ //#endregion
2046
+ //#region css/utils.ts
2047
+ function createNamedAtRuleRef(config) {
2048
+ const { id, name } = getId(config.idCounter, config.stableId || null);
2049
+ const tokens = [];
2050
+ const tokenLookup = /* @__PURE__ */ new Set();
2051
+ const css = config.buildCss(config.format || null, name, id, config.value, tokens, tokenLookup, CSS_CONFIG.tokenNameFormat || null);
2052
+ return createAtRuleRef({
2053
+ key: css.name,
2054
+ value: css.name,
2055
+ css: css.css,
2056
+ tokens: tokens.length ? tokens : void 0
2057
+ });
2058
+ }
2059
+ //#endregion
2060
+ //#region css/counterStyle.ts
2061
+ const idCounter$5 = createIdCounter("counterStyle");
2062
+ function createCounterStyle(descriptors, stableId) {
2063
+ return createNamedAtRuleRef({
2064
+ format: CSS_EXTRA_CONFIG.namedRuleFormat.counterStyle,
2065
+ buildCss: buildCounterStyleCss,
2066
+ value: descriptors,
2067
+ idCounter: idCounter$5,
2068
+ stableId
2069
+ });
2070
+ }
2071
+ //#endregion
2072
+ //#region atomic/atRule/fontFace.ts
2073
+ const FONT_FACE_AT_RULE = "font-face";
2074
+ const formatFontFaceName = createAtRuleNameFormatter("font[-(name)]-$hash");
2075
+ function buildFontFaceCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
2076
+ name = formatFontFaceName(format, id, { name });
2077
+ let css = buildAtRuleDeclarationCss(descriptors, tokens, tokenLookup, tokenNameFormat, true, (property) => property !== "fontFamily");
2078
+ css = `@${FONT_FACE_AT_RULE} { font-family: ${name}; ${css} }`;
2079
+ return {
2080
+ name,
2081
+ css
2082
+ };
2083
+ }
2084
+ //#endregion
2085
+ //#region atomic/atRule/fontSrc.ts
2086
+ function fontSrc(url, format) {
2087
+ if (typeof url !== "string") throw new Error("fontSrc url must be a static string");
2088
+ const src = `url("${escapeFontSrcPart(url)}")`;
2089
+ return format ? `${src} format("${escapeFontSrcPart(format)}")` : src;
2090
+ }
2091
+ function escapeFontSrcPart(value) {
2092
+ return value.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
2093
+ }
2094
+ //#endregion
2095
+ //#region css/fontFace.ts
2096
+ const idCounter$4 = createIdCounter("fontFace");
2097
+ function createFontFace(descriptors, stableId) {
2098
+ if (typeof descriptors.src !== "string") throw new Error("createFontFace \"src\" must be a static string");
2099
+ return createNamedAtRuleRef({
2100
+ format: CSS_EXTRA_CONFIG.namedRuleFormat.fontFace,
2101
+ buildCss: buildFontFaceCss,
2102
+ value: descriptors,
2103
+ idCounter: idCounter$4,
2104
+ stableId
2105
+ });
2106
+ }
2107
+ //#endregion
2108
+ //#region atomic/atRule/fontPaletteValues.ts
2109
+ const FONT_PALETTE_VALUES_AT_RULE = "font-palette-values";
2110
+ const formatFontPaletteValuesName = createAtRuleNameFormatter("font-palettle[-(name)]-$hash", "--");
2111
+ function buildFontPaletteValuesCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
2112
+ name = formatFontPaletteValuesName(format, id, { name });
2113
+ const css = buildNamedAtRuleCss(FONT_PALETTE_VALUES_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
2114
+ return {
2115
+ name,
2116
+ css
2117
+ };
2118
+ }
2119
+ //#endregion
2120
+ //#region css/fontPaletteValues.ts
2121
+ const idCounter$3 = createIdCounter("fontPaletteValues");
2122
+ function createFontPaletteValues(descriptors, stableId) {
2123
+ return createNamedAtRuleRef({
2124
+ format: CSS_EXTRA_CONFIG.namedRuleFormat.fontPaletteValues,
2125
+ buildCss: buildFontPaletteValuesCss,
2126
+ value: descriptors,
2127
+ idCounter: idCounter$3,
2128
+ stableId
2129
+ });
2130
+ }
2131
+ //#endregion
2132
+ //#region atomic/atRule/keyframes.ts
2133
+ const KEYFRAMES_AT_RULE = "keyframes";
2134
+ const formatKeyFramesName = createAtRuleNameFormatter("keyframes[-(name)]-$hash");
2135
+ function buildKeyframesCss(format, name, id, frames, tokens, tokenLookup, tokenNameFormat) {
2136
+ name = formatKeyFramesName(format, id, { name });
2137
+ let css = `@${KEYFRAMES_AT_RULE} ${name} {`;
2138
+ for (const selector in frames) {
2139
+ const frame = frames[selector];
2140
+ if (!frame) continue;
2141
+ css += selector + "{";
2142
+ css += buildAtRuleDeclarationCss(frame, tokens, tokenLookup, tokenNameFormat, false);
2143
+ css += "}";
2144
+ }
2145
+ css += "}";
2146
+ return {
2147
+ name,
2148
+ css
2149
+ };
2150
+ }
2151
+ //#endregion
2152
+ //#region css/keyframes.ts
2153
+ const idCounter$2 = createIdCounter("keyframes");
2154
+ function createKeyframes(frames, stableId) {
2155
+ return createNamedAtRuleRef({
2156
+ format: CSS_EXTRA_CONFIG.namedRuleFormat.keyframes,
2157
+ buildCss: buildKeyframesCss,
2158
+ value: frames,
2159
+ idCounter: idCounter$2,
2160
+ stableId
2161
+ });
2162
+ }
2163
+ //#endregion
2164
+ //#region atomic/atRule/positionTry.ts
2165
+ const POSITION_TRY_AT_RULE = "position-try";
2166
+ const formatPositionTryName = createAtRuleNameFormatter("position-try[-(name)]-$hash", "--");
2167
+ function buildPositionTryCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
2168
+ name = formatPositionTryName(format, id, { name });
2169
+ const css = buildNamedAtRuleCss(POSITION_TRY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat);
2170
+ return {
2171
+ name,
2172
+ css
2173
+ };
2174
+ }
2175
+ //#endregion
2176
+ //#region css/positionTry.ts
2177
+ const idCounter$1 = createIdCounter("positionTry");
2178
+ function createPositionTry(descriptors, stableId) {
2179
+ return createNamedAtRuleRef({
2180
+ format: CSS_EXTRA_CONFIG.namedRuleFormat.positionTry,
2181
+ buildCss: buildPositionTryCss,
2182
+ value: descriptors,
2183
+ idCounter: idCounter$1,
2184
+ stableId
2185
+ });
2186
+ }
2187
+ //#endregion
2188
+ //#region atomic/atRule/property.ts
2189
+ const PROPERTY_AT_RULE = "property";
2190
+ const formatPropertyName = createAtRuleNameFormatter("[-(name)]-$hash", "--");
2191
+ function buildPropertyCss(format, name, id, descriptors, tokens, tokenLookup, tokenNameFormat) {
2192
+ name = formatPropertyName(format, id, { name });
2193
+ return {
2194
+ css: buildNamedAtRuleCss(PROPERTY_AT_RULE, name, descriptors, tokens, tokenLookup, tokenNameFormat),
2195
+ name
2196
+ };
2197
+ }
2198
+ //#endregion
2199
+ //#region css/property.ts
2200
+ const idCounter = createIdCounter("property");
2201
+ function createProperty(nameOrDescriptors, descriptorsOrStableId) {
2202
+ const descriptors = typeof nameOrDescriptors === "string" ? descriptorsOrStableId : nameOrDescriptors;
2203
+ return createNamedAtRuleRef({
2204
+ idCounter,
2205
+ stableId: typeof nameOrDescriptors === "string" ? {
2206
+ name: nameOrDescriptors,
2207
+ id: nameOrDescriptors
2208
+ } : descriptorsOrStableId,
2209
+ format: CSS_EXTRA_CONFIG.namedRuleFormat.property,
2210
+ value: descriptors,
2211
+ buildCss: buildPropertyCss
2212
+ });
2213
+ }
2214
+ //#endregion
2215
+ //#region css/sheet.ts
2216
+ function createSheet(items, debug) {
2217
+ const callsite = resolveCallsite(debug);
2218
+ let data = createSheetData(callsite);
2219
+ if (items) data = mergeSheetItems(data, callsite, items);
2220
+ return data;
2221
+ }
2222
+ function mergeSheetItems(data, callsite, items) {
2223
+ if (!items) return data;
2224
+ if (Array.isArray(items)) {
2225
+ let next = data;
2226
+ for (let i = 0, len = items.length; i < len; i++) next = mergeSheetItems(next, callsite, items[i]);
2227
+ return next;
2228
+ }
2229
+ if (isStyleTokenOverrideData(items)) {
2230
+ addSheetTokenOverride(data, items);
2231
+ return data;
2232
+ }
2233
+ if (!isSelectorData(items) && !isSelectorOverrideData(items)) throw new Error("createSheet(items) requires selector items from style.selector(...) or token overrides");
2234
+ const selectorItem = items;
2235
+ const selectors = getSelectorSelectors(selectorItem);
2236
+ let next = data;
2237
+ if (isSelectorData(selectorItem)) return next;
2238
+ for (let i = 0, len = selectors.length; i < len; i++) next = mergeSheetData(next, callsite, getSelectorItemStyleData(selectorItem), null, selectors[i], null);
2239
+ return next;
2240
+ }
2241
+ function addSheetTokenOverride(data, item) {
2242
+ const state = data[BUILDER_STATE];
2243
+ const lookup = state.lookup ??= {};
2244
+ const lookupKey = getSheetTokenLookupKey(getStyleTokenId(item));
2245
+ const lookupIndex = lookup[lookupKey];
2246
+ if (typeof lookupIndex === "number") state.items[lookupIndex] = item;
2247
+ else lookup[lookupKey] = state.items.push(item) - 1;
2248
+ }
2249
+ function getSelectorItemStyleData(data) {
2250
+ return {
2251
+ [BUILDER_TYPE]: 1,
2252
+ [BUILDER_STATE]: data[BUILDER_STATE],
2253
+ [BUILDER_CALLSITE]: data[BUILDER_CALLSITE]
2254
+ };
2255
+ }
2256
+ function getSheetTokenLookupKey(tokenId) {
2257
+ return "token\0" + tokenId;
2258
+ }
2259
+ //#endregion
2260
+ //#region runtime/env.ts
2261
+ const IS_SERVER_RUNTIME = typeof window === "undefined";
2262
+ function isServerRSC() {
2263
+ return RUNTIME_CONFIG.isRSC && IS_SERVER_RUNTIME;
2264
+ }
2265
+ //#endregion
2266
+ //#region sheet/utils/dom.ts
2267
+ function resolveDocument(documentOverride) {
2268
+ if (documentOverride !== void 0) return documentOverride;
2269
+ if (typeof document === "undefined") return null;
2270
+ return document;
2271
+ }
2272
+ function createStyleTag(document, name, nonce = DEV_CONFIG.sheetStyleTagNonce) {
2273
+ const tag = document.createElement("style");
2274
+ tag.setAttribute("data-css-sheet", name);
2275
+ if (nonce) tag.setAttribute("nonce", nonce);
2276
+ return tag;
2277
+ }
2278
+ function appendStyleTag(document, tag) {
2279
+ (document.head || document.getElementsByTagName("head")[0] || document.documentElement).appendChild(tag);
2280
+ }
2281
+ function insertStyleTagAfter(document, tag, previous) {
2282
+ if (!previous || !previous.parentNode) {
2283
+ appendStyleTag(document, tag);
2284
+ return;
2285
+ }
2286
+ previous.parentNode.insertBefore(tag, previous.nextSibling);
2287
+ }
2288
+ function insertStyleTagAtTop(document, tag) {
2289
+ const head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
2290
+ const first = getFirstCssSheetTag(head);
2291
+ if (first) head.insertBefore(tag, first);
2292
+ else head.appendChild(tag);
2293
+ }
2294
+ function getFirstCssSheetTag(head) {
2295
+ const nodes = head.childNodes;
2296
+ for (let i = 0, len = nodes.length; i < len; i++) {
2297
+ const node = nodes[i];
2298
+ if (typeof node.getAttribute !== "function") continue;
2299
+ if (node.getAttribute("data-css-sheet")) return node;
2300
+ }
2301
+ return null;
2302
+ }
2303
+ //#endregion
2304
+ //#region sheet/utils/layer.ts
2305
+ function createSheetLayerState() {
2306
+ return createLayerPool(getStyleLayerName());
2307
+ }
2308
+ function getSheetRulePriority(priority) {
2309
+ return priority ?? LayerDefaultPriority;
2310
+ }
2311
+ function getStyleLayerName() {
2312
+ return CSS_CONFIG.layerNamespace || "css";
2313
+ }
2314
+ //#endregion
2315
+ //#region sheet/utils/noop.ts
2316
+ const noopSheet = {
2317
+ updateLayers() {},
2318
+ insert() {},
2319
+ flush() {}
2320
+ };
2321
+ function createNoopSheet() {
2322
+ return noopSheet;
2323
+ }
2324
+ //#endregion
2325
+ //#region sheet/utils/rule.ts
2326
+ function normalizeRule(rule) {
2327
+ return typeof rule === "string" ? rule : rule.css;
2328
+ }
2329
+ //#endregion
2330
+ //#region sheet/utils/sourcemap.ts
2331
+ const VLQ_BASE_SHIFT = 5;
2332
+ const VLQ_BASE = 1 << VLQ_BASE_SHIFT;
2333
+ const VLQ_BASE_MASK = VLQ_BASE - 1;
2334
+ const VLQ_CONTINUATION_BIT = VLQ_BASE;
2335
+ const BASE64 = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/";
2336
+ const SOURCE_URL_PREFIX = "source://";
2337
+ function createSourceMapComment$1(rules) {
2338
+ const sources = [];
2339
+ const sourceLookup = Object.create(null);
2340
+ let generatedLine = 0;
2341
+ let previousSource = 0;
2342
+ let previousOriginalLine = 0;
2343
+ let previousOriginalColumn = 0;
2344
+ const mappingLines = [];
2345
+ for (let i = 0, len = rules.length; i < len; i++) {
2346
+ const rule = rules[i];
2347
+ const sourceData = rule.source;
2348
+ let mapping = "";
2349
+ if (sourceData) {
2350
+ const source = getSource(sources, sourceLookup, getSourceMapSourceUrl(sourceData), sourceData.sourceContent);
2351
+ const originalLine = Math.max(sourceData.line - 1, 0);
2352
+ const originalColumn = Math.max(sourceData.column - 1, 0);
2353
+ mapping += encodeVlq(0);
2354
+ mapping += encodeVlq(source.sourceIndex - previousSource);
2355
+ mapping += encodeVlq(originalLine - previousOriginalLine);
2356
+ mapping += encodeVlq(originalColumn - previousOriginalColumn);
2357
+ previousSource = source.sourceIndex;
2358
+ previousOriginalLine = originalLine;
2359
+ previousOriginalColumn = originalColumn;
2360
+ }
2361
+ mappingLines[generatedLine] = mapping;
2362
+ const lineCount = getLineCount(rule.css);
2363
+ for (let j = 1; j < lineCount; j++) mappingLines[generatedLine + j] = "";
2364
+ generatedLine += lineCount;
2365
+ }
2366
+ if (!sources.length) return "";
2367
+ const data = {
2368
+ version: 3,
2369
+ sources: sources.map((source) => source.filePath),
2370
+ sourcesContent: sources.some((source) => source.sourceContent !== void 0) ? sources.map((source) => source.sourceContent ?? null) : void 0,
2371
+ names: [],
2372
+ mappings: mappingLines.join(";")
2373
+ };
2374
+ return "/*# sourceMappingURL=data:application/json;charset=utf-8;base64," + encodeBase64(JSON.stringify(data)) + " */";
2375
+ }
2376
+ function encodeBase64(text) {
2377
+ const bytes = new TextEncoder().encode(text);
2378
+ let binary = "";
2379
+ for (let i = 0, len = bytes.length; i < len; i++) binary += String.fromCharCode(bytes[i]);
2380
+ return btoa(binary);
2381
+ }
2382
+ function getSource(sources, sourceLookup, filePath, sourceContent) {
2383
+ let source = sourceLookup[filePath];
2384
+ if (source) {
2385
+ if (source.sourceContent === void 0) source.sourceContent = sourceContent;
2386
+ return source;
2387
+ }
2388
+ source = {
2389
+ filePath,
2390
+ sourceIndex: sources.length,
2391
+ sourceContent
2392
+ };
2393
+ sources.push(source);
2394
+ sourceLookup[filePath] = source;
2395
+ return source;
2396
+ }
2397
+ function normalizeSourcePath(filePath) {
2398
+ filePath = normalizeCallsiteSourceUrl(filePath);
2399
+ const atIndex = filePath.indexOf("/at ");
2400
+ if (atIndex !== -1) return filePath.slice(atIndex + 4);
2401
+ return filePath.replace(/^at\s+/, "");
2402
+ }
2403
+ function getSourceMapSourceUrl(sourceData) {
2404
+ const sourceUrl = sourceData.sourceUrl || sourceData.filePath;
2405
+ if (sourceData.sourceContent !== void 0) return normalizeSourcePath(sourceUrl);
2406
+ return normalizeSourcePath(resolveSidecarSourceUrl(sourceUrl));
2407
+ }
2408
+ function resolveSidecarSourceUrl(sourceUrl) {
2409
+ const sidecarUrl = getSidecarUrl();
2410
+ if (!sidecarUrl) return sourceUrl;
2411
+ return joinSourceUrl(sidecarUrl, getSourceUrlPath(sourceUrl));
2412
+ }
2413
+ function getSidecarUrl() {
2414
+ const value = globalThis[Symbol.for(SIDECAR_URL_GLOBAL_SYMBOL)];
2415
+ return typeof value === "string" && value ? value : null;
2416
+ }
2417
+ function getSourceUrlPath(sourceUrl) {
2418
+ if (sourceUrl.startsWith(SOURCE_URL_PREFIX)) return sourceUrl.slice(9).replace(/^\/+/, "");
2419
+ try {
2420
+ return new URL(sourceUrl).pathname.replace(/^\/+/, "");
2421
+ } catch {
2422
+ return sourceUrl.replace(/^[a-zA-Z][a-zA-Z\d+.-]*:\/+/, "").replace(/^\/+/, "");
2423
+ }
2424
+ }
2425
+ function joinSourceUrl(baseUrl, sourcePath) {
2426
+ const base = baseUrl.replace(/\/+$/, "");
2427
+ const path = sourcePath.replace(/^\/+/, "");
2428
+ return path ? `${base}/${path}` : base;
2429
+ }
2430
+ function getLineCount(css) {
2431
+ let count = 1;
2432
+ for (let i = 0, len = css.length; i < len; i++) if (css.charCodeAt(i) === 10) count++;
2433
+ return count;
2434
+ }
2435
+ function encodeVlq(value) {
2436
+ let vlq = value < 0 ? (-value << 1) + 1 : value << 1;
2437
+ let encoded = "";
2438
+ do {
2439
+ let digit = vlq & VLQ_BASE_MASK;
2440
+ vlq >>>= VLQ_BASE_SHIFT;
2441
+ if (vlq > 0) digit |= VLQ_CONTINUATION_BIT;
2442
+ encoded += BASE64[digit];
2443
+ } while (vlq > 0);
2444
+ return encoded;
2445
+ }
2446
+ //#endregion
2447
+ //#region sheet/sourcemap.ts
2448
+ function getRuleCallsite(callsite, debug, debugField) {
2449
+ if (debug && debugField) {
2450
+ const loc = getDebugFieldLoc(debug, debugField);
2451
+ if (loc) return normalizeRuleCallsite({
2452
+ filePath: loc[3] ?? debug.sourceUrl,
2453
+ sourceUrl: loc[3] ?? debug.sourceUrl,
2454
+ sourceContent: loc[4] ?? debug.code,
2455
+ line: loc[0],
2456
+ column: loc[1]
2457
+ });
2458
+ }
2459
+ if (callsite) return normalizeRuleCallsite(callsite);
2460
+ if (debug) return normalizeRuleCallsite({
2461
+ filePath: debug.sourceUrl,
2462
+ sourceUrl: debug.sourceUrl,
2463
+ sourceContent: debug.code,
2464
+ line: debug.loc[0],
2465
+ column: debug.loc[1]
2466
+ });
2467
+ return callsite || null;
2468
+ }
2469
+ function normalizeRuleCallsite(callsite) {
2470
+ return {
2471
+ ...callsite,
2472
+ filePath: normalizeCallsiteSourceUrl(callsite.filePath),
2473
+ sourceUrl: callsite.sourceUrl ? normalizeCallsiteSourceUrl(callsite.sourceUrl) : callsite.sourceUrl
2474
+ };
2475
+ }
2476
+ function createSourceMapComment(rules) {
2477
+ return createSourceMapComment$1(rules.map((rule) => ({
2478
+ css: rule.css,
2479
+ source: getSourcemapRuleCallsite(rule)
2480
+ })));
2481
+ }
2482
+ function getSourcemapRuleCallsite(rule) {
2483
+ return getRuleCallsite(rule.callsite, rule.debug, rule.debugField);
2484
+ }
2485
+ //#endregion
2486
+ //#region sheet/dev/utils.ts
2487
+ const SOURCEMAP_TAGS = globalData("sheet.dev.sourcemapTags", () => []);
2488
+ function pruneDevSourcemapTags() {
2489
+ for (let i = SOURCEMAP_TAGS.length - 1; i >= 0; i--) if (!SOURCEMAP_TAGS[i].tag.parentNode) SOURCEMAP_TAGS.splice(i, 1);
2490
+ }
2491
+ function createDevTag(document, previous, options) {
2492
+ const tag = createStyleTag(document, options.className ?? "rules", options.nonce);
2493
+ const wrapperEndNode = options.wrapper ? document.createTextNode(options.wrapper.after) : null;
2494
+ const sourceMapNode = options.sourcemap ? document.createTextNode("") : null;
2495
+ if (options.wrapper) tag.appendChild(document.createTextNode(options.wrapper.before));
2496
+ if (wrapperEndNode) tag.appendChild(wrapperEndNode);
2497
+ if (sourceMapNode) tag.appendChild(sourceMapNode);
2498
+ if (options.before) options.before.parentNode?.insertBefore(tag, options.before);
2499
+ else if (options.top && (!previous || !previous.parentNode)) insertStyleTagAtTop(document, tag);
2500
+ else insertStyleTagAfter(document, tag, previous);
2501
+ const item = {
2502
+ tag,
2503
+ rules: [],
2504
+ sourceMapNode,
2505
+ insertBeforeNode: wrapperEndNode ?? sourceMapNode,
2506
+ count: 0,
2507
+ updateSourceMap() {
2508
+ if (!sourceMapNode) return;
2509
+ if (sourceMapNode.parentNode !== tag) tag.appendChild(sourceMapNode);
2510
+ sourceMapNode.data = "\n" + createSourceMapComment(getSourceMapRules(item.rules, options.wrapper?.sourceMapLineOffset ?? 0));
2511
+ }
2512
+ };
2513
+ if (sourceMapNode) SOURCEMAP_TAGS.push(item);
2514
+ return item;
2515
+ }
2516
+ function insertDevRule(document, item, fragment, css, rule) {
2517
+ fragment.appendChild(document.createTextNode(css + "\n"));
2518
+ item.rules.push({
2519
+ css,
2520
+ callsite: rule?.callsite ?? null,
2521
+ debug: rule?.debug ?? null,
2522
+ debugField: rule?.debugField ?? null
2523
+ });
2524
+ item.count++;
2525
+ }
2526
+ function getSourceMapRules(rules, offset) {
2527
+ if (!offset) return rules;
2528
+ const output = [];
2529
+ for (let i = 0; i < offset; i++) output.push({
2530
+ css: "",
2531
+ callsite: null
2532
+ });
2533
+ return output.concat(rules);
2534
+ }
2535
+ //#endregion
2536
+ //#region sheet/dev/dev_layer.ts
2537
+ function createDevLayerSheet(options = {}) {
2538
+ const document = resolveDocument(options.document);
2539
+ if (!document) return createNoopSheet();
2540
+ const maxRules = Math.max(options.maxRules ?? DEV_CONFIG.sheetMaxRules, 1);
2541
+ const sourcemap = options.sourcemap ?? DEV_CONFIG.isSourcemapEnabled;
2542
+ const inserted = /* @__PURE__ */ new Set();
2543
+ const layerState = createSheetLayerState();
2544
+ const tagPrefix = options.tagName ? options.tagName + " " : "";
2545
+ const rootLayer = tagPrefix === "element-marker " ? getStyleLayerName() : null;
2546
+ const layerTag = createStyleTag(document, tagPrefix + "layers", options.nonce);
2547
+ const queued = [];
2548
+ let layerText = "";
2549
+ let activeLayers = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
2550
+ let active = null;
2551
+ let lastTag = layerTag;
2552
+ if (options.top) insertStyleTagAtTop(document, layerTag);
2553
+ else insertStyleTagAfter(document, layerTag, null);
2554
+ return {
2555
+ updateLayers(layers) {
2556
+ activeLayers = layers;
2557
+ const next = getLayerOrderCss(layers, rootLayer ?? layerState.getNames());
2558
+ if (next === layerText) return;
2559
+ layerText = next;
2560
+ layerTag.textContent = next;
2561
+ },
2562
+ insert(rule) {
2563
+ const rawCss = normalizeRule(rule);
2564
+ const ruleKey = typeof rule === "string" ? null : rule.key;
2565
+ if (ruleKey && inserted.has(ruleKey)) return;
2566
+ const priority = typeof rule === "string" ? null : rule.priority;
2567
+ const layerName = rootLayer ?? layerState.getName(getSheetRulePriority(priority));
2568
+ const nextLayerText = getLayerOrderCss(activeLayers, rootLayer ?? layerState.getNames());
2569
+ if (nextLayerText !== layerText) {
2570
+ layerText = nextLayerText;
2571
+ layerTag.textContent = nextLayerText;
2572
+ }
2573
+ const css = getLayerBlockCss(layerName, rawCss);
2574
+ const key = typeof rule === "string" ? css : ruleKey;
2575
+ if (key && inserted.has(key)) return;
2576
+ if (key) inserted.add(key);
2577
+ queued.push({
2578
+ css,
2579
+ rule: typeof rule === "string" ? null : rule
2580
+ });
2581
+ },
2582
+ flush() {
2583
+ if (!queued.length) return;
2584
+ const touched = [];
2585
+ let fragment = null;
2586
+ let fragmentTag = null;
2587
+ const flushFragment = () => {
2588
+ if (!fragment || !fragmentTag) return;
2589
+ if (fragmentTag.insertBeforeNode && fragmentTag.insertBeforeNode.parentNode === fragmentTag.tag) fragmentTag.tag.insertBefore(fragment, fragmentTag.insertBeforeNode);
2590
+ else fragmentTag.tag.appendChild(fragment);
2591
+ fragment = null;
2592
+ fragmentTag = null;
2593
+ };
2594
+ for (let i = 0, len = queued.length; i < len; i++) {
2595
+ const item = queued[i];
2596
+ if (!active || active.count >= maxRules) {
2597
+ flushFragment();
2598
+ active = createDevTag(document, lastTag, {
2599
+ sourcemap,
2600
+ nonce: options.nonce,
2601
+ className: tagPrefix + "rules",
2602
+ top: options.top
2603
+ });
2604
+ lastTag = active.tag;
2605
+ }
2606
+ if (fragmentTag !== active) {
2607
+ flushFragment();
2608
+ fragmentTag = active;
2609
+ fragment = document.createDocumentFragment();
2610
+ }
2611
+ insertDevRule(document, active, fragment, item.css, item.rule);
2612
+ if (touched[touched.length - 1] !== active) touched.push(active);
2613
+ }
2614
+ flushFragment();
2615
+ queued.length = 0;
2616
+ if (!sourcemap) return;
2617
+ for (let i = 0, len = touched.length; i < len; i++) touched[i].updateSourceMap();
2618
+ }
2619
+ };
2620
+ }
2621
+ //#endregion
2622
+ //#region sheet/dev/dev_sort.ts
2623
+ function createDevSortSheet(options = {}) {
2624
+ const document = resolveDocument(options.document);
2625
+ if (!document) return createNoopSheet();
2626
+ const maxRules = Math.max(options.maxRules ?? DEV_CONFIG.sheetMaxRules, 1);
2627
+ const sourcemap = options.sourcemap ?? DEV_CONFIG.isSourcemapEnabled;
2628
+ const inserted = /* @__PURE__ */ new Set();
2629
+ const queued = [];
2630
+ const groups = [];
2631
+ const shouldLayer = CSS_CONFIG.layer !== false;
2632
+ const layerName = getStyleLayerName();
2633
+ const tagPrefix = options.tagName ? options.tagName + " " : "";
2634
+ const layerTag = shouldLayer ? createStyleTag(document, tagPrefix + "layers", options.nonce) : null;
2635
+ let activeLayers = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
2636
+ let layerText = "";
2637
+ if (layerTag) if (options.top) insertStyleTagAtTop(document, layerTag);
2638
+ else insertStyleTagAfter(document, layerTag, null);
2639
+ return {
2640
+ updateLayers(layers) {
2641
+ activeLayers = layers;
2642
+ updateLayerText();
2643
+ },
2644
+ insert(rule) {
2645
+ const css = normalizeRule(rule);
2646
+ const ruleKey = typeof rule === "string" ? null : rule.key;
2647
+ if (ruleKey && inserted.has(ruleKey)) return;
2648
+ const key = typeof rule === "string" ? css : ruleKey;
2649
+ if (key && inserted.has(key)) return;
2650
+ if (key) inserted.add(key);
2651
+ queued.push({
2652
+ css,
2653
+ rule: typeof rule === "string" ? null : rule,
2654
+ priority: getSheetRulePriority(typeof rule === "string" ? null : rule.priority)
2655
+ });
2656
+ },
2657
+ flush() {
2658
+ if (!queued.length) return;
2659
+ const touched = [];
2660
+ let fragment = null;
2661
+ let fragmentTag = null;
2662
+ const flushFragment = () => {
2663
+ if (!fragment || !fragmentTag) return;
2664
+ if (fragmentTag.insertBeforeNode && fragmentTag.insertBeforeNode.parentNode === fragmentTag.tag) fragmentTag.tag.insertBefore(fragment, fragmentTag.insertBeforeNode);
2665
+ else fragmentTag.tag.appendChild(fragment);
2666
+ fragment = null;
2667
+ fragmentTag = null;
2668
+ };
2669
+ queued.sort((a, b) => compareLayerPriority(a.priority, b.priority));
2670
+ for (let i = 0, len = queued.length; i < len; i++) {
2671
+ const item = queued[i];
2672
+ const group = ensureGroup(groups, item.priority);
2673
+ let active = group.tags[group.tags.length - 1] ?? null;
2674
+ if (!active || active.count >= maxRules) {
2675
+ flushFragment();
2676
+ active = createGroupTag(document, groups, group, {
2677
+ previous: layerTag,
2678
+ className: tagPrefix + "rules " + group.key,
2679
+ top: options.top,
2680
+ layerName: shouldLayer ? layerName : null,
2681
+ sourcemap,
2682
+ nonce: options.nonce
2683
+ });
2684
+ }
2685
+ if (fragmentTag !== active) {
2686
+ flushFragment();
2687
+ fragmentTag = active;
2688
+ fragment = document.createDocumentFragment();
2689
+ }
2690
+ insertDevRule(document, active, fragment, item.css, item.rule);
2691
+ if (touched[touched.length - 1] !== active) touched.push(active);
2692
+ }
2693
+ flushFragment();
2694
+ queued.length = 0;
2695
+ if (!sourcemap) return;
2696
+ for (let i = 0, len = touched.length; i < len; i++) touched[i].updateSourceMap();
2697
+ }
2698
+ };
2699
+ function updateLayerText() {
2700
+ if (!layerTag) return;
2701
+ const next = getLayerOrderCss(activeLayers, layerName);
2702
+ if (next === layerText) return;
2703
+ layerText = next;
2704
+ layerTag.textContent = next;
2705
+ }
2706
+ }
2707
+ function ensureGroup(groups, priority) {
2708
+ const key = getPriorityKey(priority);
2709
+ for (let i = 0, len = groups.length; i < len; i++) {
2710
+ const group = groups[i];
2711
+ const order = compareLayerPriority(priority, group.priority);
2712
+ if (order === 0) return group;
2713
+ if (order < 0) {
2714
+ const next = {
2715
+ key,
2716
+ priority,
2717
+ tags: []
2718
+ };
2719
+ groups.splice(i, 0, next);
2720
+ return next;
2721
+ }
2722
+ }
2723
+ const group = {
2724
+ key,
2725
+ priority,
2726
+ tags: []
2727
+ };
2728
+ groups.push(group);
2729
+ return group;
2730
+ }
2731
+ function createGroupTag(document, groups, group, options) {
2732
+ const previous = getPreviousTag(groups, group, options.previous);
2733
+ const before = getNextTag(groups, group);
2734
+ const item = createDevTag(document, previous, {
2735
+ ...options,
2736
+ className: options.className,
2737
+ before: before?.tag ?? null,
2738
+ top: options.top,
2739
+ wrapper: options.layerName ? {
2740
+ before: "@layer " + options.layerName + " {\n",
2741
+ after: "}\n",
2742
+ sourceMapLineOffset: 1
2743
+ } : void 0
2744
+ });
2745
+ group.tags.push(item);
2746
+ return item;
2747
+ }
2748
+ function getPreviousTag(groups, group, fallback) {
2749
+ const index = groups.indexOf(group);
2750
+ for (let i = index; i >= 0; i--) {
2751
+ const tags = groups[i].tags;
2752
+ const tag = tags[tags.length - 1];
2753
+ if (tag) return tag.tag;
2754
+ }
2755
+ return fallback;
2756
+ }
2757
+ function getNextTag(groups, group) {
2758
+ const index = groups.indexOf(group);
2759
+ for (let i = index + 1, len = groups.length; i < len; i++) {
2760
+ const tag = groups[i].tags[0];
2761
+ if (tag) return tag;
2762
+ }
2763
+ return null;
2764
+ }
2765
+ function getPriorityKey(priority) {
2766
+ return "p-" + priority.join("-").replace(/^-/, "n");
2767
+ }
2768
+ //#endregion
2769
+ //#region sheet/dev/index.ts
2770
+ const DEV_SHEETS = globalData("sheet.dev.sheets", () => /* @__PURE__ */ new Set());
2771
+ function createDevSheet(options = {}) {
2772
+ let activeMode = DEV_CONFIG.stylePriorityMode;
2773
+ let active = createDevSheetForMode(activeMode, options);
2774
+ let activeLayers = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
2775
+ const rules = [];
2776
+ const inserted = /* @__PURE__ */ new Set();
2777
+ const state = { rebuild };
2778
+ DEV_SHEETS.add(state);
2779
+ return {
2780
+ updateLayers(layers) {
2781
+ activeLayers = layers;
2782
+ active.updateLayers(layers);
2783
+ },
2784
+ insert(rule) {
2785
+ const key = getStoredRuleKey(rule);
2786
+ if (key && inserted.has(key)) return;
2787
+ if (key) inserted.add(key);
2788
+ rules.push(rule);
2789
+ active.insert(rule);
2790
+ },
2791
+ flush() {
2792
+ ensureActiveMode();
2793
+ active.flush();
2794
+ },
2795
+ destroy() {
2796
+ DEV_SHEETS.delete(state);
2797
+ removeDevSheetTags(options.document, options.tagName);
2798
+ pruneDevSourcemapTags();
2799
+ }
2800
+ };
2801
+ function ensureActiveMode() {
2802
+ if (activeMode === DEV_CONFIG.stylePriorityMode) return;
2803
+ rebuild();
2804
+ }
2805
+ function rebuild() {
2806
+ activeMode = DEV_CONFIG.stylePriorityMode;
2807
+ removeDevSheetTags(options.document, options.tagName);
2808
+ active = createDevSheetForMode(activeMode, options);
2809
+ active.updateLayers(activeLayers);
2810
+ for (let i = 0, len = rules.length; i < len; i++) active.insert(rules[i]);
2811
+ active.flush();
2812
+ }
2813
+ }
2814
+ function createDevSheetForMode(mode, options) {
2815
+ return mode === "sort" ? createDevSortSheet(options) : createDevLayerSheet(options);
2816
+ }
2817
+ function getStoredRuleKey(rule) {
2818
+ return typeof rule === "string" ? rule : rule.key ?? rule.css;
2819
+ }
2820
+ function removeDevSheetTags(documentOverride, tagName) {
2821
+ const document = documentOverride === void 0 ? typeof globalThis.document === "undefined" ? null : globalThis.document : documentOverride;
2822
+ if (!document) return;
2823
+ const head = document.head || document.getElementsByTagName("head")[0] || document.documentElement;
2824
+ const nodes = Array.from(head.childNodes);
2825
+ for (let i = 0, len = nodes.length; i < len; i++) {
2826
+ const node = nodes[i];
2827
+ if (typeof node.getAttribute !== "function") continue;
2828
+ const sheetName = node.getAttribute("data-css-sheet");
2829
+ if (!sheetName) continue;
2830
+ if (!matchesDevSheetTag(sheetName, tagName)) continue;
2831
+ node.parentNode?.removeChild(node);
2832
+ }
2833
+ pruneDevSourcemapTags();
2834
+ }
2835
+ function matchesDevSheetTag(sheetName, tagName) {
2836
+ if (tagName) return sheetName === tagName || sheetName.startsWith(tagName + " ");
2837
+ return sheetName === "layers" || sheetName === "rules" || sheetName.startsWith("rules ");
2838
+ }
2839
+ //#endregion
2840
+ //#region sheet/prod.ts
2841
+ function createProdSheet(options = {}) {
2842
+ const document = resolveDocument(options.document);
2843
+ if (!document) return createNoopSheet();
2844
+ const inserted = /* @__PURE__ */ new Set();
2845
+ const layerState = createSheetLayerState();
2846
+ let activeLayers = CSS_CONFIG.layers ?? CSS_CONFIG_DEFAULT.layers ?? [];
2847
+ let layerText = "";
2848
+ let layerTag = null;
2849
+ let ruleTag = null;
2850
+ return {
2851
+ updateLayers(layers) {
2852
+ activeLayers = layers;
2853
+ const next = getLayerOrderCss(layers, layerState.getNames());
2854
+ if (next === layerText) return;
2855
+ layerText = next;
2856
+ layerTag = ensureLayerTag(document, layerTag, options.nonce);
2857
+ layerTag.textContent = next;
2858
+ },
2859
+ insert(rule) {
2860
+ const rawCss = normalizeRule(rule);
2861
+ const ruleKey = typeof rule === "string" ? null : rule.key;
2862
+ if (ruleKey && inserted.has(ruleKey)) return;
2863
+ const priority = typeof rule === "string" ? null : rule.priority;
2864
+ const layerName = layerState.getName(getSheetRulePriority(priority));
2865
+ const nextLayerText = getLayerOrderCss(activeLayers, layerState.getNames());
2866
+ if (nextLayerText !== layerText) {
2867
+ layerText = nextLayerText;
2868
+ layerTag = ensureLayerTag(document, layerTag, options.nonce);
2869
+ layerTag.textContent = nextLayerText;
2870
+ }
2871
+ const css = getLayerBlockCss(layerName, rawCss);
2872
+ const key = typeof rule === "string" ? css : ruleKey;
2873
+ if (key && inserted.has(key)) return;
2874
+ if (key) inserted.add(key);
2875
+ const activeLayerTag = ensureLayerTag(document, layerTag, options.nonce);
2876
+ layerTag = activeLayerTag;
2877
+ if (!ruleTag) {
2878
+ ruleTag = createStyleTag(document, "rules", options.nonce);
2879
+ insertStyleTagAfter(document, ruleTag, activeLayerTag);
2880
+ }
2881
+ insertRule(ruleTag, css);
2882
+ },
2883
+ flush() {}
2884
+ };
2885
+ }
2886
+ function ensureLayerTag(document, tag, nonce) {
2887
+ if (tag) return tag;
2888
+ const next = createStyleTag(document, "layers", nonce);
2889
+ insertStyleTagAfter(document, next, null);
2890
+ return next;
2891
+ }
2892
+ function insertRule(tag, css) {
2893
+ const sheet = tag.sheet;
2894
+ if (sheet) try {
2895
+ sheet.insertRule(css, sheet.cssRules.length);
2896
+ return;
2897
+ } catch {}
2898
+ tag.appendChild(tag.ownerDocument.createTextNode(css));
2899
+ }
2900
+ //#endregion
2901
+ //#region sheet/sheet.ts
2902
+ function createStyleSheet(options = {}) {
2903
+ return options.dev ?? DEV_CONFIG.isDev ? createDevSheet(options) : createProdSheet(options);
2904
+ }
2905
+ //#endregion
2906
+ //#region runtime/sheet/global.ts
2907
+ const GLOBAL_KEY = "runtime.sheet.global";
2908
+ function getGlobalSheet() {
2909
+ return globalData(GLOBAL_KEY, () => createStyleSheet());
2910
+ }
2911
+ //#endregion
2912
+ //#region runtime/core/elementMarkerData.ts
2913
+ function splitElementMarkerStyleProp(styleProp) {
2914
+ if (isElementDebugData(styleProp)) return {
2915
+ debug: styleProp,
2916
+ styleProp: void 0
2917
+ };
2918
+ if (!Array.isArray(styleProp) || !isElementDebugData(styleProp[0])) return {
2919
+ debug: void 0,
2920
+ styleProp
2921
+ };
2922
+ return {
2923
+ debug: styleProp[0],
2924
+ styleProp: styleProp.length > 2 ? styleProp.slice(1) : styleProp[1]
2925
+ };
2926
+ }
2927
+ function isElementDebugData(value) {
2928
+ if (!value || typeof value !== "object") return false;
2929
+ return value.$$elementDebug === true;
2930
+ }
2931
+ //#endregion
2932
+ //#region runtime/core/combinedStyle.ts
2933
+ const targets = globalData("runtime.combinedStyle.targets", () => /* @__PURE__ */ new WeakMap());
2934
+ function createCombinedStyle(meta, getField) {
2935
+ const target = {
2936
+ ...meta,
2937
+ cache: Object.create(null),
2938
+ getField
2939
+ };
2940
+ const proxyTarget = {};
2941
+ const proxy = new Proxy(proxyTarget, handlers);
2942
+ targets.set(proxyTarget, target);
2943
+ targets.set(proxy, target);
2944
+ return proxy;
2945
+ }
2946
+ function isCombinedStyle(value) {
2947
+ return !!value && typeof value === "object" && targets.has(value);
2948
+ }
2949
+ function getCombinedStyleStyles(style) {
2950
+ return getTarget(style).styles;
2951
+ }
2952
+ function getCombinedStyleScopes(style) {
2953
+ return getTarget(style).scopes;
2954
+ }
2955
+ function getCombinedStyleTokens(style) {
2956
+ return getTarget(style).tokens;
2957
+ }
2958
+ const handlers = { get(proxy, prop) {
2959
+ const target = getTarget(proxy);
2960
+ if (hasOwn(target.cache, prop)) return target.cache[prop];
2961
+ const value = target.getField(target, prop);
2962
+ if (value && typeof value === "object") target.cache[prop] = value;
2963
+ return value;
2964
+ } };
2965
+ function getTarget(value) {
2966
+ const target = targets.get(value);
2967
+ if (!target) throw new Error("[fluentic-style] Expected combined style.");
2968
+ return target;
2969
+ }
2970
+ //#endregion
2971
+ //#region runtime/core/cache/tokenValues.ts
2972
+ function createMutableTokenValues(base) {
2973
+ return {
2974
+ ids: base ? base.ids.slice() : null,
2975
+ values: base ? base.values.slice() : null,
2976
+ lookup: base ? { ...base.lookup } : null,
2977
+ index: base ? createTokenIndexLookup(base.ids) : null
2978
+ };
2979
+ }
2980
+ function addTokenOverride(values, item, resolver) {
2981
+ if (!resolver.is(item)) return false;
2982
+ addTokenValue(values, resolver.id(item), resolver.value(item));
2983
+ return true;
2984
+ }
2985
+ function addTokenValue(values, id, value) {
2986
+ if (!values.ids) values.ids = [];
2987
+ if (!values.values) values.values = [];
2988
+ if (!values.lookup) values.lookup = Object.create(null);
2989
+ if (!values.index) values.index = Object.create(null);
2990
+ const ids = values.ids;
2991
+ const tokenValues = values.values;
2992
+ const lookup = values.lookup;
2993
+ const indexLookup = values.index;
2994
+ const index = indexLookup[id];
2995
+ if (index === void 0) {
2996
+ indexLookup[id] = ids.push(id) - 1;
2997
+ tokenValues.push(value);
2998
+ } else tokenValues[index] = value;
2999
+ lookup[id] = value;
3000
+ }
3001
+ function addTokenValues(values, next) {
3002
+ if (!next) return;
3003
+ for (let i = 0, len = next.ids.length; i < len; i++) addTokenValue(values, next.ids[i], next.values[i]);
3004
+ }
3005
+ function addTokenOverrides(values, overrides, resolver) {
3006
+ for (let i = 0, len = overrides.length; i < len; i++) addTokenOverride(values, overrides[i], resolver);
3007
+ }
3008
+ function finishTokenValues(base, values) {
3009
+ if (!values.ids || !values.values || !values.lookup) return null;
3010
+ if (isSameTokenValues(base, values.ids, values.values)) return base;
3011
+ return {
3012
+ ids: values.ids,
3013
+ values: values.values,
3014
+ lookup: values.lookup
3015
+ };
3016
+ }
3017
+ function mergeTokenValues(base, next) {
3018
+ if (!next) return base;
3019
+ if (!base) return next;
3020
+ const values = createMutableTokenValues(base);
3021
+ addTokenValues(values, next);
3022
+ return finishTokenValues(base, values);
3023
+ }
3024
+ function mergeTokenOverrides(base, overrides, resolver) {
3025
+ if (!overrides.length) return base;
3026
+ const values = createMutableTokenValues(base);
3027
+ addTokenOverrides(values, overrides, resolver);
3028
+ return finishTokenValues(base, values);
3029
+ }
3030
+ function createTokenIndexLookup(ids) {
3031
+ const lookup = Object.create(null);
3032
+ for (let i = 0, len = ids.length; i < len; i++) lookup[ids[i]] = i;
3033
+ return lookup;
3034
+ }
3035
+ function isSameTokenValues(base, ids, values) {
3036
+ if (!base || base.ids.length !== ids.length) return false;
3037
+ const baseLookup = base.lookup;
3038
+ for (let i = 0, len = ids.length; i < len; i++) {
3039
+ if (!hasOwn(baseLookup, ids[i])) return false;
3040
+ if (baseLookup[ids[i]] !== values[i]) return false;
3041
+ }
3042
+ return true;
3043
+ }
3044
+ globalData("runtime.directStyleItemCache", () => /* @__PURE__ */ new WeakMap());
3045
+ function isResolvedStyleItem(value) {
3046
+ return isResolvedStyleItem$1(value);
3047
+ }
3048
+ function createResolvedStyleItem(data, scopes, tokens = null) {
3049
+ return createStyleItem({
3050
+ data,
3051
+ items: resolveItems(data, scopes)
3052
+ }, tokens);
3053
+ }
3054
+ function createResolvedStyleItemFromItems(item, tokens) {
3055
+ return createStyleItem({
3056
+ data: item.data,
3057
+ items: item.items
3058
+ }, tokens);
3059
+ }
3060
+ function getStyleTokenValues(value) {
3061
+ if (isCombinedStyle(value)) return getCombinedStyleTokens(value);
3062
+ return getResolvedStyleItemTokenValues(value);
3063
+ }
3064
+ function createCombinedStyleFacade(styles, scopes) {
3065
+ return createCombinedStyle({
3066
+ styles,
3067
+ scopes,
3068
+ tokens: null
3069
+ }, getStyleField);
3070
+ }
3071
+ function createCombinedStyleTokenWrapper(style, tokens) {
3072
+ return createCombinedStyle({
3073
+ styles: getCombinedStyleStyles(style),
3074
+ scopes: getCombinedStyleScopes(style),
3075
+ tokens
3076
+ }, getTokenField(style));
3077
+ }
3078
+ const getStyleField = (meta, prop) => {
3079
+ const value = meta.styles?.[prop] ?? null;
3080
+ if (isStyleData(value) || isSheetData(value) || isSlotData(value)) return createResolvedStyleItem(value, meta.scopes);
3081
+ if (isSelectorData(value)) return value;
3082
+ if (value && typeof value === "object") return createCombinedStyleFacade(value, meta.scopes);
3083
+ return value;
3084
+ };
3085
+ function getTokenField(base) {
3086
+ return (meta, prop) => {
3087
+ const value = base?.[prop] ?? null;
3088
+ if (isResolvedStyleItem(value)) {
3089
+ const tokens = mergeTokenValues(getStyleTokenValues(value), meta.tokens);
3090
+ return createStyleItem({
3091
+ data: value.data,
3092
+ items: value.items
3093
+ }, tokens);
3094
+ }
3095
+ if (isCombinedStyle(value)) return createCombinedStyleTokenWrapper(value, meta.tokens);
3096
+ return value;
3097
+ };
3098
+ }
3099
+ function createStyleItem(item, tokens = null) {
3100
+ markResolvedStyleItem(item);
3101
+ if (tokens) setResolvedStyleItemTokenValues(item, tokens);
3102
+ return item;
3103
+ }
3104
+ function resolveItems(data, scopes) {
3105
+ const items = [];
3106
+ const stateItems = data[BUILDER_STATE]?.items ?? [];
3107
+ const slotId = isSlotData(data) ? getSlotId(data) : null;
3108
+ for (let i = 0, len = stateItems.length; i < len; i++) {
3109
+ const item = stateItems[i];
3110
+ if (Array.isArray(item)) {
3111
+ items.push(item);
3112
+ continue;
3113
+ }
3114
+ if (isStyleTokenOverrideData(item)) {
3115
+ items.push(item);
3116
+ continue;
3117
+ }
3118
+ if (slotId && item.type !== 2) continue;
3119
+ items.push(item);
3120
+ }
3121
+ if (!slotId || isSheetData(data)) return items;
3122
+ for (let i = 0, len = scopes.length; i < len; i++) {
3123
+ const boundScope = scopes[i];
3124
+ const scope = getScopeTargetScope(boundScope);
3125
+ if (!scope) continue;
3126
+ const scopeItems = scope[BUILDER_STATE]?.items;
3127
+ if (!scopeItems) continue;
3128
+ const targetSlotId = getScopeTargetSlotId(boundScope);
3129
+ for (let j = 0, len = scopeItems.length; j < len; j++) {
3130
+ const item = scopeItems[j];
3131
+ if (Array.isArray(item)) {
3132
+ if (item[1] === slotId) items.push(item);
3133
+ const hasParentSelector = isExtractedScopeParentMarker$1(item[4]) || isExtractedScopeParentMarker$1(item[5]);
3134
+ if (targetSlotId === slotId && hasParentSelector) items.push(getScopeParentItem(String(item[3])));
3135
+ continue;
3136
+ }
3137
+ if (isStyleTokenOverrideData(item)) continue;
3138
+ if (item.type !== 4) continue;
3139
+ if (item.slotId === slotId) items.push(item);
3140
+ if (item.parentSelector && targetSlotId === slotId) items.push(getScopeParentItem(item.className));
3141
+ }
3142
+ }
3143
+ return items;
3144
+ }
3145
+ function getScopeParentItem(className) {
3146
+ const parentClassName = formatScopeClassName(className);
3147
+ return [parentClassName, parentClassName];
3148
+ }
3149
+ function formatScopeClassName(className) {
3150
+ const format = CSS_CONFIG.scopeClassNameFormat;
3151
+ if (!format) return "-" + className;
3152
+ if (typeof format === "function") return format({ className });
3153
+ return format.replace(/\[|\]/g, "").replace(/\(className\)/g, className);
3154
+ }
3155
+ function isExtractedScopeParentMarker$1(value) {
3156
+ return value === 1 || value === true;
3157
+ }
3158
+ //#endregion
3159
+ //#region runtime/core/cache/itemWithResolver.ts
3160
+ function createResolvedStyleItemWithResolver(data, tokens, resolver) {
3161
+ return createResolvedStyleItem(data, [], mergeTokenValues(getDataTokenValues(data, resolver), tokens));
3162
+ }
3163
+ function getDirectStyleItemWithResolver(item, resolver) {
3164
+ return createResolvedStyleItemWithResolver(item, null, resolver);
3165
+ }
3166
+ function getDataTokenValues(data, resolver) {
3167
+ const stateItems = data[BUILDER_STATE]?.items ?? [];
3168
+ const values = createMutableTokenValues(null);
3169
+ for (let i = 0, len = stateItems.length; i < len; i++) addTokenOverride(values, stateItems[i], resolver);
3170
+ return finishTokenValues(null, values);
3171
+ }
3172
+ //#endregion
3173
+ //#region runtime/core/cache/stateItem.ts
3174
+ function getStateItemDedupe(item) {
3175
+ if (Array.isArray(item)) {
3176
+ if (typeof item[0] === "number") switch (item[0]) {
3177
+ case 1:
3178
+ case 9: return item[1];
3179
+ case 2:
3180
+ case 3:
3181
+ case 4: return item[2];
3182
+ }
3183
+ else if (typeof item[1] === "string") return item[1];
3184
+ return "";
3185
+ }
3186
+ if (isStyleTokenOverrideData(item)) return "";
3187
+ return item.dedupe;
3188
+ }
3189
+ function getStateItemClassName(item) {
3190
+ if (Array.isArray(item)) {
3191
+ if (typeof item[0] === "number") switch (item[0]) {
3192
+ case 1:
3193
+ case 9: return item[2];
3194
+ case 2:
3195
+ case 3:
3196
+ case 4: return item[3];
3197
+ }
3198
+ else return item[1];
3199
+ return "";
3200
+ }
3201
+ if (isStyleTokenOverrideData(item)) return "";
3202
+ return item.className;
3203
+ }
3204
+ function getStateItemVariableValue(item, tokens) {
3205
+ if (isStyleTokenOverrideData(item)) {
3206
+ const id = getStyleTokenId(item);
3207
+ return [getTokenVarName(item, CSS_CONFIG.tokenNameFormat ?? null), tokens && hasOwn(tokens.lookup, id) ? tokens.lookup[id] : getTokenOverrideValue(item, CSS_CONFIG.tokenNameFormat ?? null)];
3208
+ }
3209
+ const value = getStateItemValue(item);
3210
+ if (Array.isArray(value) && value[0] === 1) return [value[1], resolveMarkedVariableValue(value[2], value[3], tokens)];
3211
+ if (!Array.isArray(item) && !isStyleTokenOverrideData(item) && item.variable?.[0] === 1) return [item.variable[1], resolveMarkedVariableValue(item.variable[2], item.variable[3], tokens)];
3212
+ if (!Array.isArray(item) && !isStyleTokenOverrideData(item) && item.token) {
3213
+ if (!tokens) return null;
3214
+ const id = getStyleTokenId(item.token);
3215
+ if (!hasOwn(tokens.lookup, id)) return null;
3216
+ return [getTokenVarName(item.token, CSS_CONFIG.tokenNameFormat ?? null), tokens.lookup[id]];
3217
+ }
3218
+ return null;
3219
+ }
3220
+ function resolveMarkedVariableValue(value, valueMode, tokens) {
3221
+ return normalizeVariableValue(resolveVariableValue(value, tokens), valueMode);
3222
+ }
3223
+ function normalizeVariableValue(value, valueMode) {
3224
+ if (typeof value !== "number") return value;
3225
+ return valueMode === 1 ? value + "px" : String(value);
3226
+ }
3227
+ function getStateItemAtRuleRef(item) {
3228
+ const value = getStateItemValue(item);
3229
+ if (Array.isArray(value) && value[0] === 3) return value[1];
3230
+ if (!Array.isArray(item) && !isStyleTokenOverrideData(item) && item.variable?.[0] === 3) return item.variable[1];
3231
+ return null;
3232
+ }
3233
+ function getStateItemAtRuleRefVariables(item, tokens) {
3234
+ if (!tokens) return null;
3235
+ const refTokens = getStateItemAtRuleRef(item)?.tokens;
3236
+ if (!refTokens?.length) return null;
3237
+ const values = [];
3238
+ for (let i = 0, len = refTokens.length; i < len; i++) {
3239
+ const token = refTokens[i];
3240
+ const id = getStyleTokenId(token);
3241
+ if (!hasOwn(tokens.lookup, id)) continue;
3242
+ values.push([getTokenVarName(token, CSS_CONFIG.tokenNameFormat ?? null), tokens.lookup[id]]);
3243
+ }
3244
+ return values.length ? values : null;
3245
+ }
3246
+ function getStateItemValue(item) {
3247
+ if (Array.isArray(item)) if (typeof item[0] === "number") switch (item[0]) {
3248
+ case 1:
3249
+ case 9: return item[3];
3250
+ case 2:
3251
+ case 3: return item[4];
3252
+ case 4: return isExtractedScopeParentMarker(item[4]) ? void 0 : item[4];
3253
+ }
3254
+ else return item[2];
3255
+ }
3256
+ function isExtractedScopeParentMarker(value) {
3257
+ return value === 1 || value === true;
3258
+ }
3259
+ function resolveVariableValue(value, tokens) {
3260
+ if (isStyleTokenData(value)) return resolveTokenValue(value, tokens);
3261
+ return value;
3262
+ }
3263
+ function resolveTokenValue(token, tokens) {
3264
+ if (tokens) {
3265
+ const id = getStyleTokenId(token);
3266
+ if (hasOwn(tokens.lookup, id)) return tokens.lookup[id];
3267
+ }
3268
+ return getTokenVar(token, CSS_CONFIG.tokenNameFormat ?? null);
3269
+ }
3270
+ //#endregion
3271
+ //#region runtime/core/cache/result.ts
3272
+ const emptyStylePropResult = {
3273
+ className: "",
3274
+ style: void 0
3275
+ };
3276
+ let runId = 0;
3277
+ const dedupeRun = Object.create(null);
3278
+ const dedupeIndex = Object.create(null);
3279
+ function createStylePropResult(items, getThemeClassName) {
3280
+ runId++;
3281
+ const classNames = [];
3282
+ let style;
3283
+ for (let i = 0, len = items.length; i < len; i++) {
3284
+ const item = items[i];
3285
+ if (!isResolvedStyleItem(item)) {
3286
+ const themeClassName = getThemeClassName(item);
3287
+ if (themeClassName) classNames.push(themeClassName);
3288
+ continue;
3289
+ }
3290
+ const tokens = getStyleTokenValues(item);
3291
+ const stateItems = item.items;
3292
+ for (let j = 0, itemLen = stateItems.length; j < itemLen; j++) style = addItem(classNames, style, stateItems[j], tokens);
3293
+ }
3294
+ if (!classNames.length && !style) return emptyStylePropResult;
3295
+ return {
3296
+ className: classNames.join(" "),
3297
+ style
3298
+ };
3299
+ }
3300
+ function addItem(classNames, style, item, tokens) {
3301
+ const dedupe = getStateItemDedupe(item);
3302
+ const className = getStateItemClassName(item);
3303
+ if (!dedupe || !className) return addItemStyle(style, item, tokens);
3304
+ if (dedupeRun[dedupe] === runId) {
3305
+ classNames[dedupeIndex[dedupe]] = className;
3306
+ return addItemStyle(style, item, tokens);
3307
+ }
3308
+ dedupeRun[dedupe] = runId;
3309
+ dedupeIndex[dedupe] = classNames.push(className) - 1;
3310
+ return addItemStyle(style, item, tokens);
3311
+ }
3312
+ function addItemStyle(style, item, tokens) {
3313
+ const variableValue = getStateItemVariableValue(item, tokens);
3314
+ if (variableValue) style = setStyleValue$1(style, variableValue[0], variableValue[1]);
3315
+ const refValues = getStateItemAtRuleRefVariables(item, tokens);
3316
+ if (!refValues) return style;
3317
+ for (let i = 0, len = refValues.length; i < len; i++) style = setStyleValue$1(style, refValues[i][0], refValues[i][1]);
3318
+ return style;
3319
+ }
3320
+ function setStyleValue$1(style, name, value) {
3321
+ const next = style ?? {};
3322
+ next[name] = value;
3323
+ return next;
3324
+ }
3325
+ //#endregion
3326
+ //#region runtime/core/cache/token.ts
3327
+ const runtimeTokenValueResolver = {
3328
+ get key() {
3329
+ return CSS_CONFIG.tokenNameFormat;
3330
+ },
3331
+ is: isStyleTokenOverrideData,
3332
+ id(token) {
3333
+ return getStyleTokenId(token);
3334
+ },
3335
+ value(token) {
3336
+ return getTokenOverrideValue(token, CSS_CONFIG.tokenNameFormat ?? null);
3337
+ }
3338
+ };
3339
+ //#endregion
3340
+ //#region runtime/core/cache/prop.ts
3341
+ function resolveStylePropRuntime(styleProp) {
3342
+ if (!styleProp) return null;
3343
+ styleProp = splitElementMarkerStyleProp(styleProp).styleProp;
3344
+ if (!styleProp) return null;
3345
+ if (RUNTIME_CONFIG.runtimeCacheTTL === 0) {
3346
+ const items = collectStylePropItems(styleProp);
3347
+ return {
3348
+ items,
3349
+ result: createStylePropResult(items, getThemeClassName)
3350
+ };
3351
+ }
3352
+ let unsupportedItem;
3353
+ const tokenBindings = [];
3354
+ const cache = getStylePropCacheValue(styleProp, walkStylePropCachePath, () => warnUnsupportedStylePropItem(unsupportedItem));
3355
+ if (cache?.d) {
3356
+ if (!tokenBindings.length) return {
3357
+ items: cache.d.i,
3358
+ result: cache.d.r
3359
+ };
3360
+ return {
3361
+ items: cache.d.i,
3362
+ result: createStylePropResult(applyTokenBindings(cache.d.i, tokenBindings), getThemeClassName)
3363
+ };
3364
+ }
3365
+ const items = collectStylePropItems(styleProp, tokenBindings.length > 0);
3366
+ const data = {
3367
+ i: items,
3368
+ r: createStylePropResult(items, getThemeClassName)
3369
+ };
3370
+ if (cache) cache.d = data;
3371
+ if (!tokenBindings.length) return {
3372
+ items: data.i,
3373
+ result: data.r
3374
+ };
3375
+ return {
3376
+ items,
3377
+ result: createStylePropResult(applyTokenBindings(items, tokenBindings), getThemeClassName)
3378
+ };
3379
+ function walkStylePropCachePath(styleProp, fn, onUnsupported) {
3380
+ walkRecursiveItems(styleProp, (item) => {
3381
+ if (isElementDebugData(item)) return;
3382
+ const key = getStylePropCacheKey(item, tokenBindings);
3383
+ if (key) fn(key);
3384
+ else {
3385
+ unsupportedItem = item;
3386
+ onUnsupported();
3387
+ }
3388
+ });
3389
+ }
3390
+ }
3391
+ function walkStyleProp(styleProp, fn, options) {
3392
+ walkRecursiveItems(styleProp, (item) => {
3393
+ if (isElementDebugData(item)) return;
3394
+ const styleItem = normalizeStylePropItem(item, options?.stableTokenBound ?? false);
3395
+ if (styleItem) fn(styleItem);
3396
+ else options?.onUnsupported?.(item);
3397
+ });
3398
+ }
3399
+ function getStylePropItems(item) {
3400
+ if (isResolvedStyleItem(item)) return item.items;
3401
+ return [];
3402
+ }
3403
+ function collectStylePropItems(styleProp, stableTokenBound = false) {
3404
+ const items = [];
3405
+ walkStyleProp(styleProp, (item) => {
3406
+ items.push(item);
3407
+ }, { stableTokenBound });
3408
+ return items;
3409
+ }
3410
+ function warnUnsupportedStylePropItem(item) {
3411
+ if (!DEV_CONFIG.isDev) return;
3412
+ if (isElementDebugData(item)) return;
3413
+ if (isSlotOverrideData(item) || isScopeData(item) || isScopeTargetData(item) || isStyleTokenOverrideData(item)) {
3414
+ console.warn("[fluentic-style] Unsupported style prop value. Pass themes, scopes, slot overrides, and token overrides to combineStyle before using style prop.", item);
3415
+ return;
3416
+ }
3417
+ if (item) console.warn("[fluentic-style] Unsupported style prop value.", item);
3418
+ }
3419
+ function normalizeStylePropItem(item, stableTokenBound) {
3420
+ if (isElementDebugData(item)) return null;
3421
+ if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
3422
+ const bound = getExtractedTokenBoundData(item);
3423
+ if (stableTokenBound) return normalizeStylePropItem(bound.data, true);
3424
+ const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
3425
+ if (isStyleData(bound.data) || isSheetData(bound.data) || isSlotData(bound.data)) return createResolvedStyleItemWithResolver(bound.data, tokens, runtimeTokenValueResolver);
3426
+ return normalizeStylePropItem(bound.data, false);
3427
+ }
3428
+ if (isResolvedStyleItem(item) || isThemeData(item)) return item;
3429
+ if (isStyleData(item) || isSheetData(item) || isSlotData(item)) return getDirectStyleItemWithResolver(item, runtimeTokenValueResolver);
3430
+ return null;
3431
+ }
3432
+ function getStylePropCacheKey(item, tokenBindings) {
3433
+ if (RUNTIME_CONFIG.isHoist && isExtractedTokenBoundData(item)) {
3434
+ const bound = getExtractedTokenBoundData(item);
3435
+ const key = getStylePropCacheKey(bound.data, tokenBindings);
3436
+ const tokens = mergeTokenOverrides(null, bound.tokens, runtimeTokenValueResolver);
3437
+ if (key && tokens) tokenBindings.push({
3438
+ data: key,
3439
+ tokens
3440
+ });
3441
+ return key;
3442
+ }
3443
+ if (isResolvedStyleItem(item) || isThemeData(item) || isStyleData(item) || isSheetData(item) || isSlotData(item)) return item;
3444
+ return null;
3445
+ }
3446
+ function getThemeClassName(item) {
3447
+ return isThemeData(item) ? item.className : null;
3448
+ }
3449
+ function applyTokenBindings(items, bindings) {
3450
+ if (!bindings.length) return items.slice();
3451
+ return items.map((item) => {
3452
+ if (!isResolvedStyleItem(item)) return item;
3453
+ const tokens = getBoundTokens(item, bindings);
3454
+ if (!tokens) return item;
3455
+ return createResolvedStyleItemFromItems(item, tokens);
3456
+ });
3457
+ }
3458
+ function getBoundTokens(item, bindings) {
3459
+ let tokens = getStyleTokenValues(item);
3460
+ for (let i = 0, len = bindings.length; i < len; i++) {
3461
+ const binding = bindings[i];
3462
+ if (binding.data !== item.data && binding.data !== item) continue;
3463
+ tokens = mergeTokenValues(tokens, binding.tokens);
3464
+ }
3465
+ return tokens;
3466
+ }
3467
+ //#endregion
3468
+ //#region atomic/rule.ts
3469
+ function buildAtomicRule(className, property, value, important, selector, parentSelector, atRules, scopeClassNameFormat) {
3470
+ const cssProp = getCssPropertyName(property);
3471
+ const cssValue = getCssPropertyValue(property, value) + (important ? " !important" : "");
3472
+ const escapedClass = escapeCssIdent(className);
3473
+ const classSelector = hasSheetSelectorAnchor(selector) ? `:where(.${escapedClass})` : "." + escapedClass;
3474
+ const itemSelector = selector ? getSelectorText$1(selector) : "";
3475
+ let selectorStr = classSelector + itemSelector;
3476
+ if (parentSelector) {
3477
+ const parentWhere = `:where(${"." + escapeCssIdent(getScopeClassName(className, scopeClassNameFormat)) + getSelectorText$1(parentSelector)})`;
3478
+ selectorStr = classSelector + parentWhere + itemSelector + "," + parentWhere + " " + selectorStr;
3479
+ }
3480
+ let rule = `${selectorStr}{${cssProp}: ${cssValue}}`;
3481
+ if (atRules) for (let i = atRules.length - 1; i >= 0; i--) rule = `${getSelectorText$1(atRules[i])}{${rule}}`;
3482
+ return rule;
3483
+ }
3484
+ function getAtomicRuleLayerPriority(property, priority, selector, parentSelector, atRules, isScopeRule = false) {
3485
+ const selectorPriority = getSelectorPriority$1(selector);
3486
+ const parentSelectorPriority = getSelectorPriority$1(parentSelector);
3487
+ const atRulePriority = getAtRulePriority(atRules);
3488
+ return [
3489
+ priority ?? 0,
3490
+ getLayerSelectorPriority(selector, parentSelector, selectorPriority),
3491
+ getParentSelectorPriority(parentSelector, parentSelectorPriority),
3492
+ getMediaPriority(atRules, atRulePriority),
3493
+ atRules ? atRules.length : 0,
3494
+ isScopeRule && !parentSelector ? 1 : 0,
3495
+ getPropertyPriority(property)
3496
+ ];
3497
+ }
3498
+ function getMediaPriority(atRules, priority) {
3499
+ if (!atRules?.length) return LayerMediaPriorities.base;
3500
+ if (priority <= 0) return LayerMediaPriorities.media;
3501
+ return LayerMediaPriorities.priorityMedia + priority;
3502
+ }
3503
+ function getLayerSelectorPriority(selector, parentSelector, priority) {
3504
+ if (selector) return priority > 0 ? LayerSelectorPriorities.prioritySelector + priority : LayerSelectorPriorities.selector;
3505
+ if (parentSelector) return LayerSelectorPriorities.parentSelector;
3506
+ return LayerSelectorPriorities.base;
3507
+ }
3508
+ function getParentSelectorPriority(parentSelector, priority) {
3509
+ if (!parentSelector) return 0;
3510
+ return priority > 0 ? priority + 1 : 1;
3511
+ }
3512
+ function getAtRulePriority(atRules) {
3513
+ if (!atRules?.length) return 0;
3514
+ let priority = 0;
3515
+ for (let i = 0, len = atRules.length; i < len; i++) priority = Math.max(priority, getSelectorPriority$1(atRules[i]));
3516
+ return priority;
3517
+ }
3518
+ //#endregion
3519
+ //#region runtime/sheet/rule.ts
3520
+ function createRuntimeSheetRules(item) {
3521
+ if (Array.isArray(item)) return null;
3522
+ if (isStyleTokenOverrideData(item)) return null;
3523
+ const runtimeItem = item;
3524
+ const parentSelector = runtimeItem.type === 4 ? runtimeItem.parentSelector : null;
3525
+ const layerPriority = getAtomicRuleLayerPriority(runtimeItem.property, runtimeItem.weight, runtimeItem.selector, parentSelector, runtimeItem.atRule, runtimeItem.type === 4);
3526
+ const ruleCss = buildAtomicRule(runtimeItem.className, runtimeItem.property, runtimeItem.value, runtimeItem.important, runtimeItem.selector, parentSelector, runtimeItem.atRule, CSS_CONFIG.scopeClassNameFormat || null);
3527
+ const rule = {
3528
+ key: runtimeItem.className,
3529
+ dedupe: runtimeItem.dedupe,
3530
+ priority: layerPriority,
3531
+ css: ruleCss,
3532
+ callsite: runtimeItem.callsite,
3533
+ debug: runtimeItem.debug,
3534
+ debugField: runtimeItem.debugField
3535
+ };
3536
+ const ref = getStateItemAtRuleRef(item);
3537
+ if (!ref?.css) return [rule];
3538
+ return [{
3539
+ key: ref.key,
3540
+ dedupe: ref.key,
3541
+ priority: null,
3542
+ css: ref.css,
3543
+ callsite: runtimeItem.callsite
3544
+ }, rule];
3545
+ }
3546
+ const formatThemeName = createNameFormatter(["name"]);
3547
+ function createThemeClassName(name, id, themeNameFormat) {
3548
+ return formatThemeName(themeNameFormat || "theme[-(name)]-$hash", getIdentifierSafeHash(id, CSS_CONFIG.hashLength), { name: normalizeThemeName(name) });
3549
+ }
3550
+ function getThemeRuleCss(className, tokens, tokenNameFormat) {
3551
+ const declarations = [];
3552
+ for (let i = 0, len = tokens.length; i < len; i++) declarations.push(getThemeDeclaration(tokens[i], tokenNameFormat));
3553
+ return "." + escapeCssIdent(className) + "{" + declarations.join(";") + "}";
3554
+ }
3555
+ function getThemeDeclaration(token, tokenNameFormat) {
3556
+ const name = getTokenVarName(token, tokenNameFormat);
3557
+ const value = token.ref ? getTokenOverrideValue(token, tokenNameFormat) : escapeCssValue(String(token.value ?? ""));
3558
+ return name + ":" + value;
3559
+ }
3560
+ function normalizeThemeName(value) {
3561
+ if (!value) return null;
3562
+ value = value.trim();
3563
+ if (!value) return null;
3564
+ if (/^\d+$/.test(value)) return null;
3565
+ if (isGeneratedNameHash(value)) return null;
3566
+ const stableSuffix = value.match(/^(.+)-[a-z0-9]{7}$/);
3567
+ if (stableSuffix?.[1] && isGeneratedNameHash(value.slice(-7))) return normalizeThemeName(stableSuffix[1]);
3568
+ value = stripGenericThemePrefix(value);
3569
+ if (!value) return null;
3570
+ return value;
3571
+ }
3572
+ function stripGenericThemePrefix(value) {
3573
+ const parts = value.split("--");
3574
+ while (parts[0] === "theme" || parts[0] === "themes") parts.shift();
3575
+ value = parts.join("--");
3576
+ if (value.startsWith("theme-")) return value.slice(6);
3577
+ if (value.startsWith("themes-")) return value.slice(7);
3578
+ return value;
3579
+ }
3580
+ function isGeneratedNameHash(value) {
3581
+ return /^[a-z0-9]{7}$/.test(value) && /\d/.test(value);
3582
+ }
3583
+ //#endregion
3584
+ //#region runtime/sheet/theme.ts
3585
+ function insertRuntimeThemeRule(sheet, theme) {
3586
+ sheet.insert({
3587
+ key: theme.className,
3588
+ css: createThemeRule(theme),
3589
+ callsite: theme[BUILDER_CALLSITE]
3590
+ });
3591
+ }
3592
+ function createThemeRule(theme) {
3593
+ return getThemeRuleCss(theme.className, theme.tokens, CSS_CONFIG.tokenNameFormat || null);
3594
+ }
3595
+ //#endregion
3596
+ //#region runtime/sheet/rules.ts
3597
+ function walkStylePropItemsSheetRules(items, onRule, onTheme) {
3598
+ for (let i = 0, len = items.length; i < len; i++) walkStylePropItemSheetRules(items[i], onRule, onTheme);
3599
+ }
3600
+ function walkStylePropItemSheetRules(item, onRule, onTheme) {
3601
+ if (isThemeData(item)) {
3602
+ onTheme?.(item);
3603
+ return;
3604
+ }
3605
+ const items = getStylePropItems(item);
3606
+ for (let i = 0, len = items.length; i < len; i++) {
3607
+ const rules = createRuntimeSheetRules(items[i]);
3608
+ if (!rules) continue;
3609
+ for (let j = 0, len = rules.length; j < len; j++) onRule(rules[j]);
3610
+ }
3611
+ }
3612
+ //#endregion
3613
+ //#region runtime/sheet/insert.ts
3614
+ function insertStylePropRuntimeItems(sheet, items) {
3615
+ if (!items.length) return;
3616
+ sheet.updateLayers(CSS_CONFIG.layers || LayerDefaultLayers);
3617
+ walkStylePropItemsSheetRules(items, (rule) => sheet.insert(rule), (theme) => insertRuntimeThemeRule(sheet, theme));
3618
+ }
3619
+ const formatElementClassName = createNameFormatter(["name"]);
3620
+ function getElementClassName(label, id, elementClassNameFormat) {
3621
+ const name = sanitizeDebugName(label) || null;
3622
+ const hash = getIdentifierSafeHash(id, DEV_CONFIG.hashLength ?? CSS_CONFIG.hashLength ?? 3);
3623
+ return formatElementClassName(elementClassNameFormat || "@(name)", hash, { name });
3624
+ }
3625
+ function getElementMarkerRuleCss(className) {
3626
+ return `.${escapeCssIdent(className)}{--fluentic-element-marker:0}`;
3627
+ }
3628
+ //#endregion
3629
+ //#region runtime/sheet/element.ts
3630
+ function createElementMarkerRule(className, callsite) {
3631
+ return {
3632
+ key: `element-marker:${className}`,
3633
+ css: getElementMarkerRuleCss(className),
3634
+ callsite
3635
+ };
3636
+ }
3637
+ //#endregion
3638
+ //#region runtime/core/elementMarker.ts
3639
+ const ELEMENT_MARKER_SHEET = globalData("runtime.elementMarkerSheet", () => ({ sheet: null }));
3640
+ function createElementMarkerClassName(debug) {
3641
+ if (!DEV_CONFIG.isDev || !DEV_CONFIG.isElementClassNameEnabled) return null;
3642
+ const marker = createElementMarkerRuleFromDebug(debug);
3643
+ if (!marker) return null;
3644
+ insertElementMarkerSheetRule(marker.rule);
3645
+ return marker.className;
3646
+ }
3647
+ function insertElementMarkerSheetRule(rule, documentOverride) {
3648
+ const document = documentOverride ?? (typeof globalThis.document === "undefined" ? null : globalThis.document);
3649
+ if (!document) return;
3650
+ const className = getElementMarkerClassNameFromRule(rule);
3651
+ if (!className) return;
3652
+ const sheet = getElementMarkerSheet(document);
3653
+ sheet.classNames.add(className);
3654
+ sheet.sheet.insert(rule);
3655
+ sheet.sheet.flush();
3656
+ }
3657
+ function createElementMarkerRuleFromDebug(debug) {
3658
+ const callsite = getElementCallsite(debug);
3659
+ if (!callsite) return null;
3660
+ const className = getElementClassName(debug?.label, getElementCallsiteId(callsite), CSS_CONFIG.elementClassNameFormat || null);
3661
+ return {
3662
+ className,
3663
+ rule: createElementMarkerRule(className, callsite)
3664
+ };
3665
+ }
3666
+ function isElementMarkerRule(rule) {
3667
+ return typeof rule.key === "string" && rule.key.startsWith("element-marker:");
3668
+ }
3669
+ function getElementMarkerClassNameFromRule(rule) {
3670
+ if (!isElementMarkerRule(rule)) return null;
3671
+ return rule.key.slice(15) || null;
3672
+ }
3673
+ function getElementMarkerSheet(document) {
3674
+ const current = ELEMENT_MARKER_SHEET.sheet;
3675
+ if (current?.document === document) return current;
3676
+ const sheet = {
3677
+ document,
3678
+ sheet: createDevSheet({
3679
+ document,
3680
+ tagName: "element-marker",
3681
+ top: true
3682
+ }),
3683
+ classNames: /* @__PURE__ */ new Set()
3684
+ };
3685
+ ELEMENT_MARKER_SHEET.sheet = sheet;
3686
+ return sheet;
3687
+ }
3688
+ function getElementCallsite(debug) {
3689
+ if (debug) return {
3690
+ filePath: debug.sourceUrl,
3691
+ sourceUrl: debug.sourceUrl,
3692
+ sourceContent: debug.code,
3693
+ line: debug.loc[0],
3694
+ column: debug.loc[1]
3695
+ };
3696
+ return null;
3697
+ }
3698
+ function getElementCallsiteId(callsite) {
3699
+ return `${callsite.filePath}\n${callsite.line}:${callsite.column}`;
3700
+ }
3701
+ //#endregion
3702
+ //#region runtime/core/resolveClassNameRuntime.ts
3703
+ function resolveClassNameRuntime(styleProp, props = {}) {
3704
+ const result = createClassNameResult(props);
3705
+ const resolved = resolveStylePropRuntime(styleProp);
3706
+ if (resolved) {
3707
+ mergeResolvedClassName(result, resolved.result.className);
3708
+ mergeResolvedStyle(result, resolved.result.style);
3709
+ }
3710
+ return {
3711
+ result: finishClassNameResult(result),
3712
+ items: resolved?.items ?? []
3713
+ };
3714
+ }
3715
+ //#endregion
3716
+ //#region runtime/core/getClassName.ts
3717
+ function getClassName(styleProp, props = {}) {
3718
+ const marker = splitElementMarkerStyleProp(styleProp);
3719
+ const resolved = resolveClassNameRuntime(marker.styleProp, props);
3720
+ if (resolved.items.length) {
3721
+ if (!RUNTIME_CONFIG.isExtracted && !isServerRSC()) {
3722
+ const sheet = getGlobalSheet();
3723
+ insertStylePropRuntimeItems(sheet, resolved.items);
3724
+ sheet.flush();
3725
+ }
3726
+ }
3727
+ prependClassName$1(resolved.result, createElementMarkerClassName(marker.debug));
3728
+ return resolved.result;
3729
+ }
3730
+ function prependClassName$1(result, className) {
3731
+ if (!className) return;
3732
+ result.className = result.className ? `${className} ${result.className}` : className;
3733
+ }
3734
+ //#endregion
3735
+ //#region runtime/core/getToken.ts
3736
+ function getToken(value) {
3737
+ if (isStyleTokenData(value)) return getTokenVar(value, CSS_CONFIG.tokenNameFormat ?? null);
3738
+ return value;
3739
+ }
3740
+ //#endregion
3741
+ //#region runtime/core/createTransformElement.ts
3742
+ function createTransformElement(getClassName) {
3743
+ return ({ type, props }) => {
3744
+ if (!props || typeof type !== "string") return {
3745
+ type,
3746
+ props
3747
+ };
3748
+ if (!hasOwn(props, "css")) return {
3749
+ type,
3750
+ props
3751
+ };
3752
+ const { css, ...rest } = props;
3753
+ if (!css) return {
3754
+ type,
3755
+ props: rest
3756
+ };
3757
+ const marker = splitElementMarkerStyleProp(css);
3758
+ if (marker.styleProp) Object.assign(rest, getClassName(marker.styleProp, rest));
3759
+ prependClassName(rest, createElementMarkerClassName(marker.debug));
3760
+ return {
3761
+ type,
3762
+ props: rest
3763
+ };
3764
+ };
3765
+ }
3766
+ function prependClassName(props, className) {
3767
+ if (!className) return;
3768
+ props.className = props.className ? `${className} ${props.className}` : className;
3769
+ }
3770
+ //#endregion
3771
+ //#region runtime/core/jsx.ts
3772
+ const transformElement = createTransformElement(getClassName);
3773
+ //#endregion
3774
+ //#region css/styleTarget.ts
3775
+ const sharedTargets = /* @__PURE__ */ new WeakMap();
3776
+ function createStyleTarget() {
3777
+ const owner = {};
3778
+ const targets = /* @__PURE__ */ new Map();
3779
+ return {
3780
+ apply(target, css, options) {
3781
+ if (!target) return;
3782
+ if (options?.enabled === false) {
3783
+ clearTarget(targets, owner, target);
3784
+ return;
3785
+ }
3786
+ const result = getClassName(css);
3787
+ const classNames = new Set(result.className?.split(/\s+/).filter(Boolean) ?? []);
3788
+ const styleEntries = Object.entries(result.style ?? {});
3789
+ const signature = createSignature(classNames, styleEntries);
3790
+ const previous = targets.get(target);
3791
+ if (previous?.signature === signature) return;
3792
+ const state = previous ?? {
3793
+ classNames: /* @__PURE__ */ new Set(),
3794
+ styleValues: /* @__PURE__ */ new Map(),
3795
+ signature: ""
3796
+ };
3797
+ updateClasses(target, state.classNames, classNames);
3798
+ updateStyles(target, owner, state.styleValues, styleEntries);
3799
+ state.classNames = classNames;
3800
+ state.signature = signature;
3801
+ targets.set(target, state);
3802
+ },
3803
+ destroy() {
3804
+ targets.forEach((_, target) => clearTarget(targets, owner, target));
3805
+ }
3806
+ };
3807
+ }
3808
+ function createSignature(classNames, styleEntries) {
3809
+ let signature = [...classNames].sort().join(" ");
3810
+ for (let i = 0, len = styleEntries.length; i < len; i++) {
3811
+ const [name, value] = styleEntries[i];
3812
+ signature += `\n${name}:${String(value)}`;
3813
+ }
3814
+ return signature;
3815
+ }
3816
+ function updateClasses(target, previous, next) {
3817
+ previous.forEach((className) => {
3818
+ if (!next.has(className)) removeClassName(target, className);
3819
+ });
3820
+ next.forEach((className) => {
3821
+ if (!previous.has(className)) addClassName(target, className);
3822
+ });
3823
+ }
3824
+ function addClassName(target, className) {
3825
+ const state = getSharedTargetState(target);
3826
+ const count = state.classNames.get(className) ?? 0;
3827
+ if (count === 0) target.classList.add(className);
3828
+ state.classNames.set(className, count + 1);
3829
+ }
3830
+ function removeClassName(target, className) {
3831
+ const state = getSharedTargetState(target);
3832
+ const count = state.classNames.get(className) ?? 0;
3833
+ if (count <= 1) {
3834
+ state.classNames.delete(className);
3835
+ target.classList.remove(className);
3836
+ deleteSharedStateIfEmpty(target, state);
3837
+ return;
3838
+ }
3839
+ state.classNames.set(className, count - 1);
3840
+ }
3841
+ function updateStyles(target, owner, previousValues, nextEntries) {
3842
+ const nextNames = /* @__PURE__ */ new Set();
3843
+ for (let i = 0, len = nextEntries.length; i < len; i++) {
3844
+ const [name, value] = nextEntries[i];
3845
+ const nextValue = String(value);
3846
+ nextNames.add(name);
3847
+ if (previousValues.get(name) !== nextValue) {
3848
+ setStyleValue(target, owner, name, nextValue);
3849
+ previousValues.set(name, nextValue);
3850
+ }
3851
+ }
3852
+ previousValues.forEach((_, name) => {
3853
+ if (nextNames.has(name)) return;
3854
+ removeStyleValue(target, owner, name);
3855
+ previousValues.delete(name);
3856
+ });
3857
+ }
3858
+ function clearTarget(targets, owner, target) {
3859
+ const state = targets.get(target);
3860
+ if (!state) return;
3861
+ state.classNames.forEach((className) => removeClassName(target, className));
3862
+ state.styleValues.forEach((_, name) => {
3863
+ removeStyleValue(target, owner, name);
3864
+ });
3865
+ targets.delete(target);
3866
+ }
3867
+ function setStyleValue(target, owner, name, value) {
3868
+ const targetState = getSharedTargetState(target);
3869
+ let styleState = targetState.styleNames.get(name);
3870
+ if (!styleState) {
3871
+ styleState = {
3872
+ initialValue: target.style.getPropertyValue(name),
3873
+ owners: /* @__PURE__ */ new Map()
3874
+ };
3875
+ targetState.styleNames.set(name, styleState);
3876
+ }
3877
+ styleState.owners.delete(owner);
3878
+ styleState.owners.set(owner, value);
3879
+ target.style.setProperty(name, value);
3880
+ }
3881
+ function removeStyleValue(target, owner, name) {
3882
+ const targetState = getSharedTargetState(target);
3883
+ const styleState = targetState.styleNames.get(name);
3884
+ if (!styleState) return;
3885
+ styleState.owners.delete(owner);
3886
+ const currentValue = getLastStyleValue(styleState);
3887
+ if (currentValue !== null) {
3888
+ target.style.setProperty(name, currentValue);
3889
+ return;
3890
+ }
3891
+ targetState.styleNames.delete(name);
3892
+ restoreStyleValue(target, name, styleState.initialValue);
3893
+ deleteSharedStateIfEmpty(target, targetState);
3894
+ }
3895
+ function getLastStyleValue(styleState) {
3896
+ let value = null;
3897
+ styleState.owners.forEach((ownerValue) => {
3898
+ value = ownerValue;
3899
+ });
3900
+ return value;
3901
+ }
3902
+ function getSharedTargetState(target) {
3903
+ let state = sharedTargets.get(target);
3904
+ if (!state) {
3905
+ state = {
3906
+ classNames: /* @__PURE__ */ new Map(),
3907
+ styleNames: /* @__PURE__ */ new Map()
3908
+ };
3909
+ sharedTargets.set(target, state);
3910
+ }
3911
+ return state;
3912
+ }
3913
+ function deleteSharedStateIfEmpty(target, state) {
3914
+ if (!state.classNames.size && !state.styleNames.size) sharedTargets.delete(target);
3915
+ }
3916
+ function restoreStyleValue(target, name, value) {
3917
+ if (value) target.style.setProperty(name, value);
3918
+ else target.style.removeProperty(name);
3919
+ }
3920
+ //#endregion
3921
+ export { getStyleTokenOverrideDebug as $, FnPrefixSelector as A, setBuildConfig as At, SELECTOR_MEDIA as B, createFontPaletteValues as C, weightValue as Ct, createIdCounter as D, hashString as Dt, createCounterStyle as E, DEV_CONFIG as Et, mergeSelectorOverrideData as F, classNameTransform as G, AT_RULE_REF as H, mergeSlotData as I, styleTransform as J, classNameValue as K, mergeSlotOverrideData as L, FnPrefixStyle as M, LayerPlaceholder as Mt, resolveCallsite as N, getId as O, configureStyleRuntime as Ot, transformStyle as P, createStyleTokenOverride as Q, mergeStyleData as R, createKeyframes as S, isStyleWeightValue as St, fontSrc as T, isStyleImportantValue as Tt, createAtRuleRef as U, normalizeSelectorArg as V, isAtRuleRef as W, TOKEN_DEBUG as X, mergeScopeData as Y, createStyleToken as Z, getCombinedStyleStyles as _, createSlotOverrideData as _t, createThemeClassName as a, isScopeTargetData as at, createProperty as b, traceError as bt, createCombinedStyleTokenWrapper as c, isStyleData as ct, addTokenValues as d, isDebugData as dt, resetStyleTokenIdCounter as et, createMutableTokenValues as f, createScopeData as ft, getCombinedStyleScopes as g, createSlotData as gt, mergeTokenValues as h, createSelectorOverrideData as ht, getClassName as i, isScopeData as it, FnPrefixSlot as j, CSS_CONFIG as jt, FnPrefixScope as k, setBuildDebugClassName as kt, getStyleTokenValues as l, getDebugCallsiteId as lt, mergeTokenOverrides as m, createSelectorData as mt, transformElement as n, getScopeTargetScope as nt, runtimeTokenValueResolver as o, isSheetData as ot, finishTokenValues as p, createScopeTargetData as pt, isClassNameValue as q, getToken as r, getScopeTargetSlotId as rt, createCombinedStyleFacade as s, isSlotData as st, createStyleTarget as t, getChildStyleTokenName as tt, addTokenOverride as u, getTraceCallsiteId as ut, isCombinedStyle as v, createStyleData as vt, createFontFace as w, importantValue as wt, createPositionTry as x, traceMarker as xt, createSheet as y, createThemeData as yt, SELECTOR_CONTAINER as z };
3922
+
3923
+ //# sourceMappingURL=css-CZwrac6F.js.map