@stacksjs/ts-css 0.1.2 → 0.1.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +28 -0
- package/dist/bin/cli.js +42 -0
- package/dist/chunk-1kmkypmr.js +3 -0
- package/dist/chunk-2wsah70r.js +2 -0
- package/dist/chunk-9ep6bwwb.js +2 -0
- package/dist/chunk-edwg811g.js +2 -0
- package/dist/chunk-thy3p95k.js +3 -0
- package/dist/index.js +51 -51
- package/dist/optimize/index.js +1 -1
- package/dist/parse/index.js +1 -1
- package/dist/select/index.js +1 -1
- package/dist/what/index.js +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,3 +1,31 @@
|
|
|
1
|
+
[Compare changes](https://github.com/stacksjs/ts-css/compare/v0.1.3...v0.1.4)
|
|
2
|
+
|
|
3
|
+
## 🐛 Bug Fixes
|
|
4
|
+
|
|
5
|
+
- **build**: build the CLI the bin field points at ([61d4584](https://github.com/stacksjs/ts-css/commit/61d4584)) _(by Chris <chrisbreuer93@gmail.com>)_
|
|
6
|
+
|
|
7
|
+
## 🧹 Chores
|
|
8
|
+
|
|
9
|
+
- release v0.1.4 ([5c4ca3d](https://github.com/stacksjs/ts-css/commit/5c4ca3d)) _(by Chris <chrisbreuer93@gmail.com>)_
|
|
10
|
+
|
|
11
|
+
## Contributors
|
|
12
|
+
|
|
13
|
+
- _Chris <chrisbreuer93@gmail.com>_
|
|
14
|
+
|
|
15
|
+
[Compare changes](https://github.com/stacksjs/ts-css/compare/v0.1.2...v0.1.3)
|
|
16
|
+
|
|
17
|
+
## ⚡ Performance Improvements
|
|
18
|
+
|
|
19
|
+
- **build**: cut the waste out of the published output ([222ad06](https://github.com/stacksjs/ts-css/commit/222ad06)) _(by Chris <chrisbreuer93@gmail.com>)_
|
|
20
|
+
|
|
21
|
+
## 🧹 Chores
|
|
22
|
+
|
|
23
|
+
- release v0.1.3 ([1b59c44](https://github.com/stacksjs/ts-css/commit/1b59c44)) _(by Chris <chrisbreuer93@gmail.com>)_
|
|
24
|
+
|
|
25
|
+
## Contributors
|
|
26
|
+
|
|
27
|
+
- _Chris <chrisbreuer93@gmail.com>_
|
|
28
|
+
|
|
1
29
|
[Compare changes](https://github.com/stacksjs/ts-css/compare/v0.1.1...v0.1.2)
|
|
2
30
|
|
|
3
31
|
## ⚡ Performance Improvements
|
package/dist/bin/cli.js
ADDED
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
#!/usr/bin/env bun
|
|
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}
|
|
4
|
+
|
|
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();
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{F as k}from"./chunk-1kmkypmr.js";var a={};k(a,{stringify:()=>O,parse:()=>W,isTraversal:()=>E,IgnoreCaseMode:()=>N});var w=/(?:\\(?:[\dA-Fa-f]{1,6} ?|[^])|[\w\-\u00B0-\uFFFF])+/y,b=/\\([\dA-Fa-f]{1,6} ?|[^])/g;function S(z){return z.replace(b,(X,Z)=>{if(Z.length>1&&/^[\dA-Fa-f]/.test(Z)){let Q=Number.parseInt(Z,16);if(Q>=55296&&Q<=57343)return"\uFFFD";return String.fromCodePoint(Q)}return Z})}function R(z){return z.indexOf("\\")<0?z:S(z)}var T=new Set(["accept","accept-charset","align","alink","axis","bgcolor","charset","checked","clear","codetype","color","compact","declare","defer","dir","direction","disabled","enctype","face","frame","hreflang","http-equiv","lang","language","link","media","method","multiple","nohref","noresize","noshade","nowrap","readonly","rel","rev","rules","scope","scrolling","selected","shape","target","text","type","valign","valuetype","vlink"]);function x(z){switch(z){case 126:return"element";case 94:return"start";case 36:return"end";case 42:return"any";case 33:return"not";case 124:return"hyphen";default:return null}}function P(z){return z===32||z===9||z===10||z===13||z===12}function W(z,X={}){let Z=[],Q=_(Z,z,X,0);if(Q<z.length)throw Error(`Unmatched selector: ${z.slice(Q)}`);return Z}function Y(z,X){w.lastIndex=X;let Z=w.exec(z);if(!Z)throw Error(`Expected name, found ${z.slice(X)}`);return{value:R(Z[0]),end:X+Z[0].length}}function L(z,X){while(X<z.length&&P(z.charCodeAt(X)))X++;return X}function _(z,X,Z,Q){let H=[],J=L(X,Q),G=X.length,B=Z.xmlMode===!0,D=Z.lowerCaseAttributeNames!==!1&&!B,V=Z.lowerCaseTags!==!1;while(J<G){let U=X.charCodeAt(J);if(P(U)){let $=J+1;while($<G&&P(X.charCodeAt($)))$++;if(H.length===0)return $;J=$,h(H,"descendant");continue}if(U===62||U===60||U===126||U===43||U===124){let $=J+1;while($<G&&P(X.charCodeAt($)))$++;switch(J=$,U){case 62:h(H,"child");break;case 60:h(H,"parent");break;case 126:h(H,"sibling");break;case 43:h(H,"adjacent");break;case 124:if(J<G&&X.charCodeAt(J)===124)J++,J=L(X,J),h(H,"column-combinator");else H.push({type:"tag",name:"",namespace:""});break}continue}if(U===44){if(H.length===0)throw Error("Empty sub-selector");z.push(H),H=[],J=L(X,J+1);continue}if(U===47&&X.charCodeAt(J+1)===42){let $=X.indexOf("*/",J+2);if($<0)throw Error("Unmatched comment");J=L(X,$+2);continue}if(U===42){J++,H.push({type:"universal",namespace:null});continue}if(U===35){let $=Y(X,J+1);J=$.end,H.push({type:"attribute",name:"id",action:"equals",value:$.value,namespace:null,ignoreCase:!1});continue}if(U===46){let $=Y(X,J+1);J=$.end,H.push({type:"attribute",name:"class",action:"element",value:$.value,namespace:null,ignoreCase:!1});continue}if(U===91){J=g(X,J,H,Z,B,D);continue}if(U===58){J=I(X,J,H,Z);continue}if(U===124){J++;let $=Y(X,J);J=$.end,H.push({type:"tag",name:V?$.value.toLowerCase():$.value,namespace:""});continue}{let $=Y(X,J);if(J=$.end,J<G&&X.charCodeAt(J)===124&&X.charCodeAt(J+1)!==61){J++;let j=Y(X,J);J=j.end,H.push({type:"tag",name:V?j.value.toLowerCase():j.value,namespace:$.value})}else H.push({type:"tag",name:V?$.value.toLowerCase():$.value,namespace:null})}}if(H.length>0)z.push(H);return J}function g(z,X,Z,Q,H,J){let G=X+1,B=z.length,D;if(z.charCodeAt(G)===124)throw Error("Empty namespace not supported");if(z.charCodeAt(G)===42&&z.charCodeAt(G+1)===124){G+=2;let K=Y(z,G);G=K.end,D=K.value}else{let K=Y(z,G);if(G=K.end,D=K.value,z.charCodeAt(G)===124&&z.charCodeAt(G+1)!==61){G++;let F=Y(z,G);G=F.end,D=F.value}}G=L(z,G);let V="exists",U="",$=null,j=z.charCodeAt(G);if(j===61)V="equals",G++;else if(j===33&&z.charCodeAt(G+1)===61)V="not",G+=2;else{let K=x(j);if(K!==null&&z.charCodeAt(G+1)===61)V=K,G+=2}if(V!=="exists"){G=L(z,G);let K=z.charCodeAt(G);if(K===34||K===39){let q=A(z,G+1,K);U=R(z.slice(G+1,q)),G=q+1}else{let q=Y(z,G);U=q.value,G=q.end}G=L(z,G);let F=z.charCodeAt(G);if(F===105||F===73)$=!0,G++;else if(F===115||F===83)$=!1,G++}if(z.charCodeAt(G)!==93)throw Error("Expected ]");if(G++,$===null&&!H&&T.has(D.toLowerCase()))$="quirks";return Z.push({type:"attribute",name:J?D.toLowerCase():D,action:V,value:U,namespace:null,ignoreCase:$}),G}function I(z,X,Z,Q){if(z.charCodeAt(X+1)===58){let B=X+2,D=Y(z,B);B=D.end;let V=D.value.toLowerCase(),U=null;if(z.charCodeAt(B)===40){let $=v(z,B);U=z.slice(B+1,$).trim(),B=$+1}return Z.push({type:"pseudo-element",name:V,data:U}),B}let H=X+1,J=Y(z,H);H=J.end;let G=J.value.toLowerCase();if(z.charCodeAt(H)===40){let B=v(z,H),D=z.slice(H+1,B);if(H=B+1,G==="is"||G==="not"||G==="where"||G==="has"||G==="matches"||G==="-moz-any"||G==="-webkit-any"){let V=[];_(V,D.trim(),Q,0),Z.push({type:"pseudo",name:G,data:V})}else Z.push({type:"pseudo",name:G,data:D.trim()})}else Z.push({type:"pseudo",name:G,data:null});return H}function h(z,X){if(z.length>0&&z[z.length-1].type==="descendant"&&X!=="descendant")z.pop();if(z.length>0&&z[z.length-1].type===X)return;z.push({type:X})}function A(z,X,Z){let Q=X,H=z.length;while(Q<H){let J=z.charCodeAt(Q);if(J===92){Q+=2;continue}if(J===Z)return Q;Q++}throw Error("Unterminated string")}function v(z,X){let Z=1,Q=X+1,H=z.length;while(Q<H){let J=z.charCodeAt(Q);if(J===92){Q+=2;continue}if(J===34||J===39){Q=A(z,Q+1,J)+1;continue}if(J===40)Z++;else if(J===41){if(Z--,Z===0)return Q}Q++}throw Error("Unterminated parenthesis")}var f={child:" > ",parent:" < ",sibling:" ~ ",adjacent:" + ",descendant:" ","column-combinator":" || "};function O(z){return z.map(u).join(", ")}function u(z){return z.map((X,Z)=>C(X,z[Z-1])).join("")}function C(z,X){switch(z.type){case"tag":return`${M(z.namespace)}${y(z.name)}`;case"universal":return`${M(z.namespace)}*`;case"attribute":{if(z.name==="id"&&z.action==="equals"&&!z.ignoreCase&&!z.namespace)return`#${y(z.value)}`;if(z.name==="class"&&z.action==="element"&&!z.ignoreCase&&!z.namespace)return`.${y(z.value)}`;let Z=`[${M(z.namespace)}${y(z.name)}`;if(z.action!=="exists"){let Q=p[z.action]??"=";if(Z+=Q,Z+=`"${z.value.replace(/"/g,"\\\"")}"`,z.ignoreCase===!0)Z+=" i";else if(z.ignoreCase===!1)Z+=" s"}return Z+="]",Z}case"pseudo":if(z.data===null)return`:${z.name}`;if(typeof z.data==="string")return`:${z.name}(${z.data})`;return`:${z.name}(${O(z.data)})`;case"pseudo-element":return z.data===null?`::${z.name}`:`::${z.name}(${z.data})`;case"descendant":case"child":case"parent":case"sibling":case"adjacent":case"column-combinator":return f[z.type]??" "}return""}var p={equals:"=",element:"~=",start:"^=",end:"$=",any:"*=",not:"!=",hyphen:"|="};function M(z){if(z===null)return"";if(z==="")return"|";return`${y(z)}|`}var m=/[^\w\u00B0-\uFFFF-]/g;function y(z){if(z==="")return"";return z.replace(m,(X)=>`\\${X}`)}var d=new Set(["adjacent","child","descendant","parent","sibling","column-combinator"]);function E(z){return d.has(z.type)}var N={Unknown:null,QuirksMode:"quirks",IgnoreCase:!0,CaseSensitive:!1};export{W as A,O as B,E as C,N as D,a as E};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{F as eM}from"./chunk-1kmkypmr.js";var MQ={};eM(MQ,{walk:()=>wM,parse:()=>WM,makeList:()=>$M,generate:()=>g,decodeName:()=>a,clone:()=>FM,Tokenizer:()=>T,TokenType:()=>p,List:()=>j});function f(M){return{prev:null,next:null,data:M}}class j{head=null;tail=null;cursors=[];allocateCursor(M,Q){let G={prev:M,next:Q};return this.cursors.push(G),G}releaseCursor(){this.cursors.pop()}updateCursors(M,Q,G,J){for(let X of this.cursors){if(X.prev===M)X.prev=Q;if(X.next===G)X.next=J}}static createItem(M){return f(M)}createItem(M){return f(M)}get isEmpty(){return this.head===null}get first(){return this.head?.data??null}get last(){return this.tail?.data??null}*[Symbol.iterator](){for(let M=this.head;M!=null;M=M.next)yield M.data}fromArray(M){let Q=null;this.head=null;for(let G of M){let J=f(G);if(J.prev=Q,Q)Q.next=J;else this.head=J;Q=J}return this.tail=Q,this}toArray(){let M=[];for(let Q=this.head;Q!=null;Q=Q.next)M.push(Q.data);return M}toJSON(){return this.toArray()}forEach(M,Q){let G=this.allocateCursor(null,this.head);while(G.next!==null){let J=G.next;G.prev=J,G.next=J.next,M.call(Q,J.data,J,this)}this.releaseCursor()}forEachRight(M,Q){let G=this.allocateCursor(this.tail,null);while(G.prev!==null){let J=G.prev;G.next=J,G.prev=J.prev,M.call(Q,J.data,J,this)}this.releaseCursor()}reduce(M,Q){let G=Q,J=0;for(let X=this.head;X!=null;X=X.next)G=M(G,X.data,J++,this);return G}some(M){let Q=0;for(let G=this.head;G!=null;G=G.next)if(M(G.data,Q++,this))return!0;return!1}map(M){let Q=new j,G=null,J=0;for(let X=this.head;X!=null;X=X.next){let Y=f(M(X.data,J++,this));if(Y.prev=G,G)G.next=Y;else Q.head=Y;G=Y}return Q.tail=G,Q}filter(M){let Q=new j,G=null,J=0;for(let X=this.head;X!=null;X=X.next)if(M(X.data,J++,this)){let Y=f(X.data);if(Y.prev=G,G)G.next=Y;else Q.head=Y;G=Y}return Q.tail=G,Q}clear(){let M=this.head;while(M){let Q=M.next;M.prev=null,M.next=null,M=Q}this.head=null,this.tail=null}copy(){let M=new j,Q=null;for(let G=this.head;G!=null;G=G.next){let J=f(G.data);if(J.prev=Q,Q)Q.next=J;else M.head=J;Q=J}return M.tail=Q,M}prepend(M){return this.insert(M,this.head)}prependData(M){return this.insert(f(M),this.head)}append(M){return this.insert(M,null)}appendData(M){return this.insert(f(M),null)}insert(M,Q=null){if(Q!=null)if(this.updateCursors(Q.prev,M,Q,M),Q.prev===null){if(this.head!==Q)throw Error("before doesn't belong to list");this.head=M,Q.prev=M,M.next=Q,this.updateCursors(null,M,null,null)}else Q.prev.next=M,M.prev=Q.prev,Q.prev=M,M.next=Q;else if(this.updateCursors(this.tail,M,null,M),this.tail!==null)this.tail.next=M,M.prev=this.tail,this.tail=M;else this.head=M,this.tail=M;return this}insertData(M,Q=null){return this.insert(f(M),Q)}remove(M){if(this.updateCursors(M,M.prev,M,M.next),M.prev!==null)M.prev.next=M.next;else if(this.head===M)this.head=M.next;else throw Error("item doesn't belong to list");if(M.next!==null)M.next.prev=M.prev;else if(this.tail===M)this.tail=M.prev;else throw Error("item doesn't belong to list");return M.prev=null,M.next=null,M}push(M){this.insert(f(M),null)}pop(){if(this.tail===null)return null;return this.remove(this.tail)}unshift(M){this.prependData(M)}shift(){if(this.head===null)return null;return this.remove(this.head)}prependList(M){return this.insertList(M,this.head)}appendList(M){return this.insertList(M,null)}insertList(M,Q=null){if(M.head===null)return this;if(Q!==null){if(this.updateCursors(Q.prev,M.tail,Q,M.head),Q.prev!==null)Q.prev.next=M.head,M.head.prev=Q.prev;else this.head=M.head;Q.prev=M.tail,M.tail.next=Q}else{if(this.updateCursors(this.tail,M.tail,null,M.head),this.tail!==null)this.tail.next=M.head,M.head.prev=this.tail;else this.head=M.head;this.tail=M.tail}return M.head=null,M.tail=null,this}replace(M,Q){if(Q instanceof j)this.insertList(Q,M),this.remove(M);else this.insert(Q,M),this.remove(M)}}function $M(){return new j}function FM(M){return k(M)}function k(M){if(M===null||typeof M!=="object")return M;if(M instanceof j){let G=new j;for(let J of M)G.appendData(k(J));return G}if(Array.isArray(M))return M.map(k);if("type"in M&&typeof M.type==="string"){let G={type:M.type};for(let J of Object.keys(M)){if(J==="type")continue;G[J]=k(M[J])}return G}let Q={};for(let G of Object.keys(M))Q[G]=k(M[G]);return Q}function g(M){switch(M.type){case"StyleSheet":return I(M.children,"");case"Rule":return`${g(M.prelude)}{${g(M.block)}}`;case"Block":return IM(M.children);case"Atrule":{let Q=`@${M.name}`;if(M.prelude){let G=g(M.prelude);if(G)Q+=` ${G}`}if(M.block)Q+=`{${g(M.block)}}`;else Q+=";";return Q}case"AtrulePrelude":return I(M.children,"");case"SelectorList":return I(M.children,",");case"Selector":return I(M.children,"");case"TypeSelector":return M.name;case"IdSelector":return`#${M.name}`;case"ClassSelector":return`.${M.name}`;case"NestingSelector":return"&";case"AttributeSelector":{let Q=`[${M.name.name}`;if(M.matcher&&M.value)if(Q+=M.matcher,M.value.type==="String")Q+=`"${n(M.value.value)}"`;else Q+=M.value.name;if(M.flags)Q+=` ${M.flags}`;return Q+="]",Q}case"PseudoClassSelector":return M.children?`:${M.name}(${I(M.children,"")})`:`:${M.name}`;case"PseudoElementSelector":return M.children?`::${M.name}(${I(M.children,"")})`:`::${M.name}`;case"Combinator":return M.name===" "?" ":M.name;case"Declaration":return`${M.property}:${g(M.value)}${M.important?"!important":""}`;case"DeclarationList":return I(M.children,";");case"Value":return I(M.children,"");case"Identifier":return M.name;case"Number":return M.value;case"Percentage":return`${M.value}%`;case"Dimension":return M.value+M.unit;case"String":return`"${n(M.value)}"`;case"Url":return/[\s"'()\\\u0000-\u001F\u007F]/.test(M.value)?`url("${n(M.value)}")`:`url(${M.value})`;case"Hash":return`#${M.name}`;case"Operator":return M.value;case"Function":return`${M.name}(${I(M.children,"")})`;case"Parentheses":return`(${I(M.children,"")})`;case"Brackets":return`[${I(M.children,"")}]`;case"Raw":return M.value;case"Comment":return M.value.startsWith("!")?`/*${M.value}*/`:"";case"WhiteSpace":return" ";case"CDO":return"<!--";case"CDC":return"-->";case"AnPlusB":{let Q=M.a??"",G=M.b??"";if(Q&&G){let J=Number(G);return`${Q==="1"?"":Q==="-1"?"-":Q}n${J>=0?`+${G}`:G}`}if(Q)return`${Q==="1"?"":Q==="-1"?"-":Q}n`;return G}case"Ratio":return`${M.left.value}/${M.right.value}`;case"UnicodeRange":return M.value;case"Nth":return M.selector?`${g(M.nth)} of ${g(M.selector)}`:g(M.nth);case"MediaQueryList":return I(M.children,",");case"MediaQuery":return I(M.children,"");case"MediaFeature":{let Q=`(${M.name}`;if(M.value)Q+=`:${g(M.value)}`;return Q+=")",Q}}return""}function I(M,Q){let G="",J=!0,X=null,Y=M.head;while(Y!=null){let Z=Y.data;if(Z.type==="WhiteSpace"){let $=Y.next?Y.next.data:null;if(UM(X)||UM($)){Y=Y.next;continue}}let F=g(Z);if(!F){Y=Y.next;continue}if(!J&&Q&&!CM(X))G+=Q;J=!1,G+=F,X=Z,Y=Y.next}return G}function IM(M){let Q="",G=null,J=M.head;while(J!=null){let X=J.data,Y=g(X);if(!Y){J=J.next;continue}if(G&&gM(G,X))Q+=";";Q+=Y,G=X,J=J.next}return Q}function gM(M,Q){return M.type==="Declaration"&&Q.type!=="Comment"}function UM(M){if(!M||M.type!=="Operator")return!1;let Q=M.value;return Q===":"||Q===","||Q==="/"}function CM(M){if(!M)return!1;return M.type==="Operator"||M.type==="Combinator"}function n(M){let Q="";for(let G=0;G<M.length;G++){let J=M.charCodeAt(G);if(J===92)Q+="\\\\";else if(J===34)Q+="\\\"";else if(J<32||J===127){let X=J.toString(16),Y=G+1<M.length?M.charCodeAt(G+1):-1,Z=Y===32||Y===9||Y===10||Y===12||Y===13||Y>=48&&Y<=57||Y>=65&&Y<=70||Y>=97&&Y<=102;Q+=`\\${X}${Z?" ":""}`}else Q+=M[G]}return Q}var p;((K)=>{K[K.EOF=0]="EOF";K[K.Ident=1]="Ident";K[K.Function=2]="Function";K[K.AtKeyword=3]="AtKeyword";K[K.Hash=4]="Hash";K[K.String=5]="String";K[K.BadString=6]="BadString";K[K.Url=7]="Url";K[K.BadUrl=8]="BadUrl";K[K.Delim=9]="Delim";K[K.Number=10]="Number";K[K.Percentage=11]="Percentage";K[K.Dimension=12]="Dimension";K[K.WhiteSpace=13]="WhiteSpace";K[K.CDO=14]="CDO";K[K.CDC=15]="CDC";K[K.Colon=16]="Colon";K[K.Semicolon=17]="Semicolon";K[K.Comma=18]="Comma";K[K.LeftSquareBracket=19]="LeftSquareBracket";K[K.RightSquareBracket=20]="RightSquareBracket";K[K.LeftParenthesis=21]="LeftParenthesis";K[K.RightParenthesis=22]="RightParenthesis";K[K.LeftCurlyBracket=23]="LeftCurlyBracket";K[K.RightCurlyBracket=24]="RightCurlyBracket";K[K.Comment=25]="Comment"})(p||={});var h=(()=>{let M=new Uint8Array(128);for(let Q=0;Q<128;Q++){let G=0;if(Q===32||Q===9||Q===10||Q===12||Q===13)G|=1;if(Q>=48&&Q<=57)G|=2;if(Q>=48&&Q<=57||Q>=65&&Q<=70||Q>=97&&Q<=102)G|=4;if(Q>=65&&Q<=90||Q>=97&&Q<=122||Q===95)G|=8;if(Q===10||Q===12||Q===13)G|=16;M[Q]=G}return M})();function P(M){return M<128&&(h[M]&2)!==0}function l(M){return M<128&&(h[M]&4)!==0}function KM(M){return M>=128||M<128&&(h[M]&8)!==0}function xM(M){return M===45||M>=128||M<128&&(h[M]&10)!==0}function PM(M){return M>=0&&M<=8||M===11||M>=14&&M<=31||M===127}function t(M){return M<128&&(h[M]&16)!==0}function S(M){return M<128&&(h[M]&1)!==0}function v(M,Q){if(M!==92)return!1;if(t(Q))return!1;return!0}function o(M,Q,G){if(M===45)return KM(Q)||Q===45||v(Q,G);if(KM(M))return!0;if(M===92)return v(M,Q);return!1}function bM(M,Q,G){if(M===43||M===45){if(P(Q))return!0;if(Q===46&&P(G))return!0;return!1}if(M===46)return P(Q);return P(M)}class T{source;offset=0;types;starts;ends;count=0;_tokens=null;_lineStarts=null;constructor(M){this.source=M;let Q=Math.max(64,Math.ceil(M.length/3));this.types=new Uint8Array(Q),this.starts=new Uint32Array(Q),this.ends=new Uint32Array(Q),this.tokenize()}get lineStarts(){if(this._lineStarts==null)this._lineStarts=fM(this.source);return this._lineStarts}get tokens(){if(this._tokens!=null)return this._tokens;let M=Array.from({length:this.count});for(let Q=0;Q<this.count;Q++)M[Q]={type:this.types[Q],start:this.starts[Q],end:this.ends[Q]};return this._tokens=M,M}addToken(M,Q,G){if(this.count>=this.types.length)this.grow();this.types[this.count]=M,this.starts[this.count]=Q,this.ends[this.count]=G,this.count++}grow(){let Q=this.types.length*2,G=new Uint8Array(Q);G.set(this.types),this.types=G;let J=new Uint32Array(Q);J.set(this.starts),this.starts=J;let X=new Uint32Array(Q);X.set(this.ends),this.ends=X}tokenize(){let M=this.source,Q=0,G=M.length;while(Q<G){let J=M.charCodeAt(Q);if(J===47&&M.charCodeAt(Q+1)===42){let Z=Q;Q+=2;while(Q<G&&!(M.charCodeAt(Q)===42&&M.charCodeAt(Q+1)===47))Q++;Q=Q<G?Q+2:G,this.addToken(25,Z,Q);continue}if(S(J)){let Z=Q;while(Q<G&&S(M.charCodeAt(Q)))Q++;this.addToken(13,Z,Q);continue}if(J===34||J===39){Q=this.consumeString(J,Q);continue}if(J===35){if(Q+1<G&&(xM(M.charCodeAt(Q+1))||v(M.charCodeAt(Q+1),M.charCodeAt(Q+2)))){let Z=Q;Q++,Q=this.consumeName(Q),this.addToken(4,Z,Q);continue}this.addToken(9,Q,Q+1),Q++;continue}switch(J){case 40:this.addToken(21,Q,Q+1),Q++;continue;case 41:this.addToken(22,Q,Q+1),Q++;continue;case 91:this.addToken(19,Q,Q+1),Q++;continue;case 93:this.addToken(20,Q,Q+1),Q++;continue;case 123:this.addToken(23,Q,Q+1),Q++;continue;case 125:this.addToken(24,Q,Q+1),Q++;continue;case 44:this.addToken(18,Q,Q+1),Q++;continue;case 58:this.addToken(16,Q,Q+1),Q++;continue;case 59:this.addToken(17,Q,Q+1),Q++;continue}if(J===60&&M.startsWith("!--",Q+1)){this.addToken(14,Q,Q+4),Q+=4;continue}if(J===45&&M.startsWith("->",Q+1)){this.addToken(15,Q,Q+3),Q+=3;continue}if(J===64){let Z=M.charCodeAt(Q+1),F=M.charCodeAt(Q+2),$=M.charCodeAt(Q+3);if(o(Z,F,$)){let z=Q;Q++,Q=this.consumeName(Q),this.addToken(3,z,Q);continue}this.addToken(9,Q,Q+1),Q++;continue}let X=M.charCodeAt(Q+1),Y=M.charCodeAt(Q+2);if(bM(J,X,Y)){Q=this.consumeNumeric(Q);continue}if(o(J,X,Y)){Q=this.consumeIdentLike(Q);continue}if(J===92){if(v(J,X)){Q=this.consumeIdentLike(Q);continue}this.addToken(9,Q,Q+1),Q++;continue}this.addToken(9,Q,Q+1),Q++}this.addToken(0,G,G)}consumeString(M,Q){let G=this.source,J=G.length,X=Q+1;while(X<J){let Y=G.charCodeAt(X);if(Y===M)return X++,this.addToken(5,Q,X),X;if(t(Y))return this.addToken(6,Q,X),X;if(Y===92){let Z=G.charCodeAt(X+1);if(t(Z)){X+=2;continue}if(X+1<J){X=this.consumeEscapeSkip(X+1);continue}}X++}return this.addToken(5,Q,X),X}consumeEscapeSkip(M){let Q=this.source;if(M>=Q.length)return M;let G=Q.charCodeAt(M);if(l(G)){let J=1;M++;while(J<6&&M<Q.length&&l(Q.charCodeAt(M)))M++,J++;if(M<Q.length&&S(Q.charCodeAt(M)))M++;return M}return M+1}consumeName(M){let Q=this.source,G=Q.length,J=M;while(J<G){let X=Q.charCodeAt(J);if(X<128&&(h[X]&10)!==0){J++;continue}if(X===45){J++;continue}if(X>=128){J++;continue}if(X===92&&v(X,Q.charCodeAt(J+1))){J=this.consumeEscapeSkip(J+1);continue}break}return J}consumeNumber(M){let Q=this.source,G=M;if(Q.charCodeAt(G)===43||Q.charCodeAt(G)===45)G++;while(G<Q.length&&P(Q.charCodeAt(G)))G++;if(Q.charCodeAt(G)===46&&P(Q.charCodeAt(G+1))){G+=2;while(G<Q.length&&P(Q.charCodeAt(G)))G++}let J=Q.charCodeAt(G);if(J===69||J===101){let X=Q.charCodeAt(G+1),Y=Q.charCodeAt(G+2);if(P(X)){G+=2;while(G<Q.length&&P(Q.charCodeAt(G)))G++}else if((X===43||X===45)&&P(Y)){G+=3;while(G<Q.length&&P(Q.charCodeAt(G)))G++}}return G}consumeNumeric(M){let Q=this.source,G=this.consumeNumber(M),J=Q.charCodeAt(G),X=Q.charCodeAt(G+1),Y=Q.charCodeAt(G+2);if(o(J,X,Y)){let Z=this.consumeName(G);return this.addToken(12,M,Z),Z}if(J===37)return this.addToken(11,M,G+1),G+1;return this.addToken(10,M,G),G}consumeIdentLike(M){let Q=this.source,G=this.consumeName(M),J=Q.charCodeAt(G);if(J===40&&G-M===3){let X=Q.charCodeAt(M)|32,Y=Q.charCodeAt(M+1)|32,Z=Q.charCodeAt(M+2)|32;if(X===117&&Y===114&&Z===108){let F=G+1;while(F<Q.length&&S(Q.charCodeAt(F)))F++;let $=Q.charCodeAt(F);if($===34||$===39)return this.addToken(2,M,G+1),G+1;return this.consumeUrl(M,G)}}if(J===40)return this.addToken(2,M,G+1),G+1;return this.addToken(1,M,G),G}consumeUrl(M,Q){let G=this.source,J=G.length,X=Q+1;while(X<J&&S(G.charCodeAt(X)))X++;while(X<J){let Y=G.charCodeAt(X);if(Y===41)return X++,this.addToken(7,M,X),X;if(S(Y)){let Z=X;while(X<J&&S(G.charCodeAt(X)))X++;if(X>=J)return this.addToken(7,M,X),X;if(G.charCodeAt(X)===41)return X++,this.addToken(7,M,X),X;return this.consumeBadUrl(M,Z)}if(Y===34||Y===39||Y===40||PM(Y))return this.consumeBadUrl(M,X);if(Y===92){if(v(Y,G.charCodeAt(X+1))){X=this.consumeEscapeSkip(X+1);continue}return this.consumeBadUrl(M,X)}X++}return this.addToken(7,M,X),X}consumeBadUrl(M,Q){let G=this.source,J=Q;while(J<G.length){let X=G.charCodeAt(J);if(X===41){J++;break}if(X===92&&v(X,G.charCodeAt(J+1))){J=this.consumeEscapeSkip(J+1);continue}J++}return this.addToken(8,M,J),J}locate(M){let Q=this.lineStarts,G=0,J=Q.length-1;while(G<J){let Y=G+J+1>>1;if(Q[Y]<=M)G=Y;else J=Y-1}let X=Q[G];return{line:G+1,column:M-X+1}}}function fM(M){let Q=[0],G=M.length;for(let J=0;J<G;J++){let X=M.charCodeAt(J);if(X===10)Q.push(J+1);else if(X===13){if(M.charCodeAt(J+1)!==10)Q.push(J+1)}}return Q}function s(M,Q,G){for(let J=Q;J<G;J++)if(M.charCodeAt(J)===92)return EM(M,Q,G,J);return M.slice(Q,G)}function EM(M,Q,G,J){let X=M.slice(Q,J),Y=J;while(Y<G){if(M.charCodeAt(Y)!==92){X+=M[Y],Y++;continue}if(Y+1>=G){Y++;continue}let F=M.charCodeAt(Y+1);if(F===10){Y+=2;continue}if(F===13){Y+=M.charCodeAt(Y+2)===10?3:2;continue}if(l(F)){let $=Y+1,z="";while(z.length<6&&$<G&&l(M.charCodeAt($)))z+=M[$],$++;let V=Number.parseInt(z,16);if($<G&&S(M.charCodeAt($)))$++;X+=V===0||V>=55296&&V<=57343||V>1114111?String.fromCodePoint(65533):String.fromCodePoint(V),Y=$;continue}X+=M[Y+1],Y+=2}return X}function a(M,Q,G){for(let J=Q;J<G;J++)if(M.charCodeAt(J)===92)return SM(M,Q,G,J);return M.slice(Q,G)}function SM(M,Q,G,J){let X=M.slice(Q,J),Y=J;while(Y<G){if(M.charCodeAt(Y)!==92){X+=M[Y],Y++;continue}let F=Y+1,$="";while($.length<6&&F<G&&l(M.charCodeAt(F)))$+=M[F],F++;if($.length>0){let z=Number.parseInt($,16);if(F<G&&S(M.charCodeAt(F)))F++;X+=z===0||z>=55296&&z<=57343||z>1114111?String.fromCodePoint(65533):String.fromCodePoint(z),Y=F;continue}if(F<G){X+=M[F],Y=F+1;continue}X+=String.fromCodePoint(65533),Y=F}return X}function DM(M,Q){let G=new T(M);return{source:M,types:G.types,starts:G.starts,ends:G.ends,count:G.count,end:G.count,pos:0,positions:Q.positions??!1,filename:Q.filename,parseValue:Q.parseValue??!0,parseAtrulePrelude:Q.parseAtrulePrelude??!0,parseCustomProperty:Q.parseCustomProperty??!1,parseRulePrelude:Q.parseRulePrelude??!0,onParseError:Q.onParseError,tokenizer:G}}function q(M){return M.pos<M.end?M.types[M.pos]:0}function H(M){let Q=M.pos;if(Q>=M.end)return{type:0,start:M.starts[Q]??M.source.length,end:M.ends[Q]??M.source.length};return{type:M.types[Q],start:M.starts[Q],end:M.ends[Q]}}function _(M){let Q=M.pos++;if(Q>=M.end)return{type:0,start:M.starts[Q]??M.source.length,end:M.ends[Q]??M.source.length};return{type:M.types[Q],start:M.starts[Q],end:M.ends[Q]}}function E(M,Q){return M.source.slice(Q.start,Q.end)}function b(M){let{types:Q,end:G}=M;while(M.pos<G){let J=Q[M.pos];if(J===13||J===25)M.pos++;else break}}function zM(M){let{types:Q,end:G}=M;while(M.pos<G&&Q[M.pos]===13)M.pos++}function B(M,Q,G){if(!M.positions)return null;let J=M.tokenizer.locate(Q.start),X=M.tokenizer.locate(G.end);return{source:M.filename??"<unknown>",start:{offset:Q.start,line:J.line,column:J.column},end:{offset:G.end,line:X.line,column:X.column}}}function NM(M){if(!M.positions)return null;let Q=H(M),G=M.tokenizer.locate(Q.start);return{source:M.filename??"<unknown>",start:{offset:Q.start,line:G.line,column:G.column},end:{offset:Q.start,line:G.line,column:G.column}}}function d(M,Q,G,J){return{type:"Raw",value:M,loc:B(J,Q,G)}}function O(){return new j}function e(M,Q,G,J){if(M.onParseError){let{line:X,column:Y}=M.tokenizer.locate(G.start),Z=SyntaxError(`${M.filename??"<input>"}:${X}:${Y}: ${Q}`);Z.line=X,Z.column=Y,Z.offset=G.start,M.onParseError(Z,J)}return J}function WM(M,Q={}){let G=DM(M,Q);switch(Q.context??"stylesheet"){case"stylesheet":return _M(G);case"atrule":return r(G)??qM(G);case"atrulePrelude":return mM(G);case"mediaQuery":case"mediaQueryList":return HM(G);case"rule":return QM(G);case"selectorList":return XM(G);case"selector":return OM(G);case"block":return GM(G);case"declarationList":return kM(G);case"declaration":return JM(G)??qM(G);case"value":return lM(G);case"raw":return HM(G);default:return _M(G)}}function qM(M){return{type:"StyleSheet",children:O(),loc:NM(M)}}function HM(M){let Q=H(M),G=Q;while(q(M)!==0)G=_(M);return{type:"Raw",value:M.source.slice(Q.start,G.end),loc:B(M,Q,G)}}function _M(M){let Q=H(M),G=O(),J=M.types,X=M.end;while(M.pos<X){let F=J[M.pos];if(F===13){M.pos++;continue}if(F===25){let V={type:25,start:M.starts[M.pos],end:M.ends[M.pos]},U=MM(M,V);M.pos++,G.appendData(U);continue}if(F===0)break;if(F===14||F===15){M.pos++;continue}if(F===3){let V=r(M);if(V)G.appendData(V);continue}if(F===24){M.pos++;continue}let $=M.pos,z=QM(M);if(G.appendData(z),M.pos===$)M.pos++}let Y=M.end-1,Z=Y>=0?{type:M.types[Y],start:M.starts[Y],end:M.ends[Y]}:{type:0,start:0,end:0};return{type:"StyleSheet",children:G,loc:B(M,Q,Z)}}function MM(M,Q){return{type:"Comment",value:M.source.slice(Q.start+2,Q.end-2),loc:B(M,Q,Q)}}function r(M){let Q=H(M);if(Q.type!==3)return null;M.pos++;let G=c(M.source,Q.start+1,Q.end);b(M);let J=M.pos,X=H(M),Y=M.types,Z=M.end,F=J,$=J;while(F<Z){let U=Y[F];if(U===0||U===17||U===23)break;if(U!==13&&U!==25)$=F+1;F++}let z=null;if($>J){let U=M.starts[J],D=M.ends[$-1],N={type:Y[$-1],start:M.starts[$-1],end:D},x=M.source.slice(U,D).trim();if(x.length>0)if(M.parseAtrulePrelude)try{let u=M.end;M.end=$,M.pos=J;let C=O();while(q(M)!==0){let y=m(M);if(y)C.appendData(y)}if(jM(C),M.end=u,M.pos=F,C.isEmpty)z=d(x,X,N,M);else z={type:"AtrulePrelude",children:C,loc:null}}catch(u){let C=d(x,X,N,M);e(M,`Failed to parse @${G} prelude: ${u.message}`,X,C),z=C,M.pos=F}else z=d(x,X,N,M),M.pos=F;else M.pos=F}else M.pos=F;let V=null;if(q(M)===17)_(M);else if(q(M)===23)V=GM(M,hM.has(G));return{type:"Atrule",name:G,prelude:z,block:V,loc:B(M,Q,H(M))}}var vM=new Set(["is","not","where","has","matches","-moz-any","-webkit-any"]),hM=new Set(["media","supports","document","layer","container","scope","starting-style","-moz-document","keyframes","-webkit-keyframes","-moz-keyframes","-o-keyframes"]);function mM(M){let Q=H(M),G=O();while(q(M)!==0){if(H(M).type===13){M.pos++;continue}let X=m(M);if(X)G.appendData(X)}return{type:"AtrulePrelude",children:G,loc:B(M,Q,H(M))}}function QM(M){let Q=H(M),G;if(M.parseRulePrelude)G=XM(M);else{let X=H(M),Y=X;while(q(M)!==0&&q(M)!==23)Y=_(M);let Z=M.source.slice(X.start,Y.end).trim();G=d(Z,X,Y,M)}let J=GM(M,!0);return{type:"Rule",prelude:G,block:J,loc:B(M,Q,H(M))}}function GM(M,Q=!1){let G=H(M);if(q(M)!==23)return{type:"Block",children:O(),loc:NM(M)};M.pos++;let J=O(),X=M.types,Y=M.end;while(M.pos<Y){let Z=X[M.pos];if(Z===24||Z===0)break;if(Z===13){M.pos++;continue}if(Z===25){let $={type:25,start:M.starts[M.pos],end:M.ends[M.pos]};M.pos++,J.appendData(MM(M,$));continue}if(Z===3){let $=r(M);if($)J.appendData($);continue}if(Q&&yM(M,uM)){let $=QM(M);J.appendData($);continue}let F=JM(M);if(F)J.appendData(F);if(M.pos<Y&&X[M.pos]===17)M.pos++}if(q(M)===24)M.pos++;return{type:"Block",children:J,loc:B(M,G,H(M))}}function yM(M,Q){let G=M.pos,J=Q(M);return M.pos=G,J}function uM(M){let{types:Q,end:G}=M;while(M.pos<G){let J=Q[M.pos];if(J===23)return!0;if(J===17||J===24||J===0)return!1;M.pos++}return!1}function kM(M){let Q=H(M),G=O();while(q(M)!==0&&q(M)!==24){let J=H(M);if(J.type===13){M.pos++;continue}if(J.type===25){G.appendData(MM(M,_(M)));continue}if(J.type===17){M.pos++;continue}if(J.type===3){let Y=r(M);if(Y)G.appendData(Y);continue}let X=JM(M);if(X)G.appendData(X);if(q(M)===17)_(M)}return{type:"DeclarationList",children:G,loc:B(M,Q,H(M))}}function JM(M){b(M);let Q=H(M);if(Q.type!==1&&Q.type!==4&&!(Q.type===9&&M.source[Q.start]==="*"&&M.source[Q.start+1]===" "))if(Q.type===9&&M.source[Q.start]==="*")M.pos++;else{e(M,"Expected property name",Q,{type:"Raw",value:"",loc:null});let{types:L,end:w}=M;while(M.pos<w){let A=L[M.pos];if(A===0||A===17||A===24)break;M.pos++}return null}let G=M.starts[M.pos],J=M.ends[M.pos];M.pos++;let X=M.source.slice(G,J);if(zM(M),q(M)!==16){e(M,`Expected ':' after property "${X}"`,H(M),{type:"Raw",value:"",loc:null});let{types:L,end:w}=M;while(M.pos<w){let A=L[M.pos];if(A===0||A===17||A===24)break;M.pos++}return null}M.pos++,zM(M);let{types:Y,starts:Z,end:F,pos:$}=M,z=$,V=$,U=-1,D=-1;while(z<F){let L=Y[z];if(L===0||L===17||L===24)break;if(L===9&&M.source.charCodeAt(Z[z])===33){let w=z+1;while(w<F&&Y[w]===13)w++;if(w<F&&Y[w]===1){let A=Z[w];if(M.ends[w]-A===9&&(M.source.charCodeAt(A)|32)===105&&(M.source.charCodeAt(A+1)|32)===109&&(M.source.charCodeAt(A+2)|32)===112&&(M.source.charCodeAt(A+3)|32)===111&&(M.source.charCodeAt(A+4)|32)===114&&(M.source.charCodeAt(A+5)|32)===116&&(M.source.charCodeAt(A+6)|32)===97&&(M.source.charCodeAt(A+7)|32)===110&&(M.source.charCodeAt(A+8)|32)===116){D=z,U=w,z=w+1;continue}}}if(L!==13&&L!==25)V=z+1;z++}let N=V,x=U>=0?{type:1,start:Z[U],end:M.ends[U]}:null,u=X.startsWith("--"),C,y=Z[$],YM=N>$?M.ends[N-1]:y,i={type:Y[$],start:y,end:M.ends[$]},ZM=N>$?{type:Y[N-1],start:Z[N-1],end:YM}:i;if(u&&!M.parseCustomProperty||!M.parseValue)C={type:"Raw",value:M.source.slice(y,YM).trim(),loc:B(M,i,ZM)};else if(N===$)C={type:"Value",children:O(),loc:B(M,i,ZM)};else{let L=M.end;M.end=N,M.pos=$,C=AM(M),M.end=L}return M.pos=z,{type:"Declaration",property:X,important:x?!0:!1,value:C,loc:B(M,Q,H(M))}}function lM(M){return AM(M)}function AM(M){let Q=H(M),G=O();while(q(M)!==0&&q(M)!==17&&q(M)!==24&&q(M)!==22&&q(M)!==20){let J=m(M);if(J)G.appendData(J)}return RM(G),{type:"Value",children:G,loc:B(M,Q,H(M))}}function jM(M){for(let Q of M)if("children"in Q&&Q.children instanceof j)jM(Q.children);RM(M)}function RM(M){let Q=M.head;while(Q){if(Q.data.type==="Number"){let G=Q.next;while(G&&G.data.type==="WhiteSpace")G=G.next;if(G&&G.data.type==="Operator"&&G.data.value==="/"){let J=G.next;while(J&&J.data.type==="WhiteSpace")J=J.next;if(J&&J.data.type==="Number"){let X={type:"Ratio",left:Q.data,right:J.data,loc:null},Y=Q.next;while(Y&&Y!==J.next){let Z=Y.next;M.remove(Y),Y=Z}M.replace(Q,M.createItem(X)),Q=M.head;continue}}}Q=Q.next}}function m(M){let Q=M.pos;if(Q>=M.end)return null;let G=M.types[Q],J=M.starts[Q],X=M.ends[Q],Y=M.source;switch(G){case 13:return M.pos++,M.positions?{type:"WhiteSpace",value:" ",loc:R(M,J,X)}:{type:"WhiteSpace",value:" ",loc:null};case 25:return M.pos++,{type:"Comment",value:Y.slice(J+2,X-2),loc:M.positions?R(M,J,X):null};case 10:return M.pos++,{type:"Number",value:Y.slice(J,X),loc:M.positions?R(M,J,X):null};case 11:return M.pos++,{type:"Percentage",value:Y.slice(J,X-1),loc:M.positions?R(M,J,X):null};case 12:{M.pos++;let Z=J,F=Y.charCodeAt(Z);if(F===43||F===45)Z++;let $=!1;while(Z<X){let V=Y.charCodeAt(Z);if(V>=48&&V<=57){Z++;continue}if(V===46&&!$){$=!0,Z++;continue}break}let z=Y.charCodeAt(Z);if(z===69||z===101){let V=Z+1,U=Y.charCodeAt(V);if(U===43||U===45)V++;let D=!1;while(V<X){let N=Y.charCodeAt(V);if(N>=48&&N<=57){V++,D=!0;continue}break}if(D)Z=V}return{type:"Dimension",value:Y.slice(J,Z),unit:Y.slice(Z,X),loc:M.positions?R(M,J,X):null}}case 1:return M.pos++,{type:"Identifier",name:a(Y,J,X),loc:M.positions?R(M,J,X):null};case 5:{M.pos++;let Z=J+1,$=X-J>=2&&Y.charCodeAt(X-1)===Y.charCodeAt(J)?X-1:X;return{type:"String",value:s(Y,Z,$),loc:M.positions?R(M,J,X):null}}case 7:{M.pos++;let Z=J+4;while(Z<X&&VM(Y.charCodeAt(Z)))Z++;let F=X;if(F>Z&&Y.charCodeAt(F-1)===41)F--;while(F>Z&&VM(Y.charCodeAt(F-1)))F--;let $;if(F-Z>=2){let z=Y.charCodeAt(Z),V=Y.charCodeAt(F-1);if((z===34||z===39)&&z===V)$=Y.slice(Z+1,F-1);else $=Y.slice(Z,F)}else $=Y.slice(Z,F);return{type:"Url",value:$,loc:M.positions?R(M,J,X):null}}case 4:return M.pos++,{type:"Hash",name:Y.slice(J+1,X),loc:M.positions?R(M,J,X):null};case 2:return pM(M);case 21:return aM(M);case 18:return M.pos++,{type:"Operator",value:",",loc:M.positions?R(M,J,X):null};case 16:return M.pos++,{type:"Operator",value:":",loc:M.positions?R(M,J,X):null};case 9:{M.pos++;let Z=Y.charCodeAt(J),F=Y[J];if(TM(Z))return{type:"Operator",value:F,loc:M.positions?R(M,J,X):null};return{type:"Identifier",name:F,loc:M.positions?R(M,J,X):null}}case 19:{M.pos++;let Z=O();while(q(M)!==0&&q(M)!==20){let $=m(M);if($)Z.appendData($)}let F=M.pos<M.end?M.ends[M.pos]:X;if(q(M)===20)M.pos++;return{type:"Brackets",children:Z,loc:M.positions?R(M,J,F):null}}case 3:case 23:case 24:case 22:case 20:case 17:case 0:case 14:case 15:case 6:case 8:return M.pos++,{type:"Raw",value:Y.slice(J,X),loc:M.positions?R(M,J,X):null}}return M.pos++,null}function VM(M){return M===32||M===9||M===10||M===12||M===13}function TM(M){return M===47||M===43||M===45||M===42||M===61||M===62||M===60||M===126||M===124||M===36||M===94||M===33||M===38}function c(M,Q,G){for(let J=Q;J<G;J++){let X=M.charCodeAt(J);if(X>=65&&X<=90)return M.slice(Q,G).toLowerCase()}return M.slice(Q,G)}function R(M,Q,G){let J=M.tokenizer.locate(Q),X=M.tokenizer.locate(G);return{source:M.filename??"<unknown>",start:{offset:Q,line:J.line,column:J.column},end:{offset:G,line:X.line,column:X.column}}}function pM(M){let Q=_(M),G=c(M.source,Q.start,Q.end-1),J=O();while(q(M)!==0&&q(M)!==22){let X=m(M);if(X)J.appendData(X)}if(q(M)===22)_(M);if(G==="url"){for(let X=J.head;X!=null;X=X.next)if(X.data.type==="String")return{type:"Url",value:X.data.value,loc:B(M,Q,H(M))}}return{type:"Function",name:G,children:J,loc:B(M,Q,H(M))}}function aM(M){let Q=_(M),G=O();while(q(M)!==0&&q(M)!==22){let J=m(M);if(J)G.appendData(J)}if(q(M)===22)_(M);return{type:"Parentheses",children:G,loc:B(M,Q,H(M))}}function XM(M){let Q=H(M),G=O();while(q(M)!==0){if(b(M),q(M)===0||q(M)===23)break;let J=OM(M);if(J.children.head!==null)G.appendData(J);if(b(M),q(M)===18){_(M);continue}break}return{type:"SelectorList",children:G,loc:B(M,Q,H(M))}}function OM(M){let Q=H(M),G=O(),J=!0;while(q(M)!==0&&q(M)!==18&&q(M)!==23){let X=H(M);if(X.type===13){if(_(M),!J&&q(M)!==0&&q(M)!==18&&q(M)!==23&&!BM(M)&&!dM(M)){let Z={type:"Combinator",name:" ",loc:B(M,X,X)};G.appendData(Z),J=!0}continue}if(X.type===9&&M.source.charCodeAt(X.start)===124&&M.types[M.pos+1]===9&&M.source.charCodeAt(M.starts[M.pos+1])===124){let Z=H(M);_(M);let F=_(M),$={type:"Combinator",name:"||",loc:B(M,Z,F)};G.appendData($),J=!0,b(M);continue}if(BM(M)){let Z=_(M),$={type:"Combinator",name:M.source[Z.start],loc:B(M,Z,Z)};G.appendData($),J=!0,b(M);continue}let Y=cM(M);if(!Y)break;G.appendData(Y),J=!1}while(G.tail&&G.tail.data.type==="Combinator")G.remove(G.tail);return{type:"Selector",children:G,loc:B(M,Q,H(M))}}function BM(M){let Q=H(M);if(Q.type!==9)return!1;let G=M.source[Q.start];return G===">"||G==="+"||G==="~"}function dM(M){if(M.types[M.pos]!==9)return!1;if(M.source.charCodeAt(M.starts[M.pos])!==124)return!1;if(M.types[M.pos+1]!==9)return!1;return M.source.charCodeAt(M.starts[M.pos+1])===124}function cM(M){let Q=H(M);switch(Q.type){case 1:{if(_(M),q(M)===9&&M.source[H(M).start]==="|"&&M.source[H(M).start+1]!=="="&&!(M.types[M.pos+1]===9&&M.source.charCodeAt(M.starts[M.pos+1])===124)){if(_(M),q(M)===1){let J=_(M);return{type:"TypeSelector",name:`${E(M,Q)}|${E(M,J)}`,loc:B(M,Q,J)}}if(q(M)===9&&M.source[H(M).start]==="*"){let J=_(M);return{type:"TypeSelector",name:`${E(M,Q)}|*`,loc:B(M,Q,J)}}}return{type:"TypeSelector",name:E(M,Q),loc:B(M,Q,Q)}}case 11:return _(M),{type:"TypeSelector",name:E(M,Q),loc:B(M,Q,Q)};case 10:return _(M),{type:"TypeSelector",name:E(M,Q),loc:B(M,Q,Q)};case 9:{let G=M.source[Q.start];if(G==="*")return _(M),{type:"TypeSelector",name:"*",loc:B(M,Q,Q)};if(G==="."){if(_(M),q(M)===1){let J=_(M);return{type:"ClassSelector",name:E(M,J),loc:B(M,Q,J)}}return null}if(G==="&")return _(M),{type:"NestingSelector",loc:B(M,Q,Q)};return _(M),null}case 4:return _(M),{type:"IdSelector",name:M.source.slice(Q.start+1,Q.end),loc:B(M,Q,Q)};case 16:{_(M);let G=q(M)===16;if(G)_(M);return rM(M,G,Q)}case 19:return iM(M)}return null}function rM(M,Q,G){let J=H(M);if(J.type===1){_(M);let X=c(M.source,J.start,J.end);return Q?{type:"PseudoElementSelector",name:X,children:null,loc:B(M,G,J)}:{type:"PseudoClassSelector",name:X,children:null,loc:B(M,G,J)}}if(J.type===2){_(M);let X=c(M.source,J.start,J.end-1),Y=O();if(!Q&&vM.has(X)){let $=H(M),z=$,V=1;while(q(M)!==0&&V>0){if(q(M)===21||q(M)===2)V++;else if(q(M)===22){if(V--,V===0)break}z=_(M)}if(q(M)===22)_(M);let U=M.source.slice($.start,z.end).trim();if(U.length>0){let D=DM(U,{positions:!1}),N=XM(D);Y.appendData(N)}}else{while(q(M)!==0&&q(M)!==22){let $=m(M);if($)Y.appendData($)}if(q(M)===22)_(M)}if(Q)return{type:"PseudoElementSelector",name:X,children:Y,loc:B(M,G,H(M))};return{type:"PseudoClassSelector",name:X,children:Y,loc:B(M,G,H(M))}}return null}function iM(M){let Q=_(M);b(M);let G=H(M);if(G.type!==1)return null;_(M);let J={type:"Identifier",name:E(M,G),loc:B(M,G,G)};b(M);let X=null,Y=null,Z=null,F=H(M);if(F.type===9){let z=M.source[F.start],V=M.source[F.start+1];if(z==="=")X="=",_(M);else if((z==="~"||z==="|"||z==="^"||z==="$"||z==="*")&&V==="="){_(M);let N=H(M);if(N.type===9&&M.source[N.start]==="=")_(M),X=`${z}=`}b(M);let U=H(M);if(U.type===5){_(M);let N=U.end-U.start>=2&&M.source.charCodeAt(U.end-1)===M.source.charCodeAt(U.start);Y={type:"String",value:s(M.source,U.start+1,N?U.end-1:U.end),loc:B(M,U,U)}}else if(U.type===1)_(M),Y={type:"Identifier",name:E(M,U),loc:B(M,U,U)};b(M);let D=H(M);if(D.type===1)_(M),Z=E(M,D)}b(M);let $=H(M);if(q(M)===20)$=_(M);return{type:"AttributeSelector",name:J,matcher:X,value:Y,flags:Z,loc:B(M,Q,$)}}var LM=Symbol("walkSkip"),W=Symbol("walkStop");function nM(M){return{root:M,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null}}function oM(M,Q){let G=nM(M),J=typeof Q==="function"?Q:Q.enter,X=typeof Q==="function"?null:Q.leave??null,Y=typeof Q==="function"?null:Q.visit??null,Z=typeof Q==="function"?!1:Q.reverse??!1;function F($,z,V){let U=null,D;switch($.type){case"StyleSheet":U="stylesheet",D=G.stylesheet,G.stylesheet=$;break;case"Atrule":U="atrule",D=G.atrule,G.atrule=$;break;case"AtrulePrelude":U="atrulePrelude",D=G.atrulePrelude,G.atrulePrelude=$;break;case"Rule":U="rule",D=G.rule,G.rule=$;break;case"Selector":U="selector",D=G.selector,G.selector=$;break;case"Block":U="block",D=G.block,G.block=$;break;case"Declaration":U="declaration",D=G.declaration,G.declaration=$;break;case"Function":U="function",D=G.function,G.function=$;break}let N;if((Y===null||Y===$.type)&&J){let x=J.call(G,$,z,V);if(x===LM){if(U)G[U]=D;return}if(x===W){if(U)G[U]=D;return W}}if(N=tM($,Z,F),N===W){if(U)G[U]=D;return W}if((Y===null||Y===$.type)&&X){if(X.call(G,$,z,V)===W){if(U)G[U]=D;return W}}if(U)G[U]=D;return}return F(M,null,null)}var wM=Object.assign(oM,{skip:LM,stop:W});function tM(M,Q,G){if("children"in M&&M.children instanceof j)return sM(M.children,Q,G);if(M.type==="Rule"){if(G(M.prelude,null,null)===W)return W;if(G(M.block,null,null)===W)return W;return}if(M.type==="Atrule"){if(M.prelude){if(G(M.prelude,null,null)===W)return W}if(M.block){if(G(M.block,null,null)===W)return W}return}if(M.type==="Declaration")return G(M.value,null,null);if(M.type==="AttributeSelector"){if(G(M.name,null,null)===W)return W;if(M.value)return G(M.value,null,null);return}return}function sM(M,Q,G){let J;if(Q)M.forEachRight((X,Y,Z)=>{if(J)return;if(G(X,Y,Z)===W)J=W});else M.forEach((X,Y,Z)=>{if(J)return;if(G(X,Y,Z)===W)J=W});return J}export{j as q,$M as r,FM as s,g as t,p as u,T as v,a as w,WM as x,wM as y,MQ as z};
|
|
@@ -0,0 +1,2 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{A as M}from"./chunk-2wsah70r.js";import{F as l}from"./chunk-1kmkypmr.js";var n={};l(n,{selectOne:()=>s,selectAll:()=>p,parseAndCompile:()=>Y,is:()=>o,compile:()=>O,clearSelectorCache:()=>r});function E(V,K,z,Z){let $=[],j=[K],J=[0];for(;;){if(J[0]>=j[0].length){if(j.length===1)return $;j.shift(),J.shift();continue}let X=j[0][J[0]++];if(!z.isTag(X))continue;if(V(X))$.push(X);if(Z||z.getName(X)!=="template"){let Q=z.getChildren(X);if(Q.length>0)j.unshift(Q),J.unshift(0)}}}function L(V,K,z,Z){let $=[K],j=[0];for(;;){if(j[0]>=$[0].length){if($.length===1)return null;$.shift(),j.shift();continue}let J=$[0][j[0]++];if(!z.isTag(J))continue;if(V(J))return J;if(Z||z.getName(J)!=="template"){let X=z.getChildren(J);if(X.length>0)$.unshift(X),j.unshift(0)}}}function W(V,K){if(Array.isArray(V))return K.removeSubsets(V);return K.getChildren(V)}var D=(V)=>{return!0};function _(V){return V===32||V===9||V===10||V===12||V===13}function I(V,K){let z=K.length,Z=V.length;if(z===0||z>Z)return!1;let $=V.indexOf(K);while($>=0){let j=$===0||_(V.charCodeAt($-1)),J=$+z,X=J===Z||_(V.charCodeAt(J));if(j&&X)return!0;$=V.indexOf(K,$+1)}return!1}function S(V,K,z){if(K.ignoreCase===!0)return!0;if(K.ignoreCase===!1)return!1;if(K.ignoreCase==="quirks")return!z.xmlMode;return!1}function w(V,K,z){let Z=K.adapter,$=V.action,j=V.name,J=V.value,X=S(J,V,K);if(X)J=J.toLowerCase();return g($,j,J,X,Z,z)}function g(V,K,z,Z,$,j){let J=j===D;switch(V){case"exists":if(J)return(X)=>$.hasAttrib(X,K);return(X)=>$.hasAttrib(X,K)&&j(X);case"equals":if(!Z){if(J)return(X)=>$.getAttributeValue(X,K)===z;return(X)=>$.getAttributeValue(X,K)===z&&j(X)}if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return Q.toLowerCase()===z};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return Q.toLowerCase()===z&&j(X)};case"not":return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return j(X);return(Z?Q.toLowerCase():Q)!==z&&j(X)};case"start":if(z==="")return()=>!1;if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return(Z?Q.toLowerCase():Q).startsWith(z)};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return(Z?Q.toLowerCase():Q).startsWith(z)&&j(X)};case"end":if(z==="")return()=>!1;if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return(Z?Q.toLowerCase():Q).endsWith(z)};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return(Z?Q.toLowerCase():Q).endsWith(z)&&j(X)};case"any":{if(z==="")return()=>!1;if(Z){if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return Q.toLowerCase().indexOf(z)>=0};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return Q.toLowerCase().indexOf(z)>=0&&j(X)}}if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return Q.indexOf(z)>=0};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return Q.indexOf(z)>=0&&j(X)}}case"element":{if(z===""||/\s/.test(z))return()=>!1;if(Z){if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return I(Q.toLowerCase(),z)};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return I(Q.toLowerCase(),z)&&j(X)}}if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return I(Q,z)};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;return I(Q,z)&&j(X)}}case"hyphen":if(J)return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;let H=Z?Q.toLowerCase():Q;if(H===z)return!0;if(H.startsWith(z)&&H.charAt(z.length)==="-")return!0;return!1};return(X)=>{let Q=$.getAttributeValue(X,K);if(Q==null)return!1;let H=Z?Q.toLowerCase():Q;if(H===z)return j(X);if(H.startsWith(z)&&H.charAt(z.length)==="-")return j(X);return!1}}return(X)=>{return!1}}var b=new Set(["link","any-link","visited","hover","active","focus","focus-visible","focus-within","target","target-within","enabled","disabled","checked","required","optional","valid","invalid","selected","placeholder-shown","read-only","read-write","in-range","out-of-range","default","indeterminate"]),f=new Set(["is","where","matches","-moz-any","-webkit-any"]),k=new Set(["nth-child","nth-last-child","nth-of-type","nth-last-of-type"]);function y(V,K,z){let Z=K.adapter,$=V.name,j=V.data;if(V.type==="pseudo"&&f.has($)){if(!Array.isArray(j))return z;let J=j.map((X)=>Y(X,K));if(J.length===1){let X=J[0];return(Q)=>X(Q)&&z(Q)}return(X)=>{for(let Q of J)if(Q(X))return z(X);return!1}}if(V.type==="pseudo"&&$==="not"){if(!Array.isArray(j))return z;let J=j.map((X)=>Y(X,K));if(J.length===1){let X=J[0];return(Q)=>!X(Q)&&z(Q)}return(X)=>{for(let Q of J)if(Q(X))return!1;return z(X)}}if(V.type==="pseudo"&&$==="has"){if(!Array.isArray(j))return z;let J=j.map((Q)=>Y(Q,K)),X=J.length===1?J[0]:(Q)=>{for(let H of J)if(H(Q))return!0;return!1};return(Q)=>{let H=Z.getChildren(Q).slice();while(H.length>0){let B=H.pop();if(!Z.isTag(B))continue;if(X(B))return z(Q);let N=Z.getChildren(B);for(let F=0;F<N.length;F++)H.push(N[F])}return!1}}if(V.type==="pseudo"&&k.has($)){let J=u(typeof j==="string"?j:"",$,K);return(X)=>J(X)&&z(X)}if(V.type==="pseudo"&&$==="first-child")return(J)=>{let X=Z.getSiblings(J);for(let Q of X){if(!Z.isTag(Q))continue;return Q===J&&z(J)}return!1};if(V.type==="pseudo"&&$==="last-child")return(J)=>{let X=Z.getSiblings(J);for(let Q=X.length-1;Q>=0;Q--){let H=X[Q];if(!Z.isTag(H))continue;return H===J&&z(J)}return!1};if(V.type==="pseudo"&&$==="first-of-type")return(J)=>{let X=Z.getName(J),Q=Z.getSiblings(J);for(let H of Q){if(!Z.isTag(H)||Z.getName(H)!==X)continue;return H===J&&z(J)}return!1};if(V.type==="pseudo"&&$==="last-of-type")return(J)=>{let X=Z.getName(J),Q=Z.getSiblings(J);for(let H=Q.length-1;H>=0;H--){let B=Q[H];if(!Z.isTag(B)||Z.getName(B)!==X)continue;return B===J&&z(J)}return!1};if(V.type==="pseudo"&&$==="only-child")return(J)=>{let X=Z.getSiblings(J),Q=0,H=!1;for(let B of X){if(!Z.isTag(B))continue;if(Q++,Q>1)return!1;if(B===J)H=!0}return Q===1&&H&&z(J)};if(V.type==="pseudo"&&$==="only-of-type")return(J)=>{let X=Z.getName(J),Q=Z.getSiblings(J),H=0,B=!1;for(let N of Q){if(!Z.isTag(N)||Z.getName(N)!==X)continue;if(H++,H>1)return!1;if(N===J)B=!0}return H===1&&B&&z(J)};if(V.type==="pseudo"&&$==="empty")return(J)=>Z.getChildren(J).length===0&&z(J);if(V.type==="pseudo"&&$==="root")return(J)=>{let X=Z.getParent(J);return(X==null||!Z.isTag(X))&&z(J)};if(V.type==="pseudo"&&$==="scope"){if(K.context&&Array.isArray(K.context)){let J=new Set(K.context);return(X)=>J.has(X)&&z(X)}if(K.context){let J=K.context;return(X)=>X===J&&z(X)}return(J)=>{let X=Z.getParent(J);return(X==null||!Z.isTag(X))&&z(J)}}if(V.type==="pseudo"&&b.has($)){if(K.pseudos&&K.pseudos[$]){let J=K.pseudos[$];if(typeof J==="function")return(X)=>J(X,void 0)&&z(X)}return(J)=>{return!1}}if(V.type==="pseudo-element")return z;if(K.pseudos&&K.pseudos[$]){let J=K.pseudos[$];if(typeof J==="function")return(X)=>J(X,typeof j==="string"?j:void 0)&&z(X);if(typeof J==="string"){let X=M(J),Q=G(X,K);return(H)=>Q(H)&&z(H)}}return(J)=>{return!1}}function v(V){let K=V.trim();if(K==="odd")return{a:2,b:1};if(K==="even")return{a:2,b:0};let z=/^([+-]?\d*)n([+-]\d+)?$/.exec(K.replace(/\s+/g,""));if(z){let $=z[1]===""||z[1]==="+"?1:z[1]==="-"?-1:Number(z[1]),j=z[2]?Number(z[2]):0;return{a:$,b:j}}let Z=Number(K);if(!Number.isNaN(Z))return{a:0,b:Z};return null}function u(V,K,z){let Z=v(V);if(!Z)return()=>!1;let{a:$,b:j}=Z,J=z.adapter,X=K==="nth-of-type"||K==="nth-last-of-type",Q=K==="nth-last-child"||K==="nth-last-of-type";return(H)=>{let B=J.getSiblings(H),N=X?J.getName(H):"",F=0,P=0;for(let U of B){if(!J.isTag(U))continue;if(X&&J.getName(U)!==N)continue;if(P++,U===H)F=P}if(F===0)return!1;let R=Q?P-F+1:F;if($===0)return R===j;return(R-j)/$>=0&&(R-j)%$===0}}function A(V,K,z){let Z=K.adapter,$=z===D;switch(V.type){case"tag":{let j=K.lowerCaseTags!==!1&&!K.xmlMode?V.name.toLowerCase():V.name;if($)return(J)=>Z.getName(J)===j;return(J)=>Z.getName(J)===j&&z(J)}case"universal":return z;case"attribute":return w(V,K,z);case"pseudo":case"pseudo-element":return y(V,K,z);case"descendant":case"child":case"parent":case"sibling":case"adjacent":case"column-combinator":return z}return(j)=>{return!1}}var x={universal:50,tag:30,attribute:1,pseudo:0,"pseudo-element":0},m={exists:10,equals:8,not:7,start:6,end:6,hyphen:5,any:4,element:3};function T(V){let K=x[V.type]??0;if(V.type==="attribute")return K+(m[V.action]??0);return K}function G(V,K){if(V.length===1)return Y(V[0],K);let z=V.map((Z)=>Y(Z,K));return(Z)=>z.some(($)=>$(Z))}function Y(V,K){let z=K.adapter,Z=[[]],$=[];for(let J of V)if(J.type==="descendant"||J.type==="child"||J.type==="sibling"||J.type==="adjacent"||J.type==="parent"||J.type==="column-combinator")$.push(J),Z.push([]);else Z[Z.length-1].push(J);let j=D;for(let J=0;J<Z.length;J++){let X=Z[J].slice().sort((Q,H)=>T(Q)-T(H));for(let Q of X)j=A(Q,K,j);if(J<$.length)j=c($[J],j,z)}return j}function c(V,K,z){switch(V.type){case"descendant":case"column-combinator":return(Z)=>{let $=z.getParent(Z);while($){if(z.isTag($)&&K($))return!0;$=z.getParent($)}return!1};case"child":return(Z)=>{let $=z.getParent(Z);return $!=null&&z.isTag($)&&K($)};case"sibling":return(Z)=>{let $=z.getSiblings(Z);for(let j of $){if(j===Z)return!1;if(z.isTag(j)&&K(j))return!0}return!1};case"adjacent":return(Z)=>{let $=z.getSiblings(Z),j=null;for(let J of $){if(J===Z)return j!=null&&z.isTag(j)&&K(j);j=J}return!1};case"parent":return(Z)=>z.existsOne(K,z.getChildren(Z))}return(Z)=>{return!1}}function h(V){if(!V||!V.adapter)throw Error("css-select: adapter is required");return V.adapter}var q=new WeakMap;function d(V){return(V.xmlMode?1:0)<<0|(V.lowerCaseAttributeNames===!1?1:0)<<1|(V.lowerCaseTags===!1?1:0)<<2}function i(V,K){let z=q.get(V);if(!z)z=[],q.set(V,z);let Z=z[K];if(!Z)Z=new Map,z[K]=Z;return Z}function C(V,K){let z=M(V,{xmlMode:K.xmlMode,lowerCaseAttributeNames:K.lowerCaseAttributeNames,lowerCaseTags:K.lowerCaseTags});return G(z,K)}function O(V,K){if(typeof V!=="string")return G(V,K);if(K.cacheResults===!1||!K.adapter)return C(V,K);let z=i(K.adapter,d(K)),Z=z.get(V);if(Z!==void 0)return Z;return Z=C(V,K),z.set(V,Z),Z}function r(V,K){if(K===void 0){q.delete(V);return}let z=q.get(V);if(!z)return;for(let Z of z)if(Z)Z.delete(K)}function p(V,K,z){let Z=h(z),$=typeof V==="function"?V:O(V,z),j=W(K,Z);return E($,j,Z,z.xmlMode===!0)}function s(V,K,z){let Z=h(z),$=typeof V==="function"?V:O(V,z),j=W(K,Z);return L($,j,Z,z.xmlMode===!0)}function o(V,K,z){return(typeof K==="function"?K:O(K,z))(V)}export{Y as a,O as b,r as c,p as d,s as e,o as f,n as g};
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
// @bun
|
|
2
|
+
import{t as q,x as K,y as E}from"./chunk-9ep6bwwb.js";import{A as R}from"./chunk-2wsah70r.js";import{F as i}from"./chunk-1kmkypmr.js";var n={};i(n,{syntax:()=>l,specificityToString:()=>I,specificity:()=>h,removeComments:()=>B,minifyBlock:()=>W,minify:()=>N,dedupeDeclarations:()=>L,compressTree:()=>w});function B(g,f={}){let b=f.exclamation??!1,H=!1;E(g,($,A,F)=>{if($.type!=="Comment")return;let M=$.value.startsWith("!");if(b===!0&&M)return;if(b==="first-exclamation"&&M&&!H){H=!0;return}if(A&&F)F.remove(A)})}function L(g){E(g,(f)=>{if(f.type!=="Block"&&f.type!=="DeclarationList")return;if(!("children"in f)||!f.children)return;let b=f.children,H=b.head;if(H==null||H.next==null)return;let $=0;for(let M=H;M!=null;M=M.next)if(M.data.type==="Declaration"){if($++,$>=2)break}if($<2)return;let A=new Map,F=[];for(let M=H;M!=null;M=M.next){let X=M.data;if(X.type!=="Declaration")continue;let _=X.property,y=A.get(_);if(y){let c=!!y.decl.important,S=!!X.important;if(S||c===S)F.push(y.item),A.set(_,{item:M,decl:X});else F.push(M)}else A.set(_,{item:M,decl:X})}for(let M of F)b.remove(M)})}var r={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"},m={"#f00":"red","#ff0000":"red","#000080":"navy","#008080":"teal"};function J(g){if(!g.startsWith("#"))return g;let f=g.slice(1);if(f.length===6){if(f[0]===f[1]&&f[2]===f[3]&&f[4]===f[5])return`#${f[0]}${f[2]}${f[4]}`}if(f.length===8){if(f[0]===f[1]&&f[2]===f[3]&&f[4]===f[5]&&f[6]===f[7])return`#${f[0]}${f[2]}${f[4]}${f[6]}`}return g}function T(g){let f=g.toLowerCase();return r[f]??null}function V(g){let f=g.toLowerCase();return m[f]??null}function v(g,f,b){let H=(g<<16|f<<8|b).toString(16).padStart(6,"0");return J(`#${H}`)}var p=/^rgba?\(\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*[,\s]\s*([+-]?\d*\.?\d+%?)\s*(?:[,/]\s*([+-]?\d*\.?\d+%?)\s*)?\)$/;function Y(g){let f=p.exec(g.trim());if(!f)return g;let b=D(f[1]),H=D(f[2]),$=D(f[3]);if(f[4]!==void 0&&!d(f[4]))return g;return v(b,H,$)}function d(g){if(g.endsWith("%"))return Number.parseFloat(g)>=100;return Number.parseFloat(g)>=1}function D(g){if(g.endsWith("%"))return Math.max(0,Math.min(255,Math.round(Number.parseFloat(g)*2.55)));return Math.max(0,Math.min(255,Math.round(Number.parseFloat(g))))}var u=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 j(g){if(g.charCodeAt(0)===43)g=g.slice(1);if(g.includes(".")){let f=g.replace(/(\.\d*?)0+($|[eE])/,"$1$2");f=f.replace(/\.($|[eE])/,"$1"),g=f}if(g.startsWith("0.")&&g.length>2)g=g.slice(1);else if(g.startsWith("-0.")&&g.length>3)g=`-${g.slice(2)}`;if(g==="-0"||g==="-.0"||g==="-0.0")g="0";return g}function z(g,f){let b=j(g);if((b==="0"||b==="-0")&&u.has(f.toLowerCase()))return{value:"0",unit:""};return{value:b,unit:f}}function C(g){return j(g)}function U(g,f){let b=Number.parseFloat(g);if(!Number.isFinite(b))return g;let H=f<0?0:f;return b.toFixed(H)}var Z=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 G(g){if(!g||g.type!=="Operator")return!1;let f=g.value;return f===":"||f===","||f==="/"}function a(g){let f=g.children;if(!f)return;while(f.head&&f.head.data.type==="WhiteSpace")f.remove(f.head);while(f.tail&&f.tail.data.type==="WhiteSpace")f.remove(f.tail);let b=f.head;while(b){let H=b.next;if(b.data.type==="WhiteSpace"){let $=b.prev&&G(b.prev.data),A=H&&G(H.data);if($||A)f.remove(b)}b=H}}function w(g,f={}){let b=f.floatPrecision??null,H=b===null?null:($)=>U($,b);E(g,{enter($,A,F){switch($.type){case"Number":{let M=H?H($.value):$.value;$.value=j(M);return}case"Percentage":{let M=H?H($.value):$.value;$.value=C(M);return}case"Dimension":{let M=H?H($.value):$.value,X=z(M,$.unit);$.value=X.value,$.unit=X.unit;return}case"Hash":{let M=J(`#${$.name}`).slice(1);if($.name=M,A&&F&&this.declaration&&Z.has(this.declaration.property.toLowerCase())){let X=V(`#${M}`);if(X&&X.length<M.length+1){let _={type:"Identifier",name:X,loc:$.loc};F.replace(A,F.createItem(_))}}return}case"Identifier":{if(!A||!F||!this.declaration)return;if(!Z.has(this.declaration.property.toLowerCase()))return;let M=T($.name);if(M&&M.length<$.name.length){let X={type:"Hash",name:M.slice(1),loc:$.loc};F.replace(A,F.createItem(X))}return}case"Url":return;case"Function":{let M=$.name.toLowerCase();if((M==="rgb"||M==="rgba")&&A&&F)$.__rgbReplaceCandidate=!0}}},leave($,A,F){if($.type==="Parentheses"||$.type==="Function"||$.type==="Value")a($);if($.type==="Function"&&$.__rgbReplaceCandidate&&A&&F){let M=q($),X=Y(M);if(X!==M&&X.startsWith("#")){let _={type:"Hash",name:X.slice(1),loc:$.loc};F.replace(A,F.createItem(_))}}}})}function N(g,f={}){let b=K(g,{context:"stylesheet"});return k(b,f)}function W(g,f={}){let b=K(g,{context:"declarationList"});return k(b,f)}function k(g,f){if(f.comments===!1)B(g,{exclamation:!1});else if(f.comments==="first-exclamation")B(g,{exclamation:"first-exclamation"});else B(g,{exclamation:!0});return w(g,{floatPrecision:f.floatPrecision??null}),L(g),{css:q(g),ast:g}}function h(g){let f=[0,0,0];if(typeof g==="string"){let b=R(g);return x(b,f),f}if(Array.isArray(g)){if(g.length===0)return f;if(Array.isArray(g[0]))x(g,f);else Q(g,f);return f}return O(g,f),f}function O(g,f){switch(g.type){case"IdSelector":f[0]++;return;case"ClassSelector":case"AttributeSelector":f[1]++;return;case"TypeSelector":if(g.name!=="*")f[2]++;return;case"PseudoClassSelector":{let b=g.name.toLowerCase();if(b==="is"||b==="matches"||b==="-moz-any"||b==="-webkit-any"||b==="not"||b==="has"){if(g.children){let H=[];for(let A of g.children)if(A.type==="SelectorList"&&"children"in A&&A.children)for(let F of A.children)H.push(F);else if(A.type==="Selector")H.push(A);let $=[0,0,0];for(let A of H){let F=h(A);if(P(F,$)>0)$=F}f[0]+=$[0],f[1]+=$[1],f[2]+=$[2]}return}if(b==="where")return;f[1]++;return}case"PseudoElementSelector":f[2]++;return;case"Selector":case"SelectorList":case"AtrulePrelude":if("children"in g&&g.children)for(let b of g.children)O(b,f);return;case"NestingSelector":return}}function x(g,f){for(let b of g)Q(b,f)}function Q(g,f){for(let b of g)switch(b.type){case"tag":if(b.name!=="*")f[2]++;break;case"attribute":if(b.name==="id"&&b.action==="equals")f[0]++;else f[1]++;break;case"pseudo":{let H=b.name.toLowerCase();if(H==="is"||H==="matches"||H==="not"||H==="has"||H==="-moz-any"||H==="-webkit-any"){if(Array.isArray(b.data)){let $=[0,0,0];for(let A of b.data){let F=[0,0,0];if(Q(A,F),P(F,$)>0)$=F}f[0]+=$[0],f[1]+=$[1],f[2]+=$[2]}break}if(H==="where")break;f[1]++;break}case"pseudo-element":f[2]++;break}}function P(g,f){for(let b=0;b<3;b++)if(g[b]!==f[b])return g[b]-f[b];return 0}function I(g){return g.join(",")}var l={specificity:h};
|
|
3
|
+
export{B as h,L as i,w as j,N as k,W as l,h as m,I as n,l as o,n as p};
|