@oddbird/css-anchor-positioning
Version:
Polyfill for the proposed CSS anchor positioning spec
1 lines • 128 kB
JavaScript
(function(){const e=document.createElement("link").relList;if(e&&e.supports&&e.supports("modulepreload"))return;for(const i of document.querySelectorAll('link[rel="modulepreload"]'))r(i);new MutationObserver(i=>{for(const s of i)if(s.type==="childList")for(const a of s.addedNodes)a.tagName==="LINK"&&a.rel==="modulepreload"&&r(a)}).observe(document,{childList:!0,subtree:!0});function n(i){const s={};return i.integrity&&(s.integrity=i.integrity),i.referrerPolicy&&(s.referrerPolicy=i.referrerPolicy),i.crossOrigin==="use-credentials"?s.credentials="include":i.crossOrigin==="anonymous"?s.credentials="omit":s.credentials="same-origin",s}function r(i){if(i.ep)return;i.ep=!0;const s=n(i);fetch(i.href,s)}})();const Qe=Math.min,_t=Math.max,he=Math.round,Jt=Math.floor,lt=t=>({x:t,y:t});function po(t,e){return typeof t=="function"?t(e):t}function go(t){return{top:0,right:0,bottom:0,left:0,...t}}function mo(t){return typeof t!="number"?go(t):{top:t,right:t,bottom:t,left:t}}function fe(t){const{x:e,y:n,width:r,height:i}=t;return{width:r,height:i,top:n,left:e,right:e+r,bottom:n+i,x:e,y:n}}async function yo(t,e){var n;e===void 0&&(e={});const{x:r,y:i,platform:s,rects:a,elements:l,strategy:u}=t,{boundary:o="clippingAncestors",rootBoundary:c="viewport",elementContext:h="floating",altBoundary:p=!1,padding:f=0}=po(e,t),d=mo(f),k=l[p?h==="floating"?"reference":"floating":h],b=fe(await s.getClippingRect({element:(n=await(s.isElement==null?void 0:s.isElement(k)))==null||n?k:k.contextElement||await(s.getDocumentElement==null?void 0:s.getDocumentElement(l.floating)),boundary:o,rootBoundary:c,strategy:u})),x=h==="floating"?{x:r,y:i,width:a.floating.width,height:a.floating.height}:a.reference,A=await(s.getOffsetParent==null?void 0:s.getOffsetParent(l.floating)),T=await(s.isElement==null?void 0:s.isElement(A))?await(s.getScale==null?void 0:s.getScale(A))||{x:1,y:1}:{x:1,y:1},O=fe(s.convertOffsetParentRelativeRectToViewportRelativeRect?await s.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:A,strategy:u}):x);return{top:(b.top-O.top+d.top)/T.y,bottom:(O.bottom-b.bottom+d.bottom)/T.y,left:(b.left-O.left+d.left)/T.x,right:(O.right-b.right+d.right)/T.x}}function be(){return typeof window<"u"}function Mt(t){return $r(t)?(t.nodeName||"").toLowerCase():"#document"}function Q(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function ut(t){var e;return(e=($r(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function $r(t){return be()?t instanceof Node||t instanceof Q(t).Node:!1}function Z(t){return be()?t instanceof Element||t instanceof Q(t).Element:!1}function ct(t){return be()?t instanceof HTMLElement||t instanceof Q(t).HTMLElement:!1}function bn(t){return!be()||typeof ShadowRoot>"u"?!1:t instanceof ShadowRoot||t instanceof Q(t).ShadowRoot}const So=new Set(["inline","contents"]);function Kt(t){const{overflow:e,overflowX:n,overflowY:r,display:i}=tt(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!So.has(i)}const ko=new Set(["table","td","th"]);function bo(t){return ko.has(Mt(t))}const Co=[":popover-open",":modal"];function Ce(t){return Co.some(e=>{try{return t.matches(e)}catch{return!1}})}const vo=["transform","translate","scale","rotate","perspective"],xo=["transform","translate","scale","rotate","perspective","filter"],wo=["paint","layout","strict","content"];function cn(t){const e=un(),n=Z(t)?tt(t):t;return vo.some(r=>n[r]?n[r]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||xo.some(r=>(n.willChange||"").includes(r))||wo.some(r=>(n.contain||"").includes(r))}function Ao(t){let e=St(t);for(;ct(e)&&!Pt(e);){if(cn(e))return e;if(Ce(e))return null;e=St(e)}return null}function un(){return typeof CSS>"u"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Lo=new Set(["html","body","#document"]);function Pt(t){return Lo.has(Mt(t))}function tt(t){return Q(t).getComputedStyle(t)}function ve(t){return Z(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function St(t){if(Mt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||bn(t)&&t.host||ut(t);return bn(e)?e.host:e}function Pr(t){const e=St(t);return Pt(e)?t.ownerDocument?t.ownerDocument.body:t.body:ct(e)&&Kt(e)?e:Pr(e)}function Gt(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const i=Pr(t),s=i===((r=t.ownerDocument)==null?void 0:r.body),a=Q(i);if(s){const l=Ke(a);return e.concat(a,a.visualViewport||[],Kt(i)?i:[],l&&n?Gt(l):[])}return e.concat(i,Gt(i,[],n))}function Ke(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Ir(t){const e=tt(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const i=ct(t),s=i?t.offsetWidth:n,a=i?t.offsetHeight:r,l=he(n)!==s||he(r)!==a;return l&&(n=s,r=a),{width:n,height:r,$:l}}function hn(t){return Z(t)?t:t.contextElement}function Et(t){const e=hn(t);if(!ct(e))return lt(1);const n=e.getBoundingClientRect(),{width:r,height:i,$:s}=Ir(e);let a=(s?he(n.width):n.width)/r,l=(s?he(n.height):n.height)/i;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const To=lt(0);function Nr(t){const e=Q(t);return!un()||!e.visualViewport?To:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function _o(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==Q(t)?!1:e}function xt(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const i=t.getBoundingClientRect(),s=hn(t);let a=lt(1);e&&(r?Z(r)&&(a=Et(r)):a=Et(t));const l=_o(s,n,r)?Nr(s):lt(0);let u=(i.left+l.x)/a.x,o=(i.top+l.y)/a.y,c=i.width/a.x,h=i.height/a.y;if(s){const p=Q(s),f=r&&Z(r)?Q(r):r;let d=p,S=Ke(d);for(;S&&r&&f!==d;){const k=Et(S),b=S.getBoundingClientRect(),x=tt(S),A=b.left+(S.clientLeft+parseFloat(x.paddingLeft))*k.x,T=b.top+(S.clientTop+parseFloat(x.paddingTop))*k.y;u*=k.x,o*=k.y,c*=k.x,h*=k.y,u+=A,o+=T,d=Q(S),S=Ke(d)}}return fe({width:c,height:h,x:u,y:o})}function xe(t,e){const n=ve(t).scrollLeft;return e?e.left+n:xt(ut(t)).left+n}function Rr(t,e){const n=t.getBoundingClientRect(),r=n.left+e.scrollLeft-xe(t,n),i=n.top+e.scrollTop;return{x:r,y:i}}function Eo(t){let{elements:e,rect:n,offsetParent:r,strategy:i}=t;const s=i==="fixed",a=ut(r),l=e?Ce(e.floating):!1;if(r===a||l&&s)return n;let u={scrollLeft:0,scrollTop:0},o=lt(1);const c=lt(0),h=ct(r);if((h||!h&&!s)&&((Mt(r)!=="body"||Kt(a))&&(u=ve(r)),ct(r))){const f=xt(r);o=Et(r),c.x=f.x+r.clientLeft,c.y=f.y+r.clientTop}const p=a&&!h&&!s?Rr(a,u):lt(0);return{width:n.width*o.x,height:n.height*o.y,x:n.x*o.x-u.scrollLeft*o.x+c.x+p.x,y:n.y*o.y-u.scrollTop*o.y+c.y+p.y}}function Oo(t){return Array.from(t.getClientRects())}function $o(t){const e=ut(t),n=ve(t),r=t.ownerDocument.body,i=_t(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),s=_t(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+xe(t);const l=-n.scrollTop;return tt(r).direction==="rtl"&&(a+=_t(e.clientWidth,r.clientWidth)-i),{width:i,height:s,x:a,y:l}}const Cn=25;function Po(t,e){const n=Q(t),r=ut(t),i=n.visualViewport;let s=r.clientWidth,a=r.clientHeight,l=0,u=0;if(i){s=i.width,a=i.height;const c=un();(!c||c&&e==="fixed")&&(l=i.offsetLeft,u=i.offsetTop)}const o=xe(r);if(o<=0){const c=r.ownerDocument,h=c.body,p=getComputedStyle(h),f=c.compatMode==="CSS1Compat"&&parseFloat(p.marginLeft)+parseFloat(p.marginRight)||0,d=Math.abs(r.clientWidth-h.clientWidth-f);d<=Cn&&(s-=d)}else o<=Cn&&(s+=o);return{width:s,height:a,x:l,y:u}}const Io=new Set(["absolute","fixed"]);function No(t,e){const n=xt(t,!0,e==="fixed"),r=n.top+t.clientTop,i=n.left+t.clientLeft,s=ct(t)?Et(t):lt(1),a=t.clientWidth*s.x,l=t.clientHeight*s.y,u=i*s.x,o=r*s.y;return{width:a,height:l,x:u,y:o}}function vn(t,e,n){let r;if(e==="viewport")r=Po(t,n);else if(e==="document")r=$o(ut(t));else if(Z(e))r=No(e,n);else{const i=Nr(t);r={x:e.x-i.x,y:e.y-i.y,width:e.width,height:e.height}}return fe(r)}function Dr(t,e){const n=St(t);return n===e||!Z(n)||Pt(n)?!1:tt(n).position==="fixed"||Dr(n,e)}function Ro(t,e){const n=e.get(t);if(n)return n;let r=Gt(t,[],!1).filter(l=>Z(l)&&Mt(l)!=="body"),i=null;const s=tt(t).position==="fixed";let a=s?St(t):t;for(;Z(a)&&!Pt(a);){const l=tt(a),u=cn(a);!u&&l.position==="fixed"&&(i=null),(s?!u&&!i:!u&&l.position==="static"&&!!i&&Io.has(i.position)||Kt(a)&&!u&&Dr(t,a))?r=r.filter(c=>c!==a):i=l,a=St(a)}return e.set(t,r),r}function Do(t){let{element:e,boundary:n,rootBoundary:r,strategy:i}=t;const a=[...n==="clippingAncestors"?Ce(e)?[]:Ro(e,this._c):[].concat(n),r],l=a[0],u=a.reduce((o,c)=>{const h=vn(e,c,i);return o.top=_t(h.top,o.top),o.right=Qe(h.right,o.right),o.bottom=Qe(h.bottom,o.bottom),o.left=_t(h.left,o.left),o},vn(e,l,i));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Mo(t){const{width:e,height:n}=Ir(t);return{width:e,height:n}}function Fo(t,e,n){const r=ct(e),i=ut(e),s=n==="fixed",a=xt(t,!0,s,e);let l={scrollLeft:0,scrollTop:0};const u=lt(0);function o(){u.x=xe(i)}if(r||!r&&!s)if((Mt(e)!=="body"||Kt(i))&&(l=ve(e)),r){const f=xt(e,!0,s,e);u.x=f.x+e.clientLeft,u.y=f.y+e.clientTop}else i&&o();s&&!r&&i&&o();const c=i&&!r&&!s?Rr(i,l):lt(0),h=a.left+l.scrollLeft-u.x-c.x,p=a.top+l.scrollTop-u.y-c.y;return{x:h,y:p,width:a.width,height:a.height}}function Ae(t){return tt(t).position==="static"}function xn(t,e){if(!ct(t)||tt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return ut(t)===n&&(n=n.ownerDocument.body),n}function Mr(t,e){const n=Q(t);if(Ce(t))return n;if(!ct(t)){let i=St(t);for(;i&&!Pt(i);){if(Z(i)&&!Ae(i))return i;i=St(i)}return n}let r=xn(t,e);for(;r&&bo(r)&&Ae(r);)r=xn(r,e);return r&&Pt(r)&&Ae(r)&&!cn(r)?n:r||Ao(t)||n}const jo=async function(t){const e=this.getOffsetParent||Mr,n=this.getDimensions,r=await n(t.floating);return{reference:Fo(t.reference,await e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}};function Bo(t){return tt(t).direction==="rtl"}const ft={convertOffsetParentRelativeRectToViewportRelativeRect:Eo,getDocumentElement:ut,getClippingRect:Do,getOffsetParent:Mr,getElementRects:jo,getClientRects:Oo,getDimensions:Mo,getScale:Et,isElement:Z,isRTL:Bo};function Fr(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Wo(t,e){let n=null,r;const i=ut(t);function s(){var l;clearTimeout(r),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),s();const o=t.getBoundingClientRect(),{left:c,top:h,width:p,height:f}=o;if(l||e(),!p||!f)return;const d=Jt(h),S=Jt(i.clientWidth-(c+p)),k=Jt(i.clientHeight-(h+f)),b=Jt(c),A={rootMargin:-d+"px "+-S+"px "+-k+"px "+-b+"px",threshold:_t(0,Qe(1,u))||1};let T=!0;function O(rt){const F=rt[0].intersectionRatio;if(F!==u){if(!T)return a();F?a(!1,F):r=setTimeout(()=>{a(!1,1e-7)},1e3)}F===1&&!Fr(o,t.getBoundingClientRect())&&a(),T=!1}try{n=new IntersectionObserver(O,{...A,root:i.ownerDocument})}catch{n=new IntersectionObserver(O,A)}n.observe(t)}return a(!0),s}function Ye(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:i=!0,ancestorResize:s=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,o=hn(t),c=i||s?[...o?Gt(o):[],...Gt(e)]:[];c.forEach(b=>{i&&b.addEventListener("scroll",n,{passive:!0}),s&&b.addEventListener("resize",n)});const h=o&&l?Wo(o,n):null;let p=-1,f=null;a&&(f=new ResizeObserver(b=>{let[x]=b;x&&x.target===o&&f&&(f.unobserve(e),cancelAnimationFrame(p),p=requestAnimationFrame(()=>{var A;(A=f)==null||A.observe(e)})),n()}),o&&!u&&f.observe(o),f.observe(e));let d,S=u?xt(t):null;u&&k();function k(){const b=xt(t);S&&!Fr(S,b)&&n(),S=b,d=requestAnimationFrame(k)}return n(),()=>{var b;c.forEach(x=>{i&&x.removeEventListener("scroll",n),s&&x.removeEventListener("resize",n)}),h?.(),(b=f)==null||b.disconnect(),f=null,u&&cancelAnimationFrame(d)}}const zo=yo;let Lt=null;class M{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return M.createItem(e)}allocateCursor(e,n){let r;return Lt!==null?(r=Lt,Lt=Lt.cursor,r.prev=e,r.next=n,r.cursor=this.cursor):r={prev:e,next:n,cursor:this.cursor},this.cursor=r,r}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=Lt,Lt=e}updateCursors(e,n,r,i){let{cursor:s}=this;for(;s!==null;)s.prev===e&&(s.prev=n),s.next===r&&(s.next=i),s=s.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 r of e){const i=M.createItem(r);n!==null?n.next=i:this.head=i,i.prev=n,n=i}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,n=this){const r=this.allocateCursor(null,this.head);for(;r.next!==null;){const i=r.next;r.next=i.next,e.call(n,i.data,i,this)}this.releaseCursor()}forEachRight(e,n=this){const r=this.allocateCursor(this.tail,null);for(;r.prev!==null;){const i=r.prev;r.prev=i.prev,e.call(n,i.data,i,this)}this.releaseCursor()}reduce(e,n,r=this){let i=this.allocateCursor(null,this.head),s=n,a;for(;i.next!==null;)a=i.next,i.next=a.next,s=e.call(r,s,a.data,a,this);return this.releaseCursor(),s}reduceRight(e,n,r=this){let i=this.allocateCursor(this.tail,null),s=n,a;for(;i.prev!==null;)a=i.prev,i.prev=a.prev,s=e.call(r,s,a.data,a,this);return this.releaseCursor(),s}some(e,n=this){for(let r=this.head;r!==null;r=r.next)if(e.call(n,r.data,r,this))return!0;return!1}map(e,n=this){const r=new M;for(let i=this.head;i!==null;i=i.next)r.appendData(e.call(n,i.data,i,this));return r}filter(e,n=this){const r=new M;for(let i=this.head;i!==null;i=i.next)e.call(n,i.data,i,this)&&r.appendData(i.data);return r}nextUntil(e,n,r=this){if(e===null)return;const i=this.allocateCursor(null,e);for(;i.next!==null;){const s=i.next;if(i.next=s.next,n.call(r,s.data,s,this))break}this.releaseCursor()}prevUntil(e,n,r=this){if(e===null)return;const i=this.allocateCursor(e,null);for(;i.prev!==null;){const s=i.prev;if(i.prev=s.prev,n.call(r,s.data,s,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new M;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(M.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(M.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(M.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(M.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(M.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 pe(t){const e={};for(const n of Object.keys(t)){let r=t[n];r&&(Array.isArray(r)||r instanceof M?r=r.map(pe):r.constructor===Object&&(r=pe(r))),e[n]=r}return e}const gt=0,C=1,_=2,D=3,I=4,pt=5,Uo=6,j=7,X=8,$=9,L=10,N=11,E=12,R=13,we=14,H=15,W=16,V=17,nt=18,Ft=19,qt=20,P=21,w=22,et=23,It=24,B=25,Vo=0;function q(t){return t>=48&&t<=57}function Nt(t){return q(t)||t>=65&&t<=70||t>=97&&t<=102}function fn(t){return t>=65&&t<=90}function Ho(t){return t>=97&&t<=122}function Go(t){return fn(t)||Ho(t)}function qo(t){return t>=128}function de(t){return Go(t)||qo(t)||t===95}function jr(t){return de(t)||q(t)||t===45}function Qo(t){return t>=0&&t<=8||t===11||t>=14&&t<=31||t===127}function ge(t){return t===10||t===13||t===12}function wt(t){return ge(t)||t===32||t===9}function at(t,e){return!(t!==92||ge(e)||e===Vo)}function Le(t,e,n){return t===45?de(e)||e===45||at(e,n):de(t)?!0:t===92?at(t,e):!1}function Te(t,e,n){return t===43||t===45?q(e)?2:e===46&&q(n)?3:0:t===46?q(e)?2:0:q(t)?1:0}function Br(t){return t===65279||t===65534?1:0}const Xe=new Array(128),Ko=128,oe=130,Wr=131,pn=132,zr=133;for(let t=0;t<Xe.length;t++)Xe[t]=wt(t)&&oe||q(t)&&Wr||de(t)&&pn||Qo(t)&&zr||t||Ko;function _e(t){return t<128?Xe[t]:pn}function Ot(t,e){return e<t.length?t.charCodeAt(e):0}function Je(t,e,n){return n===13&&Ot(t,e+1)===10?2:1}function Ur(t,e,n){let r=t.charCodeAt(e);return fn(r)&&(r=r|32),r===n}function me(t,e,n,r){if(n-e!==r.length||e<0||n>t.length)return!1;for(let i=e;i<n;i++){const s=r.charCodeAt(i-e);let a=t.charCodeAt(i);if(fn(a)&&(a=a|32),a!==s)return!1}return!0}function Yo(t,e){for(;e>=0&&wt(t.charCodeAt(e));e--);return e+1}function Zt(t,e){for(;e<t.length&&wt(t.charCodeAt(e));e++);return e}function Ee(t,e){for(;e<t.length&&q(t.charCodeAt(e));e++);return e}function Rt(t,e){if(e+=2,Nt(Ot(t,e-1))){for(const r=Math.min(t.length,e+5);e<r&&Nt(Ot(t,e));e++);const n=Ot(t,e);wt(n)&&(e+=Je(t,e,n))}return e}function te(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(!jr(n)){if(at(n,Ot(t,e+1))){e=Rt(t,e)-1;continue}break}}return e}function Vr(t,e){let n=t.charCodeAt(e);if((n===43||n===45)&&(n=t.charCodeAt(e+=1)),q(n)&&(e=Ee(t,e+1),n=t.charCodeAt(e)),n===46&&q(t.charCodeAt(e+1))&&(e+=2,e=Ee(t,e)),Ur(t,e,101)){let r=0;n=t.charCodeAt(e+1),(n===45||n===43)&&(r=1,n=t.charCodeAt(e+2)),q(n)&&(e=Ee(t,e+1+r+1))}return e}function Oe(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(n===41){e++;break}at(n,Ot(t,e+1))&&(e=Rt(t,e))}return e}function Hr(t){if(t.length===1&&!Nt(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 Gr=["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"],Xo=16*1024;function ye(t=null,e){return t===null||t.length<e?new Uint32Array(Math.max(e+1024,Xo)):t}const wn=10,Jo=12,An=13;function Ln(t){const e=t.source,n=e.length,r=e.length>0?Br(e.charCodeAt(0)):0,i=ye(t.lines,n),s=ye(t.columns,n);let a=t.startLine,l=t.startColumn;for(let u=r;u<n;u++){const o=e.charCodeAt(u);i[u]=a,s[u]=l++,(o===wn||o===An||o===Jo)&&(o===An&&u+1<n&&e.charCodeAt(u+1)===wn&&(u++,i[u]=a,s[u]=l),a++,l=1)}i[n]=a,s[n]=l,t.lines=i,t.columns=s,t.computed=!0}class Zo{constructor(e,n,r,i){this.setSource(e,n,r,i),this.lines=null,this.columns=null}setSource(e="",n=0,r=1,i=1){this.source=e,this.startOffset=n,this.startLine=r,this.startColumn=i,this.computed=!1}getLocation(e,n){return this.computed||Ln(this),{source:n,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,n,r){return this.computed||Ln(this),{source:r,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 it=16777215,st=24,At=new Uint8Array(32);At[_]=w;At[P]=w;At[Ft]=qt;At[et]=It;function Tn(t){return At[t]!==0}class ta{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 r=e.length,i=ye(this.offsetAndType,e.length+1),s=ye(this.balance,e.length+1);let a=0,l=-1,u=0,o=e.length;this.offsetAndType=null,this.balance=null,s.fill(0),n(e,(c,h,p)=>{const f=a++;if(i[f]=c<<st|p,l===-1&&(l=h),s[f]=o,c===u){const d=s[o];s[o]=f,o=d,u=At[i[d]>>st]}else Tn(c)&&(o=f,u=At[c])}),i[a]=gt<<st|r,s[a]=a;for(let c=0;c<a;c++){const h=s[c];if(h<=c){const p=s[h];p!==c&&(s[c]=p)}else h>a&&(s[c]=a)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=a,this.offsetAndType=i,this.balance=s,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>st:gt}lookupTypeNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const r=this.offsetAndType[n]>>st;if(r!==R&&r!==B&&e--===0)return r}return gt}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&it:this.source.length}lookupOffsetNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const r=this.offsetAndType[n]>>st;if(r!==R&&r!==B&&e--===0)return n-this.tokenIndex}return gt}lookupValue(e,n){return e+=this.tokenIndex,e<this.tokenCount?me(this.source,this.offsetAndType[e-1]&it,this.offsetAndType[e]&it,n):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&it:this.offsetAndType[this.tokenCount]&it: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)===$&&this.source.charCodeAt(this.lookupOffset(n))===e:this.tokenType===$&&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]&it,n=this.offsetAndType[n],this.tokenType=n>>st,this.tokenEnd=n&it):(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>>st,this.tokenEnd=e&it):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=gt,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===R||this.tokenType===B;)this.next()}skipUntilBalanced(e,n){let r=e,i=0,s=0;t:for(;r<this.tokenCount;r++){if(i=this.balance[r],i<e)break t;switch(s=r>0?this.offsetAndType[r-1]&it:this.firstCharOffset,n(this.source.charCodeAt(s))){case 1:break t;case 2:r++;break t;default:Tn(this.offsetAndType[r]>>st)&&(r=i)}}this.skip(r-this.tokenIndex)}forEachToken(e){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){const i=r,s=this.offsetAndType[n],a=s&it,l=s>>st;r=a,e(l,i,a,n)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((n,r,i,s)=>{e[s]={idx:s,type:Gr[n],chunk:this.source.substring(r,i),balance:this.balance[s]}}),e}}function qr(t,e){function n(h){return h<l?t.charCodeAt(h):0}function r(){if(o=Vr(t,o),Le(n(o),n(o+1),n(o+2))){c=E,o=te(t,o);return}if(n(o)===37){c=N,o++;return}c=L}function i(){const h=o;if(o=te(t,o),me(t,h,o,"url")&&n(o)===40){if(o=Zt(t,o+1),n(o)===34||n(o)===39){c=_,o=h+4;return}a();return}if(n(o)===40){c=_,o++;return}c=C}function s(h){for(h||(h=n(o++)),c=pt;o<t.length;o++){const p=t.charCodeAt(o);switch(_e(p)){case h:o++;return;case oe:if(ge(p)){o+=Je(t,o,p),c=Uo;return}break;case 92:if(o===t.length-1)break;const f=n(o+1);ge(f)?o+=Je(t,o+1,f):at(p,f)&&(o=Rt(t,o)-1);break}}}function a(){for(c=j,o=Zt(t,o);o<t.length;o++){const h=t.charCodeAt(o);switch(_e(h)){case 41:o++;return;case oe:if(o=Zt(t,o),n(o)===41||o>=t.length){o<t.length&&o++;return}o=Oe(t,o),c=X;return;case 34:case 39:case 40:case zr:o=Oe(t,o),c=X;return;case 92:if(at(h,n(o+1))){o=Rt(t,o)-1;break}o=Oe(t,o),c=X;return}}}t=String(t||"");const l=t.length;let u=Br(n(0)),o=u,c;for(;o<l;){const h=t.charCodeAt(o);switch(_e(h)){case oe:c=R,o=Zt(t,o+1);break;case 34:s();break;case 35:jr(n(o+1))||at(n(o+1),n(o+2))?(c=I,o=te(t,o+1)):(c=$,o++);break;case 39:s();break;case 40:c=P,o++;break;case 41:c=w,o++;break;case 43:Te(h,n(o+1),n(o+2))?r():(c=$,o++);break;case 44:c=nt,o++;break;case 45:Te(h,n(o+1),n(o+2))?r():n(o+1)===45&&n(o+2)===62?(c=H,o=o+3):Le(h,n(o+1),n(o+2))?i():(c=$,o++);break;case 46:Te(h,n(o+1),n(o+2))?r():(c=$,o++);break;case 47:n(o+1)===42?(c=B,o=t.indexOf("*/",o+2),o=o===-1?t.length:o+2):(c=$,o++);break;case 58:c=W,o++;break;case 59:c=V,o++;break;case 60:n(o+1)===33&&n(o+2)===45&&n(o+3)===45?(c=we,o=o+4):(c=$,o++);break;case 64:Le(n(o+1),n(o+2),n(o+3))?(c=D,o=te(t,o+1)):(c=$,o++);break;case 91:c=Ft,o++;break;case 92:at(h,n(o+1))?i():(c=$,o++);break;case 93:c=qt,o++;break;case 123:c=et,o++;break;case 125:c=It,o++;break;case Wr:r();break;case pn:i();break;default:c=$,o++}e(c,u,u=o)}}const _n=45;function ea(t,e){return e=e||0,t.length-e>=2&&t.charCodeAt(e)===_n&&t.charCodeAt(e+1)===_n}const Ze=92,Qr=34,na=39;function Kr(t){const e=t.length,n=t.charCodeAt(0),r=n===Qr||n===na?1:0,i=r===1&&e>1&&t.charCodeAt(e-1)===n?e-2:e-1;let s="";for(let a=r;a<=i;a++){let l=t.charCodeAt(a);if(l===Ze){if(a===i){a!==e-1&&(s=t.substr(a+1));break}if(l=t.charCodeAt(++a),at(Ze,l)){const u=a-1,o=Rt(t,u);a=o-1,s+=Hr(t.substring(u+1,o))}else l===13&&t.charCodeAt(a+1)===10&&a++}else s+=t[a]}return s}function ra(t,e){const r=Qr;let i="",s=!1;for(let a=0;a<t.length;a++){const l=t.charCodeAt(a);if(l===0){i+="�";continue}if(l<=31||l===127){i+="\\"+l.toString(16),s=!0;continue}l===r||l===Ze?(i+="\\"+t.charAt(a),s=!1):(s&&(Nt(l)||wt(l))&&(i+=" "),i+=t.charAt(a),s=!1)}return'"'+i+'"'}const ia=32,tn=92,sa=34,oa=39,aa=40,Yr=41;function la(t){const e=t.length;let n=4,r=t.charCodeAt(e-1)===Yr?e-2:e-1,i="";for(;n<r&&wt(t.charCodeAt(n));)n++;for(;n<r&&wt(t.charCodeAt(r));)r--;for(let s=n;s<=r;s++){let a=t.charCodeAt(s);if(a===tn){if(s===r){s!==e-1&&(i=t.substr(s+1));break}if(a=t.charCodeAt(++s),at(tn,a)){const l=s-1,u=Rt(t,l);s=u-1,i+=Hr(t.substring(l+1,u))}else a===13&&t.charCodeAt(s+1)===10&&s++}else i+=t[s]}return i}function ca(t){let e="",n=!1;for(let r=0;r<t.length;r++){const i=t.charCodeAt(r);if(i===0){e+="�";continue}if(i<=31||i===127){e+="\\"+i.toString(16),n=!0;continue}i===ia||i===tn||i===sa||i===oa||i===aa||i===Yr?(e+="\\"+t.charAt(r),n=!1):(n&&Nt(i)&&(e+=" "),e+=t.charAt(r),n=!1)}return"url("+e+")"}const{hasOwnProperty:dn}=Object.prototype,Bt=function(){};function En(t){return typeof t=="function"?t:Bt}function On(t,e){return function(n,r,i){n.type===e&&t.call(this,n,r,i)}}function ua(t,e){const n=e.structure,r=[];for(const i in n){if(dn.call(n,i)===!1)continue;let s=n[i];const a={name:i,type:!1,nullable:!1};Array.isArray(s)||(s=[s]);for(const l of s)l===null?a.nullable=!0:typeof l=="string"?a.type="node":Array.isArray(l)&&(a.type="list");a.type&&r.push(a)}return r.length?{context:e.walkContext,fields:r}:null}function ha(t){const e={};for(const n in t.node)if(dn.call(t.node,n)){const r=t.node[n];if(!r.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");e[n]=ua(n,r)}return e}function $n(t,e){const n=t.fields.slice(),r=t.context,i=typeof r=="string";return e&&n.reverse(),function(s,a,l,u){let o;i&&(o=a[r],a[r]=s);for(const c of n){const h=s[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}}i&&(a[r]=o)}}function Pn({StyleSheet:t,Atrule:e,Rule:n,Block:r,DeclarationList:i}){return{Atrule:{StyleSheet:t,Atrule:e,Rule:n,Block:r},Rule:{StyleSheet:t,Atrule:e,Rule:n,Block:r},Declaration:{StyleSheet:t,Atrule:e,Rule:n,Block:r,DeclarationList:i}}}function fa(t){const e=ha(t),n={},r={},i=Symbol("break-walk"),s=Symbol("skip-node");for(const o in e)dn.call(e,o)&&e[o]!==null&&(n[o]=$n(e[o],!1),r[o]=$n(e[o],!0));const a=Pn(n),l=Pn(r),u=function(o,c){function h(b,x,A){const T=p.call(k,b,x,A);return T===i?!0:T===s?!1:!!(d.hasOwnProperty(b.type)&&d[b.type](b,k,h,S)||f.call(k,b,x,A)===i)}let p=Bt,f=Bt,d=n,S=(b,x,A,T)=>b||h(x,A,T);const k={break:i,skip:s,root:o,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof c=="function")p=c;else if(c&&(p=En(c.enter),f=En(c.leave),c.reverse&&(d=r),c.visit)){if(a.hasOwnProperty(c.visit))d=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(", ")+")");p=On(p,c.visit),f=On(f,c.visit)}if(p===Bt&&f===Bt)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");h(o)};return u.break=i,u.skip=s,u.find=function(o,c){let h=null;return u(o,function(p,f,d){if(c.call(this,p,f,d))return h=p,i}),h},u.findLast=function(o,c){let h=null;return u(o,{reverse:!0,enter(p,f,d){if(c.call(this,p,f,d))return h=p,i}}),h},u.findAll=function(o,c){const h=[];return u(o,function(p,f,d){c.call(this,p,f,d)&&h.push(p)}),h},u}const ot=43,G=45,ae=110,bt=!0,pa=!1;function le(t,e){let n=this.tokenStart+t;const r=this.charCodeAt(n);for((r===ot||r===G)&&(e&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)q(this.charCodeAt(n))||this.error("Integer is expected",n)}function Tt(t){return le.call(this,0,t)}function dt(t,e){if(!this.cmpChar(this.tokenStart+t,e)){let n="";switch(e){case ae:n="N is expected";break;case G:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+t)}}function $e(){let t=0,e=0,n=this.tokenType;for(;n===R||n===B;)n=this.lookupType(++t);if(n!==L)if(this.isDelim(ot,t)||this.isDelim(G,t)){e=this.isDelim(ot,t)?ot:G;do n=this.lookupType(++t);while(n===R||n===B);n!==L&&(this.skip(t),Tt.call(this,bt))}else return null;return t>0&&this.skip(t),e===0&&(n=this.charCodeAt(this.tokenStart),n!==ot&&n!==G&&this.error("Number sign is expected")),Tt.call(this,e!==0),e===G?"-"+this.consume(L):this.consume(L)}const da="AnPlusB",ga={a:[String,null],b:[String,null]};function Xr(){const t=this.tokenStart;let e=null,n=null;if(this.tokenType===L)Tt.call(this,pa),n=this.consume(L);else if(this.tokenType===C&&this.cmpChar(this.tokenStart,G))switch(e="-1",dt.call(this,1,ae),this.tokenEnd-this.tokenStart){case 2:this.next(),n=$e.call(this);break;case 3:dt.call(this,2,G),this.next(),this.skipSC(),Tt.call(this,bt),n="-"+this.consume(L);break;default:dt.call(this,2,G),le.call(this,3,bt),this.next(),n=this.substrToCursor(t+2)}else if(this.tokenType===C||this.isDelim(ot)&&this.lookupType(1)===C){let r=0;switch(e="1",this.isDelim(ot)&&(r=1,this.next()),dt.call(this,0,ae),this.tokenEnd-this.tokenStart){case 1:this.next(),n=$e.call(this);break;case 2:dt.call(this,1,G),this.next(),this.skipSC(),Tt.call(this,bt),n="-"+this.consume(L);break;default:dt.call(this,1,G),le.call(this,2,bt),this.next(),n=this.substrToCursor(t+r+1)}}else if(this.tokenType===E){const r=this.charCodeAt(this.tokenStart),i=r===ot||r===G;let s=this.tokenStart+i;for(;s<this.tokenEnd&&q(this.charCodeAt(s));s++);s===this.tokenStart+i&&this.error("Integer is expected",this.tokenStart+i),dt.call(this,s-this.tokenStart,ae),e=this.substring(t,s),s+1===this.tokenEnd?(this.next(),n=$e.call(this)):(dt.call(this,s-this.tokenStart+1,G),s+2===this.tokenEnd?(this.next(),this.skipSC(),Tt.call(this,bt),n="-"+this.consume(L)):(le.call(this,s-this.tokenStart+2,bt),this.next(),n=this.substrToCursor(s+1)))}else this.error();return e!==null&&e.charCodeAt(0)===ot&&(e=e.substr(1)),n!==null&&n.charCodeAt(0)===ot&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(t,this.tokenStart),a:e,b:n}}function Jr(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 ma=Object.freeze(Object.defineProperty({__proto__:null,generate:Jr,name:da,parse:Xr,structure:ga},Symbol.toStringTag,{value:"Module"}));function In(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function ya(){for(let t=1,e;e=this.lookupType(t);t++){if(e===It)return!0;if(e===et||e===D)return!1}return!1}const Sa="Atrule",ka="atrule",ba={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function Zr(t=!1){const e=this.tokenStart;let n,r,i=null,s=null;switch(this.eat(D),n=this.substrToCursor(e+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==et&&this.tokenType!==V&&(this.parseAtrulePrelude?i=this.parseWithFallback(this.AtrulePrelude.bind(this,n,t),In):i=In.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case V:this.next();break;case et:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?s=this.atrule[r].block.call(this,t):s=this.Block(ya.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:n,prelude:i,block:s}}function ti(t){this.token(D,"@"+t.name),t.prelude!==null&&this.node(t.prelude),t.block?this.node(t.block):this.token(V,";")}const Ca=Object.freeze(Object.defineProperty({__proto__:null,generate:ti,name:Sa,parse:Zr,structure:ba,walkContext:ka},Symbol.toStringTag,{value:"Module"})),va="AtrulePrelude",xa="atrulePrelude",wa={children:[[]]};function ei(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!==et&&this.tokenType!==V&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function ni(t){this.children(t)}const Aa=Object.freeze(Object.defineProperty({__proto__:null,generate:ni,name:va,parse:ei,structure:wa,walkContext:xa},Symbol.toStringTag,{value:"Module"})),La=36,ri=42,ce=61,Ta=94,en=124,_a=126;function Ea(){this.eof&&this.error("Unexpected end of input");const t=this.tokenStart;let e=!1;return this.isDelim(ri)?(e=!0,this.next()):this.isDelim(en)||this.eat(C),this.isDelim(en)?this.charCodeAt(this.tokenStart+1)!==ce?(this.next(),this.eat(C)):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 Oa(){const t=this.tokenStart,e=this.charCodeAt(t);return e!==ce&&e!==_a&&e!==Ta&&e!==La&&e!==ri&&e!==en&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==ce&&(this.isDelim(ce)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(t)}const $a="AttributeSelector",Pa={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function ii(){const t=this.tokenStart;let e,n=null,r=null,i=null;return this.eat(Ft),this.skipSC(),e=Ea.call(this),this.skipSC(),this.tokenType!==qt&&(this.tokenType!==C&&(n=Oa.call(this),this.skipSC(),r=this.tokenType===pt?this.String():this.Identifier(),this.skipSC()),this.tokenType===C&&(i=this.consume(C),this.skipSC())),this.eat(qt),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:r,flags:i}}function si(t){this.token($,"["),this.node(t.name),t.matcher!==null&&(this.tokenize(t.matcher),this.node(t.value)),t.flags!==null&&this.token(C,t.flags),this.token($,"]")}const Ia=Object.freeze(Object.defineProperty({__proto__:null,generate:si,name:$a,parse:ii,structure:Pa},Symbol.toStringTag,{value:"Module"})),Na=38;function oi(){return this.Raw(null,!0)}function Nn(){return this.parseWithFallback(this.Rule,oi)}function Rn(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Ra(){if(this.tokenType===V)return Rn.call(this,this.tokenIndex);const t=this.parseWithFallback(this.Declaration,Rn);return this.tokenType===V&&this.next(),t}const Da="Block",Ma="block",Fa={children:[["Atrule","Rule","Declaration"]]};function ai(t){const e=t?Ra:Nn,n=this.tokenStart;let r=this.createList();this.eat(et);t:for(;!this.eof;)switch(this.tokenType){case It:break t;case R:case B:this.next();break;case D:r.push(this.parseWithFallback(this.Atrule.bind(this,t),oi));break;default:t&&this.isDelim(Na)?r.push(Nn.call(this)):r.push(e.call(this))}return this.eof||this.eat(It),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function li(t){this.token(et,"{"),this.children(t,e=>{e.type==="Declaration"&&this.token(V,";")}),this.token(It,"}")}const ja=Object.freeze(Object.defineProperty({__proto__:null,generate:li,name:Da,parse:ai,structure:Fa,walkContext:Ma},Symbol.toStringTag,{value:"Module"})),Ba="Brackets",Wa={children:[[]]};function ci(t,e){const n=this.tokenStart;let r=null;return this.eat(Ft),r=t.call(this,e),this.eof||this.eat(qt),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function ui(t){this.token($,"["),this.children(t),this.token($,"]")}const za=Object.freeze(Object.defineProperty({__proto__:null,generate:ui,name:Ba,parse:ci,structure:Wa},Symbol.toStringTag,{value:"Module"})),Ua="CDC",Va=[];function hi(){const t=this.tokenStart;return this.eat(H),{type:"CDC",loc:this.getLocation(t,this.tokenStart)}}function fi(){this.token(H,"-->")}const Ha=Object.freeze(Object.defineProperty({__proto__:null,generate:fi,name:Ua,parse:hi,structure:Va},Symbol.toStringTag,{value:"Module"})),Ga="CDO",qa=[];function pi(){const t=this.tokenStart;return this.eat(we),{type:"CDO",loc:this.getLocation(t,this.tokenStart)}}function di(){this.token(we,"<!--")}const Qa=Object.freeze(Object.defineProperty({__proto__:null,generate:di,name:Ga,parse:pi,structure:qa},Symbol.toStringTag,{value:"Module"})),Ka=46,Ya="ClassSelector",Xa={name:String};function gi(){return this.eatDelim(Ka),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(C)}}function mi(t){this.token($,"."),this.token(C,t.name)}const Ja=Object.freeze(Object.defineProperty({__proto__:null,generate:mi,name:Ya,parse:gi,structure:Xa},Symbol.toStringTag,{value:"Module"})),Za=43,Dn=47,tl=62,el=126,nl="Combinator",rl={name:String};function yi(){const t=this.tokenStart;let e;switch(this.tokenType){case R:e=" ";break;case $:switch(this.charCodeAt(this.tokenStart)){case tl:case Za:case el:this.next();break;case Dn:this.next(),this.eatIdent("deep"),this.eatDelim(Dn);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t);break}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function Si(t){this.tokenize(t.name)}const il=Object.freeze(Object.defineProperty({__proto__:null,generate:Si,name:nl,parse:yi,structure:rl},Symbol.toStringTag,{value:"Module"})),sl=42,ol=47,al="Comment",ll={value:String};function ki(){const t=this.tokenStart;let e=this.tokenEnd;return this.eat(B),e-t+2>=2&&this.charCodeAt(e-2)===sl&&this.charCodeAt(e-1)===ol&&(e-=2),{type:"Comment",loc:this.getLocation(t,this.tokenStart),value:this.substring(t+2,e)}}function bi(t){this.token(B,"/*"+t.value+"*/")}const cl=Object.freeze(Object.defineProperty({__proto__:null,generate:bi,name:al,parse:ki,structure:ll},Symbol.toStringTag,{value:"Module"})),ul=new Set([W,w,gt]),hl="Condition",fl={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function Mn(t){return this.lookupTypeNonSC(1)===C&&ul.has(this.lookupTypeNonSC(2))?this.Feature(t):this.FeatureRange(t)}const pl={media:Mn,container:Mn,supports(){return this.SupportsDeclaration()}};function Ci(t="media"){const e=this.createList();t:for(;!this.eof;)switch(this.tokenType){case B:case R:this.next();continue;case C:e.push(this.Identifier());break;case P:{let n=this.parseWithFallback(()=>pl[t].call(this,t),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(P);const r=this.Condition(t);return this.eat(w),r},()=>this.GeneralEnclosed(t))),e.push(n);break}case _:{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 vi(t){t.children.forEach(e=>{e.type==="Condition"?(this.token(P,"("),this.node(e),this.token(w,")")):this.node(e)})}const dl=Object.freeze(Object.defineProperty({__proto__:null,generate:vi,name:hl,parse:Ci,structure:fl},Symbol.toStringTag,{value:"Module"})),xi=33,gl=35,ml=36,yl=38,Sl=42,kl=43,Fn=47;function bl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function Cl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function vl(){const t=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==V&&this.isDelim(xi)===!1&&this.isBalanceEdge(t)===!1&&this.error(),e}const xl="Declaration",wl="declaration",Al={important:[Boolean,String],property:String,value:["Value","Raw"]};function wi(){const t=this.tokenStart,e=this.tokenIndex,n=Ll.call(this),r=ea(n),i=r?this.parseCustomProperty:this.parseValue,s=r?Cl:bl;let a=!1,l;this.skipSC(),this.eat(W);const u=this.tokenIndex;if(r||this.skipSC(),i?l=this.parseWithFallback(vl,s):l=s.call(this,this.tokenIndex),r&&l.type==="Value"&&l.children.isEmpty){for(let o=u-this.tokenIndex;o<=0;o++)if(this.lookupType(o)===R){l.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(xi)&&(a=Tl.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==V&&this.isBalanceEdge(e)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.tokenStart),important:a,property:n,value:l}}function Ai(t){this.token(C,t.property),this.token(W,":"),this.node(t.value),t.important&&(this.token($,"!"),this.token(C,t.important===!0?"important":t.important))}function Ll(){const t=this.tokenStart;if(this.tokenType===$)switch(this.charCodeAt(this.tokenStart)){case Sl:case ml:case kl:case gl:case yl:this.next();break;case Fn:this.next(),this.isDelim(Fn)&&this.next();break}return this.tokenType===I?this.eat(I):this.eat(C),this.substrToCursor(t)}function Tl(){this.eat($),this.skipSC();const t=this.consume(C);return t==="important"?!0:t}const _l=Object.freeze(Object.defineProperty({__proto__:null,generate:Ai,name:xl,parse:wi,structure:Al,walkContext:wl},Symbol.toStringTag,{value:"Module"})),El=38;function Pe(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const Ol="DeclarationList",$l={children:[["Declaration","Atrule","Rule"]]};function Li(){const t=this.createList();for(;!this.eof;)switch(this.tokenType){case R:case B:case V:this.next();break;case D:t.push(this.parseWithFallback(this.Atrule.bind(this,!0),Pe));break;default:this.isDelim(El)?t.push(this.parseWithFallback(this.Rule,Pe)):t.push(this.parseWithFallback(this.Declaration,Pe))}return{type:"DeclarationList",loc:this.getLocationFromList(t),children:t}}function Ti(t){this.children(t,e=>{e.type==="Declaration"&&this.token(V,";")})}const Pl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ti,name:Ol,parse:Li,structure:$l},Symbol.toStringTag,{value:"Module"})),Il="Dimension",Nl={value:String,unit:String};function _i(){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 Ei(t){this.token(E,t.value+t.unit)}const Rl=Object.freeze(Object.defineProperty({__proto__:null,generate:Ei,name:Il,parse:_i,structure:Nl},Symbol.toStringTag,{value:"Module"})),Dl=47,Ml="Feature",Fl={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function Oi(t){const e=this.tokenStart;let n,r=null;if(this.eat(P),this.skipSC(),n=this.consume(C),this.skipSC(),this.tokenType!==w){switch(this.eat(W),this.skipSC(),this.tokenType){case L:this.lookupNonWSType(1)===$?r=this.Ratio():r=this.Number();break;case E:r=this.Dimension();break;case C:r=this.Identifier();break;case _:r=this.parseWithFallback(()=>{const i=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(Dl)&&this.error(),i},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(w),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:t,name:n,value:r}}function $i(t){this.token(P,"("),this.token(C,t.name),t.value!==null&&(this.token(W,":"),this.node(t.value)),this.token(w,")")}const jl=Object.freeze(Object.defineProperty({__proto__:null,generate:$i,name:Ml,parse:Oi,structure:Fl},Symbol.toStringTag,{value:"Module"})),Bl="FeatureFunction",Wl={kind:String,feature:String,value:["Declaration","Selector"]};function zl(t,e){const r=(this.features[t]||{})[e];return typeof r!="function"&&this.error(`Unknown feature ${e}()`),r}function Pi(t="unknown"){const e=this.tokenStart,n=this.consumeFunctionName(),r=zl.call(this,t,n.toLowerCase());this.skipSC();const i=this.parseWithFallback(()=>{const s=this.tokenIndex,a=r.call(this);return this.eof===!1&&this.isBalanceEdge(s)===!1&&this.error(),a},()=>this.Raw(null,!1));return this.eof||this.eat(w),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:t,feature:n,value:i}}function Ii(t){this.token(_,t.feature+"("),this.node(t.value),this.token(w,")")}const Ul=Object.freeze(Object.defineProperty({__proto__:null,generate:Ii,name:Bl,parse:Pi,structure:Wl},Symbol.toStringTag,{value:"Module"})),jn=47,Vl=60,Bn=61,Hl=62,Gl="FeatureRange",ql={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 Ie(){switch(this.skipSC(),this.tokenType){case L:return this.isDelim(jn,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case E:return this.Dimension();case C:return this.Identifier();case _:return this.parseWithFallback(()=>{const t=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(jn)&&this.error(),t},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function Wn(t){if(this.skipSC(),this.isDelim(Vl)||this.isDelim(Hl)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(Bn)?(this.next(),e+"="):e}if(this.isDelim(Bn))return"=";this.error(`Expected ${t?'":", ':""}"<", ">", "=" or ")"`)}function Ni(t="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(P);const n=Ie.call(this),r=Wn.call(this,n.type==="Identifier"),i=Ie.call(this);let s=null,a=null;return this.lookupNonWSType(0)!==w&&(s=Wn.call(this),a=Ie.call(this)),this.skipSC(),this.eat(w),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:t,left:n,leftComparison:r,middle:i,rightComparison:s,right:a}}function Ri(t){this.token(P,"("),this.node(t.left),this.tokenize(t.leftComparison),this.node(t.middle),t.right&&(this.tokenize(t.rightComparison),this.node(t.right)),this.token(w,")")}const Ql=Object.freeze(Object.defineProperty({__proto__:null,generate:Ri,name:Gl,parse:Ni,structure:ql},Symbol.toStringTag,{value:"Module"})),Kl="Function",Yl="function",Xl={name:String,children:[[]]};function Di(t,e){const n=this.tokenStart,r=this.consumeFunctionName(),i=r.toLowerCase();let s;return s=e.hasOwnProperty(i)?e[i].call(this,e):t.call(this,e),this.eof||this.eat(w),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:s}}function Mi(t){this.token(_,t.name+"("),this.children(t),this.token(w,")")}const Jl=Object.freeze(Object.defineProperty({__proto__:null,generate:Mi,name:Kl,parse:Di,structure:Xl,walkContext:Yl},Symbol.toStringTag,{value:"Module"})),Zl="GeneralEnclosed",tc={kind:String,function:[String,null],children:[[]]};function Fi(t){const e=this.tokenStart;let n=null;this.tokenType===_?n=this.consumeFunctionName():this.eat(P);const r=this.parseWithFallback(()=>{const i=this.tokenIndex,s=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(i)===!1&&this.error(),s},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(w),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:t,function:n,children:r}}function ji(t){t.function?this.token(_,t.function+"("):this.token(P,"("),this.children(t),this.token(w,")")}const ec=Object.freeze(Object.defineProperty({__proto__:null,generate:ji,name:Zl,parse:Fi,structure:tc},Symbol.toStringTag,{value:"Module"})),nc="XXX",rc="Hash",ic={value:String};function Bi(){const t=this.tokenStart;return this.eat(I),{type:"Hash",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t+1)}}function Wi(t){this.token(I,"#"+t.value)}const sc=Object.freeze(Object.defineProperty({__proto__:null,generate:Wi,name:rc,parse:Bi,structure:ic,xxx:nc},Symbol.toStringTag,{value:"Module"})),oc="Identifier",ac={name:String};function zi(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(C)}}function Ui(t){this.token(C,t.name)}const lc=Object.freeze(Object.defineProperty({__proto__:null,generate:Ui,name:oc,parse:zi,structure:ac},Symbol.toStringTag,{value:"Module"})),cc="IdSelector",uc={name:String};function Vi(){const t=this.tokenStart;return this.eat(I),{type:"IdSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t+1)}}function Hi(t){this.token($,"#"+t.name)}const hc=Object.freeze(Object.defineProperty({__proto__:null,generate:Hi,name:cc,parse:Vi,structure:uc},Symbol.toStringTag,{value:"Module"})),fc=46,pc="Layer",dc={name:String};function Gi(){let t=this.tokenStart,e=this.consume(C);for(;this.isDelim(fc);)this.eat($),e+="."+this.consume(C);return{type:"Layer",loc:this.getLocation(t,this.tokenStart),name:e}}function qi(t){this.tokenize(t.name)}const gc=Object.freeze(Object.defineProperty({__proto__:null,generate:qi,name:pc,parse:Gi,structure:dc},Symbol.toStringTag,{value:"Module"})),mc="LayerList",yc={children:[["Layer"]]};function Qi(){const