diff --git a/Dynamic b/Dynamic index 37f8c26..3680d53 160000 --- a/Dynamic +++ b/Dynamic @@ -1 +1 @@ -Subproject commit 37f8c264f4998bf19c6b3fd67c4fda36d4428a1e +Subproject commit 3680d531ababfe3dab998b9cf29cc9e570f865e2 diff --git a/bare-client-custom b/bare-client-custom index e5d41a5..9f86dcd 160000 --- a/bare-client-custom +++ b/bare-client-custom @@ -1 +1 @@ -Subproject commit e5d41a5e9b1fc8b8b485223378d10311d57cb81e +Subproject commit 9f86dcd073755aefd70aa9f1d5aee08364958961 diff --git a/client/src/AdriftClient.ts b/client/src/AdriftClient.ts index 1ede195..326173d 100644 --- a/client/src/AdriftClient.ts +++ b/client/src/AdriftClient.ts @@ -18,7 +18,8 @@ const NULL_BODY_STATUSES = [101, 103, 204, 205, 304]; * below MAX_CHUNK_SIZE. */ function createBodyStream( - body: BodyInit | null + body: BodyInit | null, + arrayBufferImpl: ArrayBufferConstructor ): ReadableStream | null { if (body === null || typeof body === "undefined") return null; @@ -113,9 +114,10 @@ export class AdriftBareClient extends Client { remote: URL, cache: string | undefined, duplex: string | undefined, - signal: AbortSignal | undefined + signal: AbortSignal | undefined, + arrayBufferImpl: ArrayBufferConstructor, ): Promise { - const bodyStream = createBodyStream(body); + const bodyStream = createBodyStream(body, arrayBufferImpl); let { payload, body: respRawBody } = await this.connection.httprequest( { method, @@ -152,7 +154,8 @@ export class AdriftBareClient extends Client { getRequestHeaders: GetRequestHeadersCallback, onMeta: MetaCallback, onReadyState: ReadyStateCallback, - webSocketImpl: WebSocketImpl + webSocketImpl: WebSocketImpl, + arrayBufferImpl: ArrayBufferConstructor, ): WebSocket { const ws = new webSocketImpl("ws:null", protocols); // this will error. that's okay @@ -188,6 +191,10 @@ export class AdriftBareClient extends Client { }, (data) => { console.log({ data, binaryType: ws.binaryType }); + if (data instanceof ArrayBuffer) { + (data as any).__proto__ = arrayBufferImpl.prototype; + } + ws.dispatchEvent( new MessageEvent("message", { data, @@ -197,7 +204,8 @@ export class AdriftBareClient extends Client { (message: string) => { console.log({ message }); ws.dispatchEvent(new ErrorEvent("error", { message })); - } + }, + arrayBufferImpl ); ws.send = (data: any) => { diff --git a/client/src/Connection.ts b/client/src/Connection.ts index 350c922..bac6529 100644 --- a/client/src/Connection.ts +++ b/client/src/Connection.ts @@ -106,7 +106,8 @@ export class Connection { case S2CRequestTypes.WSDataBinary: { const socketMeta = this.openSockets[requestID]; if (!socketMeta) return; - setTimeout(() => socketMeta.onmessage(data.slice(cursor))); + let slice = data.slice(cursor); + setTimeout(() => socketMeta.onmessage(slice)); break; } @@ -200,7 +201,8 @@ export class Connection { onopen: () => void, onclose: (code: number, reason: string, wasClean: boolean) => void, onmessage: (data: any) => void, - onerror: (message: string) => void + onerror: (message: string) => void, + arrayBufferImpl: ArrayBufferConstructor, ): { send: (data: any) => void; close: (code?: number, reason?: string) => void; @@ -245,11 +247,11 @@ export class Connection { ).catch(cleanup); return; } - if (data instanceof window.ArrayBuffer) { + if (data instanceof arrayBufferImpl) { this.send(seq, C2SRequestTypes.WSSendBinary, data).catch(cleanup); return; } - if (window.ArrayBuffer.isView(data)) { + if (arrayBufferImpl.isView(data)) { this.send( seq, C2SRequestTypes.WSSendBinary, diff --git a/frontend/public/uv/uv.bundle.js b/frontend/public/uv/uv.bundle.js index 33db2c2..530f5d8 100644 --- a/frontend/public/uv/uv.bundle.js +++ b/frontend/public/uv/uv.bundle.js @@ -12,7 +12,7 @@ --------`+new Array(a.mismatchOffset+1).join("-")+"^",Object.assign(a,c),a.loc={source:n&&n.loc&&n.loc.source||"",start:c,end:l},a};var da=new Map,An=new Map,pa=45,ma=J1,Xo=Z1;function fa(e,t){return t=t||0,e.length-t>=2&&e.charCodeAt(t)===pa&&e.charCodeAt(t+1)===pa}function e0(e,t){if(t=t||0,e.length-t>=3&&e.charCodeAt(t)===pa&&e.charCodeAt(t+1)!==pa){let n=e.indexOf("-",t+2);if(n!==-1)return e.substring(t,n+1)}return""}function J1(e){if(da.has(e))return da.get(e);let t=e.toLowerCase(),n=da.get(t);if(n===void 0){let i=fa(t,0),a=i?"":e0(t,0);n=Object.freeze({basename:t.substr(a.length),name:t,prefix:a,vendor:a,custom:i})}return da.set(e,n),n}function Z1(e){if(An.has(e))return An.get(e);let t=e,n=e[0];n==="/"?n=e[1]==="/"?"//":"/":n!=="_"&&n!=="*"&&n!=="$"&&n!=="#"&&n!=="+"&&n!=="&"&&(n="");let i=fa(t,n.length);if(!i&&(t=t.toLowerCase(),An.has(t))){let r=An.get(t);return An.set(e,r),r}let a=i?"":e0(t,n.length),o=t.substr(0,n.length+a.length),s=Object.freeze({basename:t.substr(o.length),name:t.substr(n.length),hack:n,vendor:a,prefix:o,custom:i});return An.set(e,s),s}var ha=["initial","inherit","unset","revert","revert-layer"];var li=43,kt=45,Go=110,Tn=!0,eh=!1;function Ko(e,t){return e!==null&&e.type===9&&e.value.charCodeAt(0)===t}function ci(e,t,n){for(;e!==null&&(e.type===13||e.type===25);)e=n(++t);return t}function Ht(e,t,n,i){if(!e)return 0;let a=e.value.charCodeAt(t);if(a===li||a===kt){if(n)return 0;t++}for(;t6)return 0}return i}function ba(e,t,n){if(!e)return 0;for(;Zo(n(t),n0);){if(++e>6)return 0;t++}return t}function $o(e,t){let n=0;if(e===null||e.type!==1||!_t(e.value,0,nh)||(e=t(++n),e===null))return 0;if(Zo(e,th))return e=t(++n),e===null?0:e.type===1?ba(di(e,0,!0),++n,t):Zo(e,n0)?ba(1,++n,t):0;if(e.type===10){let i=di(e,1,!0);return i===0?0:(e=t(++n),e===null?n:e.type===12||e.type===10?!ih(e,t0)||!di(e,1,!1)?0:n+1:ba(i,n,t))}return e.type===12?ba(di(e,1,!0),++n,t):0}var ah=["calc(","-moz-calc(","-webkit-calc("],es=new Map([[2,22],[21,22],[19,20],[23,24]]);function pt(e,t){return te.max&&typeof e.max!="string")return!0}return!1}function oh(e,t){let n=0,i=[],a=0;e:do{switch(e.type){case 24:case 22:case 20:if(e.type!==n)break e;if(n=i.pop(),i.length===0){a++;break e}break;case 2:case 21:case 19:case 23:i.push(n),n=es.get(e.type);break}a++}while(e=t(a));return a}function ot(e){return function(t,n,i){return t===null?0:t.type===2&&a0(t.value,ah)?oh(t,n):e(t,n,i)}}function be(e){return function(t){return t===null||t.type!==e?0:1}}function sh(e){if(e===null||e.type!==1)return 0;let t=e.value.toLowerCase();return a0(t,ha)||i0(t,"default")?0:1}function uh(e){return e===null||e.type!==1||pt(e.value,0)!==45||pt(e.value,1)!==45?0:1}function rh(e){if(e===null||e.type!==4)return 0;let t=e.value.length;if(t!==4&&t!==5&&t!==7&&t!==9)return 0;for(let n=1;nxh,decibel:()=>kh,flex:()=>Ch,frequency:()=>Ah,length:()=>Eh,resolution:()=>Th,semitones:()=>yh,time:()=>vh});var Eh=["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],xh=["deg","grad","rad","turn"],vh=["s","ms"],Ah=["hz","khz"],Th=["dpi","dpcm","dppx","x"],Ch=["fr"],kh=["db"],yh=["st"];function ts(e,t,n){return Object.assign(Jt("SyntaxError",e),{input:t,offset:n,rawMessage:e,message:e+` `+t+` --`+new Array((n||t.length)+1).join("-")+"^"})}var Dh=9,Sh=10,_h=12,wh=13,Ih=32,xa=class{constructor(t){this.str=t,this.pos=0}charCodeAt(t){return t/[a-zA-Z0-9\-]/.test(String.fromCharCode(t))?1:0),m0={" ":1,"&&":2,"||":3,"|":4};function Ta(e){return e.substringToPos(e.findWsEnd(e.pos))}function Cn(e){let t=e.pos;for(;t=128||pi[n]===0)break}return e.pos===t&&e.error("Expect a keyword"),e.substringToPos(t)}function Ca(e){let t=e.pos;for(;t57)break}return e.pos===t&&e.error("Expect a number"),e.substringToPos(t)}function Mh(e){let t=e.str.indexOf("'",e.pos+1);return t===-1&&(e.pos=e.str.length,e.error("Expect an apostrophe")),e.substringToPos(t+1)}function f0(e){let t=null,n=null;return e.eat(Aa),t=Ca(e),e.charCode()===ss?(e.pos++,e.charCode()!==d0&&(n=Ca(e))):n=t,e.eat(d0),{min:Number(t),max:n?Number(n):0}}function Uh(e){let t=null,n=!1;switch(e.charCode()){case g0:e.pos++,t={min:0,max:0};break;case os:e.pos++,t={min:1,max:0};break;case is:e.pos++,t={min:0,max:1};break;case as:e.pos++,n=!0,e.charCode()===Aa?t=f0(e):e.charCode()===is?(e.pos++,t={min:0,max:0}):t={min:1,max:0};break;case Aa:t=f0(e);break;default:return null}return{type:"Multiplier",comma:n,min:t.min,max:t.max,term:null}}function kn(e,t){let n=Uh(e);return n!==null?(n.term=t,e.charCode()===as&&e.charCodeAt(e.pos-1)===os?kn(e,n):n):t}function ns(e){let t=e.peek();return t===""?null:{type:"Token",value:t}}function Hh(e){let t;return e.eat(us),e.eat(va),t=Cn(e),e.eat(va),e.eat(E0),kn(e,{type:"Property",name:t})}function jh(e){let t=null,n=null,i=1;return e.eat(ka),e.charCode()===c0&&(e.peek(),i=-1),i==-1&&e.charCode()===p0?e.peek():(t=i*Number(Ca(e)),pi[e.charCode()]!==0&&(t+=Cn(e))),Ta(e),e.eat(ss),Ta(e),e.charCode()===p0?e.peek():(i=1,e.charCode()===c0&&(e.peek(),i=-1),n=i*Number(Ca(e)),pi[e.charCode()]!==0&&(n+=Cn(e))),e.eat(rs),{type:"Range",min:t,max:n}}function qh(e){let t,n=null;return e.eat(us),t=Cn(e),e.charCode()===b0&&e.nextCharCode()===Bh&&(e.pos+=2,t+="()"),e.charCodeAt(e.findWsEnd(e.pos))===ka&&(Ta(e),n=jh(e)),e.eat(E0),kn(e,{type:"Type",name:t,opts:n})}function zh(e){let t=Cn(e);return e.charCode()===b0?(e.pos++,{type:"Function",name:t}):kn(e,{type:"Keyword",name:t})}function Yh(e,t){function n(a,o){return{type:"Group",terms:a,combinator:o,disallowEmpty:!1,explicit:!1}}let i;for(t=Object.keys(t).sort((a,o)=>m0[a]-m0[o]);t.length>0;){i=t.shift();let a=0,o=0;for(;a1&&(e.splice(o,a-o,n(e.slice(o,a),i)),a=o+1),o=-1))}o!==-1&&t.length&&e.splice(o,a-o,n(e.slice(o,a),i))}return i}function x0(e){let t=[],n={},i,a=null,o=e.pos;for(;i=Wh(e);)i.type!=="Spaces"&&(i.type==="Combinator"?((a===null||a.type==="Combinator")&&(e.pos=o,e.error("Unexpected combinator")),n[i.value]=!0):a!==null&&a.type!=="Combinator"&&(n[" "]=!0,t.push({type:"Combinator",value:" "})),t.push(i),a=i,o=e.pos);return a!==null&&a.type==="Combinator"&&(e.pos-=o,e.error("Unexpected combinator")),{type:"Group",terms:t,combinator:Yh(t,n)||" ",disallowEmpty:!1,explicit:!1}}function Vh(e){let t;return e.eat(ka),t=x0(e),e.eat(rs),t.explicit=!0,e.charCode()===h0&&(e.pos++,t.disallowEmpty=!0),t}function Wh(e){let t=e.charCode();if(t<128&&pi[t]===1)return zh(e);switch(t){case rs:break;case ka:return kn(e,Vh(e));case us:return e.nextCharCode()===va?Hh(e):qh(e);case l0:return{type:"Combinator",value:e.substringToPos(e.pos+(e.nextCharCode()===l0?2:1))};case r0:return e.pos++,e.eat(r0),{type:"Combinator",value:"&&"};case ss:return e.pos++,{type:"Comma"};case va:return kn(e,{type:"String",value:Mh(e)});case Oh:case Nh:case Lh:case Rh:case Ph:return{type:"Spaces",value:Ta(e)};case Fh:return t=e.nextCharCode(),t<128&&pi[t]===1?(e.pos++,{type:"AtKeyword",name:Cn(e)}):ns(e);case g0:case os:case is:case as:case h0:break;case Aa:if(t=e.nextCharCode(),t<48||t>57)return ns(e);break;default:return ns(e)}}function mi(e){let t=new xa(e),n=x0(t);return t.pos!==e.length&&t.error("Unexpected input"),n.terms.length===1&&n.terms[0].type==="Group"?n.terms[0]:n}var fi=function(){};function v0(e){return typeof e=="function"?e:fi}function cs(e,t,n){function i(s){switch(a.call(n,s),s.type){case"Group":s.terms.forEach(i);break;case"Multiplier":i(s.term);break;case"Type":case"Property":case"Keyword":case"AtKeyword":case"Function":case"String":case"Token":case"Comma":break;default:throw new Error("Unknown type: "+s.type)}o.call(n,s)}let a=fi,o=fi;if(typeof t=="function"?a=t:t&&(a=v0(t.enter),o=v0(t.leave)),a===fi&&o===fi)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");i(e,n)}var Gh={decorator(e){let t=[],n=null;return{...e,node(i){let a=n;n=i,e.node.call(this,i),n=a},emit(i,a,o){t.push({type:a,value:i,node:o?null:n})},result(){return t}}}};function Qh(e){let t=[];return Ut(e,(n,i,a)=>t.push({type:n,value:e.slice(i,a),node:null})),t}function A0(e,t){return typeof e=="string"?Qh(e):t.generate(e,Gh)}var ie={type:"Match"},re={type:"Mismatch"},ya={type:"DisallowEmpty"},Kh=40,Jh=41;function Ye(e,t,n){return t===ie&&n===re||e===ie&&t===ie&&n===ie?e:(e.type==="If"&&e.else===re&&t===ie&&(t=e.then,e=e.match),{type:"If",match:e,then:t,else:n})}function C0(e){return e.length>2&&e.charCodeAt(e.length-2)===Kh&&e.charCodeAt(e.length-1)===Jh}function T0(e){return e.type==="Keyword"||e.type==="AtKeyword"||e.type==="Function"||e.type==="Type"&&C0(e.name)}function ls(e,t,n){switch(e){case" ":{let i=ie;for(let a=t.length-1;a>=0;a--){let o=t[a];i=Ye(o,i,re)}return i}case"|":{let i=re,a=null;for(let o=t.length-1;o>=0;o--){let s=t[o];if(T0(s)&&(a===null&&o>0&&T0(t[o-1])&&(a=Object.create(null),i=Ye({type:"Enum",map:a},ie,i)),a!==null)){let r=(C0(s.name)?s.name.slice(0,-1):s.name).toLowerCase();if(!(r in a)){a[r]=s;continue}}a=null,i=Ye(s,ie,i)}return i}case"&&":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!0};let i=re;for(let a=t.length-1;a>=0;a--){let o=t[a],s;t.length>1?s=ls(e,t.filter(function(r){return r!==o}),!1):s=ie,i=Ye(o,s,i)}return i}case"||":{if(t.length>5)return{type:"MatchOnce",terms:t,all:!1};let i=n?ie:re;for(let a=t.length-1;a>=0;a--){let o=t[a],s;t.length>1?s=ls(e,t.filter(function(r){return r!==o}),!0):s=ie,i=Ye(o,s,i)}return i}}}function Zh(e){let t=ie,n=ds(e.term);if(e.max===0)n=Ye(n,ya,re),t=Ye(n,null,re),t.then=Ye(ie,ie,t),e.comma&&(t.then.else=Ye({type:"Comma",syntax:e},t,re));else for(let i=e.min||1;i<=e.max;i++)e.comma&&t!==ie&&(t=Ye({type:"Comma",syntax:e},t,re)),t=Ye(n,Ye(ie,ie,t),re);if(e.min===0)t=Ye(ie,ie,t);else for(let i=0;i=65&&a<=90&&(a=a|32),a!==i)return!1}return!0}function ob(e){return e.type!==9?!1:e.value!=="?"}function S0(e){return e===null?!0:e.type===18||e.type===2||e.type===21||e.type===19||e.type===23||ob(e)}function _0(e){return e===null?!0:e.type===22||e.type===20||e.type===24||e.type===9&&e.value==="/"}function sb(e,t,n){function i(){do B++,I=Bne&&(ne=B)}function l(){h={syntax:t.syntax,opts:t.syntax.opts||h!==null&&h.opts||null,prev:h},R={type:ms,syntax:t.syntax,token:R.token,prev:R}}function d(){R.type===ms?R=R.prev:R={type:w0,syntax:h.syntax,token:R.token,prev:R},h=h.prev}let h=null,m=null,x=null,k=null,S=0,P=null,I=null,B=-1,ne=0,R={type:$h,syntax:null,token:null,prev:null};for(i();P===null&&++Sx.tokenIndex)&&(x=k,k=!1);else if(x===null){P=tb;break}t=x.nextState,m=x.thenStack,h=x.syntaxStack,R=x.matchStack,B=x.tokenIndex,I=BB){for(;B":"<'"+t.name+"'>"));if(k!==!1&&I!==null&&t.type==="Type"&&(t.name==="custom-ident"&&I.type===1||t.name==="length"&&I.value==="0")){k===null&&(k=o(t,x)),t=re;break}l(),t=F.match;break}case"Keyword":{let oe=t.name;if(I!==null){let F=I.value;if(F.indexOf("\\")!==-1&&(F=F.replace(/\\[09].*$/,"")),ps(F,oe)){c(),t=ie;break}}t=re;break}case"AtKeyword":case"Function":if(I!==null&&ps(I.value,t.name)){c(),t=ie;break}t=re;break;case"Token":if(I!==null&&I.value===t.value){c(),t=ie;break}t=re;break;case"Comma":I!==null&&I.type===18?S0(R.token)?t=re:(c(),t=_0(I)?re:ie):t=S0(R.token)||_0(I)?ie:re;break;case"String":let X="",D=B;for(;DI0,isKeyword:()=>cb,isProperty:()=>rb,isType:()=>ub});function I0(e){function t(a){return a===null?!1:a.type==="Type"||a.type==="Property"||a.type==="Keyword"}function n(a){if(Array.isArray(a.match)){for(let o=0;on.type==="Type"&&n.name===t)}function rb(e,t){return hs(this,e,n=>n.type==="Property"&&n.name===t)}function cb(e){return hs(this,e,t=>t.type==="Keyword")}function hs(e,t,n){let i=I0.call(e,t);return i===null?!1:i.some(n)}function N0(e){return"node"in e?e.node:N0(e.match[0])}function L0(e){return"node"in e?e.node:L0(e.match[e.match.length-1])}function gs(e,t,n,i,a){function o(r){if(r.syntax!==null&&r.syntax.type===i&&r.syntax.name===a){let c=N0(r),l=L0(r);e.syntax.walk(t,function(d,h,m){if(d===c){let x=new Ge;do{if(x.appendData(h.data),h.data===l)break;h=h.next}while(h!==null);s.push({parent:m,nodes:x})}})}Array.isArray(r.match)&&r.match.forEach(o)}let s=[];return n.matched!==null&&o(n.matched),s}var{hasOwnProperty:hi}=Object.prototype;function Es(e){return typeof e=="number"&&isFinite(e)&&Math.floor(e)===e&&e>=0}function P0(e){return!!e&&Es(e.offset)&&Es(e.line)&&Es(e.column)}function lb(e,t){return function(i,a){if(!i||i.constructor!==Object)return a(i,"Type of node should be an Object");for(let o in i){let s=!0;if(hi.call(i,o)!==!1){if(o==="type")i.type!==e&&a(i,"Wrong node type `"+i.type+"`, expected `"+e+"`");else if(o==="loc"){if(i.loc===null)continue;if(i.loc&&i.loc.constructor===Object)if(typeof i.loc.source!="string")o+=".source";else if(!P0(i.loc.start))o+=".start";else if(!P0(i.loc.end))o+=".end";else continue;s=!1}else if(t.hasOwnProperty(o)){s=!1;for(let r=0;!s&&r");else if(Array.isArray(l))s.push("List");else throw new Error("Wrong value `"+l+"` in `"+e+"."+o+"` structure definition")}a[o]=s.join(" | ")}return{docs:a,check:lb(e,i)}}function R0(e){let t={};if(e.node){for(let n in e.node)if(hi.call(e.node,n)){let i=e.node[n];if(i.structure)t[n]=db(n,i);else throw new Error("Missed `structure` field in `"+n+"` node type definition")}}return t}var pb=Da(ha.join(" | "));function xs(e,t,n){let i={};for(let a in e)e[a].syntax&&(i[a]=n?e[a].syntax:xn(e[a].syntax,{compact:t}));return i}function mb(e,t,n){let i={};for(let[a,o]of Object.entries(e))i[a]={prelude:o.prelude&&(n?o.prelude.syntax:xn(o.prelude.syntax,{compact:t})),descriptors:o.descriptors&&xs(o.descriptors,t,n)};return i}function fb(e){for(let t=0;t(i[a]=this.createDescriptor(n.descriptors[a],"AtruleDescriptor",a,t),i),Object.create(null)):null})}addProperty_(t,n){n&&(this.properties[t]=this.createDescriptor(n,"Property",t))}addType_(t,n){n&&(this.types[t]=this.createDescriptor(n,"Type",t))}checkAtruleName(t){if(!this.getAtrule(t))return new vn("Unknown at-rule","@"+t)}checkAtrulePrelude(t,n){let i=this.checkAtruleName(t);if(i)return i;let a=this.getAtrule(t);if(!a.prelude&&n)return new SyntaxError("At-rule `@"+t+"` should not contain a prelude");if(a.prelude&&!n&&!yn(this,a.prelude,"",!1).matched)return new SyntaxError("At-rule `@"+t+"` should contain a prelude")}checkAtruleDescriptorName(t,n){let i=this.checkAtruleName(t);if(i)return i;let a=this.getAtrule(t),o=ma(n);if(!a.descriptors)return new SyntaxError("At-rule `@"+t+"` has no known descriptors");if(!a.descriptors[o.name]&&!a.descriptors[o.basename])return new vn("Unknown at-rule descriptor",n)}checkPropertyName(t){if(!this.getProperty(t))return new vn("Unknown property",t)}matchAtrulePrelude(t,n){let i=this.checkAtrulePrelude(t,n);if(i)return mt(null,i);let a=this.getAtrule(t);return a.prelude?yn(this,a.prelude,n||"",!1):mt(null,null)}matchAtruleDescriptor(t,n,i){let a=this.checkAtruleDescriptorName(t,n);if(a)return mt(null,a);let o=this.getAtrule(t),s=ma(n);return yn(this,o.descriptors[s.name]||o.descriptors[s.basename],i,!1)}matchDeclaration(t){return t.type!=="Declaration"?mt(null,new Error("Not a Declaration node")):this.matchProperty(t.property,t.value)}matchProperty(t,n){if(Xo(t).custom)return mt(null,new Error("Lexer matching doesn't applicable for custom properties"));let i=this.checkPropertyName(t);return i?mt(null,i):yn(this,this.getProperty(t),n,!0)}matchType(t,n){let i=this.getType(t);return i?yn(this,i,n,!1):mt(null,new vn("Unknown type",t))}match(t,n){return typeof t!="string"&&(!t||!t.type)?mt(null,new vn("Bad syntax")):((typeof t=="string"||!t.match)&&(t=this.createDescriptor(t,"Type","anonymous")),yn(this,t,n,!1))}findValueFragments(t,n,i,a){return gs(this,n,this.matchProperty(t,n),i,a)}findDeclarationValueFragments(t,n,i){return gs(this,t.value,this.matchDeclaration(t),n,i)}findAllFragments(t,n,i){let a=[];return this.syntax.walk(t,{visit:"Declaration",enter:o=>{a.push.apply(a,this.findDeclarationValueFragments(o,n,i))}}),a}getAtrule(t,n=!0){let i=ma(t);return(i.vendor&&n?this.atrules[i.name]||this.atrules[i.basename]:this.atrules[i.name])||null}getAtrulePrelude(t,n=!0){let i=this.getAtrule(t,n);return i&&i.prelude||null}getAtruleDescriptor(t,n){return this.atrules.hasOwnProperty(t)&&this.atrules.declarators&&this.atrules[t].declarators[n]||null}getProperty(t,n=!0){let i=Xo(t);return(i.vendor&&n?this.properties[i.name]||this.properties[i.basename]:this.properties[i.name])||null}getType(t){return hasOwnProperty.call(this.types,t)?this.types[t]:null}validate(){function t(a,o,s,r){if(s.has(o))return s.get(o);s.set(o,!1),r.syntax!==null&&cs(r.syntax,function(c){if(c.type!=="Type"&&c.type!=="Property")return;let l=c.type==="Type"?a.types:a.properties,d=c.type==="Type"?n:i;(!hasOwnProperty.call(l,c.name)||t(a,c.name,d,l[c.name]))&&s.set(o,!0)},this)}let n=new Map,i=new Map;for(let a in this.types)t(this,a,n,this.types[a]);for(let a in this.properties)t(this,a,i,this.properties[a]);return n=[...n.keys()].filter(a=>n.get(a)),i=[...i.keys()].filter(a=>i.get(a)),n.length||i.length?{types:n,properties:i}:null}dump(t,n){return{generic:this.generic,units:this.units,types:xs(this.types,!n,t),properties:xs(this.properties,!n,t),atrules:mb(this.atrules,!n,t)}}toString(){return JSON.stringify(this.dump())}};function vs(e,t){return typeof t=="string"&&/^\s*\|/.test(t)?typeof e=="string"?e+t:t.replace(/^\s*\|\s*/,""):t||null}function O0(e,t){let n=Object.create(null);for(let[i,a]of Object.entries(e))if(a){n[i]={};for(let o of Object.keys(a))t.includes(o)&&(n[i][o]=a[o])}return n}function bi(e,t){let n={...e};for(let[i,a]of Object.entries(t))switch(i){case"generic":n[i]=!!a;break;case"units":n[i]={...e[i]};for(let[o,s]of Object.entries(a))n[i][o]=Array.isArray(s)?s:[];break;case"atrules":n[i]={...e[i]};for(let[o,s]of Object.entries(a)){let r=n[i][o]||{},c=n[i][o]={prelude:r.prelude||null,descriptors:{...r.descriptors}};if(s){c.prelude=s.prelude?vs(c.prelude,s.prelude):c.prelude||null;for(let[l,d]of Object.entries(s.descriptors||{}))c.descriptors[l]=d?vs(c.descriptors[l],d):null;Object.keys(c.descriptors).length||(c.descriptors=null)}}break;case"types":case"properties":n[i]={...e[i]};for(let[o,s]of Object.entries(a))n[i][o]=vs(n[i][o],s);break;case"scope":n[i]={...e[i]};for(let[o,s]of Object.entries(a))n[i][o]={...n[i][o],...s};break;case"parseContext":n[i]={...e[i],...a};break;case"atrule":case"pseudo":n[i]={...e[i],...O0(a,["parse"])};break;case"node":n[i]={...e[i],...O0(a,["name","structure","parse","generate","walkContext"])};break}return n}function B0(e){let t=vl(e),n=Jl(e),i=Vl(e),{fromPlainObject:a,toPlainObject:o}=Wl(n),s={lexer:null,createLexer:r=>new Dn(r,s,s.lexer.structure),tokenize:Ut,parse:t,generate:i,walk:n,find:n.find,findLast:n.findLast,findAll:n.findAll,fromPlainObject:a,toPlainObject:o,fork(r){let c=bi({},e);return B0(typeof r=="function"?r(c,Object.assign):bi(c,r))}};return s.lexer=new Dn({generic:!0,units:e.units,types:e.types,atrules:e.atrules,properties:e.properties,node:e.node},s),s}var As=e=>B0(bi({},e));var F0={generic:!0,units:{angle:["deg","grad","rad","turn"],decibel:["db"],flex:["fr"],frequency:["hz","khz"],length:["cm","mm","q","in","pt","pc","px","em","rem","ex","rex","cap","rcap","ch","rch","ic","ric","lh","rlh","vw","svw","lvw","dvw","vh","svh","lvh","dvh","vi","svi","lvi","dvi","vb","svb","lvb","dvb","vmin","svmin","lvmin","dvmin","vmax","svmax","lvmax","dvmax","cqw","cqh","cqi","cqb","cqmin","cqmax"],resolution:["dpi","dpcm","dppx","x"],semitones:["st"],time:["s","ms"]},types:{"abs()":"abs( )","absolute-size":"xx-small|x-small|small|medium|large|x-large|xx-large|xxx-large","acos()":"acos( )","alpha-value":"|","angle-percentage":"|","angular-color-hint":"","angular-color-stop":"&&?","angular-color-stop-list":"[ [, ]?]# , ","animateable-feature":"scroll-position|contents|","asin()":"asin( )","atan()":"atan( )","atan2()":"atan2( , )",attachment:"scroll|fixed|local","attr()":"attr( ? [, ]? )","attr-matcher":"['~'|'|'|'^'|'$'|'*']? '='","attr-modifier":"i|s","attribute-selector":"'[' ']'|'[' [|] ? ']'","auto-repeat":"repeat( [auto-fill|auto-fit] , [? ]+ ? )","auto-track-list":"[? [|]]* ? [? [|]]* ?",axis:"block|inline|vertical|horizontal","baseline-position":"[first|last]? baseline","basic-shape":"||||","bg-image":"none|","bg-layer":"|| [/ ]?||||||||","bg-position":"[[left|center|right|top|bottom|]|[left|center|right|] [top|center|bottom|]|[center|[left|right] ?]&&[center|[top|bottom] ?]]","bg-size":"[|auto]{1,2}|cover|contain","blur()":"blur( )","blend-mode":"normal|multiply|screen|overlay|darken|lighten|color-dodge|color-burn|hard-light|soft-light|difference|exclusion|hue|saturation|color|luminosity",box:"border-box|padding-box|content-box","brightness()":"brightness( )","calc()":"calc( )","calc-sum":" [['+'|'-'] ]*","calc-product":" ['*' |'/' ]*","calc-value":"||||( )","calc-constant":"e|pi|infinity|-infinity|NaN","cf-final-image":"|","cf-mixing-image":"?&&","circle()":"circle( []? [at ]? )","clamp()":"clamp( #{3} )","class-selector":"'.' ","clip-source":"",color:"|||||||||currentcolor|","color-stop":"|","color-stop-angle":"{1,2}","color-stop-length":"{1,2}","color-stop-list":"[ [, ]?]# , ",combinator:"'>'|'+'|'~'|['||']","common-lig-values":"[common-ligatures|no-common-ligatures]","compat-auto":"searchfield|textarea|push-button|slider-horizontal|checkbox|radio|square-button|menulist|listbox|meter|progress-bar|button","composite-style":"clear|copy|source-over|source-in|source-out|source-atop|destination-over|destination-in|destination-out|destination-atop|xor","compositing-operator":"add|subtract|intersect|exclude","compound-selector":"[? * [ *]*]!","compound-selector-list":"#","complex-selector":" [? ]*","complex-selector-list":"#","conic-gradient()":"conic-gradient( [from ]? [at ]? , )","contextual-alt-values":"[contextual|no-contextual]","content-distribution":"space-between|space-around|space-evenly|stretch","content-list":"[|contents||||||]+","content-position":"center|start|end|flex-start|flex-end","content-replacement":"","contrast()":"contrast( [] )","cos()":"cos( )",counter:"|","counter()":"counter( , ? )","counter-name":"","counter-style":"|symbols( )","counter-style-name":"","counters()":"counters( , , ? )","cross-fade()":"cross-fade( , ? )","cubic-bezier-timing-function":"ease|ease-in|ease-out|ease-in-out|cubic-bezier( , , , )","deprecated-system-color":"ActiveBorder|ActiveCaption|AppWorkspace|Background|ButtonFace|ButtonHighlight|ButtonShadow|ButtonText|CaptionText|GrayText|Highlight|HighlightText|InactiveBorder|InactiveCaption|InactiveCaptionText|InfoBackground|InfoText|Menu|MenuText|Scrollbar|ThreeDDarkShadow|ThreeDFace|ThreeDHighlight|ThreeDLightShadow|ThreeDShadow|Window|WindowFrame|WindowText","discretionary-lig-values":"[discretionary-ligatures|no-discretionary-ligatures]","display-box":"contents|none","display-inside":"flow|flow-root|table|flex|grid|ruby","display-internal":"table-row-group|table-header-group|table-footer-group|table-row|table-cell|table-column-group|table-column|table-caption|ruby-base|ruby-text|ruby-base-container|ruby-text-container","display-legacy":"inline-block|inline-list-item|inline-table|inline-flex|inline-grid","display-listitem":"?&&[flow|flow-root]?&&list-item","display-outside":"block|inline|run-in","drop-shadow()":"drop-shadow( {2,3} ? )","east-asian-variant-values":"[jis78|jis83|jis90|jis04|simplified|traditional]","east-asian-width-values":"[full-width|proportional-width]","element()":"element( , [first|start|last|first-except]? )|element( )","ellipse()":"ellipse( [{2}]? [at ]? )","ending-shape":"circle|ellipse","env()":"env( , ? )","exp()":"exp( )","explicit-track-list":"[? ]+ ?","family-name":"|+","feature-tag-value":" [|on|off]?","feature-type":"@stylistic|@historical-forms|@styleset|@character-variant|@swash|@ornaments|@annotation","feature-value-block":" '{' '}'","feature-value-block-list":"+","feature-value-declaration":" : + ;","feature-value-declaration-list":"","feature-value-name":"","fill-rule":"nonzero|evenodd","filter-function":"|||||||||","filter-function-list":"[|]+","final-bg-layer":"<'background-color'>|||| [/ ]?||||||||","fixed-breadth":"","fixed-repeat":"repeat( [] , [? ]+ ? )","fixed-size":"|minmax( , )|minmax( , )","font-stretch-absolute":"normal|ultra-condensed|extra-condensed|condensed|semi-condensed|semi-expanded|expanded|extra-expanded|ultra-expanded|","font-variant-css21":"[normal|small-caps]","font-weight-absolute":"normal|bold|","frequency-percentage":"|","general-enclosed":"[ )]|( )","generic-family":"serif|sans-serif|cursive|fantasy|monospace|-apple-system","generic-name":"serif|sans-serif|cursive|fantasy|monospace","geometry-box":"|fill-box|stroke-box|view-box",gradient:"||||||<-legacy-gradient>","grayscale()":"grayscale( )","grid-line":"auto||[&&?]|[span&&[||]]","historical-lig-values":"[historical-ligatures|no-historical-ligatures]","hsl()":"hsl( [/ ]? )|hsl( , , , ? )","hsla()":"hsla( [/ ]? )|hsla( , , , ? )",hue:"|","hue-rotate()":"hue-rotate( )","hwb()":"hwb( [|none] [|none] [|none] [/ [|none]]? )","hypot()":"hypot( # )",image:"||||||","image()":"image( ? [? , ?]! )","image-set()":"image-set( # )","image-set-option":"[|] [||type( )]","image-src":"|","image-tags":"ltr|rtl","inflexible-breadth":"|min-content|max-content|auto","inset()":"inset( {1,4} [round <'border-radius'>]? )","invert()":"invert( )","keyframes-name":"|","keyframe-block":"# { }","keyframe-block-list":"+","keyframe-selector":"from|to|","lab()":"lab( [||none] [||none] [||none] [/ [|none]]? )","layer()":"layer( )","layer-name":" ['.' ]*","lch()":"lch( [||none] [||none] [|none] [/ [|none]]? )","leader()":"leader( )","leader-type":"dotted|solid|space|","length-percentage":"|","line-names":"'[' * ']'","line-name-list":"[|]+","line-style":"none|hidden|dotted|dashed|solid|double|groove|ridge|inset|outset","line-width":"|thin|medium|thick","linear-color-hint":"","linear-color-stop":" ?","linear-gradient()":"linear-gradient( [|to ]? , )","log()":"log( , ? )","mask-layer":"|| [/ ]?||||||[|no-clip]||||","mask-position":"[|left|center|right] [|top|center|bottom]?","mask-reference":"none||","mask-source":"","masking-mode":"alpha|luminance|match-source","matrix()":"matrix( #{6} )","matrix3d()":"matrix3d( #{16} )","max()":"max( # )","media-and":" [and ]+","media-condition":"|||","media-condition-without-or":"||","media-feature":"( [||] )","media-in-parens":"( )||","media-not":"not ","media-or":" [or ]+","media-query":"|[not|only]? [and ]?","media-query-list":"#","media-type":"","mf-boolean":"","mf-name":"","mf-plain":" : ","mf-range":" ['<'|'>']? '='? | ['<'|'>']? '='? | '<' '='? '<' '='? | '>' '='? '>' '='? ","mf-value":"|||","min()":"min( # )","minmax()":"minmax( [|min-content|max-content|auto] , [||min-content|max-content|auto] )","mod()":"mod( , )","name-repeat":"repeat( [|auto-fill] , + )","named-color":"transparent|aliceblue|antiquewhite|aqua|aquamarine|azure|beige|bisque|black|blanchedalmond|blue|blueviolet|brown|burlywood|cadetblue|chartreuse|chocolate|coral|cornflowerblue|cornsilk|crimson|cyan|darkblue|darkcyan|darkgoldenrod|darkgray|darkgreen|darkgrey|darkkhaki|darkmagenta|darkolivegreen|darkorange|darkorchid|darkred|darksalmon|darkseagreen|darkslateblue|darkslategray|darkslategrey|darkturquoise|darkviolet|deeppink|deepskyblue|dimgray|dimgrey|dodgerblue|firebrick|floralwhite|forestgreen|fuchsia|gainsboro|ghostwhite|gold|goldenrod|gray|green|greenyellow|grey|honeydew|hotpink|indianred|indigo|ivory|khaki|lavender|lavenderblush|lawngreen|lemonchiffon|lightblue|lightcoral|lightcyan|lightgoldenrodyellow|lightgray|lightgreen|lightgrey|lightpink|lightsalmon|lightseagreen|lightskyblue|lightslategray|lightslategrey|lightsteelblue|lightyellow|lime|limegreen|linen|magenta|maroon|mediumaquamarine|mediumblue|mediumorchid|mediumpurple|mediumseagreen|mediumslateblue|mediumspringgreen|mediumturquoise|mediumvioletred|midnightblue|mintcream|mistyrose|moccasin|navajowhite|navy|oldlace|olive|olivedrab|orange|orangered|orchid|palegoldenrod|palegreen|paleturquoise|palevioletred|papayawhip|peachpuff|peru|pink|plum|powderblue|purple|rebeccapurple|red|rosybrown|royalblue|saddlebrown|salmon|sandybrown|seagreen|seashell|sienna|silver|skyblue|slateblue|slategray|slategrey|snow|springgreen|steelblue|tan|teal|thistle|tomato|turquoise|violet|wheat|white|whitesmoke|yellow|yellowgreen|<-non-standard-color>","namespace-prefix":"","ns-prefix":"[|'*']? '|'","number-percentage":"|","numeric-figure-values":"[lining-nums|oldstyle-nums]","numeric-fraction-values":"[diagonal-fractions|stacked-fractions]","numeric-spacing-values":"[proportional-nums|tabular-nums]",nth:"|even|odd","opacity()":"opacity( [] )","overflow-position":"unsafe|safe","outline-radius":"|","page-body":"? [; ]?| ","page-margin-box":" '{' '}'","page-margin-box-type":"@top-left-corner|@top-left|@top-center|@top-right|@top-right-corner|@bottom-left-corner|@bottom-left|@bottom-center|@bottom-right|@bottom-right-corner|@left-top|@left-middle|@left-bottom|@right-top|@right-middle|@right-bottom","page-selector-list":"[#]?","page-selector":"+| *","page-size":"A5|A4|A3|B5|B4|JIS-B5|JIS-B4|letter|legal|ledger","path()":"path( [ ,]? )","paint()":"paint( , ? )","perspective()":"perspective( [|none] )","polygon()":"polygon( ? , [ ]# )",position:"[[left|center|right]||[top|center|bottom]|[left|center|right|] [top|center|bottom|]?|[[left|right] ]&&[[top|bottom] ]]","pow()":"pow( , )","pseudo-class-selector":"':' |':' ')'","pseudo-element-selector":"':' ","pseudo-page":": [left|right|first|blank]",quote:"open-quote|close-quote|no-open-quote|no-close-quote","radial-gradient()":"radial-gradient( [||]? [at ]? , )",ratio:" [/ ]?","relative-selector":"? ","relative-selector-list":"#","relative-size":"larger|smaller","rem()":"rem( , )","repeat-style":"repeat-x|repeat-y|[repeat|space|round|no-repeat]{1,2}","repeating-conic-gradient()":"repeating-conic-gradient( [from ]? [at ]? , )","repeating-linear-gradient()":"repeating-linear-gradient( [|to ]? , )","repeating-radial-gradient()":"repeating-radial-gradient( [||]? [at ]? , )","reversed-counter-name":"reversed( )","rgb()":"rgb( {3} [/ ]? )|rgb( {3} [/ ]? )|rgb( #{3} , ? )|rgb( #{3} , ? )","rgba()":"rgba( {3} [/ ]? )|rgba( {3} [/ ]? )|rgba( #{3} , ? )|rgba( #{3} , ? )","rotate()":"rotate( [|] )","rotate3d()":"rotate3d( , , , [|] )","rotateX()":"rotateX( [|] )","rotateY()":"rotateY( [|] )","rotateZ()":"rotateZ( [|] )","round()":"round( ? , , )","rounding-strategy":"nearest|up|down|to-zero","saturate()":"saturate( )","scale()":"scale( [|]#{1,2} )","scale3d()":"scale3d( [|]#{3} )","scaleX()":"scaleX( [|] )","scaleY()":"scaleY( [|] )","scaleZ()":"scaleZ( [|] )",scroller:"root|nearest","self-position":"center|start|end|self-start|self-end|flex-start|flex-end","shape-radius":"|closest-side|farthest-side","sign()":"sign( )","skew()":"skew( [|] , [|]? )","skewX()":"skewX( [|] )","skewY()":"skewY( [|] )","sepia()":"sepia( )",shadow:"inset?&&{2,4}&&?","shadow-t":"[{2,3}&&?]",shape:"rect( , , , )|rect( )","shape-box":"|margin-box","side-or-corner":"[left|right]||[top|bottom]","sin()":"sin( )","single-animation":"