@oddbird/css-anchor-positioning
Version:
Polyfill for the proposed CSS anchor positioning spec
1,776 lines • 172 kB
JavaScript
var So = Object.defineProperty, yo = Object.defineProperties;
var bo = Object.getOwnPropertyDescriptors;
var En = Object.getOwnPropertySymbols;
var xo = Object.prototype.hasOwnProperty, Co = Object.prototype.propertyIsEnumerable;
var $n = (t, e, n) => e in t ? So(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, U = (t, e) => {
for (var n in e || (e = {}))
xo.call(e, n) && $n(t, n, e[n]);
if (En)
for (var n of En(e))
Co.call(e, n) && $n(t, n, e[n]);
return t;
}, G = (t, e) => yo(t, bo(e));
var R = (t, e, n) => new Promise((s, r) => {
var o = (u) => {
try {
l(n.next(u));
} catch (i) {
r(i);
}
}, a = (u) => {
try {
l(n.throw(u));
} catch (i) {
r(i);
}
}, l = (u) => u.done ? s(u.value) : Promise.resolve(u.value).then(o, a);
l((n = n.apply(t, e)).next());
});
const nn = Math.min, Gt = Math.max, Te = Math.round, pe = Math.floor, St = (t) => ({
x: t,
y: t
});
function wo(t, e) {
return typeof t == "function" ? t(e) : t;
}
function To(t) {
return U({
top: 0,
right: 0,
bottom: 0,
left: 0
}, t);
}
function Ao(t) {
return typeof t != "number" ? To(t) : {
top: t,
right: t,
bottom: t,
left: t
};
}
function Ae(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 vo(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
} = wo(e, t), g = Ao(p), k = l[f ? h === "floating" ? "reference" : "floating" : h], S = Ae(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), M = (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
}, et = Ae(o.convertOffsetParentRelativeRectToViewportRelativeRect ? yield o.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: l,
rect: x,
offsetParent: A,
strategy: u
}) : x);
return {
top: (S.top - et.top + g.top) / M.y,
bottom: (et.bottom - S.bottom + g.bottom) / M.y,
left: (S.left - et.left + g.left) / M.x,
right: (et.right - S.right + g.right) / M.x
};
});
}
function Re() {
return typeof window != "undefined";
}
function te(t) {
return _s(t) ? (t.nodeName || "").toLowerCase() : "#document";
}
function it(t) {
var e;
return (t == null || (e = t.ownerDocument) == null ? void 0 : e.defaultView) || window;
}
function bt(t) {
var e;
return (e = (_s(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function _s(t) {
return Re() ? t instanceof Node || t instanceof it(t).Node : !1;
}
function ct(t) {
return Re() ? t instanceof Element || t instanceof it(t).Element : !1;
}
function yt(t) {
return Re() ? t instanceof HTMLElement || t instanceof it(t).HTMLElement : !1;
}
function Ln(t) {
return !Re() || typeof ShadowRoot == "undefined" ? !1 : t instanceof ShadowRoot || t instanceof it(t).ShadowRoot;
}
const Eo = /* @__PURE__ */ new Set(["inline", "contents"]);
function he(t) {
const {
overflow: e,
overflowX: n,
overflowY: s,
display: r
} = ut(t);
return /auto|scroll|overlay|hidden|clip/.test(e + s + n) && !Eo.has(r);
}
const $o = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Lo(t) {
return $o.has(te(t));
}
const Po = [":popover-open", ":modal"];
function Ie(t) {
return Po.some((e) => {
try {
return t.matches(e);
} catch (n) {
return !1;
}
});
}
const Oo = ["transform", "translate", "scale", "rotate", "perspective"], Ro = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Io = ["paint", "layout", "strict", "content"];
function kn(t) {
const e = Sn(), n = ct(t) ? ut(t) : t;
return Oo.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) || Ro.some((s) => (n.willChange || "").includes(s)) || Io.some((s) => (n.contain || "").includes(s));
}
function _o(t) {
let e = Pt(t);
for (; yt(e) && !Qt(e); ) {
if (kn(e))
return e;
if (Ie(e))
return null;
e = Pt(e);
}
return null;
}
function Sn() {
return typeof CSS == "undefined" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const No = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function Qt(t) {
return No.has(te(t));
}
function ut(t) {
return it(t).getComputedStyle(t);
}
function _e(t) {
return ct(t) ? {
scrollLeft: t.scrollLeft,
scrollTop: t.scrollTop
} : {
scrollLeft: t.scrollX,
scrollTop: t.scrollY
};
}
function Pt(t) {
if (te(t) === "html")
return t;
const e = (
// Step into the shadow DOM of the parent of a slotted node.
t.assignedSlot || // DOM Element detected.
t.parentNode || // ShadowRoot detected.
Ln(t) && t.host || // Fallback.
bt(t)
);
return Ln(e) ? e.host : e;
}
function Ns(t) {
const e = Pt(t);
return Qt(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : yt(e) && he(e) ? e : Ns(e);
}
function le(t, e, n) {
var s;
e === void 0 && (e = []), n === void 0 && (n = !0);
const r = Ns(t), o = r === ((s = t.ownerDocument) == null ? void 0 : s.body), a = it(r);
if (o) {
const l = sn(a);
return e.concat(a, a.visualViewport || [], he(r) ? r : [], l && n ? le(l) : []);
}
return e.concat(r, le(r, [], n));
}
function sn(t) {
return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
function Ds(t) {
const e = ut(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 = Te(n) !== o || Te(s) !== a;
return l && (n = o, s = a), {
width: n,
height: s,
$: l
};
}
function yn(t) {
return ct(t) ? t : t.contextElement;
}
function qt(t) {
const e = yn(t);
if (!yt(e))
return St(1);
const n = e.getBoundingClientRect(), {
width: s,
height: r,
$: o
} = Ds(e);
let a = (o ? Te(n.width) : n.width) / s, l = (o ? Te(n.height) : n.height) / r;
return (!a || !Number.isFinite(a)) && (a = 1), (!l || !Number.isFinite(l)) && (l = 1), {
x: a,
y: l
};
}
const Do = /* @__PURE__ */ St(0);
function Fs(t) {
const e = it(t);
return !Sn() || !e.visualViewport ? Do : {
x: e.visualViewport.offsetLeft,
y: e.visualViewport.offsetTop
};
}
function Fo(t, e, n) {
return e === void 0 && (e = !1), !n || e && n !== it(t) ? !1 : e;
}
function Dt(t, e, n, s) {
e === void 0 && (e = !1), n === void 0 && (n = !1);
const r = t.getBoundingClientRect(), o = yn(t);
let a = St(1);
e && (s ? ct(s) && (a = qt(s)) : a = qt(t));
const l = Fo(o, n, s) ? Fs(o) : St(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 && ct(s) ? it(s) : s;
let g = f, m = sn(g);
for (; m && s && p !== g; ) {
const k = qt(m), S = m.getBoundingClientRect(), x = ut(m), A = S.left + (m.clientLeft + parseFloat(x.paddingLeft)) * k.x, M = S.top + (m.clientTop + parseFloat(x.paddingTop)) * k.y;
u *= k.x, i *= k.y, c *= k.x, h *= k.y, u += A, i += M, g = it(m), m = sn(g);
}
}
return Ae({
width: c,
height: h,
x: u,
y: i
});
}
function Ne(t, e) {
const n = _e(t).scrollLeft;
return e ? e.left + n : Dt(bt(t)).left + n;
}
function Ms(t, e) {
const n = t.getBoundingClientRect(), s = n.left + e.scrollLeft - Ne(t, n), r = n.top + e.scrollTop;
return {
x: s,
y: r
};
}
function Mo(t) {
let {
elements: e,
rect: n,
offsetParent: s,
strategy: r
} = t;
const o = r === "fixed", a = bt(s), l = e ? Ie(e.floating) : !1;
if (s === a || l && o)
return n;
let u = {
scrollLeft: 0,
scrollTop: 0
}, i = St(1);
const c = St(0), h = yt(s);
if ((h || !h && !o) && ((te(s) !== "body" || he(a)) && (u = _e(s)), yt(s))) {
const p = Dt(s);
i = qt(s), c.x = p.x + s.clientLeft, c.y = p.y + s.clientTop;
}
const f = a && !h && !o ? Ms(a, u) : St(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 jo(t) {
return Array.from(t.getClientRects());
}
function Bo(t) {
const e = bt(t), n = _e(t), s = t.ownerDocument.body, r = Gt(e.scrollWidth, e.clientWidth, s.scrollWidth, s.clientWidth), o = Gt(e.scrollHeight, e.clientHeight, s.scrollHeight, s.clientHeight);
let a = -n.scrollLeft + Ne(t);
const l = -n.scrollTop;
return ut(s).direction === "rtl" && (a += Gt(e.clientWidth, s.clientWidth) - r), {
width: r,
height: o,
x: a,
y: l
};
}
const Pn = 25;
function Uo(t, e) {
const n = it(t), s = bt(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 = Sn();
(!c || c && e === "fixed") && (l = r.offsetLeft, u = r.offsetTop);
}
const i = Ne(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 <= Pn && (o -= g);
} else i <= Pn && (o += i);
return {
width: o,
height: a,
x: l,
y: u
};
}
const Wo = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function zo(t, e) {
const n = Dt(t, !0, e === "fixed"), s = n.top + t.clientTop, r = n.left + t.clientLeft, o = yt(t) ? qt(t) : St(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 On(t, e, n) {
let s;
if (e === "viewport")
s = Uo(t, n);
else if (e === "document")
s = Bo(bt(t));
else if (ct(e))
s = zo(e, n);
else {
const r = Fs(t);
s = {
x: e.x - r.x,
y: e.y - r.y,
width: e.width,
height: e.height
};
}
return Ae(s);
}
function js(t, e) {
const n = Pt(t);
return n === e || !ct(n) || Qt(n) ? !1 : ut(n).position === "fixed" || js(n, e);
}
function Ho(t, e) {
const n = e.get(t);
if (n)
return n;
let s = le(t, [], !1).filter((l) => ct(l) && te(l) !== "body"), r = null;
const o = ut(t).position === "fixed";
let a = o ? Pt(t) : t;
for (; ct(a) && !Qt(a); ) {
const l = ut(a), u = kn(a);
!u && l.position === "fixed" && (r = null), (o ? !u && !r : !u && l.position === "static" && !!r && Wo.has(r.position) || he(a) && !u && js(t, a)) ? s = s.filter((c) => c !== a) : r = l, a = Pt(a);
}
return e.set(t, s), s;
}
function Vo(t) {
let {
element: e,
boundary: n,
rootBoundary: s,
strategy: r
} = t;
const a = [...n === "clippingAncestors" ? Ie(e) ? [] : Ho(e, this._c) : [].concat(n), s], l = a[0], u = a.reduce((i, c) => {
const h = On(e, c, r);
return i.top = Gt(h.top, i.top), i.right = nn(h.right, i.right), i.bottom = nn(h.bottom, i.bottom), i.left = Gt(h.left, i.left), i;
}, On(e, l, r));
return {
width: u.right - u.left,
height: u.bottom - u.top,
x: u.left,
y: u.top
};
}
function Go(t) {
const {
width: e,
height: n
} = Ds(t);
return {
width: e,
height: n
};
}
function qo(t, e, n) {
const s = yt(e), r = bt(e), o = n === "fixed", a = Dt(t, !0, o, e);
let l = {
scrollLeft: 0,
scrollTop: 0
};
const u = St(0);
function i() {
u.x = Ne(r);
}
if (s || !s && !o)
if ((te(e) !== "body" || he(r)) && (l = _e(e)), s) {
const p = Dt(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 ? Ms(r, l) : St(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 Fe(t) {
return ut(t).position === "static";
}
function Rn(t, e) {
if (!yt(t) || ut(t).position === "fixed")
return null;
if (e)
return e(t);
let n = t.offsetParent;
return bt(t) === n && (n = n.ownerDocument.body), n;
}
function Bs(t, e) {
const n = it(t);
if (Ie(t))
return n;
if (!yt(t)) {
let r = Pt(t);
for (; r && !Qt(r); ) {
if (ct(r) && !Fe(r))
return r;
r = Pt(r);
}
return n;
}
let s = Rn(t, e);
for (; s && Lo(s) && Fe(s); )
s = Rn(s, e);
return s && Qt(s) && Fe(s) && !kn(s) ? n : s || _o(t) || n;
}
const Ko = function(t) {
return R(this, null, function* () {
const e = this.getOffsetParent || Bs, n = this.getDimensions, s = yield n(t.floating);
return {
reference: qo(t.reference, yield e(t.floating), t.strategy),
floating: {
x: 0,
y: 0,
width: s.width,
height: s.height
}
};
});
};
function Qo(t) {
return ut(t).direction === "rtl";
}
const H = {
convertOffsetParentRelativeRectToViewportRelativeRect: Mo,
getDocumentElement: bt,
getClippingRect: Vo,
getOffsetParent: Bs,
getElementRects: Ko,
getClientRects: jo,
getDimensions: Go,
getScale: qt,
isElement: ct,
isRTL: Qo
};
function Us(t, e) {
return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function Yo(t, e) {
let n = null, s;
const r = bt(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 = pe(h), m = pe(r.clientWidth - (c + f)), k = pe(r.clientHeight - (h + p)), S = pe(c), A = {
rootMargin: -g + "px " + -m + "px " + -k + "px " + -S + "px",
threshold: Gt(0, nn(1, u)) || 1
};
let M = !0;
function et(w) {
const C = w[0].intersectionRatio;
if (C !== u) {
if (!M)
return a();
C ? a(!1, C) : s = setTimeout(() => {
a(!1, 1e-7);
}, 1e3);
}
C === 1 && !Us(i, t.getBoundingClientRect()) && a(), M = !1;
}
try {
n = new IntersectionObserver(et, G(U({}, A), {
// Handle <iframe>s
root: r.ownerDocument
}));
} catch (w) {
n = new IntersectionObserver(et, A);
}
n.observe(t);
}
return a(!0), o;
}
function rn(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 = yn(t), c = r || o ? [...i ? le(i) : [], ...le(e)] : [];
c.forEach((S) => {
r && S.addEventListener("scroll", n, {
passive: !0
}), o && S.addEventListener("resize", n);
});
const h = i && l ? Yo(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 ? Dt(t) : null;
u && k();
function k() {
const S = Dt(t);
m && !Us(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 Xo = vo;
let zt = null;
class q {
static createItem(e) {
return {
prev: null,
next: null,
data: e
};
}
constructor() {
this.head = null, this.tail = null, this.cursor = null;
}
createItem(e) {
return q.createItem(e);
}
// cursor helpers
allocateCursor(e, n) {
let s;
return zt !== null ? (s = zt, zt = zt.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 = zt, zt = 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;
}
// getters
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;
}
// convertors
fromArray(e) {
let n = null;
this.head = null;
for (let s of e) {
const r = q.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];
}
// array-like methods
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 q();
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 q();
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();
}
// mutation
clear() {
this.head = null, this.tail = null;
}
copy() {
const e = new q();
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(q.createItem(e));
}
append(e) {
return this.insert(e);
}
appendData(e) {
return this.insert(q.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(q.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(q.createItem(e));
}
pop() {
return this.tail !== null ? this.remove(this.tail) : null;
}
unshift(e) {
this.prepend(q.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 ve(t) {
const e = {};
for (const n of Object.keys(t)) {
let s = t[n];
s && (Array.isArray(s) || s instanceof q ? s = s.map(ve) : s.constructor === Object && (s = ve(s))), e[n] = s;
}
return e;
}
const vt = 0, d = 1, T = 2, z = 3, _ = 4, Tt = 5, Jo = 6, Q = 7, at = 8, L = 9, b = 10, F = 11, E = 12, W = 13, De = 14, nt = 15, X = 16, tt = 17, ft = 18, ee = 19, ce = 20, I = 21, y = 22, ht = 23, Yt = 24, Y = 25, Zo = 0;
function rt(t) {
return t >= 48 && t <= 57;
}
function Xt(t) {
return rt(t) || // 0 .. 9
t >= 65 && t <= 70 || // A .. F
t >= 97 && t <= 102;
}
function bn(t) {
return t >= 65 && t <= 90;
}
function ta(t) {
return t >= 97 && t <= 122;
}
function ea(t) {
return bn(t) || ta(t);
}
function na(t) {
return t >= 128;
}
function Ee(t) {
return ea(t) || na(t) || t === 95;
}
function Ws(t) {
return Ee(t) || rt(t) || t === 45;
}
function sa(t) {
return t >= 0 && t <= 8 || t === 11 || t >= 14 && t <= 31 || t === 127;
}
function $e(t) {
return t === 10 || t === 13 || t === 12;
}
function Ft(t) {
return $e(t) || t === 32 || t === 9;
}
function kt(t, e) {
return !(t !== 92 || $e(e) || e === Zo);
}
function Me(t, e, n) {
return t === 45 ? Ee(e) || e === 45 || kt(e, n) : Ee(t) ? !0 : t === 92 ? kt(t, e) : !1;
}
function je(t, e, n) {
return t === 43 || t === 45 ? rt(e) ? 2 : e === 46 && rt(n) ? 3 : 0 : t === 46 ? rt(e) ? 2 : 0 : rt(t) ? 1 : 0;
}
function zs(t) {
return t === 65279 || t === 65534 ? 1 : 0;
}
const on = new Array(128), ra = 128, ye = 130, Hs = 131, xn = 132, Vs = 133;
for (let t = 0; t < on.length; t++)
on[t] = Ft(t) && ye || rt(t) && Hs || Ee(t) && xn || sa(t) && Vs || t || ra;
function Be(t) {
return t < 128 ? on[t] : xn;
}
function Kt(t, e) {
return e < t.length ? t.charCodeAt(e) : 0;
}
function an(t, e, n) {
return n === 13 && Kt(t, e + 1) === 10 ? 2 : 1;
}
function Gs(t, e, n) {
let s = t.charCodeAt(e);
return bn(s) && (s = s | 32), s === n;
}
function Le(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 (bn(a) && (a = a | 32), a !== o)
return !1;
}
return !0;
}
function ia(t, e) {
for (; e >= 0 && Ft(t.charCodeAt(e)); e--)
;
return e + 1;
}
function de(t, e) {
for (; e < t.length && Ft(t.charCodeAt(e)); e++)
;
return e;
}
function Ue(t, e) {
for (; e < t.length && rt(t.charCodeAt(e)); e++)
;
return e;
}
function Jt(t, e) {
if (e += 2, Xt(Kt(t, e - 1))) {
for (const s = Math.min(t.length, e + 5); e < s && Xt(Kt(t, e)); e++)
;
const n = Kt(t, e);
Ft(n) && (e += an(t, e, n));
}
return e;
}
function ge(t, e) {
for (; e < t.length; e++) {
const n = t.charCodeAt(e);
if (!Ws(n)) {
if (kt(n, Kt(t, e + 1))) {
e = Jt(t, e) - 1;
continue;
}
break;
}
}
return e;
}
function qs(t, e) {
let n = t.charCodeAt(e);
if ((n === 43 || n === 45) && (n = t.charCodeAt(e += 1)), rt(n) && (e = Ue(t, e + 1), n = t.charCodeAt(e)), n === 46 && rt(t.charCodeAt(e + 1)) && (e += 2, e = Ue(t, e)), Gs(
t,
e,
101
/* e */
)) {
let s = 0;
n = t.charCodeAt(e + 1), (n === 45 || n === 43) && (s = 1, n = t.charCodeAt(e + 2)), rt(n) && (e = Ue(t, e + 1 + s + 1));
}
return e;
}
function We(t, e) {
for (; e < t.length; e++) {
const n = t.charCodeAt(e);
if (n === 41) {
e++;
break;
}
kt(n, Kt(t, e + 1)) && (e = Jt(t, e));
}
return e;
}
function Ks(t) {
if (t.length === 1 && !Xt(t.charCodeAt(0)))
return t[0];
let e = parseInt(t, 16);
return (e === 0 || // If this number is zero,
e >= 55296 && e <= 57343 || // or is for a surrogate,
e > 1114111) && (e = 65533), String.fromCodePoint(e);
}
const Qs = [
"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"
], oa = 16 * 1024;
function Pe(t = null, e) {
return t === null || t.length < e ? new Uint32Array(Math.max(e + 1024, oa)) : t;
}
const In = 10, aa = 12, _n = 13;
function Nn(t) {
const e = t.source, n = e.length, s = e.length > 0 ? zs(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 === In || i === _n || i === aa) && (i === _n && u + 1 < n && e.charCodeAt(u + 1) === In && (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 la {
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 || Nn(this), {
source: n,
offset: this.startOffset + e,
line: this.lines[e],
column: this.columns[e]
};
}
getLocationRange(e, n, s) {
return this.computed || Nn(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 dt = 16777215, gt = 24, Mt = new Uint8Array(32);
Mt[T] = y;
Mt[I] = y;
Mt[ee] = ce;
Mt[ht] = Yt;
function Dn(t) {
return Mt[t] !== 0;
}
class ca {
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 << gt | f, l === -1 && (l = h), o[p] = i, c === u) {
const g = o[i];
o[i] = p, i = g, u = Mt[r[g] >> gt];
} else Dn(c) && (i = p, u = Mt[c]);
}), r[a] = vt << gt | 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] >> gt : vt;
}
lookupTypeNonSC(e) {
for (let n = this.tokenIndex; n < this.tokenCount; n++) {
const s = this.offsetAndType[n] >> gt;
if (s !== W && s !== Y && e-- === 0)
return s;
}
return vt;
}
lookupOffset(e) {
return e += this.tokenIndex, e < this.tokenCount ? this.offsetAndType[e - 1] & dt : this.source.length;
}
lookupOffsetNonSC(e) {
for (let n = this.tokenIndex; n < this.tokenCount; n++) {
const s = this.offsetAndType[n] >> gt;
if (s !== W && s !== Y && e-- === 0)
return n - this.tokenIndex;
}
return vt;
}
lookupValue(e, n) {
return e += this.tokenIndex, e < this.tokenCount ? Le(
this.source,
this.offsetAndType[e - 1] & dt,
this.offsetAndType[e] & dt,
n
) : !1;
}
getTokenStart(e) {
return e === this.tokenIndex ? this.tokenStart : e > 0 ? e < this.tokenCount ? this.offsetAndType[e - 1] & dt : this.offsetAndType[this.tokenCount] & dt : 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] & dt, n = this.offsetAndType[n], this.tokenType = n >> gt, this.tokenEnd = n & dt) : (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 >> gt, this.tokenEnd = e & dt) : (this.eof = !0, this.tokenIndex = this.tokenCount, this.tokenType = vt, this.tokenStart = this.tokenEnd = this.source.length);
}
skipSC() {
for (; this.tokenType === W || this.tokenType === Y; )
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] & dt : this.firstCharOffset, n(this.source.charCodeAt(o))) {
case 1:
break t;
case 2:
s++;
break t;
default:
Dn(this.offsetAndType[s] >> gt) && (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 & dt, l = o >> gt;
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: Qs[n],
chunk: this.source.substring(s, r),
balance: this.balance[o]
};
}), e;
}
}
function Ys(t, e) {
function n(h) {
return h < l ? t.charCodeAt(h) : 0;
}
function s() {
if (i = qs(t, i), Me(n(i), n(i + 1), n(i + 2))) {
c = E, i = ge(t, i);
return;
}
if (n(i) === 37) {
c = F, i++;
return;
}
c = b;
}
function r() {
const h = i;
if (i = ge(t, i), Le(t, h, i, "url") && n(i) === 40) {
if (i = de(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 = Tt; i < t.length; i++) {
const f = t.charCodeAt(i);
switch (Be(f)) {
// ending code point
case h:
i++;
return;
// EOF
// case EofCategory:
// This is a parse error. Return the <string-token>.
// return;
// newline
case ye:
if ($e(f)) {
i += an(t, i, f), c = Jo;
return;
}
break;
// U+005C REVERSE SOLIDUS (\)
case 92:
if (i === t.length - 1)
break;
const p = n(i + 1);
$e(p) ? i += an(t, i + 1, p) : kt(f, p) && (i = Jt(t, i) - 1);
break;
}
}
}
function a() {
for (c = Q, i = de(t, i); i < t.length; i++) {
const h = t.charCodeAt(i);
switch (Be(h)) {
// U+0029 RIGHT PARENTHESIS ())
case 41:
i++;
return;
// EOF
// case EofCategory:
// This is a parse error. Return the <url-token>.
// return;
// whitespace
case ye:
if (i = de(t, i), n(i) === 41 || i >= t.length) {
i < t.length && i++;
return;
}
i = We(t, i), c = at;
return;
// U+0022 QUOTATION MARK (")
// U+0027 APOSTROPHE (')
// U+0028 LEFT PARENTHESIS (()
// non-printable code point
case 34:
case 39:
case 40:
case Vs:
i = We(t, i), c = at;
return;
// U+005C REVERSE SOLIDUS (\)
case 92:
if (kt(h, n(i + 1))) {
i = Jt(t, i) - 1;
break;
}
i = We(t, i), c = at;
return;
}
}
}
t = String(t || "");
const l = t.length;
let u = zs(n(0)), i = u, c;
for (; i < l; ) {
const h = t.charCodeAt(i);
switch (Be(h)) {
// whitespace
case ye:
c = W, i = de(t, i + 1);
break;
// U+0022 QUOTATION MARK (")
case 34:
o();
break;
// U+0023 NUMBER SIGN (#)
case 35:
Ws(n(i + 1)) || kt(n(i + 1), n(i + 2)) ? (c = _, i = ge(t, i + 1)) : (c = L, i++);
break;
// U+0027 APOSTROPHE (')
case 39:
o();
break;
// U+0028 LEFT PARENTHESIS (()
case 40:
c = I, i++;
break;
// U+0029 RIGHT PARENTHESIS ())
case 41:
c = y, i++;
break;
// U+002B PLUS SIGN (+)
case 43:
je(h, n(i + 1), n(i + 2)) ? s() : (c = L, i++);
break;
// U+002C COMMA (,)
case 44:
c = ft, i++;
break;
// U+002D HYPHEN-MINUS (-)
case 45:
je(h, n(i + 1), n(i + 2)) ? s() : n(i + 1) === 45 && n(i + 2) === 62 ? (c = nt, i = i + 3) : Me(h, n(i + 1), n(i + 2)) ? r() : (c = L, i++);
break;
// U+002E FULL STOP (.)
case 46:
je(h, n(i + 1), n(i + 2)) ? s() : (c = L, i++);
break;
// U+002F SOLIDUS (/)
case 47:
n(i + 1) === 42 ? (c = Y, i = t.indexOf("*/", i + 2), i = i === -1 ? t.length : i + 2) : (c = L, i++);
break;
// U+003A COLON (:)
case 58:
c = X, i++;
break;
// U+003B SEMICOLON (;)
case 59:
c = tt, i++;
break;
// U+003C LESS-THAN SIGN (<)
case 60:
n(i + 1) === 33 && n(i + 2) === 45 && n(i + 3) === 45 ? (c = De, i = i + 4) : (c = L, i++);
break;
// U+0040 COMMERCIAL AT (@)
case 64:
Me(n(i + 1), n(i + 2), n(i + 3)) ? (c = z, i = ge(t, i + 1)) : (c = L, i++);
break;
// U+005B LEFT SQUARE BRACKET ([)
case 91:
c = ee, i++;
break;
// U+005C REVERSE SOLIDUS (\)
case 92:
kt(h, n(i + 1)) ? r() : (c = L, i++);
break;
// U+005D RIGHT SQUARE BRACKET (])
case 93:
c = ce, i++;
break;
// U+007B LEFT CURLY BRACKET ({)
case 123:
c = ht, i++;
break;
// U+007D RIGHT CURLY BRACKET (})
case 125:
c = Yt, i++;
break;
// digit
case Hs:
s();
break;
// name-start code point
case xn:
r();
break;
// EOF
// case EofCategory:
// Return an <EOF-token>.
// break;
// anything else
default:
c = L, i++;
}
e(c, u, u = i);
}
}
const Fn = 45;
function ua(t, e) {
return e = e || 0, t.length - e >= 2 && t.charCodeAt(e) === Fn && t.charCodeAt(e + 1) === Fn;
}
const ln = 92, Xs = 34, ha = 39;
function Js(t) {
const e = t.length, n = t.charCodeAt(0), s = n === Xs || n === ha ? 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 === ln) {
if (a === r) {
a !== e - 1 && (o = t.substr(a + 1));
break;
}
if (l = t.charCodeAt(++a), kt(ln, l)) {
const u = a - 1, i = Jt(t, u);
a = i - 1, o += Ks(t.substring(u + 1, i));
} else
l === 13 && t.charCodeAt(a + 1) === 10 && a++;
} else
o += t[a];
}
return o;
}
function fa(t, e) {
const s = Xs;
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 === ln ? (r += "\\" + t.charAt(a), o = !1) : (o && (Xt(l) || Ft(l)) && (r += " "), r += t.charAt(a), o = !1);
}
return '"' + r + '"';
}
const pa = 32, cn = 92, da = 34, ga = 39, ma = 40, Zs = 41;
function ka(t) {
const e = t.length;
let n = 4, s = t.charCodeAt(e - 1) === Zs ? e - 2 : e - 1, r = "";
for (; n < s && Ft(t.charCodeAt(n)); )
n++;
for (; n < s && Ft(t.charCodeAt(s)); )
s--;
for (let o = n; o <= s; o++) {
let a = t.charCodeAt(o);
if (a === cn) {
if (o === s) {
o !== e - 1 && (r = t.substr(o + 1));
break;
}
if (a = t.charCodeAt(++o), kt(cn, a)) {
const l = o - 1, u = Jt(t, l);
o = u - 1, r += Ks(t.substring(l + 1, u));
} else
a === 13 && t.charCodeAt(o + 1) === 10 && o++;
} else
r += t[o];
}
return r;
}
function Sa(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 === pa || r === cn || r === da || r === ga || r === ma || r === Zs ? (e += "\\" + t.charAt(s), n = !1) : (n && Xt(r) && (e += " "), e += t.charAt(s), n = !1);
}
return "url(" + e + ")";
}
const { hasOwnProperty: Cn } = Object.prototype, ne = function() {
};
function Mn(t) {
return typeof t == "function" ? t : ne;
}
function jn(t, e) {
return function(n, s, r) {
n.type === e && t.call(this, n, s, r);
};
}
function ya(t, e) {
const n = e.structure, s = [];
for (const r in n) {
if (Cn.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 ba(t) {
const e = {};
for (const n in t.node)
if (Cn.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] = ya(n, s);
}
return e;
}
function Bn(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 Un({
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 xa(t) {
const e = ba(t), n = {}, s = {}, r = Symbol("break-walk"), o = Symbol("skip-node");
for (const i in e)
Cn.call(e, i) && e[i] !== null && (n[i] = Bn(e[i], !1), s[i] = Bn(e[i], !0));
const a = Un(n), l = Un(s), u = function(i, c) {
function h(S, x, A) {
const M = f.call(k, S, x, A);
return M === r ? !0 : M === o ? !1 : !!(g.hasOwnProperty(S.type) && g[S.type](S, k, h, m) || p.call(k, S, x, A) === r);
}
let f = ne, p = ne, g = n, m = (S, x, A, M) => S || h(x, A, M);
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 = Mn(c.enter), p = Mn(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 = jn(f, c.visit), p = jn(p, c.visit);
}
if (f === ne && p === ne)
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 mt = 43, st = 45, be = 110, It = !0, Ca = !1;
function xe(t, e) {
let n = this.tokenStart + t;
const s = this.charCodeAt(n);
for ((s === mt || s === st) && (e && this.error("Number sign is not allowed"), n++); n < this.tokenEnd; n++)
rt(this.charCodeAt(n)) || this.error("Integer is expected", n);
}
function Ht(t) {
return xe.call(this, 0, t);
}
function At(t, e) {
if (!this.cmpChar(this.tokenStart + t, e)) {
let n = "";
switch (e) {
case be:
n = "N is expected";
break;
case st:
n = "HyphenMinus is expected";
break;
}
this.error(n, this.tokenStart + t);
}
}
function ze() {
let t = 0, e = 0, n = this.tokenType;
for (; n === W || n === Y; )
n = this.lookupType(++t);
if (n !== b)
if (this.isDelim(mt, t) || this.isDelim(st, t)) {
e = this.isDelim(mt, t) ? mt : st;
do
n = this.lookupType(++t);
while (n === W || n === Y);
n !== b && (this.skip(t), Ht.call(this, It));
} else
return null;
return t > 0 && this.skip(t), e === 0 && (n = this.charCodeAt(this.tokenStart), n !== mt && n !== st && this.error("Number sign is expected")), Ht.call(this, e !== 0), e === st ? "-" + this.consume(b) : this.consume(b);
}
const wa = "AnPlusB", Ta = {
a: [String, null],
b: [String, null]
};
function tr() {
const t = this.tokenStart;
let e = null, n = null;
if (this.tokenType === b)
Ht.call(this, Ca), n = this.consume(b);
else if (this.tokenType === d && this.cmpChar(this.tokenStart, st))
switch (e = "-1", At.call(this, 1, be), this.tokenEnd - this.tokenStart) {
// -n
// -n <signed-integer>
// -n ['+' | '-'] <signless-integer>
case 2:
this.next(), n = ze.call(this);
break;
// -n- <signless-integer>
case 3:
At.call(this, 2, st), this.next(), this.skipSC(), Ht.call(this, It), n = "-" + this.consume(b);
break;
// <dashndashdigit-ident>
default:
At.call(this, 2, st), xe.call(this, 3, It), this.next(), n = this.substrToCursor(t + 2);
}
else if (this.tokenType === d || this.isDelim(mt) && this.lookupType(1) === d) {
let s = 0;
switch (e = "1", this.isDelim(mt) && (s = 1, this.next()), At.call(this, 0, be), this.tokenEnd - this.tokenStart) {
// '+'? n
// '+'? n <signed-integer>
// '+'? n ['+' | '-'] <signless-integer>
case 1:
this.next(), n = ze.call(this);
break;
// '+'? n- <signless-integer>
case 2:
At.call(this, 1, st), this.next(), this.skipSC(), Ht.call(this, It), n = "-" + this.consume(b);
break;
// '+'? <ndashdigit-ident>
default:
At.call(this, 1, st), xe.call(this, 2, It), this.next(), n = this.substrToCursor(t + s + 1);
}
} else if (this.tokenType === E) {
const s = this.charCodeAt(this.tokenStart), r = s === mt || s === st;
let o = this.tokenStart + r;
for (; o < this.tokenEnd && rt(this.charCodeAt(o)); o++)
;
o === this.tokenStart + r && this.error("Integer is expected", this.tokenStart + r), At.call(this, o - this.tokenStart, be), e = this.substring(t, o), o + 1 === this.tokenEnd ? (this.next(), n = ze.call(this)) : (At.call(this, o - this.tokenStart + 1, st), o + 2 === this.tokenEnd ? (this.next(), this.skipSC(), Ht.call(this, It), n = "-" + this.consume(b)) : (xe.call(this, o - this.tokenStart + 2, It), this.next(), n = this.substrToCursor(o + 1)));
} else
this.error();
return e !== null && e.charCodeAt(0) === mt && (e = e.substr(1)), n !== null && n.charCodeAt(0) === mt && (n = n.substr(1)), {
type: "AnPlusB",
loc: this.getLocation(t, this.tokenStart),
a: e,
b: n
};
}
function er(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 Aa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
generate: er,
name: wa,
parse: tr,
structure: Ta
}, Symbol.toStringTag, { value: "Module" }));
function Wn() {
return this.Raw(this.consumeUntilLeftCurlyBracketOrSemicolon, !0);
}
function va() {
for (let t = 1, e; e = this.lookupType(t); t++) {
if (e === Yt)
return !0;
if (e === ht || e === z)
return !1;
}
return !1;
}
const Ea = "Atrule", $a = "atrule", La = {
name: String,
prelude: ["AtrulePrelude", "Raw", null],
block: ["Block", null]
};
function nr(t = !1) {
const e = this.tokenStart;
let n, s, r = null, o = null;
switch (this.eat(z), n = this.substrToCursor(e + 1), s = n.toLowerCase(), this.skipSC(), this.eof === !1 && this.tokenType !== ht && this.tokenType !== tt && (this.parseAtrulePrelude ? r = this.parseWithFallback(this.AtrulePrelude.bind(this, n, t), Wn) : r = Wn.call(this, this.tokenIndex), this.skipSC()), this.tokenType) {
case tt:
this.next();
break;
case ht:
hasOwnProperty.call(this.atrule, s) && typeof this.atrule[s].block == "function" ? o = this.atrule[s].block.call(this, t) : o = this.Block(va.call(this));
break;
}
return {
type: "Atrule",
loc: this.getLocation(e, this.tokenStart),
name: n,
prelude: r,
block: o
};
}
function sr(t) {
this.token(z, "@" + t.name), t.prelude !== null && this.node(t.prelude), t.block ? this.node(t.block) : this.token(tt, ";");
}
const Pa = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
generate: sr,
name: Ea,
parse: nr,
structure: La,
walkContext: $a
}, Symbol.toStringTag, { value: "Module" })), Oa = "AtrulePrelude", Ra = "atrulePrelude", Ia = {
children: [[]]
};
function rr(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 !== ht && this.tokenType !== tt && this.error("Semicolon or block is expected"), {
type: "AtrulePrelude",
loc: this.getLocationFromList(