@thi.ng/meta-css 0.2.0 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -1,6 +1,6 @@
1
1
  # Change Log
2
2
 
3
- - **Last updated**: 2023-12-21T22:48:14Z
3
+ - **Last updated**: 2023-12-22T17:55:14Z
4
4
  - **Generator**: [thi.ng/monopub](https://thi.ng/monopub)
5
5
 
6
6
  All notable changes to this project will be documented in this file.
@@ -9,6 +9,13 @@ See [Conventional Commits](https://conventionalcommits.org/) for commit guidelin
9
9
  **Note:** Unlisted _patch_ versions only involve non-code or otherwise excluded changes
10
10
  and/or version bumps of transitive dependencies.
11
11
 
12
+ ## [0.3.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.3.0) (2023-12-22)
13
+
14
+ #### 🚀 Features
15
+
16
+ - update convert cmd ([d0275ce](https://github.com/thi-ng/umbrella/commit/d0275ce))
17
+ - add --eval option to convert from string arg
18
+
12
19
  ## [0.2.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.2.0) (2023-12-21)
13
20
 
14
21
  #### 🚀 Features
package/README.md CHANGED
@@ -11,15 +11,9 @@ This project is part of the
11
11
  [@thi.ng/umbrella](https://github.com/thi-ng/umbrella/) monorepo and anti-framework.
12
12
 
13
13
  - [About](#about)
14
- - [Generate CSS frameworks](#generate-css-frameworks)
15
- - [Convert meta stylesheets to CSS](#convert-meta-stylesheets-to-css)
16
- - [Including custom CSS files](#including-custom-css-files)
17
- - [Force inclusion of unreferenced classes](#force-inclusion-of-unreferenced-classes)
18
- - [Export](#export)
19
- - [Media query variations](#media-query-variations)
20
- - [Framework generation rules](#framework-generation-rules)
21
- - [Overall file structure](#overall-file-structure)
22
- - [Example spec](#example-spec)
14
+ - [Generating CSS frameworks](#generating-css-frameworks)
15
+ - [Framework generation specs & syntax](#framework-generation-specs--syntax)
16
+ - [Example generation spec](#example-generation-spec)
23
17
  - [Spec structure](#spec-structure)
24
18
  - [Variations](#variations)
25
19
  - [Parametric IDs](#parametric-ids)
@@ -27,6 +21,14 @@ This project is part of the
27
21
  - [Properties](#properties)
28
22
  - [Key value generation](#key-value-generation)
29
23
  - [Media query definitions](#media-query-definitions)
24
+ - [Converting meta stylesheets to CSS](#converting-meta-stylesheets-to-css)
25
+ - [Meta-stylesheets syntax](#meta-stylesheets-syntax)
26
+ - [Class identifiers & media query prefixes](#class-identifiers--media-query-prefixes)
27
+ - [Media query prefixes](#media-query-prefixes)
28
+ - [Including custom CSS files](#including-custom-css-files)
29
+ - [Force inclusion of unreferenced classes](#force-inclusion-of-unreferenced-classes)
30
+ - [Exporting a generated framework as CSS](#exporting-a-generated-framework-as-css)
31
+ - [Media query variations](#media-query-variations)
30
32
  - [Bundled CSS base framework](#bundled-css-base-framework)
31
33
  - [Classes by category](#classes-by-category)
32
34
  - [Media queries](#media-queries)
@@ -35,13 +37,6 @@ This project is part of the
35
37
  - [Installation](#installation)
36
38
  - [Dependencies](#dependencies)
37
39
  - [Usage examples](#usage-examples)
38
- - [CLI](#cli)
39
- - [Basic usage example](#basic-usage-example)
40
- - [Generating framework code from bundled base definitions](#generating-framework-code-from-bundled-base-definitions)
41
- - [Generating CSS from `.meta` stylesheets](#generating-css-from-meta-stylesheets)
42
- - [*.meta stylesheets](#meta-stylesheets)
43
- - [Resulting CSS output](#resulting-css-output)
44
- - [index.html](#indexhtml)
45
40
  - [Authors](#authors)
46
41
  - [License](#license)
47
42
 
@@ -56,26 +51,29 @@ CSS classes are applied is however a defining point of difference to other
56
51
  existing approaches. This readme aims to provide a thorough overview and some
57
52
  concrete usage examples...
58
53
 
59
- This package provides a CLI multi-tool to:
54
+ Note: In all cases, final CSS generation itself is handled by
55
+ [thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/blob/develop/packages/hiccup-css/)
60
56
 
61
- ### Generate CSS frameworks
57
+ **👷🏻 This is all WIP!** Also see included & linked examples for basic usage...
58
+
59
+ ## Generating CSS frameworks
62
60
 
63
61
  The `generate` command is used to generate custom frameworks with (likely)
64
62
  hundreds of CSS utility classes from a number of extremely compact, parametric
65
63
  JSON rule specs. This process generates all desired, combinatorial versions of
66
64
  various rules/declarations and exports them to another JSON file used as
67
- intermediatary for the other commands provided by this toolchain. The
68
- [syntax/format of the generator rules](#framework-generation-rules) is explained
65
+ intermediary for the other commands provided by this toolchain. The
66
+ [syntax/format of the generator rules](#framework-generation-specs--syntax) is explained
69
67
  further on. These rule specs can be split up into multiple files for better
70
68
  handling, can define [arbitrary media query criteria]() (all later combinable),
71
69
  shared lookup tables for colors, margins, sizes, timings etc.
72
70
 
73
- The package provides generator specs for a basic, fully customizable,
71
+ The package includes generator specs for a basic, fully customizable,
74
72
  [tachyons.io](https://tachyons.io)-derived [CSS
75
73
  framework](#bundled-css-base-framework). These specs and resulting framework are
76
- used for some example projects in this repo, but are mainly intended as basic
77
- starting points for creating other custom frameworks (in the hope they'll be
78
- shared back similarly)...
74
+ still being worked on and are used for some example projects in this repo, but
75
+ are mostly intended as basic starting points for creating other custom
76
+ frameworks (in the hope they'll be shared back similarly)...
79
77
 
80
78
  ```text
81
79
  metacss generate --help
@@ -93,130 +91,12 @@ Main:
93
91
  --prec INT Number of fractional digits (default: 3)
94
92
  ```
95
93
 
96
- ### Convert meta stylesheets to CSS
97
-
98
- The `convert` command is used to compile & bundle actual CSS from user-provided
99
- MetaCSS stylesheets (`*.meta` files) and the JSON framework specs created by the
100
- `generate` command. The meta-stylesheets support any CSS selectors, are nestable
101
- and compose full CSS declarations from lists of the utility classes in the
102
- generated framework.
103
-
104
- Each item (aka utility class name) can be prefixed with an arbitrary number of
105
- media query IDs (also custom defined in the framework): e.g. `dark:bg-black`
106
- might refer to a CSS class to set a black ground, with the `dark:` prefix
107
- referring to a defined media query which only applies this class when dark mode
108
- is enabled...
109
-
110
- Selectors, declarations and media query criteria will be deduplicated and merged
111
- from multiple input files. The resulting CSS will only contain referenced rules
112
- and can be generated in minified or pretty printed formats (it's also possible
113
- to force include CSS classes which are otherwise unreferenced, using the
114
- `--force` CLI arg). Additionally, multiple .meta files can be watched for
115
- changes, their definitions will be merged, and existing CSS files can be
116
- included (prepended) in the bundled outout too.
117
-
118
- ```text
119
- metacss convert --help
120
-
121
- Usage: metacss convert [opts] input [...]
122
-
123
- Flags:
124
-
125
- --no-header Don't emit generated header comment
126
- -p, --pretty Pretty print output
127
- -v, --verbose Display extra process information
128
- -w, --watch Watch input files for changes
129
-
130
- Main:
131
-
132
- --force STR[,..] [multiple] CSS classes to force include (wildcards are
133
- supported, @-prefix will read from file)
134
- -I STR, --include STR [multiple] Include CSS files (prepend)
135
- -o STR, --out STR Output file (or stdout)
136
- -s STR, --specs STR [required] Path to generated JSON defs
137
- ```
138
-
139
- #### Including custom CSS files
140
-
141
- One or more existing CSS files can be included & prepended to the output via the
142
- `--include`/`-I` arg (which can be given multiple times). These files are used
143
- verbatim and will **not** be transformed or reformatted in any way.
144
-
145
- #### Force inclusion of unreferenced classes
146
-
147
- Only the CSS classes (and their optionally associated media queries) referenced
148
- in a `.meta` stylesheet will appear in the export CSS bundle. This ensures that
149
- the resulting CSS will only contain what's actually used (same effect as
150
- tree-shaking, only vastly more efficient). However, this also means any CSS
151
- classes (and optionally, their media query qualifiers) which are otherwise
152
- referenced (e.g. from JS/TS source code or HTML docs) **will not** be included
153
- by default and they will need to be listed manually for forced inclusion.
154
-
155
- This can be achieved via the `--force`/`-f` arg (also can be given multiple
156
- times). This option also supports basic `*`-wildcard patterns, e.g. `bg-*` to
157
- include all classes with prefix `bg-`. Furthermore, for larger projects it's
158
- useful to store these names/patterns in a separate file. For that purpose, use
159
- the `@` prefix (e.g. `-f @includes.txt`) to indicate reading from file (only
160
- reading from a single file is supported at current)... See the [meta-css-basics
161
- example
162
- project](https://github.com/thi-ng/umbrella/blob/develop/examples/meta-css-basics)
163
- for concrete usage...
164
-
165
- ### Export
166
-
167
- The `export` command is intended for those who're mainly interested in the CSS
168
- framework generation aspects of this toolchain. This command merely takes an
169
- existing generated framework JSON file and serializes it to a single CSS file,
170
- e.g. to be then used with other CSS tooling (e.g. `postcss`).
171
-
172
- #### Media query variations
173
-
174
- Users can choose to generate variations of all defined utility classes for any
175
- of the framework-defined media query IDs. This will create additional suffixed
176
- versions of all classes (with their appropriate media query wrappers) and cause
177
- a potentially massive output (depending on the overall number/complexity of the
178
- generated classes). Again, the idea is that the resulting CSS file will be
179
- post-processed with 3rd party CSS tooling...
180
-
181
- For example, if the framework contains a CSS class `w-50` (e.g. to set the width
182
- to 50%) and media queries for different screen sizes (e.g. named `ns`, `l`),
183
- then the export with said media queries will also generate classes `w-50-ns`
184
- and `w-50-l` (incl. their corresponding `@media` wrappers).
185
-
186
- As with the `convert` command, additional CSS files can also be included
187
- (prepended) in the output file.
188
-
189
- ```text
190
- metacss export --help
191
-
192
- Usage: metacss export [opts] input
193
-
194
- Flags:
195
-
196
- --no-header Don't emit generated header comment
197
- -p, --pretty Pretty print output
198
- -v, --verbose Display extra process information
199
-
200
- Main:
201
-
202
- -I STR, --include STR [multiple] Include CSS files (prepend)
203
- -m STR, --media STR Media query IDs (use 'ALL' for all)
204
- -o STR, --out STR Output file (or stdout)
205
- ```
206
-
207
- Note: In all cases, final CSS generation itself is handled by
208
- [thi.ng/hiccup-css](https://github.com/thi-ng/umbrella/blob/develop/packages/hiccup-css/)
209
-
210
- **👷🏻 This is all WIP!** See example below for basic example usage...
211
-
212
- ## Framework generation rules
94
+ ### Framework generation specs & syntax
213
95
 
214
96
  This section gives an overview of the JSON format used to generate CSS
215
97
  frameworks of dozens (usually hundreds) of utility classes, including many
216
98
  possible variations (per spec).
217
99
 
218
- ### Overall file structure
219
-
220
100
  Generation specs use a simple JSON structure as shown below. The specs can be
221
101
  split over multiple files within a directory and will all be merged by the
222
102
  `generate` command of the toolchain.
@@ -244,7 +124,7 @@ split over multiple files within a directory and will all be merged by the
244
124
  }
245
125
  ```
246
126
 
247
- ### Example spec
127
+ ### Example generation spec
248
128
 
249
129
  The following generator document uses a single small generative rule spec to
250
130
  create altogether 21 utility classes for various possible margins (where 21 = 3
@@ -336,8 +216,8 @@ An individual generator spec JSON object can contain the following keys:
336
216
  | `var` | string[], optional | Array of variation IDs (see section below) |
337
217
  | `user` | any, optional | Custom user data, comments, metadata etc. |
338
218
 
339
- The number of generated CSS classes per spec is number of items in `values`
340
- multiplied with the number of variations in `var` (if any).
219
+ The number of generated CSS classes per spec is the number of items in `values`
220
+ multiplied by the number of variations in `var` (if any).
341
221
 
342
222
  Any `user` data will be stored (as is) with each generated CSS class, but
343
223
  currently has no other direct use in the toolchain and is meant for additional
@@ -517,6 +397,319 @@ ALWAYS combined using `and`:
517
397
  See [media queries in the bundled base
518
398
  specs](https://github.com/thi-ng/umbrella/blob/982fff7bfcc48f108b6ad88f854ef00be4078510/packages/meta-css/specs/_info.json#L6-L24)
519
399
 
400
+ ## Converting meta stylesheets to CSS
401
+
402
+ The `convert` command is used to compile & bundle actual CSS from user-provided
403
+ MetaCSS stylesheets (`*.meta` files) and the JSON framework specs created by the
404
+ `generate` command. The meta-stylesheets support any CSS selectors, are nestable
405
+ and compose full CSS declarations from lists of the utility classes in the
406
+ generated framework.
407
+
408
+ Each item (aka utility class name) can be prefixed with an arbitrary number of
409
+ media query IDs (also custom defined in the framework): e.g. `dark:bg-black`
410
+ might refer to a CSS class to set a black ground, with the `dark:` prefix
411
+ referring to a defined media query which only applies this class when dark mode
412
+ is enabled...
413
+
414
+ Selectors, declarations and media query criteria will be deduplicated and merged
415
+ from multiple input files. **The resulting CSS will only contain referenced
416
+ rules** and can be generated in minified or pretty printed formats (it's also
417
+ possible to [force include CSS classes which are otherwise
418
+ unreferenced](#force-inclusion-of-unreferenced-classes)). Additionally, multiple
419
+ `.meta` stylesheets can be watched for changes (their definitions getting
420
+ merged), and existing CSS files can be included (prepended) in the bundled
421
+ output too.
422
+
423
+ ```text
424
+ metacss convert --help
425
+
426
+ Usage: metacss convert [opts] input [...]
427
+
428
+ Flags:
429
+
430
+ --no-header Don't emit generated header comment
431
+ -p, --pretty Pretty print output
432
+ -v, --verbose Display extra process information
433
+ -w, --watch Watch input files for changes
434
+
435
+ Main:
436
+
437
+ -e STR, --eval STR eval meta stylesheet in given string (ignores other inpu
438
+ ts & includes)
439
+ -f STR, --force STR [multiple] CSS classes to force include (wildcards are
440
+ supported, @-prefix will read from file)
441
+ -I STR, --include STR [multiple] Include CSS files (prepend)
442
+ -o STR, --out STR Output file (or stdout)
443
+ -s STR, --specs STR [required] Path to generated JSON defs
444
+ ```
445
+
446
+ ### Meta-stylesheets syntax
447
+
448
+ As mentioned earlier, the `convert` command transpiles meta-stylesheets into
449
+ actual CSS. These stylesheets support any CSS selector, support selector
450
+ nesting and have the following basic syntax:
451
+
452
+ ```text
453
+ // line comment
454
+ selector {
455
+ class-id1 class-id2 ...
456
+ {
457
+ nested-selector {
458
+ class-id3 ...
459
+ {
460
+ ...
461
+ }
462
+ }
463
+ }
464
+ }
465
+ ```
466
+
467
+ #### Class identifiers & media query prefixes
468
+
469
+ As indicated by the above file structure, `*.meta` stylesheets purely consist of
470
+ CSS selectors and the names of the generated framework-defined utility classes.
471
+ For example, using the [bundled framework specs](#bundled-css-base-framework),
472
+ this simple meta-stylesheet `body { ma0 monospace blue }` creates a CSS rule for
473
+ `body` with the definitions of the generated `ma0`, `monospace` and `blue`
474
+ classes inline-expanded:
475
+
476
+ ```css
477
+ body {
478
+ margin: 0rem;
479
+ font-family: Monaco, Menlo, Consolas, 'Courier New', monospace;
480
+ color: #357edd;
481
+ }
482
+ ```
483
+
484
+ #### Media query prefixes
485
+
486
+ This toolchain doesn't pre-generate media-query-specific versions of any CSS
487
+ class, and any class ID/token can be prefixed with any number of media query IDs
488
+ (separated by `:`). These [media queries are defined as part of the framework
489
+ generation specs](#media-query-definitions) and when used as a prefix, multiple
490
+ query IDs can be combined freely. For example, the meta-stylesheet `a:hover {
491
+ dark:bg-blue dark:anim:bg-anim2 }` will auto-create two separate CSS
492
+ `@media`-query blocks for the query IDs `dark` and `(dark AND anim)`:
493
+
494
+ ```css
495
+ @media (prefers-color-scheme: dark) {
496
+ a:hover {
497
+ background-color: #357edd;
498
+ }
499
+ }
500
+
501
+ @media (prefers-color-scheme: dark) and (not (prefers-reduced-motion)) {
502
+ a:hover {
503
+ transition: 0.25s background-color ease-in-out;
504
+ }
505
+ }
506
+ ```
507
+
508
+ A more detailed example, split over two files (for merging & bundling):
509
+
510
+ readme.meta:
511
+
512
+ ```text tangle:export/readme.meta
513
+ body {
514
+ // no margins
515
+ ma0
516
+ // default colors
517
+ bg-white black
518
+ // colors for dark mode
519
+ dark:bg-black dark:white
520
+ }
521
+
522
+ #app { ma3 }
523
+
524
+ .bt-group-v > a {
525
+ db w-100 l:w-50 ph3 pv2 bwb1
526
+ dark:bg-purple dark:white dark:b--black
527
+ light:bg-light-blue light:black light:b--white
528
+
529
+ // nested selectors
530
+ {
531
+ :hover { bg-gold black anim:bg-anim2 }
532
+ :first-child { brt3 }
533
+ :last-child { brb3 bwb0 }
534
+ }
535
+ }
536
+ ```
537
+
538
+ readme2.meta:
539
+
540
+ We will merge the definitions in this file with the ones above (i.e. adding &
541
+ overriding some of the declarations, here: a larger border radius):
542
+
543
+ ```text tangle:export/readme2.meta
544
+ #app { pa2 }
545
+
546
+ .bt-group-v > a {
547
+ {
548
+ :first-child { brt4 }
549
+ :last-child { brb4 }
550
+ }
551
+ }
552
+ ```
553
+
554
+ ```bash
555
+ # if no --out dir is specified, writes result to stdout...
556
+ # use previously generated framework for resolving all identifiers & media queries
557
+ metacss convert --pretty --specs framework.json readme.meta readme2.meta
558
+ ```
559
+
560
+ Resulting CSS bundle output:
561
+
562
+ ```css
563
+ /*! MetaCSS base v0.0.1 - generated by thi.ng/meta-css @ 2023-12-18T12:22:36.548Z */
564
+ body {
565
+ margin: 0rem;
566
+ background-color: #fff;
567
+ color: #000;
568
+ }
569
+
570
+ #app {
571
+ margin: 1rem;
572
+ padding: .5rem;
573
+ }
574
+
575
+ .bt-group-v > a {
576
+ display: block;
577
+ width: 100%;
578
+ padding-left: 1rem;
579
+ padding-right: 1rem;
580
+ padding-top: .5rem;
581
+ padding-bottom: .5rem;
582
+ border-bottom-style: solid;
583
+ border-bottom-width: .125rem;
584
+ }
585
+
586
+ .bt-group-v > a:hover {
587
+ background-color: #ffb700;
588
+ color: #000;
589
+ }
590
+
591
+ .bt-group-v > a:first-child {
592
+ border-top-left-radius: 1rem;
593
+ border-top-right-radius: 1rem;
594
+ }
595
+
596
+ .bt-group-v > a:last-child {
597
+ border-bottom-left-radius: 1rem;
598
+ border-bottom-right-radius: 1rem;
599
+ border-bottom-style: solid;
600
+ border-bottom-width: 0rem;
601
+ }
602
+
603
+ @media (prefers-color-scheme:dark) {
604
+
605
+ body {
606
+ background-color: #000;
607
+ color: #fff;
608
+ }
609
+
610
+ .bt-group-v > a {
611
+ background-color: #5e2ca5;
612
+ color: #fff;
613
+ border-color: #000;
614
+ }
615
+
616
+ }
617
+
618
+ @media (min-width:60rem) {
619
+
620
+ .bt-group-v > a {
621
+ width: 50%;
622
+ }
623
+
624
+ }
625
+
626
+ @media (prefers-color-scheme:light) {
627
+
628
+ .bt-group-v > a {
629
+ background-color: #96ccff;
630
+ color: #000;
631
+ border-color: #fff;
632
+ }
633
+
634
+ }
635
+
636
+ @media not (prefers-reduced-motion) {
637
+
638
+ .bt-group-v > a:hover {
639
+ transition: 0.2s background-color ease-in-out;
640
+ }
641
+
642
+ }
643
+ ```
644
+
645
+ ### Including custom CSS files
646
+
647
+ One or more existing CSS files can be included & prepended to the output via the
648
+ `--include`/`-I` arg (which can be given multiple times). These files are used
649
+ verbatim and will **not** be transformed or reformatted in any way.
650
+
651
+ ### Force inclusion of unreferenced classes
652
+
653
+ Only the CSS classes (and their optionally associated media queries) referenced
654
+ in a `.meta` stylesheet will appear in the export CSS bundle. This ensures that
655
+ the resulting CSS will only contain what's actually used (same effect as
656
+ tree-shaking, only vastly more efficient). However, this also means any CSS
657
+ classes (and optionally, their media query qualifiers) which are otherwise
658
+ referenced (e.g. from JS/TS source code or HTML docs) **will not** be included
659
+ by default and they will need to be listed manually for forced inclusion.
660
+
661
+ This can be achieved via the `--force`/`-f` arg (also can be given multiple
662
+ times). This option also supports basic `*`-wildcard patterns, e.g. `bg-*` to
663
+ include all classes with prefix `bg-`. Furthermore, for larger projects it's
664
+ useful to store these names/patterns in a separate file. For that purpose, use
665
+ the `@` prefix (e.g. `-f @includes.txt`) to indicate reading from file (only
666
+ reading from a single file is supported at current)... See the [meta-css-basics
667
+ example
668
+ project](https://github.com/thi-ng/umbrella/blob/develop/examples/meta-css-basics)
669
+ for concrete usage...
670
+
671
+ ## Exporting a generated framework as CSS
672
+
673
+ The `export` command is intended for those who're mainly interested in the CSS
674
+ framework generation aspects of this toolchain. This command merely takes an
675
+ existing generated framework JSON file and serializes it to a single CSS file,
676
+ e.g. to be then used with other CSS tooling (e.g. `postcss`).
677
+
678
+ ### Media query variations
679
+
680
+ Users can choose to generate variations of all defined utility classes for any
681
+ of the framework-defined media query IDs. This will create additional suffixed
682
+ versions of all classes (with their appropriate media query wrappers) and cause
683
+ a potentially massive output (depending on the overall number/complexity of the
684
+ generated classes). Again, the idea is that the resulting CSS file will be
685
+ post-processed with 3rd party CSS tooling...
686
+
687
+ For example, if the framework contains a CSS class `w-50` (e.g. to set the width
688
+ to 50%) and media queries for different screen sizes (e.g. named `ns`, `l`),
689
+ then the export with said media queries will also generate classes `w-50-ns`
690
+ and `w-50-l` (incl. their corresponding `@media` wrappers).
691
+
692
+ As with the `convert` command, additional CSS files can also be included
693
+ (prepended) in the output file.
694
+
695
+ ```text
696
+ metacss export --help
697
+
698
+ Usage: metacss export [opts] input
699
+
700
+ Flags:
701
+
702
+ --no-header Don't emit generated header comment
703
+ -p, --pretty Pretty print output
704
+ -v, --verbose Display extra process information
705
+
706
+ Main:
707
+
708
+ -I STR, --include STR [multiple] Include CSS files (prepend)
709
+ -m STR, --media STR Media query IDs (use 'ALL' for all)
710
+ -o STR, --out STR Output file (or stdout)
711
+ ```
712
+
520
713
  ## Bundled CSS base framework
521
714
 
522
715
  The package includes a large number of useful specs in [/specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/). These are provided as starting point to define your custom framework(s)...
@@ -668,7 +861,7 @@ distributed as CLI bundle with **no runtime dependencies**. The following
668
861
  dependencies are only shown for informational purposes and are (partially)
669
862
  included in the bundle.
670
863
 
671
- Package sizes (brotli'd, pre-treeshake): ESM: 11.25 KB
864
+ Package sizes (brotli'd, pre-treeshake): ESM: 11.31 KB
672
865
 
673
866
  ## Dependencies
674
867
 
@@ -696,216 +889,6 @@ directory is using this package:
696
889
  |:-----------------------------------------------------------------------------------------------------------------------|:--------------------------------------|:------------------------------------------------------|:-----------------------------------------------------------------------------------|
697
890
  | <img src="https://raw.githubusercontent.com/thi-ng/umbrella/develop/assets/examples/meta-css-basics.png" width="240"/> | Basic thi.ng/meta-css usage & testbed | [Demo](https://demo.thi.ng/umbrella/meta-css-basics/) | [Source](https://github.com/thi-ng/umbrella/tree/develop/examples/meta-css-basics) |
698
891
 
699
- ## CLI
700
-
701
- ### Basic usage example
702
-
703
- The `metacss` tool provides multiple commands. You can install & run it like so:
704
-
705
- ```text
706
- npx @thi.ng/meta-css --help
707
-
708
- █ █ █ │
709
- ██ █ │
710
- █ █ █ █ █ █ █ █ │ @thi.ng/meta-css 0.0.1
711
- █ █ █ █ █ █ █ █ █ │ Data-driven CSS component & framework codegen
712
- █ │
713
- █ █ │
714
-
715
- Usage: metacss <cmd> [opts] input [...]
716
- metacss <cmd> --help
717
-
718
- Available commands:
719
-
720
- convert : Transpile & bundle meta stylesheets to CSS
721
- export : Export entire generated framework as CSS
722
- generate : Generate framework rules from specs
723
-
724
- Flags:
725
-
726
- -v, --verbose Display extra process information
727
-
728
- Main:
729
-
730
- -o STR, --out STR Output file (or stdout)
731
- ```
732
-
733
- ### Generating framework code from bundled base definitions
734
-
735
- To create our first framework, we first need to generate CSS utility classes
736
- from given JSON generator specs. For simplicity the generated framework
737
- definitions will be stored as JSON too and then used as lookup tables for actual
738
- CSS translation in the next step.
739
-
740
- ```bash
741
- # write generated CSS classes (in JSON)
742
- metacss generate --out framework.json node_modules/@thi.ng/meta-css/specs
743
- ```
744
-
745
- ### Generating CSS from `.meta` stylesheets
746
-
747
- #### *.meta stylesheets
748
-
749
- The naming convention used by the [default framework
750
- specs](https://github.com/thi-ng/umbrella/blob/develop/packages/meta-css/specs/)
751
- is loosely based on [tachyons.io](https://tachyons.io), with the important
752
- difference of media query handling. Using MetaCSS we don't have to pre-generate
753
- mediaquery-specific versions, and any class ID/token can be prefixed with an
754
- _arbitrary_ number of media query IDs (separated by `:`). These media queries
755
- are defined as part of the framework JSON specs and when used as a prefix,
756
- multiple query IDs can be combined freely. E.g. the token `dark:anim:bg-anim2`
757
- will auto-create a merged CSS `@media`-query block for the query IDs `dark` and
758
- `anim` and only emit the definition of `bg-anim2` for this combination (see
759
- generated CSS further below).
760
-
761
- readme.meta:
762
-
763
- ```text tangle:export/readme.meta
764
-
765
- body { ma0 dark:bg-black dark:white bg-white black }
766
-
767
- #app { ma3 }
768
-
769
- .bt-group-v > a {
770
- db w-100 l:w-50 ph3 pv2 bwb1
771
- dark:bg-purple dark:white dark:b--black
772
- light:bg-light-blue light:black light:b--white
773
- {
774
- :hover { bg-gold black anim:bg-anim2 }
775
- :first-child { brt3 }
776
- :last-child { brb3 bwb0 }
777
- }
778
- }
779
- ```
780
-
781
- readme2.meta:
782
-
783
- We will merge the definitions in this file with the ones from the file above
784
- (i.e. adding & overriding some of the declarations, here: border radius):
785
-
786
- ```text tangle:export/readme2.meta
787
- #app { pa2 }
788
-
789
- .bt-group-v > a {
790
- {
791
- :first-child { brt4 }
792
- :last-child { brb4 }
793
- }
794
- }
795
- ```
796
-
797
- ```bash
798
- # if not out dir is specified writes result to stdout
799
- # use previously generated specs for resolving all identifiers & media queries
800
- metacss convert --pretty --specs framework.json readme.meta readme2.meta
801
- ```
802
-
803
- #### Resulting CSS output
804
-
805
- ```css
806
- /*! MetaCSS base v0.0.1 - generated by thi.ng/meta-css @ 2023-12-18T12:22:36.548Z */
807
- body {
808
- margin: 0rem;
809
- background-color: #fff;
810
- color: #000;
811
- }
812
-
813
- #app {
814
- margin: 1rem;
815
- padding: .5rem;
816
- }
817
-
818
- .bt-group-v > a {
819
- display: block;
820
- width: 100%;
821
- padding-left: 1rem;
822
- padding-right: 1rem;
823
- padding-top: .5rem;
824
- padding-bottom: .5rem;
825
- border-bottom-style: solid;
826
- border-bottom-width: .125rem;
827
- }
828
-
829
- .bt-group-v > a:hover {
830
- background-color: #ffb700;
831
- color: #000;
832
- }
833
-
834
- .bt-group-v > a:first-child {
835
- border-top-left-radius: 1rem;
836
- border-top-right-radius: 1rem;
837
- }
838
-
839
- .bt-group-v > a:last-child {
840
- border-bottom-left-radius: 1rem;
841
- border-bottom-right-radius: 1rem;
842
- border-bottom-style: solid;
843
- border-bottom-width: 0rem;
844
- }
845
-
846
- @media (prefers-color-scheme:dark) {
847
-
848
- body {
849
- background-color: #000;
850
- color: #fff;
851
- }
852
-
853
- .bt-group-v > a {
854
- background-color: #5e2ca5;
855
- color: #fff;
856
- border-color: #000;
857
- }
858
-
859
- }
860
-
861
- @media (min-width:60rem) {
862
-
863
- .bt-group-v > a {
864
- width: 50%;
865
- }
866
-
867
- }
868
-
869
- @media (prefers-color-scheme:light) {
870
-
871
- .bt-group-v > a {
872
- background-color: #96ccff;
873
- color: #000;
874
- border-color: #fff;
875
- }
876
-
877
- }
878
-
879
- @media not (prefers-reduced-motion) {
880
-
881
- .bt-group-v > a:hover {
882
- transition: 0.2s background-color ease-in-out;
883
- }
884
-
885
- }
886
- ```
887
-
888
- A simple HTML example using above MetaCSS styles:
889
-
890
- #### index.html
891
-
892
- ```html tangle:export/index.html
893
- <!doctype html>
894
- <html>
895
- <head>
896
- <link rel="stylesheet" href="bundle.css"/>
897
- </head>
898
- <body>
899
- <div id="app" class="bt-group-v">
900
- <a href="#">One</a>
901
- <a href="#">Two</a>
902
- <a href="#">Three</a>
903
- <a href="#">Four</a>
904
- </div>
905
- </body>
906
- </html>
907
- ```
908
-
909
892
  ## Authors
910
893
 
911
894
  - [Karsten Schmidt](https://thi.ng)
package/index.js CHANGED
@@ -1,12 +1,12 @@
1
1
  // @bun
2
- var b0={default:95,hint:90,multi:90,param:96,required:33};var L0=(X)=>X;var d=function(X,Z){return!Z&&(Z={}),(...J)=>{const W=JSON.stringify(J);if(W!==void 0)return W in Z?Z[W]:Z[W]=X.apply(null,J);return X.apply(null,J)}};var n=d((X,Z)=>X.repeat(Z));var B1=(X)=>/^[a-f0-9]+$/i.test(X);var Q1=(X)=>/^[-+]?\d+$/.test(X),z1=(X)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(X);var I=(X,Z=(J)=>J!==void 0?": "+J:"")=>class extends Error{constructor(J){super(X(J)+Z(J))}};var b8=I(()=>"illegal argument(s)"),H=(X)=>{throw new b8(X)};var S0=(X)=>z1(X)?parseFloat(X):H(`not a numeric value: ${X}`),q1=(X)=>X.map(S0),y0=(X)=>B1(X)?parseInt(X,16):H(`not a hex value: ${X}`),K1=(X)=>X.map(y0),h0=(X)=>Q1(X)?parseInt(X):H(`not an integer: ${X}`),$1=(X)=>X.map(h0);var Q0=(X,Z)=>(J)=>({coerce:X,hint:Z,group:"main",...J}),z0=(X,Z)=>(J)=>({hint:L8(Z,J.delim),multi:!0,coerce:X,group:"main",...J}),L8=(X,Z)=>X+(Z?`[${Z}..]`:""),l=(X)=>({flag:!0,default:!1,group:"flags",...X}),q0=Q0(L0,"STR"),p=z0(L0,"STR"),K4=Q0(S0,"NUM"),$4=Q0(y0,"HEX"),H1=Q0(h0,"INT"),H4=z0(q1,"NUM"),C4=z0(K1,"HEX"),M4=z0($1,"INT");var C=((X)=>{return X[X.FINE=0]="FINE",X[X.DEBUG=1]="DEBUG",X[X.INFO=2]="INFO",X[X.WARN=3]="WARN",X[X.SEVERE=4]="SEVERE",X[X.NONE=5]="NONE",X})(C||{});class f0{id;level;constructor(X,Z=C.FINE){this.id=X,this.level=typeof Z==="string"?C[Z]:Z}enabled(X){return this.level<=X}fine(...X){this.level<=C.FINE&&this.log(C.FINE,X)}debug(...X){this.level<=C.DEBUG&&this.log(C.DEBUG,X)}info(...X){this.level<=C.INFO&&this.log(C.INFO,X)}warn(...X){this.level<=C.WARN&&this.log(C.WARN,X)}severe(...X){this.level<=C.SEVERE&&this.log(C.SEVERE,X)}}var C1=(X)=>X.map((Z)=>{if(typeof Z==="function")Z=Z();if(!(typeof Z==="string"||typeof Z==="number"))Z=JSON.stringify(Z);return Z}).join(" ");class m0 extends f0{constructor(X,Z,J=C.FINE){super(Z,J);this.target=X}log(X,Z){this.target.write(`[${C[X]}] ${this.id}: ${C1(Z)}
3
- `)}}var K0=d((X,Z=" ")=>{const J=n(String(Z),X);return(W,Y)=>{if(W==null)return J;return W=W.toString(),Y=Y!==void 0?Y:W.length,Y<X?W+J.substring(Y):W}});var M1=(X,Z)=>{return!Z&&(Z=new Map),(J)=>{let W;return Z.has(J)?Z.get(J):(Z.set(J,W=X(J)),W)}};var u0={black:1,blue:5,cyan:7,gray:17,green:3,magenta:6,red:2,white:24,yellow:4,lightBlue:21,lightCyan:23,lightGray:8,lightGreen:19,lightMagenta:22,lightRed:18,lightYellow:20,bgBlack:32,bgBlue:160,bgCyan:224,bgGray:544,bgGreen:96,bgMagenta:192,bgRed:64,bgWhite:768,bgYellow:128,bgLightBlue:672,bgLightCyan:736,bgLightGray:256,bgLightGreen:608,bgLightMagenta:704,bgLightRed:576,bgLightYellow:640};var S8=(X,Z)=>(J)=>X.format(Z,J),g0=(X)=>Object.keys(u0).reduce((Z,J)=>(Z[J]=S8(X,u0[J]),Z),{format:X});var F1="\x1B[0m",y8=["","1","2","1;2","4","1;4","2;4","1;2;4"],$0={format:(X,Z)=>$0.start(X)+Z+$0.end,start:M1((X)=>{let Z=[],J=X&15;return J&&Z.push(29+(X>>4&1)*60+J),J=X>>5&15,J&&Z.push(39+(X>>9&1)*60+J),J=X>>10,J&&Z.push(y8[J]),"\x1B["+Z.join(";")+"m"}),end:F1,prefix:F1,suffix:"\n"};var P1={format:(X,Z)=>String(Z),prefix:"",suffix:"\n",start:()=>"",end:""};var H0=g0($0),O1=g0(P1);var P=Array.isArray;var h8=(X)=>X.toUpperCase(),w1=(X)=>X.toLowerCase(),N1=(X)=>X.length?X[0].toUpperCase()+X.substring(1):X,D1=(X,Z="-")=>w1(X.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(J,W,Y)=>W+Z+Y));var G1=(X,Z="-")=>w1(X).replace(new RegExp(`\\${Z}+(\\w)`,"g"),(J,W)=>h8(W));var j1=Object.getPrototypeOf,R=(X)=>{let Z;return X!=null&&typeof X==="object"&&((Z=j1(X))===null||j1(Z)===null)};var f8=/\x1b\[[0-9;]+m/g,m8=(X)=>X.replace(f8,"");var C0=(X)=>m8(X).length;var k1=(X=!1,Z)=>(J)=>X||typeof J!=="string"&&typeof J!=="number"?JSON.stringify(J,null,Z):String(J);function*m(X,Z=/\r?\n/g,J=!1){let W=0;const Y=X.length,U=~~J;let V;if(typeof Z==="string")V=new RegExp(Z,"g");else if(!Z.flags.includes("g"))V=new RegExp(Z,Z.flags+"g");else V=Z;for(;W<Y;){const B=V.exec(X);if(!B){yield X.substring(W);return}const Q=B[0].length;yield X.substring(W,B.index+U*Q),W=B.index+Q}}class x0{n=0;w=[];constructor(X,Z){X!=null&&this.add(X,Z)}add(X,Z=X.length){return this.w.push(X),this.n+=Z+~~(this.n>0),this}toString(){return this.w.join(" ")}}var u8={length:(X)=>X.length,split:(X,Z)=>Z},I1={length:C0,split:(X,Z)=>{const J=/\x1b\[[0-9;]+m/g;let W=Z,Y;while(Y=J.exec(X)){if(Y.index>=Z)break;const U=Y[0].length;W+=U,Z+=U}return W}},T1=(X,Z,J,W)=>{const Y=X[X.length-1];Y&&W-Y.n>J?Y.add(Z,J):X.push(new x0(Z,J))},g8=(X,{width:Z,min:J,hard:W,splitter:Y},U=0,V=[])=>{let B=Y.length(X),Q=Z-U;if(Q<J&&Q<B)Q=Z;while(W&&B>Q){const q=Y.split(X,Q),z=X.substring(0,q);T1(V,z,Q,Z),X=X.substring(q),Q=Z,B=Y.length(X)}return T1(V,X,B,Z),V},x8=(X,Z,J=[])=>{if(!X.length)return J.push(new x0),J;const W={width:80,min:4,hard:!1,splitter:u8,...Z};for(let Y of m(X,Z.delimWord||/\s/g)){const U=J[J.length-1];g8(Y,W,U&&U.n>0?U.n+1:0,J)}return J},R1=(X,Z)=>{let J=[];for(let W of m(X,Z.delimLine))J=J.concat(x8(W,Z));return J};var Z0=(X,Z={})=>{Z={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...Z};const J=R(Z.color)?{...b0,...Z.color}:Z.color?b0:{},W=n(" ",Z.paramWidth),Y=(B)=>B.map((Q)=>d8(Q,X[Q],Z,J,W)),U=Object.keys(X).sort(),V=Z.groups?Z.groups.map((B)=>[B,U.filter((Q)=>X[Q].group===B)]).filter((B)=>!!B[1].length):[["options",U]];return[...d0(Z.prefix,Z.lineWidth),...V.map(([B,Q])=>[...Z.showGroupNames?[`${N1(B)}:
4
- `]:[],...Y(Q),""].join("\n")),...d0(Z.suffix,Z.lineWidth)].join("\n")},d8=(X,Z,J,W,Y)=>{const U=n8(Z,W),V=l8(Z,W,U),B=J0(`--${D1(X)}`,W.param),Q=`${V}${B}${U}`,q=Z.optional===!1&&Z.default===void 0,z=[];q&&z.push("required"),Z.multi&&z.push("multiple");const K=p8(z,W,q)+(Z.desc||"")+o8(Z,J,W);return K0(J.paramWidth)(Q,C0(Q))+d0(K,J.lineWidth-J.paramWidth).map(($,v)=>v>0?Y+$:$).join("\n")},n8=(X,Z)=>X.hint?J0(" "+X.hint,Z.hint):"",l8=(X,Z,J)=>X.alias?`${J0("-"+X.alias,Z.param)}${J}, `:"",p8=(X,Z,J)=>X.length?J0(`[${X.join(", ")}] `,J?Z.required:Z.multi):"",o8=(X,Z,J)=>Z.showDefaults&&X.default!=null&&X.default!==!1?J0(` (default: ${k1(!0)(X.defaultHint!=null?X.defaultHint:X.default)})`,J.default):"",J0=(X,Z)=>Z!=null?`\x1B[${Z}m${X}\x1B[0m`:X,d0=(X,Z)=>X?R1(X,{width:Z,splitter:I1,hard:!0}):[];var i8=I(()=>"parse error"),A1=(X,Z,J)=>{J={start:2,showUsage:!0,help:["--help","-h"],...J};try{return a8(X,Z,J)}catch(W){if(J.showUsage)console.log(W.message+"\n\n"+Z0(X,J.usageOpts));throw new i8(W.message)}},a8=(X,Z,J)=>{const W=t8(X),Y={};let U,V,B=J.start;for(;B<Z.length;){const Q=Z[B];if(!U){if(J.help.includes(Q)){console.log(Z0(X,J.usageOpts));return}const q=c8(X,W,Y,Q);if(U=q.id,V=q.spec,B=B+~~(q.state<2),q.state)break}else{if(r8(V,Y,U,Q))break;U=null,B++}}return U&&H(`missing value for: --${U}`),{result:s8(X,Y),index:B,rest:Z.slice(B),done:B>=Z.length}},t8=(X)=>Object.entries(X).reduce((Z,[J,W])=>W.alias?(Z[W.alias]=J,Z):Z,{}),c8=(X,Z,J,W)=>{if(W[0]==="-"){let Y;if(W[1]==="-"){if(W==="--")return{state:1};Y=G1(W.substring(2))}else Y=Z[W.substring(1)],!Y&&H(`unknown option: ${W}`);const U=X[Y];if(!U&&H(Y),U.flag){if(J[Y]=!0,Y=void 0,U.fn&&!U.fn("true"))return{state:1,spec:U}}return{state:0,id:Y,spec:U}}return{state:2}},r8=(X,Z,J,W)=>{if(/^-[a-z]/i.test(W)&&H(`missing value for: --${J}`),X.multi)P(Z[J])?Z[J].push(W):Z[J]=[W];else Z[J]=W;return X.fn&&!X.fn(W)},s8=(X,Z)=>{let J;for(let W in X)if(J=X[W],Z[W]===void 0){if(J.default!==void 0)Z[W]=J.default;else if(J.optional===!1)H(`missing arg: --${W}`)}else if(J.coerce)e8(J,Z,W);return Z},e8=(X,Z,J)=>{try{if(X.multi&&X.delim)Z[J]=Z[J].reduce((W,Y)=>(W.push(...Y.split(X.delim)),W),[]);Z[J]=X.coerce(Z[J])}catch(W){throw new Error(`arg --${J}: ${W.message}`)}};var v1=async(X)=>{const Z=X.argv||process.argv,J=!process.env.NO_COLOR,W={prefix:"",color:J,...X.usage};try{let Y,U,V=X.start??2;if(X.single){if(Y=Object.keys(X.commands)[0],!Y)H("no command provided");U=X.commands[Y]}else{if(Y=Z[V],U=X.commands[Y],W.prefix+=XX(X.commands),!U)E1(X,W);V++}let B;try{B=A1({...X.opts,...U.opts},Z,{showUsage:!0,usageOpts:W,start:V})}catch(q){}if(!B)process.exit(1);if(U.inputs!==void 0&&U.inputs!==B.rest.length)process.stderr.write(`expected ${U.inputs||0} input(s)
5
- `),E1(X,W);const Q=await X.ctx({logger:new m0(process.stderr,X.name,"INFO"),format:J?H0:O1,opts:B.result,inputs:B.rest},U);if(await U.fn(Q),X.post)await X.post(Q,U)}catch(Y){process.stderr.write(Y.message+"\n\n"),process.exit(1)}},E1=(X,Z)=>{process.stderr.write(Z0(X.opts,Z)),process.exit(1)},XX=(X)=>["\nAvailable commands:\n",...Object.keys(X).map((Z)=>`${K0(16)(Z)}: ${X[Z].desc}`),"\n"].join("\n");import{existsSync as ZX,mkdirSync as JX,statSync as WX} from"fs";import{sep as YX} from"path";var _1=(X)=>{const Z=X.substring(0,X.lastIndexOf(YX));return Z.length>0&&!ZX(Z)?(JX(Z,{recursive:!0}),!0):!1},b1=(X)=>WX(X).isDirectory();var k=(X)=>typeof X==="function";var F=(X)=>typeof X==="string";import{readdirSync as UX,statSync as k5} from"fs";import{sep as VX} from"path";function*S1(X,Z="",J,W=Infinity,Y=0){if(Y>=W)return;const U=QX(Z);for(let V of UX(X).sort()){const B=X+VX+V;try{if(b1(B))yield*S1(B,Z,J,W,Y+1);else if(U(B))yield B}catch(Q){J&&J.warn(`ignoring file: ${V} (${Q.message})`)}}}var L1=(X,Z="",J=Infinity,W)=>S1(X,Z,W,J,0);var BX=(X)=>F(X)?new RegExp(`${X.replace(/\./g,"\\.")}\$`):X,QX=(X)=>k(X)?X:(X=BX(X),(Z)=>X.test(Z));import{readFileSync as qX} from"fs";import{writeFileSync as zX} from"fs";var y1=(X,Z,J,W,Y=!1)=>{if(W&&W.info(`${Y?"[dryrun] ":""}writing file: ${X}`),Y)return;_1(X),zX(X,Z,!J&&F(Z)?"utf-8":J)};var A=(X,Z,J="utf-8")=>{return Z&&Z.debug("reading file:",X),qX(X,J)},n0=(X,Z,J,W=!1)=>y1(X,P(Z)?Z.join("\n"):Z,"utf-8",J,W);var b=(X,Z)=>JSON.parse(A(X,Z));var M0=Object.freeze({level:C.NONE,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){}});import{join as nX} from"path";var KX=I(()=>"Assertion failed"),F0=(typeof process!=="undefined"&&process.env!==void 0?!0:import.meta.env?import.meta.env.MODE!=="production"||!!import.meta.env.UMBRELLA_ASSERTS||!!import.meta.env.VITE_UMBRELLA_ASSERTS:!0)?(X,Z)=>{if(typeof X==="function"&&!X()||!X)throw new KX(typeof Z==="function"?Z():Z)}:()=>{};var P0=(X)=>X!=null&&typeof X!=="function"&&X.length!==void 0;var h1=(X)=>{return(X==null||!X[Symbol.iterator])&&H(`value is not iterable: ${X}`),X};var f1=(X)=>P0(X)?X:[...h1(X)];var W0=(X)=>X[X.length-1];var $X=I(()=>"illegal arity"),o=(X)=>{throw new $X(X)};var HX=I(()=>"illegal state"),i=(X)=>{throw new HX(X)};var l0=function(...X){let[Z,J,W,Y,U,V,B,Q,q,z]=X;switch(X.length){case 0:o(0);case 1:return Z;case 2:return(...$)=>Z(J(...$));case 3:return(...$)=>Z(J(W(...$)));case 4:return(...$)=>Z(J(W(Y(...$))));case 5:return(...$)=>Z(J(W(Y(U(...$)))));case 6:return(...$)=>Z(J(W(Y(U(V(...$))))));case 7:return(...$)=>Z(J(W(Y(U(V(B(...$)))))));case 8:return(...$)=>Z(J(W(Y(U(V(B(Q(...$))))))));case 9:return(...$)=>Z(J(W(Y(U(V(B(Q(q(...$)))))))));case 10:default:const K=(...$)=>Z(J(W(Y(U(V(B(Q(q(z(...$))))))))));return X.length===10?K:l0(K,...X.slice(10))}};var m1=(X,Z)=>new Promise((J)=>setTimeout(()=>J(X),Z));var u1=(X)=>X;var g1=["-moz-","-ms-","-o-","-webkit-"],a={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},O0={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var G=(X)=>X!=null&&typeof X[Symbol.iterator]==="function";var w0=(X,Z)=>X!=null&&typeof X[Z]==="function";var u=(X)=>w0(X,"xform")?X.xform():X;var L=function(...X){return X=X.map(u),l0.apply(null,X)};var N0=(X)=>X!=null&&typeof X!=="string"&&typeof X[Symbol.iterator]==="function";var t=(X,Z)=>[X[0],X[1],Z];var S=Symbol(),p0=()=>{};class o0{value;constructor(X){this.value=X}deref(){return this.value}}var j=(X)=>X instanceof o0;var y=(X)=>X instanceof o0?X.deref():X;var D0=function(...X){const Z=X[0],J=Z[0],W=Z[1],Y=Z[2];X=CX(X);const U=X[0]==null?J():X[0],V=X[1];return y(W(w0(V,"$reduce")?V.$reduce(Y,U):P0(V)?MX(Y,U,V):FX(Y,U,V)))};var CX=(X)=>X.length===2?[void 0,X[1]]:X.length===3?[X[1],X[2]]:o(X.length),MX=(X,Z,J)=>{for(let W=0,Y=J.length;W<Y;W++)if(Z=X(Z,J[W]),j(Z)){Z=Z.deref();break}return Z},FX=(X,Z,J)=>{for(let W of J)if(Z=X(Z,W),j(Z)){Z=Z.deref();break}return Z},c=(X,Z)=>[X,(J)=>J,Z];var G0=function(X){return X?[...X]:c(()=>[],(Z,J)=>(Z.push(J),Z))};function*j0(X,Z){const J=u(X)(G0()),W=J[1],Y=J[2];for(let U of Z){const V=Y([],U);if(j(V)){yield*y(W(V.deref()));return}if(V.length)yield*V}yield*y(W([]))}function*g(X,Z){const J=u(X)([p0,p0,(W,Y)=>Y])[2];for(let W of Z){let Y=J(S,W);if(j(Y)){if(Y=y(Y.deref()),Y!==S)yield Y;return}if(Y!==S)yield Y}}var k0=(X,Z,J=g)=>{const W=Z.length-1;return G(Z[W])?Z.length>1?J(X.apply(null,Z.slice(0,W)),Z[W]):J(X(),Z[0]):void 0};var i0=function(X,Z){return G(Z)?j0(i0(X),F(Z)?[Z]:Z):(J)=>{const W=J[2],Y=(U,V)=>{const B=X(V);if(B){for(let Q of B)if(U=Y(U,Q),j(U))break;return U}return W(U,V)};return t(J,Y)}};var x1=function(X){return i0((Z)=>N0(Z)?Z:void 0,X)};var O=function(X,Z){return G(Z)?g(O(X),Z):(J)=>{const W=J[2];return t(J,(Y,U)=>W(Y,X(U)))}};function*T0(...X){const Z=X.length-1;if(Z<0)return;const J=new Array(Z+1).fill(0),W=X.map(f1),Y=W.reduce((U,V)=>U*V.length,1);for(let U=0;U<Y;U++){const V=[];for(let B=Z;B>=0;B--){const Q=W[B];let q=J[B];if(q===Q.length)J[B]=q=0,B>0&&J[B-1]++;V[B]=Q[q]}J[Z]++,yield V}}function*d1(X,Z=Infinity){while(Z-- >0)yield X}var a0=function(X,Z){X=X||"";let J=!0;return Z?[...Z].join(X):c(()=>"",(W,Y)=>(W=J?W+Y:W+X+Y,J=!1,W))};var I0=function(...X){return PX(I0,D0,X)};var PX=(X,Z,J)=>{let W,Y;switch(J.length){case 4:Y=J[3],W=J[2];break;case 3:Y=J[2];break;case 2:return O((U)=>X(J[0],J[1],U));default:o(J.length)}return Z(u(J[0])(J[1]),W,Y)};var OX=new Set,wX=":[",n1=L(x1(),O((X)=>wX.indexOf(X.charAt(0))>=0?X:" "+X)),NX=(X,Z)=>L(X,O((J)=>F(J)&&J.indexOf(" .")==0?J+Z:J)),r=(X,Z,J,W)=>{const Y=J.length,U=[];let V,B;const Q=(q,z)=>{let K=null;if(P(z))r(X,t0(Z,U),z,W);else if(G(z)&&!F(z))r(X,t0(Z,U),[...z],W);else if((B=k(z))||(K=W.fns[z]))if(!Z.length){if(K)return K.apply(null,J.slice(q+1))(X,W),!0;z(X,W)}else if(B)Q(q,z());else H(`quoted fn ('${z}') only allowed at head position`);else if(R(z))V=Object.assign(V||{},z);else if(z!=null)U.push(z)};for(let q=0;q<Y;q++)if(Q(q,J[q]))return X;return V&&X.push(DX(Z,U,V,W)),X},t0=(X,Z)=>X.length?[...T0(X,Z)]:Z,DX=(X,Z,J,W)=>{const Y=W.format,U=R0(W),V=W.scope?NX(n1,W.scope):n1;return[U,I0(O((B)=>I0(V,a0(),P(B)?B:[B]).trim()),a0(Y.ruleSep),t0(X,Z)),Y.declStart,c0(J,W),U,Y.declEnd].join("")},c0=(X,Z)=>{const J=Z.format,W=Z.autoprefix||OX,Y=R0(Z,Z.depth+1),U=[];for(let V in X)if(X.hasOwnProperty(V)){let B=X[V];if(k(B))B=B(X);if(P(B))B=B.map((Q)=>P(Q)?Q.join(" "):Q).join(J.ruleSep);if(W.has(V))for(let Q of Z.vendors)U.push(`${Y}${Q}${V}:${J.valSep}${B};`);U.push(`${Y}${V}:${J.valSep}${B};`)}return U.join(J.decls)+J.decls},R0=(X,Z=X.depth)=>Z>1?[...d1(X.format.indent,Z)].join(""):Z>0?X.format.indent:"";var p1=(X,Z,J)=>(W,Y)=>{const U=R0(Y);return W.push(`${U}${X} ${GX(Z)}${Y.format.declStart}`),Y.depth++,r(W,[],J,Y),Y.depth--,W.push(U+Y.format.declEnd),W},GX=(X)=>{if(F(X))return X;const Z=[];for(let J in X)if(X.hasOwnProperty(J)){let W=X[J];if(W===!0)W=l1.has(J)?J:`(${J})`;else if(W===!1)W="not "+(l1.has(J)?J:`(${J})`);else if(W==="only")W+=" "+J;else W=`(${J}:${W})`;Z.push(W)}return Z.join(" and ")},l1=new Set(["all","print","screen"]);var Y0=(X,Z)=>{return Z={format:a,vendors:g1,fns:{},depth:0,...Z},P(Z.autoprefix)&&(Z.autoprefix=new Set(Z.autoprefix)),R(X)?c0(X,Z):k(X)?X([],Z).join(Z.format.rules):r([],[],P(X)?X:N0(X)?[...X]:H("invalid rules"),Z).join(Z.format.rules)};var A0=(X,Z)=>p1("@media",X,Z);var o1=4,i1=(X)=>o1=X,D=(X)=>X===(X|0)?String(X):X.toFixed(o1).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,""),a1=(X)=>`${D(X)}em`,t1=(X)=>`${D(X)}ex`,c1=(X)=>`${D(X)}rem`,r0=(X)=>`${D(X)}%`,r1=(X)=>`${D(X)}px`,s1=(X)=>`${D(X)}vh`,e1=(X)=>`${D(X)}vw`,X8=(X)=>`${D(X)}vmin`,Z8=(X)=>`${D(X)}vmax`,J8=(X)=>`${X|0}ms`,W8=(X)=>`${D(X)}s`;var Y8=(X)=>`${D(X)}deg`,U8=(X)=>`${D(X)}rad`,V8=(X)=>`${D(X)}turn`,B8=(X)=>`url(${X})`;var w=((X)=>{return X[X.IDLE=0]="IDLE",X[X.ACTIVE=1]="ACTIVE",X[X.DONE=2]="DONE",X[X.UNSUBSCRIBED=3]="UNSUBSCRIBED",X[X.ERROR=4]="ERROR",X})(w||{}),T=((X)=>{return X[X.NEVER=0]="NEVER",X[X.FIRST=1]="FIRST",X[X.LAST=2]="LAST",X})(T||{});var jX=0,kX=()=>jX++,x=(X,Z)=>!Z||!Z.id?{...Z,id:X+"-"+kX()}:Z;var N=M0;class h{constructor(X,Z){this.wrapped=X,Z=x("sub",{closeIn:T.LAST,closeOut:T.LAST,cache:!0,...Z}),this.parent=Z.parent,this.id=Z.id,this.closeIn=Z.closeIn,this.closeOut=Z.closeOut,this.cacheLast=Z.cache,Z.xform&&(this.xform=Z.xform(G0()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=S;state=w.IDLE;subs=[];deref(){return this.last!==S?this.last:void 0}getState(){return this.state}setState(X){this.state=X}subscribe(X,Z={}){this.ensureState();let J;if(X instanceof h&&!Z.xform)X.ensureState(),F0(!X.parent,`sub '${X.id}' already has a parent`),X.parent=this,J=X;else J=new h(X,{...Z,parent:this});return this.subs.push(J),this.setState(w.ACTIVE),J.setState(w.ACTIVE),this.last!=S&&J.next(this.last),J}transform(...X){let Z,J;if(R(W0(X)))J=X.pop(),Z={error:J.error};return this.subscribe(Z,x("xform",X.length>0?{...J,xform:L(...X)}:J))}map(X,Z){return this.transform(O(X),Z||{})}unsubscribe(X){return X?this.unsubscribeChild(X):this.unsubscribeSelf()}unsubscribeSelf(){return N.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<w.UNSUBSCRIBED&&(this.state=w.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(X){N.debug(this.id,"unsub child",X.id);const Z=this.subs.indexOf(X);if(Z>=0){if(this.subs.splice(Z,1),this.closeOut===T.FIRST||!this.subs.length&&this.closeOut!==T.NEVER)this.unsubscribe();return!0}return!1}next(X){if(this.state>=w.DONE)return;this.xform?this.dispatchXform(X):this.dispatch(X)}done(){if(N.debug(this.id,"entering done()"),this.state>=w.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=w.DONE,this.dispatchTo("done"))this.state<w.UNSUBSCRIBED&&this.unsubscribe();N.debug(this.id,"exiting done()")}error(X){const Z=this.wrapped,J=Z&&Z.error;return J&&N.debug(this.id,"attempting wrapped error handler"),J&&Z.error(X)||this.unhandledError(X)}unhandledError(X){return(N!==M0?N:console).warn(this.id,"unhandled error:",X),this.unsubscribe(),this.state=w.ERROR,!1}dispatchTo(X,Z){let J=this.wrapped;if(J)try{J[X]&&J[X](Z)}catch(Y){if(!this.error(Y))return!1}const W=X==="next"?this.subs:[...this.subs];for(let Y=W.length;Y-- >0;){J=W[Y];try{J[X]&&J[X](Z)}catch(U){if(X==="error"||!J.error||!J.error(U))return this.unhandledError(U)}}return!0}dispatch(X){N.debug(this.id,"dispatch",X),this.cacheLast&&(this.last=X),this.dispatchTo("next",X)}dispatchXform(X){let Z;try{Z=this.xform[2]([],X)}catch(J){this.error(J);return}if(this.dispatchXformVals(Z))j(Z)&&this.done()}dispatchXformDone(){let X;try{X=this.xform[1]([])}catch(Z){return this.error(Z)}return this.dispatchXformVals(X)}dispatchXformVals(X){const Z=y(X);for(let J=0,W=Z.length;J<W&&this.state<w.DONE;J++)this.dispatch(Z[J]);return this.state<w.ERROR}ensureState(){if(this.state>=w.DONE)i(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Q8=(X,Z)=>{const J=new z8(Z);return J.next(X),J};class z8 extends h{src;_cancel;_inited;constructor(X,Z){const[J,W]=k(X)?[X,Z||{}]:[void 0,X||{}];super(W.error?{error:W.error}:void 0,x("stream",W));this.src=J,this._inited=!1}subscribe(X,Z={}){const J=super.subscribe(X,Z);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(W){let Y=this.wrapped;if(!Y||!Y.error||!Y.error(W))this.unhandledError(W)}this._inited=!0}return J}unsubscribe(X){const Z=super.unsubscribe(X);if(Z&&(!X||(!this.subs||!this.subs.length)&&this.closeOut!==T.NEVER))this.cancel();return Z}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(X){if(super.error(X))return!0;return this.cancel(),!1}cancel(){if(this._cancel){N.debug(this.id,"cancel");const X=this._cancel;delete this._cancel,X()}}}var q8=(X,Z)=>X===T.FIRST||X===T.LAST&&!Z;var s0=function(X){return X?D0(s0(),X):c(()=>({}),(Z,[J,W])=>(Z[J]=W,Z))};var e0=function(X,Z){return G(Z)?g(e0(X),Z):O(k(X)?(J)=>[X(J),J]:(J)=>[X,J])};var X1=function(...X){const Z=k0(X1,X);if(Z)return Z;const J=X[0],W=X[1]!==!1;return O((Y)=>{const U=W?{}:Y;for(let V in Y)U[V]=J(Y[V]);return U})};var Z1=function(...X){const Z=k0(Z1,X,j0);if(Z)return Z;const{key:J,mergeOnly:W,reset:Y,all:U,backPressure:V}={key:u1,mergeOnly:!1,reset:!0,all:!0,backPressure:0,...X[1]},B=P(X[0])?new Set(X[0]):X[0],Q=new Set,q=new Map;let z={};const K=([$,v,_])=>{let f=!0;if(W||V<1)return[$,(M)=>{if(Y&&U&&Q.size>0||!Y&&f)M=_(M,z),z={},Q.clear(),f=!1;return v(M)},(M,X0)=>{const E=J(X0);if(B.has(E)){if(z[E]=X0,Q.add(E),W||K8(B,Q))if(M=_(M,z),f=!1,Y)z={},Q.clear();else z={...z}}return M}];else return[$,(M)=>{if(U&&Q.size>0)M=_(M,$8(q,Q)),q.clear(),Q.clear();return v(M)},(M,X0)=>{const E=J(X0);if(B.has(E)){let B0=q.get(E);!B0&&q.set(E,B0=[]),B0.length>=V&&i(`max back pressure (${V}) exceeded for input: ${String(E)}`),B0.push(X0),Q.add(E);while(K8(B,Q))if(M=_(M,$8(q,Q)),f=!1,j(M))break}return M}]};return K.keys=()=>B,K.clear=()=>{q.clear(),B.clear(),Q.clear(),z={}},K.add=($)=>{B.add($)},K.delete=($,v=!0)=>{if(q.delete($),B.delete($),v)Q.delete($),delete z[$]},K},K8=(X,Z)=>{if(Z.size<X.size)return!1;for(let J of X)if(!Z.has(J))return!1;return!0},$8=(X,Z)=>{const J={};for(let W of Z){const Y=X.get(W);J[W]=Y.shift(),!Y.length&&Z.delete(W)}return J};var H8=(X,Z)=>{let J=!0;for(let W of Z)J=X.removeID(W)&&J;return J};var C8=(X)=>new M8(X);class M8 extends h{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(X){const Z=Z1(new Set,{key:(W)=>W[0],mergeOnly:X.mergeOnly===!0,reset:X.reset===!0,all:X.all!==!1,backPressure:X.backPressure||0}),J=X1((W)=>W[1]);super(void 0,x("streamsync",{...X,xform:X.xform?L(Z,J,X.xform):L(Z,J)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=Z,this.clean=!!X.clean,X.src&&this.addAll(X.src)}add(X,Z){Z||(Z=X.id),this.ensureState(),this.psync.add(Z),this.realSourceIDs.set(Z,X.id),this.invRealSourceIDs.set(X.id,Z),this.idSources.set(X.id,X),this.sources.set(X,X.subscribe({next:(J)=>J[1]instanceof h?this.add(J[1]):this.next(J),done:()=>this.markDone(X),__owner:this},{xform:e0(Z),id:`in-${Z}`}))}addAll(X){for(let Z in X)this.psync.add(Z);for(let Z in X)this.add(X[Z],Z)}remove(X){const Z=this.sources.get(X);if(Z){const J=this.invRealSourceIDs.get(X.id);return N.info(`removing src: ${X.id} (${J})`),this.psync.delete(J,this.clean),this.realSourceIDs.delete(J),this.invRealSourceIDs.delete(X.id),this.idSources.delete(X.id),this.sources.delete(X),Z.unsubscribe(),!0}return!1}removeID(X){const Z=this.getSourceForID(X);return Z?this.remove(Z):!1}removeAll(X){for(let J of X)this.psync.delete(this.invRealSourceIDs.get(J.id));let Z=!0;for(let J of X)Z=this.remove(J)&&Z;return Z}removeAllIDs(X){return H8(this,X)}getSourceForID(X){return this.idSources.get(this.realSourceIDs.get(X))}getSources(){const X={};for(let[Z,J]of this.idSources)X[this.invRealSourceIDs.get(Z)]=J;return X}unsubscribe(X){if(!X){N.debug(this.id,"unsub sources");for(let Z of this.sources.values())Z.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(X)}markDone(X){this.remove(X),q8(this.closeIn,this.sources.size)&&this.done()}}var J1=d((X,Z=" ")=>{const J=n(String(Z),X);return(W,Y)=>{if(W==null)return J;return W=W.toString(),Y=Y!==void 0?Y:W.length,Y<X?J.substring(Y)+W:W}}),R2=J1(2,"0"),F8=J1(3,"0"),A2=J1(4,"0");var W1=function(X,Z){return G(Z)?g(W1(X),Z):(J)=>{const W=J[2];return t(J,(Y,U)=>X(U)?W(Y,U):Y)}};import{watch as IX} from"fs";import{resolve as V0} from"path";var P8={specs:q0({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},E0={include:p({alias:"I",desc:"Include CSS files (prepend)"})},s={pretty:l({alias:"p",desc:"Pretty print output"})},v0={noHeader:l({desc:"Don't emit generated header comment"})},O8={watch:l({alias:"w",desc:"Watch input files for changes"})};import{resolve as TX} from"path";var e=(X,Z,J)=>{Z=F(Z)?Z:Z.join("\n"),X?n0(TX(X),Z,J):console.log(Z)},_0=({info:{name:X,version:Z}})=>`/*! ${X} v${Z} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`;var N8={desc:"Transpile & bundle meta stylesheets to CSS",opts:{...P8,...E0,...s,...v0,...O8,force:p({alias:"f",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},fn:async(X)=>{const Z=b(V0(X.opts.specs),X.logger),J=vX(Z,X.opts.force||[],X.logger);if(X.opts.watch)await RX(X,Z,J);else D8(X,Z,J,X.inputs.map((W)=>A(V0(W),X.logger)))}},RX=async(X,Z,J)=>{let W=!0;const Y=()=>{X.logger.info("closing watchers..."),U.forEach((V)=>V.watcher.close()),W=!1},U=X.inputs.map((V,B)=>{V=V0(V);const Q=Q8(A(V,X.logger),{id:`in${F8(B)}`});return{input:Q,watcher:IX(V,{},(q)=>{if(q==="change")try{Q.next(A(V,X.logger))}catch(z){X.logger.warn(z.message),Y()}else X.logger.warn("input removed:",V),Y()})}});C8({src:s0(O(({input:V})=>[V.id,V],U))}).subscribe({next(V){try{D8(X,Z,J,Object.keys(V).sort().map((B)=>V[B]))}catch(B){X.logger.warn(B.message)}}}),process.on("SIGINT",Y);while(W)await m1(null,250)},D8=({logger:X,opts:{include:Z,noHeader:J,out:W,pretty:Y}},U,V,B)=>{const Q={logger:X,specs:U,format:Y?O0:a,mediaQueryIDs:new Set(Object.keys(U.media)),mediaQueryRules:{...V.mediaQueryRules},plainRules:{...V.plainRules}},q=Z?Z.map((z)=>A(V0(z),X).trim()):[];if(!J)q.push(_0(U));B.forEach((z)=>_X(z,Q)),EX(q,Q),AX(q,Q),e(W,q,X)},AX=(X,{logger:Z,specs:J,format:W,mediaQueryRules:Y})=>{for(let U in Y){const V=j8(Y[U],J);Z.debug("mediaquery rules",U,V),X.push(Y0(A0(SX(J.media,U),V),{format:W}))}},EX=(X,{logger:Z,specs:J,format:W,plainRules:Y})=>{const U=j8(Y,J);Z.debug("plain rules",U),X.push(Y0(U,{format:W}))},vX=(X,Z,J)=>{const W=new Set(Object.keys(X.media)),Y=new Set(Object.keys(X.classes)),U={},V={};if(Z.length&&Z[0][0]==="@")Z=[...m(A(V0(Z[0].substring(1)),J))];for(let B of Z){if(!B||B.startsWith("//"))continue;const{token:Q,query:q}=k8(B,W);let z;if(Q.includes("*")){const K=new RegExp(`^${Q.replace("*",".*")}\$`);z=[...W1(($)=>K.test($),Y)]}else if(Y.has(Q))z=[Q];else{J.warn(`unknown include rule ID: ${B}, skipping...`);continue}for(let K of z)J.debug("including class:",K),q?T8(U,q,`.${K}`,K):I8(V,`.${K}`,K)}return{mediaQueryRules:U,plainRules:V}},_X=(X,{specs:Z,mediaQueryIDs:J,mediaQueryRules:W,plainRules:Y})=>{const U=U0(),V=U0(U),B={root:U,curr:V,scopes:[V]};for(let Q of m(X)){if(!Q||/^\s*\/\//.test(Q))continue;for(let q of m(Q,/\s+/g)){if(!q)continue;let z=B.curr;switch(z.state){case"sel":case"nest":if(q==="{"){if(z.state==="sel")z.sel=z.sel.map((K)=>K.replace(",","")),z.path=bX(B.scopes);z.state="class"}else if(q==="}")w8(B);else{const K=W0(z.sel);if(!K||K.endsWith(","))z.sel.push(q);else z.sel[z.sel.length-1]+=" "+q}break;case"class":if(q==="{")z.state="nest",B.scopes.push(B.curr=U0(z));else if(q==="}")w8(B);else{let{token:K,query:$}=k8(q,J);if(!Z.classes[K])H(`unknown class ID: ${K}`);if($)T8(W,$,z.path,K);else I8(Y,z.path,K)}break;default:i(z.state)}}}},Y1=":",G8="///",U0=(X)=>({state:"sel",sel:X?[]:["<root>"],path:"",parent:X}),w8=(X)=>{const Z=!X.curr.sel.length;if(F0(!!X.curr.parent,"stack underflow"),X.scopes.pop(),X.scopes.length>0){if(X.curr=W0(X.scopes),!Z&&X.curr.state==="nest")X.scopes.push(X.curr=U0(X.curr))}else X.scopes.push(X.curr=U0(X.root))},bX=(X)=>X.map((Z)=>Z.sel.join(",")).join(G8),j8=(X,Z)=>Object.entries(X).map(([J,W])=>LX(J,W,Z)),LX=(X,Z,J)=>{const W=[];let Y=W;const U=X.split(G8);for(let V=0;V<U.length;V++){const B=U[V].split(",");if(V==U.length-1){const Q=Object.assign({},...O((q)=>J.classes[q],Z));if("__user"in Q)delete Q.__user;B.push(Q)}Y.push(B),Y=B}return W[0]},k8=(X,Z)=>{if(/^::?/.test(X))return{token:X};const J=X.lastIndexOf(Y1);if(J<0)return{token:X};const W=X.substring(0,J);if(!W.split(Y1).every((U)=>Z.has(U)))H(`invalid media query in token: ${X}`);return{token:X.substring(J+1),query:W}},SX=(X,Z)=>Z.split(Y1).reduce((J,W)=>Object.assign(J,X[W]),{}),T8=(X,Z,J,W)=>{if(!X[Z])X[Z]={};(X[Z][J]||(X[Z][J]=new Set)).add(W)},I8=(X,Z,J)=>(X[Z]||(X[Z]=new Set)).add(J);import{resolve as R8} from"path";var E8={desc:"Export entire generated framework as CSS",opts:{...E0,...s,...v0,media:p({alias:"m",desc:"Media query IDs (use 'ALL' for all)",delim:","})},inputs:1,fn:async(X)=>{const{logger:Z,opts:{include:J,media:W,noHeader:Y,pretty:U,out:V},inputs:B}=X,Q=b(R8(B[0]),Z),q=J?J.map((z)=>A(R8(z),Z).trim()):[];if(!Y)q.push(_0(Q));q.push(yX(Q,W,U,Z)),e(V,q,Z)}},yX=(X,Z,J,W)=>{const Y=A8("",X);if(Z){const U=Z[0]==="ALL"?Object.keys(X.media):Z;for(let V of U)if(X.media[V])Y.push(A0(X.media[V],A8("-"+V,X)));else W.warn(`invalid media query ID: ${V}, skipping...`)}return Y0(Y,{format:J?O0:a})},A8=(X,Z)=>Object.entries(Z.classes).map(([J,W])=>[`.${J}${X}`,hX(W)]),hX=(X)=>{if("__user"in X)X={...X},delete X.__user;return X};import{statSync as fX} from"fs";import{resolve as mX} from"path";var v8={deg:Y8,em:a1,ex:t1,ms:J8,percent:r0,px:r1,rad:U8,rem:c1,second:W8,turn:V8,url:B8,vh:s1,vmax:Z8,vmin:X8,vw:e1,"%":r0},uX={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"]},_8={desc:"Generate framework rules from specs",opts:{...s,prec:H1({default:3,desc:"Number of fractional digits"})},inputs:1,fn:async(X)=>{const{logger:Z,opts:{prec:J,out:W,pretty:Y},inputs:U}=X,V=mX(U[0]);if(!fX(V).isDirectory())H(`${V} is not a directory`);const B={info:{name:"TODO",version:"0.0.0"},media:{},classes:{}};i1(J);for(let Q of L1(V,".json")){const q=b(Q,Z);Object.assign(B.info,q.info),Object.assign(B.media,q.media);for(let z of q.specs)gX(q,z,B.classes,Z)}e(W,JSON.stringify(B,null,Y?4:0),Z)}},gX=(X,Z,J,W)=>{const Y=P(Z.var)?Z.var:[""],U=F(Z.props)?{[Z.props]:"<v>"}:Z.props,V=xX(Z,X),B=new Set;for(let Q of Y)for(let[q,z]of T0(uX[Q],Object.keys(V))){const K=U1(Z.name,Q,q,z,V[z]),$=dX(V[z],Z.unit);if(!J[K])J[K]=Z.user!=null?{__user:Z.user}:{};else if(!B.has(K))H(`duplicate class ID: ${K}`);B.add(K);for(let[v,_]of Object.entries(U)){const f=U1(v,Q,q,z,V[z]),M=U1(!Z.unit||F(_)?_:v8[Z.unit](_),Q,q,z,$);J[K][f]=M,W.debug(K,f,M)}}return J},xX=(X,Z)=>{const J=F(X.values)?Z.tables?.[X.values]||H(`invalid table ID: ${X.values}`):X.values;if(R(J))return J;const W=X.key==="v"?(Y)=>String(Y):X.key==="i1"?(Y,U)=>String(U+1):X.key===void 0?(Y,U)=>String(U):H(`invalid key type: ${X.key}`);return J.reduce((Y,U,V)=>{return Y[W(U,V)]=U,Y},{})},dX=(X,Z)=>{if(!Z||F(X))return X;const J=v8[Z];if(!J)H(`invalid unit: ${Z}`);return J(X)},U1=(X,Z,J,W,Y)=>X.replace("<vid>",Z).replace("<var>",J).replace("<k>",W).replace("<v>",String(Y));var V1=b(nX(import.meta.dir,"package.json"));v1({name:"metacss",opts:{out:q0({alias:"o",desc:"Output file (or stdout)"}),verbose:l({alias:"v",desc:"Display extra process information"})},commands:{convert:N8,export:E8,generate:_8},ctx:async(X)=>{if(X.opts.verbose)X.logger.level=C.DEBUG;return{...X,format:H0}},usage:{prefix:`
2
+ var b0={default:95,hint:90,multi:90,param:96,required:33};var L0=(X)=>X;var d=function(X,Z){return!Z&&(Z={}),(...J)=>{const W=JSON.stringify(J);if(W!==void 0)return W in Z?Z[W]:Z[W]=X.apply(null,J);return X.apply(null,J)}};var n=d((X,Z)=>X.repeat(Z));var Q1=(X)=>/^[a-f0-9]+$/i.test(X);var z1=(X)=>/^[-+]?\d+$/.test(X),q1=(X)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(X);var I=(X,Z=(J)=>J!==void 0?": "+J:"")=>class extends Error{constructor(J){super(X(J)+Z(J))}};var b8=I(()=>"illegal argument(s)"),H=(X)=>{throw new b8(X)};var S0=(X)=>q1(X)?parseFloat(X):H(`not a numeric value: ${X}`),K1=(X)=>X.map(S0),y0=(X)=>Q1(X)?parseInt(X,16):H(`not a hex value: ${X}`),$1=(X)=>X.map(y0),h0=(X)=>z1(X)?parseInt(X):H(`not an integer: ${X}`),H1=(X)=>X.map(h0);var z0=(X,Z)=>(J)=>({coerce:X,hint:Z,group:"main",...J}),q0=(X,Z)=>(J)=>({hint:L8(Z,J.delim),multi:!0,coerce:X,group:"main",...J}),L8=(X,Z)=>X+(Z?`[${Z}..]`:""),l=(X)=>({flag:!0,default:!1,group:"flags",...X}),p=z0(L0,"STR"),o=q0(L0,"STR"),K4=z0(S0,"NUM"),$4=z0(y0,"HEX"),C1=z0(h0,"INT"),H4=q0(K1,"NUM"),C4=q0($1,"HEX"),M4=q0(H1,"INT");var C=((X)=>{return X[X.FINE=0]="FINE",X[X.DEBUG=1]="DEBUG",X[X.INFO=2]="INFO",X[X.WARN=3]="WARN",X[X.SEVERE=4]="SEVERE",X[X.NONE=5]="NONE",X})(C||{});class f0{id;level;constructor(X,Z=C.FINE){this.id=X,this.level=typeof Z==="string"?C[Z]:Z}enabled(X){return this.level<=X}fine(...X){this.level<=C.FINE&&this.log(C.FINE,X)}debug(...X){this.level<=C.DEBUG&&this.log(C.DEBUG,X)}info(...X){this.level<=C.INFO&&this.log(C.INFO,X)}warn(...X){this.level<=C.WARN&&this.log(C.WARN,X)}severe(...X){this.level<=C.SEVERE&&this.log(C.SEVERE,X)}}var M1=(X)=>X.map((Z)=>{if(typeof Z==="function")Z=Z();if(!(typeof Z==="string"||typeof Z==="number"))Z=JSON.stringify(Z);return Z}).join(" ");class m0 extends f0{constructor(X,Z,J=C.FINE){super(Z,J);this.target=X}log(X,Z){this.target.write(`[${C[X]}] ${this.id}: ${M1(Z)}
3
+ `)}}var K0=d((X,Z=" ")=>{const J=n(String(Z),X);return(W,Y)=>{if(W==null)return J;return W=W.toString(),Y=Y!==void 0?Y:W.length,Y<X?W+J.substring(Y):W}});var F1=(X,Z)=>{return!Z&&(Z=new Map),(J)=>{let W;return Z.has(J)?Z.get(J):(Z.set(J,W=X(J)),W)}};var u0={black:1,blue:5,cyan:7,gray:17,green:3,magenta:6,red:2,white:24,yellow:4,lightBlue:21,lightCyan:23,lightGray:8,lightGreen:19,lightMagenta:22,lightRed:18,lightYellow:20,bgBlack:32,bgBlue:160,bgCyan:224,bgGray:544,bgGreen:96,bgMagenta:192,bgRed:64,bgWhite:768,bgYellow:128,bgLightBlue:672,bgLightCyan:736,bgLightGray:256,bgLightGreen:608,bgLightMagenta:704,bgLightRed:576,bgLightYellow:640};var S8=(X,Z)=>(J)=>X.format(Z,J),g0=(X)=>Object.keys(u0).reduce((Z,J)=>(Z[J]=S8(X,u0[J]),Z),{format:X});var P1="\x1B[0m",y8=["","1","2","1;2","4","1;4","2;4","1;2;4"],$0={format:(X,Z)=>$0.start(X)+Z+$0.end,start:F1((X)=>{let Z=[],J=X&15;return J&&Z.push(29+(X>>4&1)*60+J),J=X>>5&15,J&&Z.push(39+(X>>9&1)*60+J),J=X>>10,J&&Z.push(y8[J]),"\x1B["+Z.join(";")+"m"}),end:P1,prefix:P1,suffix:"\n"};var w1={format:(X,Z)=>String(Z),prefix:"",suffix:"\n",start:()=>"",end:""};var H0=g0($0),N1=g0(w1);var P=Array.isArray;var h8=(X)=>X.toUpperCase(),O1=(X)=>X.toLowerCase(),D1=(X)=>X.length?X[0].toUpperCase()+X.substring(1):X,G1=(X,Z="-")=>O1(X.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(J,W,Y)=>W+Z+Y));var j1=(X,Z="-")=>O1(X).replace(new RegExp(`\\${Z}+(\\w)`,"g"),(J,W)=>h8(W));var k1=Object.getPrototypeOf,R=(X)=>{let Z;return X!=null&&typeof X==="object"&&((Z=k1(X))===null||k1(Z)===null)};var f8=/\x1b\[[0-9;]+m/g,m8=(X)=>X.replace(f8,"");var C0=(X)=>m8(X).length;var T1=(X=!1,Z)=>(J)=>X||typeof J!=="string"&&typeof J!=="number"?JSON.stringify(J,null,Z):String(J);function*m(X,Z=/\r?\n/g,J=!1){let W=0;const Y=X.length,U=~~J;let V;if(typeof Z==="string")V=new RegExp(Z,"g");else if(!Z.flags.includes("g"))V=new RegExp(Z,Z.flags+"g");else V=Z;for(;W<Y;){const B=V.exec(X);if(!B){yield X.substring(W);return}const Q=B[0].length;yield X.substring(W,B.index+U*Q),W=B.index+Q}}class x0{n=0;w=[];constructor(X,Z){X!=null&&this.add(X,Z)}add(X,Z=X.length){return this.w.push(X),this.n+=Z+~~(this.n>0),this}toString(){return this.w.join(" ")}}var u8={length:(X)=>X.length,split:(X,Z)=>Z},R1={length:C0,split:(X,Z)=>{const J=/\x1b\[[0-9;]+m/g;let W=Z,Y;while(Y=J.exec(X)){if(Y.index>=Z)break;const U=Y[0].length;W+=U,Z+=U}return W}},I1=(X,Z,J,W)=>{const Y=X[X.length-1];Y&&W-Y.n>J?Y.add(Z,J):X.push(new x0(Z,J))},g8=(X,{width:Z,min:J,hard:W,splitter:Y},U=0,V=[])=>{let B=Y.length(X),Q=Z-U;if(Q<J&&Q<B)Q=Z;while(W&&B>Q){const q=Y.split(X,Q),z=X.substring(0,q);I1(V,z,Q,Z),X=X.substring(q),Q=Z,B=Y.length(X)}return I1(V,X,B,Z),V},x8=(X,Z,J=[])=>{if(!X.length)return J.push(new x0),J;const W={width:80,min:4,hard:!1,splitter:u8,...Z};for(let Y of m(X,Z.delimWord||/\s/g)){const U=J[J.length-1];g8(Y,W,U&&U.n>0?U.n+1:0,J)}return J},A1=(X,Z)=>{let J=[];for(let W of m(X,Z.delimLine))J=J.concat(x8(W,Z));return J};var J0=(X,Z={})=>{Z={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...Z};const J=R(Z.color)?{...b0,...Z.color}:Z.color?b0:{},W=n(" ",Z.paramWidth),Y=(B)=>B.map((Q)=>d8(Q,X[Q],Z,J,W)),U=Object.keys(X).sort(),V=Z.groups?Z.groups.map((B)=>[B,U.filter((Q)=>X[Q].group===B)]).filter((B)=>!!B[1].length):[["options",U]];return[...d0(Z.prefix,Z.lineWidth),...V.map(([B,Q])=>[...Z.showGroupNames?[`${D1(B)}:
4
+ `]:[],...Y(Q),""].join("\n")),...d0(Z.suffix,Z.lineWidth)].join("\n")},d8=(X,Z,J,W,Y)=>{const U=n8(Z,W),V=l8(Z,W,U),B=W0(`--${G1(X)}`,W.param),Q=`${V}${B}${U}`,q=Z.optional===!1&&Z.default===void 0,z=[];q&&z.push("required"),Z.multi&&z.push("multiple");const K=p8(z,W,q)+(Z.desc||"")+o8(Z,J,W);return K0(J.paramWidth)(Q,C0(Q))+d0(K,J.lineWidth-J.paramWidth).map(($,v)=>v>0?Y+$:$).join("\n")},n8=(X,Z)=>X.hint?W0(" "+X.hint,Z.hint):"",l8=(X,Z,J)=>X.alias?`${W0("-"+X.alias,Z.param)}${J}, `:"",p8=(X,Z,J)=>X.length?W0(`[${X.join(", ")}] `,J?Z.required:Z.multi):"",o8=(X,Z,J)=>Z.showDefaults&&X.default!=null&&X.default!==!1?W0(` (default: ${T1(!0)(X.defaultHint!=null?X.defaultHint:X.default)})`,J.default):"",W0=(X,Z)=>Z!=null?`\x1B[${Z}m${X}\x1B[0m`:X,d0=(X,Z)=>X?A1(X,{width:Z,splitter:R1,hard:!0}):[];var i8=I(()=>"parse error"),E1=(X,Z,J)=>{J={start:2,showUsage:!0,help:["--help","-h"],...J};try{return a8(X,Z,J)}catch(W){if(J.showUsage)console.log(W.message+"\n\n"+J0(X,J.usageOpts));throw new i8(W.message)}},a8=(X,Z,J)=>{const W=t8(X),Y={};let U,V,B=J.start;for(;B<Z.length;){const Q=Z[B];if(!U){if(J.help.includes(Q)){console.log(J0(X,J.usageOpts));return}const q=c8(X,W,Y,Q);if(U=q.id,V=q.spec,B=B+~~(q.state<2),q.state)break}else{if(r8(V,Y,U,Q))break;U=null,B++}}return U&&H(`missing value for: --${U}`),{result:s8(X,Y),index:B,rest:Z.slice(B),done:B>=Z.length}},t8=(X)=>Object.entries(X).reduce((Z,[J,W])=>W.alias?(Z[W.alias]=J,Z):Z,{}),c8=(X,Z,J,W)=>{if(W[0]==="-"){let Y;if(W[1]==="-"){if(W==="--")return{state:1};Y=j1(W.substring(2))}else Y=Z[W.substring(1)],!Y&&H(`unknown option: ${W}`);const U=X[Y];if(!U&&H(Y),U.flag){if(J[Y]=!0,Y=void 0,U.fn&&!U.fn("true"))return{state:1,spec:U}}return{state:0,id:Y,spec:U}}return{state:2}},r8=(X,Z,J,W)=>{if(/^-[a-z]/i.test(W)&&H(`missing value for: --${J}`),X.multi)P(Z[J])?Z[J].push(W):Z[J]=[W];else Z[J]=W;return X.fn&&!X.fn(W)},s8=(X,Z)=>{let J;for(let W in X)if(J=X[W],Z[W]===void 0){if(J.default!==void 0)Z[W]=J.default;else if(J.optional===!1)H(`missing arg: --${W}`)}else if(J.coerce)e8(J,Z,W);return Z},e8=(X,Z,J)=>{try{if(X.multi&&X.delim)Z[J]=Z[J].reduce((W,Y)=>(W.push(...Y.split(X.delim)),W),[]);Z[J]=X.coerce(Z[J])}catch(W){throw new Error(`arg --${J}: ${W.message}`)}};var _1=async(X)=>{const Z=X.argv||process.argv,J=!process.env.NO_COLOR,W={prefix:"",color:J,...X.usage};try{let Y,U,V=X.start??2;if(X.single){if(Y=Object.keys(X.commands)[0],!Y)H("no command provided");U=X.commands[Y]}else{if(Y=Z[V],U=X.commands[Y],W.prefix+=XX(X.commands),!U)v1(X,W);V++}let B;try{B=E1({...X.opts,...U.opts},Z,{showUsage:!0,usageOpts:W,start:V})}catch(q){}if(!B)process.exit(1);if(U.inputs!==void 0&&U.inputs!==B.rest.length)process.stderr.write(`expected ${U.inputs||0} input(s)
5
+ `),v1(X,W);const Q=await X.ctx({logger:new m0(process.stderr,X.name,"INFO"),format:J?H0:N1,opts:B.result,inputs:B.rest},U);if(await U.fn(Q),X.post)await X.post(Q,U)}catch(Y){process.stderr.write(Y.message+"\n\n"),process.exit(1)}},v1=(X,Z)=>{process.stderr.write(J0(X.opts,Z)),process.exit(1)},XX=(X)=>["\nAvailable commands:\n",...Object.keys(X).map((Z)=>`${K0(16)(Z)}: ${X[Z].desc}`),"\n"].join("\n");import{existsSync as ZX,mkdirSync as JX,statSync as WX} from"fs";import{sep as YX} from"path";var b1=(X)=>{const Z=X.substring(0,X.lastIndexOf(YX));return Z.length>0&&!ZX(Z)?(JX(Z,{recursive:!0}),!0):!1},L1=(X)=>WX(X).isDirectory();var k=(X)=>typeof X==="function";var F=(X)=>typeof X==="string";import{readdirSync as UX,statSync as k5} from"fs";import{sep as VX} from"path";function*y1(X,Z="",J,W=Infinity,Y=0){if(Y>=W)return;const U=QX(Z);for(let V of UX(X).sort()){const B=X+VX+V;try{if(L1(B))yield*y1(B,Z,J,W,Y+1);else if(U(B))yield B}catch(Q){J&&J.warn(`ignoring file: ${V} (${Q.message})`)}}}var S1=(X,Z="",J=Infinity,W)=>y1(X,Z,W,J,0);var BX=(X)=>F(X)?new RegExp(`${X.replace(/\./g,"\\.")}\$`):X,QX=(X)=>k(X)?X:(X=BX(X),(Z)=>X.test(Z));import{readFileSync as qX} from"fs";import{writeFileSync as zX} from"fs";var h1=(X,Z,J,W,Y=!1)=>{if(W&&W.info(`${Y?"[dryrun] ":""}writing file: ${X}`),Y)return;b1(X),zX(X,Z,!J&&F(Z)?"utf-8":J)};var A=(X,Z,J="utf-8")=>{return Z&&Z.debug("reading file:",X),qX(X,J)},n0=(X,Z,J,W=!1)=>h1(X,P(Z)?Z.join("\n"):Z,"utf-8",J,W);var b=(X,Z)=>JSON.parse(A(X,Z));var M0=Object.freeze({level:C.NONE,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){}});import{join as nX} from"path";var KX=I(()=>"Assertion failed"),F0=(typeof process!=="undefined"&&process.env!==void 0?!0:import.meta.env?import.meta.env.MODE!=="production"||!!import.meta.env.UMBRELLA_ASSERTS||!!import.meta.env.VITE_UMBRELLA_ASSERTS:!0)?(X,Z)=>{if(typeof X==="function"&&!X()||!X)throw new KX(typeof Z==="function"?Z():Z)}:()=>{};var P0=(X)=>X!=null&&typeof X!=="function"&&X.length!==void 0;var f1=(X)=>{return(X==null||!X[Symbol.iterator])&&H(`value is not iterable: ${X}`),X};var m1=(X)=>P0(X)?X:[...f1(X)];var Y0=(X)=>X[X.length-1];var $X=I(()=>"illegal arity"),i=(X)=>{throw new $X(X)};var HX=I(()=>"illegal state"),a=(X)=>{throw new HX(X)};var l0=function(...X){let[Z,J,W,Y,U,V,B,Q,q,z]=X;switch(X.length){case 0:i(0);case 1:return Z;case 2:return(...$)=>Z(J(...$));case 3:return(...$)=>Z(J(W(...$)));case 4:return(...$)=>Z(J(W(Y(...$))));case 5:return(...$)=>Z(J(W(Y(U(...$)))));case 6:return(...$)=>Z(J(W(Y(U(V(...$))))));case 7:return(...$)=>Z(J(W(Y(U(V(B(...$)))))));case 8:return(...$)=>Z(J(W(Y(U(V(B(Q(...$))))))));case 9:return(...$)=>Z(J(W(Y(U(V(B(Q(q(...$)))))))));case 10:default:const K=(...$)=>Z(J(W(Y(U(V(B(Q(q(z(...$))))))))));return X.length===10?K:l0(K,...X.slice(10))}};var u1=(X,Z)=>new Promise((J)=>setTimeout(()=>J(X),Z));var g1=(X)=>X;var x1=["-moz-","-ms-","-o-","-webkit-"],t={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},w0={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var G=(X)=>X!=null&&typeof X[Symbol.iterator]==="function";var N0=(X,Z)=>X!=null&&typeof X[Z]==="function";var u=(X)=>N0(X,"xform")?X.xform():X;var L=function(...X){return X=X.map(u),l0.apply(null,X)};var O0=(X)=>X!=null&&typeof X!=="string"&&typeof X[Symbol.iterator]==="function";var c=(X,Z)=>[X[0],X[1],Z];var S=Symbol(),p0=()=>{};class o0{value;constructor(X){this.value=X}deref(){return this.value}}var j=(X)=>X instanceof o0;var y=(X)=>X instanceof o0?X.deref():X;var D0=function(...X){const Z=X[0],J=Z[0],W=Z[1],Y=Z[2];X=CX(X);const U=X[0]==null?J():X[0],V=X[1];return y(W(N0(V,"$reduce")?V.$reduce(Y,U):P0(V)?MX(Y,U,V):FX(Y,U,V)))};var CX=(X)=>X.length===2?[void 0,X[1]]:X.length===3?[X[1],X[2]]:i(X.length),MX=(X,Z,J)=>{for(let W=0,Y=J.length;W<Y;W++)if(Z=X(Z,J[W]),j(Z)){Z=Z.deref();break}return Z},FX=(X,Z,J)=>{for(let W of J)if(Z=X(Z,W),j(Z)){Z=Z.deref();break}return Z},r=(X,Z)=>[X,(J)=>J,Z];var G0=function(X){return X?[...X]:r(()=>[],(Z,J)=>(Z.push(J),Z))};function*j0(X,Z){const J=u(X)(G0()),W=J[1],Y=J[2];for(let U of Z){const V=Y([],U);if(j(V)){yield*y(W(V.deref()));return}if(V.length)yield*V}yield*y(W([]))}function*g(X,Z){const J=u(X)([p0,p0,(W,Y)=>Y])[2];for(let W of Z){let Y=J(S,W);if(j(Y)){if(Y=y(Y.deref()),Y!==S)yield Y;return}if(Y!==S)yield Y}}var k0=(X,Z,J=g)=>{const W=Z.length-1;return G(Z[W])?Z.length>1?J(X.apply(null,Z.slice(0,W)),Z[W]):J(X(),Z[0]):void 0};var i0=function(X,Z){return G(Z)?j0(i0(X),F(Z)?[Z]:Z):(J)=>{const W=J[2],Y=(U,V)=>{const B=X(V);if(B){for(let Q of B)if(U=Y(U,Q),j(U))break;return U}return W(U,V)};return c(J,Y)}};var d1=function(X){return i0((Z)=>O0(Z)?Z:void 0,X)};var w=function(X,Z){return G(Z)?g(w(X),Z):(J)=>{const W=J[2];return c(J,(Y,U)=>W(Y,X(U)))}};function*T0(...X){const Z=X.length-1;if(Z<0)return;const J=new Array(Z+1).fill(0),W=X.map(m1),Y=W.reduce((U,V)=>U*V.length,1);for(let U=0;U<Y;U++){const V=[];for(let B=Z;B>=0;B--){const Q=W[B];let q=J[B];if(q===Q.length)J[B]=q=0,B>0&&J[B-1]++;V[B]=Q[q]}J[Z]++,yield V}}function*n1(X,Z=Infinity){while(Z-- >0)yield X}var a0=function(X,Z){X=X||"";let J=!0;return Z?[...Z].join(X):r(()=>"",(W,Y)=>(W=J?W+Y:W+X+Y,J=!1,W))};var I0=function(...X){return PX(I0,D0,X)};var PX=(X,Z,J)=>{let W,Y;switch(J.length){case 4:Y=J[3],W=J[2];break;case 3:Y=J[2];break;case 2:return w((U)=>X(J[0],J[1],U));default:i(J.length)}return Z(u(J[0])(J[1]),W,Y)};var wX=new Set,NX=":[",l1=L(d1(),w((X)=>NX.indexOf(X.charAt(0))>=0?X:" "+X)),OX=(X,Z)=>L(X,w((J)=>F(J)&&J.indexOf(" .")==0?J+Z:J)),s=(X,Z,J,W)=>{const Y=J.length,U=[];let V,B;const Q=(q,z)=>{let K=null;if(P(z))s(X,t0(Z,U),z,W);else if(G(z)&&!F(z))s(X,t0(Z,U),[...z],W);else if((B=k(z))||(K=W.fns[z]))if(!Z.length){if(K)return K.apply(null,J.slice(q+1))(X,W),!0;z(X,W)}else if(B)Q(q,z());else H(`quoted fn ('${z}') only allowed at head position`);else if(R(z))V=Object.assign(V||{},z);else if(z!=null)U.push(z)};for(let q=0;q<Y;q++)if(Q(q,J[q]))return X;return V&&X.push(DX(Z,U,V,W)),X},t0=(X,Z)=>X.length?[...T0(X,Z)]:Z,DX=(X,Z,J,W)=>{const Y=W.format,U=R0(W),V=W.scope?OX(l1,W.scope):l1;return[U,I0(w((B)=>I0(V,a0(),P(B)?B:[B]).trim()),a0(Y.ruleSep),t0(X,Z)),Y.declStart,c0(J,W),U,Y.declEnd].join("")},c0=(X,Z)=>{const J=Z.format,W=Z.autoprefix||wX,Y=R0(Z,Z.depth+1),U=[];for(let V in X)if(X.hasOwnProperty(V)){let B=X[V];if(k(B))B=B(X);if(P(B))B=B.map((Q)=>P(Q)?Q.join(" "):Q).join(J.ruleSep);if(W.has(V))for(let Q of Z.vendors)U.push(`${Y}${Q}${V}:${J.valSep}${B};`);U.push(`${Y}${V}:${J.valSep}${B};`)}return U.join(J.decls)+J.decls},R0=(X,Z=X.depth)=>Z>1?[...n1(X.format.indent,Z)].join(""):Z>0?X.format.indent:"";var o1=(X,Z,J)=>(W,Y)=>{const U=R0(Y);return W.push(`${U}${X} ${GX(Z)}${Y.format.declStart}`),Y.depth++,s(W,[],J,Y),Y.depth--,W.push(U+Y.format.declEnd),W},GX=(X)=>{if(F(X))return X;const Z=[];for(let J in X)if(X.hasOwnProperty(J)){let W=X[J];if(W===!0)W=p1.has(J)?J:`(${J})`;else if(W===!1)W=`(not ${p1.has(J)?J:`(${J})`})`;else if(W==="only")W+=" "+J;else W=`(${J}:${W})`;Z.push(W)}return Z.join(" and ")},p1=new Set(["all","print","screen"]);var U0=(X,Z)=>{return Z={format:t,vendors:x1,fns:{},depth:0,...Z},P(Z.autoprefix)&&(Z.autoprefix=new Set(Z.autoprefix)),R(X)?c0(X,Z):k(X)?X([],Z).join(Z.format.rules):s([],[],P(X)?X:O0(X)?[...X]:H("invalid rules"),Z).join(Z.format.rules)};var A0=(X,Z)=>o1("@media",X,Z);var i1=4,a1=(X)=>i1=X,D=(X)=>X===(X|0)?String(X):X.toFixed(i1).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,""),t1=(X)=>`${D(X)}em`,c1=(X)=>`${D(X)}ex`,r1=(X)=>`${D(X)}rem`,r0=(X)=>`${D(X)}%`,s1=(X)=>`${D(X)}px`,e1=(X)=>`${D(X)}vh`,X8=(X)=>`${D(X)}vw`,Z8=(X)=>`${D(X)}vmin`,J8=(X)=>`${D(X)}vmax`,W8=(X)=>`${X|0}ms`,Y8=(X)=>`${D(X)}s`;var U8=(X)=>`${D(X)}deg`,V8=(X)=>`${D(X)}rad`,B8=(X)=>`${D(X)}turn`,Q8=(X)=>`url(${X})`;var N=((X)=>{return X[X.IDLE=0]="IDLE",X[X.ACTIVE=1]="ACTIVE",X[X.DONE=2]="DONE",X[X.UNSUBSCRIBED=3]="UNSUBSCRIBED",X[X.ERROR=4]="ERROR",X})(N||{}),T=((X)=>{return X[X.NEVER=0]="NEVER",X[X.FIRST=1]="FIRST",X[X.LAST=2]="LAST",X})(T||{});var jX=0,kX=()=>jX++,x=(X,Z)=>!Z||!Z.id?{...Z,id:X+"-"+kX()}:Z;var O=M0;class h{constructor(X,Z){this.wrapped=X,Z=x("sub",{closeIn:T.LAST,closeOut:T.LAST,cache:!0,...Z}),this.parent=Z.parent,this.id=Z.id,this.closeIn=Z.closeIn,this.closeOut=Z.closeOut,this.cacheLast=Z.cache,Z.xform&&(this.xform=Z.xform(G0()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=S;state=N.IDLE;subs=[];deref(){return this.last!==S?this.last:void 0}getState(){return this.state}setState(X){this.state=X}subscribe(X,Z={}){this.ensureState();let J;if(X instanceof h&&!Z.xform)X.ensureState(),F0(!X.parent,`sub '${X.id}' already has a parent`),X.parent=this,J=X;else J=new h(X,{...Z,parent:this});return this.subs.push(J),this.setState(N.ACTIVE),J.setState(N.ACTIVE),this.last!=S&&J.next(this.last),J}transform(...X){let Z,J;if(R(Y0(X)))J=X.pop(),Z={error:J.error};return this.subscribe(Z,x("xform",X.length>0?{...J,xform:L(...X)}:J))}map(X,Z){return this.transform(w(X),Z||{})}unsubscribe(X){return X?this.unsubscribeChild(X):this.unsubscribeSelf()}unsubscribeSelf(){return O.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<N.UNSUBSCRIBED&&(this.state=N.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(X){O.debug(this.id,"unsub child",X.id);const Z=this.subs.indexOf(X);if(Z>=0){if(this.subs.splice(Z,1),this.closeOut===T.FIRST||!this.subs.length&&this.closeOut!==T.NEVER)this.unsubscribe();return!0}return!1}next(X){if(this.state>=N.DONE)return;this.xform?this.dispatchXform(X):this.dispatch(X)}done(){if(O.debug(this.id,"entering done()"),this.state>=N.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=N.DONE,this.dispatchTo("done"))this.state<N.UNSUBSCRIBED&&this.unsubscribe();O.debug(this.id,"exiting done()")}error(X){const Z=this.wrapped,J=Z&&Z.error;return J&&O.debug(this.id,"attempting wrapped error handler"),J&&Z.error(X)||this.unhandledError(X)}unhandledError(X){return(O!==M0?O:console).warn(this.id,"unhandled error:",X),this.unsubscribe(),this.state=N.ERROR,!1}dispatchTo(X,Z){let J=this.wrapped;if(J)try{J[X]&&J[X](Z)}catch(Y){if(!this.error(Y))return!1}const W=X==="next"?this.subs:[...this.subs];for(let Y=W.length;Y-- >0;){J=W[Y];try{J[X]&&J[X](Z)}catch(U){if(X==="error"||!J.error||!J.error(U))return this.unhandledError(U)}}return!0}dispatch(X){O.debug(this.id,"dispatch",X),this.cacheLast&&(this.last=X),this.dispatchTo("next",X)}dispatchXform(X){let Z;try{Z=this.xform[2]([],X)}catch(J){this.error(J);return}if(this.dispatchXformVals(Z))j(Z)&&this.done()}dispatchXformDone(){let X;try{X=this.xform[1]([])}catch(Z){return this.error(Z)}return this.dispatchXformVals(X)}dispatchXformVals(X){const Z=y(X);for(let J=0,W=Z.length;J<W&&this.state<N.DONE;J++)this.dispatch(Z[J]);return this.state<N.ERROR}ensureState(){if(this.state>=N.DONE)a(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var z8=(X,Z)=>{const J=new q8(Z);return J.next(X),J};class q8 extends h{src;_cancel;_inited;constructor(X,Z){const[J,W]=k(X)?[X,Z||{}]:[void 0,X||{}];super(W.error?{error:W.error}:void 0,x("stream",W));this.src=J,this._inited=!1}subscribe(X,Z={}){const J=super.subscribe(X,Z);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(W){let Y=this.wrapped;if(!Y||!Y.error||!Y.error(W))this.unhandledError(W)}this._inited=!0}return J}unsubscribe(X){const Z=super.unsubscribe(X);if(Z&&(!X||(!this.subs||!this.subs.length)&&this.closeOut!==T.NEVER))this.cancel();return Z}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(X){if(super.error(X))return!0;return this.cancel(),!1}cancel(){if(this._cancel){O.debug(this.id,"cancel");const X=this._cancel;delete this._cancel,X()}}}var K8=(X,Z)=>X===T.FIRST||X===T.LAST&&!Z;var s0=function(X){return X?D0(s0(),X):r(()=>({}),(Z,[J,W])=>(Z[J]=W,Z))};var e0=function(X,Z){return G(Z)?g(e0(X),Z):w(k(X)?(J)=>[X(J),J]:(J)=>[X,J])};var X1=function(...X){const Z=k0(X1,X);if(Z)return Z;const J=X[0],W=X[1]!==!1;return w((Y)=>{const U=W?{}:Y;for(let V in Y)U[V]=J(Y[V]);return U})};var Z1=function(...X){const Z=k0(Z1,X,j0);if(Z)return Z;const{key:J,mergeOnly:W,reset:Y,all:U,backPressure:V}={key:g1,mergeOnly:!1,reset:!0,all:!0,backPressure:0,...X[1]},B=P(X[0])?new Set(X[0]):X[0],Q=new Set,q=new Map;let z={};const K=([$,v,_])=>{let f=!0;if(W||V<1)return[$,(M)=>{if(Y&&U&&Q.size>0||!Y&&f)M=_(M,z),z={},Q.clear(),f=!1;return v(M)},(M,Z0)=>{const E=J(Z0);if(B.has(E)){if(z[E]=Z0,Q.add(E),W||$8(B,Q))if(M=_(M,z),f=!1,Y)z={},Q.clear();else z={...z}}return M}];else return[$,(M)=>{if(U&&Q.size>0)M=_(M,H8(q,Q)),q.clear(),Q.clear();return v(M)},(M,Z0)=>{const E=J(Z0);if(B.has(E)){let Q0=q.get(E);!Q0&&q.set(E,Q0=[]),Q0.length>=V&&a(`max back pressure (${V}) exceeded for input: ${String(E)}`),Q0.push(Z0),Q.add(E);while($8(B,Q))if(M=_(M,H8(q,Q)),f=!1,j(M))break}return M}]};return K.keys=()=>B,K.clear=()=>{q.clear(),B.clear(),Q.clear(),z={}},K.add=($)=>{B.add($)},K.delete=($,v=!0)=>{if(q.delete($),B.delete($),v)Q.delete($),delete z[$]},K},$8=(X,Z)=>{if(Z.size<X.size)return!1;for(let J of X)if(!Z.has(J))return!1;return!0},H8=(X,Z)=>{const J={};for(let W of Z){const Y=X.get(W);J[W]=Y.shift(),!Y.length&&Z.delete(W)}return J};var C8=(X,Z)=>{let J=!0;for(let W of Z)J=X.removeID(W)&&J;return J};var M8=(X)=>new F8(X);class F8 extends h{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(X){const Z=Z1(new Set,{key:(W)=>W[0],mergeOnly:X.mergeOnly===!0,reset:X.reset===!0,all:X.all!==!1,backPressure:X.backPressure||0}),J=X1((W)=>W[1]);super(void 0,x("streamsync",{...X,xform:X.xform?L(Z,J,X.xform):L(Z,J)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=Z,this.clean=!!X.clean,X.src&&this.addAll(X.src)}add(X,Z){Z||(Z=X.id),this.ensureState(),this.psync.add(Z),this.realSourceIDs.set(Z,X.id),this.invRealSourceIDs.set(X.id,Z),this.idSources.set(X.id,X),this.sources.set(X,X.subscribe({next:(J)=>J[1]instanceof h?this.add(J[1]):this.next(J),done:()=>this.markDone(X),__owner:this},{xform:e0(Z),id:`in-${Z}`}))}addAll(X){for(let Z in X)this.psync.add(Z);for(let Z in X)this.add(X[Z],Z)}remove(X){const Z=this.sources.get(X);if(Z){const J=this.invRealSourceIDs.get(X.id);return O.info(`removing src: ${X.id} (${J})`),this.psync.delete(J,this.clean),this.realSourceIDs.delete(J),this.invRealSourceIDs.delete(X.id),this.idSources.delete(X.id),this.sources.delete(X),Z.unsubscribe(),!0}return!1}removeID(X){const Z=this.getSourceForID(X);return Z?this.remove(Z):!1}removeAll(X){for(let J of X)this.psync.delete(this.invRealSourceIDs.get(J.id));let Z=!0;for(let J of X)Z=this.remove(J)&&Z;return Z}removeAllIDs(X){return C8(this,X)}getSourceForID(X){return this.idSources.get(this.realSourceIDs.get(X))}getSources(){const X={};for(let[Z,J]of this.idSources)X[this.invRealSourceIDs.get(Z)]=J;return X}unsubscribe(X){if(!X){O.debug(this.id,"unsub sources");for(let Z of this.sources.values())Z.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(X)}markDone(X){this.remove(X),K8(this.closeIn,this.sources.size)&&this.done()}}var J1=d((X,Z=" ")=>{const J=n(String(Z),X);return(W,Y)=>{if(W==null)return J;return W=W.toString(),Y=Y!==void 0?Y:W.length,Y<X?J.substring(Y)+W:W}}),R2=J1(2,"0"),P8=J1(3,"0"),A2=J1(4,"0");var W1=function(X,Z){return G(Z)?g(W1(X),Z):(J)=>{const W=J[2];return c(J,(Y,U)=>X(U)?W(Y,U):Y)}};import{watch as IX} from"fs";import{resolve as B0} from"path";var w8={specs:p({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},E0={include:o({alias:"I",desc:"Include CSS files (prepend)"})},e={pretty:l({alias:"p",desc:"Pretty print output"})},v0={noHeader:l({desc:"Don't emit generated header comment"})},N8={watch:l({alias:"w",desc:"Watch input files for changes"})};import{resolve as TX} from"path";var X0=(X,Z,J)=>{Z=F(Z)?Z:Z.join("\n"),X?n0(TX(X),Z,J):console.log(Z)},_0=({info:{name:X,version:Z}})=>`/*! ${X} v${Z} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`;var D8={desc:"Transpile & bundle meta stylesheets to CSS",opts:{...w8,...E0,...e,...v0,...N8,eval:p({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"}),force:o({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},fn:async(X)=>{const Z=b(B0(X.opts.specs),X.logger),J=vX(Z,X.opts.force||[],X.logger);if(X.opts.watch)await RX(X,Z,J);else if(X.opts.eval)Y1(X,Z,J,[X.opts.eval]);else Y1(X,Z,J,X.inputs.map((W)=>A(B0(W),X.logger)))}},RX=async(X,Z,J)=>{let W=!0;const Y=()=>{X.logger.info("closing watchers..."),U.forEach((V)=>V.watcher.close()),W=!1},U=X.inputs.map((V,B)=>{V=B0(V);const Q=z8(A(V,X.logger),{id:`in${P8(B)}`});return{input:Q,watcher:IX(V,{},(q)=>{if(q==="change")try{Q.next(A(V,X.logger))}catch(z){X.logger.warn(z.message),Y()}else X.logger.warn("input removed:",V),Y()})}});M8({src:s0(w(({input:V})=>[V.id,V],U))}).subscribe({next(V){try{Y1(X,Z,J,Object.keys(V).sort().map((B)=>V[B]))}catch(B){X.logger.warn(B.message)}}}),process.on("SIGINT",Y);while(W)await u1(null,250)},Y1=({logger:X,opts:{include:Z,noHeader:J,out:W,pretty:Y}},U,V,B)=>{const Q={logger:X,specs:U,format:Y?w0:t,mediaQueryIDs:new Set(Object.keys(U.media)),mediaQueryRules:{...V.mediaQueryRules},plainRules:{...V.plainRules}},q=Z?Z.map((z)=>A(B0(z),X).trim()):[];if(!J)q.push(_0(U));B.forEach((z)=>_X(z,Q)),EX(q,Q),AX(q,Q),X0(W,q,X)},AX=(X,{logger:Z,specs:J,format:W,mediaQueryRules:Y})=>{for(let U in Y){const V=j8(Y[U],J);Z.debug("mediaquery rules",U,V),X.push(U0(A0(SX(J.media,U),V),{format:W}))}},EX=(X,{logger:Z,specs:J,format:W,plainRules:Y})=>{const U=j8(Y,J);Z.debug("plain rules",U),X.push(U0(U,{format:W}))},vX=(X,Z,J)=>{const W=new Set(Object.keys(X.media)),Y=new Set(Object.keys(X.classes)),U={},V={};if(Z.length&&Z[0][0]==="@")Z=[...m(A(B0(Z[0].substring(1)),J))];for(let B of Z){if(!B||B.startsWith("//"))continue;const{token:Q,query:q}=k8(B,W);let z;if(Q.includes("*")){const K=new RegExp(`^${Q.replace("*",".*")}\$`);z=[...W1(($)=>K.test($),Y)]}else if(Y.has(Q))z=[Q];else{J.warn(`unknown include rule ID: ${B}, skipping...`);continue}for(let K of z)J.debug("including class:",K),q?T8(U,q,`.${K}`,K):I8(V,`.${K}`,K)}return{mediaQueryRules:U,plainRules:V}},_X=(X,{specs:Z,mediaQueryIDs:J,mediaQueryRules:W,plainRules:Y})=>{const U=V0(),V=V0(U),B={root:U,curr:V,scopes:[V]};for(let Q of m(X)){if(!Q||/^\s*\/\//.test(Q))continue;for(let q of m(Q,/\s+/g)){if(!q)continue;let z=B.curr;switch(z.state){case"sel":case"nest":if(q==="{"){if(z.state==="sel")z.sel=z.sel.map((K)=>K.replace(",","")),z.path=bX(B.scopes);z.state="class"}else if(q==="}")O8(B);else{const K=Y0(z.sel);if(!K||K.endsWith(","))z.sel.push(q);else z.sel[z.sel.length-1]+=" "+q}break;case"class":if(q==="{")z.state="nest",B.scopes.push(B.curr=V0(z));else if(q==="}")O8(B);else{let{token:K,query:$}=k8(q,J);if(!Z.classes[K])H(`unknown class ID: ${K}`);if($)T8(W,$,z.path,K);else I8(Y,z.path,K)}break;default:a(z.state)}}}},U1=":",G8="///",V0=(X)=>({state:"sel",sel:X?[]:["<root>"],path:"",parent:X}),O8=(X)=>{const Z=!X.curr.sel.length;if(F0(!!X.curr.parent,"stack underflow"),X.scopes.pop(),X.scopes.length>0){if(X.curr=Y0(X.scopes),!Z&&X.curr.state==="nest")X.scopes.push(X.curr=V0(X.curr))}else X.scopes.push(X.curr=V0(X.root))},bX=(X)=>X.map((Z)=>Z.sel.join(",")).join(G8),j8=(X,Z)=>Object.entries(X).map(([J,W])=>LX(J,W,Z)),LX=(X,Z,J)=>{const W=[];let Y=W;const U=X.split(G8);for(let V=0;V<U.length;V++){const B=U[V].split(",");if(V==U.length-1){const Q=Object.assign({},...w((q)=>J.classes[q],Z));if("__user"in Q)delete Q.__user;B.push(Q)}Y.push(B),Y=B}return W[0]},k8=(X,Z)=>{if(/^::?/.test(X))return{token:X};const J=X.lastIndexOf(U1);if(J<0)return{token:X};const W=X.substring(0,J);if(!W.split(U1).every((U)=>Z.has(U)))H(`invalid media query in token: ${X}`);return{token:X.substring(J+1),query:W}},SX=(X,Z)=>Z.split(U1).reduce((J,W)=>Object.assign(J,X[W]),{}),T8=(X,Z,J,W)=>{if(!X[Z])X[Z]={};(X[Z][J]||(X[Z][J]=new Set)).add(W)},I8=(X,Z,J)=>(X[Z]||(X[Z]=new Set)).add(J);import{resolve as R8} from"path";var E8={desc:"Export entire generated framework as CSS",opts:{...E0,...e,...v0,media:o({alias:"m",desc:"Media query IDs (use 'ALL' for all)",delim:","})},inputs:1,fn:async(X)=>{const{logger:Z,opts:{include:J,media:W,noHeader:Y,pretty:U,out:V},inputs:B}=X,Q=b(R8(B[0]),Z),q=J?J.map((z)=>A(R8(z),Z).trim()):[];if(!Y)q.push(_0(Q));q.push(yX(Q,W,U,Z)),X0(V,q,Z)}},yX=(X,Z,J,W)=>{const Y=A8("",X);if(Z){const U=Z[0]==="ALL"?Object.keys(X.media):Z;for(let V of U)if(X.media[V])Y.push(A0(X.media[V],A8("-"+V,X)));else W.warn(`invalid media query ID: ${V}, skipping...`)}return U0(Y,{format:J?w0:t})},A8=(X,Z)=>Object.entries(Z.classes).map(([J,W])=>[`.${J}${X}`,hX(W)]),hX=(X)=>{if("__user"in X)X={...X},delete X.__user;return X};import{statSync as fX} from"fs";import{resolve as mX} from"path";var v8={deg:U8,em:t1,ex:c1,ms:W8,percent:r0,px:s1,rad:V8,rem:r1,second:Y8,turn:B8,url:Q8,vh:e1,vmax:J8,vmin:Z8,vw:X8,"%":r0},uX={"":[""],a:[""],h:["-left","-right"],v:["-top","-bottom"],t:["-top"],top:["top"],b:["-bottom"],bottom:["bottom"],r:["-right"],right:["right"],l:["-left"],left:["left"],x:["-x"],y:["-y"]},_8={desc:"Generate framework rules from specs",opts:{...e,prec:C1({default:3,desc:"Number of fractional digits"})},inputs:1,fn:async(X)=>{const{logger:Z,opts:{prec:J,out:W,pretty:Y},inputs:U}=X,V=mX(U[0]);if(!fX(V).isDirectory())H(`${V} is not a directory`);const B={info:{name:"TODO",version:"0.0.0"},media:{},classes:{}};a1(J);for(let Q of S1(V,".json")){const q=b(Q,Z);Object.assign(B.info,q.info),Object.assign(B.media,q.media);for(let z of q.specs)gX(q,z,B.classes,Z)}X0(W,JSON.stringify(B,null,Y?4:0),Z)}},gX=(X,Z,J,W)=>{const Y=P(Z.var)?Z.var:[""],U=F(Z.props)?{[Z.props]:"<v>"}:Z.props,V=xX(Z,X),B=new Set;for(let Q of Y)for(let[q,z]of T0(uX[Q],Object.keys(V))){const K=V1(Z.name,Q,q,z,V[z]),$=dX(V[z],Z.unit);if(!J[K])J[K]=Z.user!=null?{__user:Z.user}:{};else if(!B.has(K))H(`duplicate class ID: ${K}`);B.add(K);for(let[v,_]of Object.entries(U)){const f=V1(v,Q,q,z,V[z]),M=V1(!Z.unit||F(_)?_:v8[Z.unit](_),Q,q,z,$);J[K][f]=M,W.debug(K,f,M)}}return J},xX=(X,Z)=>{const J=F(X.values)?Z.tables?.[X.values]||H(`invalid table ID: ${X.values}`):X.values;if(R(J))return J;const W=X.key==="v"?(Y)=>String(Y):X.key==="i1"?(Y,U)=>String(U+1):X.key===void 0?(Y,U)=>String(U):H(`invalid key type: ${X.key}`);return J.reduce((Y,U,V)=>{return Y[W(U,V)]=U,Y},{})},dX=(X,Z)=>{if(!Z||F(X))return X;const J=v8[Z];if(!J)H(`invalid unit: ${Z}`);return J(X)},V1=(X,Z,J,W,Y)=>X.replace("<vid>",Z).replace("<var>",J).replace("<k>",W).replace("<v>",String(Y));var B1=b(nX(import.meta.dir,"package.json"));_1({name:"metacss",opts:{out:p({alias:"o",desc:"Output file (or stdout)"}),verbose:l({alias:"v",desc:"Display extra process information"})},commands:{convert:D8,export:E8,generate:_8},ctx:async(X)=>{if(X.opts.verbose)X.logger.level=C.DEBUG;return{...X,format:H0}},usage:{prefix:`
6
6
  \u2588 \u2588 \u2588 \u2502
7
7
  \u2588\u2588 \u2588 \u2502
8
- \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${V1.name} ${V1.version}
9
- \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${V1.description}
8
+ \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${B1.name} ${B1.version}
9
+ \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${B1.description}
10
10
  \u2588 \u2502
11
11
  \u2588 \u2588 \u2502
12
12
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/meta-css",
3
- "version": "0.2.0",
3
+ "version": "0.3.0",
4
4
  "description": "Data-driven CSS framework codegen, transpiler & bundler",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -45,7 +45,7 @@
45
45
  "@thi.ng/compose": "^2.1.53",
46
46
  "@thi.ng/errors": "^2.4.8",
47
47
  "@thi.ng/file-io": "^1.1.2",
48
- "@thi.ng/hiccup-css": "^2.3.3",
48
+ "@thi.ng/hiccup-css": "^2.3.4",
49
49
  "@thi.ng/logger": "^2.1.1",
50
50
  "@thi.ng/rstream": "^8.2.17",
51
51
  "@thi.ng/strings": "^3.7.5",
@@ -65,12 +65,15 @@
65
65
  "cli",
66
66
  "codegen",
67
67
  "component",
68
+ "combinatorial",
69
+ "compiler",
68
70
  "css",
69
71
  "export",
70
72
  "fileformat",
71
73
  "generator",
74
+ "generative",
72
75
  "json",
73
- "template",
76
+ "transpiler",
74
77
  "typescript",
75
78
  "ui"
76
79
  ],
@@ -102,5 +105,5 @@
102
105
  "status": "alpha",
103
106
  "year": 2023
104
107
  },
105
- "gitHead": "118a3455103b268b315f312b616641022d81296a\n"
108
+ "gitHead": "a30bdb0136223fe2e413a1d27a71d3bcff1dfd53\n"
106
109
  }