@thi.ng/meta-css 0.11.3 → 0.12.1
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 +7 -1
- package/README.md +62 -4
- package/index.js +6 -6
- package/package.json +20 -20
- package/specs/_info.mcss.json +1 -1
- package/specs/colors.mcss.json +64 -0
- package/specs/display.mcss.json +9 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Change Log
|
|
2
2
|
|
|
3
|
-
- **Last updated**: 2024-
|
|
3
|
+
- **Last updated**: 2024-05-08T18:24:31Z
|
|
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,12 @@ 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.12.0](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.12.0) (2024-04-26)
|
|
13
|
+
|
|
14
|
+
#### 🚀 Features
|
|
15
|
+
|
|
16
|
+
- add color-scheme, light-dark() and appearance rules/tpls ([5f90a48](https://github.com/thi-ng/umbrella/commit/5f90a48))
|
|
17
|
+
|
|
12
18
|
### [0.11.1](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.11.1) (2024-04-20)
|
|
13
19
|
|
|
14
20
|
#### ♻️ Refactoring
|
package/README.md
CHANGED
|
@@ -50,6 +50,7 @@
|
|
|
50
50
|
- [Border radius](#border-radius)
|
|
51
51
|
- [Border width](#border-width)
|
|
52
52
|
- [Box sizing](#box-sizing)
|
|
53
|
+
- [Color scheme](#color-scheme)
|
|
53
54
|
- [Content](#content)
|
|
54
55
|
- [Cursors](#cursors)
|
|
55
56
|
- [Display mode](#display-mode)
|
|
@@ -91,12 +92,14 @@
|
|
|
91
92
|
- [Z-indices](#z-indices)
|
|
92
93
|
- [Templates by category](#templates-by-category)
|
|
93
94
|
- [Animation / transition](#animation--transition)
|
|
95
|
+
- [Appearance](#appearance)
|
|
94
96
|
- [Aspect ratios](#aspect-ratios)
|
|
95
97
|
- [Background](#background)
|
|
96
98
|
- [Background color](#background-color)
|
|
97
99
|
- [Border color](#border-color)
|
|
98
100
|
- [Color adjustment](#color-adjustment)
|
|
99
101
|
- [Color definitions](#color-definitions)
|
|
102
|
+
- [Color scheme](#color-scheme)
|
|
100
103
|
- [Dimensions](#dimensions)
|
|
101
104
|
- [Font families](#font-families)
|
|
102
105
|
- [Fx](#fx)
|
|
@@ -1111,7 +1114,7 @@ These are readily usable (and used by a growing number of example projects in
|
|
|
1111
1114
|
this repo), but also are provided as starting point to define your own custom
|
|
1112
1115
|
framework(s)...
|
|
1113
1116
|
|
|
1114
|
-
Currently, there are
|
|
1117
|
+
Currently, there are 946 CSS utility classes (incl. 70 templates) defined in "MetaCSS base" (v0.12.0):
|
|
1115
1118
|
|
|
1116
1119
|
### Classes by category
|
|
1117
1120
|
|
|
@@ -1267,13 +1270,13 @@ Currently, there are 937 CSS utility classes (incl. 64 templates) defined in "Me
|
|
|
1267
1270
|
|
|
1268
1271
|
<details><summary>27 items:</summary>
|
|
1269
1272
|
|
|
1273
|
+
- `br-100` (100%)
|
|
1274
|
+
- `br-pill` (9999px)
|
|
1270
1275
|
- `br0` (0rem)
|
|
1271
1276
|
- `br1` (.125rem)
|
|
1272
1277
|
- `br2` (.25rem)
|
|
1273
1278
|
- `br3` (.5rem)
|
|
1274
1279
|
- `br4` (1rem)
|
|
1275
|
-
- `br-100` (100%)
|
|
1276
|
-
- `br-pill` (9999px)
|
|
1277
1280
|
- `brb0` (bottom 0rem)
|
|
1278
1281
|
- `brb1` (bottom .125rem)
|
|
1279
1282
|
- `brb2` (bottom .25rem)
|
|
@@ -1342,6 +1345,12 @@ Currently, there are 937 CSS utility classes (incl. 64 templates) defined in "Me
|
|
|
1342
1345
|
- `border-box` (border-box)
|
|
1343
1346
|
- `content-box` (content-box)
|
|
1344
1347
|
|
|
1348
|
+
#### Color scheme
|
|
1349
|
+
|
|
1350
|
+
- `color-scheme-dark` (dark)
|
|
1351
|
+
- `color-scheme-light` (light)
|
|
1352
|
+
- `color-scheme-light-dark` (light dark)
|
|
1353
|
+
|
|
1345
1354
|
#### Content
|
|
1346
1355
|
|
|
1347
1356
|
<details><summary>6 items:</summary>
|
|
@@ -2329,6 +2338,14 @@ Sets transition-timing-function to `steps(num)`
|
|
|
2329
2338
|
|
|
2330
2339
|
</details>
|
|
2331
2340
|
|
|
2341
|
+
#### Appearance
|
|
2342
|
+
|
|
2343
|
+
##### `appearance(mode)`
|
|
2344
|
+
|
|
2345
|
+
- **mode**: CSS value
|
|
2346
|
+
|
|
2347
|
+
Sets appearance (incl. `-webkit` prefixed version) to given value
|
|
2348
|
+
|
|
2332
2349
|
#### Aspect ratios
|
|
2333
2350
|
|
|
2334
2351
|
##### `aspect-ratio(width, height)`
|
|
@@ -2467,6 +2484,47 @@ Defines a rgb() color variable with given name and additional derived vars for e
|
|
|
2467
2484
|
|
|
2468
2485
|
</details>
|
|
2469
2486
|
|
|
2487
|
+
#### Color scheme
|
|
2488
|
+
|
|
2489
|
+
<details><summary>5 items:</summary>
|
|
2490
|
+
|
|
2491
|
+
##### `bg-light-dark(light, dark)`
|
|
2492
|
+
|
|
2493
|
+
- **light**: variable name (without `--` prefix)
|
|
2494
|
+
- **dark**: variable name (without `--` prefix)
|
|
2495
|
+
|
|
2496
|
+
Sets `background-color` using CSS light-dark() function
|
|
2497
|
+
|
|
2498
|
+
##### `border-light-dark(light, dark)`
|
|
2499
|
+
|
|
2500
|
+
- **light**: variable name (without `--` prefix)
|
|
2501
|
+
- **dark**: variable name (without `--` prefix)
|
|
2502
|
+
|
|
2503
|
+
Sets `border-color` using CSS light-dark() function
|
|
2504
|
+
|
|
2505
|
+
##### `fill-light-dark(light, dark)`
|
|
2506
|
+
|
|
2507
|
+
- **light**: variable name (without `--` prefix)
|
|
2508
|
+
- **dark**: variable name (without `--` prefix)
|
|
2509
|
+
|
|
2510
|
+
Sets `fill` color using CSS light-dark() function
|
|
2511
|
+
|
|
2512
|
+
##### `light-dark(light, dark)`
|
|
2513
|
+
|
|
2514
|
+
- **light**: variable name (without `--` prefix)
|
|
2515
|
+
- **dark**: variable name (without `--` prefix)
|
|
2516
|
+
|
|
2517
|
+
Sets `color` using CSS light-dark() function
|
|
2518
|
+
|
|
2519
|
+
##### `stroke-light-dark(light, dark)`
|
|
2520
|
+
|
|
2521
|
+
- **light**: variable name (without `--` prefix)
|
|
2522
|
+
- **dark**: variable name (without `--` prefix)
|
|
2523
|
+
|
|
2524
|
+
Sets `stroke` color using CSS light-dark() function
|
|
2525
|
+
|
|
2526
|
+
</details>
|
|
2527
|
+
|
|
2470
2528
|
#### Dimensions
|
|
2471
2529
|
|
|
2472
2530
|
<details><summary>6 items:</summary>
|
|
@@ -2715,7 +2773,7 @@ distributed as CLI bundle with **no runtime dependencies**. The following
|
|
|
2715
2773
|
dependencies are only shown for informational purposes and are (partially)
|
|
2716
2774
|
included in the bundle.
|
|
2717
2775
|
|
|
2718
|
-
Package sizes (brotli'd, pre-treeshake): ESM: 13.
|
|
2776
|
+
Package sizes (brotli'd, pre-treeshake): ESM: 13.74 KB
|
|
2719
2777
|
|
|
2720
2778
|
## Dependencies
|
|
2721
2779
|
|
package/index.js
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
// @bun
|
|
2
|
-
var
|
|
3
|
-
`),this.parent&&this.parent.logEntry(
|
|
4
|
-
`]:[],...
|
|
5
|
-
`),s1(Z,W);const U=await Z.ctx({logger:new b0(process.stderr,Z.name,"INFO"),format:J?h0:d1,opts:Q.result,inputs:Q.rest},B);if(await B.fn(U),Z.post)await Z.post(U,B)}catch(Y){process.stderr.write(Y.message+"\n\n"),process.exit(1)}},s1=(Z,X)=>{process.stderr.write(N0(Z.opts,X)),process.exit(1)},u8=(Z)=>["\nAvailable commands:\n",...Object.keys(Z).map((X)=>`${v0(16)(X)}: ${Z[X].desc}`),"\n"].join("\n");import{existsSync as g8,mkdirSync as x8,statSync as q9} from"fs";import{dirname as d8} from"path";var n8=(Z)=>Z.length>0&&!g8(Z)?(x8(Z,{recursive:!0}),!0):!1,Z4=(Z)=>n8(d8(Z));var h=(Z)=>typeof Z==="function";var w=(Z)=>typeof Z==="string";import{readFileSync as p8} from"fs";import{writeFileSync as l8} from"fs";var X4=(Z,X,J,W,Y=!1)=>{if(W&&W.info(`${Y?"[dryrun] ":""}writing file: ${Z}`),Y)return;Z4(Z),l8(Z,X,!J&&w(X)?"utf-8":J)};var D=(Z,X,J="utf-8")=>{return X&&X.debug("reading file:",Z),p8(Z,J)},K1=(Z,X,J,W=!1)=>X4(Z,N(X)?X.join("\n"):X,"utf-8",J,W);var f=(Z,X)=>JSON.parse(D(Z,X));var u=Symbol(),H1=()=>{};var D0=Object.freeze({level:P.NONE,addChild(Z){return Z},childLogger:()=>D0,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class $1 extends P0{set(Z){this.parent=Z}childLogger(Z,X){return new $1(Z,X??this.level,this)}logEntry(Z){this.parent.logEntry(Z)}}var J4=new $1("root",P.FINE,D0);import{join as _5} from"path";var M1=(Z,X)=>{if(Z===X)return 0;if(Z==null)return X==null?0:-1;if(X==null)return Z==null?0:1;if(typeof Z.compare==="function")return Z.compare(X);if(typeof X.compare==="function")return-X.compare(Z);return Z<X?-1:Z>X?1:0};var o8=S(()=>"Assertion failed"),u0=(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)?(Z,X)=>{if(typeof Z==="function"&&!Z()||!Z)throw new o8(typeof X==="function"?X():X)}:()=>{};var g0=(Z)=>Z!=null&&typeof Z!=="function"&&Z.length!==void 0;var W4=(Z)=>{return(Z==null||!Z[Symbol.iterator])&&$(`value is not iterable: ${Z}`),Z};var Y4=(Z)=>g0(Z)?Z:[...W4(Z)];var G0=(Z)=>Z[Z.length-1];var i8=S(()=>"illegal arity"),W0=(Z)=>{throw new i8(Z)};var a8=S(()=>"illegal state"),Y0=(Z)=>{throw new a8(Z)};var x0=(Z,X)=>Z!=null&&typeof Z[X]==="function";var O=(Z)=>Z!=null&&typeof Z[Symbol.iterator]==="function";var d0=(Z)=>Z!=null&&typeof Z!=="string"&&typeof Z[Symbol.iterator]==="function";var B4=["-moz-","-ms-","-o-","-webkit-"],B0={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},n0={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var C1=function(...Z){let[X,J,W,Y,B,V,Q,U,q,z]=Z;switch(Z.length){case 0:W0(0);case 1:return X;case 2:return(...K)=>X(J(...K));case 3:return(...K)=>X(J(W(...K)));case 4:return(...K)=>X(J(W(Y(...K))));case 5:return(...K)=>X(J(W(Y(B(...K)))));case 6:return(...K)=>X(J(W(Y(B(V(...K))))));case 7:return(...K)=>X(J(W(Y(B(V(Q(...K)))))));case 8:return(...K)=>X(J(W(Y(B(V(Q(U(...K))))))));case 9:return(...K)=>X(J(W(Y(B(V(Q(U(q(...K)))))))));case 10:default:const H=(...K)=>X(J(W(Y(B(V(Q(U(q(z(...K))))))))));return Z.length===10?H:C1(H,...Z.slice(10))}};var i=(Z)=>x0(Z,"xform")?Z.xform():Z;var v=function(...Z){return Z=Z.map(i),C1.apply(null,Z)};var g=(Z,X)=>[Z[0],Z[1],X];class j0{value;constructor(Z){this.value=Z}deref(){return this.value}}var G=(Z)=>Z instanceof j0,Q4=(Z)=>Z instanceof j0?Z:new j0(Z),y=(Z)=>Z instanceof j0?Z.deref():Z;var Q0=function(...Z){const X=Z[0],J=X[0],W=X[1],Y=X[2];Z=t8(Z);const B=Z[0]==null?J():Z[0],V=Z[1];return y(W(x0(V,"$reduce")?V.$reduce(Y,B):g0(V)?r8(Y,B,V):c8(Y,B,V)))};var t8=(Z)=>Z.length===2?[void 0,Z[1]]:Z.length===3?[Z[1],Z[2]]:W0(Z.length),r8=(Z,X,J)=>{for(let W=0,Y=J.length;W<Y;W++)if(X=Z(X,J[W]),G(X)){X=X.deref();break}return X},c8=(Z,X,J)=>{for(let W of J)if(X=Z(X,W),G(X)){X=X.deref();break}return X},V0=(Z,X)=>[Z,w0,X],V4=(Z,X)=>{const J=X.length-1;return O(X[J])?X.length>1?Q0(Z.apply(null,X.slice(0,J)),X[J]):Q0(Z(),X[0]):void 0};var U0=function(Z){return Z?[...Z]:V0(()=>[],(X,J)=>(X.push(J),X))};function*q0(Z,X){const J=i(Z)(U0()),W=J[1],Y=J[2];for(let B of X){const V=Y([],B);if(G(V)){yield*y(W(V.deref()));return}if(V.length)yield*V}yield*y(W([]))}function*a(Z,X){const J=i(Z)([H1,H1,(W,Y)=>Y])[2];for(let W of X){let Y=J(u,W);if(G(Y)){if(Y=y(Y.deref()),Y!==u)yield Y;return}if(Y!==u)yield Y}}var l0=(Z,X,J=a)=>{const W=X.length-1;return O(X[W])?X.length>1?J(Z.apply(null,X.slice(0,W)),X[W]):J(Z(),X[0]):void 0};var F1=function(Z,X){return O(X)?q0(F1(Z),w(X)?[X]:X):(J)=>{const W=J[2],Y=(B,V)=>{const Q=Z(V);if(Q){for(let U of Q)if(B=Y(B,U),G(B))break;return B}return W(B,V)};return g(J,Y)}};var U4=function(Z){return F1((X)=>d0(X)?X:void 0,Z)};var F=function(Z,X){return O(X)?a(F(Z),X):(J)=>{const W=J[2];return g(J,(Y,B)=>W(Y,Z(B)))}};function*p0(...Z){const X=Z.length-1;if(X<0)return;const J=new Array(X+1).fill(0),W=Z.map(Y4),Y=W.reduce((B,V)=>B*V.length,1);for(let B=0;B<Y;B++){const V=[];for(let Q=X;Q>=0;Q--){const U=W[Q];let q=J[Q];if(q===U.length)J[Q]=q=0,Q>0&&J[Q-1]++;V[Q]=U[q]}J[X]++,yield V}}function*q4(Z,X=Infinity){while(X-- >0)yield Z}var w1=function(Z,X){Z=Z||"";let J=!0;return X?[...X].join(Z):V0(()=>"",(W,Y)=>(W=J?W+Y:W+Z+Y,J=!1,W))};var o0=function(...Z){return s8(o0,Q0,Z)};var s8=(Z,X,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 F((B)=>Z(J[0],J[1],B));default:W0(J.length)}return X(i(J[0])(J[1]),W,Y)};var e8=new Set,Z5=":[",z4=v(U4(),F((Z)=>Z[0]==="&"?Z.substring(1):Z5.includes(Z[0])?Z:" "+Z)),X5=(Z,X)=>v(Z,F((J)=>w(J)&&J.startsWith(" .")?J+X:J)),z0=(Z,X,J,W)=>{const Y=J.length,B=[];let V,Q;const U=(q,z)=>{let H=null;if(N(z))z0(Z,P1(X,B),z,W);else if(O(z)&&!w(z))z0(Z,P1(X,B),[...z],W);else if((Q=h(z))||(H=W.fns[z]))if(!X.length){if(H)return H.apply(null,J.slice(q+1))(Z,W),!0;z(Z,W)}else if(Q)U(q,z());else $(`quoted fn ('${z}') only allowed at head position`);else if(b(z))V=Object.assign(V||{},z);else if(z!=null)B.push(z)};for(let q=0;q<Y;q++)if(U(q,J[q]))return Z;return V&&Z.push(J5(X,B,V,W)),Z},P1=(Z,X)=>Z.length?[...p0(Z,X)]:X,J5=(Z,X,J,W)=>{const Y=W.format,B=_(W),V=W.scope?X5(z4,W.scope):z4;return[B,o0(F((Q)=>o0(V,w1(),N(Q)?Q:[Q]).trim()),w1(Y.ruleSep),P1(Z,X)),Y.declStart,k0(J,W),B,Y.declEnd].join("")},k0=(Z,X)=>{const J=X.format,W=X.autoprefix||e8,Y=_(X,X.depth+1),B=[];for(let V in Z)if(Z.hasOwnProperty(V)){let Q=Z[V];if(h(Q))Q=Q(Z);if(N(Q))Q=Q.map((U)=>N(U)?U.join(" "):U).join(J.ruleSep);if(W.has(V))for(let U of X.vendors)B.push(`${Y}${U}${V}:${J.valSep}${Q};`);B.push(`${Y}${V}:${J.valSep}${Q};`)}return B.join(J.decls)+J.decls},_=(Z,X=Z.depth)=>X>1?[...q4(Z.format.indent,X)].join(""):X>0?Z.format.indent:"";var K4=function(Z,...X){const J=X.length===1?X[0]:X.reduce((W,Y,B)=>{return W[B/(X.length-1)*100|0]=Y,W},{});return(W,Y)=>{const B=_(Y);Y.depth++;const V=_(Y);W.push(`${B}@keyframes ${Z}${Y.format.declStart}`);for(let Q in J)if(J.hasOwnProperty(Q))W.push([V,Q+"%",Y.format.declStart,k0(J[Q],Y),V,Y.format.declEnd].join(""));return Y.depth--,W.push(B+Y.format.declEnd),W}};var H4=(Z,X=!1)=>(J,W)=>{const Y=_(W),B=_(W,W.depth+1);if(W.format.comments||X)J.push(Y+"/*",Z.split("\n").map((V)=>B+V).join("\n"),Y+"*/");return J};var i0=(Z,X,J)=>(W,Y)=>{const B=_(Y);return W.push(`${B}${Z} ${W5(X)}${Y.format.declStart}`),Y.depth++,z0(W,[],J,Y),Y.depth--,W.push(B+Y.format.declEnd),W},W5=(Z)=>{if(w(Z))return Z;const X=[];for(let J in Z)if(Z.hasOwnProperty(J)){let W=Z[J];if(W===!0)W=$4.has(J)?J:`(${J})`;else if(W===!1)W=`(not ${$4.has(J)?J:`(${J})`})`;else if(W==="only")W+=" "+J;else W=`(${J}:${W})`;X.push(W)}return X.join(" and ")},$4=new Set(["all","print","screen"]);var t=(Z,X)=>{return X={format:B0,vendors:B4,fns:{},depth:0,...X},N(X.autoprefix)&&(X.autoprefix=new Set(X.autoprefix)),b(Z)?k0(Z,X):h(Z)?Z([],X).join(X.format.rules):z0([],[],N(Z)?Z:d0(Z)?[...Z]:$("invalid rules"),X).join(X.format.rules)};var M4=(Z,...X)=>(J,W)=>(J.push(X.length?`@import url(${Z}) ${X.join(W.format.ruleSep)};`:`@import url(${Z});`),J);var K0=(Z,X)=>i0("@media",Z,X);var C4=function(...Z){return(X,J)=>(X.push(Z.length>1?`@namespace ${Z[0]} url(${Z[1]});`:`@namespace url(${Z[0]});`),X)};var F4=(Z,X)=>i0("@supports",Z,X);var a0={"@comment":H4,"@import":M4,"@keyframes":K4,"@media":K0,"@namespace":C4,"@supports":F4};var w4=4,P4=(Z)=>w4=Z,I=(Z)=>Z===(Z|0)?String(Z):Z.toFixed(w4).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var N4=(Z)=>`${I(Z)}em`,O4=(Z)=>`${I(Z)}ex`;var D4=(Z)=>`${I(Z)}rem`,N1=(Z)=>`${I(Z)}%`,G4=(Z)=>`${I(Z)}px`,j4=(Z)=>`${I(Z)}vh`,k4=(Z)=>`${I(Z)}vw`,T4=(Z)=>`${I(Z)}vmin`,I4=(Z)=>`${I(Z)}vmax`,E4=(Z)=>`${Z|0}ms`,R4=(Z)=>`${I(Z)}s`;var L4=(Z)=>`${I(Z)}deg`,S4=(Z)=>`${I(Z)}rad`,A4=(Z)=>`${I(Z)}turn`,b4=(Z)=>`url(${Z})`;var j=((Z)=>{return Z[Z.IDLE=0]="IDLE",Z[Z.ACTIVE=1]="ACTIVE",Z[Z.DONE=2]="DONE",Z[Z.UNSUBSCRIBED=3]="UNSUBSCRIBED",Z[Z.ERROR=4]="ERROR",Z})(j||{}),L=((Z)=>{return Z[Z.NEVER=0]="NEVER",Z[Z.FIRST=1]="FIRST",Z[Z.LAST=2]="LAST",Z})(L||{});var Y5=0,B5=()=>Y5++,r=(Z,X)=>!X||!X.id?{...X,id:Z+"-"+B5()}:X;var k=J4.childLogger("rstream");class x{constructor(Z,X){this.wrapped=Z,X=r("sub",{closeIn:L.LAST,closeOut:L.LAST,cache:!0,...X}),this.parent=X.parent,this.id=X.id,this.closeIn=X.closeIn,this.closeOut=X.closeOut,this.cacheLast=X.cache,X.xform&&(this.xform=X.xform(U0()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=u;state=j.IDLE;subs=[];deref(){return this.last!==u?this.last:void 0}getState(){return this.state}setState(Z){this.state=Z}subscribe(Z,X={}){this.ensureState();let J;if(Z instanceof x&&!X.xform)Z.ensureState(),u0(!Z.parent,`sub '${Z.id}' already has a parent`),Z.parent=this,J=Z;else J=new x(Z,{...X,parent:this});return this.subs.push(J),this.setState(j.ACTIVE),J.setState(j.ACTIVE),this.last!=u&&J.next(this.last),J}transform(...Z){let X,J;if(b(G0(Z)))J=Z.pop(),X={error:J.error};return this.subscribe(X,r("xform",Z.length>0?{...J,xform:v(...Z)}:J))}map(Z,X){return this.transform(F(Z),X||{})}unsubscribe(Z){return Z?this.unsubscribeChild(Z):this.unsubscribeSelf()}unsubscribeSelf(){return k.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<j.UNSUBSCRIBED&&(this.state=j.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(Z){k.debug(this.id,"unsub child",Z.id);const X=this.subs.indexOf(Z);if(X>=0){if(this.subs.splice(X,1),this.closeOut===L.FIRST||!this.subs.length&&this.closeOut!==L.NEVER)this.unsubscribe();return!0}return!1}next(Z){if(this.state>=j.DONE)return;this.xform?this.dispatchXform(Z):this.dispatch(Z)}done(){if(k.debug(this.id,"entering done()"),this.state>=j.DONE)return;if(this.xform){if(!this.dispatchXformDone())return}if(this.state=j.DONE,this.dispatchTo("done"))this.state<j.UNSUBSCRIBED&&this.unsubscribe();k.debug(this.id,"exiting done()")}error(Z){const X=this.wrapped,J=X&&X.error;return J&&k.debug(this.id,"attempting wrapped error handler"),J&&X.error(Z)||this.unhandledError(Z)}unhandledError(Z){return(k.parent!==D0?k:console).warn(this.id,"unhandled error:",Z),this.unsubscribe(),this.state=j.ERROR,!1}dispatchTo(Z,X){let J=this.wrapped;if(J)try{J[Z]&&J[Z](X)}catch(Y){if(!this.error(Y))return!1}const W=Z==="next"?this.subs:[...this.subs];for(let Y=W.length;Y-- >0;){J=W[Y];try{J[Z]&&J[Z](X)}catch(B){if(Z==="error"||!J.error||!J.error(B))return this.unhandledError(B)}}return!0}dispatch(Z){k.debug(this.id,"dispatch",Z),this.cacheLast&&(this.last=Z),this.dispatchTo("next",Z)}dispatchXform(Z){let X;try{X=this.xform[2]([],Z)}catch(J){this.error(J);return}if(this.dispatchXformVals(X))G(X)&&this.done()}dispatchXformDone(){let Z;try{Z=this.xform[1]([])}catch(X){return this.error(X)}return this.dispatchXformVals(Z)}dispatchXformVals(Z){const X=y(Z);for(let J=0,W=X.length;J<W&&this.state<j.DONE;J++)this.dispatch(X[J]);return this.state<j.ERROR}ensureState(){if(this.state>=j.DONE)Y0(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var v4=(Z,X)=>{const J=new y4(X);return J.next(Z),J};class y4 extends x{src;_cancel;_inited;constructor(Z,X){const[J,W]=h(Z)?[Z,X||{}]:[void 0,Z||{}];super(W.error?{error:W.error}:void 0,r("stream",W));this.src=J,this._inited=!1}subscribe(Z,X={}){const J=super.subscribe(Z,X);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(Z){const X=super.unsubscribe(Z);if(X&&(!Z||(!this.subs||!this.subs.length)&&this.closeOut!==L.NEVER))this.cancel();return X}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(Z){if(super.error(Z))return!0;return this.cancel(),!1}cancel(){if(this._cancel){k.debug(this.id,"cancel");const Z=this._cancel;delete this._cancel,Z()}}}var _4=(Z,X)=>Z===L.FIRST||Z===L.LAST&&!X;var O1=function(Z){return Z?Q0(O1(),Z):V0(()=>({}),(X,[J,W])=>(X[J]=W,X))};var h4=()=>(Z)=>{const X=Z[2];return g(Z,(J,W)=>{if(W){for(let Y of y(W))if(J=X(J,Y),G(J))break}return G(W)?Q4(J):J})};var D1=function(Z,X){return O(X)?q0(D1(Z),X):v(F(Z),h4())};var G1=function(Z,X){return O(X)?a(G1(Z),X):F(h(Z)?(J)=>[Z(J),J]:(J)=>[Z,J])};var j1=function(...Z){const X=l0(j1,Z);if(X)return X;const J=Z[0],W=Z[1]!==!1;return F((Y)=>{const B=W?{}:Y;for(let V in Y)B[V]=J(Y[V]);return B})};var f4=(Z)=>Z;var k1=function(...Z){const X=l0(k1,Z,q0);if(X)return X;const{key:J=f4,mergeOnly:W=!1,reset:Y=!0,all:B=!0,backPressure:V=0}=Z[1],Q=N(Z[0])?new Set(Z[0]):Z[0],U=new Set,q=new Map;let z={};const H=([K,M,E])=>{let p=!0;if(W||V<1)return[K,(C)=>{if(Y&&B&&U.size>0||!Y&&p)C=E(C,z),z={},U.clear(),p=!1;return M(C)},(C,o)=>{const T=J(o);if(Q.has(T)){if(z[T]=o,U.add(T),W||m4(Q,U))if(C=E(C,z),p=!1,Y)z={},U.clear();else z={...z}}return C}];else return[K,(C)=>{if(B&&U.size>0)C=E(C,u4(q,U)),q.clear(),U.clear();return M(C)},(C,o)=>{const T=J(o);if(Q.has(T)){let m=q.get(T);!m&&q.set(T,m=[]),m.length>=V&&Y0(`max back pressure (${V}) exceeded for input: ${String(T)}`),m.push(o),U.add(T);while(m4(Q,U))if(C=E(C,u4(q,U)),p=!1,G(C))break}return C}]};return H.keys=()=>Q,H.clear=()=>{q.clear(),Q.clear(),U.clear(),z={}},H.add=(K)=>{Q.add(K)},H.delete=(K,M=!0)=>{if(q.delete(K),Q.delete(K),M)U.delete(K),delete z[K]},H},m4=(Z,X)=>{if(X.size<Z.size)return!1;for(let J of Z)if(!X.has(J))return!1;return!0},u4=(Z,X)=>{const J={};for(let W of X){const Y=Z.get(W);J[W]=Y.shift(),!Y.length&&X.delete(W)}return J};var g4=(Z,X)=>{let J=!0;for(let W of X)J=Z.removeID(W)&&J;return J};var t0=(Z)=>new x4(Z);class x4 extends x{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(Z){const X=k1(new Set,{key:(W)=>W[0],mergeOnly:Z.mergeOnly===!0,reset:Z.reset===!0,all:Z.all!==!1,backPressure:Z.backPressure||0}),J=j1((W)=>W[1]);super(void 0,r("streamsync",{...Z,xform:Z.xform?v(X,J,Z.xform):v(X,J)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=X,this.clean=!!Z.clean,Z.src&&this.addAll(Z.src)}add(Z,X){X||(X=Z.id),this.ensureState(),this.psync.add(X),this.realSourceIDs.set(X,Z.id),this.invRealSourceIDs.set(Z.id,X),this.idSources.set(Z.id,Z),this.sources.set(Z,Z.subscribe({next:(J)=>J[1]instanceof x?this.add(J[1]):this.next(J),done:()=>this.markDone(Z),__owner:this},{xform:G1(X),id:`in-${X}`}))}addAll(Z){for(let X in Z)this.psync.add(X);for(let X in Z)this.add(Z[X],X)}remove(Z){const X=this.sources.get(Z);if(X){const J=this.invRealSourceIDs.get(Z.id);return k.info(`removing src: ${Z.id} (${J})`),this.psync.delete(J,this.clean),this.realSourceIDs.delete(J),this.invRealSourceIDs.delete(Z.id),this.idSources.delete(Z.id),this.sources.delete(Z),X.unsubscribe(),!0}return!1}removeID(Z){const X=this.getSourceForID(Z);return X?this.remove(X):!1}removeAll(Z){for(let J of Z)this.psync.delete(this.invRealSourceIDs.get(J.id));let X=!0;for(let J of Z)X=this.remove(J)&&X;return X}removeAllIDs(Z){return g4(this,Z)}getSourceForID(Z){return this.idSources.get(this.realSourceIDs.get(Z))}getSources(){const Z={};for(let[X,J]of this.idSources)Z[this.invRealSourceIDs.get(X)]=J;return Z}unsubscribe(Z){if(!Z){k.debug(this.id,"unsub sources");for(let X of this.sources.values())X.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(Z)}markDone(Z){this.remove(Z),_4(this.closeIn,this.sources.size)&&this.done()}}var T1=Z0((Z,X=" ")=>{const J=X0(String(X),Z);return(W,Y)=>{if(W==null)return J;return W=W.toString(),Y=Y!==void 0?Y:W.length,Y<Z?J.substring(Y)+W:W}}),nJ=T1(2,"0"),lJ=T1(3,"0"),d4=T1(4,"0");var Q5=/\{(\d+)\}/g;var I1=(Z,...X)=>X.length>0?Z.replace(Q5,(J,W)=>String(X[parseInt(W,10)])):Z;var n4=(Z)=>({key:(X)=>X,group:U0(),...Z});var E1=function(...Z){const X=V4(E1,Z);if(X)return X;const J=n4(Z[0]),[W,Y,B]=J.group;return[()=>({}),(V)=>{for(let Q in V)V[Q]=Y(V[Q]);return V},(V,Q)=>{const U=J.key(Q);return V[U]=V[U]?B(V[U],Q):B(W(),Q),V}]};var R1=function(Z,X){return O(X)?a(R1(Z),X):(J)=>{const W=J[2];return g(J,(Y,B)=>Z(B)?W(Y,B):Y)}};import{watch as a4} from"fs";import{resolve as c} from"path";var l4={specs:A({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},r0={bundle:R({alias:"b",desc:"Bundle inputs (see `out` option)"})},H0={include:S0({alias:"I",desc:"Include CSS files (prepend)"})},c0={eval:A({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},s0={force:S0({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},p4={media:S0({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},o4={onlyDecls:R({desc:"Only emit framework decls"})},d={out:A({alias:"o",desc:"Output file (or stdout)"})},e0={prec:A0({default:3,desc:"Number of fractional digits"})},n={pretty:R({alias:"p",desc:"Pretty print output"})},$0={noDecls:R({alias:"d",desc:"Don't emit framework decls"})},M0={noHeader:R({desc:"Don't emit generated header comment"})},C0={scope:A({desc:"Suffix for CSS class names"})},F0={watch:R({alias:"w",desc:"Watch input files for changes"})};import{watch as V5} from"fs";import{resolve as i4} from"path";var l=(Z,X,J)=>{X=w(X)?X:X.join("\n"),Z?K1(i4(Z),X,J):process.stdout.write(X+"\n")},Z1=({info:{name:Z,version:X}})=>`/*! ${Z} v${X} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,T0=(Z,X)=>{const J=()=>{X.info("closing watchers..."),W.forEach((Y)=>Y.watcher.close())},W=Z.map((Y,B)=>{Y=i4(Y);const V=v4(D(Y,X),{id:`in${d4(B)}`});return{input:V,watcher:V5(Y,{},(Q)=>{if(Q==="change")try{V.next(D(Y,X))}catch(U){X.warn(U.message),J()}else X.warn("input removed:",Y),J()})}});return process.on("SIGINT",J),t0({src:O1(F(({input:Y})=>[Y.id,Y],W))})},X1=(Z)=>Object.keys(Z).reduce((X,J)=>{if(!J.startsWith("__"))X[J]=Z[J];return X},{});async function S1(Z){const X=f(c(Z.opts.specs),Z.logger),J=H5(X,Z.opts.force||[],Z.logger);if(Z.opts.bundle)if(Z.opts.watch)await q5(Z,J);else I0(Z,X,J,Z.opts.eval?[Z.opts.eval]:Z.inputs.map((W)=>D(c(W),Z.logger)),Z.opts.out);else if(Z.opts.watch)await U5(Z,X,J);else if(Z.opts.eval)try{I0(Z,X,J,[Z.opts.eval])}catch(W){Z.logger.warn(W.message)}else for(let W of Z.inputs)try{W=c(W);const Y=!Z.opts.noWrite?W.replace(/\.mcss$/,".css"):void 0;I0(Z,X,J,[D(W,Z.logger)],Y)}catch(Y){Z.logger.warn(Y.message)}}function*M5(Z){let X=-1,J=Z.length,W=0;for(let Y=0;Y<J;Y++){const B=Z[Y];if(B===" "||B==="\t"){if(!W&&X>=0)yield Z.substring(X,Y),X=-1}else if(B==="{"||B==="}"){if(X>=0)yield Z.substring(X,Y);yield B,X=-1}else if(B==="(")W++;else if(B===")"){if(--W<0)$(`invalid nesting in line: '${Z}'`)}else if(X<0)X=Y}if(W)$("template calls must be fully on a single line");if(X>=0)yield Z.substring(X,J)}var r4={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...r0,...c0,...s0,...H0,...$0,...M0,...d,...n,...C0,...l4,...F0,noWrite:R({desc:"Don't write files, use stdout only"})},fn:S1},U5=async(Z,X,J)=>{const W=c(Z.opts.specs);let Y,B={process:()=>{try{return X=f(W,Z.logger),Y.forEach((Q)=>Q.process()),!0}catch(Q){return Z.logger.warn(Q.message+": "+W),!1}},watcher:a4(W,{},(Q)=>{if(Q==="change")B.process();else Z.logger.warn("specs file removed:",W),V()})};const V=()=>{Z.logger.info("closing watchers..."),B.watcher.close(),Y.forEach((Q)=>Q.watcher.close())};Y=Z.inputs.map((Q)=>{Q=c(Q);const U=!Z.opts.noWrite?Q.replace(/\.mcss$/,".css"):void 0,q=()=>{try{return I0(Z,X,J,[D(Q,Z.logger)],U),!0}catch(z){if(Z.logger.warn(z.message+": "+Q),Y)V();return!1}};if(!q())process.exit(1);return{process:q,watcher:a4(Q,{},(z)=>{if(z==="change")q();else Z.logger.warn("input removed:",Q),V()})}}),Z.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",V)},q5=async(Z,X)=>{t0({src:{styles:T0(Z.inputs,Z.logger),specs:T0([Z.opts.specs],Z.logger).map((J)=>JSON.parse(Object.values(J)[0]))}}).subscribe({next({styles:J,specs:W}){try{I0(Z,W,X,Object.keys(J).sort().map((Y)=>J[Y]),Z.opts.out)}catch(Y){Z.logger.warn(Y.message)}}})},I0=({logger:Z,opts:{include:X,noDecls:J,noHeader:W,pretty:Y,scope:B}},V,Q,U,q)=>{const z={logger:Z,specs:V,css:{format:Y?n0:B0,fns:a0,scope:B},mediaQueryIDs:new Set(Object.keys(V.media)),mediaQueryRules:{...Q.mediaQueryRules},plainRules:{...Q.plainRules}},H=X?X.map((K)=>D(c(K),Z).trim()):[];if(!W)H.push(Z1(V));if(!J&&V.decls.length)H.push(t(V.decls,z.css));U.forEach((K)=>$5(K,z)),K5(H,z),z5(H,z),l(q,H,Z)},z5=(Z,{css:X,logger:J,mediaQueryRules:W,specs:Y})=>{for(let B in W){const V=s4(W[B],Y);J.debug("mediaquery rules",B,V),Z.push(t(K0(w5(Y.media,B),V),X))}},K5=(Z,{css:X,logger:J,plainRules:W,specs:Y})=>{const B=s4(W,Y);J.debug("plain rules",B),Z.push(t(B,X))},H5=(Z,X,J)=>{const W=new Set(Object.keys(Z.media)),Y=new Set(Object.keys(Z.classes)),B={},V={};if(X.length&&X[0][0]==="@")X=[...J0(D(c(X[0].substring(1)),J))];for(let Q of X){if(!Q||Q.startsWith("//"))continue;const{token:U,query:q}=e4(Q,W);let z;if(U.includes("*")){const H=new RegExp(`^${U.replace("*",".*")}\$`);z=[...R1((K)=>H.test(K),Y)]}else if(Y.has(U))z=[U];else{J.warn(`unknown include rule ID: ${Q}, skipping...`);continue}for(let H of z)J.debug("including class:",H),q?Z8(B,q,`.${H}`,H):X8(V,`.${H}`,H)}return{mediaQueryRules:B,plainRules:V}},$5=(Z,{specs:X,mediaQueryIDs:J,mediaQueryRules:W,plainRules:Y})=>{const B=E0(),V=E0(B),Q={root:B,curr:V,scopes:[V]};for(let U of J0(Z)){if(!U||/^\s*\/\//.test(U))continue;for(let q of M5(U)){if(!q)continue;let z=Q.curr;switch(z.state){case"sel":case"nest":if(q==="{"){if(z.state==="sel")z.sel=z.sel.map((H)=>H.replace(",","")),z.path=C5(Q.scopes);z.state="class"}else if(q==="}")t4(Q);else{const H=G0(z.sel);if(!H||H.endsWith(","))z.sel.push(q);else z.sel[z.sel.length-1]+=" "+q}break;case"class":if(q==="{")z.state="nest",Q.scopes.push(Q.curr=E0(z));else if(q==="}")t4(Q);else{let{token:H,query:K}=e4(q,J);if(!X.classes[H]&&!(J8(H)||W8(H)))$(`unknown class ID: ${H}`);if(K)Z8(W,K,z.path,H);else X8(Y,z.path,H)}break;default:Y0(z.state)}}}},L1=":",c4="///",E0=(Z)=>({state:"sel",sel:Z?[]:["<root>"],path:"",parent:Z}),t4=(Z)=>{const X=!Z.curr.sel.length;if(u0(!!Z.curr.parent,"stack underflow"),Z.scopes.pop(),Z.scopes.length>0){if(Z.curr=G0(Z.scopes),!X&&Z.curr.state==="nest")Z.scopes.push(Z.curr=E0(Z.curr))}else Z.scopes.push(Z.curr=E0(Z.root))},C5=(Z)=>Z.map((X)=>X.sel.join(",")).join(c4),s4=(Z,X)=>Object.entries(Z).map(([J,W])=>F5(J,W,X)),F5=(Z,X,J)=>{const W=[];let Y=W;const B=Z.split(c4);for(let V=0;V<B.length;V++){const Q=B[V].split(",");if(V==B.length-1){const U=Object.assign({},...F((q)=>W8(q)?N5(J,q):J8(q)?P5(q):X1(J.classes[q]),X));Q.push(U)}Y.push(Q),Y=Q}return W[0]},e4=(Z,X)=>{if(/^::?/.test(Z))return{token:Z};const J=Z.lastIndexOf(L1);if(J<0)return{token:Z};const W=Z.substring(0,J);if(!W.split(L1).every((B)=>X.has(B)))$(`invalid media query in token: ${Z}`);return{token:Z.substring(J+1),query:W}},w5=(Z,X)=>X.split(L1).reduce((J,W)=>Object.assign(J,Z[W]),{}),Z8=(Z,X,J,W)=>{if(!Z[X])Z[X]={};(Z[X][J]||(Z[X][J]=new Set)).add(W)},X8=(Z,X,J)=>(Z[X]||(Z[X]=new Set)).add(J),P5=(Z)=>{const X=Z.indexOf("=");return{[`--${Z.substring(0,X)}`]:Z.substring(X+1)}},N5=(Z,X)=>{const J=X.indexOf("("),W=X.substring(0,J),Y=X.substring(J+1,X.length-1).split(/(?<!\\),/g).map((V)=>V.trim().replace("\\,",",")),B=Z.templates[W];if(!B)$(`unknown template: ${W}`);if(Y.length!==B.__arity)$(`template "${W}" expected ${B.__arity} arguments`);return Object.entries(B).reduce((V,[Q,U])=>{if(!Q.startsWith("__")){if(Q=I1(Q,...Y),w(U))U=I1(U,...Y);V[Q]=U}return V},{})},J8=(Z)=>Z.includes("="),W8=(Z)=>Z.includes("(");async function A1(Z){if(Z.opts.watch)await G5(Z);else await V8(Z.inputs.map((X)=>D(X,Z.logger)),Z.opts,Z.logger)}var B8={deg:L4,em:N4,ex:O4,ms:E4,percent:N1,px:G4,rad:S4,rem:D4,second:R4,turn:A4,url:b4,vh:j4,vmax:I4,vmin:T4,vw:k4,"%":N1},O5={percent:"{0}%",second:"{0}s",url:"url({0})"},D5={"":[""],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"],in:[""],out:[""]},Q8={desc:"Generate framework rules from specs",opts:{...d,...e0,...n,...F0},fn:A1},G5=async(Z)=>{T0(Z.inputs,Z.logger).subscribe({next(X){try{V8(Object.keys(X).sort().map((J)=>X[J]),Z.opts,Z.logger)}catch(J){Z.logger.warn(J.message)}}})},V8=async(Z,X,J)=>{const W={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};P4(X.prec);for(let Y of Z){const B=JSON.parse(Y);if(Object.assign(W.info,B.info),Object.assign(W.media,B.media),B.decls)W.decls.push(...B.decls);if(B.specs)for(let V of B.specs)try{U8(B,V,W.classes,J)}catch(Q){J.warn(`error processing spec: ${V.name}`,Q,", skipping...")}if(B.templates)for(let V of B.templates)j5(B,V,W.templates,J)}return l(X.out,JSON.stringify(W,null,X.pretty?4:0),J),W},U8=(Z,X,J,W,Y=!1)=>{const B=N(X.vars)?X.vars:[""],V=w(X.props)?{[X.props]:"<v>"}:X.props,Q=k5(X,Z),U=new Set;for(let q of B){const z=Z.vars?.[q]||D5[q];if(!z)$(`unknown variation ID: ${q}`);for(let[H,K]of p0(z,Object.keys(Q))){const M=s(X.name,q,H,K,Q[K]),E=X.unit?s(X.unit,q,H,K,Q[K]):void 0,p=Y?I5(E):T5(Q[K],E);if(!J[M]){if(J[M]={},X.user!=null)J[M].__user=X.user;if(X.doc!=null)J[M].__doc=E5(X.doc,q,H,K,p)}else if(!U.has(M))$(`duplicate class ID: ${M}`);U.add(M);let C=-1;for(let[o,T]of Object.entries(V)){const m=s(o,q,H,K,Q[K]),J1=s(!E||w(T)?String(T):B8[E](T),q,H,K,p);if(J[M][m]=J1,W.debug(M,m,J1),Y)C=Y8(J1,Y8(m,C))}if(Y)J[M].__arity=C+1}}return J},j5=(Z,X,J,W)=>U8(Z,{...X,values:[""]},J,W,!0),Y8=(Z,X)=>{const J=/\{(\d+)\}/g;let W;while(W=J.exec(Z))X=Math.max(X,+W[1]);return X},k5=(Z,X)=>{const J=w(Z.values)?X.tables?.[Z.values]||$(`invalid table ID: ${Z.values}`):Z.values;if(b(J))return J;const W=Z.key==="v"?(Y)=>String(Y):Z.key==="i+1"?(Y,B)=>String(B+1):Z.key===void 0?(Y,B)=>String(B):$(`invalid key type: ${Z.key}`);return J.reduce((Y,B,V)=>{return Y[W(B,V)]=B,Y},{})},T5=(Z,X)=>{if(!X||w(Z))return Z;const J=B8[X];if(!J)$(`invalid unit: ${X}`);return J(Z)},I5=(Z)=>Z?O5[Z]||"{0}"+Z:"{0}",s=(Z,X,J,W,Y)=>Z.replace(/<vid>/g,X).replace(/<var>/g,J).replace(/<k>/g,W).replace(/<v>/g,String(Y)),E5=({group:Z,desc:X,args:J},W,Y,B,V)=>({group:Z?s(Z,W,Y,B,V):"TODO",desc:X?s(X,W,Y,B,V):void 0,args:J?J.map((Q)=>s(Q,W,Y,B,V)):void 0});var q8={desc:"Combination of the generate & convert commands",opts:{...r0,...c0,...s0,...H0,...$0,...M0,...e0,...n,...C0,...F0,outCss:A({desc:"Output file for CSS bundle",optional:!1}),outSpecs:A({desc:"Output file for framework",optional:!1})},fn:async(Z)=>{const{opts:X,inputs:J}=Z,[W,Y]=J.reduce((Q,U)=>(Q[U.endsWith(".json")?0:1].push(U),Q),[[],[]]),B={inputs:W,format:Z.format,logger:Z.logger,opts:{...X,out:X.outSpecs}},V={inputs:Y,format:Z.format,logger:Z.logger,opts:{...X,noWrite:!1,out:X.outCss,scope:X.scope,specs:X.outSpecs}};await A1(B),await S1(V)}};import{resolve as R5} from"path";var H8={desc:"Generate Markdown documentation for framework specs",opts:{...d,level:A0({alias:"l",desc:"Initial heading level",default:1}),title:A({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(Z)=>{const{logger:X,opts:J,inputs:W}=Z,Y=f(R5(W[0]),X),B=L5(Y,J);l(J.out,B,X)}},L5=(Z,{level:X,title:J})=>{const W=Object.keys(Z.classes).length,Y=Object.keys(Z.templates).length,B=[`Currently, there are ${W+Y} CSS utility classes (incl. ${Y} templates) defined in "${Z.info.name}" (v${Z.info.version}):`,"",`${e(X+1)} Classes by category`,"",...K8(Z.classes,A5,X+2),`${e(X+1)} Templates by category`,"",...K8(Z.templates,b5,X+2),`${e(X+1)} Media queries`,"",...Object.entries(Z.media).map(([V,Q])=>`- **${V}**: \`${JSON.stringify(Q)}\``),""];if(J!=="NONE")B.unshift(`${e(X)} ${J??Z.info.name}\n`);return B},z8=(Z)=>Z.split(/(\d+)/).map((X)=>{const J=parseInt(X);return isNaN(J)?X:J}),S5=(Z,X)=>{if(/\d+/.test(Z)&&/\d+/.test(X)){const J=z8(Z),W=z8(X),Y=J.length;if(Y===W.length){for(let B=0;B<Y;B++)if(J[B]!==W[B])return M1(J[B],W[B]);return 0}return J.length-W.length}return M1(Z,X)},K8=(Z,X,J)=>{const W=E1({key:([Y,{__doc:B}])=>B?.group||"TODO",group:[()=>[],(Y)=>Y.sort(),(Y,B)=>(Y.push(B[0]),Y)]},Object.entries(Z));return D1((Y)=>{const B=W[Y].sort(S5).map((Q)=>X(Q,Z[Q].__doc,J+1)),V=B.length;return[`${e(J)} ${f0(Y)}`,V>3?`\n<details><summary>${V} items:</summary>\n`:"",B.join("\n"),V>3?"</details>\n":""]},Object.keys(W).sort())},A5=(Z,X)=>{if(!(X&&X.desc))return`- \`${Z}\``;let J=X.desc;if(/^-[a-z]/.test(J))J=J.substring(1);return`- \`${Z}\` (${J})`},b5=(Z,X,J)=>{if(!(X&&X.args))return`${e(J)} ${Z}(...)\n\nTODO`;const W=X.args.map((Y)=>/^\w+/.exec(Y)[0]).join(", ");return[`${e(J)} \`${Z}(${W})\``,"",...X.args.map(v5),X.desc?`\n${X.desc}\n`:""].join("\n")},v5=(Z)=>`- ${Z.replace(/^(\w+)/,(X,J)=>`**${J}**`)}`,e=y0((Z)=>"#".repeat(Z));import{resolve as $8} from"path";var C8={desc:"Export entire generated framework as CSS",opts:{...H0,...$0,...o4,...d,...n,...M0,...p4,...C0},inputs:1,fn:async(Z)=>{const{logger:X,opts:{include:J,media:W,noDecls:Y,noHeader:B,onlyDecls:V,out:Q,pretty:U,scope:q},inputs:z}=Z,H={format:U?n0:B0,fns:a0,scope:q},K=f($8(z[0]),X),M=J?J.map((E)=>D($8(E),X).trim()):[];if(!B)M.push(Z1(K));if(!Y&&K.decls.length)M.push(t(K.decls,H));if(!V)M.push(y5(K,W,H,X));l(Q,M,X)}},y5=(Z,X,J,W)=>{const Y=M8("",Z);if(X){const B=X[0]==="ALL"?Object.keys(Z.media):X;for(let V of B)if(Z.media[V])Y.push(K0(Z.media[V],M8("-"+V,Z)));else W.warn(`invalid media query ID: ${V}, skipping...`)}return t(Y,J)},M8=(Z,X)=>Object.entries(X.classes).map(([J,W])=>[`.${J}${Z}`,X1(W)]);var b1=f(_5(import.meta.dir,"package.json"));e1({name:"metacss",opts:{verbose:R({alias:"v",desc:"Display extra process information"})},commands:{convert:r4,develop:q8,doc:H8,export:C8,generate:Q8},ctx:async(Z)=>{if(Z.opts.verbose)Z.logger.level=P.DEBUG;return{...Z,format:h0}},usage:{prefix:`
|
|
2
|
+
var ro={default:95,hint:90,multi:90,param:96,required:33};var Tt=(t)=>t;var tt=function(t,o=Object.create(null)){return(...n)=>{const r=JSON.stringify(n);if(r!==void 0)return r in o?o[r]:o[r]=t.apply(null,n);return t.apply(null,n)}};var ot=tt((t,o)=>t.repeat(o));var Do=(t)=>/^[a-f0-9]+$/i.test(t);var Zo=(t)=>/^[-+]?\d+$/.test(t),jo=(t)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(t);var P=(t,o=(n)=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(t(n)+o(n));this.origMessage=n!==void 0?String(n):""}};var $r=P(()=>"illegal argument(s)"),A=(t)=>{throw new $r(t)};var mo=(t)=>jo(t)?parseFloat(t):A(`not a numeric value: ${t}`),Ko=(t)=>t.map(mo),fo=(t)=>Do(t)?parseInt(t,16):A(`not a hex value: ${t}`),Vo=(t)=>t.map(fo),Eo=(t)=>Zo(t)?parseInt(t):A(`not an integer: ${t}`),uo=(t)=>t.map(Eo);var Jt=(t,o)=>(n)=>({coerce:t,hint:o,group:"main",...n}),zt=(t,o)=>(n)=>({hint:Hr(o,n.delim),multi:!0,coerce:t,group:"main",...n}),Hr=(t,o)=>t+(o?`[${o}..]`:""),J=(t)=>({flag:!0,default:!1,group:"flags",...t}),X=Jt(Tt,"STR"),Pt=zt(Tt,"STR"),ff=Jt(mo,"NUM"),Ef=Jt(fo,"HEX"),Xt=Jt(Eo,"INT"),Gf=zt(Ko,"NUM"),_f=zt(Vo,"HEX"),Nf=zt(uo,"INT");var $=((t)=>{return t[t.FINE=0]="FINE",t[t.DEBUG=1]="DEBUG",t[t.INFO=2]="INFO",t[t.WARN=3]="WARN",t[t.SEVERE=4]="SEVERE",t[t.NONE=5]="NONE",t})($||{});var Ir=0;class $t{constructor(t,o=$.FINE,n){this.parent=n,this.id=t||`logger-${Ir++}`,this.level=typeof o==="string"?$[o]:o}id;level;addChild(t){return t.parent=this,t}enabled(t){return this.level<=t}fine(...t){this.log($.FINE,t)}debug(...t){this.log($.DEBUG,t)}info(...t){this.log($.INFO,t)}warn(...t){this.log($.WARN,t)}severe(...t){this.log($.SEVERE,t)}log(t,o){this.level<=t&&this.logEntry([t,this.id,Date.now(),...o])}}var qo=(t)=>t.map((o)=>{if(typeof o==="function")o=o();if(!(typeof o==="string"||typeof o==="number"))o=JSON.stringify(o);return o}).join(" ");class yt extends $t{constructor(t,o,n,r){super(o,n,r);this.target=t}childLogger(t,o){return new yt(this.target,t,o??this.level,this)}logEntry(t){if(t[0]<this.level)return;this.target.write(`[${$[t[0]]}] ${t[1]}: ${qo(t.slice(3))}
|
|
3
|
+
`),this.parent&&this.parent.logEntry(t)}}var Dt=tt((t,o=" ")=>{const n=ot(String(o),t);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<t?r+n.substring(m):r}});var Zt=(t,o=Object.create(null))=>(n)=>(n in o)?o[n]:o[n]=t(n);var Go={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 Sr=(t,o)=>(n)=>t.format(o,n),_o=(t)=>Object.keys(Go).reduce((o,n)=>(o[n]=Sr(t,Go[n]),o),{format:t});var Qo="\x1B[0m";var wr=["","1","2","1;2","4","1;4","2;4","1;2;4"],jt={format:(t,o)=>jt.start(t)+o+jt.end,start:Zt((t)=>{let o=[],n=t&15;return n&&o.push(29+(t>>4&1)*60+n),n=t>>5&15,n&&o.push(39+(t>>9&1)*60+n),n=t>>10,n&&o.push(wr[n]),"\x1B["+o.join(";")+"m"}),end:Qo,prefix:Qo,suffix:"\n"};var bo={format:(t,o)=>String(o),prefix:"",suffix:"\n",start:()=>"",end:""};var Kt=_o(jt),io=_o(bo);var H=Array.isArray;var Wr=(t)=>t.toUpperCase(),ko=(t)=>t.toLowerCase(),Vt=(t)=>t.length?t[0].toUpperCase()+t.substring(1):t,vo=(t,o="-")=>ko(t.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,r,m)=>r+o+m));var lo=(t,o="-")=>ko(t).replace(new RegExp(`\\${o}+(\\w)`,"g"),(n,r)=>Wr(r));var po=Object.getPrototypeOf,y=(t)=>{let o;return t!=null&&typeof t==="object"&&((o=po(t))===null||po(o)===null)};var Rr=/\x1b\[[0-9;]+m/g,Yr=(t)=>t.replace(Rr,"");var ut=(t)=>Yr(t).length;var eo=(t=!1,o)=>(n)=>t||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,o):String(n);function*nt(t,o=/\r?\n/g,n=!1){let r=0;const m=t.length,f=~~n;let G;if(typeof o==="string")G=new RegExp(o,"g");else if(!o.flags.includes("g"))G=new RegExp(o,o.flags+"g");else G=o;for(;r<m;){const E=G.exec(t);if(!E){yield t.substring(r);return}const _=E[0].length;yield t.substring(r,E.index+f*_),r=E.index+_}}class No{n=0;w=[];constructor(t,o){t!=null&&this.add(t,o)}add(t,o=t.length){return this.w.push(t),this.n+=o+~~(this.n>0),this}toString(){return this.w.join(" ")}}var Ur={length:(t)=>t.length,split:(t,o)=>o},xo={length:ut,split:(t,o)=>{const n=/\x1b\[[0-9;]+m/g;let r=o,m;while(m=n.exec(t)){if(m.index>=o)break;const f=m[0].length;r+=f,o+=f}return r}},go=(t,o,n,r)=>{const m=t[t.length-1];m&&r-m.n>n?m.add(o,n):t.push(new No(o,n))},Mr=(t,{width:o,min:n,hard:r,splitter:m},f=0,G=[])=>{let E=m.length(t),_=o-f;if(_<n&&_<E)_=o;while(r&&E>_){const N=m.split(t,_),L=t.substring(0,N);go(G,L,_,o),t=t.substring(N),_=o,E=m.length(t)}return go(G,t,E,o),G},Jr=(t,o,n=[])=>{if(!t.length)return n.push(new No),n;const r={width:80,min:4,hard:!1,splitter:Ur,...o};for(let m of nt(t,o.delimWord||/\s/g)){const f=n[n.length-1];Mr(m,r,f&&f.n>0?f.n+1:0,n)}return n},ao=(t,o)=>{let n=[];for(let r of nt(t,o.delimLine))n=n.concat(Jr(r,o));return n};var Ht=(t,o={})=>{o={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...o};const n=y(o.color)?{...ro,...o.color}:o.color?ro:{},r=ot(" ",o.paramWidth),m=(E)=>E.map((_)=>zr(_,t[_],o,n,r)),f=Object.keys(t).sort(),G=o.groups?o.groups.map((E)=>[E,f.filter((_)=>t[_].group===E)]).filter((E)=>!!E[1].length):[["options",f]];return[...Lo(o.prefix,o.lineWidth),...G.map(([E,_])=>[...o.showGroupNames?[`${Vt(E)}:
|
|
4
|
+
`]:[],...m(_),""].join("\n")),...Lo(o.suffix,o.lineWidth)].join("\n")},zr=(t,o,n,r,m)=>{const f=Pr(o,r),G=Xr(o,r,f),E=It(`--${vo(t)}`,r.param),_=`${G}${E}${f}`,N=o.optional===!1&&o.default===void 0,L=[];N&&L.push("required"),o.multi&&L.push("multiple");const B=yr(L,r,N)+(o.desc||"")+Dr(o,n,r);return Dt(n.paramWidth)(_,ut(_))+Lo(B,n.lineWidth-n.paramWidth).map((O,h)=>h>0?m+O:O).join("\n")},Pr=(t,o)=>t.hint?It(" "+t.hint,o.hint):"",Xr=(t,o,n)=>t.alias?`${It("-"+t.alias,o.param)}${n}, `:"",yr=(t,o,n)=>t.length?It(`[${t.join(", ")}] `,n?o.required:o.multi):"",Dr=(t,o,n)=>o.showDefaults&&t.default!=null&&t.default!==!1?It(` (default: ${eo(!0)(t.defaultHint!=null?t.defaultHint:t.default)})`,n.default):"",It=(t,o)=>o!=null?`\x1B[${o}m${t}\x1B[0m`:t,Lo=(t,o)=>t?ao(t,{width:o,splitter:xo,hard:!1}):[];var Zr=P(()=>"parse error"),co=(t,o,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return jr(t,o,n)}catch(r){if(n.showUsage)console.log(r.message+"\n\n"+Ht(t,n.usageOpts));throw new Zr(r.message)}},jr=(t,o,n)=>{const r=Kr(t),m={};let f,G,E=n.start;for(;E<o.length;){const _=o[E];if(!f){if(n.help.includes(_)){console.log(Ht(t,n.usageOpts));return}const N=Vr(t,r,m,_);if(f=N.id,G=N.spec,E=E+~~(N.state<2),N.state)break}else{if(ur(G,m,f,_))break;f=null,E++}}return f&&A(`missing value for: --${f}`),{result:qr(t,m),index:E,rest:o.slice(E),done:E>=o.length}},Kr=(t)=>Object.entries(t).reduce((o,[n,r])=>r.alias?(o[r.alias]=n,o):o,{}),Vr=(t,o,n,r)=>{if(r[0]==="-"){let m;if(r[1]==="-"){if(r==="--")return{state:1};m=lo(r.substring(2))}else m=o[r.substring(1)],!m&&A(`unknown option: ${r}`);const f=t[m];if(!f&&A(m),f.flag){if(n[m]=!0,m=void 0,f.fn&&!f.fn("true"))return{state:1,spec:f}}return{state:0,id:m,spec:f}}return{state:2}},ur=(t,o,n,r)=>{if(/^-[a-z]/i.test(r)&&A(`missing value for: --${n}`),t.multi)H(o[n])?o[n].push(r):o[n]=[r];else o[n]=r;return t.fn&&!t.fn(r)},qr=(t,o)=>{let n;for(let r in t)if(n=t[r],o[r]===void 0){if(n.default!==void 0)o[r]=n.default;else if(n.optional===!1)A(`missing arg: --${r}`)}else if(n.coerce)Qr(n,o,r);return o},Qr=(t,o,n)=>{try{if(t.multi&&t.delim)o[n]=o[n].reduce((r,m)=>(r.push(...m.split(t.delim)),r),[]);o[n]=t.coerce(o[n])}catch(r){throw new Error(`arg --${n}: ${r.message}`)}};var tn=async(t)=>{const o=t.argv||process.argv,n=!process.env.NO_COLOR,r={prefix:"",color:n,...t.usage};try{let m,f,G=t.start??2;if(t.single){if(m=Object.keys(t.commands)[0],!m)A("no command provided");f=t.commands[m]}else{if(m=o[G],f=t.commands[m],r.prefix+=br(t.commands),!f)so(t,r);G++}let E;try{E=co({...t.opts,...f.opts},o,{showUsage:!0,usageOpts:r,start:G})}catch(N){}if(!E)process.exit(1);if(f.inputs!==void 0&&f.inputs!==E.rest.length)process.stderr.write(`expected ${f.inputs||0} input(s)
|
|
5
|
+
`),so(t,r);const _=await t.ctx({logger:new yt(process.stderr,t.name,"INFO"),format:n?Kt:io,opts:E.result,inputs:E.rest},f);if(await f.fn(_),t.post)await t.post(_,f)}catch(m){process.stderr.write(m.message+"\n\n"),process.exit(1)}},so=(t,o)=>{process.stderr.write(Ht(t.opts,o)),process.exit(1)},br=(t)=>["\nAvailable commands:\n",...Object.keys(t).map((o)=>`${Dt(16)(o)}: ${t[o].desc}`),"\n"].join("\n");import{existsSync as ir,mkdirSync as kr,statSync as BE} from"fs";import{dirname as vr} from"path";var lr=(t)=>t.length>0&&!ir(t)?(kr(t,{recursive:!0}),!0):!1,on=(t)=>lr(vr(t));var K=(t)=>typeof t==="function";var T=(t)=>typeof t==="string";import{readFileSync as dr} from"fs";import{writeFileSync as pr} from"fs";var nn=(t,o,n,r,m=!1)=>{if(r&&r.info(`${m?"[dryrun] ":""}writing file: ${t}`),m)return;on(t),pr(t,o,!n&&T(o)?"utf-8":n)};var S=(t,o,n="utf-8")=>{return o&&o.debug("reading file:",t),dr(t,n)},Oo=(t,o,n,r=!1)=>nn(t,H(o)?o.join("\n"):o,"utf-8",n,r);var V=(t,o)=>JSON.parse(S(t,o));var q=Symbol(),Bo=()=>{};var St=Object.freeze({level:$.NONE,addChild(t){return t},childLogger:()=>St,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class Ao extends $t{set(t){this.parent=t}childLogger(t,o){return new Ao(t,o??this.level,this)}logEntry(t){this.parent.logEntry(t)}}var rn=new Ao("root",$.FINE,St);import{join as Vm} from"path";var ho=(t,o)=>{if(t===o)return 0;if(t==null)return o==null?0:-1;if(o==null)return t==null?0:1;if(typeof t.compare==="function")return t.compare(o);if(typeof o.compare==="function")return-o.compare(t);return t<o?-1:t>o?1:0};var er=P(()=>"Assertion failed"),qt=(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)?(t,o)=>{if(typeof t==="function"&&!t()||!t)throw new er(typeof o==="function"?o():o)}:()=>{};var Qt=(t)=>t!=null&&typeof t!=="function"&&t.length!==void 0;var mn=(t)=>{return(t==null||!t[Symbol.iterator])&&A(`value is not iterable: ${t}`),t};var fn=(t)=>Qt(t)?t:[...mn(t)];var wt=(t)=>t[t.length-1];var gr=P(()=>"illegal arity"),rt=(t)=>{throw new gr(t)};var xr=P(()=>"illegal state"),mt=(t)=>{throw new xr(t)};var bt=(t,o)=>t!=null&&typeof t[o]==="function";var I=(t)=>t!=null&&typeof t[Symbol.iterator]==="function";var it=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";var En=["-moz-","-ms-","-o-","-webkit-"],ft={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},kt={rules:"\n",ruleSep:", ",valSep:" ",decls:"\n",declStart:" {\n",declEnd:"}\n",indent:" ",comments:!0};var Co=function(...t){let[o,n,r,m,f,G,E,_,N,L]=t;switch(t.length){case 0:rt(0);case 1:return o;case 2:return(...O)=>o(n(...O));case 3:return(...O)=>o(n(r(...O)));case 4:return(...O)=>o(n(r(m(...O))));case 5:return(...O)=>o(n(r(m(f(...O)))));case 6:return(...O)=>o(n(r(m(f(G(...O))))));case 7:return(...O)=>o(n(r(m(f(G(E(...O)))))));case 8:return(...O)=>o(n(r(m(f(G(E(_(...O))))))));case 9:return(...O)=>o(n(r(m(f(G(E(_(N(...O)))))))));case 10:default:const B=(...O)=>o(n(r(m(f(G(E(_(N(L(...O))))))))));return t.length===10?B:Co(B,...t.slice(10))}};var d=(t)=>bt(t,"xform")?t.xform():t;var D=function(...t){return t=t.map(d),Co.apply(null,t)};var Q=(t,o)=>[t[0],t[1],o];class Wt{value;constructor(t){this.value=t}deref(){return this.value}}var w=(t)=>t instanceof Wt,Gn=(t)=>t instanceof Wt?t:new Wt(t),Z=(t)=>t instanceof Wt?t.deref():t;var Et=function(...t){const o=t[0],n=o[0],r=o[1],m=o[2];t=ar(t);const f=t[0]==null?n():t[0],G=t[1];return Z(r(bt(G,"$reduce")?G.$reduce(m,f):Qt(G)?cr(m,f,G):sr(m,f,G)))};var ar=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:rt(t.length),cr=(t,o,n)=>{for(let r=0,m=n.length;r<m;r++)if(o=t(o,n[r]),w(o)){o=o.deref();break}return o},sr=(t,o,n)=>{for(let r of n)if(o=t(o,r),w(o)){o=o.deref();break}return o},Gt=(t,o)=>[t,Tt,o],_n=(t,o)=>{const n=o.length-1;return I(o[n])?o.length>1?Et(t.apply(null,o.slice(0,n)),o[n]):Et(t(),o[0]):void 0};var _t=function(t){return t?[...t]:Gt(()=>[],(o,n)=>(o.push(n),o))};function*Nt(t,o){const n=d(t)(_t()),r=n[1],m=n[2];for(let f of o){const G=m([],f);if(w(G)){yield*Z(r(G.deref()));return}if(G.length)yield*G}yield*Z(r([]))}function*e(t,o){const n=d(t)([Bo,Bo,(r,m)=>m])[2];for(let r of o){let m=n(q,r);if(w(m)){if(m=Z(m.deref()),m!==q)yield m;return}if(m!==q)yield m}}var vt=(t,o,n=e)=>{const r=o.length-1;return I(o[r])?o.length>1?n(t.apply(null,o.slice(0,r)),o[r]):n(t(),o[0]):void 0};var Fo=function(t,o){return I(o)?Nt(Fo(t),T(o)?[o]:o):(n)=>{const r=n[2],m=(f,G)=>{const E=t(G);if(E){for(let _ of E)if(f=m(f,_),w(f))break;return f}return r(f,G)};return Q(n,m)}};var Nn=function(t){return Fo((o)=>it(o)?o:void 0,t)};var F=function(t,o){return I(o)?e(F(t),o):(n)=>{const r=n[2];return Q(n,(m,f)=>r(m,t(f)))}};function*lt(...t){const o=t.length-1;if(o<0)return;const n=new Array(o+1).fill(0),r=t.map(fn),m=r.reduce((f,G)=>f*G.length,1);for(let f=0;f<m;f++){const G=[];for(let E=o;E>=0;E--){const _=r[E];let N=n[E];if(N===_.length)n[E]=N=0,E>0&&n[E-1]++;G[E]=_[N]}n[o]++,yield G}}function*Ln(t,o=Infinity){while(o-- >0)yield t}var To=function(t,o){t=t||"";let n=!0;return o?[...o].join(t):Gt(()=>"",(r,m)=>(r=n?r+m:r+t+m,n=!1,r))};var pt=function(...t){return tm(pt,Et,t)};var tm=(t,o,n)=>{let r,m;switch(n.length){case 4:m=n[3],r=n[2];break;case 3:m=n[2];break;case 2:return F((f)=>t(n[0],n[1],f));default:rt(n.length)}return o(d(n[0])(n[1]),r,m)};var om=new Set,nm=":[",On=D(Nn(),F((t)=>t[0]==="&"?t.substring(1):nm.includes(t[0])?t:" "+t)),rm=(t,o)=>D(t,F((n)=>T(n)&&n.startsWith(" .")?n+o:n)),Lt=(t,o,n,r)=>{const m=n.length,f=[];let G,E;const _=(N,L)=>{let B=null;if(H(L))Lt(t,$o(o,f),L,r);else if(I(L)&&!T(L))Lt(t,$o(o,f),[...L],r);else if((E=K(L))||(B=r.fns[L]))if(!o.length){if(B)return B.apply(null,n.slice(N+1))(t,r),!0;L(t,r)}else if(E)_(N,L());else A(`quoted fn ('${L}') only allowed at head position`);else if(y(L))G=Object.assign(G||{},L);else if(L!=null)f.push(L)};for(let N=0;N<m;N++)if(_(N,n[N]))return t;return G&&t.push(mm(o,f,G,r)),t},$o=(t,o)=>t.length?[...lt(t,o)]:o,mm=(t,o,n,r)=>{const m=r.format,f=j(r),G=r.scope?rm(On,r.scope):On;return[f,pt(F((E)=>pt(G,To(),H(E)?E:[E]).trim()),To(m.ruleSep),$o(t,o)),m.declStart,Rt(n,r),f,m.declEnd].join("")},Rt=(t,o)=>{const n=o.format,r=o.autoprefix||om,m=j(o,o.depth+1),f=[];for(let G in t)if(t.hasOwnProperty(G)){let E=t[G];if(K(E))E=E(t);if(H(E))E=E.map((_)=>H(_)?_.join(" "):_).join(n.ruleSep);if(r.has(G))for(let _ of o.vendors)f.push(`${m}${_}${G}:${n.valSep}${E};`);f.push(`${m}${G}:${n.valSep}${E};`)}return f.join(n.decls)+n.decls},j=(t,o=t.depth)=>o>1?[...Ln(t.format.indent,o)].join(""):o>0?t.format.indent:"";var Bn=function(t,...o){const n=o.length===1?o[0]:o.reduce((r,m,f)=>{return r[f/(o.length-1)*100|0]=m,r},{});return(r,m)=>{const f=j(m);m.depth++;const G=j(m);r.push(`${f}@keyframes ${t}${m.format.declStart}`);for(let E in n)if(n.hasOwnProperty(E))r.push([G,E+"%",m.format.declStart,Rt(n[E],m),G,m.format.declEnd].join(""));return m.depth--,r.push(f+m.format.declEnd),r}};var An=(t,o=!1)=>(n,r)=>{const m=j(r),f=j(r,r.depth+1);if(r.format.comments||o)n.push(m+"/*",t.split("\n").map((G)=>f+G).join("\n"),m+"*/");return n};var dt=(t,o,n)=>(r,m)=>{const f=j(m);return r.push(`${f}${t} ${fm(o)}${m.format.declStart}`),m.depth++,Lt(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},fm=(t)=>{if(T(t))return t;const o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=hn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${hn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},hn=new Set(["all","print","screen"]);var g=(t,o)=>{return o={format:ft,vendors:En,fns:{},depth:0,...o},H(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),y(t)?Rt(t,o):K(t)?t([],o).join(o.format.rules):Lt([],[],H(t)?t:it(t)?[...t]:A("invalid rules"),o).join(o.format.rules)};var Cn=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var Ot=(t,o)=>dt("@media",t,o);var Fn=function(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)};var Tn=(t,o)=>dt("@supports",t,o);var et={"@comment":An,"@import":Cn,"@keyframes":Bn,"@media":Ot,"@namespace":Fn,"@supports":Tn};var $n=4,Hn=(t)=>$n=t,U=(t)=>t===(t|0)?String(t):t.toFixed($n).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var In=(t)=>`${U(t)}em`,Sn=(t)=>`${U(t)}ex`;var wn=(t)=>`${U(t)}rem`,Ho=(t)=>`${U(t)}%`,Wn=(t)=>`${U(t)}px`,Rn=(t)=>`${U(t)}vh`,Yn=(t)=>`${U(t)}vw`,Un=(t)=>`${U(t)}vmin`,Mn=(t)=>`${U(t)}vmax`,Jn=(t)=>`${t|0}ms`,zn=(t)=>`${U(t)}s`;var Pn=(t)=>`${U(t)}deg`,Xn=(t)=>`${U(t)}rad`,yn=(t)=>`${U(t)}turn`,Dn=(t)=>`url(${t})`;var W=((t)=>{return t[t.IDLE=0]="IDLE",t[t.ACTIVE=1]="ACTIVE",t[t.DONE=2]="DONE",t[t.UNSUBSCRIBED=3]="UNSUBSCRIBED",t[t.ERROR=4]="ERROR",t})(W||{}),z=((t)=>{return t[t.NEVER=0]="NEVER",t[t.FIRST=1]="FIRST",t[t.LAST=2]="LAST",t})(z||{});var Em=0,Gm=()=>Em++,x=(t,o)=>!o||!o.id?{...o,id:t+"-"+Gm()}:o;var R=rn.childLogger("rstream");class b{constructor(t,o){this.wrapped=t,o=x("sub",{closeIn:z.LAST,closeOut:z.LAST,cache:!0,...o}),this.parent=o.parent,this.id=o.id,this.closeIn=o.closeIn,this.closeOut=o.closeOut,this.cacheLast=o.cache,o.xform&&(this.xform=o.xform(_t()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=q;state=W.IDLE;subs=[];deref(){return this.last!==q?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof b&&!o.xform)t.ensureState(),qt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new b(t,{...o,parent:this});return this.subs.push(n),this.setState(W.ACTIVE),n.setState(W.ACTIVE),this.last!=q&&n.next(this.last),n}transform(...t){let o,n;if(y(wt(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,x("xform",t.length>0?{...n,xform:D(...t)}:n))}map(t,o){return this.transform(F(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return R.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<W.UNSUBSCRIBED&&(this.state=W.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){R.debug(this.id,"unsub child",t.id);const o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut===z.FIRST||!this.subs.length&&this.closeOut!==z.NEVER)this.unsubscribe();return!0}return!1}next(t){if(this.state>=W.DONE)return;this.xform?this.dispatchXform(t):this.dispatch(t)}done(){if(R.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();R.debug(this.id,"exiting done()")}error(t){const o=this.wrapped,n=o&&o.error;return n&&R.debug(this.id,"attempting wrapped error handler"),n&&o.error(t)||this.unhandledError(t)}unhandledError(t){return(R.parent!==St?R:console).warn(this.id,"unhandled error:",t),this.unsubscribe(),this.state=W.ERROR,!1}dispatchTo(t,o){let n=this.wrapped;if(n)try{n[t]&&n[t](o)}catch(m){if(!this.error(m))return!1}const r=t==="next"?this.subs:[...this.subs];for(let m=r.length;m-- >0;){n=r[m];try{n[t]&&n[t](o)}catch(f){if(t==="error"||!n.error||!n.error(f))return this.unhandledError(f)}}return!0}dispatch(t){R.debug(this.id,"dispatch",t),this.cacheLast&&(this.last=t),this.dispatchTo("next",t)}dispatchXform(t){let o;try{o=this.xform[2]([],t)}catch(n){this.error(n);return}if(this.dispatchXformVals(o))w(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){const o=Z(t);for(let n=0,r=o.length;n<r&&this.state<W.DONE;n++)this.dispatch(o[n]);return this.state<W.ERROR}ensureState(){if(this.state>=W.DONE)mt(`operation not allowed in state ${this.state}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Zn=(t,o)=>{const n=new jn(o);return n.next(t),n};class jn extends b{src;_cancel;_inited;constructor(t,o){const[n,r]=K(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,x("stream",r));this.src=n,this._inited=!1}subscribe(t,o={}){const n=super.subscribe(t,o);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(r){let m=this.wrapped;if(!m||!m.error||!m.error(r))this.unhandledError(r)}this._inited=!0}return n}unsubscribe(t){const o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!==z.NEVER))this.cancel();return o}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(t){if(super.error(t))return!0;return this.cancel(),!1}cancel(){if(this._cancel){R.debug(this.id,"cancel");const t=this._cancel;delete this._cancel,t()}}}var Kn=(t,o)=>t===z.FIRST||t===z.LAST&&!o;var Io=function(t){return t?Et(Io(),t):Gt(()=>({}),(o,[n,r])=>(o[n]=r,o))};var Vn=()=>(t)=>{const o=t[2];return Q(t,(n,r)=>{if(r){for(let m of Z(r))if(n=o(n,m),w(n))break}return w(r)?Gn(n):n})};var So=function(t,o){return I(o)?Nt(So(t),o):D(F(t),Vn())};var wo=function(t,o){return I(o)?e(wo(t),o):F(K(t)?(n)=>[t(n),n]:(n)=>[t,n])};var Wo=function(...t){const o=vt(Wo,t);if(o)return o;const n=t[0],r=t[1]!==!1;return F((m)=>{const f=r?{}:m;for(let G in m)f[G]=n(m[G]);return f})};var un=(t)=>t;var Ro=function(...t){const o=vt(Ro,t,Nt);if(o)return o;const{key:n=un,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:G=0}=t[1],E=H(t[0])?new Set(t[0]):t[0],_=new Set,N=new Map;let L={};const B=([O,h,M])=>{let l=!0;if(r||G<1)return[O,(C)=>{if(m&&f&&_.size>0||!m&&l)C=M(C,L),L={},_.clear(),l=!1;return h(C)},(C,p)=>{const Y=n(p);if(E.has(Y)){if(L[Y]=p,_.add(Y),r||qn(E,_))if(C=M(C,L),l=!1,m)L={},_.clear();else L={...L}}return C}];else return[O,(C)=>{if(f&&_.size>0)C=M(C,Qn(N,_)),N.clear(),_.clear();return h(C)},(C,p)=>{const Y=n(p);if(E.has(Y)){let u=N.get(Y);!u&&N.set(Y,u=[]),u.length>=G&&mt(`max back pressure (${G}) exceeded for input: ${String(Y)}`),u.push(p),_.add(Y);while(qn(E,_))if(C=M(C,Qn(N,_)),l=!1,w(C))break}return C}]};return B.keys=()=>E,B.clear=()=>{N.clear(),E.clear(),_.clear(),L={}},B.add=(O)=>{E.add(O)},B.delete=(O,h=!0)=>{if(N.delete(O),E.delete(O),h)_.delete(O),delete L[O]},B},qn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},Qn=(t,o)=>{const n={};for(let r of o){const m=t.get(r);n[r]=m.shift(),!m.length&&o.delete(r)}return n};var bn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var gt=(t)=>new kn(t);class kn extends b{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){const o=Ro(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=Wo((r)=>r[1]);super(void 0,x("streamsync",{...t,xform:t.xform?D(o,n,t.xform):D(o,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=o,this.clean=!!t.clean,t.src&&this.addAll(t.src)}add(t,o){o||(o=t.id),this.ensureState(),this.psync.add(o),this.realSourceIDs.set(o,t.id),this.invRealSourceIDs.set(t.id,o),this.idSources.set(t.id,t),this.sources.set(t,t.subscribe({next:(n)=>n[1]instanceof b?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:wo(o),id:`in-${o}`}))}addAll(t){for(let o in t)this.psync.add(o);for(let o in t)this.add(t[o],o)}remove(t){const o=this.sources.get(t);if(o){const n=this.invRealSourceIDs.get(t.id);return R.info(`removing src: ${t.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(t.id),this.idSources.delete(t.id),this.sources.delete(t),o.unsubscribe(),!0}return!1}removeID(t){const o=this.getSourceForID(t);return o?this.remove(o):!1}removeAll(t){for(let n of t)this.psync.delete(this.invRealSourceIDs.get(n.id));let o=!0;for(let n of t)o=this.remove(n)&&o;return o}removeAllIDs(t){return bn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){const t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){R.debug(this.id,"unsub sources");for(let o of this.sources.values())o.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(t)}markDone(t){this.remove(t),Kn(this.closeIn,this.sources.size)&&this.done()}}var Yo=tt((t,o=" ")=>{const n=ot(String(o),t);return(r,m)=>{if(r==null)return n;return r=r.toString(),m=m!==void 0?m:r.length,m<t?n.substring(m)+r:r}}),p_=Yo(2,"0"),d_=Yo(3,"0"),vn=Yo(4,"0");var _m=/\{(\d+)\}/g;var Uo=(t,...o)=>o.length>0?t.replace(_m,(n,r)=>String(o[parseInt(r,10)])):t;var ln=(t)=>({key:(o)=>o,group:_t(),...t});var Mo=function(...t){const o=_n(Mo,t);if(o)return o;const n=ln(t[0]),[r,m,f]=n.group;return[()=>({}),(G)=>{for(let E in G)G[E]=m(G[E]);return G},(G,E)=>{const _=n.key(E);return G[_]=G[_]?f(G[_],E):f(r(),E),G}]};var Jo=function(t,o){return I(o)?e(Jo(t),o):(n)=>{const r=n[2];return Q(n,(m,f)=>t(f)?r(m,f):m)}};import{watch as xn} from"fs";import{resolve as a} from"path";var pn={specs:X({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},xt={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},Bt={include:Pt({alias:"I",desc:"Include CSS files (prepend)"})},at={eval:X({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},ct={force:Pt({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},dn={media:Pt({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},en={onlyDecls:J({desc:"Only emit framework decls"})},i={out:X({alias:"o",desc:"Output file (or stdout)"})},st={prec:Xt({default:3,desc:"Number of fractional digits"})},k={pretty:J({alias:"p",desc:"Pretty print output"})},At={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},ht={noHeader:J({desc:"Don't emit generated header comment"})},Ct={scope:X({desc:"Suffix for CSS class names"})},Ft={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Nm} from"fs";import{resolve as gn} from"path";var v=(t,o,n)=>{o=T(o)?o:o.join("\n"),t?Oo(gn(t),o,n):process.stdout.write(o+"\n")},to=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${(new Date()).toISOString()} */`,Yt=(t,o)=>{const n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=gn(m);const G=Zn(S(m,o),{id:`in${vn(f)}`});return{input:G,watcher:Nm(m,{},(E)=>{if(E==="change")try{G.next(S(m,o))}catch(_){o.warn(_.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),gt({src:Io(F(({input:m})=>[m.id,m],r))})},oo=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});async function Po(t){const o=V(a(t.opts.specs),t.logger),n=hm(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await Om(t,n);else Ut(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>S(a(r),t.logger)),t.opts.out);else if(t.opts.watch)await Lm(t,o,n);else if(t.opts.eval)try{Ut(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=a(r);const m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;Ut(t,o,n,[S(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}function*Fm(t){let o=-1,n=t.length,r=0;for(let m=0;m<n;m++){const f=t[m];if(f===" "||f==="\t"){if(!r&&o>=0)yield t.substring(o,m),o=-1}else if(f==="{"||f==="}"){if(o>=0)yield t.substring(o,m);yield f,o=-1}else if(f==="(")r++;else if(f===")"){if(--r<0)A(`invalid nesting in line: '${t}'`)}else if(o<0)o=m}if(r)A("template calls must be fully on a single line");if(o>=0)yield t.substring(o,n)}var cn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...xt,...at,...ct,...Bt,...At,...ht,...i,...k,...Ct,...pn,...Ft,noWrite:J({desc:"Don't write files, use stdout only"})},fn:Po},Lm=async(t,o,n)=>{const r=a(t.opts.specs);let m,f={process:()=>{try{return o=V(r,t.logger),m.forEach((E)=>E.process()),!0}catch(E){return t.logger.warn(E.message+": "+r),!1}},watcher:xn(r,{},(E)=>{if(E==="change")f.process();else t.logger.warn("specs file removed:",r),G()})};const G=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((E)=>E.watcher.close())};m=t.inputs.map((E)=>{E=a(E);const _=!t.opts.noWrite?E.replace(/\.mcss$/,".css"):void 0,N=()=>{try{return Ut(t,o,n,[S(E,t.logger)],_),!0}catch(L){if(t.logger.warn(L.message+": "+E),m)G();return!1}};if(!N())process.exit(1);return{process:N,watcher:xn(E,{},(L)=>{if(L==="change")N();else t.logger.warn("input removed:",E),G()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",G)},Om=async(t,o)=>{gt({src:{styles:Yt(t.inputs,t.logger),specs:Yt([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{Ut(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},Ut=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},G,E,_,N)=>{const L={logger:t,specs:G,css:{format:m?kt:ft,fns:et,scope:f},mediaQueryIDs:new Set(Object.keys(G.media)),mediaQueryRules:{...E.mediaQueryRules},plainRules:{...E.plainRules}},B=o?o.map((O)=>S(a(O),t).trim()):[];if(!r)B.push(to(G));if(!n&&G.decls.length)B.push(g(G.decls,L.css));_.forEach((O)=>Cm(O,L)),Am(B,L),Bm(B,L),v(N,B,t)},Bm=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){const G=tr(r[f],m);n.debug("mediaquery rules",f,G),t.push(g(Ot(Hm(m.media,f),G),o))}},Am=(t,{css:o,logger:n,plainRules:r,specs:m})=>{const f=tr(r,m);n.debug("plain rules",f),t.push(g(f,o))},hm=(t,o,n)=>{const r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},G={};if(o.length&&o[0][0]==="@")o=[...nt(S(a(o[0].substring(1)),n))];for(let E of o){if(!E||E.startsWith("//"))continue;const{token:_,query:N}=or(E,r);let L;if(_.includes("*")){const B=new RegExp(`^${_.replace("*",".*")}\$`);L=[...Jo((O)=>B.test(O),m)]}else if(m.has(_))L=[_];else{n.warn(`unknown include rule ID: ${E}, skipping...`);continue}for(let B of L)n.debug("including class:",B),N?nr(f,N,`.${B}`,B):rr(G,`.${B}`,B)}return{mediaQueryRules:f,plainRules:G}},Cm=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{const f=Mt(),G=Mt(f),E={root:f,curr:G,scopes:[G]};for(let _ of nt(t)){if(!_||/^\s*\/\//.test(_))continue;for(let N of Fm(_)){if(!N)continue;let L=E.curr;switch(L.state){case"sel":case"nest":if(N==="{"){if(L.state==="sel")L.sel=L.sel.map((B)=>B.replace(",","")),L.path=Tm(E.scopes);L.state="class"}else if(N==="}")an(E);else{const B=wt(L.sel);if(!B||B.endsWith(","))L.sel.push(N);else L.sel[L.sel.length-1]+=" "+N}break;case"class":if(N==="{")L.state="nest",E.scopes.push(E.curr=Mt(L));else if(N==="}")an(E);else{let{token:B,query:O}=or(N,n);if(!o.classes[B]&&!(mr(B)||fr(B)))A(`unknown class ID: ${B}`);if(O)nr(r,O,L.path,B);else rr(m,L.path,B)}break;default:mt(L.state)}}}},zo=":",sn="///",Mt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),an=(t)=>{const o=!t.curr.sel.length;if(qt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=wt(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Mt(t.curr))}else t.scopes.push(t.curr=Mt(t.root))},Tm=(t)=>t.map((o)=>o.sel.join(",")).join(sn),tr=(t,o)=>Object.entries(t).map(([n,r])=>$m(n,r,o)),$m=(t,o,n)=>{const r=[];let m=r;const f=t.split(sn);for(let G=0;G<f.length;G++){const E=f[G].split(",");if(G==f.length-1){const _=Object.assign({},...F((N)=>fr(N)?Sm(n,N):mr(N)?Im(N):oo(n.classes[N]),o));E.push(_)}m.push(E),m=E}return r[0]},or=(t,o)=>{if(/^::?/.test(t))return{token:t};const n=t.lastIndexOf(zo);if(n<0)return{token:t};const r=t.substring(0,n);if(!r.split(zo).every((f)=>o.has(f)))A(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:r}},Hm=(t,o)=>o.split(zo).reduce((n,r)=>Object.assign(n,t[r]),{}),nr=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},rr=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Im=(t)=>{const o=t.indexOf("=");return{[`--${t.substring(0,o)}`]:t.substring(o+1)}},Sm=(t,o)=>{const n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((G)=>G.trim().replace("\\,",",")),f=t.templates[r];if(!f)A(`unknown template: ${r}`);if(m.length!==f.__arity)A(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((G,[E,_])=>{if(!E.startsWith("__")){if(E=Uo(E,...m),T(_))_=Uo(_,...m);G[E]=_}return G},{})},mr=(t)=>t.includes("="),fr=(t)=>t.includes("(");async function Xo(t){if(t.opts.watch)await Rm(t);else await Nr(t.inputs.map((o)=>S(o,t.logger)),t.opts,t.logger)}var Gr={deg:Pn,em:In,ex:Sn,ms:Jn,percent:Ho,px:Wn,rad:Xn,rem:wn,second:zn,turn:yn,url:Dn,vh:Rn,vmax:Mn,vmin:Un,vw:Yn,"%":Ho},wm={percent:"{0}%",second:"{0}s",url:"url({0})"},Wm={"":[""],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"],in:[""],out:[""]},_r={desc:"Generate framework rules from specs",opts:{...i,...st,...k,...Ft},fn:Xo},Rm=async(t)=>{Yt(t.inputs,t.logger).subscribe({next(o){try{Nr(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},Nr=async(t,o,n)=>{const r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Hn(o.prec);for(let m of t){const f=JSON.parse(m);if(Object.assign(r.info,f.info),Object.assign(r.media,f.media),f.decls)r.decls.push(...f.decls);if(f.specs)for(let G of f.specs)try{Lr(f,G,r.classes,n)}catch(E){n.warn(`error processing spec: ${G.name}`,E,", skipping...")}if(f.templates)for(let G of f.templates)Ym(f,G,r.templates,n)}return v(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},Lr=(t,o,n,r,m=!1)=>{const f=H(o.vars)?o.vars:[""],G=T(o.props)?{[o.props]:"<v>"}:o.props,E=Um(o,t),_=new Set;for(let N of f){const L=t.vars?.[N]||Wm[N];if(!L)A(`unknown variation ID: ${N}`);for(let[B,O]of lt(L,Object.keys(E))){const h=c(o.name,N,B,O,E[O]),M=o.unit?c(o.unit,N,B,O,E[O]):void 0,l=m?Jm(M):Mm(E[O],M);if(!n[h]){if(n[h]={},o.user!=null)n[h].__user=o.user;if(o.doc!=null)n[h].__doc=zm(o.doc,N,B,O,l)}else if(!_.has(h))A(`duplicate class ID: ${h}`);_.add(h);let C=-1;for(let[p,Y]of Object.entries(G)){const u=c(p,N,B,O,E[O]),no=c(!M||T(Y)?String(Y):Gr[M](Y),N,B,O,l);if(n[h][u]=no,r.debug(h,u,no),m)C=Er(no,Er(u,C))}if(m)n[h].__arity=C+1}}return n},Ym=(t,o,n,r)=>Lr(t,{...o,values:[""]},n,r,!0),Er=(t,o)=>{const n=/\{(\d+)\}/g;let r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},Um=(t,o)=>{const n=T(t.values)?o.tables?.[t.values]||A(`invalid table ID: ${t.values}`):t.values;if(y(n))return n;const r=t.key==="v"?(m)=>String(m):t.key==="i+1"?(m,f)=>String(f+1):t.key===void 0?(m,f)=>String(f):A(`invalid key type: ${t.key}`);return n.reduce((m,f,G)=>{return m[r(f,G)]=f,m},{})},Mm=(t,o)=>{if(!o||T(t))return t;const n=Gr[o];if(!n)A(`invalid unit: ${o}`);return n(t)},Jm=(t)=>t?wm[t]||"{0}"+t:"{0}",c=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),zm=({group:t,desc:o,args:n},r,m,f,G)=>({group:t?c(t,r,m,f,G):"TODO",desc:o?c(o,r,m,f,G):void 0,args:n?n.map((E)=>c(E,r,m,f,G)):void 0});var Or={desc:"Combination of the generate & convert commands",opts:{...xt,...at,...ct,...Bt,...At,...ht,...st,...k,...Ct,...Ft,outCss:X({desc:"Output file for CSS bundle",optional:!1}),outSpecs:X({desc:"Output file for framework",optional:!1})},fn:async(t)=>{const{opts:o,inputs:n}=t,[r,m]=n.reduce((E,_)=>(E[_.endsWith(".json")?0:1].push(_),E),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},G={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Xo(f),await Po(G)}};import{resolve as Pm} from"path";var hr={desc:"Generate Markdown documentation for framework specs",opts:{...i,level:Xt({alias:"l",desc:"Initial heading level",default:1}),title:X({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{const{logger:o,opts:n,inputs:r}=t,m=V(Pm(r[0]),o),f=Xm(m,n);v(n.out,f,o)}},Xm=(t,{level:o,title:n})=>{const r=Object.keys(t.classes).length,m=Object.keys(t.templates).length,f=[`Currently, there are ${r+m} CSS utility classes (incl. ${m} templates) defined in "${t.info.name}" (v${t.info.version}):`,"",`${s(o+1)} Classes by category`,"",...Ar(t.classes,Dm,o+2),`${s(o+1)} Templates by category`,"",...Ar(t.templates,Zm,o+2),`${s(o+1)} Media queries`,"",...Object.entries(t.media).map(([G,E])=>`- **${G}**: \`${JSON.stringify(E)}\``),""];if(n!=="NONE")f.unshift(`${s(o)} ${n??t.info.name}\n`);return f},Br=(t)=>t.split(/(\d+)/).map((o)=>{const n=parseInt(o);return isNaN(n)?o:n}),ym=(t,o)=>{if(/\d+/.test(t)&&/\d+/.test(o)){const n=Br(t),r=Br(o),m=n.length;if(m===r.length){for(let f=0;f<m;f++)if(n[f]!==r[f])return ho(n[f],r[f]);return 0}return n.length-r.length}return ho(t,o)},Ar=(t,o,n)=>{const r=Mo({key:([m,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(m)=>m.sort(),(m,f)=>(m.push(f[0]),m)]},Object.entries(t));return So((m)=>{const f=r[m].sort(ym).map((E)=>o(E,t[E].__doc,n+1)),G=f.length;return[`${s(n)} ${Vt(m)}`,G>3?`\n<details><summary>${G} items:</summary>\n`:"",f.join("\n"),G>3?"</details>\n":""]},Object.keys(r).sort())},Dm=(t,o)=>{if(!(o&&o.desc))return`- \`${t}\``;let n=o.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${t}\` (${n})`},Zm=(t,o,n)=>{if(!(o&&o.args))return`${s(n)} ${t}(...)\n\nTODO`;const r=o.args.map((m)=>/^\w+/.exec(m)[0]).join(", ");return[`${s(n)} \`${t}(${r})\``,"",...o.args.map(jm),o.desc?`\n${o.desc}\n`:""].join("\n")},jm=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,s=Zt((t)=>"#".repeat(t));import{resolve as Cr} from"path";var Tr={desc:"Export entire generated framework as CSS",opts:{...Bt,...At,...en,...i,...k,...ht,...dn,...Ct},inputs:1,fn:async(t)=>{const{logger:o,opts:{include:n,media:r,noDecls:m,noHeader:f,onlyDecls:G,out:E,pretty:_,scope:N},inputs:L}=t,B={format:_?kt:ft,fns:et,scope:N},O=V(Cr(L[0]),o),h=n?n.map((M)=>S(Cr(M),o).trim()):[];if(!f)h.push(to(O));if(!m&&O.decls.length)h.push(g(O.decls,B));if(!G)h.push(Km(O,r,B,o));v(E,h,o)}},Km=(t,o,n,r)=>{const m=Fr("",t);if(o){const f=o[0]==="ALL"?Object.keys(t.media):o;for(let G of f)if(t.media[G])m.push(Ot(t.media[G],Fr("-"+G,t)));else r.warn(`invalid media query ID: ${G}, skipping...`)}return g(m,n)},Fr=(t,o)=>Object.entries(o.classes).map(([n,r])=>[`.${n}${t}`,oo(r)]);var yo=V(Vm(import.meta.dir,"package.json"));tn({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:cn,develop:Or,doc:hr,export:Tr,generate:_r},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=$.DEBUG;return{...t,format:Kt}},usage:{prefix:`
|
|
6
6
|
\u2588 \u2588 \u2588 \u2502
|
|
7
7
|
\u2588\u2588 \u2588 \u2502
|
|
8
|
-
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${
|
|
9
|
-
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${
|
|
8
|
+
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${yo.name} ${yo.version}
|
|
9
|
+
\u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${yo.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.
|
|
3
|
+
"version": "0.12.1",
|
|
4
4
|
"description": "Data-driven CSS framework codegen, transpiler & bundler",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"module": "./index.js",
|
|
@@ -41,26 +41,26 @@
|
|
|
41
41
|
"tool:tangle": "../../node_modules/.bin/tangle src/**/*.ts"
|
|
42
42
|
},
|
|
43
43
|
"dependencies": {
|
|
44
|
-
"@thi.ng/api": "^8.11.
|
|
45
|
-
"@thi.ng/args": "^2.3.
|
|
46
|
-
"@thi.ng/arrays": "^2.9.
|
|
47
|
-
"@thi.ng/checks": "^3.6.
|
|
48
|
-
"@thi.ng/compare": "^2.3.
|
|
49
|
-
"@thi.ng/errors": "^2.5.
|
|
50
|
-
"@thi.ng/file-io": "^2.1.
|
|
51
|
-
"@thi.ng/hiccup-css": "^2.7.
|
|
52
|
-
"@thi.ng/logger": "^3.0.
|
|
53
|
-
"@thi.ng/memoize": "^3.3.
|
|
54
|
-
"@thi.ng/rstream": "^8.
|
|
55
|
-
"@thi.ng/strings": "^3.7.
|
|
56
|
-
"@thi.ng/text-format": "^2.2.
|
|
57
|
-
"@thi.ng/transducers": "^9.0.
|
|
44
|
+
"@thi.ng/api": "^8.11.2",
|
|
45
|
+
"@thi.ng/args": "^2.3.33",
|
|
46
|
+
"@thi.ng/arrays": "^2.9.6",
|
|
47
|
+
"@thi.ng/checks": "^3.6.4",
|
|
48
|
+
"@thi.ng/compare": "^2.3.5",
|
|
49
|
+
"@thi.ng/errors": "^2.5.7",
|
|
50
|
+
"@thi.ng/file-io": "^2.1.2",
|
|
51
|
+
"@thi.ng/hiccup-css": "^2.7.9",
|
|
52
|
+
"@thi.ng/logger": "^3.0.12",
|
|
53
|
+
"@thi.ng/memoize": "^3.3.4",
|
|
54
|
+
"@thi.ng/rstream": "^8.5.0",
|
|
55
|
+
"@thi.ng/strings": "^3.7.33",
|
|
56
|
+
"@thi.ng/text-format": "^2.2.5",
|
|
57
|
+
"@thi.ng/transducers": "^9.0.5"
|
|
58
58
|
},
|
|
59
59
|
"devDependencies": {
|
|
60
|
-
"@microsoft/api-extractor": "^7.43.
|
|
61
|
-
"esbuild": "^0.
|
|
62
|
-
"typedoc": "^0.25.
|
|
63
|
-
"typescript": "^5.4.
|
|
60
|
+
"@microsoft/api-extractor": "^7.43.2",
|
|
61
|
+
"esbuild": "^0.21.1",
|
|
62
|
+
"typedoc": "^0.25.13",
|
|
63
|
+
"typescript": "^5.4.5"
|
|
64
64
|
},
|
|
65
65
|
"keywords": [
|
|
66
66
|
"browser",
|
|
@@ -110,5 +110,5 @@
|
|
|
110
110
|
"status": "alpha",
|
|
111
111
|
"year": 2023
|
|
112
112
|
},
|
|
113
|
-
"gitHead": "
|
|
113
|
+
"gitHead": "df34b4a9e650cc7323575356de207d78933bdcf3\n"
|
|
114
114
|
}
|
package/specs/_info.mcss.json
CHANGED
package/specs/colors.mcss.json
CHANGED
|
@@ -46,9 +46,20 @@
|
|
|
46
46
|
}
|
|
47
47
|
},
|
|
48
48
|
"vars": {
|
|
49
|
+
"schemes": ["border-", "background-", ""],
|
|
49
50
|
"fill-stroke": ["fill", "stroke"]
|
|
50
51
|
},
|
|
51
52
|
"specs": [
|
|
53
|
+
{
|
|
54
|
+
"doc": { "group": "color scheme", "desc": "<v>" },
|
|
55
|
+
"name": "color-scheme-<k>",
|
|
56
|
+
"props": "color-scheme",
|
|
57
|
+
"values": {
|
|
58
|
+
"light": "light",
|
|
59
|
+
"dark": "dark",
|
|
60
|
+
"light-dark": "light dark"
|
|
61
|
+
}
|
|
62
|
+
},
|
|
52
63
|
{
|
|
53
64
|
"doc": { "group": "border color", "desc": "<v>" },
|
|
54
65
|
"name": "border-color-<k>",
|
|
@@ -119,6 +130,59 @@
|
|
|
119
130
|
}
|
|
120
131
|
],
|
|
121
132
|
"templates": [
|
|
133
|
+
{
|
|
134
|
+
"doc": {
|
|
135
|
+
"group": "color scheme",
|
|
136
|
+
"desc": "Sets `border-color` using CSS light-dark() function",
|
|
137
|
+
"args": [
|
|
138
|
+
"light: variable name (without `--` prefix)",
|
|
139
|
+
"dark: variable name (without `--` prefix)"
|
|
140
|
+
]
|
|
141
|
+
},
|
|
142
|
+
"name": "border-light-dark",
|
|
143
|
+
"props": { "border-color": "light-dark(var(--{0}), var(--{1}))" }
|
|
144
|
+
},
|
|
145
|
+
{
|
|
146
|
+
"doc": {
|
|
147
|
+
"group": "color scheme",
|
|
148
|
+
"desc": "Sets `background-color` using CSS light-dark() function",
|
|
149
|
+
"args": [
|
|
150
|
+
"light: variable name (without `--` prefix)",
|
|
151
|
+
"dark: variable name (without `--` prefix)"
|
|
152
|
+
]
|
|
153
|
+
},
|
|
154
|
+
"name": "bg-light-dark",
|
|
155
|
+
"props": {
|
|
156
|
+
"background-color": "light-dark(var(--{0}), var(--{1}))"
|
|
157
|
+
}
|
|
158
|
+
},
|
|
159
|
+
{
|
|
160
|
+
"doc": {
|
|
161
|
+
"group": "color scheme",
|
|
162
|
+
"desc": "Sets `color` using CSS light-dark() function",
|
|
163
|
+
"args": [
|
|
164
|
+
"light: variable name (without `--` prefix)",
|
|
165
|
+
"dark: variable name (without `--` prefix)"
|
|
166
|
+
]
|
|
167
|
+
},
|
|
168
|
+
"name": "light-dark",
|
|
169
|
+
"props": {
|
|
170
|
+
"background-color": "light-dark(var(--{0}), var(--{1}))"
|
|
171
|
+
}
|
|
172
|
+
},
|
|
173
|
+
{
|
|
174
|
+
"doc": {
|
|
175
|
+
"group": "color scheme",
|
|
176
|
+
"desc": "Sets `<var>` color using CSS light-dark() function",
|
|
177
|
+
"args": [
|
|
178
|
+
"light: variable name (without `--` prefix)",
|
|
179
|
+
"dark: variable name (without `--` prefix)"
|
|
180
|
+
]
|
|
181
|
+
},
|
|
182
|
+
"name": "<var>-light-dark",
|
|
183
|
+
"props": { "<var>": "light-dark(var(--{0}), var(--{1}))" },
|
|
184
|
+
"vars": ["fill-stroke"]
|
|
185
|
+
},
|
|
122
186
|
{
|
|
123
187
|
"doc": {
|
|
124
188
|
"group": "border color",
|
package/specs/display.mcss.json
CHANGED
|
@@ -30,6 +30,15 @@
|
|
|
30
30
|
"doc": { "group": "layout", "args": ["num: column count"] },
|
|
31
31
|
"name": "columns",
|
|
32
32
|
"props": "column-count"
|
|
33
|
+
},
|
|
34
|
+
{
|
|
35
|
+
"doc": {
|
|
36
|
+
"group": "appearance",
|
|
37
|
+
"desc": "Sets appearance (incl. `-webkit` prefixed version) to given value",
|
|
38
|
+
"args": ["mode: CSS value"]
|
|
39
|
+
},
|
|
40
|
+
"name": "appearance",
|
|
41
|
+
"props": { "appearance": "{0}", "-webkit-appearance": "{0}" }
|
|
33
42
|
}
|
|
34
43
|
]
|
|
35
44
|
}
|