Skip to content

Instantly share code, notes, and snippets.

@ptgott
Last active November 22, 2020 18:33
Show Gist options
  • Save ptgott/347ed3996298c77892d7fd76c7228c41 to your computer and use it in GitHub Desktop.
Save ptgott/347ed3996298c77892d7fd76c7228c41 to your computer and use it in GitHub Desktop.
A userscript for managing discussions in Google Docs
// ==UserScript==
// @name Google Docs Comment Navigator
// @author Paul Gottschling and contributors
// @copyright Paul Gottschling
// @description Adds a UI component to Google Docs that searches, filters, and navigates between discussion threads.
// @include https://docs.google.com/document/d/*/edit
// @run-at document-end
// @grant none
// @source https://github.com/ptgott/comment-navigator
// @version 0.55
// ==/UserScript==
//
// MIT License
//
// Copyright (c) 2020 Paul Gottschling
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in all
// copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
// SOFTWARE.
!function(t) {
var e = {};
function i(s) {
if (e[s]) return e[s].exports;
var n = e[s] = {
i: s,
l: !1,
exports: {}
};
return t[s].call(n.exports, n, n.exports, i), n.l = !0, n.exports;
}
i.m = t, i.c = e, i.d = function(t, e, s) {
i.o(t, e) || Object.defineProperty(t, e, {
enumerable: !0,
get: s
});
}, i.r = function(t) {
"undefined" != typeof Symbol && Symbol.toStringTag && Object.defineProperty(t, Symbol.toStringTag, {
value: "Module"
}), Object.defineProperty(t, "__esModule", {
value: !0
});
}, i.t = function(t, e) {
if (1 & e && (t = i(t)), 8 & e) return t;
if (4 & e && "object" == typeof t && t && t.__esModule) return t;
var s = Object.create(null);
if (i.r(s), Object.defineProperty(s, "default", {
enumerable: !0,
value: t
}), 2 & e && "string" != typeof t) for (var n in t) i.d(s, n, function(e) {
return t[e];
}.bind(null, n));
return s;
}, i.n = function(t) {
var e = t && t.__esModule ? function() {
return t.default;
} : function() {
return t;
};
return i.d(e, "a", e), e;
}, i.o = function(t, e) {
return Object.prototype.hasOwnProperty.call(t, e);
}, i.p = "", i(i.s = 1);
}([ function(t, e, i) {
"use strict";
/*! @author Toru Nagashima <https://github.com/mysticatea> */ Object.defineProperty(e, "__esModule", {
value: !0
});
var s = Object.freeze({});
let n = void 0, r = void 0;
function a(t) {
return !(t < 48) && (t < 58 || !(t < 65) && (t < 91 || (95 === t || !(t < 97) && (t < 123 || (o(t) || function(t) {
return h(t, r || (r = l("183 0 585 111 24 0 252 4 266 44 2 0 2 1 2 1 2 0 73 10 49 30 7 0 102 6 3 5 3 1 2 3 3 9 24 0 31 26 92 10 16 9 34 8 10 0 25 3 2 8 2 2 2 4 44 2 120 14 2 32 55 2 2 17 2 6 11 1 3 9 18 2 57 0 2 6 3 1 3 2 10 0 11 1 3 9 15 0 3 2 57 0 2 4 5 1 3 2 4 0 21 11 4 0 12 2 57 0 2 7 2 2 2 2 21 1 3 9 11 5 2 2 57 0 2 6 3 1 3 2 8 2 11 1 3 9 19 0 60 4 4 2 2 3 10 0 15 9 17 4 58 6 2 2 2 3 8 1 12 1 3 9 18 2 57 0 2 6 2 2 2 3 8 1 12 1 3 9 17 3 56 1 2 6 2 2 2 3 10 0 11 1 3 9 18 2 71 0 5 5 2 0 2 7 7 9 3 1 62 0 3 6 13 7 2 9 88 0 3 8 12 5 3 9 63 1 7 9 12 0 2 0 2 0 5 1 50 19 2 1 6 10 2 35 10 0 101 19 2 9 13 3 5 2 2 2 3 6 4 3 14 11 2 14 704 2 10 8 929 2 30 2 30 1 31 1 65 31 10 0 3 9 34 2 3 9 144 0 119 11 5 11 11 9 129 10 61 4 58 9 2 28 3 10 7 9 23 13 2 1 64 4 48 16 12 9 18 8 13 2 31 12 3 9 45 13 49 19 9 9 7 9 119 2 2 20 5 0 7 0 3 2 199 57 2 4 576 1 20 0 124 12 5 0 4 11 3071 2 142 0 97 31 555 5 106 1 30086 9 70 0 5 9 33 1 81 1 273 0 4 0 5 0 24 4 5 0 84 1 51 17 11 9 7 17 14 10 29 7 26 12 45 3 48 13 16 9 12 0 11 9 48 13 13 0 9 1 3 9 34 2 51 0 2 2 3 1 6 1 2 0 42 4 6 1 237 7 2 1 3 9 20261 0 738 15 17 15 4 1 25 2 193 9 38 0 702 0 227 0 150 4 294 9 1368 2 2 1 6 3 41 2 5 0 166 1 574 3 9 9 370 1 154 10 176 2 54 14 32 9 16 3 46 10 54 9 7 2 37 13 2 9 6 1 45 0 13 2 49 13 9 3 2 11 83 11 7 0 161 11 6 9 7 3 56 1 2 6 3 1 3 2 10 0 11 1 3 6 4 4 193 17 10 9 5 0 82 19 13 9 214 6 3 8 28 1 83 16 16 9 82 12 9 9 84 14 5 9 243 14 166 9 71 5 2 1 3 3 2 0 2 1 13 9 120 6 3 6 4 0 29 9 41 6 2 3 9 0 10 10 47 15 406 7 2 7 17 9 57 21 2 13 123 5 4 0 2 1 2 6 2 0 9 9 49 4 2 1 2 4 9 9 330 3 19306 9 135 4 60 6 26 9 1014 0 2 54 8 3 82 0 12 1 19628 1 5319 4 4 5 9 7 3 6 31 3 149 2 1418 49 513 54 5 49 9 0 15 0 23 4 2 14 1361 6 2 16 3 6 2 1 2 4 262 6 10 9 419 13 1495 6 110 6 6 9 4759 9 787719 239")));
}(t))))));
}
function o(t) {
return h(t, n || (n = l("170 0 11 0 5 0 6 22 2 30 2 457 5 11 15 4 8 0 2 0 130 4 2 1 3 3 2 0 7 0 2 2 2 0 2 19 2 82 2 138 9 165 2 37 3 0 7 40 72 26 5 3 46 42 36 1 2 98 2 0 16 1 8 1 11 2 3 0 17 0 2 29 30 88 12 0 25 32 10 1 5 0 6 21 5 0 10 0 4 0 24 24 8 10 54 20 2 17 61 53 4 0 19 0 8 9 16 15 5 7 3 1 3 21 2 6 2 0 4 3 4 0 17 0 14 1 2 2 15 1 11 0 9 5 5 1 3 21 2 6 2 1 2 1 2 1 32 3 2 0 20 2 17 8 2 2 2 21 2 6 2 1 2 4 4 0 19 0 16 1 24 0 12 7 3 1 3 21 2 6 2 1 2 4 4 0 31 1 2 2 16 0 18 0 2 5 4 2 2 3 4 1 2 0 2 1 4 1 4 2 4 11 23 0 53 7 2 2 2 22 2 15 4 0 27 2 6 1 31 0 5 7 2 2 2 22 2 9 2 4 4 0 33 0 2 1 16 1 18 8 2 2 2 40 3 0 17 0 6 2 9 2 25 5 6 17 4 23 2 8 2 0 3 6 59 47 2 1 13 6 59 1 2 0 2 4 2 23 2 0 2 9 2 1 10 0 3 4 2 0 22 3 33 0 64 7 2 35 28 4 116 42 21 0 17 5 5 3 4 0 4 1 8 2 5 12 13 0 18 37 2 0 6 0 3 42 2 332 2 3 3 6 2 0 2 3 3 40 2 3 3 32 2 3 3 6 2 0 2 3 3 14 2 56 2 3 3 66 38 15 17 85 3 5 4 619 3 16 2 25 6 74 4 10 8 12 2 3 15 17 15 17 15 12 2 2 16 51 36 0 5 0 68 88 8 40 2 0 6 69 11 30 50 29 3 4 12 43 5 25 55 22 10 52 83 0 94 46 18 6 56 29 14 1 11 43 27 35 42 2 11 35 3 8 8 42 3 2 42 3 2 5 2 1 4 0 6 191 65 277 3 5 3 37 3 5 3 7 2 0 2 0 2 0 2 30 3 52 2 6 2 0 4 2 2 6 4 3 3 5 5 12 6 2 2 6 117 0 14 0 17 12 102 0 5 0 3 9 2 0 3 5 7 0 2 0 2 0 2 15 3 3 6 4 5 0 18 40 2680 46 2 46 2 132 7 3 4 1 13 37 2 0 6 0 3 55 8 0 17 22 10 6 2 6 2 6 2 6 2 6 2 6 2 6 2 6 551 2 26 8 8 4 3 4 5 85 5 4 2 89 2 3 6 42 2 93 18 31 49 15 513 6591 65 20988 4 1164 68 45 3 268 4 15 11 1 21 46 17 30 3 79 40 8 3 102 3 52 3 8 43 12 2 2 2 3 2 22 30 51 15 49 63 5 4 0 2 1 12 27 11 22 26 28 8 46 29 0 17 4 2 9 11 4 2 40 24 2 2 7 21 22 4 0 4 49 2 0 4 1 3 4 3 0 2 0 25 2 3 10 8 2 13 5 3 5 3 5 10 6 2 6 2 42 2 13 7 114 30 11171 13 22 5 48 8453 365 3 105 39 6 13 4 6 0 2 9 2 12 2 4 2 0 2 1 2 1 2 107 34 362 19 63 3 53 41 11 117 4 2 134 37 25 7 25 12 88 4 5 3 5 3 5 3 2 36 11 2 25 2 18 2 1 2 14 3 13 35 122 70 52 268 28 4 48 48 31 14 29 6 37 11 29 3 35 5 7 2 4 43 157 19 35 5 35 5 39 9 51 157 310 10 21 11 7 153 5 3 0 2 43 2 1 4 0 3 22 11 22 10 30 66 18 2 1 11 21 11 25 71 55 7 1 65 0 16 3 2 2 2 28 43 28 4 28 36 7 2 27 28 53 11 21 11 18 14 17 111 72 56 50 14 50 14 35 349 41 7 1 79 28 11 0 9 21 107 20 28 22 13 52 76 44 33 24 27 35 30 0 3 0 9 34 4 0 13 47 15 3 22 0 2 0 36 17 2 24 85 6 2 0 2 3 2 14 2 9 8 46 39 7 3 1 3 21 2 6 2 1 2 4 4 0 19 0 13 4 159 52 19 3 21 2 31 47 21 1 2 0 185 46 42 3 37 47 21 0 60 42 14 0 72 26 230 43 117 63 32 7 3 0 3 7 2 1 2 23 16 0 2 0 95 7 3 38 17 0 2 0 29 0 11 39 8 0 22 0 12 45 20 0 35 56 264 8 2 36 18 0 50 29 113 6 2 1 2 37 22 0 26 5 2 1 2 31 15 0 328 18 190 0 80 921 103 110 18 195 2749 1070 4050 582 8634 568 8 30 114 29 19 47 17 3 32 20 6 18 689 63 129 74 6 0 67 12 65 1 2 0 29 6135 9 1237 43 8 8952 286 50 2 18 3 9 395 2309 106 6 12 4 8 8 9 5991 84 2 70 2 1 3 0 3 1 3 3 2 11 2 0 2 6 2 64 2 3 3 7 2 6 2 27 2 3 2 4 2 0 4 6 2 339 3 24 2 24 2 30 2 24 2 30 2 24 2 30 2 24 2 30 2 24 2 7 2357 44 11 6 17 0 370 43 1301 196 60 67 8 0 1205 3 2 26 2 1 2 0 3 0 2 9 2 3 2 0 2 0 7 0 5 0 2 0 2 0 2 2 2 1 2 0 3 0 2 0 2 0 2 0 2 0 2 1 2 0 3 3 2 6 2 3 2 3 2 0 2 9 2 16 6 2 2 4 2 16 4421 42717 35 4148 12 221 3 5761 15 7472 3104 541 1507 4938")));
}
function h(t, e) {
let i = 0, s = e.length / 2 | 0, n = 0, r = 0, a = 0;
for (;i < s; ) if (n = (i + s) / 2 | 0, r = e[2 * n], a = e[2 * n + 1], t < r) s = n; else {
if (!(t > a)) return !0;
i = n + 1;
}
return !1;
}
function l(t) {
let e = 0;
return t.split(" ").map(t => e += 0 | parseInt(t, 10));
}
class c {
constructor(t, e, i) {
this._raw2018 = t, this._raw2019 = e, this._raw2020 = i;
}
get es2018() {
return this._set2018 || (this._set2018 = new Set(this._raw2018.split(" ")));
}
get es2019() {
return this._set2019 || (this._set2019 = new Set(this._raw2019.split(" ")));
}
get es2020() {
return this._set2020 || (this._set2020 = new Set(this._raw2020.split(" ")));
}
}
const u = new Set([ "General_Category", "gc" ]), d = new Set([ "Script", "Script_Extensions", "sc", "scx" ]), p = new c("C Cased_Letter Cc Cf Close_Punctuation Cn Co Combining_Mark Connector_Punctuation Control Cs Currency_Symbol Dash_Punctuation Decimal_Number Enclosing_Mark Final_Punctuation Format Initial_Punctuation L LC Letter Letter_Number Line_Separator Ll Lm Lo Lowercase_Letter Lt Lu M Mark Math_Symbol Mc Me Mn Modifier_Letter Modifier_Symbol N Nd Nl No Nonspacing_Mark Number Open_Punctuation Other Other_Letter Other_Number Other_Punctuation Other_Symbol P Paragraph_Separator Pc Pd Pe Pf Pi Po Private_Use Ps Punctuation S Sc Separator Sk Sm So Space_Separator Spacing_Mark Surrogate Symbol Titlecase_Letter Unassigned Uppercase_Letter Z Zl Zp Zs cntrl digit punct", "", ""), _ = new c("Adlam Adlm Aghb Ahom Anatolian_Hieroglyphs Arab Arabic Armenian Armi Armn Avestan Avst Bali Balinese Bamu Bamum Bass Bassa_Vah Batak Batk Beng Bengali Bhaiksuki Bhks Bopo Bopomofo Brah Brahmi Brai Braille Bugi Buginese Buhd Buhid Cakm Canadian_Aboriginal Cans Cari Carian Caucasian_Albanian Chakma Cham Cher Cherokee Common Copt Coptic Cprt Cuneiform Cypriot Cyrillic Cyrl Deseret Deva Devanagari Dsrt Dupl Duployan Egyp Egyptian_Hieroglyphs Elba Elbasan Ethi Ethiopic Geor Georgian Glag Glagolitic Gonm Goth Gothic Gran Grantha Greek Grek Gujarati Gujr Gurmukhi Guru Han Hang Hangul Hani Hano Hanunoo Hatr Hatran Hebr Hebrew Hira Hiragana Hluw Hmng Hung Imperial_Aramaic Inherited Inscriptional_Pahlavi Inscriptional_Parthian Ital Java Javanese Kaithi Kali Kana Kannada Katakana Kayah_Li Khar Kharoshthi Khmer Khmr Khoj Khojki Khudawadi Knda Kthi Lana Lao Laoo Latin Latn Lepc Lepcha Limb Limbu Lina Linb Linear_A Linear_B Lisu Lyci Lycian Lydi Lydian Mahajani Mahj Malayalam Mand Mandaic Mani Manichaean Marc Marchen Masaram_Gondi Meetei_Mayek Mend Mende_Kikakui Merc Mero Meroitic_Cursive Meroitic_Hieroglyphs Miao Mlym Modi Mong Mongolian Mro Mroo Mtei Mult Multani Myanmar Mymr Nabataean Narb Nbat New_Tai_Lue Newa Nko Nkoo Nshu Nushu Ogam Ogham Ol_Chiki Olck Old_Hungarian Old_Italic Old_North_Arabian Old_Permic Old_Persian Old_South_Arabian Old_Turkic Oriya Orkh Orya Osage Osge Osma Osmanya Pahawh_Hmong Palm Palmyrene Pau_Cin_Hau Pauc Perm Phag Phags_Pa Phli Phlp Phnx Phoenician Plrd Prti Psalter_Pahlavi Qaac Qaai Rejang Rjng Runic Runr Samaritan Samr Sarb Saur Saurashtra Sgnw Sharada Shavian Shaw Shrd Sidd Siddham SignWriting Sind Sinh Sinhala Sora Sora_Sompeng Soyo Soyombo Sund Sundanese Sylo Syloti_Nagri Syrc Syriac Tagalog Tagb Tagbanwa Tai_Le Tai_Tham Tai_Viet Takr Takri Tale Talu Tamil Taml Tang Tangut Tavt Telu Telugu Tfng Tglg Thaa Thaana Thai Tibetan Tibt Tifinagh Tirh Tirhuta Ugar Ugaritic Vai Vaii Wara Warang_Citi Xpeo Xsux Yi Yiii Zanabazar_Square Zanb Zinh Zyyy", "Dogr Dogra Gong Gunjala_Gondi Hanifi_Rohingya Maka Makasar Medefaidrin Medf Old_Sogdian Rohg Sogd Sogdian Sogo", "Elym Elymaic Hmnp Nand Nandinagari Nyiakeng_Puachue_Hmong Wancho Wcho"), m = new c("AHex ASCII ASCII_Hex_Digit Alpha Alphabetic Any Assigned Bidi_C Bidi_Control Bidi_M Bidi_Mirrored CI CWCF CWCM CWKCF CWL CWT CWU Case_Ignorable Cased Changes_When_Casefolded Changes_When_Casemapped Changes_When_Lowercased Changes_When_NFKC_Casefolded Changes_When_Titlecased Changes_When_Uppercased DI Dash Default_Ignorable_Code_Point Dep Deprecated Dia Diacritic Emoji Emoji_Component Emoji_Modifier Emoji_Modifier_Base Emoji_Presentation Ext Extender Gr_Base Gr_Ext Grapheme_Base Grapheme_Extend Hex Hex_Digit IDC IDS IDSB IDST IDS_Binary_Operator IDS_Trinary_Operator ID_Continue ID_Start Ideo Ideographic Join_C Join_Control LOE Logical_Order_Exception Lower Lowercase Math NChar Noncharacter_Code_Point Pat_Syn Pat_WS Pattern_Syntax Pattern_White_Space QMark Quotation_Mark RI Radical Regional_Indicator SD STerm Sentence_Terminal Soft_Dotted Term Terminal_Punctuation UIdeo Unified_Ideograph Upper Uppercase VS Variation_Selector White_Space XIDC XIDS XID_Continue XID_Start space", "Extended_Pictographic", "");
function g(t, e, i) {
return u.has(e) ? t >= 2018 && p.es2018.has(i) : !!d.has(e) && (t >= 2018 && _.es2018.has(i) || t >= 2019 && _.es2019.has(i) || t >= 2020 && _.es2020.has(i));
}
function f(t) {
return t >= 65 && t <= 90 || t >= 97 && t <= 122;
}
function C(t) {
return t >= 48 && t <= 57;
}
function v(t) {
return t >= 48 && t <= 57 || t >= 65 && t <= 70 || t >= 97 && t <= 102;
}
function w(t) {
return t >= 97 && t <= 102 ? t - 97 + 10 : t >= 65 && t <= 70 ? t - 65 + 10 : t - 48;
}
function x(t) {
return t >= 55296 && t <= 56319;
}
function y(t) {
return t >= 56320 && t <= 57343;
}
function E(t, e) {
return 1024 * (t - 55296) + (e - 56320) + 65536;
}
const P = {
at: (t, e, i) => i < e ? t.charCodeAt(i) : -1,
width: t => 1
}, S = {
at: (t, e, i) => i < e ? t.codePointAt(i) : -1,
width: t => t > 65535 ? 2 : 1
};
class I {
constructor() {
this._impl = P, this._s = "", this._i = 0, this._end = 0, this._cp1 = -1, this._w1 = 1,
this._cp2 = -1, this._w2 = 1, this._cp3 = -1, this._w3 = 1, this._cp4 = -1;
}
get source() {
return this._s;
}
get index() {
return this._i;
}
get currentCodePoint() {
return this._cp1;
}
get nextCodePoint() {
return this._cp2;
}
get nextCodePoint2() {
return this._cp3;
}
get nextCodePoint3() {
return this._cp4;
}
reset(t, e, i, s) {
this._impl = s ? S : P, this._s = t, this._end = i, this.rewind(e);
}
rewind(t) {
const e = this._impl;
this._i = t, this._cp1 = e.at(this._s, this._end, t), this._w1 = e.width(this._cp1),
this._cp2 = e.at(this._s, this._end, t + this._w1), this._w2 = e.width(this._cp2),
this._cp3 = e.at(this._s, this._end, t + this._w1 + this._w2), this._w3 = e.width(this._cp3),
this._cp4 = e.at(this._s, this._end, t + this._w1 + this._w2 + this._w3);
}
advance() {
if (-1 !== this._cp1) {
const t = this._impl;
this._i += this._w1, this._cp1 = this._cp2, this._w1 = this._w2, this._cp2 = this._cp3,
this._w2 = t.width(this._cp2), this._cp3 = this._cp4, this._w3 = t.width(this._cp3),
this._cp4 = t.at(this._s, this._end, this._i + this._w1 + this._w2 + this._w3);
}
}
eat(t) {
return this._cp1 === t && (this.advance(), !0);
}
eat2(t, e) {
return this._cp1 === t && this._cp2 === e && (this.advance(), this.advance(), !0);
}
eat3(t, e, i) {
return this._cp1 === t && this._cp2 === e && this._cp3 === i && (this.advance(),
this.advance(), this.advance(), !0);
}
}
class L extends SyntaxError {
constructor(t, e, i, s) {
t && (t.startsWith("/") || (t = `/${t}/${e ? "u" : ""}`), t = ": " + t), super(`Invalid regular expression${t}: ${s}`),
this.index = i;
}
}
function A(t) {
return 94 === t || 36 === t || 92 === t || 46 === t || 42 === t || 43 === t || 63 === t || 40 === t || 41 === t || 91 === t || 93 === t || 123 === t || 125 === t || 124 === t;
}
function b(t) {
return function(t) {
return !(t < 65) && (t < 91 || !(t < 97) && (t < 123 || o(t)));
}(t) || 36 === t || 95 === t;
}
function V(t) {
return f(t) || 95 === t;
}
class k {
constructor(t) {
this._reader = new I, this._uFlag = !1, this._nFlag = !1, this._lastIntValue = 0,
this._lastMinValue = 0, this._lastMaxValue = 0, this._lastStrValue = "", this._lastKeyValue = "",
this._lastValValue = "", this._lastAssertionIsQuantifiable = !1, this._numCapturingParens = 0,
this._groupNames = new Set, this._backreferenceNames = new Set, this._options = t || {};
}
validateLiteral(t, e = 0, i = t.length) {
if (this._uFlag = this._nFlag = !1, this.reset(t, e, i), this.onLiteralEnter(e),
this.eat(47) && this.eatRegExpBody() && this.eat(47)) {
const s = this.index, n = t.includes("u", s);
this.validateFlags(t, s, i), this.validatePattern(t, e + 1, s - 1, n);
} else if (e >= i) this.raise("Empty"); else {
const t = String.fromCodePoint(this.currentCodePoint);
this.raise(`Unexpected character '${t}'`);
}
this.onLiteralLeave(e, i);
}
validateFlags(t, e = 0, i = t.length) {
const s = new Set;
let n = !1, r = !1, a = !1, o = !1, h = !1, l = !1;
for (let c = e; c < i; ++c) {
const e = t.charCodeAt(c);
s.has(e) && this.raise(`Duplicated flag '${t[c]}'`), s.add(e), 103 === e ? n = !0 : 105 === e ? r = !0 : 109 === e ? a = !0 : 117 === e && this.ecmaVersion >= 2015 ? h = !0 : 121 === e && this.ecmaVersion >= 2015 ? o = !0 : 115 === e && this.ecmaVersion >= 2018 ? l = !0 : this.raise(`Invalid flag '${t[c]}'`);
}
this.onFlags(e, i, n, r, a, h, o, l);
}
validatePattern(t, e = 0, i = t.length, s = !1) {
this._uFlag = s && this.ecmaVersion >= 2015, this._nFlag = s && this.ecmaVersion >= 2018,
this.reset(t, e, i), this.consumePattern(), !this._nFlag && this.ecmaVersion >= 2018 && this._groupNames.size > 0 && (this._nFlag = !0,
this.rewind(e), this.consumePattern());
}
get strict() {
return Boolean(this._options.strict || this._uFlag);
}
get ecmaVersion() {
return this._options.ecmaVersion || 2020;
}
onLiteralEnter(t) {
this._options.onLiteralEnter && this._options.onLiteralEnter(t);
}
onLiteralLeave(t, e) {
this._options.onLiteralLeave && this._options.onLiteralLeave(t, e);
}
onFlags(t, e, i, s, n, r, a, o) {
this._options.onFlags && this._options.onFlags(t, e, i, s, n, r, a, o);
}
onPatternEnter(t) {
this._options.onPatternEnter && this._options.onPatternEnter(t);
}
onPatternLeave(t, e) {
this._options.onPatternLeave && this._options.onPatternLeave(t, e);
}
onDisjunctionEnter(t) {
this._options.onDisjunctionEnter && this._options.onDisjunctionEnter(t);
}
onDisjunctionLeave(t, e) {
this._options.onDisjunctionLeave && this._options.onDisjunctionLeave(t, e);
}
onAlternativeEnter(t, e) {
this._options.onAlternativeEnter && this._options.onAlternativeEnter(t, e);
}
onAlternativeLeave(t, e, i) {
this._options.onAlternativeLeave && this._options.onAlternativeLeave(t, e, i);
}
onGroupEnter(t) {
this._options.onGroupEnter && this._options.onGroupEnter(t);
}
onGroupLeave(t, e) {
this._options.onGroupLeave && this._options.onGroupLeave(t, e);
}
onCapturingGroupEnter(t, e) {
this._options.onCapturingGroupEnter && this._options.onCapturingGroupEnter(t, e);
}
onCapturingGroupLeave(t, e, i) {
this._options.onCapturingGroupLeave && this._options.onCapturingGroupLeave(t, e, i);
}
onQuantifier(t, e, i, s, n) {
this._options.onQuantifier && this._options.onQuantifier(t, e, i, s, n);
}
onLookaroundAssertionEnter(t, e, i) {
this._options.onLookaroundAssertionEnter && this._options.onLookaroundAssertionEnter(t, e, i);
}
onLookaroundAssertionLeave(t, e, i, s) {
this._options.onLookaroundAssertionLeave && this._options.onLookaroundAssertionLeave(t, e, i, s);
}
onEdgeAssertion(t, e, i) {
this._options.onEdgeAssertion && this._options.onEdgeAssertion(t, e, i);
}
onWordBoundaryAssertion(t, e, i, s) {
this._options.onWordBoundaryAssertion && this._options.onWordBoundaryAssertion(t, e, i, s);
}
onAnyCharacterSet(t, e, i) {
this._options.onAnyCharacterSet && this._options.onAnyCharacterSet(t, e, i);
}
onEscapeCharacterSet(t, e, i, s) {
this._options.onEscapeCharacterSet && this._options.onEscapeCharacterSet(t, e, i, s);
}
onUnicodePropertyCharacterSet(t, e, i, s, n, r) {
this._options.onUnicodePropertyCharacterSet && this._options.onUnicodePropertyCharacterSet(t, e, i, s, n, r);
}
onCharacter(t, e, i) {
this._options.onCharacter && this._options.onCharacter(t, e, i);
}
onBackreference(t, e, i) {
this._options.onBackreference && this._options.onBackreference(t, e, i);
}
onCharacterClassEnter(t, e) {
this._options.onCharacterClassEnter && this._options.onCharacterClassEnter(t, e);
}
onCharacterClassLeave(t, e, i) {
this._options.onCharacterClassLeave && this._options.onCharacterClassLeave(t, e, i);
}
onCharacterClassRange(t, e, i, s) {
this._options.onCharacterClassRange && this._options.onCharacterClassRange(t, e, i, s);
}
get source() {
return this._reader.source;
}
get index() {
return this._reader.index;
}
get currentCodePoint() {
return this._reader.currentCodePoint;
}
get nextCodePoint() {
return this._reader.nextCodePoint;
}
get nextCodePoint2() {
return this._reader.nextCodePoint2;
}
get nextCodePoint3() {
return this._reader.nextCodePoint3;
}
reset(t, e, i) {
this._reader.reset(t, e, i, this._uFlag);
}
rewind(t) {
this._reader.rewind(t);
}
advance() {
this._reader.advance();
}
eat(t) {
return this._reader.eat(t);
}
eat2(t, e) {
return this._reader.eat2(t, e);
}
eat3(t, e, i) {
return this._reader.eat3(t, e, i);
}
raise(t) {
throw new L(this.source, this._uFlag, this.index, t);
}
eatRegExpBody() {
const t = this.index;
let e = !1, i = !1;
for (;;) {
const n = this.currentCodePoint;
if (-1 === n || (10 === (s = n) || 13 === s || 8232 === s || 8233 === s)) {
const t = e ? "character class" : "regular expression";
this.raise("Unterminated " + t);
}
if (i) i = !1; else if (92 === n) i = !0; else if (91 === n) e = !0; else if (93 === n) e = !1; else if (47 === n && !e || 42 === n && this.index === t) break;
this.advance();
}
var s;
return this.index !== t;
}
consumePattern() {
const t = this.index;
this._numCapturingParens = this.countCapturingParens(), this._groupNames.clear(),
this._backreferenceNames.clear(), this.onPatternEnter(t), this.consumeDisjunction();
const e = this.currentCodePoint;
if (-1 !== this.currentCodePoint) {
41 === e && this.raise("Unmatched ')'"), 92 === e && this.raise("\\ at end of pattern"),
93 !== e && 125 !== e || this.raise("Lone quantifier brackets");
const t = String.fromCodePoint(e);
this.raise(`Unexpected character '${t}'`);
}
for (const t of this._backreferenceNames) this._groupNames.has(t) || this.raise("Invalid named capture referenced");
this.onPatternLeave(t, this.index);
}
countCapturingParens() {
const t = this.index;
let e = !1, i = !1, s = 0, n = 0;
for (;-1 !== (n = this.currentCodePoint); ) i ? i = !1 : 92 === n ? i = !0 : 91 === n ? e = !0 : 93 === n ? e = !1 : 40 !== n || e || 63 === this.nextCodePoint && (60 !== this.nextCodePoint2 || 61 === this.nextCodePoint3 || 33 === this.nextCodePoint3) || (s += 1),
this.advance();
return this.rewind(t), s;
}
consumeDisjunction() {
const t = this.index;
let e = 0;
this.onDisjunctionEnter(t);
do {
this.consumeAlternative(e++);
} while (this.eat(124));
this.consumeQuantifier(!0) && this.raise("Nothing to repeat"), this.eat(123) && this.raise("Lone quantifier brackets"),
this.onDisjunctionLeave(t, this.index);
}
consumeAlternative(t) {
const e = this.index;
for (this.onAlternativeEnter(e, t); -1 !== this.currentCodePoint && this.consumeTerm(); ) ;
this.onAlternativeLeave(e, this.index, t);
}
consumeTerm() {
return this._uFlag || this.strict ? this.consumeAssertion() || this.consumeAtom() && this.consumeOptionalQuantifier() : this.consumeAssertion() && (!this._lastAssertionIsQuantifiable || this.consumeOptionalQuantifier()) || this.consumeExtendedAtom() && this.consumeOptionalQuantifier();
}
consumeOptionalQuantifier() {
return this.consumeQuantifier(), !0;
}
consumeAssertion() {
const t = this.index;
if (this._lastAssertionIsQuantifiable = !1, this.eat(94)) return this.onEdgeAssertion(t, this.index, "start"),
!0;
if (this.eat(36)) return this.onEdgeAssertion(t, this.index, "end"), !0;
if (this.eat2(92, 66)) return this.onWordBoundaryAssertion(t, this.index, "word", !0),
!0;
if (this.eat2(92, 98)) return this.onWordBoundaryAssertion(t, this.index, "word", !1),
!0;
if (this.eat2(40, 63)) {
const e = this.ecmaVersion >= 2018 && this.eat(60);
let i = !1;
if (this.eat(61) || (i = this.eat(33))) {
const s = e ? "lookbehind" : "lookahead";
return this.onLookaroundAssertionEnter(t, s, i), this.consumeDisjunction(), this.eat(41) || this.raise("Unterminated group"),
this._lastAssertionIsQuantifiable = !e && !this.strict, this.onLookaroundAssertionLeave(t, this.index, s, i),
!0;
}
this.rewind(t);
}
return !1;
}
consumeQuantifier(t = !1) {
const e = this.index;
let i = 0, s = 0, n = !1;
if (this.eat(42)) i = 0, s = Number.POSITIVE_INFINITY; else if (this.eat(43)) i = 1,
s = Number.POSITIVE_INFINITY; else if (this.eat(63)) i = 0, s = 1; else {
if (!this.eatBracedQuantifier(t)) return !1;
i = this._lastMinValue, s = this._lastMaxValue;
}
return n = !this.eat(63), t || this.onQuantifier(e, this.index, i, s, n), !0;
}
eatBracedQuantifier(t) {
const e = this.index;
if (this.eat(123)) {
if (this._lastMinValue = 0, this._lastMaxValue = Number.POSITIVE_INFINITY, this.eatDecimalDigits() && (this._lastMinValue = this._lastMaxValue = this._lastIntValue,
this.eat(44) && (this._lastMaxValue = this.eatDecimalDigits() ? this._lastIntValue : Number.POSITIVE_INFINITY),
this.eat(125))) return !t && this._lastMaxValue < this._lastMinValue && this.raise("numbers out of order in {} quantifier"),
!0;
t || !this._uFlag && !this.strict || this.raise("Incomplete quantifier"), this.rewind(e);
}
return !1;
}
consumeAtom() {
return this.consumePatternCharacter() || this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeCharacterClass() || this.consumeUncapturingGroup() || this.consumeCapturingGroup();
}
consumeDot() {
return !!this.eat(46) && (this.onAnyCharacterSet(this.index - 1, this.index, "any"),
!0);
}
consumeReverseSolidusAtomEscape() {
const t = this.index;
if (this.eat(92)) {
if (this.consumeAtomEscape()) return !0;
this.rewind(t);
}
return !1;
}
consumeUncapturingGroup() {
const t = this.index;
return !!this.eat3(40, 63, 58) && (this.onGroupEnter(t), this.consumeDisjunction(),
this.eat(41) || this.raise("Unterminated group"), this.onGroupLeave(t, this.index),
!0);
}
consumeCapturingGroup() {
const t = this.index;
if (this.eat(40)) {
let e = null;
return this.ecmaVersion >= 2018 ? this.consumeGroupSpecifier() && (e = this._lastStrValue) : 63 === this.currentCodePoint && this.raise("Invalid group"),
this.onCapturingGroupEnter(t, e), this.consumeDisjunction(), this.eat(41) || this.raise("Unterminated group"),
this.onCapturingGroupLeave(t, this.index, e), !0;
}
return !1;
}
consumeExtendedAtom() {
return this.consumeDot() || this.consumeReverseSolidusAtomEscape() || this.consumeReverseSolidusFollowedByC() || this.consumeCharacterClass() || this.consumeUncapturingGroup() || this.consumeCapturingGroup() || this.consumeInvalidBracedQuantifier() || this.consumeExtendedPatternCharacter();
}
consumeReverseSolidusFollowedByC() {
const t = this.index;
return 92 === this.currentCodePoint && 99 === this.nextCodePoint && (this._lastIntValue = this.currentCodePoint,
this.advance(), this.onCharacter(t, this.index, 92), !0);
}
consumeInvalidBracedQuantifier() {
return this.eatBracedQuantifier(!0) && this.raise("Nothing to repeat"), !1;
}
consumePatternCharacter() {
const t = this.index, e = this.currentCodePoint;
return -1 !== e && !A(e) && (this.advance(), this.onCharacter(t, this.index, e),
!0);
}
consumeExtendedPatternCharacter() {
const t = this.index, e = this.currentCodePoint;
return -1 !== e && 94 !== e && 36 !== e && 92 !== e && 46 !== e && 42 !== e && 43 !== e && 63 !== e && 40 !== e && 41 !== e && 91 !== e && 124 !== e && (this.advance(),
this.onCharacter(t, this.index, e), !0);
}
consumeGroupSpecifier() {
if (this.eat(63)) {
if (this.eatGroupName()) {
if (!this._groupNames.has(this._lastStrValue)) return this._groupNames.add(this._lastStrValue),
!0;
this.raise("Duplicate capture group name");
}
this.raise("Invalid group");
}
return !1;
}
consumeAtomEscape() {
return !!(this.consumeBackreference() || this.consumeCharacterClassEscape() || this.consumeCharacterEscape() || this._nFlag && this.consumeKGroupName()) || ((this.strict || this._uFlag) && this.raise("Invalid escape"),
!1);
}
consumeBackreference() {
const t = this.index;
if (this.eatDecimalEscape()) {
const e = this._lastIntValue;
if (e <= this._numCapturingParens) return this.onBackreference(t - 1, this.index, e),
!0;
(this.strict || this._uFlag) && this.raise("Invalid escape"), this.rewind(t);
}
return !1;
}
consumeCharacterClassEscape() {
const t = this.index;
if (this.eat(100)) return this._lastIntValue = -1, this.onEscapeCharacterSet(t - 1, this.index, "digit", !1),
!0;
if (this.eat(68)) return this._lastIntValue = -1, this.onEscapeCharacterSet(t - 1, this.index, "digit", !0),
!0;
if (this.eat(115)) return this._lastIntValue = -1, this.onEscapeCharacterSet(t - 1, this.index, "space", !1),
!0;
if (this.eat(83)) return this._lastIntValue = -1, this.onEscapeCharacterSet(t - 1, this.index, "space", !0),
!0;
if (this.eat(119)) return this._lastIntValue = -1, this.onEscapeCharacterSet(t - 1, this.index, "word", !1),
!0;
if (this.eat(87)) return this._lastIntValue = -1, this.onEscapeCharacterSet(t - 1, this.index, "word", !0),
!0;
let e = !1;
if (this._uFlag && this.ecmaVersion >= 2018 && (this.eat(112) || (e = this.eat(80)))) {
if (this._lastIntValue = -1, this.eat(123) && this.eatUnicodePropertyValueExpression() && this.eat(125)) return this.onUnicodePropertyCharacterSet(t - 1, this.index, "property", this._lastKeyValue, this._lastValValue || null, e),
!0;
this.raise("Invalid property name");
}
return !1;
}
consumeCharacterEscape() {
const t = this.index;
return !!(this.eatControlEscape() || this.eatCControlLetter() || this.eatZero() || this.eatHexEscapeSequence() || this.eatRegExpUnicodeEscapeSequence() || !this.strict && !this._uFlag && this.eatLegacyOctalEscapeSequence() || this.eatIdentityEscape()) && (this.onCharacter(t - 1, this.index, this._lastIntValue),
!0);
}
consumeKGroupName() {
const t = this.index;
if (this.eat(107)) {
if (this.eatGroupName()) {
const e = this._lastStrValue;
return this._backreferenceNames.add(e), this.onBackreference(t - 1, this.index, e),
!0;
}
this.raise("Invalid named reference");
}
return !1;
}
consumeCharacterClass() {
const t = this.index;
if (this.eat(91)) {
const e = this.eat(94);
return this.onCharacterClassEnter(t, e), this.consumeClassRanges(), this.eat(93) || this.raise("Unterminated character class"),
this.onCharacterClassLeave(t, this.index, e), !0;
}
return !1;
}
consumeClassRanges() {
const t = this.strict || this._uFlag;
for (;;) {
const e = this.index;
if (!this.consumeClassAtom()) break;
const i = this._lastIntValue;
if (!this.eat(45)) continue;
if (this.onCharacter(this.index - 1, this.index, 45), !this.consumeClassAtom()) break;
const s = this._lastIntValue;
-1 !== i && -1 !== s ? (i > s && this.raise("Range out of order in character class"),
this.onCharacterClassRange(e, this.index, i, s)) : t && this.raise("Invalid character class");
}
}
consumeClassAtom() {
const t = this.index, e = this.currentCodePoint;
if (-1 !== e && 92 !== e && 93 !== e) return this.advance(), this._lastIntValue = e,
this.onCharacter(t, this.index, this._lastIntValue), !0;
if (this.eat(92)) {
if (this.consumeClassEscape()) return !0;
if (!this.strict && 99 === this.currentCodePoint) return this._lastIntValue = 92,
this.onCharacter(t, this.index, this._lastIntValue), !0;
(this.strict || this._uFlag) && this.raise("Invalid escape"), this.rewind(t);
}
return !1;
}
consumeClassEscape() {
const t = this.index;
if (this.eat(98)) return this._lastIntValue = 8, this.onCharacter(t - 1, this.index, this._lastIntValue),
!0;
if (this._uFlag && this.eat(45)) return this._lastIntValue = 45, this.onCharacter(t - 1, this.index, this._lastIntValue),
!0;
let e = 0;
return this.strict || this._uFlag || 99 !== this.currentCodePoint || !C(e = this.nextCodePoint) && 95 !== e ? this.consumeCharacterClassEscape() || this.consumeCharacterEscape() : (this.advance(),
this.advance(), this._lastIntValue = e % 32, this.onCharacter(t - 1, this.index, this._lastIntValue),
!0);
}
eatGroupName() {
if (this.eat(60)) {
if (this.eatRegExpIdentifierName() && this.eat(62)) return !0;
this.raise("Invalid capture group name");
}
return !1;
}
eatRegExpIdentifierName() {
if (this.eatRegExpIdentifierStart()) {
for (this._lastStrValue = String.fromCodePoint(this._lastIntValue); this.eatRegExpIdentifierPart(); ) this._lastStrValue += String.fromCodePoint(this._lastIntValue);
return !0;
}
return !1;
}
eatRegExpIdentifierStart() {
const t = this.index, e = !this._uFlag && this.ecmaVersion >= 2020;
let i = this.currentCodePoint;
return this.advance(), 92 === i && this.eatRegExpUnicodeEscapeSequence(e) ? i = this._lastIntValue : e && x(i) && y(this.currentCodePoint) && (i = E(i, this.currentCodePoint),
this.advance()), b(i) ? (this._lastIntValue = i, !0) : (this.index !== t && this.rewind(t),
!1);
}
eatRegExpIdentifierPart() {
const t = this.index, e = !this._uFlag && this.ecmaVersion >= 2020;
let i = this.currentCodePoint;
return this.advance(), 92 === i && this.eatRegExpUnicodeEscapeSequence(e) ? i = this._lastIntValue : e && x(i) && y(this.currentCodePoint) && (i = E(i, this.currentCodePoint),
this.advance()), function(t) {
return a(t) || 36 === t || 95 === t || 8204 === t || 8205 === t;
}(i) ? (this._lastIntValue = i, !0) : (this.index !== t && this.rewind(t), !1);
}
eatCControlLetter() {
const t = this.index;
if (this.eat(99)) {
if (this.eatControlLetter()) return !0;
this.rewind(t);
}
return !1;
}
eatZero() {
return 48 === this.currentCodePoint && !C(this.nextCodePoint) && (this._lastIntValue = 0,
this.advance(), !0);
}
eatControlEscape() {
return this.eat(102) ? (this._lastIntValue = 12, !0) : this.eat(110) ? (this._lastIntValue = 10,
!0) : this.eat(114) ? (this._lastIntValue = 13, !0) : this.eat(116) ? (this._lastIntValue = 9,
!0) : !!this.eat(118) && (this._lastIntValue = 11, !0);
}
eatControlLetter() {
const t = this.currentCodePoint;
return !!f(t) && (this.advance(), this._lastIntValue = t % 32, !0);
}
eatRegExpUnicodeEscapeSequence(t = !1) {
const e = this.index, i = t || this._uFlag;
if (this.eat(117)) {
if (i && this.eatRegExpUnicodeSurrogatePairEscape() || this.eatFixedHexDigits(4) || i && this.eatRegExpUnicodeCodePointEscape()) return !0;
(this.strict || i) && this.raise("Invalid unicode escape"), this.rewind(e);
}
return !1;
}
eatRegExpUnicodeSurrogatePairEscape() {
const t = this.index;
if (this.eatFixedHexDigits(4)) {
const e = this._lastIntValue;
if (x(e) && this.eat(92) && this.eat(117) && this.eatFixedHexDigits(4)) {
const t = this._lastIntValue;
if (y(t)) return this._lastIntValue = E(e, t), !0;
}
this.rewind(t);
}
return !1;
}
eatRegExpUnicodeCodePointEscape() {
const t = this.index;
return !!(this.eat(123) && this.eatHexDigits() && this.eat(125) && ((e = this._lastIntValue) >= 0 && e <= 1114111)) || (this.rewind(t),
!1);
var e;
}
eatIdentityEscape() {
const t = this.currentCodePoint;
return !!this.isValidIdentityEscape(t) && (this._lastIntValue = t, this.advance(),
!0);
}
isValidIdentityEscape(t) {
return -1 !== t && (this._uFlag ? A(t) || 47 === t : this.strict ? !a(t) : this._nFlag ? !(99 === t || 107 === t) : 99 !== t);
}
eatDecimalEscape() {
this._lastIntValue = 0;
let t = this.currentCodePoint;
if (t >= 49 && t <= 57) {
do {
this._lastIntValue = 10 * this._lastIntValue + (t - 48), this.advance();
} while ((t = this.currentCodePoint) >= 48 && t <= 57);
return !0;
}
return !1;
}
eatUnicodePropertyValueExpression() {
const t = this.index;
if (this.eatUnicodePropertyName() && this.eat(61) && (this._lastKeyValue = this._lastStrValue,
this.eatUnicodePropertyValue())) {
if (this._lastValValue = this._lastStrValue, g(this.ecmaVersion, this._lastKeyValue, this._lastValValue)) return !0;
this.raise("Invalid property name");
}
if (this.rewind(t), this.eatLoneUnicodePropertyNameOrValue()) {
const t = this._lastStrValue;
if (g(this.ecmaVersion, "General_Category", t)) return this._lastKeyValue = "General_Category",
this._lastValValue = t, !0;
if (e = this.ecmaVersion, i = t, e >= 2018 && m.es2018.has(i) || e >= 2019 && m.es2019.has(i)) return this._lastKeyValue = t,
this._lastValValue = "", !0;
this.raise("Invalid property name");
}
var e, i;
return !1;
}
eatUnicodePropertyName() {
for (this._lastStrValue = ""; V(this.currentCodePoint); ) this._lastStrValue += String.fromCodePoint(this.currentCodePoint),
this.advance();
return "" !== this._lastStrValue;
}
eatUnicodePropertyValue() {
for (this._lastStrValue = ""; V(t = this.currentCodePoint) || C(t); ) this._lastStrValue += String.fromCodePoint(this.currentCodePoint),
this.advance();
var t;
return "" !== this._lastStrValue;
}
eatLoneUnicodePropertyNameOrValue() {
return this.eatUnicodePropertyValue();
}
eatHexEscapeSequence() {
const t = this.index;
if (this.eat(120)) {
if (this.eatFixedHexDigits(2)) return !0;
(this._uFlag || this.strict) && this.raise("Invalid escape"), this.rewind(t);
}
return !1;
}
eatDecimalDigits() {
const t = this.index;
for (this._lastIntValue = 0; C(this.currentCodePoint); ) this._lastIntValue = 10 * this._lastIntValue + w(this.currentCodePoint),
this.advance();
return this.index !== t;
}
eatHexDigits() {
const t = this.index;
for (this._lastIntValue = 0; v(this.currentCodePoint); ) this._lastIntValue = 16 * this._lastIntValue + w(this.currentCodePoint),
this.advance();
return this.index !== t;
}
eatLegacyOctalEscapeSequence() {
if (this.eatOctalDigit()) {
const t = this._lastIntValue;
if (this.eatOctalDigit()) {
const e = this._lastIntValue;
t <= 3 && this.eatOctalDigit() ? this._lastIntValue = 64 * t + 8 * e + this._lastIntValue : this._lastIntValue = 8 * t + e;
} else this._lastIntValue = t;
return !0;
}
return !1;
}
eatOctalDigit() {
const t = this.currentCodePoint;
return (e = t) >= 48 && e <= 55 ? (this.advance(), this._lastIntValue = t - 48,
!0) : (this._lastIntValue = 0, !1);
var e;
}
eatFixedHexDigits(t) {
const e = this.index;
this._lastIntValue = 0;
for (let i = 0; i < t; ++i) {
const t = this.currentCodePoint;
if (!v(t)) return this.rewind(e), !1;
this._lastIntValue = 16 * this._lastIntValue + w(t), this.advance();
}
return !0;
}
}
const D = {}, G = {}, B = {};
class M {
constructor(t) {
this._node = D, this._flags = G, this._backreferences = [], this._capturingGroups = [],
this.source = "", this.strict = Boolean(t && t.strict), this.ecmaVersion = t && t.ecmaVersion || 2020;
}
get pattern() {
if ("Pattern" !== this._node.type) throw new Error("UnknownError");
return this._node;
}
get flags() {
if ("Flags" !== this._flags.type) throw new Error("UnknownError");
return this._flags;
}
onFlags(t, e, i, s, n, r, a, o) {
this._flags = {
type: "Flags",
parent: null,
start: t,
end: e,
raw: this.source.slice(t, e),
global: i,
ignoreCase: s,
multiline: n,
unicode: r,
sticky: a,
dotAll: o
};
}
onPatternEnter(t) {
this._node = {
type: "Pattern",
parent: null,
start: t,
end: t,
raw: "",
alternatives: []
}, this._backreferences.length = 0, this._capturingGroups.length = 0;
}
onPatternLeave(t, e) {
this._node.end = e, this._node.raw = this.source.slice(t, e);
for (const t of this._backreferences) {
const e = t.ref, i = "number" == typeof e ? this._capturingGroups[e - 1] : this._capturingGroups.find(t => t.name === e);
t.resolved = i, i.references.push(t);
}
}
onAlternativeEnter(t) {
const e = this._node;
if ("Assertion" !== e.type && "CapturingGroup" !== e.type && "Group" !== e.type && "Pattern" !== e.type) throw new Error("UnknownError");
this._node = {
type: "Alternative",
parent: e,
start: t,
end: t,
raw: "",
elements: []
}, e.alternatives.push(this._node);
}
onAlternativeLeave(t, e) {
const i = this._node;
if ("Alternative" !== i.type) throw new Error("UnknownError");
i.end = e, i.raw = this.source.slice(t, e), this._node = i.parent;
}
onGroupEnter(t) {
const e = this._node;
if ("Alternative" !== e.type) throw new Error("UnknownError");
this._node = {
type: "Group",
parent: e,
start: t,
end: t,
raw: "",
alternatives: []
}, e.elements.push(this._node);
}
onGroupLeave(t, e) {
const i = this._node;
if ("Group" !== i.type || "Alternative" !== i.parent.type) throw new Error("UnknownError");
i.end = e, i.raw = this.source.slice(t, e), this._node = i.parent;
}
onCapturingGroupEnter(t, e) {
const i = this._node;
if ("Alternative" !== i.type) throw new Error("UnknownError");
this._node = {
type: "CapturingGroup",
parent: i,
start: t,
end: t,
raw: "",
name: e,
alternatives: [],
references: []
}, i.elements.push(this._node), this._capturingGroups.push(this._node);
}
onCapturingGroupLeave(t, e) {
const i = this._node;
if ("CapturingGroup" !== i.type || "Alternative" !== i.parent.type) throw new Error("UnknownError");
i.end = e, i.raw = this.source.slice(t, e), this._node = i.parent;
}
onQuantifier(t, e, i, s, n) {
const r = this._node;
if ("Alternative" !== r.type) throw new Error("UnknownError");
const a = r.elements.pop();
if (null == a || "Quantifier" === a.type || "Assertion" === a.type && "lookahead" !== a.kind) throw new Error("UnknownError");
const o = {
type: "Quantifier",
parent: r,
start: a.start,
end: e,
raw: this.source.slice(a.start, e),
min: i,
max: s,
greedy: n,
element: a
};
r.elements.push(o), a.parent = o;
}
onLookaroundAssertionEnter(t, e, i) {
const s = this._node;
if ("Alternative" !== s.type) throw new Error("UnknownError");
const n = this._node = {
type: "Assertion",
parent: s,
start: t,
end: t,
raw: "",
kind: e,
negate: i,
alternatives: []
};
s.elements.push(n);
}
onLookaroundAssertionLeave(t, e) {
const i = this._node;
if ("Assertion" !== i.type || "Alternative" !== i.parent.type) throw new Error("UnknownError");
i.end = e, i.raw = this.source.slice(t, e), this._node = i.parent;
}
onEdgeAssertion(t, e, i) {
const s = this._node;
if ("Alternative" !== s.type) throw new Error("UnknownError");
s.elements.push({
type: "Assertion",
parent: s,
start: t,
end: e,
raw: this.source.slice(t, e),
kind: i
});
}
onWordBoundaryAssertion(t, e, i, s) {
const n = this._node;
if ("Alternative" !== n.type) throw new Error("UnknownError");
n.elements.push({
type: "Assertion",
parent: n,
start: t,
end: e,
raw: this.source.slice(t, e),
kind: i,
negate: s
});
}
onAnyCharacterSet(t, e, i) {
const s = this._node;
if ("Alternative" !== s.type) throw new Error("UnknownError");
s.elements.push({
type: "CharacterSet",
parent: s,
start: t,
end: e,
raw: this.source.slice(t, e),
kind: i
});
}
onEscapeCharacterSet(t, e, i, s) {
const n = this._node;
if ("Alternative" !== n.type && "CharacterClass" !== n.type) throw new Error("UnknownError");
n.elements.push({
type: "CharacterSet",
parent: n,
start: t,
end: e,
raw: this.source.slice(t, e),
kind: i,
negate: s
});
}
onUnicodePropertyCharacterSet(t, e, i, s, n, r) {
const a = this._node;
if ("Alternative" !== a.type && "CharacterClass" !== a.type) throw new Error("UnknownError");
a.elements.push({
type: "CharacterSet",
parent: a,
start: t,
end: e,
raw: this.source.slice(t, e),
kind: i,
key: s,
value: n,
negate: r
});
}
onCharacter(t, e, i) {
const s = this._node;
if ("Alternative" !== s.type && "CharacterClass" !== s.type) throw new Error("UnknownError");
s.elements.push({
type: "Character",
parent: s,
start: t,
end: e,
raw: this.source.slice(t, e),
value: i
});
}
onBackreference(t, e, i) {
const s = this._node;
if ("Alternative" !== s.type) throw new Error("UnknownError");
const n = {
type: "Backreference",
parent: s,
start: t,
end: e,
raw: this.source.slice(t, e),
ref: i,
resolved: B
};
s.elements.push(n), this._backreferences.push(n);
}
onCharacterClassEnter(t, e) {
const i = this._node;
if ("Alternative" !== i.type) throw new Error("UnknownError");
this._node = {
type: "CharacterClass",
parent: i,
start: t,
end: t,
raw: "",
negate: e,
elements: []
}, i.elements.push(this._node);
}
onCharacterClassLeave(t, e) {
const i = this._node;
if ("CharacterClass" !== i.type || "Alternative" !== i.parent.type) throw new Error("UnknownError");
i.end = e, i.raw = this.source.slice(t, e), this._node = i.parent;
}
onCharacterClassRange(t, e) {
const i = this._node;
if ("CharacterClass" !== i.type) throw new Error("UnknownError");
const s = i.elements, n = s.pop(), r = s.pop(), a = s.pop();
if (!a || !n || !r || "Character" !== a.type || "Character" !== n.type || "Character" !== r.type || 45 !== r.value) throw new Error("UnknownError");
const o = {
type: "CharacterClassRange",
parent: i,
start: t,
end: e,
raw: this.source.slice(t, e),
min: a,
max: n
};
a.parent = o, n.parent = o, s.push(o);
}
}
class F {
constructor(t) {
this._state = new M(t), this._validator = new k(this._state);
}
parseLiteral(t, e = 0, i = t.length) {
this._state.source = t, this._validator.validateLiteral(t, e, i);
const s = this._state.pattern, n = this._state.flags, r = {
type: "RegExpLiteral",
parent: null,
start: e,
end: i,
raw: t,
pattern: s,
flags: n
};
return s.parent = r, n.parent = r, r;
}
parseFlags(t, e = 0, i = t.length) {
return this._state.source = t, this._validator.validateFlags(t, e, i), this._state.flags;
}
parsePattern(t, e = 0, i = t.length, s = !1) {
return this._state.source = t, this._validator.validatePattern(t, e, i, s), this._state.pattern;
}
}
class N {
constructor(t) {
this._handlers = t;
}
visit(t) {
switch (t.type) {
case "Alternative":
this.visitAlternative(t);
break;
case "Assertion":
this.visitAssertion(t);
break;
case "Backreference":
this.visitBackreference(t);
break;
case "CapturingGroup":
this.visitCapturingGroup(t);
break;
case "Character":
this.visitCharacter(t);
break;
case "CharacterClass":
this.visitCharacterClass(t);
break;
case "CharacterClassRange":
this.visitCharacterClassRange(t);
break;
case "CharacterSet":
this.visitCharacterSet(t);
break;
case "Flags":
this.visitFlags(t);
break;
case "Group":
this.visitGroup(t);
break;
case "Pattern":
this.visitPattern(t);
break;
case "Quantifier":
this.visitQuantifier(t);
break;
case "RegExpLiteral":
this.visitRegExpLiteral(t);
break;
default:
throw new Error("Unknown type: " + t.type);
}
}
visitAlternative(t) {
this._handlers.onAlternativeEnter && this._handlers.onAlternativeEnter(t), t.elements.forEach(this.visit, this),
this._handlers.onAlternativeLeave && this._handlers.onAlternativeLeave(t);
}
visitAssertion(t) {
this._handlers.onAssertionEnter && this._handlers.onAssertionEnter(t), "lookahead" !== t.kind && "lookbehind" !== t.kind || t.alternatives.forEach(this.visit, this),
this._handlers.onAssertionLeave && this._handlers.onAssertionLeave(t);
}
visitBackreference(t) {
this._handlers.onBackreferenceEnter && this._handlers.onBackreferenceEnter(t), this._handlers.onBackreferenceLeave && this._handlers.onBackreferenceLeave(t);
}
visitCapturingGroup(t) {
this._handlers.onCapturingGroupEnter && this._handlers.onCapturingGroupEnter(t),
t.alternatives.forEach(this.visit, this), this._handlers.onCapturingGroupLeave && this._handlers.onCapturingGroupLeave(t);
}
visitCharacter(t) {
this._handlers.onCharacterEnter && this._handlers.onCharacterEnter(t), this._handlers.onCharacterLeave && this._handlers.onCharacterLeave(t);
}
visitCharacterClass(t) {
this._handlers.onCharacterClassEnter && this._handlers.onCharacterClassEnter(t),
t.elements.forEach(this.visit, this), this._handlers.onCharacterClassLeave && this._handlers.onCharacterClassLeave(t);
}
visitCharacterClassRange(t) {
this._handlers.onCharacterClassRangeEnter && this._handlers.onCharacterClassRangeEnter(t),
this.visitCharacter(t.min), this.visitCharacter(t.max), this._handlers.onCharacterClassRangeLeave && this._handlers.onCharacterClassRangeLeave(t);
}
visitCharacterSet(t) {
this._handlers.onCharacterSetEnter && this._handlers.onCharacterSetEnter(t), this._handlers.onCharacterSetLeave && this._handlers.onCharacterSetLeave(t);
}
visitFlags(t) {
this._handlers.onFlagsEnter && this._handlers.onFlagsEnter(t), this._handlers.onFlagsLeave && this._handlers.onFlagsLeave(t);
}
visitGroup(t) {
this._handlers.onGroupEnter && this._handlers.onGroupEnter(t), t.alternatives.forEach(this.visit, this),
this._handlers.onGroupLeave && this._handlers.onGroupLeave(t);
}
visitPattern(t) {
this._handlers.onPatternEnter && this._handlers.onPatternEnter(t), t.alternatives.forEach(this.visit, this),
this._handlers.onPatternLeave && this._handlers.onPatternLeave(t);
}
visitQuantifier(t) {
this._handlers.onQuantifierEnter && this._handlers.onQuantifierEnter(t), this.visit(t.element),
this._handlers.onQuantifierLeave && this._handlers.onQuantifierLeave(t);
}
visitRegExpLiteral(t) {
this._handlers.onRegExpLiteralEnter && this._handlers.onRegExpLiteralEnter(t), this.visitPattern(t.pattern),
this.visitFlags(t.flags), this._handlers.onRegExpLiteralLeave && this._handlers.onRegExpLiteralLeave(t);
}
}
e.AST = s, e.RegExpParser = F, e.RegExpValidator = k, e.parseRegExpLiteral = function(t, e) {
return new F(e).parseLiteral(String(t));
}, e.validateRegExpLiteral = function(t, e) {
return new k(e).validateLiteral(t);
}, e.visitRegExpAST = function(t, e) {
new N(e).visit(t);
};
}, function(t, e, i) {
"use strict";
i.r(e);
class s {
constructor(t, e, i, s) {
this.before = t, this.after = e, this.filters = i, this.previouslySelectedDiscussion = s;
}
}
const n = ".docos-anchoredreplyview-author.docos-author";
class r {
constructor(t, e) {
this.element = t, this.pagePosition = [ ...e.querySelectorAll(".docos-docoview-replycontainer") ].indexOf(this.element);
}
getPagePosition() {
return this.pagePosition;
}
finalComment() {
const t = [ ...this.element.querySelectorAll(".docos-replyview-comment") ];
return 0 == t.length ? this.element.querySelector(".docos-docoview-rootreply") : t[t.length - 1];
}
}
class a {
constructor(t) {
this.elements = t.sort((t, e) => t.getPagePosition() - e.getPagePosition());
}
finalCommentAuthorNames() {
const t = this.elements.map(t => t.finalComment().querySelector(n).textContent);
return [ ...new Set(t) ];
}
getSelectedThread() {
return this.elements.find(t => t.element.parentElement.parentElement.matches(".docos-docoview-active"));
}
}
class o {
constructor(t, e) {
if (-1 == [ "AND", "OR" ].indexOf(e)) throw new Error("Provided Boolean operator is not valid");
this.booleanOperator = e, this.filters = t;
}
useAnd(t) {
return this.filters.reduce((t, e) => e.use(t), t);
}
useOr(t) {
let e = this.filters.reduce((e, i) => e.concat(i.use(t).elements), []);
return new a([ ...new Set(e) ]);
}
use(t) {
const e = new Map;
return e.set("AND", this.useAnd.bind(this)), e.set("OR", this.useOr.bind(this)),
e.get(this.booleanOperator)(t);
}
}
class h {
constructor(t, e) {
this.refreshInterval = e, this.element = document.createElement("div"), this.element.style.transitionProperty = "transform",
this.element.style.transitionDuration = "1s", this.element.style.width = "590px",
this.element.style.position = "fixed", this.element.style.left = "50%", this.element.style.padding = "30px 15px 15px 15px",
this.element.style.border = "solid rgb(50,50,50) 3px", this.element.style.borderRadius = "8px 8px 0px 0px",
this.element.style.backgroundColor = "white", this.element.style.fontFamily = "sans-serif",
this.element.style.fontSize = "14px", this.element.style.top = "100%", this.element.style.boxShadow = "rgba(0, 0, 0, 0.75) 3px 0px 10px -5px",
this.element.style.zIndex = "10000", this.minButton = document.createElement("span"),
this.minButton.textContent = "—", this.minButton.style.cursor = "pointer", this.minButton.style.position = "absolute",
this.minButton.style.top = "-10px", this.minButton.style.left = "575px", this.minButton.style.fontSize = "30px",
this.minButton.style.fontWeight = "bold", this.minButton.addEventListener("click", this.toggleMinimize.bind(this, e)),
document.addEventListener("keydown", t => {
"Escape" === t.key && this.minimize(e);
}), this.element.id = "googleDocsCommentNavigator", this.subcomponents = t;
}
renderSubcomponents() {
if (!this.subcomponents) throw new Error("The Navigator has null or undefined subcomponents.");
this.subcomponents.forEach(t => {
this.element.appendChild(t.render());
});
}
render(t) {
const e = document.createElement("span");
e.textContent = "Esc to minimize", e.style.fontStyle = "italic", e.style.fontSize = ".8em",
e.style.position = "absolute", e.style.top = "2px", e.style.left = "7px", e.style.width = "100px",
this.context = t, t.appendChild(this.element), this.element.appendChild(e), this.element.appendChild(this.minButton),
this.renderSubcomponents(), this.minimize(0), this.readAndRefresh(), window.setInterval(() => {
this.readAndRefresh();
}, this.refreshInterval);
}
readAndRefresh() {
const t = function(t) {
if (!t) throw new Error("the context given to ParseForThreads is null or undefined");
const e = [ ...t.querySelectorAll(".docos-docoview-replycontainer") ].map(e => new r(e, t));
return new a(e);
}(this.context), e = t.getSelectedThread();
e && (this.previouslySelectedThread = e);
const i = this.readFilters(), n = i.use(t);
this.refresh(new s(t, n, i, this.previouslySelectedThread));
}
maximize() {
this.minimized = !1, this.element.style.transform = "translate(-50%,-100%)";
}
minimize(t, e) {
this.minimized = !0, this.element.style.transform = `translate(-50%,-${this.element.style.paddingTop})`,
setTimeout(() => {
e && e();
}, t);
}
toggleMinimize(t) {
0 == this.minimized ? this.minimize(t) : this.maximize();
}
refresh(t, e) {
this.subcomponents.forEach(i => {
i.refresh(t, e);
});
}
readFilters() {
return new o(this.subcomponents.reduce((t, e) => {
let i;
return i = e.readFilters(), t.concat(i);
}, []), "AND");
}
}
var l = i(0);
class c {
constructor(t) {
this.criterion = t;
}
matches(t) {
throw new Error("Not implemented");
}
use(t) {
return new a(t.elements.reduce((t, e) => (this.matches(e) && t.push(e), t), []));
}
}
class u extends c {
constructor(t) {
super(t);
}
matches(t) {
return "" == this.criterion.trim() || t.finalComment().querySelector(n).textContent.trim() == this.criterion.trim();
}
}
class d extends c {
constructor() {
super(null);
}
matches(t) {
return null !== t.element.querySelector(".docos-replyview-suggest");
}
}
class p extends c {
constructor() {
super(null);
}
matches(t) {
return null !== t.element.querySelector(".docos-replyview-first.docos-replyview-comment");
}
}
class _ extends c {
constructor(t) {
super(t);
}
matches(t) {
if ("//" == this.criterion || "" == this.criterion) return !0;
let e;
e = "/" == this.criterion[0] && this.criterion[this.criterion.length - 1] ? this.criterion.match(/^\/(.*)\/$/)[1] : this.criterion;
try {
Object(l.validateRegExpLiteral)(`/${e}/`);
} catch (t) {
return !1;
}
const i = [ ...t.element.querySelectorAll(".docos-replyview-body.docos-anchoredreplyview-body") ], s = new RegExp(e);
return i.some(t => s.test(t.textContent));
}
}
class m {
constructor() {}
destroy() {
this.wrapper.remove();
}
}
class g extends m {
constructor() {
super();
}
render() {
return this.wrapper = document.createElement("span"), this.wrapper.id = "commentThreadCount",
this.wrapper.style.fontSize = "1.2em", this.wrapper.style.fontWeight = "900", this.wrapper.style.display = "inline-block",
this.wrapper.style.verticalAlign = "middle", this.wrapper.style.marginRight = "10px",
this.wrapper;
}
refresh(t) {
this.wrapper.textContent = `${t.after.elements.length}/${t.before.elements.length} discussions shown`;
}
readFilters() {
return new o([], "AND");
}
}
class f extends m {
constructor(t, e) {
super(), this.text = t, this.nextTarget = e;
}
target() {
return this.targetThread;
}
controlElement() {
return this.wrapper;
}
refresh(t) {
this.targetThread = this.nextTarget(t);
}
render() {
return this.wrapper = document.createElement("button"), this.wrapper.textContent = this.text,
this.wrapper.dataset.direction = this.text, this.wrapper.style.marginTop = "10px",
this.wrapper.style.marginRight = "5px", this.wrapper.style.width = "80px", this.wrapper.style.height = "30px",
this.wrapper.addEventListener("click", () => {
this.targetThread && this.targetThread.element.parentElement.parentElement.dispatchEvent(new MouseEvent("click"));
}), this.wrapper;
}
readFilters() {
return new o([], "AND");
}
static startingDiscussionForNavigation(t) {
let e = t.after.getSelectedThread();
return e || (t.previouslySelectedDiscussion ? t.previouslySelectedDiscussion : void 0);
}
}
class C extends m {
constructor() {
super();
}
render() {
this.wrapper = document.createElement("div"), this.wrapper.style.width = "200px",
this.wrapper.style.display = "inline-block", this.input = document.createElement("select"),
this.input.setAttribute("multiple", "true"), this.input.setAttribute("size", "3"),
this.input.name = "authorSelectBox", this.input.style.width = "190px";
const t = document.createElement("label");
return t.textContent = "Filter by the final author in each discussion", t.setAttribute("for", this.input.name),
t.style.display = "block", t.style.marginBottom = "10px", this.wrapper.appendChild(t),
this.wrapper.appendChild(this.input), this.wrapper;
}
refresh(t) {
const e = [ ...this.input.options ].map(t => ({
name: t.textContent,
selected: t.selected
}), []), i = t.before.finalCommentAuthorNames();
e.forEach(t => {
if (-1 == i.indexOf(t.name)) {
const i = e.indexOf(t);
e.splice(Math.max(i, 0), 1);
}
}), i.forEach(t => {
null == e.find(e => e.name == t) && e.push({
name: t,
selected: !1
});
}), this.input.innerHTML = "", e.forEach(t => {
let e = document.createElement("option");
e.textContent = t.name, e.value = t.name, e.selected = t.selected, this.input.appendChild(e);
});
}
readFilters() {
const t = [ ...this.input.getElementsByTagName("option") ].reduce((t, e) => 1 == e.selected ? t.concat(new u(e.textContent)) : t, []);
return 0 == t.length && t.push(new u("")), new o(t, "OR");
}
}
class v extends m {
constructor() {
super();
}
render() {
this.wrapper = document.createElement("div"), this.wrapper.style.display = "inline-block",
this.wrapper.style.verticalAlign = "top", this.wrapper.style.width = "200px", this.textInput = document.createElement("input"),
this.textInput.setAttribute("type", "text"), this.textInput.setAttribute("name", "regexpSearch"),
this.textInput.setAttribute("autocomplete", "off");
const t = document.createElement("label");
return t.innerText = "Search by JS regular expression", t.style.display = "block",
t.style.marginBottom = "10px", t.setAttribute("for", "regexpSearch"), this.wrapper.appendChild(t),
this.wrapper.appendChild(this.textInput), this.wrapper;
}
readFilters() {
return new o([ new _(this.textInput.value) ], "AND");
}
refresh(t) {}
}
class w extends m {
constructor() {
super(), this.boxRules = new Map, this.boxRules.set("Comments", new p), this.boxRules.set("Suggestions", new d);
}
render() {
this.wrapper = document.createElement("div"), this.wrapper.style.display = "inline-block",
this.wrapper.style.width = "100px", this.wrapper.style.verticalAlign = "top", this.wrapper.style.marginLeft = "10px",
this.wrapper.style.marginRight = "10px";
const t = document.createElement("span");
return t.textContent = "Show only:", t.style.display = "block", t.style.marginBottom = "10px",
this.wrapper.appendChild(t), this.boxRules.forEach((t, e) => {
let i = document.createElement("input");
i.setAttribute("type", "checkbox"), i.setAttribute("name", e);
let s = document.createElement("label");
s.setAttribute("for", e), s.innerText = e, this.wrapper.appendChild(i), this.wrapper.appendChild(s);
}), this.wrapper;
}
readFilters() {
let t = [ ...this.wrapper.getElementsByTagName("input") ].reduce((t, e) => 1 == e.checked ? t.concat(this.boxRules.get(e.name)) : t, []);
return 0 == t.length && (t = [ ...this.boxRules ].map(t => t[1])), new o(t, "OR");
}
refresh(t) {}
}
new h([ new C, new w, new v, new g, new f("First", t => t.after.elements[0]), new f("Previous", t => {
const e = f.startingDiscussionForNavigation(t);
if (!e || !t.after.elements[0]) return t.after.elements[0];
const i = e.getPagePosition(), s = t.after.elements.filter(t => t.element !== e.element && t.getPagePosition() <= i), n = s.sort((t, e) => t.getPagePosition() - e.getPagePosition())[Math.max(s.length - 1, 0)];
return n || e;
}), new f("Next", t => {
const e = f.startingDiscussionForNavigation(t);
if (!e || !t.after.elements[0]) return t.after.elements[0];
const i = e.getPagePosition(), s = t.after.elements.filter(t => t.element !== e.element && t.getPagePosition() >= i).sort((t, e) => t.getPagePosition() - e.getPagePosition())[0];
return s || e;
}), new f("Last", t => t.after.elements[Math.max(0, t.after.elements.length - 1)]) ], 100).render(document.body);
} ]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment