polite-crawler 0.3.0 → 0.4.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (32) hide show
  1. package/build/{cli-daemon-C2_Pd4v_.mjs → cli-daemon-Br17snPs.mjs} +2 -2
  2. package/build/{cli-daemon-C2_Pd4v_.mjs.map → cli-daemon-Br17snPs.mjs.map} +1 -1
  3. package/build/{cli-recipes-XlxoNo75.mjs → cli-recipes-Cjq6ohWH.mjs} +2 -2
  4. package/build/{cli-recipes-XlxoNo75.mjs.map → cli-recipes-Cjq6ohWH.mjs.map} +1 -1
  5. package/build/cli.mjs +7 -7
  6. package/build/{daemon-B0Cp8xeB.mjs → daemon-BPswUOgu.mjs} +3 -3
  7. package/build/{daemon-B0Cp8xeB.mjs.map → daemon-BPswUOgu.mjs.map} +1 -1
  8. package/build/{diff-DHpF9lYY.mjs → diff-DuD9pinS.mjs} +2 -2
  9. package/build/{diff-DHpF9lYY.mjs.map → diff-DuD9pinS.mjs.map} +1 -1
  10. package/build/{extract-BgcEkiQr.mjs → extract-BISJyKWN.mjs} +3 -3
  11. package/build/{extract-BgcEkiQr.mjs.map → extract-BISJyKWN.mjs.map} +1 -1
  12. package/build/{html-DzobO0fy.mjs → html-Dir5QEi0.mjs} +2 -2
  13. package/build/html-Dir5QEi0.mjs.map +1 -0
  14. package/build/html.mjs +1 -1
  15. package/build/index.d.mts +1 -1
  16. package/build/index.mjs +11 -11
  17. package/build/{open-YGJPjbDc.mjs → open-CsFRWOjf.mjs} +7 -7
  18. package/build/{open-YGJPjbDc.mjs.map → open-CsFRWOjf.mjs.map} +1 -1
  19. package/build/{recipe-CPmYb91t.mjs → recipe-30dN3orz.mjs} +4 -4
  20. package/build/{recipe-CPmYb91t.mjs.map → recipe-30dN3orz.mjs.map} +1 -1
  21. package/build/{recipe-product-B6XmkpB3.mjs → recipe-product-BuJ_gEwn.mjs} +5 -5
  22. package/build/{recipe-product-B6XmkpB3.mjs.map → recipe-product-BuJ_gEwn.mjs.map} +1 -1
  23. package/build/{runtime-j2NpXEiN.mjs → runtime-C2VRY89U.mjs} +3 -3
  24. package/build/{runtime-j2NpXEiN.mjs.map → runtime-C2VRY89U.mjs.map} +1 -1
  25. package/build/{version-Dw3pZOVT.mjs → version-B9CUZfx5.mjs} +2 -2
  26. package/build/{version-Dw3pZOVT.mjs.map → version-B9CUZfx5.mjs.map} +1 -1
  27. package/build/{wacz-ixsUXYCs.mjs → wacz-D5bvxsiM.mjs} +3 -3
  28. package/build/{wacz-ixsUXYCs.mjs.map → wacz-D5bvxsiM.mjs.map} +1 -1
  29. package/build/{warc-B47Bdjzk.mjs → warc-DsB3oP78.mjs} +2 -2
  30. package/build/{warc-B47Bdjzk.mjs.map → warc-DsB3oP78.mjs.map} +1 -1
  31. package/package.json +1 -1
  32. package/build/html-DzobO0fy.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"html-DzobO0fy.mjs","names":[],"sources":["../src/text.ts","../src/html.ts"],"sourcesContent":["/**\n * The body decoder changes the bytes of a response into text. It finds the encoding in this order,\n * as the WHATWG encoding rules and the browsers do:\n *\n * 1. A byte order mark.\n * 2. The `charset` of the `Content-Type` header.\n * 3. A `<meta charset>` or `http-equiv` declaration in the first 2,048 bytes of an HTML page, or the\n * encoding of an XML declaration.\n * 4. UTF-8 when the bytes are UTF-8, and windows-1252 when they are not.\n *\n * It uses only `TextDecoder`, so it operates in a browser too. A byte that the encoding does not\n * know becomes U+FFFD. The decoder does not throw.\n */\n\nconst PRESCAN_BYTES = 2048;\n\n/** This function gives the WHATWG name of an encoding label, or undefined when the runtime does not know the label. */\nconst encodingOf = (label: string): string | undefined => {\n try {\n return new TextDecoder(label.trim().toLowerCase()).encoding;\n } catch {\n return undefined;\n }\n};\n\nconst bomOf = (bytes: Uint8Array): string | undefined => {\n if (bytes[0] === 0xef && bytes[1] === 0xbb && bytes[2] === 0xbf) return \"utf-8\";\n if (bytes[0] === 0xfe && bytes[1] === 0xff) return \"utf-16be\";\n if (bytes[0] === 0xff && bytes[1] === 0xfe) return \"utf-16le\";\n return undefined;\n};\n\n/** This function gives the `charset` parameter of a media type, or undefined. */\nconst charsetOf = (contentType: string | null): string | undefined => {\n if (contentType === null) return undefined;\n const match = /;\\s*charset\\s*=\\s*(?:\"([^\"]*)\"|([^\\s;\"]+))/i.exec(contentType.slice(0, 512));\n return match?.[1] ?? match?.[2] ?? undefined;\n};\n\n/**\n * This function removes each comment (`<!--` to the next `-->`) of a text, in one pass from the\n * start. It uses no regular expression, so its time is linear.\n */\nconst withoutComments = (text: string): string => {\n let out = \"\";\n let at = 0;\n for (let open = text.indexOf(\"<!--\"); open !== -1; open = text.indexOf(\"<!--\", at)) {\n const close = text.indexOf(\"-->\", open + 4);\n // a comment that does not close stays, and no later comment can close\n if (close === -1) break;\n out += text.slice(at, open);\n at = close + 3;\n }\n return out + text.slice(at);\n};\n\n/** This function reads the encoding that the start of an HTML or XML document declares. */\nconst declaredCharset = (bytes: Uint8Array): string | undefined => {\n let head = \"\";\n const end = Math.min(bytes.length, PRESCAN_BYTES);\n for (let index = 0; index < end; index += 1) head += String.fromCharCode(bytes[index]!);\n const xml = /^\\s*<\\?xml[^>]*?\\bencoding\\s*=\\s*[\"']([^\"']+)[\"']/i.exec(head);\n if (xml !== null) return xml[1];\n // a declaration inside a comment declares nothing\n const markup = withoutComments(head);\n // `<meta charset=x>`, and `<meta http-equiv=\"Content-Type\" content=\"text/html; charset=x\">`\n const meta = /<meta\\b[^>]*?\\bcharset\\s*=\\s*[\"']?\\s*([A-Za-z0-9_:.+-]+)/i.exec(markup);\n return meta?.[1];\n};\n\n/**\n * This function counts the UTF-8 sequences of more than one byte, and the bytes that no UTF-8\n * sequence explains. An incomplete sequence at the end is no error: a body cut at its size limit\n * ends so.\n */\nconst utf8Evidence = (\n bytes: Uint8Array,\n): { readonly multibyte: number; readonly invalid: number } => {\n let multibyte = 0;\n let invalid = 0;\n let index = 0;\n while (index < bytes.length) {\n const lead = bytes[index]!;\n if (lead < 0x80) {\n index += 1;\n continue;\n }\n const need =\n lead >= 0xc2 && lead <= 0xdf\n ? 1\n : lead >= 0xe0 && lead <= 0xef\n ? 2\n : lead >= 0xf0 && lead <= 0xf4\n ? 3\n : 0;\n if (need === 0) {\n invalid += 1;\n index += 1;\n continue;\n }\n // the second byte has a narrower range after E0, ED, F0 and F4\n const low = lead === 0xe0 ? 0xa0 : lead === 0xf0 ? 0x90 : 0x80;\n const high = lead === 0xed ? 0x9f : lead === 0xf4 ? 0x8f : 0xbf;\n let ok = true;\n let at = 1;\n while (at <= need && index + at < bytes.length) {\n const next = bytes[index + at]!;\n if (at === 1 ? next < low || next > high : next < 0x80 || next > 0xbf) {\n ok = false;\n break;\n }\n at += 1;\n }\n // the body ends inside the sequence\n if (ok && at <= need) break;\n if (ok) {\n multibyte += 1;\n index += need + 1;\n } else {\n invalid += 1;\n index += 1;\n }\n }\n return { multibyte, invalid };\n};\n\n/**\n * This function gives the WHATWG name of the encoding of a body, for example `utf-8` or\n * `windows-1252`. The function `decodeBody` uses it.\n */\nexport const bodyEncoding = (bytes: Uint8Array, contentType: string | null): string => {\n const bom = bomOf(bytes);\n if (bom !== undefined) return bom;\n const header = charsetOf(contentType);\n const fromHeader = header === undefined ? undefined : encodingOf(header);\n if (fromHeader !== undefined) return fromHeader;\n if (contentType === null || /html|xml/i.test(contentType)) {\n const label = declaredCharset(bytes);\n let declared = label === undefined ? undefined : encodingOf(label);\n // the HTML standard reads a UTF-16 declaration in ASCII-compatible bytes as UTF-8\n if (declared?.startsWith(\"utf-16\") === true) declared = \"utf-8\";\n if (declared === \"x-user-defined\") declared = \"windows-1252\";\n if (declared === \"utf-8\") return declared;\n if (declared !== undefined) {\n // A browser serialises the page it rendered as UTF-8, and the old declaration stays. UTF-8\n // with no error is almost never a legacy encoding by chance.\n const evidence = utf8Evidence(bytes);\n return evidence.invalid === 0 && evidence.multibyte > 0 ? \"utf-8\" : declared;\n }\n }\n if (/json/i.test(contentType ?? \"\")) return \"utf-8\";\n const evidence = utf8Evidence(bytes);\n return evidence.invalid > 0 && evidence.invalid >= evidence.multibyte ? \"windows-1252\" : \"utf-8\";\n};\n\n/**\n * These are the characters of the bytes 0x80 to 0x9F in windows-1252, from the WHATWG index.\n * Node.js 22 decodes windows-1252 as ISO-8859-1, which gives a control character for each of\n * these bytes. A later runtime gives the correct characters, and then the map changes nothing.\n */\nconst WINDOWS_1252_HIGH = [\n 0x20ac, 0x81, 0x201a, 0x192, 0x201e, 0x2026, 0x2020, 0x2021, 0x2c6, 0x2030, 0x160, 0x2039, 0x152,\n 0x8d, 0x17d, 0x8f, 0x90, 0x2018, 0x2019, 0x201c, 0x201d, 0x2022, 0x2013, 0x2014, 0x2dc, 0x2122,\n 0x161, 0x203a, 0x153, 0x9d, 0x17e, 0x178,\n];\nconst C1_CONTROLS = new RegExp(`[${String.fromCharCode(0x80)}-${String.fromCharCode(0x9f)}]`, \"g\");\nconst repairWindows1252 = (text: string): string =>\n text.replace(C1_CONTROLS, (char) =>\n String.fromCharCode(WINDOWS_1252_HIGH[char.charCodeAt(0) - 0x80]!),\n );\n\n/**\n * This function decodes the body of a response. It reads the encoding from the byte order mark,\n * the `Content-Type` header and the document, with `bodyEncoding`. It does not throw.\n */\nexport const decodeBody = (bytes: Uint8Array, contentType: string | null): string => {\n const encoding = bodyEncoding(bytes, contentType);\n try {\n const text = new TextDecoder(encoding, { fatal: false }).decode(bytes);\n return encoding === \"windows-1252\" ? repairWindows1252(text) : text;\n } catch {\n // a runtime with a small ICU knows only a few encodings\n return new TextDecoder(\"utf-8\", { fatal: false }).decode(bytes);\n }\n};\n","import { Readability } from \"@mozilla/readability\";\nimport { parseHTML } from \"linkedom\";\nimport { canonicalUrl } from \"./urls.ts\";\n\nexport { bodyEncoding, decodeBody } from \"./text.ts\";\n\n/**\n * The page reader reads a web page with no browser first. It gives:\n *\n * 1. The JSON-LD, the structured data that 41% of pages have. For a venue, it gives the name, the\n * address, the phone number and sometimes the hours.\n * 2. The visible text of the page.\n * 3. A decision: does the page need JavaScript to show its content?\n *\n * On a short page, the text is all of the visible text. Readability is for articles, and it\n * removes footers, sidebars and tables, where a venue keeps its hours. Thus on a long page, the\n * main text of Readability comes first. A blank line follows it, and then each other line of the\n * page.\n *\n * The cost of the reader grows in proportion to the size of the page. It walks the document with\n * no recursion, so deep markup cannot overflow the stack. It does not use Readability on a page\n * that is too large or too deep for it.\n */\n\nexport interface PageLink {\n readonly href: string;\n readonly text: string;\n}\n\nexport interface PageExtract {\n readonly title: string;\n readonly description: string | null;\n readonly text: string;\n /**\n * When the reader cut `text` to its maximum, this text is the whole visible text in the order of\n * the page. A quote past the cut is still in it. Otherwise this value is undefined.\n */\n readonly fullText?: string | undefined;\n /** These are the JSON-LD objects of the page, with each `@graph` made flat. */\n readonly jsonld: readonly Record<string, unknown>[];\n readonly links: readonly PageLink[];\n readonly lang: string | null;\n readonly visibleChars: number;\n /** These are the names of the application states that the HTML holds (Next.js, Nuxt, Apollo). */\n readonly embedded: readonly string[];\n /** This value is true when the page shows almost nothing without its scripts. */\n readonly needsRender: boolean;\n readonly renderReason: string | null;\n /** This URL is the `<link rel=\"canonical\">` of the page when it is on the same site, or null. */\n readonly canonical: string | null;\n /**\n * These URLs are the RSS and Atom feeds that the page links with `<link rel=\"alternate\">`, 10 or\n * fewer. They can be on a different site. `extractPage` always gives them. The field is optional,\n * so a `PageExtract` of version 0.1.1 stays correct.\n */\n readonly feeds?: readonly string[] | undefined;\n /** This URL is the target of a `<meta http-equiv=\"refresh\">` that sends the reader on in 5 seconds or less. */\n readonly redirect: string | null;\n /**\n * This value names the bot check or the firewall that sent its page in place of the content, for\n * example \"Cloudflare\". A crawler must not open a browser to get past it.\n */\n readonly blocked: string | null;\n /** These notes tell what the reader left out, for example a JSON-LD block that it cannot read. */\n readonly notes: readonly string[];\n}\n\nconst SKIP = new Set([\n \"script\",\n \"style\",\n \"noscript\",\n // a template is inert; a declarative shadow root is read (see `isShadowRoot`)\n \"template\",\n \"svg\",\n \"math\",\n // never shown, and a page without a <head> leaves it among the content\n \"title\",\n \"meta\",\n \"link\",\n \"base\",\n \"iframe\",\n \"frame\",\n \"object\",\n \"embed\",\n \"canvas\",\n \"audio\",\n \"video\",\n \"datalist\",\n \"param\",\n \"source\",\n \"track\",\n]);\n/** These elements show as blocks: each starts a line. The list follows the default style sheet of HTML. */\nconst BLOCK = new Set([\n \"address\",\n \"article\",\n \"aside\",\n \"blockquote\",\n \"body\",\n \"br\",\n \"caption\",\n \"center\",\n \"dd\",\n \"details\",\n \"dialog\",\n \"dir\",\n \"div\",\n \"dl\",\n \"dt\",\n \"fieldset\",\n \"figcaption\",\n \"figure\",\n \"footer\",\n \"form\",\n \"frameset\",\n \"h1\",\n \"h2\",\n \"h3\",\n \"h4\",\n \"h5\",\n \"h6\",\n // linkedom leaves the content of a page that never closes its <head> inside it\n \"head\",\n \"header\",\n \"hgroup\",\n \"hr\",\n \"html\",\n \"legend\",\n \"li\",\n \"listing\",\n \"main\",\n \"marquee\",\n \"menu\",\n \"nav\",\n \"noframes\",\n \"ol\",\n // a dropdown's choices, one to a line\n \"optgroup\",\n \"option\",\n \"p\",\n \"plaintext\",\n \"pre\",\n \"search\",\n \"section\",\n \"summary\",\n \"table\",\n \"tbody\",\n \"tfoot\",\n \"thead\",\n \"tr\",\n \"ul\",\n \"xmp\",\n]);\n/**\n * These elements run inline with the text around them. Any other element, a custom element too,\n * ends a word, so its text stays apart from the next word.\n */\nconst INLINE = new Set([\n \"a\",\n \"abbr\",\n \"acronym\",\n \"b\",\n \"bdi\",\n \"bdo\",\n \"big\",\n \"blink\",\n \"cite\",\n \"code\",\n \"data\",\n \"del\",\n \"dfn\",\n \"em\",\n \"font\",\n \"i\",\n \"img\",\n \"ins\",\n \"kbd\",\n \"label\",\n \"mark\",\n \"nobr\",\n \"picture\",\n \"q\",\n \"rb\",\n \"rp\",\n \"rt\",\n \"rtc\",\n \"ruby\",\n \"s\",\n \"samp\",\n \"slot\",\n \"small\",\n \"span\",\n \"strike\",\n \"strong\",\n \"sub\",\n \"sup\",\n \"time\",\n \"tt\",\n \"u\",\n \"var\",\n \"wbr\",\n]);\n/** A table row becomes one line (\"Sunday 10 am–5 pm\"), with a space between its cells. */\nconst CELL = new Set([\"td\", \"th\"]);\nconst WORD_END = new Set([\"a\", \"button\"]);\n\n/** A page shorter than this keeps all its text. On a longer page, the text of Readability comes first. */\nconst SHORT_PAGE_CHARS = 6000;\nconst MAX_TEXT_CHARS = 50_000;\n/** On a long page, this part of the text is kept for the lines after the article: a footer keeps its hours. */\nconst REST_RESERVE_CHARS = 12_000;\nconst MAX_LINKS = 300;\n/** The reader keeps this number of feed links of a page at most. */\nconst MAX_FEEDS = 10;\n/** These media types name an RSS or an Atom feed in a `<link rel=\"alternate\">`. */\nconst FEED_TYPES: ReadonlySet<string> = new Set([\"application/rss+xml\", \"application/atom+xml\"]);\n/** Readability takes seconds on a page with more elements or links than this, and more time again on deep markup. */\nconst READABILITY_MAX_ELEMENTS = 10_000;\nconst READABILITY_MAX_LINKS = 1500;\nconst READABILITY_MAX_DEPTH = 150;\n/**\n * The parser of linkedom takes time in proportion to the square of the depth of the markup: 200,000\n * levels take 30 seconds. The reader reads the tags below this depth as text.\n */\nconst MAX_DEPTH = 1000;\n\n/** This is the small part of the DOM that this file uses. Node has no DOM types, and linkedom supplies the DOM. */\nexport interface DomNode {\n readonly nodeType: number;\n readonly nodeName: string;\n readonly textContent: string | null;\n readonly childNodes: ArrayLike<DomNode>;\n readonly firstChild?: DomNode | null | undefined;\n readonly nextSibling?: DomNode | null | undefined;\n readonly parentNode?: DomNode | null | undefined;\n /** This method takes the node out of its parent. */\n readonly remove?: (() => void) | undefined;\n}\n\ninterface DomElement extends DomNode {\n getAttribute(name: string): string | null;\n querySelector(selector: string): DomElement | null;\n /** This is the content of a `<template>`. */\n readonly content?: DomNode | null | undefined;\n}\n\n/**\n * This type has no `body` or `head`, on purpose. When an element comes before `<head>`, linkedom\n * makes a new, empty pair. Then `document.body` reads nothing, but a browser shows the full page.\n */\ninterface DomDocument extends DomNode {\n querySelector(selector: string): DomElement | null;\n querySelectorAll(selector: string): ArrayLike<DomElement> & Iterable<DomElement>;\n readonly documentElement: DomElement | null;\n}\n\nconst parse = (html: string): DomDocument =>\n (parseHTML(html) as unknown as { document: DomDocument }).document;\n\n/** These elements have no end tag. */\nconst VOID = new Set([\n \"area\",\n \"base\",\n \"basefont\",\n \"bgsound\",\n \"br\",\n \"col\",\n \"embed\",\n \"frame\",\n \"hr\",\n \"img\",\n \"input\",\n \"keygen\",\n \"link\",\n \"meta\",\n \"param\",\n \"source\",\n \"track\",\n \"wbr\",\n]);\n/** The content of these elements is text up to their end tag, not markup. */\nconst RAW_TEXT = new Set([\n \"iframe\",\n \"noembed\",\n \"noframes\",\n \"noscript\",\n \"plaintext\",\n \"script\",\n \"style\",\n \"textarea\",\n \"title\",\n \"xmp\",\n]);\n/** A new element of one of these kinds closes the open one (\"<li>one<li>two\"). */\nconst IMPLIED_END = new Set([\n \"dd\",\n \"dt\",\n \"li\",\n \"optgroup\",\n \"option\",\n \"p\",\n \"rb\",\n \"rp\",\n \"rt\",\n \"rtc\",\n \"tbody\",\n \"td\",\n \"tfoot\",\n \"th\",\n \"thead\",\n \"tr\",\n]);\n\nconst isLetter = (code: number): boolean =>\n (code >= 0x61 && code <= 0x7a) || (code >= 0x41 && code <= 0x5a);\nconst isNameChar = (code: number): boolean =>\n isLetter(code) ||\n (code >= 0x30 && code <= 0x39) ||\n code === 0x2d ||\n code === 0x3a ||\n code === 0x5f ||\n code === 0x2e;\n\n/** This function gives the index after the `>` of a tag. A `>` inside a quoted attribute value does not end it. */\nconst endOfTag = (html: string, from: number): number => {\n let quote = 0;\n let afterEquals = false;\n for (let at = from; at < html.length; at += 1) {\n const code = html.charCodeAt(at);\n if (quote !== 0) {\n if (code === quote) quote = 0;\n } else if ((code === 0x22 || code === 0x27) && afterEquals) {\n quote = code;\n } else if (code === 0x3e) {\n return at + 1;\n }\n if (code === 0x3d) afterEquals = true;\n else if (code !== 0x20 && code !== 0x09 && code !== 0x0a && code !== 0x0d) afterEquals = false;\n }\n return html.length;\n};\n\n/**\n * This function reads the tags below `MAX_DEPTH` levels as text: a block tag becomes a line break\n * and another tag becomes nothing. It counts the open elements roughly, in one pass. When it\n * removes nothing, it gives the same string.\n */\nconst flattenDeepMarkup = (html: string): { readonly html: string; readonly dropped: number } => {\n const stack: string[] = [];\n const open = new Map<string, number>();\n const extra = new Map<string, number>();\n const out: string[] = [];\n let copied = 0;\n let dropped = 0;\n const popTo = (name: string): void => {\n if ((open.get(name) ?? 0) === 0) return;\n for (;;) {\n const top = stack.pop()!;\n open.set(top, (open.get(top) ?? 1) - 1);\n if (top === name) return;\n }\n };\n const replace = (start: number, end: number, name: string): void => {\n out.push(html.slice(copied, start), BLOCK.has(name) ? \"\\n\" : INLINE.has(name) ? \"\" : \" \");\n copied = end;\n };\n let index = 0;\n while (index < html.length) {\n const lt = html.indexOf(\"<\", index);\n if (lt === -1) break;\n if (html.startsWith(\"<!--\", lt)) {\n const end = html.indexOf(\"-->\", lt + 4);\n index = end === -1 ? html.length : end + 3;\n continue;\n }\n const next = html.charCodeAt(lt + 1);\n if (next === 0x21 || next === 0x3f) {\n const end = html.indexOf(\">\", lt);\n index = end === -1 ? html.length : end + 1;\n continue;\n }\n const closing = next === 0x2f;\n const nameStart = lt + (closing ? 2 : 1);\n if (!isLetter(html.charCodeAt(nameStart))) {\n index = lt + 1;\n continue;\n }\n let nameEnd = nameStart + 1;\n while (nameEnd < html.length && isNameChar(html.charCodeAt(nameEnd))) nameEnd += 1;\n const name = html.slice(nameStart, nameEnd).toLowerCase();\n const tagEnd = endOfTag(html, nameEnd);\n index = tagEnd;\n if (closing) {\n // the deepest elements close first, and those are the ones that were removed\n const removed = extra.get(name) ?? 0;\n if (removed > 0) {\n extra.set(name, removed - 1);\n replace(lt, tagEnd, name);\n } else {\n popTo(name);\n }\n continue;\n }\n if (RAW_TEXT.has(name)) {\n const end = new RegExp(`</${name}[\\\\s/>]`, \"gi\");\n end.lastIndex = tagEnd;\n index = end.exec(html)?.index ?? html.length;\n continue;\n }\n if (VOID.has(name) || html.charCodeAt(tagEnd - 2) === 0x2f) continue;\n if (IMPLIED_END.has(name)) popTo(name);\n if (stack.length >= MAX_DEPTH) {\n extra.set(name, (extra.get(name) ?? 0) + 1);\n dropped += 1;\n replace(lt, tagEnd, name);\n continue;\n }\n stack.push(name);\n open.set(name, (open.get(name) ?? 0) + 1);\n }\n if (dropped === 0) return { html, dropped };\n out.push(html.slice(copied));\n return { html: out.join(\"\"), dropped };\n};\n\nconst attribute = (node: DomNode, name: string): string | null =>\n typeof (node as Partial<DomElement>).getAttribute === \"function\"\n ? (node as DomElement).getAttribute(name)\n : null;\n\n/** A `<template shadowrootmode>` holds a declarative shadow root: the browser shows its content. */\nconst isShadowRoot = (node: DomNode): boolean =>\n attribute(node, \"shadowrootmode\") !== null || attribute(node, \"shadowroot\") !== null;\n\n/** The reader reads only these properties of an inline style. */\nconst STYLE_PROPERTIES = new Set([\"display\", \"font-size\"]);\n\n/**\n * This function reads `display` and `font-size` from the `style` attribute of an element. The last\n * declaration wins, and an `!important` declaration wins over a declaration that is not important.\n * It reads no style sheet. Its time grows in proportion to the length of the attribute.\n */\nconst inlineStyle = (node: DomNode): ReadonlyMap<string, string> => {\n const found = new Map<string, string>();\n const style = attribute(node, \"style\");\n if (style === null || style.length === 0) return found;\n const important = new Set<string>();\n for (const declaration of style.split(\";\")) {\n const colon = declaration.indexOf(\":\");\n if (colon === -1) continue;\n const property = declaration.slice(0, colon).trim().toLowerCase();\n if (!STYLE_PROPERTIES.has(property)) continue;\n let value = declaration\n .slice(colon + 1)\n .trim()\n .toLowerCase();\n const bang = value.lastIndexOf(\"!\");\n const strong = bang !== -1 && value.slice(bang + 1).trim() === \"important\";\n if (strong) value = value.slice(0, bang).trim();\n if (important.has(property) && !strong) continue;\n if (strong) important.add(property);\n found.set(property, value);\n }\n return found;\n};\n\n/**\n * This function tells if a reader of the page does not get an element and its content. A browser\n * does not show an element with `display: none` or with the attribute `hidden` (unless its inline\n * style sets a different display). A screen reader skips an element with `aria-hidden=\"true\"`, and\n * a model reads a page as a screen reader does.\n */\nconst notRendered = (node: DomNode, style: ReadonlyMap<string, string>): boolean => {\n const display = style.get(\"display\");\n if (display === \"none\") return true;\n if (display === undefined && attribute(node, \"hidden\") !== null) return true;\n return attribute(node, \"aria-hidden\")?.trim().toLowerCase() === \"true\";\n};\n\n/** A font size of zero: `0`, `0px`, `0em` or `0%`. */\nconst ZERO_SIZE = /^\\+?(?:0+(?:\\.0*)?|\\.0+)(?:[a-z]{1,4}|%)?$/;\n/** These sizes are a part of the size of the parent, so a part of zero stays zero. */\nconst RELATIVE_SIZE =\n /^(?:\\+?[\\d.]+(?:em|ex|ch|cap|ic|lh|%)|larger|smaller|inherit|unset|revert|revert-layer)$/;\n\n/** This function tells if the text of an element has a zero size. A child that sets a size of its own shows its text again. */\nconst zeroSize = (fontSize: string | undefined, parentZero: boolean): boolean => {\n if (fontSize === undefined) return parentZero;\n if (ZERO_SIZE.test(fontSize)) return true;\n return parentZero && RELATIVE_SIZE.test(fontSize);\n};\n\ninterface Walked {\n readonly text: string;\n readonly elements: number;\n readonly links: number;\n readonly depth: number;\n /** These nodes are not text for a reader: the elements that `notRendered` refuses, and the text of a zero size. */\n readonly unseen: readonly DomNode[];\n}\n\ninterface Frame {\n readonly name: string;\n /** The children of an element are read with `nextSibling`, which costs nothing in linkedom. */\n next: DomNode | null | undefined;\n /** linkedom gives a document type no `nextSibling`, so the few children of a document are read as a list. */\n readonly list: ArrayLike<DomNode> | undefined;\n index: number;\n /** This value is true when the text of the element has a zero size. */\n readonly zero: boolean;\n}\n\n/**\n * This function walks a tree with a stack of its own. Thus the depth of the markup cannot overflow\n * the stack. It reads only the text that a reader gets (refer to `notRendered` and `zeroSize`), and it\n * gives the nodes that it did not read.\n */\nconst walkText = (root: DomNode): Walked => {\n const parts: string[] = [];\n const unseen: DomNode[] = [];\n // a link or a button ends a word even where the markup runs it into the\n // next (\"Offers from AmexGlobal Dining Access\"), though not before a stop\n let seam = false;\n let elements = 0;\n let links = 0;\n let depth = 0;\n const stack: Frame[] = [];\n const enter = (node: DomNode): void => {\n if (node.nodeType === 3) {\n if (stack[stack.length - 1]?.zero === true) {\n unseen.push(node);\n return;\n }\n const text = node.textContent ?? \"\";\n if (seam && /^[^\\s.,;:!?)\\]–—-]/.test(text)) parts.push(\" \");\n if (text.length > 0) seam = false;\n parts.push(text);\n return;\n }\n if (node.nodeType !== 1 && node.nodeType !== 9 && node.nodeType !== 11) return;\n const name = node.nodeName.toLowerCase();\n let container = node;\n if (name === \"template\") {\n if (!isShadowRoot(node)) return;\n container = (node as DomElement).content ?? node;\n } else if (SKIP.has(name)) {\n return;\n }\n let zero = stack[stack.length - 1]?.zero ?? false;\n if (node.nodeType === 1) {\n const style = inlineStyle(node);\n if (notRendered(node, style)) {\n unseen.push(node);\n return;\n }\n zero = zeroSize(style.get(\"font-size\"), zero);\n elements += 1;\n if (name === \"a\") links += 1;\n if (BLOCK.has(name)) parts.push(\"\\n\");\n else if (!INLINE.has(name) && !CELL.has(name)) seam = true;\n }\n stack.push(\n container.nodeType === 1\n ? { name, next: container.firstChild, list: undefined, index: 0, zero }\n : { name, next: undefined, list: container.childNodes, index: 0, zero },\n );\n if (stack.length > depth) depth = stack.length;\n };\n const leave = (name: string): void => {\n const block = BLOCK.has(name);\n if (block) parts.push(\"\\n\");\n else if (CELL.has(name)) parts.push(\" \");\n if (block) seam = false;\n else if (WORD_END.has(name) || !INLINE.has(name)) seam = true;\n };\n enter(root);\n while (stack.length > 0) {\n const frame = stack[stack.length - 1]!;\n let child: DomNode | null | undefined;\n if (frame.list !== undefined) {\n child = frame.index < frame.list.length ? frame.list[frame.index] : undefined;\n frame.index += 1;\n } else {\n child = frame.next;\n if (child !== null && child !== undefined) frame.next = child.nextSibling;\n }\n if (child === null || child === undefined) {\n stack.pop();\n leave(frame.name);\n } else {\n enter(child);\n }\n }\n const text = parts\n .join(\"\")\n .split(\"\\n\")\n .map((line) =>\n line\n .replace(/[​-‍⁠­]/g, \"\")\n .replace(/\\s+/g, \" \")\n .trim(),\n )\n .filter((line) => line.length > 0)\n .join(\"\\n\");\n return { text, elements, links, depth, unseen };\n};\n\n/** This function gives the text that a reader sees, with one line for each block. */\nexport const visibleText = (root: DomNode): string => walkText(root).text;\n\n// ── JSON-LD ─────────────────────────────────────────────────────────────────\n\nconst WRAPPERS: ReadonlyArray<readonly [RegExp, RegExp]> = [\n [/^<!--/, /-->$/],\n [/^\\/\\/\\s{0,8}<!\\[CDATA\\[/, /\\/\\/\\s{0,8}\\]\\]>$/],\n [/^\\/\\*\\s{0,8}<!\\[CDATA\\[\\s{0,8}\\*\\//, /\\/\\*\\s{0,8}\\]\\]>\\s{0,8}\\*\\/$/],\n [/^<!\\[CDATA\\[/, /\\]\\]>$/],\n];\n\nconst unwrap = (source: string): string => {\n let text = source.replace(/^/, \"\").trim();\n for (const [open, close] of WRAPPERS) {\n text = text.replace(open, \"\").trim();\n text = text.replace(close, \"\").trim();\n }\n return text;\n};\n\n/**\n * This function cuts a script into its top-level JSON values. It also repairs two common faults: a\n * comma before a closing bracket, and a raw control character inside a string.\n */\nconst jsonValues = (source: string): string[] => {\n const values: string[] = [];\n let out: string[] = [];\n let depth = 0;\n let inString = false;\n let escaped = false;\n let pendingComma = false;\n for (let index = 0; index < source.length; index += 1) {\n const char = source[index]!;\n const code = source.charCodeAt(index);\n if (inString) {\n if (escaped) escaped = false;\n else if (char === \"\\\\\") escaped = true;\n else if (char === '\"') inString = false;\n // a string between two values is skipped with them\n if (depth === 0) continue;\n out.push(\n code >= 0x20\n ? char\n : char === \"\\n\"\n ? \"\\\\n\"\n : char === \"\\r\"\n ? \"\\\\r\"\n : char === \"\\t\"\n ? \"\\\\t\"\n : `\\\\u${code.toString(16).padStart(4, \"0\")}`,\n );\n continue;\n }\n if (depth === 0) {\n // between values only an object or an array starts a value\n if (char === \"{\" || char === \"[\") {\n depth = 1;\n out = [char];\n pendingComma = false;\n } else if (char === '\"') {\n inString = true;\n }\n continue;\n }\n if (code === 0x20 || code === 0x09 || code === 0x0a || code === 0x0d) {\n out.push(char);\n continue;\n }\n if (char === \",\") {\n if (pendingComma) out.push(\",\");\n pendingComma = true;\n continue;\n }\n if (pendingComma) {\n // a comma before a closing bracket is dropped\n if (char !== \"}\" && char !== \"]\") out.push(\",\");\n pendingComma = false;\n }\n out.push(char);\n if (char === '\"') inString = true;\n else if (char === \"{\" || char === \"[\") depth += 1;\n else if (char === \"}\" || char === \"]\") {\n depth -= 1;\n if (depth === 0) {\n values.push(out.join(\"\"));\n out = [];\n }\n }\n }\n // a value that never closes is given whole, and its parse fails\n if (depth > 0) values.push(out.join(\"\"));\n return values;\n};\n\nconst parseJsonLd = (\n sources: readonly string[],\n): { readonly records: Record<string, unknown>[]; readonly unreadable: number } => {\n const records: Record<string, unknown>[] = [];\n let unreadable = 0;\n // an explicit stack: JSON nested deeply in arrays cannot overflow the call stack\n const push = (first: unknown): void => {\n const stack: unknown[] = [first];\n const found: Record<string, unknown>[] = [];\n while (stack.length > 0) {\n const value = stack.pop();\n if (Array.isArray(value)) {\n for (let index = value.length - 1; index >= 0; index -= 1) stack.push(value[index]);\n continue;\n }\n if (value === null || typeof value !== \"object\") continue;\n const record = value as Record<string, unknown>;\n const graph = record[\"@graph\"];\n if (graph !== undefined && graph !== null && typeof graph === \"object\") {\n const { \"@graph\": _graph, ...rest } = record;\n // the record itself first, then its graph, in the order of the page\n stack.push(graph);\n if (Object.keys(rest).some((key) => key !== \"@context\")) found.push(rest);\n continue;\n }\n found.push(record);\n }\n records.push(...found);\n };\n for (const source of sources) {\n const text = unwrap(source);\n if (text.length === 0) continue;\n try {\n push(JSON.parse(text));\n continue;\n } catch {\n // repaired below\n }\n let failed = false;\n let any = false;\n for (const value of jsonValues(text)) {\n try {\n push(JSON.parse(value));\n any = true;\n } catch {\n failed = true;\n }\n }\n if (failed || !any) unreadable += 1;\n }\n return { records, unreadable };\n};\n\n/**\n * This function reads the JSON-LD blocks and makes arrays and `@graph` flat. It repairs a comma\n * before a closing bracket, a raw line break in a string and two values in one block. It ignores\n * a block that it cannot repair.\n */\nexport const readJsonLd = (sources: readonly string[]): Record<string, unknown>[] =>\n parseJsonLd(sources).records;\n\n/** This function gives the types that a JSON-LD object declares, without the schema.org prefix. */\nexport const typesOf = (record: Record<string, unknown>): string[] => {\n const raw = record[\"@type\"];\n const list = Array.isArray(raw) ? raw : raw === undefined ? [] : [raw];\n return list\n .filter((value): value is string => typeof value === \"string\")\n .map((value) => value.replace(/^.*[/#]/, \"\").replace(/^[A-Za-z][\\w.+-]*:/, \"\"));\n};\n\n// ── URLs ────────────────────────────────────────────────────────────────────\n\nexport { canonicalUrl };\n\nconst isWeb = (url: URL): boolean => url.protocol === \"http:\" || url.protocol === \"https:\";\nconst siteOf = (host: string): string => host.toLowerCase().replace(/^www\\./, \"\");\n\n// ── what the page needs ─────────────────────────────────────────────────────\n\n/** The marks of the pages that a bot check or a firewall sends in place of the content. */\nconst CHALLENGES: ReadonlyArray<readonly [string, RegExp]> = [\n [\"Incapsula\", /_Incapsula_Resource|Incapsula incident ID/i],\n [\"Cloudflare\", /\\/cdn-cgi\\/challenge-platform\\/|cf-chl-|cf_chl_opt|cf-browser-verification/i],\n [\"Sucuri\", /sucuri_cloudproxy|Sucuri WebSite Firewall/i],\n [\"DataDome\", /captcha-delivery\\.com/i],\n [\"PerimeterX\", /_pxCaptcha|px-captcha|captcha\\.px-cdn\\.net/i],\n [\"AWS WAF\", /AwsWafIntegration|token\\.awswaf\\.com|\\/challenge\\.js.{0,80}awswaf/i],\n [\"DDoS-Guard\", /ddos-guard\\.net\\/|__ddg1_/i],\n];\nconst CHALLENGE_TITLE =\n /^(?:just a moment\\.*|attention required!? \\| cloudflare|access to this page has been denied\\.?|please verify you are a human|are you a robot\\??|ddos-guard|checking your browser.{0,40})$/i;\n\nconst ASKS_FOR_SCRIPT =\n /(?:enable|turn on|activate|switch on|allow)\\s+(?:your\\s+)?javascript|javascript\\s+(?:is\\s+)?(?:required|disabled|turned off|not enabled|must be enabled|needs to be enabled)|(?:requires?|needs?)\\s+javascript|javascript\\s+aktivieren|activ(?:er|ez)\\s+(?:le\\s+)?javascript|habilit(?:ar|e)\\s+(?:el\\s+)?javascript/i;\n/** The noscript of a comment widget (Disqus) asks for JavaScript for the comments, not for the page. */\nconst COMMENTS = /comments|disqus/i;\n\n/** These elements hold the whole page of an application that its scripts draw. */\nconst APP_ROOTS = \"#root, #app, #__next, #__nuxt, #___gatsby, app-root, my-app, [data-reactroot]\";\n\nconst EMBEDDED: ReadonlyArray<readonly [string, (html: string, doc: DomDocument) => boolean]> = [\n [\"next\", (_html, doc) => doc.querySelector('script[id=\"__NEXT_DATA__\"]') !== null],\n [\"next-app\", (html) => html.includes(\"self.__next_f.push\")],\n [\"nuxt\", (html) => html.includes(\"__NUXT_DATA__\") || html.includes(\"window.__NUXT__\")],\n [\"apollo\", (html) => html.includes(\"__APOLLO_STATE__\")],\n];\n\n/** This function reads `content=\"0; url=/home\"`. A refresh with no URL reloads the page, and is no redirect. */\nconst refreshTarget = (\n content: string,\n): { readonly delay: number; readonly url: string } | undefined => {\n const text = content.slice(0, 2000).trim();\n const delay = /^\\d+(?:\\.\\d*)?/.exec(text)?.[0] ?? \"\";\n const url = text\n .slice(delay.length)\n .replace(/^[\\s;,]+/, \"\")\n .replace(/^url\\s*=\\s*/i, \"\")\n .replace(/^([\"'])(.*)\\1$/s, \"$2\")\n .trim();\n return url.length === 0 ? undefined : { delay: Number(delay || 0), url };\n};\n\n// ── composing the text ──────────────────────────────────────────────────────\n\n/** This function cuts text to a length at the end of a line where it can. It does not cut a surrogate pair. */\nconst cutHead = (text: string, length: number): string => {\n if (text.length <= length) return text;\n if (length <= 0) return \"\";\n const line = text.lastIndexOf(\"\\n\", length);\n let end = line > length - 2000 && line > 0 ? line : length;\n const code = text.charCodeAt(end - 1);\n if (code >= 0xd800 && code <= 0xdbff) end -= 1;\n return text.slice(0, end);\n};\n\n/** This function keeps the end of the text, from the start of a line where it can. */\nconst cutTail = (text: string, length: number): string => {\n if (text.length <= length) return text;\n if (length <= 0) return \"\";\n let start = text.length - length;\n const line = text.indexOf(\"\\n\", start);\n if (line !== -1 && line < start + 2000) start = line + 1;\n const code = text.charCodeAt(start);\n if (code >= 0xdc00 && code <= 0xdfff) start += 1;\n return text.slice(start);\n};\n\n/** This function keeps the start and the end of a text that is too long: a footer keeps its hours. */\nconst capText = (text: string): string =>\n text.length <= MAX_TEXT_CHARS\n ? text\n : `${cutHead(text, MAX_TEXT_CHARS - REST_RESERVE_CHARS - 2)}\\n\\n${cutTail(text, REST_RESERVE_CHARS)}`;\n\n/** A line that can label the lines below it: short, with no number, and not a sentence (\"Opening hours\"). */\nconst isHeading = (line: string): boolean =>\n line.length <= 40 && !/[.!?]$/.test(line) && !/[0-9]/.test(line);\n\n/**\n * This function finds the lines of the article in the lines of the page, one for one and in order.\n * Thus a line that the article and a sidebar share stays in the sidebar (\"10 am – 5 pm\").\n */\nconst articleLines = (all: readonly string[], main: readonly string[]): Uint8Array => {\n const taken = new Uint8Array(all.length);\n const positions = new Map<string, number[]>();\n all.forEach((line, index) => {\n const list = positions.get(line);\n if (list === undefined) positions.set(line, [index]);\n else list.push(index);\n });\n const cursors = new Map<string, number>();\n let at = 0;\n let matched = 0;\n for (const line of main) {\n const list = positions.get(line);\n if (list === undefined) continue;\n let cursor = cursors.get(line) ?? 0;\n while (cursor < list.length && list[cursor]! < at) cursor += 1;\n cursors.set(line, cursor);\n const position = list[cursor];\n if (position === undefined) continue;\n // a line far ahead is the same line only when the page has it once\n if (matched > 0 && position - at > 400 && list.length > 1) continue;\n taken[position] = 1;\n cursors.set(line, cursor + 1);\n at = position + 1;\n matched += 1;\n }\n return taken;\n};\n\n/** This function gives the lines of the page that are not in the article. Each run keeps the heading above it. */\nconst restOf = (all: readonly string[], taken: Uint8Array): string[] => {\n const rest: string[] = [];\n for (let index = 0; index < all.length; index += 1) {\n if (taken[index] === 1) continue;\n const above = all[index - 1];\n if (index > 0 && taken[index - 1] === 1 && above !== undefined && isHeading(above))\n rest.push(above);\n rest.push(all[index]!);\n }\n return rest;\n};\n\nexport const extractPage = (html: string, pageUrl: string): PageExtract => {\n const notes: string[] = [];\n const flat = flattenDeepMarkup(html);\n if (flat.dropped > 0) {\n notes.push(\n `the markup nests deeper than ${String(MAX_DEPTH)} elements, so the reader read the deeper tags as text`,\n );\n }\n const doc = parse(flat.html);\n const meta = (selector: string): string | null =>\n doc.querySelector(selector)?.getAttribute(\"content\")?.trim() || null;\n\n const scripts = [...doc.querySelectorAll(\"script\")];\n const parsed = parseJsonLd(\n scripts\n .filter((node) =>\n /^\\s*application\\/ld\\+json\\s*(?:;|$)/i.test(node.getAttribute(\"type\") ?? \"\"),\n )\n .map((node) => node.textContent ?? \"\"),\n );\n const jsonld = parsed.records;\n if (parsed.unreadable > 0) {\n notes.push(\n `${String(parsed.unreadable)} JSON-LD ${parsed.unreadable === 1 ? \"block\" : \"blocks\"} could not be read`,\n );\n }\n\n const page = (() => {\n try {\n return new URL(pageUrl);\n } catch {\n return undefined;\n }\n })();\n const baseHref = doc.querySelector(\"base[href]\")?.getAttribute(\"href\");\n const base = (() => {\n try {\n const resolved = new URL(baseHref ?? pageUrl, pageUrl);\n // a <base href=\"javascript:...\"> would take every relative link with it\n return isWeb(resolved) ? resolved.href : pageUrl;\n } catch {\n return pageUrl;\n }\n })();\n const resolve = (raw: string): URL | undefined => {\n try {\n const url = new URL(raw.trim(), base);\n if (!isWeb(url)) return undefined;\n url.username = \"\";\n url.password = \"\";\n return url;\n } catch {\n return undefined;\n }\n };\n const self = page === undefined ? undefined : canonicalUrl(page.href);\n\n const refresh = [...doc.querySelectorAll(\"meta[http-equiv]\")]\n .filter((node) => /^\\s*refresh\\s*$/i.test(node.getAttribute(\"http-equiv\") ?? \"\"))\n .map((node) => refreshTarget(node.getAttribute(\"content\") ?? \"\"))\n .find((target) => target !== undefined);\n const refreshUrl = refresh === undefined ? undefined : resolve(refresh.url);\n const redirect =\n refresh !== undefined &&\n refresh.delay <= 5 &&\n refreshUrl !== undefined &&\n canonicalUrl(refreshUrl.href) !== self\n ? canonicalUrl(refreshUrl.href)\n : null;\n\n const canonical = (() => {\n const node = [...doc.querySelectorAll(\"link[rel][href]\")].find((link) =>\n (link.getAttribute(\"rel\") ?? \"\").toLowerCase().split(/\\s+/).includes(\"canonical\"),\n );\n const url = node === undefined ? undefined : resolve(node.getAttribute(\"href\") ?? \"\");\n // a canonical on another site could take the page's identity: it is not trusted\n if (url === undefined || page === undefined || siteOf(url.hostname) !== siteOf(page.hostname)) {\n return null;\n }\n return canonicalUrl(url.href);\n })();\n\n const feeds: string[] = [];\n for (const link of doc.querySelectorAll(\"link[rel][href]\")) {\n if (feeds.length >= MAX_FEEDS) break;\n if (!(link.getAttribute(\"rel\") ?? \"\").toLowerCase().split(/\\s+/).includes(\"alternate\"))\n continue;\n const type = (link.getAttribute(\"type\") ?? \"\").split(\";\")[0]!.trim().toLowerCase();\n if (!FEED_TYPES.has(type)) continue;\n const url = resolve(link.getAttribute(\"href\") ?? \"\");\n const href = url === undefined ? undefined : canonicalUrl(url.href);\n if (href !== undefined && !feeds.includes(href)) feeds.push(href);\n }\n\n const clean = (value: string | null | undefined): string =>\n (value ?? \"\").replace(/\\s+/g, \" \").trim();\n const titles = [...doc.querySelectorAll(\"title\")];\n // an <svg> keeps a <title> of its own (\"Icon\"), which names no page\n const inSvg = (node: DomNode): boolean => {\n for (let parent = node.parentNode; parent; parent = parent.parentNode) {\n if (parent.nodeName.toLowerCase() === \"svg\") return true;\n }\n return false;\n };\n const title =\n meta('meta[property=\"og:title\"]') ||\n clean(titles.find((node) => !inSvg(node))?.textContent) ||\n clean(doc.querySelector(\"h1\")?.textContent) ||\n pageUrl;\n const description = meta('meta[name=\"description\"]') ?? meta('meta[property=\"og:description\"]');\n const lang = doc.documentElement?.getAttribute(\"lang\")?.trim() || null;\n const noscript = [...doc.querySelectorAll(\"noscript\")]\n .map((node) => node.textContent ?? \"\")\n .filter((text) => !COMMENTS.test(text))\n .join(\" \");\n const embedded = EMBEDDED.filter(([, found]) => found(html, doc)).map(([name]) => name);\n const appShell = [...doc.querySelectorAll(APP_ROOTS)].some(\n (node) => (node.textContent ?? \"\").trim().length === 0,\n );\n\n // the whole document: a page that omits <html> is not under\n // documentElement at all, and document.body can be a decoy (see DomDocument;\n // a homepage read as 0 characters and went to the browser for nothing)\n const walked = walkText(doc);\n // the links and Readability read only what a reader gets: text that the page hides goes now\n for (const node of walked.unseen) node.remove?.();\n\n const seen = new Set<string>(self === undefined ? [] : [self]);\n const links: PageLink[] = [];\n if (redirect !== null) {\n seen.add(redirect);\n links.push({ href: redirect, text: \"\" });\n }\n for (const anchor of doc.querySelectorAll(\"a[href]\")) {\n if (links.length >= MAX_LINKS) break;\n const url = resolve(anchor.getAttribute(\"href\") ?? \"\");\n if (url === undefined) continue;\n const href = canonicalUrl(url.href);\n const text =\n (anchor.textContent ?? \"\").replace(/\\s+/g, \" \").trim() ||\n anchor.getAttribute(\"aria-label\")?.trim() ||\n anchor.getAttribute(\"title\")?.trim() ||\n anchor.querySelector(\"img[alt]\")?.getAttribute(\"alt\")?.trim() ||\n \"\";\n // the link to the target of a meta refresh gets the text of the first anchor that names it\n if (href === redirect && links[0]?.href === redirect && links[0].text === \"\") {\n links[0] = { href, text: text.slice(0, 120) };\n continue;\n }\n // a link to the page itself (\"#menu\") is no link\n if (seen.has(href)) continue;\n seen.add(href);\n links.push({ href, text: text.slice(0, 120) });\n }\n\n const all = walked.text;\n let text = capText(all);\n let cut = text.length < all.length;\n if (all.length > SHORT_PAGE_CHARS) {\n const main = (() => {\n if (\n walked.elements > READABILITY_MAX_ELEMENTS ||\n walked.links > READABILITY_MAX_LINKS ||\n walked.depth > READABILITY_MAX_DEPTH\n ) {\n notes.push(\"the page is too large for Readability, so its text is in page order\");\n return \"\";\n }\n try {\n // Readability rewrites the document, and the reader has no more use for it. It gives its\n // article as an element, read here so that blocks stay lines\n const article = new Readability<DomNode>(\n doc as unknown as ConstructorParameters<typeof Readability>[0],\n {\n charThreshold: 500,\n disableJSONLD: true,\n serializer: (node) => node as unknown as DomNode,\n },\n ).parse();\n return article?.content === null || article?.content === undefined\n ? \"\"\n : visibleText(article.content);\n } catch {\n notes.push(\"Readability could not read the page, so its text is in page order\");\n return \"\";\n }\n })();\n if (main.length > 500) {\n // the article first, then every other line the page shows: a venue's\n // hours sit in a table or a sidebar Readability drops (a museum's visit\n // page), not only in its footer\n const lines = all.split(\"\\n\");\n const rest = restOf(lines, articleLines(lines, main.split(\"\\n\"))).join(\"\\n\");\n const head = cutHead(main, MAX_TEXT_CHARS - Math.min(rest.length, REST_RESERVE_CHARS) - 2);\n const tail = cutHead(rest, MAX_TEXT_CHARS - head.length - 2);\n text = rest.length > 0 ? `${head}\\n\\n${tail}` : head;\n cut = head.length < main.length || tail.length < rest.length;\n }\n }\n if (cut) notes.push(`the text is cut to ${String(MAX_TEXT_CHARS)} characters`);\n\n const visibleChars = all.length;\n const pageTitle = clean(titles[0]?.textContent);\n const blocked =\n visibleChars < 2000\n ? CHALLENGE_TITLE.test(pageTitle)\n ? (CHALLENGES.find(([, pattern]) => pattern.test(html))?.[0] ?? \"a bot check\")\n : (CHALLENGES.find(([, pattern]) => pattern.test(html))?.[0] ?? null)\n : null;\n const reason =\n // a browser would only go past a bot check or follow the redirect\n blocked !== null || redirect !== null\n ? null\n : // an app shell shows next to nothing; a small venue page can still say\n // its hours and address in a hundred characters, and needs no browser\n visibleChars < 80\n ? `only ${String(visibleChars)} characters of visible text`\n : visibleChars < 1200 && ASKS_FOR_SCRIPT.test(noscript)\n ? \"the page asks for JavaScript\"\n : visibleChars < 1200 && appShell\n ? \"an empty application root\"\n : null;\n\n return {\n title: title.replace(/\\s+/g, \" \").slice(0, 300),\n description,\n text,\n ...(cut ? { fullText: all } : {}),\n jsonld,\n links,\n lang,\n visibleChars,\n embedded,\n needsRender: reason !== null,\n renderReason: reason,\n canonical,\n feeds,\n redirect,\n blocked,\n notes,\n };\n};\n"],"mappings":";;;;;;;;;;;;;;;;;AAcA,MAAM,gBAAgB;;AAGtB,MAAM,cAAc,UAAsC;CACxD,IAAI;EACF,OAAO,IAAI,YAAY,MAAM,KAAK,CAAC,CAAC,YAAY,CAAC,CAAC,CAAC;CACrD,QAAQ;EACN;CACF;AACF;AAEA,MAAM,SAAS,UAA0C;CACvD,IAAI,MAAM,OAAO,OAAQ,MAAM,OAAO,OAAQ,MAAM,OAAO,KAAM,OAAO;CACxE,IAAI,MAAM,OAAO,OAAQ,MAAM,OAAO,KAAM,OAAO;CACnD,IAAI,MAAM,OAAO,OAAQ,MAAM,OAAO,KAAM,OAAO;AAErD;;AAGA,MAAM,aAAa,gBAAmD;CACpE,IAAI,gBAAgB,MAAM,OAAO,KAAA;CACjC,MAAM,QAAQ,8CAA8C,KAAK,YAAY,MAAM,GAAG,GAAG,CAAC;CAC1F,OAAO,QAAQ,MAAM,QAAQ,MAAM,KAAA;AACrC;;;;;AAMA,MAAM,mBAAmB,SAAyB;CAChD,IAAI,MAAM;CACV,IAAI,KAAK;CACT,KAAK,IAAI,OAAO,KAAK,QAAQ,MAAM,GAAG,SAAS,IAAI,OAAO,KAAK,QAAQ,QAAQ,EAAE,GAAG;EAClF,MAAM,QAAQ,KAAK,QAAQ,OAAO,OAAO,CAAC;EAE1C,IAAI,UAAU,IAAI;EAClB,OAAO,KAAK,MAAM,IAAI,IAAI;EAC1B,KAAK,QAAQ;CACf;CACA,OAAO,MAAM,KAAK,MAAM,EAAE;AAC5B;;AAGA,MAAM,mBAAmB,UAA0C;CACjE,IAAI,OAAO;CACX,MAAM,MAAM,KAAK,IAAI,MAAM,QAAQ,aAAa;CAChD,KAAK,IAAI,QAAQ,GAAG,QAAQ,KAAK,SAAS,GAAG,QAAQ,OAAO,aAAa,MAAM,MA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ACjE,QAAQ;EAEN,OAAO,IAAI,YAAY,SAAS,EAAE,OAAO,MAAM,CAAC,CAAC,CAAC,OAAO,KAAK;CAChE;AACF;;;ACrHA,MAAM,uBAAO,IAAI,IAAI;CACnB;CACA;CACA;CAEA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAED,MAAM,wBAAQ,IAAI,IAAI;CACpB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CAEA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;;;;AAKD,MAAM,yBAAS,IAAI,IAAI;CACrB;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;CACA;AACF,CAAC;;AAED,MAAM,uBAAO,IAAI,IAAI,CAAC,MAAM,IAAI,CAAC;AACjC,MAAM,2BAAW,IAAI,IAAI,CAAC,KAAK,QAAQ,CAAC;;AAGxC,MAAM,mBAAmB;AACzB,MAAM,iBAAiB;;AAEvB,MAAM,qBAAqB;AAC3B,MAAM,YAAY;;AAElB,MAAM,YAAY;;AAElB,MAAM,6BAAkC,IAAI,IAAI,CAAC,uBAAuB,sBAAsB,CAAC;;AAE/F,MAAM,2BAA2B;AACjC,MAAM,wBAAwB;AAC9B,MAAM,wBAAwB;;;;;AAK9B,MAAM,YAAY;AAgClB,MAAM,SAAS,SACZ,UAAU,IAAI,CAA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