@stacksjs/ts-css 0.1.4 → 0.3.2

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 (56) hide show
  1. package/ENGINE.md +677 -0
  2. package/PLUGIN.md +217 -0
  3. package/dist/bin/cli.js +29 -38
  4. package/dist/bin/cssx.js +405 -0
  5. package/dist/chunk-0h48763m.js +2 -0
  6. package/dist/chunk-br9jax0b.js +2 -0
  7. package/dist/chunk-f9gzb0a5.js +3 -0
  8. package/dist/chunk-genwkevp.js +3 -0
  9. package/dist/chunk-jj3s4ctf.js +62 -0
  10. package/dist/chunk-mz87cw2e.js +2 -0
  11. package/dist/engine/build.d.ts +26 -0
  12. package/dist/engine/color-modifier.d.ts +8 -0
  13. package/dist/engine/config.d.ts +5 -0
  14. package/dist/engine/format.d.ts +20 -0
  15. package/dist/engine/generator.d.ts +14 -0
  16. package/dist/engine/index.d.ts +13 -0
  17. package/dist/engine/index.js +653 -0
  18. package/dist/engine/parser.d.ts +68 -0
  19. package/dist/engine/plugin.d.ts +22 -0
  20. package/dist/engine/preflight-forms.d.ts +6 -0
  21. package/dist/engine/preflight.d.ts +3 -0
  22. package/dist/engine/rules-advanced.d.ts +27 -0
  23. package/dist/engine/rules-effects.d.ts +35 -0
  24. package/dist/engine/rules-forms.d.ts +8 -0
  25. package/dist/engine/rules-grid.d.ts +13 -0
  26. package/dist/engine/rules-icons.d.ts +2 -0
  27. package/dist/engine/rules-interactivity.d.ts +41 -0
  28. package/dist/engine/rules-layout.d.ts +28 -0
  29. package/dist/engine/rules-transforms.d.ts +35 -0
  30. package/dist/engine/rules-typography.d.ts +47 -0
  31. package/dist/engine/rules.d.ts +56 -0
  32. package/dist/engine/scanner.d.ts +16 -0
  33. package/dist/engine/style/api.d.ts +95 -0
  34. package/dist/engine/style/collect.d.ts +10 -0
  35. package/dist/engine/style/evaluate.d.ts +11 -0
  36. package/dist/engine/style/hash.d.ts +15 -0
  37. package/dist/engine/style/index.d.ts +56 -0
  38. package/dist/engine/style/plugin.d.ts +27 -0
  39. package/dist/engine/style/priority.d.ts +12 -0
  40. package/dist/engine/style/registry.d.ts +56 -0
  41. package/dist/engine/style/types.d.ts +54 -0
  42. package/dist/engine/style/value.d.ts +15 -0
  43. package/dist/engine/transformer-compile-class.d.ts +34 -0
  44. package/dist/engine/types.d.ts +156 -0
  45. package/dist/index.js +1 -60
  46. package/dist/optimize/index.js +1 -1
  47. package/dist/parse/index.js +1 -1
  48. package/dist/parse/list.d.ts +1 -1
  49. package/dist/select/index.js +1 -1
  50. package/dist/what/index.js +1 -1
  51. package/package.json +35 -19
  52. package/dist/chunk-1kmkypmr.js +0 -3
  53. package/dist/chunk-2wsah70r.js +0 -2
  54. package/dist/chunk-9ep6bwwb.js +0 -2
  55. package/dist/chunk-edwg811g.js +0 -2
  56. package/dist/chunk-thy3p95k.js +0 -3
package/dist/bin/cli.js CHANGED
@@ -1,42 +1,33 @@
1
1
  #!/usr/bin/env bun
2
2
  // @bun
