@oddbird/css-anchor-positioning
Version:
Polyfill for the proposed CSS anchor positioning spec
1 lines • 118 kB
JavaScript
(function(G){typeof define=="function"&&define.amd?define(G):G()})((function(){"use strict";var Np=Object.defineProperty,Dp=Object.defineProperties;var Fp=Object.getOwnPropertyDescriptors;var bo=Object.getOwnPropertySymbols;var Mp=Object.prototype.hasOwnProperty,jp=Object.prototype.propertyIsEnumerable;var xo=(G,N,j)=>N in G?Np(G,N,{enumerable:!0,configurable:!0,writable:!0,value:j}):G[N]=j,H=(G,N)=>{for(var j in N||(N={}))Mp.call(N,j)&&xo(G,j,N[j]);if(bo)for(var j of bo(N))jp.call(N,j)&&xo(G,j,N[j]);return G},Y=(G,N)=>Dp(G,Fp(N));var R=(G,N,j)=>new Promise((zt,rt)=>{var Be=ut=>{try{oe(j.next(ut))}catch(ae){rt(ae)}},We=ut=>{try{oe(j.throw(ut))}catch(ae){rt(ae)}},oe=ut=>ut.done?zt(ut.value):Promise.resolve(ut.value).then(Be,We);oe((j=j.apply(G,N)).next())});const G=Math.min,N=Math.max,j=Math.round,zt=Math.floor,rt=t=>({x:t,y:t});function Be(t,e){return typeof t=="function"?t(e):t}function We(t){return H({top:0,right:0,bottom:0,left:0},t)}function oe(t){return typeof t!="number"?We(t):{top:t,right:t,bottom:t,left:t}}function ut(t){const{x:e,y:n,width:s,height:r}=t;return{width:s,height:r,top:n,left:e,right:e+s,bottom:n+r,x:e,y:n}}function ae(t,e){return R(this,null,function*(){var n;e===void 0&&(e={});const{x:s,y:r,platform:o,rects:a,elements:l,strategy:u}=t,{boundary:i="clippingAncestors",rootBoundary:c="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=Be(e,t),g=oe(p),k=l[f?h==="floating"?"reference":"floating":h],S=ut(yield o.getClippingRect({element:(n=yield o.isElement==null?void 0:o.isElement(k))==null||n?k:k.contextElement||(yield o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:i,rootBoundary:c,strategy:u})),x=h==="floating"?{x:s,y:r,width:a.floating.width,height:a.floating.height}:a.reference,T=yield o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating),W=(yield o.isElement==null?void 0:o.isElement(T))?(yield o.getScale==null?void 0:o.getScale(T))||{x:1,y:1}:{x:1,y:1},ct=ut(o.convertOffsetParentRelativeRectToViewportRelativeRect?yield o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:T,strategy:u}):x);return{top:(S.top-ct.top+g.top)/W.y,bottom:(ct.bottom-S.bottom+g.bottom)/W.y,left:(S.left-ct.left+g.left)/W.x,right:(ct.right-S.right+g.right)/W.x}})}function Se(){return typeof window!="undefined"}function Ht(t){return Pn(t)?(t.nodeName||"").toLowerCase():"#document"}function it(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function St(t){var e;return(e=(Pn(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Pn(t){return Se()?t instanceof Node||t instanceof it(t).Node:!1}function ft(t){return Se()?t instanceof Element||t instanceof it(t).Element:!1}function yt(t){return Se()?t instanceof HTMLElement||t instanceof it(t).HTMLElement:!1}function Rn(t){return!Se()||typeof ShadowRoot=="undefined"?!1:t instanceof ShadowRoot||t instanceof it(t).ShadowRoot}const Co=new Set(["inline","contents"]);function le(t){const{overflow:e,overflowX:n,overflowY:s,display:r}=pt(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!Co.has(r)}const wo=new Set(["table","td","th"]);function Ao(t){return wo.has(Ht(t))}const To=[":popover-open",":modal"];function ye(t){return To.some(e=>{try{return t.matches(e)}catch(n){return!1}})}const vo=["transform","translate","scale","rotate","perspective"],Eo=["transform","translate","scale","rotate","perspective","filter"],$o=["paint","layout","strict","content"];function Ue(t){const e=ze(),n=ft(t)?pt(t):t;return vo.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||Eo.some(s=>(n.willChange||"").includes(s))||$o.some(s=>(n.contain||"").includes(s))}function Oo(t){let e=Ot(t);for(;yt(e)&&!Vt(e);){if(Ue(e))return e;if(ye(e))return null;e=Ot(e)}return null}function ze(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Lo=new Set(["html","body","#document"]);function Vt(t){return Lo.has(Ht(t))}function pt(t){return it(t).getComputedStyle(t)}function be(t){return ft(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Ot(t){if(Ht(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Rn(t)&&t.host||St(t);return Rn(e)?e.host:e}function In(t){const e=Ot(t);return Vt(e)?t.ownerDocument?t.ownerDocument.body:t.body:yt(e)&&le(e)?e:In(e)}function ce(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=In(t),o=r===((s=t.ownerDocument)==null?void 0:s.body),a=it(r);if(o){const l=He(a);return e.concat(a,a.visualViewport||[],le(r)?r:[],l&&n?ce(l):[])}return e.concat(r,ce(r,[],n))}function He(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _n(t){const e=pt(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const r=yt(t),o=r?t.offsetWidth:n,a=r?t.offsetHeight:s,l=j(n)!==o||j(s)!==a;return l&&(n=o,s=a),{width:n,height:s,$:l}}function Ve(t){return ft(t)?t:t.contextElement}function Gt(t){const e=Ve(t);if(!yt(e))return rt(1);const n=e.getBoundingClientRect(),{width:s,height:r,$:o}=_n(e);let a=(o?j(n.width):n.width)/s,l=(o?j(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Po=rt(0);function Nn(t){const e=it(t);return!ze()||!e.visualViewport?Po:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Ro(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==it(t)?!1:e}function Nt(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),o=Ve(t);let a=rt(1);e&&(s?ft(s)&&(a=Gt(s)):a=Gt(t));const l=Ro(o,n,s)?Nn(o):rt(0);let u=(r.left+l.x)/a.x,i=(r.top+l.y)/a.y,c=r.width/a.x,h=r.height/a.y;if(o){const f=it(o),p=s&&ft(s)?it(s):s;let g=f,m=He(g);for(;m&&s&&p!==g;){const k=Gt(m),S=m.getBoundingClientRect(),x=pt(m),T=S.left+(m.clientLeft+parseFloat(x.paddingLeft))*k.x,W=S.top+(m.clientTop+parseFloat(x.paddingTop))*k.y;u*=k.x,i*=k.y,c*=k.x,h*=k.y,u+=T,i+=W,g=it(m),m=He(g)}}return ut({width:c,height:h,x:u,y:i})}function xe(t,e){const n=be(t).scrollLeft;return e?e.left+n:Nt(St(t)).left+n}function Dn(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-xe(t,n),r=n.top+e.scrollTop;return{x:s,y:r}}function Io(t){let{elements:e,rect:n,offsetParent:s,strategy:r}=t;const o=r==="fixed",a=St(s),l=e?ye(e.floating):!1;if(s===a||l&&o)return n;let u={scrollLeft:0,scrollTop:0},i=rt(1);const c=rt(0),h=yt(s);if((h||!h&&!o)&&((Ht(s)!=="body"||le(a))&&(u=be(s)),yt(s))){const p=Nt(s);i=Gt(s),c.x=p.x+s.clientLeft,c.y=p.y+s.clientTop}const f=a&&!h&&!o?Dn(a,u):rt(0);return{width:n.width*i.x,height:n.height*i.y,x:n.x*i.x-u.scrollLeft*i.x+c.x+f.x,y:n.y*i.y-u.scrollTop*i.y+c.y+f.y}}function _o(t){return Array.from(t.getClientRects())}function No(t){const e=St(t),n=be(t),s=t.ownerDocument.body,r=N(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=N(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+xe(t);const l=-n.scrollTop;return pt(s).direction==="rtl"&&(a+=N(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:a,y:l}}const Fn=25;function Do(t,e){const n=it(t),s=St(t),r=n.visualViewport;let o=s.clientWidth,a=s.clientHeight,l=0,u=0;if(r){o=r.width,a=r.height;const c=ze();(!c||c&&e==="fixed")&&(l=r.offsetLeft,u=r.offsetTop)}const i=xe(s);if(i<=0){const c=s.ownerDocument,h=c.body,f=getComputedStyle(h),p=c.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(s.clientWidth-h.clientWidth-p);g<=Fn&&(o-=g)}else i<=Fn&&(o+=i);return{width:o,height:a,x:l,y:u}}const Fo=new Set(["absolute","fixed"]);function Mo(t,e){const n=Nt(t,!0,e==="fixed"),s=n.top+t.clientTop,r=n.left+t.clientLeft,o=yt(t)?Gt(t):rt(1),a=t.clientWidth*o.x,l=t.clientHeight*o.y,u=r*o.x,i=s*o.y;return{width:a,height:l,x:u,y:i}}function Mn(t,e,n){let s;if(e==="viewport")s=Do(t,n);else if(e==="document")s=No(St(t));else if(ft(e))s=Mo(e,n);else{const r=Nn(t);s={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return ut(s)}function jn(t,e){const n=Ot(t);return n===e||!ft(n)||Vt(n)?!1:pt(n).position==="fixed"||jn(n,e)}function jo(t,e){const n=e.get(t);if(n)return n;let s=ce(t,[],!1).filter(l=>ft(l)&&Ht(l)!=="body"),r=null;const o=pt(t).position==="fixed";let a=o?Ot(t):t;for(;ft(a)&&!Vt(a);){const l=pt(a),u=Ue(a);!u&&l.position==="fixed"&&(r=null),(o?!u&&!r:!u&&l.position==="static"&&!!r&&Fo.has(r.position)||le(a)&&!u&&jn(t,a))?s=s.filter(c=>c!==a):r=l,a=Ot(a)}return e.set(t,s),s}function Bo(t){let{element:e,boundary:n,rootBoundary:s,strategy:r}=t;const a=[...n==="clippingAncestors"?ye(e)?[]:jo(e,this._c):[].concat(n),s],l=a[0],u=a.reduce((i,c)=>{const h=Mn(e,c,r);return i.top=N(h.top,i.top),i.right=G(h.right,i.right),i.bottom=G(h.bottom,i.bottom),i.left=N(h.left,i.left),i},Mn(e,l,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Wo(t){const{width:e,height:n}=_n(t);return{width:e,height:n}}function Uo(t,e,n){const s=yt(e),r=St(e),o=n==="fixed",a=Nt(t,!0,o,e);let l={scrollLeft:0,scrollTop:0};const u=rt(0);function i(){u.x=xe(r)}if(s||!s&&!o)if((Ht(e)!=="body"||le(r))&&(l=be(e)),s){const p=Nt(e,!0,o,e);u.x=p.x+e.clientLeft,u.y=p.y+e.clientTop}else r&&i();o&&!s&&r&&i();const c=r&&!s&&!o?Dn(r,l):rt(0),h=a.left+l.scrollLeft-u.x-c.x,f=a.top+l.scrollTop-u.y-c.y;return{x:h,y:f,width:a.width,height:a.height}}function Ge(t){return pt(t).position==="static"}function Bn(t,e){if(!yt(t)||pt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return St(t)===n&&(n=n.ownerDocument.body),n}function Wn(t,e){const n=it(t);if(ye(t))return n;if(!yt(t)){let r=Ot(t);for(;r&&!Vt(r);){if(ft(r)&&!Ge(r))return r;r=Ot(r)}return n}let s=Bn(t,e);for(;s&&Ao(s)&&Ge(s);)s=Bn(s,e);return s&&Vt(s)&&Ge(s)&&!Ue(s)?n:s||Oo(t)||n}const zo=function(t){return R(this,null,function*(){const e=this.getOffsetParent||Wn,n=this.getDimensions,s=yield n(t.floating);return{reference:Uo(t.reference,yield e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}})};function Ho(t){return pt(t).direction==="rtl"}const q={convertOffsetParentRelativeRectToViewportRelativeRect:Io,getDocumentElement:St,getClippingRect:Bo,getOffsetParent:Wn,getElementRects:zo,getClientRects:_o,getDimensions:Wo,getScale:Gt,isElement:ft,isRTL:Ho};function Un(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Vo(t,e){let n=null,s;const r=St(t);function o(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),o();const i=t.getBoundingClientRect(),{left:c,top:h,width:f,height:p}=i;if(l||e(),!f||!p)return;const g=zt(h),m=zt(r.clientWidth-(c+f)),k=zt(r.clientHeight-(h+p)),S=zt(c),T={rootMargin:-g+"px "+-m+"px "+-k+"px "+-S+"px",threshold:N(0,G(1,u))||1};let W=!0;function ct(w){const C=w[0].intersectionRatio;if(C!==u){if(!W)return a();C?a(!1,C):s=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!Un(i,t.getBoundingClientRect())&&a(),W=!1}try{n=new IntersectionObserver(ct,Y(H({},T),{root:r.ownerDocument}))}catch(w){n=new IntersectionObserver(ct,T)}n.observe(t)}return a(!0),o}function qe(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,i=Ve(t),c=r||o?[...i?ce(i):[],...ce(e)]:[];c.forEach(S=>{r&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});const h=i&&l?Vo(i,n):null;let f=-1,p=null;a&&(p=new ResizeObserver(S=>{let[x]=S;x&&x.target===i&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var T;(T=p)==null||T.observe(e)})),n()}),i&&!u&&p.observe(i),p.observe(e));let g,m=u?Nt(t):null;u&&k();function k(){const S=Nt(t);m&&!Un(m,S)&&n(),m=S,g=requestAnimationFrame(k)}return n(),()=>{var S;c.forEach(x=>{r&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),h==null||h(),(S=p)==null||S.disconnect(),p=null,u&&cancelAnimationFrame(g)}}const Go=ae;let qt=null;class K{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return K.createItem(e)}allocateCursor(e,n){let s;return qt!==null?(s=qt,qt=qt.cursor,s.prev=e,s.next=n,s.cursor=this.cursor):s={prev:e,next:n,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=qt,qt=e}updateCursors(e,n,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=n),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let n=this.head;n!==null;n=n.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let n=null;this.head=null;for(let s of e){const r=K.createItem(s);n!==null?n.next=r:this.head=r,r.prev=n,n=r}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,n=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(n,r.data,r,this)}this.releaseCursor()}forEachRight(e,n=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(n,r.data,r,this)}this.releaseCursor()}reduce(e,n,s=this){let r=this.allocateCursor(null,this.head),o=n,a;for(;r.next!==null;)a=r.next,r.next=a.next,o=e.call(s,o,a.data,a,this);return this.releaseCursor(),o}reduceRight(e,n,s=this){let r=this.allocateCursor(this.tail,null),o=n,a;for(;r.prev!==null;)a=r.prev,r.prev=a.prev,o=e.call(s,o,a.data,a,this);return this.releaseCursor(),o}some(e,n=this){for(let s=this.head;s!==null;s=s.next)if(e.call(n,s.data,s,this))return!0;return!1}map(e,n=this){const s=new K;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(n,r.data,r,this));return s}filter(e,n=this){const s=new K;for(let r=this.head;r!==null;r=r.next)e.call(n,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,n,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,n.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,n,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,n.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new K;for(let n of this)e.appendData(n);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(K.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(K.createItem(e))}insert(e,n=null){if(n!==null)if(this.updateCursors(n.prev,e,n,e),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=e,n.prev=e,e.next=n,this.updateCursors(null,e)}else n.prev.next=e,e.prev=n.prev,n.prev=e,e.next=n;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,n){return this.insert(K.createItem(e),n)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(K.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(K.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,n){return e.head===null?this:(n!=null?(this.updateCursors(n.prev,e.tail,n,e.head),n.prev!==null?(n.prev.next=e.head,e.head.prev=n.prev):this.head=e.head,n.prev=e.tail,e.tail.next=n):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,n){"head"in n?this.insertList(n,e):this.insert(n,e),this.remove(e)}}function Ce(t){const e={};for(const n of Object.keys(t)){let s=t[n];s&&(Array.isArray(s)||s instanceof K?s=s.map(Ce):s.constructor===Object&&(s=Ce(s))),e[n]=s}return e}const Lt=0,d=1,A=2,V=3,_=4,Tt=5,qo=6,X=7,dt=8,O=9,b=10,D=11,E=12,B=13,we=14,ot=15,J=16,et=17,gt=18,Kt=19,ue=20,I=21,y=22,mt=23,Qt=24,Z=25,Ko=0;function at(t){return t>=48&&t<=57}function Yt(t){return at(t)||t>=65&&t<=70||t>=97&&t<=102}function Ke(t){return t>=65&&t<=90}function Qo(t){return t>=97&&t<=122}function Yo(t){return Ke(t)||Qo(t)}function Xo(t){return t>=128}function Ae(t){return Yo(t)||Xo(t)||t===95}function zn(t){return Ae(t)||at(t)||t===45}function Jo(t){return t>=0&&t<=8||t===11||t>=14&&t<=31||t===127}function Te(t){return t===10||t===13||t===12}function Dt(t){return Te(t)||t===32||t===9}function bt(t,e){return!(t!==92||Te(e)||e===Ko)}function Qe(t,e,n){return t===45?Ae(e)||e===45||bt(e,n):Ae(t)?!0:t===92?bt(t,e):!1}function Ye(t,e,n){return t===43||t===45?at(e)?2:e===46&&at(n)?3:0:t===46?at(e)?2:0:at(t)?1:0}function Hn(t){return t===65279||t===65534?1:0}const Xe=new Array(128),Zo=128,ve=130,Vn=131,Je=132,Gn=133;for(let t=0;t<Xe.length;t++)Xe[t]=Dt(t)&&ve||at(t)&&Vn||Ae(t)&&Je||Jo(t)&&Gn||t||Zo;function Ze(t){return t<128?Xe[t]:Je}function Xt(t,e){return e<t.length?t.charCodeAt(e):0}function tn(t,e,n){return n===13&&Xt(t,e+1)===10?2:1}function qn(t,e,n){let s=t.charCodeAt(e);return Ke(s)&&(s=s|32),s===n}function Ee(t,e,n,s){if(n-e!==s.length||e<0||n>t.length)return!1;for(let r=e;r<n;r++){const o=s.charCodeAt(r-e);let a=t.charCodeAt(r);if(Ke(a)&&(a=a|32),a!==o)return!1}return!0}function ta(t,e){for(;e>=0&&Dt(t.charCodeAt(e));e--);return e+1}function $e(t,e){for(;e<t.length&&Dt(t.charCodeAt(e));e++);return e}function en(t,e){for(;e<t.length&&at(t.charCodeAt(e));e++);return e}function Jt(t,e){if(e+=2,Yt(Xt(t,e-1))){for(const s=Math.min(t.length,e+5);e<s&&Yt(Xt(t,e));e++);const n=Xt(t,e);Dt(n)&&(e+=tn(t,e,n))}return e}function Oe(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(!zn(n)){if(bt(n,Xt(t,e+1))){e=Jt(t,e)-1;continue}break}}return e}function Kn(t,e){let n=t.charCodeAt(e);if((n===43||n===45)&&(n=t.charCodeAt(e+=1)),at(n)&&(e=en(t,e+1),n=t.charCodeAt(e)),n===46&&at(t.charCodeAt(e+1))&&(e+=2,e=en(t,e)),qn(t,e,101)){let s=0;n=t.charCodeAt(e+1),(n===45||n===43)&&(s=1,n=t.charCodeAt(e+2)),at(n)&&(e=en(t,e+1+s+1))}return e}function nn(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(n===41){e++;break}bt(n,Xt(t,e+1))&&(e=Jt(t,e))}return e}function Qn(t){if(t.length===1&&!Yt(t.charCodeAt(0)))return t[0];let e=parseInt(t,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const Yn=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],ea=16*1024;function Le(t=null,e){return t===null||t.length<e?new Uint32Array(Math.max(e+1024,ea)):t}const Xn=10,na=12,Jn=13;function Zn(t){const e=t.source,n=e.length,s=e.length>0?Hn(e.charCodeAt(0)):0,r=Le(t.lines,n),o=Le(t.columns,n);let a=t.startLine,l=t.startColumn;for(let u=s;u<n;u++){const i=e.charCodeAt(u);r[u]=a,o[u]=l++,(i===Xn||i===Jn||i===na)&&(i===Jn&&u+1<n&&e.charCodeAt(u+1)===Xn&&(u++,r[u]=a,o[u]=l),a++,l=1)}r[n]=a,o[n]=l,t.lines=r,t.columns=o,t.computed=!0}class sa{constructor(e,n,s,r){this.setSource(e,n,s,r),this.lines=null,this.columns=null}setSource(e="",n=0,s=1,r=1){this.source=e,this.startOffset=n,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,n){return this.computed||Zn(this),{source:n,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,n,s){return this.computed||Zn(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}const xt=16777215,Ct=24,Ft=new Uint8Array(32);Ft[A]=y,Ft[I]=y,Ft[Kt]=ue,Ft[mt]=Qt;function ts(t){return Ft[t]!==0}class ra{constructor(e,n){this.setSource(e,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",n=()=>{}){e=String(e||"");const s=e.length,r=Le(this.offsetAndType,e.length+1),o=Le(this.balance,e.length+1);let a=0,l=-1,u=0,i=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),n(e,(c,h,f)=>{const p=a++;if(r[p]=c<<Ct|f,l===-1&&(l=h),o[p]=i,c===u){const g=o[i];o[i]=p,i=g,u=Ft[r[g]>>Ct]}else ts(c)&&(i=p,u=Ft[c])}),r[a]=Lt<<Ct|s,o[a]=a;for(let c=0;c<a;c++){const h=o[c];if(h<=c){const f=o[h];f!==c&&(o[c]=f)}else h>a&&(o[c]=a)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=a,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Ct:Lt}lookupTypeNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const s=this.offsetAndType[n]>>Ct;if(s!==B&&s!==Z&&e--===0)return s}return Lt}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&xt:this.source.length}lookupOffsetNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const s=this.offsetAndType[n]>>Ct;if(s!==B&&s!==Z&&e--===0)return n-this.tokenIndex}return Lt}lookupValue(e,n){return e+=this.tokenIndex,e<this.tokenCount?Ee(this.source,this.offsetAndType[e-1]&xt,this.offsetAndType[e]&xt,n):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&xt:this.offsetAndType[this.tokenCount]&xt:this.firstCharOffset}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,n){return n?this.lookupType(n)===O&&this.source.charCodeAt(this.lookupOffset(n))===e:this.tokenType===O&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let n=this.tokenIndex+e;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&xt,n=this.offsetAndType[n],this.tokenType=n>>Ct,this.tokenEnd=n&xt):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Ct,this.tokenEnd=e&xt):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=Lt,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===B||this.tokenType===Z;)this.next()}skipUntilBalanced(e,n){let s=e,r=0,o=0;t:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break t;switch(o=s>0?this.offsetAndType[s-1]&xt:this.firstCharOffset,n(this.source.charCodeAt(o))){case 1:break t;case 2:s++;break t;default:ts(this.offsetAndType[s]>>Ct)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let n=0,s=this.firstCharOffset;n<this.tokenCount;n++){const r=s,o=this.offsetAndType[n],a=o&xt,l=o>>Ct;s=a,e(l,r,a,n)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((n,s,r,o)=>{e[o]={idx:o,type:Yn[n],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function es(t,e){function n(h){return h<l?t.charCodeAt(h):0}function s(){if(i=Kn(t,i),Qe(n(i),n(i+1),n(i+2))){c=E,i=Oe(t,i);return}if(n(i)===37){c=D,i++;return}c=b}function r(){const h=i;if(i=Oe(t,i),Ee(t,h,i,"url")&&n(i)===40){if(i=$e(t,i+1),n(i)===34||n(i)===39){c=A,i=h+4;return}a();return}if(n(i)===40){c=A,i++;return}c=d}function o(h){for(h||(h=n(i++)),c=Tt;i<t.length;i++){const f=t.charCodeAt(i);switch(Ze(f)){case h:i++;return;case ve:if(Te(f)){i+=tn(t,i,f),c=qo;return}break;case 92:if(i===t.length-1)break;const p=n(i+1);Te(p)?i+=tn(t,i+1,p):bt(f,p)&&(i=Jt(t,i)-1);break}}}function a(){for(c=X,i=$e(t,i);i<t.length;i++){const h=t.charCodeAt(i);switch(Ze(h)){case 41:i++;return;case ve:if(i=$e(t,i),n(i)===41||i>=t.length){i<t.length&&i++;return}i=nn(t,i),c=dt;return;case 34:case 39:case 40:case Gn:i=nn(t,i),c=dt;return;case 92:if(bt(h,n(i+1))){i=Jt(t,i)-1;break}i=nn(t,i),c=dt;return}}}t=String(t||"");const l=t.length;let u=Hn(n(0)),i=u,c;for(;i<l;){const h=t.charCodeAt(i);switch(Ze(h)){case ve:c=B,i=$e(t,i+1);break;case 34:o();break;case 35:zn(n(i+1))||bt(n(i+1),n(i+2))?(c=_,i=Oe(t,i+1)):(c=O,i++);break;case 39:o();break;case 40:c=I,i++;break;case 41:c=y,i++;break;case 43:Ye(h,n(i+1),n(i+2))?s():(c=O,i++);break;case 44:c=gt,i++;break;case 45:Ye(h,n(i+1),n(i+2))?s():n(i+1)===45&&n(i+2)===62?(c=ot,i=i+3):Qe(h,n(i+1),n(i+2))?r():(c=O,i++);break;case 46:Ye(h,n(i+1),n(i+2))?s():(c=O,i++);break;case 47:n(i+1)===42?(c=Z,i=t.indexOf("*/",i+2),i=i===-1?t.length:i+2):(c=O,i++);break;case 58:c=J,i++;break;case 59:c=et,i++;break;case 60:n(i+1)===33&&n(i+2)===45&&n(i+3)===45?(c=we,i=i+4):(c=O,i++);break;case 64:Qe(n(i+1),n(i+2),n(i+3))?(c=V,i=Oe(t,i+1)):(c=O,i++);break;case 91:c=Kt,i++;break;case 92:bt(h,n(i+1))?r():(c=O,i++);break;case 93:c=ue,i++;break;case 123:c=mt,i++;break;case 125:c=Qt,i++;break;case Vn:s();break;case Je:r();break;default:c=O,i++}e(c,u,u=i)}}const ns=45;function ia(t,e){return e=e||0,t.length-e>=2&&t.charCodeAt(e)===ns&&t.charCodeAt(e+1)===ns}const sn=92,ss=34,oa=39;function rs(t){const e=t.length,n=t.charCodeAt(0),s=n===ss||n===oa?1:0,r=s===1&&e>1&&t.charCodeAt(e-1)===n?e-2:e-1;let o="";for(let a=s;a<=r;a++){let l=t.charCodeAt(a);if(l===sn){if(a===r){a!==e-1&&(o=t.substr(a+1));break}if(l=t.charCodeAt(++a),bt(sn,l)){const u=a-1,i=Jt(t,u);a=i-1,o+=Qn(t.substring(u+1,i))}else l===13&&t.charCodeAt(a+1)===10&&a++}else o+=t[a]}return o}function aa(t,e){const s=ss;let r="",o=!1;for(let a=0;a<t.length;a++){const l=t.charCodeAt(a);if(l===0){r+="�";continue}if(l<=31||l===127){r+="\\"+l.toString(16),o=!0;continue}l===s||l===sn?(r+="\\"+t.charAt(a),o=!1):(o&&(Yt(l)||Dt(l))&&(r+=" "),r+=t.charAt(a),o=!1)}return'"'+r+'"'}const la=32,rn=92,ca=34,ua=39,ha=40,is=41;function fa(t){const e=t.length;let n=4,s=t.charCodeAt(e-1)===is?e-2:e-1,r="";for(;n<s&&Dt(t.charCodeAt(n));)n++;for(;n<s&&Dt(t.charCodeAt(s));)s--;for(let o=n;o<=s;o++){let a=t.charCodeAt(o);if(a===rn){if(o===s){o!==e-1&&(r=t.substr(o+1));break}if(a=t.charCodeAt(++o),bt(rn,a)){const l=o-1,u=Jt(t,l);o=u-1,r+=Qn(t.substring(l+1,u))}else a===13&&t.charCodeAt(o+1)===10&&o++}else r+=t[o]}return r}function pa(t){let e="",n=!1;for(let s=0;s<t.length;s++){const r=t.charCodeAt(s);if(r===0){e+="�";continue}if(r<=31||r===127){e+="\\"+r.toString(16),n=!0;continue}r===la||r===rn||r===ca||r===ua||r===ha||r===is?(e+="\\"+t.charAt(s),n=!1):(n&&Yt(r)&&(e+=" "),e+=t.charAt(s),n=!1)}return"url("+e+")"}const{hasOwnProperty:on}=Object.prototype,he=function(){};function os(t){return typeof t=="function"?t:he}function as(t,e){return function(n,s,r){n.type===e&&t.call(this,n,s,r)}}function da(t,e){const n=e.structure,s=[];for(const r in n){if(on.call(n,r)===!1)continue;let o=n[r];const a={name:r,type:!1,nullable:!1};Array.isArray(o)||(o=[o]);for(const l of o)l===null?a.nullable=!0:typeof l=="string"?a.type="node":Array.isArray(l)&&(a.type="list");a.type&&s.push(a)}return s.length?{context:e.walkContext,fields:s}:null}function ga(t){const e={};for(const n in t.node)if(on.call(t.node,n)){const s=t.node[n];if(!s.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");e[n]=da(n,s)}return e}function ls(t,e){const n=t.fields.slice(),s=t.context,r=typeof s=="string";return e&&n.reverse(),function(o,a,l,u){let i;r&&(i=a[s],a[s]=o);for(const c of n){const h=o[c.name];if(!c.nullable||h){if(c.type==="list"){if(e?h.reduceRight(u,!1):h.reduce(u,!1))return!0}else if(l(h))return!0}}r&&(a[s]=i)}}function cs({StyleSheet:t,Atrule:e,Rule:n,Block:s,DeclarationList:r}){return{Atrule:{StyleSheet:t,Atrule:e,Rule:n,Block:s},Rule:{StyleSheet:t,Atrule:e,Rule:n,Block:s},Declaration:{StyleSheet:t,Atrule:e,Rule:n,Block:s,DeclarationList:r}}}function ma(t){const e=ga(t),n={},s={},r=Symbol("break-walk"),o=Symbol("skip-node");for(const i in e)on.call(e,i)&&e[i]!==null&&(n[i]=ls(e[i],!1),s[i]=ls(e[i],!0));const a=cs(n),l=cs(s),u=function(i,c){function h(S,x,T){const W=f.call(k,S,x,T);return W===r?!0:W===o?!1:!!(g.hasOwnProperty(S.type)&&g[S.type](S,k,h,m)||p.call(k,S,x,T)===r)}let f=he,p=he,g=n,m=(S,x,T,W)=>S||h(x,T,W);const k={break:r,skip:o,root:i,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof c=="function")f=c;else if(c&&(f=os(c.enter),p=os(c.leave),c.reverse&&(g=s),c.visit)){if(a.hasOwnProperty(c.visit))g=c.reverse?l[c.visit]:a[c.visit];else if(!e.hasOwnProperty(c.visit))throw new Error("Bad value `"+c.visit+"` for `visit` option (should be: "+Object.keys(e).sort().join(", ")+")");f=as(f,c.visit),p=as(p,c.visit)}if(f===he&&p===he)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");h(i)};return u.break=r,u.skip=o,u.find=function(i,c){let h=null;return u(i,function(f,p,g){if(c.call(this,f,p,g))return h=f,r}),h},u.findLast=function(i,c){let h=null;return u(i,{reverse:!0,enter(f,p,g){if(c.call(this,f,p,g))return h=f,r}}),h},u.findAll=function(i,c){const h=[];return u(i,function(f,p,g){c.call(this,f,p,g)&&h.push(f)}),h},u}const wt=43,lt=45,Pe=110,Mt=!0,ka=!1;function Re(t,e){let n=this.tokenStart+t;const s=this.charCodeAt(n);for((s===wt||s===lt)&&(e&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)at(this.charCodeAt(n))||this.error("Integer is expected",n)}function Zt(t){return Re.call(this,0,t)}function Pt(t,e){if(!this.cmpChar(this.tokenStart+t,e)){let n="";switch(e){case Pe:n="N is expected";break;case lt:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+t)}}function an(){let t=0,e=0,n=this.tokenType;for(;n===B||n===Z;)n=this.lookupType(++t);if(n!==b)if(this.isDelim(wt,t)||this.isDelim(lt,t)){e=this.isDelim(wt,t)?wt:lt;do n=this.lookupType(++t);while(n===B||n===Z);n!==b&&(this.skip(t),Zt.call(this,Mt))}else return null;return t>0&&this.skip(t),e===0&&(n=this.charCodeAt(this.tokenStart),n!==wt&&n!==lt&&this.error("Number sign is expected")),Zt.call(this,e!==0),e===lt?"-"+this.consume(b):this.consume(b)}const Sa="AnPlusB",ya={a:[String,null],b:[String,null]};function us(){const t=this.tokenStart;let e=null,n=null;if(this.tokenType===b)Zt.call(this,ka),n=this.consume(b);else if(this.tokenType===d&&this.cmpChar(this.tokenStart,lt))switch(e="-1",Pt.call(this,1,Pe),this.tokenEnd-this.tokenStart){case 2:this.next(),n=an.call(this);break;case 3:Pt.call(this,2,lt),this.next(),this.skipSC(),Zt.call(this,Mt),n="-"+this.consume(b);break;default:Pt.call(this,2,lt),Re.call(this,3,Mt),this.next(),n=this.substrToCursor(t+2)}else if(this.tokenType===d||this.isDelim(wt)&&this.lookupType(1)===d){let s=0;switch(e="1",this.isDelim(wt)&&(s=1,this.next()),Pt.call(this,0,Pe),this.tokenEnd-this.tokenStart){case 1:this.next(),n=an.call(this);break;case 2:Pt.call(this,1,lt),this.next(),this.skipSC(),Zt.call(this,Mt),n="-"+this.consume(b);break;default:Pt.call(this,1,lt),Re.call(this,2,Mt),this.next(),n=this.substrToCursor(t+s+1)}}else if(this.tokenType===E){const s=this.charCodeAt(this.tokenStart),r=s===wt||s===lt;let o=this.tokenStart+r;for(;o<this.tokenEnd&&at(this.charCodeAt(o));o++);o===this.tokenStart+r&&this.error("Integer is expected",this.tokenStart+r),Pt.call(this,o-this.tokenStart,Pe),e=this.substring(t,o),o+1===this.tokenEnd?(this.next(),n=an.call(this)):(Pt.call(this,o-this.tokenStart+1,lt),o+2===this.tokenEnd?(this.next(),this.skipSC(),Zt.call(this,Mt),n="-"+this.consume(b)):(Re.call(this,o-this.tokenStart+2,Mt),this.next(),n=this.substrToCursor(o+1)))}else this.error();return e!==null&&e.charCodeAt(0)===wt&&(e=e.substr(1)),n!==null&&n.charCodeAt(0)===wt&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(t,this.tokenStart),a:e,b:n}}function hs(t){if(t.a){const e=t.a==="+1"&&"n"||t.a==="1"&&"n"||t.a==="-1"&&"-n"||t.a+"n";if(t.b){const n=t.b[0]==="-"||t.b[0]==="+"?t.b:"+"+t.b;this.tokenize(e+n)}else this.tokenize(e)}else this.tokenize(t.b)}const ba=Object.freeze(Object.defineProperty({__proto__:null,generate:hs,name:Sa,parse:us,structure:ya},Symbol.toStringTag,{value:"Module"}));function fs(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function xa(){for(let t=1,e;e=this.lookupType(t);t++){if(e===Qt)return!0;if(e===mt||e===V)return!1}return!1}const Ca="Atrule",wa="atrule",Aa={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function ps(t=!1){const e=this.tokenStart;let n,s,r=null,o=null;switch(this.eat(V),n=this.substrToCursor(e+1),s=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==mt&&this.tokenType!==et&&(this.parseAtrulePrelude?r=this.parseWithFallback(this.AtrulePrelude.bind(this,n,t),fs):r=fs.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case et:this.next();break;case mt:hasOwnProperty.call(this.atrule,s)&&typeof this.atrule[s].block=="function"?o=this.atrule[s].block.call(this,t):o=this.Block(xa.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:n,prelude:r,block:o}}function ds(t){this.token(V,"@"+t.name),t.prelude!==null&&this.node(t.prelude),t.block?this.node(t.block):this.token(et,";")}const Ta=Object.freeze(Object.defineProperty({__proto__:null,generate:ds,name:Ca,parse:ps,structure:Aa,walkContext:wa},Symbol.toStringTag,{value:"Module"})),va="AtrulePrelude",Ea="atrulePrelude",$a={children:[[]]};function gs(t){let e=null;return t!==null&&(t=t.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,t)&&typeof this.atrule[t].prelude=="function"?e=this.atrule[t].prelude.call(this):e=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==mt&&this.tokenType!==et&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function ms(t){this.children(t)}const Oa=Object.freeze(Object.defineProperty({__proto__:null,generate:ms,name:va,parse:gs,structure:$a,walkContext:Ea},Symbol.toStringTag,{value:"Module"})),La=36,ks=42,Ie=61,Pa=94,ln=124,Ra=126;function Ia(){this.eof&&this.error("Unexpected end of input");const t=this.tokenStart;let e=!1;return this.isDelim(ks)?(e=!0,this.next()):this.isDelim(ln)||this.eat(d),this.isDelim(ln)?this.charCodeAt(this.tokenStart+1)!==Ie?(this.next(),this.eat(d)):e&&this.error("Identifier is expected",this.tokenEnd):e&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function _a(){const t=this.tokenStart,e=this.charCodeAt(t);return e!==Ie&&e!==Ra&&e!==Pa&&e!==La&&e!==ks&&e!==ln&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==Ie&&(this.isDelim(Ie)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(t)}const Na="AttributeSelector",Da={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function Ss(){const t=this.tokenStart;let e,n=null,s=null,r=null;return this.eat(Kt),this.skipSC(),e=Ia.call(this),this.skipSC(),this.tokenType!==ue&&(this.tokenType!==d&&(n=_a.call(this),this.skipSC(),s=this.tokenType===Tt?this.String():this.Identifier(),this.skipSC()),this.tokenType===d&&(r=this.consume(d),this.skipSC())),this.eat(ue),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:s,flags:r}}function ys(t){this.token(O,"["),this.node(t.name),t.matcher!==null&&(this.tokenize(t.matcher),this.node(t.value)),t.flags!==null&&this.token(d,t.flags),this.token(O,"]")}const Fa=Object.freeze(Object.defineProperty({__proto__:null,generate:ys,name:Na,parse:Ss,structure:Da},Symbol.toStringTag,{value:"Module"})),Ma=38;function bs(){return this.Raw(null,!0)}function xs(){return this.parseWithFallback(this.Rule,bs)}function Cs(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function ja(){if(this.tokenType===et)return Cs.call(this,this.tokenIndex);const t=this.parseWithFallback(this.Declaration,Cs);return this.tokenType===et&&this.next(),t}const Ba="Block",Wa="block",Ua={children:[["Atrule","Rule","Declaration"]]};function ws(t){const e=t?ja:xs,n=this.tokenStart;let s=this.createList();this.eat(mt);t:for(;!this.eof;)switch(this.tokenType){case Qt:break t;case B:case Z:this.next();break;case V:s.push(this.parseWithFallback(this.Atrule.bind(this,t),bs));break;default:t&&this.isDelim(Ma)?s.push(xs.call(this)):s.push(e.call(this))}return this.eof||this.eat(Qt),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:s}}function As(t){this.token(mt,"{"),this.children(t,e=>{e.type==="Declaration"&&this.token(et,";")}),this.token(Qt,"}")}const za=Object.freeze(Object.defineProperty({__proto__:null,generate:As,name:Ba,parse:ws,structure:Ua,walkContext:Wa},Symbol.toStringTag,{value:"Module"})),Ha="Brackets",Va={children:[[]]};function Ts(t,e){const n=this.tokenStart;let s=null;return this.eat(Kt),s=t.call(this,e),this.eof||this.eat(ue),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:s}}function vs(t){this.token(O,"["),this.children(t),this.token(O,"]")}const Ga=Object.freeze(Object.defineProperty({__proto__:null,generate:vs,name:Ha,parse:Ts,structure:Va},Symbol.toStringTag,{value:"Module"})),qa="CDC",Ka=[];function Es(){const t=this.tokenStart;return this.eat(ot),{type:"CDC",loc:this.getLocation(t,this.tokenStart)}}function $s(){this.token(ot,"-->")}const Qa=Object.freeze(Object.defineProperty({__proto__:null,generate:$s,name:qa,parse:Es,structure:Ka},Symbol.toStringTag,{value:"Module"})),Ya="CDO",Xa=[];function Os(){const t=this.tokenStart;return this.eat(we),{type:"CDO",loc:this.getLocation(t,this.tokenStart)}}function Ls(){this.token(we,"<!--")}const Ja=Object.freeze(Object.defineProperty({__proto__:null,generate:Ls,name:Ya,parse:Os,structure:Xa},Symbol.toStringTag,{value:"Module"})),Za=46,tl="ClassSelector",el={name:String};function Ps(){return this.eatDelim(Za),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(d)}}function Rs(t){this.token(O,"."),this.token(d,t.name)}const nl=Object.freeze(Object.defineProperty({__proto__:null,generate:Rs,name:tl,parse:Ps,structure:el},Symbol.toStringTag,{value:"Module"})),sl=43,Is=47,rl=62,il=126,ol="Combinator",al={name:String};function _s(){const t=this.tokenStart;let e;switch(this.tokenType){case B:e=" ";break;case O:switch(this.charCodeAt(this.tokenStart)){case rl:case sl:case il:this.next();break;case Is:this.next(),this.eatIdent("deep"),this.eatDelim(Is);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t);break}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function Ns(t){this.tokenize(t.name)}const ll=Object.freeze(Object.defineProperty({__proto__:null,generate:Ns,name:ol,parse:_s,structure:al},Symbol.toStringTag,{value:"Module"})),cl=42,ul=47,hl="Comment",fl={value:String};function Ds(){const t=this.tokenStart;let e=this.tokenEnd;return this.eat(Z),e-t+2>=2&&this.charCodeAt(e-2)===cl&&this.charCodeAt(e-1)===ul&&(e-=2),{type:"Comment",loc:this.getLocation(t,this.tokenStart),value:this.substring(t+2,e)}}function Fs(t){this.token(Z,"/*"+t.value+"*/")}const pl=Object.freeze(Object.defineProperty({__proto__:null,generate:Fs,name:hl,parse:Ds,structure:fl},Symbol.toStringTag,{value:"Module"})),dl=new Set([J,y,Lt]),gl="Condition",ml={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function Ms(t){return this.lookupTypeNonSC(1)===d&&dl.has(this.lookupTypeNonSC(2))?this.Feature(t):this.FeatureRange(t)}const kl={media:Ms,container:Ms,supports(){return this.SupportsDeclaration()}};function js(t="media"){const e=this.createList();t:for(;!this.eof;)switch(this.tokenType){case Z:case B:this.next();continue;case d:e.push(this.Identifier());break;case I:{let n=this.parseWithFallback(()=>kl[t].call(this,t),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(I);const s=this.Condition(t);return this.eat(y),s},()=>this.GeneralEnclosed(t))),e.push(n);break}case A:{let n=this.parseWithFallback(()=>this.FeatureFunction(t),()=>null);n||(n=this.GeneralEnclosed(t)),e.push(n);break}default:break t}return e.isEmpty&&this.error("Condition is expected"),{type:"Condition",loc:this.getLocationFromList(e),kind:t,children:e}}function Bs(t){t.children.forEach(e=>{e.type==="Condition"?(this.token(I,"("),this.node(e),this.token(y,")")):this.node(e)})}const Sl=Object.freeze(Object.defineProperty({__proto__:null,generate:Bs,name:gl,parse:js,structure:ml},Symbol.toStringTag,{value:"Module"})),Ws=33,yl=35,bl=36,xl=38,Cl=42,wl=43,Us=47;function Al(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function Tl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function vl(){const t=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==et&&this.isDelim(Ws)===!1&&this.isBalanceEdge(t)===!1&&this.error(),e}const El="Declaration",$l="declaration",Ol={important:[Boolean,String],property:String,value:["Value","Raw"]};function zs(){const t=this.tokenStart,e=this.tokenIndex,n=Ll.call(this),s=ia(n),r=s?this.parseCustomProperty:this.parseValue,o=s?Tl:Al;let a=!1,l;this.skipSC(),this.eat(J);const u=this.tokenIndex;if(s||this.skipSC(),r?l=this.parseWithFallback(vl,o):l=o.call(this,this.tokenIndex),s&&l.type==="Value"&&l.children.isEmpty){for(let i=u-this.tokenIndex;i<=0;i++)if(this.lookupType(i)===B){l.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(Ws)&&(a=Pl.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==et&&this.isBalanceEdge(e)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.tokenStart),important:a,property:n,value:l}}function Hs(t){this.token(d,t.property),this.token(J,":"),this.node(t.value),t.important&&(this.token(O,"!"),this.token(d,t.important===!0?"important":t.important))}function Ll(){const t=this.tokenStart;if(this.tokenType===O)switch(this.charCodeAt(this.tokenStart)){case Cl:case bl:case wl:case yl:case xl:this.next();break;case Us:this.next(),this.isDelim(Us)&&this.next();break}return this.tokenType===_?this.eat(_):this.eat(d),this.substrToCursor(t)}function Pl(){this.eat(O),this.skipSC();const t=this.consume(d);return t==="important"?!0:t}const Rl=Object.freeze(Object.defineProperty({__proto__:null,generate:Hs,name:El,parse:zs,structure:Ol,walkContext:$l},Symbol.toStringTag,{value:"Module"})),Il=38;function cn(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const _l="DeclarationList",Nl={children:[["Declaration","Atrule","Rule"]]};function Vs(){const t=this.createList();for(;!this.eof;)switch(this.tokenType){case B:case Z:case et:this.next();break;case V:t.push(this.parseWithFallback(this.Atrule.bind(this,!0),cn));break;default:this.isDelim(Il)?t.push(this.parseWithFallback(this.Rule,cn)):t.push(this.parseWithFallback(this.Declaration,cn))}return{type:"DeclarationList",loc:this.getLocationFromList(t),children:t}}function Gs(t){this.children(t,e=>{e.type==="Declaration"&&this.token(et,";")})}const Dl=Object.freeze(Object.defineProperty({__proto__:null,generate:Gs,name:_l,parse:Vs,structure:Nl},Symbol.toStringTag,{value:"Module"})),Fl="Dimension",Ml={value:String,unit:String};function qs(){const t=this.tokenStart,e=this.consumeNumber(E);return{type:"Dimension",loc:this.getLocation(t,this.tokenStart),value:e,unit:this.substring(t+e.length,this.tokenStart)}}function Ks(t){this.token(E,t.value+t.unit)}const jl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ks,name:Fl,parse:qs,structure:Ml},Symbol.toStringTag,{value:"Module"})),Bl=47,Wl="Feature",Ul={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function Qs(t){const e=this.tokenStart;let n,s=null;if(this.eat(I),this.skipSC(),n=this.consume(d),this.skipSC(),this.tokenType!==y){switch(this.eat(J),this.skipSC(),this.tokenType){case b:this.lookupNonWSType(1)===O?s=this.Ratio():s=this.Number();break;case E:s=this.Dimension();break;case d:s=this.Identifier();break;case A:s=this.parseWithFallback(()=>{const r=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(Bl)&&this.error(),r},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(y),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:t,name:n,value:s}}function Ys(t){this.token(I,"("),this.token(d,t.name),t.value!==null&&(this.token(J,":"),this.node(t.value)),this.token(y,")")}const zl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ys,name:Wl,parse:Qs,structure:Ul},Symbol.toStringTag,{value:"Module"})),Hl="FeatureFunction",Vl={kind:String,feature:String,value:["Declaration","Selector"]};function Gl(t,e){const s=(this.features[t]||{})[e];return typeof s!="function"&&this.error(`Unknown feature ${e}()`),s}function Xs(t="unknown"){const e=this.tokenStart,n=this.consumeFunctionName(),s=Gl.call(this,t,n.toLowerCase());this.skipSC();const r=this.parseWithFallback(()=>{const o=this.tokenIndex,a=s.call(this);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),a},()=>this.Raw(null,!1));return this.eof||this.eat(y),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:t,feature:n,value:r}}function Js(t){this.token(A,t.feature+"("),this.node(t.value),this.token(y,")")}const ql=Object.freeze(Object.defineProperty({__proto__:null,generate:Js,name:Hl,parse:Xs,structure:Vl},Symbol.toStringTag,{value:"Module"})),Zs=47,Kl=60,tr=61,Ql=62,Yl="FeatureRange",Xl={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]};function un(){switch(this.skipSC(),this.tokenType){case b:return this.isDelim(Zs,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case E:return this.Dimension();case d:return this.Identifier();case A:return this.parseWithFallback(()=>{const t=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(Zs)&&this.error(),t},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function er(t){if(this.skipSC(),this.isDelim(Kl)||this.isDelim(Ql)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(tr)?(this.next(),e+"="):e}if(this.isDelim(tr))return"=";this.error(`Expected ${t?'":", ':""}"<", ">", "=" or ")"`)}function nr(t="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(I);const n=un.call(this),s=er.call(this,n.type==="Identifier"),r=un.call(this);let o=null,a=null;return this.lookupNonWSType(0)!==y&&(o=er.call(this),a=un.call(this)),this.skipSC(),this.eat(y),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:t,left:n,leftComparison:s,middle:r,rightComparison:o,right:a}}function sr(t){this.token(I,"("),this.node(t.left),this.tokenize(t.leftComparison),this.node(t.middle),t.right&&(this.tokenize(t.rightComparison),this.node(t.right)),this.token(y,")")}const Jl=Object.freeze(Object.defineProperty({__proto__:null,generate:sr,name:Yl,parse:nr,structure:Xl},Symbol.toStringTag,{value:"Module"})),Zl="Function",tc="function",ec={name:String,children:[[]]};function rr(t,e){const n=this.tokenStart,s=this.consumeFunctionName(),r=s.toLowerCase();let o;return o=e.hasOwnProperty(r)?e[r].call(this,e):t.call(this,e),this.eof||this.eat(y),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:s,children:o}}function ir(t){this.token(A,t.name+"("),this.children(t),this.token(y,")")}const nc=Object.freeze(Object.defineProperty({__proto__:null,generate:ir,name:Zl,parse:rr,structure:ec,walkContext:tc},Symbol.toStringTag,{value:"Module"})),sc="GeneralEnclosed",rc={kind:String,function:[String,null],children:[[]]};function or(t){const e=this.tokenStart;let n=null;this.tokenType===A?n=this.consumeFunctionName():this.eat(I);const s=this.parseWithFallback(()=>{const r=this.tokenIndex,o=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(r)===!1&&this.error(),o},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(y),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:t,function:n,children:s}}function ar(t){t.function?this.token(A,t.function+"("):this.token(I,"("),this.children(t),this.token(y,")")}const ic=Object.freeze(Object.defineProperty({__proto__:null,generate:ar,name:sc,parse:or,structure:rc},Symbol.toStringTag,{value:"Module"})),oc="XXX",ac="Hash",lc={value:String};function lr(){const t=this.tokenStart;return this.eat(_),{type:"Hash",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t+1)}}function cr(t){this.token(_,"#"+t.value)}const cc=Object.freeze(Object.defineProperty({__proto__:null,generate:cr,name:ac,parse:lr,structure:lc,xxx:oc},Symbol.toStringTag,{value:"Module"})),uc="Identifier",hc={name:String};function ur(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(d)}}function hr(t){this.token(d,t.name)}const fc=Object.freeze(Object.defineProperty({__proto__:null,generate:hr,name:uc,parse:ur,structure:hc},Symbol.toStringTag,{value:"Module"})),pc="IdSelector",dc={name:String};function fr(){const t=this.tokenStart;return this.eat(_),{type:"IdSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t+1)}}function pr(t){this.token(O,"#"+t.name)}const gc=Object.freeze(Object.defineProperty({__proto__:null,generate:pr,name:pc,parse:fr,structure:dc},Symbol.toStringTag,{value:"Module"})),mc=46,kc="Layer",Sc={name:String};function dr(){let t=this.tokenStart,e=this.consume(d);for(;this.isDelim(mc);)this.eat(O),e+="."+this.consume(d);return{type:"Layer",loc:this.getLocation(t,this.tokenStart),name:e}}function gr(t){th