class ParseError extends Error{sourceStart;sourceEnd;parserState;constructor(e,n,r,t){super(e),this.name="ParseError",this.sourceStart=n,this.sourceEnd=r,this.parserState=t}}class Reader{cursor;source="";codePointSource=[];length=0;representationStart=0;representationEnd=-1;constructor(e){this.cursor=0,this.source=e,this.length=e.length,this.codePointSource=new Array(this.length);for(let e=0;e=48&&e<=57}function isUppercaseLetterCodePoint(e){return e>=65&&e<=90}function isLowercaseLetterCodePoint(e){return e>=97&&e<=122}function isHexDigitCodePoint(e){return isDigitCodePoint(e)||e>=97&&e<=102||e>=65&&e<=70}function isLetterCodePoint(e){return isLowercaseLetterCodePoint(e)||isUppercaseLetterCodePoint(e)}function isNonASCIICodePoint(e){return e>=128}function isIdentStartCodePoint(e){return isLetterCodePoint(e)||isNonASCIICodePoint(e)||e===A}function isIdentCodePoint(e){return isIdentStartCodePoint(e)||isDigitCodePoint(e)||e===E}function isNewLine(e){return 10===e||13===e||12===e}function isWhitespace(e){return 32===e||10===e||9===e||13===e||12===e}function checkIfTwoCodePointsAreAValidEscape(e,n){return n.codePointSource[n.cursor]===N&&!isNewLine(n.codePointSource[n.cursor+1])}function checkIfThreeCodePointsWouldStartAnIdentSequence(e,n){return n.codePointSource[n.cursor]===E?n.codePointSource[n.cursor+1]===E||(!!isIdentStartCodePoint(n.codePointSource[n.cursor+1])||n.codePointSource[n.cursor+1]===N&&!isNewLine(n.codePointSource[n.cursor+2])):!!isIdentStartCodePoint(n.codePointSource[n.cursor])||checkIfTwoCodePointsAreAValidEscape(0,n)}function checkIfThreeCodePointsWouldStartANumber(e,n){return n.codePointSource[n.cursor]===q||n.codePointSource[n.cursor]===E?!!isDigitCodePoint(n.codePointSource[n.cursor+1])||n.codePointSource[n.cursor+1]===l&&isDigitCodePoint(n.codePointSource[n.cursor+2]):n.codePointSource[n.cursor]===l?isDigitCodePoint(n.codePointSource[n.cursor+1]):isDigitCodePoint(n.codePointSource[n.cursor])}function checkIfTwoCodePointsStartAComment(e,n){return n.codePointSource[n.cursor]===H&&n.codePointSource[n.cursor+1]===i}function checkIfThreeCodePointsWouldStartCDC(e,n){return n.codePointSource[n.cursor]===E&&n.codePointSource[n.cursor+1]===E&&n.codePointSource[n.cursor+2]===f}function consumeComment(n,r){for(r.advanceCodePoint(2);;){const e=r.readCodePoint();if(!1===e){n.onParseError(new ParseError("Unexpected EOF while consuming a comment.",r.representationStart,r.representationEnd,["4.3.2. Consume comments","Unexpected EOF"]));break}if(e===i&&(void 0!==r.codePointSource[r.cursor]&&r.codePointSource[r.cursor]===H)){r.advanceCodePoint();break}}return[e.Comment,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,void 0]}function consumeEscapedCodePoint(e,n){const r=n.readCodePoint();if(!1===r)return e.onParseError(new ParseError("Unexpected EOF while consuming an escaped code point.",n.representationStart,n.representationEnd,["4.3.7. Consume an escaped code point","Unexpected EOF"])),x;if(isHexDigitCodePoint(r)){const e=[r];for(;void 0!==n.codePointSource[n.cursor]&&isHexDigitCodePoint(n.codePointSource[n.cursor])&&e.length<6;)e.push(n.codePointSource[n.cursor]),n.advanceCodePoint();isWhitespace(n.codePointSource[n.cursor])&&n.advanceCodePoint();const o=parseInt(String.fromCharCode(...e),16);return 0===o?x:(t=o)>=55296&&t<=57343||o>U?x:o}var t;return r}function consumeIdentSequence(e,n){const r=[];for(;;)if(isIdentCodePoint(n.codePointSource[n.cursor]))r.push(n.codePointSource[n.cursor]),n.advanceCodePoint();else{if(!checkIfTwoCodePointsAreAValidEscape(0,n))return r;n.advanceCodePoint(),r.push(consumeEscapedCodePoint(e,n))}}function consumeHashToken(n,t){if(t.advanceCodePoint(),void 0!==t.codePointSource[t.cursor]&&(isIdentCodePoint(t.codePointSource[t.cursor])||checkIfTwoCodePointsAreAValidEscape(0,t))){let o=r.Unrestricted;checkIfThreeCodePointsWouldStartAnIdentSequence(0,t)&&(o=r.ID);const i=consumeIdentSequence(n,t);return[e.Hash,t.source.slice(t.representationStart,t.representationEnd+1),t.representationStart,t.representationEnd,{value:String.fromCharCode(...i),type:o}]}return[e.Delim,"#",t.representationStart,t.representationEnd,{value:"#"}]}function consumeNumber(e,r){let t=n.Integer;for(r.codePointSource[r.cursor]!==q&&r.codePointSource[r.cursor]!==E||r.advanceCodePoint();isDigitCodePoint(r.codePointSource[r.cursor]);)r.advanceCodePoint();if(r.codePointSource[r.cursor]===l&&isDigitCodePoint(r.codePointSource[r.cursor+1]))for(r.advanceCodePoint(2),t=n.Number;isDigitCodePoint(r.codePointSource[r.cursor]);)r.advanceCodePoint();if(r.codePointSource[r.cursor]===v||r.codePointSource[r.cursor]===m){if(isDigitCodePoint(r.codePointSource[r.cursor+1]))r.advanceCodePoint(2);else{if(r.codePointSource[r.cursor+1]!==E&&r.codePointSource[r.cursor+1]!==q||!isDigitCodePoint(r.codePointSource[r.cursor+2]))return t;r.advanceCodePoint(3)}for(t=n.Number;isDigitCodePoint(r.codePointSource[r.cursor]);)r.advanceCodePoint()}return t}function consumeNumericToken(n,r){const t=consumeNumber(0,r),o=parseFloat(r.source.slice(r.representationStart,r.representationEnd+1));if(checkIfThreeCodePointsWouldStartAnIdentSequence(0,r)){const i=consumeIdentSequence(n,r);return[e.Dimension,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:o,type:t,unit:String.fromCharCode(...i)}]}return r.codePointSource[r.cursor]===y?(r.advanceCodePoint(),[e.Percentage,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:o}]):[e.Number,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:o,type:t}]}function consumeWhiteSpace(n,r){for(;isWhitespace(r.codePointSource[r.cursor]);)r.advanceCodePoint();return[e.Whitespace,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,void 0]}function consumeStringToken(n,r){let t="";const o=r.readCodePoint();for(;;){const i=r.readCodePoint();if(!1===i)return n.onParseError(new ParseError("Unexpected EOF while consuming a string token.",r.representationStart,r.representationEnd,["4.3.5. Consume a string token","Unexpected EOF"])),[e.String,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:t}];if(isNewLine(i))return n.onParseError(new ParseError("Unexpected newline while consuming a string token.",r.representationStart,r.representationEnd,["4.3.5. Consume a string token","Unexpected newline"])),r.unreadCodePoint(),[e.BadString,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,void 0];if(i===o)return[e.String,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:t}];if(i!==N)t+=String.fromCharCode(i);else{if(void 0===r.codePointSource[r.cursor])continue;if(isNewLine(r.codePointSource[r.cursor])){r.advanceCodePoint();continue}t+=String.fromCharCode(consumeEscapedCodePoint(n,r))}}}const K="u".charCodeAt(0),M="U".charCodeAt(0),$="r".charCodeAt(0),J="R".charCodeAt(0),j="l".charCodeAt(0),Q="L".charCodeAt(0);function checkIfCodePointsMatchURLIdent(e,n){return 3===n.length&&((n[0]===K||n[0]===M)&&((n[1]===$||n[1]===J)&&(n[2]===j||n[2]===Q)))}function consumeBadURL(e,n){for(;;){if(void 0===n.codePointSource[n.cursor])return;if(n.codePointSource[n.cursor]===W)return void n.advanceCodePoint();checkIfTwoCodePointsAreAValidEscape(0,n)?(n.advanceCodePoint(),consumeEscapedCodePoint(e,n)):n.advanceCodePoint()}}function consumeUrlToken(n,r){consumeWhiteSpace(0,r);let t="";for(;;){if(void 0===r.codePointSource[r.cursor])return n.onParseError(new ParseError("Unexpected EOF while consuming a url token.",r.representationStart,r.representationEnd,["4.3.6. Consume a url token","Unexpected EOF"])),[e.URL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:t}];if(r.codePointSource[r.cursor]===W)return r.advanceCodePoint(),[e.URL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:t}];if(isWhitespace(r.codePointSource[r.cursor]))return consumeWhiteSpace(0,r),void 0===r.codePointSource[r.cursor]?(n.onParseError(new ParseError("Unexpected EOF while consuming a url token.",r.representationStart,r.representationEnd,["4.3.6. Consume a url token","Consume as much whitespace as possible","Unexpected EOF"])),[e.URL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:t}]):r.codePointSource[r.cursor]===W?(r.advanceCodePoint(),[e.URL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:t}]):(consumeBadURL(n,r),[e.BadURL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,void 0]);if(r.codePointSource[r.cursor]===R||r.codePointSource[r.cursor]===o||r.codePointSource[r.cursor]===g||((i=r.codePointSource[r.cursor])===w||i===S||D<=i&&i<=c||B<=i&&i<=h))return consumeBadURL(n,r),n.onParseError(new ParseError("Unexpected character while consuming a url token.",r.representationStart,r.representationEnd,["4.3.6. Consume a url token","Unexpected U+0022 QUOTATION MARK (\"), U+0027 APOSTROPHE ('), U+0028 LEFT PARENTHESIS (() or non-printable code point"])),[e.BadURL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,void 0];if(r.codePointSource[r.cursor]===N){if(checkIfTwoCodePointsAreAValidEscape(0,r)){r.advanceCodePoint(),t+=String.fromCharCode(consumeEscapedCodePoint(n,r));continue}return consumeBadURL(n,r),n.onParseError(new ParseError("Invalid escape sequence while consuming a url token.",r.representationStart,r.representationEnd,["4.3.6. Consume a url token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"])),[e.BadURL,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,void 0]}t+=String.fromCharCode(r.codePointSource[r.cursor]),r.advanceCodePoint()}var i}function consumeIdentLikeToken(n,r){const t=consumeIdentSequence(n,r);if(r.codePointSource[r.cursor]!==g)return[e.Ident,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:String.fromCharCode(...t)}];if(checkIfCodePointsMatchURLIdent(0,t)){r.advanceCodePoint();let i=0;for(;;){const n=isWhitespace(r.codePointSource[r.cursor]),c=isWhitespace(r.codePointSource[r.cursor+1]);if(n&&c){i+=1,r.advanceCodePoint(1);continue}const s=n?r.codePointSource[r.cursor+1]:r.codePointSource[r.cursor];if(s===R||s===o)return i>0&&r.unreadCodePoint(i),[e.Function,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:String.fromCharCode(...t)}];break}return consumeUrlToken(n,r)}return r.advanceCodePoint(),[e.Function,r.source.slice(r.representationStart,r.representationEnd+1),r.representationStart,r.representationEnd,{value:String.fromCharCode(...t)}]}function tokenize(e,n){const r=tokenizer(e,n),t=[];{for(;!r.endOfFile();){const e=r.nextToken();e&&t.push(e)}const e=r.nextToken();e&&t.push(e)}return t}function tokenizer(n,r){const t=n.css.valueOf(),i=new Reader(t),c={onParseError:(null==r?void 0:r.onParseError)??(()=>{})};return{nextToken:function nextToken(){if(i.representationStart=i.cursor,i.representationEnd=-1,checkIfTwoCodePointsStartAComment(0,i))return consumeComment(c,i);const n=i.codePointSource[i.cursor];if(void 0===n)return[e.EOF,"",-1,-1,void 0];if(isIdentStartCodePoint(n))return consumeIdentLikeToken(c,i);if(isDigitCodePoint(n))return consumeNumericToken(c,i);switch(n){case d:return i.advanceCodePoint(),[e.Comma,",",i.representationStart,i.representationEnd,void 0];case u:return i.advanceCodePoint(),[e.Colon,":",i.representationStart,i.representationEnd,void 0];case V:return i.advanceCodePoint(),[e.Semicolon,";",i.representationStart,i.representationEnd,void 0];case g:return i.advanceCodePoint(),[e.OpenParen,"(",i.representationStart,i.representationEnd,void 0];case W:return i.advanceCodePoint(),[e.CloseParen,")",i.representationStart,i.representationEnd,void 0];case I:return i.advanceCodePoint(),[e.OpenSquare,"[",i.representationStart,i.representationEnd,void 0];case F:return i.advanceCodePoint(),[e.CloseSquare,"]",i.representationStart,i.representationEnd,void 0];case k:return i.advanceCodePoint(),[e.OpenCurly,"{",i.representationStart,i.representationEnd,void 0];case b:return i.advanceCodePoint(),[e.CloseCurly,"}",i.representationStart,i.representationEnd,void 0];case o:case R:return consumeStringToken(c,i);case L:return consumeHashToken(c,i);case q:case l:return checkIfThreeCodePointsWouldStartANumber(0,i)?consumeNumericToken(c,i):(i.advanceCodePoint(),[e.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]);case O:case s:case C:case a:case z:return consumeWhiteSpace(0,i);case E:return checkIfThreeCodePointsWouldStartANumber(0,i)?consumeNumericToken(c,i):checkIfThreeCodePointsWouldStartCDC(0,i)?(i.advanceCodePoint(3),[e.CDC,"--\x3e",i.representationStart,i.representationEnd,void 0]):checkIfThreeCodePointsWouldStartAnIdentSequence(0,i)?consumeIdentLikeToken(c,i):(i.advanceCodePoint(),[e.Delim,"-",i.representationStart,i.representationEnd,{value:"-"}]);case T:return checkIfFourCodePointsWouldStartCDO(0,i)?(i.advanceCodePoint(4),[e.CDO,"\x3c!--",i.representationStart,i.representationEnd,void 0]):(i.advanceCodePoint(),[e.Delim,"<",i.representationStart,i.representationEnd,{value:"<"}]);case p:if(i.advanceCodePoint(),checkIfThreeCodePointsWouldStartAnIdentSequence(0,i)){const n=consumeIdentSequence(c,i);return[e.AtKeyword,i.source.slice(i.representationStart,i.representationEnd+1),i.representationStart,i.representationEnd,{value:String.fromCharCode(...n)}]}return[e.Delim,"@",i.representationStart,i.representationEnd,{value:"@"}];case N:return checkIfTwoCodePointsAreAValidEscape(0,i)?consumeIdentLikeToken(c,i):(i.advanceCodePoint(),c.onParseError(new ParseError('Invalid escape sequence after "\\"',i.representationStart,i.representationEnd,["4.3.1. Consume a token","U+005C REVERSE SOLIDUS (\\)","The input stream does not start with a valid escape sequence"])),[e.Delim,"\\",i.representationStart,i.representationEnd,{value:"\\"}])}return i.advanceCodePoint(),[e.Delim,i.source[i.representationStart],i.representationStart,i.representationEnd,{value:i.source[i.representationStart]}]},endOfFile:function endOfFile(){return void 0===i.codePointSource[i.cursor]}}}function cloneTokens(e){return"undefined"!=typeof globalThis&&"structuredClone"in globalThis?structuredClone(e):JSON.parse(JSON.stringify(e))}function mutateIdent(e,n){let r="";const t=new Array(n.length);for(let e=0;e