@thi.ng/meta-css 0.17.7 → 0.17.8

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**: 2025-01-04T21:07:38Z
3
+ - **Last updated**: 2025-01-14T12:23:33Z
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.17.8](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.17.8) (2025-01-14)
13
+
14
+ #### ♻️ Refactoring
15
+
16
+ - use optional chaining & nullish coalescing ([c5a0a13](https://github.com/thi-ng/umbrella/commit/c5a0a13))
17
+
12
18
  ### [0.17.4](https://github.com/thi-ng/umbrella/tree/@thi.ng/meta-css@0.17.4) (2024-12-13)
13
19
 
14
20
  #### 🩹 Bug fixes
package/README.md CHANGED
@@ -2767,7 +2767,7 @@ distributed as CLI bundle with **no runtime dependencies**. The following
2767
2767
  dependencies are only shown for informational purposes and are (partially)
2768
2768
  included in the bundle.
2769
2769
 
2770
- Package sizes (brotli'd, pre-treeshake): ESM: 13.85 KB
2770
+ Package sizes (brotli'd, pre-treeshake): ESM: 13.83 KB
2771
2771
 
2772
2772
  ## Dependencies
2773
2773
 
package/index.js CHANGED
@@ -1,40 +1,40 @@
1
1
  // @bun
2
2
  var mt={default:95,hint:90,multi:90,param:96,required:33};var To=(o)=>o;function z(o,t=Object.create(null)){return(...n)=>{let m=n.join("-");return m in t?t[m]:t[m]=o(...n)}}var oo=z((o,t)=>o.repeat(t));var Zt=(o)=>/^[a-f0-9]+$/i.test(o);var Dt=(o)=>/^[-+]?\d+$/.test(o),jt=(o)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(o);var X=(o,t=(n)=>n!==void 0?": "+n:"")=>class extends Error{origMessage;constructor(n){super(o(n)+t(n));this.origMessage=n!==void 0?String(n):""}};var $m=X(()=>"illegal argument(s)"),C=(o)=>{throw new $m(o)};var ft=(o)=>jt(o)?parseFloat(o):C(`not a numeric value: ${o}`),yt=(o)=>o.map(ft),rt=(o)=>Zt(o)?parseInt(o,16):C(`not a hex value: ${o}`),Kt=(o)=>o.map(rt),Et=(o)=>Dt(o)?parseInt(o):C(`not an integer: ${o}`),Vt=(o)=>o.map(Et);var Jo=(o,t)=>(n)=>({coerce:o,hint:t,group:"main",...n}),zo=(o,t)=>(n)=>({hint:Hm(t,n.delim),multi:!0,coerce:o,group:"main",...n}),Hm=(o,t)=>o+(t?`[${t}..]`:""),J=(o)=>({flag:!0,default:!1,group:"flags",...o}),P=Jo(To,"STR"),Xo=zo(To,"STR"),Er=Jo(ft,"NUM"),Gr=Jo(rt,"HEX"),Po=Jo(Et,"INT"),Nr=zo(yt,"NUM"),Lr=zo(Kt,"HEX"),Br=zo(Vt,"INT");var H=((o)=>{return o[o.FINE=0]="FINE",o[o.DEBUG=1]="DEBUG",o[o.INFO=2]="INFO",o[o.WARN=3]="WARN",o[o.SEVERE=4]="SEVERE",o[o.NONE=5]="NONE",o})(H||{});var _m=0;class $o{constructor(o,t=H.FINE,n){this.parent=n,this.id=o||`logger-${_m++}`,this.level=typeof t==="string"?H[t]:t}id;level;addChild(o){return o.parent=this,o}enabled(o){return this.level<=o}fine(...o){this.log(H.FINE,o)}debug(...o){this.log(H.DEBUG,o)}info(...o){this.log(H.INFO,o)}warn(...o){this.log(H.WARN,o)}severe(...o){this.log(H.SEVERE,o)}log(o,t){this.level<=o&&this.logEntry([o,this.id,Date.now(),...t])}}var qt=(o)=>o.map((t)=>{if(typeof t==="function")t=t();if(!(typeof t==="string"||typeof t==="number"))t=JSON.stringify(t);return t}).join(" ");class Zo extends $o{constructor(o,t,n,m){super(t,n,m);this.target=o}childLogger(o,t){return new Zo(this.target,o,t??this.level,this)}logEntry(o){if(o[0]<this.level)return;this.target.write(`[${H[o[0]]}] ${o[1]}: ${qt(o.slice(3))}
3
- `),this.parent&&this.parent.logEntry(o)}}var Do=z((o,t=" ")=>{let n=oo(String(t),o);return(m,f)=>{if(m==null)return n;return m=m.toString(),f=f!==void 0?f:m.length,f<o?m+n.substring(f):m}});var Gt={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 wm=(o,t)=>(n)=>o.format(t,n),Nt=(o)=>Object.keys(Gt).reduce((t,n)=>(t[n]=wm(o,Gt[n]),t),{format:o});var ut="\x1B[0m";var Wm=["","1","2","1;2","4","1;4","2;4","1;2;4"],jo={format:(o,t)=>jo.start(o)+t+jo.end,start:z((o)=>{let t=[],n=o&15;return n&&t.push(29+(o>>4&1)*60+n),n=o>>5&15,n&&t.push(39+(o>>9&1)*60+n),n=o>>10,n&&t.push(Wm[n]),"\x1B["+t.join(";")+"m"}),end:ut,prefix:ut,suffix:`
4
- `};var Qt={format:(o,t)=>String(t),prefix:"",suffix:`
5
- `,start:()=>"",end:""};var yo=Nt(jo),bt=Nt(Qt);var _=Array.isArray;var Mm=(o)=>o.toUpperCase(),kt=(o)=>o.toLowerCase(),Ko=(o)=>o.length?o[0].toUpperCase()+o.substring(1):o,it=(o,t="-")=>kt(o.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,m,f)=>m+t+f));var vt=(o,t="-")=>kt(o).replace(new RegExp(`\\${t}+(\\w)`,"g"),(n,m)=>Mm(m));var pt=Object.getPrototypeOf,Z=(o)=>{let t;return o!=null&&typeof o==="object"&&((t=pt(o))===null||pt(t)===null)};var Ym=/\x1b\[[0-9;]+m/g,Im=(o)=>o.replace(Ym,"");var Vo=(o)=>Im(o).length;var lt=(o=!1,t)=>(n)=>o||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,t):String(n);function*to(o,t=/\r?\n/g,n=!1){let m=0,f=o.length,r=~~n,E;if(typeof t==="string")E=new RegExp(t,"g");else if(!t.flags.includes("g"))E=new RegExp(t,t.flags+"g");else E=t;for(;m<f;){let G=E.exec(o);if(!G){yield o.substring(m);return}let N=G[0].length;yield o.substring(m,G.index+r*N),m=G.index+N}}class Lt{n=0;w=[];constructor(o,t){o!=null&&this.add(o,t)}add(o,t=o.length){return this.w.push(o),this.n+=t+~~(this.n>0),this}toString(){return this.w.join(" ")}}var Sm={length:(o)=>o.length,split:(o,t)=>t},gt={length:Vo,split:(o,t)=>{let n=/\x1b\[[0-9;]+m/g,m=t,f;while(f=n.exec(o)){if(f.index>=t)break;let r=f[0].length;m+=r,t+=r}return m}},dt=(o,t,n,m)=>{let f=o[o.length-1];f&&m-f.n>n?f.add(t,n):o.push(new Lt(t,n))},Rm=(o,{width:t,min:n,hard:m,splitter:f},r=0,E=[])=>{let G=f.length(o),N=t-r;if(N<n&&N<G)N=t;while(m&&G>N){let L=f.split(o,N),B=o.substring(0,L);dt(E,B,N,t),o=o.substring(L),N=t,G=f.length(o)}return dt(E,o,G,t),E},Um=(o,t,n=[])=>{if(!o.length)return n.push(new Lt),n;let m={width:80,min:4,hard:!1,splitter:Sm,...t};for(let f of to(o,t.delimWord||/\s/g)){let r=n[n.length-1];Rm(f,m,r&&r.n>0?r.n+1:0,n)}return n},et=(o,t)=>{let n=[];for(let m of to(o,t.delimLine))n=n.concat(Um(m,t));return n};var Ho=(o,t={})=>{t={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...t};let n=Z(t.color)?{...mt,...t.color}:t.color?mt:{},m=oo(" ",t.paramWidth),f=(G)=>G.map((N)=>Jm(N,o[N],t,n,m)),r=Object.keys(o).sort(),E=t.groups?t.groups.map((G)=>[G,r.filter((N)=>o[N].group===G)]).filter((G)=>!!G[1].length):[["options",r]];return[...Bt(t.prefix,t.lineWidth),...E.map(([G,N])=>[...t.showGroupNames?[`${Ko(G)}:
3
+ `),this.parent?.logEntry(o)}}var Do=z((o,t=" ")=>{let n=oo(String(t),o);return(m,f)=>{if(m==null)return n;return m=m.toString(),f=f!==void 0?f:m.length,f<o?m+n.substring(f):m}});var Gt={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 wm=(o,t)=>(n)=>o.format(t,n),Nt=(o)=>Object.keys(Gt).reduce((t,n)=>(t[n]=wm(o,Gt[n]),t),{format:o});var bt="\x1B[0m";var Wm=["","1","2","1;2","4","1;4","2;4","1;2;4"],jo={format:(o,t)=>jo.start(o)+t+jo.end,start:z((o)=>{let t=[],n=o&15;return n&&t.push(29+(o>>4&1)*60+n),n=o>>5&15,n&&t.push(39+(o>>9&1)*60+n),n=o>>10,n&&t.push(Wm[n]),"\x1B["+t.join(";")+"m"}),end:bt,prefix:bt,suffix:`
4
+ `};var ut={format:(o,t)=>String(t),prefix:"",suffix:`
5
+ `,start:()=>"",end:""};var yo=Nt(jo),Qt=Nt(ut);var _=Array.isArray;var Mm=(o)=>o.toUpperCase(),kt=(o)=>o.toLowerCase(),Ko=(o)=>o.length?o[0].toUpperCase()+o.substring(1):o,it=(o,t="-")=>kt(o.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,m,f)=>m+t+f));var vt=(o,t="-")=>kt(o).replace(new RegExp(`\\${t}+(\\w)`,"g"),(n,m)=>Mm(m));var pt=Object.getPrototypeOf,Z=(o)=>{let t;return o!=null&&typeof o==="object"&&((t=pt(o))===null||pt(t)===null)};var Ym=/\x1b\[[0-9;]+m/g,Im=(o)=>o.replace(Ym,"");var Vo=(o)=>Im(o).length;var dt=(o=!1,t)=>(n)=>o||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,t):String(n);function*to(o,t=/\r?\n/g,n=!1){let m=0,f=o.length,r=~~n,E;if(typeof t==="string")E=new RegExp(t,"g");else if(!t.flags.includes("g"))E=new RegExp(t,t.flags+"g");else E=t;for(;m<f;){let G=E.exec(o);if(!G){yield o.substring(m);return}let N=G[0].length;yield o.substring(m,G.index+r*N),m=G.index+N}}class Lt{n=0;w=[];constructor(o,t){o!=null&&this.add(o,t)}add(o,t=o.length){return this.w.push(o),this.n+=t+~~(this.n>0),this}toString(){return this.w.join(" ")}}var Sm={length:(o)=>o.length,split:(o,t)=>t},gt={length:Vo,split:(o,t)=>{let n=/\x1b\[[0-9;]+m/g,m=t,f;while(f=n.exec(o)){if(f.index>=t)break;let r=f[0].length;m+=r,t+=r}return m}},lt=(o,t,n,m)=>{let f=o[o.length-1];f&&m-f.n>n?f.add(t,n):o.push(new Lt(t,n))},Rm=(o,{width:t,min:n,hard:m,splitter:f},r=0,E=[])=>{let G=f.length(o),N=t-r;if(N<n&&N<G)N=t;while(m&&G>N){let L=f.split(o,N),B=o.substring(0,L);lt(E,B,N,t),o=o.substring(L),N=t,G=f.length(o)}return lt(E,o,G,t),E},Um=(o,t,n=[])=>{if(!o.length)return n.push(new Lt),n;let m={width:80,min:4,hard:!1,splitter:Sm,...t};for(let f of to(o,t.delimWord||/\s/g)){let r=n[n.length-1];Rm(f,m,r&&r.n>0?r.n+1:0,n)}return n},et=(o,t)=>{let n=[];for(let m of to(o,t.delimLine))n=n.concat(Um(m,t));return n};var Ho=(o,t={})=>{t={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...t};let n=Z(t.color)?{...mt,...t.color}:t.color?mt:{},m=oo(" ",t.paramWidth),f=(G)=>G.map((N)=>Jm(N,o[N],t,n,m)),r=Object.keys(o).sort(),E=t.groups?t.groups.map((G)=>[G,r.filter((N)=>o[N].group===G)]).filter((G)=>!!G[1].length):[["options",r]];return[...Bt(t.prefix,t.lineWidth),...E.map(([G,N])=>[...t.showGroupNames?[`${Ko(G)}:
6
6
  `]:[],...f(N),""].join(`
7
7
  `)),...Bt(t.suffix,t.lineWidth)].join(`
8
8
  `)},Jm=(o,t,n,m,f)=>{let r=zm(t,m),E=Xm(t,m,r),G=_o(`--${it(o)}`,m.param),N=`${E}${G}${r}`,L=t.optional===!1&&t.default===void 0,B=[];L&&B.push("required"),t.multi&&B.push("multiple");let h=Pm(B,m,L)+(t.desc||"")+Zm(t,n,m);return Do(n.paramWidth)(N,Vo(N))+Bt(h,n.lineWidth-n.paramWidth).map((O,A)=>A>0?f+O:O).join(`
9
- `)},zm=(o,t)=>o.hint?_o(" "+o.hint,t.hint):"",Xm=(o,t,n)=>o.alias?`${_o("-"+o.alias,t.param)}${n}, `:"",Pm=(o,t,n)=>o.length?_o(`[${o.join(", ")}] `,n?t.required:t.multi):"",Zm=(o,t,n)=>t.showDefaults&&o.default!=null&&o.default!==!1?_o(` (default: ${lt(!0)(o.defaultHint!=null?o.defaultHint:o.default)})`,n.default):"",_o=(o,t)=>t!=null?`\x1B[${t}m${o}\x1B[0m`:o,Bt=(o,t)=>o?et(o,{width:t,splitter:gt,hard:!1}):[];var Dm=X(()=>"parse error"),xt=(o,t,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return jm(o,t,n)}catch(m){if(n.showUsage)console.log(m.message+`
9
+ `)},zm=(o,t)=>o.hint?_o(" "+o.hint,t.hint):"",Xm=(o,t,n)=>o.alias?`${_o("-"+o.alias,t.param)}${n}, `:"",Pm=(o,t,n)=>o.length?_o(`[${o.join(", ")}] `,n?t.required:t.multi):"",Zm=(o,t,n)=>t.showDefaults&&o.default!=null&&o.default!==!1?_o(` (default: ${dt(!0)(o.defaultHint!=null?o.defaultHint:o.default)})`,n.default):"",_o=(o,t)=>t!=null?`\x1B[${t}m${o}\x1B[0m`:o,Bt=(o,t)=>o?et(o,{width:t,splitter:gt,hard:!1}):[];var Dm=X(()=>"parse error"),xt=(o,t,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return jm(o,t,n)}catch(m){if(n.showUsage)console.log(m.message+`
10
10
 
11
- `+Ho(o,n.usageOpts));throw new Dm(m.message)}},jm=(o,t,n)=>{let m=ym(o),f={},r,E,G=n.start;for(;G<t.length;){let N=t[G];if(!r){if(n.help.includes(N)){console.log(Ho(o,n.usageOpts));return}let L=Km(o,m,f,N);if(r=L.id,E=L.spec,G=G+~~(L.state<2),L.state)break}else{if(Vm(E,f,r,N))break;r=null,G++}}return r&&C(`missing value for: --${r}`),{result:qm(o,f),index:G,rest:t.slice(G),done:G>=t.length}},ym=(o)=>Object.entries(o).reduce((t,[n,m])=>m.alias?(t[m.alias]=n,t):t,{}),Km=(o,t,n,m)=>{if(m[0]==="-"){let f;if(m[1]==="-"){if(m==="--")return{state:1};f=vt(m.substring(2))}else f=t[m.substring(1)],!f&&C(`unknown option: ${m}`);let r=o[f];if(!r&&C(f),r.flag){if(n[f]=!0,f=void 0,r.fn&&!r.fn("true"))return{state:1,spec:r}}return{state:0,id:f,spec:r}}return{state:2}},Vm=(o,t,n,m)=>{if(/^-[a-z]/i.test(m)&&C(`missing value for: --${n}`),o.multi)_(t[n])?t[n].push(m):t[n]=[m];else t[n]=m;return o.fn&&!o.fn(m)},qm=(o,t)=>{let n;for(let m in o)if(n=o[m],t[m]===void 0){if(n.default!==void 0)t[m]=n.default;else if(n.optional===!1)C(`missing arg: --${m}`)}else if(n.coerce)um(n,t,m);return t},um=(o,t,n)=>{try{if(o.multi&&o.delim)t[n]=t[n].reduce((m,f)=>(m.push(...f.split(o.delim)),m),[]);t[n]=o.coerce(t[n])}catch(m){throw new Error(`arg --${n}: ${m.message}`)}};var st=async(o)=>{let t=o.argv||process.argv,n=!process.env.NO_COLOR,m={prefix:"",color:n,...o.usage};try{let f,r,E=o.start??2;if(o.single){if(f=Object.keys(o.commands)[0],!f)C("no command provided");r=o.commands[f]}else{if(f=t[E],r=o.commands[f],m.prefix+=Qm(o.commands),!r)at(o,m);E++}let G;try{G=xt({...o.opts,...r.opts},t,{showUsage:!0,usageOpts:m,start:E})}catch(L){}if(!G)process.exit(1);if(r.inputs!==void 0&&r.inputs!==G.rest.length)process.stderr.write(`expected ${r.inputs||0} input(s)
12
- `),at(o,m);let N=await o.ctx({logger:new Zo(process.stderr,o.name,"INFO"),format:n?yo:bt,opts:G.result,inputs:G.rest},r);if(await r.fn(N),o.post)await o.post(N,r)}catch(f){process.stderr.write(f.message+`
11
+ `+Ho(o,n.usageOpts));throw new Dm(m.message)}},jm=(o,t,n)=>{let m=ym(o),f={},r,E,G=n.start;for(;G<t.length;){let N=t[G];if(!r){if(n.help.includes(N)){console.log(Ho(o,n.usageOpts));return}let L=Km(o,m,f,N);if(r=L.id,E=L.spec,G=G+~~(L.state<2),L.state)break}else{if(Vm(E,f,r,N))break;r=null,G++}}return r&&C(`missing value for: --${r}`),{result:qm(o,f),index:G,rest:t.slice(G),done:G>=t.length}},ym=(o)=>Object.entries(o).reduce((t,[n,m])=>m.alias?(t[m.alias]=n,t):t,{}),Km=(o,t,n,m)=>{if(m[0]==="-"){let f;if(m[1]==="-"){if(m==="--")return{state:1};f=vt(m.substring(2))}else f=t[m.substring(1)],!f&&C(`unknown option: ${m}`);let r=o[f];if(!r&&C(f),r.flag){if(n[f]=!0,f=void 0,r.fn&&!r.fn("true"))return{state:1,spec:r}}return{state:0,id:f,spec:r}}return{state:2}},Vm=(o,t,n,m)=>{if(/^-[a-z]/i.test(m)&&C(`missing value for: --${n}`),o.multi)_(t[n])?t[n].push(m):t[n]=[m];else t[n]=m;return o.fn&&!o.fn(m)},qm=(o,t)=>{let n;for(let m in o)if(n=o[m],t[m]===void 0){if(n.default!==void 0)t[m]=n.default;else if(n.optional===!1)C(`missing arg: --${m}`)}else if(n.coerce)bm(n,t,m);return t},bm=(o,t,n)=>{try{if(o.multi&&o.delim)t[n]=t[n].reduce((m,f)=>(m.push(...f.split(o.delim)),m),[]);t[n]=o.coerce(t[n])}catch(m){throw new Error(`arg --${n}: ${m.message}`)}};var st=async(o)=>{let t=o.argv||process.argv,n=!process.env.NO_COLOR,m={prefix:"",color:n,...o.usage};try{let f,r,E=o.start??2;if(o.single){if(f=Object.keys(o.commands)[0],!f)C("no command provided");r=o.commands[f]}else{if(f=t[E],r=o.commands[f],m.prefix+=um(o.commands),!r)at(o,m);E++}let G;try{G=xt({...o.opts,...r.opts},t,{showUsage:!0,usageOpts:m,start:E})}catch(L){}if(!G)process.exit(1);if(r.inputs!==void 0&&r.inputs!==G.rest.length)process.stderr.write(`expected ${r.inputs||0} input(s)
12
+ `),at(o,m);let N=await o.ctx({logger:new Zo(process.stderr,o.name,"INFO"),format:n?yo:Qt,opts:G.result,inputs:G.rest},r);if(await r.fn(N),o.post)await o.post(N,r)}catch(f){process.stderr.write(f.message+`
13
13
 
14
- `),process.exit(1)}},at=(o,t)=>{process.stderr.write(Ho(o.opts,t)),process.exit(1)},Qm=(o)=>[`
14
+ `),process.exit(1)}},at=(o,t)=>{process.stderr.write(Ho(o.opts,t)),process.exit(1)},um=(o)=>[`
15
15
  Available commands:
16
16
  `,...Object.keys(o).map((t)=>`${Do(16)(t)}: ${o[t].desc}`),`
17
17
  `].join(`
18
- `);import{existsSync as bm,mkdirSync as km,statSync as OE}from"fs";import{dirname as im}from"path";var vm=(o)=>o.length>0&&!bm(o)?(km(o,{recursive:!0}),!0):!1,ct=(o)=>vm(im(o));var K=(o)=>typeof o==="function";var $=(o)=>typeof o==="string";import{readFileSync as lm}from"fs";import{writeFileSync as pm}from"fs";var on=(o,t,n,m,f=!1)=>{if(m&&m.info(`${f?"[dryrun] ":""}writing file: ${o}`),f)return;ct(o),pm(o,t,!n&&$(t)?"utf-8":n)};var M=(o,t,n="utf-8")=>{return t&&t.debug("reading file:",o),lm(o,n)},Ot=(o,t,n,m=!1)=>on(o,_(t)?t.join(`
19
- `):t,"utf-8",n,m);var V=(o,t)=>JSON.parse(M(o,t));var u=Symbol(),ht=()=>{};var wo=Object.freeze({level:H.NONE,addChild(o){return o},childLogger:()=>wo,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class Ct extends $o{set(o){this.parent=o}childLogger(o,t){return new Ct(o,t??this.level,this)}logEntry(o){this.parent.logEntry(o)}}var tn=new Ct("root",H.FINE,wo);import{join as Vf}from"path";var At=(o,t)=>{if(o===t)return 0;if(o==null)return t==null?0:-1;if(t==null)return o==null?0:1;if(typeof o.compare==="function")return o.compare(t);if(typeof t.compare==="function")return-t.compare(o);return o<t?-1:o>t?1:0};var dm=X(()=>"Assertion failed"),qo=(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)?(o,t)=>{if(typeof o==="function"&&!o()||!o)throw new dm(typeof t==="function"?t():t)}:()=>{};var uo=(o)=>o!=null&&typeof o!=="function"&&o.length!==void 0;var nn=(o)=>{return(o==null||!o[Symbol.iterator])&&C(`value is not iterable: ${o}`),o};var mn=(o)=>uo(o)?o:[...nn(o)];var Wo=(o)=>o[o.length-1];var Qo=(o,t)=>o!=null&&typeof o[t]==="function";var w=(o)=>o!=null&&typeof o[Symbol.iterator]==="function";var bo=(o)=>o!=null&&typeof o!=="string"&&typeof o[Symbol.iterator]==="function";var gm=X(()=>"illegal arity"),no=(o)=>{throw new gm(o)};var em=X(()=>"illegal state"),mo=(o)=>{throw new em(o)};var fn=["-moz-","-ms-","-o-","-webkit-"],fo={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},ko={rules:`
18
+ `);import{existsSync as Qm,mkdirSync as km,statSync as OE}from"fs";import{dirname as im}from"path";var vm=(o)=>o.length>0&&!Qm(o)?(km(o,{recursive:!0}),!0):!1,ct=(o)=>vm(im(o));var K=(o)=>typeof o==="function";var $=(o)=>typeof o==="string";import{readFileSync as dm}from"fs";import{writeFileSync as pm}from"fs";var on=(o,t,n,m,f=!1)=>{if(m?.info(`${f?"[dryrun] ":""}writing file: ${o}`),f)return;ct(o),pm(o,t,!n&&$(t)?"utf-8":n)};var M=(o,t,n="utf-8")=>{return t?.debug("reading file:",o),dm(o,n)},Ot=(o,t,n,m=!1)=>on(o,_(t)?t.join(`
19
+ `):t,"utf-8",n,m);var V=(o,t)=>JSON.parse(M(o,t));var b=Symbol(),ht=()=>{};var wo=Object.freeze({level:H.NONE,addChild(o){return o},childLogger:()=>wo,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},logEntry(){}});class Ct extends $o{set(o){this.parent=o}childLogger(o,t){return new Ct(o,t??this.level,this)}logEntry(o){this.parent.logEntry(o)}}var tn=new Ct("root",H.FINE,wo);import{join as Vf}from"path";var At=(o,t)=>{if(o===t)return 0;if(o==null)return t==null?0:-1;if(t==null)return o==null?0:1;if(typeof o.compare==="function")return o.compare(t);if(typeof t.compare==="function")return-t.compare(o);return o<t?-1:o>t?1:0};var lm=X(()=>"Assertion failed"),qo=(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)?(o,t)=>{if(typeof o==="function"&&!o()||!o)throw new lm(typeof t==="function"?t():t)}:()=>{};var bo=(o)=>o!=null&&typeof o!=="function"&&o.length!==void 0;var nn=(o)=>{return(o==null||!o[Symbol.iterator])&&C(`value is not iterable: ${o}`),o};var mn=(o)=>bo(o)?o:[...nn(o)];var Wo=(o)=>o[o.length-1];var uo=(o,t)=>typeof o?.[t]==="function";var w=(o)=>typeof o?.[Symbol.iterator]==="function";var Qo=(o)=>o!=null&&typeof o!=="string"&&typeof o[Symbol.iterator]==="function";var gm=X(()=>"illegal arity"),no=(o)=>{throw new gm(o)};var em=X(()=>"illegal state"),mo=(o)=>{throw new em(o)};var fn=["-moz-","-ms-","-o-","-webkit-"],fo={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},ko={rules:`
20
20
  `,ruleSep:", ",valSep:" ",decls:`
21
21
  `,declStart:` {
22
22
  `,declEnd:`}
23
- `,indent:" ",comments:!0};function Ft(...o){let[t,n,m,f,r,E,G,N,L,B]=o;switch(o.length){case 0:no(0);case 1:return t;case 2:return(...O)=>t(n(...O));case 3:return(...O)=>t(n(m(...O)));case 4:return(...O)=>t(n(m(f(...O))));case 5:return(...O)=>t(n(m(f(r(...O)))));case 6:return(...O)=>t(n(m(f(r(E(...O))))));case 7:return(...O)=>t(n(m(f(r(E(G(...O)))))));case 8:return(...O)=>t(n(m(f(r(E(G(N(...O))))))));case 9:return(...O)=>t(n(m(f(r(E(G(N(L(...O)))))))));case 10:default:let h=(...O)=>t(n(m(f(r(E(G(N(L(B(...O))))))))));return o.length===10?h:Ft(h,...o.slice(10))}}var d=(o)=>Qo(o,"xform")?o.xform():o;function D(...o){return o=o.map(d),Ft.apply(null,o)}var Q=(o,t)=>[o[0],o[1],t];class Mo{value;constructor(o){this.value=o}deref(){return this.value}}var Y=(o)=>o instanceof Mo,rn=(o)=>o instanceof Mo?o:new Mo(o),j=(o)=>o instanceof Mo?o.deref():o;var xm=(o)=>o.length===2?[void 0,o[1]]:o.length===3?[o[1],o[2]]:no(o.length);function ro(...o){let t=o[0],n=t[0],m=t[1],f=t[2];o=xm(o);let r=o[0]==null?n():o[0],E=o[1];return j(m(Qo(E,"$reduce")?E.$reduce(f,r):uo(E)?am(f,r,E):sm(f,r,E)))}var am=(o,t,n)=>{for(let m=0,f=n.length;m<f;m++)if(t=o(t,n[m]),Y(t)){t=t.deref();break}return t},sm=(o,t,n)=>{for(let m of n)if(t=o(t,m),Y(t)){t=t.deref();break}return t},Eo=(o,t)=>[o,To,t],En=(o,t)=>{let n=t.length-1;return w(t[n])?t.length>1?ro(o.apply(null,t.slice(0,n)),t[n]):ro(o(),t[0]):void 0};function Go(o){return o?[...o]:Eo(()=>[],(t,n)=>(t.push(n),t))}function*No(o,t){let n=d(o)(Go()),m=n[1],f=n[2];for(let r of t){let E=f([],r);if(Y(E)){yield*j(m(E.deref()));return}if(E.length)yield*E}yield*j(m([]))}function*g(o,t){let n=d(o)([ht,ht,(m,f)=>f])[2];for(let m of t){let f=n(u,m);if(Y(f)){if(f=j(f.deref()),f!==u)yield f;return}if(f!==u)yield f}}var io=(o,t,n=g)=>{let m=t.length-1;return w(t[m])?t.length>1?n(o.apply(null,t.slice(0,m)),t[m]):n(o(),t[0]):void 0};function Tt(o,t){return w(t)?No(Tt(o),$(t)?[t]:t):(n)=>{let m=n[2],f=(r,E)=>{let G=o(E);if(G){for(let N of G)if(r=f(r,N),Y(r))break;return r}return m(r,E)};return Q(n,f)}}function Gn(o){return Tt((t)=>bo(t)?t:void 0,o)}function T(o,t){return w(t)?g(T(o),t):(n)=>{let m=n[2];return Q(n,(f,r)=>m(f,o(r)))}}function*vo(...o){let t=o.length-1;if(t<0)return;let n=new Array(t+1).fill(0),m=o.map(mn),f=m.reduce((r,E)=>r*E.length,1);for(let r=0;r<f;r++){let E=[];for(let G=t;G>=0;G--){let N=m[G],L=n[G];if(L===N.length)n[G]=L=0,G>0&&n[G-1]++;E[G]=N[L]}n[t]++,yield E}}function*Nn(o,t=1/0){while(t-- >0)yield o}function $t(o,t){o=o||"";let n=!0;return t?[...t].join(o):Eo(()=>"",(m,f)=>(m=n?m+f:m+o+f,n=!1,m))}function po(...o){return cm(po,ro,o)}var cm=(o,t,n)=>{let m,f;switch(n.length){case 4:f=n[3],m=n[2];break;case 3:f=n[2];break;case 2:return T((r)=>o(n[0],n[1],r));default:no(n.length)}return t(d(n[0])(n[1]),m,f)};var of=new Set,tf=":[",Ln=D(Gn(),T((o)=>o[0]==="&"?o.substring(1):tf.includes(o[0])?o:" "+o)),nf=(o,t)=>D(o,T((n)=>$(n)&&n.startsWith(" .")?n+t:n)),Lo=(o,t,n,m)=>{let f=n.length,r=[],E,G,N=(L,B)=>{let h=null;if(_(B))Lo(o,Ht(t,r),B,m);else if(w(B)&&!$(B))Lo(o,Ht(t,r),[...B],m);else if((G=K(B))||(h=m.fns[B]))if(!t.length){if(h)return h.apply(null,n.slice(L+1))(o,m),!0;B(o,m)}else if(G)N(L,B());else C(`quoted fn ('${B}') only allowed at head position`);else if(Z(B))E=Object.assign(E||{},B);else if(B!=null)r.push(B)};for(let L=0;L<f;L++)if(N(L,n[L]))return o;return E&&o.push(mf(t,r,E,m)),o},Ht=(o,t)=>o.length?[...vo(o,t)]:t,mf=(o,t,n,m)=>{let f=m.format,r=y(m),E=m.scope?nf(Ln,m.scope):Ln;return[r,po(T((G)=>po(E,$t(),_(G)?G:[G]).trim()),$t(f.ruleSep),Ht(o,t)),f.declStart,Yo(n,m),r,f.declEnd].join("")},Yo=(o,t)=>{let n=t.format,m=t.autoprefix||of,f=y(t,t.depth+1),r=[];for(let E in o)if(o.hasOwnProperty(E)){let G=o[E];if(K(G))G=G(o);if(_(G))G=G.map((N)=>_(N)?N.join(" "):N).join(n.ruleSep);if(m.has(E))for(let N of t.vendors)r.push(`${f}${N}${E}:${n.valSep}${G};`);r.push(`${f}${E}:${n.valSep}${G};`)}return r.join(n.decls)+n.decls},y=(o,t=o.depth)=>t>1?[...Nn(o.format.indent,t)].join(""):t>0?o.format.indent:"";function Bn(o,...t){let n=t.length===1?t[0]:t.reduce((m,f,r)=>{return m[r/(t.length-1)*100|0]=f,m},{});return(m,f)=>{let r=y(f);f.depth++;let E=y(f);m.push(`${r}@keyframes ${o}${f.format.declStart}`);for(let G in n)if(n.hasOwnProperty(G))m.push([E,G+"%",f.format.declStart,Yo(n[G],f),E,f.format.declEnd].join(""));return f.depth--,m.push(r+f.format.declEnd),m}}var On=(o,t=!1)=>(n,m)=>{let f=y(m),r=y(m,m.depth+1);if(m.format.comments||t)n.push(f+"/*",o.split(`
23
+ `,indent:" ",comments:!0};function Ft(...o){let[t,n,m,f,r,E,G,N,L,B]=o;switch(o.length){case 0:no(0);case 1:return t;case 2:return(...O)=>t(n(...O));case 3:return(...O)=>t(n(m(...O)));case 4:return(...O)=>t(n(m(f(...O))));case 5:return(...O)=>t(n(m(f(r(...O)))));case 6:return(...O)=>t(n(m(f(r(E(...O))))));case 7:return(...O)=>t(n(m(f(r(E(G(...O)))))));case 8:return(...O)=>t(n(m(f(r(E(G(N(...O))))))));case 9:return(...O)=>t(n(m(f(r(E(G(N(L(...O)))))))));case 10:default:let h=(...O)=>t(n(m(f(r(E(G(N(L(B(...O))))))))));return o.length===10?h:Ft(h,...o.slice(10))}}var l=(o)=>uo(o,"xform")?o.xform():o;function D(...o){return o=o.map(l),Ft.apply(null,o)}var u=(o,t)=>[o[0],o[1],t];class Mo{value;constructor(o){this.value=o}deref(){return this.value}}var Y=(o)=>o instanceof Mo,rn=(o)=>o instanceof Mo?o:new Mo(o),j=(o)=>o instanceof Mo?o.deref():o;var xm=(o)=>o.length===2?[void 0,o[1]]:o.length===3?[o[1],o[2]]:no(o.length);function ro(...o){let t=o[0],n=t[0],m=t[1],f=t[2];o=xm(o);let r=o[0]==null?n():o[0],E=o[1];return j(m(uo(E,"$reduce")?E.$reduce(f,r):bo(E)?am(f,r,E):sm(f,r,E)))}var am=(o,t,n)=>{for(let m=0,f=n.length;m<f;m++)if(t=o(t,n[m]),Y(t)){t=t.deref();break}return t},sm=(o,t,n)=>{for(let m of n)if(t=o(t,m),Y(t)){t=t.deref();break}return t},Eo=(o,t)=>[o,To,t],En=(o,t)=>{let n=t.length-1;return w(t[n])?t.length>1?ro(o.apply(null,t.slice(0,n)),t[n]):ro(o(),t[0]):void 0};function Go(o){return o?[...o]:Eo(()=>[],(t,n)=>(t.push(n),t))}function*No(o,t){let n=l(o)(Go()),m=n[1],f=n[2];for(let r of t){let E=f([],r);if(Y(E)){yield*j(m(E.deref()));return}if(E.length)yield*E}yield*j(m([]))}function*g(o,t){let n=l(o)([ht,ht,(m,f)=>f])[2];for(let m of t){let f=n(b,m);if(Y(f)){if(f=j(f.deref()),f!==b)yield f;return}if(f!==b)yield f}}var io=(o,t,n=g)=>{let m=t.length-1;return w(t[m])?t.length>1?n(o.apply(null,t.slice(0,m)),t[m]):n(o(),t[0]):void 0};function Tt(o,t){return w(t)?No(Tt(o),$(t)?[t]:t):(n)=>{let m=n[2],f=(r,E)=>{let G=o(E);if(G){for(let N of G)if(r=f(r,N),Y(r))break;return r}return m(r,E)};return u(n,f)}}function Gn(o){return Tt((t)=>Qo(t)?t:void 0,o)}function T(o,t){return w(t)?g(T(o),t):(n)=>{let m=n[2];return u(n,(f,r)=>m(f,o(r)))}}function*vo(...o){let t=o.length-1;if(t<0)return;let n=new Array(t+1).fill(0),m=o.map(mn),f=m.reduce((r,E)=>r*E.length,1);for(let r=0;r<f;r++){let E=[];for(let G=t;G>=0;G--){let N=m[G],L=n[G];if(L===N.length)n[G]=L=0,G>0&&n[G-1]++;E[G]=N[L]}n[t]++,yield E}}function*Nn(o,t=1/0){while(t-- >0)yield o}function $t(o,t){o=o||"";let n=!0;return t?[...t].join(o):Eo(()=>"",(m,f)=>(m=n?m+f:m+o+f,n=!1,m))}function po(...o){return cm(po,ro,o)}var cm=(o,t,n)=>{let m,f;switch(n.length){case 4:f=n[3],m=n[2];break;case 3:f=n[2];break;case 2:return T((r)=>o(n[0],n[1],r));default:no(n.length)}return t(l(n[0])(n[1]),m,f)};var of=new Set,tf=":[",Ln=D(Gn(),T((o)=>o[0]==="&"?o.substring(1):tf.includes(o[0])?o:" "+o)),nf=(o,t)=>D(o,T((n)=>$(n)&&n.startsWith(" .")?n+t:n)),Lo=(o,t,n,m)=>{let f=n.length,r=[],E,G,N=(L,B)=>{let h=null;if(_(B))Lo(o,Ht(t,r),B,m);else if(w(B)&&!$(B))Lo(o,Ht(t,r),[...B],m);else if((G=K(B))||(h=m.fns[B]))if(!t.length){if(h)return h.apply(null,n.slice(L+1))(o,m),!0;B(o,m)}else if(G)N(L,B());else C(`quoted fn ('${B}') only allowed at head position`);else if(Z(B))E=Object.assign(E||{},B);else if(B!=null)r.push(B)};for(let L=0;L<f;L++)if(N(L,n[L]))return o;return E&&o.push(mf(t,r,E,m)),o},Ht=(o,t)=>o.length?[...vo(o,t)]:t,mf=(o,t,n,m)=>{let f=m.format,r=y(m),E=m.scope?nf(Ln,m.scope):Ln;return[r,po(T((G)=>po(E,$t(),_(G)?G:[G]).trim()),$t(f.ruleSep),Ht(o,t)),f.declStart,Yo(n,m),r,f.declEnd].join("")},Yo=(o,t)=>{let n=t.format,m=t.autoprefix||of,f=y(t,t.depth+1),r=[];for(let E in o)if(o.hasOwnProperty(E)){let G=o[E];if(K(G))G=G(o);if(_(G))G=G.map((N)=>_(N)?N.join(" "):N).join(n.ruleSep);if(m.has(E))for(let N of t.vendors)r.push(`${f}${N}${E}:${n.valSep}${G};`);r.push(`${f}${E}:${n.valSep}${G};`)}return r.join(n.decls)+n.decls},y=(o,t=o.depth)=>t>1?[...Nn(o.format.indent,t)].join(""):t>0?o.format.indent:"";function Bn(o,...t){let n=t.length===1?t[0]:t.reduce((m,f,r)=>{return m[r/(t.length-1)*100|0]=f,m},{});return(m,f)=>{let r=y(f);f.depth++;let E=y(f);m.push(`${r}@keyframes ${o}${f.format.declStart}`);for(let G in n)if(n.hasOwnProperty(G))m.push([E,G+"%",f.format.declStart,Yo(n[G],f),E,f.format.declEnd].join(""));return f.depth--,m.push(r+f.format.declEnd),m}}var On=(o,t=!1)=>(n,m)=>{let f=y(m),r=y(m,m.depth+1);if(m.format.comments||t)n.push(f+"/*",o.split(`
24
24
  `).map((E)=>r+E).join(`
25
- `),f+"*/");return n};var lo=(o,t,n)=>(m,f)=>{let r=y(f);return m.push(`${r}${o} ${ff(t)}${f.format.declStart}`),f.depth++,Lo(m,[],n,f),f.depth--,m.push(r+f.format.declEnd),m},ff=(o)=>{if($(o))return o;let t=[];for(let n in o)if(o.hasOwnProperty(n)){let m=o[n];if(m===!0)m=hn.has(n)?n:`(${n})`;else if(m===!1)m=`(not ${hn.has(n)?n:`(${n})`})`;else if(m==="only")m+=" "+n;else m=`(${n}:${m})`;t.push(m)}return t.join(" and ")},hn=new Set(["all","print","screen"]);var e=(o,t)=>{return t={format:fo,vendors:fn,fns:{},depth:0,...t},_(t.autoprefix)&&(t.autoprefix=new Set(t.autoprefix)),Z(o)?Yo(o,t):K(o)?o([],t).join(t.format.rules):Lo([],[],_(o)?o:bo(o)?[...o]:C("invalid rules"),t).join(t.format.rules)};var Cn=(o,...t)=>(n,m)=>(n.push(t.length?`@import url(${o}) ${t.join(m.format.ruleSep)};`:`@import url(${o});`),n);var Bo=(o,t)=>lo("@media",o,t);function An(...o){return(t,n)=>(t.push(o.length>1?`@namespace ${o[0]} url(${o[1]});`:`@namespace url(${o[0]});`),t)}var Fn=(o,t)=>lo("@supports",o,t);var go={"@comment":On,"@import":Cn,"@keyframes":Bn,"@media":Bo,"@namespace":An,"@supports":Fn};var Tn=4,$n=(o)=>Tn=o,R=(o)=>o===(o|0)?String(o):o.toFixed(Tn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Hn=(o)=>`${R(o)}em`,_n=(o)=>`${R(o)}ex`;var wn=(o)=>`${R(o)}rem`,_t=(o)=>`${R(o)}%`,Wn=(o)=>`${R(o)}px`,Mn=(o)=>`${R(o)}vh`,Yn=(o)=>`${R(o)}vw`,In=(o)=>`${R(o)}vmin`,Sn=(o)=>`${R(o)}vmax`,Rn=(o)=>`${o|0}ms`,Un=(o)=>`${R(o)}s`;var Jn=(o)=>`${R(o)}deg`,zn=(o)=>`${R(o)}rad`,Xn=(o)=>`${R(o)}turn`,Pn=(o)=>`url(${o})`;var W=((o)=>{return o[o.IDLE=0]="IDLE",o[o.ACTIVE=1]="ACTIVE",o[o.DONE=2]="DONE",o[o.UNSUBSCRIBED=3]="UNSUBSCRIBED",o[o.ERROR=4]="ERROR",o})(W||{});var rf=0,Ef=()=>rf++,x=(o,t)=>!t||!t.id?{...t,id:o+"-"+Ef()}:t;var I=tn.childLogger("rstream");class b{constructor(o,t){this.wrapped=o,t=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...t}),this.parent=t.parent,this.id=t.id,this.closeIn=t.closeIn,this.closeOut=t.closeOut,this.cacheLast=t.cache,t.xform&&(this.xform=t.xform(Go()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=u;state=W.IDLE;subs=[];deref(){return this.last!==u?this.last:void 0}getState(){return this.state}setState(o){this.state=o}subscribe(o,t={}){this.ensureState();let n;if(o instanceof b&&!t.xform)o.ensureState(),qo(!o.parent,`sub '${o.id}' already has a parent`),o.parent=this,n=o;else n=new b(o,{...t,parent:this});return this.subs.push(n),this.setState(W.ACTIVE),n.setState(W.ACTIVE),this.last!=u&&n.next(this.last),n}transform(...o){let t,n;if(Z(Wo(o)))n=o.pop(),t={error:n.error};return this.subscribe(t,x("xform",o.length>0?{...n,xform:D(...o)}:n))}map(o,t){return this.transform(T(o),t||{})}unsubscribe(o){return o?this.unsubscribeChild(o):this.unsubscribeSelf()}unsubscribeSelf(){return I.debug(this.id,"unsub self"),this.parent&&this.parent.unsubscribe(this),this.state<W.UNSUBSCRIBED&&(this.state=W.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(o){I.debug(this.id,"unsub child",o.id);let t=this.subs.indexOf(o);if(t>=0){if(this.subs.splice(t,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(o){if(this.state>=W.DONE)return;this.xform?this.dispatchXform(o):this.dispatch(o)}done(){if(I.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();I.debug(this.id,"exiting done()")}error(o){let t=this.wrapped,n=t&&t.error;return n&&I.debug(this.id,"attempting wrapped error handler"),n&&t.error(o)||this.unhandledError(o)}unhandledError(o){return(I.parent!==wo?I:console).warn(this.id,"unhandled error:",o),this.unsubscribe(),this.state=W.ERROR,!1}dispatchTo(o,t){let n=this.wrapped;if(n)try{n[o]&&n[o](t)}catch(f){if(!this.error(f))return!1}let m=o==="next"?this.subs:[...this.subs];for(let f=m.length;f-- >0;){n=m[f];try{n[o]&&n[o](t)}catch(r){if(o==="error"||!n.error||!n.error(r))return this.unhandledError(r)}}return!0}dispatch(o){I.debug(this.id,"dispatch",o),this.cacheLast&&(this.last=o),this.dispatchTo("next",o)}dispatchXform(o){let t;try{t=this.xform[2]([],o)}catch(n){this.error(n);return}if(this.dispatchXformVals(t))Y(t)&&this.done()}dispatchXformDone(){let o;try{o=this.xform[1]([])}catch(t){return this.error(t)}return this.dispatchXformVals(o)}dispatchXformVals(o){let t=j(o);for(let n=0,m=t.length;n<m&&this.state<W.DONE;n++)this.dispatch(t[n]);return this.state<W.ERROR}ensureState(){if(this.state>=W.DONE)mo(`operation not allowed in state ${W[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Zn=(o,t)=>{let n=new Dn(t);return n.next(o),n};class Dn extends b{src;_cancel;_inited;constructor(o,t){let[n,m]=K(o)?[o,t||{}]:[void 0,o||{}];super(m.error?{error:m.error}:void 0,x("stream",m));this.src=n,this._inited=!1}subscribe(o,t={}){let n=super.subscribe(o,t);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(m){let f=this.wrapped;if(!f||!f.error||!f.error(m))this.unhandledError(m)}this._inited=!0}return n}unsubscribe(o){let t=super.unsubscribe(o);if(t&&(!o||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return t}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(o){if(super.error(o))return!0;return this.cancel(),!1}cancel(){if(this._cancel){I.debug(this.id,"cancel");let o=this._cancel;delete this._cancel,o()}}}var jn=(o,t)=>o==="first"||o==="last"&&!t;function wt(o){return o?ro(wt(),o):Eo(()=>({}),(t,[n,m])=>(t[n]=m,t))}var yn=()=>(o)=>{let t=o[2];return Q(o,(n,m)=>{if(m){for(let f of j(m)||[])if(n=t(n,f),Y(n))break}return Y(m)?rn(n):n})};function Wt(o,t){return w(t)?No(Wt(o),t):D(T(o),yn())}function Mt(o,t){return w(t)?g(Mt(o),t):T(K(o)?(n)=>[o(n),n]:(n)=>[o,n])}function Yt(...o){let t=io(Yt,o);if(t)return t;let n=o[0],m=o[1]!==!1;return T((f)=>{let r=m?{}:f;for(let E in f)r[E]=n(f[E]);return r})}var Kn=(o)=>o;function It(...o){let t=io(It,o,No);if(t)return t;let{key:n=Kn,mergeOnly:m=!1,reset:f=!0,all:r=!0,backPressure:E=0}=o[1],G=_(o[0])?new Set(o[0]):o[0],N=new Set,L=new Map,B={},h=([O,A,U])=>{let p=!0;if(m||E<1)return[O,(F)=>{if(f&&r&&N.size>0||!f&&p)F=U(F,B),B={},N.clear(),p=!1;return A(F)},(F,l)=>{let S=n(l);if(G.has(S)){if(B[S]=l,N.add(S),m||Vn(G,N))if(F=U(F,B),p=!1,f)B={},N.clear();else B={...B}}return F}];else return[O,(F)=>{if(r&&N.size>0)F=U(F,qn(L,N)),L.clear(),N.clear();return A(F)},(F,l)=>{let S=n(l);if(G.has(S)){let q=L.get(S);!q&&L.set(S,q=[]),q.length>=E&&mo(`max back pressure (${E}) exceeded for input: ${String(S)}`),q.push(l),N.add(S);while(Vn(G,N))if(F=U(F,qn(L,N)),p=!1,Y(F))break}return F}]};return h.keys=()=>G,h.clear=()=>{L.clear(),G.clear(),N.clear(),B={}},h.add=(O)=>{G.add(O)},h.delete=(O,A=!0)=>{if(L.delete(O),G.delete(O),A)N.delete(O),delete B[O]},h}var Vn=(o,t)=>{if(t.size<o.size)return!1;for(let n of o)if(!t.has(n))return!1;return!0},qn=(o,t)=>{let n={};for(let m of t){let f=o.get(m);n[m]=f.shift(),!f.length&&t.delete(m)}return n};var un=(o,t)=>{let n=!0;for(let m of t)n=o.removeID(m)&&n;return n};var eo=(o)=>new Qn(o);class Qn extends b{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(o){let t=It(new Set,{key:(m)=>m[0],mergeOnly:o.mergeOnly===!0,reset:o.reset===!0,all:o.all!==!1,backPressure:o.backPressure||0}),n=Yt((m)=>m[1]);super(void 0,x("streamsync",{...o,xform:o.xform?D(t,n,o.xform):D(t,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=t,this.clean=!!o.clean,o.src&&this.addAll(o.src)}add(o,t){t||(t=o.id),this.ensureState(),this.psync.add(t),this.realSourceIDs.set(t,o.id),this.invRealSourceIDs.set(o.id,t),this.idSources.set(o.id,o),this.sources.set(o,o.subscribe({next:(n)=>n[1]instanceof b?this.add(n[1]):this.next(n),done:()=>this.markDone(o),__owner:this},{xform:Mt(t),id:`in-${t}`}))}addAll(o){for(let t in o)this.psync.add(t);for(let t in o)this.add(o[t],t)}remove(o){let t=this.sources.get(o);if(t){let n=this.invRealSourceIDs.get(o.id);return I.info(`removing src: ${o.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(o.id),this.idSources.delete(o.id),this.sources.delete(o),t.unsubscribe(),!0}return!1}removeID(o){let t=this.getSourceForID(o);return t?this.remove(t):!1}removeAll(o){for(let n of o)this.psync.delete(this.invRealSourceIDs.get(n.id));let t=!0;for(let n of o)t=this.remove(n)&&t;return t}removeAllIDs(o){return un(this,o)}getSourceForID(o){return this.idSources.get(this.realSourceIDs.get(o))}getSources(){let o={};for(let[t,n]of this.idSources)o[this.invRealSourceIDs.get(t)]=n;return o}unsubscribe(o){if(!o){I.debug(this.id,"unsub sources");for(let t of this.sources.values())t.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(o)}markDone(o){this.remove(o),jn(this.closeIn,this.sources.size)&&this.done()}}var St=z((o,t=" ")=>{let n=oo(String(t),o);return(m,f)=>{if(m==null)return n;return m=m.toString(),f=f!==void 0?f:m.length,f<o?n.substring(f)+m:m}}),iN=St(2,"0"),vN=St(3,"0"),bn=St(4,"0");var Gf=/\{(\d+)\}/g;var Rt=(o,...t)=>t.length>0?o.replace(Gf,(n,m)=>String(t[parseInt(m,10)])):o;var kn=(o)=>({key:(t)=>t,group:Go(),...o});function Ut(...o){let t=En(Ut,o);if(t)return t;let n=kn(o[0]),[m,f,r]=n.group;return[()=>({}),(E)=>{for(let G in E)E[G]=f(E[G]);return E},(E,G)=>{let N=n.key(G);return E[N]=E[N]?r(E[N],G):r(m(),G),E}]}function Jt(o,t){return w(t)?g(Jt(o),t):(n)=>{let m=n[2];return Q(n,(f,r)=>o(r)?m(f,r):f)}}import{watch as gn}from"fs";import{resolve as a}from"path";var vn={specs:P({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},xo={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},Oo={include:Xo({alias:"I",desc:"Include CSS files (prepend)"})},ao={eval:P({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},so={force:Xo({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},pn={media:Xo({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},ln={onlyDecls:J({desc:"Only emit framework decls"})},k={out:P({alias:"o",desc:"Output file (or stdout)"})},co={prec:Po({default:3,desc:"Number of fractional digits"})},i={pretty:J({alias:"p",desc:"Pretty print output"})},ho={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},Co={noHeader:J({desc:"Don't emit generated header comment"})},Ao={scope:P({desc:"Suffix for CSS class names"})},Fo={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Nf}from"fs";import{resolve as dn}from"path";var v=(o,t,n)=>{t=$(t)?t:t.join(`
26
- `),o?Ot(dn(o),t,n):process.stdout.write(t+`
27
- `)},ot=({info:{name:o,version:t}})=>`/*! ${o} v${t} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,Io=(o,t)=>{let n=()=>{t.info("closing watchers..."),m.forEach((f)=>f.watcher.close())},m=o.map((f,r)=>{f=dn(f);let E=Zn(M(f,t),{id:`in${bn(r)}`});return{input:E,watcher:Nf(f,{},(G)=>{if(G==="change")try{E.next(M(f,t))}catch(N){t.warn(N.message),n()}else t.warn("input removed:",f),n()})}});return process.on("SIGINT",n),eo({src:wt(T(({input:f})=>[f.id,f],m))})},tt=(o)=>Object.keys(o).reduce((t,n)=>{if(!n.startsWith("__"))t[n]=o[n];return t},{});var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...xo,...ao,...so,...Oo,...ho,...Co,...k,...i,...Ao,...vn,...Fo,noWrite:J({desc:"Don't write files, use stdout only"})},fn:zt};async function zt(o){let t=V(a(o.opts.specs),o.logger),n=Cf(t,o.opts.force||[],o.logger);if(o.opts.bundle)if(o.opts.watch)await Bf(o,n);else Ro(o,t,n,o.opts.eval?[o.opts.eval]:o.inputs.map((m)=>M(a(m),o.logger)),o.opts.out);else if(o.opts.watch)await Lf(o,t,n);else if(o.opts.eval)try{Ro(o,t,n,[o.opts.eval])}catch(m){o.logger.warn(m.message)}else for(let m of o.inputs)try{m=a(m);let f=!o.opts.noWrite?m.replace(/\.mcss$/,".css"):void 0;Ro(o,t,n,[M(m,o.logger)],f)}catch(f){o.logger.warn(f.message)}}var Lf=async(o,t,n)=>{let m=a(o.opts.specs),f,r={process:()=>{try{return t=V(m,o.logger),f.forEach((G)=>G.process()),!0}catch(G){return o.logger.warn(G.message+": "+m),!1}},watcher:gn(m,{},(G)=>{if(G==="change")r.process();else o.logger.warn("specs file removed:",m),E()})},E=()=>{o.logger.info("closing watchers..."),r.watcher.close(),f.forEach((G)=>G.watcher.close())};f=o.inputs.map((G)=>{G=a(G);let N=!o.opts.noWrite?G.replace(/\.mcss$/,".css"):void 0,L=()=>{try{return Ro(o,t,n,[M(G,o.logger)],N),!0}catch(B){if(o.logger.warn(B.message+": "+G),f)E();return!1}};if(!L())process.exit(1);return{process:L,watcher:gn(G,{},(B)=>{if(B==="change")L();else o.logger.warn("input removed:",G),E()})}}),o.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",E)},Bf=async(o,t)=>{eo({src:{styles:Io(o.inputs,o.logger),specs:Io([o.opts.specs],o.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:m}){try{Ro(o,m,t,Object.keys(n).sort().map((f)=>n[f]),o.opts.out)}catch(f){o.logger.warn(f.message)}}})},Ro=({logger:o,opts:{include:t,noDecls:n,noHeader:m,pretty:f,scope:r}},E,G,N,L)=>{let B={logger:o,specs:E,css:{format:f?ko:fo,fns:go,scope:r},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},h=t?t.map((O)=>M(a(O),o).trim()):[];if(!m)h.push(ot(E));if(!n&&E.decls.length)h.push(e(E.decls,B.css));N.forEach((O)=>Af(O,B)),hf(h,B),Of(h,B),v(L,h,o)},Of=(o,{css:t,logger:n,mediaQueryRules:m,specs:f})=>{for(let r in m){let E=sn(m[r],f);n.debug("mediaquery rules",r,E),o.push(e(Bo(Hf(f.media,r),E),t))}},hf=(o,{css:t,logger:n,plainRules:m,specs:f})=>{let r=sn(m,f);n.debug("plain rules",r),o.push(e(r,t))},Cf=(o,t,n)=>{let m=new Set(Object.keys(o.media)),f=new Set(Object.keys(o.classes)),r={},E={};if(t.length&&t[0][0]==="@")t=[...to(M(a(t[0].substring(1)),n))];for(let G of t){if(!G||G.startsWith("//"))continue;let{token:N,query:L}=cn(G,m),B;if(N.includes("*")){let h=new RegExp(`^${N.replace("*",".*")}$`);B=[...Jt((O)=>h.test(O),f)]}else if(f.has(N))B=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let h of B)n.debug("including class:",h),L?om(r,L,`.${h}`,h):tm(E,`.${h}`,h)}return{mediaQueryRules:r,plainRules:E}},Af=(o,{specs:t,mediaQueryIDs:n,mediaQueryRules:m,plainRules:f})=>{let r=Uo(),E=Uo(r),G={root:r,curr:E,scopes:[E]};for(let N of to(o)){if(!N||/^\s*\/\//.test(N))continue;for(let L of Ff(N)){if(!L)continue;let B=G.curr;switch(B.state){case"sel":case"nest":if(L==="{"){if(B.state==="sel")B.sel=B.sel.map((h)=>h.replace(",","")),B.path=Tf(G.scopes);B.state="class"}else if(L==="}")en(G);else{let h=Wo(B.sel);if(!h||h.endsWith(","))B.sel.push(L);else B.sel[B.sel.length-1]+=" "+L}break;case"class":if(L==="{")B.state="nest",G.scopes.push(G.curr=Uo(B));else if(L==="}")en(G);else{let{token:h,query:O}=cn(L,n);if(!t.classes[h]&&!(nm(h)||fm(h)||mm(h)))C(`unknown class ID: ${h}`);if(O)om(m,O,B.path,h);else tm(f,B.path,h)}break;default:mo(B.state)}}}};function*Ff(o){let t=-1,n=o.length,m=0,f=0;for(let r=0;r<n;r++){let E=o[r];if(E===" "||E==="\t"){if(!(m||f)&&t>=0)yield o.substring(t,r),t=-1}else if(E==="{"||E==="}"){if(t>=0)yield o.substring(t,r);yield E,t=-1}else if(E==="(")m++;else if(E===")"){if(--m<0)C(`invalid nesting in line: '${o}'`)}else if(E==="["){if(t<0)t=r;f++}else if(E==="]"){if(--f<0)C(`invalid arg nesting in line: '${o}'`)}else if(t<0)t=r}if(m)C("template calls must be fully on a single line");if(f)C("verbatim properties must be fully on a single line");if(t>=0)yield o.substring(t,n)}var So=":",an="///",Uo=(o)=>({state:"sel",sel:o?[]:["<root>"],path:"",parent:o}),en=(o)=>{let t=!o.curr.sel.length;if(qo(!!o.curr.parent,"stack underflow"),o.scopes.pop(),o.scopes.length>0){if(o.curr=Wo(o.scopes),!t&&o.curr.state==="nest")o.scopes.push(o.curr=Uo(o.curr))}else o.scopes.push(o.curr=Uo(o.root))},Tf=(o)=>o.map((t)=>t.sel.join(",")).join(an),sn=(o,t)=>Object.entries(o).map(([n,m])=>$f(n,m,t)),$f=(o,t,n)=>{let m=[],f=m,r=o.split(an);for(let E=0;E<r.length;E++){let G=r[E].split(",");if(E==r.length-1){let N=Object.assign({},...T((L)=>fm(L)?Wf(L):nm(L)?_f(L):mm(L)?wf(n,L):tt(n.classes[L]),t));G.push(N)}f.push(G),f=G}return m[0]},cn=(o,t)=>{if(/^::?/.test(o))return{token:o};let n=o.lastIndexOf(So);if(n<0)return{token:o};let m=o.indexOf("(");if(m>0){if(m<n&&o.indexOf(So)>m)return{token:o};n=o.substring(0,m).lastIndexOf(So)}let f=o.substring(0,n);if(!f.split(So).every((E)=>t.has(E)))C(`invalid media query in token: ${o}`);return{token:o.substring(n+1),query:f}},Hf=(o,t)=>t.split(So).reduce((n,m)=>Object.assign(n,o[m]),{}),om=(o,t,n,m)=>{if(!o[t])o[t]={};(o[t][n]||(o[t][n]=new Set)).add(m)},tm=(o,t,n)=>(o[t]||(o[t]=new Set)).add(n),_f=(o)=>{let t=o.indexOf("=");return{[`--${o.substring(0,t)}`]:o.substring(t+1)}},wf=(o,t)=>{let n=t.indexOf("("),m=t.substring(0,n),f=t.substring(n+1,t.length-1).split(/(?<!\\),/g).map((E)=>E.trim().replace("\\,",",")),r=o.templates[m];if(!r)C(`unknown template: ${m}`);if(f.length!==r.__arity)C(`template "${m}" expected ${r.__arity} arguments`);return Object.entries(r).reduce((E,[G,N])=>{if(!G.startsWith("__")){if(G=Rt(G,...f),$(N))N=Rt(N,...f);E[G]=N}return E},{})},Wf=(o)=>{let[t,n,m]=/^(.+)-\[(.+)\]/.exec(o);return{[n]:m}},nm=(o)=>/^[a-z0-9:_-]+=.+/i.test(o),mm=(o)=>o.includes("(")&&o.endsWith(")"),fm=(o)=>o.indexOf("-[")>0&&o.endsWith("]");var Em={deg:Jn,em:Hn,ex:_n,ms:Rn,percent:_t,px:Wn,rad:zn,rem:wn,second:Un,turn:Xn,url:Pn,vh:Mn,vmax:Sn,vmin:In,vw:Yn,"%":_t},Mf={percent:"{0}%",second:"{0}s",url:"url({0})"},Yf={"":[""],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:[""]},Gm={desc:"Generate framework rules from specs",opts:{...k,...co,...i,...Fo},fn:Xt};async function Xt(o){if(o.opts.watch)await If(o);else await Nm(o.inputs.map((t)=>M(t,o.logger)),o.opts,o.logger)}var If=async(o)=>{Io(o.inputs,o.logger).subscribe({next(t){try{Nm(Object.keys(t).sort().map((n)=>t[n]),o.opts,o.logger)}catch(n){o.logger.warn(n.message)}}})},Nm=async(o,t,n)=>{let m={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};$n(t.prec);for(let f of o){let r=JSON.parse(f);if(Object.assign(m.info,r.info),Object.assign(m.media,r.media),r.decls)m.decls.push(...r.decls);if(r.specs)for(let E of r.specs)try{Lm(r,E,m.classes,n)}catch(G){n.warn(`error processing spec: ${E.name}`,G,", skipping...")}if(r.templates)for(let E of r.templates)Sf(r,E,m.templates,n)}return v(t.out,JSON.stringify(m,null,t.pretty?4:0),n),m},Lm=(o,t,n,m,f=!1)=>{let r=_(t.vars)?t.vars:[""],E=$(t.props)?{[t.props]:"<v>"}:t.props,G=Rf(t,o),N=new Set;for(let L of r){let B=o.vars?.[L]||Yf[L];if(!B)C(`unknown variation ID: ${L}`);for(let[h,O]of vo(B,Object.keys(G))){let A=s(t.name,L,h,O,G[O]),U=t.unit?s(t.unit,L,h,O,G[O]):void 0,p=f?Jf(U):Uf(G[O],U);if(!n[A]){if(n[A]={},t.user!=null)n[A].__user=t.user;if(t.doc!=null)n[A].__doc=zf(t.doc,L,h,O,p)}else if(!N.has(A))C(`duplicate class ID: ${A}`);N.add(A);let F=-1;for(let[l,S]of Object.entries(E)){let q=s(l,L,h,O,G[O]),nt=s(!U||$(S)?String(S):Em[U](S),L,h,O,p);if(n[A][q]=nt,m.debug(A,q,nt),f)F=rm(nt,rm(q,F))}if(f)n[A].__arity=F+1}}return n},Sf=(o,t,n,m)=>Lm(o,{...t,values:[""]},n,m,!0),rm=(o,t)=>{let n=/\{(\d+)\}/g,m;while(m=n.exec(o))t=Math.max(t,+m[1]);return t},Rf=(o,t)=>{let n=$(o.values)?t.tables?.[o.values]||C(`invalid table ID: ${o.values}`):o.values;if(Z(n))return n;let m=o.key==="v"?(f)=>String(f):o.key==="i+1"?(f,r)=>String(r+1):o.key==="i"||o.key===void 0?(f,r)=>String(r):C(`invalid key type: ${o.key}`);return n.reduce((f,r,E)=>{return f[m(r,E)]=r,f},{})},Uf=(o,t)=>{if(!t||$(o))return o;let n=Em[t];if(!n)C(`invalid unit: ${t}`);return n(o)},Jf=(o)=>o?Mf[o]||"{0}"+o:"{0}",s=(o,t,n,m,f)=>o.replace(/<vid>/g,t).replace(/<var>/g,n).replace(/<k>/g,m).replace(/<v>/g,String(f)),zf=({group:o,desc:t,args:n},m,f,r,E)=>({group:o?s(o,m,f,r,E):"TODO",desc:t?s(t,m,f,r,E):void 0,args:n?n.map((G)=>s(G,m,f,r,E)):void 0});var Bm={desc:"Combination of the generate & convert commands",opts:{...xo,...ao,...so,...Oo,...ho,...Co,...co,...i,...Ao,...Fo,outCss:P({desc:"Output file for CSS bundle",optional:!1}),outSpecs:P({desc:"Output file for framework",optional:!1})},fn:async(o)=>{let{opts:t,inputs:n}=o,[m,f]=n.reduce((G,N)=>(G[N.endsWith(".json")?0:1].push(N),G),[[],[]]),r={inputs:m,format:o.format,logger:o.logger,opts:{...t,out:t.outSpecs}},E={inputs:f,format:o.format,logger:o.logger,opts:{...t,noWrite:!1,out:t.outCss,scope:t.scope,specs:t.outSpecs}};await Xt(r),await zt(E)}};import{resolve as Xf}from"path";var Cm={desc:"Generate Markdown documentation for framework specs",opts:{...k,level:Po({alias:"l",desc:"Initial heading level",default:1}),title:P({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(o)=>{let{logger:t,opts:n,inputs:m}=o,f=V(Xf(m[0]),t),r=Pf(f,n);v(n.out,r,t)}},Pf=(o,{level:t,title:n})=>{let m=Object.keys(o.classes).length,f=Object.keys(o.templates).length,r=[`Currently, there are ${m+f} CSS utility classes (incl. ${f} templates) defined in "${o.info.name}" (v${o.info.version}):`,"",`${c(t+1)} Classes by category`,"",...hm(o.classes,Df,t+2),`${c(t+1)} Templates by category`,"",...hm(o.templates,jf,t+2),`${c(t+1)} Media queries`,"",...Object.entries(o.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")r.unshift(`${c(t)} ${n??o.info.name}
25
+ `),f+"*/");return n};var lo=(o,t,n)=>(m,f)=>{let r=y(f);return m.push(`${r}${o} ${ff(t)}${f.format.declStart}`),f.depth++,Lo(m,[],n,f),f.depth--,m.push(r+f.format.declEnd),m},ff=(o)=>{if($(o))return o;let t=[];for(let n in o)if(o.hasOwnProperty(n)){let m=o[n];if(m===!0)m=hn.has(n)?n:`(${n})`;else if(m===!1)m=`(not ${hn.has(n)?n:`(${n})`})`;else if(m==="only")m+=" "+n;else m=`(${n}:${m})`;t.push(m)}return t.join(" and ")},hn=new Set(["all","print","screen"]);var e=(o,t)=>{return t={format:fo,vendors:fn,fns:{},depth:0,...t},_(t.autoprefix)&&(t.autoprefix=new Set(t.autoprefix)),Z(o)?Yo(o,t):K(o)?o([],t).join(t.format.rules):Lo([],[],_(o)?o:Qo(o)?[...o]:C("invalid rules"),t).join(t.format.rules)};var Cn=(o,...t)=>(n,m)=>(n.push(t.length?`@import url(${o}) ${t.join(m.format.ruleSep)};`:`@import url(${o});`),n);var Bo=(o,t)=>lo("@media",o,t);function An(...o){return(t,n)=>(t.push(o.length>1?`@namespace ${o[0]} url(${o[1]});`:`@namespace url(${o[0]});`),t)}var Fn=(o,t)=>lo("@supports",o,t);var go={"@comment":On,"@import":Cn,"@keyframes":Bn,"@media":Bo,"@namespace":An,"@supports":Fn};var Tn=4,$n=(o)=>Tn=o,R=(o)=>o===(o|0)?String(o):o.toFixed(Tn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var Hn=(o)=>`${R(o)}em`,_n=(o)=>`${R(o)}ex`;var wn=(o)=>`${R(o)}rem`,_t=(o)=>`${R(o)}%`,Wn=(o)=>`${R(o)}px`,Mn=(o)=>`${R(o)}vh`,Yn=(o)=>`${R(o)}vw`,In=(o)=>`${R(o)}vmin`,Sn=(o)=>`${R(o)}vmax`,Rn=(o)=>`${o|0}ms`,Un=(o)=>`${R(o)}s`;var Jn=(o)=>`${R(o)}deg`,zn=(o)=>`${R(o)}rad`,Xn=(o)=>`${R(o)}turn`,Pn=(o)=>`url(${o})`;var W=((o)=>{return o[o.IDLE=0]="IDLE",o[o.ACTIVE=1]="ACTIVE",o[o.DONE=2]="DONE",o[o.UNSUBSCRIBED=3]="UNSUBSCRIBED",o[o.ERROR=4]="ERROR",o})(W||{});var rf=0,Ef=()=>rf++,x=(o,t)=>!t||!t.id?{...t,id:o+"-"+Ef()}:t;var I=tn.childLogger("rstream");class Q{constructor(o,t){this.wrapped=o,t=x("sub",{closeIn:"last",closeOut:"last",cache:!0,...t}),this.parent=t.parent,this.id=t.id,this.closeIn=t.closeIn,this.closeOut=t.closeOut,this.cacheLast=t.cache,t.xform&&(this.xform=t.xform(Go()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=b;state=W.IDLE;subs=[];deref(){return this.last!==b?this.last:void 0}getState(){return this.state}setState(o){this.state=o}subscribe(o,t={}){this.ensureState();let n;if(o instanceof Q&&!t.xform)o.ensureState(),qo(!o.parent,`sub '${o.id}' already has a parent`),o.parent=this,n=o;else n=new Q(o,{...t,parent:this});return this.subs.push(n),this.setState(W.ACTIVE),n.setState(W.ACTIVE),this.last!=b&&n.next(this.last),n}transform(...o){let t,n;if(Z(Wo(o)))n=o.pop(),t={error:n.error};return this.subscribe(t,x("xform",o.length>0?{...n,xform:D(...o)}:n))}map(o,t){return this.transform(T(o),t||{})}unsubscribe(o){return o?this.unsubscribeChild(o):this.unsubscribeSelf()}unsubscribeSelf(){return I.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<W.UNSUBSCRIBED&&(this.state=W.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(o){I.debug(this.id,"unsub child",o.id);let t=this.subs.indexOf(o);if(t>=0){if(this.subs.splice(t,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="never")this.unsubscribe();return!0}return!1}next(o){if(this.state>=W.DONE)return;this.xform?this.dispatchXform(o):this.dispatch(o)}done(){if(I.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();I.debug(this.id,"exiting done()")}error(o){let n=this.wrapped?.error;return n&&I.debug(this.id,"attempting wrapped error handler"),n?.(o)||this.unhandledError(o)}unhandledError(o){return(I.parent!==wo?I:console).warn(this.id,"unhandled error:",o),this.unsubscribe(),this.state=W.ERROR,!1}dispatchTo(o,t){let n=this.wrapped;if(n)try{n[o]&&n[o](t)}catch(f){if(!this.error(f))return!1}let m=o==="next"?this.subs:[...this.subs];for(let f=m.length;f-- >0;){n=m[f];try{n[o]&&n[o](t)}catch(r){if(o==="error"||!n.error||!n.error(r))return this.unhandledError(r)}}return!0}dispatch(o){I.debug(this.id,"dispatch",o),this.cacheLast&&(this.last=o),this.dispatchTo("next",o)}dispatchXform(o){let t;try{t=this.xform[2]([],o)}catch(n){this.error(n);return}if(this.dispatchXformVals(t))Y(t)&&this.done()}dispatchXformDone(){let o;try{o=this.xform[1]([])}catch(t){return this.error(t)}return this.dispatchXformVals(o)}dispatchXformVals(o){let t=j(o);for(let n=0,m=t.length;n<m&&this.state<W.DONE;n++)this.dispatch(t[n]);return this.state<W.ERROR}ensureState(){if(this.state>=W.DONE)mo(`operation not allowed in state ${W[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var Zn=(o,t)=>{let n=new Dn(t);return n.next(o),n};class Dn extends Q{src;_cancel;_inited;constructor(o,t){let[n,m]=K(o)?[o,t||{}]:[void 0,o||{}];super(m.error?{error:m.error}:void 0,x("stream",m));this.src=n,this._inited=!1}subscribe(o,t={}){let n=super.subscribe(o,t);if(!this._inited){if(this.src)try{this._cancel=this.src(this)||(()=>{return})}catch(m){let f=this.wrapped;if(!f||!f.error||!f.error(m))this.unhandledError(m)}this._inited=!0}return n}unsubscribe(o){let t=super.unsubscribe(o);if(t&&(!o||(!this.subs||!this.subs.length)&&this.closeOut!=="never"))this.cancel();return t}done(){this.cancel(),super.done(),delete this.src,delete this._cancel}error(o){if(super.error(o))return!0;return this.cancel(),!1}cancel(){if(this._cancel){I.debug(this.id,"cancel");let o=this._cancel;delete this._cancel,o()}}}var jn=(o,t)=>o==="first"||o==="last"&&!t;function wt(o){return o?ro(wt(),o):Eo(()=>({}),(t,[n,m])=>(t[n]=m,t))}var yn=()=>(o)=>{let t=o[2];return u(o,(n,m)=>{if(m){for(let f of j(m)||[])if(n=t(n,f),Y(n))break}return Y(m)?rn(n):n})};function Wt(o,t){return w(t)?No(Wt(o),t):D(T(o),yn())}function Mt(o,t){return w(t)?g(Mt(o),t):T(K(o)?(n)=>[o(n),n]:(n)=>[o,n])}function Yt(...o){let t=io(Yt,o);if(t)return t;let n=o[0],m=o[1]!==!1;return T((f)=>{let r=m?{}:f;for(let E in f)r[E]=n(f[E]);return r})}var Kn=(o)=>o;function It(...o){let t=io(It,o,No);if(t)return t;let{key:n=Kn,mergeOnly:m=!1,reset:f=!0,all:r=!0,backPressure:E=0}=o[1],G=_(o[0])?new Set(o[0]):o[0],N=new Set,L=new Map,B={},h=([O,A,U])=>{let p=!0;if(m||E<1)return[O,(F)=>{if(f&&r&&N.size>0||!f&&p)F=U(F,B),B={},N.clear(),p=!1;return A(F)},(F,d)=>{let S=n(d);if(G.has(S)){if(B[S]=d,N.add(S),m||Vn(G,N))if(F=U(F,B),p=!1,f)B={},N.clear();else B={...B}}return F}];else return[O,(F)=>{if(r&&N.size>0)F=U(F,qn(L,N)),L.clear(),N.clear();return A(F)},(F,d)=>{let S=n(d);if(G.has(S)){let q=L.get(S);!q&&L.set(S,q=[]),q.length>=E&&mo(`max back pressure (${E}) exceeded for input: ${String(S)}`),q.push(d),N.add(S);while(Vn(G,N))if(F=U(F,qn(L,N)),p=!1,Y(F))break}return F}]};return h.keys=()=>G,h.clear=()=>{L.clear(),G.clear(),N.clear(),B={}},h.add=(O)=>{G.add(O)},h.delete=(O,A=!0)=>{if(L.delete(O),G.delete(O),A)N.delete(O),delete B[O]},h}var Vn=(o,t)=>{if(t.size<o.size)return!1;for(let n of o)if(!t.has(n))return!1;return!0},qn=(o,t)=>{let n={};for(let m of t){let f=o.get(m);n[m]=f.shift(),!f.length&&t.delete(m)}return n};var bn=(o,t)=>{let n=!0;for(let m of t)n=o.removeID(m)&&n;return n};var eo=(o)=>new un(o);class un extends Q{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(o){let t=It(new Set,{key:(m)=>m[0],mergeOnly:o.mergeOnly===!0,reset:o.reset===!0,all:o.all!==!1,backPressure:o.backPressure||0}),n=Yt((m)=>m[1]);super(void 0,x("streamsync",{...o,xform:o.xform?D(t,n,o.xform):D(t,n)}));this.sources=new Map,this.realSourceIDs=new Map,this.invRealSourceIDs=new Map,this.idSources=new Map,this.psync=t,this.clean=!!o.clean,o.src&&this.addAll(o.src)}add(o,t){t||(t=o.id),this.ensureState(),this.psync.add(t),this.realSourceIDs.set(t,o.id),this.invRealSourceIDs.set(o.id,t),this.idSources.set(o.id,o),this.sources.set(o,o.subscribe({next:(n)=>n[1]instanceof Q?this.add(n[1]):this.next(n),done:()=>this.markDone(o),__owner:this},{xform:Mt(t),id:`in-${t}`}))}addAll(o){for(let t in o)this.psync.add(t);for(let t in o)this.add(o[t],t)}remove(o){let t=this.sources.get(o);if(t){let n=this.invRealSourceIDs.get(o.id);return I.info(`removing src: ${o.id} (${n})`),this.psync.delete(n,this.clean),this.realSourceIDs.delete(n),this.invRealSourceIDs.delete(o.id),this.idSources.delete(o.id),this.sources.delete(o),t.unsubscribe(),!0}return!1}removeID(o){let t=this.getSourceForID(o);return t?this.remove(t):!1}removeAll(o){for(let n of o)this.psync.delete(this.invRealSourceIDs.get(n.id));let t=!0;for(let n of o)t=this.remove(n)&&t;return t}removeAllIDs(o){return bn(this,o)}getSourceForID(o){return this.idSources.get(this.realSourceIDs.get(o))}getSources(){let o={};for(let[t,n]of this.idSources)o[this.invRealSourceIDs.get(t)]=n;return o}unsubscribe(o){if(!o){I.debug(this.id,"unsub sources");for(let t of this.sources.values())t.unsubscribe();this.sources.clear(),this.psync.clear(),this.realSourceIDs.clear(),this.invRealSourceIDs.clear(),this.idSources.clear()}return super.unsubscribe(o)}markDone(o){this.remove(o),jn(this.closeIn,this.sources.size)&&this.done()}}var St=z((o,t=" ")=>{let n=oo(String(t),o);return(m,f)=>{if(m==null)return n;return m=m.toString(),f=f!==void 0?f:m.length,f<o?n.substring(f)+m:m}}),iN=St(2,"0"),vN=St(3,"0"),Qn=St(4,"0");var Gf=/\{(\d+)\}/g;var Rt=(o,...t)=>t.length>0?o.replace(Gf,(n,m)=>String(t[parseInt(m,10)])):o;var kn=(o)=>({key:(t)=>t,group:Go(),...o});function Ut(...o){let t=En(Ut,o);if(t)return t;let n=kn(o[0]),[m,f,r]=n.group;return[()=>({}),(E)=>{for(let G in E)E[G]=f(E[G]);return E},(E,G)=>{let N=n.key(G);return E[N]=E[N]?r(E[N],G):r(m(),G),E}]}function Jt(o,t){return w(t)?g(Jt(o),t):(n)=>{let m=n[2];return u(n,(f,r)=>o(r)?m(f,r):f)}}import{watch as gn}from"fs";import{resolve as a}from"path";var vn={specs:P({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},xo={bundle:J({alias:"b",desc:"Bundle inputs (see `out` option)"})},Oo={include:Xo({alias:"I",desc:"Include CSS files (prepend)"})},ao={eval:P({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},so={force:Xo({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},pn={media:Xo({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},dn={onlyDecls:J({desc:"Only emit framework decls"})},k={out:P({alias:"o",desc:"Output file (or stdout)"})},co={prec:Po({default:3,desc:"Number of fractional digits"})},i={pretty:J({alias:"p",desc:"Pretty print output"})},ho={noDecls:J({alias:"d",desc:"Don't emit framework decls"})},Co={noHeader:J({desc:"Don't emit generated header comment"})},Ao={scope:P({desc:"Suffix for CSS class names"})},Fo={watch:J({alias:"w",desc:"Watch input files for changes"})};import{watch as Nf}from"fs";import{resolve as ln}from"path";var v=(o,t,n)=>{t=$(t)?t:t.join(`
26
+ `),o?Ot(ln(o),t,n):process.stdout.write(t+`
27
+ `)},ot=({info:{name:o,version:t}})=>`/*! ${o} v${t} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,Io=(o,t)=>{let n=()=>{t.info("closing watchers..."),m.forEach((f)=>f.watcher.close())},m=o.map((f,r)=>{f=ln(f);let E=Zn(M(f,t),{id:`in${Qn(r)}`});return{input:E,watcher:Nf(f,{},(G)=>{if(G==="change")try{E.next(M(f,t))}catch(N){t.warn(N.message),n()}else t.warn("input removed:",f),n()})}});return process.on("SIGINT",n),eo({src:wt(T(({input:f})=>[f.id,f],m))})},tt=(o)=>Object.keys(o).reduce((t,n)=>{if(!n.startsWith("__"))t[n]=o[n];return t},{});var xn={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...xo,...ao,...so,...Oo,...ho,...Co,...k,...i,...Ao,...vn,...Fo,noWrite:J({desc:"Don't write files, use stdout only"})},fn:zt};async function zt(o){let t=V(a(o.opts.specs),o.logger),n=Cf(t,o.opts.force||[],o.logger);if(o.opts.bundle)if(o.opts.watch)await Bf(o,n);else Ro(o,t,n,o.opts.eval?[o.opts.eval]:o.inputs.map((m)=>M(a(m),o.logger)),o.opts.out);else if(o.opts.watch)await Lf(o,t,n);else if(o.opts.eval)try{Ro(o,t,n,[o.opts.eval])}catch(m){o.logger.warn(m.message)}else for(let m of o.inputs)try{m=a(m);let f=!o.opts.noWrite?m.replace(/\.mcss$/,".css"):void 0;Ro(o,t,n,[M(m,o.logger)],f)}catch(f){o.logger.warn(f.message)}}var Lf=async(o,t,n)=>{let m=a(o.opts.specs),f,r={process:()=>{try{return t=V(m,o.logger),f.forEach((G)=>G.process()),!0}catch(G){return o.logger.warn(G.message+": "+m),!1}},watcher:gn(m,{},(G)=>{if(G==="change")r.process();else o.logger.warn("specs file removed:",m),E()})},E=()=>{o.logger.info("closing watchers..."),r.watcher.close(),f.forEach((G)=>G.watcher.close())};f=o.inputs.map((G)=>{G=a(G);let N=!o.opts.noWrite?G.replace(/\.mcss$/,".css"):void 0,L=()=>{try{return Ro(o,t,n,[M(G,o.logger)],N),!0}catch(B){if(o.logger.warn(B.message+": "+G),f)E();return!1}};if(!L())process.exit(1);return{process:L,watcher:gn(G,{},(B)=>{if(B==="change")L();else o.logger.warn("input removed:",G),E()})}}),o.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",E)},Bf=async(o,t)=>{eo({src:{styles:Io(o.inputs,o.logger),specs:Io([o.opts.specs],o.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:m}){try{Ro(o,m,t,Object.keys(n).sort().map((f)=>n[f]),o.opts.out)}catch(f){o.logger.warn(f.message)}}})},Ro=({logger:o,opts:{include:t,noDecls:n,noHeader:m,pretty:f,scope:r}},E,G,N,L)=>{let B={logger:o,specs:E,css:{format:f?ko:fo,fns:go,scope:r},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},h=t?t.map((O)=>M(a(O),o).trim()):[];if(!m)h.push(ot(E));if(!n&&E.decls.length)h.push(e(E.decls,B.css));N.forEach((O)=>Af(O,B)),hf(h,B),Of(h,B),v(L,h,o)},Of=(o,{css:t,logger:n,mediaQueryRules:m,specs:f})=>{for(let r in m){let E=sn(m[r],f);n.debug("mediaquery rules",r,E),o.push(e(Bo(Hf(f.media,r),E),t))}},hf=(o,{css:t,logger:n,plainRules:m,specs:f})=>{let r=sn(m,f);n.debug("plain rules",r),o.push(e(r,t))},Cf=(o,t,n)=>{let m=new Set(Object.keys(o.media)),f=new Set(Object.keys(o.classes)),r={},E={};if(t.length&&t[0][0]==="@")t=[...to(M(a(t[0].substring(1)),n))];for(let G of t){if(!G||G.startsWith("//"))continue;let{token:N,query:L}=cn(G,m),B;if(N.includes("*")){let h=new RegExp(`^${N.replace("*",".*")}$`);B=[...Jt((O)=>h.test(O),f)]}else if(f.has(N))B=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let h of B)n.debug("including class:",h),L?om(r,L,`.${h}`,h):tm(E,`.${h}`,h)}return{mediaQueryRules:r,plainRules:E}},Af=(o,{specs:t,mediaQueryIDs:n,mediaQueryRules:m,plainRules:f})=>{let r=Uo(),E=Uo(r),G={root:r,curr:E,scopes:[E]};for(let N of to(o)){if(!N||/^\s*\/\//.test(N))continue;for(let L of Ff(N)){if(!L)continue;let B=G.curr;switch(B.state){case"sel":case"nest":if(L==="{"){if(B.state==="sel")B.sel=B.sel.map((h)=>h.replace(",","")),B.path=Tf(G.scopes);B.state="class"}else if(L==="}")en(G);else{let h=Wo(B.sel);if(!h||h.endsWith(","))B.sel.push(L);else B.sel[B.sel.length-1]+=" "+L}break;case"class":if(L==="{")B.state="nest",G.scopes.push(G.curr=Uo(B));else if(L==="}")en(G);else{let{token:h,query:O}=cn(L,n);if(!t.classes[h]&&!(nm(h)||fm(h)||mm(h)))C(`unknown class ID: ${h}`);if(O)om(m,O,B.path,h);else tm(f,B.path,h)}break;default:mo(B.state)}}}};function*Ff(o){let t=-1,n=o.length,m=0,f=0;for(let r=0;r<n;r++){let E=o[r];if(E===" "||E==="\t"){if(!(m||f)&&t>=0)yield o.substring(t,r),t=-1}else if(E==="{"||E==="}"){if(t>=0)yield o.substring(t,r);yield E,t=-1}else if(E==="(")m++;else if(E===")"){if(--m<0)C(`invalid nesting in line: '${o}'`)}else if(E==="["){if(t<0)t=r;f++}else if(E==="]"){if(--f<0)C(`invalid arg nesting in line: '${o}'`)}else if(t<0)t=r}if(m)C("template calls must be fully on a single line");if(f)C("verbatim properties must be fully on a single line");if(t>=0)yield o.substring(t,n)}var So=":",an="///",Uo=(o)=>({state:"sel",sel:o?[]:["<root>"],path:"",parent:o}),en=(o)=>{let t=!o.curr.sel.length;if(qo(!!o.curr.parent,"stack underflow"),o.scopes.pop(),o.scopes.length>0){if(o.curr=Wo(o.scopes),!t&&o.curr.state==="nest")o.scopes.push(o.curr=Uo(o.curr))}else o.scopes.push(o.curr=Uo(o.root))},Tf=(o)=>o.map((t)=>t.sel.join(",")).join(an),sn=(o,t)=>Object.entries(o).map(([n,m])=>$f(n,m,t)),$f=(o,t,n)=>{let m=[],f=m,r=o.split(an);for(let E=0;E<r.length;E++){let G=r[E].split(",");if(E==r.length-1){let N=Object.assign({},...T((L)=>fm(L)?Wf(L):nm(L)?_f(L):mm(L)?wf(n,L):tt(n.classes[L]),t));G.push(N)}f.push(G),f=G}return m[0]},cn=(o,t)=>{if(/^::?/.test(o))return{token:o};let n=o.lastIndexOf(So);if(n<0)return{token:o};let m=o.indexOf("(");if(m>0){if(m<n&&o.indexOf(So)>m)return{token:o};n=o.substring(0,m).lastIndexOf(So)}let f=o.substring(0,n);if(!f.split(So).every((E)=>t.has(E)))C(`invalid media query in token: ${o}`);return{token:o.substring(n+1),query:f}},Hf=(o,t)=>t.split(So).reduce((n,m)=>Object.assign(n,o[m]),{}),om=(o,t,n,m)=>{if(!o[t])o[t]={};(o[t][n]||(o[t][n]=new Set)).add(m)},tm=(o,t,n)=>(o[t]||(o[t]=new Set)).add(n),_f=(o)=>{let t=o.indexOf("=");return{[`--${o.substring(0,t)}`]:o.substring(t+1)}},wf=(o,t)=>{let n=t.indexOf("("),m=t.substring(0,n),f=t.substring(n+1,t.length-1).split(/(?<!\\),/g).map((E)=>E.trim().replace("\\,",",")),r=o.templates[m];if(!r)C(`unknown template: ${m}`);if(f.length!==r.__arity)C(`template "${m}" expected ${r.__arity} arguments`);return Object.entries(r).reduce((E,[G,N])=>{if(!G.startsWith("__")){if(G=Rt(G,...f),$(N))N=Rt(N,...f);E[G]=N}return E},{})},Wf=(o)=>{let[t,n,m]=/^(.+)-\[(.+)\]/.exec(o);return{[n]:m}},nm=(o)=>/^[a-z0-9:_-]+=.+/i.test(o),mm=(o)=>o.includes("(")&&o.endsWith(")"),fm=(o)=>o.indexOf("-[")>0&&o.endsWith("]");var Em={deg:Jn,em:Hn,ex:_n,ms:Rn,percent:_t,px:Wn,rad:zn,rem:wn,second:Un,turn:Xn,url:Pn,vh:Mn,vmax:Sn,vmin:In,vw:Yn,"%":_t},Mf={percent:"{0}%",second:"{0}s",url:"url({0})"},Yf={"":[""],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:[""]},Gm={desc:"Generate framework rules from specs",opts:{...k,...co,...i,...Fo},fn:Xt};async function Xt(o){if(o.opts.watch)await If(o);else await Nm(o.inputs.map((t)=>M(t,o.logger)),o.opts,o.logger)}var If=async(o)=>{Io(o.inputs,o.logger).subscribe({next(t){try{Nm(Object.keys(t).sort().map((n)=>t[n]),o.opts,o.logger)}catch(n){o.logger.warn(n.message)}}})},Nm=async(o,t,n)=>{let m={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};$n(t.prec);for(let f of o){let r=JSON.parse(f);if(Object.assign(m.info,r.info),Object.assign(m.media,r.media),r.decls)m.decls.push(...r.decls);if(r.specs)for(let E of r.specs)try{Lm(r,E,m.classes,n)}catch(G){n.warn(`error processing spec: ${E.name}`,G,", skipping...")}if(r.templates)for(let E of r.templates)Sf(r,E,m.templates,n)}return v(t.out,JSON.stringify(m,null,t.pretty?4:0),n),m},Lm=(o,t,n,m,f=!1)=>{let r=_(t.vars)?t.vars:[""],E=$(t.props)?{[t.props]:"<v>"}:t.props,G=Rf(t,o),N=new Set;for(let L of r){let B=o.vars?.[L]||Yf[L];if(!B)C(`unknown variation ID: ${L}`);for(let[h,O]of vo(B,Object.keys(G))){let A=s(t.name,L,h,O,G[O]),U=t.unit?s(t.unit,L,h,O,G[O]):void 0,p=f?Jf(U):Uf(G[O],U);if(!n[A]){if(n[A]={},t.user!=null)n[A].__user=t.user;if(t.doc!=null)n[A].__doc=zf(t.doc,L,h,O,p)}else if(!N.has(A))C(`duplicate class ID: ${A}`);N.add(A);let F=-1;for(let[d,S]of Object.entries(E)){let q=s(d,L,h,O,G[O]),nt=s(!U||$(S)?String(S):Em[U](S),L,h,O,p);if(n[A][q]=nt,m.debug(A,q,nt),f)F=rm(nt,rm(q,F))}if(f)n[A].__arity=F+1}}return n},Sf=(o,t,n,m)=>Lm(o,{...t,values:[""]},n,m,!0),rm=(o,t)=>{let n=/\{(\d+)\}/g,m;while(m=n.exec(o))t=Math.max(t,+m[1]);return t},Rf=(o,t)=>{let n=$(o.values)?t.tables?.[o.values]||C(`invalid table ID: ${o.values}`):o.values;if(Z(n))return n;let m=o.key==="v"?(f)=>String(f):o.key==="i+1"?(f,r)=>String(r+1):o.key==="i"||o.key===void 0?(f,r)=>String(r):C(`invalid key type: ${o.key}`);return n.reduce((f,r,E)=>{return f[m(r,E)]=r,f},{})},Uf=(o,t)=>{if(!t||$(o))return o;let n=Em[t];if(!n)C(`invalid unit: ${t}`);return n(o)},Jf=(o)=>o?Mf[o]||"{0}"+o:"{0}",s=(o,t,n,m,f)=>o.replace(/<vid>/g,t).replace(/<var>/g,n).replace(/<k>/g,m).replace(/<v>/g,String(f)),zf=({group:o,desc:t,args:n},m,f,r,E)=>({group:o?s(o,m,f,r,E):"TODO",desc:t?s(t,m,f,r,E):void 0,args:n?n.map((G)=>s(G,m,f,r,E)):void 0});var Bm={desc:"Combination of the generate & convert commands",opts:{...xo,...ao,...so,...Oo,...ho,...Co,...co,...i,...Ao,...Fo,outCss:P({desc:"Output file for CSS bundle",optional:!1}),outSpecs:P({desc:"Output file for framework",optional:!1})},fn:async(o)=>{let{opts:t,inputs:n}=o,[m,f]=n.reduce((G,N)=>(G[N.endsWith(".json")?0:1].push(N),G),[[],[]]),r={inputs:m,format:o.format,logger:o.logger,opts:{...t,out:t.outSpecs}},E={inputs:f,format:o.format,logger:o.logger,opts:{...t,noWrite:!1,out:t.outCss,scope:t.scope,specs:t.outSpecs}};await Xt(r),await zt(E)}};import{resolve as Xf}from"path";var Cm={desc:"Generate Markdown documentation for framework specs",opts:{...k,level:Po({alias:"l",desc:"Initial heading level",default:1}),title:P({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(o)=>{let{logger:t,opts:n,inputs:m}=o,f=V(Xf(m[0]),t),r=Pf(f,n);v(n.out,r,t)}},Pf=(o,{level:t,title:n})=>{let m=Object.keys(o.classes).length,f=Object.keys(o.templates).length,r=[`Currently, there are ${m+f} CSS utility classes (incl. ${f} templates) defined in "${o.info.name}" (v${o.info.version}):`,"",`${c(t+1)} Classes by category`,"",...hm(o.classes,Df,t+2),`${c(t+1)} Templates by category`,"",...hm(o.templates,jf,t+2),`${c(t+1)} Media queries`,"",...Object.entries(o.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")r.unshift(`${c(t)} ${n??o.info.name}
28
28
  `);return r},Om=(o)=>o.split(/(\d+)/).map((t)=>{let n=parseInt(t);return isNaN(n)?t:n}),Zf=(o,t)=>{if(/\d+/.test(o)&&/\d+/.test(t)){let n=Om(o),m=Om(t),f=n.length;if(f===m.length){for(let r=0;r<f;r++)if(n[r]!==m[r])return At(n[r],m[r]);return 0}return n.length-m.length}return At(o,t)},hm=(o,t,n)=>{let m=Ut({key:([f,{__doc:r}])=>r?.group||"TODO",group:[()=>[],(f)=>f.sort(),(f,r)=>(f.push(r[0]),f)]},Object.entries(o));return Wt((f)=>{let r=m[f].sort(Zf).map((G)=>t(G,o[G].__doc,n+1)),E=r.length;return[`${c(n)} ${Ko(f)}`,E>3?`
29
29
  <details><summary>${E} items:</summary>
30
30
  `:"",r.join(`
31
31
  `),E>3?`</details>
32
- `:""]},Object.keys(m).sort())},Df=(o,t)=>{if(!(t&&t.desc))return`- \`${o}\``;let n=t.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${o}\` (${n})`},jf=(o,t,n)=>{if(!(t&&t.args))return`${c(n)} ${o}(...)
32
+ `:""]},Object.keys(m).sort())},Df=(o,t)=>{if(!t?.desc)return`- \`${o}\``;let n=t.desc;if(/^-[a-z]/.test(n))n=n.substring(1);return`- \`${o}\` (${n})`},jf=(o,t,n)=>{if(!t?.args)return`${c(n)} ${o}(...)
33
33
 
34
34
  TODO`;let m=t.args.map((f)=>/^\w+/.exec(f)[0]).join(", ");return[`${c(n)} \`${o}(${m})\``,"",...t.args.map(yf),t.desc?`
35
35
  ${t.desc}
36
36
  `:""].join(`
37
- `)},yf=(o)=>`- ${o.replace(/^(\w+)/,(t,n)=>`**${n}**`)}`,c=z((o)=>"#".repeat(o));import{resolve as Am}from"path";var Tm={desc:"Export entire generated framework as CSS",opts:{...Oo,...ho,...ln,...k,...i,...Co,...pn,...Ao},inputs:1,fn:async(o)=>{let{logger:t,opts:{include:n,media:m,noDecls:f,noHeader:r,onlyDecls:E,out:G,pretty:N,scope:L},inputs:B}=o,h={format:N?ko:fo,fns:go,scope:L},O=V(Am(B[0]),t),A=n?n.map((U)=>M(Am(U),t).trim()):[];if(!r)A.push(ot(O));if(!f&&O.decls.length)A.push(e(O.decls,h));if(!E)A.push(Kf(O,m,h,t));v(G,A,t)}},Kf=(o,t,n,m)=>{let f=Fm("",o);if(t){let r=t[0]==="ALL"?Object.keys(o.media):t;for(let E of r)if(o.media[E])f.push(Bo(o.media[E],Fm("-"+E,o)));else m.warn(`invalid media query ID: ${E}, skipping...`)}return e(f,n)},Fm=(o,t)=>Object.entries(t.classes).map(([n,m])=>[`.${n}${o}`,tt(m)]);var Pt=V(Vf(import.meta.dir,"package.json"));st({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:xn,develop:Bm,doc:Cm,export:Tm,generate:Gm},ctx:async(o)=>{if(o.opts.verbose)o.logger.level=H.DEBUG;return{...o,format:yo}},usage:{prefix:`
37
+ `)},yf=(o)=>`- ${o.replace(/^(\w+)/,(t,n)=>`**${n}**`)}`,c=z((o)=>"#".repeat(o));import{resolve as Am}from"path";var Tm={desc:"Export entire generated framework as CSS",opts:{...Oo,...ho,...dn,...k,...i,...Co,...pn,...Ao},inputs:1,fn:async(o)=>{let{logger:t,opts:{include:n,media:m,noDecls:f,noHeader:r,onlyDecls:E,out:G,pretty:N,scope:L},inputs:B}=o,h={format:N?ko:fo,fns:go,scope:L},O=V(Am(B[0]),t),A=n?n.map((U)=>M(Am(U),t).trim()):[];if(!r)A.push(ot(O));if(!f&&O.decls.length)A.push(e(O.decls,h));if(!E)A.push(Kf(O,m,h,t));v(G,A,t)}},Kf=(o,t,n,m)=>{let f=Fm("",o);if(t){let r=t[0]==="ALL"?Object.keys(o.media):t;for(let E of r)if(o.media[E])f.push(Bo(o.media[E],Fm("-"+E,o)));else m.warn(`invalid media query ID: ${E}, skipping...`)}return e(f,n)},Fm=(o,t)=>Object.entries(t.classes).map(([n,m])=>[`.${n}${o}`,tt(m)]);var Pt=V(Vf(import.meta.dir,"package.json"));st({name:"metacss",opts:{verbose:J({alias:"v",desc:"Display extra process information"})},commands:{convert:xn,develop:Bm,doc:Cm,export:Tm,generate:Gm},ctx:async(o)=>{if(o.opts.verbose)o.logger.level=H.DEBUG;return{...o,format:yo}},usage:{prefix:`
38
38
  \u2588 \u2588 \u2588 \u2502
39
39
  \u2588\u2588 \u2588 \u2502
40
40
  \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${Pt.name} ${Pt.version}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/meta-css",
3
- "version": "0.17.7",
3
+ "version": "0.17.8",
4
4
  "description": "Data-driven CSS framework codegen, transpiler & bundler",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -46,19 +46,19 @@
46
46
  },
47
47
  "dependencies": {
48
48
  "@thi.ng/api": "^8.11.16",
49
- "@thi.ng/args": "^2.3.52",
50
- "@thi.ng/arrays": "^2.10.9",
51
- "@thi.ng/checks": "^3.6.18",
49
+ "@thi.ng/args": "^2.3.53",
50
+ "@thi.ng/arrays": "^2.10.10",
51
+ "@thi.ng/checks": "^3.6.19",
52
52
  "@thi.ng/compare": "^2.4.8",
53
53
  "@thi.ng/errors": "^2.5.22",
54
- "@thi.ng/file-io": "^2.1.20",
55
- "@thi.ng/hiccup-css": "^2.7.32",
56
- "@thi.ng/logger": "^3.0.26",
54
+ "@thi.ng/file-io": "^2.1.21",
55
+ "@thi.ng/hiccup-css": "^2.7.33",
56
+ "@thi.ng/logger": "^3.0.27",
57
57
  "@thi.ng/memoize": "^4.0.6",
58
- "@thi.ng/rstream": "^9.2.3",
58
+ "@thi.ng/rstream": "^9.2.4",
59
59
  "@thi.ng/strings": "^3.9.0",
60
60
  "@thi.ng/text-format": "^2.2.21",
61
- "@thi.ng/transducers": "^9.2.12"
61
+ "@thi.ng/transducers": "^9.2.13"
62
62
  },
63
63
  "devDependencies": {
64
64
  "@microsoft/api-extractor": "^7.48.1",
@@ -114,5 +114,5 @@
114
114
  "status": "alpha",
115
115
  "year": 2023
116
116
  },
117
- "gitHead": "56c1d57a96565bbcc8c06c73779a619bba0db368\n"
117
+ "gitHead": "6542b842120bef47cc18d45a1b1db68307a7f04b\n"
118
118
  }