!i.includes(e)).join(" ").length/n.join(" ").length:0},_checkByline:function(e,t){if(this._articleByline)return!1;if(void 0!==e.getAttribute)var i=e.getAttribute("rel"),n=e.getAttribute("itemprop");return!!(("author"===i||n&&-1!==n.indexOf("author")||this.REGEXPS.byline.test(t))&&this._isValidByline(e.textContent))&&(this._articleByline=e.textContent.trim(),!0)},_getNodeAncestors:function(e,t){t=t||0;for(var i=0,n=[];e.parentNode&&(n.push(e.parentNode),!t||++i!==t);)e=e.parentNode;return n},_grabArticle:function(e){this.log("**** grabArticle ****");var t=this._doc,i=null!==e;if(!(e=e||this._doc.body))return this.log("No body found in document. Abort."),null;for(var n=e.innerHTML;;){this.log("Starting grabArticle loop");var r,o=this._flagIsActive(this.FLAG_STRIP_UNLIKELYS),a=[],l=this._doc.documentElement;let $=!0;for(;l;){"HTML"===l.tagName&&(this._articleLang=l.getAttribute("lang"));var s=l.className+" "+l.id;if(!this._isProbablyVisible(l)){this.log("Removing hidden node - "+s),l=this._removeAndGetNext(l);continue}if("true"==l.getAttribute("aria-modal")&&"dialog"==l.getAttribute("role")||this._checkByline(l,s)){l=this._removeAndGetNext(l);continue}if($&&this._headerDuplicatesTitle(l)){this.log("Removing header: ",l.textContent.trim(),this._articleTitle.trim()),$=!1,l=this._removeAndGetNext(l);continue}if(o){if(this.REGEXPS.unlikelyCandidates.test(s)&&!this.REGEXPS.okMaybeItsACandidate.test(s)&&!this._hasAncestorTag(l,"table")&&!this._hasAncestorTag(l,"code")&&"BODY"!==l.tagName&&"A"!==l.tagName){this.log("Removing unlikely candidate - "+s),l=this._removeAndGetNext(l);continue}if(this.UNLIKELY_ROLES.includes(l.getAttribute("role"))){this.log("Removing content with role "+l.getAttribute("role")+" - "+s),l=this._removeAndGetNext(l);continue}}if(("DIV"===l.tagName||"SECTION"===l.tagName||"HEADER"===l.tagName||"H1"===l.tagName||"H2"===l.tagName||"H3"===l.tagName||"H4"===l.tagName||"H5"===l.tagName||"H6"===l.tagName)&&this._isElementWithoutContent(l)){l=this._removeAndGetNext(l);continue}if(-1!==this.DEFAULT_TAGS_TO_SCORE.indexOf(l.tagName)&&a.push(l),"DIV"===l.tagName){for(var c=null,d=l.firstChild;d;){var h=d.nextSibling;if(this._isPhrasingContent(d))null!==c?c.appendChild(d):this._isWhitespace(d)||(c=t.createElement("p"),l.replaceChild(c,d),c.appendChild(d));else if(null!==c){for(;c.lastChild&&this._isWhitespace(c.lastChild);)c.removeChild(c.lastChild);c=null}d=h}if(this._hasSingleTagInsideElement(l,"P")&&.25>this._getLinkDensity(l)){var u=l.children[0];l.parentNode.replaceChild(u,l),l=u,a.push(l)}else this._hasChildBlockElement(l)||(l=this._setNodeTag(l,"P"),a.push(l))}l=this._getNextNode(l)}var f=[];this._forEachNode(a,function(e){if(e.parentNode&&void 0!==e.parentNode.tagName){var t,i=this._getInnerText(e);if(!(i.length<25)){var n=this._getNodeAncestors(e,5);0!==n.length&&(t=1+i.split(",").length+Math.min(Math.floor(i.length/100),3),this._forEachNode(n,function(e,i){if(e.tagName&&e.parentNode&&void 0!==e.parentNode.tagName){if(void 0===e.readability&&(this._initializeNode(e),f.push(e)),0===i)var n=1;else n=1===i?2:3*i;e.readability.contentScore+=t/n}}))}}});for(var g=[],m=0,p=f.length;mE.readability.contentScore){g.splice(v,0,_),g.length>this._nbTopCandidates&&g.pop();break}}}var b=g[0]||null,N=!1;if(null===b||"BODY"===b.tagName){for(b=t.createElement("DIV"),N=!0;e.firstChild;)this.log("Moving child out:",e.firstChild),b.appendChild(e.firstChild);e.appendChild(b),this._initializeNode(b)}else if(b){for(var T=[],A=1;A=.75&&T.push(this._getNodeAncestors(g[A]));if(T.length>=3)for(r=b.parentNode;"BODY"!==r.tagName;){for(var S=0,C=0;C=3){b=r;break}r=r.parentNode}b.readability||this._initializeNode(b),r=b.parentNode;for(var L=b.readability.contentScore,x=L/3;"BODY"!==r.tagName;){if(!r.readability){r=r.parentNode;continue}var w=r.readability.contentScore;if(wL){b=r;break}L=r.readability.contentScore,r=r.parentNode}for(r=b.parentNode;"BODY"!=r.tagName&&1==r.children.length;)r=(b=r).parentNode;b.readability||this._initializeNode(b)}var O=t.createElement("DIV");i&&(O.id="readability-content");for(var R=Math.max(10,.2*b.readability.contentScore),I=(r=b.parentNode).children,P=0,D=I.length;P=R)B=!0;else if("P"===M.nodeName){var k=this._getLinkDensity(M),U=this._getInnerText(M),G=U.length;G>80&&k<.25?B=!0:G<80&&G>0&&0===k&&-1!==U.search(/\.( |$)/)&&(B=!0)}}B&&(this.log("Appending node:",M),-1===this.ALTER_TO_DIV_EXCEPTIONS.indexOf(M.nodeName)&&(this.log("Altering sibling:",M,"to div."),M=this._setNodeTag(M,"DIV")),O.appendChild(M),I=r.children,P-=1,D-=1)}if(this._debug&&this.log("Article content pre-prep: "+O.innerHTML),this._prepArticle(O),this._debug&&this.log("Article content post-prep: "+O.innerHTML),N)b.id="readability-page-1",b.className="page";else{var j=t.createElement("DIV");for(j.id="readability-page-1",j.className="page";O.firstChild;)j.appendChild(O.firstChild);O.appendChild(j)}this._debug&&this.log("Article content after paging: "+O.innerHTML);var W=!0,V=this._getInnerText(O,!0).length;if(V0&&e.length<100},_unescapeHtmlEntities:function(e){if(!e)return e;var t=this.HTML_ESCAPE_MAP;return e.replace(/&(quot|amp|apos|lt|gt);/g,function(e,i){return t[i]}).replace(/(?:x([0-9a-z]{1,4})|([0-9]{1,4}));/gi,function(e,t,i){return String.fromCharCode(parseInt(t||i,t?16:10))})},_getJSONLD:function(e){var t,i=this._getAllNodesWithTag(e,["script"]);return this._forEachNode(i,function(e){if(!t&&"application/ld+json"===e.getAttribute("type"))try{var i=e.textContent.replace(/^\s*\s*$/g,""),n=JSON.parse(i);if(!n["@context"]||!n["@context"].match(/^https?\:\/\/schema\.org$/)||(!n["@type"]&&Array.isArray(n["@graph"])&&(n=n["@graph"].find(function(e){return(e["@type"]||"").match(this.REGEXPS.jsonLdArticleTypes)})),!n||!n["@type"]||!n["@type"].match(this.REGEXPS.jsonLdArticleTypes)))return;if(t={},"string"==typeof n.name&&"string"==typeof n.headline&&n.name!==n.headline){var r=this._getArticleTitle(),o=this._textSimilarity(n.name,r)>.75;this._textSimilarity(n.headline,r)>.75&&!o?t.title=n.headline:t.title=n.name}else"string"==typeof n.name?t.title=n.name.trim():"string"==typeof n.headline&&(t.title=n.headline.trim());n.author&&("string"==typeof n.author.name?t.byline=n.author.name.trim():Array.isArray(n.author)&&n.author[0]&&"string"==typeof n.author[0].name&&(t.byline=n.author.filter(function(e){return e&&"string"==typeof e.name}).map(function(e){return e.name.trim()}).join(", "))),"string"==typeof n.description&&(t.excerpt=n.description.trim()),n.publisher&&"string"==typeof n.publisher.name&&(t.siteName=n.publisher.name.trim());return}catch(e){this.log(e.message)}}),t||{}},_getArticleMetadata:function(e){var t={},i={},n=this._doc.getElementsByTagName("meta"),r=/\s*(dc|dcterm|og|twitter)\s*:\s*(author|creator|description|title|site_name)\s*/gi,o=/^\s*(?:(dc|dcterm|og|twitter|weibo:(article|webpage))\s*[\.:]\s*)?(author|creator|description|title|site_name)\s*$/i;return this._forEachNode(n,function(e){var t=e.getAttribute("name"),n=e.getAttribute("property"),a=e.getAttribute("content");if(a){var l=null,s=null;n&&(l=n.match(r))&&(i[s=l[0].toLowerCase().replace(/\s/g,"")]=a.trim()),!l&&t&&o.test(t)&&(s=t,a&&(i[s=s.toLowerCase().replace(/\s/g,"").replace(/\./g,":")]=a.trim()))}}),t.title=e.title||i["dc:title"]||i["dcterm:title"]||i["og:title"]||i["weibo:article:title"]||i["weibo:webpage:title"]||i.title||i["twitter:title"],t.title||(t.title=this._getArticleTitle()),t.byline=e.byline||i["dc:creator"]||i["dcterm:creator"]||i.author,t.excerpt=e.excerpt||i["dc:description"]||i["dcterm:description"]||i["og:description"]||i["weibo:article:description"]||i["weibo:webpage:description"]||i.description||i["twitter:description"],t.siteName=e.siteName||i["og:site_name"],t.title=this._unescapeHtmlEntities(t.title),t.byline=this._unescapeHtmlEntities(t.byline),t.excerpt=this._unescapeHtmlEntities(t.excerpt),t.siteName=this._unescapeHtmlEntities(t.siteName),t},_isSingleImage:function(e){return"IMG"===e.tagName||1===e.children.length&&""===e.textContent.trim()&&this._isSingleImage(e.children[0])},_unwrapNoscriptImages:function(e){var t=Array.from(e.getElementsByTagName("img"));this._forEachNode(t,function(e){for(var t=0;t0)||!(r>i));){if(e.parentNode.tagName===t&&(!n||n(e.parentNode)))return!0;e=e.parentNode,r++}return!1},_getRowAndColumnCount:function(e){for(var t=0,i=0,n=e.getElementsByTagName("tr"),r=0;r0){n._readabilityDataTable=!0;continue}if(["col","colgroup","tfoot","thead","th"].some(function(e){return!!n.getElementsByTagName(e)[0]})){this.log("Data table because found data-y descendant"),n._readabilityDataTable=!0;continue}if(n.getElementsByTagName("table")[0]){n._readabilityDataTable=!1;continue}var o=this._getRowAndColumnCount(n);if(o.rows>=10||o.columns>4){n._readabilityDataTable=!0;continue}n._readabilityDataTable=o.rows*o.columns>10}},_fixLazyImages:function(e){this._forEachNode(this._getAllNodesWithTag(e,["img","picture","figure"]),function(e){if(e.src&&this.REGEXPS.b64DataUrl.test(e.src)){if("image/svg+xml"===this.REGEXPS.b64DataUrl.exec(e.src)[1])return;for(var t=!1,i=0;in+=this._getInnerText(e,!0).length),n/i},_cleanConditionally:function(e,t){this._flagIsActive(this.FLAG_CLEAN_CONDITIONALLY)&&this._removeNodes(this._getAllNodesWithTag(e,[t]),function(e){var i=function(e){return e._readabilityDataTable},n="ul"===t||"ol"===t;if(!n){var r=0,o=this._getAllNodesWithTag(e,["ul","ol"]);this._forEachNode(o,e=>r+=this._getInnerText(e).length),n=r/this._getInnerText(e).length>.9}if("table"===t&&i(e)||this._hasAncestorTag(e,"table",-1,i)||this._hasAncestorTag(e,"code"))return!1;var a=this._getClassWeight(e);if(this.log("Cleaning Conditionally",e),a+0<0)return!0;if(10>this._getCharCount(e,",")){for(var l=e.getElementsByTagName("p").length,s=e.getElementsByTagName("img").length,c=e.getElementsByTagName("li").length-100,d=e.getElementsByTagName("input").length,h=this._getTextDensity(e,["h1","h2","h3","h4","h5","h6"]),u=0,f=this._getAllNodesWithTag(e,["object","embed","iframe"]),g=0;g1&&l/s<.5&&!this._hasAncestorTag(e,"figure")||!n&&c>l||d>Math.floor(l/3)||!n&&h<.9&&_<25&&(0===s||s>2)&&!this._hasAncestorTag(e,"figure")||!n&&a<25&&p>.2||a>=25&&p>.5||1===u&&_<75||u>1;if(n&&y){for(var v=0;v1)return y;if(s==e.getElementsByTagName("li").length)return!1}return y}return!1})},_cleanMatchedNodes:function(e,t){for(var i=this._getNextNode(e,!0),n=this._getNextNode(e);n&&n!=i;)n=t.call(this,n,n.className+" "+n.id)?this._removeAndGetNext(n):this._getNextNode(n)},_cleanHeaders:function(e){let t=this._getAllNodesWithTag(e,["h1","h2"]);this._removeNodes(t,function(e){let t=0>this._getClassWeight(e);return t&&this.log("Removing header with low class weight:",e),t})},_headerDuplicatesTitle:function(e){if("H1"!=e.tagName&&"H2"!=e.tagName)return!1;var t=this._getInnerText(e,!1);return this.log("Evaluating similarity of header:",t,this._articleTitle),this._textSimilarity(this._articleTitle,t)>.75},_flagIsActive:function(e){return(this._flags&e)>0},_removeFlag:function(e){this._flags=this._flags&~e},_isProbablyVisible:function(e){return(!e.style||"none"!=e.style.display)&&!e.hasAttribute("hidden")&&(!e.hasAttribute("aria-hidden")||"true"!=e.getAttribute("aria-hidden")||e.className&&e.className.indexOf&&-1!==e.className.indexOf("fallback-image"))},parse:function(){if(this._maxElemsToParse>0){var e=this._doc.getElementsByTagName("*").length;if(e>this._maxElemsToParse)throw Error("Aborting parsing document; "+e+" elements found")}this._unwrapNoscriptImages(this._doc);var t=this._disableJSONLD?{}:this._getJSONLD(this._doc);this._removeScripts(this._doc),this._prepDocument();var i=this._getArticleMetadata(t);this._articleTitle=i.title;var n=this._grabArticle();if(!n)return null;if(this.log("Grabbed: "+n.innerHTML),this._postProcessContent(n),!i.excerpt){var r=n.getElementsByTagName("p");r.length>0&&(i.excerpt=r[0].textContent.trim())}var o=n.textContent;return{title:this._articleTitle,byline:i.byline||this._articleByline,dir:this._articleDir,lang:this._articleLang,content:this._serializer(n),textContent:o,length:o.length,excerpt:i.excerpt,siteName:i.siteName||this._articleSiteName}}},e.exports=t},396:function(e,t,i){e.exports={Readability:i(238),isProbablyReaderable:i(804)}},900:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.cloneNode=function(e,t){let n=(e=e.cloneNode(!0)).querySelectorAll("img");if(t.images)for(let e of n)e.src=e.currentSrc;else for(let e of n)e.remove();if(!t.styles)for(let t of e.querySelectorAll("button, form, select, input, textarea"))t.remove();for(let t of e.querySelectorAll(i.join(",")))t.remove();return e};let i=["script","noscript"]},399:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.toJpeg=function(e,t,i){return n(this,void 0,void 0,function*(){return i.raster=!0,d(e,t,i).then(e=>null==e?void 0:e.toDataURL("image/jpeg",i.quality||1))})},t.toBlob=function(e,t,i){return i.raster=!0,d(e,t,i).then(e=>e&&(0,l.canvasToBlob)(e))},t.toPng=function(e,t,i){return i.raster=!0,d(e,t,i).then(function(e){return null==e?void 0:e.toDataURL()})},t.toSvg=function(e,t,i){return h(e,t,i.width||(0,l.width)(e),i.height||(0,l.height)(e))},t.getInlinedNode=function(e,t){return n(this,void 0,void 0,function*(){let{fonts:i,images:n,stylesheets:r,inlineImages:c}=t.inlineOptions||{},d=(0,s.cloneNode)(e,{images:n,styles:r});if(!(!d||d instanceof Text)){var h,u;return i&&(d=yield(h=d,u=t.fetchOptions,(0,o.resolveAll)(u).then(function(e){let t=document.createElement("style");return h.appendChild(t),t.appendChild(document.createTextNode(e)),h}))),c&&(yield(0,a.inlineAllImages)(d,t.fetchOptions)),function(e){for(let t of e.querySelectorAll("*"))!(!(t instanceof HTMLElement)||(0,l.isSVGElement)(t))&&t instanceof HTMLAnchorElement&&(t.href=t.href.startsWith("http")?t.href:document.location.origin+t.href)}(d),d}})};let r=i(113),o=i(536),a=i(307),l=i(132),s=i(900),c={inlineOptions:{}};function d(e,t,i){return n(this,void 0,void 0,function*(){let n="data:image/svg+xml; charset=utf8, "+encodeURIComponent(h(e,t,(i=Object.assign(Object.assign({},c),i)).width||(0,l.width)(e),i.height||(0,l.height)(e)));return(0,r.createImage)(n,i.fetchOptions).then((0,l.delay)(0)).then(function(t){if(!t)return null;t.setAttribute("crossorigin","anonymous");let n="number"!=typeof i.scale?1:i.scale,r=function(e,t,i){let n=document.createElement("canvas");if(n.width=(i.width||(0,l.width)(e))*t,n.height=(i.height||(0,l.height)(e))*t,i.backgroundColor){let e=n.getContext("2d");if(!e)return null;e.fillStyle=i.backgroundColor,e.fillRect(0,0,n.width,n.height)}return n}(e,n,i),o=null==r?void 0:r.getContext("2d");return o?(o.imageSmoothingEnabled=!1,o.scale(n,n),o.drawImage(t,0,0),r):null})})}function h(e,t,i,n){for(let t of(e.setAttribute("xmlns","http://www.w3.org/1999/xhtml"),e.querySelectorAll("img, svg, video, iframe")))for(let e of t.getAttributeNames())e.match(/\W/)&&t.removeAttribute(e);let r=new XMLSerializer().serializeToString(e);return'"}},113:function(e,t){"use strict";var i=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};function n(e,t){if(!e.startsWith("http"))return e;if((null==t?void 0:t.noCache)&&(e+=(/\?/.test(e)?"&":"?")+Date.now()),(null==t?void 0:t.bypassCors)&&(null==t?void 0:t.corsHost)){if(e.startsWith(t.corsHost))return e;e=`${t.corsHost}/${e}`}return e}Object.defineProperty(t,"__esModule",{value:!0}),t.fetchResource=function(e,t){return i(this,void 0,void 0,function*(){if(!e)return null;let i=yield fetch(n(e,t));if(!i.ok)return"";let r=yield i.blob(),o=new FileReader;return o.readAsDataURL(r),new Promise(e=>{o.addEventListener("loadend",()=>{"string"==typeof o.result&&e(o.result)})})})},t.createImage=function(e,t){return"data:,"===e?Promise.resolve(null):new Promise(function(i,r){let o=new Image;o.crossOrigin=(null==t?void 0:t.crossOrigin)||null,o.onload=function(){i(o)},o.onerror=()=>r(Error("Failed to render image.")),o.src=n(e,t)})},t.reloadImage=function(e,t){return t.corsHost&&e.currentSrc.startsWith(t.corsHost)?Promise.resolve(null):(t.noCache=!0,new Promise(function(i,r){e.crossOrigin=t.crossOrigin||null,e.onload=function(){i(e)},e.onerror=t=>{console.error("Failed to load image",e.currentSrc),r(t)},e.src=n(e.currentSrc,t)}))},t.constructUrl=n},536:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.resolveAll=function(e){return n(this,void 0,void 0,function*(){let t=a(function(e){let t=[];for(let i of e)try{let e=a(Array.from(i.cssRules));e.length>3&&t.push(e[0])}catch(e){e instanceof Error&&console.log("Error while reading CSS rules from "+i.href,e.toString())}return t}(document.styleSheets)).map(o),i=[];for(let n of t)i.push((yield n.resolve(e)));return i.join("\n")})};let r=i(812);function o(e){return{resolve:function(t){let i=(e.parentStyleSheet||{}).href||void 0;return(0,r.inlineAll)(e.cssText,t,i)},src:function(){return e.style.getPropertyValue("src")}}}function a(e){return e.filter(function(e){return e.type===CSSRule.FONT_FACE_RULE}).filter(function(e){return(0,r.shouldProcess)(e.style.getPropertyValue("src"))})}},307:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.inlineAllImages=function(e,t){return n(this,void 0,void 0,function*(){let i=e.querySelectorAll("img"),a=[];for(let e=0;econsole.error(e))})};let r=i(113),o=i(132)},769:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.clipPage=function(e,t,i){return n(this,void 0,void 0,function*(){let{body:n,head:r}=yield E(e,i,t);if(!n||!r)return null;let o=y(r,n).documentElement.outerHTML;return`
${o}`})},t.clipArticle=function(e,t){return n(this,void 0,void 0,function*(){let{body:i,head:n}=yield E(e,t);if(!i||!n)return null;let o=y(n,i),a=new r.Readability(o);a.PRESENTATIONAL_ATTRIBUTES=["align","background","bgcolor","border","cellpadding","cellspacing","frame","hspace","rules","valign","vspace"];let l=a.parse();return`${(null==n?void 0:n.outerHTML)||""}${(null==l?void 0:l.content)||""}`})},t.cleanup=v,t.clipScreenshot=function(e){return n(this,arguments,void 0,function*(e,t="jpeg",i){let n=b(i),{body:r,head:o}=yield E(document,i,!1);if(!r||!o)return null;let a="jpeg"===t?l.toJpeg:"png"===t?l.toPng:"svg"===t?l.toSvg:l.toBlob,s=yield a(r,o,{quality:1,backgroundColor:"white",width:document.body.scrollWidth,height:document.body.scrollHeight,fetchOptions:n,inlineOptions:{inlineImages:!0,fonts:!0,images:!0,stylesheets:!0}});return"jpeg"===t||"png"===t?`
`:s})},t.enterNodeSelectionMode=function(e,t){let i;return setTimeout(()=>{e.body.addEventListener("click",_),e.body.addEventListener("mouseout",p),e.body.addEventListener("mouseover",m)},0),i=`.${c} {
border: 1px solid green;
background-color: rgb(0,0,0,0.05);
cursor: pointer;
}
.${d} {
border: 2px solid green;
cursor: pointer;
}
.${h} {
position: fixed;
bottom: 0px;
right: 0px;
z-index: ${Number.MAX_VALUE};
}`,(0,o.injectCss)(i,"nn-clipper-styles"),new Promise((e,i)=>{var r,o;let s;r=()=>n(this,void 0,void 0,function*(){v();let i=document.querySelectorAll(`.${d}`),{head:n}=yield E(document,t,!1),r=document.createElement("html");r.append(n);let o=document.createElement("body");for(let e of(r.append(o),i)){e.classList.remove(d);let i=yield(0,l.getInlinedNode)(e,{raster:!1,fetchOptions:b(t),inlineOptions:Object.assign(Object.assign({},f),{images:null==t?void 0:t.images,inlineImages:null==t?void 0:t.inlineImages})});i&&o.appendChild(i)}e(null==r?void 0:r.outerHTML)}),o=()=>i("Cancelled."),(s=document.createElement("div")).classList.add(h),setTimeout(()=>{document.body.appendChild(s)},0),(0,a.app)({init:{isClipping:!1},view:({isClipping:e})=>(0,a.h)("div",{style:{padding:"10px",backgroundColor:"white",borderRadius:"5px",boxShadow:"0px 0px 10px 0px #00000038"}},[(0,a.h)("p",{style:{marginBottom:"0px",fontSize:"18px"}},[(0,a.text)("Notesnook Web Clipper")]),(0,a.h)("p",{style:{margin:"0px",marginBottom:"5px",fontStyle:"italic"}},[e?(0,a.text)("Clipping selected elements. Please wait..."):(0,a.text)("Click on any element to select it.")]),(0,a.h)("div",{style:{display:"flex",alignItems:"center"}},[(0,a.h)("button",{onclick:e=>[Object.assign(Object.assign({},e),{isClipping:!0}),e=>{null==r||r(),e({isClipping:!1})}],style:{marginRight:"5px"},disabled:e},[e?(0,a.text)("Clipping..."):(0,a.text)("Clip")]),(0,a.h)("button",{onclick:e=>(v(),null==o||o(),e),disabled:e},[(0,a.text)("Cancel")])])]),node:s})})};let r=i(396),o=i(132),a=i(673),l=i(399),s=i(707),c="nn-node-selection--hover",d="nn-node-selection--selected",h="nn-node-selection-container",u=[d,h],f={fonts:!1,images:!1,stylesheets:!0};function g(e){for(let t of u)if(e.classList.contains(t)||e.closest(`.${t}`))return!1;return!0}let m=e=>{let t=e.target;!t.classList.contains(c)&&g(t)&&t.classList.add(c)},p=e=>{let t=e.target;t.classList.contains(c)&&t.classList.remove(c)},_=e=>{e.preventDefault();let t=e.target;t.classList.contains(d)?t.classList.remove(d):g(t)&&t.classList.add(d)};function y(e,t){let i=document.implementation.createHTMLDocument();return i.documentElement.replaceChildren(e,t),i}function v(){setTimeout(()=>{var e;document.querySelectorAll(`.${d}`).forEach(e=>{e instanceof HTMLElement&&e.classList.remove(d)}),document.querySelectorAll(`.${h}`).forEach(e=>e.remove()),(e=document).body.removeEventListener("mouseout",p),e.body.removeEventListener("mouseover",m),document.body.removeEventListener("click",_)},0)}function E(e,t){return n(this,arguments,void 0,function*(e,t,i=!1){let n=b(t),r=yield(0,l.getInlinedNode)(e.body,{raster:!0,fetchOptions:n,inlineOptions:{fonts:!1,inlineImages:null==t?void 0:t.inlineImages,images:null==t?void 0:t.images,stylesheets:null==t?void 0:t.styles},filter:e=>{var t;let n,r,o,a,l,s,c,d,h,u,f,g,m,p,_,y;return!i||(((t=e).nodeType===Node.TEXT_NODE||!t.getBoundingClientRect)&&t.parentElement&&(t=t.parentElement),(n={isInViewport:!1,isPartiallyInViewport:!1,isInsideViewport:!1,isAroundViewport:!1,isOnEdge:!1,isOnTopEdge:!1,isOnRightEdge:!1,isOnBottomEdge:!1,isOnLeftEdge:!1},r=t.getBoundingClientRect(),o=window.innerHeight||document.documentElement.clientHeight,a=window.innerWidth||document.documentElement.clientWidth,l=r.left>=0&&r.left+r.width<=a,s=r.top>=0&&r.top+r.height<=o,n.isInsideViewport=l&&s,c=r.left<0&&r.left+r.width>a,d=r.top<0&&r.top+r.height>o,n.isAroundViewport=c&&d,h=r.top<0&&r.top+r.height>0,u=r.lefta,f=r.left<0&&r.left+r.width>0,g=r.topo,m=s||d||h||g,p=l||c||f||u,n.isOnTopEdge=h&&p,n.isOnRightEdge=u&&m,n.isOnBottomEdge=g&&p,n.isOnLeftEdge=f&&m,n.isOnEdge=n.isOnLeftEdge||n.isOnRightEdge||n.isOnTopEdge||n.isOnBottomEdge,_=l||c||n.isOnLeftEdge||n.isOnRightEdge,y=s||d||n.isOnTopEdge||n.isOnBottomEdge,n.isInViewport=_&&y,n.isPartiallyInViewport=n.isInViewport&&n.isOnEdge,n).isInViewport)}});if(!r)return{};let o=e.createElement("head"),a=e.createElement("title");for(let[i,l]of(a.innerText=e.title,o.appendChild(a),(null==t?void 0:t.styles)&&(yield(0,s.addStylesToHead)(o,n)),Object.entries(function(e){let t={};for(let{name:i}of e.attributes){let n=e.getAttribute(i);n&&(t[i]=n)}return t}(e.documentElement))))r.setAttribute(i,l);return{body:r,head:o}})}function b(e){return(null==e?void 0:e.corsProxy)?{bypassCors:!0,corsHost:e.corsProxy,crossOrigin:"anonymous",noCache:!0}:void 0}},812:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.shouldProcess=l,t.inlineAll=function(e,t,i,a){return n(this,void 0,void 0,function*(){if(!l(e))return e;for(let l of s(e))e=yield(function(e,t,i,a,l){return n(this,void 0,void 0,function*(){let n=a?(0,o.resolveUrl)(t,a):t,s=l?(0,r.constructUrl)(n,i):yield(0,r.fetchResource)(n,i).catch(()=>(0,r.constructUrl)(n,i));return e.replace(t,s||n)})})(e,l,t,i,a).catch(t=>(console.error(t),e));return e})},t.readUrls=s;let r=i(113),o=i(132),a=/url\(['"]?([^'"]+?)['"]?\)/g;function l(e){return -1!==e.search(a)}function s(e){let t,i=[];for(;null!==(t=a.exec(e));)i.push(t[1]);return i.filter(function(e){return!(0,o.isDataUrl)(e)})}},707:function(e,t,i){"use strict";var n=this&&this.__awaiter||function(e,t,i,n){return new(i||(i=Promise))(function(r,o){function a(e){try{s(n.next(e))}catch(e){o(e)}}function l(e){try{s(n.throw(e))}catch(e){o(e)}}function s(e){var t;e.done?r(e.value):((t=e.value)instanceof i?t:new i(function(e){e(t)})).then(a,l)}s((n=n.apply(e,t||[])).next())})};Object.defineProperty(t,"__esModule",{value:!0}),t.addStylesToHead=function(e,t){return n(this,void 0,void 0,function*(){for(let i of(yield function(e){return n(this,void 0,void 0,function*(){for(let t of document.styleSheets){let i=[];if(!(yield function(e,t){return n(this,void 0,void 0,function*(){try{e.cssRules.length}catch(n){let i=e.ownerNode;if(e.href&&i instanceof HTMLLinkElement){if(l(i))return!0;let e=yield a(i.href,t);e&&i.replaceWith(e)}return!0}return l(e)})}(t,e))){for(let n=0;n0){yield c(i,t);let n=s(i.cssRules);e.appendChild(n);continue}if(i.ownerNode instanceof HTMLStyleElement){e.appendChild(i.ownerNode.cloneNode(!0));continue}}})};let r=i(113),o=i(812);function a(e,t){return n(this,void 0,void 0,function*(){try{let i=document.createElement("style"),n=yield fetch((0,r.constructUrl)(e,t));if(!n.ok)return!1;return i.innerHTML=yield n.text(),i.setAttribute("href",e),i}catch(t){console.error("Failed to inline stylesheet",e,t)}})}function l(e){return("string"==typeof e.media?e.media:e.media.mediaText).split(",").map(e=>e.trim()).includes("print")}function s(e){let t=Array.from(e).map(e=>e.cssText).reduce((e,t)=>e+t,""),i=document.createElement("style");return i.innerHTML=t,i}function c(e,t){return n(this,void 0,void 0,function*(){let i=[];for(let n of e.cssRules)if(n.type===CSSRule.STYLE_RULE)i.push(d(e,n,t));else if(n.type===CSSRule.MEDIA_RULE){let r=window.matchMedia(n.media.mediaText).matches;for(let o of n.cssRules)o&&o.type===CSSRule.STYLE_RULE&&i.push(d(e,o,t,r))}else if(n.type===CSSRule.SUPPORTS_RULE)for(let r of n.cssRules)r&&r.type===CSSRule.STYLE_RULE&&i.push(d(e,r,t,!1));yield Promise.allSettled(i)})}function d(e,t,i){return n(this,arguments,void 0,function*(e,t,i,n=!0){let r=e.href||document.location.href;for(let e of t.style){let a=t.style.getPropertyValue(e);if(!a)continue;let l=yield(0,o.inlineAll)(a,i,r,!n);t.style.setProperty(e,l)}})}},132:function(e,t){"use strict";Object.defineProperty(t,"__esModule",{value:!0}),t.injectCss=function(e,t){let i=document.getElementById(t),n=document.getElementsByTagName("head")[0];i&&n.removeChild(i);let r=document.createElement("style");r.type="text/css",r.id=t,r.appendChild(document.createTextNode(e)),n.insertBefore(r,function(){for(let e of document.querySelectorAll("style"))if(e.innerHTML.includes("#root"))return e;return null}())},t.escape=function(e){return e.replace(/([.*+?^${}()|[\]/\\])/g,"\\$1")},t.parseExtension=a,t.mimeType=function(e){return o[a(e).toLowerCase()]||""},t.dataAsUrl=function(e,t){return"data:"+t+";base64,"+e},t.isDataUrl=function(e){return -1!==e.search(/^(data:)/)},t.canvasToBlob=function(e){return e.toBlob?new Promise(function(t){e.toBlob(t)}):Promise.resolve(function(e){let t=atob(e.toDataURL().split(",")[1]),i=t.length,n=new Uint8Array(i);for(let e=0;ee.toLowerCase()),o={woff:i,woff2:i,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:n,jpeg:n,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml"};function a(e){let t=/\.([^./]*?)(\?|$)/g.exec(e);return t?t[1]:""}let l=0;function s(e,t){return parseFloat(getComputedStyle(e).getPropertyValue(t).replace("px",""))}},673:function(e,t,i){"use strict";i.r(t),i.d(t,{app:()=>b,h:()=>E,memo:()=>y,text:()=>v});var n={},r=[],o=e=>e,a=r.map,l=Array.isArray,s="undefined"!=typeof requestAnimationFrame?requestAnimationFrame:setTimeout,c=e=>{var t="";if("string"==typeof e)return e;if(l(e))for(var i,n=0;n{for(var i in{...e,...t})if("function"==typeof(l(e[i])?e[i][0]:e[i]))t[i]=e[i];else if(e[i]!==t[i])return!0},h=e=>null==e?e:e.key,u=(e,t,i,n,r,o)=>{if("style"===t)for(var a in{...i,...n})i=null==n||null==n[a]?"":n[a],"-"===a[0]?e[t].setProperty(a,i):e[t][a]=i;else"o"===t[0]&&"n"===t[1]?((e.events||(e.events={}))[t=t.slice(2)]=n)?i||e.addEventListener(t,r):e.removeEventListener(t,r):!o&&"list"!==t&&"form"!==t&&t in e?e[t]=null==n?"":n:null==n||!1===n?e.removeAttribute(t):e.setAttribute(t,n)},f=(e,t,i)=>{var n=e.props,r=3===e.type?document.createTextNode(e.tag):(i=i||"svg"===e.tag)?document.createElementNS("http://www.w3.org/2000/svg",e.tag,n.is&&n):document.createElement(e.tag,n.is&&n);for(var o in n)u(r,o,null,n[o],t,i);for(var a=0;a{if(i===n);else if(null!=i&&3===i.type&&3===n.type)i.tag!==n.tag&&(t.nodeValue=n.tag);else if(null==i||i.tag!==n.tag)t=e.insertBefore(f(n=m(n),r,o),t),null!=i&&e.removeChild(i.node);else{var a,l,s,c,d=i.props,p=n.props,_=i.children,y=n.children,v=0,E=0,b=_.length-1,N=y.length-1;for(var T in o=o||"svg"===n.tag,{...d,...p})("value"===T||"selected"===T||"checked"===T?t[T]:d[T])!==p[T]&&u(t,T,d[T],p[T],r,o);for(;E<=N&&v<=b&&null!=(s=h(_[v]))&&s===h(y[E]);)g(t,_[v].node,_[v],y[E]=m(y[E++],_[v++]),r,o);for(;E<=N&&v<=b&&null!=(s=h(_[b]))&&s===h(y[N]);)g(t,_[b].node,_[b],y[N]=m(y[N--],_[b--]),r,o);if(v>b)for(;E<=N;)t.insertBefore(f(y[E]=m(y[E++]),r,o),(l=_[v])&&l.node);else if(E>N)for(;v<=b;)t.removeChild(_[v++].node);else{for(var A={},S={},T=v;T<=b;T++)null!=(s=_[T].key)&&(A[s]=_[T]);for(;E<=N;){if(s=h(l=_[v]),c=h(y[E]=m(y[E],l)),S[s]||null!=c&&c===h(_[v+1])){null==s&&t.removeChild(l.node),v++;continue}null==c||1===i.type?(null==s&&(g(t,l&&l.node,l,y[E],r,o),E++),v++):(s===c?(g(t,l.node,l,y[E],r,o),S[c]=!0,v++):null!=(a=A[c])?(g(t,t.insertBefore(a.node,l&&l.node),a,y[E],r,o),S[c]=!0):g(t,l&&l.node,null,y[E],r,o),E++)}for(;v<=b;)null==h(l=_[v++])&&t.removeChild(l.node);for(var T in A)null==S[T]&&t.removeChild(A[T].node)}}return n.node=t},m=(e,t)=>!0!==e&&!1!==e&&e?"function"==typeof e.tag?((!t||null==t.memo||((e,t)=>{for(var i in e)if(e[i]!==t[i])return!0;for(var i in t)if(e[i]!==t[i])return!0})(t.memo,e.memo))&&((t=e.tag(e.memo)).memo=e.memo),t):e:v(""),p=e=>3===e.nodeType?v(e.nodeValue,e):_(e.nodeName.toLowerCase(),n,a.call(e.childNodes,p),1,e),_=(e,{key:t,...i},n,r,o)=>({tag:e,props:i,key:t,children:n,type:r,node:o}),y=(e,t)=>({tag:e,memo:t}),v=(e,t)=>_(e,n,r,3,t),E=(e,{class:t,...i},o=r)=>_(e,{...i,...t?{class:c(t)}:n},l(o)?o:[o]),b=({node:e,view:t,subscriptions:i,dispatch:a=o,init:c=n})=>{var h,u,f=e&&p(e),m=[],_=e=>{h!==e&&(null==(h=e)&&(a=i=y=o),i&&(m=((e,t=r,i)=>{for(var n,o,a=[],l=0;le=g(e.parentNode,e,f,f=t(h),v,u=!1),v=function(e){a(this.events[e.type],e)};return(a=a((e,t)=>"function"==typeof e?a(e(h,t)):l(e)?"function"==typeof e[0]?a(e[0],e[1]):e.slice(1).map(e=>e&&!0!==e&&(e[0]||e)(a,e[1]),_(e[0])):_(e)))(c),a}}},t={};function i(n){var r=t[n];if(void 0!==r)return r.exports;var o=t[n]={exports:{}};return e[n].call(o.exports,o,o.exports,i),o.exports}i.d=(e,t)=>{for(var n in t)i.o(t,n)&&!i.o(e,n)&&Object.defineProperty(e,n,{enumerable:!0,get:t[n]})},i.o=(e,t)=>Object.prototype.hasOwnProperty.call(e,t),i.r=e=>{"undefined"!=typeof Symbol&&Symbol.toStringTag&&Object.defineProperty(e,Symbol.toStringTag,{value:"Module"}),Object.defineProperty(e,"__esModule",{value:!0})};var n={};(()=>{"use strict";Object.defineProperty(n,"__esModule",{value:!0});let e=i(769);globalThis.Clipper={clipArticle:e.clipArticle,clipPage:e.clipPage}})(),module.exports=n})();