browser-pilot-cli 0.1.6 → 0.2.2

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.
@@ -1,7 +0,0 @@
1
- #!/usr/bin/env node
2
-
3
- // src/defuddle-bundle.ts
4
- var DEFUDDLE_BUNDLE = '(function(){if(window.__defuddle_loaded)return;window.__defuddle_loaded=true;!function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.Defuddle=e():t.Defuddle=e()}(Object("undefined"!=typeof self?self:this),(()=>(()=>{"use strict";var t={640(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.ALLOWED_ATTRIBUTES_DEBUG=e.ALLOWED_ATTRIBUTES=e.ALLOWED_EMPTY_ELEMENTS=e.FOOTNOTE_LIST_SELECTORS=e.FOOTNOTE_INLINE_REFERENCES=e.TEST_ATTRIBUTES_SELECTOR=e.PARTIAL_SELECTORS_REGEX=e.PARTIAL_SELECTORS=e.TEST_ATTRIBUTES=e.EXACT_SELECTORS_JOINED=e.EXACT_SELECTORS=e.HIDDEN_EXACT_SKIP_SELECTOR=e.HIDDEN_EXACT_SELECTOR=e.CONTENT_ELEMENT_SELECTOR=e.INLINE_ELEMENTS=e.PRESERVE_ELEMENTS=e.BLOCK_LEVEL_ELEMENTS=e.BLOCK_ELEMENTS_SET=e.BLOCK_ELEMENTS_SELECTOR=e.BLOCK_ELEMENTS=e.MOBILE_WIDTH=e.ENTRY_POINT_ELEMENTS=void 0,e.ENTRY_POINT_ELEMENTS=["#post",".post-content",".post-body",".article-content","#article-content",".article_post",".article-wrapper",".entry-content",".content-article",".instapaper_body",".post",".markdown-body","article",\'[role="article"]\',"main",\'[role="main"]\',".article-body","#content","body"],e.MOBILE_WIDTH=600,e.BLOCK_ELEMENTS=["div","section","article","main","aside","header","footer","nav","content"],e.BLOCK_ELEMENTS_SELECTOR=e.BLOCK_ELEMENTS.join(","),e.BLOCK_ELEMENTS_SET=new Set(e.BLOCK_ELEMENTS),e.BLOCK_LEVEL_ELEMENTS=new Set([...e.BLOCK_ELEMENTS,"p","h1","h2","h3","h4","h5","h6","ul","ol","li","dl","dt","dd","pre","blockquote","figure","figcaption","table","thead","tbody","tfoot","tr","td","th","details","summary","address","hr","form","fieldset"]),e.PRESERVE_ELEMENTS=new Set(["pre","code","table","thead","tbody","tr","td","th","ul","ol","li","dl","dt","dd","figure","figcaption","picture","details","summary","blockquote","form","fieldset"]),e.INLINE_ELEMENTS=new Set(["a","span","strong","em","i","b","u","code","br","small","sub","sup","mark","date","del","ins","q","abbr","cite","relative-time","time","font"]),e.CONTENT_ELEMENT_SELECTOR=["math","[data-mathml]",".katex",".katex-mathml",".katex-display",".MathJax",".MathJax_Display",".MathJax_SVG","mjx-container","pre","code","table","img","picture","video","blockquote","figure"].join(", ");const r=["[hidden]",\'[aria-hidden="true"]\',".hidden",".invisible"],n=r.map((t=>\'[aria-hidden="true"]\'===t?\'[aria-hidden="true"]:not([class*="math"])\':t));e.HIDDEN_EXACT_SELECTOR=n.join(","),e.HIDDEN_EXACT_SKIP_SELECTOR=r.join(","),e.EXACT_SELECTORS=["noscript",\'script:not([type^="math/"])\',"style","meta","link","audio:not([src])",\'.ad:not([class*="gradient"])\',\'[class^="ad-" i]\',\'[class$="-ad" i]\',\'[id^="ad-" i]\',\'[id$="-ad" i]\',\'[role="banner" i]\',\'[alt*="advert" i]\',".promo",".Promo","#barrier-page",".alert",\'[id="comments" i]\',\'[id="comment" i]\',\'div[class*="cover-"]\',\'div[id*="cover-"]\',"ads-breadcrumbs","header:not(:has(p))",".header:not(.banner)","#header","#Header","#banner","#Banner","nav",".navigation","#navigation",\'[role="navigation" i]\',\'[role="dialog" i]\',\'[role*="complementary" i]\',\'[class*="pagination" i]\',".menu","#siteSub",".previous",".author",".Author",\'[class$="_bio"]\',"#categories",".contributor",".date","#date","[data-date]",".entry-meta",".meta",".tags","#tags",\'[rel="tag"]\',".toc",".Toc","#toc",".headline","#headline","#title","#Title","#articleTag",\'[href*="/tag/"]\',\'[href*="/tags/"]\',\'[href*="/author/"]\',\'[href*="/author?"]\',\'[href$="/author"]\',\'a[href*="copyright.com"]\',\'a[href*="google.com/preferences"]\',\'[href*="#toc"]\',\'[href="#top"]\',\'[href="#Top"]\',\'[href="#page-header"]\',\'[href="#content"]\',\'[href="#site-content"]\',\'[href="#main-content"]\',\'[href^="#main"]\',\'[src*="author"]\',"footer",".aside",\'aside:not([class*="callout"])\',"button","canvas","date","dialog","fieldset","form",\'input:not([type="checkbox"])\',"label","option","select",\'[role="listbox"]\',\'[role="option"]\',"textarea",...n,"instaread-player","iframe:not([src])",\'[class="logo" i]\',"#logo","#Logo","#newsletter","#Newsletter",".subscribe",".noprint",\'[data-print-layout="hide" i]\',\'[data-block="donotprint" i]\',\'[class*="clickable-icon" i]\',\'li span[class*="ltx_tag" i][class*="ltx_tag_item" i]\',\'a[href^="#"][class*="anchor" i]\',\'a[href^="#"][class*="ref" i]:not(.ltx_ref)\',\'[data-container*="most-viewed" i]\',".sidebar",".Sidebar","#sidebar","#Sidebar","#side-bar","#sitesub",\'[data-link-name*="skip" i]\',\'[aria-label*="skip" i]\',".copyright","#copyright",".licensebox","#page-info","#rss","#feed",".gutter","#primaryaudio","#NYT_ABOVE_MAIN_CONTENT_REGION",\'[data-testid="photoviewer-children-figure"] > span\',"table.infobox",\'[data-optimizely="related-articles-section" i]\',\'[data-orientation="vertical"]\',".gh-header-sticky",\'[data-testid="issue-metadata-sticky"]\'],e.EXACT_SELECTORS_JOINED=e.EXACT_SELECTORS.join(","),e.TEST_ATTRIBUTES=["class","id","data-component","data-test","data-testid","data-test-id","data-qa","data-cy"],e.PARTIAL_SELECTORS=["a-statement","(?<!main-)access-wall","activitypub","actioncall","addcomment","addtoany","advert","adlayout","ad-tldr","ad-placement","ads-container","_ad_","AdBlock_","AdUnit","after_content","after_main_article","afterpost","allterms","-alert-","alert-box","_archive","around-the-web","aroundpages","article-author","article-badges","article-banner","article-bottom-section","article-bottom","article-category","article-card","article-citation","article__copy","article_date","article-date","article-end ","article_header","article-header","article__header","article__hero","article__info","article-info","article-meta","article_meta","article__meta","articlename","article-subject","article_subject","article-snippet","article-separator","article--share","article--topics","articletags","article-tags","article_tags","articletitle","article-title","article_title","articletopics","article-topics","article-actions","article--lede","articlewell","associated-people","ambient-video__button","audio-card","author-bio","author-box","author-info","author_info","authorm","author-mini-bio","author-name","author-publish-info","authored-by","avatar","back-to-top","backlink_container","backlinks-section","bio-block","biobox","blog-pager","bookmark-","-bookmark","bottominfo","bottomnav","bottom-of-article","bottom-wrapper","brand-bar","bcrumb","breadcrumb","brdcrumb","button-wrapper","buttons-container","btn-","-btn","byline","captcha","card-text","card-media","card-post","carouselcontainer","carousel-container","cat_header","catlinks","_categories","card-author","card-content","chapter-list","collections","comments","-comment","commentbox","comment-button","commentcomp","comment-content","comment-count","comment-form","comment-number","comment-respond","comment-thread","comment-wrap","complementary","consent","contact-","content-card","copycontent","content-topics","contentpromo","context-bar","context-widget","core-collateral","cover-image","cover-photo","cover-wrap","created-date","creative-commons_","c-subscribe","_cta","-cta","cta-","cta_","current-issue","custom-list-number","dateline","dateheader","date-header","date-pub","disclaimer","disclosure","discussion","discuss_","-dismiss","disqus","donate","donation","dropdown","editorial_contact","editorial-contact","element-invisible","elementor-shortcode","eletters","emailsignup","emoji-bar","engagement-widget","enhancement-","entry-author-info","entry-categories","entry-date","entry-title","entry-utility","-error","error-","eyebrow","expand-reduce","external-anchor","externallinkembedwrapper","extra-services","extra-title","facebook","fancy-box","favorite","featured-content","feature_feed","feedback","feed-links","field-site-sections","fixheader","floating-vid","follower","footer","footnote-back","footnoteback","form-group","for-you","frontmatter","further-reading","fullbleedheader","gallery-count","gated-","gh-feed","gist-meta","goog-","graph-view","hamburger","header_logo","header-logo","header-pattern","hero-list","hide-for-print","hide-print","hide-when-no-script","hidden-print","hidden-sidenote","hidden-accessibility","infoline","inline-topic","instacartIntegration","interlude","interaction","itemendrow","intro-date","invisible","jp-no-solution","jp-relatedposts","jswarning","js-warning","jumplink","jumpto","jump-to-","js-skip-to-content","keepreading","keep-reading","keep_reading","keyword_wrap","kicker","labstab","-labels","language-name","lastupdated","latest-content","-ledes-","-license","license-","lightbox-popup","like-button","link-box","links-grid","links-title","listing-dynamic-terms","list-tags","listinks","loading","loa-info","logo_container","ltx_role_refnum","ltx_tag_bibitem","ltx_error","masthead","marketing","media-inquiry","-menu","menu-","metadata","meta-bottom","meta-date","meta-row","might-like","minibio","more-about","mod-paywall","_modal","-modal","more-","morenews","morestories","more_wrapper","most-read","move-helper","mw-editsection","mw-cite-backlink","mw-indicators","mw-jump-link","nav-","nav_","navigation-post","next-","next_prev","no-script","newsgallery","news-story-title","newsletter_","newsletterbanner","newslettercontainer","newsletter-form","newsletter-signup","newslettersignup","newsletterwidget","newsletterwrapper","not-found","notessection","nomobile","noprint","open-slideshow","originally-published","other-blogs","outline-view","pagehead","page-header","page-title","paywall_message","-partners","permission-","plea","popular","popup_links","pop_stories","pop-up","post__author","post-author","post-bottom","post__category","postcomment","postdate","post-date","post_date","post-details","post-feeds","postinfo","post-info","post_info","post-inline-date","post-links","postlist","post_list","post_meta","post-meta","postmeta","post_more","postnavi","post-navigation","postpath","post-preview","postsnippet","post_snippet","post-snippet","post-subject","posttax","post-tax","post_tax","posttag","post_tag","post-tag","post_time","posttitle","post-title","post_title","post__title","post-ufi-button","prev-post","prevnext","prev_next","prev-next","previousnext","press-inquiries","print-none","print-header","print:hidden","privacy-notice","privacy-settings","profile","promo_article","promo-bar","promo-box","pubdate","pub_date","pub-date","publish_date","publish-date","publication-date","publicationName","qr-code","qr_code","quick_up","_rail","ratingssection","read_also","readmore","read-next","read_next","read_time","read-time","reading_time","reading-time","reading-list","recent-","recent-articles","recentpost","recent_post","recent-post","recommend","redirectedfrom","recirc","register","related","relevant","reversefootnote","robots-nocontent","_rss","rss-link","screen-reader-text","scroll_to","scroll-to","_search","-search","section-nav","series-banner","share-box","sharedaddy","share-icons","sharelinks","share-post","share-print","share-section","sharing_","shariff-","show-for-print","sidebartitle","sidebar-content","sidebar-wrapper","sideitems","sidebar-author","sidebar-item","side-box","side-logo","sign-in-gate","similar-","similar_","similars-","site-index","site-header","siteheader","site-logo","site-name","site-wordpress","skip-content","skip-to-content","skip-link","c-skip-link","_skip-link","-slider","slug-wrap","social-author","social-shar","social-date","speechify-ignore","speedbump","sponsor","springercitation","sr-only","_stats","story-date","story-navigation","storyreadtime","storysmall","storypublishdate","subject-label","subhead","submenu","-subscribe-","subscriber-drive","subscription-","_tags","tags__item","tag_list","tag-list","taxonomy","table-of-contents","tblc","tabs-","terminaltout","time-rubric","timestamp","time-read","time-to-read","tip_off","tiptout","-tout-","toc-container","toggle-caption","tooltip-content","topbar","subnavbar","topic-authors","topic-footer","topic-list","topic-subnav","top-wrapper","tree-item","trending","trust-feat","trust-badge","trust-project","chakra-badge","twitter","twiblock","u-hide","upsell","viewbottom","view-language","yarpp-related","visually-hidden","welcomebox","widget_pages","w-form-done","w-form-fail"],e.PARTIAL_SELECTORS_REGEX=new RegExp(e.PARTIAL_SELECTORS.join("|"),"i"),e.TEST_ATTRIBUTES_SELECTOR=e.TEST_ATTRIBUTES.map((t=>`[${t}]`)).join(","),e.FOOTNOTE_INLINE_REFERENCES=["sup.reference","cite.ltx_cite",\'sup[id^="fnr"]\',\'span[id^="fnr"]\',\'span[class*="footnote_ref"]\',\'span[class*="footnote-ref"]\',"span.footnote-link","a.citation",\'a[id^="ref-link"]\',\'a[href^="#fn"]\',\'a[href^="#cite"]\',\'a[href^="#reference"]\',\'a[href^="#footnote"]\',\'a[href^="#r"]\',\'a[href^="#b"]\',\'a[href*="cite_note"]\',\'a[href*="cite_ref"]\',"a.footnote-anchor","span.footnote-hovercard-target a",\'a[role="doc-biblioref"]\',\'a[id^="fnref"]\',\'a[id^="ref-link"]\',"sup.footnoteref"].join(","),e.FOOTNOTE_LIST_SELECTORS=["div.footnote ol","div.footnotes ol",\'div[role="doc-endnotes"]\',\'div[role="doc-footnotes"]\',"ol.footnotes-list","ol.footnotes","ol.references",\'ol[class*="article-references"]\',"section.footnotes ol",\'section[role="doc-endnotes"]\',\'section[role="doc-footnotes"]\',\'section[role="doc-bibliography"]\',"ul.footnotes-list","ul.ltx_biblist",\'div.footnote[data-component-name="FootnoteToDOM"]\',"div.footnotes-footer","div.footnote-definitions","#footnotes"].join(","),e.ALLOWED_EMPTY_ELEMENTS=new Set(["area","audio","base","br","circle","col","defs","ellipse","embed","figure","g","hr","iframe","img","input","line","link","mask","meta","object","param","path","pattern","picture","polygon","polyline","rect","source","stop","svg","td","th","track","use","video","wbr"]),e.ALLOWED_ATTRIBUTES=new Set(["alt","allow","allowfullscreen","aria-label","checked","colspan","controls","data-latex","data-src","data-srcset","data-callout","data-callout-title","data-lang","dir","display","frameborder","headers","height","href","kind","label","lang","role","rowspan","src","srclang","srcset","title","type","width","accent","accentunder","align","columnalign","columnlines","columnspacing","columnspan","data-mjx-texclass","depth","displaystyle","fence","frame","framespacing","linethickness","lspace","mathsize","mathvariant","maxsize","minsize","movablelimits","notation","rowalign","rowlines","rowspacing","rowspan","rspace","scriptlevel","separator","stretchy","symmetric","voffset","xmlns"]),e.ALLOWED_ATTRIBUTES_DEBUG=new Set(["class","id"])},628(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.Defuddle=void 0;const o=r(608),i=r(917),s=r(640),a=r(840),l=r(610),c=r(726),u=r(550),d=r(408),h=r(983),m=r(393),p=r(172),f=r(662),g=r(552),v=r(639),y=new Set(["title","author","published","site","description","image","language"]);e.Defuddle=class{constructor(t,e={}){this._schemaOrgData=void 0,this._schemaOrgExtracted=!1,this._inExtractorPipelineRun=!1,this.doc=t,this.options=e,this.debug=e.debug||!1}getSchemaOrgData(){return this._schemaOrgExtracted||(this._schemaOrgData=this._extractSchemaOrgData(this.doc),this._schemaOrgExtracted=!0),this._schemaOrgData}parse(){let t=this.parseInternal();if(t.wordCount<200){this._log("Initial parse returned very little content, trying again");const e=this.parseInternal({removePartialSelectors:!1});e.wordCount>2*t.wordCount&&(this._log("Retry produced more content"),t=e)}if(t.wordCount<50){this._log("Still very little content, retrying without hidden-element removal");const e=this.parseInternal({removeHiddenElements:!1});e.wordCount>2*t.wordCount&&(this._log("Hidden-element retry produced more content"),t=e);const r=this.findLargestHiddenContentSelector();if(r){this._log("Retrying with hidden content selector:",r);const e=this.parseInternal({removeHiddenElements:!1,removePartialSelectors:!1,contentSelector:r});(e.wordCount>t.wordCount||e.wordCount>Math.max(20,.7*t.wordCount)&&e.content.length<t.content.length)&&(this._log("Hidden-selector retry produced better focused content"),t=e)}}if(t.wordCount<50){this._log("Still very little content, retrying without scoring/partial selectors (possible index page)");const e=this.parseInternal({removeLowScoring:!1,removePartialSelectors:!1,removeContentPatterns:!1});e.wordCount>t.wordCount&&(this._log("Index page retry produced more content"),t=e)}this._stripUnsafeElements();const e=this._getSchemaText(t.schemaOrgData);if(e&&this.countHtmlWords(e)>1.5*t.wordCount){const r=this._findElementBySchemaText(this.doc.body,e);if(r){const e=this.getElementSelector(r);this._log("Schema.org suggests a better content element, retrying with selector:",e);t=this.parseInternal({contentSelector:e})}else this._log("Using schema.org text as content (DOM element not found)"),t.content=e,t.wordCount=this.countHtmlWords(e)}return t}_getSchemaText(t,e=0){if(!t||e>10)return"";const r=Array.isArray(t)?t:[t];for(const t of r)if(Array.isArray(t)){const r=this._getSchemaText(t,e+1);if(r)return r}else{if((null==t?void 0:t.text)&&"string"==typeof t.text)return t.text;if((null==t?void 0:t.articleBody)&&"string"==typeof t.articleBody)return t.articleBody;if((null==t?void 0:t["@graph"])&&Array.isArray(t["@graph"])){const r=this._getSchemaText(t["@graph"],e+1);if(r)return r}}return""}_stripUnsafeElements(){const t=this.doc.body;if(!t)return;const e=t.querySelectorAll(\'script:not([type^="math/"]), style, noscript, frame, frameset, object, embed, applet, base\');for(const t of e)t.remove();const r=t.querySelectorAll("*");for(const t of r)for(const e of Array.from(t.attributes)){const r=e.name.toLowerCase();(r.startsWith("on")||"srcdoc"===r||["href","src","action","formaction","xlink:href"].includes(r)&&(0,v.isDangerousUrl)(e.value))&&t.removeAttribute(e.name)}}_findElementBySchemaText(t,e){var r;const n=((null===(r=e.split(/\\n\\s*\\n/)[0])||void 0===r?void 0:r.trim())||"").substring(0,100).trim();if(!n)return null;const o=(0,g.countWords)(e);let i=null,s=1/0;const a=t.querySelectorAll("*");for(const e of a){if(e===t)continue;const r=e.textContent||"";if(!r.includes(n))continue;const a=(0,g.countWords)(r);a>=.8*o&&a<s&&(s=a,i=e)}return i}findLargestHiddenContentSelector(){const t=this.doc.body;if(!t)return;const e=Array.from(t.querySelectorAll(s.HIDDEN_EXACT_SKIP_SELECTOR)).filter((t=>!(t.getAttribute("class")||"").includes("math")));let r=null,n=0;for(const t of e){const e=(0,g.countWords)(t.textContent||"");e>n&&(r=t,n=e)}return!r||n<30?void 0:this.getElementSelector(r)}_getLargestImageSrc(t){const e=t.getAttribute("srcset")||"";if(!e)return t.getAttribute("src")||"";const r=/(.+?)\\s+(\\d+(?:\\.\\d+)?)w/g;let n,o="",i=0,s=0;for(;null!==(n=r.exec(e));){let t=n[1].trim();s>0&&(t=t.replace(/^,\\s*/,"")),s=r.lastIndex;const e=parseFloat(n[2]);t&&e>i&&(i=e,o=t)}let a=o||t.getAttribute("src")||"";return a=a.replace(/,w_\\d+/g,"").replace(/,c_\\w+/g,""),a}parseAsync(){return n(this,void 0,void 0,(function*(){var t;if(!1!==this.options.useAsync){const t=yield this.tryAsyncExtractor(i.ExtractorRegistry.findPreferredAsyncExtractor.bind(i.ExtractorRegistry));if(t)return t}const e=this.parse();return e.wordCount>0||!1===this.options.useAsync?e:null!==(t=yield this.tryAsyncExtractor(i.ExtractorRegistry.findAsyncExtractor.bind(i.ExtractorRegistry)))&&void 0!==t?t:e}))}fetchAsyncVariables(){return n(this,void 0,void 0,(function*(){var t;if(!1===this.options.useAsync)return null;try{const e=this.options.url||this.doc.URL,r=this.getSchemaOrgData(),n={includeReplies:null!==(t=this.options.includeReplies)&&void 0!==t?t:"extractors",language:this.options.language},o=i.ExtractorRegistry.findPreferredAsyncExtractor(this.doc,e,r,n);if(o){const t=yield o.extractAsync();return this.getExtractorVariables(t.variables)||null}}catch(t){console.error("Defuddle","Error fetching async variables:",t)}return null}))}tryAsyncExtractor(t){return n(this,void 0,void 0,(function*(){var e;try{const r=this.options.url||this.doc.URL,n=this.getSchemaOrgData(),i={includeReplies:null!==(e=this.options.includeReplies)&&void 0!==e?e:"extractors",language:this.options.language},s=t(this.doc,r,n,i);if(s){const t=Date.now(),e=yield s.extractAsync(),r=this._collectMetaTags(),i=o.MetadataExtractor.extract(this.doc,n,r);return this.buildExtractorResponse(e,i,t,s,r)}}catch(t){console.error("Defuddle","Error in async extraction:",t)}return null}))}parseInternal(t={}){var e,r,n,s,g,y,b;const C=Date.now(),x={},E=null!==(e=this.options.profile)&&void 0!==e&&e,S=(t,e)=>{if(!E)return e();const r=performance.now(),n=e();return x[t]=Math.round(performance.now()-r),n};if(!this.doc.documentElement){const t=this.options.url||"";return{content:"",title:"",description:"",domain:t?new URL(t).hostname:"",favicon:"",image:"",language:"",parseTime:Date.now()-C,published:"",author:"",site:"",schemaOrgData:null,wordCount:0}}const w=Object.assign(Object.assign({removeExactSelectors:!0,removePartialSelectors:!0,removeHiddenElements:!0,removeLowScoring:!0,removeSmallImages:!0,removeContentPatterns:!0,standardize:!0,includeReplies:"extractors"},this.options),t),A=[],T=this.getSchemaOrgData();this._metaTags||(this._metaTags=this._collectMetaTags());const _=this._metaTags;this._metadata||(this._metadata=o.MetadataExtractor.extract(this.doc,T,_));const L=this._metadata;w.removeImages&&this.removeImages(this.doc);try{const t=w.url||this.doc.URL,e={includeReplies:w.includeReplies,language:w.language};if(!this._inExtractorPipelineRun){const o=i.ExtractorRegistry.findExtractor(this.doc,t,T,e);if(o&&o.canExtract()){const t=o.extract();if(t.contentSelector){this._inExtractorPipelineRun=!0;try{const e=this.parseInternal({contentSelector:t.contentSelector,removeLowScoring:!1,removeHiddenElements:!1}),i=this.getExtractorVariables(t.variables);return Object.assign(Object.assign(Object.assign({},e),{title:(null===(r=t.variables)||void 0===r?void 0:r.title)||e.title,description:(null===(n=t.variables)||void 0===n?void 0:n.description)||e.description,author:(null===(s=t.variables)||void 0===s?void 0:s.author)||e.author,published:(null===(g=t.variables)||void 0===g?void 0:g.published)||e.published,site:(null===(y=t.variables)||void 0===y?void 0:y.site)||e.site,language:(null===(b=t.variables)||void 0===b?void 0:b.language)||e.language,extractorType:o.constructor.name.replace("Extractor","").toLowerCase()}),i?{variables:i}:{})}finally{this._inExtractorPipelineRun=!1}}return this.buildExtractorResponse(t,L,C,o,_)}}this._mobileStyles||(this._mobileStyles=this._evaluateMediaQueries(this.doc));const o=this._mobileStyles;this._smallImages||(this._smallImages=(0,d.findSmallImages)(this.doc,this.debug));const N=this._smallImages;let q;S("cloneDocument",(()=>{var t;q=this.doc.cloneNode(!0),null===(t=q.body)||void 0===t||t.normalize()})),S("flattenShadowRoots",(()=>this.flattenShadowRoots(this.doc,q))),S("resolveStreamedContent",(()=>this.resolveStreamedContent(q))),S("applyMobileStyles",(()=>this.applyMobileStyles(q,o)));const k=S("findMainContent",(()=>{let t=null;if(w.contentSelector&&(t=q.querySelector(w.contentSelector),this._log("Using contentSelector:",w.contentSelector,t?"found":"not found")),t||(t=this.findMainContent(q)),t&&"body"===t.tagName.toLowerCase()){const e=this._getSchemaText(T);if(e){const r=this._findElementBySchemaText(q.body,e);r&&(this._log("Found content element via schema.org text"),t=r)}}return t}));if(!k){const t=this.doc.body?this.resolveContentUrls((0,v.serializeHTML)(this.doc.body)):"",e=Date.now();return Object.assign(Object.assign({content:t},L),{wordCount:this.countHtmlWords(t),parseTime:Math.round(e-C),metaTags:_})}S("removeMetadataBlock",(()=>{(L.published||L.author)&&(0,f.removeMetadataBlock)(k),k.querySelectorAll("wbr").forEach((t=>t.remove()))})),S("standardizeFootnotesCallouts",(()=>{w.standardize&&((0,l.standardizeFootnotes)(k),(0,c.standardizeCallouts)(k))})),S("removeSmallImages",(()=>{w.removeSmallImages&&(0,d.removeSmallImages)(q,N,this.debug)})),S("removeHiddenElements",(()=>{w.removeHiddenElements&&(0,h.removeHiddenElements)(q,this.debug,A)})),S("removeBySelector",(()=>{(w.removeExactSelectors||w.removePartialSelectors)&&(0,m.removeBySelector)(q,this.debug,w.removeExactSelectors,w.removePartialSelectors,k,A,!1===w.removeHiddenElements)})),S("removeLowScoring",(()=>{w.removeLowScoring&&u.ContentScorer.scoreAndRemove(q,this.debug,A,k)})),S("removeByContentPattern",(()=>{if(w.removeContentPatterns&&k){const t=this.options.url||this.doc.URL||"";(0,p.removeByContentPattern)(k,this.debug,t,A)}})),S("standardizeContent",(()=>{w.standardize&&(0,a.standardizeContent)(k,L,this.doc,this.debug,E?x:void 0)})),S("resolveRelativeUrls",(()=>this.resolveRelativeUrls(k)));const $=k.outerHTML,M=Date.now(),O=Object.assign(Object.assign({content:$},L),{wordCount:this.countHtmlWords($),parseTime:Math.round(M-C),metaTags:_});return this.debug&&(O.debug={contentSelector:this.getElementSelector(k),removals:A}),this.options.profile&&(O.profile=x),O}catch(t){console.error("Defuddle","Error processing document:",t);const e=this.doc.body?this.resolveContentUrls((0,v.serializeHTML)(this.doc.body)):"",r=Date.now();return Object.assign(Object.assign({content:e},L),{wordCount:this.countHtmlWords(e),parseTime:Math.round(r-C),metaTags:_})}}countHtmlWords(t){const e=t.replace(/<[^>]*>/g," ").replace(/&nbsp;/gi," ").replace(/&amp;/gi,"&").replace(/&lt;/gi,"<").replace(/&gt;/gi,">").replace(/&quot;/gi,\'"\').replace(/&#\\d+;/g," ").replace(/&\\w+;/g," ");return(0,g.countWords)(e)}_log(...t){this.debug&&console.log("Defuddle:",...t)}_evaluateMediaQueries(t){const e=[],r=/max-width[^:]*:\\s*(\\d+)/;try{if(!t.styleSheets)return e;const n=Array.from(t.styleSheets).filter((t=>{try{return t.cssRules,!0}catch(t){return t instanceof DOMException&&t.name,!1}}));n.flatMap((t=>{try{return"undefined"==typeof CSSMediaRule?[]:Array.from(t.cssRules).filter((t=>t instanceof CSSMediaRule&&t.conditionText.includes("max-width")))}catch(t){return this.debug&&console.warn("Defuddle: Failed to process stylesheet:",t),[]}})).forEach((t=>{const n=t.conditionText.match(r);if(n){const r=parseInt(n[1]);if(s.MOBILE_WIDTH<=r){Array.from(t.cssRules).filter((t=>t instanceof CSSStyleRule)).forEach((t=>{try{e.push({selector:t.selectorText,styles:t.style.cssText})}catch(t){this.debug&&console.warn("Defuddle: Failed to process CSS rule:",t)}}))}}}))}catch(t){console.error("Defuddle: Error evaluating media queries:",t)}return e}applyMobileStyles(t,e){e.forEach((({selector:e,styles:r})=>{try{t.querySelectorAll(e).forEach((t=>{t.setAttribute("style",(t.getAttribute("style")||"")+r)}))}catch(t){console.error("Defuddle","Error applying styles for selector:",e,t)}}))}removeImages(t){const e=t.getElementsByTagName("img");Array.from(e).forEach((t=>{t.remove()}))}findMainContent(t){const e=[];if(s.ENTRY_POINT_ELEMENTS.forEach(((r,n)=>{t.querySelectorAll(r).forEach((t=>{let r=40*(s.ENTRY_POINT_ELEMENTS.length-n);r+=u.ContentScorer.scoreElement(t),e.push({element:t,score:r,selectorIndex:n})}))})),0===e.length)return this.findContentByScoring(t);if(e.sort(((t,e)=>e.score-t.score)),this.debug&&this._log("Content candidates:",e.map((t=>({element:t.element.tagName,selector:this.getElementSelector(t.element),score:t.score})))),1===e.length&&"body"===e[0].element.tagName.toLowerCase()){const e=this.findTableBasedContent(t);if(e)return e}const r=e[0];let n=r;for(let t=1;t<e.length;t++){const o=e[t],i=(0,g.countWords)(o.element.textContent||"");if(o.selectorIndex<n.selectorIndex&&n.element.contains(o.element)&&i>50){let t=0;for(const n of e)if(n.selectorIndex===o.selectorIndex&&r.element.contains(n.element)&&++t>1)break;if(t>1)continue;n=o}}return n!==r?n.element:r.element}findTableBasedContent(t){if(!Array.from(t.getElementsByTagName("table")).some((t=>{var e;const r=parseInt(t.getAttribute("width")||"0"),n=this.getComputedStyle(t);return r>400||(null===(e=null==n?void 0:n.width)||void 0===e?void 0:e.includes("px"))&&parseInt(n.width)>400||"center"===t.getAttribute("align")||(t.className||"").toLowerCase().includes("content")||(t.className||"").toLowerCase().includes("article")})))return null;const e=Array.from(t.getElementsByTagName("td"));return u.ContentScorer.findBestElement(e)}findContentByScoring(t){const e=[];return t.querySelectorAll(s.BLOCK_ELEMENTS_SELECTOR).forEach((t=>{const r=u.ContentScorer.scoreElement(t);r>0&&e.push({score:r,element:t})})),e.length>0?e.sort(((t,e)=>e.score-t.score))[0].element:null}getElementSelector(t){const e=[];let r=t;for(;r&&r!==this.doc.documentElement;){let t=r.tagName.toLowerCase();r.id?t+="#"+r.id:(0,v.getClassName)(r)&&(t+="."+(0,v.getClassName)(r).trim().split(/\\s+/).join(".")),e.unshift(t),r=r.parentElement}return e.join(" > ")}getComputedStyle(t){return(0,g.getComputedStyle)(t)}resolveRelativeUrls(t){const e=this.options.url||this.doc.URL;if(!e)return;let r=e;const n=this.doc.querySelector("base[href]");if(n){const t=n.getAttribute("href");if(t)try{r=new URL(t,e).href}catch(t){}}const o=t=>{const e=t.trim().replace(/^\\\\?["\']+/,"").replace(/\\\\?["\']+$/,"");if(e.startsWith("#"))return e;try{return new URL(e,r).href}catch(r){return e||t}};t.querySelectorAll("[href]").forEach((t=>{const e=t.getAttribute("href");e&&t.setAttribute("href",o(e))})),t.querySelectorAll("[src]").forEach((t=>{const e=t.getAttribute("src");e&&t.setAttribute("src",o(e))})),t.querySelectorAll("[srcset]").forEach((t=>{const e=t.getAttribute("srcset");if(e){const r=/(.+?)\\s+(\\d+(?:\\.\\d+)?[wx])/g,n=[];let i,s=0;for(;null!==(i=r.exec(e));){let t=i[1].trim();s>0&&(t=t.replace(/^,\\s*/,"")),s=r.lastIndex,n.push(`${o(t)} ${i[2]}`)}if(n.length>0)t.setAttribute("srcset",n.join(", "));else{const r=e.split(",").map((t=>{const e=t.trim().split(/\\s+/);return e[0]&&(e[0]=o(e[0])),e.join(" ")})).join(", ");t.setAttribute("srcset",r)}}})),t.querySelectorAll("[poster]").forEach((t=>{const e=t.getAttribute("poster");e&&t.setAttribute("poster",o(e))}))}flattenShadowRoots(t,e){var r,n,o;if(!t.body||!e.body)return;const i=Array.from(t.body.querySelectorAll("*")),s=i.find((t=>t.shadowRoot));if(!s)return;const a=Array.from(e.body.querySelectorAll("*"));if((null!==(o=null===(n=null===(r=s.shadowRoot)||void 0===r?void 0:r.childNodes)||void 0===n?void 0:n.length)&&void 0!==o?o:0)>0)for(let t=i.length-1;t>=0;t--){const r=i[t];if(!r.shadowRoot)continue;const n=a[t];if(!n)continue;const o=r.shadowRoot.innerHTML;o.length>0&&this.replaceShadowHost(n,o,e)}else{const t=[];for(let e=0;e<i.length;e++){const r=i[e],n=r.getAttribute("data-defuddle-shadow");if(!n)continue;const o=a[e];o&&(t.push({cloneEl:o,html:n}),r.removeAttribute("data-defuddle-shadow"),o.removeAttribute("data-defuddle-shadow"))}for(const{cloneEl:r,html:n}of t)this.replaceShadowHost(r,n,e)}}resolveStreamedContent(t){const e=t.querySelectorAll("script"),r=[],n=/\\$RC\\("(B:\\d+)","(S:\\d+)"\\)/g;for(const t of e){const e=t.textContent||"";if(!e.includes("$RC("))continue;let o;for(n.lastIndex=0;null!==(o=n.exec(e));)r.push({templateId:o[1],contentId:o[2]})}if(0===r.length)return;let o=0;for(const{templateId:e,contentId:n}of r){const r=t.getElementById(e),i=t.getElementById(n);if(!r||!i)continue;const s=r.parentNode;if(!s)continue;let a=r.nextSibling,l=!1;for(;a;){const t=a.nextSibling;if(8===a.nodeType&&"/$"===a.data){a.remove(),l=!0;break}a.remove(),a=t}if(l){for(;i.firstChild;)s.insertBefore(i.firstChild,r);r.remove(),i.remove(),o++}}o>0&&this._log("Resolved streamed content:",o,"suspense boundaries")}replaceShadowHost(t,e,r){var n;const o=(0,v.parseHTML)(r,e);if(t.tagName.includes("-")){const e=r.createElement("div");e.appendChild(o),null===(n=t.parentNode)||void 0===n||n.replaceChild(e,t)}else t.textContent="",t.appendChild(o)}resolveContentUrls(t){if(!(this.options.url||this.doc.URL))return t;const e=this.doc.createElement("div");return e.appendChild((0,v.parseHTML)(this.doc,t)),this.resolveRelativeUrls(e),(0,v.serializeHTML)(e)}_extractSchemaOrgData(t){const e=t.querySelectorAll(\'script[type="application/ld+json"]\'),r=[];e.forEach((t=>{let e=t.textContent||"";try{e=e.replace(/\\/\\*[\\s\\S]*?\\*\\/|^\\s*\\/\\/.*$/gm,"").replace(/^\\s*<!\\[CDATA\\[([\\s\\S]*?)\\]\\]>\\s*$/,"$1").replace(/^\\s*(\\*\\/|\\/\\*)\\s*|\\s*(\\*\\/|\\/\\*)\\s*$/g,"").trim();const t=JSON.parse(e);t["@graph"]&&Array.isArray(t["@graph"])?r.push(...t["@graph"]):r.push(t)}catch(t){console.error("Defuddle: Error parsing schema.org data:",t),this.debug&&console.error("Defuddle: Problematic JSON content:",e)}}));const n=t=>{if("string"==typeof t)return this._decodeHTMLEntities(t);if(Array.isArray(t))return t.map(n);if("object"==typeof t&&null!==t){const e={};for(const r in t)Object.prototype.hasOwnProperty.call(t,r)&&(e[r]=n(t[r]));return e}return t};return r.map(n)}_collectMetaTags(){const t=[];return this.doc.querySelectorAll("meta").forEach((e=>{const r=e.getAttribute("name"),n=e.getAttribute("property");let o=e.getAttribute("content");o&&t.push({name:r,property:n,content:this._decodeHTMLEntities(o)})})),t}_decodeHTMLEntities(t){return(0,v.decodeHTMLEntities)(this.doc,t)}buildExtractorResponse(t,e,r,n,o){var i,s,a,l,c,u;const d=this.resolveContentUrls(t.contentHtml),h=this.getExtractorVariables(t.variables);return Object.assign({content:d,title:(null===(i=t.variables)||void 0===i?void 0:i.title)||e.title,description:(null===(s=t.variables)||void 0===s?void 0:s.description)||e.description,domain:e.domain,favicon:e.favicon,image:e.image,language:(null===(a=t.variables)||void 0===a?void 0:a.language)||e.language,published:(null===(l=t.variables)||void 0===l?void 0:l.published)||e.published,author:(null===(c=t.variables)||void 0===c?void 0:c.author)||e.author,site:(null===(u=t.variables)||void 0===u?void 0:u.site)||e.site,schemaOrgData:e.schemaOrgData,wordCount:this.countHtmlWords(t.contentHtml),parseTime:Math.round(Date.now()-r),extractorType:n.constructor.name.replace("Extractor","").toLowerCase(),metaTags:o},h?{variables:h}:{})}getExtractorVariables(t){if(!t)return;const e={};let r=!1;for(const[n,o]of Object.entries(t))y.has(n)||(e[n]=o,r=!0);return r?e:void 0}}},726(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.standardizeCallouts=function(t){var e;const r=t.ownerDocument;if(!r)return;const n=Array.from(t.querySelectorAll(".markdown-alert"));for(const t of n){const e=Array.from(t.classList).find((t=>t.startsWith("markdown-alert-")&&"markdown-alert"!==t)),n=e?e.replace("markdown-alert-",""):"note",i=n.charAt(0).toUpperCase()+n.slice(1),s=t.querySelector(".markdown-alert-title");s&&s.remove(),t.replaceWith(o(r,n,i,t))}const i=Array.from(t.querySelectorAll(\'aside[class*="callout"]\'));for(const t of i){const e=Array.from(t.classList).find((t=>t.startsWith("callout-"))),n=e?e.replace("callout-",""):"note",i=n.charAt(0).toUpperCase()+n.slice(1),s=t.querySelector(".callout-content");t.replaceWith(o(r,n,i,s||t))}const s=Array.from(t.querySelectorAll(\'.alert[class*="alert-"]\'));for(const t of s){const n=Array.from(t.classList).find((t=>t.startsWith("alert-")&&"alert-dismissible"!==t)),i=n?n.replace("alert-",""):"note",s=t.querySelector(".alert-heading, .alert-title"),a=(null===(e=null==s?void 0:s.textContent)||void 0===e?void 0:e.trim())||i.charAt(0).toUpperCase()+i.slice(1);s&&s.remove(),t.replaceWith(o(r,i,a,t))}};const n=r(639);function o(t,e,r,o){const i=t.createElement("div");i.setAttribute("data-callout",e),i.className="callout";const s=t.createElement("div");s.className="callout-title";const a=t.createElement("div");a.className="callout-title-inner",a.textContent=r,s.appendChild(a),i.appendChild(s);const l=t.createElement("div");return l.className="callout-content",(0,n.transferContent)(o,l),i.appendChild(l),i}},754(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.codeBlockRules=void 0;const n=r(552),o=[/^language-(\\w+)$/,/^lang-(\\w+)$/,/^(\\w+)-code$/,/^code-(\\w+)$/,/^syntax-(\\w+)$/,/^code-snippet__(\\w+)$/,/^highlight-(\\w+)$/,/^(\\w+)-snippet$/,/(?:^|\\s)(?:language|lang|brush|syntax)-(\\w+)(?:\\s|$)/i],i=new Set(["abap","actionscript","ada","adoc","agda","antlr4","applescript","arduino","armasm","asciidoc","aspnet","atom","bash","batch","c","clojure","cmake","cobol","coffeescript","cpp","c++","crystal","csharp","cs","dart","django","dockerfile","dotnet","elixir","elm","erlang","fortran","fsharp","gdscript","gitignore","glsl","golang","gradle","graphql","groovy","haskell","hs","haxe","hlsl","html","idris","java","javascript","js","jsx","jsdoc","json","jsonp","julia","kotlin","latex","lean","lean4","lisp","elisp","livescript","lua","makefile","markdown","md","markup","masm","mathml","matlab","mongodb","mysql","nasm","nginx","nim","nix","objc","ocaml","pascal","perl","php","postgresql","powershell","prolog","puppet","python","regex","rss","ruby","rb","rust","scala","scheme","shell","sh","solidity","sparql","sql","ssml","svg","swift","tcl","terraform","tex","toml","typescript","ts","tsx","unrealscript","verilog","vhdl","webassembly","wasm","xml","yaml","yml","zig"]);e.codeBlockRules=[{selector:["pre",\'div[class*="prismjs"]\',".syntaxhighlighter",".highlight",".highlight-source",".wp-block-syntaxhighlighter-code",".wp-block-code",\'div[class*="language-"]\',"code.hl.block"].join(", "),element:"pre",transform:(t,e)=>{if(!(t=>"classList"in t&&"getAttribute"in t&&"querySelector"in t)(t))return t;const r=t=>{var e;const r=t.getAttribute("data-lang")||t.getAttribute("data-language")||t.getAttribute("language");if(r)return r.toLowerCase();const n=Array.from(t.classList||[]);if(null===(e=t.classList)||void 0===e?void 0:e.contains("syntaxhighlighter")){const t=n.find((t=>!["syntaxhighlighter","nogutter"].includes(t)));if(t&&i.has(t.toLowerCase()))return t.toLowerCase()}for(const t of n)for(const e of o){const r=t.toLowerCase().match(e);if(r&&r[1]&&i.has(r[1].toLowerCase()))return r[1].toLowerCase()}for(const t of n)if(i.has(t.toLowerCase()))return t.toLowerCase();return""};let s="",a=t;for(;a&&!s;){if(s=r(a),!s&&a===t){const t=a.querySelector(\'code[data-lang], code[class*="language-"]\')||a.querySelector("code");t&&(s=r(t))}a=a.parentElement}const l=t.querySelector(".cm-content");if(l&&!s){const e=Array.from(t.querySelectorAll("div"));for(const t of e){if(t.contains(l))continue;const e=(t.textContent||"").trim().toLowerCase();if(e&&i.has(e)){s=e;break}}}const c=t=>{var e;if((0,n.isTextNode)(t))return(null===(e=t.parentElement)||void 0===e?void 0:e.querySelector("[data-line], .line"))&&!(t.textContent||"").trim()?"":t.textContent||"";let r="";if((0,n.isElement)(t)){if(t.matches(".hover-info, .hover-container"))return"";if("BUTTON"===t.tagName||"STYLE"===t.tagName)return"";if("BR"===t.tagName){const e=t.previousElementSibling;return e&&e.matches(\'div[class*="line"], span[class*="line"], .ec-line, [data-line-number], [data-line]\')?"":"\\n"}if(t.matches("span.lnt"))return"";if(t.matches(".react-syntax-highlighter-line-number"))return"";if(t.matches(".rouge-gutter"))return"";if(("DIV"===t.tagName||"SPAN"===t.tagName)&&2===t.children.length){const e=(t.children[0].textContent||"").trim();if(/^\\d+$/.test(e))return c(t.children[1]).replace(/\\n$/,"")+"\\n"}if(t.matches(\'div[class*="line"], span[class*="line"], .ec-line, [data-line-number], [data-line]\')){const e=t.querySelector(\'.code, .content, [class*="code-"], [class*="content-"]\');if(e)return(e.textContent||"").replace(/\\n$/,"")+"\\n";const r=t.querySelector(\'.line-number, .gutter, [class*="line-number"], [class*="gutter"]\');if(r){return Array.from(t.childNodes).filter((t=>!r.contains(t))).map((t=>c(t))).join("").replace(/\\n$/,"")+"\\n"}return(t.textContent||"").replace(/\\n$/,"")+"\\n"}t.childNodes.forEach((t=>{r+=c(t)}))}return r};let u="";t.matches(".syntaxhighlighter, .wp-block-syntaxhighlighter-code")&&(u=(t=>{const e=t.querySelector(".syntaxhighlighter table .code .container");if(e)return Array.from(e.children).map((t=>{const e=Array.from(t.querySelectorAll("code")).map((t=>{var e;let r=t.textContent||"";return(null===(e=t.classList)||void 0===e?void 0:e.contains("spaces"))&&(r=" ".repeat(r.length)),r})).join("");return e||t.textContent||""})).join("\\n");const r=t.querySelectorAll(".code .line");return r.length>0?Array.from(r).map((t=>{const e=Array.from(t.querySelectorAll("code")).map((t=>t.textContent||"")).join("");return e||t.textContent||""})).join("\\n"):""})(t)),!u&&l?u=c(l):u||(u=c(t));u=t.matches("code.hl.block")?u.replace(/^[ \\t]+|[ \\t]+$/g,"").replace(/\\t/g," ").replace(/\\u00a0/g," ").replace(/^\\n+/,""):u.replace(/^\\s+|\\s+$/g,"").replace(/\\t/g," ").replace(/\\n{3,}/g,"\\n\\n").replace(/\\u00a0/g," ").replace(/^\\n+/,"").replace(/\\n+$/,"");let d=t;for(let e=0;e<3&&d;e++){const e=d.parentElement;if(!e||"BODY"===e.tagName)break;const r=Array.from(e.children);for(const e of r){if(e.contains(t))continue;const r=e.tagName;if("DIV"!==r&&"SPAN"!==r)continue;const o=(e.textContent||"").trim();(0,n.countWords)(o)<=5&&!e.querySelector("pre, code, img, table, h1, h2, h3, h4, h5, h6, p, blockquote, ul, ol")&&e.remove()}d=e}const h=e.createElement("pre");t.matches("code.hl.block, pre.hl.lean.lean-output")&&h.setAttribute("data-verso-code","true");const m=e.createElement("code");return s&&(m.setAttribute("data-lang",s),m.setAttribute("class",`language-${s}`)),m.textContent=u,h.appendChild(m),h}}]},610(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.standardizeFootnotes=function(t){const e=t.ownerDocument;if(!e)return void console.warn("standardizeFootnotes: No document available");new l(e).standardizeFootnotes(t)};const n=r(640),o=r(639),i=r(552),s=r(840),a=/^(foot\\s*notes?|end\\s*notes?|notes?|references?)$/i;class l{constructor(t){this.genericContainer=null,this.genericElements=[],this.extraContainersToRemove=[],this.doc=t}createFootnoteItem(t,e,r){const n="string"==typeof e?this.doc:e.ownerDocument,i=n.createElement("li");if(i.className="footnote",i.id=`fn:${t}`,"string"==typeof e){const t=n.createElement("p");t.appendChild((0,o.parseHTML)(n,e)),i.appendChild(t)}else{const t=new Set(["div","section","article","aside","blockquote","dl","figure","footer","form","h1","h2","h3","h4","h5","h6","header","hr","main","nav","ol","p","pre","table","ul"]),r=Array.from(e.children),s=r.some((t=>"p"===t.tagName.toLowerCase())),a=r.some((e=>t.has(e.tagName.toLowerCase())));if(s||a)!s&&a?r.forEach((t=>{const e=t.cloneNode(!0);this.removeBackrefs(e),i.appendChild(e)})):r.forEach((t=>{var e;if("p"===t.tagName.toLowerCase()){if(!(null===(e=t.textContent)||void 0===e?void 0:e.trim())&&!t.querySelector("img, br"))return;const r=n.createElement("p");(0,o.transferContent)(t,r),this.removeBackrefs(r),i.appendChild(r)}else{const e=t.cloneNode(!0);this.removeBackrefs(e),i.appendChild(e)}}));else{const t=n.createElement("p");(0,o.transferContent)(e,t),this.removeBackrefs(t),i.appendChild(t)}}const s=i.querySelector("p:last-of-type")||i;return r.forEach(((t,e)=>{const o=n.createElement("a");o.href=`#${t}`,o.title="return to article",o.className="footnote-backref",o.textContent="\\u21a9",e<r.length-1&&(o.textContent+=" "),s.appendChild(o)})),i}collectFootnotes(t){var e,r;const i={};let s=1;const a=new Set;if(t.querySelectorAll(n.FOOTNOTE_LIST_SELECTORS).forEach((e=>{var r;if(e.matches("div.footnotes-footer")){return void e.querySelectorAll("div.footnote-footer").forEach((e=>{const r=(e.id||"").match(/^footnote-(\\d+)$/);if(r){const n=r[1];if(!a.has(n)){const r=e.cloneNode(!0),l=r.querySelector("a");l&&l.remove();let c=(0,o.serializeHTML)(r);c=c.replace(/^\\s*\\.\\s*/,"");const u=t.ownerDocument.createElement("div");u.appendChild((0,o.parseHTML)(t.ownerDocument,c.trim())),i[s]={content:u,originalId:n,refs:[]},a.add(n),s++}}}))}if(e.matches("div.footnote-definitions")){e.querySelectorAll("div.footnote-definition").forEach((t=>{const e=t.querySelector("sup[id]"),r=t.querySelector(".footnote-body");if(!e||!r)return;const n=(e.id||"").toLowerCase();n&&!a.has(n)&&(i[s]={content:r.cloneNode(!0),originalId:n,refs:[]},a.add(n),s++)}));const n=e.parentElement;return void(n&&n!==t&&(null===(r=n.classList)||void 0===r?void 0:r.contains("footnotes"))&&this.extraContainersToRemove.push(n))}if(e.matches(\'div.footnote[data-component-name="FootnoteToDOM"]\')){const t=e.querySelector("a.footnote-number"),r=e.querySelector(".footnote-content");if(t&&r){const e=t.id.replace("footnote-","").toLowerCase();e&&!a.has(e)&&(i[s]={content:r,originalId:e,refs:[]},a.add(e),s++)}return}e.querySelectorAll(\'li, div[role="listitem"]\').forEach((t=>{var e,r,n,o;let l="",c=null;const u=t.querySelector(".citations");if(null===(e=null==u?void 0:u.id)||void 0===e?void 0:e.toLowerCase().startsWith("r")){l=u.id.toLowerCase();const t=u.querySelector(".citation-content");t&&(c=t)}else{if(t.id.toLowerCase().startsWith("bib.bib"))l=t.id.replace("bib.bib","").toLowerCase();else if(t.id.toLowerCase().startsWith("fn:"))l=t.id.replace("fn:","").toLowerCase();else if(t.id.toLowerCase().startsWith("fn"))l=t.id.replace("fn","").toLowerCase();else if(t.hasAttribute("data-counter"))l=(null===(n=null===(r=t.getAttribute("data-counter"))||void 0===r?void 0:r.replace(/\\.$/,""))||void 0===n?void 0:n.toLowerCase())||"";else{const e=null===(o=t.id.split("/").pop())||void 0===o?void 0:o.match(/cite_note-(.+)/);l=e?e[1].toLowerCase():t.id.toLowerCase()}c=t}l&&!a.has(l)&&(i[s]={content:c||t,originalId:l,refs:[]},a.add(l),s++)}))})),1===s){const e=new Map;if(t.querySelectorAll(\'a[href*="#"]\').forEach((t=>{var r,n;const o=null===(r=(t.getAttribute("href")||"").split("#").pop())||void 0===r?void 0:r.toLowerCase();if(!o)return;const i=(null===(n=t.textContent)||void 0===n?void 0:n.trim())||"";/^\\[?\\(?\\d{1,4}\\)?\\]?$/.test(i)&&(e.has(o)||e.set(o,[]),e.get(o).push(t))})),e.size>=2){const r=new Set(e.keys()),n=t.querySelectorAll("div, section, aside, footer, ol, ul");let l=null,c=0;if(n.forEach((e=>{if(e===t)return;const n=this.findMatchingFootnoteElements(e,r).length;n>=2&&n>=c&&(c=n,l=e)})),l){const n=this.findMatchingFootnoteElements(l,r),c=new Set(n.map((({id:t})=>t)));let u=0,d=0;e.forEach(((t,e)=>{t.some((t=>l.contains(t)))||(u++,c.has(e)&&d++)})),d<Math.max(2,Math.ceil(.75*u))&&(l=null),n.forEach((({el:e,id:n})=>{var l,c;if(a.has(n))return;const u=t.ownerDocument.createElement("div"),d=e.cloneNode(!0),h=d.querySelector(`a[id="${n}"]`);!h||(null===(l=h.textContent)||void 0===l?void 0:l.trim())&&!/^\\d+[.)]*\\s*$/.test(h.textContent.trim())||h.remove();const m=d.querySelector("a[name]");m&&(null===(c=m.getAttribute("name"))||void 0===c?void 0:c.toLowerCase())===n&&m.remove();const p=d.childNodes[0];p&&3===p.nodeType&&(p.textContent=p.textContent.replace(/^\\d+\\.\\s*/,"").replace(/^\\s+/,"")),d.matches("li")?(0,o.transferContent)(d,u):u.appendChild(d);let f=e.nextElementSibling;for(;f&&!f.id;){const t=this.getChildAnchorId(f);if(t&&r.has(t))break;const e=f.cloneNode(!0);u.appendChild(e),f=f.nextElementSibling}i[s]={content:u,originalId:n,refs:[]},a.add(n),s++})),this.genericContainer=l}}}if(1===s){const e=Array.from(t.querySelectorAll(\'a[href*="#_ftnref"]\'));if(e.length>=2){const r=[];e.forEach((t=>{const e=((t.getAttribute("href")||"").split("#").pop()||"").match(/^_ftnref(\\d+)$/);e&&r.push({num:parseInt(e[1]),anchor:t})})),r.sort(((t,e)=>t.num-e.num)),r.forEach((({num:e,anchor:r})=>{const n=`_ftn${e}`;if(a.has(n))return;let o=r.parentElement;for(;o&&o!==t;){const t=o.tagName.toLowerCase();if("p"===t||"div"===t||"li"===t)break;o=o.parentElement}if(!o||o===t)return;const l=o.cloneNode(!0),c=l.querySelector(\'a[href*="_ftnref"]\');if(c){const t=c.closest("sup");t?t.remove():c.remove()}const u=t.ownerDocument.createElement("div");u.appendChild(l),i[e]={content:u,originalId:n,refs:[]},a.add(n),e>=s&&(s=e+1),this.genericElements.push(o)}))}}if(1===s){const n=this.findLooseFootnoteParagraphs(t);if(n){const{paragraphs:o,toRemove:l}=n;for(let n=0;n<o.length;n++){const{num:l,el:c}=o[n],u=null!==(r=null===(e=o[n+1])||void 0===e?void 0:e.el)&&void 0!==r?r:null,d=String(l);if(a.has(d))continue;const h=t.ownerDocument.createElement("div"),m=c.cloneNode(!0),p=m.firstElementChild;if(p){p.remove();const t=m.firstChild;3===(null==t?void 0:t.nodeType)&&(t.textContent=t.textContent.replace(/^\\s+/,""))}h.appendChild(m);let f=c.nextElementSibling;for(;f&&f!==u;)h.appendChild(f.cloneNode(!0)),f=f.nextElementSibling;i[s]={content:h,originalId:d,refs:[]},a.add(d),s++}this.genericElements.push(...l)}}return i}parseFootnoteNum(t){var e;const r=t.firstElementChild;if(!r)return null;const n=r.tagName.toLowerCase();if("sup"!==n&&"strong"!==n)return null;const o=(null===(e=r.textContent)||void 0===e?void 0:e.trim())||"",i=parseInt(o,10);return!isNaN(i)&&i>=1&&String(i)===o?i:null}crossValidate(t,e){const r=new Set(e.map((t=>t.num))),n=new Set;return t.querySelectorAll("sup").forEach((t=>{var o;if(e.some((e=>e.el.contains(t))))return;if(t.querySelector("a"))return;const i=(null===(o=t.textContent)||void 0===o?void 0:o.trim())||"",s=parseInt(i,10);!isNaN(s)&&s>=1&&String(s)===i&&r.has(s)&&n.add(s)})),n.size>=2}findLooseFootnoteParagraphs(t){var e,r;const n=Array.from(t.querySelectorAll("p")),o=n.length>0&&null!==(e=n[n.length-1].parentElement)&&void 0!==e?e:t,i=Array.from(o.children);for(let e=i.length-1;e>=0;e--){if("hr"!==i[e].tagName.toLowerCase())continue;const r=[];for(let t=e+1;t<i.length;t++){const e=this.parseFootnoteNum(i[t]);null!==e&&r.push({num:e,el:i[t]})}if(r.length>=2&&this.crossValidate(t,r))return{paragraphs:r,toRemove:i.slice(e)};break}const s=[];let l=-1;for(let t=i.length-1;t>=0;t--){const e=i[t],r=e.tagName.toLowerCase();if("p"===r){const r=this.parseFootnoteNum(e);if(null!==r){s.unshift({num:r,el:e}),l=t;continue}break}if("ul"!==r&&"ol"!==r&&"blockquote"!==r)break}if(s.length>=2&&this.crossValidate(t,s)){const t=i.slice(l),e=s[0].el.previousElementSibling;if(e){const n=e.tagName.toLowerCase();/^h[1-6]$/.test(n)&&a.test((null===(r=e.textContent)||void 0===r?void 0:r.trim())||"")&&t.unshift(e)}return{paragraphs:s,toRemove:t}}return null}removeBackrefs(t){for(t.querySelectorAll("a").forEach((t=>{var e,r;const n=(null===(e=t.textContent)||void 0===e?void 0:e.trim().replace(/\\uFE0E|\\uFE0F/g,""))||"";(/^[\\u21A9\\u21A5\\u2191\\u21B5\\u2934\\u2935\\u23CE]+$/.test(n)||(null===(r=t.classList)||void 0===r?void 0:r.contains("footnote-backref")))&&t.remove()}));t.lastChild&&3===t.lastChild.nodeType;){const e=t.lastChild.textContent;if(!/^[\\s,.;]*$/.test(e))break;t.lastChild.remove()}}getChildAnchorId(t){const e=t.querySelector("a[id], a[name]");return e?(e.id||e.getAttribute("name")||"").toLowerCase():""}findMatchingFootnoteElements(t,e){const r=[],n=new Set;return t.querySelectorAll("li, p, div").forEach((t=>{let o="";if(t.id&&e.has(t.id.toLowerCase()))o=t.id.toLowerCase();else if(!t.id){const r=this.getChildAnchorId(t);r&&e.has(r)&&(o=r)}o&&!n.has(o)&&(r.push({el:t,id:o}),n.add(o))})),r}findOuterFootnoteContainer(t){let e=t,r=t.parentElement;for(;r&&("span"===r.tagName.toLowerCase()||"sup"===r.tagName.toLowerCase());)e=r,r=r.parentElement;return e}createFootnoteReference(t,e){const r=this.doc.createElement("sup");r.id=e;const n=this.doc.createElement("a");return n.href=`#fn:${t}`,n.textContent=t,r.appendChild(n),r}collectInlineSidenotes(t){const e={},r=t.querySelectorAll("span.footnote-container, span.sidenote-container, span.inline-footnote");if(0===r.length)return t.querySelectorAll("span.sidenote").forEach((t=>{t.remove()})),e;let n=1;return r.forEach((t=>{const r=t.querySelector("span.footnote, span.sidenote, span.footnoteContent");if(!r)return;const o=r.cloneNode(!0);e[n]={content:o,originalId:String(n),refs:[`fnref:${n}`]};const i=this.createFootnoteReference(String(n),`fnref:${n}`);t.replaceWith(i),n++})),e}collectAsideFootnotes(t){const e={},r=Array.from(t.querySelectorAll("aside > ol[start]"));return 0===r.length||r.forEach((t=>{const r=t.parentElement,n=parseInt(t.getAttribute("start")||"",10);if(isNaN(n)||n<1)return;const i=Array.from(t.querySelectorAll("li"));if(0===i.length)return;const s=this.doc.createElement("div");1===i.length?(0,o.transferContent)(i[0].cloneNode(!0),s):i.forEach((t=>{const e=this.doc.createElement("p");(0,o.transferContent)(t.cloneNode(!0),e),s.appendChild(e)})),e[n]={content:s,originalId:String(n),refs:[]},r.remove()})),e}standardizeFootnotes(t){const e=this.collectInlineSidenotes(t),r=this.collectFootnotes(t),o=this.collectAsideFootnotes(t);for(const[t,e]of Object.entries(o)){const n=parseInt(t);r[n]||(r[n]=e)}const a=t.querySelectorAll(n.FOOTNOTE_INLINE_REFERENCES),l=new Map;a.forEach((t=>{var e,n,o,s;if(!t||!t.parentNode)return;let a="",c="";if(t.matches("sup.footnoteref")){const e=t.querySelector(\'a[id^="footnoteref-"]\');if(e){const t=(e.id||"").match(/^footnoteref-(\\d+)$/);t&&(a=t[1])}}else if(t.matches(\'a[id^="ref-link"]\'))a=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";else if(t.matches(\'a[role="doc-biblioref"]\')){const e=t.getAttribute("data-xml-rid");if(e)a=e;else{const e=t.getAttribute("href");(null==e?void 0:e.startsWith("#core-R"))&&(a=e.replace("#core-",""))}}else if(t.matches("a.footnote-anchor, span.footnote-hovercard-target a")){const e=(null===(n=t.id)||void 0===n?void 0:n.replace("footnote-anchor-",""))||"";e&&(a=e.toLowerCase())}else if(t.matches("cite.ltx_cite")){const e=Array.from(t.querySelectorAll("a"));if(e.length>0){const n=[];if(e.forEach((t=>{var e;const o=t.getAttribute("href");if(!o)return;const i=null===(e=o.split("/").pop())||void 0===e?void 0:e.match(/bib\\.bib(\\d+)/);if(!i)return;const s=i[1].toLowerCase(),a=Object.entries(r).find((([t,e])=>e.originalId===s));if(!a)return;const[l,c]=a,u=c.refs.length>0?`fnref:${l}-${c.refs.length+1}`:`fnref:${l}`;c.refs.push(u),n.push(this.createFootnoteReference(l,u))})),n.length>0){const e=this.findOuterFootnoteContainer(t),r=t.ownerDocument.createDocumentFragment();return n.forEach(((e,n)=>{n>0&&r.appendChild(t.ownerDocument.createTextNode(" ")),r.appendChild(e)})),void e.replaceWith(r)}}}else if(t.matches("sup.reference")){const e=t.querySelectorAll("a");Array.from(e).forEach((t=>{var e;const r=t.getAttribute("href");if(r){const t=null===(e=r.split("/").pop())||void 0===e?void 0:e.match(/(?:cite_note|cite_ref)-(.+)/);t&&(a=t[1].toLowerCase())}}))}else if(t.matches(\'sup[id^="fnref:"]\'))a=t.id.replace("fnref:","").toLowerCase();else if(t.matches(\'sup[id^="fnr"]\'))a=t.id.replace("fnr","").toLowerCase();else if(t.matches("span.footnote-reference"))a=t.getAttribute("data-footnote-id")||"",!a&&(null===(o=t.id)||void 0===o?void 0:o.startsWith("fnref"))&&(a=t.id.replace("fnref","").toLowerCase());else if(t.matches("span.footnote-link"))a=t.getAttribute("data-footnote-id")||"",c=t.getAttribute("data-footnote-content")||"";else if(t.matches("a.citation"))a=(null===(s=t.textContent)||void 0===s?void 0:s.trim())||"",c=t.getAttribute("href")||"";else if(t.matches(\'a[id^="fnref"]\'))a=t.id.replace("fnref","").toLowerCase();else{const e=t.getAttribute("href");if(e){const t=e.replace(/^[#]/,"");a=t.toLowerCase()}}if(a){const e=Object.entries(r).find((([t,e])=>e.originalId===a.toLowerCase()));if(e){const[r,n]=e,o=n.refs.length>0?`fnref:${r}-${n.refs.length+1}`:`fnref:${r}`;n.refs.push(o);const s=this.findOuterFootnoteContainer(t);if("sup"===s.tagName.toLowerCase()){l.has(s)||l.set(s,[]);l.get(s).push(this.createFootnoteReference(r,o))}else{let t="",e=!1;for(const r of s.childNodes)(0,i.isTextNode)(r)?t+=r.textContent||"":(0,i.isElement)(r)&&(e=!0);if(t=t.trim(),t&&e){const e=s.ownerDocument.createDocumentFragment();e.appendChild(s.ownerDocument.createTextNode(t)),e.appendChild(this.createFootnoteReference(r,o)),s.replaceWith(e)}else s.replaceWith(this.createFootnoteReference(r,o))}}}}));const c=Object.entries(r).filter((([t,e])=>0===e.refs.length));if(c.length>0){const e=new Map,n=new Map;c.forEach((([t,r])=>{e.set(r.originalId,[t,r]),n.set(t,[t,r])}));t.querySelectorAll(\'a[href*="#"]\').forEach((t=>{var r,n;if(!t.parentNode)return;if(t.closest(\'[id^="fnref:"]\'))return;if(t.closest("#footnotes"))return;if(this.genericContainer&&this.genericContainer.contains(t))return;if(this.genericElements.some((e=>e.contains(t))))return;const o=null===(r=(t.getAttribute("href")||"").split("#").pop())||void 0===r?void 0:r.toLowerCase();if(!o)return;const i=e.get(o);if(!i)return;const s=(null===(n=t.textContent)||void 0===n?void 0:n.trim())||"";if(!/^[\\[\\(]?\\d{1,4}[\\]\\)]?$/.test(s))return;const[a,l]=i,c=l.refs.length>0?`fnref:${a}-${l.refs.length+1}`:`fnref:${a}`;l.refs.push(c);this.findOuterFootnoteContainer(t).replaceWith(this.createFootnoteReference(a,c))}));if(Object.entries(r).filter((([t,e])=>0===e.refs.length)).length>0){t.querySelectorAll("sup, span.footnote-ref").forEach((t=>{var r,o;if(!t.parentNode)return;if(null===(r=t.id)||void 0===r?void 0:r.startsWith("fnref:"))return;if(t.closest("#footnotes"))return;const i=((null===(o=t.textContent)||void 0===o?void 0:o.trim())||"").match(/^[\\[\\(]?(\\d{1,4})[\\]\\)]?$/);if(!i)return;const s=i[1],a=n.get(s)||e.get(s);if(!a)return;const[l,c]=a;if(c.refs.length>0)return;const u=`fnref:${l}`;c.refs.push(u);this.findOuterFootnoteContainer(t).replaceWith(this.createFootnoteReference(l,u))}))}}l.forEach(((t,e)=>{if(t.length>0){const r=this.doc.createDocumentFragment();t.forEach((t=>{const e=t.querySelector("a");if(e){const n=this.doc.createElement("sup");n.id=t.id,n.appendChild(e.cloneNode(!0)),r.appendChild(n)}})),e.replaceWith(r)}}));const u=this.doc.createElement("div");u.id="footnotes";const d=this.doc.createElement("ol"),h=Object.assign(Object.assign({},e),r);Object.entries(h).forEach((([t,e])=>{const r=this.createFootnoteItem(parseInt(t),e.content,e.refs);d.appendChild(r)}));t.querySelectorAll(n.FOOTNOTE_LIST_SELECTORS).forEach((t=>t.remove())),this.genericContainer&&this.genericContainer.parentNode&&this.genericContainer.remove(),this.genericElements.forEach((t=>{t.parentNode&&t.remove()})),this.extraContainersToRemove.forEach((t=>{t.parentNode&&t.remove()})),(0,s.removeOrphanedDividers)(t),d.children.length>0&&(u.appendChild(d),t.appendChild(u))}}},864(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.headingRules=void 0,e.removeHeadingAnchors=function(t){Array.from(t.querySelectorAll("h1 a, h2 a, h3 a, h4 a, h5 a, h6 a")).forEach((t=>{o(t)&&t.remove()}))},e.isPermalinkAnchor=o;const n=r(640);function o(t){if("a"!==t.tagName.toLowerCase())return!1;const e=t.getAttribute("href")||"",r=(t.getAttribute("title")||"").toLowerCase(),n=(t.getAttribute("class")||"").toLowerCase(),o=(t.textContent||"").trim();return!(!e.startsWith("#")&&!e.includes("#"))||(!!r.includes("permalink")||(!!(n.includes("permalink")||n.includes("heading-anchor")||n.includes("anchor-link"))||!!/^[#\\xb6\\xa7\\ud83d\\udd17]$/.test(o)))}e.headingRules=[{selector:"h1, h2, h3, h4, h5, h6",element:"keep",transform:t=>{var e,r;const i=t.ownerDocument;if(!i)return console.warn("No document available"),t;const s=i.createElement(t.tagName);if(Array.from(t.attributes).forEach((t=>{n.ALLOWED_ATTRIBUTES.has(t.name)&&s.setAttribute(t.name,t.value)})),!t.children.length)return s.textContent=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"",s;const a=t.cloneNode(!0),l=new Map,c=[];Array.from(a.querySelectorAll("*")).forEach((t=>{var e,r,n,i;if(!function(t){const e=t.tagName.toLowerCase();return"button"===e||!("a"!==e||!o(t))||!(!t.classList.contains("anchor")&&!t.classList.contains("permalink-widget"))||!("span"!==e&&"div"!==e||!Array.from(t.querySelectorAll("a")).some((t=>o(t))))}(t))return;l.set(t,(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"");const s=t.parentElement;s&&s!==a&&(null===(r=s.textContent)||void 0===r?void 0:r.trim())===(null===(n=t.textContent)||void 0===n?void 0:n.trim())&&l.set(s,(null===(i=t.textContent)||void 0===i?void 0:i.trim())||""),c.push(t)})),c.forEach((t=>t.remove()));let u=(null===(r=a.textContent)||void 0===r?void 0:r.trim())||"";return!u&&l.size>0&&(u=Array.from(l.values())[0]),s.textContent=u,s}}]},649(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.imageRules=void 0;const n=r(552),o=r(639),i=r(640),s=/^data:image\\/([^;]+);base64,/,a=/\\.(jpg|jpeg|png|webp)\\s+\\d/,l=/^\\s*\\S+\\.(jpg|jpeg|png|webp)\\S*\\s*$/,c=/\\.(jpg|jpeg|png|webp|gif|avif)(\\?.*)?$/i,u=/\\s(\\d+)w/,d=/dpr=(\\d+(?:\\.\\d+)?)/,h=/^([^\\s]+)/,m=/^[\\w\\-\\.\\/\\\\]+\\.(jpg|jpeg|png|gif|webp|svg)$/i,p=/^\\d{4}-\\d{2}-\\d{2}$/;function f(t,e,r){const i=r.createElement("figure");i.appendChild(t.cloneNode(!0));const s=r.createElement("figcaption"),a=function(t){const e=[],r=new Set,i=t=>{var o;if((0,n.isTextNode)(t)){const n=(null===(o=t.textContent)||void 0===o?void 0:o.trim())||"";n&&!r.has(n)&&(e.push(n),r.add(n))}else if((0,n.isElement)(t)){const e=t.childNodes;for(let t=0;t<e.length;t++)i(e[t])}},s=t.childNodes;for(let t=0;t<s.length;t++)i(s[t]);if(e.length>0)return e.join(" ");return(0,o.serializeHTML)(t)}(e);return s.appendChild((0,o.parseHTML)(r,a)),i.appendChild(s),i}function g(t,e){e.setAttribute("srcset",t);const r=L(t);r&&C(r)&&e.setAttribute("src",r)}function v(t,e,r){for(let n=0;n<t.attributes.length;n++){const o=t.attributes[n];r.includes(o.name)||e.setAttribute(o.name,o.value)}}function y(t){const e=t.match(s);if(!e)return!1;if("svg+xml"===e[1])return!1;const r=e[0].length;return t.length-r<133}function b(t){return t.startsWith("data:image/svg+xml")}function C(t){return!t.startsWith("data:")&&(!(!t||""===t.trim())&&(c.test(t)||t.includes("image")||t.includes("img")||t.includes("photo")))}function x(t){if(E(t))return!0;return t.querySelectorAll("img, video, picture, source").length>0}function E(t){const e=t.tagName.toLowerCase();return"img"===e||"video"===e||"picture"===e||"source"===e}function S(t){if(E(t))return t;const e=t.querySelectorAll("picture");if(e.length>0)return e[0];const r=t.querySelectorAll("img"),n=[];for(let t=0;t<r.length;t++){const e=r[t],o=e.getAttribute("src")||"",i=e.getAttribute("alt")||"";o.includes("data:image/svg+xml")||(y(o)||!i.trim()&&r.length>1||n.push(e))}if(n.length>0)return n[0];const o=t.querySelectorAll("video");if(o.length>0)return o[0];const i=t.querySelectorAll("source");if(i.length>0)return i[0];const s=t.querySelectorAll("img, picture, source, video");return s.length>0?s[0]:null}function w(t){var e,r,n,o;const i=t.querySelector("figcaption");if(i)return i;const s=new Set,a=[\'[class*="caption"]\',\'[class*="description"]\',\'[class*="alt"]\',\'[class*="title"]\',\'[class*="credit"]\',\'[class*="text"]\',\'[class*="post-thumbnail-text"]\',\'[class*="image-caption"]\',\'[class*="photo-caption"]\',"[aria-label]","[title]"].join(", "),l=t.querySelectorAll(a);for(let t=0;t<l.length;t++){const r=l[t];if(E(r))continue;const n=null===(e=r.textContent)||void 0===e?void 0:e.trim();if(n&&n.length>0&&!s.has(n))return s.add(n),r}const c=t.querySelector("img");if(c&&c.hasAttribute("alt")){const e=c.getAttribute("alt");if(e&&e.trim().length>0){const r=t.ownerDocument.createElement("div");return r.textContent=e,r}}if(t.parentElement){const e=t.parentElement.children;for(let n=0;n<e.length;n++){const o=e[n];if(o===t)continue;if(Array.from(o.classList).some((t=>t.includes("caption")||t.includes("credit")||t.includes("text")||t.includes("description")))){const t=null===(r=o.textContent)||void 0===r?void 0:r.trim();if(t&&t.length>0)return o}}}const u=t.querySelectorAll("img");for(let t=0;t<u.length;t++){const e=u[t];if(!e.parentElement)continue;let r=e.nextElementSibling;for(;r;){if(["EM","STRONG","SPAN","I","B","SMALL","CITE"].includes(r.tagName)){const t=null===(n=r.textContent)||void 0===n?void 0:n.trim();if(t&&t.length>0)return r}r=r.nextElementSibling}}for(let t=0;t<u.length;t++){const e=u[t],r=e.parentElement;if(!r)continue;const n=r.querySelectorAll("em, strong, span, i, b, small, cite");for(let t=0;t<n.length;t++){const r=n[t];if(r===e)continue;const i=null===(o=r.textContent)||void 0===o?void 0:o.trim();if(i&&i.length>0)return r}}return null}function A(t){var e;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";return!(r.length<10||r.startsWith("http://")||r.startsWith("https://"))&&(!m.test(r)&&(!r.match(/^\\d+$/)&&!p.test(r)))}function T(t,e){const r=t.tagName.toLowerCase();if("img"===r)return _(t,e);if("picture"===r){const r=t.querySelector("img");return r?_(r,e):t.cloneNode(!0)}return"source"===r?function(t,e){const r=e.createElement("img"),n=t.getAttribute("srcset");n&&g(n,r);const o=t.parentElement;if(o){const t=o.querySelectorAll("img"),e=[];for(let r=0;r<t.length;r++){const n=t[r],o=n.getAttribute("src")||"";y(o)||b(o)||""===o||e.push(n)}if(e.length>0){if(v(e[0],r,["src","srcset"]),!r.hasAttribute("src")||!C(r.getAttribute("src")||"")){const t=e[0].getAttribute("src");t&&C(t)&&r.setAttribute("src",t)}}else{const t=o.querySelector("img[data-src]");if(t&&(v(t,r,["src","srcset"]),!r.hasAttribute("src")||!C(r.getAttribute("src")||""))){const e=t.getAttribute("data-src");e&&C(e)&&r.setAttribute("src",e)}}}return r}(t,e):t.cloneNode(!0)}function _(t,e){const r=t.getAttribute("src")||"";if(y(r)||b(r)){const r=t.parentElement;if(r){const n=r.querySelectorAll("source"),o=[];for(let t=0;t<n.length;t++){const e=n[t];e.hasAttribute("data-srcset")&&""!==e.getAttribute("data-srcset")&&o.push(e)}if(o.length>0){const r=e.createElement("img"),n=t.getAttribute("data-src");return n&&!b(n)&&r.setAttribute("src",n),v(t,r,["src"]),r}}}return t.cloneNode(!0)}function L(t){if(!t||!t.trim())return null;const e=t.trim(),r=/(.+?)\\s+(\\d+(?:\\.\\d+)?[wx])/g;let n,o=0;for(;null!==(n=r.exec(e));){let t=n[1].trim();if(o>0&&(t=t.replace(/^,\\s*/,"")),o=r.lastIndex,t&&!b(t))return t}const i=e.match(h);return i&&i[1]&&!b(i[1])?i[1]:null}function N(t){if(0===t.length)return null;if(1===t.length)return t[0];for(let e=0;e<t.length;e++)if(!t[e].hasAttribute("media"))return t[e];let e=null,r=0;for(let n=0;n<t.length;n++){const o=t[n],i=o.getAttribute("srcset");if(!i)continue;const s=i.match(u),a=i.match(d);if(s&&s[1]){const t=parseInt(s[1],10)*(a?parseFloat(a[1]):1);t>r&&(r=t,e=o)}}return e||t[0]}e.imageRules=[{selector:"picture",element:"picture",transform:(t,e)=>{const r=t.querySelectorAll("source"),n=t.querySelector("img");if(!n){console.warn("Picture element without img fallback:",t.outerHTML);const n=N(r);if(n){const r=n.getAttribute("srcset");if(r){const n=e.createElement("img");return g(r,n),t.replaceChildren(n),t}}return t}let o=null,i=null;if(r.length>0){const t=N(r);t&&(o=t.getAttribute("srcset"),o&&(i=L(o)))}if(o&&n.setAttribute("srcset",o),i&&C(i))n.setAttribute("src",i);else if(!n.hasAttribute("src")||!C(n.getAttribute("src")||"")){const t=L(n.getAttribute("srcset")||o||"");t&&C(t)&&n.setAttribute("src",t)}return r.forEach((t=>t.remove())),t}},{selector:"uni-image-full-width",element:"figure",transform:(t,e)=>{var r;const n=e.createElement("figure"),i=e.createElement("img"),s=t.querySelector("img");if(!s)return console.warn("uni-image-full-width without img:",t.outerHTML),n;let a=s.getAttribute("src");const l=s.getAttribute("data-loading");if(l)try{const t=JSON.parse(l);t.desktop&&C(t.desktop)&&(a=t.desktop)}catch(t){console.warn("Failed to parse data-loading attribute:",l,t)}if(!a||!C(a))return console.warn("Could not find valid src for uni-image-full-width:",t.outerHTML),n;i.setAttribute("src",a);let c=s.getAttribute("alt");c||(c=t.getAttribute("alt-text")),c&&i.setAttribute("alt",c),n.appendChild(i);const u=t.querySelector("figcaption");if(u){const t=null===(r=u.textContent)||void 0===r?void 0:r.trim();if(t&&t.length>5){const r=e.createElement("figcaption"),i=u.querySelector(".rich-text p");i?(0,o.transferContent)(i,r):r.textContent=t,n.appendChild(r)}}return n}},{selector:\'img[data-src], img[data-srcset], img[loading="lazy"], img.lazy, img.lazyload\',element:"img",transform:(t,e)=>{const r=t.getAttribute("src")||"",n=function(t){if(t.hasAttribute("data-src")||t.hasAttribute("data-srcset"))return!0;for(let e=0;e<t.attributes.length;e++){const r=t.attributes[e];if("src"!==r.name){if(r.name.startsWith("data-")&&/\\.(jpg|jpeg|png|webp|gif)(\\?.*)?$/i.test(r.value))return!0;if(/\\.(jpg|jpeg|png|webp|gif)(\\?.*)?$/i.test(r.value))return!0}}return!1}(t);y(r)&&n&&t.removeAttribute("src");const o=t.getAttribute("data-src");o&&!t.getAttribute("src")&&t.setAttribute("src",o);const i=t.getAttribute("data-srcset");i&&!t.getAttribute("srcset")&&t.setAttribute("srcset",i);for(let e=0;e<t.attributes.length;e++){const r=t.attributes[e];if("src"===r.name||"srcset"===r.name||"alt"===r.name)continue;const n=r.value.charAt(0);"{"!==n&&"["!==n&&(a.test(r.value)?t.setAttribute("srcset",r.value):l.test(r.value)&&t.setAttribute("src",r.value))}return t.classList.remove("lazy","lazyload"),t.removeAttribute("data-ll-status"),t.removeAttribute("data-src"),t.removeAttribute("data-srcset"),t.removeAttribute("loading"),t}},{selector:"span:has(img)",element:"span",transform:(t,e)=>{try{if(!x(t))return t;for(const e of t.children)if(i.BLOCK_LEVEL_ELEMENTS.has(e.tagName.toLowerCase()))return t;const r=S(t);if(!r)return t;const n=w(t),o=T(r,e);if(n&&A(n)){const t=f(o,n,e);return n.parentNode&&n.parentNode.removeChild(n),t}return o}catch(e){return console.warn("Error processing span with image:",e),t}}},{selector:\'figure, p:has([class*="caption"])\',element:"figure",transform:(t,e)=>{try{if(!x(t))return t;const r=S(t);if(!r)return t;const n=w(t);if(n&&A(n)){const o=S(t);let i;return o?i=o:(console.warn("Figure rule couldn\'t find current image element in:",t.outerHTML),i=T(r,e)),f(i,n,e)}return t}catch(e){return console.warn("Error processing complex image element:",e),t}}}]},282(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.mathSelectors=e.mathFastCheck=e.isBlockDisplay=e.getBasicLatexFromElement=e.getMathMLFromElement=void 0;const n=r(639);e.getMathMLFromElement=t=>{if("math"===t.tagName.toLowerCase()){const e="block"===t.getAttribute("display");return{mathml:t.outerHTML,latex:t.getAttribute("alttext")||null,isBlock:e}}const e=t.getAttribute("data-mathml");if(e){const r=t.ownerDocument||document,o=(0,n.parseHTML)(r,e).querySelector("math");if(o){const t="block"===o.getAttribute("display");return{mathml:o.outerHTML,latex:o.getAttribute("alttext")||null,isBlock:t}}}const r=t.querySelector(".MJX_Assistive_MathML, mjx-assistive-mml");if(r){const t=r.querySelector("math");if(t){const e=t.getAttribute("display"),n=r.getAttribute("display"),o="block"===e||"block"===n;return{mathml:t.outerHTML,latex:t.getAttribute("alttext")||null,isBlock:o}}}const o=t.querySelector(".katex-mathml math");return o?{mathml:o.outerHTML,latex:null,isBlock:!1}:null};e.getBasicLatexFromElement=t=>{var e,r,n;const o=t.getAttribute("data-latex");if(o)return o;if("img"===t.tagName.toLowerCase()&&t.classList.contains("latex")){const e=t.getAttribute("alt");if(e)return e;const r=t.getAttribute("src");if(r){const t=r.match(/latex\\.php\\?latex=([^&]+)/);if(t)return decodeURIComponent(t[1]).replace(/\\+/g," ").replace(/%5C/g,"\\\\")}}const i=t.querySelector(\'annotation[encoding="application/x-tex"]\');if(null==i?void 0:i.textContent)return i.textContent.trim();if(t.matches(".katex")){const e=t.querySelector(\'.katex-mathml annotation[encoding="application/x-tex"]\');if(null==e?void 0:e.textContent)return e.textContent.trim()}if(t.matches(\'script[type="math/tex"]\')||t.matches(\'script[type="math/tex; mode=display"]\'))return(null===(e=t.textContent)||void 0===e?void 0:e.trim())||null;if(t.parentElement){const e=t.parentElement.querySelector(\'script[type="math/tex"], script[type="math/tex; mode=display"]\');if(e)return(null===(r=e.textContent)||void 0===r?void 0:r.trim())||null}return"math"===t.tagName.toLowerCase()&&(null===(n=t.textContent)||void 0===n?void 0:n.trim())?t.textContent.trim():t.getAttribute("alt")||null};e.isBlockDisplay=t=>{if("block"===t.getAttribute("display"))return!0;const e=(0,n.getClassName)(t).toLowerCase();if(e.includes("display")||e.includes("block"))return!0;if(t.closest(\'.katex-display, .MathJax_Display, [data-display="block"]\'))return!0;const r=t.previousElementSibling;if("p"===(null==r?void 0:r.tagName.toLowerCase()))return!0;if(t.matches(".mwe-math-fallback-image-display"))return!0;if(t.matches(".katex"))return null!==t.closest(".katex-display");if(t.hasAttribute("display"))return"true"===t.getAttribute("display");if(t.matches(\'script[type="math/tex; mode=display"]\'))return!0;const o=t.closest("[display]");return!!o&&"true"===o.getAttribute("display")},e.mathFastCheck=\'math, mjx-container, .MathJax, .katex, img.latex, [data-math], [data-latex], script[type^="math/"]\',e.mathSelectors=[\'img.latex[src*="latex.php"]\',"span.MathJax","mjx-container",\'script[type="math/tex"]\',\'script[type="math/tex; mode=display"]\',\'.MathJax_Preview + script[type="math/tex"]\',".MathJax_Display",".MathJax_SVG",".MathJax_MathML",".mwe-math-element",".mwe-math-fallback-image-inline",".mwe-math-fallback-image-display",".mwe-math-mathml-inline",".mwe-math-mathml-display",".katex",".katex-display",".katex-mathml",".katex-html","[data-katex]",\'script[type="math/katex"]\',"math","[data-math]","[data-latex]","[data-tex]",\'script[type^="math/"]\',\'annotation[encoding="application/x-tex"]\'].join(",")},0(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.mathRules=e.createCleanMathEl=void 0;const n=r(282),o=r(639);e.createCleanMathEl=(t,e,r,n)=>{const i=t.createElement("math");if(i.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),i.setAttribute("display",n?"block":"inline"),i.setAttribute("data-latex",r||""),null==e?void 0:e.mathml){const r=(0,o.parseHTML)(t,e.mathml).querySelector("math");r&&(0,o.transferContent)(r,i)}else r&&(i.textContent=r);return i},e.mathRules=[{selector:n.mathSelectors,element:"math",fastCheck:n.mathFastCheck,transform:(t,r)=>{if(!function(t){return"classList"in t&&"getAttribute"in t&&"querySelector"in t}(t))return t;const o=(0,n.getMathMLFromElement)(t),i=(0,n.getBasicLatexFromElement)(t),s=(0,n.isBlockDisplay)(t),a=(0,e.createCleanMathEl)(r,o,i,s);if(t.parentElement&&!t.matches(\'script[type^="math/"]\')){t.parentElement.querySelectorAll(\'script[type^="math/"], .MathJax_Preview, script[type="text/javascript"][src*="mathjax"], script[type="text/javascript"][src*="katex"]\').forEach((t=>t.remove()))}return a}}]},917(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.ExtractorRegistry=void 0;const n=r(959),o=r(248),i=r(64),s=r(258),a=r(458),l=r(632),c=r(397),u=r(20),d=r(732),h=r(588),m=r(666),p=r(55),f=r(27),g=r(581);class v{static initialize(){this.register({patterns:["x.com","twitter.com"],extractor:i.XArticleExtractor}),this.register({patterns:["twitter.com",/\\/x\\.com\\/.*/],extractor:o.TwitterExtractor}),this.register({patterns:["x.com","twitter.com"],extractor:m.XOembedExtractor}),this.register({patterns:["reddit.com","old.reddit.com","new.reddit.com",/^https:\\/\\/[^\\/]+\\.reddit\\.com/],extractor:n.RedditExtractor}),this.register({patterns:["youtube.com","youtu.be",/youtube\\.com\\/watch\\?v=.*/,/youtu\\.be\\/.*/],extractor:s.YoutubeExtractor}),this.register({patterns:[/news\\.ycombinator\\.com\\/item\\?id=.*/],extractor:a.HackerNewsExtractor}),this.register({patterns:[/^https?:\\/\\/chatgpt\\.com\\/(c|share)\\/.*/],extractor:l.ChatGPTExtractor}),this.register({patterns:["claude.ai",/^https?:\\/\\/claude\\.ai\\/(chat|share)\\/.*/],extractor:c.ClaudeExtractor}),this.register({patterns:[/^https?:\\/\\/grok\\.com\\/(chat|share)(\\/.*)?$/],extractor:u.GrokExtractor}),this.register({patterns:[/^https?:\\/\\/gemini\\.google\\.com\\/app\\/.*/],extractor:d.GeminiExtractor}),this.register({patterns:["github.com",/^https?:\\/\\/github\\.com\\/.*/],extractor:h.GitHubExtractor}),this.register({patterns:["wiki.c2.com"],extractor:f.C2WikiExtractor}),this.register({patterns:[/^https?:\\/\\/substack\\.com\\/@[^/]+\\/note\\/.+/,/^https?:\\/\\/substack\\.com\\/home\\/post\\/p-\\d+/],extractor:g.SubstackExtractor}),this.register({patterns:[/.*/],extractor:p.BbcodeDataExtractor})}static register(t){this.mappings.push(t)}static findExtractor(t,e,r,n){return this.findByPredicate(t,e,r,(t=>t.canExtract()),n)}static findAsyncExtractor(t,e,r,n){return this.findByPredicate(t,e,r,(t=>t.canExtractAsync()),n)}static findPreferredAsyncExtractor(t,e,r,n){return this.findByPredicate(t,e,r,(t=>t.canExtractAsync()&&t.prefersAsync()),n)}static findByPredicate(t,e,r,n,o){try{const i=new URL(e).hostname;for(const{patterns:s,extractor:a}of this.mappings){if(s.some((t=>t instanceof RegExp?t.test(e):i.includes(t)))){const i=new a(t,e,r,o);if(n(i))return i}}return null}catch(t){return console.error("Error finding extractor:",t),null}}}e.ExtractorRegistry=v,v.mappings=[],v.initialize()},279(t,e){var r=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.BaseExtractor=void 0;e.BaseExtractor=class{constructor(t,e,r,n){this.document=t,this.url=e,this.schemaOrgData=r,this.options=n||{}}canExtractAsync(){return!1}prefersAsync(){return!1}extractAsync(){return r(this,void 0,void 0,(function*(){return this.extract()}))}}},181(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.ConversationExtractor=void 0;const n=r(279),o=r(628),i=r(639);class s extends n.BaseExtractor{getFootnotes(){return[]}extract(){var t;const e=this.extractMessages(),r=this.getMetadata(),n=this.getFootnotes(),s=this.createContentHtml(e,n),a=this.document.implementation.createHTMLDocument(),l=a.createElement("article");l.appendChild((0,i.parseHTML)(a,s)),a.body.appendChild(l);const c=new o.Defuddle(a).parse(),u=c.content;return{content:u,contentHtml:u,extractedContent:{messageCount:e.length.toString()},variables:{title:r.title||"Conversation",site:r.site,description:r.description||`${r.site} conversation with ${e.length} messages`,wordCount:(null===(t=c.wordCount)||void 0===t?void 0:t.toString())||""}}}createContentHtml(t,e){return`${t.map(((e,r)=>{const n=e.timestamp?`<div class="message-timestamp">${e.timestamp}</div>`:"",o=/<p[^>]*>[\\s\\S]*?<\\/p>/i.test(e.content)?e.content:`<p>${e.content}</p>`,i=e.metadata?Object.entries(e.metadata).map((([t,e])=>`data-${t}="${e}"`)).join(" "):"";return`\\n\\t\\t\\t<div class="message message-${e.author.toLowerCase()}" ${i}>\\n\\t\\t\\t\\t<div class="message-header">\\n\\t\\t\\t\\t\\t<p class="message-author"><strong>${e.author}</strong></p>\\n\\t\\t\\t\\t\\t${n}\\n\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t<div class="message-content">\\n\\t\\t\\t\\t\\t${o}\\n\\t\\t\\t\\t</div>\\n\\t\\t\\t</div>${r<t.length-1?"\\n<hr>":""}`})).join("\\n").trim()}\\n${e.length>0?`\\n\\t\\t\\t<div id="footnotes">\\n\\t\\t\\t\\t<ol>\\n\\t\\t\\t\\t\\t${e.map(((t,e)=>`\\n\\t\\t\\t\\t\\t\\t<li class="footnote" id="fn:${e+1}">\\n\\t\\t\\t\\t\\t\\t\\t<p>\\n\\t\\t\\t\\t\\t\\t\\t\\t<a href="${t.url}" target="_blank">${t.text}</a>&nbsp;<a href="#fnref:${e+1}" class="footnote-backref">\\u21a9</a>\\n\\t\\t\\t\\t\\t\\t\\t</p>\\n\\t\\t\\t\\t\\t\\t</li>\\n\\t\\t\\t\\t\\t`)).join("")}\\n\\t\\t\\t\\t</ol>\\n\\t\\t\\t</div>`:""}`.trim()}}e.ConversationExtractor=s},55(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.BbcodeDataExtractor=void 0;const n=r(279),o=r(618);class i extends n.BaseExtractor{constructor(){super(...arguments),this.eventData=void 0}canExtract(){var t,e;return!!(null===(e=null===(t=this.getEventData())||void 0===t?void 0:t.announcement_body)||void 0===e?void 0:e.body)}extract(){const t=this.getEventData(),e=t.announcement_body,r=(0,o.bbcodeToHtml)(e.body||""),n=e.headline||t.event_name||"",i=e.posttime?new Date(1e3*e.posttime).toISOString():"";return{content:r,contentHtml:r,extractedContent:{},variables:{title:n,author:this.getGroupName(),published:i}}}getEventData(){var t;return void 0===this.eventData&&(this.eventData=null!==(t=this.parseConfigAttr("data-partnereventstore"))&&void 0!==t?t:null),this.eventData}getGroupName(){const t=this.parseConfigAttr("data-groupvanityinfo");return(null==t?void 0:t.group_name)||""}parseConfigAttr(t){const e=this.document.querySelector("#application_config"),r=null==e?void 0:e.getAttribute(t);if(!r)return null;try{const t=JSON.parse(r);return Array.isArray(t)?t[0]:t}catch(t){return null}}}e.BbcodeDataExtractor=i},27(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.C2WikiExtractor=void 0;const o=r(279),i=r(639);class s extends o.BaseExtractor{canExtract(){return!1}canExtractAsync(){return null!==this.getPageTitle()}prefersAsync(){return!0}extract(){return{content:"",contentHtml:""}}extractAsync(){return n(this,void 0,void 0,(function*(){const t=this.getPageTitle();if(!t)return{content:"",contentHtml:""};const e=yield fetch("https://c2.com/wiki/remodel/pages/"+t).then((t=>t.json()));if(!e||!e.text)return{content:"",contentHtml:""};const r=t.replace(/([a-z])([A-Z])/g,"$1 $2"),n=this.renderPage(e);return{content:n,contentHtml:n,variables:Object.assign({title:r,site:"C2 Wiki"},e.date?{published:e.date}:{})}}))}getPageTitle(){if(void 0!==this.pageTitle)return this.pageTitle;try{const t=new URL(this.url).search.match(/[?&]([A-Za-z]\\w*)/);this.pageTitle=t?t[1]:"WelcomeVisitors"}catch(t){this.pageTitle=null}return this.pageTitle}renderPage(t){return`${this.markup(t.text)}${t.date?`<hr><p>Last edit ${(0,i.escapeHtml)(t.date)}</p>`:""}`}markup(t){const e=t.replace(/\\\\\\n/g," ").split(/\\r?\\n/),r=[];let n=[];for(const t of e){const{html:e,openTags:o}=this.applyBullets(t,n);r.push(this.applyInline(e)),n=o}for(;n.length>0;)r.push(`</${n.pop()}>`);return r.join("\\n")}applyBullets(t,e){const r=[...e];let n="";const o=(t,e)=>{for(;r.length>t;)n+=`</${r.pop()}>`;e&&r.length<t?(n+=`<${e}>`,r.push(e)):e&&r.length===t&&r[t-1]!==e&&(n+=`</${r.pop()}><${e}>`,r.push(e))};if(/^\\s*$/.test(t)){return r.some((t=>"ul"===t||"ol"===t||"dl"===t))?{html:"",openTags:r}:(o(0),{html:n+"<p></p>",openTags:r})}if(/^-----*/.test(t))return o(0),{html:n+"<hr>",openTags:r};const i=t.match(/^(\\t+)(.+):\\t/);if(i)return o(i[1].length,"dl"),{html:n+`<dt>${i[2]}<dd>`+t.slice(i[0].length),openTags:r};const s=t.match(/^(\\t+)\\*/);if(s)return o(s[1].length,"ul"),{html:n+"<li>"+t.slice(s[0].length),openTags:r};const a=t.match(/^(\\*+)/);if(a)return o(a[1].length,"ul"),{html:n+"<li>"+t.slice(a[0].length),openTags:r};const l=t.match(/^(\\t+)\\d+\\.?/);return l?(o(l[1].length,"ol"),{html:n+"<li>"+t.slice(l[0].length),openTags:r}):/^\\s/.test(t)?(o(1,"pre"),{html:n+t,openTags:r}):(o(0),{html:n+t,openTags:r})}applyInline(t){return t.replace(/\'\'\'(.*?)\'\'\'/g,"<strong>$1</strong>").replace(/\'\'(.*?)\'\'/g,"<em>$1</em>").replace(/\\b(https?|ftp|mailto|file|telnet|news):[^\\s<>[\\]"\'()]*[^\\s<>[\\]"\'(),.?]/g,(t=>(0,i.isDangerousUrl)(t)?(0,i.escapeHtml)(t):/\\.(gif|jpg|jpeg|png)$/i.test(t)?`<img src="${a(t)}">`:`<a href="${a(t)}" rel="nofollow" target="_blank">${(0,i.escapeHtml)(t)}</a>`))}}function a(t){return t.replace(/"/g,"&quot;").replace(/\'/g,"&#39;")}e.C2WikiExtractor=s},632(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.ChatGPTExtractor=void 0;const n=r(181),o=r(639);class i extends n.ConversationExtractor{constructor(t,e){super(t,e),this.cachedMessages=null,this.articles=t.querySelectorAll(\'article[data-testid^="conversation-turn-"]\'),this.footnotes=[],this.footnoteCounter=0}canExtract(){return!!this.articles&&this.articles.length>0}extractMessages(){if(this.cachedMessages)return this.cachedMessages;const t=[];return this.footnotes=[],this.footnoteCounter=0,this.articles?(this.articles.forEach((e=>{var r,n;const i=e.querySelector("h5.sr-only, h6.sr-only"),s=(null===(n=null===(r=null==i?void 0:i.textContent)||void 0===r?void 0:r.trim())||void 0===n?void 0:n.replace(/:\\s*$/,""))||"";let a="";const l=e.getAttribute("data-message-author-role");l&&(a=l);let c=(0,o.serializeHTML)(e);c=c.replace(/\\u200B/g,"");const u=this.document.createElement("div");u.appendChild((0,o.parseHTML)(this.document,c)),u.querySelectorAll(\'h5.sr-only, h6.sr-only, span[data-state="closed"]\').forEach((t=>t.remove())),c=(0,o.serializeHTML)(u);c=c.replace(/(&ZeroWidthSpace;)?(<span[^>]*?>\\s*<a(?=[^>]*?href="([^"]+)")(?=[^>]*?target="_blank")(?=[^>]*?rel="noopener")[^>]*?>[\\s\\S]*?<\\/a>\\s*<\\/span>)/gi,((t,e,r,n)=>{let o="",i="";try{o=new URL(n).hostname.replace(/^www\\./,"");const t=n.split("#:~:text=");if(t.length>1){i=decodeURIComponent(t[1]),i=i.replace(/%2C/g,",");const e=i.split(",");i=e.length>1&&e[0].trim()?` \\u2014 ${e[0].trim()}...`:e[0].trim()?` \\u2014 ${i.trim()}`:""}}catch(t){console.error(`Failed to parse URL: ${n}`,t),o=n}let s,a=this.footnotes.findIndex((t=>t.url===n));return-1===a?(this.footnoteCounter++,s=this.footnoteCounter,this.footnotes.push({url:n,text:`<a href="${n}">${o}</a>${i}`})):s=a+1,`<sup id="fnref:${s}"><a href="#fn:${s}">${s}</a></sup>`})),c=c.replace(/<p[^>]*>\\s*<\\/p>/g,""),t.push({author:s,content:c.trim(),metadata:{role:a||"unknown"}})})),this.cachedMessages=t,t):t}getFootnotes(){return this.footnotes}getMetadata(){const t=this.getTitle(),e=this.extractMessages();return{title:t,site:"ChatGPT",url:this.url,messageCount:e.length,description:`ChatGPT conversation with ${e.length} messages`}}getTitle(){var t,e,r;const n=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(n&&"ChatGPT"!==n)return n;const o=null===(r=null===(e=this.articles)||void 0===e?void 0:e.item(0))||void 0===r?void 0:r.querySelector(".text-message");if(o){const t=o.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"ChatGPT Conversation"}}e.ChatGPTExtractor=i},397(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.ClaudeExtractor=void 0;const n=r(181),o=r(639);class i extends n.ConversationExtractor{constructor(t,e){super(t,e),this.articles=t.querySelectorAll(\'div[data-testid="user-message"], div[data-testid="assistant-message"], div.font-claude-response\')}canExtract(){return!!this.articles&&this.articles.length>0}extractMessages(){const t=[];return this.articles?(this.articles.forEach((e=>{let r,n;if(e.hasAttribute("data-testid")){if("user-message"!==e.getAttribute("data-testid"))return;r="you",n=(0,o.serializeHTML)(e)}else{if(!e.classList.contains("font-claude-response"))return;{r="assistant";const t=e.querySelector(".standard-markdown")||e;n=(0,o.serializeHTML)(t)}}n&&(n=n.replace(/\\u200B/g,"").replace(/<p[^>]*>\\s*<\\/p>/g,""),t.push({author:"you"===r?"You":"Claude",content:n.trim(),metadata:{role:r}}))})),t):t}getMetadata(){const t=this.getTitle(),e=this.extractMessages();return{title:t,site:"Claude",url:this.url,messageCount:e.length,description:`Claude conversation with ${e.length} messages`}}getTitle(){var t,e,r,n,o;const i=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(i&&"Claude"!==i)return i.replace(/ - Claude$/,"");const s=null===(r=null===(e=this.document.querySelector("header .font-tiempos"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim();if(s)return s;const a=null===(o=null===(n=this.articles)||void 0===n?void 0:n.item(0))||void 0===o?void 0:o.querySelector(\'[data-testid="user-message"]\');if(a){const t=a.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"Claude Conversation"}}e.ClaudeExtractor=i},732(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.GeminiExtractor=void 0;const n=r(181),o=r(639);class i extends n.ConversationExtractor{constructor(t,e){super(t,e),this.messageCount=null,this.conversationContainers=t.querySelectorAll("div.conversation-container"),this.footnotes=[]}canExtract(){return!!this.conversationContainers&&this.conversationContainers.length>0}extractMessages(){this.messageCount=0;const t=[];return this.conversationContainers?(this.extractSources(),this.conversationContainers.forEach((e=>{const r=e.querySelector("user-query");if(r){const e=r.querySelector(".query-text");if(e){const r=(0,o.serializeHTML)(e);t.push({author:"You",content:r.trim(),metadata:{role:"user"}})}}const n=e.querySelector("model-response");if(n){const e=n.querySelector(".model-response-text .markdown"),r=n.querySelector("#extended-response-markdown-content")||e;if(r){let e=(0,o.serializeHTML)(r);const n=this.document.createElement("div");n.appendChild((0,o.parseHTML)(this.document,e)),n.querySelectorAll(".table-content").forEach((t=>{t.classList.remove("table-content")})),e=(0,o.serializeHTML)(n),t.push({author:"Gemini",content:e.trim(),metadata:{role:"assistant"}})}}})),this.messageCount=t.length,t):t}extractSources(){const t=this.document.querySelectorAll("browse-item");t&&t.length>0&&t.forEach((t=>{var e,r,n,o;const i=t.querySelector("a");if(i instanceof HTMLAnchorElement){const t=i.href,s=(null===(r=null===(e=i.querySelector(".domain"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",a=(null===(o=null===(n=i.querySelector(".title"))||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||"";t&&(s||a)&&this.footnotes.push({url:t,text:a?`${s}: ${a}`:s})}}))}getFootnotes(){return this.footnotes}getMetadata(){var t;const e=this.getTitle(),r=null!==(t=this.messageCount)&&void 0!==t?t:this.extractMessages().length;return{title:e,site:"Gemini",url:this.url,messageCount:r,description:`Gemini conversation with ${r} messages`}}getTitle(){var t,e,r,n,o;const i=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(i&&"Gemini"!==i&&!i.includes("Gemini"))return i;const s=null===(r=null===(e=this.document.querySelector(".title-text"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim();if(s)return s;const a=null===(o=null===(n=this.conversationContainers)||void 0===n?void 0:n.item(0))||void 0===o?void 0:o.querySelector(".query-text");if(a){const t=a.textContent||"";return t.length>50?t.slice(0,50)+"...":t}return"Gemini Conversation"}}e.GeminiExtractor=i},588(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.GitHubExtractor=void 0;const n=r(279),o=r(639),i=r(77);class s extends n.BaseExtractor{constructor(t,e){super(t,e),this.isIssue=/\\/issues\\/\\d+/.test(e),this.isPR=/\\/pull\\/\\d+/.test(e)}canExtract(){return!![\'meta[name="expected-hostname"][content="github.com"]\',\'meta[name="octolytics-url"]\',\'meta[name="github-keyboard-shortcuts"]\',".js-header-wrapper","#js-repo-pjax-container"].some((t=>null!==this.document.querySelector(t)))&&(this.isIssue?[\'[data-testid="issue-metadata-sticky"]\',\'[data-testid="issue-title"]\'].some((t=>null!==this.document.querySelector(t))):!!this.isPR&&[".pull-discussion-timeline",".discussion-timeline",".gh-header-title",".js-issue-title"].some((t=>null!==this.document.querySelector(t))))}extract(){const t=this.extractRepoInfo(),e=this.extractNumber(),r=this.isPR?"pull":"issue",n=this.isPR?this.getPRBody():null,{content:o,author:i,published:s}=this.isPR?this.getPRContent(n):this.getIssueContent(),a=!1!==this.options.includeReplies?this.isPR?this.extractPRComments(n):this.extractComments():"",l=this.createContentHtml(o,a);return{content:l,contentHtml:l,extractedContent:{type:r,number:e,repository:t.repo,owner:t.owner},variables:{title:this.document.title,author:i,published:s,site:`GitHub - ${t.owner}/${t.repo}`,description:this.createDescription(l)}}}createContentHtml(t,e){return(0,i.buildContentHtml)("github",t,e)}getIssueContent(){const t=this.document.querySelector(\'[data-testid="issue-viewer-issue-container"]\');if(!t)return{content:"",author:"",published:""};const e=this.extractAuthor(t,[\'a[data-testid="issue-body-header-author"]\',".IssueBodyHeaderAuthor-module__authorLoginLink--_S7aT",".ActivityHeader-module__AuthorLink--iofTU",\'a[href*="/users/"][data-hovercard-url*="/users/"]\',\'a[aria-label*="profile"]\']),r=t.querySelector("relative-time"),n=(null==r?void 0:r.getAttribute("datetime"))||"",o=t.querySelector(\'[data-testid="issue-body-viewer"] .markdown-body\');if(!o)return{content:"",author:e,published:n};return{content:this.cleanBodyContent(o),author:e,published:n}}extractComments(){const t=Array.from(this.document.querySelectorAll("[data-wrapper-timeline-id]")),e=new Set,r=[];for(const n of t){const t=n.querySelector(".react-issue-comment");if(!t)continue;const o=n.getAttribute("data-wrapper-timeline-id");if(!o||e.has(o))continue;e.add(o);const i=this.extractAuthor(t,[".ActivityHeader-module__AuthorLink--iofTU",\'a[data-testid="avatar-link"]\',\'a[href^="/"][data-hovercard-url*="/users/"]\']),s=t.querySelector("relative-time"),a=(null==s?void 0:s.getAttribute("datetime"))||"",l=a?new Date(a).toISOString().split("T")[0]:"",c=t.querySelector(".markdown-body");if(!c)continue;const u=this.cleanBodyContent(c);u&&r.push({author:i,date:l,content:u})}return(0,i.buildCommentTree)(r)}getPRBody(){return this.document.querySelector(\'[id^="pullrequest-"]\')||this.document.querySelector(".timeline-comment")}getPRContent(t){var e;const r=(null==t?void 0:t.querySelector(".comment-body.markdown-body"))||this.document.querySelector(".comment-body.markdown-body"),n=r?this.cleanBodyContent(r):"",o=(null==t?void 0:t.querySelector(".author"))||this.document.querySelector(".gh-header-meta .author"),i=(null===(e=null==o?void 0:o.textContent)||void 0===e?void 0:e.trim())||"",s=null==t?void 0:t.querySelector("relative-time");return{content:n,author:i,published:(null==s?void 0:s.getAttribute("datetime"))||""}}extractPRComments(t){var e;const r=Array.from(this.document.querySelectorAll(".timeline-comment, .review-comment")),n=[];for(const o of r){if(t&&(o===t||t.contains(o)))continue;const r=o.querySelector(".author"),i=(null===(e=null==r?void 0:r.textContent)||void 0===e?void 0:e.trim())||"",s=o.querySelector("relative-time"),a=(null==s?void 0:s.getAttribute("datetime"))||"",l=a?new Date(a).toISOString().split("T")[0]:"",c=o.querySelector(".comment-body.markdown-body");if(!c)continue;const u=this.cleanBodyContent(c);u&&n.push({author:i,date:l,content:u})}return(0,i.buildCommentTree)(n)}extractAuthor(t,e){for(const r of e){const e=t.querySelector(r);if(e){const t=e.getAttribute("href");if(t){if(t.startsWith("/"))return t.substring(1);if(t.includes("github.com/")){const e=t.match(/github\\.com\\/([^\\/\\?#]+)/);if(e&&e[1])return e[1]}}}}return"Unknown"}cleanBodyContent(t){const e=t.cloneNode(!0);return e.querySelectorAll(\'button, [data-testid*="button"], [data-testid*="menu"]\').forEach((t=>t.remove())),e.querySelectorAll(".js-clipboard-copy, .zeroclipboard-container").forEach((t=>t.remove())),e.querySelectorAll(\'div.highlight[class*="highlight-source-"] pre, div.highlight pre\').forEach((t=>{const e=t.parentElement;if(!e)return;const r=e.className.match(/highlight-source-(\\w+)/),n=(null==r?void 0:r[1])||"",o=e.getAttribute("data-snippet-clipboard-copy-content")||t.textContent||"",i=this.document.createElement("code");n&&(i.setAttribute("class",`language-${n}`),i.setAttribute("data-lang",n)),i.textContent=o;const s=this.document.createElement("pre");s.appendChild(i),e.replaceWith(s)})),(0,o.serializeHTML)(e).trim()}extractNumber(){var t;const e=this.url.match(/\\/(issues|pull)\\/(\\d+)/);if(e)return e[2];const r=this.document.querySelector("h1"),n=null===(t=null==r?void 0:r.textContent)||void 0===t?void 0:t.match(/#(\\d+)/);return n?n[1]:""}extractRepoInfo(){const t=this.url.match(/github\\.com\\/([^\\/]+)\\/([^\\/]+)/);if(t)return{owner:t[1],repo:t[2]};const e=this.document.title.match(/([^\\/\\s]+)\\/([^\\/\\s]+)/);return e?{owner:e[1],repo:e[2]}:{owner:"",repo:""}}createDescription(t){var e;if(!t)return"";const r=this.document.createElement("div");return r.appendChild((0,o.parseHTML)(this.document,t)),(null===(e=r.textContent)||void 0===e?void 0:e.trim().slice(0,140).replace(/\\s+/g," "))||""}}e.GitHubExtractor=s},20(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.GrokExtractor=void 0;const n=r(181),o=r(639);class i extends n.ConversationExtractor{constructor(t,e){super(t,e),this.messageContainerSelector=".relative.group.flex.flex-col.justify-center.w-full",this.messageBubbles=t.querySelectorAll(this.messageContainerSelector),this.footnotes=[],this.footnoteCounter=0}canExtract(){return!!this.messageBubbles&&this.messageBubbles.length>0}extractMessages(){const t=[];return this.footnotes=[],this.footnoteCounter=0,this.messageBubbles&&0!==this.messageBubbles.length?(this.messageBubbles.forEach((e=>{var r;const n=e.classList.contains("items-end"),i=e.classList.contains("items-start");if(!n&&!i)return;const s=e.querySelector(".message-bubble");if(!s)return;let a="",l="",c="";if(n)a=s.textContent||"",l="user",c="You";else if(i){l="assistant",c="Grok";const t=s.cloneNode(!0);null===(r=t.querySelector(".relative.border.border-border-l1.bg-surface-base"))||void 0===r||r.remove(),a=(0,o.serializeHTML)(t),a=this.processFootnotes(a)}a.trim()&&t.push({author:c,content:a.trim(),metadata:{role:l}})})),t):t}getFootnotes(){return this.footnotes}getMetadata(){var t;const e=this.getTitle(),r=(null===(t=this.messageBubbles)||void 0===t?void 0:t.length)||0;return{title:e,site:"Grok",url:this.url,messageCount:r,description:`Grok conversation with ${r} messages`}}getTitle(){var t,e;const r=null===(t=this.document.title)||void 0===t?void 0:t.trim();if(r&&"Grok"!==r&&!r.startsWith("Grok by "))return r.replace(/\\s-\\s*Grok$/,"").trim();const n=this.document.querySelector(`${this.messageContainerSelector}.items-end`);if(n){const t=n.querySelector(".message-bubble");if(t){const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";return r.length>50?r.slice(0,50)+"...":r}}return"Grok Conversation"}processFootnotes(t){return t.replace(/<a\\s+(?:[^>]*?\\s+)?href="([^"]*)"[^>]*>(.*?)<\\/a>/gi,((t,e,r)=>{if(!e||e.startsWith("#")||!e.match(/^https?:\\/\\//i))return t;let n;if(this.footnotes.find((t=>t.url===e)))n=this.footnotes.findIndex((t=>t.url===e))+1;else{this.footnoteCounter++,n=this.footnoteCounter;let t=e;try{const r=new URL(e).hostname.replace(/^www\\./,"");t=`<a href="${e}" target="_blank" rel="noopener noreferrer">${r}</a>`}catch(r){t=`<a href="${e}" target="_blank" rel="noopener noreferrer">${e}</a>`,console.warn(`GrokExtractor: Could not parse URL for footnote: ${e}`)}this.footnotes.push({url:e,text:t})}return`${r}<sup id="fnref:${n}" class="footnote-ref"><a href="#fn:${n}" class="footnote-link">${n}</a></sup>`}))}}e.GrokExtractor=i},458(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.HackerNewsExtractor=void 0;const n=r(279),o=r(639),i=r(77);class s extends n.BaseExtractor{constructor(t,e){super(t,e),this.mainPost=t.querySelector(".fatitem"),this.isCommentPage=this.detectCommentPage(),this.mainComment=this.isCommentPage?this.findMainComment():null}detectCommentPage(){var t,e;return!!(null===(t=this.mainPost)||void 0===t?void 0:t.querySelector(".onstory"))&&!(null===(e=this.mainPost)||void 0===e?void 0:e.querySelector(".titleline"))}findMainComment(){var t;return(null===(t=this.mainPost)||void 0===t?void 0:t.querySelector("tr.athing"))||null}canExtract(){return!!this.mainPost}extract(){const t=this.getPostContent(),e=!1!==this.options.includeReplies?this.extractComments():"",r=this.createContentHtml(t,e),n=this.getPostTitle(),o=this.getPostAuthor(),i=this.createDescription(),s=this.getPostDate();return{content:r,contentHtml:r,extractedContent:{postId:this.getPostId(),postAuthor:o},variables:{title:n,author:o,site:"Hacker News",description:i,published:s}}}createContentHtml(t,e){return(0,i.buildContentHtml)("hackernews",t,e)}getPostContent(){var t,e,r,n;if(!this.mainPost)return"";if(this.isCommentPage&&this.mainComment){const n=(null===(t=this.mainComment.querySelector(".hnuser"))||void 0===t?void 0:t.textContent)||"[deleted]",s=this.mainComment.querySelector(".commtext"),a=s?(0,o.serializeHTML)(s):"",l=this.mainComment.querySelector(".age"),c=((null==l?void 0:l.getAttribute("title"))||"").split("T")[0]||"",u=(null===(r=null===(e=this.mainComment.querySelector(".score"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"";return(0,i.buildComment)({author:n,date:c,content:a,score:u||void 0})}const s=this.mainPost.querySelector("tr.athing"),a=(null==s||s.nextElementSibling,(null===(n=null==s?void 0:s.querySelector(".titleline a"))||void 0===n?void 0:n.getAttribute("href"))||"");let l="";a&&(l+=`<p><a href="${a}" target="_blank">${a}</a></p>`);const c=this.mainPost.querySelector(".toptext");return c&&(l+=`<div class="post-text">${(0,o.serializeHTML)(c)}</div>`),l}extractComments(){const t=Array.from(this.document.querySelectorAll("tr.comtr"));return this.processComments(t)}processComments(t){var e,r,n,s;const a=[],l=new Set;for(const i of t){const t=i.getAttribute("id");if(!t||l.has(t))continue;l.add(t);const c=(null===(e=i.querySelector(".ind img"))||void 0===e?void 0:e.getAttribute("width"))||"0",u=parseInt(c)/40,d=i.querySelector(".commtext"),h=(null===(r=i.querySelector(".hnuser"))||void 0===r?void 0:r.textContent)||"[deleted]",m=i.querySelector(".age"),p=(null===(s=null===(n=i.querySelector(".score"))||void 0===n?void 0:n.textContent)||void 0===s?void 0:s.trim())||"";if(!d)continue;const f=`https://news.ycombinator.com/item?id=${t}`,g=((null==m?void 0:m.getAttribute("title"))||"").split("T")[0]||"";a.push({author:h,date:g,content:(0,o.serializeHTML)(d),depth:u,score:p||void 0,url:f})}return(0,i.buildCommentTree)(a)}getPostId(){const t=this.url.match(/id=(\\d+)/);return(null==t?void 0:t[1])||""}getPostTitle(){var t,e,r,n,o;if(this.isCommentPage&&this.mainComment){const r=(null===(t=this.mainComment.querySelector(".hnuser"))||void 0===t?void 0:t.textContent)||"[deleted]",n=(null===(e=this.mainComment.querySelector(".commtext"))||void 0===e?void 0:e.textContent)||"";return`Comment by ${r}: ${n.trim().slice(0,50)+(n.length>50?"...":"")}`}return(null===(o=null===(n=null===(r=this.mainPost)||void 0===r?void 0:r.querySelector(".titleline"))||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||""}getPostAuthor(){var t,e,r;return(null===(r=null===(e=null===(t=this.mainPost)||void 0===t?void 0:t.querySelector(".hnuser"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||""}createDescription(){const t=this.getPostTitle(),e=this.getPostAuthor();return this.isCommentPage?`Comment by ${e} on Hacker News`:`${t} - by ${e} on Hacker News`}getPostDate(){if(!this.mainPost)return"";const t=this.mainPost.querySelector(".age");return((null==t?void 0:t.getAttribute("title"))||"").split("T")[0]||""}}e.HackerNewsExtractor=s},959(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.RedditExtractor=void 0;const o=r(279),i=r(639),s=r(77);class a extends o.BaseExtractor{constructor(t,e){super(t,e),this.shredditPost=t.querySelector("shreddit-post"),this.isOldReddit=!!t.querySelector(".thing.link")}canExtract(){return!!this.shredditPost||this.isOldReddit}canExtractAsync(){return this.isCommentsPage()&&!this.isOldReddit}prefersAsync(){const t="undefined"!=typeof window&&this.document.defaultView===window;return this.isCommentsPage()&&!this.isOldReddit&&!t}isCommentsPage(){return/\\/r\\/.+\\/comments\\//.test(this.url)}extractAsync(){return n(this,void 0,void 0,(function*(){var t,e;const r=new URL(this.url);r.hostname="old.reddit.com";const n=yield fetch(r.toString(),{headers:{"User-Agent":"Mozilla/5.0 (compatible; Defuddle/1.0)"}});if(!n.ok)throw new Error(`Failed to fetch old.reddit.com: ${n.status}`);const o=yield n.text(),i=null!==(e=null===(t=this.document.defaultView)||void 0===t?void 0:t.DOMParser)&&void 0!==e?e:"undefined"!=typeof DOMParser?DOMParser:null;if(!i)throw new Error("DOMParser is not available in this environment");const s=(new i).parseFromString(o,"text/html");return this.extractOldReddit(s)}))}extract(){var t,e;if(this.isOldReddit)return this.extractOldReddit(this.document);const r=(null===(e=null===(t=this.document.querySelector("h1"))||void 0===t?void 0:t.textContent)||void 0===e?void 0:e.trim())||"",n=this.getSubreddit(),o=this.getPostAuthor(),i=this.getPostContent(),s=this.createDescription(i),a=!1!==this.options.includeReplies?this.extractComments():"",l=this.createContentHtml(i,a);return{content:l,contentHtml:l,extractedContent:{postId:this.getPostId(),subreddit:n,postAuthor:o},variables:{title:r,author:o,site:`r/${n}`,description:s}}}extractOldReddit(t){var e,r;const n=t.querySelector(".thing.link"),o=(null===(r=null===(e=null==n?void 0:n.querySelector("a.title"))||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",a=(null==n?void 0:n.getAttribute("data-author"))||"",l=(null==n?void 0:n.getAttribute("data-subreddit"))||"",c=null==n?void 0:n.querySelector(".usertext-body .md"),u=c?(0,i.serializeHTML)(c):"";let d="";if(!1!==this.options.includeReplies){const e=t.querySelector(".commentarea .sitetable"),r=e?this.collectOldRedditComments(e):[];d=r.length>0?(0,s.buildCommentTree)(r):""}const h=this.createContentHtml(u,d),m=this.createDescription(u);return{content:h,contentHtml:h,extractedContent:{postId:this.getPostId(),subreddit:l,postAuthor:a},variables:{title:o,author:a,site:`r/${l}`,description:m}}}getPostContent(){var t,e,r;const n=null===(t=this.shredditPost)||void 0===t?void 0:t.querySelector(\'[slot="text-body"]\');return(n?(0,i.serializeHTML)(n):"")+((null===(r=null===(e=this.shredditPost)||void 0===e?void 0:e.querySelector("#post-image"))||void 0===r?void 0:r.outerHTML)||"")}createContentHtml(t,e){return(0,s.buildContentHtml)("reddit",t,e)}extractComments(){const t=Array.from(this.document.querySelectorAll("shreddit-comment"));return this.processComments(t)}getPostId(){const t=this.url.match(/comments\\/([a-zA-Z0-9]+)/);return(null==t?void 0:t[1])||""}getSubreddit(){const t=this.url.match(/\\/r\\/([^/]+)/);return(null==t?void 0:t[1])||""}getPostAuthor(){var t;return(null===(t=this.shredditPost)||void 0===t?void 0:t.getAttribute("author"))||""}createDescription(t){var e;if(!t)return"";const r=this.document.createElement("div");return r.appendChild((0,i.parseHTML)(this.document,t)),(null===(e=r.textContent)||void 0===e?void 0:e.trim().slice(0,140).replace(/\\s+/g," "))||""}collectOldRedditComments(t,e=0){var r,n;const o=[],s=Array.from(t.querySelectorAll(":scope > .thing.comment"));for(const t of s){const s=t.getAttribute("data-author")||"",a=t.getAttribute("data-permalink")||"",l=(null===(n=null===(r=t.querySelector(".entry .tagline .score.unvoted"))||void 0===r?void 0:r.textContent)||void 0===n?void 0:n.trim())||"",c=t.querySelector(".entry .tagline time[datetime]"),u=(null==c?void 0:c.getAttribute("datetime"))||"",d=u?new Date(u).toISOString().split("T")[0]:"",h=t.querySelector(".entry .usertext-body .md"),m=h?(0,i.serializeHTML)(h):"";o.push({author:s,date:d,content:m,depth:e,score:l||void 0,url:a?`https://reddit.com${a}`:void 0});const p=t.querySelector(".child > .sitetable");p&&o.push(...this.collectOldRedditComments(p,e+1))}return o}processComments(t){var e;const r=[];for(const n of t){const t=parseInt(n.getAttribute("depth")||"0"),o=n.getAttribute("author")||"",s=n.getAttribute("score")||"0",a=n.getAttribute("permalink")||"",l=n.querySelector(\'[slot="comment"]\'),c=l?(0,i.serializeHTML)(l):"",u=n.getAttribute("created")||(null===(e=n.querySelector("time"))||void 0===e?void 0:e.getAttribute("datetime"))||"",d=u?new Date(u).toISOString().split("T")[0]:"";r.push({author:o,date:d,content:c,depth:t,score:`${s} points`,url:a?`https://reddit.com${a}`:void 0})}return(0,s.buildCommentTree)(r)}}e.RedditExtractor=a},581(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.SubstackExtractor=void 0;const n=r(279),o=r(639),i="data-defuddle-substack-post";class s extends n.BaseExtractor{constructor(t,e,r,n){var s,a;if(super(t,e,r,n),this.noteText=null,this.noteImage=null,this.postData=null,this.postContentSelector=null,t.querySelector("div.body.markup"))return this.postData=this.extractPreloadData(),void(this.postContentSelector="div.body.markup");if(this.postData=this.extractPreloadData(),null===(s=this.postData)||void 0===s?void 0:s.body_html){if(!t.querySelector(`[${i}]`)){const e=t.createElement("div");e.setAttribute(i,""),e.appendChild((0,o.parseHTML)(t,this.postData.body_html)),t.body.appendChild(e)}this.postContentSelector=`[${i}]`}else if(this.noteText=t.querySelector("div.ProseMirror.FeedProseMirror"),this.noteText){const t=this.noteText.closest(\'[class*="feedCommentBody"]:not([class*="feedCommentBodyInner"])\'),e=null===(a=null==t?void 0:t.parentElement)||void 0===a?void 0:a.nextElementSibling,r=(null==e?void 0:e.getAttribute("class"))||"";e&&r.includes("imageGrid")&&(this.noteImage=e)}}canExtract(){return null!==this.postContentSelector||null!==this.noteText}extract(){return this.postContentSelector?this.extractPost():this.extractNote()}extractPost(){var t,e,r,n,o,i,s,a,l,c;const u=(null===(t=this.postData)||void 0===t?void 0:t.title)||(null===(e=this.document.querySelector(\'meta[property="og:title"]\'))||void 0===e?void 0:e.getAttribute("content"))||"",d=(null===(r=this.postData)||void 0===r?void 0:r.subtitle)||(null===(n=this.document.querySelector(\'meta[property="og:description"]\'))||void 0===n?void 0:n.getAttribute("content"))||"",h=(null===(s=null===(i=null===(o=this.postData)||void 0===o?void 0:o.publishedBylines)||void 0===i?void 0:i[0])||void 0===s?void 0:s.name)||(null===(l=null===(a=this.document.querySelector(\'a[href*="substack.com/@"]\'))||void 0===a?void 0:a.textContent)||void 0===l?void 0:l.trim())||"",m=(null===(c=this.postData)||void 0===c?void 0:c.post_date)||this.parseDateFromByline()||"";return{content:"",contentHtml:"",contentSelector:this.postContentSelector,variables:{title:u,author:h,site:"Substack",description:d,published:m}}}extractNote(){var t,e;const r=this.noteText.outerHTML,n=this.buildImageHtml(),o=n?`${r}\\n${n}`:r,i=(null===(t=this.document.querySelector(\'meta[property="og:title"]\'))||void 0===t?void 0:t.getAttribute("content"))||"",s=(null===(e=this.document.querySelector(\'meta[property="og:description"]\'))||void 0===e?void 0:e.getAttribute("content"))||"",a=i.replace(/\\s*\\(@[^)]+\\)\\s*$/,"").trim();return{content:o,contentHtml:o,variables:{title:i,author:a,site:"Substack",description:s}}}parseDateFromByline(){const t=this.document.querySelector(\'[class*="byline-wrapper"]\');if(!t)return"";const e={Jan:"01",Feb:"02",Mar:"03",Apr:"04",May:"05",Jun:"06",Jul:"07",Aug:"08",Sep:"09",Oct:"10",Nov:"11",Dec:"12"},r=(t.textContent||"").trim().replace(/([a-z])([A-Z])/g,"$1 $2").match(new RegExp("\\\\b(Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)\\\\s+(\\\\d{1,2}),?\\\\s+(\\\\d{4})\\\\b"));if(r){const t=e[r[1]],n=r[2].padStart(2,"0");return`${r[3]}-${t}-${n}T00:00:00+00:00`}return""}extractPreloadData(){var t,e;const r=Array.from(this.document.querySelectorAll("script"));for(const n of r){const r=n.textContent||"";if(!r.includes("window._preloads")||!r.includes("body_html"))continue;const o=r.indexOf(\'JSON.parse("\');if(-1===o)continue;const i=o+12;let s=i;for(;s<r.length;)if("\\\\"===r[s])s+=2;else{if(\'"\'===r[s])break;s++}try{const n=r.slice(i,s),o=JSON.parse(\'"\'+n+\'"\'),a=JSON.parse(o),l=null===(e=null===(t=null==a?void 0:a.feedData)||void 0===t?void 0:t.initialPost)||void 0===e?void 0:e.post;if(null==l?void 0:l.body_html)return l}catch(t){}}return null}buildImageHtml(){var t;if(!this.noteImage)return"";const e=null===(t=this.document.querySelector(\'meta[property="og:image"]\'))||void 0===t?void 0:t.getAttribute("content");if(e)return`<img src="${e}" alt="" />`;const r=this.noteImage.querySelector("img");if(!r)return"";const n=this.getLargestSrc(r);return n?`<img src="${n}" alt="" />`:""}getLargestSrc(t){const e=t.getAttribute("srcset")||"";if(e){const t=/(.+?)\\s+(\\d+(?:\\.\\d+)?)w/g;let r,n="",o=0,i=0;for(;null!==(r=t.exec(e));){let e=r[1].trim();i>0&&(e=e.replace(/^,\\s*/,"")),i=t.lastIndex;const s=parseFloat(r[2]);e&&s>o&&(o=s,n=e)}if(n)return n.replace(/,w_\\d+/g,"").replace(/,c_\\w+/g,"")}return t.getAttribute("src")||""}}e.SubstackExtractor=s},248(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.TwitterExtractor=void 0;const n=r(279),o=r(639);class i extends n.BaseExtractor{constructor(t,e){var r;super(t,e),this.mainTweet=null,this.threadTweets=[];const n=t.querySelector(\'[aria-label="Timeline: Conversation"]\');if(!n){const e=t.querySelector(\'article[data-testid="tweet"]\');return void(e&&(this.mainTweet=e))}let o=Array.from(n.querySelectorAll(\'article[data-testid="tweet"]\'));const i=null===(r=n.querySelector("section, h2"))||void 0===r?void 0:r.parentElement;if(i){const t=o.findIndex((t=>i.compareDocumentPosition(t)&Node.DOCUMENT_POSITION_FOLLOWING));-1!==t&&(o=o.slice(0,t))}this.mainTweet=o[0]||null,this.threadTweets=o.slice(1)}canExtract(){return!!this.mainTweet}extract(){const t=this.extractTweet(this.mainTweet),e=!1!==this.options.includeReplies?this.threadTweets.map((t=>this.extractTweet(t))).join("\\n<hr>\\n"):"",r=`\\n\\t\\t\\t<div class="tweet-thread">\\n\\t\\t\\t\\t<div class="main-tweet">\\n\\t\\t\\t\\t\\t${t}\\n\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t${e?`\\n\\t\\t\\t\\t\\t<hr>\\n\\t\\t\\t\\t\\t<div class="thread-tweets">\\n\\t\\t\\t\\t\\t\\t${e}\\n\\t\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t`:""}\\n\\t\\t\\t</div>\\n\\t\\t`.trim(),n=this.getTweetId(),o=this.getTweetAuthor();return{content:r,contentHtml:r,extractedContent:{tweetId:n,tweetAuthor:o},variables:{title:`Thread by ${o}`,author:o,site:"X (Twitter)",description:this.createDescription(this.mainTweet)}}}formatTweetText(t){if(!t)return"";const e=this.document.createElement("div");e.appendChild((0,o.parseHTML)(this.document,t)),e.querySelectorAll("a").forEach((t=>{var e;const r=(null===(e=t.textContent)||void 0===e?void 0:e.trim())||"";t.replaceWith(r)})),e.querySelectorAll("span, div").forEach((t=>{t.replaceWith(...Array.from(t.childNodes))}));return(0,o.serializeHTML)(e).split("\\n").map((t=>t.trim())).filter((t=>t)).map((t=>`<p>${t}</p>`)).join("\\n")}extractTweet(t){var e,r;if(!t)return"";const n=t.cloneNode(!0);n.querySelectorAll(\'img[src*="/emoji/"]\').forEach((t=>{if("img"===t.tagName.toLowerCase()&&t.getAttribute("alt")){const e=t.getAttribute("alt");e&&t.replaceWith(e)}}));const i=n.querySelector(\'[data-testid="tweetText"]\'),s=i?(0,o.serializeHTML)(i):"",a=this.formatTweetText(s),l=this.extractImages(t),c=this.extractUserInfo(t),u=null===(r=null===(e=t.querySelector(\'[aria-labelledby*="id__"]\'))||void 0===e?void 0:e.querySelector(\'[data-testid="User-Name"]\'))||void 0===r?void 0:r.closest(\'[aria-labelledby*="id__"]\'),d=u?this.extractTweet(u):"";return`\\n\\t\\t\\t<div class="tweet">\\n\\t\\t\\t\\t<div class="tweet-header">\\n\\t\\t\\t\\t\\t<span class="tweet-author"><strong>${c.fullName}</strong> <span class="tweet-handle">${c.handle}</span></span>\\n\\t\\t\\t\\t\\t${c.date?`<a href="${c.permalink}" class="tweet-date">${c.date}</a>`:""}\\n\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t${a?`<div class="tweet-text">${a}</div>`:""}\\n\\t\\t\\t\\t${l.length?`\\n\\t\\t\\t\\t\\t<div class="tweet-media">\\n\\t\\t\\t\\t\\t\\t${l.join("\\n")}\\n\\t\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t`:""}\\n\\t\\t\\t\\t${d?`\\n\\t\\t\\t\\t\\t<blockquote class="quoted-tweet">\\n\\t\\t\\t\\t\\t\\t${d}\\n\\t\\t\\t\\t\\t</blockquote>\\n\\t\\t\\t\\t`:""}\\n\\t\\t\\t</div>\\n\\t\\t`.trim()}extractUserInfo(t){var e,r,n,o,i,s,a,l,c;const u=t.querySelector(\'[data-testid="User-Name"]\');if(!u)return{fullName:"",handle:"",date:"",permalink:""};const d=u.querySelectorAll("a");let h=(null===(r=null===(e=null==d?void 0:d[0])||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"",m=(null===(o=null===(n=null==d?void 0:d[1])||void 0===n?void 0:n.textContent)||void 0===o?void 0:o.trim())||"";h&&m||(h=(null===(s=null===(i=u.querySelector(\'span[style*="color: rgb(15, 20, 25)"] span\'))||void 0===i?void 0:i.textContent)||void 0===s?void 0:s.trim())||"",m=(null===(l=null===(a=u.querySelector(\'span[style*="color: rgb(83, 100, 113)"]\'))||void 0===a?void 0:a.textContent)||void 0===l?void 0:l.trim())||"");const p=t.querySelector("time"),f=(null==p?void 0:p.getAttribute("datetime"))||"";return{fullName:h,handle:m,date:f?new Date(f).toISOString().split("T")[0]:"",permalink:(null===(c=null==p?void 0:p.closest("a"))||void 0===c?void 0:c.href)||""}}extractImages(t){var e,r;const n=[\'[data-testid="tweetPhoto"]\',\'[data-testid="tweet-image"]\',\'img[src*="media"]\'],o=[],i=null===(r=null===(e=t.querySelector(\'[aria-labelledby*="id__"]\'))||void 0===e?void 0:e.querySelector(\'[data-testid="User-Name"]\'))||void 0===r?void 0:r.closest(\'[aria-labelledby*="id__"]\');for(const e of n){t.querySelectorAll(e).forEach((t=>{var e,r;if(!(null==i?void 0:i.contains(t))&&"img"===t.tagName.toLowerCase()&&t.getAttribute("alt")){const n=(null===(e=t.getAttribute("src"))||void 0===e?void 0:e.replace(/&name=\\w+$/,"&name=large"))||"",i=(null===(r=t.getAttribute("alt"))||void 0===r?void 0:r.replace(/\\s+/g," ").trim())||"";o.push(`<img src="${n}" alt="${i}" />`)}}))}return o}getTweetId(){const t=this.url.match(/status\\/(\\d+)/);return(null==t?void 0:t[1])||""}getTweetAuthor(){var t,e,r;const n=null===(t=this.mainTweet)||void 0===t?void 0:t.querySelector(\'[data-testid="User-Name"]\'),o=null==n?void 0:n.querySelectorAll("a"),i=(null===(r=null===(e=null==o?void 0:o[1])||void 0===e?void 0:e.textContent)||void 0===r?void 0:r.trim())||"";return i.startsWith("@")?i:`@${i}`}createDescription(t){var e;if(!t)return"";return((null===(e=t.querySelector(\'[data-testid="tweetText"]\'))||void 0===e?void 0:e.textContent)||"").trim().slice(0,140).replace(/\\s+/g," ")}}e.TwitterExtractor=i},64(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.XArticleExtractor=void 0;const n=r(279),o=r(639),i=\'[data-testid="twitterArticleRichTextView"]\',s=\'[data-testid="twitter-article-title"]\',a=\'[itemprop="author"]\',l=\'meta[itemprop="name"]\',c=\'meta[itemprop="additionalName"]\',u=\'[data-testid="tweetPhoto"] img\',d=".longform-unstyled, .public-DraftStyleDefault-block",h=\'span[style*="font-weight: bold"]\',m="[data-offset-key]",p=\'[data-testid="simpleTweet"]\',f=\'[data-testid="tweetText"]\',g=\'[data-testid="User-Name"]\',v=\'[data-testid="markdown-code-block"]\';class y extends n.BaseExtractor{constructor(t,e,r){super(t,e,r),this.articleContainer=t.querySelector(i)}canExtract(){return!!this.articleContainer}extract(){const t=this.extractTitle(),e=this.extractAuthor(),r=this.extractContent(),n=this.createDescription();return{content:r,contentHtml:r,extractedContent:{articleId:this.getArticleId()},variables:{title:t,author:e,site:"X (Twitter)",description:n}}}extractTitle(){var t;const e=this.document.querySelector(s);return(null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.trim())||"Untitled X Article"}extractAuthor(){var t,e;const r=this.document.querySelector(a);if(!r)return this.getAuthorFromUrl();const n=null===(t=r.querySelector(l))||void 0===t?void 0:t.getAttribute("content"),o=null===(e=r.querySelector(c))||void 0===e?void 0:e.getAttribute("content");return n&&o?`${n} (@${o})`:n||o||this.getAuthorFromUrl()}getAuthorFromUrl(){const t=this.url.match(/\\/([a-zA-Z0-9_][a-zA-Z0-9_]{0,14})\\/(article|status)\\/\\d+/);return t?`@${t[1]}`:this.getAuthorFromOgTitle()}getAuthorFromOgTitle(){var t;const e=((null===(t=this.document.querySelector(\'meta[property="og:title"]\'))||void 0===t?void 0:t.getAttribute("content"))||"").match(/^(?:\\(\\d+\\)\\s+)?(.+?)\\s+on\\s+X\\s*:/);return e?e[1].trim():"Unknown"}getArticleId(){const t=this.url.match(/article\\/(\\d+)/);return t?t[1]:""}extractContent(){if(!this.articleContainer)return"";const t=this.articleContainer.cloneNode(!0);return this.cleanContent(t),`<article class="x-article">${(0,o.serializeHTML)(t)}</article>`}cleanContent(t){const e=t.ownerDocument||this.document;this.convertEmbeddedTweets(t,e),this.convertCodeBlocks(t,e),this.convertHeaders(t,e),this.unwrapLinkedImages(t,e),this.upgradeImageQuality(t),this.convertBoldSpans(t,e),this.convertDraftParagraphs(t,e),this.removeDraftAttributes(t),this.repairSurrogatePairs(t)}convertEmbeddedTweets(t,e){t.querySelectorAll(p).forEach((t=>{var r,n,o,i,s;const a=e.createElement("blockquote");a.className="embedded-tweet";const l=t.querySelector(g),c=null==l?void 0:l.querySelectorAll("a"),u=(null===(n=null===(r=null==c?void 0:c[0])||void 0===r?void 0:r.textContent)||void 0===n?void 0:n.trim())||"",d=(null===(i=null===(o=null==c?void 0:c[1])||void 0===o?void 0:o.textContent)||void 0===i?void 0:i.trim())||"",h=t.querySelector(f),m=(null===(s=null==h?void 0:h.textContent)||void 0===s?void 0:s.trim())||"";if(u||d){const t=e.createElement("cite");t.textContent=d?`${u} ${d}`:u,a.appendChild(t)}if(m){const t=e.createElement("p");t.textContent=m,a.appendChild(t)}t.replaceWith(a)}))}convertCodeBlocks(t,e){t.querySelectorAll(v).forEach((t=>{var r;const n=t.querySelector("pre"),o=t.querySelector("code");if(!n||!o)return;let i="";const s=o.className.match(/language-(\\w+)/);if(s)i=s[1];else{const e=t.querySelector("span");i=(null===(r=null==e?void 0:e.textContent)||void 0===r?void 0:r.trim())||""}const a=e.createElement("pre"),l=e.createElement("code");i&&(l.setAttribute("data-lang",i),l.className=`language-${i}`),l.textContent=o.textContent||"",a.appendChild(l),t.replaceWith(a)}))}convertHeaders(t,e){t.querySelectorAll("h1, h2, h3, h4, h5, h6").forEach((t=>{var r;const n=t.tagName.toLowerCase(),o=(null===(r=t.textContent)||void 0===r?void 0:r.trim())||"";if(!o)return;const i=e.createElement(n);i.textContent=o,t.replaceWith(i)}))}unwrapLinkedImages(t,e){t.querySelectorAll(u).forEach((r=>{var n;const o=r.closest("a");if(!o||!t.contains(o))return;let i=r.getAttribute("src")||"";const s=(null===(n=r.getAttribute("alt"))||void 0===n?void 0:n.replace(/\\s+/g," ").trim())||"Image";i=i.includes("&name=")?i.replace(/&name=\\w+/,"&name=large"):i.includes("?")?`${i}&name=large`:`${i}?name=large`;const a=e.createElement("img");a.setAttribute("src",i),a.setAttribute("alt",s),o.replaceWith(a)}))}upgradeImageQuality(t){t.querySelectorAll(u).forEach((t=>{const e=t.getAttribute("src");e&&(e.includes("&name=")?t.setAttribute("src",e.replace(/&name=\\w+/,"&name=large")):e.includes("?")?t.setAttribute("src",`${e}&name=large`):t.setAttribute("src",`${e}?name=large`))}))}convertDraftParagraphs(t,e){t.querySelectorAll(d).forEach((t=>{const r=e.createElement("p"),n=t=>{if(3===t.nodeType)r.appendChild(e.createTextNode(t.textContent||""));else if(1===t.nodeType){const o=t,i=o.tagName.toLowerCase();if("strong"===i){const t=e.createElement("strong");t.textContent=o.textContent||"",r.appendChild(t)}else if("a"===i){const t=e.createElement("a");t.setAttribute("href",o.getAttribute("href")||""),t.textContent=o.textContent||"",r.appendChild(t)}else if("code"===i){const t=e.createElement("code");t.textContent=o.textContent||"",r.appendChild(t)}else o.childNodes.forEach((t=>n(t)))}};t.childNodes.forEach((t=>n(t))),t.replaceWith(r)}))}convertBoldSpans(t,e){t.querySelectorAll(h).forEach((t=>{const r=e.createElement("strong");r.textContent=t.textContent||"",t.replaceWith(r)}))}removeDraftAttributes(t){t.querySelectorAll(m).forEach((t=>{t.removeAttribute("data-offset-key")}))}repairSurrogatePairs(t){const e=(t.ownerDocument||this.document).createTreeWalker(t,4);let r,n=null;for(;r=e.nextNode();){const t=r;if(n){const e=n.textContent||"",r=t.textContent||"";if(e&&r){const o=e.charCodeAt(e.length-1),i=r.charCodeAt(0);o>=55296&&o<=56319&&i>=56320&&i<=57343&&(n.textContent=e.slice(0,-1),t.textContent=e.slice(-1)+r)}}n=t}}createDescription(){var t,e;const r=(null===(e=null===(t=this.articleContainer)||void 0===t?void 0:t.textContent)||void 0===e?void 0:e.trim())||"";return r.slice(0,140)+(r.length>140?"...":"")}}e.XArticleExtractor=y},666(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.XOembedExtractor=void 0;const o=r(279),i=r(639);class s extends o.BaseExtractor{canExtract(){return!1}extract(){return{content:"",contentHtml:""}}canExtractAsync(){return/\\/(status|article)\\/\\d+/.test(this.url)}extractAsync(){return n(this,void 0,void 0,(function*(){const t=yield this.tryExtractFxTwitter();return t||this.extractOembed()}))}extractOembed(){return n(this,void 0,void 0,(function*(){var t;const e=`https://publish.twitter.com/oembed?url=${encodeURIComponent(this.url)}&omit_script=true`,r=yield fetch(e);if(!r.ok)throw new Error(`oEmbed request failed: ${r.status}`);const n=yield r.json(),o=this.document.createElement("div");o.appendChild((0,i.parseHTML)(this.document,n.html));const s=o.querySelector("blockquote"),a=(null==s?void 0:s.querySelectorAll("p"))||[],l=Array.from(a).map((t=>`<p>${(0,i.serializeHTML)(t)}</p>`)).join("\\n"),c=n.author_url?`@${n.author_url.split("/").pop()}`:"",u=null==s?void 0:s.querySelector("a:last-child"),d=(null===(t=null==u?void 0:u.textContent)||void 0===t?void 0:t.trim())||"",h=(null==u?void 0:u.getAttribute("href"))||this.url,m=(0,i.escapeHtml)(n.author_name),p=(0,i.escapeHtml)(c),f=(0,i.escapeHtml)(d),g=(0,i.escapeHtml)(h),v=`\\n\\t\\t\\t<div class="tweet-thread">\\n\\t\\t\\t\\t<div class="main-tweet">\\n\\t\\t\\t\\t\\t<div class="tweet">\\n\\t\\t\\t\\t\\t\\t<div class="tweet-header">\\n\\t\\t\\t\\t\\t\\t\\t<span class="tweet-author"><strong>${m}</strong> <span class="tweet-handle">${p}</span></span>\\n\\t\\t\\t\\t\\t\\t\\t${d?`<a href="${g}" class="tweet-date">${f}</a>`:""}\\n\\t\\t\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t\\t\\t${l?`<div class="tweet-text">${l}</div>`:""}\\n\\t\\t\\t\\t\\t</div>\\n\\t\\t\\t\\t</div>\\n\\t\\t\\t</div>\\n\\t\\t`.trim();return{content:v,contentHtml:v,variables:{title:`Post by ${c||n.author_name}`,author:c||n.author_name,site:"X (Twitter)"}}}))}tryExtractFxTwitter(){return n(this,void 0,void 0,(function*(){var t,e;const r=this.url.match(/\\/([a-zA-Z0-9_][a-zA-Z0-9_]{0,14})\\/(status|article)\\/(\\d+)/);if(!r)return null;try{const n=yield this.fetchFxTwitter(r[1],r[3]);return(null===(t=n.tweet)||void 0===t?void 0:t.article)?this.buildArticleResult(n):(null===(e=n.tweet)||void 0===e?void 0:e.text)?this.buildTweetResult(n):null}catch(t){return null}}))}fetchFxTwitter(t,e){return n(this,void 0,void 0,(function*(){const r=`https://api.fxtwitter.com/${t}/status/${e}`,n=yield fetch(r,{headers:{"User-Agent":"Mozilla/5.0 (compatible; Defuddle/1.0; +https://defuddle.md)"}});if(!n.ok)throw new Error(`FxTwitter API request failed: ${n.status}`);return n.json()}))}buildArticleResult(t){const e=t.tweet.article,{blocks:r,entityMap:n}=e.content,o=this.renderArticle(r,n,e.cover_media),i=`@${t.tweet.author.screen_name}`;return{content:o,contentHtml:o,variables:{title:e.title,author:i,site:"X (Twitter)",description:e.preview_text}}}buildTweetResult(t){const e=t.tweet,r=`@${e.author.screen_name}`,n=this.renderTweet(e);return{content:n,contentHtml:n,variables:{title:`Post by ${r}`,author:r,site:"X (Twitter)"}}}renderTweet(t){var e,r,n;const o=(null===(e=t.raw_text)||void 0===e?void 0:e.text)||t.text,s=((null===(r=t.raw_text)||void 0===r?void 0:r.facets)||[]).filter((t=>"media"!==t.type)),a=o.split(/\\n\\n+/);let l=0;const c=[];for(const t of a){const e=o.indexOf(t,l),r=e+t.length;l=r;const n=t.trimStart().startsWith(">");let i=n?t.trimStart().slice(1).trimStart():t;const a=n?e+(t.length-t.trimStart().length)+1+(t.trimStart().slice(1).length-t.trimStart().slice(1).trimStart().length):e,u=this.applyFacets(i,a,r,s).replace(/\\n/g,"<br>");n?c.push(`<blockquote><p>${u}</p></blockquote>`):u.trim()&&c.push(`<p>${u}</p>`)}if(null===(n=t.media)||void 0===n?void 0:n.photos)for(const e of t.media.photos)c.push(`<img src="${(0,i.escapeHtml)(e.url)}" alt="">`);const u=(0,i.escapeHtml)(`@${t.author.screen_name}`);return`<div class="tweet-thread"><div class="main-tweet"><div class="tweet"><div class="tweet-header"><span class="tweet-author"><strong>${(0,i.escapeHtml)(t.author.name)}</strong> <span class="tweet-handle">${u}</span></span></div><div class="tweet-text">${c.join("\\n")}</div></div></div></div>`}applyMarkers(t,e){if(0===e.length)return(0,i.escapeHtml)(t);e.sort(((t,e)=>t.offset!==e.offset?t.offset-e.offset:"close"===t.type&&"open"===e.type?-1:"open"===t.type&&"close"===e.type?1:0));let r="",n=0;for(const o of e)o.offset>n&&(r+=(0,i.escapeHtml)(t.slice(n,o.offset))),r+=o.tag,n=o.offset;return n<t.length&&(r+=(0,i.escapeHtml)(t.slice(n))),r}applyFacets(t,e,r,n){const o=[];for(const s of n){const[n,a]=s.indices;if(a<=e||n>=r)continue;const l=Math.max(0,n-e),c=Math.min(t.length,a-e);if("italic"===s.type)o.push({offset:l,type:"open",tag:"<em>"}),o.push({offset:c,type:"close",tag:"</em>"});else if("mention"===s.type&&s.text){const t=`https://x.com/${(0,i.escapeHtml)(s.text)}`;o.push({offset:l,type:"open",tag:`<a href="${t}">`}),o.push({offset:c,type:"close",tag:"</a>"})}else if("url"===s.type&&s.original){const t=(0,i.escapeHtml)(s.original);o.push({offset:l,type:"open",tag:`<a href="${t}">`}),o.push({offset:c,type:"close",tag:"</a>"})}}return this.applyMarkers(t,o)}renderArticle(t,e,r){var n;const o=[];(null===(n=null==r?void 0:r.media_info)||void 0===n?void 0:n.original_img_url)&&o.push(`<img src="${(0,i.escapeHtml)(r.media_info.original_img_url)}" alt="Cover image">`);let s=0;for(;s<t.length;){const r=t[s];if("unordered-list-item"===r.type){const r=[];for(;s<t.length&&"unordered-list-item"===t[s].type;)r.push(`<li>${this.renderInlineContent(t[s],e)}</li>`),s++;o.push(`<ul>${r.join("")}</ul>`);continue}const n=this.renderBlock(r,e);n&&o.push(n),s++}return`<article class="x-article">${o.join("")}</article>`}renderBlock(t,e){switch(t.type){case"unstyled":default:return t.text.trim()?`<p>${this.renderInlineContent(t,e)}</p>`:"";case"header-two":return`<h2>${this.renderInlineContent(t,e)}</h2>`;case"header-three":return`<h3>${this.renderInlineContent(t,e)}</h3>`;case"atomic":return this.renderAtomicBlock(t,e)}}renderAtomicBlock(t,e){if(0===t.entityRanges.length)return"";const r=e.find((e=>e.key===String(t.entityRanges[0].key)));if(!r)return"";const n=r.value;switch(n.type){case"MEDIA":{const t=n.data.caption;return t?`<figure><figcaption>${(0,i.escapeHtml)(t)}</figcaption></figure>`:""}case"MARKDOWN":{const t=n.data.markdown||"",e=t.match(/^```(\\w*)\\n([\\s\\S]*?)\\n?```$/);if(e){const t=e[1],r=e[2];return`<pre><code${t?` class="language-${(0,i.escapeHtml)(t)}" data-lang="${(0,i.escapeHtml)(t)}"`:""}>${(0,i.escapeHtml)(r)}</code></pre>`}return`<pre><code>${(0,i.escapeHtml)(t)}</code></pre>`}default:return""}}renderInlineContent(t,e){var r,n;const o=t.text;if(!o)return"";const s=[];for(const e of t.inlineStyleRanges)"Bold"===e.style&&(s.push({offset:e.offset,type:"open",tag:"<strong>"}),s.push({offset:e.offset+e.length,type:"close",tag:"</strong>"}));for(const r of t.entityRanges){const t=e.find((t=>t.key===String(r.key)));if("LINK"===(null==t?void 0:t.value.type)&&t.value.data.url){const e=(0,i.escapeHtml)(t.value.data.url);s.push({offset:r.offset,type:"open",tag:`<a href="${e}">`}),s.push({offset:r.offset+r.length,type:"close",tag:"</a>"})}}if(null===(r=t.data)||void 0===r?void 0:r.mentions)for(const e of t.data.mentions){const t=`https://x.com/${(0,i.escapeHtml)(e.text)}`;s.push({offset:e.fromIndex,type:"open",tag:`<a href="${t}">`}),s.push({offset:e.toIndex,type:"close",tag:"</a>"})}if(null===(n=t.data)||void 0===n?void 0:n.urls)for(const e of t.data.urls){const t=(0,i.escapeHtml)(e.text);s.push({offset:e.fromIndex,type:"open",tag:`<a href="${t}">`}),s.push({offset:e.toIndex,type:"close",tag:"</a>"})}return this.applyMarkers(o,s)}}e.XOembedExtractor=s},258(t,e,r){var n=this&&this.__awaiter||function(t,e,r,n){return new(r||(r=Promise))((function(o,i){function s(t){try{l(n.next(t))}catch(t){i(t)}}function a(t){try{l(n.throw(t))}catch(t){i(t)}}function l(t){var e;t.done?o(t.value):(e=t.value,e instanceof r?e:new r((function(t){t(e)}))).then(s,a)}l((n=n.apply(t,e||[])).next())}))};Object.defineProperty(e,"__esModule",{value:!0}),e.YoutubeExtractor=void 0;const o=r(279),i=r(552),s=r(497),a=/[.!?]["\'\\u2019\\u201D)]*\\s*$/,l=/\\?["\'\\u2019\\u201D)]*\\s*$/,c="https://www.youtube.com/youtubei/v1/player?prettyPrint=false",u="20.10.38",d={client:{clientName:"ANDROID",clientVersion:u}},h=`com.google.android.youtube/${u} (Linux; U; Android 14)`,m={client:{clientName:"WEB",clientVersion:"2.20240101.00.00"}},p={segments:"ytd-transcript-segment-renderer",timestamp:".segment-timestamp",text:".segment-text"},f={segments:"transcript-segment-view-model",timestamp:".ytwTranscriptSegmentViewModelTimestamp",text:"span.yt-core-attributed-string",chapters:"timeline-chapter-view-model h3"};class g extends o.BaseExtractor{constructor(t,e,r,n){super(t,e,r,n),this.inlineJsonCache=new Map,this.videoElement=t.querySelector("video"),this.schemaOrgData=r}canExtract(){return!0}canExtractAsync(){return!0}prefersAsync(){return!0}extract(){return this.buildResult(this.extractTranscriptFromExistingDom())}extractAsync(){return n(this,void 0,void 0,(function*(){const t=this.extractTranscriptFromExistingDom(),e=this.shouldUseExistingDomTranscript(t)?t:(yield this.fetchTranscript())||t||(yield this.extractTranscriptFromOpenedDom());return this.buildResult(e)}))}normalizeLanguageCode(t){return(t||"").trim().replace(/_/g,"-").toLocaleLowerCase()}languageCodeMatchesPreference(t,e){const r=this.normalizeLanguageCode(t),n=this.normalizeLanguageCode(e);if(!r||!n)return!1;if(r===n)return!0;const o=r.split("-")[0],i=n.split("-")[0];return o===i&&(r===o||n===i)}shouldUseExistingDomTranscript(t){return!!t&&(!this.options.language||this.languageCodeMatchesPreference(t.languageCode,this.options.language))}getCaptionTracks(t){var e,r;const n=null===(r=null===(e=null==t?void 0:t.captions)||void 0===e?void 0:e.playerCaptionsTracklistRenderer)||void 0===r?void 0:r.captionTracks;return Array.isArray(n)?n:[]}findPreferredCaptionTrack(t,e){var r,n,o;const i=this.normalizeLanguageCode(e);if(!i)return;const s=i.split("-")[0],a=t.map((t=>({t,code:this.normalizeLanguageCode(t.languageCode)})));return null===(o=null!==(n=null!==(r=a.find((({code:t})=>t===i)))&&void 0!==r?r:a.find((({code:t})=>t===s)))&&void 0!==n?n:a.find((({code:t})=>t.split("-")[0]===s)))||void 0===o?void 0:o.t}pickCaptionTrack(t){const e=this.options.language;if(e){const r=this.findPreferredCaptionTrack(t,e);if(r)return r}return t.find((t=>"en"===t.languageCode))||t[0]}getTrackDisplayName(t){var e,r,n;return(null===(e=null==t?void 0:t.name)||void 0===e?void 0:e.simpleText)||(null===(n=null===(r=null==t?void 0:t.name)||void 0===r?void 0:r.runs)||void 0===n?void 0:n.map((t=>(null==t?void 0:t.text)||"")).join("").trim())||""}normalizeLanguageLabel(t){return t.replace(/\\s*\\([^)]*\\)\\s*/g," ").replace(/\\s+/g," ").trim().toLocaleLowerCase()}getTranscriptLanguageCodeFromDom(){var t;const e=this.document.querySelector(\'ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-searchable-transcript"] #footer yt-sort-filter-sub-menu-renderer yt-dropdown-menu button\'),r=null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.trim(),n=this.getCaptionTracks(this.getValidatedPlayerResponse()),o=1===n.length?n[0]:void 0;if(!r)return null==o?void 0:o.languageCode;const i=this.normalizeLanguageLabel(r),s=n.find((t=>this.normalizeLanguageLabel(this.getTrackDisplayName(t))===i));return(null==s?void 0:s.languageCode)||(null==o?void 0:o.languageCode)}getInlineChapters(){var t,e,r,n;const o=this.getVideoId(),i=this.parseInlineJson("ytInitialData");if(!i)return[];if(o){const s=null===(e=null===(t=null==i?void 0:i.currentVideoEndpoint)||void 0===t?void 0:t.watchEndpoint)||void 0===e?void 0:e.videoId,a=null===(n=null===(r=null==i?void 0:i.endpoint)||void 0===r?void 0:r.watchEndpoint)||void 0===n?void 0:n.videoId;if(s!==o&&a!==o)return[]}const s=this.extractChaptersFromPlayerBar(i);return s.length>0?s:this.extractChaptersFromEngagementPanels(i)}getTranscriptContainer(){const t=this.document.querySelector(\'ytd-engagement-panel-section-list-renderer[target-id="engagement-panel-searchable-transcript"] #segments-container\');return t||this.document.querySelector("ytm-macro-markers-list-renderer .ytm-macro-markers-list-container")}getTranscriptSelectors(t){return t.querySelectorAll("ytd-transcript-segment-renderer").length>0?p:t.querySelectorAll("transcript-segment-view-model").length>0?f:void 0}buildTranscriptFromContainer(t,e){var r;if(0===t.children.length)return;const n=this.getTranscriptSelectors(t);if(!n)return;const o=[],i=[];if(n.chapters){const e=t.querySelectorAll(n.chapters);for(const t of e){const e=(t.textContent||"").trim();if(!e)continue;const o=t.closest("macro-markers-panel-item-view-model"),s=null===(r=null==o?void 0:o.nextElementSibling)||void 0===r?void 0:r.querySelector(n.timestamp),a=((null==s?void 0:s.textContent)||"").trim(),l=this.parseTimestamp(a);null!==l&&i.push({title:e,start:l})}}const a=t.querySelectorAll(n.segments);for(const t of a){const e=t.querySelector(n.timestamp),r=t.querySelector(n.text);if(!e||!r)continue;const i=(e.textContent||"").trim(),s=(r.textContent||"").trim();if(!s)continue;const a=this.parseTimestamp(i);null!==a&&o.push({start:a,text:s})}if(0===o.length)return;const l=e.length>0?e:i,c=this.groupTranscriptSegments(o),{html:u,text:d}=(0,s.buildTranscript)("youtube",c,l);return{html:u,text:d,languageCode:this.getTranscriptLanguageCodeFromDom()}}extractTranscriptFromExistingDom(){try{const t=this.getTranscriptContainer();if(!t)return;return this.buildTranscriptFromContainer(t,this.getInlineChapters())}catch(t){return void console.error("YoutubeExtractor: failed to extract transcript from existing DOM",t)}}canOpenTranscriptPanel(){var t;return"function"==typeof(null===(t=this.document.defaultView)||void 0===t?void 0:t.MutationObserver)}buildResult(t){const e=this.getVideoData(),r=this.getChannelName(e),n=e.description||"",o=this.formatDescription(n);let i=`<iframe width="560" height="315" src="https://www.youtube.com/embed/${this.getVideoId()}" title="YouTube video player" frameborder="0" allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share" referrerpolicy="strict-origin-when-cross-origin" allowfullscreen></iframe>${o}`;(null==t?void 0:t.html)&&(i+=t.html);const s={title:e.name||"",author:r,site:"YouTube",image:Array.isArray(e.thumbnailUrl)&&e.thumbnailUrl[0]||"",published:e.uploadDate,description:n.slice(0,200).trim()};return(null==t?void 0:t.text)&&(s.transcript=t.text),(null==t?void 0:t.languageCode)&&(s.language=t.languageCode),{content:i,contentHtml:i,extractedContent:{videoId:this.getVideoId(),author:r},variables:s}}formatDescription(t){return`<p>${t.replace(/\\n/g,"<br>")}</p>`}getVideoData(){var t,e,r,n;const o=this.getVideoId(),i=Array.from(this.document.querySelectorAll(\'script[type="application/ld+json"]\'));for(const t of i)try{const e=JSON.parse(t.textContent||""),r=(Array.isArray(e)?e:[e]).find((t=>{if("VideoObject"!==t["@type"])return!1;if(!o)return!0;return(t["@id"]||t.url||t.embedUrl||"").includes(o)}));if(r)return r}catch(t){}if(o){if(((null===(t=this.document.querySelector(\'meta[property="og:url"]\'))||void 0===t?void 0:t.getAttribute("content"))||"").includes(o))return{name:(null===(e=this.document.querySelector(\'meta[property="og:title"]\'))||void 0===e?void 0:e.getAttribute("content"))||"",description:(null===(r=this.document.querySelector(\'meta[property="og:description"]\'))||void 0===r?void 0:r.getAttribute("content"))||"",thumbnailUrl:(null===(n=this.document.querySelector(\'meta[property="og:image"]\'))||void 0===n?void 0:n.getAttribute("content"))||""}}return{}}getChannelName(t){const e=this.getChannelNameFromDom();if(e)return e;const r=this.getChannelNameFromPlayerResponse();return r||((null==t?void 0:t.author)||"")}getChannelNameFromDom(){var t;const e=[\'ytd-video-owner-renderer #channel-name a[href^="/@"]\',\'#owner-name a[href^="/@"]\'];for(const r of e){const e=this.document.querySelector(r),n=null===(t=null==e?void 0:e.textContent)||void 0===t?void 0:t.trim();if(n)return n}return this.getChannelNameFromMicrodata()}getChannelNameFromMicrodata(){var t;const e=this.document.querySelector(\'[itemprop="author"]\');if(!e)return"";const r=e.querySelector(\'meta[itemprop="name"]\');if(null==r?void 0:r.getAttribute("content"))return r.getAttribute("content").trim();const n=e.querySelector(\'link[itemprop="name"]\');if(null==n?void 0:n.getAttribute("content"))return n.getAttribute("content").trim();const o=e.querySelector(\'[itemprop="name"], a, span\');return(null===(t=null==o?void 0:o.textContent)||void 0===t?void 0:t.trim())||""}getChannelNameFromPlayerResponse(){var t,e,r,n;const o=this.getValidatedPlayerResponse();return o&&((null===(t=o.videoDetails)||void 0===t?void 0:t.author)||(null===(e=o.videoDetails)||void 0===e?void 0:e.ownerChannelName)||(null===(n=null===(r=o.microformat)||void 0===r?void 0:r.playerMicroformatRenderer)||void 0===n?void 0:n.ownerChannelName))||""}getValidatedPlayerResponse(){var t,e,r;const n=this.getVideoId();if(!n)return null;const o=this.parseInlineJson("ytInitialPlayerResponse");if(!o)return null;const i=null===(t=o.videoDetails)||void 0===t?void 0:t.videoId,s=null===(r=null===(e=o.microformat)||void 0===e?void 0:e.playerMicroformatRenderer)||void 0===r?void 0:r.externalVideoId;return i===n||s===n?o:null}parseInlineJson(t){if(this.inlineJsonCache.has(t))return this.inlineJsonCache.get(t);const e=Array.from(this.document.querySelectorAll("script"));for(const r of e){const e=r.textContent||"";if(!e.includes(t))continue;const n=e.indexOf("{",e.indexOf(t));if(-1===n)continue;let o=0;for(let r=n;r<e.length;r++){const i=e[r];if("{"===i)o+=1;else if("}"===i&&(o-=1,0===o)){const o=e.slice(n,r+1);try{const e=JSON.parse(o);return this.inlineJsonCache.set(t,e),e}catch(t){console.error("YoutubeExtractor: failed to parse inline JSON",t);break}}}}return null}fetchTranscript(){return n(this,void 0,void 0,(function*(){try{const t=this.getVideoId();if(!t)return;const[e,r]=yield Promise.all([this.fetchPlayerData(t),this.fetchChapters(t)]);if(!e)return;const n=this.getCaptionTracks(e);if(0===n.length)return;const o=this.pickCaptionTrack(n);if(!(null==o?void 0:o.baseUrl))return;try{if(!new URL(o.baseUrl).hostname.endsWith(".youtube.com"))return}catch(t){return}const i={"User-Agent":"Mozilla/5.0"};this.options.language&&(i["Accept-Language"]=this.options.language);const s=yield fetch(o.baseUrl,{headers:i,signal:AbortSignal.timeout(4e3)});if(!s.ok)return;let a;try{a=yield s.text()}catch(t){return void console.error("YoutubeExtractor: response.text() failed:",t)}if(!a)return;return this.parseTranscriptXml(a,o.languageCode||"en",r)}catch(t){return void console.error("YoutubeExtractor: failed to fetch transcript",t)}}))}pollFor(t,e=20){return new Promise((r=>{let n=0;const o=()=>{const i=t();i?r(i):n++<e?setTimeout(o,250):r(null)};o()}))}waitForTranscriptSegments(){return this.pollFor((()=>{const t=this.getTranscriptContainer();return t&&0!==t.children.length&&t.querySelectorAll(f.segments).length>0?t:null}))}waitForTranscriptContainer(){return this.pollFor((()=>{const t=this.getTranscriptContainer();return t&&t.children.length>0?t:null}))}waitForElement(t){return this.pollFor((()=>this.document.querySelector(t)))}isMobileYoutube(){return!!this.document.querySelector("ytm-slim-video-metadata-section-renderer")}extractTranscriptFromOpenedDom(){return n(this,void 0,void 0,(function*(){try{if(!this.canOpenTranscriptPanel())return;if(this.isMobileYoutube())return this.openMobileTranscriptPanel();const t=this.document.querySelector("ytd-video-description-transcript-section-renderer button");if(!t)return;t.click();const e=yield this.waitForTranscriptContainer();if(!e)return;const r=this.getVideoId(),n=r?yield this.fetchChapters(r):this.getInlineChapters();return this.buildTranscriptFromContainer(e,n)}catch(t){return void console.error("YoutubeExtractor: failed to extract transcript from opened DOM",t)}}))}openMobileTranscriptPanel(){return n(this,void 0,void 0,(function*(){try{const t=this.document.querySelector(\'button[aria-label="Show more"]\');t&&t.click();const e=yield this.waitForElement(\'button[aria-label="View all"]\');if(!e)return;e.click();const r=yield this.waitForElement(\'button[aria-label="Timeline"]\');if(!r)return;r.click();const n=yield this.waitForTranscriptSegments();if(!n)return;return this.buildTranscriptFromContainer(n,[])}catch(t){return void console.error("YoutubeExtractor: failed to open mobile transcript panel",t)}}))}fetchPlayerData(t){return n(this,void 0,void 0,(function*(){let e=!1;try{const e={"Content-Type":"application/json","User-Agent":h};this.options.language&&(e["Accept-Language"]=this.options.language);const r=yield fetch(c,{method:"POST",headers:e,signal:AbortSignal.timeout(4e3),body:JSON.stringify({context:d,videoId:t})});if(r.ok){const t=yield r.json();if(this.getCaptionTracks(t).length>0)return t}}catch(t){"TimeoutError"===(null==t?void 0:t.name)&&(e=!0)}if(e)return;try{const e={"Content-Type":"application/json"};this.options.language&&(e["Accept-Language"]=this.options.language);const r=yield fetch(c,{method:"POST",headers:e,signal:AbortSignal.timeout(4e3),body:JSON.stringify({context:m,videoId:t})});if(r.ok){const t=yield r.json();if(this.getCaptionTracks(t).length>0)return t}}catch(t){}const r=this.parseInlineJson("ytInitialPlayerResponse");return this.getCaptionTracks(r).length>0?r:void 0}))}fetchChapters(t){return n(this,void 0,void 0,(function*(){const e=this.getInlineChapters();if(e.length>0)return e;try{const e={"Content-Type":"application/json"};this.options.language&&(e["Accept-Language"]=this.options.language);const r=yield fetch("https://www.youtube.com/youtubei/v1/next?prettyPrint=false",{method:"POST",headers:e,signal:AbortSignal.timeout(4e3),body:JSON.stringify({context:m,videoId:t})});if(!r.ok)return[];const n=yield r.json(),o=this.extractChaptersFromPlayerBar(n);return o.length>0?o:this.extractChaptersFromEngagementPanels(n)}catch(t){return[]}}))}extractChaptersFromPlayerBar(t){var e,r,n,o,i,s,a,l;const c=[],u=null===(s=null===(i=null===(o=null===(n=null===(r=null===(e=null==t?void 0:t.playerOverlays)||void 0===e?void 0:e.playerOverlayRenderer)||void 0===r?void 0:r.decoratedPlayerBarRenderer)||void 0===n?void 0:n.decoratedPlayerBarRenderer)||void 0===o?void 0:o.playerBar)||void 0===i?void 0:i.multiMarkersPlayerBarRenderer)||void 0===s?void 0:s.markersMap;if(!Array.isArray(u))return c;for(const t of u){const e=null===(a=null==t?void 0:t.value)||void 0===a?void 0:a.chapters;if(Array.isArray(e))for(const t of e){const e=null==t?void 0:t.chapterRenderer;if(!e)continue;const r=(null===(l=e.title)||void 0===l?void 0:l.simpleText)||"",n=e.timeRangeStartMillis;r&&"number"==typeof n&&c.push({title:r,start:n/1e3})}}return c}extractChaptersFromEngagementPanels(t){var e,r,n,o;const i=[],s=null==t?void 0:t.engagementPanels;if(!Array.isArray(s))return i;for(const t of s){const s=null===(e=null==t?void 0:t.engagementPanelSectionListRenderer)||void 0===e?void 0:e.content,a=null===(r=null==s?void 0:s.macroMarkersListRenderer)||void 0===r?void 0:r.contents;if(Array.isArray(a))for(const t of a){const e=null==t?void 0:t.macroMarkersListItemRenderer;if(!e)continue;const r=(null===(n=e.title)||void 0===n?void 0:n.simpleText)||"",s=(null===(o=e.timeDescription)||void 0===o?void 0:o.simpleText)||"";if(!r||!s)continue;const a=this.parseTimestamp(s);null!==a&&i.push({title:r,start:a})}}return i}parseTimestamp(t){const e=t.split(":").map(Number);return e.some(isNaN)?null:3===e.length?3600*e[0]+60*e[1]+e[2]:2===e.length?60*e[0]+e[1]:null}parseTranscriptXml(t,e,r=[]){const n=[],o=/<p\\s+t="(\\d+)"[^>]*>([\\s\\S]*?)<\\/p>/g;let i;for(;null!==(i=o.exec(t));){const t=parseInt(i[1],10),e=i[2];let r="";const o=/<s[^>]*>([^<]*)<\\/s>/g;let s;for(;null!==(s=o.exec(e));)r+=s[1];r||(r=e.replace(/<[^>]+>/g,"")),r=this.decodeEntities(r),r.trim()&&n.push({start:t/1e3,text:r.trim()})}if(0===n.length){const e=/<text\\s+start="([^"]*)"[^>]*>([\\s\\S]*?)<\\/text>/g;for(;null!==(i=e.exec(t));){const t=parseFloat(i[1]);let e=this.decodeEntities(i[2].replace(/<[^>]+>/g,""));e.trim()&&n.push({start:t,text:e.trim()})}}if(0===n.length)return;const a=this.groupTranscriptSegments(n),{html:l,text:c}=(0,s.buildTranscript)("youtube",a,r);return{html:l,text:c,languageCode:e}}decodeEntities(t){return t.replace(/&amp;/g,"&").replace(/&lt;/g,"<").replace(/&gt;/g,">").replace(/&quot;/g,\'"\').replace(/&#39;/g,"\'").replace(/&apos;/g,"\'").replace(/&#x([0-9a-fA-F]+);/g,((t,e)=>String.fromCodePoint(parseInt(e,16)))).replace(/&#(\\d+);/g,((t,e)=>String.fromCodePoint(parseInt(e,10))))}getVideoId(){if(void 0===this._videoId){const t=new URL(this.url);this._videoId="youtu.be"===t.hostname?t.pathname.slice(1):t.pathname.includes("/shorts/")?t.pathname.split("/shorts/")[1].split("/")[0]:new URLSearchParams(t.search).get("v")||""}return this._videoId}groupTranscriptSegments(t){if(0===t.length)return[];return t.some((t=>/^>>/.test(t.text)))?this.groupBySpeaker(t):this.groupBySentence(t)}groupBySpeaker(t){const e=[];let r=null,n=-1,o="";for(const i of t){const t=/^>>/.test(i.text),s=i.text.replace(/^>>\\s*/,"").replace(/^-\\s+/,""),l=/,\\s*$/.test(o),c=(a.test(o)||!o)&&!l;t&&c?(r&&e.push(r),n=(n+1)%2,r={start:i.start,segments:[{start:i.start,text:s}],speakerChange:!0,speaker:n}):(r||(r={start:i.start,segments:[],speakerChange:!1}),r.segments.push({start:i.start,text:s})),o=s}r&&e.push(r),this.splitAffirmativeTurns(e);const i=[];for(const t of e){const e=void 0===t.speaker?this.groupBySentence(t.segments):this.mergeSentenceGroupsWithinTurn(this.groupBySentence(t.segments));for(let r=0;r<e.length;r++)i.push(Object.assign(Object.assign({},e[r]),{speakerChange:0===r&&t.speakerChange,speaker:t.speaker}))}return i}splitAffirmativeTurns(t){const e=/^(mhm|yeah|yes|yep|right|okay|ok|absolutely|sure|exactly|uh-huh|mm-hmm)[.!,]?\\s+/i;for(let r=0;r<t.length;r++){const n=t[r];if(void 0===n.speaker||0===n.segments.length)continue;const o=n.segments[0],s=e.exec(o.text);if(!s)continue;if(/,\\s*$/.test(s[0]))continue;const a=o.text.slice(s[0].length).trim(),l=n.segments.slice(1);if((0,i.countWords)(a)+l.reduce(((t,e)=>t+(0,i.countWords)(e.text)),0)<30)continue;const c=s[0].trimEnd(),u=a?[{start:o.start,text:a},...l]:l,d={start:n.start,segments:[{start:o.start,text:c}],speakerChange:n.speakerChange,speaker:n.speaker},h={start:u[0].start,segments:u,speakerChange:!0,speaker:0===n.speaker?1:0};t.splice(r,1,d,h),r++}}mergeSentenceGroupsWithinTurn(t){if(t.length<=1)return t;const e=[];let r=Object.assign({},t[0]),n=!0;for(let o=1;o<t.length;o++){const i=t[o];this.shouldMergeSentenceGroups(r,i,n)?r.text=`${r.text} ${i.text}`:(e.push(r),r=Object.assign({},i),n=!1)}return e.push(r),e}shouldMergeSentenceGroups(t,e,r){const n=(0,i.countWords)(t.text),o=(0,i.countWords)(e.text);return!this.isShortStandaloneUtterance(t.text,n)&&!this.isShortStandaloneUtterance(e.text,o)&&(!(r&&n<8)&&(!l.test(t.text)&&!l.test(e.text)&&(!(n+o>80)&&!(e.start-t.start>45))))}isShortStandaloneUtterance(t,e){const r=null!=e?e:(0,i.countWords)(t);return r>0&&r<=3&&a.test(t)}groupBySentence(t){const e=[];let r="",n=0,o=0;const i=()=>{r.trim()&&(e.push({start:n,text:r.trim(),speakerChange:!1}),r="")};for(const e of t)r&&e.start-o>20&&i(),r||(n=e.start),r+=(r?" ":"")+e.text,o=e.start,a.test(e.text)&&i();return i(),e}}e.YoutubeExtractor=g},608(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.MetadataExtractor=void 0;const n=r(552);class o{static extract(t,e,r){var n,o;let i="",s="";try{if(s=(null===(n=t.location)||void 0===n?void 0:n.href)||"",s||(s=this.getMetaContent(r,"property","og:url")||this.getMetaContent(r,"property","twitter:url")||this.getSchemaProperty(e,"url")||this.getSchemaProperty(e,"mainEntityOfPage.url")||this.getSchemaProperty(e,"mainEntity.url")||this.getSchemaProperty(e,"WebSite.url")||(null===(o=t.querySelector(\'link[rel="canonical"]\'))||void 0===o?void 0:o.getAttribute("href"))||""),s)try{i=new URL(s).hostname.replace(/^www\\./,"")}catch(t){console.warn("Failed to parse URL:",t)}}catch(e){const r=t.querySelector("base[href]");if(r)try{s=r.getAttribute("href")||"",i=new URL(s).hostname.replace(/^www\\./,"")}catch(t){console.warn("Failed to parse base URL:",t)}}const a=this.getSiteName(e,r),{title:l,detectedSiteName:c}=this.cleanTitle(this.getBestTitle(t,e,r,i,a),a),u=this.getAuthor(t,e,r),d=u&&!u.includes(",")?u:"",h=a||c||d||i||"";return{title:l,description:this.getDescription(t,e,r),domain:i,favicon:this.getFavicon(t,s,r),image:this.getImage(t,e,r),language:this.getLanguage(t,e,r),published:this.getPublished(t,e,r),author:u,site:h,schemaOrgData:e,wordCount:0,parseTime:0}}static isTemplateArtifact(t){return/[{}]/.test(t)||/^#[a-zA-Z]/.test(t)}static getAuthor(t,e,r){var n,o,i;let s;if(s=this.getMetaContent(r,"name","sailthru.author")||this.getMetaContent(r,"property","author")||this.getMetaContent(r,"name","author")||this.getMetaContent(r,"name","byl")||this.getMetaContent(r,"name","authorList"),s&&!this.isTemplateArtifact(s))return s;let a=this.getMetaContents(r,"name","citation_author").filter((t=>!this.isTemplateArtifact(t)));if(0===a.length&&(a=this.getMetaContents(r,"property","dc.creator").filter((t=>!this.isTemplateArtifact(t)))),a.length>0)return s=a.map((t=>{if(!t.includes(","))return t.trim();const e=/(.*),\\s(.*)/.exec(t);return e&&3===e.length?`${e[2]} ${e[1]}`:t.trim()})).join(", "),s;let l=this.getSchemaProperty(e,"author.name")||this.getSchemaProperty(e,"author.[].name");if(l){const t=l.split(",").map((t=>t.trim().replace(/,$/,"").trim())).filter(Boolean);if(t.length>0){let e=[...new Set(t)];return e.length>10&&(e=e.slice(0,10)),e.join(", ")}}const c=[],u=[{selector:\'[itemprop="author"]\'},{selector:".author",maxMatches:3},{selector:\'[href*="/author/"]\',maxMatches:3},{selector:".authors a",maxMatches:3}];for(const{selector:e,maxMatches:r}of u){const n=t.querySelectorAll(e);r&&n.length>r||n.forEach((t=>{var e;(e=t.textContent)&&e.split(",").forEach((t=>{const e=t.replace(/\\s+/g," ").trim().replace(/,$/,"").trim(),r=e.toLowerCase();e&&"author"!==r&&"authors"!==r&&c.push(e)}))}))}if(c.length>0){let t=[...new Set(c.map((t=>t.trim())).filter(Boolean))];if(t.length>1&&(t=t.filter((e=>!t.some((t=>t!==e&&e.includes(t)))))),t.length>0)return t.length>10&&(t=t.slice(0,10)),t.join(", ")}const d=t.querySelector("h1");if(d){let t=d.nextElementSibling;for(let e=0;e<3&&t;e++){const e=(null===(n=t.textContent)||void 0===n?void 0:n.trim())||"",r=Array.from(t.querySelectorAll("p, time")),s=r.some((t=>{var e;return!!this.parseDateText((null===(e=t.textContent)||void 0===e?void 0:e.trim())||"")}));if(!!this.parseDateText(e)||s){const n=t.querySelectorAll("a");if(1===n.length){const t=((null===(o=n[0].textContent)||void 0===o?void 0:o.trim())||"").replace(/\\u00a0/g," ");if(t.length>0&&t.length<100&&!this.parseDateText(t))return t}if(s&&e.length<300)for(const t of r){if("P"!==t.tagName)continue;const e=((null===(i=t.textContent)||void 0===i?void 0:i.trim())||"").replace(/\\u00a0/g," ");if(e.length>0&&e.length<150&&!this.parseDateText(e))return e}}t=t.nextElementSibling}let e=d;for(let t=0;t<3&&e;t++){let t=e.previousElementSibling;for(let e=0;e<3&&t;e++){const e=this.extractByline(t);if(e)return e;t=t.previousElementSibling}t=e.nextElementSibling;for(let e=0;e<3&&t;e++){const e=this.extractByline(t);if(e)return e;t=t.nextElementSibling}e=e.parentElement}}return""}static extractByline(t){var e;const r=[t,...t.querySelectorAll("p, span, address")];for(const t of r){const r=((null===(e=t.textContent)||void 0===e?void 0:e.trim())||"").replace(/\\u00a0/g," ");if(r.length>0&&r.length<50){const t=r.match(/^By\\s+([A-Z].+)$/i);if(t)return t[1].trim()}}return null}static getSiteName(t,e){const r=this.getSchemaProperty(t,"publisher.name")||this.getMetaContent(e,"property","og:site_name")||this.getMetaContent(e,"name","og:site_name")||this.getSchemaProperty(t,"WebSite.name")||this.getSchemaProperty(t,"sourceOrganization.name")||this.getMetaContent(e,"name","copyright")||this.getSchemaProperty(t,"copyrightHolder.name")||this.getSchemaProperty(t,"isPartOf.name")||this.getMetaContent(e,"name","application-name")||"";return r&&(0,n.countWords)(r)>6?"":r}static getBestTitle(t,e,r,n,o){var i,s,a;const l=[this.getMetaContent(r,"property","og:title"),this.getMetaContent(r,"name","twitter:title"),this.getSchemaProperty(e,"headline"),this.getMetaContent(r,"name","title"),this.getMetaContent(r,"name","sailthru.title"),(null===(s=null===(i=t.querySelector("title"))||void 0===i?void 0:i.textContent)||void 0===s?void 0:s.trim())||""].filter(Boolean);if(0===l.length)return"";const c=(this.getMetaContent(r,"property","author")||this.getMetaContent(r,"name","author")).trim().toLowerCase(),u=o.trim().toLowerCase(),d=n?n.replace(/\\.[^.]+$/,"").toLowerCase().replace(/[^a-z0-9]/g,""):"";return null!==(a=l.find((t=>!this.isSiteIdentifier(t,c,u,d))))&&void 0!==a?a:l[0]}static isSiteIdentifier(t,e,r,n){const o=t.trim().toLowerCase();if(e&&o===e)return!0;if(r&&o===r)return!0;if(n){if(o.replace(/[^a-z0-9]/g,"")===n)return!0}return!1}static cleanTitle(t,e){if(!t)return{title:t,detectedSiteName:""};const r="[|\\\\-\\u2013\\u2014/\\xb7]";if(e&&e.toLowerCase()!==t.toLowerCase()&&(0,n.countWords)(e)<=6){const o=e.toLowerCase(),i=e.replace(/[.*+?^${}()|[\\]\\\\]/g,"\\\\$&"),s=[`\\\\s*${r}\\\\s*${i}\\\\s*$`,`^\\\\s*${i}\\\\s*${r}\\\\s*`];for(const r of s){const n=new RegExp(r,"i");if(n.test(t))return{title:t.replace(n,"").trim(),detectedSiteName:e}}const a=new RegExp(`\\\\s+${r}\\\\s+`,"g");let l;const c=[];for(;null!==(l=a.exec(t));)c.push({index:l.index,length:l[0].length});if(c.length>0){const r=c[c.length-1],i=t.substring(r.index+r.length).trim().toLowerCase();if(i&&o.includes(i)){let o=r.index;for(let e=c.length-2;e>=0;e--){const r=c[e],i=t.substring(r.index+r.length,o).trim();if((0,n.countWords)(i)>3)break;o=r.index}return{title:t.substring(0,o).trim(),detectedSiteName:e}}const s=c[0],a=t.substring(0,s.index).trim().toLowerCase();if(a&&o.includes(a)){let r=s.index+s.length;for(let e=1;e<c.length;e++){const o=c[e],i=t.substring(r,o.index).trim();if((0,n.countWords)(i)>3)break;r=o.index+o.length}return{title:t.substring(r).trim(),detectedSiteName:e}}}}const o=/\\s+([|/\\xb7])\\s+/g;let i;const s=[];for(;null!==(i=o.exec(t));)s.push({index:i.index,length:i[0].length});if(s.length>0){const e=s[s.length-1],r=t.substring(0,e.index).trim(),o=t.substring(e.index+e.length).trim(),i=(0,n.countWords)(r),a=(0,n.countWords)(o);if(a<=3&&i>=3&&i>=2*a)return{title:r,detectedSiteName:o};const l=s[0],c=t.substring(0,l.index).trim(),u=t.substring(l.index+l.length).trim(),d=(0,n.countWords)(c),h=(0,n.countWords)(u);if(d<=3&&h>=3&&h>=2*d)return{title:u,detectedSiteName:c}}return{title:t.trim(),detectedSiteName:""}}static getDescription(t,e,r){return this.getMetaContent(r,"name","description")||this.getMetaContent(r,"property","description")||this.getMetaContent(r,"property","og:description")||this.getSchemaProperty(e,"description")||this.getMetaContent(r,"name","twitter:description")||this.getMetaContent(r,"name","sailthru.description")||""}static getImage(t,e,r){return this.getMetaContent(r,"property","og:image")||this.getMetaContent(r,"name","twitter:image")||this.getSchemaProperty(e,"image.url")||this.getMetaContent(r,"name","sailthru.image.full")||""}static getLanguage(t,e,r){var n,o,i,s;const a=null===(o=null===(n=t.documentElement)||void 0===n?void 0:n.getAttribute("lang"))||void 0===o?void 0:o.trim();if(a)return this.normalizeLangCode(a);const l=this.getMetaContent(r,"name","content-language")||this.getMetaContent(r,"property","og:locale");if(l)return this.normalizeLangCode(l);const c=null===(s=null===(i=t.querySelector(\'meta[http-equiv="Content-Language" i]\'))||void 0===i?void 0:i.getAttribute("content"))||void 0===s?void 0:s.trim();if(c)return this.normalizeLangCode(c);const u=this.getSchemaProperty(e,"inLanguage");return u?this.normalizeLangCode(u):""}static normalizeLangCode(t){return t.replace(/_/g,"-")}static getFavicon(t,e,r){var n,o;const i=this.getMetaContent(r,"property","og:image:favicon");if(i)return i;const s=null===(n=t.querySelector("link[rel=\'icon\']"))||void 0===n?void 0:n.getAttribute("href");if(s)return s;const a=null===(o=t.querySelector("link[rel=\'shortcut icon\']"))||void 0===o?void 0:o.getAttribute("href");if(a)return a;if(e&&/^https?:\\/\\//.test(e))try{return new URL("/favicon.ico",e).href}catch(t){}return""}static getPublished(t,e,r){var n,o,i,s;const a=this.getSchemaProperty(e,"datePublished")||this.getMetaContent(r,"name","publishDate")||this.getMetaContent(r,"property","article:published_time")||(null===(o=null===(n=t.querySelector(\'abbr[itemprop="datePublished"]\'))||void 0===n?void 0:n.title)||void 0===o?void 0:o.trim())||this.getTimeElement(t)||this.getMetaContent(r,"name","sailthru.date");if(a)return a;const l=t.querySelector("h1");if(l){let t=l.nextElementSibling;for(let e=0;e<3&&t;e++){for(const e of Array.from(t.querySelectorAll("p, time"))){const t=this.parseDateText((null===(i=e.textContent)||void 0===i?void 0:i.trim())||"");if(t)return t}const e=this.parseDateText((null===(s=t.textContent)||void 0===s?void 0:s.trim())||"");if(e)return e;t=t.nextElementSibling}}return""}static getMetaContent(t,e,r){var n;return null!==(n=this.getMetaContents(t,e,r)[0])&&void 0!==n?n:""}static getMetaContents(t,e,r){return t.filter((t=>{const n="name"===e?t.name:t.property;return(null==n?void 0:n.toLowerCase())===r.toLowerCase()})).map((t=>{var e,r;return null!==(r=null===(e=t.content)||void 0===e?void 0:e.trim())&&void 0!==r?r:""}))}static getTimeElement(t){var e,r,n,o;const i=Array.from(t.querySelectorAll("time"))[0];return i&&null!==(o=null!==(r=null===(e=i.getAttribute("datetime"))||void 0===e?void 0:e.trim())&&void 0!==r?r:null===(n=i.textContent)||void 0===n?void 0:n.trim())&&void 0!==o?o:""}static parseDateText(t){let e=t.match(/\\b(\\d{1,2})\\s+(January|February|March|April|May|June|July|August|September|October|November|December)\\s+(\\d{4})\\b/i);if(e){const t=e[1].padStart(2,"0"),r=this.MONTH_MAP[e[2].toLowerCase()];return`${e[3]}-${r}-${t}T00:00:00+00:00`}if(e=t.match(/\\b(January|February|March|April|May|June|July|August|September|October|November|December)\\s+(\\d{1,2}),?\\s+(\\d{4})\\b/i),e){const t=this.MONTH_MAP[e[1].toLowerCase()],r=e[2].padStart(2,"0");return`${e[3]}-${t}-${r}T00:00:00+00:00`}return""}static getSchemaProperty(t,e,r=""){if(!t)return r;const n=(t,e,r,o=!0)=>{if("string"==typeof t)return 0===e.length?[t]:[];if(!t||"object"!=typeof t)return[];if(Array.isArray(t)){const i=e[0];if(/^\\[\\d+\\]$/.test(i)){const s=parseInt(i.slice(1,-1));return t[s]?n(t[s],e.slice(1),r,o):[]}return 0===e.length&&t.every((t=>"string"==typeof t||"number"==typeof t))?t.map(String):t.flatMap((t=>n(t,e,r,o)))}const[i,...s]=e;if(!i)return"string"==typeof t?[t]:"object"==typeof t&&t.name?[t.name]:[];if(t.hasOwnProperty(i))return n(t[i],s,r?`${r}.${i}`:i,!0);if(!o){const o=[];for(const i in t)if("object"==typeof t[i]){const s=n(t[i],e,r?`${r}.${i}`:i,!1);o.push(...s)}if(o.length>0)return o}return[]};try{let o=n(t,e.split("."),"",!0);0===o.length&&(o=n(t,e.split("."),"",!1));return o.length>0?o.filter(Boolean).join(", "):r}catch(t){return console.error(`Error in getSchemaProperty for ${e}:`,t),r}}}e.MetadataExtractor=o,o.MONTH_MAP={january:"01",february:"02",march:"03",april:"04",may:"05",june:"06",july:"07",august:"08",september:"09",october:"10",november:"11",december:"12"}},172(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.removeByContentPattern=function(t,e,r,u){var m,C,x,E,S,w,A,T,_,L,N,q,k,$,M,O,P,D,R,I;const B=t.querySelector("ul, ol");if(B&&function(t){const e=t.querySelectorAll("li");if(e.length<2||e.length>8)return!1;const r=Array.from(t.querySelectorAll("a"));if(r.length<1||r.length>=e.length)return!1;if(t.querySelector("img, p, figure, blockquote"))return!1;let n=!0,o=!1,i=!0;for(const t of r){const e=t.getAttribute("href")||"";if(e.startsWith("http")||e.startsWith("//")){n=!1;break}("/"===e||/^\\/[a-zA-Z0-9_-]+\\/?$/.test(e))&&(o=!0),(t.textContent||"").trim().split(/\\s+/).filter(Boolean).length>5&&(i=!1)}return n&&o&&i}(B)){let r=B;for(;r.parentElement&&r.parentElement!==t&&1===r.parentElement.children.length;)r=r.parentElement;e&&u&&u.push({step:"removeByContentPattern",reason:"breadcrumb navigation list",text:(0,o.textPreview)(r)}),r.remove()}const H=t.querySelector("h1");if(H)for(const r of t.querySelectorAll("a[href]")){if(!r.parentNode)continue;if(!(4&r.compareDocumentPosition(H)))continue;if(!r.querySelector("div"))continue;const t=(null===(m=r.textContent)||void 0===m?void 0:m.trim())||"";(0,o.countWords)(t)>25||(/[.!?]\\s/.test(t)||(e&&u&&u.push({step:"removeByContentPattern",reason:"promotional banner link",text:(0,o.textPreview)(r)}),r.remove()))}!function(t,e,r){var n,i;const s=t.querySelectorAll("time");if(0===s.length)return;const a=t.textContent||"";for(const l of s){const s=(null===(n=l.textContent)||void 0===n?void 0:n.trim())||"";if(a.indexOf(s)>300)continue;let c=null,u=l.parentElement;for(;u&&u!==t;){if(u.querySelector("h1, h2")&&u.querySelector("time")){const t=(null===(i=u.textContent)||void 0===i?void 0:i.trim())||"",e=(0,o.countWords)(t),r=new Set;for(const t of u.querySelectorAll("h1, h2, h3, time, [aria-label]")){let e=!1;for(const n of r)if(n.contains(t)){e=!0;break}e||r.add(t)}let n=0;for(const t of r)n+=(0,o.countWords)(t.textContent||"");if(!(e-n<30))break;c=u}u=u.parentElement}if(c)return e&&r&&r.push({step:"removeByContentPattern",reason:"hero header block",text:(0,o.textPreview)(c)}),void c.remove()}}(t,e,u);const j=t.textContent||"",F=Array.from(t.querySelectorAll("p, span, div, time"));let W=!1,U=!1;for(const r of F){if(!r.parentNode)continue;const n=(null===(C=r.textContent)||void 0===C?void 0:C.trim())||"",c=(0,o.countWords)(n);if(c>15||0===c)continue;if(r.closest("pre, code"))continue;const d=r.tagName,h=i.test(n);let m=-2;const v=()=>(-2===m&&(m=j.indexOf(n)),m);if("DIV"===d&&c>=1&&c<=10&&h&&!/[.!?]/.test(n)&&v()<=400&&!Array.from(r.querySelectorAll("p, h1, h2, h3, h4, h5, h6")).some((t=>(0,o.countWords)(t.textContent||"")>8)))e&&u&&u.push({step:"removeByContentPattern",reason:"article metadata header block",text:(0,o.textPreview)(r)}),r.remove();else if(!W&&l.test(n)&&c>=2&&!/[.!?]$/.test(n)&&v()<=600){const i=g(r,n,t);e&&u&&u.push({step:"removeByContentPattern",reason:"author byline",text:(0,o.textPreview)(i)}),i.remove(),W=!0}else{if(h&&s.test(n)&&0===r.querySelectorAll("p, div, section, article").length){let t=n;for(const e of p)t=t.replace(e,"");if(0===t.trim().length){e&&u&&u.push({step:"removeByContentPattern",reason:"read time metadata",text:(0,o.textPreview)(r)}),r.remove();continue}}if(!U&&c>=2&&c<=10&&h&&v()<=500){let i=n;for(const t of f)i=i.replace(t,"");if(i=i.trim(),i){const s=i.split(/\\s+/).filter((t=>t.length>0));if(s.length>=1&&s.length<=4&&s.every((t=>a.test(t)))){const i=g(r,n,t);e&&u&&u.push({step:"removeByContentPattern",reason:"author date metadata",text:(0,o.textPreview)(i)}),i.remove(),U=!0;continue}}}}}const z=Array.from(t.querySelectorAll("time"));for(const r of z){if(!r.parentNode)continue;let n=r,i=(null===(x=n.textContent)||void 0===x?void 0:x.trim())||"";for(;n.parentElement&&n.parentElement!==t;){const t=n.parentElement.tagName.toLowerCase(),e=(null===(E=n.parentElement.textContent)||void 0===E?void 0:E.trim())||"";if("p"===t&&e===i){n=n.parentElement;break}if(!["i","em","span","b","strong","small"].includes(t)||e!==i)break;n=n.parentElement,i=e}const s=(null===(S=n.textContent)||void 0===S?void 0:S.trim())||"";if((0,o.countWords)(s)>10)continue;const a=j.indexOf(s),l=j.length-(a+s.length);a>200&&l>200||(e&&u&&u.push({step:"removeByContentPattern",reason:"boundary date element",text:(0,o.textPreview)(n)}),n.remove())}const J=t.querySelectorAll("ul, ol, dl");for(const r of J){if(!r.parentNode)continue;const n="DL"===r.tagName,i=Array.from(r.children).filter((t=>n?"DD"===t.tagName:"LI"===t.tagName)),s=n?1:2;if(i.length<s||i.length>8)continue;const a=(null===(w=r.textContent)||void 0===w?void 0:w.trim())||"",l=j.indexOf(a),c=j.length-(l+a.length);if(l>500&&c>500)continue;const d=r.previousElementSibling;if(d){if(((null===(A=d.textContent)||void 0===A?void 0:A.trim())||"").endsWith(":"))continue}let h=!0;for(const t of i){const e=(null===(T=t.textContent)||void 0===T?void 0:T.trim())||"";if((0,o.countWords)(e)>8){h=!1;break}if(/[.!?]$/.test(e)){h=!1;break}}if(!h)continue;if((0,o.countWords)(a)>30)continue;const m=g(r,a,t);e&&u&&u.push({step:"removeByContentPattern",reason:"blog metadata list",text:(0,o.textPreview)(m)}),m.remove()}let V="",G="";try{const t=new URL(r);V=t.pathname,G=t.hostname.replace(/^www\\./,"")}catch(t){}if(V){const n=t.querySelectorAll("div, span, p, a[href]"),i=t.querySelector("h1, h2, h3");for(const s of n){if(!s.parentNode)continue;const n=(null===(_=s.textContent)||void 0===_?void 0:_.trim())||"";if((0,o.countWords)(n)>10)continue;if(s.querySelectorAll("p, div, section, article").length>0)continue;if(s.matches("a[href]")&&s.parentElement&&s.parentElement!==t&&((null===(L=s.parentElement.textContent)||void 0===L?void 0:L.trim())||"")!==n){if(!i)continue;if(!(4&s.compareDocumentPosition(i)))continue}const a=s.matches("a[href]")?s:s.querySelector("a[href]");if(a)try{const t=new URL(a.getAttribute("href")||"",r).pathname,n=t.replace(/\\/[^/]*$/,"/"),i=/^index\\.(html?|php)$/i.test(t.split("/").pop()||"")&&V.startsWith(n);"/"!==t&&t!==V&&(V.startsWith(t)||i)&&(e&&u&&u.push({step:"removeByContentPattern",reason:"section breadcrumb",text:(0,o.textPreview)(s)}),s.remove())}catch(t){}}}if(G){const n=t.querySelectorAll("h2, h3, h4, h5, h6");for(const i of n){if(!i.parentNode)continue;const n=i.nextElementSibling;if(!n||"UL"!==n.tagName&&"OL"!==n.tagName)continue;const s=Array.from(n.children).filter((t=>"LI"===t.tagName));if(s.length<2)continue;let a=!1,l=n;for(;l&&l!==t;){let t=l.nextElementSibling;for(;t;){if(((null===(N=t.textContent)||void 0===N?void 0:N.trim())||"").length>0){a=!0;break}t=t.nextElementSibling}if(a)break;l=l.parentElement}if(a)continue;let c=!0;for(const t of s){const e=t.querySelectorAll("a[href]");if(0===e.length){c=!1;break}const n=(null===(q=t.textContent)||void 0===q?void 0:q.trim())||"";let o=0;for(const t of e){o+=((null===(k=t.textContent)||void 0===k?void 0:k.trim())||"").length;try{if(new URL(t.getAttribute("href")||"",r).hostname.replace(/^www\\./,"")===G){c=!1;break}}catch(t){}}if(!c)break;if(o<.6*n.length){c=!1;break}}c&&(e&&u&&(u.push({step:"removeByContentPattern",reason:"trailing external link list",text:(0,o.textPreview)(i)}),u.push({step:"removeByContentPattern",reason:"trailing external link list",text:(0,o.textPreview)(n)})),n.remove(),i.remove())}}let X=t.lastElementChild;for(;X&&["HR","BR"].includes(X.tagName);)X=X.previousElementSibling;if(X&&["SECTION","DIV","ASIDE"].includes(X.tagName)){const t=[];let r=!1;for(const e of X.children){if((null===($=e.textContent)||void 0===$?void 0:$.trim())||"")if("P"===e.tagName)t.push(e);else if("BR"!==e.tagName){r=!0;break}}if(t.length>=2&&!r){const r=t.every((t=>{var e,r,n;const o=((null===(e=t.textContent)||void 0===e?void 0:e.trim())||"").replace(/\\s+/g," "),i=t.querySelectorAll("a[href]");if(0===i.length)return!1;let s=0;for(const t of i)s+=((null===(r=t.textContent)||void 0===r?void 0:r.trim())||"").length;if(s/(o.length||1)<=.6)return!1;let a=o;for(const t of i)a=a.split((null===(n=t.textContent)||void 0===n?void 0:n.trim())||"").join("");return!/[.!?]/.test(a)}));r&&(e&&u&&u.push({step:"removeByContentPattern",reason:"trailing related posts block",text:(0,o.textPreview)(X)}),X.remove())}}const Y=(0,o.countWords)(t.textContent||"");if(Y>300){const r=[];let i=0,s=t.lastElementChild;for(;s;){let t=0;for(const e of s.querySelectorAll("svg"))t+=(0,o.countWords)(e.textContent||"");const e=(0,o.countWords)((null===(M=s.textContent)||void 0===M?void 0:M.trim())||"")-t;if(e>25)break;i+=e,r.push(s),s=s.previousElementSibling}if(r.length>=1&&i<.15*Y){const t=r.some((t=>/^H[1-6]$/.test(t.tagName)||t.querySelector("h1, h2, h3, h4, h5, h6"))),i=r.some((t=>t.querySelector(n.CONTENT_ELEMENT_SELECTOR)));if(t&&!i)for(const t of r)e&&u&&u.push({step:"removeByContentPattern",reason:"trailing thin section",text:(0,o.textPreview)(t)}),t.remove()}}const K=t.textContent||"",Z=t.querySelectorAll("p, div, span, section");for(const r of Z){if(!r.parentNode)continue;const n=(null===(O=r.textContent)||void 0===O?void 0:O.trim())||"",i=(0,o.countWords)(n);if(!(i>50||i<1))for(const i of c)if(i.test(n)){let n=r;for(;n.parentElement&&n.parentElement!==t&&!n.nextElementSibling;)n=n.parentElement;const i=n.textContent||"";if(K.indexOf(i)<200){n===r||r.nextElementSibling||(e&&u&&u.push({step:"removeByContentPattern",reason:"boilerplate text",text:(0,o.textPreview)(r)}),r.remove());continue}const s=[];let a=n.parentElement;for(;a&&a!==t;)s.push(a),a=a.parentElement;v(n,!0,e,u);for(const t of s)v(t,!1,e,u);return}}for(const r of t.querySelectorAll("h2, h3, h4, h5, h6")){if(!r.parentNode)continue;const n=(null===(P=r.textContent)||void 0===P?void 0:P.trim())||"";if(!h.test(n))continue;if(j.indexOf(n)<500)continue;const i=y(r,t);if(i!==r){b(i,e,u),e&&u&&u.push({step:"removeByContentPattern",reason:"related content section",text:(0,o.textPreview)(i)}),v(i,!0,e,u);break}}for(const r of t.querySelectorAll("div")){if(!r.parentNode)continue;if(r.children.length<2)continue;const n=Array.from(r.children),i=n.filter((t=>t.querySelector("img, picture")&&t.querySelector("h2, h3, h4"))).length;if(i<2||i<.7*n.length)continue;const s=(null===(D=n[0].textContent)||void 0===D?void 0:D.trim().substring(0,30))||"";if(s.length<5||j.indexOf(s)<500)continue;const a=y(r,t);if(a!==r){b(a,e,u),e&&u&&u.push({step:"removeByContentPattern",reason:"related post cards",text:(0,o.textPreview)(a)}),v(a,!0,e,u);break}}for(const r of t.querySelectorAll("div, section, aside")){if(!r.parentNode)continue;if(r.closest("pre, code"))continue;if(!d(r,60))continue;const n=(0,o.countWords)((null===(R=r.textContent)||void 0===R?void 0:R.trim())||"");let i=r;for(;i.parentElement&&i.parentElement!==t;){if((0,o.countWords)((null===(I=i.parentElement.textContent)||void 0===I?void 0:I.trim())||"")>2*n+15)break;i=i.parentElement}e&&u&&u.push({step:"removeByContentPattern",reason:"newsletter signup",text:(0,o.textPreview)(i)}),i.remove();break}for(const r of t.querySelectorAll("ul"))if(r.parentNode&&d(r,30)){e&&u&&u.push({step:"removeByContentPattern",reason:"newsletter signup list",text:(0,o.textPreview)(r)}),r.remove();break}};const n=r(640),o=r(552),i=/(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\\s+\\d{1,2}/i,s=/\\d+\\s*min(?:ute)?s?\\s+read\\b/i,a=/^\\p{Lu}/u,l=/^by\\s+\\S/i,c=[/^This (?:article|story|piece) (?:appeared|was published|originally appeared) in\\b/i,/^A version of this (?:article|story) (?:appeared|was published) in\\b/i,/^Originally (?:published|appeared) (?:in|on|at)\\b/i,/^Any re-?use permitted\\b/i,/^\\xa9\\s*(?:Copyright\\s+)?\\d{4}/i,/^Comments?$/i,/^Leave a (?:comment|reply)$/i],u=/\\bsubscribe\\b[\\s\\S]{0,40}\\bnewsletter\\b|\\bnewsletter\\b[\\s\\S]{0,40}\\bsubscribe\\b|\\bsign[- ]up\\b[\\s\\S]{0,80}\\b(?:newsletter|email alert)/i;function d(t,e){var r;const i=(null===(r=t.textContent)||void 0===r?void 0:r.trim())||"",s=(0,o.countWords)(i);if(s<2||s>e)return!1;if(t.querySelector(n.CONTENT_ELEMENT_SELECTOR))return!1;const a=i.replace(/([a-z])([A-Z])/g,"$1 $2");return u.test(a)}const h=/^(?:related (?:posts?|articles?|content|stories|reads?|reading)|you (?:might|may|could) (?:also )?(?:like|enjoy|be interested in)|read (?:next|more|also)|further reading|see also|more (?:from|articles?|posts?|like this)|more to (?:read|explore)|about (?:the )?author)$/i,m=[/\\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\\b/gi,/\\b\\d+(?:st|nd|rd|th)?\\b/g],p=[...m,/\\bmin(?:ute)?s?\\b/gi,/\\bread\\b/gi,/[/|\\xb7\\u2022\\u2014\\u2013\\-,.\\s]+/g],f=[...m,/\\bby\\b/gi,/[/|\\xb7\\u2022\\u2014\\u2013\\-,]+/g];function g(t,e,r){var n;let o=t;for(;o.parentElement&&o.parentElement!==r&&((null===(n=o.parentElement.textContent)||void 0===n?void 0:n.trim())||"")===e;)o=o.parentElement;return o}function v(t,e,r,n){let i=t.nextElementSibling;for(;i;){const t=i.nextElementSibling;r&&n&&n.push({step:"removeByContentPattern",reason:"trailing non-content",text:(0,o.textPreview)(i)}),i.remove(),i=t}e&&(r&&n&&n.push({step:"removeByContentPattern",reason:"boilerplate text",text:(0,o.textPreview)(t)}),t.remove())}function y(t,e){let r=t;for(;r.parentElement&&r.parentElement!==e;){let t=0,e=r.previousElementSibling;for(;e&&(t+=(0,o.countWords)(e.textContent||""),!(t>10));)e=e.previousElementSibling;if(t>10)break;r=r.parentElement}return r}function b(t,e,r){const i=t.previousElementSibling;i&&((0,o.countWords)(i.textContent||"")>=50||i.querySelector(n.CONTENT_ELEMENT_SELECTOR)||(e&&r&&r.push({step:"removeByContentPattern",reason:"thin CTA section",text:(0,o.textPreview)(i)}),i.remove()))}},983(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.removeHiddenElements=function(t,e,r){let o=0;const i=new Map,s=/(?:^|;\\s*)(?:display\\s*:\\s*none|visibility\\s*:\\s*hidden|opacity\\s*:\\s*0)(?:\\s*;|\\s*$)/i,a=t.defaultView,l="undefined"!=typeof window&&a===window,c=t.querySelectorAll("*");for(const t of c){if(t.querySelector("math, [data-mathml], .katex-mathml")||"math"===t.tagName.toLowerCase())continue;const e=t.getAttribute("style");if(e&&s.test(e)){const r=e.includes("display")?"display:none":e.includes("visibility")?"visibility:hidden":"opacity:0";i.set(t,r),o++;continue}if(l)try{const e=a.getComputedStyle(t);let r="";if("none"===e.display?r="display:none":"hidden"===e.visibility?r="visibility:hidden":"0"===e.opacity&&(r="opacity:0"),r){i.set(t,r),o++;continue}}catch(t){}const r=t.getAttribute("class")||"";if(r){const e=r.split(/\\s+/);for(const r of e)if("hidden"===r||r.endsWith(":hidden")||"invisible"===r||r.endsWith(":invisible")){i.set(t,`class:${r}`),o++;break}}}i.forEach(((t,o)=>{e&&r&&r.push({step:"removeHiddenElements",reason:t,text:(0,n.textPreview)(o)}),o.remove()})),(0,n.logDebug)(e,"Removed hidden elements:",o)};const n=r(552)},662(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.removeMetadataBlock=function(t){var e,n;const o=t.querySelector("h1");if(!o)return;let i=o.nextElementSibling;for(let t=0;t<3&&i;t++){const t=i.nextElementSibling,o=(null===(e=i.textContent)||void 0===e?void 0:e.trim())||"";if(o.length>0&&o.length<300){let t=r.test(o);if(!t)for(const e of i.querySelectorAll("p, time"))if(r.test((null===(n=e.textContent)||void 0===n?void 0:n.trim())||"")){t=!0;break}if(t){i.remove();break}}i=t}};const r=/\\b(?:Jan(?:uary)?|Feb(?:ruary)?|Mar(?:ch)?|Apr(?:il)?|May|Jun(?:e)?|Jul(?:y)?|Aug(?:ust)?|Sep(?:t(?:ember)?)?|Oct(?:ober)?|Nov(?:ember)?|Dec(?:ember)?)\\s+\\d{1,2}[\\s,]+\\d{4}\\b/i},550(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.ContentScorer=void 0;const n=r(640),o=r(552),i=r(639),s=["admonition","article","content","entry","image","img","font","figure","figcaption","pre","main","post","story","table"],a=["advertisement","all rights reserved","banner","cookie","comments","copyright","follow me","follow us","footer","header","homepage","login","menu","more articles","more like this","most read","nav","navigation","newsletter","popular","privacy","recommended","register","related","responses","share","sidebar","sign in","sign up","signup","social","sponsored","subscribe","terms","trending"],l=/\\b(linkedin\\.com\\/(in|company)\\/|twitter\\.com\\/(?!intent\\b)\\w|x\\.com\\/(?!intent\\b)\\w|facebook\\.com\\/(?!share\\b)\\w|instagram\\.com\\/\\w|threads\\.net\\/\\w|mastodon\\.\\w)/i,c=/(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\\s+\\d{1,2}/i,u=/\\bBy\\s+[A-Z]/,d=a.map((t=>new RegExp(`\\\\b${t.replace(/\\s+/g,"\\\\s+")}\\\\b`))),h=new RegExp(a.map((t=>t.replace(/\\s+/g,"\\\\s+"))).join("|"),"i"),m=/\\b(?:Jan|Feb|Mar|Apr|May|Jun|Jul|Aug|Sep|Oct|Nov|Dec)[a-z]*\\s+\\d{1,2},?\\s+\\d{4}\\b/i,p=/\\b(?:by|written by|author:)\\s+[A-Za-z\\s]+\\b/i,f=["advert","ad-","ads","banner","cookie","copyright","footer","header","homepage","menu","nav","newsletter","popular","privacy","recommended","related","rights","share","sidebar","social","sponsored","subscribe","terms","trending","widget"];class g{constructor(t,e=!1){this.doc=t,this.debug=e}static scoreElement(t){let e=0;const r=t.textContent||"",s=(0,o.countWords)(r);e+=s;e+=10*t.getElementsByTagName("p").length;e+=r.split(/,/).length-1;e-=3*(t.getElementsByTagName("img").length/(s||1));try{const r=t.getAttribute("style")||"",n=t.getAttribute("align")||"";(r.includes("float: right")||r.includes("text-align: right")||"right"===n)&&(e+=5)}catch(t){}m.test(r)&&(e+=10);p.test(r)&&(e+=10);const a=(0,i.getClassName)(t).toLowerCase();(a.includes("content")||a.includes("article")||a.includes("post"))&&(e+=15);t.querySelector(n.FOOTNOTE_INLINE_REFERENCES)&&(e+=10);t.querySelector(n.FOOTNOTE_LIST_SELECTORS)&&(e+=10);if(e-=5*t.getElementsByTagName("table").length,"td"===t.tagName.toLowerCase()){const r=t.closest("table");if(r){const n=parseInt(r.getAttribute("width")||"0"),o=r.getAttribute("align")||"",s=(0,i.getClassName)(r).toLowerCase();if(n>400||"center"===o||s.includes("content")||s.includes("article")){const n=Array.from(r.getElementsByTagName("td")),o=n.indexOf(t);o>0&&o<n.length-1&&(e+=10)}}}const l=t.getElementsByTagName("a");let c=0;for(let t=0;t<l.length;t++)c+=(l[t].textContent||"").length;const u=r.length||1;return e*=1-Math.min(c/u,.5),e}static findBestElement(t,e=50){let r=null,n=0;return t.forEach((t=>{const e=this.scoreElement(t);e>n&&(n=e,r=t)})),n>e?r:null}static scoreAndRemove(t,e=!1,r,i){const s=Date.now(),a=new Map;Array.from(t.querySelectorAll(n.BLOCK_ELEMENTS_SELECTOR)).forEach((t=>{if(a.has(t))return;if(i&&t.contains(i))return;if(t.closest("pre"))return;if(g.isLikelyContent(t))return;const e=g.scoreNonContentBlock(t);e<0&&a.set(t,e)})),a.forEach(((t,n)=>{e&&r&&r.push({step:"scoreAndRemove",reason:`score: ${t}`,text:(0,o.textPreview)(n)}),n.remove()}));const l=Date.now();(0,o.logDebug)(e,"Removed non-content blocks:",{count:a.size,processingTime:`${(l-s).toFixed(2)}ms`})}static isLikelyContent(t){const e=t.getAttribute("role");if(e&&["article","main","contentinfo"].includes(e))return!0;const r=(0,i.getClassName)(t).toLowerCase(),n=t.id.toLowerCase();for(const t of s)if(r.includes(t)||n.includes(t))return!0;if(t.querySelector("pre, table"))return!0;const a=t.textContent||"",c=(0,o.countWords)(a);if(c<1e3){const e=t.querySelectorAll("h1, h2, h3, h4, h5, h6");let r=!1;for(let t=0;t<e.length;t++){const n=(e[t].textContent||"").toLowerCase().trim();if(h.test(n)){r=!0;break}}if(r){if(c<200)return!1;if(t.getElementsByTagName("a").length/(c||1)>.2)return!1}}if(g.isCardGrid(t,c))return!1;if(c<80){const e=t.getElementsByTagName("a");for(let t=0;t<e.length;t++){const r=(e[t].getAttribute("href")||"").toLowerCase();if(l.test(r))return!1}}const u=t.getElementsByTagName("p").length+t.getElementsByTagName("li").length;if(c>50&&u>1)return!0;if(c>100)return!0;if(c>30&&u>0)return!0;if(c>=10&&/[.?!]/.test(a)){if(t.getElementsByTagName("a").length/c<.1)return!0}return!1}static scoreNonContentBlock(t){try{if(t.matches(n.FOOTNOTE_LIST_SELECTORS)||t.querySelector(n.FOOTNOTE_LIST_SELECTORS)||t.closest(n.FOOTNOTE_LIST_SELECTORS))return 0}catch(t){}let e=0;const r=t.textContent||"",s=(0,o.countWords)(r);if(s<3)return 0;e+=r.split(/,/).length-1;const a=r.toLowerCase();let h=0;for(const t of d)t.test(a)&&h++;e-=10*h;const m=t.getElementsByTagName("a"),p=m.length;if(p/(s||1)>.5&&(e-=15),p>1&&s<80){let t=0;for(let e=0;e<m.length;e++)t+=(m[e].textContent||"").length;const n=r.length;n>0&&t/n>.8&&(e-=15)}const v=t.getElementsByTagName("ul").length+t.getElementsByTagName("ol").length;if(v>0&&p>3*v&&(e-=10),s<80){const r=t.getElementsByTagName("a");for(let t=0;t<r.length;t++){const n=(r[t].getAttribute("href")||"").toLowerCase();if(l.test(n)){e-=15;break}}}s<15&&u.test(r)&&c.test(r)&&(e-=10),g.isCardGrid(t,s)&&(e-=15);const y=(0,i.getClassName)(t).toLowerCase(),b=t.id.toLowerCase();for(const t of f)(y.includes(t)||b.includes(t))&&(e-=8);return e}static isCardGrid(t,e){if(e<3||e>=500)return!1;const r=t.querySelectorAll("h2, h3, h4");if(r.length<3)return!1;if(t.querySelectorAll("img").length<2)return!1;let n=0;for(let t=0;t<r.length;t++)n+=(0,o.countWords)(r[t].textContent||"");return(e-n)/r.length<20}}e.ContentScorer=g},393(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.removeBySelector=function(t,e,r=!0,s=!0,a,l,c=!1){const u=Date.now();let d=0,h=0;const m=new Map;if(r){t.querySelectorAll(n.EXACT_SELECTORS_JOINED).forEach((t=>{if(null==t?void 0:t.parentNode){if(c){const e=t.closest(n.HIDDEN_EXACT_SKIP_SELECTOR),r=(t.getAttribute("role")||"").toLowerCase();if(t.matches(n.HIDDEN_EXACT_SELECTOR)||e&&"dialog"===r)return}if(t.closest("pre, code"))return;m.set(t,{type:"exact"}),d++}}))}if(s){const r=e?n.PARTIAL_SELECTORS.map((t=>({pattern:t,regex:new RegExp(t,"i")}))):null;t.querySelectorAll(n.TEST_ATTRIBUTES_SELECTOR).forEach((t=>{var e;if(m.has(t))return;const o=t.tagName;if("CODE"===o||"PRE"===o||t.querySelector("pre")||t.closest("code, pre"))return;const s=((0,i.getClassName)(t)+" "+(t.id||"")+" "+(t.getAttribute("data-component")||"")+" "+(t.getAttribute("data-test")||"")+" "+(t.getAttribute("data-testid")||"")+" "+(t.getAttribute("data-test-id")||"")+" "+(t.getAttribute("data-qa")||"")+" "+(t.getAttribute("data-cy")||"")).toLowerCase();if(s.trim()&&n.PARTIAL_SELECTORS_REGEX.test(s)){const n=r?null===(e=r.find((t=>t.regex.test(s))))||void 0===e?void 0:e.pattern:void 0;m.set(t,{type:"partial",selector:n}),h++}}))}m.forEach((({type:t,selector:r},i)=>{if(!(a&&i.contains(a)||"A"===i.tagName&&i.closest("h1, h2, h3, h4, h5, h6"))){try{if(i.matches(n.FOOTNOTE_LIST_SELECTORS)||i.querySelector(n.FOOTNOTE_LIST_SELECTORS))return;const t=i.parentElement;if(t&&t.matches(n.FOOTNOTE_LIST_SELECTORS))return}catch(t){}e&&l&&l.push({step:"removeBySelector",selector:"exact"===t?"exact":r,reason:"exact"===t?"exact selector match":`partial match: ${r}`,text:(0,o.textPreview)(i)}),i.remove()}}));const p=Date.now();(0,o.logDebug)(e,"Removed clutter elements:",{exactSelectors:d,partialSelectors:h,total:m.size,processingTime:`${(p-u).toFixed(2)}ms`})};const n=r(640),o=r(552),i=r(639)},408(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.getElementIdentifier=a,e.findSmallImages=function(t,e){var r,o;const l=new Set;let c=0;const u=t.querySelectorAll("img, svg"),d=t.defaultView,h="undefined"!=typeof window&&d===window;for(const t of u){const e=parseInt(t.getAttribute("width")||"0"),n=parseInt(t.getAttribute("height")||"0"),u=t.getAttribute("style")||"",m=parseInt((null===(r=u.match(i))||void 0===r?void 0:r[1])||"0"),p=parseInt((null===(o=u.match(s))||void 0===o?void 0:o[1])||"0");let f=0,g=0;if(h){try{const e=d.getComputedStyle(t);f=parseInt(e.width)||0,g=parseInt(e.height)||0}catch(t){}try{const e=t.getBoundingClientRect();e.width>0&&(f=f||e.width),e.height>0&&(g=g||e.height)}catch(t){}}const v=[e,m,f].filter((t=>t>0)),y=[n,p,g].filter((t=>t>0));if(v.length>0&&y.length>0){const e=Math.min(...v),r=Math.min(...y);if(e<33||r<33){const e=a(t);e&&(l.add(e),c++)}}}return(0,n.logDebug)(e,"Found small elements:",c),l},e.removeSmallImages=function(t,e,r){let o=0;["img","svg"].forEach((r=>{const n=t.getElementsByTagName(r);Array.from(n).forEach((t=>{if("img"===r){if(!(t.getAttribute("src")||t.getAttribute("srcset")||t.getAttribute("data-src")||t.getAttribute("data-srcset")||t.getAttribute("data-lazy-src")||t.getAttribute("data-original")))return t.remove(),void o++}const n=a(t);n&&e.has(n)&&(t.remove(),o++)}))})),(0,n.logDebug)(r,"Removed small elements:",o)};const n=r(552),o=r(639),i=/width\\s*:\\s*(\\d+)/,s=/height\\s*:\\s*(\\d+)/;function a(t){if("img"===t.tagName.toLowerCase()){const e=t.getAttribute("data-src");if(e)return`src:${e}`;const r=t.getAttribute("src")||"",n=t.getAttribute("srcset")||"",o=t.getAttribute("data-srcset");if(r)return`src:${r}`;if(n)return`srcset:${n}`;if(o)return`srcset:${o}`}const e=t.id||"",r=(0,o.getClassName)(t),n="svg"===t.tagName.toLowerCase()&&t.getAttribute("viewBox")||"";return e?`id:${e}`:n?`viewBox:${n}`:r?`class:${r}`:null}},840(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.standardizeContent=function(t,e,r,o=!1,i){u=o;const a=i?(t,e)=>{var r;const n=performance.now(),o=e();return i[t]=(null!==(r=i[t])&&void 0!==r?r:0)+Math.round(performance.now()-n),o}:(t,e)=>e();a("standardizeSpaces",(()=>function(t){const e=t=>{if((0,l.isElement)(t)){const e=t.tagName.toLowerCase();if("pre"===e||"code"===e)return}if((0,l.isTextNode)(t)){const e=t.textContent||"",r=e.replace(/\\xA0/g," ");r!==e&&(t.textContent=r)}t.hasChildNodes()&&Array.from(t.childNodes).forEach(e)};e(t)}(t))),a("removeHtmlComments",(()=>function(t){var e;let r=0;const n=t.ownerDocument,o=n.createTreeWalker(t,128),i=[];for(;o.nextNode();)i.push(o.currentNode);for(const t of i)null===(e=t.parentNode)||void 0===e||e.removeChild(t),r++;(0,l.logDebug)(u,"Removed HTML comments:",r)}(t))),a("standardizeHeadings",(()=>function(t,e,r){const o=t=>t.replace(/\\u00A0/g," ").replace(/\\s+/g," ").trim().toLowerCase(),i=t.getElementsByTagName("h1");Array.from(i).forEach((t=>{var e;const o=r.createElement("h2");(0,c.transferContent)(t,o),Array.from(t.attributes).forEach((t=>{n.ALLOWED_ATTRIBUTES.has(t.name)&&o.setAttribute(t.name,t.value)})),null===(e=t.parentNode)||void 0===e||e.replaceChild(o,t)}));const s=t.getElementsByTagName("h2");if(s.length>0){const t=s[0],r=o(t.textContent||""),n=o(e);n&&n===r&&t.remove()}}(t,e.title,r))),a("wrapPreformattedCode",(()=>function(t,e){var r;const n=Array.from(t.querySelectorAll("code"));for(const t of n){if(t.closest("pre"))continue;const n=t.getAttribute("style")||"";if(!/white-space\\s*:\\s*pre/.test(n))continue;const o=e.createElement("pre");null===(r=t.parentNode)||void 0===r||r.insertBefore(o,t),o.appendChild(t)}}(t,r))),a("standardizeElements",(()=>function(t,e,r){let n=0;const o=r?(t,e)=>{var n;const o=performance.now(),i=e();return r["se:"+t]=(null!==(n=r["se:"+t])&&void 0!==n?n:0)+Math.round(performance.now()-o),i}:(t,e)=>e();d.forEach((r=>{const i=r.selector.substring(0,30);o(i,(()=>{if(r.fastCheck&&!t.querySelector(r.fastCheck))return;let o;try{o=t.querySelectorAll(r.selector)}catch(t){return}o.forEach((t=>{if(r.transform){const o=r.transform(t,e);t.replaceWith(o),n++}}))}))})),Array.from(t.querySelectorAll("code > pre")).forEach((t=>{const e=t.parentElement;e&&"CODE"===e.tagName&&e.replaceWith(t)}));const i=Array.from(t.querySelectorAll("table.ltx_equation, table.ltx_eqn_table, table.ltx_equationgroup"));i.forEach((t=>{const r=t.querySelectorAll("math");if(0===r.length)return;const o=e.createDocumentFragment();r.forEach((r=>{var n;const i=r.getAttribute("alttext"),s=r.querySelector(\'annotation[encoding="application/x-tex"]\'),a=i||(null===(n=null==s?void 0:s.textContent)||void 0===n?void 0:n.trim())||"";if(!a)return;const l="block"===r.getAttribute("display")||t.classList.contains("ltx_equation")||t.classList.contains("ltx_equationgroup"),c=e.createElement("math");c.setAttribute("xmlns","http://www.w3.org/1998/Math/MathML"),c.setAttribute("display",l?"block":"inline"),c.setAttribute("data-latex",a),c.textContent=a,o.appendChild(c)})),o.childNodes.length>0&&(t.replaceWith(o),n++)}));const s=Array.from(t.querySelectorAll("span.ltx_note_outer"));s.forEach((t=>{t.remove(),n++}));const a=Array.from(t.querySelectorAll("a.ltx_ref"));a.forEach((t=>{if(t.querySelector("span.ltx_ref_tag, span.ltx_text.ltx_ref_tag")){const r=e.createTextNode(t.textContent||"");t.replaceWith(r),n++}}));const h=Array.from(t.querySelectorAll("table"));h.forEach((t=>{if(!t.parentNode)return;const r=Array.from(t.querySelectorAll("td, th")).filter((e=>(0,c.isDirectTableChild)(e,t)));if(r.some((t=>"TH"===t.tagName)))return;const o=Array.from(t.querySelectorAll("tr")).filter((e=>(0,c.isDirectTableChild)(e,t)));if(0===o.length)return;if(!o.every((t=>r.filter((e=>e.parentNode===t)).length<=1)))return;const i=e.createDocumentFragment();r.forEach((t=>{for(;t.firstChild;)i.appendChild(t.firstChild)})),t.replaceWith(i),n++})),t.querySelectorAll("video:not([controls])").forEach((t=>{t.setAttribute("controls","")}));const m=t.querySelectorAll("lite-youtube");m.forEach((t=>{const r=t.getAttribute("videoid");if(!r)return;const o=e.createElement("iframe");o.width="560",o.height="315",o.src=`https://www.youtube.com/embed/${r}`,o.title=t.getAttribute("videotitle")||"YouTube video player",o.frameBorder="0",o.allow="accelerometer; autoplay; clipboard-write; encrypted-media; gyroscope; picture-in-picture; web-share",o.setAttribute("allowfullscreen",""),t.replaceWith(o),n++})),(0,l.logDebug)(u,"Converted embedded elements:",n),function(t){var e;const r=t=>{let e=null;for(const r of t.children){if("code"!==r.tagName.toLowerCase())return null;if(e)return null;e=r}return e},n=t=>{var e;const r=(t.getAttribute("data-lang")||"").toLowerCase();if(r)return r;const n=(t.getAttribute("class")||"").match(/(?:^|\\s)language-([a-z0-9_+-]+)(?:\\s|$)/i);return(null===(e=null==n?void 0:n[1])||void 0===e?void 0:e.toLowerCase())||""},o=t.querySelectorAll(\'pre[data-verso-code="true"]\'),i=new Set;for(const t of o){const e=t.parentElement;e&&i.add(e)}for(const t of i){const o=Array.from(t.childNodes);for(let t=0;t<o.length;t++){const i=o[t];if(!(0,l.isElement)(i)||"pre"!==i.tagName.toLowerCase())continue;if("true"!==i.getAttribute("data-verso-code"))continue;const s=r(i);if(!s)continue;const a=n(s);if("lean"!==a&&"lean4"!==a)continue;const c=[{pre:i,code:s}],u=[];let d=t+1;for(;d<o.length;){const t=o[d];if((0,l.isTextNode)(t)&&!(t.textContent||"").trim()){u.push(t),d++;continue}if(!(0,l.isElement)(t)||"pre"!==t.tagName.toLowerCase())break;const e=t;if("true"!==e.getAttribute("data-verso-code"))break;const i=r(e);if(!i||n(i)!==a)break;c.push({pre:e,code:i}),d++}if(c.length<=1)continue;const h=c.map((({code:t})=>(t.textContent||"").replace(/\\r?\\n$/,""))).join("\\n").replace(/\\n{3,}/g,"\\n\\n").replace(/^\\n+|\\n+$/g,"");s.textContent=h;for(let t=1;t<c.length;t++)c[t].pre.remove();for(const t of u)null===(e=t.parentNode)||void 0===e||e.removeChild(t);t=d-1}}}(t)}(t,r,i))),o?(a("stripUnwantedAttributes",(()=>p(t,o))),a("removeTrailingHeadings",(()=>h(t))),a("stripExtraBrElements",(()=>g(t))),(0,l.logDebug)(u,"Debug mode: Skipping div flattening to preserve structure")):(a("flattenWrapperElements[1]",(()=>y(t,r))),a("stripUnwantedAttributes",(()=>p(t,o))),a("unwrapBareSpans",(()=>function(t){const e=Array.from(t.querySelectorAll("span")).reverse();let r=0;for(const t of e){if(!t.parentNode)continue;if(t.attributes.length>0)continue;const e=t.parentNode;if(e){for(;t.firstChild;)e.insertBefore(t.firstChild,t);t.remove(),r++}}r>0&&t.normalize();(0,l.logDebug)(u,"Unwrapped bare spans:",r)}(t))),a("unwrapSpecialLinks",(()=>{Array.from(t.querySelectorAll("code a")).forEach(f),Array.from(t.querySelectorAll(\'a[href^="javascript:"]\')).forEach(f),Array.from(t.querySelectorAll("a")).forEach((t=>{const e=t.getAttribute("href");if(!e||e.startsWith("#"))return;const n=Array.from(t.children).find((t=>/^H[1-6]$/.test(t.nodeName)));if(!n)return;const o=r.createElement("a");for(o.setAttribute("href",e);n.firstChild;)o.appendChild(n.firstChild);n.appendChild(o),f(t)})),Array.from(t.querySelectorAll(\'a[href^="#"]\')).forEach((t=>{t.querySelector("h1, h2, h3, h4, h5, h6")&&f(t)}))})),a("removeHeadingAnchors",(()=>(0,s.removeHeadingAnchors)(t))),a("removeObsoleteElements",(()=>t.querySelectorAll("object, embed, applet").forEach((t=>t.remove())))),a("removeEmptyElements",(()=>function(t){let e=0;const r=t=>{var e;if(n.ALLOWED_EMPTY_ELEMENTS.has(t.tagName.toLowerCase()))return!1;if("DIV"===t.tagName){const r=t.children;if(r.length>0){let t=!0;for(let n=0;n<r.length;n++){const o=r[n];if("SPAN"!==o.tagName){t=!1;break}const i=(null===(e=o.textContent)||void 0===e?void 0:e.trim())||"";if(","!==i&&""!==i&&" "!==i){t=!1;break}}if(t)return!0}}const r=t.textContent||"";if(r.trim().length>0||r.includes("\\xa0"))return!1;if(!t.hasChildNodes())return!0;const o=t.childNodes;for(let t=0;t<o.length;t++){const e=o[t];if((0,l.isElement)(e)&&"br"===e.tagName.toLowerCase())continue;if(!(0,l.isTextNode)(e))return!1;const r=e.textContent||"";if(r.trim().length>0||r.includes("\\xa0"))return!1}return!0},o=Array.from(t.querySelectorAll("*")).reverse();for(const t of o)t.parentNode&&r(t)&&(t.remove(),e++);(0,l.logDebug)(u,"Removed empty elements:",e)}(t))),a("removeTrailingHeadings",(()=>h(t))),a("removeOrphanedDividers[1]",(()=>m(t))),a("flattenWrapperElements[2]",(()=>y(t,r))),a("removeOrphanedDividers[2]",(()=>m(t))),a("stripExtraBrElements",(()=>g(t))),a("removeEmptyLines",(()=>function(t,e){let r=0;const o=Date.now(),i=t=>{var e;if((0,l.isElement)(t)){const e=t.tagName.toLowerCase();if("pre"===e||"code"===e)return}if(Array.from(t.childNodes).forEach(i),(0,l.isTextNode)(t)){const n=t.textContent||"";if(!n||/^[\\u200C\\u200B\\u200D\\u200E\\u200F\\uFEFF]*$/.test(n))null===(e=t.parentNode)||void 0===e||e.removeChild(t),r++;else{const e=n.replace(/[\\n\\r]+/g," ").replace(/\\t+/g," ").replace(/ {2,}/g," ").replace(/^[ ]+$/," ").replace(/\\s+([,.!?:;])/g,"$1").replace(/[\\u200B\\u200D\\u200E\\u200F\\uFEFF]+/g,"").replace(/(?:\\xA0){2,}/g,"\\xa0");e!==n&&(t.textContent=e,r+=n.length-e.length)}}},s=t=>{var o;if(!(0,l.isElement)(t))return;const i=t.tagName.toLowerCase();if("pre"===i||"code"===i)return;Array.from(t.childNodes).filter(l.isElement).forEach(s),t.normalize();const a="block"===(null===(o=(0,l.getComputedStyle)(t))||void 0===o?void 0:o.display),c=a?/^[\\n\\r\\t \\u200C\\u200B\\u200D\\u200E\\u200F\\uFEFF\\xA0]*$/:/^[\\n\\r\\t\\u200C\\u200B\\u200D\\u200E\\u200F\\uFEFF]*$/;for(;t.firstChild&&(0,l.isTextNode)(t.firstChild)&&(t.firstChild.textContent||"").match(c);)t.removeChild(t.firstChild),r++;for(;t.lastChild&&(0,l.isTextNode)(t.lastChild)&&(t.lastChild.textContent||"").match(c);)t.removeChild(t.lastChild),r++;if(!a&&n.INLINE_ELEMENTS.has(i)&&t.parentNode&&(r+=v(t,e,"leading"),r+=v(t,e,"trailing")),!a){const r=Array.from(t.childNodes);for(let n=0;n<r.length-1;n++){const o=r[n],i=r[n+1];if((0,l.isElement)(o)||(0,l.isElement)(i)){const r=i.textContent||"",n=o.textContent||"",s=r.match(/^[,.!?:;)\\]]/),a=n.match(/[,.!?:;(\\[]\\s*$/),c=(0,l.isTextNode)(o)&&(o.textContent||"").endsWith(" ")||(0,l.isTextNode)(i)&&(i.textContent||"").startsWith(" ");if(!s&&!a&&!c){const r=e.createTextNode(" ");t.insertBefore(r,i)}}}}};i(t),s(t);const a=Date.now();(0,l.logDebug)(u,"Removed empty lines:",{charactersRemoved:r,processingTime:`${(a-o).toFixed(2)}ms`})}(t,r))))},e.removeOrphanedDividers=m;const n=r(640),o=r(0),i=r(754),s=r(864),a=r(649),l=r(552),c=r(639);let u=!1;const d=[...o.mathRules,...i.codeBlockRules,...s.headingRules,...a.imageRules,{selector:\'div[data-testid^="paragraph"], div[role="paragraph"]\',element:"p",transform:(t,e)=>{const r=e.createElement("p");return(0,c.transferContent)(t,r),Array.from(t.attributes).forEach((t=>{n.ALLOWED_ATTRIBUTES.has(t.name)&&r.setAttribute(t.name,t.value)})),r}},{selector:\'div[role="list"]\',element:"ul",transform:(t,e)=>{var r;const n=t.querySelector(\'div[role="listitem"] .label\'),o=((null===(r=null==n?void 0:n.textContent)||void 0===r?void 0:r.trim())||"").match(/^\\d+\\)/),i=e.createElement(o?"ol":"ul");return t.querySelectorAll(\'div[role="listitem"]\').forEach((t=>{const r=e.createElement("li"),n=t.querySelector(".content");if(n){n.querySelectorAll(\'div[role="paragraph"]\').forEach((t=>{const r=e.createElement("p");(0,c.transferContent)(t,r),t.replaceWith(r)}));n.querySelectorAll(\'div[role="list"]\').forEach((t=>{var r;const n=t.querySelector(\'div[role="listitem"] .label\'),o=((null===(r=null==n?void 0:n.textContent)||void 0===r?void 0:r.trim())||"").match(/^\\d+\\)/),i=e.createElement(o?"ol":"ul");t.querySelectorAll(\'div[role="listitem"]\').forEach((t=>{const r=e.createElement("li"),n=t.querySelector(".content");if(n){n.querySelectorAll(\'div[role="paragraph"]\').forEach((t=>{const r=e.createElement("p");(0,c.transferContent)(t,r),t.replaceWith(r)})),(0,c.transferContent)(n,r)}i.appendChild(r)})),t.replaceWith(i)})),(0,c.transferContent)(n,r)}i.appendChild(r)})),i}},{selector:\'div[role="listitem"]\',element:"li",transform:(t,e)=>{const r=t.querySelector(".content");if(!r)return t;return r.querySelectorAll(\'div[role="paragraph"]\').forEach((t=>{const r=e.createElement("p");(0,c.transferContent)(t,r),t.replaceWith(r)})),r}}];function h(t){let e=0;const r=e=>{let n="",o=e.nextSibling;for(;o;)((0,l.isTextNode)(o)||(0,l.isElement)(o))&&(n+=o.textContent||""),o=o.nextSibling;if(n.trim())return!0;const i=e.parentElement;return!(!i||i===t)&&r(i)},n=Array.from(t.querySelectorAll("h1, h2, h3, h4, h5, h6")).reverse();for(const t of n){if(r(t))break;t.remove(),e++}e>0&&(0,l.logDebug)(u,"Removed trailing headings:",e)}function m(t){for(;;){let e=t.firstChild;for(;e&&(0,l.isTextNode)(e)&&!(e.textContent||"").trim();)e=e.nextSibling;if(!e||!(0,l.isElement)(e)||"hr"!==e.tagName.toLowerCase())break;e.remove()}for(;;){let e=t.lastChild;for(;e&&(0,l.isTextNode)(e)&&!(e.textContent||"").trim();)e=e.previousSibling;if(!e||!(0,l.isElement)(e)||"hr"!==e.tagName.toLowerCase())break;e.remove()}}function p(t,e){let r=0;const o=t=>{if("svg"===t.tagName.toLowerCase()||"http://www.w3.org/2000/svg"===t.namespaceURI)return;const o=Array.from(t.attributes),i=t.tagName.toLowerCase();o.forEach((o=>{const s=o.name.toLowerCase(),a=o.value;"id"===s&&(a.startsWith("fnref:")||a.startsWith("fn:")||"footnotes"===a)||"class"===s&&("code"===i&&a.startsWith("language-")||"footnote-backref"===a||/^callout(?:-|$)/.test(a))||(e?n.ALLOWED_ATTRIBUTES.has(s)||n.ALLOWED_ATTRIBUTES_DEBUG.has(s)||s.startsWith("data-")||(t.removeAttribute(o.name),r++):n.ALLOWED_ATTRIBUTES.has(s)||(t.removeAttribute(o.name),r++))}))};o(t),t.querySelectorAll("*").forEach(o),(0,l.logDebug)(u,"Stripped attributes:",r)}function f(t){for(var e;t.firstChild;)null===(e=t.parentNode)||void 0===e||e.insertBefore(t.firstChild,t);t.remove()}function g(t){let e=0;const r=Date.now(),n=Array.from(t.getElementsByTagName("br"));let o=[];const i=()=>{if(o.length>2)for(let t=2;t<o.length;t++)o[t].remove(),e++;o=[]};n.forEach((t=>{var e;let r=!1;if(o.length>0){const n=o[o.length-1];let i=t.previousSibling;for(;i&&(0,l.isTextNode)(i)&&!(null===(e=i.textContent)||void 0===e?void 0:e.trim());)i=i.previousSibling;i===n&&(r=!0)}r?o.push(t):(i(),o=[t])})),i();const s=Date.now();(0,l.logDebug)(u,"Standardized br elements:",{removed:e,processingTime:`${(s-r).toFixed(2)}ms`})}function v(t,e,r){const n="leading"===r?t.firstChild:t.lastChild;if(!n||!(0,l.isTextNode)(n))return 0;const o=n.textContent||"",i="leading"===r?o.replace(/^\\s+/,""):o.replace(/\\s+$/,"");if(i===o||!t.parentNode)return 0;n.textContent=i;const s="leading"===r?t.previousSibling:t.nextSibling;if(!(s&&(0,l.isTextNode)(s)&&("leading"===r?(s.textContent||"").endsWith(" "):(s.textContent||"").startsWith(" ")))){const n="leading"===r?t:t.nextSibling;t.parentNode.insertBefore(e.createTextNode(" "),n)}return 1}function y(t,e){let r=0;const o=Date.now();let i=!0;function s(t){var e;for(const r of t.childNodes){if((0,l.isTextNode)(r)&&(null===(e=r.textContent)||void 0===e?void 0:e.trim()))return!0;if((0,l.isElement)(r)&&n.INLINE_ELEMENTS.has(r.nodeName.toLowerCase()))return!0}return!1}const a=t=>{var e;const r=t.tagName.toLowerCase();if(n.PRESERVE_ELEMENTS.has(r))return!0;if(t.getAttribute("data-callout")||(null===(e=t.closest)||void 0===e?void 0:e.call(t,"[data-callout]")))return!0;const o=t.getAttribute("role");if(o&&["article","main","navigation","banner","contentinfo"].includes(o))return!0;const i=(0,c.getClassName)(t);if(i&&i.toLowerCase().match(/(?:article|main|content|footnote|reference|bibliography)/))return!0;return!!Array.from(t.children).some((t=>n.PRESERVE_ELEMENTS.has(t.tagName.toLowerCase())||"article"===t.getAttribute("role")||!!(0,c.getClassName)(t)&&(0,c.getClassName)(t).toLowerCase().match(/(?:article|main|content|footnote|reference|bibliography)/)))},d=t=>{var e;if(s(t))return!1;if(!(null===(e=t.textContent)||void 0===e?void 0:e.trim()))return!0;const r=Array.from(t.children);if(0===r.length)return!0;if(r.every((t=>n.BLOCK_LEVEL_ELEMENTS.has(t.tagName.toLowerCase()))))return!0;const o=(0,c.getClassName)(t).toLowerCase();if(/(?:wrapper|container|layout|row|col|grid|flex|outer|inner|content-area)/i.test(o))return!0;const i=Array.from(t.childNodes).filter((t=>{var e;return(0,l.isTextNode)(t)&&(null===(e=t.textContent)||void 0===e?void 0:e.trim())}));if(0===i.length)return!0;return!(!(r.length>0)||r.some((t=>{const e=t.tagName.toLowerCase();return n.INLINE_ELEMENTS.has(e)})))},h=o=>{var i,c;if(!o.parentNode||a(o))return!1;const u=o.tagName.toLowerCase();if(!n.ALLOWED_EMPTY_ELEMENTS.has(u)&&!o.children.length&&!(null===(i=o.textContent)||void 0===i?void 0:i.trim()))return o.remove(),r++,!0;if(o.parentElement===t){const t=Array.from(o.children);if(t.length>0&&!t.some((t=>{const e=t.tagName.toLowerCase();return n.INLINE_ELEMENTS.has(e)}))){const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}}if(d(o)){const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}const h=Array.from(o.childNodes);if(h.length>0&&h.every((t=>(0,l.isTextNode)(t)||(0,l.isElement)(t)&&n.INLINE_ELEMENTS.has(t.nodeName.toLowerCase())))&&(null===(c=o.textContent)||void 0===c?void 0:c.trim())){const t=e.createElement("p");for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}if(1===o.children.length){const t=o.firstElementChild,e=t.tagName.toLowerCase();if(n.BLOCK_ELEMENTS_SET.has(e)&&!a(t))return o.replaceWith(t),r++,!0}let m=0,p=o.parentElement;for(;p;){const t=p.tagName.toLowerCase();n.BLOCK_ELEMENTS_SET.has(t)&&m++,p=p.parentElement}if(m>0&&!s(o)){const t=e.createDocumentFragment();for(;o.firstChild;)t.appendChild(o.firstChild);return o.replaceWith(t),r++,!0}return!1},m=()=>{const e=Array.from(t.children).filter((t=>n.BLOCK_ELEMENTS_SET.has(t.tagName.toLowerCase())));let r=!1;return e.forEach((t=>{h(t)&&(r=!0)})),r},p=()=>{const e=Array.from(t.querySelectorAll(n.BLOCK_ELEMENTS_SELECTOR)).sort(((t,e)=>{const r=t=>{let e=0,r=t.parentElement;for(;r;){const t=r.tagName.toLowerCase();n.BLOCK_ELEMENTS_SET.has(t)&&e++,r=r.parentElement}return e};return r(e)-r(t)}));let r=!1;return e.forEach((t=>{h(t)&&(r=!0)})),r},f=()=>{const o=Array.from(t.querySelectorAll(n.BLOCK_ELEMENTS_SELECTOR));let i=!1;return o.forEach((t=>{const n=Array.from(t.children);if(n.length>0&&n.every((t=>"p"===t.tagName.toLowerCase()))||!a(t)&&d(t)){const n=e.createDocumentFragment();for(;t.firstChild;)n.appendChild(t.firstChild);t.replaceWith(n),r++,i=!0}})),i};do{i=!1,m()&&(i=!0),p()&&(i=!0),f()&&(i=!0)}while(i);const g=Date.now();(0,l.logDebug)(u,"Flattened wrapper elements:",{count:r,processingTime:`${(g-o).toFixed(2)}ms`})}},552(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.isElement=function(t){return t.nodeType===r},e.isTextNode=function(t){return t.nodeType===n},e.isCommentNode=function(t){return t.nodeType===o},e.getComputedStyle=function(t){const e=i(t.ownerDocument);return e&&"function"==typeof e.getComputedStyle?e.getComputedStyle(t):null},e.getWindow=i,e.textPreview=function(t){return(t.textContent||"").trim().substring(0,200)},e.logDebug=function(t,e,...r){t&&console.log("Defuddle:",e,...r)},e.countWords=function(t){if(!t)return 0;let e=0,r=0,n=!1;for(let o=0;o<t.length;o++){const i=t.charCodeAt(o);i>=12352&&i<=12447||i>=12448&&i<=12543||i>=13312&&i<=19903||i>=19968&&i<=40959||i>=63744&&i<=64255||i>=44032&&i<=55215?(e++,n=!1):i<=32?n=!1:n||(r++,n=!0)}return e+r};const r=1,n=3,o=8;function i(t){return t.defaultView?t.defaultView:t.ownerWindow?t.ownerWindow:t.window?t.window:null}},618(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.bbcodeToHtml=function(t){let e=t;return e=e.replace(/\\[h1\\]([\\s\\S]*?)\\[\\/h1\\]/gi,"<h1>$1</h1>"),e=e.replace(/\\[h2\\]([\\s\\S]*?)\\[\\/h2\\]/gi,"<h2>$1</h2>"),e=e.replace(/\\[h3\\]([\\s\\S]*?)\\[\\/h3\\]/gi,"<h3>$1</h3>"),e=e.replace(/\\[b\\]([\\s\\S]*?)\\[\\/b\\]/gi,"<strong>$1</strong>"),e=e.replace(/\\[i\\]([\\s\\S]*?)\\[\\/i\\]/gi,"<em>$1</em>"),e=e.replace(/\\[u\\]([\\s\\S]*?)\\[\\/u\\]/gi,"<u>$1</u>"),e=e.replace(/\\[s\\]([\\s\\S]*?)\\[\\/s\\]/gi,"<s>$1</s>"),e=e.replace(/\\[url=["\']?([^"\'\\]]+)["\']?\\]([\\s\\S]*?)\\[\\/url\\]/gi,((t,e,r)=>(0,n.isDangerousUrl)(e)?r:`<a href="${e}">${r}</a>`)),e=e.replace(/\\[img\\]([\\s\\S]*?)\\[\\/img\\]/gi,\'<img src="$1">\'),e=e.replace(/\\[previewyoutube=["\']?([^;\'"]+)[^"\'\\]]*["\']?\\]\\[\\/previewyoutube\\]/gi,\'<img src="https://www.youtube.com/watch?v=$1">\'),e=e.replace(/\\[list\\]([\\s\\S]*?)\\[\\/list\\]/gi,((t,e)=>`<ul>${e.replace(/\\[\\*\\]([\\s\\S]*?)(?=\\[\\*\\]|\\[\\/list\\]|$)/gi,"<li>$1</li>")}</ul>`)),e=e.replace(/\\[olist\\]([\\s\\S]*?)\\[\\/olist\\]/gi,((t,e)=>`<ol>${e.replace(/\\[\\*\\]([\\s\\S]*?)(?=\\[\\*\\]|\\[\\/olist\\]|$)/gi,"<li>$1</li>")}</ol>`)),e=e.replace(/\\[quote(?:=[^\\]]+)?\\]([\\s\\S]*?)\\[\\/quote\\]/gi,"<blockquote>$1</blockquote>"),e=e.replace(/\\[code\\]([\\s\\S]*?)\\[\\/code\\]/gi,"<pre><code>$1</code></pre>"),e=e.replace(/\\[spoiler\\]([\\s\\S]*?)\\[\\/spoiler\\]/gi,"<details><summary>Spoiler</summary>$1</details>"),e=e.replace(/\\[p\\]([\\s\\S]*?)\\[\\/p\\]/gi,((t,e)=>`<p>${e.replace(/\\n/g,"<br>")}</p>`)),e=e.replace(/\\n/g,"<br>"),e=e.replace(/\\[[^\\]]+\\]/g,""),e};const n=r(639)},77(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.buildContentHtml=function(t,e,r){return`\\n\\t\\t<div class="${t} post">\\n\\t\\t\\t<div class="post-content">\\n\\t\\t\\t\\t${e}\\n\\t\\t\\t</div>\\n\\t\\t</div>\\n\\t\\t${r?`\\n\\t\\t\\t<hr>\\n\\t\\t\\t<div class="${t} comments">\\n\\t\\t\\t\\t<h2>Comments</h2>\\n\\t\\t\\t\\t${r}\\n\\t\\t\\t</div>\\n\\t\\t`:""}\\n\\t`.trim()},e.buildCommentTree=function(t){var e,r,n;const i=[],s=[];for(const a of t){const t=null!==(e=a.depth)&&void 0!==e?e:0;if(0===t){for(;s.length>0;)i.push("</blockquote>"),s.pop();i.push("<blockquote>"),s.push(0)}else{if(t<(null!==(r=s[s.length-1])&&void 0!==r?r:-1))for(;s.length>0&&s[s.length-1]>=t;)i.push("</blockquote>"),s.pop();t>(null!==(n=s[s.length-1])&&void 0!==n?n:-1)&&(i.push("<blockquote>"),s.push(t))}i.push(o(a))}for(;s.length>0;)i.push("</blockquote>"),s.pop();return i.join("")},e.buildComment=o;const n=r(639);function o(t){const e=`<span class="comment-author"><strong>${(0,n.escapeHtml)(t.author)}</strong></span>`,r=t.url&&!(0,n.isDangerousUrl)(t.url)?t.url:"";return`<div class="comment">\\n\\t<div class="comment-metadata">\\n\\t\\t${e} \\xb7 ${r?`<a href="${(0,n.escapeHtml)(r)}" class="comment-link">${(0,n.escapeHtml)(t.date)}</a>`:`<span class="comment-date">${(0,n.escapeHtml)(t.date)}</span>`}${t.score?` \\xb7 <span class="comment-points">${(0,n.escapeHtml)(t.score)}</span>`:""}\\n\\t</div>\\n\\t<div class="comment-content">${t.content}</div>\\n</div>`}},639(t,e){Object.defineProperty(e,"__esModule",{value:!0}),e.transferContent=function(t,e){if("replaceChildren"in e)e.replaceChildren();else for(;e.firstChild;)e.removeChild(e.firstChild);for(;t.firstChild;)e.appendChild(t.firstChild)},e.serializeHTML=function(t){return t.innerHTML},e.decodeHTMLEntities=function(t,e){const r=t.createElement("textarea");return r.innerHTML=e,r.value},e.escapeHtml=function(t){return t.replace(/&/g,"&amp;").replace(/</g,"&lt;").replace(/>/g,"&gt;").replace(/"/g,"&quot;")},e.getClassName=function(t){return"string"==typeof t.className?t.className:t.getAttribute("class")||""},e.isDangerousUrl=function(t){const e=t.replace(/[\\s\\u0000-\\u001F]+/g,"").toLowerCase();return e.startsWith("javascript:")||e.startsWith("data:text/html")},e.isDirectTableChild=function(t,e){let r=t.parentNode;for(;r&&r!==e;){if("TABLE"===r.nodeName)return!1;r=r.parentNode}return r===e},e.parseHTML=function(t,e){if(!e)return t.createDocumentFragment();const r=t.createElement("template");if(r.innerHTML=e,r.content)return r.content;const n=t.createElement("div");n.innerHTML=e;const o=t.createDocumentFragment();for(;n.firstChild;)o.appendChild(n.firstChild);return o}},497(t,e,r){Object.defineProperty(e,"__esModule",{value:!0}),e.formatTimestamp=o,e.buildTranscript=function(t,e,r=[]){const i=[...r].sort(((t,e)=>t.start-e.start));let s=0;const a=[],l=[];for(const t of e){for(;s<i.length&&i[s].start<=t.start;){const t=i[s].title;a.push(`<h3>${(0,n.escapeHtml)(t)}</h3>`),l.length>0&&l.push(""),l.push(`### ${t}`),l.push(""),s++}const e=o(t.start),r=void 0!==t.speaker?` speaker-${t.speaker}`:"",c=`<strong><span class="timestamp" data-timestamp="${t.start}">${e}</span></strong>`;a.push(`<p class="transcript-segment${r}">${c} \\xb7 ${(0,n.escapeHtml)(t.text)}</p>`),t.speakerChange&&l.length>0&&l.push(""),l.push(`**${e}** \\xb7 ${t.text}`)}return{html:`<div class="${t} transcript">\\n<h2>Transcript</h2>\\n${a.join("\\n")}\\n</div>`,text:l.join("\\n")}};const n=r(639);function o(t){const e=Math.floor(t/3600),r=Math.floor(t%3600/60),n=Math.floor(t%60);return e>0?`${e}:${String(r).padStart(2,"0")}:${String(n).padStart(2,"0")}`:`${r}:${String(n).padStart(2,"0")}`}}},e={};function r(n){var o=e[n];if(void 0!==o)return o.exports;var i=e[n]={exports:{}};return t[n].call(i.exports,i,i.exports,r),i.exports}var n={};return(()=>{var t=n;const e=r(628);t.default=e.Defuddle})(),n=n.default})()));})()';
5
- export {
6
- DEFUDDLE_BUNDLE
7
- };