@oddbird/css-anchor-positioning
Version:
Polyfill for the proposed CSS anchor positioning spec
1,693 lines • 185 kB
JavaScript
var bo = Object.defineProperty, xo = Object.defineProperties;
var Co = Object.getOwnPropertyDescriptors;
var $n = Object.getOwnPropertySymbols;
var wo = Object.prototype.hasOwnProperty, Ao = Object.prototype.propertyIsEnumerable;
var On = (t, e, n) => e in t ? bo(t, e, { enumerable: !0, configurable: !0, writable: !0, value: n }) : t[e] = n, U = (t, e) => {
for (var n in e || (e = {}))
wo.call(e, n) && On(t, n, e[n]);
if ($n)
for (var n of $n(e))
Ao.call(e, n) && On(t, n, e[n]);
return t;
}, G = (t, e) => xo(t, Co(e));
var To = (t, e) => () => (e || t((e = { exports: {} }).exports, e), e.exports);
var R = (t, e, n) => new Promise((r, s) => {
var o = (u) => {
try {
l(n.next(u));
} catch (i) {
s(i);
}
}, a = (u) => {
try {
l(n.throw(u));
} catch (i) {
s(i);
}
}, l = (u) => u.done ? r(u.value) : Promise.resolve(u.value).then(o, a);
l((n = n.apply(t, e)).next());
});
var id = To((fe) => {
const rn = Math.min, Gt = Math.max, Te = Math.round, de = Math.floor, St = (t) => ({
x: t,
y: t
});
function vo(t, e) {
return typeof t == "function" ? t(e) : t;
}
function Eo(t) {
return U({
top: 0,
right: 0,
bottom: 0,
left: 0
}, t);
}
function $o(t) {
return typeof t != "number" ? Eo(t) : {
top: t,
right: t,
bottom: t,
left: t
};
}
function ve(t) {
const {
x: e,
y: n,
width: r,
height: s
} = t;
return {
width: r,
height: s,
top: n,
left: e,
right: e + r,
bottom: n + s,
x: e,
y: n
};
}
function Oo(t, e) {
return R(this, null, function* () {
var n;
e === void 0 && (e = {});
const {
x: r,
y: s,
platform: o,
rects: a,
elements: l,
strategy: u
} = t, {
boundary: i = "clippingAncestors",
rootBoundary: c = "viewport",
elementContext: h = "floating",
altBoundary: f = !1,
padding: p = 0
} = vo(e, t), g = $o(p), k = l[f ? h === "floating" ? "reference" : "floating" : h], S = ve(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: r,
y: s,
width: a.floating.width,
height: a.floating.height
} : a.reference, T = yield o.getOffsetParent == null ? void 0 : o.getOffsetParent(l.floating), M = (yield o.isElement == null ? void 0 : o.isElement(T)) ? (yield o.getScale == null ? void 0 : o.getScale(T)) || {
x: 1,
y: 1
} : {
x: 1,
y: 1
}, et = ve(o.convertOffsetParentRelativeRectToViewportRelativeRect ? yield o.convertOffsetParentRelativeRectToViewportRelativeRect({
elements: l,
rect: x,
offsetParent: T,
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 Ie() {
return typeof window != "undefined";
}
function te(t) {
return Dr(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 = (Dr(t) ? t.ownerDocument : t.document) || window.document) == null ? void 0 : e.documentElement;
}
function Dr(t) {
return Ie() ? t instanceof Node || t instanceof it(t).Node : !1;
}
function ct(t) {
return Ie() ? t instanceof Element || t instanceof it(t).Element : !1;
}
function yt(t) {
return Ie() ? t instanceof HTMLElement || t instanceof it(t).HTMLElement : !1;
}
function Ln(t) {
return !Ie() || typeof ShadowRoot == "undefined" ? !1 : t instanceof ShadowRoot || t instanceof it(t).ShadowRoot;
}
const Lo = /* @__PURE__ */ new Set(["inline", "contents"]);
function he(t) {
const {
overflow: e,
overflowX: n,
overflowY: r,
display: s
} = ut(t);
return /auto|scroll|overlay|hidden|clip/.test(e + r + n) && !Lo.has(s);
}
const Po = /* @__PURE__ */ new Set(["table", "td", "th"]);
function Ro(t) {
return Po.has(te(t));
}
const Io = [":popover-open", ":modal"];
function _e(t) {
return Io.some((e) => {
try {
return t.matches(e);
} catch (n) {
return !1;
}
});
}
const _o = ["transform", "translate", "scale", "rotate", "perspective"], No = ["transform", "translate", "scale", "rotate", "perspective", "filter"], Do = ["paint", "layout", "strict", "content"];
function Sn(t) {
const e = yn(), n = ct(t) ? ut(t) : t;
return _o.some((r) => n[r] ? n[r] !== "none" : !1) || (n.containerType ? n.containerType !== "normal" : !1) || !e && (n.backdropFilter ? n.backdropFilter !== "none" : !1) || !e && (n.filter ? n.filter !== "none" : !1) || No.some((r) => (n.willChange || "").includes(r)) || Do.some((r) => (n.contain || "").includes(r));
}
function Fo(t) {
let e = Lt(t);
for (; yt(e) && !Qt(e); ) {
if (Sn(e))
return e;
if (_e(e))
return null;
e = Lt(e);
}
return null;
}
function yn() {
return typeof CSS == "undefined" || !CSS.supports ? !1 : CSS.supports("-webkit-backdrop-filter", "none");
}
const Mo = /* @__PURE__ */ new Set(["html", "body", "#document"]);
function Qt(t) {
return Mo.has(te(t));
}
function ut(t) {
return it(t).getComputedStyle(t);
}
function Ne(t) {
return ct(t) ? {
scrollLeft: t.scrollLeft,
scrollTop: t.scrollTop
} : {
scrollLeft: t.scrollX,
scrollTop: t.scrollY
};
}
function Lt(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 Fr(t) {
const e = Lt(t);
return Qt(e) ? t.ownerDocument ? t.ownerDocument.body : t.body : yt(e) && he(e) ? e : Fr(e);
}
function le(t, e, n) {
var r;
e === void 0 && (e = []), n === void 0 && (n = !0);
const s = Fr(t), o = s === ((r = t.ownerDocument) == null ? void 0 : r.body), a = it(s);
if (o) {
const l = sn(a);
return e.concat(a, a.visualViewport || [], he(s) ? s : [], l && n ? le(l) : []);
}
return e.concat(s, le(s, [], n));
}
function sn(t) {
return t.parent && Object.getPrototypeOf(t.parent) ? t.frameElement : null;
}
function Mr(t) {
const e = ut(t);
let n = parseFloat(e.width) || 0, r = parseFloat(e.height) || 0;
const s = yt(t), o = s ? t.offsetWidth : n, a = s ? t.offsetHeight : r, l = Te(n) !== o || Te(r) !== a;
return l && (n = o, r = a), {
width: n,
height: r,
$: l
};
}
function bn(t) {
return ct(t) ? t : t.contextElement;
}
function qt(t) {
const e = bn(t);
if (!yt(e))
return St(1);
const n = e.getBoundingClientRect(), {
width: r,
height: s,
$: o
} = Mr(e);
let a = (o ? Te(n.width) : n.width) / r, l = (o ? Te(n.height) : n.height) / s;
return (!a || !Number.isFinite(a)) && (a = 1), (!l || !Number.isFinite(l)) && (l = 1), {
x: a,
y: l
};
}
const jo = /* @__PURE__ */ St(0);
function jr(t) {
const e = it(t);
return !yn() || !e.visualViewport ? jo : {
x: e.visualViewport.offsetLeft,
y: e.visualViewport.offsetTop
};
}
function Bo(t, e, n) {
return e === void 0 && (e = !1), !n || e && n !== it(t) ? !1 : e;
}
function Dt(t, e, n, r) {
e === void 0 && (e = !1), n === void 0 && (n = !1);
const s = t.getBoundingClientRect(), o = bn(t);
let a = St(1);
e && (r ? ct(r) && (a = qt(r)) : a = qt(t));
const l = Bo(o, n, r) ? jr(o) : St(0);
let u = (s.left + l.x) / a.x, i = (s.top + l.y) / a.y, c = s.width / a.x, h = s.height / a.y;
if (o) {
const f = it(o), p = r && ct(r) ? it(r) : r;
let g = f, m = sn(g);
for (; m && r && p !== g; ) {
const k = qt(m), S = m.getBoundingClientRect(), x = ut(m), T = 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 += T, i += M, g = it(m), m = sn(g);
}
}
return ve({
width: c,
height: h,
x: u,
y: i
});
}
function De(t, e) {
const n = Ne(t).scrollLeft;
return e ? e.left + n : Dt(bt(t)).left + n;
}
function Br(t, e) {
const n = t.getBoundingClientRect(), r = n.left + e.scrollLeft - De(t, n), s = n.top + e.scrollTop;
return {
x: r,
y: s
};
}
function Uo(t) {
let {
elements: e,
rect: n,
offsetParent: r,
strategy: s
} = t;
const o = s === "fixed", a = bt(r), l = e ? _e(e.floating) : !1;
if (r === a || l && o)
return n;
let u = {
scrollLeft: 0,
scrollTop: 0
}, i = St(1);
const c = St(0), h = yt(r);
if ((h || !h && !o) && ((te(r) !== "body" || he(a)) && (u = Ne(r)), yt(r))) {
const p = Dt(r);
i = qt(r), c.x = p.x + r.clientLeft, c.y = p.y + r.clientTop;
}
const f = a && !h && !o ? Br(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 Wo(t) {
return Array.from(t.getClientRects());
}
function zo(t) {
const e = bt(t), n = Ne(t), r = t.ownerDocument.body, s = Gt(e.scrollWidth, e.clientWidth, r.scrollWidth, r.clientWidth), o = Gt(e.scrollHeight, e.clientHeight, r.scrollHeight, r.clientHeight);
let a = -n.scrollLeft + De(t);
const l = -n.scrollTop;
return ut(r).direction === "rtl" && (a += Gt(e.clientWidth, r.clientWidth) - s), {
width: s,
height: o,
x: a,
y: l
};
}
const Pn = 25;
function Ho(t, e) {
const n = it(t), r = bt(t), s = n.visualViewport;
let o = r.clientWidth, a = r.clientHeight, l = 0, u = 0;
if (s) {
o = s.width, a = s.height;
const c = yn();
(!c || c && e === "fixed") && (l = s.offsetLeft, u = s.offsetTop);
}
const i = De(r);
if (i <= 0) {
const c = r.ownerDocument, h = c.body, f = getComputedStyle(h), p = c.compatMode === "CSS1Compat" && parseFloat(f.marginLeft) + parseFloat(f.marginRight) || 0, g = Math.abs(r.clientWidth - h.clientWidth - p);
g <= Pn && (o -= g);
} else i <= Pn && (o += i);
return {
width: o,
height: a,
x: l,
y: u
};
}
const Vo = /* @__PURE__ */ new Set(["absolute", "fixed"]);
function Go(t, e) {
const n = Dt(t, !0, e === "fixed"), r = n.top + t.clientTop, s = n.left + t.clientLeft, o = yt(t) ? qt(t) : St(1), a = t.clientWidth * o.x, l = t.clientHeight * o.y, u = s * o.x, i = r * o.y;
return {
width: a,
height: l,
x: u,
y: i
};
}
function Rn(t, e, n) {
let r;
if (e === "viewport")
r = Ho(t, n);
else if (e === "document")
r = zo(bt(t));
else if (ct(e))
r = Go(e, n);
else {
const s = jr(t);
r = {
x: e.x - s.x,
y: e.y - s.y,
width: e.width,
height: e.height
};
}
return ve(r);
}
function Ur(t, e) {
const n = Lt(t);
return n === e || !ct(n) || Qt(n) ? !1 : ut(n).position === "fixed" || Ur(n, e);
}
function qo(t, e) {
const n = e.get(t);
if (n)
return n;
let r = le(t, [], !1).filter((l) => ct(l) && te(l) !== "body"), s = null;
const o = ut(t).position === "fixed";
let a = o ? Lt(t) : t;
for (; ct(a) && !Qt(a); ) {
const l = ut(a), u = Sn(a);
!u && l.position === "fixed" && (s = null), (o ? !u && !s : !u && l.position === "static" && !!s && Vo.has(s.position) || he(a) && !u && Ur(t, a)) ? r = r.filter((c) => c !== a) : s = l, a = Lt(a);
}
return e.set(t, r), r;
}
function Ko(t) {
let {
element: e,
boundary: n,
rootBoundary: r,
strategy: s
} = t;
const a = [...n === "clippingAncestors" ? _e(e) ? [] : qo(e, this._c) : [].concat(n), r], l = a[0], u = a.reduce((i, c) => {
const h = Rn(e, c, s);
return i.top = Gt(h.top, i.top), i.right = rn(h.right, i.right), i.bottom = rn(h.bottom, i.bottom), i.left = Gt(h.left, i.left), i;
}, Rn(e, l, s));
return {
width: u.right - u.left,
height: u.bottom - u.top,
x: u.left,
y: u.top
};
}
function Qo(t) {
const {
width: e,
height: n
} = Mr(t);
return {
width: e,
height: n
};
}
function Yo(t, e, n) {
const r = yt(e), s = 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 = De(s);
}
if (r || !r && !o)
if ((te(e) !== "body" || he(s)) && (l = Ne(e)), r) {
const p = Dt(e, !0, o, e);
u.x = p.x + e.clientLeft, u.y = p.y + e.clientTop;
} else s && i();
o && !r && s && i();
const c = s && !r && !o ? Br(s, 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 Me(t) {
return ut(t).position === "static";
}
function In(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 Wr(t, e) {
const n = it(t);
if (_e(t))
return n;
if (!yt(t)) {
let s = Lt(t);
for (; s && !Qt(s); ) {
if (ct(s) && !Me(s))
return s;
s = Lt(s);
}
return n;
}
let r = In(t, e);
for (; r && Ro(r) && Me(r); )
r = In(r, e);
return r && Qt(r) && Me(r) && !Sn(r) ? n : r || Fo(t) || n;
}
const Xo = function(t) {
return R(this, null, function* () {
const e = this.getOffsetParent || Wr, n = this.getDimensions, r = yield n(t.floating);
return {
reference: Yo(t.reference, yield e(t.floating), t.strategy),
floating: {
x: 0,
y: 0,
width: r.width,
height: r.height
}
};
});
};
function Jo(t) {
return ut(t).direction === "rtl";
}
const H = {
convertOffsetParentRelativeRectToViewportRelativeRect: Uo,
getDocumentElement: bt,
getClippingRect: Ko,
getOffsetParent: Wr,
getElementRects: Xo,
getClientRects: Wo,
getDimensions: Qo,
getScale: qt,
isElement: ct,
isRTL: Jo
};
function zr(t, e) {
return t.x === e.x && t.y === e.y && t.width === e.width && t.height === e.height;
}
function Zo(t, e) {
let n = null, r;
const s = bt(t);
function o() {
var l;
clearTimeout(r), (l = n) == null || l.disconnect(), n = null;
}
function a(l, u) {
l === void 0 && (l = !1), u === void 0 && (u = 1), o();
const i = t.getBoundingClientRect(), {
left: c,
top: h,
width: f,
height: p
} = i;
if (l || e(), !f || !p)
return;
const g = de(h), m = de(s.clientWidth - (c + f)), k = de(s.clientHeight - (h + p)), S = de(c), T = {
rootMargin: -g + "px " + -m + "px " + -k + "px " + -S + "px",
threshold: Gt(0, rn(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) : r = setTimeout(() => {
a(!1, 1e-7);
}, 1e3);
}
C === 1 && !zr(i, t.getBoundingClientRect()) && a(), M = !1;
}
try {
n = new IntersectionObserver(et, G(U({}, T), {
// Handle <iframe>s
root: s.ownerDocument
}));
} catch (w) {
n = new IntersectionObserver(et, T);
}
n.observe(t);
}
return a(!0), o;
}
function on(t, e, n, r) {
r === void 0 && (r = {});
const {
ancestorScroll: s = !0,
ancestorResize: o = !0,
elementResize: a = typeof ResizeObserver == "function",
layoutShift: l = typeof IntersectionObserver == "function",
animationFrame: u = !1
} = r, i = bn(t), c = s || o ? [...i ? le(i) : [], ...le(e)] : [];
c.forEach((S) => {
s && S.addEventListener("scroll", n, {
passive: !0
}), o && S.addEventListener("resize", n);
});
const h = i && l ? Zo(i, n) : null;
let f = -1, p = null;
a && (p = new ResizeObserver((S) => {
let [x] = S;
x && x.target === i && p && (p.unobserve(e), cancelAnimationFrame(f), f = requestAnimationFrame(() => {
var T;
(T = p) == null || T.observe(e);
})), n();
}), i && !u && p.observe(i), p.observe(e));
let g, m = u ? Dt(t) : null;
u && k();
function k() {
const S = Dt(t);
m && !zr(m, S) && n(), m = S, g = requestAnimationFrame(k);
}
return n(), () => {
var S;
c.forEach((x) => {
s && x.removeEventListener("scroll", n), o && x.removeEventListener("resize", n);
}), h == null || h(), (S = p) == null || S.disconnect(), p = null, u && cancelAnimationFrame(g);
};
}
const ta = Oo;
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 r;
return zt !== null ? (r = zt, zt = zt.cursor, r.prev = e, r.next = n, r.cursor = this.cursor) : r = {
prev: e,
next: n,
cursor: this.cursor
}, this.cursor = r, r;
}
releaseCursor() {
const { cursor: e } = this;
this.cursor = e.cursor, e.prev = null, e.next = null, e.cursor = zt, zt = e;
}
updateCursors(e, n, r, s) {
let { cursor: o } = this;
for (; o !== null; )
o.prev === e && (o.prev = n), o.next === r && (o.next = s), 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 r of e) {
const s = q.createItem(r);
n !== null ? n.next = s : this.head = s, s.prev = n, n = s;
}
return this.tail = n, this;
}
toArray() {
return [...this];
}
toJSON() {
return [...this];
}
// array-like methods
forEach(e, n = this) {
const r = this.allocateCursor(null, this.head);
for (; r.next !== null; ) {
const s = r.next;
r.next = s.next, e.call(n, s.data, s, this);
}
this.releaseCursor();
}
forEachRight(e, n = this) {
const r = this.allocateCursor(this.tail, null);
for (; r.prev !== null; ) {
const s = r.prev;
r.prev = s.prev, e.call(n, s.data, s, this);
}
this.releaseCursor();
}
reduce(e, n, r = this) {
let s = this.allocateCursor(null, this.head), o = n, a;
for (; s.next !== null; )
a = s.next, s.next = a.next, o = e.call(r, o, a.data, a, this);
return this.releaseCursor(), o;
}
reduceRight(e, n, r = this) {
let s = this.allocateCursor(this.tail, null), o = n, a;
for (; s.prev !== null; )
a = s.prev, s.prev = a.prev, o = e.call(r, o, a.data, a, this);
return this.releaseCursor(), o;
}
some(e, n = this) {
for (let r = this.head; r !== null; r = r.next)
if (e.call(n, r.data, r, this))
return !0;
return !1;
}
map(e, n = this) {
const r = new q();
for (let s = this.head; s !== null; s = s.next)
r.appendData(e.call(n, s.data, s, this));
return r;
}
filter(e, n = this) {
const r = new q();
for (let s = this.head; s !== null; s = s.next)
e.call(n, s.data, s, this) && r.appendData(s.data);
return r;
}
nextUntil(e, n, r = this) {
if (e === null)
return;
const s = this.allocateCursor(null, e);
for (; s.next !== null; ) {
const o = s.next;
if (s.next = o.next, n.call(r, o.data, o, this))
break;
}
this.releaseCursor();
}
prevUntil(e, n, r = this) {
if (e === null)
return;
const s = this.allocateCursor(e, null);
for (; s.prev !== null; ) {
const o = s.prev;
if (s.prev = o.prev, n.call(r, 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 Ee(t) {
const e = {};
for (const n of Object.keys(t)) {
let r = t[n];
r && (Array.isArray(r) || r instanceof q ? r = r.map(Ee) : r.constructor === Object && (r = Ee(r))), e[n] = r;
}
return e;
}
const vt = 0, d = 1, A = 2, z = 3, _ = 4, At = 5, ea = 6, Q = 7, at = 8, O = 9, b = 10, F = 11, E = 12, W = 13, Fe = 14, nt = 15, X = 16, tt = 17, ft = 18, ee = 19, ce = 20, I = 21, y = 22, ht = 23, Yt = 24, Y = 25, na = 0;
function st(t) {
return t >= 48 && t <= 57;
}
function Xt(t) {
return st(t) || // 0 .. 9
t >= 65 && t <= 70 || // A .. F
t >= 97 && t <= 102;
}
function xn(t) {
return t >= 65 && t <= 90;
}
function ra(t) {
return t >= 97 && t <= 122;
}
function sa(t) {
return xn(t) || ra(t);
}
function ia(t) {
return t >= 128;
}
function $e(t) {
return sa(t) || ia(t) || t === 95;
}
function Hr(t) {
return $e(t) || st(t) || t === 45;
}
function oa(t) {
return t >= 0 && t <= 8 || t === 11 || t >= 14 && t <= 31 || t === 127;
}
function Oe(t) {
return t === 10 || t === 13 || t === 12;
}
function Ft(t) {
return Oe(t) || t === 32 || t === 9;
}
function kt(t, e) {
return !(t !== 92 || Oe(e) || e === na);
}
function je(t, e, n) {
return t === 45 ? $e(e) || e === 45 || kt(e, n) : $e(t) ? !0 : t === 92 ? kt(t, e) : !1;
}
function Be(t, e, n) {
return t === 43 || t === 45 ? st(e) ? 2 : e === 46 && st(n) ? 3 : 0 : t === 46 ? st(e) ? 2 : 0 : st(t) ? 1 : 0;
}
function Vr(t) {
return t === 65279 || t === 65534 ? 1 : 0;
}
const an = new Array(128), aa = 128, be = 130, Gr = 131, Cn = 132, qr = 133;
for (let t = 0; t < an.length; t++)
an[t] = Ft(t) && be || st(t) && Gr || $e(t) && Cn || oa(t) && qr || t || aa;
function Ue(t) {
return t < 128 ? an[t] : Cn;
}
function Kt(t, e) {
return e < t.length ? t.charCodeAt(e) : 0;
}
function ln(t, e, n) {
return n === 13 && Kt(t, e + 1) === 10 ? 2 : 1;
}
function Kr(t, e, n) {
let r = t.charCodeAt(e);
return xn(r) && (r = r | 32), r === n;
}
function Le(t, e, n, r) {
if (n - e !== r.length || e < 0 || n > t.length)
return !1;
for (let s = e; s < n; s++) {
const o = r.charCodeAt(s - e);
let a = t.charCodeAt(s);
if (xn(a) && (a = a | 32), a !== o)
return !1;
}
return !0;
}
function la(t, e) {
for (; e >= 0 && Ft(t.charCodeAt(e)); e--)
;
return e + 1;
}
function ge(t, e) {
for (; e < t.length && Ft(t.charCodeAt(e)); e++)
;
return e;
}
function We(t, e) {
for (; e < t.length && st(t.charCodeAt(e)); e++)
;
return e;
}
function Jt(t, e) {
if (e += 2, Xt(Kt(t, e - 1))) {
for (const r = Math.min(t.length, e + 5); e < r && Xt(Kt(t, e)); e++)
;
const n = Kt(t, e);
Ft(n) && (e += ln(t, e, n));
}
return e;
}
function me(t, e) {
for (; e < t.length; e++) {
const n = t.charCodeAt(e);
if (!Hr(n)) {
if (kt(n, Kt(t, e + 1))) {
e = Jt(t, e) - 1;
continue;
}
break;
}
}
return e;
}
function Qr(t, e) {
let n = t.charCodeAt(e);
if ((n === 43 || n === 45) && (n = t.charCodeAt(e += 1)), st(n) && (e = We(t, e + 1), n = t.charCodeAt(e)), n === 46 && st(t.charCodeAt(e + 1)) && (e += 2, e = We(t, e)), Kr(
t,
e,
101
/* e */
)) {
let r = 0;
n = t.charCodeAt(e + 1), (n === 45 || n === 43) && (r = 1, n = t.charCodeAt(e + 2)), st(n) && (e = We(t, e + 1 + r + 1));
}
return e;
}
function ze(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 Yr(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 Xr = [
"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"
], ca = 16 * 1024;
function Pe(t = null, e) {
return t === null || t.length < e ? new Uint32Array(Math.max(e + 1024, ca)) : t;
}
const _n = 10, ua = 12, Nn = 13;
function Dn(t) {
const e = t.source, n = e.length, r = e.length > 0 ? Vr(e.charCodeAt(0)) : 0, s = Pe(t.lines, n), o = Pe(t.columns, n);
let a = t.startLine, l = t.startColumn;
for (let u = r; u < n; u++) {
const i = e.charCodeAt(u);
s[u] = a, o[u] = l++, (i === _n || i === Nn || i === ua) && (i === Nn && u + 1 < n && e.charCodeAt(u + 1) === _n && (u++, s[u] = a, o[u] = l), a++, l = 1);
}
s[n] = a, o[n] = l, t.lines = s, t.columns = o, t.computed = !0;
}
class ha {
constructor(e, n, r, s) {
this.setSource(e, n, r, s), this.lines = null, this.columns = null;
}
setSource(e = "", n = 0, r = 1, s = 1) {
this.source = e, this.startOffset = n, this.startLine = r, this.startColumn = s, this.computed = !1;
}
getLocation(e, n) {
return this.computed || Dn(this), {
source: n,
offset: this.startOffset + e,
line: this.lines[e],
column: this.columns[e]
};
}
getLocationRange(e, n, r) {
return this.computed || Dn(this), {
source: r,
start: {
offset: this.startOffset + e,
line: this.lines[e],
column: this.columns[e]
},
end: {
offset: this.startOffset + n,
line: this.lines[n],
column: this.columns[n]
}
};
}
}
const dt = 16777215, gt = 24, Mt = new Uint8Array(32);
Mt[A] = y;
Mt[I] = y;
Mt[ee] = ce;
Mt[ht] = Yt;
function Fn(t) {
return Mt[t] !== 0;
}
class fa {
constructor(e, n) {
this.setSource(e, n);
}
reset() {
this.eof = !1, this.tokenIndex = -1, this.tokenType = 0, this.tokenStart = this.firstCharOffset, this.tokenEnd = this.firstCharOffset;
}
setSource(e = "", n = () => {
}) {
e = String(e || "");
const r = e.length, s = 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 (s[p] = c << gt | f, l === -1 && (l = h), o[p] = i, c === u) {
const g = o[i];
o[i] = p, i = g, u = Mt[s[g] >> gt];
} else Fn(c) && (i = p, u = Mt[c]);
}), s[a] = vt << gt | r, 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 = s, 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 r = this.offsetAndType[n] >> gt;
if (r !== W && r !== Y && e-- === 0)
return r;
}
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 r = this.offsetAndType[n] >> gt;
if (r !== W && r !== 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) === O && this.source.charCodeAt(this.lookupOffset(n)) === e : this.tokenType === O && this.source.charCodeAt(this.tokenStart) === e;
}
skip(e) {
let n = this.tokenIndex + e;
n < this.tokenCount ? (this.tokenIndex = n, this.tokenStart = this.offsetAndType[n - 1] & 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 r = e, s = 0, o = 0;
t:
for (; r < this.tokenCount; r++) {
if (s = this.balance[r], s < e)
break t;
switch (o = r > 0 ? this.offsetAndType[r - 1] & dt : this.firstCharOffset, n(this.source.charCodeAt(o))) {
case 1:
break t;
case 2:
r++;
break t;
default:
Fn(this.offsetAndType[r] >> gt) && (r = s);
}
}
this.skip(r - this.tokenIndex);
}
forEachToken(e) {
for (let n = 0, r = this.firstCharOffset; n < this.tokenCount; n++) {
const s = r, o = this.offsetAndType[n], a = o & dt, l = o >> gt;
r = a, e(l, s, a, n);
}
}
dump() {
const e = new Array(this.tokenCount);
return this.forEachToken((n, r, s, o) => {
e[o] = {
idx: o,
type: Xr[n],
chunk: this.source.substring(r, s),
balance: this.balance[o]
};
}), e;
}
}
function Jr(t, e) {
function n(h) {
return h < l ? t.charCodeAt(h) : 0;
}
function r() {
if (i = Qr(t, i), je(n(i), n(i + 1), n(i + 2))) {
c = E, i = me(t, i);
return;
}
if (n(i) === 37) {
c = F, i++;
return;
}
c = b;
}
function s() {
const h = i;
if (i = me(t, i), Le(t, h, i, "url") && n(i) === 40) {
if (i = ge(t, i + 1), n(i) === 34 || n(i) === 39) {
c = A, i = h + 4;
return;
}
a();
return;
}
if (n(i) === 40) {
c = A, i++;
return;
}
c = d;
}
function o(h) {
for (h || (h = n(i++)), c = At; i < t.length; i++) {
const f = t.charCodeAt(i);
switch (Ue(f)) {
// ending code point
case h:
i++;
return;
// EOF
// case EofCategory:
// This is a parse error. Return the <string-token>.
// return;
// newline
case be:
if (Oe(f)) {
i += ln(t, i, f), c = ea;
return;
}
break;
// U+005C REVERSE SOLIDUS (\)
case 92:
if (i === t.length - 1)
break;
const p = n(i + 1);
Oe(p) ? i += ln(t, i + 1, p) : kt(f, p) && (i = Jt(t, i) - 1);
break;
}
}
}
function a() {
for (c = Q, i = ge(t, i); i < t.length; i++) {
const h = t.charCodeAt(i);
switch (Ue(h)) {
// U+0029 RIGHT PARENTHESIS ())
case 41:
i++;
return;
// EOF
// case EofCategory:
// This is a parse error. Return the <url-token>.
// return;
// whitespace
case be:
if (i = ge(t, i), n(i) === 41 || i >= t.length) {
i < t.length && i++;
return;
}
i = ze(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 qr:
i = ze(t, i), c = at;
return;
// U+005C REVERSE SOLIDUS (\)
case 92:
if (kt(h, n(i + 1))) {
i = Jt(t, i) - 1;
break;
}
i = ze(t, i), c = at;
return;
}
}
}
t = String(t || "");
const l = t.length;
let u = Vr(n(0)), i = u, c;
for (; i < l; ) {
const h = t.charCodeAt(i);
switch (Ue(h)) {
// whitespace
case be:
c = W, i = ge(t, i + 1);
break;
// U+0022 QUOTATION MARK (")
case 34:
o();
break;
// U+0023 NUMBER SIGN (#)
case 35:
Hr(n(i + 1)) || kt(n(i + 1), n(i + 2)) ? (c = _, i = me(t, i + 1)) : (c = O, 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:
Be(h, n(i + 1), n(i + 2)) ? r() : (c = O, i++);
break;
// U+002C COMMA (,)
case 44:
c = ft, i++;
break;
// U+002D HYPHEN-MINUS (-)
case 45:
Be(h, n(i + 1), n(i + 2)) ? r() : n(i + 1) === 45 && n(i + 2) === 62 ? (c = nt, i = i + 3) : je(h, n(i + 1), n(i + 2)) ? s() : (c = O, i++);
break;
// U+002E FULL STOP (.)
case 46:
Be(h, n(i + 1), n(i + 2)) ? r() : (c = O, 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 = O, 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 = Fe, i = i + 4) : (c = O, i++);
break;
// U+0040 COMMERCIAL AT (@)
case 64:
je(n(i + 1), n(i + 2), n(i + 3)) ? (c = z, i = me(t, i + 1)) : (c = O, i++);
break;
// U+005B LEFT SQUARE BRACKET ([)
case 91:
c = ee, i++;
break;
// U+005C REVERSE SOLIDUS (\)
case 92:
kt(h, n(i + 1)) ? s() : (c = O, 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 Gr:
r();
break;
// name-start code point
case Cn:
s();
break;
// EOF
// case EofCategory:
// Return an <EOF-token>.
// break;
// anything else
default:
c = O, i++;
}
e(c, u, u = i);
}
}
const Mn = 45;
function pa(t, e) {
return e = e || 0, t.length - e >= 2 && t.charCodeAt(e) === Mn && t.charCodeAt(e + 1) === Mn;
}
const cn = 92, Zr = 34, da = 39;
function ts(t) {
const e = t.length, n = t.charCodeAt(0), r = n === Zr || n === da ? 1 : 0, s = r === 1 && e > 1 && t.charCodeAt(e - 1) === n ? e - 2 : e - 1;
let o = "";
for (let a = r; a <= s; a++) {
let l = t.charCodeAt(a);
if (l === cn) {
if (a === s) {
a !== e - 1 && (o = t.substr(a + 1));
break;
}
if (l = t.charCodeAt(++a), kt(cn, l)) {
const u = a - 1, i = Jt(t, u);
a = i - 1, o += Yr(t.substring(u + 1, i));
} else
l === 13 && t.charCodeAt(a + 1) === 10 && a++;
} else
o += t[a];
}
return o;
}
function ga(t, e) {
const r = Zr;
let s = "", o = !1;
for (let a = 0; a < t.length; a++) {
const l = t.charCodeAt(a);
if (l === 0) {
s += "�";
continue;
}
if (l <= 31 || l === 127) {
s += "\\" + l.toString(16), o = !0;
continue;
}
l === r || l === cn ? (s += "\\" + t.charAt(a), o = !1) : (o && (Xt(l) || Ft(l)) && (s += " "), s += t.charAt(a), o = !1);
}
return '"' + s + '"';
}
const ma = 32, un = 92, ka = 34, Sa = 39, ya = 40, es = 41;
function ba(t) {
const e = t.length;
let n = 4, r = t.charCodeAt(e - 1) === es ? e - 2 : e - 1, s = "";
for (; n < r && Ft(t.charCodeAt(n)); )
n++;
for (; n < r && Ft(t.charCodeAt(r)); )
r--;
for (let o = n; o <= r; o++) {
let a = t.charCodeAt(o);
if (a === un) {
if (o === r) {
o !== e - 1 && (s = t.substr(o + 1));
break;
}
if (a = t.charCodeAt(++o), kt(un, a)) {
const l = o - 1, u = Jt(t, l);
o = u - 1, s += Yr(t.substring(l + 1, u));
} else
a === 13 && t.charCodeAt(o + 1) === 10 && o++;
} else
s += t[o];
}
return s;
}
function xa(t) {
let e = "", n = !1;
for (let r = 0; r < t.length; r++) {
const s = t.charCodeAt(r);
if (s === 0) {
e += "�";
continue;
}
if (s <= 31 || s === 127) {
e += "\\" + s.toString(16), n = !0;
continue;
}
s === ma || s === un || s === ka || s === Sa || s === ya || s === es ? (e += "\\" + t.charAt(r), n = !1) : (n && Xt(s) && (e += " "), e += t.charAt(r), n = !1);
}
return "url(" + e + ")";
}
const { hasOwnProperty: wn } = Object.prototype, ne = function() {
};
function jn(t) {
return typeof t == "function" ? t : ne;
}
function Bn(t, e) {
return function(n, r, s) {
n.type === e && t.call(this, n, r, s);
};
}
function Ca(t, e) {
const n = e.structure, r = [];
for (const s in n) {
if (wn.call(n, s) === !1)
continue;
let o = n[s];
const a = {
name: s,
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 && r.push(a);
}
return r.length ? {
context: e.walkContext,
fields: r
} : null;
}
function wa(t) {
const e = {};
for (const n in t.node)
if (wn.call(t.node, n)) {
const r = t.node[n];
if (!r.structure)
throw new Error("Missed `structure` field in `" + n + "` node type definition");
e[n] = Ca(n, r);
}
return e;
}
function Un(t, e) {
const n = t.fields.slice(), r = t.context, s = typeof r == "string";
return e && n.reverse(), function(o, a, l, u) {
let i;
s && (i = a[r], a[r] = 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;
}
}
s && (a[r] = i);
};
}
function Wn({
StyleSheet: t,
Atrule: e,
Rule: n,
Block: r,
DeclarationList: s
}) {
return {
Atrule: {
StyleSheet: t,
Atrule: e,
Rule: n,
Block: r
},
Rule: {
StyleSheet: t,
Atrule: e,
Rule: n,
Block: r
},
Declaration: {
StyleSheet: t,
Atrule: e,
Rule: n,
Block: r,
DeclarationList: s
}
};
}
function Aa(t) {
const e = wa(t), n = {}, r = {}, s = Symbol("break-walk"), o = Symbol("skip-node");
for (const i in e)
wn.call(e, i) && e[i] !== null && (n[i] = Un(e[i], !1), r[i] = Un(e[i], !0));
const a = Wn(n), l = Wn(r), u = function(i, c) {
function h(S, x, T) {
const M = f.call(k, S, x, T);
return M === s ? !0 : M === o ? !1 : !!(g.hasOwnProperty(S.type) && g[S.type](S, k, h, m) || p.call(k, S, x, T) === s);
}
let f = ne, p = ne, g = n, m = (S, x, T, M) => S || h(x, T, M);
const k = {
break: s,
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 = jn(c.enter), p = jn(c.leave), c.reverse && (g = r), 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 = Bn(f, c.visit), p = Bn(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 = s, 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, s;
}), 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, s;
}
}), 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, rt = 45, xe = 110, It = !0, Ta = !1;
function Ce(t, e) {
let n = this.tokenStart + t;
const r = this.charCodeAt(n);
for ((r === mt || r === rt) && (e && this.error("Number sign is not allowed"), n++); n < this.tokenEnd; n++)
st(this.charCodeAt(n)) || this.error("Integer is expected", n);
}
function Ht(t) {
return Ce.call(this, 0, t);
}
function Tt(t, e) {
if (!this.cmpChar(this.tokenStart + t, e)) {
let n = "";
switch (e) {
case xe:
n = "N is expected";
break;
case rt:
n = "HyphenMinus is expected";
break;
}
this.error(n, this.tokenStart + t);
}
}
function He() {
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(rt, t)) {
e = this.isDelim(mt, t) ? mt : rt;
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 !== rt && this.error("Number sign is expected")), Ht.call(this, e !== 0), e === rt ? "-" + this.consume(b) : this.consume(b);
}
const va = "AnPlusB", Ea = {
a: [String, null],
b: [String, null]
};
function ns() {
const t = this.tokenStart;
let e = null, n = null;
if (this.tokenType === b)
Ht.call(this, Ta), n = this.consume(b);
else if (this.tokenType === d && this.cmpChar(this.tokenStart, rt))
switch (e = "-1", Tt.call(this, 1, xe), this.tokenEnd - this.tokenStart) {
// -n
// -n <signed-integer>
// -n ['+' | '-'] <signless-integer>
case 2:
this.next(), n = He.call(this);
break;
// -n- <signless-integer>
case 3:
Tt.call(this, 2, rt), this.next(), this.skipSC(), Ht.call(this, It), n = "-" + this.consume(b);
break;
// <dashndashdigit-ident>
default:
Tt.call(this, 2, rt), Ce.call(this, 3, It), this.next(), n = this.substrToCursor(t + 2);
}
else if (this.tokenType === d || this.isDelim(mt) && this.lookupType(1) === d) {
let r = 0;
switch (e = "1", this.isDelim(mt) && (r = 1, this.next()), Tt.call(this, 0, xe), this.tokenEnd - this.tokenStart) {
// '+'? n
// '+'? n <signed-integer>
// '+'? n ['+' | '-'] <signless-integer>
case 1:
this.next(), n = He.call(this);
break;
// '+'? n- <signless-integer>
case 2:
Tt.call(this, 1, rt), this.next(), this.skipSC(), Ht.call(this, It), n = "-" + this.consume(b);
break;
// '+'? <ndashdigit-ident>
default:
Tt.call(this, 1, rt), Ce.call(this, 2, It), this.next(), n = this.substrToCursor(t + r + 1);
}
} else if (this.tokenType === E) {
const r = this.c