@thi.ng/meta-css 0.19.11 → 0.19.13

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/index.js +11 -11
  2. package/package.json +6 -6
package/index.js CHANGED
@@ -1,14 +1,14 @@
1
1
  // @bun
2
- var Go={default:95,command:92,error:91,hint:90,multi:90,param:96,required:33};var ut=(t)=>t;function U(t,o=Object.create(null)){return(...n)=>{let r=n.join("-");return r in o?o[r]:o[r]=t(...n)}}var nt=U((t,o)=>t.repeat(o));var Po=(t)=>/^[a-f0-9]+$/i.test(t);var jo=(t)=>/^[-+]?\d+$/.test(t),Xo=(t)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(t);var Y=(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 Sr=Y(()=>"illegal argument(s)"),L=(t)=>{throw new Sr(t)};var No=(t)=>Xo(t)?parseFloat(t):L(`not a numeric value: ${t}`),Zo=(t)=>t.map(No),Oo=(t)=>Po(t)?parseInt(t,16):L(`not a hex value: ${t}`),bo=(t)=>t.map(Oo),eo=(t)=>jo(t)?parseInt(t):L(`not an integer: ${t}`),Ko=(t)=>t.map(eo);var Ut=(t,o)=>(n)=>({coerce:t,hint:o,group:"main",...n}),Yt=(t,o)=>(n)=>({hint:Hr(o,n.delim),multi:!0,coerce:t,group:"main",...n}),Hr=(t,o)=>t+(o?`[${o}..]`:""),R=(t)=>({flag:!0,default:!1,group:"flags",...t}),D=Ut(ut,"STR"),Dt=Yt(ut,"STR"),Lf=Ut(No,"NUM"),_f=Ut(Oo,"HEX"),Jt=Ut(eo,"INT"),Bf=Yt(Zo,"NUM"),Af=Yt(bo,"HEX"),$f=Yt(Ko,"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 yr=0;class Tt{constructor(t,o=$.FINE,n){this.parent=n,this.id=t||`logger-${yr++}`,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)}none(){}log(t,o){this.level<=t&&this.logEntry([t,this.id,Date.now(),...o])}}var po=(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 zt extends Tt{constructor(t,o,n,r){super(o,n,r);this.target=t}childLogger(t,o){return new zt(this.target,t,o??this.level,this)}logEntry(t){if(t[0]<this.level)return;this.target.write(`[${$[t[0]]}] ${t[1]}: ${po(t.slice(3))}
3
- `),this.parent?.logEntry(t)}}var ho={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 Mr=(t,o)=>(n)=>t.format(o,n),Co=(t)=>Object.keys(ho).reduce((o,n)=>(o[n]=Mr(t,ho[n]),o),{format:t});var Vo="\x1B[0m";var Ir=["","1","2","1;2","4","1;4","2;4","1;2;4"],Pt={format:(t,o)=>Pt.start(t)+o+Pt.end,start:U((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(Ir[n]),"\x1B["+o.join(";")+"m"}),end:Vo,prefix:Vo,suffix:`
2
+ var Go={default:95,command:92,error:91,hint:90,multi:90,param:96,required:33};var Tt=(t)=>t;function U(t,o=Object.create(null)){return(...n)=>{let r=n.join("-");return r in o?o[r]:o[r]=t(...n)}}var nt=U((t,o)=>t.repeat(o));var Po=(t)=>/^[a-f0-9]+$/i.test(t);var jo=(t)=>/^[-+]?\d+$/.test(t),Xo=(t)=>/^[-+]?\d*\.?\d+(e[-+]?\d+)?$/i.test(t);var Y=(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 Sr=Y(()=>"illegal argument(s)"),L=(t)=>{throw new Sr(t)};var No=(t)=>Xo(t)?parseFloat(t):L(`not a numeric value: ${t}`),Zo=(t)=>t.map(No),Oo=(t)=>Po(t)?parseInt(t,16):L(`not a hex value: ${t}`),bo=(t)=>t.map(Oo),ho=(t)=>jo(t)?parseInt(t):L(`not an integer: ${t}`),Ko=(t)=>t.map(ho);var Ut=(t,o)=>(n)=>({coerce:t,hint:o,group:"main",...n}),Yt=(t,o)=>(n)=>({hint:Hr(o,n.delim),multi:!0,coerce:t,group:"main",...n}),Hr=(t,o)=>t+(o?`[${o}..]`:""),R=(t)=>({flag:!0,default:!1,group:"flags",...t}),D=Ut(Tt,"STR"),Dt=Yt(Tt,"STR"),Lf=Ut(No,"NUM"),_f=Ut(Oo,"HEX"),Jt=Ut(ho,"INT"),Bf=Yt(Zo,"NUM"),Af=Yt(bo,"HEX"),$f=Yt(Ko,"INT");var A=Array.isArray;var T=((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})(T||{});var yr=0;class ut{constructor(t,o=T.FINE,n){this.parent=n,this.id=t||`logger-${yr++}`,this.level=typeof o==="string"?T[o]:o}id;level;addChild(t){return t.parent=this,t}enabled(t){return this.level<=t}fine(...t){this.log(T.FINE,t)}debug(...t){this.log(T.DEBUG,t)}info(...t){this.log(T.INFO,t)}warn(...t){this.log(T.WARN,t)}severe(...t){this.log(T.SEVERE,t)}none(){}log(t,o){this.level<=t&&this.logEntry([t,this.id,Date.now(),...o])}}var po=(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 zt extends ut{constructor(t,o,n,r){super(o,n,r);this.target=t}childLogger(t,o){return new zt(this.target,t,o??this.level,this)}logEntry(t){if(t[0]<this.level)return;this.target.write(`[${T[t[0]]}] ${t[1]}: ${po(t.slice(3))}
3
+ `),this.parent?.logEntry(t)}}var eo={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 Mr=(t,o)=>(n)=>t.format(o,n),Co=(t)=>Object.keys(eo).reduce((o,n)=>(o[n]=Mr(t,eo[n]),o),{format:t});var Vo="\x1B[0m";var Ir=["","1","2","1;2","4","1;4","2;4","1;2;4"],Pt={format:(t,o)=>Pt.start(t)+o+Pt.end,start:U((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(Ir[n]),"\x1B["+o.join(";")+"m"}),end:Vo,prefix:Vo,suffix:`
4
4
  `};var qo={format:(t,o)=>String(o),prefix:"",suffix:`
5
- `,start:()=>"",end:""};var jt=Co(Pt),Qo=Co(qo);var u=Array.isArray;var Rr=(t)=>t.toUpperCase(),ko=(t)=>t.toLowerCase(),Xt=(t)=>t.length?t[0].toUpperCase()+t.substring(1):t,rt=(t,o="-")=>ko(t.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,r,m)=>r+o+m));var vo=(t,o="-")=>ko(t).replace(new RegExp(`\\${o}+(\\w)`,"g"),(n,r)=>Rr(r));var lo=(t=!1,o)=>(n)=>t||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,o):String(n);var go=Object.getPrototypeOf,J=(t)=>{let o;return t!=null&&typeof t==="object"&&((o=go(t))===null||go(o)===null)};var Wr=/\x1b\[[0-9;]+m/g,Ur=(t)=>t.replace(Wr,"");var Zt=(t)=>Ur(t).length;var xo=U((t,o=" ")=>{let n=nt(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}});function*mt(t,o=/\r?\n/g,n=!1){let r=0,m=t.length,f=~~n,E;if(typeof o==="string")E=new RegExp(o,"g");else if(!o.flags.includes("g"))E=new RegExp(o,o.flags+"g");else E=o;for(;r<m;){let G=E.exec(t);if(!G){yield t.substring(r);return}let N=G[0].length;yield t.substring(r,G.index+f*N),r=G.index+N}}class Lo{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 Yr={length:(t)=>t.length,split:(t,o)=>o},so={length:Zt,split:(t,o)=>{let n=/\x1b\[[0-9;]+m/g,r=o,m;while(m=n.exec(t)){if(m.index>=o)break;let f=m[0].length;r+=f,o+=f}return r}},ao=(t,o,n,r)=>{let m=t[t.length-1];m&&r-m.n>n?m.add(o,n):t.push(new Lo(o,n))},Dr=(t,{width:o,min:n,hard:r,splitter:m},f=0,E=[])=>{let G=m.length(t),N=o-f;if(N<n&&N<G)N=o;while(r&&G>N){let O=m.split(t,N),e=t.substring(0,O);ao(E,e,N,o),t=t.substring(O),N=o,G=m.length(t)}return ao(E,t,G,o),E},Jr=(t,o,n=[])=>{if(!t.length)return n.push(new Lo),n;let r={width:80,min:4,hard:!1,splitter:Yr,...o};for(let m of mt(t,o.delimWord||/\s/g)){let f=n[n.length-1];Dr(m,r,f&&f.n>0?f.n+1:0,n)}return n},co=(t,o)=>{let n=[];for(let r of mt(t,o.delimLine))n=n.concat(Jr(r,o));return n};var W=(t,o)=>o!=null?`\x1B[${o}m${t}\x1B[0m`:t,bt=(t,o)=>xo(o)(t,Zt(t)),Kt=(t,o)=>t?co(t,{width:o,splitter:so,hard:!1}):[],pt=(t,o,n)=>{let r=nt(" ",o);return Kt(t,n-o).map((m,f)=>f?r+m:m).join(`
5
+ `,start:()=>"",end:""};var jt=Co(Pt),Qo=Co(qo);var Rr=(t)=>t.toUpperCase(),ko=(t)=>t.toLowerCase(),Xt=(t)=>t.length?t[0].toUpperCase()+t.substring(1):t,rt=(t,o="-")=>ko(t.replace(/([a-z0-9\u00e0-\u00fd])([A-Z\u00c0-\u00dd])/g,(n,r,m)=>r+o+m));var vo=(t,o="-")=>ko(t).replace(new RegExp(`\\${o}+(\\w)`,"g"),(n,r)=>Rr(r));var lo=(t=!1,o)=>(n)=>t||typeof n!=="string"&&typeof n!=="number"?JSON.stringify(n,null,o):String(n);var go=Object.getPrototypeOf,J=(t)=>{let o;return t!=null&&typeof t==="object"&&((o=go(t))===null||go(o)===null)};var Wr=/\x1b\[[0-9;]+m/g,Ur=(t)=>t.replace(Wr,"");var Zt=(t)=>Ur(t).length;var xo=U((t,o=" ")=>{let n=nt(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}});function*mt(t,o=/\r?\n/g,n=!1){let r=0,m=t.length,f=~~n,E;if(typeof o==="string")E=new RegExp(o,"g");else if(!o.flags.includes("g"))E=new RegExp(o,o.flags+"g");else E=o;for(;r<m;){let G=E.exec(t);if(!G){yield t.substring(r);return}let N=G[0].length;yield t.substring(r,G.index+f*N),r=G.index+N}}class Lo{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 Yr={length:(t)=>t.length,split:(t,o)=>o},so={length:Zt,split:(t,o)=>{let n=/\x1b\[[0-9;]+m/g,r=o,m;while(m=n.exec(t)){if(m.index>=o)break;let f=m[0].length;r+=f,o+=f}return r}},ao=(t,o,n,r)=>{let m=t[t.length-1];m&&r-m.n>n?m.add(o,n):t.push(new Lo(o,n))},Dr=(t,{width:o,min:n,hard:r,splitter:m},f=0,E=[])=>{let G=m.length(t),N=o-f;if(N<n&&N<G)N=o;while(r&&G>N){let O=m.split(t,N),h=t.substring(0,O);ao(E,h,N,o),t=t.substring(O),N=o,G=m.length(t)}return ao(E,t,G,o),E},Jr=(t,o,n=[])=>{if(!t.length)return n.push(new Lo),n;let r={width:80,min:4,hard:!1,splitter:Yr,...o};for(let m of mt(t,o.delimWord||/\s/g)){let f=n[n.length-1];Dr(m,r,f&&f.n>0?f.n+1:0,n)}return n},co=(t,o)=>{let n=[];for(let r of mt(t,o.delimLine))n=n.concat(Jr(r,o));return n};var W=(t,o)=>o!=null?`\x1B[${o}m${t}\x1B[0m`:t,bt=(t,o)=>xo(o)(t,Zt(t)),Kt=(t,o)=>t?co(t,{width:o,splitter:so,hard:!1}):[],pt=(t,o,n)=>{let r=nt(" ",o);return Kt(t,n-o).map((m,f)=>f?r+m:m).join(`
6
6
  `)},d=(t)=>J(t)?{...Go,...t}:t!==!1?Go:{};var wt=(t,o={})=>{o={lineWidth:80,paramWidth:32,showDefaults:!0,prefix:"",suffix:"",groups:["flags","main"],...o};let n=d(o.color),r=(E)=>E.map((G)=>zr(G,t[G],o,n,o.paramWidth)),m=Object.keys(t).sort(),f=o.groups?o.groups.map((E)=>[E,m.filter((G)=>t[G].group===E)]).filter((E)=>!!E[1].length):[["options",m]];return[...Kt(o.prefix,o.lineWidth),...f.map(([E,G])=>[...o.showGroupNames?[`${Xt(E)}:
7
7
  `]:[],...r(G),""].join(`
8
8
  `)),...Kt(o.suffix,o.lineWidth)].join(`
9
- `)},zr=(t,o,n,r,m)=>{let f=Pr(o,r),E=jr(o,r,f),G=W(`--${rt(t)}`,r.param),N=`${E}${G}${f}`,O=o.optional===!1&&o.default===void 0,e=[];O&&e.push("required"),o.multi&&e.push("multiple");let C=Xr(e,r,O)+(o.desc||"")+Zr(o,n,r);return bt(N,n.paramWidth)+pt(C,m,n.lineWidth)},Pr=(t,o)=>t.hint?W(" "+t.hint,o.hint):"",jr=(t,o,n)=>t.alias?`${W("-"+t.alias,o.param)}${n}, `:"",Xr=(t,o,n)=>t.length?W(`[${t.join(", ")}] `,n?o.required:o.multi):"",Zr=(t,o,n)=>o.showDefaults&&t.default!=null&&t.default!==!1?W(` (default: ${lo(!0)(t.defaultHint!=null?t.defaultHint:t.default)})`,n.default):"";var br=Y(()=>"parse error"),tn=(t,o,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return Kr(t,o,n)}catch(r){if(n.showUsage)console.log(W(r.message,d(n.usageOpts?.color).error)+`
9
+ `)},zr=(t,o,n,r,m)=>{let f=Pr(o,r),E=jr(o,r,f),G=W(`--${rt(t)}`,r.param),N=`${E}${G}${f}`,O=o.optional===!1&&o.default===void 0,h=[];O&&h.push("required"),o.multi&&h.push("multiple");let e=Xr(h,r,O)+(o.desc||"")+Zr(o,n,r);return bt(N,n.paramWidth)+pt(e,m,n.lineWidth)},Pr=(t,o)=>t.hint?W(" "+t.hint,o.hint):"",jr=(t,o,n)=>t.alias?`${W("-"+t.alias,o.param)}${n}, `:"",Xr=(t,o,n)=>t.length?W(`[${t.join(", ")}] `,n?o.required:o.multi):"",Zr=(t,o,n)=>o.showDefaults&&t.default!=null&&t.default!==!1?W(` (default: ${lo(!0)(t.defaultHint!=null?t.defaultHint:t.default)})`,n.default):"";var br=Y(()=>"parse error"),tn=(t,o,n)=>{n={start:2,showUsage:!0,help:["--help","-h"],...n};try{return Kr(t,o,n)}catch(r){if(n.showUsage)console.log(W(r.message,d(n.usageOpts?.color).error)+`
10
10
 
11
- `+wt(t,n.usageOpts));throw new br(r.message)}},Kr=(t,o,n)=>{let r=pr(t),m={},f,E,G=n.start;for(;G<o.length;){let N=o[G];if(!f){if(n.help.includes(N)){console.log(wt(t,n.usageOpts));return}let O=Vr(t,r,m,N);if(f=O.id,E=O.spec,G=G+~~(O.state<2),O.state)break}else{if(qr(E,m,f,N))break;f=null,G++}}return f&&L(`missing value for: --${rt(f)}`),{result:Qr(t,m),index:G,rest:o.slice(G),done:G>=o.length}},pr=(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=vo(r.substring(2))}else m=o[r.substring(1)],!m&&L(`unknown option: ${r}`);let f=t[m];if(!f&&L(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}},qr=(t,o,n,r)=>{if(t.multi)u(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)L(`missing arg: --${rt(r)}`)}else if(n.coerce)kr(n,o,r);return o},kr=(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 --${rt(n)}: ${r.message}`)}};var rn=async(t)=>{let o=t.argv||process.argv,n=!process.env.NO_COLOR,r=d(n),m={prefix:"",color:n,...t.usage};try{let f,E,G=t.start??2;if(t.single){if(f=Object.keys(t.commands)[0],!f)L("no command provided");E=t.commands[f]}else{if(f=o[G],E=t.commands[f],!E)m.prefix+=vr(t.commands,m),on(t,m);G++}let N;try{N=tn({...t.opts,...E.opts},o,{usageOpts:m,start:G})}catch(e){process.exit(1)}if(!N)process.exit(0);if(E.inputs!==void 0&&E.inputs!==N.rest.length)nn(`expected ${E.inputs||0} input(s)`,r),on(t,m);let O=await t.ctx({logger:new zt(process.stderr,t.name,"INFO"),format:n?jt:Qo,opts:N.result,inputs:N.rest},E);if(await E.fn(O),t.post)await t.post(O,E)}catch(f){nn(f.message,r),process.exit(1)}},on=(t,o)=>{process.stderr.write(wt(t.opts,o)),process.exit(1)},vr=(t,{color:o,lineWidth:n=80}={})=>{let r=Object.keys(t),m=Math.max(...r.map((E)=>E.length)),f=d(o);return[`
11
+ `+wt(t,n.usageOpts));throw new br(r.message)}},Kr=(t,o,n)=>{let r=pr(t),m={},f,E,G=n.start;for(;G<o.length;){let N=o[G];if(!f){if(n.help.includes(N)){console.log(wt(t,n.usageOpts));return}let O=Vr(t,r,m,N);if(f=O.id,E=O.spec,G=G+~~(O.state<2),O.state)break}else{if(qr(E,m,f,N))break;f=null,G++}}return f&&L(`missing value for: --${rt(f)}`),{result:Qr(t,m),index:G,rest:o.slice(G),done:G>=o.length}},pr=(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=vo(r.substring(2))}else m=o[r.substring(1)],!m&&L(`unknown option: ${r}`);let f=t[m];if(!f&&L(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}},qr=(t,o,n,r)=>{if(t.multi)A(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)L(`missing arg: --${rt(r)}`)}else if(n.coerce)kr(n,o,r);return o},kr=(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 --${rt(n)}: ${r.message}`)}};var rn=async(t)=>{let o=t.argv||process.argv,n=!process.env.NO_COLOR,r=d(n),m={prefix:"",color:n,...t.usage};try{let f,E,G=t.start??2;if(t.single){if(f=Object.keys(t.commands)[0],!f)L("no command provided");E=t.commands[f]}else{if(f=o[G],E=t.commands[f],!E)m.prefix+=vr(t.commands,m),on(t,m);G++}let N;try{N=tn({...t.opts,...E.opts},o,{usageOpts:m,start:G})}catch(h){process.exit(1)}if(!N)process.exit(0);if(E.inputs!==void 0){let h=N.rest.length,e;if(A(E.inputs)){let[C,_]=E.inputs;if(h<C||h>_)e=_<1/0?`expected ${C}-${_} inputs`:`expected at least ${C} inputs`}else if(h!==E.inputs)e=`expected ${E.inputs} input(s)`;if(e)nn(e,r),on(t,m)}let O=await t.ctx({logger:new zt(process.stderr,t.name,"INFO"),format:n?jt:Qo,opts:N.result,inputs:N.rest},E);if(await E.fn(O),t.post)await t.post(O,E)}catch(f){nn(f.message,r),process.exit(1)}},on=(t,o)=>{process.stderr.write(wt(t.opts,o)),process.exit(1)},vr=(t,{color:o,lineWidth:n=80}={})=>{let r=Object.keys(t),m=Math.max(...r.map((E)=>E.length)),f=d(o);return[`
12
12
  Available commands:
13
13
  `,...r.map((E)=>`${bt(W(E,f.command),m)} : ${pt(t[E].desc,m+3,n)}`),`
14
14
  `].join(`
@@ -20,16 +20,16 @@ Available commands:
20
20
  \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${t} v${o}
21
21
  \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2588 \u2502 ${n}
22
22
  \u2588 \u2502
23
- \u2588 \u2588 \u2502`;var A=(t)=>typeof t==="string";var lr=[[process.env.HOME?new RegExp(process.env.HOME,"g"):/~/,"~"]];var Vt=(t)=>{for(let[o,n]of lr)t=t.replace(o,n);return t};import{existsSync as dr,mkdirSync as gr,statSync as yE}from"fs";import{dirname as xr}from"path";var ar=(t)=>t.length>0&&!dr(t)?(gr(t,{recursive:!0}),!0):!1,fn=(t)=>ar(xr(t));var X=(t)=>typeof t==="function";import{readFileSync as tm}from"fs";import{writeFileSync as sr}from"fs";var En=(t,o,n,r,m=!1)=>cr(sr,t,o,n,r,m);var cr=(t,o,n,r,m,f=!1)=>{if(m?.info(`${f?"[dryrun] ":""}writing file: ${Vt(o)}`),f)return;return fn(o),t(o,n,!r&&A(n)?"utf-8":r)};var F=(t,o,n="utf-8")=>{return o?.debug("reading file:",Vt(t)),tm(t,n)};var _o=(t,o,n,r=!1)=>En(t,u(o)?o.join(`
24
- `):o,"utf-8",n,r);var Z=(t,o)=>JSON.parse(F(t,o));var K=Symbol(),io=()=>{};var Ft=Object.freeze({level:$.NONE,addChild(t){return t},childLogger:()=>Ft,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},none(){},logEntry(){}});class Bo extends Tt{set(t){this.parent=t}childLogger(t,o){return new Bo(t,o??this.level,this)}logEntry(t){this.parent.logEntry(t)}}var Gn=new Bo("root",$.FINE,Ft);import{join as km}from"path";var Ao=(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 om=Y(()=>"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 om(typeof o==="function"?o():o)}:()=>{};var Qt=(t)=>t!=null&&typeof t!=="function"&&t.length!==void 0;var Nn=(t)=>{return(t==null||!t[Symbol.iterator])&&L(`value is not iterable: ${t}`),t};var On=(t)=>Qt(t)?t:[...Nn(t)];var St=(t)=>t[t.length-1];var kt=(t,o)=>typeof t?.[o]==="function";var T=(t)=>typeof t?.[Symbol.iterator]==="function";var vt=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";var nm=Y(()=>"illegal arity"),ft=(t)=>{throw new nm(t)};var rm=Y(()=>"illegal state"),Et=(t)=>{throw new rm(t)};var en=["-moz-","-ms-","-o-","-webkit-"],Gt={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},lt={rules:`
23
+ \u2588 \u2588 \u2502`;var $=(t)=>typeof t==="string";var lr=[[process.env.HOME?new RegExp(process.env.HOME,"g"):/~/,"~"]];var Vt=(t)=>{for(let[o,n]of lr)t=t.replace(o,n);return t};import{existsSync as dr,mkdirSync as gr,statSync as ME}from"fs";import{dirname as xr}from"path";var ar=(t)=>t.length>0&&!dr(t)?(gr(t,{recursive:!0}),!0):!1,fn=(t)=>ar(xr(t));var X=(t)=>typeof t==="function";import{readFileSync as tm}from"fs";import{writeFileSync as sr}from"fs";var En=(t,o,n,r,m=!1)=>cr(sr,t,o,n,r,m);var cr=(t,o,n,r,m,f=!1)=>{if(m?.info(`${f?"[dryrun] ":""}writing file: ${Vt(o)}`),f)return;return fn(o),t(o,n,!r&&$(n)?"utf-8":r)};var F=(t,o,n="utf-8")=>{return o?.debug("reading file:",Vt(t)),tm(t,n)};var _o=(t,o,n,r=!1)=>En(t,A(o)?o.join(`
24
+ `):o,"utf-8",n,r);var Z=(t,o)=>JSON.parse(F(t,o));var K=Symbol(),io=()=>{};var Ft=Object.freeze({level:T.NONE,addChild(t){return t},childLogger:()=>Ft,enabled:()=>!1,fine(){},debug(){},info(){},warn(){},severe(){},none(){},logEntry(){}});class Bo extends ut{set(t){this.parent=t}childLogger(t,o){return new Bo(t,o??this.level,this)}logEntry(t){this.parent.logEntry(t)}}var Gn=new Bo("root",T.FINE,Ft);import{join as km}from"path";var Ao=(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 om=Y(()=>"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 om(typeof o==="function"?o():o)}:()=>{};var Qt=(t)=>t!=null&&typeof t!=="function"&&t.length!==void 0;var Nn=(t)=>{return(t==null||!t[Symbol.iterator])&&L(`value is not iterable: ${t}`),t};var On=(t)=>Qt(t)?t:[...Nn(t)];var St=(t)=>t[t.length-1];var kt=(t,o)=>typeof t?.[o]==="function";var u=(t)=>typeof t?.[Symbol.iterator]==="function";var vt=(t)=>t!=null&&typeof t!=="string"&&typeof t[Symbol.iterator]==="function";var nm=Y(()=>"illegal arity"),ft=(t)=>{throw new nm(t)};var rm=Y(()=>"illegal state"),Et=(t)=>{throw new rm(t)};var hn=["-moz-","-ms-","-o-","-webkit-"],Gt={rules:"",ruleSep:",",valSep:"",decls:"",declStart:"{",declEnd:"}",indent:"",comments:!1},lt={rules:`
25
25
  `,ruleSep:", ",valSep:" ",decls:`
26
26
  `,declStart:` {
27
27
  `,declEnd:`}
28
- `,indent:" ",comments:!0};function $o(...t){let[o,n,r,m,f,E,G,N,O,e]=t;switch(t.length){case 0:ft(0);case 1:return o;case 2:return(...h)=>o(n(...h));case 3:return(...h)=>o(n(r(...h)));case 4:return(...h)=>o(n(r(m(...h))));case 5:return(...h)=>o(n(r(m(f(...h)))));case 6:return(...h)=>o(n(r(m(f(E(...h))))));case 7:return(...h)=>o(n(r(m(f(E(G(...h)))))));case 8:return(...h)=>o(n(r(m(f(E(G(N(...h))))))));case 9:return(...h)=>o(n(r(m(f(E(G(N(O(...h)))))))));case 10:default:let C=(...h)=>o(n(r(m(f(E(G(N(O(e(...h))))))))));return t.length===10?C:$o(C,...t.slice(10))}}var g=(t)=>kt(t,"xform")?t.xform():t;function z(...t){return t=t.map(g),$o.apply(null,t)}var p=(t,o)=>[t[0],t[1],o];class Ht{value;constructor(t){this.value=t}deref(){return this.value}}var S=(t)=>t instanceof Ht,hn=(t)=>t instanceof Ht?t:new Ht(t),P=(t)=>t instanceof Ht?t.deref():t;var mm=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:ft(t.length);function Nt(...t){let o=t[0],n=o[0],r=o[1],m=o[2];t=mm(t);let f=t[0]==null?n():t[0],E=t[1];return P(r(kt(E,"$reduce")?E.$reduce(m,f):Qt(E)?fm(m,f,E):Em(m,f,E)))}var fm=(t,o,n)=>{for(let r=0,m=n.length;r<m;r++)if(o=t(o,n[r]),S(o)){o=o.deref();break}return o},Em=(t,o,n)=>{for(let r of n)if(o=t(o,r),S(o)){o=o.deref();break}return o},Ot=(t,o)=>[t,ut,o],Cn=(t,o)=>{let n=o.length-1;return T(o[n])?o.length>1?Nt(t.apply(null,o.slice(0,n)),o[n]):Nt(t(),o[0]):void 0};function et(t){return t?[...t]:Ot(()=>[],(o,n)=>(o.push(n),o))}function*ht(t,o){let n=g(t)(et()),r=n[1],m=n[2];for(let f of o){let E=m([],f);if(S(E)){yield*P(r(E.deref()));return}if(E.length)yield*E}yield*P(r([]))}function*x(t,o){let n=g(t)([io,io,(r,m)=>m])[2];for(let r of o){let m=n(K,r);if(S(m)){if(m=P(m.deref()),m!==K)yield m;return}if(m!==K)yield m}}var dt=(t,o,n=x)=>{let r=o.length-1;return T(o[r])?o.length>1?n(t.apply(null,o.slice(0,r)),o[r]):n(t(),o[0]):void 0};function uo(t,o){return T(o)?ht(uo(t),A(o)?[o]:o):(n)=>{let r=n[2],m=(f,E)=>{let G=t(E);if(G){for(let N of G)if(f=m(f,N),S(f))break;return f}return r(f,E)};return p(n,m)}}function Ln(t){return uo((o)=>vt(o)?o:void 0,t)}function B(t,o){return T(o)?x(B(t),o):(n)=>{let r=n[2];return p(n,(m,f)=>r(m,t(f)))}}function*gt(...t){let o=t.length-1;if(o<0)return;let n=new Array(o+1).fill(0),r=t.map(On),m=r.reduce((f,E)=>f*E.length,1);for(let f=0;f<m;f++){let E=[];for(let G=o;G>=0;G--){let N=r[G],O=n[G];if(O===N.length)n[G]=O=0,G>0&&n[G-1]++;E[G]=N[O]}n[o]++,yield E}}function*_n(t,o=1/0){while(o-- >0)yield t}function To(t,o){t=t||"";let n=!0;return o?[...o].join(t):Ot(()=>"",(r,m)=>(r=n?r+m:r+t+m,n=!1,r))}function xt(...t){return Gm(xt,Nt,t)}var Gm=(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 B((f)=>t(n[0],n[1],f));default:ft(n.length)}return o(g(n[0])(n[1]),r,m)};var Nm=new Set,Om=":[",Bn=z(Ln(),B((t)=>t[0]==="&"?t.substring(1):Om.includes(t[0])?t:" "+t)),em=(t,o)=>z(t,B((n)=>A(n)&&n.startsWith(" .")?n+o:n)),Ct=(t,o,n,r)=>{let m=n.length,f=[],E,G,N=(O,e)=>{let C=null;if(u(e))Ct(t,wo(o,f),e,r);else if(T(e)&&!A(e))Ct(t,wo(o,f),[...e],r);else if((G=X(e))||(C=r.fns[e]))if(!o.length){if(C)return C.apply(null,n.slice(O+1))(t,r),!0;e(t,r)}else if(G)N(O,e());else L(`quoted fn ('${e}') only allowed at head position`);else if(J(e))E=Object.assign(E||{},e);else if(e!=null)f.push(e)};for(let O=0;O<m;O++)if(N(O,n[O]))return t;return E&&t.push(hm(o,f,E,r)),t},wo=(t,o)=>t.length?[...gt(t,o)]:o,hm=(t,o,n,r)=>{let m=r.format,f=j(r),E=r.scope?em(Bn,r.scope):Bn;return[f,xt(B((G)=>xt(E,To(),u(G)?G:[G]).trim()),To(m.ruleSep),wo(t,o)),m.declStart,yt(n,r),f,m.declEnd].join("")},yt=(t,o)=>{let n=o.format,r=o.autoprefix||Nm,m=j(o,o.depth+1),f=[];for(let E in t)if(t.hasOwnProperty(E)){let G=t[E];if(X(G))G=G(t);if(u(G))G=G.map((N)=>u(N)?N.join(" "):N).join(n.ruleSep);if(r.has(E))for(let N of o.vendors)f.push(`${m}${N}${E}:${n.valSep}${G};`);f.push(`${m}${E}:${n.valSep}${G};`)}return f.join(n.decls)+n.decls},j=(t,o=t.depth)=>o>1?[..._n(t.format.indent,o)].join(""):o>0?t.format.indent:"";function An(t,...o){let n=o.length===1?o[0]:o.reduce((r,m,f)=>{return r[f/(o.length-1)*100|0]=m,r},{});return(r,m)=>{let f=j(m);m.depth++;let E=j(m);r.push(`${f}@keyframes ${t}${m.format.declStart}`);for(let G in n)if(n.hasOwnProperty(G))r.push([E,G+"%",m.format.declStart,yt(n[G],m),E,m.format.declEnd].join(""));return m.depth--,r.push(f+m.format.declEnd),r}}var $n=(t,o=!1)=>(n,r)=>{let m=j(r),f=j(r,r.depth+1);if(r.format.comments||o)n.push(m+"/*",t.split(`
28
+ `,indent:" ",comments:!0};function $o(...t){let[o,n,r,m,f,E,G,N,O,h]=t;switch(t.length){case 0:ft(0);case 1:return o;case 2:return(...C)=>o(n(...C));case 3:return(...C)=>o(n(r(...C)));case 4:return(...C)=>o(n(r(m(...C))));case 5:return(...C)=>o(n(r(m(f(...C)))));case 6:return(...C)=>o(n(r(m(f(E(...C))))));case 7:return(...C)=>o(n(r(m(f(E(G(...C)))))));case 8:return(...C)=>o(n(r(m(f(E(G(N(...C))))))));case 9:return(...C)=>o(n(r(m(f(E(G(N(O(...C)))))))));case 10:default:let e=(...C)=>o(n(r(m(f(E(G(N(O(h(...C))))))))));return t.length===10?e:$o(e,...t.slice(10))}}var g=(t)=>kt(t,"xform")?t.xform():t;function z(...t){return t=t.map(g),$o.apply(null,t)}var p=(t,o)=>[t[0],t[1],o];class Ht{value;constructor(t){this.value=t}deref(){return this.value}}var S=(t)=>t instanceof Ht,en=(t)=>t instanceof Ht?t:new Ht(t),P=(t)=>t instanceof Ht?t.deref():t;var mm=(t)=>t.length===2?[void 0,t[1]]:t.length===3?[t[1],t[2]]:ft(t.length);function Nt(...t){let o=t[0],n=o[0],r=o[1],m=o[2];t=mm(t);let f=t[0]==null?n():t[0],E=t[1];return P(r(kt(E,"$reduce")?E.$reduce(m,f):Qt(E)?fm(m,f,E):Em(m,f,E)))}var fm=(t,o,n)=>{for(let r=0,m=n.length;r<m;r++)if(o=t(o,n[r]),S(o)){o=o.deref();break}return o},Em=(t,o,n)=>{for(let r of n)if(o=t(o,r),S(o)){o=o.deref();break}return o},Ot=(t,o)=>[t,Tt,o],Cn=(t,o)=>{let n=o.length-1;return u(o[n])?o.length>1?Nt(t.apply(null,o.slice(0,n)),o[n]):Nt(t(),o[0]):void 0};function ht(t){return t?[...t]:Ot(()=>[],(o,n)=>(o.push(n),o))}function*et(t,o){let n=g(t)(ht()),r=n[1],m=n[2];for(let f of o){let E=m([],f);if(S(E)){yield*P(r(E.deref()));return}if(E.length)yield*E}yield*P(r([]))}function*x(t,o){let n=g(t)([io,io,(r,m)=>m])[2];for(let r of o){let m=n(K,r);if(S(m)){if(m=P(m.deref()),m!==K)yield m;return}if(m!==K)yield m}}var dt=(t,o,n=x)=>{let r=o.length-1;return u(o[r])?o.length>1?n(t.apply(null,o.slice(0,r)),o[r]):n(t(),o[0]):void 0};function To(t,o){return u(o)?et(To(t),$(o)?[o]:o):(n)=>{let r=n[2],m=(f,E)=>{let G=t(E);if(G){for(let N of G)if(f=m(f,N),S(f))break;return f}return r(f,E)};return p(n,m)}}function Ln(t){return To((o)=>vt(o)?o:void 0,t)}function B(t,o){return u(o)?x(B(t),o):(n)=>{let r=n[2];return p(n,(m,f)=>r(m,t(f)))}}function*gt(...t){let o=t.length-1;if(o<0)return;let n=new Array(o+1).fill(0),r=t.map(On),m=r.reduce((f,E)=>f*E.length,1);for(let f=0;f<m;f++){let E=[];for(let G=o;G>=0;G--){let N=r[G],O=n[G];if(O===N.length)n[G]=O=0,G>0&&n[G-1]++;E[G]=N[O]}n[o]++,yield E}}function*_n(t,o=1/0){while(o-- >0)yield t}function uo(t,o){t=t||"";let n=!0;return o?[...o].join(t):Ot(()=>"",(r,m)=>(r=n?r+m:r+t+m,n=!1,r))}function xt(...t){return Gm(xt,Nt,t)}var Gm=(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 B((f)=>t(n[0],n[1],f));default:ft(n.length)}return o(g(n[0])(n[1]),r,m)};var Nm=new Set,Om=":[",Bn=z(Ln(),B((t)=>t[0]==="&"?t.substring(1):Om.includes(t[0])?t:" "+t)),hm=(t,o)=>z(t,B((n)=>$(n)&&n.startsWith(" .")?n+o:n)),Ct=(t,o,n,r)=>{let m=n.length,f=[],E,G,N=(O,h)=>{let e=null;if(A(h))Ct(t,wo(o,f),h,r);else if(u(h)&&!$(h))Ct(t,wo(o,f),[...h],r);else if((G=X(h))||(e=r.fns[h]))if(!o.length){if(e)return e.apply(null,n.slice(O+1))(t,r),!0;h(t,r)}else if(G)N(O,h());else L(`quoted fn ('${h}') only allowed at head position`);else if(J(h))E=Object.assign(E||{},h);else if(h!=null)f.push(h)};for(let O=0;O<m;O++)if(N(O,n[O]))return t;return E&&t.push(em(o,f,E,r)),t},wo=(t,o)=>t.length?[...gt(t,o)]:o,em=(t,o,n,r)=>{let m=r.format,f=j(r),E=r.scope?hm(Bn,r.scope):Bn;return[f,xt(B((G)=>xt(E,uo(),A(G)?G:[G]).trim()),uo(m.ruleSep),wo(t,o)),m.declStart,yt(n,r),f,m.declEnd].join("")},yt=(t,o)=>{let n=o.format,r=o.autoprefix||Nm,m=j(o,o.depth+1),f=[];for(let E in t)if(t.hasOwnProperty(E)){let G=t[E];if(X(G))G=G(t);if(A(G))G=G.map((N)=>A(N)?N.join(" "):N).join(n.ruleSep);if(r.has(E))for(let N of o.vendors)f.push(`${m}${N}${E}:${n.valSep}${G};`);f.push(`${m}${E}:${n.valSep}${G};`)}return f.join(n.decls)+n.decls},j=(t,o=t.depth)=>o>1?[..._n(t.format.indent,o)].join(""):o>0?t.format.indent:"";function An(t,...o){let n=o.length===1?o[0]:o.reduce((r,m,f)=>{return r[f/(o.length-1)*100|0]=m,r},{});return(r,m)=>{let f=j(m);m.depth++;let E=j(m);r.push(`${f}@keyframes ${t}${m.format.declStart}`);for(let G in n)if(n.hasOwnProperty(G))r.push([E,G+"%",m.format.declStart,yt(n[G],m),E,m.format.declEnd].join(""));return m.depth--,r.push(f+m.format.declEnd),r}}var $n=(t,o=!1)=>(n,r)=>{let m=j(r),f=j(r,r.depth+1);if(r.format.comments||o)n.push(m+"/*",t.split(`
29
29
  `).map((E)=>f+E).join(`
30
- `),m+"*/");return n};var at=(t,o,n)=>(r,m)=>{let f=j(m);return r.push(`${f}${t} ${Cm(o)}${m.format.declStart}`),m.depth++,Ct(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},Cm=(t)=>{if(A(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=un.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${un.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},un=new Set(["all","print","screen"]);var a=(t,o)=>{return o={format:Gt,vendors:en,fns:{},depth:0,...o},u(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),J(t)?yt(t,o):X(t)?t([],o).join(o.format.rules):Ct([],[],u(t)?t:vt(t)?[...t]:L("invalid rules"),o).join(o.format.rules)};var Tn=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var Lt=(t,o)=>at("@media",t,o);function wn(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var Fn=(t,o)=>at("@supports",t,o);var st={"@comment":$n,"@import":Tn,"@keyframes":An,"@media":Lt,"@namespace":wn,"@supports":Fn};var Sn=4,Hn=(t)=>Sn=t,M=(t)=>t===(t|0)?String(t):t.toFixed(Sn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var yn=(t)=>`${M(t)}em`,Mn=(t)=>`${M(t)}ex`;var In=(t)=>`${M(t)}rem`,Fo=(t)=>`${M(t)}%`,Rn=(t)=>`${M(t)}px`,Wn=(t)=>`${M(t)}vh`,Un=(t)=>`${M(t)}vw`,Yn=(t)=>`${M(t)}vmin`,Dn=(t)=>`${M(t)}vmax`,Jn=(t)=>`${t|0}ms`,zn=(t)=>`${M(t)}s`;var Pn=(t)=>`${M(t)}deg`,jn=(t)=>`${M(t)}rad`,Xn=(t)=>`${M(t)}turn`,Zn=(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||{});var Lm=0,_m=()=>Lm++,s=(t,o)=>!o||!o.id?{...o,id:t+"-"+_m()}:o;var H=Gn.childLogger("rstream");class V{constructor(t,o){this.wrapped=t,o=s("sub",{closeIn:"last",closeOut:"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(et()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=K;state=w.IDLE;subs=[];deref(){return this.last!==K?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof V&&!o.xform)t.ensureState(),qt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new V(t,{...o,parent:this});return this.subs.push(n),this.setState(w.ACTIVE),n.setState(w.ACTIVE),this.last!=K&&n.next(this.last),n}transform(...t){let o,n;if(J(St(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,s("xform",t.length>0?{...n,xform:z(...t)}:n))}map(t,o){return this.transform(B(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return H.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<w.UNSUBSCRIBED&&(this.state=w.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){H.debug(this.id,"unsub child",t.id);let o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="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(H.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();H.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&H.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(H.parent!==Ft?H: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}let 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){H.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))S(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){let o=P(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)Et(`operation not allowed in state ${w[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var bn=(t,o)=>{let n=new Kn(o);return n.next(t),n};class Kn extends V{src;_cancel;_inited;constructor(t,o){let[n,r]=X(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,s("stream",r));this.src=n,this._inited=!1}subscribe(t,o={}){let 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){let o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!=="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){H.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var pn=(t,o)=>t==="first"||t==="last"&&!o;function So(t){return t?Nt(So(),t):Ot(()=>({}),(o,[n,r])=>(o[n]=r,o))}var Vn=()=>(t)=>{let o=t[2];return p(t,(n,r)=>{if(r){for(let m of P(r)||[])if(n=o(n,m),S(n))break}return S(r)?hn(n):n})};function Ho(t,o){return T(o)?ht(Ho(t),o):z(B(t),Vn())}function yo(t,o){return T(o)?x(yo(t),o):B(X(t)?(n)=>[t(n),n]:(n)=>[t,n])}function Mo(...t){let o=dt(Mo,t);if(o)return o;let n=t[0],r=t[1]!==!1;return B((m)=>{let f=r?{}:m;for(let E in m)f[E]=n(m[E]);return f})}var qn=(t)=>t;function Io(...t){let o=dt(Io,t,ht);if(o)return o;let{key:n=qn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:E=0}=t[1],G=u(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,e={},C=([h,_,I])=>{let v=!0;if(r||E<1)return[h,(i)=>{if(m&&f&&N.size>0||!m&&v)i=I(i,e),e={},N.clear(),v=!1;return _(i)},(i,l)=>{let y=n(l);if(G.has(y)){if(e[y]=l,N.add(y),r||Qn(G,N))if(i=I(i,e),v=!1,m)e={},N.clear();else e={...e}}return i}];else return[h,(i)=>{if(f&&N.size>0)i=I(i,kn(O,N)),O.clear(),N.clear();return _(i)},(i,l)=>{let y=n(l);if(G.has(y)){let b=O.get(y);!b&&O.set(y,b=[]),b.length>=E&&Et(`max back pressure (${E}) exceeded for input: ${String(y)}`),b.push(l),N.add(y);while(Qn(G,N))if(i=I(i,kn(O,N)),v=!1,S(i))break}return i}]};return C.keys=()=>G,C.clear=()=>{O.clear(),G.clear(),N.clear(),e={}},C.add=(h)=>{G.add(h)},C.delete=(h,_=!0)=>{if(O.delete(h),G.delete(h),_)N.delete(h),delete e[h]},C}var Qn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},kn=(t,o)=>{let n={};for(let r of o){let m=t.get(r);n[r]=m.shift(),!m.length&&o.delete(r)}return n};var vn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var ct=(t)=>new ln(t);class ln extends V{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Io(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=Mo((r)=>r[1]);super(void 0,s("streamsync",{...t,xform:t.xform?z(o,n,t.xform):z(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 V?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:yo(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){let o=this.sources.get(t);if(o){let n=this.invRealSourceIDs.get(t.id);return H.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){let 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 vn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){let t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){H.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),pn(this.closeIn,this.sources.size)&&this.done()}}var Ro=U((t,o=" ")=>{let n=nt(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}}),G1=Ro(2,"0"),N1=Ro(3,"0"),dn=Ro(4,"0");var im=/\{(\d+)\}/g;var Wo=(t,...o)=>o.length>0?t.replace(im,(n,r)=>String(o[parseInt(r,10)])):t;var gn=(t)=>({key:(o)=>o,group:et(),...t});function Uo(...t){let o=Cn(Uo,t);if(o)return o;let n=gn(t[0]),[r,m,f]=n.group;return[()=>({}),(E)=>{for(let G in E)E[G]=m(E[G]);return E},(E,G)=>{let N=n.key(G);return E[N]=E[N]?f(E[N],G):f(r(),G),E}]}function Yo(t,o){return T(o)?x(Yo(t),o):(n)=>{let r=n[2];return p(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as tr}from"fs";import{resolve as c}from"path";var xn={specs:D({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},to={bundle:R({alias:"b",desc:"Bundle inputs (see `out` option)"})},_t={include:Dt({alias:"I",desc:"Include CSS files (prepend)"})},oo={eval:D({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},no={force:Dt({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},an={media:Dt({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},sn={onlyDecls:R({desc:"Only emit framework decls"})},q={out:D({alias:"o",desc:"Output file (or stdout)"})},ro={prec:Jt({default:3,desc:"Number of fractional digits"})},Q={pretty:R({alias:"p",desc:"Pretty print output"})},it={noDecls:R({alias:"d",desc:"Don't emit framework decls"})},Bt={noHeader:R({desc:"Don't emit generated header comment"})},At={scope:D({desc:"Suffix for CSS class names"})},$t={watch:R({alias:"w",desc:"Watch input files for changes"})};import{watch as Bm}from"fs";import{resolve as cn}from"path";var k=(t,o,n)=>{o=A(o)?o:o.join(`
30
+ `),m+"*/");return n};var at=(t,o,n)=>(r,m)=>{let f=j(m);return r.push(`${f}${t} ${Cm(o)}${m.format.declStart}`),m.depth++,Ct(r,[],n,m),m.depth--,r.push(f+m.format.declEnd),r},Cm=(t)=>{if($(t))return t;let o=[];for(let n in t)if(t.hasOwnProperty(n)){let r=t[n];if(r===!0)r=Tn.has(n)?n:`(${n})`;else if(r===!1)r=`(not ${Tn.has(n)?n:`(${n})`})`;else if(r==="only")r+=" "+n;else r=`(${n}:${r})`;o.push(r)}return o.join(" and ")},Tn=new Set(["all","print","screen"]);var a=(t,o)=>{return o={format:Gt,vendors:hn,fns:{},depth:0,...o},A(o.autoprefix)&&(o.autoprefix=new Set(o.autoprefix)),J(t)?yt(t,o):X(t)?t([],o).join(o.format.rules):Ct([],[],A(t)?t:vt(t)?[...t]:L("invalid rules"),o).join(o.format.rules)};var un=(t,...o)=>(n,r)=>(n.push(o.length?`@import url(${t}) ${o.join(r.format.ruleSep)};`:`@import url(${t});`),n);var Lt=(t,o)=>at("@media",t,o);function wn(...t){return(o,n)=>(o.push(t.length>1?`@namespace ${t[0]} url(${t[1]});`:`@namespace url(${t[0]});`),o)}var Fn=(t,o)=>at("@supports",t,o);var st={"@comment":$n,"@import":un,"@keyframes":An,"@media":Lt,"@namespace":wn,"@supports":Fn};var Sn=4,Hn=(t)=>Sn=t,M=(t)=>t===(t|0)?String(t):t.toFixed(Sn).replace(/^0./,".").replace(/^-0./,"-.").replace(/0+$/,"");var yn=(t)=>`${M(t)}em`,Mn=(t)=>`${M(t)}ex`;var In=(t)=>`${M(t)}rem`,Fo=(t)=>`${M(t)}%`,Rn=(t)=>`${M(t)}px`,Wn=(t)=>`${M(t)}vh`,Un=(t)=>`${M(t)}vw`,Yn=(t)=>`${M(t)}vmin`,Dn=(t)=>`${M(t)}vmax`,Jn=(t)=>`${t|0}ms`,zn=(t)=>`${M(t)}s`;var Pn=(t)=>`${M(t)}deg`,jn=(t)=>`${M(t)}rad`,Xn=(t)=>`${M(t)}turn`,Zn=(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||{});var Lm=0,_m=()=>Lm++,s=(t,o)=>!o||!o.id?{...o,id:t+"-"+_m()}:o;var H=Gn.childLogger("rstream");class V{constructor(t,o){this.wrapped=t,o=s("sub",{closeIn:"last",closeOut:"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(ht()))}id;closeIn;closeOut;parent;__owner;xform;cacheLast;last=K;state=w.IDLE;subs=[];deref(){return this.last!==K?this.last:void 0}getState(){return this.state}setState(t){this.state=t}subscribe(t,o={}){this.ensureState();let n;if(t instanceof V&&!o.xform)t.ensureState(),qt(!t.parent,`sub '${t.id}' already has a parent`),t.parent=this,n=t;else n=new V(t,{...o,parent:this});return this.subs.push(n),this.setState(w.ACTIVE),n.setState(w.ACTIVE),this.last!=K&&n.next(this.last),n}transform(...t){let o,n;if(J(St(t)))n=t.pop(),o={error:n.error};return this.subscribe(o,s("xform",t.length>0?{...n,xform:z(...t)}:n))}map(t,o){return this.transform(B(t),o||{})}unsubscribe(t){return t?this.unsubscribeChild(t):this.unsubscribeSelf()}unsubscribeSelf(){return H.debug(this.id,"unsub self"),this.parent?.unsubscribe(this),this.state<w.UNSUBSCRIBED&&(this.state=w.UNSUBSCRIBED),this.release(),!0}unsubscribeChild(t){H.debug(this.id,"unsub child",t.id);let o=this.subs.indexOf(t);if(o>=0){if(this.subs.splice(o,1),this.closeOut==="first"||!this.subs.length&&this.closeOut!=="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(H.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();H.debug(this.id,"exiting done()")}error(t){let n=this.wrapped?.error;return n&&H.debug(this.id,"attempting wrapped error handler"),n?.(t)||this.unhandledError(t)}unhandledError(t){return(H.parent!==Ft?H: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}let 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){H.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))S(o)&&this.done()}dispatchXformDone(){let t;try{t=this.xform[1]([])}catch(o){return this.error(o)}return this.dispatchXformVals(t)}dispatchXformVals(t){let o=P(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)Et(`operation not allowed in state ${w[this.state]}`)}release(){this.subs.length=0,delete this.parent,delete this.xform,delete this.last}}var bn=(t,o)=>{let n=new Kn(o);return n.next(t),n};class Kn extends V{src;_cancel;_inited;constructor(t,o){let[n,r]=X(t)?[t,o||{}]:[void 0,t||{}];super(r.error?{error:r.error}:void 0,s("stream",r));this.src=n,this._inited=!1}subscribe(t,o={}){let 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){let o=super.unsubscribe(t);if(o&&(!t||(!this.subs||!this.subs.length)&&this.closeOut!=="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){H.debug(this.id,"cancel");let t=this._cancel;delete this._cancel,t()}}}var pn=(t,o)=>t==="first"||t==="last"&&!o;function So(t){return t?Nt(So(),t):Ot(()=>({}),(o,[n,r])=>(o[n]=r,o))}var Vn=()=>(t)=>{let o=t[2];return p(t,(n,r)=>{if(r){for(let m of P(r)||[])if(n=o(n,m),S(n))break}return S(r)?en(n):n})};function Ho(t,o){return u(o)?et(Ho(t),o):z(B(t),Vn())}function yo(t,o){return u(o)?x(yo(t),o):B(X(t)?(n)=>[t(n),n]:(n)=>[t,n])}function Mo(...t){let o=dt(Mo,t);if(o)return o;let n=t[0],r=t[1]!==!1;return B((m)=>{let f=r?{}:m;for(let E in m)f[E]=n(m[E]);return f})}var qn=(t)=>t;function Io(...t){let o=dt(Io,t,et);if(o)return o;let{key:n=qn,mergeOnly:r=!1,reset:m=!0,all:f=!0,backPressure:E=0}=t[1],G=A(t[0])?new Set(t[0]):t[0],N=new Set,O=new Map,h={},e=([C,_,I])=>{let v=!0;if(r||E<1)return[C,(i)=>{if(m&&f&&N.size>0||!m&&v)i=I(i,h),h={},N.clear(),v=!1;return _(i)},(i,l)=>{let y=n(l);if(G.has(y)){if(h[y]=l,N.add(y),r||Qn(G,N))if(i=I(i,h),v=!1,m)h={},N.clear();else h={...h}}return i}];else return[C,(i)=>{if(f&&N.size>0)i=I(i,kn(O,N)),O.clear(),N.clear();return _(i)},(i,l)=>{let y=n(l);if(G.has(y)){let b=O.get(y);!b&&O.set(y,b=[]),b.length>=E&&Et(`max back pressure (${E}) exceeded for input: ${String(y)}`),b.push(l),N.add(y);while(Qn(G,N))if(i=I(i,kn(O,N)),v=!1,S(i))break}return i}]};return e.keys=()=>G,e.clear=()=>{O.clear(),G.clear(),N.clear(),h={}},e.add=(C)=>{G.add(C)},e.delete=(C,_=!0)=>{if(O.delete(C),G.delete(C),_)N.delete(C),delete h[C]},e}var Qn=(t,o)=>{if(o.size<t.size)return!1;for(let n of t)if(!o.has(n))return!1;return!0},kn=(t,o)=>{let n={};for(let r of o){let m=t.get(r);n[r]=m.shift(),!m.length&&o.delete(r)}return n};var vn=(t,o)=>{let n=!0;for(let r of o)n=t.removeID(r)&&n;return n};var ct=(t)=>new ln(t);class ln extends V{sources;idSources;realSourceIDs;invRealSourceIDs;psync;clean;constructor(t){let o=Io(new Set,{key:(r)=>r[0],mergeOnly:t.mergeOnly===!0,reset:t.reset===!0,all:t.all!==!1,backPressure:t.backPressure||0}),n=Mo((r)=>r[1]);super(void 0,s("streamsync",{...t,xform:t.xform?z(o,n,t.xform):z(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 V?this.add(n[1]):this.next(n),done:()=>this.markDone(t),__owner:this},{xform:yo(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){let o=this.sources.get(t);if(o){let n=this.invRealSourceIDs.get(t.id);return H.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){let 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 vn(this,t)}getSourceForID(t){return this.idSources.get(this.realSourceIDs.get(t))}getSources(){let t={};for(let[o,n]of this.idSources)t[this.invRealSourceIDs.get(o)]=n;return t}unsubscribe(t){if(!t){H.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),pn(this.closeIn,this.sources.size)&&this.done()}}var Ro=U((t,o=" ")=>{let n=nt(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}}),N1=Ro(2,"0"),O1=Ro(3,"0"),dn=Ro(4,"0");var im=/\{(\d+)\}/g;var Wo=(t,...o)=>o.length>0?t.replace(im,(n,r)=>String(o[parseInt(r,10)])):t;var gn=(t)=>({key:(o)=>o,group:ht(),...t});function Uo(...t){let o=Cn(Uo,t);if(o)return o;let n=gn(t[0]),[r,m,f]=n.group;return[()=>({}),(E)=>{for(let G in E)E[G]=m(E[G]);return E},(E,G)=>{let N=n.key(G);return E[N]=E[N]?f(E[N],G):f(r(),G),E}]}function Yo(t,o){return u(o)?x(Yo(t),o):(n)=>{let r=n[2];return p(n,(m,f)=>t(f)?r(m,f):m)}}import{watch as tr}from"fs";import{resolve as c}from"path";var xn={specs:D({alias:"s",optional:!1,desc:"Path to generated JSON defs"})},to={bundle:R({alias:"b",desc:"Bundle inputs (see `out` option)"})},_t={include:Dt({alias:"I",desc:"Include CSS files (prepend)"})},oo={eval:D({alias:"e",desc:"eval meta stylesheet in given string (ignores other inputs & includes)"})},no={force:Dt({alias:"f",hint:"STR",desc:"CSS classes to force include (wildcards are supported, @-prefix will read from file)",delim:","})},an={media:Dt({alias:"m",hint:"ID",desc:"Media query IDs (use 'ALL' for all)",delim:","})},sn={onlyDecls:R({desc:"Only emit framework decls"})},q={out:D({alias:"o",desc:"Output file (or stdout)"})},ro={prec:Jt({default:3,desc:"Number of fractional digits"})},Q={pretty:R({alias:"p",desc:"Pretty print output"})},it={noDecls:R({alias:"d",desc:"Don't emit framework decls"})},Bt={noHeader:R({desc:"Don't emit generated header comment"})},At={scope:D({desc:"Suffix for CSS class names"})},$t={watch:R({alias:"w",desc:"Watch input files for changes"})};import{watch as Bm}from"fs";import{resolve as cn}from"path";var k=(t,o,n)=>{o=$(o)?o:o.join(`
31
31
  `),t?_o(cn(t),o,n):process.stdout.write(o+`
32
- `)},mo=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,Mt=(t,o)=>{let n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=cn(m);let E=bn(F(m,o),{id:`in${dn(f)}`});return{input:E,watcher:Bm(m,{},(G)=>{if(G==="change")try{E.next(F(m,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),ct({src:So(B(({input:m})=>[m.id,m],r))})},fo=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var nr={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...to,...oo,...no,..._t,...it,...Bt,...q,...Q,...At,...xn,...$t,noWrite:R({desc:"Don't write files, use stdout only"})},fn:Do};async function Do(t){let o=Z(c(t.opts.specs),t.logger),n=wm(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await $m(t,n);else Rt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>F(c(r),t.logger)),t.opts.out);else if(t.opts.watch)await Am(t,o,n);else if(t.opts.eval)try{Rt(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=c(r);let m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;Rt(t,o,n,[F(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}var Am=async(t,o,n)=>{let r=c(t.opts.specs),m,f={process:()=>{try{return o=Z(r,t.logger),m.forEach((G)=>G.process()),!0}catch(G){return t.logger.warn(G.message+": "+r),!1}},watcher:tr(r,{},(G)=>{if(G==="change")f.process();else t.logger.warn("specs file removed:",r),E()})},E=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((G)=>G.watcher.close())};m=t.inputs.map((G)=>{G=c(G);let N=!t.opts.noWrite?G.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return Rt(t,o,n,[F(G,t.logger)],N),!0}catch(e){if(t.logger.warn(e.message+": "+G),m)E();return!1}};if(!O())process.exit(1);return{process:O,watcher:tr(G,{},(e)=>{if(e==="change")O();else t.logger.warn("input removed:",G),E()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",E)},$m=async(t,o)=>{ct({src:{styles:Mt(t.inputs,t.logger),specs:Mt([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{Rt(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},Rt=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},E,G,N,O)=>{let e={logger:t,specs:E,css:{format:m?lt:Gt,fns:st,scope:f},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},C=o?o.map((h)=>F(c(h),t).trim()):[];if(!r)C.push(mo(E));if(!n&&E.decls.length)C.push(a(E.decls,e.css));N.forEach((h)=>Fm(h,e)),Tm(C,e),um(C,e),k(O,C,t)},um=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let E=mr(r[f],m);n.debug("mediaquery rules",f,E),t.push(a(Lt(Mm(m.media,f),E),o))}},Tm=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=mr(r,m);n.debug("plain rules",f),t.push(a(f,o))},wm=(t,o,n)=>{let r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},E={};if(o.length&&o[0][0]==="@")o=[...mt(F(c(o[0].substring(1)),n))];for(let G of o){if(!G||G.startsWith("//"))continue;let{token:N,query:O}=fr(G,r),e;if(N.includes("*")){let C=new RegExp(`^${N.replace("*",".*")}$`);e=[...Yo((h)=>C.test(h),m)]}else if(m.has(N))e=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let C of e)n.debug("including class:",C),O?Er(f,O,`.${C}`,C):Gr(E,`.${C}`,C)}return{mediaQueryRules:f,plainRules:E}},Fm=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=Wt(),E=Wt(f),G={root:f,curr:E,scopes:[E]};for(let N of mt(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of Sm(N)){if(!O)continue;let e=G.curr;switch(e.state){case"sel":case"nest":if(O==="{"){if(e.state==="sel")e.sel=e.sel.map((C)=>C.replace(",","")),e.path=Hm(G.scopes);e.state="class"}else if(O==="}")or(G);else{let C=St(e.sel);if(!C||C.endsWith(","))e.sel.push(O);else e.sel[e.sel.length-1]+=" "+O}break;case"class":if(O==="{")e.state="nest",G.scopes.push(G.curr=Wt(e));else if(O==="}")or(G);else{let{token:C,query:h}=fr(O,n);if(!o.classes[C]&&!(Nr(C)||er(C)||Or(C)))L(`unknown class ID: ${C}`);if(h)Er(r,h,e.path,C);else Gr(m,e.path,C)}break;default:Et(e.state)}}}};function*Sm(t){let o=-1,n=t.length,r=0,m=0,f=!1;for(let E=0;E<n;E++){let G=t[E];if(G==='"'&&!(r||m))if(f)yield t.substring(o,E+1),o=-1,f=!1;else f=!0;else if(G===" "||G==="\t"){if(!(r||m||f)&&o>=0)yield t.substring(o,E),o=-1}else if(G==="{"||G==="}"){if(o>=0)yield t.substring(o,E);yield G,o=-1}else if(G==="(")r++;else if(G===")"){if(--r<0)L(`invalid nesting in line: '${t}'`)}else if(G==="["){if(o<0)o=E;m++}else if(G==="]"){if(--m<0)L(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=E}if(f)L("string literals must be fully on a single line");if(r)L("template calls must be fully on a single line");if(m)L("verbatim properties must be fully on a single line");if(o>=0)yield t.substring(o,n)}var It=":",rr="///",Wt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),or=(t)=>{let o=!t.curr.sel.length;if(qt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=St(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Wt(t.curr))}else t.scopes.push(t.curr=Wt(t.root))},Hm=(t)=>t.map((o)=>o.sel.join(",")).join(rr),mr=(t,o)=>Object.entries(t).map(([n,r])=>ym(n,r,o)),ym=(t,o,n)=>{let r=[],m=r,f=t.split(rr);for(let E=0;E<f.length;E++){let G=f[E].split(",");if(E==f.length-1){let N=Object.assign({},...B((O)=>er(O)?Wm(O):Nr(O)?Im(O):Or(O)?Rm(n,O):fo(n.classes[O]),o));G.push(N)}m.push(G),m=G}return r[0]},fr=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(It);if(n<0)return{token:t};let r=t.indexOf("("),m=t.indexOf("[");if(r>0||m>0){let G=r>0?m>0?Math.min(r,m):r:m;if(G<n&&t.indexOf(It)>G)return{token:t};n=t.substring(0,G).lastIndexOf(It)}let f=t.substring(0,n);if(!f.split(It).every((G)=>o.has(G)))L(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:f}},Mm=(t,o)=>o.split(It).reduce((n,r)=>Object.assign(n,t[r]),{}),Er=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},Gr=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Im=(t)=>{let o=t.indexOf("="),n=t.substring(0,o),r=t.substring(o+1);return{[`--${n}`]:r[0]==='"'?r.slice(1,-1):r}},Rm=(t,o)=>{let n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((E)=>E.trim().replace("\\,",",")),f=t.templates[r];if(!f)L(`unknown template: ${r}`);if(m.length!==f.__arity)L(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((E,[G,N])=>{if(!G.startsWith("__")){if(G=Wo(G,...m),A(N))N=Wo(N,...m);E[G]=N}return E},{})},Wm=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},Nr=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),Or=(t)=>t.includes("(")&&t.endsWith(")"),er=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var Cr={deg:Pn,em:yn,ex:Mn,ms:Jn,percent:Fo,px:Rn,rad:jn,rem:In,second:zn,turn:Xn,url:Zn,vh:Wn,vmax:Dn,vmin:Yn,vw:Un,"%":Fo},Um={percent:"{0}%",second:"{0}s",url:"url({0})"},Ym={"":[""],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:[""]},Lr={desc:"Generate framework rules from specs",opts:{...q,...ro,...Q,...$t},fn:Jo};async function Jo(t){if(t.opts.watch)await Dm(t);else await _r(t.inputs.map((o)=>F(o,t.logger)),t.opts,t.logger)}var Dm=async(t)=>{Mt(t.inputs,t.logger).subscribe({next(o){try{_r(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},_r=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Hn(o.prec);for(let m of t){let 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 E of f.specs)try{ir(f,E,r.classes,n)}catch(G){n.warn(`error processing spec: ${E.name}`,G,", skipping...")}if(f.templates)for(let E of f.templates)Jm(f,E,r.templates,n)}return k(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},ir=(t,o,n,r,m=!1)=>{let f=u(o.vars)?o.vars:[""],E=A(o.props)?{[o.props]:"<v>"}:o.props,G=zm(o,t),N=new Set;for(let O of f){let e=t.vars?.[O]||Ym[O];if(!e)L(`unknown variation ID: ${O}`);for(let[C,h]of gt(e,Object.keys(G))){let _=tt(o.name,O,C,h,G[h]),I=o.unit?tt(o.unit,O,C,h,G[h]):void 0,v=m?jm(I):Pm(G[h],I);if(!n[_]){if(n[_]={},o.user!=null)n[_].__user=o.user;if(o.doc!=null)n[_].__doc=Xm(o.doc,O,C,h,v)}else if(!N.has(_))L(`duplicate class ID: ${_}`);N.add(_);let i=-1;for(let[l,y]of Object.entries(E)){let b=tt(l,O,C,h,G[h]),Eo=tt(!I||A(y)?String(y):Cr[I](y),O,C,h,v);if(n[_][b]=Eo,r.debug(_,b,Eo),m)i=hr(Eo,hr(b,i))}if(m)n[_].__arity=i+1}}return n},Jm=(t,o,n,r)=>ir(t,{...o,values:[""]},n,r,!0),hr=(t,o)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},zm=(t,o)=>{let n=A(t.values)?o.tables?.[t.values]||L(`invalid table ID: ${t.values}`):t.values;if(J(n))return n;let r=t.key==="v"?(m)=>String(m):t.key==="i+1"?(m,f)=>String(f+1):t.key==="i"||t.key===void 0?(m,f)=>String(f):L(`invalid key type: ${t.key}`);return n.reduce((m,f,E)=>{return m[r(f,E)]=f,m},{})},Pm=(t,o)=>{if(!o||A(t))return t;let n=Cr[o];if(!n)L(`invalid unit: ${o}`);return n(t)},jm=(t)=>t?Um[t]||"{0}"+t:"{0}",tt=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Xm=({group:t,desc:o,args:n},r,m,f,E)=>({group:t?tt(t,r,m,f,E):"TODO",desc:o?tt(o,r,m,f,E):void 0,args:n?n.map((G)=>tt(G,r,m,f,E)):void 0});var Br={desc:"Combination of the generate & convert commands",opts:{...to,...oo,...no,..._t,...it,...Bt,...ro,...Q,...At,...$t,outCss:D({desc:"Output file for CSS bundle",optional:!1}),outSpecs:D({desc:"Output file for framework",optional:!1})},fn:async(t)=>{let{opts:o,inputs:n}=t,[r,m]=n.reduce((G,N)=>(G[N.endsWith(".json")?0:1].push(N),G),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},E={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Jo(f),await Do(E)}};import{resolve as Zm}from"path";var ur={desc:"Generate Markdown documentation for framework specs",opts:{...q,level:Jt({alias:"l",desc:"Initial heading level",default:1}),title:D({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{let{logger:o,opts:n,inputs:r}=t,m=Z(Zm(r[0]),o),f=bm(m,n);k(n.out,f,o)}},bm=(t,{level:o,title:n})=>{let 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}):`,"",`${ot(o+1)} Classes by category`,"",...$r(t.classes,pm,o+2),`${ot(o+1)} Templates by category`,"",...$r(t.templates,Vm,o+2),`${ot(o+1)} Media queries`,"",...Object.entries(t.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")f.unshift(`${ot(o)} ${n??t.info.name}
32
+ `)},mo=({info:{name:t,version:o}})=>`/*! ${t} v${o} - generated by thi.ng/meta-css @ ${new Date().toISOString()} */`,Mt=(t,o)=>{let n=()=>{o.info("closing watchers..."),r.forEach((m)=>m.watcher.close())},r=t.map((m,f)=>{m=cn(m);let E=bn(F(m,o),{id:`in${dn(f)}`});return{input:E,watcher:Bm(m,{},(G)=>{if(G==="change")try{E.next(F(m,o))}catch(N){o.warn(N.message),n()}else o.warn("input removed:",m),n()})}});return process.on("SIGINT",n),ct({src:So(B(({input:m})=>[m.id,m],r))})},fo=(t)=>Object.keys(t).reduce((o,n)=>{if(!n.startsWith("__"))o[n]=t[n];return o},{});var nr={desc:"Transpile (and optionally bundle) meta stylesheets to CSS",opts:{...to,...oo,...no,..._t,...it,...Bt,...q,...Q,...At,...xn,...$t,noWrite:R({desc:"Don't write files, use stdout only"})},fn:Do};async function Do(t){let o=Z(c(t.opts.specs),t.logger),n=wm(o,t.opts.force||[],t.logger);if(t.opts.bundle)if(t.opts.watch)await $m(t,n);else Rt(t,o,n,t.opts.eval?[t.opts.eval]:t.inputs.map((r)=>F(c(r),t.logger)),t.opts.out);else if(t.opts.watch)await Am(t,o,n);else if(t.opts.eval)try{Rt(t,o,n,[t.opts.eval])}catch(r){t.logger.warn(r.message)}else for(let r of t.inputs)try{r=c(r);let m=!t.opts.noWrite?r.replace(/\.mcss$/,".css"):void 0;Rt(t,o,n,[F(r,t.logger)],m)}catch(m){t.logger.warn(m.message)}}var Am=async(t,o,n)=>{let r=c(t.opts.specs),m,f={process:()=>{try{return o=Z(r,t.logger),m.forEach((G)=>G.process()),!0}catch(G){return t.logger.warn(G.message+": "+r),!1}},watcher:tr(r,{},(G)=>{if(G==="change")f.process();else t.logger.warn("specs file removed:",r),E()})},E=()=>{t.logger.info("closing watchers..."),f.watcher.close(),m.forEach((G)=>G.watcher.close())};m=t.inputs.map((G)=>{G=c(G);let N=!t.opts.noWrite?G.replace(/\.mcss$/,".css"):void 0,O=()=>{try{return Rt(t,o,n,[F(G,t.logger)],N),!0}catch(h){if(t.logger.warn(h.message+": "+G),m)E();return!1}};if(!O())process.exit(1);return{process:O,watcher:tr(G,{},(h)=>{if(h==="change")O();else t.logger.warn("input removed:",G),E()})}}),t.logger.info("waiting for changes, press ctrl+c to cancel..."),process.on("SIGINT",E)},$m=async(t,o)=>{ct({src:{styles:Mt(t.inputs,t.logger),specs:Mt([t.opts.specs],t.logger).map((n)=>JSON.parse(Object.values(n)[0]))}}).subscribe({next({styles:n,specs:r}){try{Rt(t,r,o,Object.keys(n).sort().map((m)=>n[m]),t.opts.out)}catch(m){t.logger.warn(m.message)}}})},Rt=({logger:t,opts:{include:o,noDecls:n,noHeader:r,pretty:m,scope:f}},E,G,N,O)=>{let h={logger:t,specs:E,css:{format:m?lt:Gt,fns:st,scope:f},mediaQueryIDs:new Set(Object.keys(E.media)),mediaQueryRules:{...G.mediaQueryRules},plainRules:{...G.plainRules}},e=o?o.map((C)=>F(c(C),t).trim()):[];if(!r)e.push(mo(E));if(!n&&E.decls.length)e.push(a(E.decls,h.css));N.forEach((C)=>Fm(C,h)),um(e,h),Tm(e,h),k(O,e,t)},Tm=(t,{css:o,logger:n,mediaQueryRules:r,specs:m})=>{for(let f in r){let E=mr(r[f],m);n.debug("mediaquery rules",f,E),t.push(a(Lt(Mm(m.media,f),E),o))}},um=(t,{css:o,logger:n,plainRules:r,specs:m})=>{let f=mr(r,m);n.debug("plain rules",f),t.push(a(f,o))},wm=(t,o,n)=>{let r=new Set(Object.keys(t.media)),m=new Set(Object.keys(t.classes)),f={},E={};if(o.length&&o[0][0]==="@")o=[...mt(F(c(o[0].substring(1)),n))];for(let G of o){if(!G||G.startsWith("//"))continue;let{token:N,query:O}=fr(G,r),h;if(N.includes("*")){let e=new RegExp(`^${N.replace("*",".*")}$`);h=[...Yo((C)=>e.test(C),m)]}else if(m.has(N))h=[N];else{n.warn(`unknown include rule ID: ${G}, skipping...`);continue}for(let e of h)n.debug("including class:",e),O?Er(f,O,`.${e}`,e):Gr(E,`.${e}`,e)}return{mediaQueryRules:f,plainRules:E}},Fm=(t,{specs:o,mediaQueryIDs:n,mediaQueryRules:r,plainRules:m})=>{let f=Wt(),E=Wt(f),G={root:f,curr:E,scopes:[E]};for(let N of mt(t)){if(!N||/^\s*\/\//.test(N))continue;for(let O of Sm(N)){if(!O)continue;let h=G.curr;switch(h.state){case"sel":case"nest":if(O==="{"){if(h.state==="sel")h.sel=h.sel.map((e)=>e.replace(",","")),h.path=Hm(G.scopes);h.state="class"}else if(O==="}")or(G);else{let e=St(h.sel);if(!e||e.endsWith(","))h.sel.push(O);else h.sel[h.sel.length-1]+=" "+O}break;case"class":if(O==="{")h.state="nest",G.scopes.push(G.curr=Wt(h));else if(O==="}")or(G);else{let{token:e,query:C}=fr(O,n);if(!o.classes[e]&&!(Nr(e)||hr(e)||Or(e)))L(`unknown class ID: ${e}`);if(C)Er(r,C,h.path,e);else Gr(m,h.path,e)}break;default:Et(h.state)}}}};function*Sm(t){let o=-1,n=t.length,r=0,m=0,f=!1;for(let E=0;E<n;E++){let G=t[E];if(G==='"'&&!(r||m))if(f)yield t.substring(o,E+1),o=-1,f=!1;else f=!0;else if(G===" "||G==="\t"){if(!(r||m||f)&&o>=0)yield t.substring(o,E),o=-1}else if(G==="{"||G==="}"){if(o>=0)yield t.substring(o,E);yield G,o=-1}else if(G==="(")r++;else if(G===")"){if(--r<0)L(`invalid nesting in line: '${t}'`)}else if(G==="["){if(o<0)o=E;m++}else if(G==="]"){if(--m<0)L(`invalid arg nesting in line: '${t}'`)}else if(o<0)o=E}if(f)L("string literals must be fully on a single line");if(r)L("template calls must be fully on a single line");if(m)L("verbatim properties must be fully on a single line");if(o>=0)yield t.substring(o,n)}var It=":",rr="///",Wt=(t)=>({state:"sel",sel:t?[]:["<root>"],path:"",parent:t}),or=(t)=>{let o=!t.curr.sel.length;if(qt(!!t.curr.parent,"stack underflow"),t.scopes.pop(),t.scopes.length>0){if(t.curr=St(t.scopes),!o&&t.curr.state==="nest")t.scopes.push(t.curr=Wt(t.curr))}else t.scopes.push(t.curr=Wt(t.root))},Hm=(t)=>t.map((o)=>o.sel.join(",")).join(rr),mr=(t,o)=>Object.entries(t).map(([n,r])=>ym(n,r,o)),ym=(t,o,n)=>{let r=[],m=r,f=t.split(rr);for(let E=0;E<f.length;E++){let G=f[E].split(",");if(E==f.length-1){let N=Object.assign({},...B((O)=>hr(O)?Wm(O):Nr(O)?Im(O):Or(O)?Rm(n,O):fo(n.classes[O]),o));G.push(N)}m.push(G),m=G}return r[0]},fr=(t,o)=>{if(/^::?/.test(t))return{token:t};let n=t.lastIndexOf(It);if(n<0)return{token:t};let r=t.indexOf("("),m=t.indexOf("[");if(r>0||m>0){let G=r>0?m>0?Math.min(r,m):r:m;if(G<n&&t.indexOf(It)>G)return{token:t};n=t.substring(0,G).lastIndexOf(It)}let f=t.substring(0,n);if(!f.split(It).every((G)=>o.has(G)))L(`invalid media query in token: ${t}`);return{token:t.substring(n+1),query:f}},Mm=(t,o)=>o.split(It).reduce((n,r)=>Object.assign(n,t[r]),{}),Er=(t,o,n,r)=>{if(!t[o])t[o]={};(t[o][n]||(t[o][n]=new Set)).add(r)},Gr=(t,o,n)=>(t[o]||(t[o]=new Set)).add(n),Im=(t)=>{let o=t.indexOf("="),n=t.substring(0,o),r=t.substring(o+1);return{[`--${n}`]:r[0]==='"'?r.slice(1,-1):r}},Rm=(t,o)=>{let n=o.indexOf("("),r=o.substring(0,n),m=o.substring(n+1,o.length-1).split(/(?<!\\),/g).map((E)=>E.trim().replace("\\,",",")),f=t.templates[r];if(!f)L(`unknown template: ${r}`);if(m.length!==f.__arity)L(`template "${r}" expected ${f.__arity} arguments`);return Object.entries(f).reduce((E,[G,N])=>{if(!G.startsWith("__")){if(G=Wo(G,...m),$(N))N=Wo(N,...m);E[G]=N}return E},{})},Wm=(t)=>{let[o,n,r]=/^(.+)-\[(.+)\]/.exec(t);return{[n]:r}},Nr=(t)=>/^[a-z0-9:_-]+=.+/i.test(t),Or=(t)=>t.includes("(")&&t.endsWith(")"),hr=(t)=>t.indexOf("-[")>0&&t.endsWith("]");var Cr={deg:Pn,em:yn,ex:Mn,ms:Jn,percent:Fo,px:Rn,rad:jn,rem:In,second:zn,turn:Xn,url:Zn,vh:Wn,vmax:Dn,vmin:Yn,vw:Un,"%":Fo},Um={percent:"{0}%",second:"{0}s",url:"url({0})"},Ym={"":[""],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:[""]},Lr={desc:"Generate framework rules from specs",opts:{...q,...ro,...Q,...$t},fn:Jo};async function Jo(t){if(t.opts.watch)await Dm(t);else await _r(t.inputs.map((o)=>F(o,t.logger)),t.opts,t.logger)}var Dm=async(t)=>{Mt(t.inputs,t.logger).subscribe({next(o){try{_r(Object.keys(o).sort().map((n)=>o[n]),t.opts,t.logger)}catch(n){t.logger.warn(n.message)}}})},_r=async(t,o,n)=>{let r={info:{name:"TODO",version:"0.0.0"},media:{},classes:{},templates:{},decls:[]};Hn(o.prec);for(let m of t){let 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 E of f.specs)try{ir(f,E,r.classes,n)}catch(G){n.warn(`error processing spec: ${E.name}`,G,", skipping...")}if(f.templates)for(let E of f.templates)Jm(f,E,r.templates,n)}return k(o.out,JSON.stringify(r,null,o.pretty?4:0),n),r},ir=(t,o,n,r,m=!1)=>{let f=A(o.vars)?o.vars:[""],E=$(o.props)?{[o.props]:"<v>"}:o.props,G=zm(o,t),N=new Set;for(let O of f){let h=t.vars?.[O]||Ym[O];if(!h)L(`unknown variation ID: ${O}`);for(let[e,C]of gt(h,Object.keys(G))){let _=tt(o.name,O,e,C,G[C]),I=o.unit?tt(o.unit,O,e,C,G[C]):void 0,v=m?jm(I):Pm(G[C],I);if(!n[_]){if(n[_]={},o.user!=null)n[_].__user=o.user;if(o.doc!=null)n[_].__doc=Xm(o.doc,O,e,C,v)}else if(!N.has(_))L(`duplicate class ID: ${_}`);N.add(_);let i=-1;for(let[l,y]of Object.entries(E)){let b=tt(l,O,e,C,G[C]),Eo=tt(!I||$(y)?String(y):Cr[I](y),O,e,C,v);if(n[_][b]=Eo,r.debug(_,b,Eo),m)i=er(Eo,er(b,i))}if(m)n[_].__arity=i+1}}return n},Jm=(t,o,n,r)=>ir(t,{...o,values:[""]},n,r,!0),er=(t,o)=>{let n=/\{(\d+)\}/g,r;while(r=n.exec(t))o=Math.max(o,+r[1]);return o},zm=(t,o)=>{let n=$(t.values)?o.tables?.[t.values]||L(`invalid table ID: ${t.values}`):t.values;if(J(n))return n;let r=t.key==="v"?(m)=>String(m):t.key==="i+1"?(m,f)=>String(f+1):t.key==="i"||t.key===void 0?(m,f)=>String(f):L(`invalid key type: ${t.key}`);return n.reduce((m,f,E)=>{return m[r(f,E)]=f,m},{})},Pm=(t,o)=>{if(!o||$(t))return t;let n=Cr[o];if(!n)L(`invalid unit: ${o}`);return n(t)},jm=(t)=>t?Um[t]||"{0}"+t:"{0}",tt=(t,o,n,r,m)=>t.replace(/<vid>/g,o).replace(/<var>/g,n).replace(/<k>/g,r).replace(/<v>/g,String(m)),Xm=({group:t,desc:o,args:n},r,m,f,E)=>({group:t?tt(t,r,m,f,E):"TODO",desc:o?tt(o,r,m,f,E):void 0,args:n?n.map((G)=>tt(G,r,m,f,E)):void 0});var Br={desc:"Combination of the generate & convert commands",opts:{...to,...oo,...no,..._t,...it,...Bt,...ro,...Q,...At,...$t,outCss:D({desc:"Output file for CSS bundle",optional:!1}),outSpecs:D({desc:"Output file for framework",optional:!1})},fn:async(t)=>{let{opts:o,inputs:n}=t,[r,m]=n.reduce((G,N)=>(G[N.endsWith(".json")?0:1].push(N),G),[[],[]]),f={inputs:r,format:t.format,logger:t.logger,opts:{...o,out:o.outSpecs}},E={inputs:m,format:t.format,logger:t.logger,opts:{...o,noWrite:!1,out:o.outCss,scope:o.scope,specs:o.outSpecs}};await Jo(f),await Do(E)}};import{resolve as Zm}from"path";var Tr={desc:"Generate Markdown documentation for framework specs",opts:{...q,level:Jt({alias:"l",desc:"Initial heading level",default:1}),title:D({alias:"t",desc:"Custom main title, set to NONE to disable"})},inputs:1,fn:async(t)=>{let{logger:o,opts:n,inputs:r}=t,m=Z(Zm(r[0]),o),f=bm(m,n);k(n.out,f,o)}},bm=(t,{level:o,title:n})=>{let 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}):`,"",`${ot(o+1)} Classes by category`,"",...$r(t.classes,pm,o+2),`${ot(o+1)} Templates by category`,"",...$r(t.templates,Vm,o+2),`${ot(o+1)} Media queries`,"",...Object.entries(t.media).map(([E,G])=>`- **${E}**: \`${JSON.stringify(G)}\``),""];if(n!=="NONE")f.unshift(`${ot(o)} ${n??t.info.name}
33
33
  `);return f},Ar=(t)=>t.split(/(\d+)/).map((o)=>{let n=parseInt(o);return isNaN(n)?o:n}),Km=(t,o)=>{if(/\d+/.test(t)&&/\d+/.test(o)){let n=Ar(t),r=Ar(o),m=n.length;if(m===r.length){for(let f=0;f<m;f++)if(n[f]!==r[f])return Ao(n[f],r[f]);return 0}return n.length-r.length}return Ao(t,o)},$r=(t,o,n)=>{let r=Uo({key:([m,{__doc:f}])=>f?.group||"TODO",group:[()=>[],(m)=>m.sort(),(m,f)=>(m.push(f[0]),m)]},Object.entries(t));return Ho((m)=>{let f=r[m].sort(Km).map((G)=>o(G,t[G].__doc,n+1)),E=f.length;return[`${ot(n)} ${Xt(m)}`,E>3?`
34
34
  <details><summary>${E} items:</summary>
35
35
  `:"",f.join(`
@@ -39,7 +39,7 @@ Available commands:
39
39
  TODO`;let r=o.args.map((m)=>/^\w+/.exec(m)[0]).join(", ");return[`${ot(n)} \`${t}(${r})\``,"",...o.args.map(qm),o.desc?`
40
40
  ${o.desc}
41
41
  `:""].join(`
42
- `)},qm=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,ot=U((t)=>"#".repeat(t));import{resolve as Tr}from"path";var Fr={desc:"Export entire generated framework as CSS",opts:{..._t,...it,...sn,...q,...Q,...Bt,...an,...At},inputs:1,fn:async(t)=>{let{logger:o,opts:{include:n,media:r,noDecls:m,noHeader:f,onlyDecls:E,out:G,pretty:N,scope:O},inputs:e}=t,C={format:N?lt:Gt,fns:st,scope:O},h=Z(Tr(e[0]),o),_=n?n.map((I)=>F(Tr(I),o).trim()):[];if(!f)_.push(mo(h));if(!m&&h.decls.length)_.push(a(h.decls,C));if(!E)_.push(Qm(h,r,C,o));k(G,_,o)}},Qm=(t,o,n,r)=>{let m=wr("",t);if(o){let f=o[0]==="ALL"?Object.keys(t.media):o;for(let E of f)if(t.media[E])m.push(Lt(t.media[E],wr("-"+E,t)));else r.warn(`invalid media query ID: ${E}, skipping...`)}return a(m,n)},wr=(t,o)=>Object.entries(o.classes).map(([n,r])=>[`.${n}${t}`,fo(r)]);var zo=Z(km(process.argv[2],"package.json"));rn({name:"metacss",start:3,opts:{verbose:R({alias:"v",desc:"Display extra process information"})},commands:{convert:nr,develop:Br,doc:ur,export:Fr,generate:Lr},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=$.DEBUG;return{...t,format:jt}},usage:{prefix:`${mn(zo.name,zo.version,zo.description)}
42
+ `)},qm=(t)=>`- ${t.replace(/^(\w+)/,(o,n)=>`**${n}**`)}`,ot=U((t)=>"#".repeat(t));import{resolve as ur}from"path";var Fr={desc:"Export entire generated framework as CSS",opts:{..._t,...it,...sn,...q,...Q,...Bt,...an,...At},inputs:1,fn:async(t)=>{let{logger:o,opts:{include:n,media:r,noDecls:m,noHeader:f,onlyDecls:E,out:G,pretty:N,scope:O},inputs:h}=t,e={format:N?lt:Gt,fns:st,scope:O},C=Z(ur(h[0]),o),_=n?n.map((I)=>F(ur(I),o).trim()):[];if(!f)_.push(mo(C));if(!m&&C.decls.length)_.push(a(C.decls,e));if(!E)_.push(Qm(C,r,e,o));k(G,_,o)}},Qm=(t,o,n,r)=>{let m=wr("",t);if(o){let f=o[0]==="ALL"?Object.keys(t.media):o;for(let E of f)if(t.media[E])m.push(Lt(t.media[E],wr("-"+E,t)));else r.warn(`invalid media query ID: ${E}, skipping...`)}return a(m,n)},wr=(t,o)=>Object.entries(o.classes).map(([n,r])=>[`.${n}${t}`,fo(r)]);var zo=Z(km(process.argv[2],"package.json"));rn({name:"metacss",start:3,opts:{verbose:R({alias:"v",desc:"Display extra process information"})},commands:{convert:nr,develop:Br,doc:Tr,export:Fr,generate:Lr},ctx:async(t)=>{if(t.opts.verbose)t.logger.level=T.DEBUG;return{...t,format:jt}},usage:{prefix:`${mn(zo.name,zo.version,zo.description)}
43
43
 
44
44
  Usage: metacss <cmd> [opts] input [...]
45
45
  metacss <cmd> --help
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@thi.ng/meta-css",
3
- "version": "0.19.11",
3
+ "version": "0.19.13",
4
4
  "description": "Data-driven CSS framework codegen, transpiler & bundler",
5
5
  "type": "module",
6
6
  "module": "./index.js",
@@ -45,19 +45,19 @@
45
45
  },
46
46
  "dependencies": {
47
47
  "@thi.ng/api": "^8.11.30",
48
- "@thi.ng/args": "^2.8.0",
48
+ "@thi.ng/args": "^2.8.1",
49
49
  "@thi.ng/arrays": "^2.13.2",
50
50
  "@thi.ng/checks": "^3.7.10",
51
51
  "@thi.ng/compare": "^2.4.22",
52
52
  "@thi.ng/errors": "^2.5.36",
53
53
  "@thi.ng/file-io": "^2.2.1",
54
- "@thi.ng/hiccup-css": "^2.7.54",
54
+ "@thi.ng/hiccup-css": "^2.7.55",
55
55
  "@thi.ng/logger": "^3.1.11",
56
56
  "@thi.ng/memoize": "^4.0.20",
57
- "@thi.ng/rstream": "^9.2.29",
57
+ "@thi.ng/rstream": "^9.2.31",
58
58
  "@thi.ng/strings": "^3.9.16",
59
59
  "@thi.ng/text-format": "^2.2.35",
60
- "@thi.ng/transducers": "^9.5.1"
60
+ "@thi.ng/transducers": "^9.6.0"
61
61
  },
62
62
  "devDependencies": {
63
63
  "@types/node": "^24.0.12",
@@ -113,5 +113,5 @@
113
113
  "status": "alpha",
114
114
  "year": 2023
115
115
  },
116
- "gitHead": "a157f18f16200faad01e15da553c9eea3fa37014\n"
116
+ "gitHead": "63a8b97642b9c481bb623e8d53e6250749a2cbfb\n"
117
117
  }