3
- import{existsSync as E6}from"fs";import j0 from"fs/promises";import p0 from"os";import V0 from"path";import u from"process";import{EventEmitter as I6}from"events";import k from"process";import c0 from"process";import L0 from"process";import J0 from"process";import s from"process";import n0 from"tty";import D4,{stdin as yz,stdout as fz}from"process";import r0,{stdin as w4,stdout as N4}from"process";import B4 from"readline";class t0{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let z=p0.homedir(),$=V0.join(z,".config","clapp");this.configPath=V0.join($,"telemetry.json")}async isEnabled(){if(u.env.DO_NOT_TRACK==="1"||u.env.DO_NOT_TRACK==="true")return!1;if(u.env.NO_TELEMETRY==="1"||u.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let z=await this.loadConfig();if(z.enabled=!0,!z.userId)z.userId=this.generateUserId();await this.saveConfig(z)}async disable(){let z=await this.loadConfig();z.enabled=!1,await this.saveConfig(z)}async track(z,$){if(!await this.isEnabled())return;let Q={event:z,...$,timestamp:Date.now(),platform:p0.platform(),nodeVersion:u.version};if(this.events.push(Q),this.events.length>=10)await this.send()}async trackCommand(z,$){await this.track("command",{command:z,duration:$})}async trackError(z,$){await this.track("error",{error:z,command:$})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let $=await this.loadConfig();return $.lastSent=Date.now(),await this.saveConfig($),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let $=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep($),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(z){return new Promise(($)=>setTimeout($,z))}async status(){let z=await this.loadConfig();return{enabled:z.enabled,doNotTrack:u.env.DO_NOT_TRACK==="1"||u.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:z.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(E6(this.configPath)){let z=await j0.readFile(this.configPath,"utf-8");return this.config=JSON.parse(z),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(z){this.config=z;try{let $=V0.dirname(this.configPath);await j0.mkdir($,{recursive:!0}),await j0.writeFile(this.configPath,JSON.stringify(z,null,2),"utf-8")}catch{}}generateUserId(){let z=Math.random().toString(36).substring(2,15),$=Date.now().toString(36);return`${z}-${$}`}}var Az=new t0;function C6(z,$={}){let J={_:[]},Q=$.alias||{},Z=new Set($.boolean||[]),Y={};for(let X of Object.keys(Q))for(let U of Q[X])Y[U]=X;for(let X of Z)if(Q[X])for(let U of Q[X])Z.add(U);function q(X,U){let F=Y[X]||X;if(J[F]=U,Q[F])for(let H of Q[F])J[H]=U;if(Y[X]&&Q[Y[X]])for(let H of Q[Y[X]])J[H]=U;J[X]=U}for(let X=0;X<z.length;X++){let U=z[X];if(U==="--"){J._.push(...z.slice(X+1));break}if(U.startsWith("--")){let F=U.indexOf("=");if(F!==-1){let H=U.slice(2,F),G=U.slice(F+1);q(H,G)}else{let H=U.slice(2);if(H.startsWith("no-")){let K=H.slice(3);q(K,!1);continue}let G=Y[H]||H;if(Z.has(G)||Z.has(H))q(H,!0);else{let K=z[X+1];if(K!==void 0&&!K.startsWith("-"))q(H,K),X++;else q(H,!0)}}}else if(U.startsWith("-")&&U.length>1){let F=U.slice(1);for(let H=0;H<F.length;H++){let G=F[H],K=Y[G]||G;if(H===F.length-1&&!Z.has(K)&&!Z.has(G)){let V=z[X+1];if(V!==void 0&&!V.startsWith("-"))q(G,V),X++;else q(G,!0)}else q(G,!0)}}else J._.push(U)}return J}function W0(z){return z.replace(/[<[].+/,"").trim()}function h6(z){let $=/<([^>]+)>/g,J=/\[([^\]]+)\]/g,Q=[],Z=(X)=>{let U=!1,F=X[1];if(F.startsWith("..."))F=F.slice(3),U=!0;return{required:X[0].startsWith("<"),value:F,variadic:U}},Y;while(Y=$.exec(z))Q.push(Z(Y));let q;while(q=J.exec(z))Q.push(Z(q));return Q}function S6(z){let $={alias:{},boolean:[]};for(let[J,Q]of z.entries()){if(Q.names.length>1)$.alias[Q.names[0]]=Q.names.slice(1);if(Q.isBoolean)if(Q.negated){if(!z.some((Y,q)=>{return q!==J&&Y.names.some((X)=>Q.names.includes(X))&&typeof Y.required==="boolean"}))$.boolean.push(Q.names[0])}else $.boolean.push(Q.names[0])}return $}function l0(z){return z.reduce(($,J)=>$.length>=J.length?$:J,"")}function M0(z,$){return z.length>=$?z:`${z}${" ".repeat($-z.length)}`}function g6(z){return z.replace(/([a-z])-([a-z])/g,($,J,Q)=>{return J+Q.toUpperCase()})}function v6(z,$,J){let Q=0,Z=$.length,Y=z,q;for(;Q<Z;++Q)q=Y[$[Q]],Y=Y[$[Q]]=Q===Z-1?J:q!=null?q:!!~$[Q+1].indexOf(".")||!(+$[Q+1]>-1)?{}:[]}function _6(z,$){for(let J of Object.keys($)){let Q=$[J];if(Q.shouldTransform){if(z[J]=Array.prototype.concat.call([],z[J]),typeof Q.transformFunction==="function")z[J]=z[J].map(Q.transformFunction)}}}function y6(z){let $=/([^\\/]+)$/.exec(z);return $?$[1]:""}function s0(z){return z.split(".").map(($,J)=>{return J===0?g6($):$}).join(".")}class $0 extends Error{exitCode=2;isUsageError=!0;constructor(z){super(z);if(this.name=this.constructor.name,typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(z).stack}format(z=!1){if(z&&this.stack)return`${this.message}
3
+ import{EventEmitter as wt}from"events";import V from"process";import We from"process";import ge from"process";import re from"process";import X from"process";import ze from"tty";import un,{stdin as pr,stdout as gr}from"process";import{existsSync as pn}from"fs";import me from"fs/promises";import He from"os";import fe from"path";import j from"process";function pe(e){return e.replace(/[<[].+/,"").trim()}function $t(e){let t=/<([^>]+)>/g,n=/\[([^\]]+)\]/g,r=[],s=(a)=>{let o=!1,c=a[1];if(c.startsWith("..."))c=c.slice(3),o=!0;else if(c.endsWith("..."))c=c.slice(0,-3),o=!0;return{required:a[0].startsWith("<"),value:c.trim(),variadic:o}},i;while(i=t.exec(e))r.push(s(i));let l;while(l=n.exec(e))r.push(s(l));return r}function xt(e){let t={alias:{},boolean:[]};for(let[n,r]of e.entries()){if(r.names.length>1)t.alias[r.names[0]]=r.names.slice(1);if(r.isBoolean)if(r.negated){if(!e.some((i,l)=>l!==n&&i.names.some((a)=>r.names.includes(a))&&typeof i.required==="boolean"))t.boolean.push(r.names[0])}else t.boolean.push(r.names[0])}return t}function je(e){return e.reduce((t,n)=>t.length>=n.length?t:n,"")}function de(e,t){return e.length>=t?e:`${e}${" ".repeat(t-e.length)}`}function ne(e){return e.replace(/([a-z])-([a-z])/g,(t,n,r)=>n+r.toUpperCase())}function St(e,t,n){let r=0,s=t.length,i=e,l;for(;r<s;++r)l=i[t[r]],i=i[t[r]]=r===s-1?n:l!=null?l:!!~t[r+1].indexOf(".")||!(+t[r+1]>-1)?{}:[]}function kt(e,t){for(let n of Object.keys(t)){let r=t[n];if(e[n]===void 0)continue;if(r.shouldTransform){if(e[n]=Array.prototype.concat.call([],e[n]),typeof r.transformFunction==="function")e[n]=e[n].map(r.transformFunction)}}}function Tt(e){let t=/([^\\/]+)$/.exec(e);return t?t[1]:""}function Z(e){return e.split(".").map((t,n)=>n===0?ne(t):t).join(".")}class ee extends Error{exitCode=2;isUsageError=!0;usage;constructor(e,t){super(e);if(this.name=this.constructor.name,t!==void 0)this.usage=t;if(typeof Error.captureStackTrace==="function")Error.captureStackTrace(this,this.constructor);else this.stack=Error(e).stack}format(e=!1){if(e&&this.stack)return`${this.message}
4
4
 
5
5
  Stack trace:
6
- ${this.stack}`;return this.message}}function f6(){let{env:z}=c0,{TERM:$,TERM_PROGRAM:J}=z;if(c0.platform!=="win32")return $!=="linux";return Boolean(z.WT_SESSION)||Boolean(z.TERMINUS_SUBLIME)||z.ConEmuTask==="{cmd::Cmder}"||J==="Terminus-Sublime"||J==="vscode"||$==="xterm-256color"||$==="alacritty"||$==="rxvt-unicode"||$==="rxvt-unicode-256color"||z.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var Y0="\x1B",N=`${Y0}[`;var y={to(z,$){if(!$)return`${N}${z+1}G`;return`${N}${$+1};${z+1}H`},move(z,$){let J="";if(z<0)J+=`${N}${-z}D`;else if(z>0)J+=`${N}${z}C`;if($<0)J+=`${N}${-$}A`;else if($>0)J+=`${N}${$}B`;return J},up:(z=1)=>`${N}${z}A`,down:(z=1)=>`${N}${z}B`,forward:(z=1)=>`${N}${z}C`,backward:(z=1)=>`${N}${z}D`,nextLine:(z=1)=>`${N}E`.repeat(z),prevLine:(z=1)=>`${N}F`.repeat(z),left:`${N}G`,hide:`${N}?25l`,show:`${N}?25h`,save:`${Y0}7`,restore:`${Y0}8`};var D0={screen:`${N}2J`,up:(z=1)=>`${N}1J`.repeat(z),down:(z=1)=>`${N}J`.repeat(z),line:`${N}2K`,lineEnd:`${N}K`,lineStart:`${N}1K`,lines(z){let $="";for(let J=0;J<z;J++)$+=this.line+(J<z-1?y.up():"");if(z)$+=y.left;return $}},Ez={screen:`${Y0}c`};function T6(z,$){let J=[];for(let Q=0;Q<=$.length;Q++)J[Q]=[Q];for(let Q=0;Q<=z.length;Q++)J[0][Q]=Q;for(let Q=1;Q<=$.length;Q++)for(let Z=1;Z<=z.length;Z++)if($.charAt(Q-1)===z.charAt(Z-1))J[Q][Z]=J[Q-1][Z-1];else J[Q][Z]=Math.min(J[Q-1][Z-1]+1,J[Q][Z-1]+1,J[Q-1][Z]+1);return J[$.length][z.length]}function e0(z,$,J=2,Q=3){return $.map((Z)=>({cmd:Z,distance:T6(z,Z)})).filter(({distance:Z})=>Z<=J).sort((Z,Y)=>Z.distance-Y.distance).slice(0,Q).map(({cmd:Z})=>Z)}class z6{rawName;description;name;names;isBoolean;required;config;negated;constructor(z,$,J){if(this.rawName=z,this.description=$,this.config=Object.assign({},J),z=z.replace(/\.\*/g,""),this.negated=!1,this.names=W0(z).split(",").map((Q)=>{let Z=Q.trim().replace(/^-{1,2}/,"");if(Z.startsWith("no-"))this.negated=!0,Z=Z.replace(/^no-/,"");return s0(Z)}).sort((Q,Z)=>Q.length>Z.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(z.includes("<"))this.required=!0;else if(z.includes("["))this.required=!1;else this.isBoolean=!0}}var Cz=L0.argv,k6=`${L0.platform}-${L0.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,i0=J0.argv,m6=`${J0.platform}-${J0.arch} node-${J0.version}`;class w0{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(z,$,J,Q){this.rawName=z,this.description=$,this.config=J,this.cli=Q,this.options=[],this.aliasNames=[],this.name=W0(z);let Z=W0(z),Y=Z.indexOf(":");if(Y>0)this.namespace=Z.substring(0,Y),this.name=Z.substring(Y+1);if(this.args=h6(z),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!J)this.config={}}usage(z){return this.usageText=z,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(z,$="-v, --version"){return this.versionNumber=z,this.option($,"Display version number"),this}example(z){return this.examples.push(z),this}option(z,$,J){let Q=new z6(z,$,J);return this.options.push(Q),this}alias(z){return this.aliasNames.push(z),this}action(z){return this.commandAction=z,this}before(z){return this.beforeHooks.push(z),this}after(z){return this.afterHooks.push(z),this}use(z){return this.middleware.push(z),this}isMatched(z){if(this.aliasNames.includes(z))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===z;return this.name===z}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof N0}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(z){return z=z.split(".")[0],!!this.options.find(($)=>{return $.names.includes(z)})}outputHelp(){let{name:z,commands:$}=this.cli,{versionNumber:J,options:Q,helpCallback:Z}=this.cli.globalCommand,Y=[{body:`${z}${J?`/${J}`:""}`}];if(Y.push({title:"Usage",body:` $ ${z} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&$.length>0){let U=l0($.map((V)=>V.rawName)),F=new Map,H=[];for(let V of $)if(V.namespace){if(!F.has(V.namespace))F.set(V.namespace,[]);F.get(V.namespace).push(V)}else H.push(V);let G="";if(H.length>0)G+=H.map((V)=>{return` ${M0(V.rawName,U.length)} ${V.description}`}).join(`
7
- `);let K=Array.from(F.keys()).sort();for(let V of K){let b=F.get(V);if(G.length>0)G+=`
8
-
9
- `;G+=` ${V}:
10
- `,G+=b.map((T)=>{return` ${M0(T.rawName,U.length-2)} ${T.description}`}).join(`
11
- `)}Y.push({title:"Commands",body:G}),Y.push({title:"For more info, run any command with the `--help` flag",body:$.map((V)=>` $ ${z}${V.displayName===""?"":` ${V.displayName}`} --help`).join(`
12
- `)})}let X=this.isGlobalCommand?Q:[...this.options,...Q||[]];if(!this.isGlobalCommand&&!this.isDefaultCommand)X=X.filter((U)=>U.name!=="version");if(X.length>0){let U=l0(X.map((F)=>F.rawName));Y.push({title:"Options",body:X.map((F)=>{return` ${M0(F.rawName,U.length)} ${F.description} ${F.config.default===void 0?"":`(default: ${F.config.default})`}`}).join(`
13
- `)})}if(this.examples.length>0)Y.push({title:"Examples",body:this.examples.map((U)=>{if(typeof U==="function")return U(z);return U}).join(`
14
- `)});if(Z)Y=Z(Y)||Y;console.log(Y.map((U)=>{return U.title?`${U.title}:
15
- ${U.body}`:U.body}).join(`
16
-
17
- `))}outputVersion(){let{name:z}=this.cli,{versionNumber:$}=this.cli.globalCommand;if($)console.log(`${z}/${$} ${typeof Bun<"u"?k6:m6}`)}checkRequiredArgs(){let z=this.args.filter(($)=>$.required).length;if(this.cli.args.length<z){let J=this.args.filter((Z)=>Z.required).slice(this.cli.args.length),Q=J.map((Z)=>`<${Z.value}>`).join(" ");throw new $0(`Missing required argument${J.length>1?"s":""}: ${Q}
18
-
19
- Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`)}}checkUnknownOptions(){let{options:z,globalCommand:$}=this.cli;if(!this.config.allowUnknownOptions){for(let J of Object.keys(z))if(J!=="--"&&!this.hasOption(J)&&!$.hasOption(J)){let Z=[...$.options,...this.options].flatMap((U)=>U.names),Y=J.length>1?`--${J}`:`-${J}`,q=e0(J,Z),X=`Unknown option \`${Y}\``;if(q.length>0)X+=`
20
-
21
- Did you mean one of these?`,q.forEach((U)=>{let F=U.length>1?`--${U}`:`-${U}`;X+=`
22
- \u2022 ${F}`});throw X+=`
23
-
24
- Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new $0(X)}}}checkOptionValue(){let{options:z,globalCommand:$}=this.cli,J=[...$.options,...this.options];for(let Q of J){let Z=z[Q.name.split(".")[0]];if(Q.required){let Y=J.some((q)=>q.negated&&q.names.includes(Q.name));if(Z===!0||Z===!1&&!Y)throw new $0(`Option \`${Q.rawName}\` requires a value.
25
-
26
- Example: ${this.cli.name} ${this.rawName} ${Q.rawName} <value>`)}}}}class N0 extends w0{constructor(z){super("@@global@@","",{},z)}}var u6=w0,m={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]};var o={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function d6(){return!0}function p6(){let z={};z.supportsColor=d6();function $(Q,Z=[]){let Y=Q===""?[]:[...Z,Q],q=function(U){if(!z.supportsColor)return U;let F="",H="";for(let G of Y)if(G in o&&o[G]in m){let K=o[G];F+=m[K][0],H=m[K][1]+H}else if(G in m)F+=m[G][0],H=m[G][1]+H;return F+U+H},X=[...Object.keys(m),...Object.keys(o)];for(let U of X)if(!(U in q))Object.defineProperty(q,U,{get(){return $(U,Y)}});return q}let J=[...Object.keys(m),...Object.keys(o)];for(let Q of J)if(!(Q in z))Object.defineProperty(z,Q,{get(){return $(Q)}});return z}var t=p6();class B0 extends I6{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(z=""){super();this.name=z,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new N0(this),this.globalCommand.usage("<command> [options]")}handleSignals(z){if(this.signalHandlersSet)return this;let $=async(J)=>{if(console.log(`
27
-
28
- Received ${J}, cleaning up...`),z)try{await z()}catch(Q){console.error("Error during cleanup:",Q)}k.exit(0)};return k.on("SIGINT",()=>$("SIGINT")),k.on("SIGTERM",()=>$("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(z=!0){return this.enableDidYouMean=z,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(z){return this.globalCommand.usage(z),this}command(z,$,J){if(!J)J={};let Q=new u6(z,$||"",J,this);return Q.globalCommand=this.globalCommand,this.commands.push(Q),Q}option(z,$,J){return this.globalCommand.option(z,$,J),this}help(z){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=z,this.showHelpOnExit=!0,this}version(z,$="-v, --version"){return this.globalCommand.version(z,$),this.showVersionOnExit=!0,this}example(z){return this.globalCommand.example(z),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:z,options:$},J,Q){if(this.args=z,this.options=$,J)this.matchedCommand=J;if(Q)this.matchedCommandName=Q;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(z){if(console.log(t.red(`
29
- \u2717 Command "${z}" not found.
30
- `)),this.enableDidYouMean){let $=[];for(let Q of this.commands){if(Q.displayName)$.push(Q.displayName);if(Q.aliasNames)$.push(...Q.aliasNames)}let J=e0(z,$);if(J.length>0)console.log(t.yellow("Did you mean one of these?")),J.forEach((Q)=>console.log(` ${t.dim("\u2022")} ${this.name} ${Q}`)),console.log("")}console.log(t.dim("Run"),`${this.name} --help`,t.dim("to see all available commands")),k.exit(1)}async parse(z=i0,$={}){let{run:J=!0,exitOnError:Q=!1}=$;if(Q)try{return await this.parse(z,{run:J})}catch(U){throw this.handleUsageError(U),U}if(this.rawArgs=z,!this.name)this.name=z[1]?y6(z[1]):"cli";let Z=!0,Y=z.slice(2),q=Y[0];if(q&&!q.startsWith("-")){for(let U of this.commands)if(U.isMatched(q)){let F=this.mri(Y,U);Z=!1;let H={...F,args:F.args.slice(1)};this.setParsedInfo(H,U,q),this.emit(`command:${q}`,U);break}}if(Z){for(let U of this.commands)if(U.name===""){Z=!1;let F=this.mri(Y,U);this.setParsedInfo(F,U),this.emit("command:!",U);break}}if(Z){let U=this.mri(z.slice(2));this.setParsedInfo(U)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji!==void 0)this.useEmoji=!this.options.noEmoji;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache!==void 0)this.isNoCache=Boolean(this.options.noCache);if(this.options.help&&this.showHelpOnExit)this.outputHelp(),J=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),J=!1,this.unsetMatchedCommand();let X={args:this.args,options:this.options};if(J)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return X}mri(z,$){let J=[...this.globalCommand.options,...$?$.options:[]],Q=S6(J),Z=[],Y=z.indexOf("--");if(Y>-1)Z=z.slice(Y+1),z=z.slice(0,Y);let q=C6(z,Q),X={_:q._};for(let K of Object.keys(q))if(K!=="_")X[s0(K)]=q[K];let U=X._,F={"--":Z},H=$&&$.config.ignoreOptionDefaultValue?$.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,G=Object.create(null);for(let K of J){if(!H&&K.config.default!==void 0)for(let V of K.names)F[V]=K.config.default;if(Array.isArray(K.config.type)){if(G[K.name]===void 0)G[K.name]={shouldTransform:!0,transformFunction:K.config.type[0]}}}for(let K of Object.keys(X))if(K!=="_"){let V=K.split(".");v6(F,V,X[K]),_6(F,G)}return{args:U,options:F}}async run(z=i0){return this.parse(z,{run:!0,exitOnError:!0})}handleUsageError(z){if(!(!!z&&typeof z==="object"&&z.name==="ClappError"&&z.isUsageError!==!1))return;let Q=z,Z=Q.message??"command-line error",Y=this.name?`${this.name}: `:"",q=/--help/.test(Z)?"":`
31
- Run \`${this.name??"cli"} --help\` for usage.`;k.stderr.write(`${Y}${Z}${q}
32
- `),k.exit(Q.exitCode??2)}async runMatchedCommand(){let{args:z,options:$,matchedCommand:J}=this;if(!J||!J.commandAction)return;J.checkUnknownOptions(),J.checkOptionValue(),J.checkRequiredArgs();let Q=[];J.args.forEach((X,U)=>{if(X.variadic)Q.push(z.slice(U));else Q.push(z[U])}),Q.push($);let Z={command:J,args:Q,options:$};for(let X of J.beforeHooks)await X(Z);let Y,q=async()=>{let X=J.commandAction.apply(this,Q);if(X instanceof Promise)Y=await X;else Y=X;return Y};if(J.middleware.length>0){let X=0,U=async()=>{if(X<J.middleware.length){let F=J.middleware[X++];await F({...Z,next:U})}else await q()};await U()}else await q();for(let X of J.afterHooks)await X(Z);return Y}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return k.removeAllListeners("SIGINT"),k.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class $6{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(z){if(!this.enabled){this.misses++;return}let $=this.cache.get(z);if(!$){this.misses++;return}if(Date.now()-$.timestamp>$.ttl){this.cache.delete(z),this.misses++;return}return this.hits++,$.value}set(z,$,J=5000){if(!this.enabled)return;this.cache.set(z,{value:$,timestamp:Date.now(),ttl:J})}has(z){if(!this.enabled)return!1;let $=this.cache.get(z);if(!$)return!1;if(Date.now()-$.timestamp>$.ttl)return this.cache.delete(z),!1;return!0}delete(z){this.cache.delete(z)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let z=Date.now();for(let[$,J]of this.cache.entries())if(z-J.timestamp>J.ttl)this.cache.delete($)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var Sz=new $6;function c6(){if("FORCE_COLOR"in s.env)return s.env.FORCE_COLOR!=="0";if("NO_COLOR"in s.env||s.env.TERM==="dumb")return!1;if(s.platform==="win32")return!0;return n0.isatty(1)&&n0.isatty(2)}var J6=c6();function w(z,$){if(!J6)return(J)=>J;return(J)=>z+J+$}var l6=w("\x1B[0m","\x1B[0m"),i6=w("\x1B[31m","\x1B[39m"),n6=w("\x1B[32m","\x1B[39m"),a6=w("\x1B[33m","\x1B[39m"),r6=w("\x1B[34m","\x1B[39m"),o6=w("\x1B[35m","\x1B[39m"),t6=w("\x1B[36m","\x1B[39m"),s6=w("\x1B[37m","\x1B[39m"),e6=w("\x1B[90m","\x1B[39m"),z4=w("\x1B[1m","\x1B[22m"),$4=w("\x1B[3m","\x1B[23m"),J4=w("\x1B[4m","\x1B[24m"),Q4=w("\x1B[2m","\x1B[22m"),Z4=w("\x1B[7m","\x1B[27m"),Y4=w("\x1B[8m","\x1B[28m"),X4=w("\x1B[9m","\x1B[29m"),U4=w("\x1B[41m","\x1B[49m"),q4=w("\x1B[42m","\x1B[49m"),F4=w("\x1B[43m","\x1B[49m"),G4=w("\x1B[44m","\x1B[49m"),H4=w("\x1B[45m","\x1B[49m"),K4=w("\x1B[46m","\x1B[49m"),j4=w("\x1B[47m","\x1B[49m"),V4=J6,M4={reset:l6,red:i6,green:n6,yellow:a6,blue:r6,magenta:o6,cyan:t6,white:s6,gray:e6,bold:z4,italic:$4,underline:J4,dim:Q4,inverse:Z4,hidden:Y4,strikethrough:X4,bgRed:U4,bgGreen:q4,bgYellow:F4,bgBlue:G4,bgMagenta:H4,bgCyan:K4,bgWhite:j4,isColorSupported:V4},Q0=M4,W4=["up","down","left","right","space","enter","cancel"],Z0={actions:new Set(W4),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};function Q6(z,$){if(typeof z==="string")return Z0.aliases.get(z)===$;for(let J of z){if(J===void 0)continue;if(Q6(J,$))return!0}return!1}function L4(z,$){if(z===$)return[];let J=z.split(`
33
- `),Q=$.split(`
34
- `),Z=[];for(let Y=0;Y<Math.max(J.length,Q.length);Y++)if(J[Y]!==Q[Y])Z.push(Y);return Z}var Tz=D4.platform.startsWith("win"),a0=Symbol("clapp:cancel");function z0(z,$){let J=z;if(J.isTTY)J.setRawMode($)}function O4(z){return z.replace(/\x1b\[[0-9;]*m/g,"")}function P4(z){return O4(z).length}function o0(z,$,J){if(!$||$<1)return z;let Q=J?.hard??!1,Z=J?.trim??!0,Y=z.split(`
35
- `),q=[];for(let X of Y){if(P4(X)<=$){q.push(Z?X.trimEnd():X);continue}if(Q){let U="",F=0,H=0;while(H<X.length){let G=X.slice(H).match(/^\x1b\[[0-9;]*m/);if(G){U+=G[0],H+=G[0].length;continue}if(F>=$)q.push(Z?U.trimEnd():U),U="",F=0;U+=X[H],F++,H++}if(U)q.push(Z?U.trimEnd():U)}else q.push(Z?X.trimEnd():X)}return q.join(`
36
- `)}class O0{input;output;_abortSignal;rl;opts;_render;_track=!1;_prevFrame="";_subscribers=new Map;_cursor=0;_manualLine="";state="initial";error="";value;userInput="";constructor(z,$=!0){let{input:J=w4,output:Q=N4,render:Z,signal:Y,...q}=z;this.opts=q,this.onKeypress=this.onKeypress.bind(this),this.close=this.close.bind(this),this.render=this.render.bind(this),this._render=Z.bind(this),this._track=$,this._abortSignal=Y,this.input=J,this.output=Q}unsubscribe(){this._subscribers.clear()}setSubscriber(z,$){let J=this._subscribers.get(z)??[];J.push($),this._subscribers.set(z,J)}on(z,$){return this.setSubscriber(z,{cb:$}),this}once(z,$){return this.setSubscriber(z,{cb:$,once:!0}),this}emit(z,...$){let J=this._subscribers.get(z)??[],Q=[];for(let Z of J)if(Z.cb(...$),Z.once)Q.push(()=>J.splice(J.indexOf(Z),1));for(let Z of Q)Z();return this}prompt(){return new Promise((z)=>{if(this._abortSignal){if(this._abortSignal.aborted)return this.state="cancel",this.close(),z(a0);this._abortSignal.addEventListener("abort",()=>{this.state="cancel",this.close()},{once:!0})}if(this.rl=B4.createInterface({input:this.input,tabSize:2,prompt:"",escapeCodeTimeout:50,terminal:!0}),this.rl.prompt(),this.opts.initialUserInput!==void 0)this._setUserInput(this.opts.initialUserInput,!0);this.input.on("keypress",this.onKeypress),z0(this.input,!0),this.output.on("resize",this.render),this.render(),this.once("submit",()=>{this.output.write(y.show),this.output.off("resize",this.render),z0(this.input,!1),z(this.value)}),this.once("cancel",()=>{this.output.write(y.show),this.output.off("resize",this.render),z0(this.input,!1),z(a0)})})}_isActionKey(z,$){return z==="\t"}_setValue(z){this.value=z,this.emit("value",this.value)}_setUserInput(z,$){if(this.userInput=z??"",this.emit("userInput",this.userInput),$&&this._track&&this.rl)this.rl.write(this.userInput),this._cursor=this.rl.cursor}onKeypress(z,$){if(this._track&&$.name!=="return"){if($.name&&this._isActionKey(z,$))this.rl?.write(null,{ctrl:!0,name:"h"});this._cursor=this.rl?.cursor??0;let J=$.name==="tab"||$.name==="escape"||$.name==="backspace"||$.name==="delete"||$.name==="enter"||$.name==="return"||$.name&&["up","down","left","right"].includes($.name);if(z&&!J&&z.length===1&&z>=" ")this._manualLine+=z;else if($.name==="backspace"&&this._manualLine.length>0)this._manualLine=this._manualLine.slice(0,-1);let Q=this._manualLine.length>=(this.rl?.line?.length||0)?this._manualLine:this.rl?.line;this._setUserInput(Q)}if(this.state==="error")this.state="active",this.error="";if($?.name){if(!this._track&&Z0.aliases.has($.name))this.emit("cursor",Z0.aliases.get($.name));if(Z0.actions.has($.name))this.emit("cursor",$.name)}if(z&&(z.toLowerCase()==="y"||z.toLowerCase()==="n"))this.emit("confirm",z.toLowerCase()==="y");if(this.emit("key",z?.toLowerCase(),$),$?.name==="return"){if(this.opts.validate){let J=this.opts.validate(this.value);if(J)this.error=J instanceof Error?J.message:J,this.state="error"}if(this.state!=="error")this.state="submit"}if(Q6([z,$?.name,$?.sequence],"cancel"))this.state="cancel";if(this.state==="submit"||this.state==="cancel")this.emit("finalize");if(this.render(),this.state==="submit"||this.state==="cancel")this.close()}close(){if(this.input.unpipe(),this.input.removeListener("keypress",this.onKeypress),this.output.write(`
37
- `),z0(this.input,!1),this.rl?.close(),this.rl=void 0,this.emit(`${this.state}`,this.value),this.state==="cancel")setTimeout(()=>{this.unsubscribe()},10);else this.unsubscribe()}restoreCursor(){let z=o0(this._prevFrame,r0.stdout.columns,{hard:!0,trim:!1}).split(`
38
- `).length-1;this.output.write(y.move(-999,z*-1))}render(){let z=o0(this._render(this)??"",r0.stdout.columns,{hard:!0,trim:!1});if(z===this._prevFrame)return;if(this.state==="initial")this.output.write(y.hide);else{let $=L4(this._prevFrame,z);if(this.restoreCursor(),$&&$?.length===1){let J=$[0];this.output.write(y.move(0,J)),this.output.write(D0.lines(1));let Q=z.split(`
39
- `);this.output.write(Q[J]),this._prevFrame=z,this.output.write(y.move(0,Q.length-J-1));return}if($&&$?.length>1){let J=$[0];this.output.write(y.move(0,J)),this.output.write(D0.down());let Z=z.split(`
40
- `).slice(J);this.output.write(Z.join(`
41
- `)),this._prevFrame=z;return}this.output.write(D0.down())}if(this.output.write(z),this.state==="initial")this.state="active";this._prevFrame=z}}function A4(z,$){if(z===void 0)return 0;if($.length===0)return 0;let Q=$.findIndex((Z)=>Z.value===z);return Q!==-1?Q:0}function x4(z,$){return($.label??String($.value)).toLowerCase().includes(z.toLowerCase())}function b4(z,$){if(!$)return;if(z)return $;return $[0]}class R4 extends O0{filteredOptions;multiple;isNavigating=!1;selectedValues=[];focusedValue;#z=0;#J="";#Q;#$;get cursor(){return this.#z}get userInputWithCursor(){if(!this.userInput)return Q0.inverse(Q0.hidden("_"));if(this._cursor>=this.userInput.length)return`${this.userInput}\u2588`;let z=this.userInput.slice(0,this._cursor),[$,...J]=this.userInput.slice(this._cursor);return`${z}${Q0.inverse($)}${J.join("")}`}get options(){if(typeof this.#$==="function")return this.#$();return this.#$}constructor(z){super(z);this.#$=z.options;let $=this.options;this.filteredOptions=[...$],this.multiple=z.multiple===!0,this.#Q=z.filter??x4;let J;if(z.initialValue&&Array.isArray(z.initialValue))if(this.multiple)J=z.initialValue;else J=z.initialValue.slice(0,1);else if(!this.multiple&&this.options.length>0)J=[this.options[0].value];if(J)for(let Q of J){let Z=$.findIndex((Y)=>Y.value===Q);if(Z!==-1)this.toggleSelected(Q),this.#z=Z}this.focusedValue=this.options[this.#z]?.value,this.on("key",(Q,Z)=>this.#Z(Q,Z)),this.on("userInput",(Q)=>this.#Y(Q))}_isActionKey(z,$){return z==="\t"||this.multiple&&this.isNavigating&&$.name==="space"&&z!==void 0&&z!==""}#Z(z,$){let J=$.name==="up",Q=$.name==="down",Z=$.name==="return";if(J||Q){if(this.#z=Math.max(0,Math.min(this.#z+(J?-1:1),this.filteredOptions.length-1)),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)this.selectedValues=[this.focusedValue];this.isNavigating=!0}else if(Z)this.value=b4(this.multiple,this.selectedValues);else if(this.multiple)if(this.focusedValue!==void 0&&($.name==="tab"||this.isNavigating&&$.name==="space"))this.toggleSelected(this.focusedValue);else this.isNavigating=!1;else{if(this.focusedValue)this.selectedValues=[this.focusedValue];this.isNavigating=!1}}deselectAll(){this.selectedValues=[]}toggleSelected(z){if(this.filteredOptions.length===0)return;if(this.multiple)if(this.selectedValues.includes(z))this.selectedValues=this.selectedValues.filter(($)=>$!==z);else this.selectedValues=[...this.selectedValues,z];else this.selectedValues=[z]}#Y(z){if(z!==this.#J){this.#J=z;let $=this.options;if(z)this.filteredOptions=$.filter((J)=>this.#Q(z,J));else this.filteredOptions=[...$];if(this.#z=A4(this.focusedValue,this.filteredOptions),this.focusedValue=this.filteredOptions[this.#z]?.value,!this.multiple)if(this.focusedValue!==void 0)this.toggleSelected(this.focusedValue);else this.deselectAll()}}}class E4 extends O0{options;cursor=0;#z;getGroupItems(z){return this.options.filter(($)=>$.group===z)}isGroupSelected(z){let $=this.getGroupItems(z),J=this.value;if(J===void 0)return!1;return $.every((Q)=>J.includes(Q.value))}toggleValue(){let z=this.options[this.cursor];if(this.value===void 0)this.value=[];if(z.group===!0){let $=String(z.value),J=this.getGroupItems($);if(this.isGroupSelected($))this.value=this.value.filter((Q)=>J.findIndex((Z)=>Z.value===Q)===-1);else this.value=[...this.value,...J.map((Q)=>Q.value)];this.value=Array.from(new Set(this.value))}else{let $=this.value.includes(z.value);this.value=$?this.value.filter((J)=>J!==z.value):[...this.value,z.value]}}constructor(z){super(z,!1);let{options:$}=z;this.#z=z.selectableGroups!==!1,this.options=Object.entries($).flatMap(([J,Q])=>[{value:J,group:!0,label:J},...Q.map((Z)=>({...Z,group:J}))]),this.value=[...z.initialValues??[]],this.cursor=Math.max(this.options.findIndex(({value:J})=>J===z.cursorAt),this.#z?0:1),this.on("cursor",(J)=>{switch(J){case"left":case"up":{this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;let Q=this.options[this.cursor]?.group===!0;if(!this.#z&&Q)this.cursor=this.cursor===0?this.options.length-1:this.cursor-1;break}case"down":case"right":{this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;let Q=this.options[this.cursor]?.group===!0;if(!this.#z&&Q)this.cursor=this.cursor===this.options.length-1?0:this.cursor+1;break}case"space":this.toggleValue();break}})}}var I4=f6();var L=(z,$)=>I4?z:$,uz=L("\u25C6","*"),dz=L("\u25A0","x"),pz=L("\u25B2","x"),cz=L("\u25C7","o"),lz=L("\u250C","T"),C4=L("\u2502","|"),iz=L("\u2514","\u2014"),nz=L("\u25CF",">"),az=L("\u25CB"," "),rz=L("\u25FB","[\u2022]"),oz=L("\u25FC","[+]"),tz=L("\u25FB","[ ]"),sz=L("\u25AA","\u2022"),ez=L("\u2500","-"),z$=L("\u256E","+"),$$=L("\u251C","+"),J$=L("\u256F","+"),Q$=L("\u25CF","\u2022"),Z$=L("\u25C6","*"),Y$=L("\u25B2","!"),X$=L("\u25A0","x");var U$={light:L("\u2500","-"),heavy:L("\u2501","="),block:L("\u2588","#")};function h4(){return`${Q0.gray(C4)} `}var q$=h4();import{existsSync as Dz,readFileSync as Wz}from"fs";function v(z){return{prev:null,next:null,data:z}}class h{head=null;tail=null;cursors=[];allocateCursor(z,$){let J={prev:z,next:$};return this.cursors.push(J),J}releaseCursor(){this.cursors.pop()}updateCursors(z,$,J,Q){for(let Z of this.cursors){if(Z.prev===z)Z.prev=$;if(Z.next===J)Z.next=Q}}static createItem(z){return v(z)}createItem(z){return v(z)}get isEmpty(){return this.head===null}get first(){return this.head?.data??null}get last(){return this.tail?.data??null}*[Symbol.iterator](){for(let z=this.head;z!=null;z=z.next)yield z.data}fromArray(z){let $=null;this.head=null;for(let J of z){let Q=v(J);if(Q.prev=$,$)$.next=Q;else this.head=Q;$=Q}return this.tail=$,this}toArray(){let z=[];for(let $=this.head;$!=null;$=$.next)z.push($.data);return z}toJSON(){return this.toArray()}forEach(z,$){let J=this.allocateCursor(null,this.head);while(J.next!==null){let Q=J.next;J.prev=Q,J.next=Q.next,z.call($,Q.data,Q,this)}this.releaseCursor()}forEachRight(z,$){let J=this.allocateCursor(this.tail,null);while(J.prev!==null){let Q=J.prev;J.next=Q,J.prev=Q.prev,z.call($,Q.data,Q,this)}this.releaseCursor()}reduce(z,$){let J=$,Q=0;for(let Z=this.head;Z!=null;Z=Z.next)J=z(J,Z.data,Q++,this);return J}some(z){let $=0;for(let J=this.head;J!=null;J=J.next)if(z(J.data,$++,this))return!0;return!1}map(z){let $=new h,J=null,Q=0;for(let Z=this.head;Z!=null;Z=Z.next){let Y=v(z(Z.data,Q++,this));if(Y.prev=J,J)J.next=Y;else $.head=Y;J=Y}return $.tail=J,$}filter(z){let $=new h,J=null,Q=0;for(let Z=this.head;Z!=null;Z=Z.next)if(z(Z.data,Q++,this)){let Y=v(Z.data);if(Y.prev=J,J)J.next=Y;else $.head=Y;J=Y}return $.tail=J,$}clear(){let z=this.head;while(z){let $=z.next;z.prev=null,z.next=null,z=$}this.head=null,this.tail=null}copy(){let z=new h,$=null;for(let J=this.head;J!=null;J=J.next){let Q=v(J.data);if(Q.prev=$,$)$.next=Q;else z.head=Q;$=Q}return z.tail=$,z}prepend(z){return this.insert(z,this.head)}prependData(z){return this.insert(v(z),this.head)}append(z){return this.insert(z,null)}appendData(z){return this.insert(v(z),null)}insert(z,$=null){if($!=null)if(this.updateCursors($.prev,z,$,z),$.prev===null){if(this.head!==$)throw Error("before doesn't belong to list");this.head=z,$.prev=z,z.next=$,this.updateCursors(null,z,null,null)}else $.prev.next=z,z.prev=$.prev,$.prev=z,z.next=$;else if(this.updateCursors(this.tail,z,null,z),this.tail!==null)this.tail.next=z,z.prev=this.tail,this.tail=z;else this.head=z,this.tail=z;return this}insertData(z,$=null){return this.insert(v(z),$)}remove(z){if(this.updateCursors(z,z.prev,z,z.next),z.prev!==null)z.prev.next=z.next;else if(this.head===z)this.head=z.next;else throw Error("item doesn't belong to list");if(z.next!==null)z.next.prev=z.prev;else if(this.tail===z)this.tail=z.prev;else throw Error("item doesn't belong to list");return z.prev=null,z.next=null,z}push(z){this.insert(v(z),null)}pop(){if(this.tail===null)return null;return this.remove(this.tail)}unshift(z){this.prependData(z)}shift(){if(this.head===null)return null;return this.remove(this.head)}prependList(z){return this.insertList(z,this.head)}appendList(z){return this.insertList(z,null)}insertList(z,$=null){if(z.head===null)return this;if($!==null){if(this.updateCursors($.prev,z.tail,$,z.head),$.prev!==null)$.prev.next=z.head,z.head.prev=$.prev;else this.head=z.head;$.prev=z.tail,z.tail.next=$}else{if(this.updateCursors(this.tail,z.tail,null,z.head),this.tail!==null)this.tail.next=z.head,z.head.prev=this.tail;else this.head=z.head;this.tail=z.tail}return z.head=null,z.tail=null,this}replace(z,$){if($ instanceof h)this.insertList($,z),this.remove(z);else this.insert($,z),this.remove(z)}}function P(z){switch(z.type){case"StyleSheet":return I(z.children,"");case"Rule":return`${P(z.prelude)}{${P(z.block)}}`;case"Block":return S4(z.children);case"Atrule":{let $=`@${z.name}`;if(z.prelude){let J=P(z.prelude);if(J)$+=` ${J}`}if(z.block)$+=`{${P(z.block)}}`;else $+=";";return $}case"AtrulePrelude":return I(z.children,"");case"SelectorList":return I(z.children,",");case"Selector":return I(z.children,"");case"TypeSelector":return z.name;case"IdSelector":return`#${z.name}`;case"ClassSelector":return`.${z.name}`;case"NestingSelector":return"&";case"AttributeSelector":{let $=`[${z.name.name}`;if(z.matcher&&z.value)if($+=z.matcher,z.value.type==="String")$+=`"${P0(z.value.value)}"`;else $+=z.value.name;if(z.flags)$+=` ${z.flags}`;return $+="]",$}case"PseudoClassSelector":return z.children?`:${z.name}(${I(z.children,"")})`:`:${z.name}`;case"PseudoElementSelector":return z.children?`::${z.name}(${I(z.children,"")})`:`::${z.name}`;case"Combinator":return z.name===" "?" ":z.name;case"Declaration":return`${z.property}:${P(z.value)}${z.important?"!important":""}`;case"DeclarationList":return I(z.children,";");case"Value":return I(z.children,"");case"Identifier":return z.name;case"Number":return z.value;case"Percentage":return`${z.value}%`;case"Dimension":return z.value+z.unit;case"String":return`"${P0(z.value)}"`;case"Url":return/[\s"'()\\\u0000-\u001F\u007F]/.test(z.value)?`url("${P0(z.value)}")`:`url(${z.value})`;case"Hash":return`#${z.name}`;case"Operator":return z.value;case"Function":return`${z.name}(${I(z.children,"")})`;case"Parentheses":return`(${I(z.children,"")})`;case"Brackets":return`[${I(z.children,"")}]`;case"Raw":return z.value;case"Comment":return z.value.startsWith("!")?`/*${z.value}*/`:"";case"WhiteSpace":return" ";case"CDO":return"<!--";case"CDC":return"-->";case"AnPlusB":{let $=z.a??"",J=z.b??"";if($&&J){let Q=Number(J);return`${$==="1"?"":$==="-1"?"-":$}n${Q>=0?`+${J}`:J}`}if($)return`${$==="1"?"":$==="-1"?"-":$}n`;return J}case"Ratio":return`${z.left.value}/${z.right.value}`;case"UnicodeRange":return z.value;case"Nth":return z.selector?`${P(z.nth)} of ${P(z.selector)}`:P(z.nth);case"MediaQueryList":return I(z.children,",");case"MediaQuery":return I(z.children,"");case"MediaFeature":{let $=`(${z.name}`;if(z.value)$+=`:${P(z.value)}`;return $+=")",$}}return""}function I(z,$){let J="",Q=!0,Z=null,Y=z.head;while(Y!=null){let q=Y.data;if(q.type==="WhiteSpace"){let U=Y.next?Y.next.data:null;if(Z6(Z)||Z6(U)){Y=Y.next;continue}}let X=P(q);if(!X){Y=Y.next;continue}if(!Q&&$&&!v4(Z))J+=$;Q=!1,J+=X,Z=q,Y=Y.next}return J}function S4(z){let $="",J=null,Q=z.head;while(Q!=null){let Z=Q.data,Y=P(Z);if(!Y){Q=Q.next;continue}if(J&&g4(J,Z))$+=";";$+=Y,J=Z,Q=Q.next}return $}function g4(z,$){return z.type==="Declaration"&&$.type!=="Comment"}function Z6(z){if(!z||z.type!=="Operator")return!1;let $=z.value;return $===":"||$===","||$==="/"}function v4(z){if(!z)return!1;return z.type==="Operator"||z.type==="Combinator"}function P0(z){let $="";for(let J=0;J<z.length;J++){let Q=z.charCodeAt(J);if(Q===92)$+="\\\\";else if(Q===34)$+="\\\"";else if(Q<32||Q===127){let Z=Q.toString(16),Y=J+1<z.length?z.charCodeAt(J+1):-1,q=Y===32||Y===9||Y===10||Y===12||Y===13||Y>=48&&Y<=57||Y>=65&&Y<=70||Y>=97&&Y<=102;$+=`\\${Z}${q?" ":""}`}else $+=z[J]}return $}var p=(()=>{let z=new Uint8Array(128);for(let $=0;$<128;$++){let J=0;if($===32||$===9||$===10||$===12||$===13)J|=1;if($>=48&&$<=57)J|=2;if($>=48&&$<=57||$>=65&&$<=70||$>=97&&$<=102)J|=4;if($>=65&&$<=90||$>=97&&$<=122||$===95)J|=8;if($===10||$===12||$===13)J|=16;z[$]=J}return z})();function S(z){return z<128&&(p[z]&2)!==0}function e(z){return z<128&&(p[z]&4)!==0}function Y6(z){return z>=128||z<128&&(p[z]&8)!==0}function _4(z){return z===45||z>=128||z<128&&(p[z]&10)!==0}function y4(z){return z>=0&&z<=8||z===11||z>=14&&z<=31||z===127}function x0(z){return z<128&&(p[z]&16)!==0}function f(z){return z<128&&(p[z]&1)!==0}function d(z,$){if(z!==92)return!1;if(x0($))return!1;return!0}function A0(z,$,J){if(z===45)return Y6($)||$===45||d($,J);if(Y6(z))return!0;if(z===92)return d(z,$);return!1}function f4(z,$,J){if(z===43||z===45){if(S($))return!0;if($===46&&S(J))return!0;return!1}if(z===46)return S($);return S(z)}class X0{source;offset=0;types;starts;ends;count=0;_tokens=null;_lineStarts=null;constructor(z){this.source=z;let $=Math.max(64,Math.ceil(z.length/3));this.types=new Uint8Array($),this.starts=new Uint32Array($),this.ends=new Uint32Array($),this.tokenize()}get lineStarts(){if(this._lineStarts==null)this._lineStarts=T4(this.source);return this._lineStarts}get tokens(){if(this._tokens!=null)return this._tokens;let z=Array.from({length:this.count});for(let $=0;$<this.count;$++)z[$]={type:this.types[$],start:this.starts[$],end:this.ends[$]};return this._tokens=z,z}addToken(z,$,J){if(this.count>=this.types.length)this.grow();this.types[this.count]=z,this.starts[this.count]=$,this.ends[this.count]=J,this.count++}grow(){let $=this.types.length*2,J=new Uint8Array($);J.set(this.types),this.types=J;let Q=new Uint32Array($);Q.set(this.starts),this.starts=Q;let Z=new Uint32Array($);Z.set(this.ends),this.ends=Z}tokenize(){let z=this.source,$=0,J=z.length;while($<J){let Q=z.charCodeAt($);if(Q===47&&z.charCodeAt($+1)===42){let q=$;$+=2;while($<J&&!(z.charCodeAt($)===42&&z.charCodeAt($+1)===47))$++;$=$<J?$+2:J,this.addToken(25,q,$);continue}if(f(Q)){let q=$;while($<J&&f(z.charCodeAt($)))$++;this.addToken(13,q,$);continue}if(Q===34||Q===39){$=this.consumeString(Q,$);continue}if(Q===35){if($+1<J&&(_4(z.charCodeAt($+1))||d(z.charCodeAt($+1),z.charCodeAt($+2)))){let q=$;$++,$=this.consumeName($),this.addToken(4,q,$);continue}this.addToken(9,$,$+1),$++;continue}switch(Q){case 40:this.addToken(21,$,$+1),$++;continue;case 41:this.addToken(22,$,$+1),$++;continue;case 91:this.addToken(19,$,$+1),$++;continue;case 93:this.addToken(20,$,$+1),$++;continue;case 123:this.addToken(23,$,$+1),$++;continue;case 125:this.addToken(24,$,$+1),$++;continue;case 44:this.addToken(18,$,$+1),$++;continue;case 58:this.addToken(16,$,$+1),$++;continue;case 59:this.addToken(17,$,$+1),$++;continue}if(Q===60&&z.startsWith("!--",$+1)){this.addToken(14,$,$+4),$+=4;continue}if(Q===45&&z.startsWith("->",$+1)){this.addToken(15,$,$+3),$+=3;continue}if(Q===64){let q=z.charCodeAt($+1),X=z.charCodeAt($+2),U=z.charCodeAt($+3);if(A0(q,X,U)){let F=$;$++,$=this.consumeName($),this.addToken(3,F,$);continue}this.addToken(9,$,$+1),$++;continue}let Z=z.charCodeAt($+1),Y=z.charCodeAt($+2);if(f4(Q,Z,Y)){$=this.consumeNumeric($);continue}if(A0(Q,Z,Y)){$=this.consumeIdentLike($);continue}if(Q===92){if(d(Q,Z)){$=this.consumeIdentLike($);continue}this.addToken(9,$,$+1),$++;continue}this.addToken(9,$,$+1),$++}this.addToken(0,J,J)}consumeString(z,$){let J=this.source,Q=J.length,Z=$+1;while(Z<Q){let Y=J.charCodeAt(Z);if(Y===z)return Z++,this.addToken(5,$,Z),Z;if(x0(Y))return this.addToken(6,$,Z),Z;if(Y===92){let q=J.charCodeAt(Z+1);if(x0(q)){Z+=2;continue}if(Z+1<Q){Z=this.consumeEscapeSkip(Z+1);continue}}Z++}return this.addToken(5,$,Z),Z}consumeEscapeSkip(z){let $=this.source;if(z>=$.length)return z;let J=$.charCodeAt(z);if(e(J)){let Q=1;z++;while(Q<6&&z<$.length&&e($.charCodeAt(z)))z++,Q++;if(z<$.length&&f($.charCodeAt(z)))z++;return z}return z+1}consumeName(z){let $=this.source,J=$.length,Q=z;while(Q<J){let Z=$.charCodeAt(Q);if(Z<128&&(p[Z]&10)!==0){Q++;continue}if(Z===45){Q++;continue}if(Z>=128){Q++;continue}if(Z===92&&d(Z,$.charCodeAt(Q+1))){Q=this.consumeEscapeSkip(Q+1);continue}break}return Q}consumeNumber(z){let $=this.source,J=z;if($.charCodeAt(J)===43||$.charCodeAt(J)===45)J++;while(J<$.length&&S($.charCodeAt(J)))J++;if($.charCodeAt(J)===46&&S($.charCodeAt(J+1))){J+=2;while(J<$.length&&S($.charCodeAt(J)))J++}let Q=$.charCodeAt(J);if(Q===69||Q===101){let Z=$.charCodeAt(J+1),Y=$.charCodeAt(J+2);if(S(Z)){J+=2;while(J<$.length&&S($.charCodeAt(J)))J++}else if((Z===43||Z===45)&&S(Y)){J+=3;while(J<$.length&&S($.charCodeAt(J)))J++}}return J}consumeNumeric(z){let $=this.source,J=this.consumeNumber(z),Q=$.charCodeAt(J),Z=$.charCodeAt(J+1),Y=$.charCodeAt(J+2);if(A0(Q,Z,Y)){let q=this.consumeName(J);return this.addToken(12,z,q),q}if(Q===37)return this.addToken(11,z,J+1),J+1;return this.addToken(10,z,J),J}consumeIdentLike(z){let $=this.source,J=this.consumeName(z),Q=$.charCodeAt(J);if(Q===40&&J-z===3){let Z=$.charCodeAt(z)|32,Y=$.charCodeAt(z+1)|32,q=$.charCodeAt(z+2)|32;if(Z===117&&Y===114&&q===108){let X=J+1;while(X<$.length&&f($.charCodeAt(X)))X++;let U=$.charCodeAt(X);if(U===34||U===39)return this.addToken(2,z,J+1),J+1;return this.consumeUrl(z,J)}}if(Q===40)return this.addToken(2,z,J+1),J+1;return this.addToken(1,z,J),J}consumeUrl(z,$){let J=this.source,Q=J.length,Z=$+1;while(Z<Q&&f(J.charCodeAt(Z)))Z++;while(Z<Q){let Y=J.charCodeAt(Z);if(Y===41)return Z++,this.addToken(7,z,Z),Z;if(f(Y)){let q=Z;while(Z<Q&&f(J.charCodeAt(Z)))Z++;if(Z>=Q)return this.addToken(7,z,Z),Z;if(J.charCodeAt(Z)===41)return Z++,this.addToken(7,z,Z),Z;return this.consumeBadUrl(z,q)}if(Y===34||Y===39||Y===40||y4(Y))return this.consumeBadUrl(z,Z);if(Y===92){if(d(Y,J.charCodeAt(Z+1))){Z=this.consumeEscapeSkip(Z+1);continue}return this.consumeBadUrl(z,Z)}Z++}return this.addToken(7,z,Z),Z}consumeBadUrl(z,$){let J=this.source,Q=$;while(Q<J.length){let Z=J.charCodeAt(Q);if(Z===41){Q++;break}if(Z===92&&d(Z,J.charCodeAt(Q+1))){Q=this.consumeEscapeSkip(Q+1);continue}Q++}return this.addToken(8,z,Q),Q}locate(z){let $=this.lineStarts,J=0,Q=$.length-1;while(J<Q){let Y=J+Q+1>>1;if($[Y]<=z)J=Y;else Q=Y-1}let Z=$[J];return{line:J+1,column:z-Z+1}}}function T4(z){let $=[0],J=z.length;for(let Q=0;Q<J;Q++){let Z=z.charCodeAt(Q);if(Z===10)$.push(Q+1);else if(Z===13){if(z.charCodeAt(Q+1)!==10)$.push(Q+1)}}return $}function b0(z,$,J){for(let Q=$;Q<J;Q++)if(z.charCodeAt(Q)===92)return k4(z,$,J,Q);return z.slice($,J)}function k4(z,$,J,Q){let Z=z.slice($,Q),Y=Q;while(Y<J){if(z.charCodeAt(Y)!==92){Z+=z[Y],Y++;continue}if(Y+1>=J){Y++;continue}let X=z.charCodeAt(Y+1);if(X===10){Y+=2;continue}if(X===13){Y+=z.charCodeAt(Y+2)===10?3:2;continue}if(e(X)){let U=Y+1,F="";while(F.length<6&&U<J&&e(z.charCodeAt(U)))F+=z[U],U++;let H=Number.parseInt(F,16);if(U<J&&f(z.charCodeAt(U)))U++;Z+=H===0||H>=55296&&H<=57343||H>1114111?String.fromCodePoint(65533):String.fromCodePoint(H),Y=U;continue}Z+=z[Y+1],Y+=2}return Z}function R0(z,$,J){for(let Q=$;Q<J;Q++)if(z.charCodeAt(Q)===92)return m4(z,$,J,Q);return z.slice($,J)}function m4(z,$,J,Q){let Z=z.slice($,Q),Y=Q;while(Y<J){if(z.charCodeAt(Y)!==92){Z+=z[Y],Y++;continue}let X=Y+1,U="";while(U.length<6&&X<J&&e(z.charCodeAt(X)))U+=z[X],X++;if(U.length>0){let F=Number.parseInt(U,16);if(X<J&&f(z.charCodeAt(X)))X++;Z+=F===0||F>=55296&&F<=57343||F>1114111?String.fromCodePoint(65533):String.fromCodePoint(F),Y=X;continue}if(X<J){Z+=z[X],Y=X+1;continue}Z+=String.fromCodePoint(65533),Y=X}return Z}function K6(z,$){let J=new X0(z);return{source:z,types:J.types,starts:J.starts,ends:J.ends,count:J.count,end:J.count,pos:0,positions:$.positions??!1,filename:$.filename,parseValue:$.parseValue??!0,parseAtrulePrelude:$.parseAtrulePrelude??!0,parseCustomProperty:$.parseCustomProperty??!1,parseRulePrelude:$.parseRulePrelude??!0,onParseError:$.onParseError,tokenizer:J}}function j(z){return z.pos<z.end?z.types[z.pos]:0}function M(z){let $=z.pos;if($>=z.end)return{type:0,start:z.starts[$]??z.source.length,end:z.ends[$]??z.source.length};return{type:z.types[$],start:z.starts[$],end:z.ends[$]}}function D(z){let $=z.pos++;if($>=z.end)return{type:0,start:z.starts[$]??z.source.length,end:z.ends[$]??z.source.length};return{type:z.types[$],start:z.starts[$],end:z.ends[$]}}function _(z,$){return z.source.slice($.start,$.end)}function g(z){let{types:$,end:J}=z;while(z.pos<J){let Q=$[z.pos];if(Q===13||Q===25)z.pos++;else break}}function X6(z){let{types:$,end:J}=z;while(z.pos<J&&$[z.pos]===13)z.pos++}function W(z,$,J){if(!z.positions)return null;let Q=z.tokenizer.locate($.start),Z=z.tokenizer.locate(J.end);return{source:z.filename??"<unknown>",start:{offset:$.start,line:Q.line,column:Q.column},end:{offset:J.end,line:Z.line,column:Z.column}}}function j6(z){if(!z.positions)return null;let $=M(z),J=z.tokenizer.locate($.start);return{source:z.filename??"<unknown>",start:{offset:$.start,line:J.line,column:J.column},end:{offset:$.start,line:J.line,column:J.column}}}function U0(z,$,J,Q){return{type:"Raw",value:z,loc:W(Q,$,J)}}function x(){return new h}function E0(z,$,J,Q){if(z.onParseError){let{line:Z,column:Y}=z.tokenizer.locate(J.start),q=SyntaxError(`${z.filename??"<input>"}:${Z}:${Y}: ${$}`);q.line=Z,q.column=Y,q.offset=J.start,z.onParseError(q,Q)}return Q}function c(z,$={}){let J=K6(z,$);switch($.context??"stylesheet"){case"stylesheet":return F6(J);case"atrule":return F0(J)??U6(J);case"atrulePrelude":return c4(J);case"mediaQuery":case"mediaQueryList":return q6(J);case"rule":return C0(J);case"selectorList":return g0(J);case"selector":return W6(J);case"block":return h0(J);case"declarationList":return n4(J);case"declaration":return S0(J)??U6(J);case"value":return a4(J);case"raw":return q6(J);default:return F6(J)}}function U6(z){return{type:"StyleSheet",children:x(),loc:j6(z)}}function q6(z){let $=M(z),J=$;while(j(z)!==0)J=D(z);return{type:"Raw",value:z.source.slice($.start,J.end),loc:W(z,$,J)}}function F6(z){let $=M(z),J=x(),Q=z.types,Z=z.end;while(z.pos<Z){let X=Q[z.pos];if(X===13){z.pos++;continue}if(X===25){let H={type:25,start:z.starts[z.pos],end:z.ends[z.pos]},G=I0(z,H);z.pos++,J.appendData(G);continue}if(X===0)break;if(X===14||X===15){z.pos++;continue}if(X===3){let H=F0(z);if(H)J.appendData(H);continue}if(X===24){z.pos++;continue}let U=z.pos,F=C0(z);if(J.appendData(F),z.pos===U)z.pos++}let Y=z.end-1,q=Y>=0?{type:z.types[Y],start:z.starts[Y],end:z.ends[Y]}:{type:0,start:0,end:0};return{type:"StyleSheet",children:J,loc:W(z,$,q)}}function I0(z,$){return{type:"Comment",value:z.source.slice($.start+2,$.end-2),loc:W(z,$,$)}}function F0(z){let $=M(z);if($.type!==3)return null;z.pos++;let J=q0(z.source,$.start+1,$.end);g(z);let Q=z.pos,Z=M(z),Y=z.types,q=z.end,X=Q,U=Q;while(X<q){let G=Y[X];if(G===0||G===17||G===23)break;if(G!==13&&G!==25)U=X+1;X++}let F=null;if(U>Q){let G=z.starts[Q],K=z.ends[U-1],V={type:Y[U-1],start:z.starts[U-1],end:K},b=z.source.slice(G,K).trim();if(b.length>0)if(z.parseAtrulePrelude)try{let T=z.end;z.end=U,z.pos=Q;let C=x();while(j(z)!==0){let a=l(z);if(a)C.appendData(a)}if(M6(C),z.end=T,z.pos=X,C.isEmpty)F=U0(b,Z,V,z);else F={type:"AtrulePrelude",children:C,loc:null}}catch(T){let C=U0(b,Z,V,z);E0(z,`Failed to parse @${J} prelude: ${T.message}`,Z,C),F=C,z.pos=X}else F=U0(b,Z,V,z),z.pos=X;else z.pos=X}else z.pos=X;let H=null;if(j(z)===17)D(z);else if(j(z)===23)H=h0(z,p4.has(J));return{type:"Atrule",name:J,prelude:F,block:H,loc:W(z,$,M(z))}}var d4=new Set(["is","not","where","has","matches","-moz-any","-webkit-any"]),p4=new Set(["media","supports","document","layer","container","scope","starting-style","-moz-document","keyframes","-webkit-keyframes","-moz-keyframes","-o-keyframes"]);function c4(z){let $=M(z),J=x();while(j(z)!==0){if(M(z).type===13){z.pos++;continue}let Z=l(z);if(Z)J.appendData(Z)}return{type:"AtrulePrelude",children:J,loc:W(z,$,M(z))}}function C0(z){let $=M(z),J;if(z.parseRulePrelude)J=g0(z);else{let Z=M(z),Y=Z;while(j(z)!==0&&j(z)!==23)Y=D(z);let q=z.source.slice(Z.start,Y.end).trim();J=U0(q,Z,Y,z)}let Q=h0(z,!0);return{type:"Rule",prelude:J,block:Q,loc:W(z,$,M(z))}}function h0(z,$=!1){let J=M(z);if(j(z)!==23)return{type:"Block",children:x(),loc:j6(z)};z.pos++;let Q=x(),Z=z.types,Y=z.end;while(z.pos<Y){let q=Z[z.pos];if(q===24||q===0)break;if(q===13){z.pos++;continue}if(q===25){let U={type:25,start:z.starts[z.pos],end:z.ends[z.pos]};z.pos++,Q.appendData(I0(z,U));continue}if(q===3){let U=F0(z);if(U)Q.appendData(U);continue}if($&&l4(z,i4)){let U=C0(z);Q.appendData(U);continue}let X=S0(z);if(X)Q.appendData(X);if(z.pos<Y&&Z[z.pos]===17)z.pos++}if(j(z)===24)z.pos++;return{type:"Block",children:Q,loc:W(z,J,M(z))}}function l4(z,$){let J=z.pos,Q=$(z);return z.pos=J,Q}function i4(z){let{types:$,end:J}=z;while(z.pos<J){let Q=$[z.pos];if(Q===23)return!0;if(Q===17||Q===24||Q===0)return!1;z.pos++}return!1}function n4(z){let $=M(z),J=x();while(j(z)!==0&&j(z)!==24){let Q=M(z);if(Q.type===13){z.pos++;continue}if(Q.type===25){J.appendData(I0(z,D(z)));continue}if(Q.type===17){z.pos++;continue}if(Q.type===3){let Y=F0(z);if(Y)J.appendData(Y);continue}let Z=S0(z);if(Z)J.appendData(Z);if(j(z)===17)D(z)}return{type:"DeclarationList",children:J,loc:W(z,$,M(z))}}function S0(z){g(z);let $=M(z);if($.type!==1&&$.type!==4&&!($.type===9&&z.source[$.start]==="*"&&z.source[$.start+1]===" "))if($.type===9&&z.source[$.start]==="*")z.pos++;else{E0(z,"Expected property name",$,{type:"Raw",value:"",loc:null});let{types:R,end:E}=z;while(z.pos<E){let O=R[z.pos];if(O===0||O===17||O===24)break;z.pos++}return null}let J=z.starts[z.pos],Q=z.ends[z.pos];z.pos++;let Z=z.source.slice(J,Q);if(X6(z),j(z)!==16){E0(z,`Expected ':' after property "${Z}"`,M(z),{type:"Raw",value:"",loc:null});let{types:R,end:E}=z;while(z.pos<E){let O=R[z.pos];if(O===0||O===17||O===24)break;z.pos++}return null}z.pos++,X6(z);let{types:Y,starts:q,end:X,pos:U}=z,F=U,H=U,G=-1,K=-1;while(F<X){let R=Y[F];if(R===0||R===17||R===24)break;if(R===9&&z.source.charCodeAt(q[F])===33){let E=F+1;while(E<X&&Y[E]===13)E++;if(E<X&&Y[E]===1){let O=q[E];if(z.ends[E]-O===9&&(z.source.charCodeAt(O)|32)===105&&(z.source.charCodeAt(O+1)|32)===109&&(z.source.charCodeAt(O+2)|32)===112&&(z.source.charCodeAt(O+3)|32)===111&&(z.source.charCodeAt(O+4)|32)===114&&(z.source.charCodeAt(O+5)|32)===116&&(z.source.charCodeAt(O+6)|32)===97&&(z.source.charCodeAt(O+7)|32)===110&&(z.source.charCodeAt(O+8)|32)===116){K=F,G=E,F=E+1;continue}}}if(R!==13&&R!==25)H=F+1;F++}let V=H,b=G>=0?{type:1,start:q[G],end:z.ends[G]}:null,T=Z.startsWith("--"),C,a=q[U],u0=V>U?z.ends[V-1]:a,K0={type:Y[U],start:a,end:z.ends[U]},d0=V>U?{type:Y[V-1],start:q[V-1],end:u0}:K0;if(T&&!z.parseCustomProperty||!z.parseValue)C={type:"Raw",value:z.source.slice(a,u0).trim(),loc:W(z,K0,d0)};else if(V===U)C={type:"Value",children:x(),loc:W(z,K0,d0)};else{let R=z.end;z.end=V,z.pos=U,C=V6(z),z.end=R}return z.pos=F,{type:"Declaration",property:Z,important:b?!0:!1,value:C,loc:W(z,$,M(z))}}function a4(z){return V6(z)}function V6(z){let $=M(z),J=x();while(j(z)!==0&&j(z)!==17&&j(z)!==24&&j(z)!==22&&j(z)!==20){let Q=l(z);if(Q)J.appendData(Q)}return D6(J),{type:"Value",children:J,loc:W(z,$,M(z))}}function M6(z){for(let $ of z)if("children"in $&&$.children instanceof h)M6($.children);D6(z)}function D6(z){let $=z.head;while($){if($.data.type==="Number"){let J=$.next;while(J&&J.data.type==="WhiteSpace")J=J.next;if(J&&J.data.type==="Operator"&&J.data.value==="/"){let Q=J.next;while(Q&&Q.data.type==="WhiteSpace")Q=Q.next;if(Q&&Q.data.type==="Number"){let Z={type:"Ratio",left:$.data,right:Q.data,loc:null},Y=$.next;while(Y&&Y!==Q.next){let q=Y.next;z.remove(Y),Y=q}z.replace($,z.createItem(Z)),$=z.head;continue}}}$=$.next}}function l(z){let $=z.pos;if($>=z.end)return null;let J=z.types[$],Q=z.starts[$],Z=z.ends[$],Y=z.source;switch(J){case 13:return z.pos++,z.positions?{type:"WhiteSpace",value:" ",loc:A(z,Q,Z)}:{type:"WhiteSpace",value:" ",loc:null};case 25:return z.pos++,{type:"Comment",value:Y.slice(Q+2,Z-2),loc:z.positions?A(z,Q,Z):null};case 10:return z.pos++,{type:"Number",value:Y.slice(Q,Z),loc:z.positions?A(z,Q,Z):null};case 11:return z.pos++,{type:"Percentage",value:Y.slice(Q,Z-1),loc:z.positions?A(z,Q,Z):null};case 12:{z.pos++;let q=Q,X=Y.charCodeAt(q);if(X===43||X===45)q++;let U=!1;while(q<Z){let H=Y.charCodeAt(q);if(H>=48&&H<=57){q++;continue}if(H===46&&!U){U=!0,q++;continue}break}let F=Y.charCodeAt(q);if(F===69||F===101){let H=q+1,G=Y.charCodeAt(H);if(G===43||G===45)H++;let K=!1;while(H<Z){let V=Y.charCodeAt(H);if(V>=48&&V<=57){H++,K=!0;continue}break}if(K)q=H}return{type:"Dimension",value:Y.slice(Q,q),unit:Y.slice(q,Z),loc:z.positions?A(z,Q,Z):null}}case 1:return z.pos++,{type:"Identifier",name:R0(Y,Q,Z),loc:z.positions?A(z,Q,Z):null};case 5:{z.pos++;let q=Q+1,U=Z-Q>=2&&Y.charCodeAt(Z-1)===Y.charCodeAt(Q)?Z-1:Z;return{type:"String",value:b0(Y,q,U),loc:z.positions?A(z,Q,Z):null}}case 7:{z.pos++;let q=Q+4;while(q<Z&&G6(Y.charCodeAt(q)))q++;let X=Z;if(X>q&&Y.charCodeAt(X-1)===41)X--;while(X>q&&G6(Y.charCodeAt(X-1)))X--;let U;if(X-q>=2){let F=Y.charCodeAt(q),H=Y.charCodeAt(X-1);if((F===34||F===39)&&F===H)U=Y.slice(q+1,X-1);else U=Y.slice(q,X)}else U=Y.slice(q,X);return{type:"Url",value:U,loc:z.positions?A(z,Q,Z):null}}case 4:return z.pos++,{type:"Hash",name:Y.slice(Q+1,Z),loc:z.positions?A(z,Q,Z):null};case 2:return o4(z);case 21:return t4(z);case 18:return z.pos++,{type:"Operator",value:",",loc:z.positions?A(z,Q,Z):null};case 16:return z.pos++,{type:"Operator",value:":",loc:z.positions?A(z,Q,Z):null};case 9:{z.pos++;let q=Y.charCodeAt(Q),X=Y[Q];if(r4(q))return{type:"Operator",value:X,loc:z.positions?A(z,Q,Z):null};return{type:"Identifier",name:X,loc:z.positions?A(z,Q,Z):null}}case 19:{z.pos++;let q=x();while(j(z)!==0&&j(z)!==20){let U=l(z);if(U)q.appendData(U)}let X=z.pos<z.end?z.ends[z.pos]:Z;if(j(z)===20)z.pos++;return{type:"Brackets",children:q,loc:z.positions?A(z,Q,X):null}}case 3:case 23:case 24:case 22:case 20:case 17:case 0:case 14:case 15:case 6:case 8:return z.pos++,{type:"Raw",value:Y.slice(Q,Z),loc:z.positions?A(z,Q,Z):null}}return z.pos++,null}function G6(z){return z===32||z===9||z===10||z===12||z===13}function r4(z){return z===47||z===43||z===45||z===42||z===61||z===62||z===60||z===126||z===124||z===36||z===94||z===33||z===38}function q0(z,$,J){for(let Q=$;Q<J;Q++){let Z=z.charCodeAt(Q);if(Z>=65&&Z<=90)return z.slice($,J).toLowerCase()}return z.slice($,J)}function A(z,$,J){let Q=z.tokenizer.locate($),Z=z.tokenizer.locate(J);return{source:z.filename??"<unknown>",start:{offset:$,line:Q.line,column:Q.column},end:{offset:J,line:Z.line,column:Z.column}}}function o4(z){let $=D(z),J=q0(z.source,$.start,$.end-1),Q=x();while(j(z)!==0&&j(z)!==22){let Z=l(z);if(Z)Q.appendData(Z)}if(j(z)===22)D(z);if(J==="url"){for(let Z=Q.head;Z!=null;Z=Z.next)if(Z.data.type==="String")return{type:"Url",value:Z.data.value,loc:W(z,$,M(z))}}return{type:"Function",name:J,children:Q,loc:W(z,$,M(z))}}function t4(z){let $=D(z),J=x();while(j(z)!==0&&j(z)!==22){let Q=l(z);if(Q)J.appendData(Q)}if(j(z)===22)D(z);return{type:"Parentheses",children:J,loc:W(z,$,M(z))}}function g0(z){let $=M(z),J=x();while(j(z)!==0){if(g(z),j(z)===0||j(z)===23)break;let Q=W6(z);if(Q.children.head!==null)J.appendData(Q);if(g(z),j(z)===18){D(z);continue}break}return{type:"SelectorList",children:J,loc:W(z,$,M(z))}}function W6(z){let $=M(z),J=x(),Q=!0;while(j(z)!==0&&j(z)!==18&&j(z)!==23){let Z=M(z);if(Z.type===13){if(D(z),!Q&&j(z)!==0&&j(z)!==18&&j(z)!==23&&!H6(z)&&!s4(z)){let q={type:"Combinator",name:" ",loc:W(z,Z,Z)};J.appendData(q),Q=!0}continue}if(Z.type===9&&z.source.charCodeAt(Z.start)===124&&z.types[z.pos+1]===9&&z.source.charCodeAt(z.starts[z.pos+1])===124){let q=M(z);D(z);let X=D(z),U={type:"Combinator",name:"||",loc:W(z,q,X)};J.appendData(U),Q=!0,g(z);continue}if(H6(z)){let q=D(z),U={type:"Combinator",name:z.source[q.start],loc:W(z,q,q)};J.appendData(U),Q=!0,g(z);continue}let Y=e4(z);if(!Y)break;J.appendData(Y),Q=!1}while(J.tail&&J.tail.data.type==="Combinator")J.remove(J.tail);return{type:"Selector",children:J,loc:W(z,$,M(z))}}function H6(z){let $=M(z);if($.type!==9)return!1;let J=z.source[$.start];return J===">"||J==="+"||J==="~"}function s4(z){if(z.types[z.pos]!==9)return!1;if(z.source.charCodeAt(z.starts[z.pos])!==124)return!1;if(z.types[z.pos+1]!==9)return!1;return z.source.charCodeAt(z.starts[z.pos+1])===124}function e4(z){let $=M(z);switch($.type){case 1:{if(D(z),j(z)===9&&z.source[M(z).start]==="|"&&z.source[M(z).start+1]!=="="&&!(z.types[z.pos+1]===9&&z.source.charCodeAt(z.starts[z.pos+1])===124)){if(D(z),j(z)===1){let Q=D(z);return{type:"TypeSelector",name:`${_(z,$)}|${_(z,Q)}`,loc:W(z,$,Q)}}if(j(z)===9&&z.source[M(z).start]==="*"){let Q=D(z);return{type:"TypeSelector",name:`${_(z,$)}|*`,loc:W(z,$,Q)}}}return{type:"TypeSelector",name:_(z,$),loc:W(z,$,$)}}case 11:return D(z),{type:"TypeSelector",name:_(z,$),loc:W(z,$,$)};case 10:return D(z),{type:"TypeSelector",name:_(z,$),loc:W(z,$,$)};case 9:{let J=z.source[$.start];if(J==="*")return D(z),{type:"TypeSelector",name:"*",loc:W(z,$,$)};if(J==="."){if(D(z),j(z)===1){let Q=D(z);return{type:"ClassSelector",name:_(z,Q),loc:W(z,$,Q)}}return null}if(J==="&")return D(z),{type:"NestingSelector",loc:W(z,$,$)};return D(z),null}case 4:return D(z),{type:"IdSelector",name:z.source.slice($.start+1,$.end),loc:W(z,$,$)};case 16:{D(z);let J=j(z)===16;if(J)D(z);return zz(z,J,$)}case 19:return $z(z)}return null}function zz(z,$,J){let Q=M(z);if(Q.type===1){D(z);let Z=q0(z.source,Q.start,Q.end);return $?{type:"PseudoElementSelector",name:Z,children:null,loc:W(z,J,Q)}:{type:"PseudoClassSelector",name:Z,children:null,loc:W(z,J,Q)}}if(Q.type===2){D(z);let Z=q0(z.source,Q.start,Q.end-1),Y=x();if(!$&&d4.has(Z)){let U=M(z),F=U,H=1;while(j(z)!==0&&H>0){if(j(z)===21||j(z)===2)H++;else if(j(z)===22){if(H--,H===0)break}F=D(z)}if(j(z)===22)D(z);let G=z.source.slice(U.start,F.end).trim();if(G.length>0){let K=K6(G,{positions:!1}),V=g0(K);Y.appendData(V)}}else{while(j(z)!==0&&j(z)!==22){let U=l(z);if(U)Y.appendData(U)}if(j(z)===22)D(z)}if($)return{type:"PseudoElementSelector",name:Z,children:Y,loc:W(z,J,M(z))};return{type:"PseudoClassSelector",name:Z,children:Y,loc:W(z,J,M(z))}}return null}function $z(z){let $=D(z);g(z);let J=M(z);if(J.type!==1)return null;D(z);let Q={type:"Identifier",name:_(z,J),loc:W(z,J,J)};g(z);let Z=null,Y=null,q=null,X=M(z);if(X.type===9){let F=z.source[X.start],H=z.source[X.start+1];if(F==="=")Z="=",D(z);else if((F==="~"||F==="|"||F==="^"||F==="$"||F==="*")&&H==="="){D(z);let V=M(z);if(V.type===9&&z.source[V.start]==="=")D(z),Z=`${F}=`}g(z);let G=M(z);if(G.type===5){D(z);let V=G.end-G.start>=2&&z.source.charCodeAt(G.end-1)===z.source.charCodeAt(G.start);Y={type:"String",value:b0(z.source,G.start+1,V?G.end-1:G.end),loc:W(z,G,G)}}else if(G.type===1)D(z),Y={type:"Identifier",name:_(z,G),loc:W(z,G,G)};g(z);let K=M(z);if(K.type===1)D(z),q=_(z,K)}g(z);let U=M(z);if(j(z)===20)U=D(z);return{type:"AttributeSelector",name:Q,matcher:Z,value:Y,flags:q,loc:W(z,$,U)}}var L6=Symbol("walkSkip"),B=Symbol("walkStop");function Jz(z){return{root:z,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null}}function Qz(z,$){let J=Jz(z),Q=typeof $==="function"?$:$.enter,Z=typeof $==="function"?null:$.leave??null,Y=typeof $==="function"?null:$.visit??null,q=typeof $==="function"?!1:$.reverse??!1;function X(U,F,H){let G=null,K;switch(U.type){case"StyleSheet":G="stylesheet",K=J.stylesheet,J.stylesheet=U;break;case"Atrule":G="atrule",K=J.atrule,J.atrule=U;break;case"AtrulePrelude":G="atrulePrelude",K=J.atrulePrelude,J.atrulePrelude=U;break;case"Rule":G="rule",K=J.rule,J.rule=U;break;case"Selector":G="selector",K=J.selector,J.selector=U;break;case"Block":G="block",K=J.block,J.block=U;break;case"Declaration":G="declaration",K=J.declaration,J.declaration=U;break;case"Function":G="function",K=J.function,J.function=U;break}let V;if((Y===null||Y===U.type)&&Q){let b=Q.call(J,U,F,H);if(b===L6){if(G)J[G]=K;return}if(b===B){if(G)J[G]=K;return B}}if(V=Zz(U,q,X),V===B){if(G)J[G]=K;return B}if((Y===null||Y===U.type)&&Z){if(Z.call(J,U,F,H)===B){if(G)J[G]=K;return B}}if(G)J[G]=K;return}return X(z,null,null)}var i=Object.assign(Qz,{skip:L6,stop:B});function Zz(z,$,J){if("children"in z&&z.children instanceof h)return Yz(z.children,$,J);if(z.type==="Rule"){if(J(z.prelude,null,null)===B)return B;if(J(z.block,null,null)===B)return B;return}if(z.type==="Atrule"){if(z.prelude){if(J(z.prelude,null,null)===B)return B}if(z.block){if(J(z.block,null,null)===B)return B}return}if(z.type==="Declaration")return J(z.value,null,null);if(z.type==="AttributeSelector"){if(J(z.name,null,null)===B)return B;if(z.value)return J(z.value,null,null);return}return}function Yz(z,$,J){let Q;if($)z.forEachRight((Z,Y,q)=>{if(Q)return;if(J(Z,Y,q)===B)Q=B});else z.forEach((Z,Y,q)=>{if(Q)return;if(J(Z,Y,q)===B)Q=B});return Q}function r(z,$={}){let J=$.exclamation??!1,Q=!1;i(z,(Z,Y,q)=>{if(Z.type!=="Comment")return;let X=Z.value.startsWith("!");if(J===!0&&X)return;if(J==="first-exclamation"&&X&&!Q){Q=!0;return}if(Y&&q)q.remove(Y)})}function G0(z){i(z,($)=>{if($.type!=="Block"&&$.type!=="DeclarationList")return;if(!("children"in $)||!$.children)return;let J=$.children,Q=J.head;if(Q==null||Q.next==null)return;let Z=0;for(let X=Q;X!=null;X=X.next)if(X.data.type==="Declaration"){if(Z++,Z>=2)break}if(Z<2)return;let Y=new Map,q=[];for(let X=Q;X!=null;X=X.next){let U=X.data;if(U.type!=="Declaration")continue;let F=U.property,H=Y.get(F);if(H){let G=!!H.decl.important,K=!!U.important;if(K||G===K)q.push(H.item),Y.set(F,{item:X,decl:U});else q.push(X)}else Y.set(F,{item:X,decl:U})}for(let X of q)J.remove(X)})}var Xz={black:"#000",fuchsia:"#f0f",white:"#fff",red:"#f00",cyan:"#0ff",blue:"#00f",yellow:"#ff0",magenta:"#f0f",lime:"#0f0",silver:"#c0c0c0",gray:"#808080",maroon:"#800000",olive:"#808000",green:"#008000",purple:"#800080",teal:"#008080",navy:"#000080"},Uz={"#f00":"red","#ff0000":"red","#000080":"navy","#008080":"teal"};function _0(z){if(!z.startsWith("#"))return z;let $=z.slice(1);if($.length===6){if($[0]===$[1]&&$[2]===$[3]&&$[4]===$[5])return`#${$[0]}${$[2]}${$[4]}`}if($.length===8){if($[0]===$[1]&&$[2]===$[3]&&$[4]===$[5]&&$[6]===$[7])return`#${$[0]}${$[2]}${$[4]}${$[6]}`}return z}function w6(z){let $=z.toLowerCase();return Xz[$]??null}function N6(z){let $=z.toLowerCase();return Uz[$]??null}function qz(z,$,J){let Q=(z<<16|$<<8|J).toString(16).padStart(6,"0");return _0(`#${Q}`)}var Fz=/^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*(?:[,/]\s*([+-]?\d*\.?\d+%?)\s*)?\)$/;function B6(z){let $=Fz.exec(z.trim());if(!$)return z;let J=v0($[1]),Q=v0($[2]),Z=v0($[3]);if($[4]!==void 0&&!Gz($[4]))return z;return qz(J,Q,Z)}function Gz(z){if(z.endsWith("%"))return Number.parseFloat(z)>=100;return Number.parseFloat(z)>=1}function v0(z){if(z.endsWith("%"))return Math.max(0,Math.min(255,Math.round(Number.parseFloat(z)*2.55)));return Math.max(0,Math.min(255,Math.round(Number.parseFloat(z))))}var Hz=new Set(["px","pt","pc","in","cm","mm","q","em","rem","ex","ch","cap","ic","lh","rlh","vw","vh","vi","vb","vmin","vmax","svw","svh","svi","svb","svmin","svmax","lvw","lvh","lvi","lvb","lvmin","lvmax","dvw","dvh","dvi","dvb","dvmin","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"]);function H0(z){if(z.charCodeAt(0)===43)z=z.slice(1);if(z.includes(".")){let $=z.replace(/(\.\d*?)0+($|[eE])/,"$1$2");$=$.replace(/\.($|[eE])/,"$1"),z=$}if(z.startsWith("0.")&&z.length>2)z=z.slice(1);else if(z.startsWith("-0.")&&z.length>3)z=`-${z.slice(2)}`;if(z==="-0"||z==="-.0"||z==="-0.0")z="0";return z}function O6(z,$){let J=H0(z);if((J==="0"||J==="-0")&&Hz.has($.toLowerCase()))return{value:"0",unit:""};return{value:J,unit:$}}function P6(z){return H0(z)}function A6(z,$){let J=Number.parseFloat(z);if(!Number.isFinite(J))return z;let Q=$<0?0:$;return J.toFixed(Q)}var x6=new Set(["color","background","background-color","border","border-color","border-top","border-top-color","border-right","border-right-color","border-bottom","border-bottom-color","border-left","border-left-color","border-block","border-block-color","border-block-start-color","border-block-end-color","border-inline","border-inline-color","border-inline-start-color","border-inline-end-color","outline","outline-color","caret-color","fill","stroke","flood-color","lighting-color","stop-color","column-rule","column-rule-color","text-decoration","text-decoration-color","text-emphasis","text-emphasis-color","text-shadow","box-shadow","accent-color","scrollbar-color"]);function b6(z){if(!z||z.type!=="Operator")return!1;let $=z.value;return $===":"||$===","||$==="/"}function Kz(z){let $=z.children;if(!$)return;while($.head&&$.head.data.type==="WhiteSpace")$.remove($.head);while($.tail&&$.tail.data.type==="WhiteSpace")$.remove($.tail);let J=$.head;while(J){let Q=J.next;if(J.data.type==="WhiteSpace"){let Z=J.prev&&b6(J.prev.data),Y=Q&&b6(Q.data);if(Z||Y)$.remove(J)}J=Q}}function y0(z,$={}){let J=$.floatPrecision??null,Q=J===null?null:(Z)=>A6(Z,J);i(z,{enter(Z,Y,q){switch(Z.type){case"Number":{let X=Q?Q(Z.value):Z.value;Z.value=H0(X);return}case"Percentage":{let X=Q?Q(Z.value):Z.value;Z.value=P6(X);return}case"Dimension":{let X=Q?Q(Z.value):Z.value,U=O6(X,Z.unit);Z.value=U.value,Z.unit=U.unit;return}case"Hash":{let X=_0(`#${Z.name}`).slice(1);if(Z.name=X,Y&&q&&this.declaration&&x6.has(this.declaration.property.toLowerCase())){let U=N6(`#${X}`);if(U&&U.length<X.length+1){let F={type:"Identifier",name:U,loc:Z.loc};q.replace(Y,q.createItem(F))}}return}case"Identifier":{if(!Y||!q||!this.declaration)return;if(!x6.has(this.declaration.property.toLowerCase()))return;let X=w6(Z.name);if(X&&X.length<Z.name.length){let U={type:"Hash",name:X.slice(1),loc:Z.loc};q.replace(Y,q.createItem(U))}return}case"Url":return;case"Function":{let X=Z.name.toLowerCase();if((X==="rgb"||X==="rgba")&&Y&&q)Z.__rgbReplaceCandidate=!0}}},leave(Z,Y,q){if(Z.type==="Parentheses"||Z.type==="Function"||Z.type==="Value")Kz(Z);if(Z.type==="Function"&&Z.__rgbReplaceCandidate&&Y&&q){let X=P(Z),U=B6(X);if(U!==X&&U.startsWith("#")){let F={type:"Hash",name:U.slice(1),loc:Z.loc};q.replace(Y,q.createItem(F))}}}})}function f0(z,$={}){let J=c(z,{context:"stylesheet"});return R6(J,$)}function T0(z,$={}){let J=c(z,{context:"declarationList"});return R6(J,$)}function R6(z,$){if($.comments===!1)r(z,{exclamation:!1});else if($.comments==="first-exclamation")r(z,{exclamation:"first-exclamation"});else r(z,{exclamation:!0});return y0(z,{floatPrecision:$.floatPrecision??null}),G0(z),{css:P(z),ast:z}}var k0="0.1.4";function m0(z){if(!Dz(z))process.stderr.write(`ts-css: file not found: ${z}
42
- `),process.exit(1);return Wz(z,"utf8")}var n=new B0("ts-css");n.command("minify <file>","Minify a CSS file").option("--no-comments","Strip /*!*/ comments too").option("--block",'Treat input as a declarationList (style="\u2026" body)').action(async(z,$)=>{let J=m0(z),Q={comments:$.comments===!1?!1:"exclamation"},Z=$.block?T0(J,Q):f0(J,Q);process.stdout.write(Z.css)});n.command("parse <file>","Parse a CSS file and print its AST as JSON").option("--positions","Include source locations on every node").action(async(z,$)=>{let J=m0(z),Q=c(J,{positions:$.positions});process.stdout.write(JSON.stringify(Q,null,2))});n.command("format <file>","Round-trip CSS through parser/generator (deterministic single-line output)").action(async(z)=>{let $=m0(z),J=c($);process.stdout.write(P(J))});n.command("version","Show the version of the CLI").action(()=>{console.log(k0)});n.version(k0);n.help();n.parse();
6
+ ${this.stack}`;return this.message}}function At(e){if(e instanceof ee)return!0;return!!e&&typeof e==="object"&&e.name==="ClappError"&&typeof e.message==="string"}function Nt(){let{env:e}=We,{TERM:t,TERM_PROGRAM:n}=e;if(We.platform!=="win32")return t!=="linux";return Boolean(e.WT_SESSION)||Boolean(e.TERMINUS_SUBLIME)||e.ConEmuTask==="{cmd::Cmder}"||n==="Terminus-Sublime"||n==="vscode"||t==="xterm-256color"||t==="alacritty"||t==="rxvt-unicode"||t==="rxvt-unicode-256color"||e.TERMINAL_EMULATOR==="JetBrains-JediTerm"}var se="\x1B",w=`${se}[`;var Fe={to(e,t){if(!t)return`${w}${e+1}G`;return`${w}${t+1};${e+1}H`},move(e,t){let n="";if(e<0)n+=`${w}${-e}D`;else if(e>0)n+=`${w}${e}C`;if(t<0)n+=`${w}${-t}A`;else if(t>0)n+=`${w}${t}B`;return n},up:(e=1)=>`${w}${e}A`,down:(e=1)=>`${w}${e}B`,forward:(e=1)=>`${w}${e}C`,backward:(e=1)=>`${w}${e}D`,nextLine:(e=1)=>`${w}E`.repeat(e),prevLine:(e=1)=>`${w}F`.repeat(e),left:`${w}G`,hide:`${w}?25l`,show:`${w}?25h`,save:`${se}7`,restore:`${se}8`};var or={screen:`${w}2J`,up:(e=1)=>`${w}1J`.repeat(e),down:(e=1)=>`${w}J`.repeat(e),line:`${w}2K`,lineEnd:`${w}K`,lineStart:`${w}1K`,lines(e){let t="";for(let n=0;n<e;n++)t+=this.line+(n<e-1?Fe.up():"");if(e)t+=Fe.left;return t}},ar={screen:`${se}c`};function It(e,t){let n=[];for(let r=0;r<=t.length;r++)n[r]=[r];for(let r=0;r<=e.length;r++)n[0][r]=r;for(let r=1;r<=t.length;r++)for(let s=1;s<=e.length;s++)if(t.charAt(r-1)===e.charAt(s-1))n[r][s]=n[r-1][s-1];else n[r][s]=Math.min(n[r-1][s-1]+1,n[r][s-1]+1,n[r-1][s]+1);return n[t.length][e.length]}function qe(e,t,n=2,r=3){return t.map((s)=>({cmd:s,distance:It(e,s)})).filter(({distance:s})=>s<=n).sort((s,i)=>s.distance-i.distance).slice(0,r).map(({cmd:s})=>s)}function Et(e,t={}){let n={_:[]},r=t.alias||{},s=new Set(t.boolean||[]),i={};for(let o of Object.keys(r))for(let c of r[o])i[c]=o;for(let o of s)if(r[o])for(let c of r[o])s.add(c);function l(o,c){if(o===void 0)return c;if(typeof c==="boolean")return c;return Array.isArray(o)?[...o,c]:[o,c]}function a(o,c){let h=i[o]||o,u=l(n[h],c);if(n[h]=u,r[h])for(let d of r[h])n[d]=u;if(i[o]&&r[i[o]])for(let d of r[i[o]])n[d]=u;n[o]=u}for(let o=0;o<e.length;o++){let c=e[o];if(c==="--"){n._.push(...e.slice(o+1));break}if(c.startsWith("--")){let h=c.indexOf("=");if(h!==-1){let u=ne(c.slice(2,h)),d=c.slice(h+1);a(u,d)}else{let u=c.slice(2);if(u.startsWith("no-")){let p=ne(u.slice(3));a(p,!1);continue}let d=ne(u),b=i[d]||d;if(s.has(b)||s.has(d))a(d,!0);else{let p=e[o+1];if(p!==void 0&&!p.startsWith("-"))a(d,p),o++;else a(d,!0)}}}else if(c.startsWith("-")&&c.length>1){let h=c.slice(1);for(let u=0;u<h.length;u++){let d=h[u],b=i[d]||d;if(u===h.length-1&&!s.has(b)&&!s.has(d)){let p=e[o+1];if(p!==void 0&&!p.startsWith("-"))a(d,p),o++;else a(d,!0)}else a(d,!0)}}else n._.push(c)}return n}class Ge{rawName;description;name;names;isBoolean;required;config;negated;variadic;constructor(e,t,n){if(this.rawName=e,this.description=t,this.config=Object.assign({},n),e=e.replace(/\.\*/g,""),this.negated=!1,this.variadic=/[<[](?:\.\.\.[^\]>]+|[^\]>]+\.\.\.)[\]>]/.test(e),this.names=pe(e).split(",").map((r)=>{let s=r.trim().replace(/^-{1,2}/,"");if(s.startsWith("no-"))this.negated=!0,s=s.replace(/^no-/,"");return Z(s)}).sort((r,s)=>r.length>s.length?1:-1),this.name=this.names[this.names.length-1],this.negated&&this.config.default==null)this.config.default=!0;if(e.includes("<"))this.required=!0;else if(e.includes("["))this.required=!1;else this.isBoolean=!0}}var cr=ge.argv,Ot=`${ge.platform}-${ge.arch} bun-v${typeof Bun<"u"?Bun.version:"unknown"}`,Ue=re.argv,Lt=`${re.platform}-${re.arch} node-${re.version}`;class ye{rawName;description;config;cli;options;aliasNames;name;namespace;args;commandAction;usageText;versionNumber;examples;helpCallback;globalCommand;beforeHooks;afterHooks;middleware;constructor(e,t,n,r){this.rawName=e,this.description=t,this.config=n,this.cli=r,this.options=[],this.aliasNames=[],this.name=pe(e);let s=pe(e),i=s.indexOf(":");if(i>0)this.namespace=s.substring(0,i),this.name=s.substring(i+1);if(this.args=$t(e),this.examples=[],this.beforeHooks=[],this.afterHooks=[],this.middleware=[],!n)this.config={}}usage(e){return this.usageText=e,this}allowUnknownOptions(){return this.config.allowUnknownOptions=!0,this}ignoreOptionDefaultValue(){return this.config.ignoreOptionDefaultValue=!0,this}version(e,t="-v, --version"){return this.versionNumber=e,this.option(t,"Display version number"),this}example(e){return this.examples.push(e),this}option(e,t,n){let r=new Ge(e,t,n);return this.options.push(r),this}alias(e){return this.aliasNames.push(e),this}action(e){return this.commandAction=e,this}before(e){return this.beforeHooks.push(e),this}after(e){return this.afterHooks.push(e),this}use(e){return this.middleware.push(e),this}isMatched(e){if(this.aliasNames.includes(e))return!0;if(this.namespace)return`${this.namespace}:${this.name}`===e;return this.name===e}get isDefaultCommand(){return this.name===""||this.aliasNames.includes("!")}get isGlobalCommand(){return this instanceof be}get displayName(){return this.namespace?`${this.namespace}:${this.name}`:this.name}hasOption(e){let t=Z(e.split(".")[0]);return!!this.options.find((n)=>n.names.some((r)=>Z(r)===t))}outputHelp(){let{name:e,commands:t}=this.cli,{versionNumber:n,options:r,helpCallback:s}=this.cli.globalCommand,i=[{body:`${e}${n?`/${n}`:""}`}];if(i.push({title:"Usage",body:` $ ${e} ${this.usageText||this.rawName}`}),(this.isGlobalCommand||this.isDefaultCommand)&&t.length>0){let c=je(t.map((p)=>p.rawName)),h=new Map,u=[];for(let p of t)if(p.namespace){if(!h.has(p.namespace))h.set(p.namespace,[]);h.get(p.namespace).push(p)}else u.push(p);let d="";if(u.sort((p,_)=>p.rawName<_.rawName?-1:p.rawName>_.rawName?1:0),u.length>0)d+=u.map((p)=>` ${de(p.rawName,c.length)} ${p.description}`).join(`
7
+ `);let b=Array.from(h.keys()).sort();for(let p of b){let _=h.get(p);if(d.length>0)d+=`
8
+
9
+ `;d+=` ${p}:
10
+ `,d+=_.map((T)=>` ${de(T.rawName,c.length-2)} ${T.description}`).join(`
11
+ `)}i.push({title:"Commands",body:d}),i.push({body:`Run \`${e} <command> --help\` for command details.`})}let a=new Set(this.options.flatMap((c)=>c.names)),o=this.isGlobalCommand?r:[...this.options,...(r||[]).filter((c)=>!c.names.some((h)=>a.has(h)))];if(!this.isGlobalCommand&&!this.isDefaultCommand)o=o.filter((c)=>c.name!=="version");if(o.length>0){let c=je(o.map((h)=>h.rawName));i.push({title:"Options",body:o.map((h)=>` ${de(h.rawName,c.length)} ${h.description} ${h.config.default===void 0?"":`(default: ${h.config.default})`}`).join(`
12
+ `)})}if(this.examples.length>0)i.push({title:"Examples",body:this.examples.map((c)=>{if(typeof c==="function")return c(e);return c}).join(`
13
+ `)});if(s)i=s(i)||i;console.log(i.map((c)=>c.title?`${c.title}:
14
+ ${c.body}`:c.body).join(`
15
+
16
+ `))}outputVersion(){let{name:e}=this.cli,{versionNumber:t}=this.cli.globalCommand;if(t)console.log(`${e}/${t} ${typeof Bun<"u"?Ot:Lt}`)}get usageLine(){return`$ ${this.cli.name} ${this.usageText||this.rawName}`}checkRequiredArgs(){let e=this.args.filter((t)=>t.required).length;if(this.cli.args.length<e){let n=this.args.filter((s)=>s.required).slice(this.cli.args.length),r=n.map((s)=>`<${s.value}>`).join(" ");throw new ee(`Missing required argument${n.length>1?"s":""}: ${r}
17
+
18
+ Run \`${this.cli.name} ${this.rawName} --help\` for usage information.`,this.usageLine)}}checkUnknownOptions(){let{options:e,globalCommand:t}=this.cli;if(!this.config.allowUnknownOptions){for(let n of Object.keys(e))if(n!=="--"&&!this.hasOption(n)&&!t.hasOption(n)){let s=[...t.options,...this.options].flatMap((c)=>c.names),i=Z(n.split(".")[0]),l=n.length>1?`--${n}`:`-${n}`,a=qe(i,s),o=`Unknown option \`${l}\``;if(a.length>0)o+=`
19
+
20
+ Did you mean one of these?`,a.forEach((c)=>{let h=c.length>1?`--${c}`:`-${c}`;o+=`
21
+ \u2022 ${h}`});throw o+=`
22
+
23
+ Run \`${this.cli.name} ${this.rawName} --help\` to see available options.`,new ee(o,this.usageLine)}}}checkOptionValue(){let{options:e,globalCommand:t}=this.cli,n=[...t.options,...this.options];for(let r of n){let s=e[r.name.split(".")[0]];if(r.required){let i=n.some((l)=>l.negated&&l.names.includes(r.name));if(s===!0||s===!1&&!i)throw new ee(`Option \`${r.rawName}\` requires a value.
24
+
25
+ Example: ${this.cli.name} ${this.rawName} ${r.rawName} <value>`,this.usageLine)}}}}class be extends ye{constructor(e){super("@@global@@","",{},e)}}var Pt=ye,W={red:["\x1B[31m","\x1B[39m"],green:["\x1B[32m","\x1B[39m"],blue:["\x1B[34m","\x1B[39m"],yellow:["\x1B[33m","\x1B[39m"],cyan:["\x1B[36m","\x1B[39m"],magenta:["\x1B[35m","\x1B[39m"],white:["\x1B[37m","\x1B[39m"],gray:["\x1B[90m","\x1B[39m"],bgRed:["\x1B[41m","\x1B[49m"],bgGreen:["\x1B[42m","\x1B[49m"],bgBlue:["\x1B[44m","\x1B[49m"],bgYellow:["\x1B[43m","\x1B[49m"],bgCyan:["\x1B[46m","\x1B[49m"],bgMagenta:["\x1B[45m","\x1B[49m"],bold:["\x1B[1m","\x1B[22m"],italic:["\x1B[3m","\x1B[23m"],underline:["\x1B[4m","\x1B[24m"],dim:["\x1B[2m","\x1B[22m"],inverse:["\x1B[7m","\x1B[27m"],hidden:["\x1B[8m","\x1B[28m"],strikethrough:["\x1B[9m","\x1B[29m"]};var Q={primary:"blue",secondary:"cyan",success:"green",warning:"yellow",error:"red",info:"magenta",muted:"gray"};function Rt(){return!0}function _t(){let e={};e.supportsColor=Rt();function t(r,s=[]){let i=r===""?[]:[...s,r],l=function(o){if(!e.supportsColor)return o;let c="",h="";for(let u of i)if(u in Q&&Q[u]in W){let d=Q[u];c+=W[d][0],h=W[d][1]+h}else if(u in W)c+=W[u][0],h=W[u][1]+h;return c+o+h},a=[...Object.keys(W),...Object.keys(Q)];for(let o of a)if(!(o in l))Object.defineProperty(l,o,{get(){return t(o,i)}});return l}let n=[...Object.keys(W),...Object.keys(Q)];for(let r of n)if(!(r in e))Object.defineProperty(e,r,{get(){return t(r)}});return e}var J=_t();class Ce extends wt{name;commands;globalCommand;matchedCommand;matchedCommandName;rawArgs;args;options;showHelpOnExit;showVersionOnExit;enableDidYouMean=!0;signalHandlersSet=!1;isVerbose=!1;isQuiet=!1;isDebug=!1;isNoInteraction=!1;environment;isDryRun=!1;isForce=!1;useEmoji=!0;theme;isNoCache=!1;constructor(e=""){super();this.name=e,this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.globalCommand=new be(this),this.globalCommand.usage("<command> [options]")}handleSignals(e){if(this.signalHandlersSet)return this;let t=async(n)=>{if(console.log(`
26
+
27
+ Received ${n}, cleaning up...`),e)try{await e()}catch(r){console.error("Error during cleanup:",r)}V.exit(0)};return V.on("SIGINT",()=>t("SIGINT")),V.on("SIGTERM",()=>t("SIGTERM")),this.signalHandlersSet=!0,this}didYouMean(e=!0){return this.enableDidYouMean=e,this}verbose(){return this.globalCommand.option("-v, --verbose","Enable verbose output"),this}quiet(){return this.globalCommand.option("-q, --quiet","Suppress non-essential output"),this}debug(){return this.globalCommand.option("--debug","Enable debug mode with detailed error information"),this}noInteraction(){return this.globalCommand.option("-n, --no-interaction","Do not ask any interactive questions (for CI/CD)"),this}env(){return this.globalCommand.option("--env <environment>","Target environment (e.g., production, staging, local)"),this}dryRun(){return this.globalCommand.option("--dry-run","Preview actions without executing them"),this}force(){return this.globalCommand.option("-f, --force","Skip confirmation prompts"),this}emoji(){return this.globalCommand.option("--no-emoji","Disable emoji in output"),this}themes(){return this.globalCommand.option("--theme <theme>","Color theme (default, dracula, nord, solarized, monokai)"),this}cache(){return this.globalCommand.option("--no-cache","Disable caching"),this}usage(e){return this.globalCommand.usage(e),this}command(e,t,n){if(!n)n={};let r=new Pt(e,t||"",n,this);return r.globalCommand=this.globalCommand,this.commands.push(r),r}option(e,t,n){return this.globalCommand.option(e,t,n),this}help(e){return this.globalCommand.option("-h, --help","Display this message"),this.globalCommand.helpCallback=e,this.showHelpOnExit=!0,this}version(e,t="-v, --version"){return this.globalCommand.version(e,t),this.showVersionOnExit=!0,this}example(e){return this.globalCommand.example(e),this}outputHelp(){if(this.matchedCommand)this.matchedCommand.outputHelp();else this.globalCommand.outputHelp()}outputVersion(){this.globalCommand.outputVersion()}setParsedInfo({args:e,options:t},n,r){if(this.args=e,this.options=t,n)this.matchedCommand=n;if(r)this.matchedCommandName=r;return this}unsetMatchedCommand(){this.matchedCommand=void 0,this.matchedCommandName=void 0}showCommandNotFound(e){if(console.log(J.red(`
28
+ \u2717 Command "${e}" not found.
29
+ `)),this.enableDidYouMean){let t=[];for(let r of this.commands){if(r.displayName)t.push(r.displayName);if(r.aliasNames)t.push(...r.aliasNames)}let n=qe(e,t);if(n.length>0)console.log(J.yellow("Did you mean one of these?")),n.forEach((r)=>console.log(` ${J.dim("\u2022")} ${this.name} ${r}`)),console.log("")}console.log(J.dim("Run"),`${this.name} --help`,J.dim("to see all available commands")),V.exit(1)}async parse(e=Ue,t={}){let{run:n=!0,exitOnError:r=!1}=t;if(r)try{return await this.parse(e,{run:n})}catch(o){throw this.handleUsageError(o),o}if(this.rawArgs=e,!this.name)this.name=e[1]?Tt(e[1]):"cli";let s=!0,i=e.slice(2),l=i[0];if(l&&!l.startsWith("-")){for(let o of this.commands)if(o.isMatched(l)){let c=this.mri(i,o);s=!1;let h={...c,args:c.args.slice(1)};this.setParsedInfo(h,o,l),this.emit(`command:${l}`,o);break}if(s){let o=i[1];if(o&&!o.startsWith("-")){let c=`${l}:${o}`;for(let h of this.commands)if(h.isMatched(c)){let u=this.mri(i,h);s=!1;let d={...u,args:u.args.slice(2)};this.setParsedInfo(d,h,c),this.emit(`command:${c}`,h);break}}}}if(s){for(let o of this.commands)if(o.name===""){s=!1;let c=this.mri(i,o);this.setParsedInfo(c,o),this.emit("command:!",o);break}}if(s){let o=this.mri(e.slice(2));this.setParsedInfo(o)}if(this.options.verbose)this.isVerbose=!0;if(this.options.quiet)this.isQuiet=!0;if(this.options.debug)this.isDebug=!0;if(this.options.noInteraction||this.options.interaction===!1)this.isNoInteraction=!0;if(this.options.env)this.environment=String(this.options.env);if(this.options.dryRun)this.isDryRun=!0;if(this.options.force)this.isForce=!0;if(this.options.noEmoji||this.options.emoji===!1)this.useEmoji=!1;if(this.options.theme)this.theme=String(this.options.theme);if(this.options.noCache||this.options.cache===!1)this.isNoCache=!0;if(this.options.help&&this.showHelpOnExit)this.outputHelp(),n=!1,this.unsetMatchedCommand();if(this.options.version&&this.showVersionOnExit&&this.matchedCommandName==null)this.outputVersion(),n=!1,this.unsetMatchedCommand();let a={args:this.args,options:this.options};if(n)await this.runMatchedCommand();if(!this.matchedCommand&&this.args[0]){if(this.emit("command:*"),!(this.listenerCount("command:*")>0))this.showCommandNotFound(this.args[0])}return a}mri(e,t){let n=[...this.globalCommand.options,...t?t.options:[]],r=xt(n),s=[],i=e.indexOf("--");if(i>-1)s=e.slice(i+1),e=e.slice(0,i);let l=Et(e,r),a={_:l._};for(let d of Object.keys(l))if(d!=="_")a[Z(d)]=l[d];let o=a._,c={"--":s},h=t&&t.config.ignoreOptionDefaultValue?t.config.ignoreOptionDefaultValue:this.globalCommand.config.ignoreOptionDefaultValue,u=Object.create(null);for(let d of n){if(!h&&d.config.default!==void 0)for(let b of d.names)c[b]=d.config.default;if(Array.isArray(d.config.type)){if(u[d.name]===void 0)u[d.name]={shouldTransform:!0,transformFunction:d.config.type[0]}}}for(let d of Object.keys(a))if(d!=="_"){let b=d.split(".");St(c,b,a[d]),kt(c,u)}for(let d of n){if(!d.variadic)continue;for(let b of d.names){let p=c[b];if(p===void 0||Array.isArray(p))continue;if(d.config.default!==void 0&&p===d.config.default)continue;c[b]=[p]}}return{args:o,options:c}}async run(e=Ue){return this.parse(e,{run:!0,exitOnError:!0})}handleUsageError(e){if(!At(e)||e.isUsageError===!1)return;let t=e.message||"command-line error",n=this.name?`${this.name}: `:"",r=/--help/.test(t)?"":e.usage?`
30
+ Usage: ${e.usage}`:`
31
+ Run \`${this.name??"cli"} --help\` for usage.`;V.stderr.write(`${n}${t}${r}
32
+ `),V.exit(e.exitCode??2)}async runMatchedCommand(){let{args:e,options:t,matchedCommand:n}=this;if(!n||!n.commandAction)return;n.checkUnknownOptions(),n.checkOptionValue(),n.checkRequiredArgs();let r=[];n.args.forEach((a,o)=>{if(a.variadic)r.push(e.slice(o));else r.push(e[o])}),r.push(t);let s={command:n,args:r,options:t};for(let a of n.beforeHooks)await a(s);let i,l=async()=>{let a=n.commandAction.apply(this,r);if(a instanceof Promise)i=await a;else i=a;return i};if(n.middleware.length>0){let a=0,o=async()=>{if(a<n.middleware.length){let c=n.middleware[a++];await c({...s,next:o})}else await l()};await o()}else await l();for(let a of n.afterHooks)await a(s);return i}removeSignalHandlers(){if(!this.signalHandlersSet)return this;return V.removeAllListeners("SIGINT"),V.removeAllListeners("SIGTERM"),this.signalHandlersSet=!1,this}destroy(){this.removeSignalHandlers(),this.commands=[],this.rawArgs=[],this.args=[],this.options={},this.matchedCommand=void 0,this.matchedCommandName=void 0,this.removeAllListeners()}}class Ke{cache;enabled;cleanupInterval=null;hits=0;misses=0;constructor(){this.cache=new Map,this.enabled=!0,this.startCleanupInterval()}startCleanupInterval(){if(this.cleanupInterval)return;this.cleanupInterval=setInterval(()=>{this.cleanup()},30000),this.cleanupInterval.unref()}stopCleanup(){if(this.cleanupInterval)clearInterval(this.cleanupInterval),this.cleanupInterval=null}isEnabled(){return this.enabled}get(e){if(!this.enabled){this.misses++;return}let t=this.cache.get(e);if(!t){this.misses++;return}if(Date.now()-t.timestamp>t.ttl){this.cache.delete(e),this.misses++;return}return this.hits++,t.value}set(e,t,n=5000){if(!this.enabled)return;this.cache.set(e,{value:t,timestamp:Date.now(),ttl:n})}has(e){if(!this.enabled)return!1;let t=this.cache.get(e);if(!t)return!1;if(Date.now()-t.timestamp>t.ttl)return this.cache.delete(e),!1;return!0}delete(e){this.cache.delete(e)}clear(){this.cache.clear()}disable(){this.enabled=!1,this.clear()}enable(){this.enabled=!0}stats(){return{size:this.cache.size,enabled:this.enabled,hits:this.hits,misses:this.misses}}resetStats(){this.hits=0,this.misses=0}keys(){return Array.from(this.cache.keys())}cleanup(){let e=Date.now();for(let[t,n]of this.cache.entries())if(e-n.timestamp>n.ttl)this.cache.delete(t)}destroy(){this.stopCleanup(),this.clear(),this.resetStats()}}var hr=new Ke;function Bt(){if("FORCE_COLOR"in X.env)return X.env.FORCE_COLOR!=="0";if("NO_COLOR"in X.env||X.env.TERM==="dumb")return!1;if(X.platform==="win32")return!0;return ze.isatty(1)&&ze.isatty(2)}var Ye=Bt();function v(e,t){if(!Ye)return(n)=>n;return(n)=>e+n+t}var Dt=v("\x1B[0m","\x1B[0m"),Mt=v("\x1B[31m","\x1B[39m"),Vt=v("\x1B[32m","\x1B[39m"),Wt=v("\x1B[33m","\x1B[39m"),jt=v("\x1B[34m","\x1B[39m"),Ft=v("\x1B[35m","\x1B[39m"),Ut=v("\x1B[36m","\x1B[39m"),zt=v("\x1B[37m","\x1B[39m"),Ht=v("\x1B[90m","\x1B[39m"),qt=v("\x1B[1m","\x1B[22m"),Gt=v("\x1B[3m","\x1B[23m"),Kt=v("\x1B[4m","\x1B[24m"),Yt=v("\x1B[2m","\x1B[22m"),Qt=v("\x1B[7m","\x1B[27m"),Jt=v("\x1B[8m","\x1B[28m"),Xt=v("\x1B[9m","\x1B[29m"),Zt=v("\x1B[41m","\x1B[49m"),en=v("\x1B[42m","\x1B[49m"),tn=v("\x1B[43m","\x1B[49m"),nn=v("\x1B[44m","\x1B[49m"),rn=v("\x1B[45m","\x1B[49m"),sn=v("\x1B[46m","\x1B[49m"),on=v("\x1B[47m","\x1B[49m"),an=Ye,ln={reset:Dt,red:Mt,green:Vt,yellow:Wt,blue:jt,magenta:Ft,cyan:Ut,white:zt,gray:Ht,bold:qt,italic:Gt,underline:Kt,dim:Yt,inverse:Qt,hidden:Jt,strikethrough:Xt,bgRed:Zt,bgGreen:en,bgYellow:tn,bgBlue:nn,bgMagenta:rn,bgCyan:sn,bgWhite:on,isColorSupported:an},cn=ln,hn=["up","down","left","right","space","enter","cancel"],yr={actions:new Set(hn),aliases:new Map([["k","up"],["j","down"],["h","left"],["l","right"],["\x03","cancel"],["escape","cancel"]]),messages:{cancel:"Canceled",error:"Something went wrong"}};var br=un.platform.startsWith("win"),Cr=Symbol("clapp:cancel");var dn=Nt();var C=(e,t)=>dn?e:t,vr=C("\u25C6","*"),wr=C("\u25A0","x"),$r=C("\u25B2","x"),xr=C("\u25C7","o"),Sr=C("\u250C","T"),mn=C("\u2502","|"),kr=C("\u2514","\u2014"),Tr=C("\u25CF",">"),Ar=C("\u25CB"," "),Nr=C("\u25FB","[\u2022]"),Ir=C("\u25FC","[+]"),Er=C("\u25FB","[ ]"),Or=C("\u25AA","\u2022"),Lr=C("\u2500","-"),Pr=C("\u256E","+"),Rr=C("\u251C","+"),_r=C("\u256F","+"),Br=C("\u25CF","\u2022"),Dr=C("\u25C6","*"),Mr=C("\u25B2","!"),Vr=C("\u25A0","x");var Wr={light:C("\u2500","-"),heavy:C("\u2501","="),block:C("\u2588","#")};function fn(){return`${cn.gray(mn)} `}var jr=fn();class Qe{configPath;config=null;events=[];retryCount=0;maxRetries=3;retryDelayMs=1000;constructor(){let e=He.homedir(),t=fe.join(e,".config","clapp");this.configPath=fe.join(t,"telemetry.json")}async isEnabled(){if(j.env.DO_NOT_TRACK==="1"||j.env.DO_NOT_TRACK==="true")return!1;if(j.env.NO_TELEMETRY==="1"||j.env.NO_TELEMETRY==="true")return!1;return(await this.loadConfig()).enabled}async enable(){let e=await this.loadConfig();if(e.enabled=!0,!e.userId)e.userId=this.generateUserId();await this.saveConfig(e)}async disable(){let e=await this.loadConfig();e.enabled=!1,await this.saveConfig(e)}async track(e,t){if(!await this.isEnabled())return;let r={event:e,...t,timestamp:Date.now(),platform:He.platform(),nodeVersion:j.version};if(this.events.push(r),this.events.length>=10)await this.send()}async trackCommand(e,t){await this.track("command",{command:e,duration:t})}async trackError(e,t){await this.track("error",{error:e,command:t})}async send(){if(!await this.isEnabled()||this.events.length===0)return!0;try{this.events=[],this.retryCount=0;let t=await this.loadConfig();return t.lastSent=Date.now(),await this.saveConfig(t),!0}catch{if(this.retryCount<this.maxRetries){this.retryCount++;let t=this.retryDelayMs*2**(this.retryCount-1);return await this.sleep(t),this.send()}return this.events=[],this.retryCount=0,!1}}async flush(){if(this.events.length===0)return!0;return this.send()}sleep(e){return new Promise((t)=>setTimeout(t,e))}async status(){let e=await this.loadConfig();return{enabled:e.enabled,doNotTrack:j.env.DO_NOT_TRACK==="1"||j.env.DO_NOT_TRACK==="true",eventsQueued:this.events.length,lastSent:e.lastSent}}async loadConfig(){if(this.config)return this.config;try{if(pn(this.configPath)){let e=await me.readFile(this.configPath,"utf-8");return this.config=JSON.parse(e),this.config}}catch{}return this.config={enabled:!1},this.config}async saveConfig(e){this.config=e;try{let t=fe.dirname(this.configPath);await me.mkdir(t,{recursive:!0}),await me.writeFile(this.configPath,JSON.stringify(e,null,2),"utf-8")}catch{}}generateUserId(){let e=Math.random().toString(36).substring(2,15),t=Date.now().toString(36);return`${e}-${t}`}}var Gr=new Qe;import{existsSync as er,readFileSync as tr}from"fs";function B(e){return{prev:null,next:null,data:e}}class L{head=null;tail=null;cursors=[];allocateCursor(e,t){let n={prev:e,next:t};return this.cursors.push(n),n}releaseCursor(){this.cursors.pop()}updateCursors(e,t,n,r){for(let s of this.cursors){if(s.prev===e)s.prev=t;if(s.next===n)s.next=r}}static createItem(e){return B(e)}createItem(e){return B(e)}get isEmpty(){return this.head===null}get first(){return this.head?.data??null}get last(){return this.tail?.data??null}*[Symbol.iterator](){for(let e=this.head;e!=null;e=e.next)yield e.data}fromArray(e){let t=null;this.head=null;for(let n of e){let r=B(n);if(r.prev=t,t)t.next=r;else this.head=r;t=r}return this.tail=t,this}toArray(){let e=[];for(let t=this.head;t!=null;t=t.next)e.push(t.data);return e}toJSON(){return this.toArray()}forEach(e,t){let n=this.allocateCursor(null,this.head);while(n.next!==null){let r=n.next;n.prev=r,n.next=r.next,e.call(t,r.data,r,this)}this.releaseCursor()}forEachRight(e,t){let n=this.allocateCursor(this.tail,null);while(n.prev!==null){let r=n.prev;n.next=r,n.prev=r.prev,e.call(t,r.data,r,this)}this.releaseCursor()}reduce(e,t){let n=t,r=0;for(let s=this.head;s!=null;s=s.next)n=e(n,s.data,r++,this);return n}some(e){let t=0;for(let n=this.head;n!=null;n=n.next)if(e(n.data,t++,this))return!0;return!1}map(e){let t=new L,n=null,r=0;for(let s=this.head;s!=null;s=s.next){let i=B(e(s.data,r++,this));if(i.prev=n,n)n.next=i;else t.head=i;n=i}return t.tail=n,t}filter(e){let t=new L,n=null,r=0;for(let s=this.head;s!=null;s=s.next)if(e(s.data,r++,this)){let i=B(s.data);if(i.prev=n,n)n.next=i;else t.head=i;n=i}return t.tail=n,t}clear(){let e=this.head;while(e){let t=e.next;e.prev=null,e.next=null,e=t}this.head=null,this.tail=null}copy(){let e=new L,t=null;for(let n=this.head;n!=null;n=n.next){let r=B(n.data);if(r.prev=t,t)t.next=r;else e.head=r;t=r}return e.tail=t,e}prepend(e){return this.insert(e,this.head)}prependData(e){return this.insert(B(e),this.head)}append(e){return this.insert(e,null)}appendData(e){return this.insert(B(e),null)}insert(e,t=null){if(t!=null)if(this.updateCursors(t.prev,e,t,e),t.prev===null){if(this.head!==t)throw Error("before doesn't belong to list");this.head=e,t.prev=e,e.next=t,this.updateCursors(null,e,null,null)}else t.prev.next=e,e.prev=t.prev,t.prev=e,e.next=t;else if(this.updateCursors(this.tail,e,null,e),this.tail!==null)this.tail.next=e,e.prev=this.tail,this.tail=e;else this.head=e,this.tail=e;return this}insertData(e,t=null){return this.insert(B(e),t)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else if(this.head===e)this.head=e.next;else throw Error("item doesn't belong to list");if(e.next!==null)e.next.prev=e.prev;else if(this.tail===e)this.tail=e.prev;else throw Error("item doesn't belong to list");return e.prev=null,e.next=null,e}push(e){this.insert(B(e),null)}pop(){if(this.tail===null)return null;return this.remove(this.tail)}unshift(e){this.prependData(e)}shift(){if(this.head===null)return null;return this.remove(this.head)}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e,null)}insertList(e,t=null){if(e.head===null)return this;if(t!==null){if(this.updateCursors(t.prev,e.tail,t,e.head),t.prev!==null)t.prev.next=e.head,e.head.prev=t.prev;else this.head=e.head;t.prev=e.tail,e.tail.next=t}else{if(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null)this.tail.next=e.head,e.head.prev=this.tail;else this.head=e.head;this.tail=e.tail}return e.head=null,e.tail=null,this}replace(e,t){if(t instanceof L)this.insertList(t,e),this.remove(e);else this.insert(t,e),this.remove(e)}}function k(e){switch(e.type){case"StyleSheet":return O(e.children,"");case"Rule":return`${k(e.prelude)}{${k(e.block)}}`;case"Block":return gn(e.children);case"Atrule":{let t=`@${e.name}`;if(e.prelude){let n=k(e.prelude);if(n)t+=` ${n}`}if(e.block)t+=`{${k(e.block)}}`;else t+=";";return t}case"AtrulePrelude":return O(e.children,"");case"SelectorList":return O(e.children,",");case"Selector":return O(e.children,"");case"TypeSelector":return e.name;case"IdSelector":return`#${e.name}`;case"ClassSelector":return`.${e.name}`;case"NestingSelector":return"&";case"AttributeSelector":{let t=`[${e.name.name}`;if(e.matcher&&e.value)if(t+=e.matcher,e.value.type==="String")t+=`"${ve(e.value.value)}"`;else t+=e.value.name;if(e.flags)t+=` ${e.flags}`;return t+="]",t}case"PseudoClassSelector":return e.children?`:${e.name}(${O(e.children,"")})`:`:${e.name}`;case"PseudoElementSelector":return e.children?`::${e.name}(${O(e.children,"")})`:`::${e.name}`;case"Combinator":return e.name===" "?" ":e.name;case"Declaration":return`${e.property}:${k(e.value)}${e.important?"!important":""}`;case"DeclarationList":return O(e.children,";");case"Value":return O(e.children,"");case"Identifier":return e.name;case"Number":return e.value;case"Percentage":return`${e.value}%`;case"Dimension":return e.value+e.unit;case"String":return`"${ve(e.value)}"`;case"Url":return/[\s"'()\\\u0000-\u001F\u007F]/.test(e.value)?`url("${ve(e.value)}")`:`url(${e.value})`;case"Hash":return`#${e.name}`;case"Operator":return e.value;case"Function":return`${e.name}(${O(e.children,"")})`;case"Parentheses":return`(${O(e.children,"")})`;case"Brackets":return`[${O(e.children,"")}]`;case"Raw":return e.value;case"Comment":return e.value.startsWith("!")?`/*${e.value}*/`:"";case"WhiteSpace":return" ";case"CDO":return"<!--";case"CDC":return"-->";case"AnPlusB":{let t=e.a??"",n=e.b??"";if(t&&n){let r=Number(n);return`${t==="1"?"":t==="-1"?"-":t}n${r>=0?`+${n}`:n}`}if(t)return`${t==="1"?"":t==="-1"?"-":t}n`;return n}case"Ratio":return`${e.left.value}/${e.right.value}`;case"UnicodeRange":return e.value;case"Nth":return e.selector?`${k(e.nth)} of ${k(e.selector)}`:k(e.nth);case"MediaQueryList":return O(e.children,",");case"MediaQuery":return O(e.children,"");case"MediaFeature":{let t=`(${e.name}`;if(e.value)t+=`:${k(e.value)}`;return t+=")",t}}return""}function O(e,t){let n="",r=!0,s=null,i=e.head;while(i!=null){let l=i.data;if(l.type==="WhiteSpace"){let o=i.next?i.next.data:null;if(Je(s)||Je(o)){i=i.next;continue}}let a=k(l);if(!a){i=i.next;continue}if(!r&&t&&!bn(s))n+=t;r=!1,n+=a,s=l,i=i.next}return n}function gn(e){let t="",n=null,r=e.head;while(r!=null){let s=r.data,i=k(s);if(!i){r=r.next;continue}if(n&&yn(n,s))t+=";";t+=i,n=s,r=r.next}return t}function yn(e,t){return e.type==="Declaration"&&t.type!=="Comment"}function Je(e){if(!e||e.type!=="Operator")return!1;let t=e.value;return t===":"||t===","||t==="/"}function bn(e){if(!e)return!1;return e.type==="Operator"||e.type==="Combinator"}function ve(e){let t="";for(let n=0;n<e.length;n++){let r=e.charCodeAt(n);if(r===92)t+="\\\\";else if(r===34)t+="\\\"";else if(r<32||r===127){let s=r.toString(16),i=n+1<e.length?e.charCodeAt(n+1):-1,l=i===32||i===9||i===10||i===12||i===13||i>=48&&i<=57||i>=65&&i<=70||i>=97&&i<=102;t+=`\\${s}${l?" ":""}`}else t+=e[n]}return t}var U=(()=>{let e=new Uint8Array(128);for(let t=0;t<128;t++){let n=0;if(t===32||t===9||t===10||t===12||t===13)n|=1;if(t>=48&&t<=57)n|=2;if(t>=48&&t<=57||t>=65&&t<=70||t>=97&&t<=102)n|=4;if(t>=65&&t<=90||t>=97&&t<=122||t===95)n|=8;if(t===10||t===12||t===13)n|=16;e[t]=n}return e})();function P(e){return e<128&&(U[e]&2)!==0}function te(e){return e<128&&(U[e]&4)!==0}function Xe(e){return e>=128||e<128&&(U[e]&8)!==0}function Cn(e){return e===45||e>=128||e<128&&(U[e]&10)!==0}function vn(e){return e>=0&&e<=8||e===11||e>=14&&e<=31||e===127}function $e(e){return e<128&&(U[e]&16)!==0}function M(e){return e<128&&(U[e]&1)!==0}function F(e,t){if(e!==92)return!1;if($e(t))return!1;return!0}function we(e,t,n){if(e===45)return Xe(t)||t===45||F(t,n);if(Xe(e))return!0;if(e===92)return F(e,t);return!1}function wn(e,t,n){if(e===43||e===45){if(P(t))return!0;if(t===46&&P(n))return!0;return!1}if(e===46)return P(t);return P(e)}class ie{source;offset=0;types;starts;ends;count=0;_tokens=null;_lineStarts=null;constructor(e){this.source=e;let t=Math.max(64,Math.ceil(e.length/3));this.types=new Uint8Array(t),this.starts=new Uint32Array(t),this.ends=new Uint32Array(t),this.tokenize()}get lineStarts(){if(this._lineStarts==null)this._lineStarts=$n(this.source);return this._lineStarts}get tokens(){if(this._tokens!=null)return this._tokens;let e=Array.from({length:this.count});for(let t=0;t<this.count;t++)e[t]={type:this.types[t],start:this.starts[t],end:this.ends[t]};return this._tokens=e,e}addToken(e,t,n){if(this.count>=this.types.length)this.grow();this.types[this.count]=e,this.starts[this.count]=t,this.ends[this.count]=n,this.count++}grow(){let t=this.types.length*2,n=new Uint8Array(t);n.set(this.types),this.types=n;let r=new Uint32Array(t);r.set(this.starts),this.starts=r;let s=new Uint32Array(t);s.set(this.ends),this.ends=s}tokenize(){let e=this.source,t=0,n=e.length;while(t<n){let r=e.charCodeAt(t);if(r===47&&e.charCodeAt(t+1)===42){let l=t;t+=2;while(t<n&&!(e.charCodeAt(t)===42&&e.charCodeAt(t+1)===47))t++;t=t<n?t+2:n,this.addToken(25,l,t);continue}if(M(r)){let l=t;while(t<n&&M(e.charCodeAt(t)))t++;this.addToken(13,l,t);continue}if(r===34||r===39){t=this.consumeString(r,t);continue}if(r===35){if(t+1<n&&(Cn(e.charCodeAt(t+1))||F(e.charCodeAt(t+1),e.charCodeAt(t+2)))){let l=t;t++,t=this.consumeName(t),this.addToken(4,l,t);continue}this.addToken(9,t,t+1),t++;continue}switch(r){case 40:this.addToken(21,t,t+1),t++;continue;case 41:this.addToken(22,t,t+1),t++;continue;case 91:this.addToken(19,t,t+1),t++;continue;case 93:this.addToken(20,t,t+1),t++;continue;case 123:this.addToken(23,t,t+1),t++;continue;case 125:this.addToken(24,t,t+1),t++;continue;case 44:this.addToken(18,t,t+1),t++;continue;case 58:this.addToken(16,t,t+1),t++;continue;case 59:this.addToken(17,t,t+1),t++;continue}if(r===60&&e.startsWith("!--",t+1)){this.addToken(14,t,t+4),t+=4;continue}if(r===45&&e.startsWith("->",t+1)){this.addToken(15,t,t+3),t+=3;continue}if(r===64){let l=e.charCodeAt(t+1),a=e.charCodeAt(t+2),o=e.charCodeAt(t+3);if(we(l,a,o)){let c=t;t++,t=this.consumeName(t),this.addToken(3,c,t);continue}this.addToken(9,t,t+1),t++;continue}let s=e.charCodeAt(t+1),i=e.charCodeAt(t+2);if(wn(r,s,i)){t=this.consumeNumeric(t);continue}if(we(r,s,i)){t=this.consumeIdentLike(t);continue}if(r===92){if(F(r,s)){t=this.consumeIdentLike(t);continue}this.addToken(9,t,t+1),t++;continue}this.addToken(9,t,t+1),t++}this.addToken(0,n,n)}consumeString(e,t){let n=this.source,r=n.length,s=t+1;while(s<r){let i=n.charCodeAt(s);if(i===e)return s++,this.addToken(5,t,s),s;if($e(i))return this.addToken(6,t,s),s;if(i===92){let l=n.charCodeAt(s+1);if($e(l)){s+=2;continue}if(s+1<r){s=this.consumeEscapeSkip(s+1);continue}}s++}return this.addToken(5,t,s),s}consumeEscapeSkip(e){let t=this.source;if(e>=t.length)return e;let n=t.charCodeAt(e);if(te(n)){let r=1;e++;while(r<6&&e<t.length&&te(t.charCodeAt(e)))e++,r++;if(e<t.length&&M(t.charCodeAt(e)))e++;return e}return e+1}consumeName(e){let t=this.source,n=t.length,r=e;while(r<n){let s=t.charCodeAt(r);if(s<128&&(U[s]&10)!==0){r++;continue}if(s===45){r++;continue}if(s>=128){r++;continue}if(s===92&&F(s,t.charCodeAt(r+1))){r=this.consumeEscapeSkip(r+1);continue}break}return r}consumeNumber(e){let t=this.source,n=e;if(t.charCodeAt(n)===43||t.charCodeAt(n)===45)n++;while(n<t.length&&P(t.charCodeAt(n)))n++;if(t.charCodeAt(n)===46&&P(t.charCodeAt(n+1))){n+=2;while(n<t.length&&P(t.charCodeAt(n)))n++}let r=t.charCodeAt(n);if(r===69||r===101){let s=t.charCodeAt(n+1),i=t.charCodeAt(n+2);if(P(s)){n+=2;while(n<t.length&&P(t.charCodeAt(n)))n++}else if((s===43||s===45)&&P(i)){n+=3;while(n<t.length&&P(t.charCodeAt(n)))n++}}return n}consumeNumeric(e){let t=this.source,n=this.consumeNumber(e),r=t.charCodeAt(n),s=t.charCodeAt(n+1),i=t.charCodeAt(n+2);if(we(r,s,i)){let l=this.consumeName(n);return this.addToken(12,e,l),l}if(r===37)return this.addToken(11,e,n+1),n+1;return this.addToken(10,e,n),n}consumeIdentLike(e){let t=this.source,n=this.consumeName(e),r=t.charCodeAt(n);if(r===40&&n-e===3){let s=t.charCodeAt(e)|32,i=t.charCodeAt(e+1)|32,l=t.charCodeAt(e+2)|32;if(s===117&&i===114&&l===108){let a=n+1;while(a<t.length&&M(t.charCodeAt(a)))a++;let o=t.charCodeAt(a);if(o===34||o===39)return this.addToken(2,e,n+1),n+1;return this.consumeUrl(e,n)}}if(r===40)return this.addToken(2,e,n+1),n+1;return this.addToken(1,e,n),n}consumeUrl(e,t){let n=this.source,r=n.length,s=t+1;while(s<r&&M(n.charCodeAt(s)))s++;while(s<r){let i=n.charCodeAt(s);if(i===41)return s++,this.addToken(7,e,s),s;if(M(i)){let l=s;while(s<r&&M(n.charCodeAt(s)))s++;if(s>=r)return this.addToken(7,e,s),s;if(n.charCodeAt(s)===41)return s++,this.addToken(7,e,s),s;return this.consumeBadUrl(e,l)}if(i===34||i===39||i===40||vn(i))return this.consumeBadUrl(e,s);if(i===92){if(F(i,n.charCodeAt(s+1))){s=this.consumeEscapeSkip(s+1);continue}return this.consumeBadUrl(e,s)}s++}return this.addToken(7,e,s),s}consumeBadUrl(e,t){let n=this.source,r=t;while(r<n.length){let s=n.charCodeAt(r);if(s===41){r++;break}if(s===92&&F(s,n.charCodeAt(r+1))){r=this.consumeEscapeSkip(r+1);continue}r++}return this.addToken(8,e,r),r}locate(e){let t=this.lineStarts,n=0,r=t.length-1;while(n<r){let i=n+r+1>>1;if(t[i]<=e)n=i;else r=i-1}let s=t[n];return{line:n+1,column:e-s+1}}}function $n(e){let t=[0],n=e.length;for(let r=0;r<n;r++){let s=e.charCodeAt(r);if(s===10)t.push(r+1);else if(s===13){if(e.charCodeAt(r+1)!==10)t.push(r+1)}}return t}function xe(e,t,n){for(let r=t;r<n;r++)if(e.charCodeAt(r)===92)return xn(e,t,n,r);return e.slice(t,n)}function xn(e,t,n,r){let s=e.slice(t,r),i=r;while(i<n){if(e.charCodeAt(i)!==92){s+=e[i],i++;continue}if(i+1>=n){i++;continue}let a=e.charCodeAt(i+1);if(a===10){i+=2;continue}if(a===13){i+=e.charCodeAt(i+2)===10?3:2;continue}if(te(a)){let o=i+1,c="";while(c.length<6&&o<n&&te(e.charCodeAt(o)))c+=e[o],o++;let h=Number.parseInt(c,16);if(o<n&&M(e.charCodeAt(o)))o++;s+=h===0||h>=55296&&h<=57343||h>1114111?String.fromCodePoint(65533):String.fromCodePoint(h),i=o;continue}s+=e[i+1],i+=2}return s}function Se(e,t,n){for(let r=t;r<n;r++)if(e.charCodeAt(r)===92)return Sn(e,t,n,r);return e.slice(t,n)}function Sn(e,t,n,r){let s=e.slice(t,r),i=r;while(i<n){if(e.charCodeAt(i)!==92){s+=e[i],i++;continue}let a=i+1,o="";while(o.length<6&&a<n&&te(e.charCodeAt(a)))o+=e[a],a++;if(o.length>0){let c=Number.parseInt(o,16);if(a<n&&M(e.charCodeAt(a)))a++;s+=c===0||c>=55296&&c<=57343||c>1114111?String.fromCodePoint(65533):String.fromCodePoint(c),i=a;continue}if(a<n){s+=e[a],i=a+1;continue}s+=String.fromCodePoint(65533),i=a}return s}function it(e,t){let n=new ie(e);return{source:e,types:n.types,starts:n.starts,ends:n.ends,count:n.count,end:n.count,pos:0,positions:t.positions??!1,filename:t.filename,parseValue:t.parseValue??!0,parseAtrulePrelude:t.parseAtrulePrelude??!0,parseCustomProperty:t.parseCustomProperty??!1,parseRulePrelude:t.parseRulePrelude??!0,onParseError:t.onParseError,tokenizer:n}}function m(e){return e.pos<e.end?e.types[e.pos]:0}function f(e){let t=e.pos;if(t>=e.end)return{type:0,start:e.starts[t]??e.source.length,end:e.ends[t]??e.source.length};return{type:e.types[t],start:e.starts[t],end:e.ends[t]}}function g(e){let t=e.pos++;if(t>=e.end)return{type:0,start:e.starts[t]??e.source.length,end:e.ends[t]??e.source.length};return{type:e.types[t],start:e.starts[t],end:e.ends[t]}}function D(e,t){return e.source.slice(t.start,t.end)}function R(e){let{types:t,end:n}=e;while(e.pos<n){let r=t[e.pos];if(r===13||r===25)e.pos++;else break}}function Ze(e){let{types:t,end:n}=e;while(e.pos<n&&t[e.pos]===13)e.pos++}function y(e,t,n){if(!e.positions)return null;let r=e.tokenizer.locate(t.start),s=e.tokenizer.locate(n.end);return{source:e.filename??"<unknown>",start:{offset:t.start,line:r.line,column:r.column},end:{offset:n.end,line:s.line,column:s.column}}}function ot(e){if(!e.positions)return null;let t=f(e),n=e.tokenizer.locate(t.start);return{source:e.filename??"<unknown>",start:{offset:t.start,line:n.line,column:n.column},end:{offset:t.start,line:n.line,column:n.column}}}function oe(e,t,n,r){return{type:"Raw",value:e,loc:y(r,t,n)}}function N(){return new L}function ke(e,t,n,r){if(e.onParseError){let{line:s,column:i}=e.tokenizer.locate(n.start),l=SyntaxError(`${e.filename??"<input>"}:${s}:${i}: ${t}`);l.line=s,l.column=i,l.offset=n.start,e.onParseError(l,r)}return r}function z(e,t={}){let n=it(e,t);switch(t.context??"stylesheet"){case"stylesheet":return nt(n);case"atrule":return le(n)??et(n);case"atrulePrelude":return Nn(n);case"mediaQuery":case"mediaQueryList":return tt(n);case"rule":return Ae(n);case"selectorList":return Ee(n);case"selector":return ut(n);case"block":return Ne(n);case"declarationList":return On(n);case"declaration":return Ie(n)??et(n);case"value":return Ln(n);case"raw":return tt(n);default:return nt(n)}}function et(e){return{type:"StyleSheet",children:N(),loc:ot(e)}}function tt(e){let t=f(e),n=t;while(m(e)!==0)n=g(e);return{type:"Raw",value:e.source.slice(t.start,n.end),loc:y(e,t,n)}}function nt(e){let t=f(e),n=N(),{types:r,end:s}=e;while(e.pos<s){let a=r[e.pos];if(a===13){e.pos++;continue}if(a===25){let h={type:25,start:e.starts[e.pos],end:e.ends[e.pos]},u=Te(e,h);e.pos++,n.appendData(u);continue}if(a===0)break;if(a===14||a===15){e.pos++;continue}if(a===3){let h=le(e);if(h)n.appendData(h);continue}if(a===24){e.pos++;continue}let o=e.pos,c=Ae(e);if(n.appendData(c),e.pos===o)e.pos++}let i=e.end-1,l=i>=0?{type:e.types[i],start:e.starts[i],end:e.ends[i]}:{type:0,start:0,end:0};return{type:"StyleSheet",children:n,loc:y(e,t,l)}}function Te(e,t){return{type:"Comment",value:e.source.slice(t.start+2,t.end-2),loc:y(e,t,t)}}function le(e){let t=f(e);if(t.type!==3)return null;e.pos++;let n=ae(e.source,t.start+1,t.end);R(e);let r=e.pos,s=f(e),{types:i,end:l}=e,a=r,o=r;while(a<l){let u=i[a];if(u===0||u===17||u===23)break;if(u!==13&&u!==25)o=a+1;a++}let c=null;if(o>r){let u=e.starts[r],d=e.ends[o-1],b={type:i[o-1],start:e.starts[o-1],end:d},p=e.source.slice(u,d).trim();if(p.length>0)if(e.parseAtrulePrelude)try{let _=e.end;e.end=o,e.pos=r;let T=N();while(m(e)!==0){let K=H(e);if(K)T.appendData(K)}if(lt(T),e.end=_,e.pos=a,T.isEmpty)c=oe(p,s,b,e);else c={type:"AtrulePrelude",children:T,loc:null}}catch(_){let T=oe(p,s,b,e);ke(e,`Failed to parse @${n} prelude: ${_.message}`,s,T),c=T,e.pos=a}else c=oe(p,s,b,e),e.pos=a;else e.pos=a}else e.pos=a;let h=null;if(m(e)===17)g(e);else if(m(e)===23)h=Ne(e,An.has(n));return{type:"Atrule",name:n,prelude:c,block:h,loc:y(e,t,f(e))}}var Tn=new Set(["is","not","where","has","matches","-moz-any","-webkit-any"]),An=new Set(["media","supports","document","layer","container","scope","starting-style","-moz-document","keyframes","-webkit-keyframes","-moz-keyframes","-o-keyframes"]);function Nn(e){let t=f(e),n=N();while(m(e)!==0){if(f(e).type===13){e.pos++;continue}let s=H(e);if(s)n.appendData(s)}return{type:"AtrulePrelude",children:n,loc:y(e,t,f(e))}}function Ae(e){let t=f(e),n;if(e.parseRulePrelude)n=Ee(e);else{let s=f(e),i=s;while(m(e)!==0&&m(e)!==23)i=g(e);let l=e.source.slice(s.start,i.end).trim();n=oe(l,s,i,e)}let r=Ne(e,!0);return{type:"Rule",prelude:n,block:r,loc:y(e,t,f(e))}}function Ne(e,t=!1){let n=f(e);if(m(e)!==23)return{type:"Block",children:N(),loc:ot(e)};e.pos++;let r=N(),{types:s,end:i}=e;while(e.pos<i){let l=s[e.pos];if(l===24||l===0)break;if(l===13){e.pos++;continue}if(l===25){let o={type:25,start:e.starts[e.pos],end:e.ends[e.pos]};e.pos++,r.appendData(Te(e,o));continue}if(l===3){let o=le(e);if(o)r.appendData(o);continue}if(t&&In(e,En)){let o=Ae(e);r.appendData(o);continue}let a=Ie(e);if(a)r.appendData(a);if(e.pos<i&&s[e.pos]===17)e.pos++}if(m(e)===24)e.pos++;return{type:"Block",children:r,loc:y(e,n,f(e))}}function In(e,t){let n=e.pos,r=t(e);return e.pos=n,r}function En(e){let{types:t,end:n}=e;while(e.pos<n){let r=t[e.pos];if(r===23)return!0;if(r===17||r===24||r===0)return!1;e.pos++}return!1}function On(e){let t=f(e),n=N();while(m(e)!==0&&m(e)!==24){let r=f(e);if(r.type===13){e.pos++;continue}if(r.type===25){n.appendData(Te(e,g(e)));continue}if(r.type===17){e.pos++;continue}if(r.type===3){let i=le(e);if(i)n.appendData(i);continue}let s=Ie(e);if(s)n.appendData(s);if(m(e)===17)g(e)}return{type:"DeclarationList",children:n,loc:y(e,t,f(e))}}function Ie(e){R(e);let t=f(e);if(t.type!==1&&t.type!==4&&!(t.type===9&&e.source[t.start]==="*"&&e.source[t.start+1]===" "))if(t.type===9&&e.source[t.start]==="*")e.pos++;else{ke(e,"Expected property name",t,{type:"Raw",value:"",loc:null});let{types:I,end:E}=e;while(e.pos<E){let S=I[e.pos];if(S===0||S===17||S===24)break;e.pos++}return null}let n=e.starts[e.pos],r=e.ends[e.pos];e.pos++;let s=e.source.slice(n,r);if(Ze(e),m(e)!==16){ke(e,`Expected ':' after property "${s}"`,f(e),{type:"Raw",value:"",loc:null});let{types:I,end:E}=e;while(e.pos<E){let S=I[e.pos];if(S===0||S===17||S===24)break;e.pos++}return null}e.pos++,Ze(e);let{types:i,starts:l,end:a,pos:o}=e,c=o,h=o,u=-1,d=-1;while(c<a){let I=i[c];if(I===0||I===17||I===24)break;if(I===9&&e.source.charCodeAt(l[c])===33){let E=c+1;while(E<a&&i[E]===13)E++;if(E<a&&i[E]===1){let S=l[E];if(e.ends[E]-S===9&&(e.source.charCodeAt(S)|32)===105&&(e.source.charCodeAt(S+1)|32)===109&&(e.source.charCodeAt(S+2)|32)===112&&(e.source.charCodeAt(S+3)|32)===111&&(e.source.charCodeAt(S+4)|32)===114&&(e.source.charCodeAt(S+5)|32)===116&&(e.source.charCodeAt(S+6)|32)===97&&(e.source.charCodeAt(S+7)|32)===110&&(e.source.charCodeAt(S+8)|32)===116){d=c,u=E,c=E+1;continue}}}if(I!==13&&I!==25)h=c+1;c++}let b=h,p=u>=0?{type:1,start:l[u],end:e.ends[u]}:null,_=s.startsWith("--"),T,K=l[o],Me=b>o?e.ends[b-1]:K,he={type:i[o],start:K,end:e.ends[o]},Ve=b>o?{type:i[b-1],start:l[b-1],end:Me}:he;if(_&&!e.parseCustomProperty||!e.parseValue)T={type:"Raw",value:e.source.slice(K,Me).trim(),loc:y(e,he,Ve)};else if(b===o)T={type:"Value",children:N(),loc:y(e,he,Ve)};else{let I=e.end;e.end=b,e.pos=o,T=at(e),e.end=I}return e.pos=c,{type:"Declaration",property:s,important:p?!0:!1,value:T,loc:y(e,t,f(e))}}function Ln(e){return at(e)}function at(e){let t=f(e),n=N();while(m(e)!==0&&m(e)!==17&&m(e)!==24&&m(e)!==22&&m(e)!==20){let r=H(e);if(r)n.appendData(r)}return ct(n),{type:"Value",children:n,loc:y(e,t,f(e))}}function lt(e){for(let t of e)if("children"in t&&t.children instanceof L)lt(t.children);ct(e)}function ct(e){let t=e.head;while(t){if(t.data.type==="Number"){let n=t.next;while(n&&n.data.type==="WhiteSpace")n=n.next;if(n&&n.data.type==="Operator"&&n.data.value==="/"){let r=n.next;while(r&&r.data.type==="WhiteSpace")r=r.next;if(r&&r.data.type==="Number"){let s={type:"Ratio",left:t.data,right:r.data,loc:null},i=t.next;while(i&&i!==r.next){let l=i.next;e.remove(i),i=l}e.replace(t,e.createItem(s)),t=e.head;continue}}}t=t.next}}function H(e){let t=e.pos;if(t>=e.end)return null;let n=e.types[t],r=e.starts[t],s=e.ends[t],i=e.source;switch(n){case 13:return e.pos++,e.positions?{type:"WhiteSpace",value:" ",loc:A(e,r,s)}:{type:"WhiteSpace",value:" ",loc:null};case 25:return e.pos++,{type:"Comment",value:i.slice(r+2,s-2),loc:e.positions?A(e,r,s):null};case 10:return e.pos++,{type:"Number",value:i.slice(r,s),loc:e.positions?A(e,r,s):null};case 11:return e.pos++,{type:"Percentage",value:i.slice(r,s-1),loc:e.positions?A(e,r,s):null};case 12:{e.pos++;let l=r,a=i.charCodeAt(l);if(a===43||a===45)l++;let o=!1;while(l<s){let h=i.charCodeAt(l);if(h>=48&&h<=57){l++;continue}if(h===46&&!o){o=!0,l++;continue}break}let c=i.charCodeAt(l);if(c===69||c===101){let h=l+1,u=i.charCodeAt(h);if(u===43||u===45)h++;let d=!1;while(h<s){let b=i.charCodeAt(h);if(b>=48&&b<=57){h++,d=!0;continue}break}if(d)l=h}return{type:"Dimension",value:i.slice(r,l),unit:i.slice(l,s),loc:e.positions?A(e,r,s):null}}case 1:return e.pos++,{type:"Identifier",name:Se(i,r,s),loc:e.positions?A(e,r,s):null};case 5:{e.pos++;let l=r+1,o=s-r>=2&&i.charCodeAt(s-1)===i.charCodeAt(r)?s-1:s;return{type:"String",value:xe(i,l,o),loc:e.positions?A(e,r,s):null}}case 7:{e.pos++;let l=r+4;while(l<s&&rt(i.charCodeAt(l)))l++;let a=s;if(a>l&&i.charCodeAt(a-1)===41)a--;while(a>l&&rt(i.charCodeAt(a-1)))a--;let o;if(a-l>=2){let c=i.charCodeAt(l),h=i.charCodeAt(a-1);if((c===34||c===39)&&c===h)o=i.slice(l+1,a-1);else o=i.slice(l,a)}else o=i.slice(l,a);return{type:"Url",value:o,loc:e.positions?A(e,r,s):null}}case 4:return e.pos++,{type:"Hash",name:i.slice(r+1,s),loc:e.positions?A(e,r,s):null};case 2:return Rn(e);case 21:return _n(e);case 18:return e.pos++,{type:"Operator",value:",",loc:e.positions?A(e,r,s):null};case 16:return e.pos++,{type:"Operator",value:":",loc:e.positions?A(e,r,s):null};case 9:{e.pos++;let l=i.charCodeAt(r),a=i[r];if(Pn(l))return{type:"Operator",value:a,loc:e.positions?A(e,r,s):null};return{type:"Identifier",name:a,loc:e.positions?A(e,r,s):null}}case 19:{e.pos++;let l=N();while(m(e)!==0&&m(e)!==20){let o=H(e);if(o)l.appendData(o)}let a=e.pos<e.end?e.ends[e.pos]:s;if(m(e)===20)e.pos++;return{type:"Brackets",children:l,loc:e.positions?A(e,r,a):null}}case 3:case 23:case 24:case 22:case 20:case 17:case 0:case 14:case 15:case 6:case 8:return e.pos++,{type:"Raw",value:i.slice(r,s),loc:e.positions?A(e,r,s):null}}return e.pos++,null}function rt(e){return e===32||e===9||e===10||e===12||e===13}function Pn(e){return e===47||e===43||e===45||e===42||e===61||e===62||e===60||e===126||e===124||e===36||e===94||e===33||e===38}function ae(e,t,n){for(let r=t;r<n;r++){let s=e.charCodeAt(r);if(s>=65&&s<=90)return e.slice(t,n).toLowerCase()}return e.slice(t,n)}function A(e,t,n){let r=e.tokenizer.locate(t),s=e.tokenizer.locate(n);return{source:e.filename??"<unknown>",start:{offset:t,line:r.line,column:r.column},end:{offset:n,line:s.line,column:s.column}}}function Rn(e){let t=g(e),n=ae(e.source,t.start,t.end-1),r=N();while(m(e)!==0&&m(e)!==22){let s=H(e);if(s)r.appendData(s)}if(m(e)===22)g(e);if(n==="url"){for(let s=r.head;s!=null;s=s.next)if(s.data.type==="String")return{type:"Url",value:s.data.value,loc:y(e,t,f(e))}}return{type:"Function",name:n,children:r,loc:y(e,t,f(e))}}function _n(e){let t=g(e),n=N();while(m(e)!==0&&m(e)!==22){let r=H(e);if(r)n.appendData(r)}if(m(e)===22)g(e);return{type:"Parentheses",children:n,loc:y(e,t,f(e))}}function Ee(e){let t=f(e),n=N();while(m(e)!==0){if(R(e),m(e)===0||m(e)===23)break;let r=ut(e);if(r.children.head!==null)n.appendData(r);if(R(e),m(e)===18){g(e);continue}break}return{type:"SelectorList",children:n,loc:y(e,t,f(e))}}function ut(e){let t=f(e),n=N(),r=!0;while(m(e)!==0&&m(e)!==18&&m(e)!==23){let s=f(e);if(s.type===13){if(g(e),!r&&m(e)!==0&&m(e)!==18&&m(e)!==23&&!st(e)&&!Bn(e)){let l={type:"Combinator",name:" ",loc:y(e,s,s)};n.appendData(l),r=!0}continue}if(s.type===9&&e.source.charCodeAt(s.start)===124&&e.types[e.pos+1]===9&&e.source.charCodeAt(e.starts[e.pos+1])===124){let l=f(e);g(e);let a=g(e),o={type:"Combinator",name:"||",loc:y(e,l,a)};n.appendData(o),r=!0,R(e);continue}if(st(e)){let l=g(e),o={type:"Combinator",name:e.source[l.start],loc:y(e,l,l)};n.appendData(o),r=!0,R(e);continue}let i=Dn(e);if(!i)break;n.appendData(i),r=!1}while(n.tail&&n.tail.data.type==="Combinator")n.remove(n.tail);return{type:"Selector",children:n,loc:y(e,t,f(e))}}function st(e){let t=f(e);if(t.type!==9)return!1;let n=e.source[t.start];return n===">"||n==="+"||n==="~"}function Bn(e){if(e.types[e.pos]!==9)return!1;if(e.source.charCodeAt(e.starts[e.pos])!==124)return!1;if(e.types[e.pos+1]!==9)return!1;return e.source.charCodeAt(e.starts[e.pos+1])===124}function Dn(e){let t=f(e);switch(t.type){case 1:{if(g(e),m(e)===9&&e.source[f(e).start]==="|"&&e.source[f(e).start+1]!=="="&&!(e.types[e.pos+1]===9&&e.source.charCodeAt(e.starts[e.pos+1])===124)){if(g(e),m(e)===1){let r=g(e);return{type:"TypeSelector",name:`${D(e,t)}|${D(e,r)}`,loc:y(e,t,r)}}if(m(e)===9&&e.source[f(e).start]==="*"){let r=g(e);return{type:"TypeSelector",name:`${D(e,t)}|*`,loc:y(e,t,r)}}}return{type:"TypeSelector",name:D(e,t),loc:y(e,t,t)}}case 11:return g(e),{type:"TypeSelector",name:D(e,t),loc:y(e,t,t)};case 10:return g(e),{type:"TypeSelector",name:D(e,t),loc:y(e,t,t)};case 9:{let n=e.source[t.start];if(n==="*")return g(e),{type:"TypeSelector",name:"*",loc:y(e,t,t)};if(n==="."){if(g(e),m(e)===1){let r=g(e);return{type:"ClassSelector",name:D(e,r),loc:y(e,t,r)}}return null}if(n==="&")return g(e),{type:"NestingSelector",loc:y(e,t,t)};return g(e),null}case 4:return g(e),{type:"IdSelector",name:e.source.slice(t.start+1,t.end),loc:y(e,t,t)};case 16:{g(e);let n=m(e)===16;if(n)g(e);return Mn(e,n,t)}case 19:return Vn(e)}return null}function Mn(e,t,n){let r=f(e);if(r.type===1){g(e);let s=ae(e.source,r.start,r.end);return t?{type:"PseudoElementSelector",name:s,children:null,loc:y(e,n,r)}:{type:"PseudoClassSelector",name:s,children:null,loc:y(e,n,r)}}if(r.type===2){g(e);let s=ae(e.source,r.start,r.end-1),i=N();if(!t&&Tn.has(s)){let o=f(e),c=o,h=1;while(m(e)!==0&&h>0){if(m(e)===21||m(e)===2)h++;else if(m(e)===22){if(h--,h===0)break}c=g(e)}if(m(e)===22)g(e);let u=e.source.slice(o.start,c.end).trim();if(u.length>0){let d=it(u,{positions:!1}),b=Ee(d);i.appendData(b)}}else{while(m(e)!==0&&m(e)!==22){let o=H(e);if(o)i.appendData(o)}if(m(e)===22)g(e)}if(t)return{type:"PseudoElementSelector",name:s,children:i,loc:y(e,n,f(e))};return{type:"PseudoClassSelector",name:s,children:i,loc:y(e,n,f(e))}}return null}function Vn(e){let t=g(e);R(e);let n=f(e);if(n.type!==1)return null;g(e);let r={type:"Identifier",name:D(e,n),loc:y(e,n,n)};R(e);let s=null,i=null,l=null,a=f(e);if(a.type===9){let c=e.source[a.start],h=e.source[a.start+1];if(c==="=")s="=",g(e);else if((c==="~"||c==="|"||c==="^"||c==="$"||c==="*")&&h==="="){g(e);let b=f(e);if(b.type===9&&e.source[b.start]==="=")g(e),s=`${c}=`}R(e);let u=f(e);if(u.type===5){g(e);let b=u.end-u.start>=2&&e.source.charCodeAt(u.end-1)===e.source.charCodeAt(u.start);i={type:"String",value:xe(e.source,u.start+1,b?u.end-1:u.end),loc:y(e,u,u)}}else if(u.type===1)g(e),i={type:"Identifier",name:D(e,u),loc:y(e,u,u)};R(e);let d=f(e);if(d.type===1)g(e),l=D(e,d)}R(e);let o=f(e);if(m(e)===20)o=g(e);return{type:"AttributeSelector",name:r,matcher:s,value:i,flags:l,loc:y(e,t,o)}}var ht=Symbol("walkSkip"),x=Symbol("walkStop");function Wn(e){return{root:e,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null}}function jn(e,t){let n=Wn(e),r=typeof t==="function"?t:t.enter,s=typeof t==="function"?null:t.leave??null,i=typeof t==="function"?null:t.visit??null,l=typeof t==="function"?!1:t.reverse??!1;function a(o,c,h){let u=null,d;switch(o.type){case"StyleSheet":u="stylesheet",d=n.stylesheet,n.stylesheet=o;break;case"Atrule":u="atrule",d=n.atrule,n.atrule=o;break;case"AtrulePrelude":u="atrulePrelude",d=n.atrulePrelude,n.atrulePrelude=o;break;case"Rule":u="rule",d=n.rule,n.rule=o;break;case"Selector":u="selector",d=n.selector,n.selector=o;break;case"Block":u="block",d=n.block,n.block=o;break;case"Declaration":u="declaration",d=n.declaration,n.declaration=o;break;case"Function":u="function",d=n.function,n.function=o;break}let b;if((i===null||i===o.type)&&r){let p=r.call(n,o,c,h);if(p===ht){if(u)n[u]=d;return}if(p===x){if(u)n[u]=d;return x}}if(b=Fn(o,l,a),b===x){if(u)n[u]=d;return x}if((i===null||i===o.type)&&s){if(s.call(n,o,c,h)===x){if(u)n[u]=d;return x}}if(u)n[u]=d;return}return a(e,null,null)}var q=Object.assign(jn,{skip:ht,stop:x});function Fn(e,t,n){if("children"in e&&e.children instanceof L)return Un(e.children,t,n);if(e.type==="Rule"){if(n(e.prelude,null,null)===x)return x;if(n(e.block,null,null)===x)return x;return}if(e.type==="Atrule"){if(e.prelude){if(n(e.prelude,null,null)===x)return x}if(e.block){if(n(e.block,null,null)===x)return x}return}if(e.type==="Declaration")return n(e.value,null,null);if(e.type==="AttributeSelector"){if(n(e.name,null,null)===x)return x;if(e.value)return n(e.value,null,null);return}return}function Un(e,t,n){let r;if(t)e.forEachRight((s,i,l)=>{if(r)return;if(n(s,i,l)===x)r=x});else e.forEach((s,i,l)=>{if(r)return;if(n(s,i,l)===x)r=x});return r}function Y(e,t={}){let n=t.exclamation??!1,r=!1;q(e,(s,i,l)=>{if(s.type!=="Comment")return;let a=s.value.startsWith("!");if(n===!0&&a)return;if(n==="first-exclamation"&&a&&!r){r=!0;return}if(i&&l)l.remove(i)})}function ce(e){q(e,(t)=>{if(t.type!=="Block"&&t.type!=="DeclarationList")return;if(!("children"in t)||!t.children)return;let n=t.children,r=n.head;if(r==null||r.next==null)return;let s=0;for(let a=r;a!=null;a=a.next)if(a.data.type==="Declaration"){if(s++,s>=2)break}if(s<2)return;let i=new Map,l=[];for(let a=r;a!=null;a=a.next){let o=a.data;if(o.type!=="Declaration")continue;let c=o.property,h=i.get(c);if(h){let u=!!h.decl.important,d=!!o.important;if(d||u===d)l.push(h.item),i.set(c,{item:a,decl:o});else l.push(a)}else i.set(c,{item:a,decl:o})}for(let a of l)n.remove(a)})}var zn={black:"#000",fuchsia:"#f0f",white:"#fff",red:"#f00",cyan:"#0ff",blue:"#00f",yellow:"#ff0",magenta:"#f0f",lime:"#0f0",silver:"#c0c0c0",gray:"#808080",maroon:"#800000",olive:"#808000",green:"#008000",purple:"#800080",teal:"#008080",navy:"#000080"},Hn={"#f00":"red","#ff0000":"red","#000080":"navy","#008080":"teal"};function Le(e){if(!e.startsWith("#"))return e;let t=e.slice(1);if(t.length===6){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5])return`#${t[0]}${t[2]}${t[4]}`}if(t.length===8){if(t[0]===t[1]&&t[2]===t[3]&&t[4]===t[5]&&t[6]===t[7])return`#${t[0]}${t[2]}${t[4]}${t[6]}`}return e}function dt(e){let t=e.toLowerCase();return zn[t]??null}function mt(e){let t=e.toLowerCase();return Hn[t]??null}function qn(e,t,n){let r=(e<<16|t<<8|n).toString(16).padStart(6,"0");return Le(`#${r}`)}var Gn=/^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*(?:[,/]\s*([+-]?\d*\.?\d+%?)\s*)?\)$/;function ft(e){let t=Gn.exec(e.trim());if(!t)return e;let n=Oe(t[1]),r=Oe(t[2]),s=Oe(t[3]);if(t[4]!==void 0&&!Kn(t[4]))return e;return qn(n,r,s)}function Kn(e){if(e.endsWith("%"))return Number.parseFloat(e)>=100;return Number.parseFloat(e)>=1}function Oe(e){if(e.endsWith("%"))return Math.max(0,Math.min(255,Math.round(Number.parseFloat(e)*2.55)));return Math.max(0,Math.min(255,Math.round(Number.parseFloat(e))))}var Yn=new Set(["px","pt","pc","in","cm","mm","q","em","rem","ex","ch","cap","ic","lh","rlh","vw","vh","vi","vb","vmin","vmax","svw","svh","svi","svb","svmin","svmax","lvw","lvh","lvi","lvb","lvmin","lvmax","dvw","dvh","dvi","dvb","dvmin","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"]);function ue(e){if(e.charCodeAt(0)===43)e=e.slice(1);if(e.includes(".")){let t=e.replace(/(\.\d*?)0+($|[eE])/,"$1$2");t=t.replace(/\.($|[eE])/,"$1"),e=t}if(e.startsWith("0.")&&e.length>2)e=e.slice(1);else if(e.startsWith("-0.")&&e.length>3)e=`-${e.slice(2)}`;if(e==="-0"||e==="-.0"||e==="-0.0")e="0";return e}function pt(e,t){let n=ue(e);if((n==="0"||n==="-0")&&Yn.has(t.toLowerCase()))return{value:"0",unit:""};return{value:n,unit:t}}function gt(e){return ue(e)}function yt(e,t){let n=Number.parseFloat(e);if(!Number.isFinite(n))return e;let r=t<0?0:t;return n.toFixed(r)}var bt=new Set(["color","background","background-color","border","border-color","border-top","border-top-color","border-right","border-right-color","border-bottom","border-bottom-color","border-left","border-left-color","border-block","border-block-color","border-block-start-color","border-block-end-color","border-inline","border-inline-color","border-inline-start-color","border-inline-end-color","outline","outline-color","caret-color","fill","stroke","flood-color","lighting-color","stop-color","column-rule","column-rule-color","text-decoration","text-decoration-color","text-emphasis","text-emphasis-color","text-shadow","box-shadow","accent-color","scrollbar-color"]);function Ct(e){if(!e||e.type!=="Operator")return!1;let t=e.value;return t===":"||t===","||t==="/"}function Qn(e){let t=e.children;if(!t)return;while(t.head&&t.head.data.type==="WhiteSpace")t.remove(t.head);while(t.tail&&t.tail.data.type==="WhiteSpace")t.remove(t.tail);let n=t.head;while(n){let r=n.next;if(n.data.type==="WhiteSpace"){let s=n.prev&&Ct(n.prev.data),i=r&&Ct(r.data);if(s||i)t.remove(n)}n=r}}function Pe(e,t={}){let n=t.floatPrecision??null,r=n===null?null:(s)=>yt(s,n);q(e,{enter(s,i,l){switch(s.type){case"Number":{let a=r?r(s.value):s.value;s.value=ue(a);return}case"Percentage":{let a=r?r(s.value):s.value;s.value=gt(a);return}case"Dimension":{let a=r?r(s.value):s.value,o=pt(a,s.unit);s.value=o.value,s.unit=o.unit;return}case"Hash":{let a=Le(`#${s.name}`).slice(1);if(s.name=a,i&&l&&this.declaration&&bt.has(this.declaration.property.toLowerCase())){let o=mt(`#${a}`);if(o&&o.length<a.length+1){let c={type:"Identifier",name:o,loc:s.loc};l.replace(i,l.createItem(c))}}return}case"Identifier":{if(!i||!l||!this.declaration)return;if(!bt.has(this.declaration.property.toLowerCase()))return;let a=dt(s.name);if(a&&a.length<s.name.length){let o={type:"Hash",name:a.slice(1),loc:s.loc};l.replace(i,l.createItem(o))}return}case"Url":return;case"Function":{let a=s.name.toLowerCase();if((a==="rgb"||a==="rgba")&&i&&l)s.__rgbReplaceCandidate=!0}}},leave(s,i,l){if(s.type==="Parentheses"||s.type==="Function"||s.type==="Value")Qn(s);if(s.type==="Function"&&s.__rgbReplaceCandidate&&i&&l){let a=k(s),o=ft(a);if(o!==a&&o.startsWith("#")){let c={type:"Hash",name:o.slice(1),loc:s.loc};l.replace(i,l.createItem(c))}}}})}function Re(e,t={}){let n=z(e,{context:"stylesheet"});return vt(n,t)}function _e(e,t={}){let n=z(e,{context:"declarationList"});return vt(n,t)}function vt(e,t){if(t.comments===!1)Y(e,{exclamation:!1});else if(t.comments==="first-exclamation")Y(e,{exclamation:"first-exclamation"});else Y(e,{exclamation:!0});return Pe(e,{floatPrecision:t.floatPrecision??null}),ce(e),{css:k(e),ast:e}}var Be="0.3.2";function De(e){if(!er(e))process.stderr.write(`ts-css: file not found: ${e}
33
+ `),process.exit(1);return tr(e,"utf8")}var G=new Ce("ts-css");G.command("minify <file>","Minify a CSS file").option("--no-comments","Strip /*!*/ comments too").option("--block",'Treat input as a declarationList (style="\u2026" body)').action(async(e,t)=>{let n=De(e),r={comments:t.comments===!1?!1:"exclamation"},s=t.block?_e(n,r):Re(n,r);process.stdout.write(s.css)});G.command("parse <file>","Parse a CSS file and print its AST as JSON").option("--positions","Include source locations on every node").action(async(e,t)=>{let n=De(e),r=z(n,{positions:t.positions});process.stdout.write(JSON.stringify(r,null,2))});G.command("format <file>","Round-trip CSS through parser/generator (deterministic single-line output)").action(async(e)=>{let t=De(e),n=z(t);process.stdout.write(k(n))});G.command("version","Show the version of the CLI").action(()=>{console.log(Be)});G.version(Be);G.help();G.parse();