@oddbird/css-anchor-positioning
Version:
Polyfill for the proposed CSS anchor positioning spec
1 lines • 116 kB
JavaScript
(function(H,I){typeof exports=="object"&&typeof module!="undefined"?module.exports=I():typeof define=="function"&&define.amd?define(I):(H=typeof globalThis!="undefined"?globalThis:H||self,H.CssAnchorPositioning=I())})(this,function(){"use strict";var wp=Object.defineProperty,Tp=Object.defineProperties;var Ap=Object.getOwnPropertyDescriptors;var go=Object.getOwnPropertySymbols;var vp=Object.prototype.hasOwnProperty,Ep=Object.prototype.propertyIsEnumerable;var mo=(H,I,j)=>I in H?wp(H,I,{enumerable:!0,configurable:!0,writable:!0,value:j}):H[I]=j,G=(H,I)=>{for(var j in I||(I={}))vp.call(I,j)&&mo(H,j,I[j]);if(go)for(var j of go(I))Ep.call(I,j)&&mo(H,j,I[j]);return H},tt=(H,I)=>Tp(H,Ap(I));var R=(H,I,j)=>new Promise((Wt,st)=>{var Fe=ct=>{try{ie(j.next(ct))}catch(oe){st(oe)}},Me=ct=>{try{ie(j.throw(ct))}catch(oe){st(oe)}},ie=ct=>ct.done?Wt(ct.value):Promise.resolve(ct.value).then(Fe,Me);ie((j=j.apply(H,I)).next())});const H=Math.min,I=Math.max,j=Math.round,Wt=Math.floor,st=t=>({x:t,y:t});function Fe(t,e){return typeof t=="function"?t(e):t}function Me(t){return G({top:0,right:0,bottom:0,left:0},t)}function ie(t){return typeof t!="number"?Me(t):{top:t,right:t,bottom:t,left:t}}function ct(t){const{x:e,y:n,width:r,height:s}=t;return{width:r,height:s,top:n,left:e,right:e+r,bottom:n+s,x:e,y:n}}function oe(t,e){return R(this,null,function*(){var n;e===void 0&&(e={});const{x:r,y:s,platform:o,rects:a,elements:c,strategy:u}=t,{boundary:i="clippingAncestors",rootBoundary:l="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=Fe(e,t),g=ie(p),y=c[f?h==="floating"?"reference":"floating":h],b=ct(yield o.getClippingRect({element:(n=yield o.isElement==null?void 0:o.isElement(y))==null||n?y:y.contextElement||(yield o.getDocumentElement==null?void 0:o.getDocumentElement(c.floating)),boundary:i,rootBoundary:l,strategy:u})),C=h==="floating"?{x:r,y:s,width:a.floating.width,height:a.floating.height}:a.reference,v=yield o.getOffsetParent==null?void 0:o.getOffsetParent(c.floating),U=(yield o.isElement==null?void 0:o.isElement(v))?(yield o.getScale==null?void 0:o.getScale(v))||{x:1,y:1}:{x:1,y:1},k=ct(o.convertOffsetParentRelativeRectToViewportRelativeRect?yield o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:c,rect:C,offsetParent:v,strategy:u}):C);return{top:(b.top-k.top+g.top)/U.y,bottom:(k.bottom-b.bottom+g.bottom)/U.y,left:(b.left-k.left+g.left)/U.x,right:(k.right-b.right+g.right)/U.x}})}function me(){return typeof window!="undefined"}function zt(t){return Ln(t)?(t.nodeName||"").toLowerCase():"#document"}function it(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function kt(t){var e;return(e=(Ln(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function Ln(t){return me()?t instanceof Node||t instanceof it(t).Node:!1}function ht(t){return me()?t instanceof Element||t instanceof it(t).Element:!1}function St(t){return me()?t instanceof HTMLElement||t instanceof it(t).HTMLElement:!1}function Pn(t){return!me()||typeof ShadowRoot=="undefined"?!1:t instanceof ShadowRoot||t instanceof it(t).ShadowRoot}function ae(t){const{overflow:e,overflowX:n,overflowY:r,display:s}=ft(t);return/auto|scroll|overlay|hidden|clip/.test(e+r+n)&&!["inline","contents"].includes(s)}function ko(t){return["table","td","th"].includes(zt(t))}function ke(t){return[":popover-open",":modal"].some(e=>{try{return t.matches(e)}catch(n){return!1}})}function je(t){const e=Be(),n=ht(t)?ft(t):t;return["transform","translate","scale","rotate","perspective"].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)||["transform","translate","scale","rotate","perspective","filter"].some(r=>(n.willChange||"").includes(r))||["paint","layout","strict","content"].some(r=>(n.contain||"").includes(r))}function So(t){let e=$t(t);for(;St(e)&&!Ht(e);){if(je(e))return e;if(ke(e))return null;e=$t(e)}return null}function Be(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}function Ht(t){return["html","body","#document"].includes(zt(t))}function ft(t){return it(t).getComputedStyle(t)}function Se(t){return ht(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function $t(t){if(zt(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Pn(t)&&t.host||kt(t);return Pn(e)?e.host:e}function On(t){const e=$t(t);return Ht(e)?t.ownerDocument?t.ownerDocument.body:t.body:St(e)&&ae(e)?e:On(e)}function le(t,e,n){var r;e===void 0&&(e=[]),n===void 0&&(n=!0);const s=On(t),o=s===((r=t.ownerDocument)==null?void 0:r.body),a=it(s);if(o){const c=Ue(a);return e.concat(a,a.visualViewport||[],ae(s)?s:[],c&&n?le(c):[])}return e.concat(s,le(s,[],n))}function Ue(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function Rn(t){const e=ft(t);let n=parseFloat(e.width)||0,r=parseFloat(e.height)||0;const s=St(t),o=s?t.offsetWidth:n,a=s?t.offsetHeight:r,c=j(n)!==o||j(r)!==a;return c&&(n=o,r=a),{width:n,height:r,$:c}}function We(t){return ht(t)?t:t.contextElement}function Vt(t){const e=We(t);if(!St(e))return st(1);const n=e.getBoundingClientRect(),{width:r,height:s,$:o}=Rn(e);let a=(o?j(n.width):n.width)/r,c=(o?j(n.height):n.height)/s;return(!a||!Number.isFinite(a))&&(a=1),(!c||!Number.isFinite(c))&&(c=1),{x:a,y:c}}const yo=st(0);function In(t){const e=it(t);return!Be()||!e.visualViewport?yo:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function bo(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==it(t)?!1:e}function _t(t,e,n,r){e===void 0&&(e=!1),n===void 0&&(n=!1);const s=t.getBoundingClientRect(),o=We(t);let a=st(1);e&&(r?ht(r)&&(a=Vt(r)):a=Vt(t));const c=bo(o,n,r)?In(o):st(0);let u=(s.left+c.x)/a.x,i=(s.top+c.y)/a.y,l=s.width/a.x,h=s.height/a.y;if(o){const f=it(o),p=r&&ht(r)?it(r):r;let g=f,m=Ue(g);for(;m&&r&&p!==g;){const y=Vt(m),b=m.getBoundingClientRect(),C=ft(m),v=b.left+(m.clientLeft+parseFloat(C.paddingLeft))*y.x,U=b.top+(m.clientTop+parseFloat(C.paddingTop))*y.y;u*=y.x,i*=y.y,l*=y.x,h*=y.y,u+=v,i+=U,g=it(m),m=Ue(g)}}return ct({width:l,height:h,x:u,y:i})}function ze(t,e){const n=Se(t).scrollLeft;return e?e.left+n:_t(kt(t)).left+n}function _n(t,e,n){n===void 0&&(n=!1);const r=t.getBoundingClientRect(),s=r.left+e.scrollLeft-(n?0:ze(t,r)),o=r.top+e.scrollTop;return{x:s,y:o}}function xo(t){let{elements:e,rect:n,offsetParent:r,strategy:s}=t;const o=s==="fixed",a=kt(r),c=e?ke(e.floating):!1;if(r===a||c&&o)return n;let u={scrollLeft:0,scrollTop:0},i=st(1);const l=st(0),h=St(r);if((h||!h&&!o)&&((zt(r)!=="body"||ae(a))&&(u=Se(r)),St(r))){const p=_t(r);i=Vt(r),l.x=p.x+r.clientLeft,l.y=p.y+r.clientTop}const f=a&&!h&&!o?_n(a,u,!0):st(0);return{width:n.width*i.x,height:n.height*i.y,x:n.x*i.x-u.scrollLeft*i.x+l.x+f.x,y:n.y*i.y-u.scrollTop*i.y+l.y+f.y}}function Co(t){return Array.from(t.getClientRects())}function wo(t){const e=kt(t),n=Se(t),r=t.ownerDocument.body,s=I(e.scrollWidth,e.clientWidth,r.scrollWidth,r.clientWidth),o=I(e.scrollHeight,e.clientHeight,r.scrollHeight,r.clientHeight);let a=-n.scrollLeft+ze(t);const c=-n.scrollTop;return ft(r).direction==="rtl"&&(a+=I(e.clientWidth,r.clientWidth)-s),{width:s,height:o,x:a,y:c}}function To(t,e){const n=it(t),r=kt(t),s=n.visualViewport;let o=r.clientWidth,a=r.clientHeight,c=0,u=0;if(s){o=s.width,a=s.height;const i=Be();(!i||i&&e==="fixed")&&(c=s.offsetLeft,u=s.offsetTop)}return{width:o,height:a,x:c,y:u}}function Ao(t,e){const n=_t(t,!0,e==="fixed"),r=n.top+t.clientTop,s=n.left+t.clientLeft,o=St(t)?Vt(t):st(1),a=t.clientWidth*o.x,c=t.clientHeight*o.y,u=s*o.x,i=r*o.y;return{width:a,height:c,x:u,y:i}}function Nn(t,e,n){let r;if(e==="viewport")r=To(t,n);else if(e==="document")r=wo(kt(t));else if(ht(e))r=Ao(e,n);else{const s=In(t);r={x:e.x-s.x,y:e.y-s.y,width:e.width,height:e.height}}return ct(r)}function Dn(t,e){const n=$t(t);return n===e||!ht(n)||Ht(n)?!1:ft(n).position==="fixed"||Dn(n,e)}function vo(t,e){const n=e.get(t);if(n)return n;let r=le(t,[],!1).filter(c=>ht(c)&&zt(c)!=="body"),s=null;const o=ft(t).position==="fixed";let a=o?$t(t):t;for(;ht(a)&&!Ht(a);){const c=ft(a),u=je(a);!u&&c.position==="fixed"&&(s=null),(o?!u&&!s:!u&&c.position==="static"&&!!s&&["absolute","fixed"].includes(s.position)||ae(a)&&!u&&Dn(t,a))?r=r.filter(l=>l!==a):s=c,a=$t(a)}return e.set(t,r),r}function Eo(t){let{element:e,boundary:n,rootBoundary:r,strategy:s}=t;const a=[...n==="clippingAncestors"?ke(e)?[]:vo(e,this._c):[].concat(n),r],c=a[0],u=a.reduce((i,l)=>{const h=Nn(e,l,s);return i.top=I(h.top,i.top),i.right=H(h.right,i.right),i.bottom=H(h.bottom,i.bottom),i.left=I(h.left,i.left),i},Nn(e,c,s));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function $o(t){const{width:e,height:n}=Rn(t);return{width:e,height:n}}function Lo(t,e,n){const r=St(e),s=kt(e),o=n==="fixed",a=_t(t,!0,o,e);let c={scrollLeft:0,scrollTop:0};const u=st(0);function i(){u.x=ze(s)}if(r||!r&&!o)if((zt(e)!=="body"||ae(s))&&(c=Se(e)),r){const p=_t(e,!0,o,e);u.x=p.x+e.clientLeft,u.y=p.y+e.clientTop}else s&&i();o&&!r&&s&&i();const l=s&&!r&&!o?_n(s,c):st(0),h=a.left+c.scrollLeft-u.x-l.x,f=a.top+c.scrollTop-u.y-l.y;return{x:h,y:f,width:a.width,height:a.height}}function He(t){return ft(t).position==="static"}function Fn(t,e){if(!St(t)||ft(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return kt(t)===n&&(n=n.ownerDocument.body),n}function Mn(t,e){const n=it(t);if(ke(t))return n;if(!St(t)){let s=$t(t);for(;s&&!Ht(s);){if(ht(s)&&!He(s))return s;s=$t(s)}return n}let r=Fn(t,e);for(;r&&ko(r)&&He(r);)r=Fn(r,e);return r&&Ht(r)&&He(r)&&!je(r)?n:r||So(t)||n}const Po=function(t){return R(this,null,function*(){const e=this.getOffsetParent||Mn,n=this.getDimensions,r=yield n(t.floating);return{reference:Lo(t.reference,yield e(t.floating),t.strategy),floating:{x:0,y:0,width:r.width,height:r.height}}})};function Oo(t){return ft(t).direction==="rtl"}const q={convertOffsetParentRelativeRectToViewportRelativeRect:xo,getDocumentElement:kt,getClippingRect:Eo,getOffsetParent:Mn,getElementRects:Po,getClientRects:Co,getDimensions:$o,getScale:Vt,isElement:ht,isRTL:Oo};function jn(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ro(t,e){let n=null,r;const s=kt(t);function o(){var c;clearTimeout(r),(c=n)==null||c.disconnect(),n=null}function a(c,u){c===void 0&&(c=!1),u===void 0&&(u=1),o();const i=t.getBoundingClientRect(),{left:l,top:h,width:f,height:p}=i;if(c||e(),!f||!p)return;const g=Wt(h),m=Wt(s.clientWidth-(l+f)),y=Wt(s.clientHeight-(h+p)),b=Wt(l),v={rootMargin:-g+"px "+-m+"px "+-y+"px "+-b+"px",threshold:I(0,H(1,u))||1};let U=!0;function k(O){const w=O[0].intersectionRatio;if(w!==u){if(!U)return a();w?a(!1,w):r=setTimeout(()=>{a(!1,1e-7)},1e3)}w===1&&!jn(i,t.getBoundingClientRect())&&a(),U=!1}try{n=new IntersectionObserver(k,tt(G({},v),{root:s.ownerDocument}))}catch(O){n=new IntersectionObserver(k,v)}n.observe(t)}return a(!0),o}function Ve(t,e,n,r){r===void 0&&(r={});const{ancestorScroll:s=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:c=typeof IntersectionObserver=="function",animationFrame:u=!1}=r,i=We(t),l=s||o?[...i?le(i):[],...le(e)]:[];l.forEach(b=>{s&&b.addEventListener("scroll",n,{passive:!0}),o&&b.addEventListener("resize",n)});const h=i&&c?Ro(i,n):null;let f=-1,p=null;a&&(p=new ResizeObserver(b=>{let[C]=b;C&&C.target===i&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var v;(v=p)==null||v.observe(e)})),n()}),i&&!u&&p.observe(i),p.observe(e));let g,m=u?_t(t):null;u&&y();function y(){const b=_t(t);m&&!jn(m,b)&&n(),m=b,g=requestAnimationFrame(y)}return n(),()=>{var b;l.forEach(C=>{s&&C.removeEventListener("scroll",n),o&&C.removeEventListener("resize",n)}),h==null||h(),(b=p)==null||b.disconnect(),p=null,u&&cancelAnimationFrame(g)}}const Io=oe,{hasOwnProperty:Ge}=Object.prototype,ce=function(){};function Bn(t){return typeof t=="function"?t:ce}function Un(t,e){return function(n,r,s){n.type===e&&t.call(this,n,r,s)}}function _o(t,e){const n=e.structure,r=[];for(const s in n){if(Ge.call(n,s)===!1)continue;let o=n[s];const a={name:s,type:!1,nullable:!1};Array.isArray(o)||(o=[o]);for(const c of o)c===null?a.nullable=!0:typeof c=="string"?a.type="node":Array.isArray(c)&&(a.type="list");a.type&&r.push(a)}return r.length?{context:e.walkContext,fields:r}:null}function No(t){const e={};for(const n in t.node)if(Ge.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]=_o(n,r)}return e}function Wn(t,e){const n=t.fields.slice(),r=t.context,s=typeof r=="string";return e&&n.reverse(),function(o,a,c,u){let i;s&&(i=a[r],a[r]=o);for(const l of n){const h=o[l.name];if(!l.nullable||h){if(l.type==="list"){if(e?h.reduceRight(u,!1):h.reduce(u,!1))return!0}else if(c(h))return!0}}s&&(a[r]=i)}}function zn({StyleSheet:t,Atrule:e,Rule:n,Block:r,DeclarationList:s}){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:s}}}function Do(t){const e=No(t),n={},r={},s=Symbol("break-walk"),o=Symbol("skip-node");for(const i in e)Ge.call(e,i)&&e[i]!==null&&(n[i]=Wn(e[i],!1),r[i]=Wn(e[i],!0));const a=zn(n),c=zn(r),u=function(i,l){function h(b,C,v){const U=f.call(y,b,C,v);return U===s?!0:U===o?!1:!!(g.hasOwnProperty(b.type)&&g[b.type](b,y,h,m)||p.call(y,b,C,v)===s)}let f=ce,p=ce,g=n,m=(b,C,v,U)=>b||h(C,v,U);const y={break:s,skip:o,root:i,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof l=="function")f=l;else if(l&&(f=Bn(l.enter),p=Bn(l.leave),l.reverse&&(g=r),l.visit)){if(a.hasOwnProperty(l.visit))g=l.reverse?c[l.visit]:a[l.visit];else if(!e.hasOwnProperty(l.visit))throw new Error("Bad value `"+l.visit+"` for `visit` option (should be: "+Object.keys(e).sort().join(", ")+")");f=Un(f,l.visit),p=Un(p,l.visit)}if(f===ce&&p===ce)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");h(i)};return u.break=s,u.skip=o,u.find=function(i,l){let h=null;return u(i,function(f,p,g){if(l.call(this,f,p,g))return h=f,s}),h},u.findLast=function(i,l){let h=null;return u(i,{reverse:!0,enter(f,p,g){if(l.call(this,f,p,g))return h=f,s}}),h},u.findAll=function(i,l){const h=[];return u(i,function(f,p,g){l.call(this,f,p,g)&&h.push(f)}),h},u}const Lt=0,d=1,T=2,V=3,N=4,Tt=5,Fo=6,Q=7,pt=8,P=9,x=10,F=11,E=12,B=13,ye=14,ot=15,Y=16,et=17,dt=18,Gt=19,ue=20,_=21,S=22,gt=23,qt=24,X=25,Mo=0;function at(t){return t>=48&&t<=57}function Kt(t){return at(t)||t>=65&&t<=70||t>=97&&t<=102}function qe(t){return t>=65&&t<=90}function jo(t){return t>=97&&t<=122}function Bo(t){return qe(t)||jo(t)}function Uo(t){return t>=128}function be(t){return Bo(t)||Uo(t)||t===95}function Hn(t){return be(t)||at(t)||t===45}function Wo(t){return t>=0&&t<=8||t===11||t>=14&&t<=31||t===127}function xe(t){return t===10||t===13||t===12}function Nt(t){return xe(t)||t===32||t===9}function yt(t,e){return!(t!==92||xe(e)||e===Mo)}function Ke(t,e,n){return t===45?be(e)||e===45||yt(e,n):be(t)?!0:t===92?yt(t,e):!1}function Qe(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 Vn(t){return t===65279||t===65534?1:0}const Ye=new Array(128),zo=128,Ce=130,Gn=131,Xe=132,qn=133;for(let t=0;t<Ye.length;t++)Ye[t]=Nt(t)&&Ce||at(t)&&Gn||be(t)&&Xe||Wo(t)&&qn||t||zo;function Je(t){return t<128?Ye[t]:Xe}function Qt(t,e){return e<t.length?t.charCodeAt(e):0}function Ze(t,e,n){return n===13&&Qt(t,e+1)===10?2:1}function Kn(t,e,n){let r=t.charCodeAt(e);return qe(r)&&(r=r|32),r===n}function we(t,e,n,r){if(n-e!==r.length||e<0||n>t.length)return!1;for(let s=e;s<n;s++){const o=r.charCodeAt(s-e);let a=t.charCodeAt(s);if(qe(a)&&(a=a|32),a!==o)return!1}return!0}function Ho(t,e){for(;e>=0&&Nt(t.charCodeAt(e));e--);return e+1}function Te(t,e){for(;e<t.length&&Nt(t.charCodeAt(e));e++);return e}function tn(t,e){for(;e<t.length&&at(t.charCodeAt(e));e++);return e}function Yt(t,e){if(e+=2,Kt(Qt(t,e-1))){for(const r=Math.min(t.length,e+5);e<r&&Kt(Qt(t,e));e++);const n=Qt(t,e);Nt(n)&&(e+=Ze(t,e,n))}return e}function Ae(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(!Hn(n)){if(yt(n,Qt(t,e+1))){e=Yt(t,e)-1;continue}break}}return e}function Qn(t,e){let n=t.charCodeAt(e);if((n===43||n===45)&&(n=t.charCodeAt(e+=1)),at(n)&&(e=tn(t,e+1),n=t.charCodeAt(e)),n===46&&at(t.charCodeAt(e+1))&&(e+=2,e=tn(t,e)),Kn(t,e,101)){let r=0;n=t.charCodeAt(e+1),(n===45||n===43)&&(r=1,n=t.charCodeAt(e+2)),at(n)&&(e=tn(t,e+1+r+1))}return e}function en(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(n===41){e++;break}yt(n,Qt(t,e+1))&&(e=Yt(t,e))}return e}function Yn(t){if(t.length===1&&!Kt(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 Xn=["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"],Vo=16*1024;function ve(t=null,e){return t===null||t.length<e?new Uint32Array(Math.max(e+1024,Vo)):t}const Jn=10,Go=12,Zn=13;function tr(t){const e=t.source,n=e.length,r=e.length>0?Vn(e.charCodeAt(0)):0,s=ve(t.lines,n),o=ve(t.columns,n);let a=t.startLine,c=t.startColumn;for(let u=r;u<n;u++){const i=e.charCodeAt(u);s[u]=a,o[u]=c++,(i===Jn||i===Zn||i===Go)&&(i===Zn&&u+1<n&&e.charCodeAt(u+1)===Jn&&(u++,s[u]=a,o[u]=c),a++,c=1)}s[n]=a,o[n]=c,t.lines=s,t.columns=o,t.computed=!0}class qo{constructor(e,n,r,s){this.setSource(e,n,r,s),this.lines=null,this.columns=null}setSource(e="",n=0,r=1,s=1){this.source=e,this.startOffset=n,this.startLine=r,this.startColumn=s,this.computed=!1}getLocation(e,n){return this.computed||tr(this),{source:n,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,n,r){return this.computed||tr(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 bt=16777215,xt=24,Dt=new Uint8Array(32);Dt[T]=S,Dt[_]=S,Dt[Gt]=ue,Dt[gt]=qt;function er(t){return Dt[t]!==0}class Ko{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,s=ve(this.offsetAndType,e.length+1),o=ve(this.balance,e.length+1);let a=0,c=-1,u=0,i=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),n(e,(l,h,f)=>{const p=a++;if(s[p]=l<<xt|f,c===-1&&(c=h),o[p]=i,l===u){const g=o[i];o[i]=p,i=g,u=Dt[s[g]>>xt]}else er(l)&&(i=p,u=Dt[l])}),s[a]=Lt<<xt|r,o[a]=a;for(let l=0;l<a;l++){const h=o[l];if(h<=l){const f=o[h];f!==l&&(o[l]=f)}else h>a&&(o[l]=a)}this.source=e,this.firstCharOffset=c===-1?0:c,this.tokenCount=a,this.offsetAndType=s,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>xt:Lt}lookupTypeNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const r=this.offsetAndType[n]>>xt;if(r!==B&&r!==X&&e--===0)return r}return Lt}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&bt:this.source.length}lookupOffsetNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const r=this.offsetAndType[n]>>xt;if(r!==B&&r!==X&&e--===0)return n-this.tokenIndex}return Lt}lookupValue(e,n){return e+=this.tokenIndex,e<this.tokenCount?we(this.source,this.offsetAndType[e-1]&bt,this.offsetAndType[e]&bt,n):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&bt:this.offsetAndType[this.tokenCount]&bt: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)===P&&this.source.charCodeAt(this.lookupOffset(n))===e:this.tokenType===P&&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]&bt,n=this.offsetAndType[n],this.tokenType=n>>xt,this.tokenEnd=n&bt):(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>>xt,this.tokenEnd=e&bt):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=Lt,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===B||this.tokenType===X;)this.next()}skipUntilBalanced(e,n){let r=e,s=0,o=0;t:for(;r<this.tokenCount;r++){if(s=this.balance[r],s<e)break t;switch(o=r>0?this.offsetAndType[r-1]&bt:this.firstCharOffset,n(this.source.charCodeAt(o))){case 1:break t;case 2:r++;break t;default:er(this.offsetAndType[r]>>xt)&&(r=s)}}this.skip(r-this.tokenIndex)}forEachToken(e){for(let n=0,r=this.firstCharOffset;n<this.tokenCount;n++){const s=r,o=this.offsetAndType[n],a=o&bt,c=o>>xt;r=a,e(c,s,a,n)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((n,r,s,o)=>{e[o]={idx:o,type:Xn[n],chunk:this.source.substring(r,s),balance:this.balance[o]}}),e}}function nr(t,e){function n(h){return h<c?t.charCodeAt(h):0}function r(){if(i=Qn(t,i),Ke(n(i),n(i+1),n(i+2))){l=E,i=Ae(t,i);return}if(n(i)===37){l=F,i++;return}l=x}function s(){const h=i;if(i=Ae(t,i),we(t,h,i,"url")&&n(i)===40){if(i=Te(t,i+1),n(i)===34||n(i)===39){l=T,i=h+4;return}a();return}if(n(i)===40){l=T,i++;return}l=d}function o(h){for(h||(h=n(i++)),l=Tt;i<t.length;i++){const f=t.charCodeAt(i);switch(Je(f)){case h:i++;return;case Ce:if(xe(f)){i+=Ze(t,i,f),l=Fo;return}break;case 92:if(i===t.length-1)break;const p=n(i+1);xe(p)?i+=Ze(t,i+1,p):yt(f,p)&&(i=Yt(t,i)-1);break}}}function a(){for(l=Q,i=Te(t,i);i<t.length;i++){const h=t.charCodeAt(i);switch(Je(h)){case 41:i++;return;case Ce:if(i=Te(t,i),n(i)===41||i>=t.length){i<t.length&&i++;return}i=en(t,i),l=pt;return;case 34:case 39:case 40:case qn:i=en(t,i),l=pt;return;case 92:if(yt(h,n(i+1))){i=Yt(t,i)-1;break}i=en(t,i),l=pt;return}}}t=String(t||"");const c=t.length;let u=Vn(n(0)),i=u,l;for(;i<c;){const h=t.charCodeAt(i);switch(Je(h)){case Ce:l=B,i=Te(t,i+1);break;case 34:o();break;case 35:Hn(n(i+1))||yt(n(i+1),n(i+2))?(l=N,i=Ae(t,i+1)):(l=P,i++);break;case 39:o();break;case 40:l=_,i++;break;case 41:l=S,i++;break;case 43:Qe(h,n(i+1),n(i+2))?r():(l=P,i++);break;case 44:l=dt,i++;break;case 45:Qe(h,n(i+1),n(i+2))?r():n(i+1)===45&&n(i+2)===62?(l=ot,i=i+3):Ke(h,n(i+1),n(i+2))?s():(l=P,i++);break;case 46:Qe(h,n(i+1),n(i+2))?r():(l=P,i++);break;case 47:n(i+1)===42?(l=X,i=t.indexOf("*/",i+2),i=i===-1?t.length:i+2):(l=P,i++);break;case 58:l=Y,i++;break;case 59:l=et,i++;break;case 60:n(i+1)===33&&n(i+2)===45&&n(i+3)===45?(l=ye,i=i+4):(l=P,i++);break;case 64:Ke(n(i+1),n(i+2),n(i+3))?(l=V,i=Ae(t,i+1)):(l=P,i++);break;case 91:l=Gt,i++;break;case 92:yt(h,n(i+1))?s():(l=P,i++);break;case 93:l=ue,i++;break;case 123:l=gt,i++;break;case 125:l=qt,i++;break;case Gn:r();break;case Xe:s();break;default:l=P,i++}e(l,u,u=i)}}const Ct=43,lt=45,Ee=110,Ft=!0,Qo=!1;function $e(t,e){let n=this.tokenStart+t;const r=this.charCodeAt(n);for((r===Ct||r===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 Xt(t){return $e.call(this,0,t)}function Pt(t,e){if(!this.cmpChar(this.tokenStart+t,e)){let n="";switch(e){case Ee:n="N is expected";break;case lt:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+t)}}function nn(){let t=0,e=0,n=this.tokenType;for(;n===B||n===X;)n=this.lookupType(++t);if(n!==x)if(this.isDelim(Ct,t)||this.isDelim(lt,t)){e=this.isDelim(Ct,t)?Ct:lt;do n=this.lookupType(++t);while(n===B||n===X);n!==x&&(this.skip(t),Xt.call(this,Ft))}else return null;return t>0&&this.skip(t),e===0&&(n=this.charCodeAt(this.tokenStart),n!==Ct&&n!==lt&&this.error("Number sign is expected")),Xt.call(this,e!==0),e===lt?"-"+this.consume(x):this.consume(x)}const Yo="AnPlusB",Xo={a:[String,null],b:[String,null]};function rr(){const t=this.tokenStart;let e=null,n=null;if(this.tokenType===x)Xt.call(this,Qo),n=this.consume(x);else if(this.tokenType===d&&this.cmpChar(this.tokenStart,lt))switch(e="-1",Pt.call(this,1,Ee),this.tokenEnd-this.tokenStart){case 2:this.next(),n=nn.call(this);break;case 3:Pt.call(this,2,lt),this.next(),this.skipSC(),Xt.call(this,Ft),n="-"+this.consume(x);break;default:Pt.call(this,2,lt),$e.call(this,3,Ft),this.next(),n=this.substrToCursor(t+2)}else if(this.tokenType===d||this.isDelim(Ct)&&this.lookupType(1)===d){let r=0;switch(e="1",this.isDelim(Ct)&&(r=1,this.next()),Pt.call(this,0,Ee),this.tokenEnd-this.tokenStart){case 1:this.next(),n=nn.call(this);break;case 2:Pt.call(this,1,lt),this.next(),this.skipSC(),Xt.call(this,Ft),n="-"+this.consume(x);break;default:Pt.call(this,1,lt),$e.call(this,2,Ft),this.next(),n=this.substrToCursor(t+r+1)}}else if(this.tokenType===E){const r=this.charCodeAt(this.tokenStart),s=r===Ct||r===lt;let o=this.tokenStart+s;for(;o<this.tokenEnd&&at(this.charCodeAt(o));o++);o===this.tokenStart+s&&this.error("Integer is expected",this.tokenStart+s),Pt.call(this,o-this.tokenStart,Ee),e=this.substring(t,o),o+1===this.tokenEnd?(this.next(),n=nn.call(this)):(Pt.call(this,o-this.tokenStart+1,lt),o+2===this.tokenEnd?(this.next(),this.skipSC(),Xt.call(this,Ft),n="-"+this.consume(x)):($e.call(this,o-this.tokenStart+2,Ft),this.next(),n=this.substrToCursor(o+1)))}else this.error();return e!==null&&e.charCodeAt(0)===Ct&&(e=e.substr(1)),n!==null&&n.charCodeAt(0)===Ct&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(t,this.tokenStart),a:e,b:n}}function sr(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 Jo=Object.freeze(Object.defineProperty({__proto__:null,generate:sr,name:Yo,parse:rr,structure:Xo},Symbol.toStringTag,{value:"Module"}));function ir(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function Zo(){for(let t=1,e;e=this.lookupType(t);t++){if(e===qt)return!0;if(e===gt||e===V)return!1}return!1}const ta="Atrule",ea="atrule",na={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function or(t=!1){const e=this.tokenStart;let n,r,s=null,o=null;switch(this.eat(V),n=this.substrToCursor(e+1),r=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==gt&&this.tokenType!==et&&(this.parseAtrulePrelude?s=this.parseWithFallback(this.AtrulePrelude.bind(this,n,t),ir):s=ir.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case et:this.next();break;case gt:hasOwnProperty.call(this.atrule,r)&&typeof this.atrule[r].block=="function"?o=this.atrule[r].block.call(this,t):o=this.Block(Zo.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:n,prelude:s,block:o}}function ar(t){this.token(V,"@"+t.name),t.prelude!==null&&this.node(t.prelude),t.block?this.node(t.block):this.token(et,";")}const ra=Object.freeze(Object.defineProperty({__proto__:null,generate:ar,name:ta,parse:or,structure:na,walkContext:ea},Symbol.toStringTag,{value:"Module"})),sa="AtrulePrelude",ia="atrulePrelude",oa={children:[[]]};function lr(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!==gt&&this.tokenType!==et&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function cr(t){this.children(t)}const aa=Object.freeze(Object.defineProperty({__proto__:null,generate:cr,name:sa,parse:lr,structure:oa,walkContext:ia},Symbol.toStringTag,{value:"Module"})),la=36,ur=42,Le=61,ca=94,rn=124,ua=126;function ha(){this.eof&&this.error("Unexpected end of input");const t=this.tokenStart;let e=!1;return this.isDelim(ur)?(e=!0,this.next()):this.isDelim(rn)||this.eat(d),this.isDelim(rn)?this.charCodeAt(this.tokenStart+1)!==Le?(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 fa(){const t=this.tokenStart,e=this.charCodeAt(t);return e!==Le&&e!==ua&&e!==ca&&e!==la&&e!==ur&&e!==rn&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==Le&&(this.isDelim(Le)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(t)}const pa="AttributeSelector",da={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function hr(){const t=this.tokenStart;let e,n=null,r=null,s=null;return this.eat(Gt),this.skipSC(),e=ha.call(this),this.skipSC(),this.tokenType!==ue&&(this.tokenType!==d&&(n=fa.call(this),this.skipSC(),r=this.tokenType===Tt?this.String():this.Identifier(),this.skipSC()),this.tokenType===d&&(s=this.consume(d),this.skipSC())),this.eat(ue),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:r,flags:s}}function fr(t){this.token(P,"["),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(P,"]")}const ga=Object.freeze(Object.defineProperty({__proto__:null,generate:fr,name:pa,parse:hr,structure:da},Symbol.toStringTag,{value:"Module"})),ma=38;function pr(){return this.Raw(null,!0)}function dr(){return this.parseWithFallback(this.Rule,pr)}function gr(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function ka(){if(this.tokenType===et)return gr.call(this,this.tokenIndex);const t=this.parseWithFallback(this.Declaration,gr);return this.tokenType===et&&this.next(),t}const Sa="Block",ya="block",ba={children:[["Atrule","Rule","Declaration"]]};function mr(t){const e=t?ka:dr,n=this.tokenStart;let r=this.createList();this.eat(gt);t:for(;!this.eof;)switch(this.tokenType){case qt:break t;case B:case X:this.next();break;case V:r.push(this.parseWithFallback(this.Atrule.bind(this,t),pr));break;default:t&&this.isDelim(ma)?r.push(dr.call(this)):r.push(e.call(this))}return this.eof||this.eat(qt),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:r}}function kr(t){this.token(gt,"{"),this.children(t,e=>{e.type==="Declaration"&&this.token(et,";")}),this.token(qt,"}")}const xa=Object.freeze(Object.defineProperty({__proto__:null,generate:kr,name:Sa,parse:mr,structure:ba,walkContext:ya},Symbol.toStringTag,{value:"Module"})),Ca="Brackets",wa={children:[[]]};function Sr(t,e){const n=this.tokenStart;let r=null;return this.eat(Gt),r=t.call(this,e),this.eof||this.eat(ue),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:r}}function yr(t){this.token(P,"["),this.children(t),this.token(P,"]")}const Ta=Object.freeze(Object.defineProperty({__proto__:null,generate:yr,name:Ca,parse:Sr,structure:wa},Symbol.toStringTag,{value:"Module"})),Aa="CDC",va=[];function br(){const t=this.tokenStart;return this.eat(ot),{type:"CDC",loc:this.getLocation(t,this.tokenStart)}}function xr(){this.token(ot,"-->")}const Ea=Object.freeze(Object.defineProperty({__proto__:null,generate:xr,name:Aa,parse:br,structure:va},Symbol.toStringTag,{value:"Module"})),$a="CDO",La=[];function Cr(){const t=this.tokenStart;return this.eat(ye),{type:"CDO",loc:this.getLocation(t,this.tokenStart)}}function wr(){this.token(ye,"<!--")}const Pa=Object.freeze(Object.defineProperty({__proto__:null,generate:wr,name:$a,parse:Cr,structure:La},Symbol.toStringTag,{value:"Module"})),Oa=46,Ra="ClassSelector",Ia={name:String};function Tr(){return this.eatDelim(Oa),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(d)}}function Ar(t){this.token(P,"."),this.token(d,t.name)}const _a=Object.freeze(Object.defineProperty({__proto__:null,generate:Ar,name:Ra,parse:Tr,structure:Ia},Symbol.toStringTag,{value:"Module"})),Na=43,vr=47,Da=62,Fa=126,Ma="Combinator",ja={name:String};function Er(){const t=this.tokenStart;let e;switch(this.tokenType){case B:e=" ";break;case P:switch(this.charCodeAt(this.tokenStart)){case Da:case Na:case Fa:this.next();break;case vr:this.next(),this.eatIdent("deep"),this.eatDelim(vr);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t);break}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function $r(t){this.tokenize(t.name)}const Ba=Object.freeze(Object.defineProperty({__proto__:null,generate:$r,name:Ma,parse:Er,structure:ja},Symbol.toStringTag,{value:"Module"})),Ua=42,Wa=47,za="Comment",Ha={value:String};function Lr(){const t=this.tokenStart;let e=this.tokenEnd;return this.eat(X),e-t+2>=2&&this.charCodeAt(e-2)===Ua&&this.charCodeAt(e-1)===Wa&&(e-=2),{type:"Comment",loc:this.getLocation(t,this.tokenStart),value:this.substring(t+2,e)}}function Pr(t){this.token(X,"/*"+t.value+"*/")}const Va=Object.freeze(Object.defineProperty({__proto__:null,generate:Pr,name:za,parse:Lr,structure:Ha},Symbol.toStringTag,{value:"Module"})),Ga=new Set([Y,S,Lt]),qa="Condition",Ka={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function Or(t){return this.lookupTypeNonSC(1)===d&&Ga.has(this.lookupTypeNonSC(2))?this.Feature(t):this.FeatureRange(t)}const Qa={media:Or,container:Or,supports(){return this.SupportsDeclaration()}};function Rr(t="media"){const e=this.createList();t:for(;!this.eof;)switch(this.tokenType){case X:case B:this.next();continue;case d:e.push(this.Identifier());break;case _:{let n=this.parseWithFallback(()=>Qa[t].call(this,t),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(_);const r=this.Condition(t);return this.eat(S),r},()=>this.GeneralEnclosed(t))),e.push(n);break}case T:{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 Ir(t){t.children.forEach(e=>{e.type==="Condition"?(this.token(_,"("),this.node(e),this.token(S,")")):this.node(e)})}const Ya=Object.freeze(Object.defineProperty({__proto__:null,generate:Ir,name:qa,parse:Rr,structure:Ka},Symbol.toStringTag,{value:"Module"})),_r=45;function Xa(t,e){return e=e||0,t.length-e>=2&&t.charCodeAt(e)===_r&&t.charCodeAt(e+1)===_r}const Nr=33,Ja=35,Za=36,tl=38,el=42,nl=43,Dr=47;function rl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function sl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function il(){const t=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==et&&this.isDelim(Nr)===!1&&this.isBalanceEdge(t)===!1&&this.error(),e}const ol="Declaration",al="declaration",ll={important:[Boolean,String],property:String,value:["Value","Raw"]};function Fr(){const t=this.tokenStart,e=this.tokenIndex,n=cl.call(this),r=Xa(n),s=r?this.parseCustomProperty:this.parseValue,o=r?sl:rl;let a=!1,c;this.skipSC(),this.eat(Y);const u=this.tokenIndex;if(r||this.skipSC(),s?c=this.parseWithFallback(il,o):c=o.call(this,this.tokenIndex),r&&c.type==="Value"&&c.children.isEmpty){for(let i=u-this.tokenIndex;i<=0;i++)if(this.lookupType(i)===B){c.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(Nr)&&(a=ul.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:c}}function Mr(t){this.token(d,t.property),this.token(Y,":"),this.node(t.value),t.important&&(this.token(P,"!"),this.token(d,t.important===!0?"important":t.important))}function cl(){const t=this.tokenStart;if(this.tokenType===P)switch(this.charCodeAt(this.tokenStart)){case el:case Za:case nl:case Ja:case tl:this.next();break;case Dr:this.next(),this.isDelim(Dr)&&this.next();break}return this.tokenType===N?this.eat(N):this.eat(d),this.substrToCursor(t)}function ul(){this.eat(P),this.skipSC();const t=this.consume(d);return t==="important"?!0:t}const hl=Object.freeze(Object.defineProperty({__proto__:null,generate:Mr,name:ol,parse:Fr,structure:ll,walkContext:al},Symbol.toStringTag,{value:"Module"})),fl=38;function sn(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const pl="DeclarationList",dl={children:[["Declaration","Atrule","Rule"]]};function jr(){const t=this.createList();for(;!this.eof;)switch(this.tokenType){case B:case X:case et:this.next();break;case V:t.push(this.parseWithFallback(this.Atrule.bind(this,!0),sn));break;default:this.isDelim(fl)?t.push(this.parseWithFallback(this.Rule,sn)):t.push(this.parseWithFallback(this.Declaration,sn))}return{type:"DeclarationList",loc:this.getLocationFromList(t),children:t}}function Br(t){this.children(t,e=>{e.type==="Declaration"&&this.token(et,";")})}const gl=Object.freeze(Object.defineProperty({__proto__:null,generate:Br,name:pl,parse:jr,structure:dl},Symbol.toStringTag,{value:"Module"})),ml="Dimension",kl={value:String,unit:String};function Ur(){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 Wr(t){this.token(E,t.value+t.unit)}const Sl=Object.freeze(Object.defineProperty({__proto__:null,generate:Wr,name:ml,parse:Ur,structure:kl},Symbol.toStringTag,{value:"Module"})),yl=47,bl="Feature",xl={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function zr(t){const e=this.tokenStart;let n,r=null;if(this.eat(_),this.skipSC(),n=this.consume(d),this.skipSC(),this.tokenType!==S){switch(this.eat(Y),this.skipSC(),this.tokenType){case x:this.lookupNonWSType(1)===P?r=this.Ratio():r=this.Number();break;case E:r=this.Dimension();break;case d:r=this.Identifier();break;case T:r=this.parseWithFallback(()=>{const s=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(yl)&&this.error(),s},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(S),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:t,name:n,value:r}}function Hr(t){this.token(_,"("),this.token(d,t.name),t.value!==null&&(this.token(Y,":"),this.node(t.value)),this.token(S,")")}const Cl=Object.freeze(Object.defineProperty({__proto__:null,generate:Hr,name:bl,parse:zr,structure:xl},Symbol.toStringTag,{value:"Module"})),wl="FeatureFunction",Tl={kind:String,feature:String,value:["Declaration","Selector"]};function Al(t,e){const r=(this.features[t]||{})[e];return typeof r!="function"&&this.error(`Unknown feature ${e}()`),r}function Vr(t="unknown"){const e=this.tokenStart,n=this.consumeFunctionName(),r=Al.call(this,t,n.toLowerCase());this.skipSC();const s=this.parseWithFallback(()=>{const o=this.tokenIndex,a=r.call(this);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),a},()=>this.Raw(null,!1));return this.eof||this.eat(S),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:t,feature:n,value:s}}function Gr(t){this.token(T,t.feature+"("),this.node(t.value),this.token(S,")")}const vl=Object.freeze(Object.defineProperty({__proto__:null,generate:Gr,name:wl,parse:Vr,structure:Tl},Symbol.toStringTag,{value:"Module"})),qr=47,El=60,Kr=61,$l=62,Ll="FeatureRange",Pl={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 on(){switch(this.skipSC(),this.tokenType){case x:return this.isDelim(qr,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case E:return this.Dimension();case d:return this.Identifier();case T:return this.parseWithFallback(()=>{const t=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(qr)&&this.error(),t},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function Qr(t){if(this.skipSC(),this.isDelim(El)||this.isDelim($l)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(Kr)?(this.next(),e+"="):e}if(this.isDelim(Kr))return"=";this.error(`Expected ${t?'":", ':""}"<", ">", "=" or ")"`)}function Yr(t="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(_);const n=on.call(this),r=Qr.call(this,n.type==="Identifier"),s=on.call(this);let o=null,a=null;return this.lookupNonWSType(0)!==S&&(o=Qr.call(this),a=on.call(this)),this.skipSC(),this.eat(S),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:t,left:n,leftComparison:r,middle:s,rightComparison:o,right:a}}function Xr(t){this.token(_,"("),this.node(t.left),this.tokenize(t.leftComparison),this.node(t.middle),t.right&&(this.tokenize(t.rightComparison),this.node(t.right)),this.token(S,")")}const Ol=Object.freeze(Object.defineProperty({__proto__:null,generate:Xr,name:Ll,parse:Yr,structure:Pl},Symbol.toStringTag,{value:"Module"})),Rl="Function",Il="function",_l={name:String,children:[[]]};function Jr(t,e){const n=this.tokenStart,r=this.consumeFunctionName(),s=r.toLowerCase();let o;return o=e.hasOwnProperty(s)?e[s].call(this,e):t.call(this,e),this.eof||this.eat(S),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:r,children:o}}function Zr(t){this.token(T,t.name+"("),this.children(t),this.token(S,")")}const Nl=Object.freeze(Object.defineProperty({__proto__:null,generate:Zr,name:Rl,parse:Jr,structure:_l,walkContext:Il},Symbol.toStringTag,{value:"Module"})),Dl="GeneralEnclosed",Fl={kind:String,function:[String,null],children:[[]]};function ts(t){const e=this.tokenStart;let n=null;this.tokenType===T?n=this.consumeFunctionName():this.eat(_);const r=this.parseWithFallback(()=>{const s=this.tokenIndex,o=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(s)===!1&&this.error(),o},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(S),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:t,function:n,children:r}}function es(t){t.function?this.token(T,t.function+"("):this.token(_,"("),this.children(t),this.token(S,")")}const Ml=Object.freeze(Object.defineProperty({__proto__:null,generate:es,name:Dl,parse:ts,structure:Fl},Symbol.toStringTag,{value:"Module"})),jl="XXX",Bl="Hash",Ul={value:String};function ns(){const t=this.tokenStart;return this.eat(N),{type:"Hash",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t+1)}}function rs(t){this.token(N,"#"+t.value)}const Wl=Object.freeze(Object.defineProperty({__proto__:null,generate:rs,name:Bl,parse:ns,structure:Ul,xxx:jl},Symbol.toStringTag,{value:"Module"})),zl="Identifier",Hl={name:String};function ss(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(d)}}function is(t){this.token(d,t.name)}const Vl=Object.freeze(Object.defineProperty({__proto__:null,generate:is,name:zl,parse:ss,structure:Hl},Symbol.toStringTag,{value:"Module"})),Gl="IdSelector",ql={name:String};function os(){const t=this.tokenStart;return this.eat(N),{type:"IdSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t+1)}}function as(t){this.token(P,"#"+t.name)}const Kl=Object.freeze(Object.defineProperty({__proto__:null,generate:as,name:Gl,parse:os,structure:ql},Symbol.toStringTag,{value:"Module"})),Ql=46,Yl="Layer",Xl={name:String};function ls(){let t=this.tokenStart,e=this.consume(d);for(;this.isDelim(Ql);)this.eat(P),e+="."+this.consume(d);return{type:"Layer",loc:this.getLocation(t,this.tokenStart),name:e}}function cs(t){this.tokenize(t.name)}const Jl=Object.freeze(Object.defineProperty({__proto__:null,generate:cs,name:Yl,parse:ls,structure:Xl},Symbol.toStringTag,{value:"Module"})),Zl="LayerList",tc={children:[["Layer"]]};function us(){const t=this.createList();for(this.skipSC();!this.eof&&(t.push(this.Layer()),this.lookupTypeNonSC(0)===dt);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(t),children:t}}function hs(t){this.children(t,()=>this.token(dt,","))}const ec=Object.freeze(Object.defineProperty({__proto__:null,generate:hs,name:Zl,parse:us,structure:tc},Symbol.toStringTag,{value:"Module"})),nc="MediaQuery",rc={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function fs(){const t=this.tokenStart;let e=null,n=null,r=null;if(this.skipSC(),this.tokenType===d&&this.lookupTypeNonSC(1)!==_){const s=this.consume(d),o=s.toLowerCase();switch(o==="not"||o==="only"?(this.skipSC(),e=o,n=this.consume(d)):n=s,this.lookupTypeNonSC(0)){case d:{this.skipSC(),this.eatIdent("and"),r=this.Condition("media");break}case gt:case et:case dt:case Lt:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case d:case _:case T:{r=this.Condition("media");break}case gt:case et:case Lt:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(t,this.tokenStart),modifier:e,mediaType:n,condition:r}}function ps(t){t.mediaType?(t.modifier&&this.token(d,t.modifier),this.token(d,t.mediaType),t.condition&&(this.token(d,"and"),this.node(t.condition))):t.condition&&this.node(t.condition)}const sc=Object.freeze(Object.defineProperty({__proto__:null,generate:ps,name:nc,parse:fs,structure:rc},Symbol.toStringTag,{value:"Module"})),ic="MediaQueryList",oc={children:[["MediaQuery"]]};function ds(){const t=this.createList();for(this.skipSC();!this.eof&&(t.push(this.MediaQuery()),this.tokenType===dt);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(t),children:t}}function gs(t){this.children(t,()=>this.token(dt,","))}const ac=Object.freeze(Object.defineProperty({__proto__:null,generate:gs,name:ic,parse:ds,structure:oc},Symbol.toStringTag,{value:"Module"})),lc=38,cc="NestingSelector",uc={};function ms(){const t=this.tokenStart;return this.eatDelim(lc),{type:"NestingSelector",loc:this.getLocation(t,this.tokenStart)}}function ks(){this.token(P,"&")}const hc=Object.freeze(Object.defineProperty({__proto__:null,generate:ks,name:cc,parse:ms,structure:uc},Symbol.toStringTag,{value:"Module"})),fc="Nth",pc={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function Ss(){this.skipSC();const t=this.tokenStart;let e=t,n=null,r;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?r=this.Identifier():r=this.AnPlusB(),e=this.tokenStart,this.skipSC(),this.lookupValue(0,"of")&&(this.next(),n=this.SelectorList(),e=this.tokenStart),{type:"Nth",loc:this.getLocation(t,e),nth:r,selector:n}}function ys(t){this.node(t.nth),t.selector!==null&&(this.token(d,"of"),this.node(t.selector))}const dc=Object.freeze(Object.defineProperty({__proto__:null,generate:ys,name:fc,parse:Ss,structure:pc},Symbol.toStringTag,{value:"Module"})),gc="Number",mc={value:String};function bs(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(x)}}function xs(t){this.token(x,t.value)}const kc=Object.freeze(Object.defineProperty({__proto__:null,generate:xs,name:gc,parse:bs,structure:mc},Symbol.toStringTag,{value:"Module"})),Sc="Operator",yc={value:String};function Cs(){const t=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t)}}function ws(t){this.tokenize(t.value)}const bc=Object.freeze(Object.defineProperty({__proto__:null,generate:ws,name:Sc,parse:Cs,structure:yc},Symbol.toStringTag,{value:"Module"})),xc="Parentheses",Cc={children:[[]]};function Ts(t,e){const n=this.tokenStart;let r=null;return this.eat(_),r=t.call(this,e),this.eof||this.eat(S),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:r}}function As(t){this.token(_,"("),this.children(t),this.token(S,")")}const wc=Object.freeze(Object.defineProperty({__proto__:null,generate:As,name:xc,parse:Ts,structure:Cc},Symbol.toStringTag,{value:"Module"})),Tc="Percentage",Ac={value:String};function vs(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(F)}}function Es(t){this.token(F,t.value+"%")}const vc=Object.freeze(Object.defineProperty({__proto__:null,generate:Es,name:Tc,parse:vs,structure:Ac},Symbol.toStringTag,{value:"Module"})),Ec="PseudoClassSelector",$c="function",Lc={name:String,children:[["Raw"],null]};function $s(){const t=this.tokenStart;let e=null,n,r;return this.eat(Y),this.tokenType===T?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==S?e=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),e=this.pseudo[r].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(S)):n=this.consume(d),{type:"PseudoClassSelector",loc:this.getLocation(t,this.tokenStart),name:n,children:e}}function Ls(t){this.token(Y,":"),t.children===null?this.token(d,t.name):(this.token(T,t.name+"("),this.children(t),this.token(S,")"))}const Pc=Object.freeze(Object.defineProperty({__proto__:null,generate:Ls,name:Ec,parse:$s,structure:Lc,walkContext:$c},Symbol.toStringTag,{value:"Module"})),Oc="PseudoElementSelector",Rc="function",Ic={name:String,children:[["Raw"],null]};function Ps(){const t=this.tokenStart;let e=null,n,r;return this.eat(Y),this.eat(Y),this.tokenType===T?(n=this.consumeFunctionName(),r=n.toLowerCase(),this.lookupNonWSType(0)==S?e=this.createList():hasOwnProperty.call(this.pseudo,r)?(this.skipSC(),e=this.pseudo[r].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(S)):n=this.consume(d),{type:"PseudoElementSelector",loc:this.getLocation(t,this.tokenStart),name:n,children:e}}function