UNPKG

@oddbird/css-anchor-positioning

Version:

Polyfill for the proposed CSS anchor positioning spec

19 lines 118 kB
(function(V,I){typeof exports=="object"&&typeof module!="undefined"?module.exports=I():typeof define=="function"&&define.amd?define(I):(V=typeof globalThis!="undefined"?globalThis:V||self,V.CssAnchorPositioning=I())})(this,(function(){"use strict";var Np=Object.defineProperty,Dp=Object.defineProperties;var Fp=Object.getOwnPropertyDescriptors;var yo=Object.getOwnPropertySymbols;var Mp=Object.prototype.hasOwnProperty,jp=Object.prototype.propertyIsEnumerable;var bo=(V,I,j)=>I in V?Np(V,I,{enumerable:!0,configurable:!0,writable:!0,value:j}):V[I]=j,H=(V,I)=>{for(var j in I||(I={}))Mp.call(I,j)&&bo(V,j,I[j]);if(yo)for(var j of yo(I))jp.call(I,j)&&bo(V,j,I[j]);return V},Y=(V,I)=>Dp(V,Fp(I));var R=(V,I,j)=>new Promise((zt,rt)=>{var Be=ut=>{try{oe(j.next(ut))}catch(ae){rt(ae)}},We=ut=>{try{oe(j.throw(ut))}catch(ae){rt(ae)}},oe=ut=>ut.done?zt(ut.value):Promise.resolve(ut.value).then(Be,We);oe((j=j.apply(V,I)).next())});const V=Math.min,I=Math.max,j=Math.round,zt=Math.floor,rt=t=>({x:t,y:t});function Be(t,e){return typeof t=="function"?t(e):t}function We(t){return H({top:0,right:0,bottom:0,left:0},t)}function oe(t){return typeof t!="number"?We(t):{top:t,right:t,bottom:t,left:t}}function ut(t){const{x:e,y:n,width:s,height:r}=t;return{width:s,height:r,top:n,left:e,right:e+s,bottom:n+r,x:e,y:n}}function ae(t,e){return R(this,null,function*(){var n;e===void 0&&(e={});const{x:s,y:r,platform:o,rects:a,elements:l,strategy:u}=t,{boundary:i="clippingAncestors",rootBoundary:c="viewport",elementContext:h="floating",altBoundary:f=!1,padding:p=0}=Be(e,t),g=oe(p),k=l[f?h==="floating"?"reference":"floating":h],S=ut(yield o.getClippingRect({element:(n=yield o.isElement==null?void 0:o.isElement(k))==null||n?k:k.contextElement||(yield o.getDocumentElement==null?void 0:o.getDocumentElement(l.floating)),boundary:i,rootBoundary:c,strategy:u})),x=h==="floating"?{x:s,y:r,width:a.floating.width,height:a.floating.height}:a.reference,A=yield o.getOffsetParent==null?void 0:o.getOffsetParent(l.floating),W=(yield o.isElement==null?void 0:o.isElement(A))?(yield o.getScale==null?void 0:o.getScale(A))||{x:1,y:1}:{x:1,y:1},ct=ut(o.convertOffsetParentRelativeRectToViewportRelativeRect?yield o.convertOffsetParentRelativeRectToViewportRelativeRect({elements:l,rect:x,offsetParent:A,strategy:u}):x);return{top:(S.top-ct.top+g.top)/W.y,bottom:(ct.bottom-S.bottom+g.bottom)/W.y,left:(S.left-ct.left+g.left)/W.x,right:(ct.right-S.right+g.right)/W.x}})}function Se(){return typeof window!="undefined"}function Ht(t){return On(t)?(t.nodeName||"").toLowerCase():"#document"}function it(t){var e;return(t==null||(e=t.ownerDocument)==null?void 0:e.defaultView)||window}function St(t){var e;return(e=(On(t)?t.ownerDocument:t.document)||window.document)==null?void 0:e.documentElement}function On(t){return Se()?t instanceof Node||t instanceof it(t).Node:!1}function ft(t){return Se()?t instanceof Element||t instanceof it(t).Element:!1}function yt(t){return Se()?t instanceof HTMLElement||t instanceof it(t).HTMLElement:!1}function Rn(t){return!Se()||typeof ShadowRoot=="undefined"?!1:t instanceof ShadowRoot||t instanceof it(t).ShadowRoot}const xo=new Set(["inline","contents"]);function le(t){const{overflow:e,overflowX:n,overflowY:s,display:r}=pt(t);return/auto|scroll|overlay|hidden|clip/.test(e+s+n)&&!xo.has(r)}const Co=new Set(["table","td","th"]);function wo(t){return Co.has(Ht(t))}const To=[":popover-open",":modal"];function ye(t){return To.some(e=>{try{return t.matches(e)}catch(n){return!1}})}const Ao=["transform","translate","scale","rotate","perspective"],vo=["transform","translate","scale","rotate","perspective","filter"],Eo=["paint","layout","strict","content"];function Ue(t){const e=ze(),n=ft(t)?pt(t):t;return Ao.some(s=>n[s]?n[s]!=="none":!1)||(n.containerType?n.containerType!=="normal":!1)||!e&&(n.backdropFilter?n.backdropFilter!=="none":!1)||!e&&(n.filter?n.filter!=="none":!1)||vo.some(s=>(n.willChange||"").includes(s))||Eo.some(s=>(n.contain||"").includes(s))}function $o(t){let e=Lt(t);for(;yt(e)&&!Vt(e);){if(Ue(e))return e;if(ye(e))return null;e=Lt(e)}return null}function ze(){return typeof CSS=="undefined"||!CSS.supports?!1:CSS.supports("-webkit-backdrop-filter","none")}const Lo=new Set(["html","body","#document"]);function Vt(t){return Lo.has(Ht(t))}function pt(t){return it(t).getComputedStyle(t)}function be(t){return ft(t)?{scrollLeft:t.scrollLeft,scrollTop:t.scrollTop}:{scrollLeft:t.scrollX,scrollTop:t.scrollY}}function Lt(t){if(Ht(t)==="html")return t;const e=t.assignedSlot||t.parentNode||Rn(t)&&t.host||St(t);return Rn(e)?e.host:e}function In(t){const e=Lt(t);return Vt(e)?t.ownerDocument?t.ownerDocument.body:t.body:yt(e)&&le(e)?e:In(e)}function ce(t,e,n){var s;e===void 0&&(e=[]),n===void 0&&(n=!0);const r=In(t),o=r===((s=t.ownerDocument)==null?void 0:s.body),a=it(r);if(o){const l=He(a);return e.concat(a,a.visualViewport||[],le(r)?r:[],l&&n?ce(l):[])}return e.concat(r,ce(r,[],n))}function He(t){return t.parent&&Object.getPrototypeOf(t.parent)?t.frameElement:null}function _n(t){const e=pt(t);let n=parseFloat(e.width)||0,s=parseFloat(e.height)||0;const r=yt(t),o=r?t.offsetWidth:n,a=r?t.offsetHeight:s,l=j(n)!==o||j(s)!==a;return l&&(n=o,s=a),{width:n,height:s,$:l}}function Ve(t){return ft(t)?t:t.contextElement}function Gt(t){const e=Ve(t);if(!yt(e))return rt(1);const n=e.getBoundingClientRect(),{width:s,height:r,$:o}=_n(e);let a=(o?j(n.width):n.width)/s,l=(o?j(n.height):n.height)/r;return(!a||!Number.isFinite(a))&&(a=1),(!l||!Number.isFinite(l))&&(l=1),{x:a,y:l}}const Po=rt(0);function Nn(t){const e=it(t);return!ze()||!e.visualViewport?Po:{x:e.visualViewport.offsetLeft,y:e.visualViewport.offsetTop}}function Oo(t,e,n){return e===void 0&&(e=!1),!n||e&&n!==it(t)?!1:e}function Nt(t,e,n,s){e===void 0&&(e=!1),n===void 0&&(n=!1);const r=t.getBoundingClientRect(),o=Ve(t);let a=rt(1);e&&(s?ft(s)&&(a=Gt(s)):a=Gt(t));const l=Oo(o,n,s)?Nn(o):rt(0);let u=(r.left+l.x)/a.x,i=(r.top+l.y)/a.y,c=r.width/a.x,h=r.height/a.y;if(o){const f=it(o),p=s&&ft(s)?it(s):s;let g=f,m=He(g);for(;m&&s&&p!==g;){const k=Gt(m),S=m.getBoundingClientRect(),x=pt(m),A=S.left+(m.clientLeft+parseFloat(x.paddingLeft))*k.x,W=S.top+(m.clientTop+parseFloat(x.paddingTop))*k.y;u*=k.x,i*=k.y,c*=k.x,h*=k.y,u+=A,i+=W,g=it(m),m=He(g)}}return ut({width:c,height:h,x:u,y:i})}function xe(t,e){const n=be(t).scrollLeft;return e?e.left+n:Nt(St(t)).left+n}function Dn(t,e){const n=t.getBoundingClientRect(),s=n.left+e.scrollLeft-xe(t,n),r=n.top+e.scrollTop;return{x:s,y:r}}function Ro(t){let{elements:e,rect:n,offsetParent:s,strategy:r}=t;const o=r==="fixed",a=St(s),l=e?ye(e.floating):!1;if(s===a||l&&o)return n;let u={scrollLeft:0,scrollTop:0},i=rt(1);const c=rt(0),h=yt(s);if((h||!h&&!o)&&((Ht(s)!=="body"||le(a))&&(u=be(s)),yt(s))){const p=Nt(s);i=Gt(s),c.x=p.x+s.clientLeft,c.y=p.y+s.clientTop}const f=a&&!h&&!o?Dn(a,u):rt(0);return{width:n.width*i.x,height:n.height*i.y,x:n.x*i.x-u.scrollLeft*i.x+c.x+f.x,y:n.y*i.y-u.scrollTop*i.y+c.y+f.y}}function Io(t){return Array.from(t.getClientRects())}function _o(t){const e=St(t),n=be(t),s=t.ownerDocument.body,r=I(e.scrollWidth,e.clientWidth,s.scrollWidth,s.clientWidth),o=I(e.scrollHeight,e.clientHeight,s.scrollHeight,s.clientHeight);let a=-n.scrollLeft+xe(t);const l=-n.scrollTop;return pt(s).direction==="rtl"&&(a+=I(e.clientWidth,s.clientWidth)-r),{width:r,height:o,x:a,y:l}}const Fn=25;function No(t,e){const n=it(t),s=St(t),r=n.visualViewport;let o=s.clientWidth,a=s.clientHeight,l=0,u=0;if(r){o=r.width,a=r.height;const c=ze();(!c||c&&e==="fixed")&&(l=r.offsetLeft,u=r.offsetTop)}const i=xe(s);if(i<=0){const c=s.ownerDocument,h=c.body,f=getComputedStyle(h),p=c.compatMode==="CSS1Compat"&&parseFloat(f.marginLeft)+parseFloat(f.marginRight)||0,g=Math.abs(s.clientWidth-h.clientWidth-p);g<=Fn&&(o-=g)}else i<=Fn&&(o+=i);return{width:o,height:a,x:l,y:u}}const Do=new Set(["absolute","fixed"]);function Fo(t,e){const n=Nt(t,!0,e==="fixed"),s=n.top+t.clientTop,r=n.left+t.clientLeft,o=yt(t)?Gt(t):rt(1),a=t.clientWidth*o.x,l=t.clientHeight*o.y,u=r*o.x,i=s*o.y;return{width:a,height:l,x:u,y:i}}function Mn(t,e,n){let s;if(e==="viewport")s=No(t,n);else if(e==="document")s=_o(St(t));else if(ft(e))s=Fo(e,n);else{const r=Nn(t);s={x:e.x-r.x,y:e.y-r.y,width:e.width,height:e.height}}return ut(s)}function jn(t,e){const n=Lt(t);return n===e||!ft(n)||Vt(n)?!1:pt(n).position==="fixed"||jn(n,e)}function Mo(t,e){const n=e.get(t);if(n)return n;let s=ce(t,[],!1).filter(l=>ft(l)&&Ht(l)!=="body"),r=null;const o=pt(t).position==="fixed";let a=o?Lt(t):t;for(;ft(a)&&!Vt(a);){const l=pt(a),u=Ue(a);!u&&l.position==="fixed"&&(r=null),(o?!u&&!r:!u&&l.position==="static"&&!!r&&Do.has(r.position)||le(a)&&!u&&jn(t,a))?s=s.filter(c=>c!==a):r=l,a=Lt(a)}return e.set(t,s),s}function jo(t){let{element:e,boundary:n,rootBoundary:s,strategy:r}=t;const a=[...n==="clippingAncestors"?ye(e)?[]:Mo(e,this._c):[].concat(n),s],l=a[0],u=a.reduce((i,c)=>{const h=Mn(e,c,r);return i.top=I(h.top,i.top),i.right=V(h.right,i.right),i.bottom=V(h.bottom,i.bottom),i.left=I(h.left,i.left),i},Mn(e,l,r));return{width:u.right-u.left,height:u.bottom-u.top,x:u.left,y:u.top}}function Bo(t){const{width:e,height:n}=_n(t);return{width:e,height:n}}function Wo(t,e,n){const s=yt(e),r=St(e),o=n==="fixed",a=Nt(t,!0,o,e);let l={scrollLeft:0,scrollTop:0};const u=rt(0);function i(){u.x=xe(r)}if(s||!s&&!o)if((Ht(e)!=="body"||le(r))&&(l=be(e)),s){const p=Nt(e,!0,o,e);u.x=p.x+e.clientLeft,u.y=p.y+e.clientTop}else r&&i();o&&!s&&r&&i();const c=r&&!s&&!o?Dn(r,l):rt(0),h=a.left+l.scrollLeft-u.x-c.x,f=a.top+l.scrollTop-u.y-c.y;return{x:h,y:f,width:a.width,height:a.height}}function Ge(t){return pt(t).position==="static"}function Bn(t,e){if(!yt(t)||pt(t).position==="fixed")return null;if(e)return e(t);let n=t.offsetParent;return St(t)===n&&(n=n.ownerDocument.body),n}function Wn(t,e){const n=it(t);if(ye(t))return n;if(!yt(t)){let r=Lt(t);for(;r&&!Vt(r);){if(ft(r)&&!Ge(r))return r;r=Lt(r)}return n}let s=Bn(t,e);for(;s&&wo(s)&&Ge(s);)s=Bn(s,e);return s&&Vt(s)&&Ge(s)&&!Ue(s)?n:s||$o(t)||n}const Uo=function(t){return R(this,null,function*(){const e=this.getOffsetParent||Wn,n=this.getDimensions,s=yield n(t.floating);return{reference:Wo(t.reference,yield e(t.floating),t.strategy),floating:{x:0,y:0,width:s.width,height:s.height}}})};function zo(t){return pt(t).direction==="rtl"}const q={convertOffsetParentRelativeRectToViewportRelativeRect:Ro,getDocumentElement:St,getClippingRect:jo,getOffsetParent:Wn,getElementRects:Uo,getClientRects:Io,getDimensions:Bo,getScale:Gt,isElement:ft,isRTL:zo};function Un(t,e){return t.x===e.x&&t.y===e.y&&t.width===e.width&&t.height===e.height}function Ho(t,e){let n=null,s;const r=St(t);function o(){var l;clearTimeout(s),(l=n)==null||l.disconnect(),n=null}function a(l,u){l===void 0&&(l=!1),u===void 0&&(u=1),o();const i=t.getBoundingClientRect(),{left:c,top:h,width:f,height:p}=i;if(l||e(),!f||!p)return;const g=zt(h),m=zt(r.clientWidth-(c+f)),k=zt(r.clientHeight-(h+p)),S=zt(c),A={rootMargin:-g+"px "+-m+"px "+-k+"px "+-S+"px",threshold:I(0,V(1,u))||1};let W=!0;function ct(w){const C=w[0].intersectionRatio;if(C!==u){if(!W)return a();C?a(!1,C):s=setTimeout(()=>{a(!1,1e-7)},1e3)}C===1&&!Un(i,t.getBoundingClientRect())&&a(),W=!1}try{n=new IntersectionObserver(ct,Y(H({},A),{root:r.ownerDocument}))}catch(w){n=new IntersectionObserver(ct,A)}n.observe(t)}return a(!0),o}function qe(t,e,n,s){s===void 0&&(s={});const{ancestorScroll:r=!0,ancestorResize:o=!0,elementResize:a=typeof ResizeObserver=="function",layoutShift:l=typeof IntersectionObserver=="function",animationFrame:u=!1}=s,i=Ve(t),c=r||o?[...i?ce(i):[],...ce(e)]:[];c.forEach(S=>{r&&S.addEventListener("scroll",n,{passive:!0}),o&&S.addEventListener("resize",n)});const h=i&&l?Ho(i,n):null;let f=-1,p=null;a&&(p=new ResizeObserver(S=>{let[x]=S;x&&x.target===i&&p&&(p.unobserve(e),cancelAnimationFrame(f),f=requestAnimationFrame(()=>{var A;(A=p)==null||A.observe(e)})),n()}),i&&!u&&p.observe(i),p.observe(e));let g,m=u?Nt(t):null;u&&k();function k(){const S=Nt(t);m&&!Un(m,S)&&n(),m=S,g=requestAnimationFrame(k)}return n(),()=>{var S;c.forEach(x=>{r&&x.removeEventListener("scroll",n),o&&x.removeEventListener("resize",n)}),h==null||h(),(S=p)==null||S.disconnect(),p=null,u&&cancelAnimationFrame(g)}}const Vo=ae;let qt=null;class K{static createItem(e){return{prev:null,next:null,data:e}}constructor(){this.head=null,this.tail=null,this.cursor=null}createItem(e){return K.createItem(e)}allocateCursor(e,n){let s;return qt!==null?(s=qt,qt=qt.cursor,s.prev=e,s.next=n,s.cursor=this.cursor):s={prev:e,next:n,cursor:this.cursor},this.cursor=s,s}releaseCursor(){const{cursor:e}=this;this.cursor=e.cursor,e.prev=null,e.next=null,e.cursor=qt,qt=e}updateCursors(e,n,s,r){let{cursor:o}=this;for(;o!==null;)o.prev===e&&(o.prev=n),o.next===s&&(o.next=r),o=o.cursor}*[Symbol.iterator](){for(let e=this.head;e!==null;e=e.next)yield e.data}get size(){let e=0;for(let n=this.head;n!==null;n=n.next)e++;return e}get isEmpty(){return this.head===null}get first(){return this.head&&this.head.data}get last(){return this.tail&&this.tail.data}fromArray(e){let n=null;this.head=null;for(let s of e){const r=K.createItem(s);n!==null?n.next=r:this.head=r,r.prev=n,n=r}return this.tail=n,this}toArray(){return[...this]}toJSON(){return[...this]}forEach(e,n=this){const s=this.allocateCursor(null,this.head);for(;s.next!==null;){const r=s.next;s.next=r.next,e.call(n,r.data,r,this)}this.releaseCursor()}forEachRight(e,n=this){const s=this.allocateCursor(this.tail,null);for(;s.prev!==null;){const r=s.prev;s.prev=r.prev,e.call(n,r.data,r,this)}this.releaseCursor()}reduce(e,n,s=this){let r=this.allocateCursor(null,this.head),o=n,a;for(;r.next!==null;)a=r.next,r.next=a.next,o=e.call(s,o,a.data,a,this);return this.releaseCursor(),o}reduceRight(e,n,s=this){let r=this.allocateCursor(this.tail,null),o=n,a;for(;r.prev!==null;)a=r.prev,r.prev=a.prev,o=e.call(s,o,a.data,a,this);return this.releaseCursor(),o}some(e,n=this){for(let s=this.head;s!==null;s=s.next)if(e.call(n,s.data,s,this))return!0;return!1}map(e,n=this){const s=new K;for(let r=this.head;r!==null;r=r.next)s.appendData(e.call(n,r.data,r,this));return s}filter(e,n=this){const s=new K;for(let r=this.head;r!==null;r=r.next)e.call(n,r.data,r,this)&&s.appendData(r.data);return s}nextUntil(e,n,s=this){if(e===null)return;const r=this.allocateCursor(null,e);for(;r.next!==null;){const o=r.next;if(r.next=o.next,n.call(s,o.data,o,this))break}this.releaseCursor()}prevUntil(e,n,s=this){if(e===null)return;const r=this.allocateCursor(e,null);for(;r.prev!==null;){const o=r.prev;if(r.prev=o.prev,n.call(s,o.data,o,this))break}this.releaseCursor()}clear(){this.head=null,this.tail=null}copy(){const e=new K;for(let n of this)e.appendData(n);return e}prepend(e){return this.updateCursors(null,e,this.head,e),this.head!==null?(this.head.prev=e,e.next=this.head):this.tail=e,this.head=e,this}prependData(e){return this.prepend(K.createItem(e))}append(e){return this.insert(e)}appendData(e){return this.insert(K.createItem(e))}insert(e,n=null){if(n!==null)if(this.updateCursors(n.prev,e,n,e),n.prev===null){if(this.head!==n)throw new Error("before doesn't belong to list");this.head=e,n.prev=e,e.next=n,this.updateCursors(null,e)}else n.prev.next=e,e.prev=n.prev,n.prev=e,e.next=n;else this.updateCursors(this.tail,e,null,e),this.tail!==null?(this.tail.next=e,e.prev=this.tail):this.head=e,this.tail=e;return this}insertData(e,n){return this.insert(K.createItem(e),n)}remove(e){if(this.updateCursors(e,e.prev,e,e.next),e.prev!==null)e.prev.next=e.next;else{if(this.head!==e)throw new Error("item doesn't belong to list");this.head=e.next}if(e.next!==null)e.next.prev=e.prev;else{if(this.tail!==e)throw new Error("item doesn't belong to list");this.tail=e.prev}return e.prev=null,e.next=null,e}push(e){this.insert(K.createItem(e))}pop(){return this.tail!==null?this.remove(this.tail):null}unshift(e){this.prepend(K.createItem(e))}shift(){return this.head!==null?this.remove(this.head):null}prependList(e){return this.insertList(e,this.head)}appendList(e){return this.insertList(e)}insertList(e,n){return e.head===null?this:(n!=null?(this.updateCursors(n.prev,e.tail,n,e.head),n.prev!==null?(n.prev.next=e.head,e.head.prev=n.prev):this.head=e.head,n.prev=e.tail,e.tail.next=n):(this.updateCursors(this.tail,e.tail,null,e.head),this.tail!==null?(this.tail.next=e.head,e.head.prev=this.tail):this.head=e.head,this.tail=e.tail),e.head=null,e.tail=null,this)}replace(e,n){"head"in n?this.insertList(n,e):this.insert(n,e),this.remove(e)}}function Ce(t){const e={};for(const n of Object.keys(t)){let s=t[n];s&&(Array.isArray(s)||s instanceof K?s=s.map(Ce):s.constructor===Object&&(s=Ce(s))),e[n]=s}return e}const Pt=0,d=1,T=2,G=3,N=4,At=5,Go=6,X=7,dt=8,L=9,b=10,D=11,E=12,B=13,we=14,ot=15,J=16,et=17,gt=18,Kt=19,ue=20,_=21,y=22,mt=23,Qt=24,Z=25,qo=0;function at(t){return t>=48&&t<=57}function Yt(t){return at(t)||t>=65&&t<=70||t>=97&&t<=102}function Ke(t){return t>=65&&t<=90}function Ko(t){return t>=97&&t<=122}function Qo(t){return Ke(t)||Ko(t)}function Yo(t){return t>=128}function Te(t){return Qo(t)||Yo(t)||t===95}function zn(t){return Te(t)||at(t)||t===45}function Xo(t){return t>=0&&t<=8||t===11||t>=14&&t<=31||t===127}function Ae(t){return t===10||t===13||t===12}function Dt(t){return Ae(t)||t===32||t===9}function bt(t,e){return!(t!==92||Ae(e)||e===qo)}function Qe(t,e,n){return t===45?Te(e)||e===45||bt(e,n):Te(t)?!0:t===92?bt(t,e):!1}function Ye(t,e,n){return t===43||t===45?at(e)?2:e===46&&at(n)?3:0:t===46?at(e)?2:0:at(t)?1:0}function Hn(t){return t===65279||t===65534?1:0}const Xe=new Array(128),Jo=128,ve=130,Vn=131,Je=132,Gn=133;for(let t=0;t<Xe.length;t++)Xe[t]=Dt(t)&&ve||at(t)&&Vn||Te(t)&&Je||Xo(t)&&Gn||t||Jo;function Ze(t){return t<128?Xe[t]:Je}function Xt(t,e){return e<t.length?t.charCodeAt(e):0}function tn(t,e,n){return n===13&&Xt(t,e+1)===10?2:1}function qn(t,e,n){let s=t.charCodeAt(e);return Ke(s)&&(s=s|32),s===n}function Ee(t,e,n,s){if(n-e!==s.length||e<0||n>t.length)return!1;for(let r=e;r<n;r++){const o=s.charCodeAt(r-e);let a=t.charCodeAt(r);if(Ke(a)&&(a=a|32),a!==o)return!1}return!0}function Zo(t,e){for(;e>=0&&Dt(t.charCodeAt(e));e--);return e+1}function $e(t,e){for(;e<t.length&&Dt(t.charCodeAt(e));e++);return e}function en(t,e){for(;e<t.length&&at(t.charCodeAt(e));e++);return e}function Jt(t,e){if(e+=2,Yt(Xt(t,e-1))){for(const s=Math.min(t.length,e+5);e<s&&Yt(Xt(t,e));e++);const n=Xt(t,e);Dt(n)&&(e+=tn(t,e,n))}return e}function Le(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(!zn(n)){if(bt(n,Xt(t,e+1))){e=Jt(t,e)-1;continue}break}}return e}function Kn(t,e){let n=t.charCodeAt(e);if((n===43||n===45)&&(n=t.charCodeAt(e+=1)),at(n)&&(e=en(t,e+1),n=t.charCodeAt(e)),n===46&&at(t.charCodeAt(e+1))&&(e+=2,e=en(t,e)),qn(t,e,101)){let s=0;n=t.charCodeAt(e+1),(n===45||n===43)&&(s=1,n=t.charCodeAt(e+2)),at(n)&&(e=en(t,e+1+s+1))}return e}function nn(t,e){for(;e<t.length;e++){const n=t.charCodeAt(e);if(n===41){e++;break}bt(n,Xt(t,e+1))&&(e=Jt(t,e))}return e}function Qn(t){if(t.length===1&&!Yt(t.charCodeAt(0)))return t[0];let e=parseInt(t,16);return(e===0||e>=55296&&e<=57343||e>1114111)&&(e=65533),String.fromCodePoint(e)}const Yn=["EOF-token","ident-token","function-token","at-keyword-token","hash-token","string-token","bad-string-token","url-token","bad-url-token","delim-token","number-token","percentage-token","dimension-token","whitespace-token","CDO-token","CDC-token","colon-token","semicolon-token","comma-token","[-token","]-token","(-token",")-token","{-token","}-token","comment-token"],ta=16*1024;function Pe(t=null,e){return t===null||t.length<e?new Uint32Array(Math.max(e+1024,ta)):t}const Xn=10,ea=12,Jn=13;function Zn(t){const e=t.source,n=e.length,s=e.length>0?Hn(e.charCodeAt(0)):0,r=Pe(t.lines,n),o=Pe(t.columns,n);let a=t.startLine,l=t.startColumn;for(let u=s;u<n;u++){const i=e.charCodeAt(u);r[u]=a,o[u]=l++,(i===Xn||i===Jn||i===ea)&&(i===Jn&&u+1<n&&e.charCodeAt(u+1)===Xn&&(u++,r[u]=a,o[u]=l),a++,l=1)}r[n]=a,o[n]=l,t.lines=r,t.columns=o,t.computed=!0}class na{constructor(e,n,s,r){this.setSource(e,n,s,r),this.lines=null,this.columns=null}setSource(e="",n=0,s=1,r=1){this.source=e,this.startOffset=n,this.startLine=s,this.startColumn=r,this.computed=!1}getLocation(e,n){return this.computed||Zn(this),{source:n,offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]}}getLocationRange(e,n,s){return this.computed||Zn(this),{source:s,start:{offset:this.startOffset+e,line:this.lines[e],column:this.columns[e]},end:{offset:this.startOffset+n,line:this.lines[n],column:this.columns[n]}}}}const xt=16777215,Ct=24,Ft=new Uint8Array(32);Ft[T]=y,Ft[_]=y,Ft[Kt]=ue,Ft[mt]=Qt;function ts(t){return Ft[t]!==0}class sa{constructor(e,n){this.setSource(e,n)}reset(){this.eof=!1,this.tokenIndex=-1,this.tokenType=0,this.tokenStart=this.firstCharOffset,this.tokenEnd=this.firstCharOffset}setSource(e="",n=()=>{}){e=String(e||"");const s=e.length,r=Pe(this.offsetAndType,e.length+1),o=Pe(this.balance,e.length+1);let a=0,l=-1,u=0,i=e.length;this.offsetAndType=null,this.balance=null,o.fill(0),n(e,(c,h,f)=>{const p=a++;if(r[p]=c<<Ct|f,l===-1&&(l=h),o[p]=i,c===u){const g=o[i];o[i]=p,i=g,u=Ft[r[g]>>Ct]}else ts(c)&&(i=p,u=Ft[c])}),r[a]=Pt<<Ct|s,o[a]=a;for(let c=0;c<a;c++){const h=o[c];if(h<=c){const f=o[h];f!==c&&(o[c]=f)}else h>a&&(o[c]=a)}this.source=e,this.firstCharOffset=l===-1?0:l,this.tokenCount=a,this.offsetAndType=r,this.balance=o,this.reset(),this.next()}lookupType(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e]>>Ct:Pt}lookupTypeNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const s=this.offsetAndType[n]>>Ct;if(s!==B&&s!==Z&&e--===0)return s}return Pt}lookupOffset(e){return e+=this.tokenIndex,e<this.tokenCount?this.offsetAndType[e-1]&xt:this.source.length}lookupOffsetNonSC(e){for(let n=this.tokenIndex;n<this.tokenCount;n++){const s=this.offsetAndType[n]>>Ct;if(s!==B&&s!==Z&&e--===0)return n-this.tokenIndex}return Pt}lookupValue(e,n){return e+=this.tokenIndex,e<this.tokenCount?Ee(this.source,this.offsetAndType[e-1]&xt,this.offsetAndType[e]&xt,n):!1}getTokenStart(e){return e===this.tokenIndex?this.tokenStart:e>0?e<this.tokenCount?this.offsetAndType[e-1]&xt:this.offsetAndType[this.tokenCount]&xt:this.firstCharOffset}substrToCursor(e){return this.source.substring(e,this.tokenStart)}isBalanceEdge(e){return this.balance[this.tokenIndex]<e}isDelim(e,n){return n?this.lookupType(n)===L&&this.source.charCodeAt(this.lookupOffset(n))===e:this.tokenType===L&&this.source.charCodeAt(this.tokenStart)===e}skip(e){let n=this.tokenIndex+e;n<this.tokenCount?(this.tokenIndex=n,this.tokenStart=this.offsetAndType[n-1]&xt,n=this.offsetAndType[n],this.tokenType=n>>Ct,this.tokenEnd=n&xt):(this.tokenIndex=this.tokenCount,this.next())}next(){let e=this.tokenIndex+1;e<this.tokenCount?(this.tokenIndex=e,this.tokenStart=this.tokenEnd,e=this.offsetAndType[e],this.tokenType=e>>Ct,this.tokenEnd=e&xt):(this.eof=!0,this.tokenIndex=this.tokenCount,this.tokenType=Pt,this.tokenStart=this.tokenEnd=this.source.length)}skipSC(){for(;this.tokenType===B||this.tokenType===Z;)this.next()}skipUntilBalanced(e,n){let s=e,r=0,o=0;t:for(;s<this.tokenCount;s++){if(r=this.balance[s],r<e)break t;switch(o=s>0?this.offsetAndType[s-1]&xt:this.firstCharOffset,n(this.source.charCodeAt(o))){case 1:break t;case 2:s++;break t;default:ts(this.offsetAndType[s]>>Ct)&&(s=r)}}this.skip(s-this.tokenIndex)}forEachToken(e){for(let n=0,s=this.firstCharOffset;n<this.tokenCount;n++){const r=s,o=this.offsetAndType[n],a=o&xt,l=o>>Ct;s=a,e(l,r,a,n)}}dump(){const e=new Array(this.tokenCount);return this.forEachToken((n,s,r,o)=>{e[o]={idx:o,type:Yn[n],chunk:this.source.substring(s,r),balance:this.balance[o]}}),e}}function es(t,e){function n(h){return h<l?t.charCodeAt(h):0}function s(){if(i=Kn(t,i),Qe(n(i),n(i+1),n(i+2))){c=E,i=Le(t,i);return}if(n(i)===37){c=D,i++;return}c=b}function r(){const h=i;if(i=Le(t,i),Ee(t,h,i,"url")&&n(i)===40){if(i=$e(t,i+1),n(i)===34||n(i)===39){c=T,i=h+4;return}a();return}if(n(i)===40){c=T,i++;return}c=d}function o(h){for(h||(h=n(i++)),c=At;i<t.length;i++){const f=t.charCodeAt(i);switch(Ze(f)){case h:i++;return;case ve:if(Ae(f)){i+=tn(t,i,f),c=Go;return}break;case 92:if(i===t.length-1)break;const p=n(i+1);Ae(p)?i+=tn(t,i+1,p):bt(f,p)&&(i=Jt(t,i)-1);break}}}function a(){for(c=X,i=$e(t,i);i<t.length;i++){const h=t.charCodeAt(i);switch(Ze(h)){case 41:i++;return;case ve:if(i=$e(t,i),n(i)===41||i>=t.length){i<t.length&&i++;return}i=nn(t,i),c=dt;return;case 34:case 39:case 40:case Gn:i=nn(t,i),c=dt;return;case 92:if(bt(h,n(i+1))){i=Jt(t,i)-1;break}i=nn(t,i),c=dt;return}}}t=String(t||"");const l=t.length;let u=Hn(n(0)),i=u,c;for(;i<l;){const h=t.charCodeAt(i);switch(Ze(h)){case ve:c=B,i=$e(t,i+1);break;case 34:o();break;case 35:zn(n(i+1))||bt(n(i+1),n(i+2))?(c=N,i=Le(t,i+1)):(c=L,i++);break;case 39:o();break;case 40:c=_,i++;break;case 41:c=y,i++;break;case 43:Ye(h,n(i+1),n(i+2))?s():(c=L,i++);break;case 44:c=gt,i++;break;case 45:Ye(h,n(i+1),n(i+2))?s():n(i+1)===45&&n(i+2)===62?(c=ot,i=i+3):Qe(h,n(i+1),n(i+2))?r():(c=L,i++);break;case 46:Ye(h,n(i+1),n(i+2))?s():(c=L,i++);break;case 47:n(i+1)===42?(c=Z,i=t.indexOf("*/",i+2),i=i===-1?t.length:i+2):(c=L,i++);break;case 58:c=J,i++;break;case 59:c=et,i++;break;case 60:n(i+1)===33&&n(i+2)===45&&n(i+3)===45?(c=we,i=i+4):(c=L,i++);break;case 64:Qe(n(i+1),n(i+2),n(i+3))?(c=G,i=Le(t,i+1)):(c=L,i++);break;case 91:c=Kt,i++;break;case 92:bt(h,n(i+1))?r():(c=L,i++);break;case 93:c=ue,i++;break;case 123:c=mt,i++;break;case 125:c=Qt,i++;break;case Vn:s();break;case Je:r();break;default:c=L,i++}e(c,u,u=i)}}const ns=45;function ra(t,e){return e=e||0,t.length-e>=2&&t.charCodeAt(e)===ns&&t.charCodeAt(e+1)===ns}const sn=92,ss=34,ia=39;function rs(t){const e=t.length,n=t.charCodeAt(0),s=n===ss||n===ia?1:0,r=s===1&&e>1&&t.charCodeAt(e-1)===n?e-2:e-1;let o="";for(let a=s;a<=r;a++){let l=t.charCodeAt(a);if(l===sn){if(a===r){a!==e-1&&(o=t.substr(a+1));break}if(l=t.charCodeAt(++a),bt(sn,l)){const u=a-1,i=Jt(t,u);a=i-1,o+=Qn(t.substring(u+1,i))}else l===13&&t.charCodeAt(a+1)===10&&a++}else o+=t[a]}return o}function oa(t,e){const s=ss;let r="",o=!1;for(let a=0;a<t.length;a++){const l=t.charCodeAt(a);if(l===0){r+="�";continue}if(l<=31||l===127){r+="\\"+l.toString(16),o=!0;continue}l===s||l===sn?(r+="\\"+t.charAt(a),o=!1):(o&&(Yt(l)||Dt(l))&&(r+=" "),r+=t.charAt(a),o=!1)}return'"'+r+'"'}const aa=32,rn=92,la=34,ca=39,ua=40,is=41;function ha(t){const e=t.length;let n=4,s=t.charCodeAt(e-1)===is?e-2:e-1,r="";for(;n<s&&Dt(t.charCodeAt(n));)n++;for(;n<s&&Dt(t.charCodeAt(s));)s--;for(let o=n;o<=s;o++){let a=t.charCodeAt(o);if(a===rn){if(o===s){o!==e-1&&(r=t.substr(o+1));break}if(a=t.charCodeAt(++o),bt(rn,a)){const l=o-1,u=Jt(t,l);o=u-1,r+=Qn(t.substring(l+1,u))}else a===13&&t.charCodeAt(o+1)===10&&o++}else r+=t[o]}return r}function fa(t){let e="",n=!1;for(let s=0;s<t.length;s++){const r=t.charCodeAt(s);if(r===0){e+="�";continue}if(r<=31||r===127){e+="\\"+r.toString(16),n=!0;continue}r===aa||r===rn||r===la||r===ca||r===ua||r===is?(e+="\\"+t.charAt(s),n=!1):(n&&Yt(r)&&(e+=" "),e+=t.charAt(s),n=!1)}return"url("+e+")"}const{hasOwnProperty:on}=Object.prototype,he=function(){};function os(t){return typeof t=="function"?t:he}function as(t,e){return function(n,s,r){n.type===e&&t.call(this,n,s,r)}}function pa(t,e){const n=e.structure,s=[];for(const r in n){if(on.call(n,r)===!1)continue;let o=n[r];const a={name:r,type:!1,nullable:!1};Array.isArray(o)||(o=[o]);for(const l of o)l===null?a.nullable=!0:typeof l=="string"?a.type="node":Array.isArray(l)&&(a.type="list");a.type&&s.push(a)}return s.length?{context:e.walkContext,fields:s}:null}function da(t){const e={};for(const n in t.node)if(on.call(t.node,n)){const s=t.node[n];if(!s.structure)throw new Error("Missed `structure` field in `"+n+"` node type definition");e[n]=pa(n,s)}return e}function ls(t,e){const n=t.fields.slice(),s=t.context,r=typeof s=="string";return e&&n.reverse(),function(o,a,l,u){let i;r&&(i=a[s],a[s]=o);for(const c of n){const h=o[c.name];if(!c.nullable||h){if(c.type==="list"){if(e?h.reduceRight(u,!1):h.reduce(u,!1))return!0}else if(l(h))return!0}}r&&(a[s]=i)}}function cs({StyleSheet:t,Atrule:e,Rule:n,Block:s,DeclarationList:r}){return{Atrule:{StyleSheet:t,Atrule:e,Rule:n,Block:s},Rule:{StyleSheet:t,Atrule:e,Rule:n,Block:s},Declaration:{StyleSheet:t,Atrule:e,Rule:n,Block:s,DeclarationList:r}}}function ga(t){const e=da(t),n={},s={},r=Symbol("break-walk"),o=Symbol("skip-node");for(const i in e)on.call(e,i)&&e[i]!==null&&(n[i]=ls(e[i],!1),s[i]=ls(e[i],!0));const a=cs(n),l=cs(s),u=function(i,c){function h(S,x,A){const W=f.call(k,S,x,A);return W===r?!0:W===o?!1:!!(g.hasOwnProperty(S.type)&&g[S.type](S,k,h,m)||p.call(k,S,x,A)===r)}let f=he,p=he,g=n,m=(S,x,A,W)=>S||h(x,A,W);const k={break:r,skip:o,root:i,stylesheet:null,atrule:null,atrulePrelude:null,rule:null,selector:null,block:null,declaration:null,function:null};if(typeof c=="function")f=c;else if(c&&(f=os(c.enter),p=os(c.leave),c.reverse&&(g=s),c.visit)){if(a.hasOwnProperty(c.visit))g=c.reverse?l[c.visit]:a[c.visit];else if(!e.hasOwnProperty(c.visit))throw new Error("Bad value `"+c.visit+"` for `visit` option (should be: "+Object.keys(e).sort().join(", ")+")");f=as(f,c.visit),p=as(p,c.visit)}if(f===he&&p===he)throw new Error("Neither `enter` nor `leave` walker handler is set or both aren't a function");h(i)};return u.break=r,u.skip=o,u.find=function(i,c){let h=null;return u(i,function(f,p,g){if(c.call(this,f,p,g))return h=f,r}),h},u.findLast=function(i,c){let h=null;return u(i,{reverse:!0,enter(f,p,g){if(c.call(this,f,p,g))return h=f,r}}),h},u.findAll=function(i,c){const h=[];return u(i,function(f,p,g){c.call(this,f,p,g)&&h.push(f)}),h},u}const wt=43,lt=45,Oe=110,Mt=!0,ma=!1;function Re(t,e){let n=this.tokenStart+t;const s=this.charCodeAt(n);for((s===wt||s===lt)&&(e&&this.error("Number sign is not allowed"),n++);n<this.tokenEnd;n++)at(this.charCodeAt(n))||this.error("Integer is expected",n)}function Zt(t){return Re.call(this,0,t)}function Ot(t,e){if(!this.cmpChar(this.tokenStart+t,e)){let n="";switch(e){case Oe:n="N is expected";break;case lt:n="HyphenMinus is expected";break}this.error(n,this.tokenStart+t)}}function an(){let t=0,e=0,n=this.tokenType;for(;n===B||n===Z;)n=this.lookupType(++t);if(n!==b)if(this.isDelim(wt,t)||this.isDelim(lt,t)){e=this.isDelim(wt,t)?wt:lt;do n=this.lookupType(++t);while(n===B||n===Z);n!==b&&(this.skip(t),Zt.call(this,Mt))}else return null;return t>0&&this.skip(t),e===0&&(n=this.charCodeAt(this.tokenStart),n!==wt&&n!==lt&&this.error("Number sign is expected")),Zt.call(this,e!==0),e===lt?"-"+this.consume(b):this.consume(b)}const ka="AnPlusB",Sa={a:[String,null],b:[String,null]};function us(){const t=this.tokenStart;let e=null,n=null;if(this.tokenType===b)Zt.call(this,ma),n=this.consume(b);else if(this.tokenType===d&&this.cmpChar(this.tokenStart,lt))switch(e="-1",Ot.call(this,1,Oe),this.tokenEnd-this.tokenStart){case 2:this.next(),n=an.call(this);break;case 3:Ot.call(this,2,lt),this.next(),this.skipSC(),Zt.call(this,Mt),n="-"+this.consume(b);break;default:Ot.call(this,2,lt),Re.call(this,3,Mt),this.next(),n=this.substrToCursor(t+2)}else if(this.tokenType===d||this.isDelim(wt)&&this.lookupType(1)===d){let s=0;switch(e="1",this.isDelim(wt)&&(s=1,this.next()),Ot.call(this,0,Oe),this.tokenEnd-this.tokenStart){case 1:this.next(),n=an.call(this);break;case 2:Ot.call(this,1,lt),this.next(),this.skipSC(),Zt.call(this,Mt),n="-"+this.consume(b);break;default:Ot.call(this,1,lt),Re.call(this,2,Mt),this.next(),n=this.substrToCursor(t+s+1)}}else if(this.tokenType===E){const s=this.charCodeAt(this.tokenStart),r=s===wt||s===lt;let o=this.tokenStart+r;for(;o<this.tokenEnd&&at(this.charCodeAt(o));o++);o===this.tokenStart+r&&this.error("Integer is expected",this.tokenStart+r),Ot.call(this,o-this.tokenStart,Oe),e=this.substring(t,o),o+1===this.tokenEnd?(this.next(),n=an.call(this)):(Ot.call(this,o-this.tokenStart+1,lt),o+2===this.tokenEnd?(this.next(),this.skipSC(),Zt.call(this,Mt),n="-"+this.consume(b)):(Re.call(this,o-this.tokenStart+2,Mt),this.next(),n=this.substrToCursor(o+1)))}else this.error();return e!==null&&e.charCodeAt(0)===wt&&(e=e.substr(1)),n!==null&&n.charCodeAt(0)===wt&&(n=n.substr(1)),{type:"AnPlusB",loc:this.getLocation(t,this.tokenStart),a:e,b:n}}function hs(t){if(t.a){const e=t.a==="+1"&&"n"||t.a==="1"&&"n"||t.a==="-1"&&"-n"||t.a+"n";if(t.b){const n=t.b[0]==="-"||t.b[0]==="+"?t.b:"+"+t.b;this.tokenize(e+n)}else this.tokenize(e)}else this.tokenize(t.b)}const ya=Object.freeze(Object.defineProperty({__proto__:null,generate:hs,name:ka,parse:us,structure:Sa},Symbol.toStringTag,{value:"Module"}));function fs(){return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon,!0)}function ba(){for(let t=1,e;e=this.lookupType(t);t++){if(e===Qt)return!0;if(e===mt||e===G)return!1}return!1}const xa="Atrule",Ca="atrule",wa={name:String,prelude:["AtrulePrelude","Raw",null],block:["Block",null]};function ps(t=!1){const e=this.tokenStart;let n,s,r=null,o=null;switch(this.eat(G),n=this.substrToCursor(e+1),s=n.toLowerCase(),this.skipSC(),this.eof===!1&&this.tokenType!==mt&&this.tokenType!==et&&(this.parseAtrulePrelude?r=this.parseWithFallback(this.AtrulePrelude.bind(this,n,t),fs):r=fs.call(this,this.tokenIndex),this.skipSC()),this.tokenType){case et:this.next();break;case mt:hasOwnProperty.call(this.atrule,s)&&typeof this.atrule[s].block=="function"?o=this.atrule[s].block.call(this,t):o=this.Block(ba.call(this));break}return{type:"Atrule",loc:this.getLocation(e,this.tokenStart),name:n,prelude:r,block:o}}function ds(t){this.token(G,"@"+t.name),t.prelude!==null&&this.node(t.prelude),t.block?this.node(t.block):this.token(et,";")}const Ta=Object.freeze(Object.defineProperty({__proto__:null,generate:ds,name:xa,parse:ps,structure:wa,walkContext:Ca},Symbol.toStringTag,{value:"Module"})),Aa="AtrulePrelude",va="atrulePrelude",Ea={children:[[]]};function gs(t){let e=null;return t!==null&&(t=t.toLowerCase()),this.skipSC(),hasOwnProperty.call(this.atrule,t)&&typeof this.atrule[t].prelude=="function"?e=this.atrule[t].prelude.call(this):e=this.readSequence(this.scope.AtrulePrelude),this.skipSC(),this.eof!==!0&&this.tokenType!==mt&&this.tokenType!==et&&this.error("Semicolon or block is expected"),{type:"AtrulePrelude",loc:this.getLocationFromList(e),children:e}}function ms(t){this.children(t)}const $a=Object.freeze(Object.defineProperty({__proto__:null,generate:ms,name:Aa,parse:gs,structure:Ea,walkContext:va},Symbol.toStringTag,{value:"Module"})),La=36,ks=42,Ie=61,Pa=94,ln=124,Oa=126;function Ra(){this.eof&&this.error("Unexpected end of input");const t=this.tokenStart;let e=!1;return this.isDelim(ks)?(e=!0,this.next()):this.isDelim(ln)||this.eat(d),this.isDelim(ln)?this.charCodeAt(this.tokenStart+1)!==Ie?(this.next(),this.eat(d)):e&&this.error("Identifier is expected",this.tokenEnd):e&&this.error("Vertical line is expected"),{type:"Identifier",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function Ia(){const t=this.tokenStart,e=this.charCodeAt(t);return e!==Ie&&e!==Oa&&e!==Pa&&e!==La&&e!==ks&&e!==ln&&this.error("Attribute selector (=, ~=, ^=, $=, *=, |=) is expected"),this.next(),e!==Ie&&(this.isDelim(Ie)||this.error("Equal sign is expected"),this.next()),this.substrToCursor(t)}const _a="AttributeSelector",Na={name:"Identifier",matcher:[String,null],value:["String","Identifier",null],flags:[String,null]};function Ss(){const t=this.tokenStart;let e,n=null,s=null,r=null;return this.eat(Kt),this.skipSC(),e=Ra.call(this),this.skipSC(),this.tokenType!==ue&&(this.tokenType!==d&&(n=Ia.call(this),this.skipSC(),s=this.tokenType===At?this.String():this.Identifier(),this.skipSC()),this.tokenType===d&&(r=this.consume(d),this.skipSC())),this.eat(ue),{type:"AttributeSelector",loc:this.getLocation(t,this.tokenStart),name:e,matcher:n,value:s,flags:r}}function ys(t){this.token(L,"["),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(L,"]")}const Da=Object.freeze(Object.defineProperty({__proto__:null,generate:ys,name:_a,parse:Ss,structure:Na},Symbol.toStringTag,{value:"Module"})),Fa=38;function bs(){return this.Raw(null,!0)}function xs(){return this.parseWithFallback(this.Rule,bs)}function Cs(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}function Ma(){if(this.tokenType===et)return Cs.call(this,this.tokenIndex);const t=this.parseWithFallback(this.Declaration,Cs);return this.tokenType===et&&this.next(),t}const ja="Block",Ba="block",Wa={children:[["Atrule","Rule","Declaration"]]};function ws(t){const e=t?Ma:xs,n=this.tokenStart;let s=this.createList();this.eat(mt);t:for(;!this.eof;)switch(this.tokenType){case Qt:break t;case B:case Z:this.next();break;case G:s.push(this.parseWithFallback(this.Atrule.bind(this,t),bs));break;default:t&&this.isDelim(Fa)?s.push(xs.call(this)):s.push(e.call(this))}return this.eof||this.eat(Qt),{type:"Block",loc:this.getLocation(n,this.tokenStart),children:s}}function Ts(t){this.token(mt,"{"),this.children(t,e=>{e.type==="Declaration"&&this.token(et,";")}),this.token(Qt,"}")}const Ua=Object.freeze(Object.defineProperty({__proto__:null,generate:Ts,name:ja,parse:ws,structure:Wa,walkContext:Ba},Symbol.toStringTag,{value:"Module"})),za="Brackets",Ha={children:[[]]};function As(t,e){const n=this.tokenStart;let s=null;return this.eat(Kt),s=t.call(this,e),this.eof||this.eat(ue),{type:"Brackets",loc:this.getLocation(n,this.tokenStart),children:s}}function vs(t){this.token(L,"["),this.children(t),this.token(L,"]")}const Va=Object.freeze(Object.defineProperty({__proto__:null,generate:vs,name:za,parse:As,structure:Ha},Symbol.toStringTag,{value:"Module"})),Ga="CDC",qa=[];function Es(){const t=this.tokenStart;return this.eat(ot),{type:"CDC",loc:this.getLocation(t,this.tokenStart)}}function $s(){this.token(ot,"-->")}const Ka=Object.freeze(Object.defineProperty({__proto__:null,generate:$s,name:Ga,parse:Es,structure:qa},Symbol.toStringTag,{value:"Module"})),Qa="CDO",Ya=[];function Ls(){const t=this.tokenStart;return this.eat(we),{type:"CDO",loc:this.getLocation(t,this.tokenStart)}}function Ps(){this.token(we,"<!--")}const Xa=Object.freeze(Object.defineProperty({__proto__:null,generate:Ps,name:Qa,parse:Ls,structure:Ya},Symbol.toStringTag,{value:"Module"})),Ja=46,Za="ClassSelector",tl={name:String};function Os(){return this.eatDelim(Ja),{type:"ClassSelector",loc:this.getLocation(this.tokenStart-1,this.tokenEnd),name:this.consume(d)}}function Rs(t){this.token(L,"."),this.token(d,t.name)}const el=Object.freeze(Object.defineProperty({__proto__:null,generate:Rs,name:Za,parse:Os,structure:tl},Symbol.toStringTag,{value:"Module"})),nl=43,Is=47,sl=62,rl=126,il="Combinator",ol={name:String};function _s(){const t=this.tokenStart;let e;switch(this.tokenType){case B:e=" ";break;case L:switch(this.charCodeAt(this.tokenStart)){case sl:case nl:case rl:this.next();break;case Is:this.next(),this.eatIdent("deep"),this.eatDelim(Is);break;default:this.error("Combinator is expected")}e=this.substrToCursor(t);break}return{type:"Combinator",loc:this.getLocation(t,this.tokenStart),name:e}}function Ns(t){this.tokenize(t.name)}const al=Object.freeze(Object.defineProperty({__proto__:null,generate:Ns,name:il,parse:_s,structure:ol},Symbol.toStringTag,{value:"Module"})),ll=42,cl=47,ul="Comment",hl={value:String};function Ds(){const t=this.tokenStart;let e=this.tokenEnd;return this.eat(Z),e-t+2>=2&&this.charCodeAt(e-2)===ll&&this.charCodeAt(e-1)===cl&&(e-=2),{type:"Comment",loc:this.getLocation(t,this.tokenStart),value:this.substring(t+2,e)}}function Fs(t){this.token(Z,"/*"+t.value+"*/")}const fl=Object.freeze(Object.defineProperty({__proto__:null,generate:Fs,name:ul,parse:Ds,structure:hl},Symbol.toStringTag,{value:"Module"})),pl=new Set([J,y,Pt]),dl="Condition",gl={kind:String,children:[["Identifier","Feature","FeatureFunction","FeatureRange","SupportsDeclaration"]]};function Ms(t){return this.lookupTypeNonSC(1)===d&&pl.has(this.lookupTypeNonSC(2))?this.Feature(t):this.FeatureRange(t)}const ml={media:Ms,container:Ms,supports(){return this.SupportsDeclaration()}};function js(t="media"){const e=this.createList();t:for(;!this.eof;)switch(this.tokenType){case Z:case B:this.next();continue;case d:e.push(this.Identifier());break;case _:{let n=this.parseWithFallback(()=>ml[t].call(this,t),()=>null);n||(n=this.parseWithFallback(()=>{this.eat(_);const s=this.Condition(t);return this.eat(y),s},()=>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 Bs(t){t.children.forEach(e=>{e.type==="Condition"?(this.token(_,"("),this.node(e),this.token(y,")")):this.node(e)})}const kl=Object.freeze(Object.defineProperty({__proto__:null,generate:Bs,name:dl,parse:js,structure:gl},Symbol.toStringTag,{value:"Module"})),Ws=33,Sl=35,yl=36,bl=38,xl=42,Cl=43,Us=47;function wl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!0)}function Tl(){return this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1)}function Al(){const t=this.tokenIndex,e=this.Value();return e.type!=="Raw"&&this.eof===!1&&this.tokenType!==et&&this.isDelim(Ws)===!1&&this.isBalanceEdge(t)===!1&&this.error(),e}const vl="Declaration",El="declaration",$l={important:[Boolean,String],property:String,value:["Value","Raw"]};function zs(){const t=this.tokenStart,e=this.tokenIndex,n=Ll.call(this),s=ra(n),r=s?this.parseCustomProperty:this.parseValue,o=s?Tl:wl;let a=!1,l;this.skipSC(),this.eat(J);const u=this.tokenIndex;if(s||this.skipSC(),r?l=this.parseWithFallback(Al,o):l=o.call(this,this.tokenIndex),s&&l.type==="Value"&&l.children.isEmpty){for(let i=u-this.tokenIndex;i<=0;i++)if(this.lookupType(i)===B){l.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}return this.isDelim(Ws)&&(a=Pl.call(this),this.skipSC()),this.eof===!1&&this.tokenType!==et&&this.isBalanceEdge(e)===!1&&this.error(),{type:"Declaration",loc:this.getLocation(t,this.tokenStart),important:a,property:n,value:l}}function Hs(t){this.token(d,t.property),this.token(J,":"),this.node(t.value),t.important&&(this.token(L,"!"),this.token(d,t.important===!0?"important":t.important))}function Ll(){const t=this.tokenStart;if(this.tokenType===L)switch(this.charCodeAt(this.tokenStart)){case xl:case yl:case Cl:case Sl:case bl:this.next();break;case Us:this.next(),this.isDelim(Us)&&this.next();break}return this.tokenType===N?this.eat(N):this.eat(d),this.substrToCursor(t)}function Pl(){this.eat(L),this.skipSC();const t=this.consume(d);return t==="important"?!0:t}const Ol=Object.freeze(Object.defineProperty({__proto__:null,generate:Hs,name:vl,parse:zs,structure:$l,walkContext:El},Symbol.toStringTag,{value:"Module"})),Rl=38;function cn(){return this.Raw(this.consumeUntilSemicolonIncluded,!0)}const Il="DeclarationList",_l={children:[["Declaration","Atrule","Rule"]]};function Vs(){const t=this.createList();for(;!this.eof;)switch(this.tokenType){case B:case Z:case et:this.next();break;case G:t.push(this.parseWithFallback(this.Atrule.bind(this,!0),cn));break;default:this.isDelim(Rl)?t.push(this.parseWithFallback(this.Rule,cn)):t.push(this.parseWithFallback(this.Declaration,cn))}return{type:"DeclarationList",loc:this.getLocationFromList(t),children:t}}function Gs(t){this.children(t,e=>{e.type==="Declaration"&&this.token(et,";")})}const Nl=Object.freeze(Object.defineProperty({__proto__:null,generate:Gs,name:Il,parse:Vs,structure:_l},Symbol.toStringTag,{value:"Module"})),Dl="Dimension",Fl={value:String,unit:String};function qs(){const t=this.tokenStart,e=this.consumeNumber(E);return{type:"Dimension",loc:this.getLocation(t,this.tokenStart),value:e,unit:this.substring(t+e.length,this.tokenStart)}}function Ks(t){this.token(E,t.value+t.unit)}const Ml=Object.freeze(Object.defineProperty({__proto__:null,generate:Ks,name:Dl,parse:qs,structure:Fl},Symbol.toStringTag,{value:"Module"})),jl=47,Bl="Feature",Wl={kind:String,name:String,value:["Identifier","Number","Dimension","Ratio","Function",null]};function Qs(t){const e=this.tokenStart;let n,s=null;if(this.eat(_),this.skipSC(),n=this.consume(d),this.skipSC(),this.tokenType!==y){switch(this.eat(J),this.skipSC(),this.tokenType){case b:this.lookupNonWSType(1)===L?s=this.Ratio():s=this.Number();break;case E:s=this.Dimension();break;case d:s=this.Identifier();break;case T:s=this.parseWithFallback(()=>{const r=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(jl)&&this.error(),r},()=>this.Ratio());break;default:this.error("Number, dimension, ratio or identifier is expected")}this.skipSC()}return this.eof||this.eat(y),{type:"Feature",loc:this.getLocation(e,this.tokenStart),kind:t,name:n,value:s}}function Ys(t){this.token(_,"("),this.token(d,t.name),t.value!==null&&(this.token(J,":"),this.node(t.value)),this.token(y,")")}const Ul=Object.freeze(Object.defineProperty({__proto__:null,generate:Ys,name:Bl,parse:Qs,structure:Wl},Symbol.toStringTag,{value:"Module"})),zl="FeatureFunction",Hl={kind:String,feature:String,value:["Declaration","Selector"]};function Vl(t,e){const s=(this.features[t]||{})[e];return typeof s!="function"&&this.error(`Unknown feature ${e}()`),s}function Xs(t="unknown"){const e=this.tokenStart,n=this.consumeFunctionName(),s=Vl.call(this,t,n.toLowerCase());this.skipSC();const r=this.parseWithFallback(()=>{const o=this.tokenIndex,a=s.call(this);return this.eof===!1&&this.isBalanceEdge(o)===!1&&this.error(),a},()=>this.Raw(null,!1));return this.eof||this.eat(y),{type:"FeatureFunction",loc:this.getLocation(e,this.tokenStart),kind:t,feature:n,value:r}}function Js(t){this.token(T,t.feature+"("),this.node(t.value),this.token(y,")")}const Gl=Object.freeze(Object.defineProperty({__proto__:null,generate:Js,name:zl,parse:Xs,structure:Hl},Symbol.toStringTag,{value:"Module"})),Zs=47,ql=60,tr=61,Kl=62,Ql="FeatureRange",Yl={kind:String,left:["Identifier","Number","Dimension","Ratio","Function"],leftComparison:String,middle:["Identifier","Number","Dimension","Ratio","Function"],rightComparison:[String,null],right:["Identifier","Number","Dimension","Ratio","Function",null]};function un(){switch(this.skipSC(),this.tokenType){case b:return this.isDelim(Zs,this.lookupOffsetNonSC(1))?this.Ratio():this.Number();case E:return this.Dimension();case d:return this.Identifier();case T:return this.parseWithFallback(()=>{const t=this.Function(this.readSequence,this.scope.Value);return this.skipSC(),this.isDelim(Zs)&&this.error(),t},()=>this.Ratio());default:this.error("Number, dimension, ratio or identifier is expected")}}function er(t){if(this.skipSC(),this.isDelim(ql)||this.isDelim(Kl)){const e=this.source[this.tokenStart];return this.next(),this.isDelim(tr)?(this.next(),e+"="):e}if(this.isDelim(tr))return"=";this.error(`Expected ${t?'":", ':""}"<", ">", "=" or ")"`)}function nr(t="unknown"){const e=this.tokenStart;this.skipSC(),this.eat(_);const n=un.call(this),s=er.call(this,n.type==="Identifier"),r=un.call(this);let o=null,a=null;return this.lookupNonWSType(0)!==y&&(o=er.call(this),a=un.call(this)),this.skipSC(),this.eat(y),{type:"FeatureRange",loc:this.getLocation(e,this.tokenStart),kind:t,left:n,leftComparison:s,middle:r,rightComparison:o,right:a}}function sr(t){this.token(_,"("),this.node(t.left),this.tokenize(t.leftComparison),this.node(t.middle),t.right&&(this.tokenize(t.rightComparison),this.node(t.right)),this.token(y,")")}const Xl=Object.freeze(Object.defineProperty({__proto__:null,generate:sr,name:Ql,parse:nr,structure:Yl},Symbol.toStringTag,{value:"Module"})),Jl="Function",Zl="function",tc={name:String,children:[[]]};function rr(t,e){const n=this.tokenStart,s=this.consumeFunctionName(),r=s.toLowerCase();let o;return o=e.hasOwnProperty(r)?e[r].call(this,e):t.call(this,e),this.eof||this.eat(y),{type:"Function",loc:this.getLocation(n,this.tokenStart),name:s,children:o}}function ir(t){this.token(T,t.name+"("),this.children(t),this.token(y,")")}const ec=Object.freeze(Object.defineProperty({__proto__:null,generate:ir,name:Jl,parse:rr,structure:tc,walkContext:Zl},Symbol.toStringTag,{value:"Module"})),nc="GeneralEnclosed",sc={kind:String,function:[String,null],children:[[]]};function or(t){const e=this.tokenStart;let n=null;this.tokenType===T?n=this.consumeFunctionName():this.eat(_);const s=this.parseWithFallback(()=>{const r=this.tokenIndex,o=this.readSequence(this.scope.Value);return this.eof===!1&&this.isBalanceEdge(r)===!1&&this.error(),o},()=>this.createSingleNodeList(this.Raw(null,!1)));return this.eof||this.eat(y),{type:"GeneralEnclosed",loc:this.getLocation(e,this.tokenStart),kind:t,function:n,children:s}}function ar(t){t.function?this.token(T,t.function+"("):this.token(_,"("),this.children(t),this.token(y,")")}const rc=Object.freeze(Object.defineProperty({__proto__:null,generate:ar,name:nc,parse:or,structure:sc},Symbol.toStringTag,{value:"Module"})),ic="XXX",oc="Hash",ac={value:String};function lr(){const t=this.tokenStart;return this.eat(N),{type:"Hash",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t+1)}}function cr(t){this.token(N,"#"+t.value)}const lc=Object.freeze(Object.defineProperty({__proto__:null,generate:cr,name:oc,parse:lr,structure:ac,xxx:ic},Symbol.toStringTag,{value:"Module"})),cc="Identifier",uc={name:String};function ur(){return{type:"Identifier",loc:this.getLocation(this.tokenStart,this.tokenEnd),name:this.consume(d)}}function hr(t){this.token(d,t.name)}const hc=Object.freeze(Object.defineProperty({__proto__:null,generate:hr,name:cc,parse:ur,structure:uc},Symbol.toStringTag,{value:"Module"})),fc="IdSelector",pc={name:String};function fr(){const t=this.tokenStart;return this.eat(N),{type:"IdSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t+1)}}function pr(t){this.token(L,"#"+t.name)}const dc=Object.freeze(Object.defineProperty({__proto__:null,generate:pr,name:fc,parse:fr,structure:pc},Symbol.toStringTag,{value:"Module"})),gc=46,mc="Layer",kc={name:String};function dr(){let t=this.tokenStart,e=this.consume(d);for(;this.isDelim(gc);)this.eat(L),e+="."+this.consume(d);return{type:"Layer",loc:this.getLocation(t,this.tokenStart),name:e}}function gr(t){this.tokenize(t.name)}const Sc=Object.freeze(Object.defineProperty({__proto__:null,generate:gr,name:mc,parse:dr,structure:kc},Symbol.toStringTag,{value:"Module"})),yc="LayerList",bc={children:[["Layer"]]};function mr(){const t=this.createList();for(this.skipSC();!this.eof&&(t.push(this.Layer()),this.lookupTypeNonSC(0)===gt);)this.skipSC(),this.next(),this.skipSC();return{type:"LayerList",loc:this.getLocationFromList(t),children:t}}function kr(t){this.children(t,()=>this.token(gt,","))}const xc=Object.freeze(Object.defineProperty({__proto__:null,generate:kr,name:yc,parse:mr,structure:bc},Symbol.toStringTag,{value:"Module"})),Cc="MediaQuery",wc={modifier:[String,null],mediaType:[String,null],condition:["Condition",null]};function Sr(){const t=this.tokenStart;let e=null,n=null,s=null;if(this.skipSC(),this.tokenType===d&&this.lookupTypeNonSC(1)!==_){const r=this.consume(d),o=r.toLowerCase();switch(o==="not"||o==="only"?(this.skipSC(),e=o,n=this.consume(d)):n=r,this.lookupTypeNonSC(0)){case d:{this.skipSC(),this.eatIdent("and"),s=this.Condition("media");break}case mt:case et:case gt:case Pt:break;default:this.error("Identifier or parenthesis is expected")}}else switch(this.tokenType){case d:case _:case T:{s=this.Condition("media");break}case mt:case et:case Pt:break;default:this.error("Identifier or parenthesis is expected")}return{type:"MediaQuery",loc:this.getLocation(t,this.tokenStart),modifier:e,mediaType:n,condition:s}}function yr(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 Tc=Object.freeze(Object.defineProperty({__proto__:null,generate:yr,name:Cc,parse:Sr,structure:wc},Symbol.toStringTag,{value:"Module"})),Ac="MediaQueryList",vc={children:[["MediaQuery"]]};function br(){const t=this.createList();for(this.skipSC();!this.eof&&(t.push(this.MediaQuery()),this.tokenType===gt);)this.next();return{type:"MediaQueryList",loc:this.getLocationFromList(t),children:t}}function xr(t){this.children(t,()=>this.token(gt,","))}const Ec=Object.freeze(Object.defineProperty({__proto__:null,generate:xr,name:Ac,parse:br,structure:vc},Symbol.toStringTag,{value:"Module"})),$c=38,Lc="NestingSelector",Pc={};function Cr(){const t=this.tokenStart;return this.eatDelim($c),{type:"NestingSelector",loc:this.getLocation(t,this.tokenStart)}}function wr(){this.token(L,"&")}const Oc=Object.freeze(Object.defineProperty({__proto__:null,generate:wr,name:Lc,parse:Cr,structure:Pc},Symbol.toStringTag,{value:"Module"})),Rc="Nth",Ic={nth:["AnPlusB","Identifier"],selector:["SelectorList",null]};function Tr(){this.skipSC();const t=this.tokenStart;let e=t,n=null,s;return this.lookupValue(0,"odd")||this.lookupValue(0,"even")?s=this.Identifier():s=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:s,selector:n}}function Ar(t){this.node(t.nth),t.selector!==null&&(this.token(d,"of"),this.node(t.selector))}const _c=Object.freeze(Object.defineProperty({__proto__:null,generate:Ar,name:Rc,parse:Tr,structure:Ic},Symbol.toStringTag,{value:"Module"})),Nc="Number",Dc={value:String};function vr(){return{type:"Number",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consume(b)}}function Er(t){this.token(b,t.value)}const Fc=Object.freeze(Object.defineProperty({__proto__:null,generate:Er,name:Nc,parse:vr,structure:Dc},Symbol.toStringTag,{value:"Module"})),Mc="Operator",jc={value:String};function $r(){const t=this.tokenStart;return this.next(),{type:"Operator",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t)}}function Lr(t){this.tokenize(t.value)}const Bc=Object.freeze(Object.defineProperty({__proto__:null,generate:Lr,name:Mc,parse:$r,structure:jc},Symbol.toStringTag,{value:"Module"})),Wc="Parentheses",Uc={children:[[]]};function Pr(t,e){const n=this.tokenStart;let s=null;return this.eat(_),s=t.call(this,e),this.eof||this.eat(y),{type:"Parentheses",loc:this.getLocation(n,this.tokenStart),children:s}}function Or(t){this.token(_,"("),this.children(t),this.token(y,")")}const zc=Object.freeze(Object.defineProperty({__proto__:null,generate:Or,name:Wc,parse:Pr,structure:Uc},Symbol.toStringTag,{value:"Module"})),Hc="Percentage",Vc={value:String};function Rr(){return{type:"Percentage",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:this.consumeNumber(D)}}function Ir(t){this.token(D,t.value+"%")}const Gc=Object.freeze(Object.defineProperty({__proto__:null,generate:Ir,name:Hc,parse:Rr,structure:Vc},Symbol.toStringTag,{value:"Module"})),qc="PseudoClassSelector",Kc="function",Qc={name:String,children:[["Raw"],null]};function _r(){const t=this.tokenStart;let e=null,n,s;return this.eat(J),this.tokenType===T?(n=this.consumeFunctionName(),s=n.toLowerCase(),this.lookupNonWSType(0)==y?e=this.createList():hasOwnProperty.call(this.pseudo,s)?(this.skipSC(),e=this.pseudo[s].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(y)):n=this.consume(d),{type:"PseudoClassSelector",loc:this.getLocation(t,this.tokenStart),name:n,children:e}}function Nr(t){this.token(J,":"),t.children===null?this.token(d,t.name):(this.token(T,t.name+"("),this.children(t),this.token(y,")"))}const Yc=Object.freeze(Object.defineProperty({__proto__:null,generate:Nr,name:qc,parse:_r,structure:Qc,walkContext:Kc},Symbol.toStringTag,{value:"Module"})),Xc="PseudoElementSelector",Jc="function",Zc={name:String,children:[["Raw"],null]};function Dr(){const t=this.tokenStart;let e=null,n,s;return this.eat(J),this.eat(J),this.tokenType===T?(n=this.consumeFunctionName(),s=n.toLowerCase(),this.lookupNonWSType(0)==y?e=this.createList():hasOwnProperty.call(this.pseudo,s)?(this.skipSC(),e=this.pseudo[s].call(this),this.skipSC()):(e=this.createList(),e.push(this.Raw(null,!1))),this.eat(y)):n=this.consume(d),{type:"PseudoElementSelector",loc:this.getLocation(t,this.tokenStart),name:n,children:e}}function Fr(t){this.token(J,":"),this.token(J,":"),t.children===null?this.token(d,t.name):(this.token(T,t.name+"("),this.children(t),this.token(y,")"))}const tu=Object.freeze(Object.defineProperty({__proto__:null,generate:Fr,name:Xc,parse:Dr,structure:Zc,walkContext:Jc},Symbol.toStringTag,{value:"Module"})),Mr=47;function jr(){switch(this.skipSC(),this.tokenType){case b:return this.Number();case T:return this.Function(this.readSequence,this.scope.Value);default:this.error("Number of function is expected")}}const eu="Ratio",nu={left:["Number","Function"],right:["Number","Function",null]};function Br(){const t=this.tokenStart,e=jr.call(this);let n=null;return this.skipSC(),this.isDelim(Mr)&&(this.eatDelim(Mr),n=jr.call(this)),{type:"Ratio",loc:this.getLocation(t,this.tokenStart),left:e,right:n}}function Wr(t){this.node(t.left),this.token(L,"/"),t.right?this.node(t.right):this.node(b,1)}const su=Object.freeze(Object.defineProperty({__proto__:null,generate:Wr,name:eu,parse:Br,structure:nu},Symbol.toStringTag,{value:"Module"}));function ru(){return this.tokenIndex>0&&this.lookupType(-1)===B?this.tokenIndex>1?this.getTokenStart(this.tokenIndex-1):this.firstCharOffset:this.tokenStart}const iu="Raw",ou={value:String};function Ur(t,e){const n=this.getTokenStart(this.tokenIndex);let s;return this.skipUntilBalanced(this.tokenIndex,t||this.consumeUntilBalanceEnd),e&&this.tokenStart>n?s=ru.call(this):s=this.tokenStart,{type:"Raw",loc:this.getLocation(n,s),value:this.substring(n,s)}}function zr(t){this.tokenize(t.value)}const au=Object.freeze(Object.defineProperty({__proto__:null,generate:zr,name:iu,parse:Ur,structure:ou},Symbol.toStringTag,{value:"Module"}));function Hr(){return this.Raw(this.consumeUntilLeftCurlyBracket,!0)}function lu(){const t=this.SelectorList();return t.type!=="Raw"&&this.eof===!1&&this.tokenType!==mt&&this.error(),t}const cu="Rule",uu="rule",hu={prelude:["SelectorList","Raw"],block:["Block"]};function Vr(){const t=this.tokenIndex,e=this.tokenStart;let n,s;return this.parseRulePrelude?n=this.parseWithFallback(lu,Hr):n=Hr.call(this,t),s=this.Block(!0),{type:"Rule",loc:this.getLocation(e,this.tokenStart),prelude:n,block:s}}function Gr(t){this.node(t.prelude),this.node(t.block)}const fu=Object.freeze(Object.defineProperty({__proto__:null,generate:Gr,name:cu,parse:Vr,structure:hu,walkContext:uu},Symbol.toStringTag,{value:"Module"})),pu="Scope",du={root:["SelectorList","Raw",null],limit:["SelectorList","Raw",null]};function qr(){let t=null,e=null;this.skipSC();const n=this.tokenStart;return this.tokenType===_&&(this.next(),this.skipSC(),t=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(y)),this.lookupNonWSType(0)===d&&(this.skipSC(),this.eatIdent("to"),this.skipSC(),this.eat(_),this.skipSC(),e=this.parseWithFallback(this.SelectorList,()=>this.Raw(!1,!0)),this.skipSC(),this.eat(y)),{type:"Scope",loc:this.getLocation(n,this.tokenStart),root:t,limit:e}}function Kr(t){t.root&&(this.token(_,"("),this.node(t.root),this.token(y,")")),t.limit&&(this.token(d,"to"),this.token(_,"("),this.node(t.limit),this.token(y,")"))}const gu=Object.freeze(Object.defineProperty({__proto__:null,generate:Kr,name:pu,parse:qr,structure:du},Symbol.toStringTag,{value:"Module"})),mu="Selector",ku={children:[["TypeSelector","IdSelector","ClassSelector","AttributeSelector","PseudoClassSelector","PseudoElementSelector","Combinator"]]};function Qr(){const t=this.readSequence(this.scope.Selector);return this.getFirstListNode(t)===null&&this.error("Selector is expected"),{type:"Selector",loc:this.getLocationFromList(t),children:t}}function Yr(t){this.children(t)}const Su=Object.freeze(Object.defineProperty({__proto__:null,generate:Yr,name:mu,parse:Qr,structure:ku},Symbol.toStringTag,{value:"Module"})),yu="SelectorList",bu="selector",xu={children:[["Selector","Raw"]]};function Xr(){const t=this.createList();for(;!this.eof;){if(t.push(this.Selector()),this.tokenType===gt){this.next();continue}break}return{type:"SelectorList",loc:this.getLocationFromList(t),children:t}}function Jr(t){this.children(t,()=>this.token(gt,","))}const Cu=Object.freeze(Object.defineProperty({__proto__:null,generate:Jr,name:yu,parse:Xr,structure:xu,walkContext:bu},Symbol.toStringTag,{value:"Module"})),wu="String",Tu={value:String};function Zr(){return{type:"String",loc:this.getLocation(this.tokenStart,this.tokenEnd),value:rs(this.consume(At))}}function ti(t){this.token(At,oa(t.value))}const Au=Object.freeze(Object.defineProperty({__proto__:null,generate:ti,name:wu,parse:Zr,structure:Tu},Symbol.toStringTag,{value:"Module"})),vu=33;function ei(){return this.Raw(null,!1)}const Eu="StyleSheet",$u="stylesheet",Lu={children:[["Comment","CDO","CDC","Atrule","Rule","Raw"]]};function ni(){const t=this.tokenStart,e=this.createList();let n;for(;!this.eof;){switch(this.tokenType){case B:this.next();continue;case Z:if(this.charCodeAt(this.tokenStart+2)!==vu){this.next();continue}n=this.Comment();break;case we:n=this.CDO();break;case ot:n=this.CDC();break;case G:n=this.parseWithFallback(this.Atrule,ei);break;default:n=this.parseWithFallback(this.Rule,ei)}e.push(n)}return{type:"StyleSheet",loc:this.getLocation(t,this.tokenStart),children:e}}function si(t){this.children(t)}const Pu=Object.freeze(Object.defineProperty({__proto__:null,generate:si,name:Eu,parse:ni,structure:Lu,walkContext:$u},Symbol.toStringTag,{value:"Module"})),Ou="SupportsDeclaration",Ru={declaration:"Declaration"};function ri(){const t=this.tokenStart;this.eat(_),this.skipSC();const e=this.Declaration();return this.eof||this.eat(y),{type:"SupportsDeclaration",loc:this.getLocation(t,this.tokenStart),declaration:e}}function ii(t){this.token(_,"("),this.node(t.declaration),this.token(y,")")}const Iu=Object.freeze(Object.defineProperty({__proto__:null,generate:ii,name:Ou,parse:ri,structure:Ru},Symbol.toStringTag,{value:"Module"})),_u=42,oi=124;function hn(){this.tokenType!==d&&this.isDelim(_u)===!1&&this.error("Identifier or asterisk is expected"),this.next()}const Nu="TypeSelector",Du={name:String};function ai(){const t=this.tokenStart;return this.isDelim(oi)?(this.next(),hn.call(this)):(hn.call(this),this.isDelim(oi)&&(this.next(),hn.call(this))),{type:"TypeSelector",loc:this.getLocation(t,this.tokenStart),name:this.substrToCursor(t)}}function li(t){this.tokenize(t.name)}const Fu=Object.freeze(Object.defineProperty({__proto__:null,generate:li,name:Nu,parse:ai,structure:Du},Symbol.toStringTag,{value:"Module"})),ci=43,ui=45,fn=63;function fe(t,e){let n=0;for(let s=this.tokenStart+t;s<this.tokenEnd;s++){const r=this.charCodeAt(s);if(r===ui&&e&&n!==0)return fe.call(this,t+n+1,!1),-1;Yt(r)||this.error(e&&n!==0?"Hyphen minus"+(n<6?" or hex digit":"")+" is expected":n<6?"Hex digit is expected":"Unexpected input",s),++n>6&&this.error("Too many hex digits",s)}return this.next(),n}function _e(t){let e=0;for(;this.isDelim(fn);)++e>t&&this.error("Too many question marks"),this.next()}function Mu(t){this.charCodeAt(this.tokenStart)!==t&&this.error((t===ci?"Plus sign":"Hyphen minus")+" is expected")}function ju(){let t=0;switch(this.tokenType){case b:if(t=fe.call(this,1,!0),this.isDelim(fn)){_e.call(this,6-t);break}if(this.tokenType===E||this.tokenType===b){Mu.call(this,ui),fe.call(this,1,!1);break}break;case E:t=fe.call(this,1,!0),t>0&&_e.call(this,6-t);break;default:if(this.eatDelim(ci),this.tokenType===d){t=fe.call(this,0,!0),t>0&&_e.call(this,6-t);break}if(this.isDelim(fn)){this.next(),_e.call(this,5);break}this.error("Hex digit or question mark is expected")}}const Bu="UnicodeRange",Wu={value:String};function hi(){const t=this.tokenStart;return this.eatIdent("u"),ju.call(this),{type:"UnicodeRange",loc:this.getLocation(t,this.tokenStart),value:this.substrToCursor(t)}}function fi(t){this.tokenize(t.value)}const Uu=Object.freeze(Object.defineProperty({__proto__:null,generate:fi,name:Bu,parse:hi,structure:Wu},Symbol.toStringTag,{value:"Module"})),zu="Url",Hu={value:String};function pi(){const t=this.tokenStart;let e;switch(this.tokenType){case X:e=ha(this.consume(X));break;case T:this.cmpStr(this.tokenStart,this.tokenEnd,"url(")||this.error("Function name must be `url`"),this.eat(T),this.skipSC(),e=rs(this.consume(At)),this.skipSC(),this.eof||this.eat(y);break;default:this.error("Url or Function is expected")}return{type:"Url",loc:this.getLocation(t,this.tokenStart),value:e}}function di(t){this.token(X,fa(t.value))}const Vu=Object.freeze(Object.defineProperty({__proto__:null,generate:di,name:zu,parse:pi,structure:Hu},Symbol.toStringTag,{value:"Module"})),Gu="Value",qu={children:[[]]};function gi(){const t=this.tokenStart,e=this.readSequence(this.scope.Value);return{type:"Value",loc:this.getLocation(t,this.tokenStart),children:e}}function mi(t){this.children(t)}const Ku=Object.freeze(Object.defineProperty({__proto__:null,generate:mi,name:Gu,parse:gi,structure:qu},Symbol.toStringTag,{value:"Module"})),Qu=Object.freeze({type:"WhiteSpace",loc:null,value:" "}),Yu="WhiteSpace",Xu={value:String};function ki(){return this.eat(B),Qu}function Si(t){this.token(B,t.value)}const Rt=ga({node:Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:ya,Atrule:Ta,AtrulePrelude:$a,AttributeSelector:Da,Block:Ua,Brackets:Va,CDC:Ka,CDO:Xa,ClassSelector:el,Combinator:al,Comment:fl,Condition:kl,Declaration:Ol,DeclarationList:Nl,Dimension:Ml,Feature:Ul,FeatureFunction:Gl,FeatureRange:Xl,Function:ec,GeneralEnclosed:rc,Hash:lc,IdSelector:dc,Identifier:hc,Layer:Sc,LayerList:xc,MediaQuery:Tc,MediaQueryList:Ec,NestingSelector:Oc,Nth:_c,Number:Fc,Operator:Bc,Parentheses:zc,Percentage:Gc,PseudoClassSelector:Yc,PseudoElementSelector:tu,Ratio:su,Raw:au,Rule:fu,Scope:gu,Selector:Su,SelectorList:Cu,String:Au,StyleSheet:Pu,SupportsDeclaration:Iu,TypeSelector:Fu,UnicodeRange:Uu,Url:Vu,Value:Ku,WhiteSpace:Object.freeze(Object.defineProperty({__proto__:null,generate:Si,name:Yu,parse:ki,structure:Xu},Symbol.toStringTag,{value:"Module"}))},Symbol.toStringTag,{value:"Module"}))}),pn=["left","right","top","bottom","inset-block-start","inset-block-end","inset-inline-start","inset-inline-end","inset-block","inset-inline","inset"];function pe(t){return pn.includes(t)}const dn=["margin-block-start","margin-block-end","margin-block","margin-inline-start","margin-inline-end","margin-inline","margin-bottom","margin-left","margin-right","margin-top","margin"];function Ju(t){return dn.includes(t)}const gn=["width","height","min-width","min-height","max-width","max-height","block-size","inline-size","min-block-size","min-inline-size","max-block-size","max-inline-size"];function yi(t){return gn.includes(t)}const bi=["justify-self","align-self","place-self"];function Zu(t){return bi.includes(t)}const xi=[...pn,...dn,...gn,...bi,"position-anchor","position-area"],th=[...gn,...pn,...dn];function Ci(t){return th.includes(t)}const eh=["top","left","right","bottom","start","end","self-start","self-end","center","inside","outside"];function wi(t){return eh.includes(t)}const nh=["width","height","block","inline","self-block","self-inline"];function sh(t){return nh.includes(t)}const Ti=new Set(["Atrule","Selector","Declaration"]);function rh(t){const e=new SourceMapGenerator,n={line:1,column:0},s={line:0,column:0},r={line:1,column:0},o={generated:r};let a=1,l=0,u=!1;const i=t.node;t.node=function(f){if(f.loc&&f.loc.start&&Ti.has(f.type)){const p=f.loc.start.line,g=f.loc.start.column-1;(s.line!==p||s.column!==g)&&(s.line=p,s.column=g,n.line=a,n.column=l,u&&(u=!1,(n.line!==r.line||n.column!==r.column)&&e.addMapping(o)),u=!0,e.addMapping({source:f.loc.source,original:s,generated:n}))}i.call(this,f),u&&Ti.has(f.type)&&(r.line=a,r.column=l)};const c=t.emit;t.emit=function(f,p,g){for(let m=0;m<f.length;m++)f.charCodeAt(m)===10?(a++,l=0):l++;c(f,p,g)};const h=t.result;return t.result=function(){return u&&e.addMapping(o),{css:h(),map:e}},t}const ih=43,oh=45,mn=(t,e)=>{if(t===L&&(t=e),typeof t=="string"){const n=t.charCodeAt(0);return n>127?32768:n<<8}return t},Ai=[[d,d],[d,T],[d,X],[d,dt],[d,"-"],[d,b],[d,D],[d,E],[d,ot],[d,_],[G,d],[G,T],[G,X],[G,dt],[G,"-"],[G,b],[G,D],[G,E],[G,ot],[N,d],[N,T],[N,X],[N,dt],[N,"-"],[N,b],[N,D],[N,E],[N,ot],[E,d],[E,T],[E,X],[E,dt],[E,"-"],[E,b],[E,D],[E,E],[E,ot],["#",d],["#",T],["#",X],["#",dt],["#","-"],["#",b],["#",D],["#",E],["#",ot],["-",d],["-",T],["-",X],["-",dt],["-","-"],["-",b],["-",D],["-",E],["-",ot],[b,d],[b,T],[b,X],[b,dt],[b,b],[b,D],[b,E],[b,"%"],[b,ot],["@",d],["@",T],["@",X],["@",dt],["@","-"],["@",ot],[".",b],[".",D],[".",E],["+",b],["+",D],["+",E],["/","*"]],ah=Ai.concat([[d,N],[E,N],[N,N],[G,_],[G,At],[G,J],[D,D],[D,E],[D,T],[D,"-"],[y,d],[y,T],[y,D],[y,E],[y,N],[y,"-"]]);function vi(t){const e=new Set(t.map(([n,s])=>mn(n)<<16|mn(s)));return function(n,s,r){const o=mn(s,r),a=r.charCodeAt(0);return(a===oh&&s!==d&&s!==T&&s!==ot||a===ih?e.has(n<<16|a<<8):e.has(n<<16|o))&&this.emit(" ",B,!0),o}}const lh=vi(Ai),Ei=vi(ah),$i=Object.freeze(Object.defineProperty({__proto__:null,safe:Ei,spec:lh},Symbol.toStringTag,{value:"Module"})),ch=92;function uh(t,e){if(typeof e=="function"){let n=null;t.children.forEach(s=>{n!==null&&e.call(this,n),this.node(s),n=s});return}t.children.forEach(this.node,this)}function hh(t){es(t,(e,n,s)=>{this.token(e,t.slice(n,s))})}function fh(t){const e=new Map;for(let[n,s]of Object.entries(t.node))typeof(s.generate||s)=="function"&&e.set(n,s.generate||s);return function(n,s){let r="",o=0,a={node(u){if(e.has(u.type))e.get(u.type).call(l,u);else throw new Error("Unknown node type: "+u.type)},tokenBefore:Ei,token(u,i){o=this.tokenBefore(o,u,i),this.emit(i,u,!1),u===L&&i.charCodeAt(0)===ch&&this.emit(`
`,B,!0)},emit(u){r+=u},result(){return r}};s&&(typeof s.decorator=="function"&&(a=s.decorator(a)),s.sourceMap&&(a=rh(a)),s.mode in $i&&(a.tokenBefore=$i[s.mode]));const l={node:u=>a.node(u),children:uh,token:(u,i)=>a.token(u,i),tokenize:hh};return a.node(n),a.result()}}const ph=fh({node:Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:hs,Atrule:ds,AtrulePrelude:ms,AttributeSelector:ys,Block:Ts,Brackets:vs,CDC:$s,CDO:Ps,ClassSelector:Rs,Combinator:Ns,Comment:Fs,Condition:Bs,Declaration:Hs,DeclarationList:Gs,Dimension:Ks,Feature:Ys,FeatureFunction:Js,FeatureRange:sr,Function:ir,GeneralEnclosed:ar,Hash:cr,IdSelector:pr,Identifier:hr,Layer:gr,LayerList:kr,MediaQuery:yr,MediaQueryList:xr,NestingSelector:wr,Nth:Ar,Number:Er,Operator:Lr,Parentheses:Or,Percentage:Ir,PseudoClassSelector:Nr,PseudoElementSelector:Fr,Ratio:Wr,Raw:zr,Rule:Gr,Scope:Kr,Selector:Yr,SelectorList:Jr,String:ti,StyleSheet:si,SupportsDeclaration:ii,TypeSelector:li,UnicodeRange:fi,Url:di,Value:mi,WhiteSpace:Si},Symbol.toStringTag,{value:"Module"}))});function dh(t,e){const n=Object.create(SyntaxError.prototype),s=new Error;return Object.assign(n,{name:t,message:e,get stack(){return(s.stack||"").replace(/^(.+\n){1,3}/,`${t}: ${e}
`)}})}const kn=100,Li=60,Pi="    ";function Oi({source:t,line:e,column:n,baseLine:s,baseColumn:r},o){function a(g,m){return i.slice(g,m).map((k,S)=>String(g+S+1).padStart(f)+" |"+k).join(`
`)}const l=`
`.repeat(Math.max(s-1,0)),u=" ".repeat(Math.max(r-1,0)),i=(l+u+t).split(/\r\n?|\n|\f/),c=Math.max(1,e-o)-1,h=Math.min(e+o,i.length+1),f=Math.max(4,String(h).length)+1;let p=0;n+=(Pi.length-1)*(i[e-1].substr(0,n-1).match(/\t/g)||[]).length,n>kn&&(p=n-Li+3,n=Li-2);for(let g=c;g<=h;g++)g>=0&&g<i.length&&(i[g]=i[g].replace(/\t/g,Pi),i[g]=(p>0&&i[g].length>p?"…":"")+i[g].substr(p,kn-2)+(i[g].length>p+kn-1?"…":""));return[a(c,e),new Array(n+f+2).join("-")+"^",a(e,h)].filter(Boolean).join(`
`).replace(/^(\s+\d+\s+\|\n)+/,"").replace(/\n(\s+\d+\s+\|)+$/,"")}function Ri(t,e,n,s,r,o=1,a=1){return Object.assign(dh("SyntaxError",t),{source:e,offset:n,line:s,column:r,sourceFragment(u){return Oi({source:e,line:s,column:r,baseLine:o,baseColumn:a},isNaN(u)?0:u)},get formattedMessage(){return`Parse error: ${t}
`+Oi({source:e,line:s,column:r,baseLine:o,baseColumn:a},2)}})}function gh(t){const e=this.createList();let n=!1;const s={recognizer:t};for(;!this.eof;){switch(this.tokenType){case Z:this.next();continue;case B:n=!0,this.next();continue}let r=t.getNode.call(this,s);if(r===void 0)break;n&&(t.onWhiteSpace&&t.onWhiteSpace.call(this,r,e,s),n=!1),e.push(r)}return n&&t.onWhiteSpace&&t.onWhiteSpace.call(this,null,e,s),e}const Ii=()=>{},mh=33,kh=35,Sn=59,_i=123,Ni=0;function Sh(t){return function(){return this[t]()}}function yn(t){const e=Object.create(null);for(const n of Object.keys(t)){const s=t[n],r=s.parse||s;r&&(e[n]=r)}return e}function yh(t){const e={context:Object.create(null),features:Object.assign(Object.create(null),t.features),scope:Object.assign(Object.create(null),t.scope),atrule:yn(t.atrule),pseudo:yn(t.pseudo),node:yn(t.node)};for(const[n,s]of Object.entries(t.parseContext))switch(typeof s){case"function":e.context[n]=s;break;case"string":e.context[n]=Sh(s);break}return H(H({config:e},e),e.node)}function bh(t){let e="",n="<unknown>",s=!1,r=Ii,o=!1;const a=new na,l=Object.assign(new sa,yh(t||{}),{parseAtrulePrelude:!0,parseRulePrelude:!0,parseValue:!0,parseCustomProperty:!1,readSequence:gh,consumeUntilBalanceEnd:()=>0,consumeUntilLeftCurlyBracket(i){return i===_i?1:0},consumeUntilLeftCurlyBracketOrSemicolon(i){return i===_i||i===Sn?1:0},consumeUntilExclamationMarkOrSemicolon(i){return i===mh||i===Sn?1:0},consumeUntilSemicolonIncluded(i){return i===Sn?2:0},createList(){return new K},createSingleNodeList(i){return new K().appendData(i)},getFirstListNode(i){return i&&i.first},getLastListNode(i){return i&&i.last},parseWithFallback(i,c){const h=this.tokenIndex;try{return i.call(this)}catch(f){if(o)throw f;this.skip(h-this.tokenIndex);const p=c.call(this);return o=!0,r(f,p),o=!1,p}},lookupNonWSType(i){let c;do if(c=this.lookupType(i++),c!==B&&c!==Z)return c;while(c!==Ni);return Ni},charCodeAt(i){return i>=0&&i<e.length?e.charCodeAt(i):0},substring(i,c){return e.substring(i,c)},substrToCursor(i){return this.source.substring(i,this.tokenStart)},cmpChar(i,c){return qn(e,i,c)},cmpStr(i,c,h){return Ee(e,i,c,h)},consume(i){const c=this.tokenStart;return this.eat(i),this.substrToCursor(c)},consumeFunctionName(){const i=e.substring(this.tokenStart,this.tokenEnd-1);return this.eat(T),i},consumeNumber(i){const c=e.substring(this.tokenStart,Kn(e,this.tokenStart));return this.eat(i),c},eat(i){if(this.tokenType!==i){const c=Yn[i].slice(0,-6).replace(/-/g," ").replace(/^./,p=>p.toUpperCase());let h=`${/[[\](){}]/.test(c)?`"${c}"`:c} is expected`,f=this.tokenStart;switch(i){case d:this.tokenType===T||this.tokenType===X?(f=this.tokenEnd-1,h="Identifier is expected but function found"):h="Identifier is expected";break;case N:this.isDelim(kh)&&(this.next(),f++,h="Name is expected");break;case D:this.tokenType===b&&(f=this.tokenEnd,h="Percent sign is expected");break}this.error(h,f)}this.next()},eatIdent(i){(this.tokenType!==d||this.lookupValue(0,i)===!1)&&this.error(`Identifier "${i}" is expected`),this.next()},eatDelim(i){this.isDelim(i)||this.error(`Delim "${String.fromCharCode(i)}" is expected`),this.next()},getLocation(i,c){return s?a.getLocationRange(i,c,n):null},getLocationFromList(i){if(s){const c=this.getFirstListNode(i),h=this.getLastListNode(i);return a.getLocationRange(c!==null?c.loc.start.offset-a.startOffset:this.tokenStart,h!==null?h.loc.end.offset-a.startOffset:this.tokenStart,n)}return null},error(i,c){const h=typeof c!="undefined"&&c<e.length?a.getLocation(c):this.eof?a.getLocation(Zo(e,e.length-1)):a.getLocation(this.tokenStart);throw new Ri(i||"Unexpected input",e,h.offset,h.line,h.column,a.startLine,a.startColumn)}});return Object.assign(function(i,c){e=i,c=c||{},l.setSource(e,es),a.setSource(e,c.offset,c.line,c.column),n=c.filename||"<unknown>",s=!!c.positions,r=typeof c.onParseError=="function"?c.onParseError:Ii,o=!1,l.parseAtrulePrelude="parseAtrulePrelude"in c?!!c.parseAtrulePrelude:!0,l.parseRulePrelude="parseRulePrelude"in c?!!c.parseRulePrelude:!0,l.parseValue="parseValue"in c?!!c.parseValue:!0,l.parseCustomProperty="parseCustomProperty"in c?!!c.parseCustomProperty:!1;const{context:h="default",onComment:f}=c;if(!(h in l.context))throw new Error("Unknown context `"+h+"`");typeof f=="function"&&l.forEachToken((g,m,k)=>{if(g===Z){const S=l.getLocation(m,k),x=Ee(e,k-2,k,"*/")?e.slice(m+2,k-2):e.slice(m+2,k);f(x,S)}});const p=l.context[h].call(l,c);return l.eof||l.error(),p},{SyntaxError:Ri,config:l.config})}const xh=35,Ch=42,Di=43,wh=45,Th=47,Ah=117;function Fi(t){switch(this.tokenType){case N:return this.Hash();case gt:return this.Operator();case _:return this.Parentheses(this.readSequence,t.recognizer);case Kt:return this.Brackets(this.readSequence,t.recognizer);case At:return this.String();case E:return this.Dimension();case D:return this.Percentage();case b:return this.Number();case T:return this.cmpStr(this.tokenStart,this.tokenEnd,"url(")?this.Url():this.Function(this.readSequence,t.recognizer);case X:return this.Url();case d:return this.cmpChar(this.tokenStart,Ah)&&this.cmpChar(this.tokenStart+1,Di)?this.UnicodeRange():this.Identifier();case L:{const e=this.charCodeAt(this.tokenStart);if(e===Th||e===Ch||e===Di||e===wh)return this.Operator();e===xh&&this.error("Hex or identifier is expected",this.tokenStart+1);break}}}const vh={getNode:Fi},Eh=35,$h=38,Lh=42,Ph=43,Oh=47,Mi=46,Rh=62,Ih=124,_h=126;function Nh(t,e){e.last!==null&&e.last.type!=="Combinator"&&t!==null&&t.type!=="Combinator"&&e.push({type:"Combinator",loc:null,name:" "})}function Dh(){switch(this.tokenType){case Kt:return this.AttributeSelector();case N:return this.IdSelector();case J:return this.lookupType(1)===J?this.PseudoElementSelector():this.PseudoClassSelector();case d:return this.TypeSelector();case b:case D:return this.Percentage();case E:this.charCodeAt(this.tokenStart)===Mi&&this.error("Identifier is expected",this.tokenStart+1);break;case L:{switch(this.charCodeAt(this.tokenStart)){case Ph:case Rh:case _h:case Oh:return this.Combinator();case Mi:return this.ClassSelector();case Lh:case Ih:return this.TypeSelector();case Eh:return this.IdSelector();case $h:return this.NestingSelector()}break}}}const Fh={onWhiteSpace:Nh,getNode:Dh};function Mh(){return this.createSingleNodeList(this.Raw(null,!1))}function jh(){const t=this.createList();if(this.skipSC(),t.push(this.Identifier()),this.skipSC(),this.tokenType===gt){t.push(this.Operator());const e=this.tokenIndex,n=this.parseCustomProperty?this.Value(null):this.Raw(this.consumeUntilExclamationMarkOrSemicolon,!1);if(n.type==="Value"&&n.children.isEmpty){for(let s=e-this.tokenIndex;s<=0;s++)if(this.lookupType(s)===B){n.children.appendData({type:"WhiteSpace",loc:null,value:" "});break}}t.push(n)}return t}function ji(t){return t!==null&&t.type==="Operator"&&(t.value[t.value.length-1]==="-"||t.value[t.value.length-1]==="+")}const Bh=Object.freeze(Object.defineProperty({__proto__:null,AtrulePrelude:vh,Selector:Fh,Value:{getNode:Fi,onWhiteSpace(t,e){ji(t)&&(t.value=" "+t.value),ji(e.last)&&(e.last.value+=" ")},expression:Mh,var:jh}},Symbol.toStringTag,{value:"Module"})),Wh=new Set(["none","and","not","or"]),Uh={parse:{prelude(){const t=this.createList();if(this.tokenType===d){const e=this.substring(this.tokenStart,this.tokenEnd);Wh.has(e.toLowerCase())||t.push(this.Identifier())}return t.push(this.Condition("container")),t},block(t=!1){return this.Block(t)}}},zh={parse:{prelude:null,block(){return this.Block(!0)}}};function bn(t,e){return this.parseWithFallback(()=>{try{return t.call(this)}finally{this.skipSC(),this.lookupNonWSType(0)!==y&&this.error()}},e||(()=>this.Raw(null,!0)))}const Bi={layer(){this.skipSC();const t=this.createList(),e=bn.call(this,this.Layer);return(e.type!=="Raw"||e.value!=="")&&t.push(e),t},supports(){this.skipSC();const t=this.createList(),e=bn.call(this,this.Declaration,()=>bn.call(this,()=>this.Condition("supports")));return(e.type!=="Raw"||e.value!=="")&&t.push(e),t}},Hh={container:Uh,"font-face":zh,import:{parse:{prelude(){const t=this.createList();switch(this.tokenType){case At:t.push(this.String());break;case X:case T:t.push(this.Url());break;default:this.error("String or url() is expected")}return this.skipSC(),this.tokenType===d&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer")?t.push(this.Identifier()):this.tokenType===T&&this.cmpStr(this.tokenStart,this.tokenEnd,"layer(")&&t.push(this.Function(null,Bi)),this.skipSC(),this.tokenType===T&&this.cmpStr(this.tokenStart,this.tokenEnd,"supports(")&&t.push(this.Function(null,Bi)),(this.lookupNonWSType(0)===d||this.lookupNonWSType(0)===_)&&t.push(this.MediaQueryList()),t},block:null}},layer:{parse:{prelude(){return this.createSingleNodeList(this.LayerList())},block(){return this.Block(!1)}}},media:{parse:{prelude(){return this.createSingleNodeList(this.MediaQueryList())},block(t=!1){return this.Block(t)}}},nest:{parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},page:{parse:{prelude(){return this.createSingleNodeList(this.SelectorList())},block(){return this.Block(!0)}}},scope:{parse:{prelude(){return this.createSingleNodeList(this.Scope())},block(t=!1){return this.Block(t)}}},"starting-style":{parse:{prelude:null,block(t=!1){return this.Block(t)}}},supports:{parse:{prelude(){return this.createSingleNodeList(this.Condition("supports"))},block(t=!1){return this.Block(t)}}}};function Vh(){const t=this.createList();this.skipSC();t:for(;!this.eof;){switch(this.tokenType){case d:t.push(this.Identifier());break;case At:t.push(this.String());break;case gt:t.push(this.Operator());break;case y:break t;default:this.error("Identifier, string or comma is expected")}this.skipSC()}return t}const jt={parse(){return this.createSingleNodeList(this.SelectorList())}},xn={parse(){return this.createSingleNodeList(this.Selector())}},Gh={parse(){return this.createSingleNodeList(this.Identifier())}},qh={parse:Vh},Ne={parse(){return this.createSingleNodeList(this.Nth())}},Kh=bh({parseContext:{default:"StyleSheet",stylesheet:"StyleSheet",atrule:"Atrule",atrulePrelude(t){return this.AtrulePrelude(t.atrule?String(t.atrule):null)},mediaQueryList:"MediaQueryList",mediaQuery:"MediaQuery",condition(t){return this.Condition(t.kind)},rule:"Rule",selectorList:"SelectorList",selector:"Selector",block(){return this.Block(!0)},declarationList:"DeclarationList",declaration:"Declaration",value:"Value"},features:{supports:{selector(){return this.Selector()}},container:{style(){return this.Declaration()}}},scope:Bh,atrule:Hh,pseudo:{dir:Gh,has:jt,lang:qh,matches:jt,is:jt,"-moz-any":jt,"-webkit-any":jt,where:jt,not:jt,"nth-child":Ne,"nth-last-child":Ne,"nth-last-of-type":Ne,"nth-of-type":Ne,slotted:xn,host:xn,"host-context":xn},node:Object.freeze(Object.defineProperty({__proto__:null,AnPlusB:us,Atrule:ps,AtrulePrelude:gs,AttributeSelector:Ss,Block:ws,Brackets:As,CDC:Es,CDO:Ls,ClassSelector:Os,Combinator:_s,Comment:Ds,Condition:js,Declaration:zs,DeclarationList:Vs,Dimension:qs,Feature:Qs,FeatureFunction:Xs,FeatureRange:nr,Function:rr,GeneralEnclosed:or,Hash:lr,IdSelector:fr,Identifier:ur,Layer:dr,LayerList:mr,MediaQuery:Sr,MediaQueryList:br,NestingSelector:Cr,Nth:Tr,Number:vr,Operator:$r,Parentheses:Pr,Percentage:Rr,PseudoClassSelector:_r,PseudoElementSelector:Dr,Ratio:Br,Raw:Ur,Rule:Vr,Scope:qr,Selector:Qr,SelectorList:Xr,String:Zr,StyleSheet:ni,SupportsDeclaration:ri,TypeSelector:ai,UnicodeRange:hi,Url:pi,Value:gi,WhiteSpace:ki},Symbol.toStringTag,{value:"Module"}))});let Qh="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict",kt=(t=21)=>{let e="",n=t|0;for(;n--;)e+=Qh[Math.random()*64|0];return e};const Wi=kt(),de=new Set;function De(t){return!!(t&&t.type==="Function"&&t.name==="anchor")}function It(t,e=!1){return Kh(t,{parseAtrulePrelude:!1,parseCustomProperty:!0,onParseError:n=>{e&&de.add(n)}})}function nt(t){return ph(t,{mode:"spec"})}function Ui(t){return t.type==="Declaration"}function Yh(t){return t.toArray().reduce((e,n)=>n.type==="Operator"&&n.value===","?(e.push([]),e):(n.type==="Identifier"&&e[e.length-1].push(n),e),[[]])}function Cn(t){return t?t.children.map(e=>{var r;let n;((r=e.children.last)==null?void 0:r.type)==="PseudoElementSelector"&&(e=Ce(e),n=nt(e.children.last),e.children.pop());const s=nt(e);return{selector:s+(n!=null?n:""),elementPart:s,pseudoElementPart:n}}).toArray():[]}function Xh(){de.size>0&&(console.group(`The CSS anchor positioning polyfill was not applied due to ${de.size===1?"a CSS parse error":"CSS parse errors"}.`),de.forEach(t=>{console.warn(t.formattedMessage)}),console.groupEnd())}function Jh(){de.clear()}const wn=[...xi,"anchor-scope","anchor-name"].reduce((t,e)=>(t[e]=`--${e}-${Wi}`,t),{});function Zh(t,e){return Ui(t)&&wn[t.property]&&e?(e.children.appendData(Y(H({},t),{property:wn[t.property]})),{updated:!0}):{updated:!1}}function tf(t,e){const n=["inset","inset-block","inset-inline"];if(!Ui(t)||!e||!n.includes(t.property))return{updated:!1};const s=(r,o)=>{o&&e.children.appendData(Y(H({},t),{property:r,value:{type:"Value",children:new K().fromArray([o])}}))};if(t.property==="inset"){const r=t.value.children.toArray(),[o,a,l,u]=(()=>{switch(r.length){case 1:return[r[0],r[0],r[0],r[0]];case 2:return[r[0],r[1],r[0],r[1]];case 3:return[r[0],r[1],r[2],r[1]];case 4:return[r[0],r[1],r[2],r[3]];default:return[]}})();s("top",o),s("right",a),s("bottom",l),s("left",u)}else if(t.property==="inset-block"){const r=t.value.children.toArray(),[o,a]=(()=>{switch(r.length){case 1:return[r[0],r[0]];case 2:return[r[0],r[1]];default:return[]}})();s("inset-block-start",o),s("inset-block-end",a)}else if(t.property==="inset-inline"){const r=t.value.children.toArray(),[o,a]=(()=>{switch(r.length){case 1:return[r[0],r[0]];case 2:return[r[0],r[1]];default:return[]}})();s("inset-inline-start",o),s("inset-inline-end",a)}return{updated:!0}}function ef(t){for(const e of t){let n=!1;const s=It(e.css,!0);Rt(s,{visit:"Declaration",enter(r){var u;const o=(u=this.rule)==null?void 0:u.block,{updated:a}=tf(r,o),{updated:l}=Zh(r,o);(l||a)&&(n=!0)}}),n&&(e.css=nt(s),e.changed=!0)}return t.some(e=>e.changed===!0)}var zi=(t=>(t.All="all",t.None="none",t))(zi||{});function ht(t,e){var s;return e=(s=wn[e])!=null?s:e,(t instanceof HTMLElement?getComputedStyle(t):t.computedStyle).getPropertyValue(e).trim()}function te(t,e,n){return ht(t,e)===n}function nf(t,{selector:e,pseudoElementPart:n}){const s=getComputedStyle(t,n),r=document.createElement("div"),o=document.createElement("style");r.id=`fake-pseudo-element-${kt()}`;for(const l of Array.from(s)){const u=s.getPropertyValue(l);r.style.setProperty(l,u)}o.textContent+=`#${r.id}${n} { content: ${s.content}; }`,o.textContent+=`${e} { display: none !important; }`,document.head.append(o);const a=n==="::before"?"afterbegin":"beforeend";return t.insertAdjacentElement(a,r),{fakePseudoElement:r,sheet:o,computedStyle:s}}function sf(t){let e=t;for(;e;){if(te(e,"overflow","scroll"))return e;e=e.parentElement}return e}function rf(t){let e=sf(t);return e===document.documentElement&&(e=null),e!=null?e:{scrollTop:0,scrollLeft:0}}function of(t,e){const{elementPart:n,pseudoElementPart:s}=t,r=[];if(s&&!(s==="::before"||s==="::after"))return r;const l=ge(e.roots,n);if(!s)return r.push(...l),r;for(const u of l){const{fakePseudoElement:i,sheet:c,computedStyle:h}=nf(u,t),f=i.getBoundingClientRect(),{scrollY:p,scrollX:g}=globalThis,m=rf(u);r.push({fakePseudoElement:i,computedStyle:h,removeFakePseudoElement(){i.remove(),c.remove()},contextElement:u,getBoundingClientRect(){const{scrollY:k,scrollX:S}=globalThis,{scrollTop:x,scrollLeft:A}=m;return DOMRect.fromRect({y:f.y+(p-k)+(m.scrollTop-x),x:f.x+(g-S)+(m.scrollLeft-A),width:f.width,height:f.height})}})}return r}function af(t,e){const n=ht(t,"anchor-name");return e?n.split(",").map(s=>s.trim()).includes(e):!n}function lf(t,e){const n=ht(t,"anchor-scope");return n===e||n==="all"}const Tn=t=>R(null,null,function*(){var n,s,r;let e=yield(n=q.getOffsetParent)==null?void 0:n.call(q,t);return(yield(s=q.isElement)==null?void 0:s.call(q,e))||(e=(yield(r=q.getDocumentElement)==null?void 0:r.call(q,t))||window.document.documentElement),e}),ge=(t,e)=>t.flatMap(n=>[...n.querySelectorAll(e)]),Hi="InvalidMimeType";function cf(t){return!!((t.type==="text/css"||t.rel==="stylesheet")&&t.href)}function uf(t){const e=new URL(t.href,document.baseURI);if(cf(t)&&e.origin===location.origin)return e}function hf(t){return R(this,null,function*(){return(yield Promise.all(t.map(n=>R(null,null,function*(){var s;if(!n.url)return n;if((s=n.el)!=null&&s.disabled)return null;try{const r=yield fetch(n.url.toString()),o=r.headers.get("content-type");if(!(o!=null&&o.startsWith("text/css"))){const l=new Error(`Error loading ${n.url}: expected content-type "text/css", got "${o}".`);throw l.name=Hi,l}const a=yield r.text();return Y(H({},n),{css:a})}catch(r){if(r instanceof Error&&r.name===Hi)return console.warn(r),null;throw r}})))).filter(n=>n!==null)})}const Vi='[style*="anchor"]',Gi='[style*="position-area"]';function ff(t){const e=t?t.filter(s=>s instanceof HTMLElement&&(s.matches(Vi)||s.matches(Gi))):Array.from(document.querySelectorAll([Vi,Gi].join(","))),n=[];return e.filter(s=>s instanceof HTMLElement).forEach(s=>{const r=kt(12),o="data-has-inline-styles";s.setAttribute(o,r);const a=s.getAttribute("style"),l=`[${o}="${r}"] { ${a} }`;n.push({el:s,css:l})}),n}function pf(t){return R(this,null,function*(){var o,a;const e=(o=t.elements)!=null?o:ge(t.roots,"link, style"),n=[];e.filter(l=>l instanceof HTMLElement).forEach(l=>{if(l.tagName.toLowerCase()==="link"){const u=uf(l);u&&n.push({el:l,url:u})}l.tagName.toLowerCase()==="style"&&n.push({el:l,css:l.innerHTML})});const s=t.excludeInlineStyles?(a=t.elements)!=null?a:[]:void 0,r=ff(s);return yield hf([...n,...r])})}const df="useandom-26T198340PX75pxJACKVERYMINDBUSHWOLF_GQZbfghjklqvwyzrict";let qi=(t=21)=>{let e="",n=crypto.getRandomValues(new Uint8Array(t|=0));for(;t--;)e+=df[n[t]&63];return e};const Ki="--pa-cascade-property",Qi="data-anchor-position-wrapper",Yi="data-pa-wrapper-for-",Xi="POLYFILL-POSITION-AREA",gf=["left","center","right","span-left","span-right","x-start","x-end","span-x-start","span-x-end","self-x-start","self-x-end","span-self-x-start","span-self-x-end","span-all","top","bottom","span-top","span-bottom","y-start","y-end","span-y-start","span-y-end","self-y-start","self-y-end","span-self-y-start","span-self-y-end","block-start","block-end","span-block-start","span-block-end","inline-start","inline-end","span-inline-start","span-inline-end","self-block-start","self-block-end","span-self-block-start","span-self-block-end","self-inline-start","self-inline-end","span-self-inline-start","span-self-inline-end","start","end","span-start","span-end","self-start","self-end","span-self-start","span-self-end"];function Ji(t){return gf.includes(t)}const Zi={left:[0,1,"Irrelevant"],center:[1,2,"Irrelevant"],right:[2,3,"Irrelevant"],"span-left":[0,2,"Irrelevant"],"span-right":[1,3,"Irrelevant"],"x-start":[0,1,"Physical"],"x-end":[2,3,"Physical"],"span-x-start":[0,2,"Physical"],"span-x-end":[1,3,"Physical"],"self-x-start":[0,1,"PhysicalSelf"],"self-x-end":[2,3,"PhysicalSelf"],"span-self-x-start":[0,2,"PhysicalSelf"],"span-self-x-end":[1,3,"PhysicalSelf"],"span-all":[0,3,"Irrelevant"],top:[0,1,"Irrelevant"],bottom:[2,3,"Irrelevant"],"span-top":[0,2,"Irrelevant"],"span-bottom":[1,3,"Irrelevant"],"y-start":[0,1,"Physical"],"y-end":[2,3,"Physical"],"span-y-start":[0,2,"Physical"],"span-y-end":[1,3,"Physical"],"self-y-start":[0,1,"PhysicalSelf"],"self-y-end":[2,3,"PhysicalSelf"],"span-self-y-start":[0,2,"PhysicalSelf"],"span-self-y-end":[1,3,"PhysicalSelf"],"block-start":[0,1,"Logical"],"block-end":[2,3,"Logical"],"span-block-start":[0,2,"Logical"],"span-block-end":[1,3,"Logical"],"inline-start":[0,1,"Logical"],"inline-end":[2,3,"Logical"],"span-inline-start":[0,2,"Logical"],"span-inline-end":[1,3,"Logical"],"self-block-start":[0,1,"LogicalSelf"],"self-block-end":[2,3,"LogicalSelf"],"span-self-block-start":[0,2,"LogicalSelf"],"span-self-block-end":[1,3,"LogicalSelf"],"self-inline-start":[0,1,"LogicalSelf"],"self-inline-end":[2,3,"LogicalSelf"],"span-self-inline-start":[0,2,"LogicalSelf"],"span-self-inline-end":[1,3,"LogicalSelf"],start:[0,1,"Logical"],end:[2,3,"Logical"],"span-start":[0,2,"Logical"],"span-end":[1,3,"Logical"],"self-start":[0,1,"LogicalSelf"],"self-end":[2,3,"LogicalSelf"],"span-self-start":[0,2,"LogicalSelf"],"span-self-end":[1,3,"LogicalSelf"]},mf=["left","center","right","span-left","span-right","x-start","x-end","span-x-start","span-x-end","self-x-start","self-x-end","span-self-x-start","span-self-x-end","span-all"],kf=["top","center","bottom","span-top","span-bottom","y-start","y-end","span-y-start","span-y-end","self-y-start","self-y-end","span-self-y-start","span-self-y-end","span-all"],Sf=["block-start","center","block-end","span-block-start","span-block-end","span-all"],yf=["inline-start","center","inline-end","span-inline-start","span-inline-end","span-all"],bf=["self-block-start","center","self-block-end","span-self-block-start","span-self-block-end","span-all"],xf=["self-inline-start","center","self-inline-end","span-self-inline-start","span-self-inline-end","span-all"],to=["start","center","end","span-start","span-end","span-all"],eo=["self-start","center","self-end","span-self-start","span-self-end","span-all"],Cf=["block","top","bottom","y"],wf=["inline","left","right","x"];function An(t){const e=t.split("-");for(const n of e){if(Cf.includes(n))return"block";if(wf.includes(n))return"inline"}return"ambiguous"}function Tf(t,e){return e[0].includes(t[0])&&e[1].includes(t[1])||e[0].includes(t[1])&&e[1].includes(t[0])}const Af=[[mf,kf],[Sf,yf],[bf,xf],[to,to],[eo,eo]];function vf(t){for(const e of Af)if(Tf(t,e))return!0;return!1}const no=t=>{const e=getComputedStyle(t);return{writingMode:e.writingMode,direction:e.direction}},Ef=(t,e)=>R(null,null,function*(){const n=yield Tn(t);switch(e){case"Logical":case"Physical":return no(n);case"LogicalSelf":case"PhysicalSelf":return no(t);default:return null}}),vn=t=>t.reverse().map(e=>3-e),so=(t,e)=>t==="Irrelevant"?e:t,$f=(s,r)=>R(null,[s,r],function*({block:t,inline:e},n){const o=so(t[2],e[2]),a=yield Ef(n,o),l={block:[t[0],t[1]],inline:[e[0],e[1]]};if(a){if(a.direction==="rtl"&&(l.inline=vn(l.inline)),a.writingMode.startsWith("vertical")){const u=l.block;l.block=l.inline,l.inline=u}if(a.writingMode.startsWith("sideways")){const u=l.block;l.block=l.inline,l.inline=u,a.writingMode.endsWith("lr")&&(l.block=vn(l.block))}a.writingMode.endsWith("rl")&&(l.inline=vn(l.inline))}return l}),Lf=({block:t,inline:e})=>{const n=[0,"top","bottom",0],s=[0,"left","right",0];return{block:[n[t[0]],n[t[1]]],inline:[s[e[0]],s[e[1]]]}};function ro([t,e]){return t===0&&e===3?"center":t===0?"end":e===3?"start":"center"}function Pf(t){return t.type==="Declaration"&&t.property==="position-area"}function Of(t){const e=t.value.children.toArray().map(({name:n})=>n);return e.length===1&&(An(e[0])==="ambiguous"?e.push(e[0]):e.push("span-all")),e}function Rf(t){if(!Pf(t))return;const e=Of(t);if(!vf(e))return;const n={};switch(An(e[0])){case"block":n.block=e[0],n.inline=e[1];break;case"inline":n.inline=e[0],n.block=e[1];break;case"ambiguous":An(e[1])=="block"?(n.block=e[1],n.inline=e[0]):(n.inline=e[1],n.block=e[0]);break}const s={block:Zi[n.block],inline:Zi[n.inline]},r=`--pa-declaration-${qi(12)}`;return{values:n,grid:s,selectorUUID:r}}function If(t,e){["justify-self","align-self"].forEach(n=>{e.children.appendData({type:"Declaration",property:n,value:{type:"Raw",value:`var(--pa-value-${n})`},important:!1})}),e.children.appendData({type:"Declaration",property:Ki,value:{type:"Raw",value:t.selectorUUID},important:!1})}function _f(t,e){var s,r;let n;if(((s=t.parentElement)==null?void 0:s.tagName)===Xi)n=t.parentElement;else{n=document.createElement(Xi),n.style.display="grid",n.style.position="absolute";const o=getComputedStyle(t).pointerEvents;n.style.pointerEvents="none",t.style.pointerEvents=o,["top","left","right","bottom"].forEach(a=>{n.style.setProperty(a,`var(--pa-value-${a})`)}),(r=t.parentElement)==null||r.insertBefore(n,t),n.appendChild(t)}return n.setAttribute(`${Yi}${e}`,""),n}function Nf(t,e,n){return R(this,null,function*(){const s=`--pa-target-${qi(12)}`,r=yield $f(e.grid,t),o=Lf(r),a=so(e.grid.block[2],e.grid.inline[2]),l=["LogicalSelf","PhysicalSelf"].includes(a)?r:e.grid,u={block:ro([l.block[0],l.block[1]]),inline:ro([l.inline[0],l.inline[1]])};return{insets:o,alignments:u,targetUUID:s,targetEl:t,anchorEl:n,wrapperEl:_f(t,s),values:e.values,grid:e.grid,selectorUUID:e.selectorUUID}})}function Df(t,e){return`
    [${Qi}="${e}"][${Yi}${t}] {
      --pa-value-top: var(${t}-top);
      --pa-value-left: var(${t}-left);
      --pa-value-right: var(${t}-right);
      --pa-value-bottom: var(${t}-bottom);
      --pa-value-justify-self: var(${t}-justify-self);
      --pa-value-align-self: var(${t}-align-self);
    }
  `.replaceAll(`
`,"")}const Ff=["normal","most-width","most-height","most-block-size","most-inline-size"],Mf=["flip-block","flip-inline","flip-start"];function jf(t){return t.type==="Declaration"}function Bf(t){return t.type==="Declaration"&&t.property==="position-try-fallbacks"}function Wf(t){return t.type==="Declaration"&&t.property==="position-try-order"}function Uf(t){return t.type==="Declaration"&&t.property==="position-try"}function zf(t){return t.type==="Atrule"&&t.name==="position-try"}function Hf(t){return Mf.includes(t)}function Vf(t){return Ff.includes(t)}function Gf(t,e){const n=document.querySelector(t);if(n){let s=Kf(n);return e.forEach(r=>{s=io(s,r)}),s}}function qf(t,e){let n=t.declarations;return e.forEach(s=>{n=io(n,s)}),n}function Kf(t){const e={};return xi.forEach(n=>{const s=ht(t,`--${n}-${Wi}`);s&&(e[n]=s)}),e}const Qf={"flip-block":{top:"bottom",bottom:"top","inset-block-start":"inset-block-end","inset-block-end":"inset-block-start","margin-top":"margin-bottom","margin-bottom":"margin-top"},"flip-inline":{left:"right",right:"left","inset-inline-start":"inset-inline-end","inset-inline-end":"inset-inline-start","margin-left":"margin-right","margin-right":"margin-left"},"flip-start":{left:"top",right:"bottom",top:"left",bottom:"right","inset-block-start":"inset-block-end","inset-block-end":"inset-block-start","inset-inline-start":"inset-inline-end","inset-inline-end":"inset-inline-start","inset-block":"inset-inline","inset-inline":"inset-block"}},Yf={"flip-block":{top:"bottom",bottom:"top",start:"end",end:"start","self-end":"self-start","self-start":"self-end"},"flip-inline":{left:"right",right:"left",start:"end",end:"start","self-end":"self-start","self-start":"self-end"},"flip-start":{top:"left",left:"top",right:"bottom",bottom:"right"}},Xf={"flip-block":{top:"bottom",bottom:"top",start:"end",end:"start"},"flip-inline":{left:"right",right:"left",start:"end",end:"start"},"flip-start":{}};function Jf(t,e){return Qf[e][t]||t}function Zf(t,e){return Yf[e][t]||t}function tp(t,e){if(e==="flip-start")return t;{const n=Xf[e];return t.split("-").map(s=>n[s]||s).join("-")}}function ep(t,e,n){if(t==="margin"){const[s,r,o,a]=e.children.toArray();n==="flip-block"?a?e.children.fromArray([o,r,s,a]):o&&e.children.fromArray([o,r,s]):n==="flip-inline"&&a&&e.children.fromArray([s,a,o,r])}else if(t==="margin-block"){const[s,r]=e.children.toArray();n==="flip-block"&&r&&e.children.fromArray([r,s])}else if(t==="margin-inline"){const[s,r]=e.children.toArray();n==="flip-inline"&&r&&e.children.fromArray([r,s])}}const np=(t,e)=>{var r;return((r=It(`#id{${t}: ${e};}`).children.first)==null?void 0:r.block.children.first).value};function io(t,e){const n={};return Object.entries(t).forEach(([s,r])=>{var u;const o=s,a=np(o,r),l=Jf(o,e);l!==o&&((u=n[o])!=null||(n[o]="revert")),Rt(a,{visit:"Function",enter(i){De(i)&&i.children.forEach(c=>{me(c)&&wi(c.name)&&(c.name=Zf(c.name,e))})}}),o==="position-area"&&a.children.forEach(i=>{me(i)&&Ji(i.name)&&(i.name=tp(i.name,e))}),o.startsWith("margin")&&ep(o,a,e),n[l]=nt(a)}),n}function oo(t){const e=Yh(t),n=[];return e.forEach(s=>{const r={atRules:[],tactics:[],positionAreas:[]};s.forEach(o=>{Hf(o.name)?r.tactics.push(o.name):o.name.startsWith("--")?r.atRules.push(o.name):Ji(o.name)&&r.positionAreas.push(o.name)}),r.positionAreas.length?n.push({positionArea:r.positionAreas[0],type:"position-area"}):r.atRules.length&&r.tactics.length?n.push({tactics:r.tactics,atRule:r.atRules[0],type:"at-rule-with-try-tactic"}):r.atRules.length?n.push({atRule:r.atRules[0],type:"at-rule"}):r.tactics.length&&n.push({tactics:r.tactics,type:"try-tactic"})}),n}function sp(t){return Bf(t)&&t.value.children.first?oo(t.value.children):[]}function rp(t){if(Uf(t)&&t.value.children.first){const e=Ce(t);let n;const s=e.value.children.first.name;s&&Vf(s)&&(n=s,e.value.children.shift());const r=oo(e.value.children);return{order:n,options:r}}return{}}function ip(t){return Wf(t)&&t.value.children.first?{order:t.value.children.first.name}:{}}function op(t){const{order:e,options:n}=rp(t);if(e||n)return{order:e,options:n};const{order:s}=ip(t),r=sp(t);return s||r?{order:s,options:r}:{}}function ap(t){return pe(t.property)||Ju(t.property)||yi(t.property)||Zu(t.property)||["position-anchor","position-area"].includes(t.property)}function lp(t){var e,n;if(zf(t)&&((e=t.prelude)!=null&&e.value)&&((n=t.block)!=null&&n.children)){const s=t.prelude.value,r=t.block.children.filter(a=>jf(a)&&ap(a)),o={uuid:`${s}-try-${kt(12)}`,declarations:Object.fromEntries(r.map(a=>[a.property,nt(a.value)]))};return{name:s,tryBlock:o}}return{}}function cp(t){const e={},n={},s={};for(const r of t){const o=It(r.css);Rt(o,{visit:"Atrule",enter(a){const{name:l,tryBlock:u}=lp(a);l&&u&&(e[l]=u)}})}for(const r of t){let o=!1;const a=new Set,l=It(r.css);Rt(l,{visit:"Declaration",enter(u){var g;const i=(g=this.rule)==null?void 0:g.prelude,c=Cn(i);if(!c.length)return;const{order:h,options:f}=op(u),p={};h&&(p.order=h),c.forEach(({selector:m})=>{var k,S;f==null||f.forEach(x=>{var W,ct,w;let A;if(x.type==="at-rule")A=x.atRule;else if(x.type==="try-tactic"){A=`${m}-${x.tactics.join("-")}`;const C=Gf(m,x.tactics);C&&(e[A]={uuid:`${m}-${x.tactics.join("-")}-try-${kt(12)}`,declarations:C})}else if(x.type==="at-rule-with-try-tactic"){A=`${m}-${x.atRule}-${x.tactics.join("-")}`;const C=e[x.atRule],O=qf(C,x.tactics);O&&(e[A]={uuid:`${m}-${x.atRule}-${x.tactics.join("-")}-try-${kt(12)}`,declarations:O})}if(A&&e[A]){const C=`[data-anchor-polyfill="${e[A].uuid}"]`;(W=n[C])!=null||(n[C]=[]),n[C].push(m),a.has(A)||((ct=p.fallbacks)!=null||(p.fallbacks=[]),p.fallbacks.push(e[A]),a.add(A),(w=this.stylesheet)==null||w.children.prependData({type:"Rule",prelude:{type:"Raw",value:C},block:{type:"Block",children:new K().fromArray(Object.entries(e[A].declarations).map(([O,P])=>({type:"Declaration",important:!0,property:O,value:{type:"Raw",value:P}})))}}),o=!0)}}),Object.keys(p).length>0&&(s[m]?(p.order&&(s[m].order=p.order),p.fallbacks&&((S=(k=s[m]).fallbacks)!=null||(k.fallbacks=[]),s[m].fallbacks.push(...p.fallbacks))):s[m]=p)})}}),o&&(r.css=nt(l),r.changed=!0)}return{fallbackTargets:n,validPositions:s}}function up(t,e){return!t||t===e?!1:ao(t)?t.document.contains(e):t.contains(e)}function ao(t){return!!(t&&t===t.window)}function hp(t){return te(t,"position","fixed")}function En(t){return!!(t&&(hp(t)||te(t,"position","absolute")))}function lo(t,e){return t.compareDocumentPosition(e)&Node.DOCUMENT_POSITION_FOLLOWING}function fp(t){return R(this,null,function*(){return yield q.getOffsetParent(t)})}function $n(t){return R(this,null,function*(){if(!["absolute","fixed"].includes(ht(t,"position")))return yield fp(t);let e=t.parentElement;for(;e;){if(!te(e,"position","static")&&te(e,"display","block"))return e;e=e.parentElement}return window})}function pp(t,e,n,s){return R(this,null,function*(){const r=yield $n(t),o=yield $n(n);if(!(up(o,t)||ao(o))||r===o&&!(!En(t)||lo(t,n)))return!1;if(r!==o){let a;const l=[];for(a=r;a&&a!==o&&a!==window;)l.push(a),a=yield $n(a);const u=l[l.length-1];if(u instanceof HTMLElement&&!(!En(u)||lo(u,n)))return!1}{let a=t.parentElement;for(;a;){if(te(a,"content-visibility","hidden"))return!1;a=a.parentElement}}return!(e&&s&&co(t,e,s)!==co(n,e,s))})}function co(t,e,n){for(;!(t.matches(n)&&lf(t,e));){if(!t.parentElement)return null;t=t.parentElement}return t}function dp(t,e,n,s,r){return R(this,null,function*(){if(!(t instanceof HTMLElement&&n.length&&En(t)))return null;const o=n.flatMap(l=>of(l,r)).filter(l=>af(l,e)),a=s.map(l=>l.selector).join(",")||null;for(let l=o.length-1;l>=0;l--){const u=o[l],i="fakePseudoElement"in u;if(yield pp(i?u.fakePseudoElement:u,e,t,a))return i&&u.removeFakePseudoElement(),u}return null})}function gp(t){return t.type==="Declaration"&&t.property==="anchor-name"}function mp(t){return t.type==="Declaration"&&t.property==="anchor-scope"}function Ln(t){return!!(t&&t.type==="Function"&&t.name==="anchor-size")}function Fe(t){return!!(t&&t.type==="Function"&&t.name==="var")}function me(t){return!!(t.type==="Identifier"&&t.name)}function kp(t){return!!(t.type==="Percentage"&&t.value)}function uo(t,e){let n,s,r,o="",a=!1,l;const u=[];t.children.toArray().forEach(f=>{if(a){o=`${o}${nt(f)}`;return}if(f.type==="Operator"&&f.value===","){a=!0;return}u.push(f)});let[i,c]=u;if(c||(c=i,i=void 0),i&&(me(i)&&i.name.startsWith("--")?n=i.name:Fe(i)&&i.children.first&&(l=i.children.first.name)),c)if(De(t)){if(me(c)&&wi(c.name))s=c.name;else if(kp(c)){const f=Number(c.value);s=Number.isNaN(f)?void 0:f}}else Ln(t)&&me(c)&&sh(c.name)&&(r=c.name);const h=`--anchor-${kt(12)}`;return Object.assign(t,{type:"Raw",value:`var(${h})`,children:null}),Reflect.deleteProperty(t,"name"),{anchorName:n,anchorSide:s,anchorSize:r,fallbackValue:o,customPropName:l,uuid:h}}function ho(t){return t.value.children.map(({name:e})=>e)}let ee={},_t={},Bt={},ke={},Wt={};function Sp(){ee={},_t={},Bt={},ke={},Wt={}}function yp(t,e){var n;if((De(t)||Ln(t))&&e){if(e.property.startsWith("--")){const s=nt(e.value),r=uo(t);return ke[r.uuid]=s,Bt[e.property]=[...(n=Bt[e.property])!=null?n:[],r],{changed:!0}}if(De(t)&&pe(e.property)||Ln(t)&&Ci(e.property)){const s=uo(t);return{prop:e.property,data:s,changed:!0}}}return{}}function fo(t,e,n){return R(this,null,function*(){let s=e==null?void 0:e.anchorName;const r=e==null?void 0:e.customPropName;if(t&&!s){const u=ht(t,"position-anchor");u?s=u:r&&(s=ht(t,r))}const o=s?ee[s]||[]:[],a=s?_t[zi.All]||[]:[],l=s?_t[s]||[]:[];return yield dp(t,s||null,o,[...a,...l],{roots:n.roots})})}function bp(t,e){return R(this,null,function*(){var h,f,p,g,m,k,S,x,A,W,ct;const n={},s={};Sp();const{fallbackTargets:r,validPositions:o}=cp(t);for(const w of t){let C=!1;const O=It(w.css);Rt(O,function(P){var st,vt,Ut,Et,Tt,$t;const F=(st=this.rule)==null?void 0:st.prelude,$=Cn(F);if(gp(P)&&$.length)for(const z of ho(P))(vt=ee[z])!=null||(ee[z]=[]),ee[z].push(...$);if(mp(P)&&$.length)for(const z of ho(P))(Ut=_t[z])!=null||(_t[z]=[]),_t[z].push(...$);const{prop:v,data:U,changed:M}=yp(P,this.declaration);if(v&&U&&$.length)for(const{selector:z}of $)n[z]=Y(H({},n[z]),{[v]:[...(Tt=(Et=n[z])==null?void 0:Et[v])!=null?Tt:[],U]});let Q;if(this.block&&(Q=Rf(P),Q)){If(Q,this.block);for(const{selector:z}of $)s[z]=[...($t=s[z])!=null?$t:[],Q]}(M||Q)&&(C=!0)}),C&&(w.css=nt(O),w.changed=!0)}const a=new Set(Object.keys(Bt)),l={},u=w=>{var P,F,$,v,U;const C=[],O=new Set((F=(P=l[w])==null?void 0:P.names)!=null?F:[]);for(;O.size>0;)for(const M of O)C.push(...($=Bt[M])!=null?$:[]),O.delete(M),(U=(v=l[M])==null?void 0:v.names)!=null&&U.length&&l[M].names.forEach(Q=>O.add(Q));return C};for(;a.size>0;){const w=[];for(const C of t){let O=!1;const P=It(C.css);Rt(P,{visit:"Function",enter(F){var M,Q;const $=(M=this.rule)==null?void 0:M.prelude,v=this.declaration,U=v==null?void 0:v.property;if(($==null?void 0:$.children.isEmpty)===!1&&Fe(F)&&v&&U&&F.children.first&&a.has(F.children.first.name)&&U.startsWith("--")){const st=F.children.first,vt=(Q=Bt[st.name])!=null?Q:[],Ut=u(st.name);if(!(vt.length||Ut.length))return;const Et=`${st.name}-anchor-${kt(12)}`,Tt=nt(v.value);ke[Et]=Tt,l[U]||(l[U]={names:[],uuids:[]});const $t=l[U];$t.names.includes(st.name)||$t.names.push(st.name),$t.uuids.push(Et),w.push(U),st.name=Et,O=!0}}}),O&&(C.css=nt(P),C.changed=!0)}a.clear(),w.forEach(C=>a.add(C))}for(const w of t){let C=!1;const O=It(w.css);Rt(O,{visit:"Function",enter(P){var U,M,Q,st,vt,Ut,Et;const F=(U=this.rule)==null?void 0:U.prelude,$=this.declaration,v=$==null?void 0:$.property;if((F==null?void 0:F.children.isEmpty)===!1&&Fe(P)&&$&&v&&P.children.first&&(pe(v)||yi(v))){const Tt=P.children.first,$t=(M=Bt[Tt.name])!=null?M:[],z=u(Tt.name);if(!($t.length||z.length))return;const je=`${v}-${kt(12)}`;if(z.length){const ne=new Set([Tt.name]);for(;ne.size>0;)for(const se of ne){const tt=l[se];if((Q=tt==null?void 0:tt.names)!=null&&Q.length&&((st=tt==null?void 0:tt.uuids)!=null&&st.length))for(const re of tt.names)for(const ie of tt.uuids)Wt[ie]=Y(H({},Wt[ie]),{[je]:`${re}-${je}`});ne.delete(se),(vt=tt==null?void 0:tt.names)!=null&&vt.length&&tt.names.forEach(re=>ne.add(re))}}const _p=Cn(F);for(const ne of[...$t,...z]){const se=H({},ne),tt=`--anchor-${kt(12)}-${v}`,re=se.uuid;se.uuid=tt;for(const{selector:ie}of _p)n[ie]=Y(H({},n[ie]),{[v]:[...(Et=(Ut=n[ie])==null?void 0:Ut[v])!=null?Et:[],se]});Wt[re]=Y(H({},Wt[re]),{[je]:tt})}Tt.name=`${Tt.name}-${je}`,C=!0}}}),C&&(w.css=nt(O),w.changed=!0)}if(Object.keys(Wt).length>0)for(const w of t){let C=!1;const O=It(w.css);Rt(O,{visit:"Function",enter(P){var F,$,v,U;if(Fe(P)&&(($=(F=P.children.first)==null?void 0:F.name)!=null&&$.startsWith("--"))&&((U=(v=this.declaration)==null?void 0:v.property)!=null&&U.startsWith("--"))&&this.block){const M=P.children.first,Q=Wt[M.name];if(Q)for(const[st,vt]of Object.entries(Q))this.block.children.appendData({type:"Declaration",important:!1,property:`${this.declaration.property}-${st}`,value:{type:"Raw",value:nt(this.declaration.value).replace(`var(${M.name})`,`var(${vt})`)}}),C=!0;ke[M.name]&&(this.declaration.value={type:"Raw",value:ke[M.name]},C=!0)}}}),C&&(w.css=nt(O),w.changed=!0)}const i=new Map;for(const[w,C]of Object.entries(n)){let O;w.startsWith("[data-anchor-polyfill=")&&((h=r[w])!=null&&h.length)?O=ge(e.roots,r[w].join(",")):O=ge(e.roots,w);for(const[P,F]of Object.entries(C))for(const $ of F)for(const v of O){const U=yield fo(v,$,{roots:e.roots}),M=`--anchor-${kt(12)}`;i.set(v,Y(H({},(f=i.get(v))!=null?f:{}),{[$.uuid]:M})),v.setAttribute("style",`${$.uuid}: var(${M}); ${(p=v.getAttribute("style"))!=null?p:""}`),o[w]=Y(H({},o[w]),{declarations:Y(H({},(g=o[w])==null?void 0:g.declarations),{[P]:[...(S=(k=(m=o[w])==null?void 0:m.declarations)==null?void 0:k[P])!=null?S:[],Y(H({},$),{anchorEl:U,targetEl:v,uuid:M})]})})}}const c={el:document.createElement("link"),changed:!1,created:!0,css:""};t.push(c);for(const[w,C]of Object.entries(s)){const O=ge(e.roots,w);for(const P of O){const F=yield fo(P,null,{roots:e.roots});for(const $ of C){const v=yield Nf(P,$,F);c.css+=Df(v.targetUUID,$.selectorUUID),c.changed=!0,o[w]=Y(H({},o[w]),{declarations:Y(H({},(x=o[w])==null?void 0:x.declarations),{"position-area":[...(ct=(W=(A=o[w])==null?void 0:A.declarations)==null?void 0:W["position-area"])!=null?ct:[],v]})})}}}return{rules:o,inlineStyles:i,anchorScopes:_t}})}const xp=["as","blocking","crossorigin","disabled","fetchpriority","href","hreflang","integrity","referrerpolicy","rel","type"];function po(t,e,n=!1){const s=[];for(const{el:r,css:o,changed:a,created:l=!1}of t){const u={el:r,css:o,changed:!1};if(a){if(r.tagName.toLowerCase()==="style")r.innerHTML=o;else if(r instanceof HTMLLinkElement){const i=document.createElement("style");i.textContent=o;for(const c of r.getAttributeNames())if(!c.startsWith("on")&&!xp.includes(c)){const h=r.getAttribute(c);h!==null&&i.setAttribute(c,h)}r.hasAttribute("href")&&i.setAttribute("data-original-href",r.getAttribute("href")),l?(i.setAttribute("data-generated-by-polyfill","true"),document.head.insertAdjacentElement("beforeend",i)):(r.insertAdjacentElement("beforebegin",i),r.remove()),u.el=i}else if(r.hasAttribute("data-has-inline-styles")){const i=r.getAttribute("data-has-inline-styles");if(i){const c=`[data-has-inline-styles="${i}"]{`;let f=o.slice(c.length,0-"}".length);const p=e==null?void 0:e.get(r);if(p)for(const[g,m]of Object.entries(p))f=`${g}: var(${m}); ${f}`;r.setAttribute("style",f)}}}n&&r.hasAttribute("data-has-inline-styles")&&r.removeAttribute("data-has-inline-styles"),s.push(u)}return s}const Cp=Y(H({},q),{_c:new Map}),wp=(t,e)=>{let n;switch(t){case"start":case"self-start":n=0;break;case"end":case"self-end":n=100;break;default:typeof t=="number"&&!Number.isNaN(t)&&(n=t)}if(n!==void 0)return e?100-n:n},Tp=(t,e)=>{let n;switch(t){case"block":case"self-block":n=e?"width":"height";break;case"inline":case"self-inline":n=e?"height":"width";break}return n},go=t=>{switch(t){case"top":case"bottom":case"inset-block-start":case"inset-block-end":return"y";case"left":case"right":case"inset-inline-start":case"inset-inline-end":return"x"}return null},Ap=t=>{switch(t){case"x":return"width";case"y":return"height"}return null},mo=t=>ht(t,"display")==="inline",ko=(t,e)=>(e==="x"?["border-left-width","border-right-width"]:["border-top-width","border-bottom-width"]).reduce((s,r)=>s+parseInt(ht(t,r),10),0)||0,Me=(t,e)=>parseInt(ht(t,`margin-${e}`),10)||0,vp=t=>({top:Me(t,"top"),right:Me(t,"right"),bottom:Me(t,"bottom"),left:Me(t,"left")}),Pn=a=>R(null,[a],function*({targetEl:t,targetProperty:e,anchorRect:n,anchorSide:s,anchorSize:r,fallback:o=null}){var l;if(!((r||s!==void 0)&&t&&n))return o;if(r){if(!Ci(e))return o;let u;switch(r){case"width":case"height":u=r;break;default:{let i=!1;const c=ht(t,"writing-mode");i=c.startsWith("vertical-")||c.startsWith("sideways-"),u=Tp(r,i)}}return u?`${n[u]}px`:o}if(s!==void 0){let u,i;const c=go(e);if(!(pe(e)&&c&&(!pe(s)||c===go(s))))return o;const h=["top","left","inset-block-start","inset-inline-start"],f=["bottom","right","inset-block-end","inset-inline-end"];switch(s){case"left":case"top":u=0;break;case"right":case"bottom":u=100;break;case"center":u=50;break;case"inside":u=h.includes(e)?0:100;break;case"outside":u=h.includes(e)?100:0;break;default:if(t){const m=(yield(l=q.isRTL)==null?void 0:l.call(q,t))||!1;u=wp(s,m)}}const p=typeof u=="number"&&!Number.isNaN(u),g=Ap(c);if(p&&g){f.includes(e)&&(i=yield Tn(t));let m=n[c]+n[g]*(u/100);switch(e){case"bottom":case"inset-block-end":{if(!i)break;let k=i.clientHeight;if(k===0&&mo(i)){const S=ko(i,c);k=i.offsetHeight-S}m=k-m;break}case"right":case"inset-inline-end":{if(!i)break;let k=i.clientWidth;if(k===0&&mo(i)){const S=ko(i,c);k=i.offsetWidth-S}m=k-m;break}}return`${m}px`}}return o}),Ep=t=>"wrapperEl"in t,$p=t=>"uuid"in t;function Lp(t,e=!1){return R(this,null,function*(){const n=document.documentElement;for(const[s,r]of Object.entries(t))for(const o of r){const a=o.anchorEl,l=o.targetEl;if(a&&l)if(Ep(o)){const u=o.wrapperEl,i=(c,h,f)=>R(null,null,function*(){return c===0?"0px":yield Pn({targetEl:u,targetProperty:h,anchorRect:f,anchorSide:c})});qe(a,u,()=>R(null,null,function*(){const c=ht(l,Ki);u.setAttribute(Qi,c);const h=yield q.getElementRects({reference:a,floating:u,strategy:"absolute"}),f=o.insets,p=yield i(f.block[0],"top",h.reference),g=yield i(f.block[1],"bottom",h.reference),m=yield i(f.inline[0],"left",h.reference),k=yield i(f.inline[1],"right",h.reference);n.style.setProperty(`${o.targetUUID}-top`,p||null),n.style.setProperty(`${o.targetUUID}-left`,m||null),n.style.setProperty(`${o.targetUUID}-right`,k||null),n.style.setProperty(`${o.targetUUID}-bottom`,g||null),n.style.setProperty(`${o.targetUUID}-justify-self`,o.alignments.inline),n.style.setProperty(`${o.targetUUID}-align-self`,o.alignments.block)}),{animationFrame:e})}else qe(a,l,()=>R(null,null,function*(){const u=yield q.getElementRects({reference:a,floating:l,strategy:"absolute"}),i=yield Pn({targetEl:l,targetProperty:s,anchorRect:u.reference,anchorSide:o.anchorSide,anchorSize:o.anchorSize,fallback:o.fallbackValue});n.style.setProperty(o.uuid,i)}),{animationFrame:e});else if($p(o)){const u=yield Pn({targetProperty:s,anchorSide:o.anchorSide,anchorSize:o.anchorSize,fallback:o.fallbackValue});n.style.setProperty(o.uuid,u)}}})}function So(t,e){return R(this,null,function*(){const n=yield q.getElementRects({reference:t,floating:t,strategy:"absolute"});return yield Vo({x:t.offsetLeft,y:t.offsetTop,platform:Cp,rects:n,elements:{floating:t,reference:e},strategy:"absolute"},{padding:vp(t)})})}function Pp(t,e,n=!1){return R(this,null,function*(){if(!e.length)return;const s=document.querySelectorAll(t);for(const r of s){let o=!1;const a=yield Tn(r);qe({},r,()=>R(null,null,function*(){if(o)return;o=!0,r.removeAttribute("data-anchor-polyfill");const l=yield So(r,a);if(Object.values(l).every(u=>u<=0)){r.removeAttribute("data-anchor-polyfill-last-successful"),o=!1;return}for(const[u,{uuid:i}]of e.entries()){r.setAttribute("data-anchor-polyfill",i);const c=yield So(r,a);if(Object.values(c).every(h=>h<=0)){r.setAttribute("data-anchor-polyfill-last-successful",i),o=!1;break}if(u===e.length-1){const h=r.getAttribute("data-anchor-polyfill-last-successful");h?r.setAttribute("data-anchor-polyfill",h):r.removeAttribute("data-anchor-polyfill"),o=!1;break}}}),{animationFrame:n,layoutShift:!1})}})}function Op(t,e=!1){return R(this,null,function*(){var n,s;for(const r of Object.values(t))yield Lp((n=r.declarations)!=null?n:{},e);for(const[r,o]of Object.entries(t))yield Pp(r,(s=o.fallbacks)!=null?s:[],e)})}function Rp(t={}){const e=typeof t=="boolean"?{useAnimationFrame:t}:t,n=e.useAnimationFrame===void 0?!!window.UPDATE_ANCHOR_ON_ANIMATION_FRAME:e.useAnimationFrame;return Array.isArray(e.elements)||(e.elements=void 0),(!Array.isArray(e.roots)||e.roots.length===0)&&(e.roots=[document]),Object.assign(e,{useAnimationFrame:n})}function Ip(t){return R(this,null,function*(){const e=Rp(t!=null?t:window.ANCHOR_POSITIONING_POLYFILL_OPTIONS);let n=yield pf(e),s={},r;Jh();try{ef(n)&&(n=po(n));const a=yield bp(n,{roots:e.roots});s=a.rules,r=a.inlineStyles}catch(o){throw Xh(),o}return Object.values(s).length&&(po(n,r,!0),yield Op(s,e.useAnimationFrame)),s})}return Ip}));
//# sourceMappingURL=css-anchor-positioning-fn.umd.cjs.map