single-file-cli 1.0.34 → 1.0.36

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.
package/args.js CHANGED
@@ -55,6 +55,7 @@ const args = require("yargs")
55
55
  "browser-start-minimized": false,
56
56
  "browser-cookie": [],
57
57
  "browser-cookies-file": "",
58
+ "browser-ignore-insecure-certs": false,
58
59
  "compress-CSS": false,
59
60
  "compress-HTML": true,
60
61
  "dump-content": false,
@@ -150,6 +151,8 @@ const args = require("yargs")
150
151
  .array("browser-cookie")
151
152
  .options("browser-cookies-file", { description: "Path of the cookies file formatted as a JSON file or a Netscape text file (puppeteer, webdriver-gecko, webdriver-chromium, jsdom)" })
152
153
  .string("browser-cookies-file")
154
+ .options("browser-ignore-insecure-certs", { description: "Ignore HTTPs errors" })
155
+ .boolean("browser-ignore-insecure-certs")
153
156
  .options("compress-CSS", { description: "Compress CSS stylesheets" })
154
157
  .boolean("compress-CSS")
155
158
  .options("compress-HTML", { description: "Compress HTML content" })
@@ -96,7 +96,8 @@ async function getBrowserOptions(options) {
96
96
  }
97
97
  }
98
98
  const resourceLoader = new ResourceLoader({
99
- userAgent: options.userAgent
99
+ userAgent: options.userAgent,
100
+ strictSSL: options.browserIgnoreInsecureCerts === undefined || !options.browserIgnoreInsecureCerts
100
101
  });
101
102
  const jsdomOptions = {
102
103
  virtualConsole: new VirtualConsole(),
@@ -38,7 +38,8 @@ exports.getPageData = async options => {
38
38
  let page, context;
39
39
  try {
40
40
  const contextOptions = {
41
- bypassCSP: options.browserBypassCSP === undefined || options.browserBypassCSP
41
+ bypassCSP: options.browserBypassCSP === undefined || options.browserBypassCSP,
42
+ ignoreHTTPSErrors: options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts
42
43
  };
43
44
  if (options.httpProxyServer) {
44
45
  contextOptions.proxy = {
@@ -38,7 +38,8 @@ exports.getPageData = async options => {
38
38
  let page, context;
39
39
  try {
40
40
  context = await browser.newContext({
41
- bypassCSP: options.browserBypassCSP === undefined || options.browserBypassCSP
41
+ bypassCSP: options.browserBypassCSP === undefined || options.browserBypassCSP,
42
+ ignoreHTTPSErrors: options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts
42
43
  });
43
44
  await setContextOptions(context, options);
44
45
  page = await context.newPage();
@@ -38,7 +38,8 @@ exports.getPageData = async options => {
38
38
  let page, context;
39
39
  try {
40
40
  const contextOptions = {
41
- bypassCSP: options.browserBypassCSP === undefined || options.browserBypassCSP
41
+ bypassCSP: options.browserBypassCSP === undefined || options.browserBypassCSP,
42
+ ignoreHTTPSErrors: options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts
42
43
  };
43
44
  if (options.httpProxyServer) {
44
45
  contextOptions.proxy = {
@@ -63,6 +63,9 @@ function getBrowserOptions(options) {
63
63
  if (options.browserExecutablePath) {
64
64
  browserOptions.executablePath = options.browserExecutablePath || "firefox";
65
65
  }
66
+ if (options.browserIgnoreInsecureCerts !== undefined) {
67
+ browserOptions.ignoreHTTPSErrors = options.browserIgnoreInsecureCerts;
68
+ }
66
69
  browserOptions.product = "firefox";
67
70
  return browserOptions;
68
71
  }
@@ -72,6 +72,9 @@ function getBrowserOptions(options = {}) {
72
72
  if (options.browserHeadless !== undefined) {
73
73
  browserOptions.headless = options.browserHeadless && !options.browserDebug;
74
74
  }
75
+ if (options.browserIgnoreInsecureCerts !== undefined) {
76
+ browserOptions.ignoreHTTPSErrors = options.browserIgnoreInsecureCerts;
77
+ }
75
78
  browserOptions.args = options.browserArgs ? JSON.parse(options.browserArgs) : [];
76
79
  if (options.browserDisableWebSecurity === undefined || options.browserDisableWebSecurity) {
77
80
  browserOptions.args.push("--disable-web-security");
@@ -24,7 +24,7 @@
24
24
  /* global require, exports, process, setTimeout, clearTimeout, Buffer */
25
25
 
26
26
  const chrome = require("selenium-webdriver/chrome");
27
- const { Builder } = require("selenium-webdriver");
27
+ const { Builder, Capabilities } = require("selenium-webdriver");
28
28
 
29
29
  exports.initialize = async () => { };
30
30
 
@@ -33,6 +33,7 @@ exports.getPageData = async options => {
33
33
  try {
34
34
  const builder = new Builder();
35
35
  builder.setChromeOptions(getBrowserOptions(options));
36
+ setBuilderCapabilities(builder, options);
36
37
  driver = builder.forBrowser("chrome").build();
37
38
  return await getPageData(driver, options);
38
39
  } finally {
@@ -44,6 +45,14 @@ exports.getPageData = async options => {
44
45
 
45
46
  exports.closeBrowser = () => { };
46
47
 
48
+ function setBuilderCapabilities(builder, options) {
49
+ if (options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts) {
50
+ const capabilities = new Capabilities();
51
+ capabilities.setAcceptInsecureCerts(true);
52
+ builder.withCapabilities(capabilities);
53
+ }
54
+ }
55
+
47
56
  function getBrowserOptions(options) {
48
57
  const chromeOptions = new chrome.Options();
49
58
  const optionHeadless = (options.browserHeadless === undefined || options.browserHeadless) && !options.browserDebug;
@@ -24,7 +24,7 @@
24
24
  /* global require, exports, process, setTimeout, clearTimeout */
25
25
 
26
26
  const firefox = require("selenium-webdriver/firefox");
27
- const { Builder, By, Key } = require("selenium-webdriver");
27
+ const { Builder, By, Key, Capabilities } = require("selenium-webdriver");
28
28
 
29
29
  exports.initialize = async () => { };
30
30
 
@@ -33,6 +33,7 @@ exports.getPageData = async options => {
33
33
  try {
34
34
  const builder = new Builder().withCapabilities({ "pageLoadStrategy": "none" });
35
35
  builder.setFirefoxOptions(getBrowserOptions(options));
36
+ setBuilderCapabilities(builder, options);
36
37
  driver = builder.forBrowser("firefox").build();
37
38
  return await getPageData(driver, options);
38
39
  } finally {
@@ -44,6 +45,14 @@ exports.getPageData = async options => {
44
45
 
45
46
  exports.closeBrowser = () => { };
46
47
 
48
+ function setBuilderCapabilities(builder, options) {
49
+ if (options.browserIgnoreInsecureCerts !== undefined && options.browserIgnoreInsecureCerts) {
50
+ const capabilities = new Capabilities();
51
+ capabilities.setAcceptInsecureCerts(true);
52
+ builder.withCapabilities(capabilities);
53
+ }
54
+ }
55
+
47
56
  function getBrowserOptions(options) {
48
57
  const firefoxOptions = new firefox.Options().setBinary(firefox.Channel.NIGHTLY);
49
58
  if ((options.browserHeadless === undefined || options.browserHeadless) && !options.browserDebug) {
@@ -75,6 +84,7 @@ function getBrowserOptions(options) {
75
84
  if (options.userAgent) {
76
85
  firefoxOptions.setPreference("general.useragent.override", options.userAgent);
77
86
  }
87
+ return firefoxOptions;
78
88
  }
79
89
 
80
90
  async function getPageData(driver, options) {
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefileBootstrap={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",a="single-file-block-cookies-start",i="single-file-block-cookies-end",r="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",m="single-file-load-image",u="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),p=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},f=globalThis.CustomEvent,h=globalThis.document,E=globalThis.Document;let T;T=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,h instanceof E&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,T.set(JSON.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,T.delete(JSON.stringify(s))})),g("single-file-clear-fonts",(()=>T=new Map)));const b="[\\x20\\t\\r\\n\\f]",y=new RegExp("\\\\([\\da-f]{1,6}"+b+"?|("+b+")|.)","ig");const w="single-file-on-before-capture",I="single-file-on-after-capture",A="data-single-file-removed-content",N="data-single-file-hidden-content",v="data-single-file-kept-content",S="data-single-file-hidden-frame",R="data-single-file-preserved-space-element",_="data-single-file-shadow-root-element",C="data-single-file-image",F="data-single-file-poster",M="data-single-file-video",P="data-single-file-canvas",x="data-single-file-movable-style",O="data-single-file-input-value",L="data-single-file-lazy-loaded-src",D="data-single-file-stylesheet",q="data-single-file-disabled-noscript",k="data-single-file-invalid-element",U="data-single-file-async-script",H="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",V=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],B=/^'(.*?)'$/,W=/^"(.*?)"$/,z={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},j="single-file-ui-element",Y="data:,",G=(e,t,s)=>globalThis.addEventListener(e,t,s),J=e=>{try{globalThis.dispatchEvent(e)}catch(e){}};function Z(e,t,s){e.querySelectorAll("noscript:not(["+q+"])").forEach((e=>{e.setAttribute(q,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(H).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+H+", html > body > "+H);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const s=e.createElement("template");s.setAttribute(k,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=K(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=ne(t,e);s&&ee(e,s)&&(e.setAttribute(x,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(T.values()),stylesheets:se(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}}function K(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},a){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let i,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=ne(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(a||s.closest("html > head"))&&V.includes(s.tagName)||s.closest("details"),r||(i=a||ee(s,l),i&&(s.setAttribute(N,""),n.markedElements.push(s)))),!i)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(R,""),n.markedElements.push(s))}o.removeUnusedFonts&&($(l,o,n.usedFonts),$(ne(e,s,":first-letter"),o,n.usedFonts),$(ne(e,s,":before"),o,n.usedFonts),$(ne(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,a,i){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(P,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:a?Y:o.loadDeferredImages&&s.getAttribute(L)||s.currentSrc};if(n.images.push(t),s.setAttribute(C,n.images.length-1),n.markedElements.push(s),s.removeAttribute(L),i=i||ne(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const a=null==t.getAttribute("style");if(s=s||ne(e,t)){let e,i,r,l,d,c,m,u,g=!1;if("content-box"==s.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=oe("padding-left",s),i=oe("padding-right",s),r=oe("padding-top",s),l=oe("padding-bottom",s),g?(d=oe("border-left-width",s),c=oe("border-right-width",s),m=oe("border-top-width",s),u=oe("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-e-i-d-c),n=Math.max(0,t.clientHeight-r-l-m-u),a&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,i);const o=i.getPropertyValue("box-shadow"),n=i.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=i.getPropertyValue("background-color"),t.objectFit=i.getPropertyValue("object-fit"),t.boxSizing=i.getPropertyValue("box-sizing"),t.objectPosition=i.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=ne(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(M,n.videos.length-1)}if(!s.getAttribute("poster")){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(F,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&a&&o.removeHiddenElements&&(s.setAttribute(S,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(O,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(O,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(O,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(O,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(U,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,i,l);const d=!(s instanceof e.SVGElement)&&X(s);if(d&&!s.classList.contains(j)){const a={};s.setAttribute(_,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(a),K(e,t,d,o,n,i),a.content=d.innerHTML,a.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(a.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}K(e,t,s,o,n,i),!o.autoSaveExternalSave&&o.removeHiddenElements&&a&&(r||""==s.getAttribute(v)?s.parentElement&&(s.parentElement.setAttribute(v,""),n.markedElements.push(s.parentElement)):i&&(s.setAttribute(A,""),n.markedElements.push(s)))})),n}function $(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=Q(n),!t.loadedFonts||t.loadedFonts.find((e=>Q(e.family)==n&&e.style==o))){const t=(a=e.getPropertyValue("font-weight"),z[a.toLowerCase().trim()]||a),i=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,i];s.set(JSON.stringify(r),[n,t,o,i])}var a}))}}function X(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function Q(e=""){return function(e){e=e.match(B)?e.replace(B,"$1"):e.replace(W,"$1");return e.trim()}((t=e.trim(),t.replace(y,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function ee(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),a=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==a)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function te(e,t,s){if(e.querySelectorAll("["+q+"]").forEach((e=>{e.textContent=e.getAttribute(q),e.removeAttribute(q)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[A,S,N,R,C,F,M,P,O,_,D,U];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(A),e.removeAttribute(N),e.removeAttribute(v),e.removeAttribute(S),e.removeAttribute(R),e.removeAttribute(C),e.removeAttribute(F),e.removeAttribute(M),e.removeAttribute(P),e.removeAttribute(O),e.removeAttribute(_),e.removeAttribute(D),e.removeAttribute(U),e.removeAttribute(x)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))}function se(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const a=n.sheet;n.remove(),a&&a.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(D,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function oe(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function ne(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const ae={LAZY_SRC_ATTRIBUTE_NAME:L,SINGLE_FILE_UI_ELEMENT_CLASS:j},ie=10,re="attributes",le=globalThis.browser,de=globalThis.document,ce=globalThis.MutationObserver,me=(e,t,s)=>globalThis.addEventListener(e,t,s),ue=(e,t,s)=>globalThis.removeEventListener(e,t,s),ge=new Map;let pe;async function fe(e){if(de.documentElement){ge.clear();const s=de.body&&de.body.scrollHeight||de.documentElement.scrollHeight,n=de.body&&de.body.scrollWidth||de.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const i=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<i||globalThis.scrollX<l)return function(e){return pe=0,new Promise((async s=>{let n;const i=new Set,l=new ce((async t=>{if((t=t.filter((e=>e.type==re))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(ae.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(ae.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ee(l,e,T),i.size||await he(l,e,T))}}));async function c(t){await be("idleTimeout",(async()=>{n?pe<ie&&(pe++,we("idleTimeout"),await c(Math.max(500,t/2))):(we("loadTimeout"),we("maxTimeout"),Te(l,e,T))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(ae.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function h(t){n=!0,await Ee(l,e,T),await he(l,e,T),t.detail&&i.add(t.detail)}async function E(t){await Ee(l,e,T),await he(l,e,T),i.delete(t.detail),i.size||await he(l,e,T)}function T(e){l.disconnect(),ue(m,h),ue(u,E),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await Ee(l,e,T),l.observe(de,{subtree:!0,childList:!0,attributes:!0}),me(m,h),me(u,E),function(e){e.loadDeferredImagesBlockCookies&&p(new f(a)),e.loadDeferredImagesBlockStorage&&p(new f(d)),e.loadDeferredImagesDispatchScrollEvent&&p(new f(r)),e.loadDeferredImagesKeepZoomLevel?p(new f(o)):p(new f(t))}(e)}))}(e)}}}async function he(e,t,s){await be("loadTimeout",(()=>Te(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ee(e,t,s){await be("maxTimeout",(async()=>{await we("loadTimeout"),await Te(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Te(e,t,o){await we("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&p(new f(i)),e.loadDeferredImagesBlockStorage&&p(new f(c)),e.loadDeferredImagesDispatchScrollEvent&&p(new f(l)),e.loadDeferredImagesKeepZoomLevel?p(new f(n)):p(new f(s))}(t),await be("endTimeout",(async()=>{await we("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function be(e,t,s,o){if(le&&le.runtime&&le.runtime.sendMessage&&!o){if(!ge.get(e)||!ge.get(e).pending){const o={callback:t,pending:!0};ge.set(e,o);try{await le.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){ye(e,t,s)}o.pending=!1}}else ye(e,t,s)}function ye(e,t,s){const o=ge.get(e);o&&globalThis.clearTimeout(o),ge.set(e,t),globalThis.setTimeout(t,s)}async function we(e){if(le&&le.runtime&&le.runtime.sendMessage)try{await le.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Ie(e)}else Ie(e)}function Ie(e){const t=ge.get(e);ge.delete(e),t&&globalThis.clearTimeout(t)}le&&le.runtime&&le.runtime.onMessage&&le.runtime.onMessage.addListener&&le.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=ge.get(e.type);if(t){ge.delete(e.type);try{t.callback()}catch(t){Ie(e.type)}}}}));const Ae={ON_BEFORE_CAPTURE_EVENT_NAME:w,ON_AFTER_CAPTURE_EVENT_NAME:I,WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:Z,serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:te,getShadowRoot:X},Ne="__frameTree__::",ve='iframe, frame, object[type="text/html"][data]',Se="*",Re="singlefile.frameTree.initRequest",_e="singlefile.frameTree.ackInitRequest",Ce="singlefile.frameTree.cleanupRequest",Fe="singlefile.frameTree.initResponse",Me="*",Pe=5e3,xe=1e4,Oe=".",Le=globalThis.window==globalThis.top,De=globalThis.browser,qe=globalThis.top,ke=globalThis.MessageChannel,Ue=globalThis.document;let He,Ve=globalThis.sessions;var Be,We,ze;function je(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ye(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Le||(He=globalThis.frameId=e.windowId),Ze(Ue,e.options,He,t),Le||(e.options.userScriptEnabled&&s&&await s(Ae.ON_BEFORE_CAPTURE_EVENT_NAME),Qe({frames:[tt(Ue,globalThis,He,e.options)],sessionId:t,requestedFrameId:Ue.documentElement.dataset.requestedFrameId&&He}),e.options.userScriptEnabled&&s&&await s(Ae.ON_AFTER_CAPTURE_EVENT_NAME),delete Ue.documentElement.dataset.requestedFrameId)}function Ge(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;Xe(st(Ue),e.windowId,t)}}function Je(e){e.frames.forEach((t=>Ke("responseTimeouts",e.sessionId,t.windowId)));const t=Ve.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Oe).length-e.windowId.split(Oe).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Ze(e,t,s,o){const n=st(e);!function(e,t,s,o,n){const a=[];let i;Ve.get(n)?i=Ve.get(n).requestTimeouts:(i={},Ve.set(n,{requestTimeouts:i}));t.forEach(((e,t)=>{const s=o+Oe+t;e.setAttribute(Ae.WIN_ID_ATTRIBUTE_NAME,s),a.push({windowId:s})})),Qe({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const a=o+Oe+t;try{et(e.contentWindow,{method:Re,windowId:a,sessionId:n,options:s})}catch(e){}i[a]=globalThis.setTimeout((()=>Qe({frames:[{windowId:a,processed:!0}],sessionId:n})),Pe)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const a=[];t.forEach(((e,t)=>{const i=o+Oe+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Ke("requestTimeouts",n,i),Ze(r,s,i,n),a.push(tt(r,t,i,s))}catch(e){a.push({windowId:i,processed:!0})}})),Qe({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Ke(e,t,s){const o=Ve.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function $e(e,t){const s=Ve.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>Qe({frames:[{windowId:t,processed:!0}],sessionId:e})),xe))}function Xe(e,t,s){e.forEach(((e,o)=>{const n=t+Oe+o;e.removeAttribute(Ae.WIN_ID_ATTRIBUTE_NAME);try{et(e.contentWindow,{method:Ce,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Oe+o;let a;try{a=e.contentDocument}catch(e){}if(a)try{Xe(st(a),n,s)}catch(e){}}))}function Qe(e){e.method=Fe;try{qe.singlefile.processors.frameTree.initResponse(e)}catch(t){et(qe,e,!0)}}function et(e,t,s){if(e==qe&&De&&De.runtime&&De.runtime.sendMessage)De.runtime.sendMessage(t);else if(s){const s=new ke;e.postMessage(Ne+JSON.stringify({method:t.method,sessionId:t.sessionId}),Me,[s.port2]),s.port1.postMessage(t)}else e.postMessage(Ne+JSON.stringify(t),Me)}function tt(e,t,s,o){const n=Ae.preProcessDoc(e,t,o),a=Ae.serialize(e);Ae.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:a,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function st(e){let t=Array.from(e.querySelectorAll(ve));return e.querySelectorAll(Se).forEach((e=>{const s=Ae.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(ve)))})),t}Ve||(Ve=globalThis.sessions=new Map),Le&&(He="0",De&&De.runtime&&De.runtime.onMessage&&De.runtime.onMessage.addListener&&De.runtime.onMessage.addListener((e=>e.method==Fe?(Je(e),Promise.resolve({})):e.method==_e?(Ke("requestTimeouts",e.sessionId,e.windowId),$e(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Be="message",We=async e=>{if("string"==typeof e.data&&e.data.startsWith(Ne)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(Ne.length));t.method==Re?(e.source&&et(e.source,{method:_e,windowId:t.windowId,sessionId:t.sessionId}),Le||(globalThis.stop(),t.options.loadDeferredImages&&fe(t.options),await Ye(t))):t.method==_e?(Ke("requestTimeouts",t.sessionId,t.windowId),$e(t.sessionId,t.windowId)):t.method==Ce?Ge(t):t.method==Fe&&Ve.get(t.sessionId)&&(e.ports[0].onmessage=e=>Je(e.data))}},ze=!0,globalThis.addEventListener(Be,We,ze);var ot=Object.freeze({__proto__:null,getAsync:function(e){const t=je();return e=JSON.parse(JSON.stringify(e)),new Promise((s=>{Ve.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ye({windowId:He,sessionId:t,options:e})}))},getSync:function(e){const t=je();e=JSON.parse(JSON.stringify(e)),Ve.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Le||(He=globalThis.frameId=e.windowId);Ze(Ue,e.options,He,t),Le||(e.options.userScriptEnabled&&s&&s(Ae.ON_BEFORE_CAPTURE_EVENT_NAME),Qe({frames:[tt(Ue,globalThis,He,e.options)],sessionId:t,requestedFrameId:Ue.documentElement.dataset.requestedFrameId&&He}),e.options.userScriptEnabled&&s&&s(Ae.ON_AFTER_CAPTURE_EVENT_NAME),delete Ue.documentElement.dataset.requestedFrameId)}({windowId:He,sessionId:t,options:e});const s=Ve.get(t).frames;return s.sessionId=t,s},cleanup:function(e){Ve.delete(e),Ge({windowId:He,sessionId:e,options:{sessionId:e}})},initResponse:Je,TIMEOUT_INIT_REQUEST_MESSAGE:Pe});const nt=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],at=1,it=3,rt=8,lt=[{tagName:"head",accept:e=>!e.childNodes.length||e.childNodes[0].nodeType==at},{tagName:"body",accept:e=>!e.childNodes.length}],dt=[{tagName:"html",accept:e=>!e||e.nodeType!=rt},{tagName:"head",accept:e=>!e||e.nodeType!=rt&&(e.nodeType!=it||!ut(e.textContent))},{tagName:"body",accept:e=>!e||e.nodeType!=rt},{tagName:"li",accept:(e,t)=>!e&&t.parentElement&&("UL"==t.parentElement.tagName||"OL"==t.parentElement.tagName)||e&&["LI"].includes(e.tagName)},{tagName:"dt",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"p",accept:e=>e&&["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"].includes(e.tagName)},{tagName:"dd",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"rt",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"rp",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"optgroup",accept:e=>!e||["OPTGROUP"].includes(e.tagName)},{tagName:"option",accept:e=>!e||["OPTION","OPTGROUP"].includes(e.tagName)},{tagName:"colgroup",accept:e=>!e||e.nodeType!=rt&&(e.nodeType!=it||!ut(e.textContent))},{tagName:"caption",accept:e=>!e||e.nodeType!=rt&&(e.nodeType!=it||!ut(e.textContent))},{tagName:"thead",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tbody",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tfoot",accept:e=>!e},{tagName:"tr",accept:e=>!e||["TR"].includes(e.tagName)},{tagName:"td",accept:e=>!e||["TD","TH"].includes(e.tagName)},{tagName:"th",accept:e=>!e||["TD","TH"].includes(e.tagName)}],ct=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"];function mt(e,t,s){return e.nodeType==it?function(e){const t=e.parentNode;let s;t&&t.nodeType==at&&(s=t.tagName.toLowerCase());return!s||ct.includes(s)?"script"==s||"style"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&amp;").replace(/\u00a0/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}(e):e.nodeType==rt?"\x3c!--"+e.textContent+"--\x3e":e.nodeType==at?function(e,t,s){const o=e.tagName.toLowerCase(),n=t&&lt.find((t=>o==t.tagName&&t.accept(e)));let a="";n&&!e.attributes.length||(a="<"+o,Array.from(e.attributes).forEach((s=>a+=function(e,t,s){const o=e.name;let n="";if(!o.match(/["'>/=]/)){let a,i=e.value;s&&"class"==o&&(i=Array.from(t.classList).map((e=>e.trim())).join(" ")),i=i.replace(/&/g,"&amp;").replace(/\u00a0/g,"&nbsp;"),i.includes('"')&&(i.includes("'")||!s?i=i.replace(/"/g,"&quot;"):a=!0);const r=!s||i.match(/[ \t\n\f\r'"`=<>]/);n+=" ",e.namespace?"http://www.w3.org/XML/1998/namespace"==e.namespaceURI?n+="xml:"+o:"http://www.w3.org/2000/xmlns/"==e.namespaceURI?("xmlns"!==o&&(n+="xmlns:"),n+=o):"http://www.w3.org/1999/xlink"==e.namespaceURI?n+="xlink:"+o:n+=o:n+=o,""!=i&&(n+="=",r&&(n+=a?"'":'"'),n+=i,r&&(n+=a?"'":'"'))}return n}(s,e,t))),a+=">");"TEMPLATE"!=e.tagName||e.childNodes.length?Array.from(e.childNodes).forEach((e=>a+=mt(e,t,s||"svg"==o))):a+=e.innerHTML;const i=t&&dt.find((t=>o==t.tagName&&t.accept(e.nextSibling,e)));(s||!i&&!nt.includes(o))&&(a+="</"+o+">");return a}(e,t,s):void 0}function ut(e){return Boolean(e.match(/^[ \t\n\f\r]/))}const gt={frameTree:ot},pt={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:w,ON_AFTER_CAPTURE_EVENT_NAME:I,preProcessDoc:Z,postProcessDoc:te,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o="<!DOCTYPE "+s.nodeName,s.publicId?(o+=' PUBLIC "'+s.publicId+'"',s.systemId&&(o+=' "'+s.systemId+'"')):s.systemId&&(o+=' SYSTEM "'+s.systemId+'"'),s.internalSubset&&(o+=" ["+s.internalSubset+"]"),o+="> "),o+mt(e.documentElement,t)}(e,t),getShadowRoot:X};G("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>G(e+"-response",t)));J(t),t.defaultPrevented&&await s})),e.helper=pt,e.processors=gt,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefileBootstrap={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",a="single-file-block-cookies-start",i="single-file-block-cookies-end",r="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",m="single-file-load-image",u="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),p=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},f=globalThis.CustomEvent,h=globalThis.document,T=globalThis.Document,E=globalThis.JSON;let b;b=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,h instanceof T&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.set(E.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,b.delete(E.stringify(s))})),g("single-file-clear-fonts",(()=>b=new Map)));const y="[\\x20\\t\\r\\n\\f]",w=new RegExp("\\\\([\\da-f]{1,6}"+y+"?|("+y+")|.)","ig");const I="single-file-on-before-capture",A="single-file-on-after-capture",v="data-single-file-removed-content",N="data-single-file-hidden-content",S="data-single-file-kept-content",R="data-single-file-hidden-frame",_="data-single-file-preserved-space-element",C="data-single-file-shadow-root-element",F="data-single-file-image",M="data-single-file-poster",P="data-single-file-video",x="data-single-file-canvas",L="data-single-file-movable-style",D="data-single-file-input-value",O="data-single-file-lazy-loaded-src",q="data-single-file-stylesheet",k="data-single-file-disabled-noscript",U="data-single-file-invalid-element",H="data-single-file-async-script",V="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",B=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],W=/^'(.*?)'$/,z=/^"(.*?)"$/,j={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},Y="single-file-ui-element",G="data:,",Z=(e,t,s)=>globalThis.addEventListener(e,t,s),J=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},K=globalThis.JSON;function $(e,t,s){e.querySelectorAll("noscript:not(["+k+"])").forEach((e=>{e.setAttribute(k,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(V).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+V+", html > body > "+V);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const s=e.createElement("template");s.setAttribute(U,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=X(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=ie(t,e);s&&se(e,s)&&(e.setAttribute(L,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(b.values()),stylesheets:ne(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}}function X(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},a){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let i,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=ie(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(a||s.closest("html > head"))&&B.includes(s.tagName)||s.closest("details"),r||(i=a||se(s,l),i&&(s.setAttribute(N,""),n.markedElements.push(s)))),!i)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(_,""),n.markedElements.push(s))}o.removeUnusedFonts&&(Q(l,o,n.usedFonts),Q(ie(e,s,":first-letter"),o,n.usedFonts),Q(ie(e,s,":before"),o,n.usedFonts),Q(ie(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,a,i){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(x,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:a?G:o.loadDeferredImages&&s.getAttribute(O)||s.currentSrc};if(n.images.push(t),s.setAttribute(F,n.images.length-1),n.markedElements.push(s),s.removeAttribute(O),i=i||ie(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const a=null==t.getAttribute("style");if(s=s||ie(e,t)){let e,i,r,l,d,c,m,u,g=!1;if("content-box"==s.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=ae("padding-left",s),i=ae("padding-right",s),r=ae("padding-top",s),l=ae("padding-bottom",s),g?(d=ae("border-left-width",s),c=ae("border-right-width",s),m=ae("border-top-width",s),u=ae("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-e-i-d-c),n=Math.max(0,t.clientHeight-r-l-m-u),a&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,i);const o=i.getPropertyValue("box-shadow"),n=i.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=i.getPropertyValue("background-color"),t.objectFit=i.getPropertyValue("object-fit"),t.boxSizing=i.getPropertyValue("box-sizing"),t.objectPosition=i.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=ie(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(P,n.videos.length-1)}if(!s.getAttribute("poster")){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(M,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&a&&o.removeHiddenElements&&(s.setAttribute(R,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(D,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(D,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(D,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(D,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(H,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,i,l);const d=!(s instanceof e.SVGElement)&&ee(s);if(d&&!s.classList.contains(Y)){const a={};s.setAttribute(C,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(a),X(e,t,d,o,n,i),a.content=d.innerHTML,a.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(a.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}X(e,t,s,o,n,i),!o.autoSaveExternalSave&&o.removeHiddenElements&&a&&(r||""==s.getAttribute(S)?s.parentElement&&(s.parentElement.setAttribute(S,""),n.markedElements.push(s.parentElement)):i&&(s.setAttribute(v,""),n.markedElements.push(s)))})),n}function Q(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=te(n),!t.loadedFonts||t.loadedFonts.find((e=>te(e.family)==n&&e.style==o))){const t=(a=e.getPropertyValue("font-weight"),j[a.toLowerCase().trim()]||a),i=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,i];s.set(K.stringify(r),[n,t,o,i])}var a}))}}function ee(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function te(e=""){return function(e){e=e.match(W)?e.replace(W,"$1"):e.replace(z,"$1");return e.trim()}((t=e.trim(),t.replace(w,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function se(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),a=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==a)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function oe(e,t,s){if(e.querySelectorAll("["+k+"]").forEach((e=>{e.textContent=e.getAttribute(k),e.removeAttribute(k)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[v,R,N,_,F,M,P,x,D,C,q,H];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(v),e.removeAttribute(N),e.removeAttribute(S),e.removeAttribute(R),e.removeAttribute(_),e.removeAttribute(F),e.removeAttribute(M),e.removeAttribute(P),e.removeAttribute(x),e.removeAttribute(D),e.removeAttribute(C),e.removeAttribute(q),e.removeAttribute(H),e.removeAttribute(L)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))}function ne(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const a=n.sheet;n.remove(),a&&a.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(q,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function ae(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function ie(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const re={LAZY_SRC_ATTRIBUTE_NAME:O,SINGLE_FILE_UI_ELEMENT_CLASS:Y},le=10,de="attributes",ce=globalThis.browser,me=globalThis.document,ue=globalThis.MutationObserver,ge=(e,t,s)=>globalThis.addEventListener(e,t,s),pe=(e,t,s)=>globalThis.removeEventListener(e,t,s),fe=new Map;let he;async function Te(e){if(me.documentElement){fe.clear();const s=me.body&&me.body.scrollHeight||me.documentElement.scrollHeight,n=me.body&&me.body.scrollWidth||me.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const i=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<i||globalThis.scrollX<l)return function(e){return he=0,new Promise((async s=>{let n;const i=new Set,l=new ue((async t=>{if((t=t.filter((e=>e.type==de))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(re.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(re.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await be(l,e,E),i.size||await Ee(l,e,E))}}));async function c(t){await we("idleTimeout",(async()=>{n?he<le&&(he++,Ae("idleTimeout"),await c(Math.max(500,t/2))):(Ae("loadTimeout"),Ae("maxTimeout"),ye(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(re.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function h(t){n=!0,await be(l,e,E),await Ee(l,e,E),t.detail&&i.add(t.detail)}async function T(t){await be(l,e,E),await Ee(l,e,E),i.delete(t.detail),i.size||await Ee(l,e,E)}function E(e){l.disconnect(),pe(m,h),pe(u,T),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await be(l,e,E),l.observe(me,{subtree:!0,childList:!0,attributes:!0}),ge(m,h),ge(u,T),function(e){e.loadDeferredImagesBlockCookies&&p(new f(a)),e.loadDeferredImagesBlockStorage&&p(new f(d)),e.loadDeferredImagesDispatchScrollEvent&&p(new f(r)),e.loadDeferredImagesKeepZoomLevel?p(new f(o)):p(new f(t))}(e)}))}(e)}}}async function Ee(e,t,s){await we("loadTimeout",(()=>ye(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function be(e,t,s){await we("maxTimeout",(async()=>{await Ae("loadTimeout"),await ye(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function ye(e,t,o){await Ae("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&p(new f(i)),e.loadDeferredImagesBlockStorage&&p(new f(c)),e.loadDeferredImagesDispatchScrollEvent&&p(new f(l)),e.loadDeferredImagesKeepZoomLevel?p(new f(n)):p(new f(s))}(t),await we("endTimeout",(async()=>{await Ae("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function we(e,t,s,o){if(ce&&ce.runtime&&ce.runtime.sendMessage&&!o){if(!fe.get(e)||!fe.get(e).pending){const o={callback:t,pending:!0};fe.set(e,o);try{await ce.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){Ie(e,t,s)}o.pending=!1}}else Ie(e,t,s)}function Ie(e,t,s){const o=fe.get(e);o&&globalThis.clearTimeout(o),fe.set(e,t),globalThis.setTimeout(t,s)}async function Ae(e){if(ce&&ce.runtime&&ce.runtime.sendMessage)try{await ce.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){ve(e)}else ve(e)}function ve(e){const t=fe.get(e);fe.delete(e),t&&globalThis.clearTimeout(t)}ce&&ce.runtime&&ce.runtime.onMessage&&ce.runtime.onMessage.addListener&&ce.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=fe.get(e.type);if(t){fe.delete(e.type);try{t.callback()}catch(t){ve(e.type)}}}}));const Ne={ON_BEFORE_CAPTURE_EVENT_NAME:I,ON_AFTER_CAPTURE_EVENT_NAME:A,WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:$,serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:oe,getShadowRoot:ee},Se="__frameTree__::",Re='iframe, frame, object[type="text/html"][data]',_e="*",Ce="singlefile.frameTree.initRequest",Fe="singlefile.frameTree.ackInitRequest",Me="singlefile.frameTree.cleanupRequest",Pe="singlefile.frameTree.initResponse",xe="*",Le=5e3,De=1e4,Oe=".",qe=globalThis.window==globalThis.top,ke=globalThis.browser,Ue=globalThis.top,He=globalThis.MessageChannel,Ve=globalThis.document,Be=globalThis.JSON;let We,ze=globalThis.sessions;var je,Ye,Ge;function Ze(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Je(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(We=globalThis.frameId=e.windowId),Xe(Ve,e.options,We,t),qe||(e.options.userScriptEnabled&&s&&await s(Ne.ON_BEFORE_CAPTURE_EVENT_NAME),st({frames:[nt(Ve,globalThis,We,e.options)],sessionId:t,requestedFrameId:Ve.documentElement.dataset.requestedFrameId&&We}),e.options.userScriptEnabled&&s&&await s(Ne.ON_AFTER_CAPTURE_EVENT_NAME),delete Ve.documentElement.dataset.requestedFrameId)}function Ke(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;tt(at(Ve),e.windowId,t)}}function $e(e){e.frames.forEach((t=>Qe("responseTimeouts",e.sessionId,t.windowId)));const t=ze.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Oe).length-e.windowId.split(Oe).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Xe(e,t,s,o){const n=at(e);!function(e,t,s,o,n){const a=[];let i;ze.get(n)?i=ze.get(n).requestTimeouts:(i={},ze.set(n,{requestTimeouts:i}));t.forEach(((e,t)=>{const s=o+Oe+t;e.setAttribute(Ne.WIN_ID_ATTRIBUTE_NAME,s),a.push({windowId:s})})),st({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const a=o+Oe+t;try{ot(e.contentWindow,{method:Ce,windowId:a,sessionId:n,options:s})}catch(e){}i[a]=globalThis.setTimeout((()=>st({frames:[{windowId:a,processed:!0}],sessionId:n})),Le)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const a=[];t.forEach(((e,t)=>{const i=o+Oe+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Qe("requestTimeouts",n,i),Xe(r,s,i,n),a.push(nt(r,t,i,s))}catch(e){a.push({windowId:i,processed:!0})}})),st({frames:a,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Qe(e,t,s){const o=ze.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function et(e,t){const s=ze.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>st({frames:[{windowId:t,processed:!0}],sessionId:e})),De))}function tt(e,t,s){e.forEach(((e,o)=>{const n=t+Oe+o;e.removeAttribute(Ne.WIN_ID_ATTRIBUTE_NAME);try{ot(e.contentWindow,{method:Me,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Oe+o;let a;try{a=e.contentDocument}catch(e){}if(a)try{tt(at(a),n,s)}catch(e){}}))}function st(e){e.method=Pe;try{Ue.singlefile.processors.frameTree.initResponse(e)}catch(t){ot(Ue,e,!0)}}function ot(e,t,s){if(e==Ue&&ke&&ke.runtime&&ke.runtime.sendMessage)ke.runtime.sendMessage(t);else if(s){const s=new He;e.postMessage(Se+Be.stringify({method:t.method,sessionId:t.sessionId}),xe,[s.port2]),s.port1.postMessage(t)}else e.postMessage(Se+Be.stringify(t),xe)}function nt(e,t,s,o){const n=Ne.preProcessDoc(e,t,o),a=Ne.serialize(e);Ne.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:a,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function at(e){let t=Array.from(e.querySelectorAll(Re));return e.querySelectorAll(_e).forEach((e=>{const s=Ne.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Re)))})),t}ze||(ze=globalThis.sessions=new Map),qe&&(We="0",ke&&ke.runtime&&ke.runtime.onMessage&&ke.runtime.onMessage.addListener&&ke.runtime.onMessage.addListener((e=>e.method==Pe?($e(e),Promise.resolve({})):e.method==Fe?(Qe("requestTimeouts",e.sessionId,e.windowId),et(e.sessionId,e.windowId),Promise.resolve({})):void 0))),je="message",Ye=async e=>{if("string"==typeof e.data&&e.data.startsWith(Se)){e.preventDefault(),e.stopPropagation();const t=Be.parse(e.data.substring(Se.length));t.method==Ce?(e.source&&ot(e.source,{method:Fe,windowId:t.windowId,sessionId:t.sessionId}),qe||(globalThis.stop(),t.options.loadDeferredImages&&Te(t.options),await Je(t))):t.method==Fe?(Qe("requestTimeouts",t.sessionId,t.windowId),et(t.sessionId,t.windowId)):t.method==Me?Ke(t):t.method==Pe&&ze.get(t.sessionId)&&(e.ports[0].onmessage=e=>$e(e.data))}},Ge=!0,globalThis.addEventListener(je,Ye,Ge);var it=Object.freeze({__proto__:null,getAsync:function(e){const t=Ze();return e=Be.parse(Be.stringify(e)),new Promise((s=>{ze.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Je({windowId:We,sessionId:t,options:e})}))},getSync:function(e){const t=Ze();e=Be.parse(Be.stringify(e)),ze.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(We=globalThis.frameId=e.windowId);Xe(Ve,e.options,We,t),qe||(e.options.userScriptEnabled&&s&&s(Ne.ON_BEFORE_CAPTURE_EVENT_NAME),st({frames:[nt(Ve,globalThis,We,e.options)],sessionId:t,requestedFrameId:Ve.documentElement.dataset.requestedFrameId&&We}),e.options.userScriptEnabled&&s&&s(Ne.ON_AFTER_CAPTURE_EVENT_NAME),delete Ve.documentElement.dataset.requestedFrameId)}({windowId:We,sessionId:t,options:e});const s=ze.get(t).frames;return s.sessionId=t,s},cleanup:function(e){ze.delete(e),Ke({windowId:We,sessionId:e,options:{sessionId:e}})},initResponse:$e,TIMEOUT_INIT_REQUEST_MESSAGE:Le});const rt=["area","base","br","col","command","embed","hr","img","input","keygen","link","meta","param","source","track","wbr"],lt=1,dt=3,ct=8,mt=[{tagName:"head",accept:e=>!e.childNodes.length||e.childNodes[0].nodeType==lt},{tagName:"body",accept:e=>!e.childNodes.length}],ut=[{tagName:"html",accept:e=>!e||e.nodeType!=ct},{tagName:"head",accept:e=>!e||e.nodeType!=ct&&(e.nodeType!=dt||!ft(e.textContent))},{tagName:"body",accept:e=>!e||e.nodeType!=ct},{tagName:"li",accept:(e,t)=>!e&&t.parentElement&&("UL"==t.parentElement.tagName||"OL"==t.parentElement.tagName)||e&&["LI"].includes(e.tagName)},{tagName:"dt",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"p",accept:e=>e&&["ADDRESS","ARTICLE","ASIDE","BLOCKQUOTE","DETAILS","DIV","DL","FIELDSET","FIGCAPTION","FIGURE","FOOTER","FORM","H1","H2","H3","H4","H5","H6","HEADER","HR","MAIN","NAV","OL","P","PRE","SECTION","TABLE","UL"].includes(e.tagName)},{tagName:"dd",accept:e=>!e||["DT","DD"].includes(e.tagName)},{tagName:"rt",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"rp",accept:e=>!e||["RT","RP"].includes(e.tagName)},{tagName:"optgroup",accept:e=>!e||["OPTGROUP"].includes(e.tagName)},{tagName:"option",accept:e=>!e||["OPTION","OPTGROUP"].includes(e.tagName)},{tagName:"colgroup",accept:e=>!e||e.nodeType!=ct&&(e.nodeType!=dt||!ft(e.textContent))},{tagName:"caption",accept:e=>!e||e.nodeType!=ct&&(e.nodeType!=dt||!ft(e.textContent))},{tagName:"thead",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tbody",accept:e=>!e||["TBODY","TFOOT"].includes(e.tagName)},{tagName:"tfoot",accept:e=>!e},{tagName:"tr",accept:e=>!e||["TR"].includes(e.tagName)},{tagName:"td",accept:e=>!e||["TD","TH"].includes(e.tagName)},{tagName:"th",accept:e=>!e||["TD","TH"].includes(e.tagName)}],gt=["style","script","xmp","iframe","noembed","noframes","plaintext","noscript"];function pt(e,t,s){return e.nodeType==dt?function(e){const t=e.parentNode;let s;t&&t.nodeType==lt&&(s=t.tagName.toLowerCase());return!s||gt.includes(s)?"script"==s||"style"==s?e.textContent.replace(/<\//gi,"<\\/").replace(/\/>/gi,"\\/>"):e.textContent:e.textContent.replace(/&/g,"&amp;").replace(/\u00a0/g,"&nbsp;").replace(/</g,"&lt;").replace(/>/g,"&gt;")}(e):e.nodeType==ct?"\x3c!--"+e.textContent+"--\x3e":e.nodeType==lt?function(e,t,s){const o=e.tagName.toLowerCase(),n=t&&mt.find((t=>o==t.tagName&&t.accept(e)));let a="";n&&!e.attributes.length||(a="<"+o,Array.from(e.attributes).forEach((s=>a+=function(e,t,s){const o=e.name;let n="";if(!o.match(/["'>/=]/)){let a,i=e.value;s&&"class"==o&&(i=Array.from(t.classList).map((e=>e.trim())).join(" ")),i=i.replace(/&/g,"&amp;").replace(/\u00a0/g,"&nbsp;"),i.includes('"')&&(i.includes("'")||!s?i=i.replace(/"/g,"&quot;"):a=!0);const r=!s||i.match(/[ \t\n\f\r'"`=<>]/);n+=" ",e.namespace?"http://www.w3.org/XML/1998/namespace"==e.namespaceURI?n+="xml:"+o:"http://www.w3.org/2000/xmlns/"==e.namespaceURI?("xmlns"!==o&&(n+="xmlns:"),n+=o):"http://www.w3.org/1999/xlink"==e.namespaceURI?n+="xlink:"+o:n+=o:n+=o,""!=i&&(n+="=",r&&(n+=a?"'":'"'),n+=i,r&&(n+=a?"'":'"'))}return n}(s,e,t))),a+=">");"TEMPLATE"!=e.tagName||e.childNodes.length?Array.from(e.childNodes).forEach((e=>a+=pt(e,t,s||"svg"==o))):a+=e.innerHTML;const i=t&&ut.find((t=>o==t.tagName&&t.accept(e.nextSibling,e)));(s||!i&&!rt.includes(o))&&(a+="</"+o+">");return a}(e,t,s):void 0}function ft(e){return Boolean(e.match(/^[ \t\n\f\r]/))}const ht={frameTree:it},Tt={COMMENT_HEADER:"Page saved with SingleFile",COMMENT_HEADER_LEGACY:"Archive processed by SingleFile",ON_BEFORE_CAPTURE_EVENT_NAME:I,ON_AFTER_CAPTURE_EVENT_NAME:A,preProcessDoc:$,postProcessDoc:oe,serialize:(e,t)=>function(e,t){const s=e.doctype;let o="";return s&&(o="<!DOCTYPE "+s.nodeName,s.publicId?(o+=' PUBLIC "'+s.publicId+'"',s.systemId&&(o+=' "'+s.systemId+'"')):s.systemId&&(o+=' SYSTEM "'+s.systemId+'"'),s.internalSubset&&(o+=" ["+s.internalSubset+"]"),o+="> "),o+pt(e.documentElement,t)}(e,t),getShadowRoot:ee};Z("single-file-user-script-init",(()=>globalThis._singleFile_waitForUserScript=async e=>{const t=new CustomEvent(e+"-request",{cancelable:!0}),s=new Promise((t=>Z(e+"-response",t)));J(t),t.defaultPrevented&&await s})),e.helper=Tt,e.processors=ht,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1 +1 @@
1
- !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefile={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",i="single-file-block-cookies-start",a="single-file-block-cookies-end",r="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",m="single-file-load-image",u="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),f=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},h=globalThis.CustomEvent,p=globalThis.document,b=globalThis.Document;let E;E=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,p instanceof b&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,E.set(JSON.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,E.delete(JSON.stringify(s))})),g("single-file-clear-fonts",(()=>E=new Map)));const y="[\\x20\\t\\r\\n\\f]",T=new RegExp("\\\\([\\da-f]{1,6}"+y+"?|("+y+")|.)","ig");const w="data-single-file-removed-content",I="data-single-file-hidden-content",A="data-single-file-kept-content",v="data-single-file-hidden-frame",S="data-single-file-preserved-space-element",_="data-single-file-shadow-root-element",N="data-single-file-image",R="data-single-file-poster",M="data-single-file-video",F="data-single-file-canvas",q="data-single-file-movable-style",C="data-single-file-input-value",x="data-single-file-lazy-loaded-src",P="data-single-file-stylesheet",k="data-single-file-disabled-noscript",L="data-single-file-invalid-element",D="data-single-file-async-script",O="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",U=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],V=/^'(.*?)'$/,W=/^"(.*?)"$/,H={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},z="single-file-ui-element",B="data:,";function j(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=X(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&U.includes(s.tagName)||s.closest("details"),r||(a=i||Z(s,l),a&&(s.setAttribute(I,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(S,""),n.markedElements.push(s))}o.removeUnusedFonts&&(J(l,o,n.usedFonts),J(X(e,s,":first-letter"),o,n.usedFonts),J(X(e,s,":before"),o,n.usedFonts),J(X(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(F,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:i?B:o.loadDeferredImages&&s.getAttribute(x)||s.currentSrc};if(n.images.push(t),s.setAttribute(N,n.images.length-1),n.markedElements.push(s),s.removeAttribute(x),a=a||X(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");if(s=s||X(e,t)){let e,a,r,l,d,c,m,u,g=!1;if("content-box"==s.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=K("padding-left",s),a=K("padding-right",s),r=K("padding-top",s),l=K("padding-bottom",s),g?(d=K("border-left-width",s),c=K("border-right-width",s),m=K("border-top-width",s),u=K("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-e-a-d-c),n=Math.max(0,t.clientHeight-r-l-m-u),i&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=X(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(M,n.videos.length-1)}if(!s.getAttribute("poster")){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(R,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&i&&o.removeHiddenElements&&(s.setAttribute(v,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(C,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(C,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(C,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(C,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(D,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&Y(s);if(d&&!s.classList.contains(z)){const i={};s.setAttribute(_,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i),j(e,t,d,o,n,a),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(i.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}j(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(A)?s.parentElement&&(s.parentElement.setAttribute(A,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(w,""),n.markedElements.push(s)))})),n}function J(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=G(n),!t.loadedFonts||t.loadedFonts.find((e=>G(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),H[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(JSON.stringify(r),[n,t,o,a])}var i}))}}function Y(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function G(e=""){return function(e){e=e.match(V)?e.replace(V,"$1"):e.replace(W,"$1");return e.trim()}((t=e.trim(),t.replace(T,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function Z(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function $(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(P,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function K(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function X(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const Q={LAZY_SRC_ATTRIBUTE_NAME:x,SINGLE_FILE_UI_ELEMENT_CLASS:z},ee=10,te="attributes",se=globalThis.browser,oe=globalThis.document,ne=globalThis.MutationObserver,ie=(e,t,s)=>globalThis.addEventListener(e,t,s),ae=(e,t,s)=>globalThis.removeEventListener(e,t,s),re=new Map;let le;async function de(e){if(oe.documentElement){re.clear();const s=oe.body&&oe.body.scrollHeight||oe.documentElement.scrollHeight,n=oe.body&&oe.body.scrollWidth||oe.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const a=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<a||globalThis.scrollX<l)return function(e){return le=0,new Promise((async s=>{let n;const a=new Set,l=new ne((async t=>{if((t=t.filter((e=>e.type==te))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(Q.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(Q.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await me(l,e,E),a.size||await ce(l,e,E))}}));async function c(t){await ge("idleTimeout",(async()=>{n?le<ee&&(le++,he("idleTimeout"),await c(Math.max(500,t/2))):(he("loadTimeout"),he("maxTimeout"),ue(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(Q.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function p(t){n=!0,await me(l,e,E),await ce(l,e,E),t.detail&&a.add(t.detail)}async function b(t){await me(l,e,E),await ce(l,e,E),a.delete(t.detail),a.size||await ce(l,e,E)}function E(e){l.disconnect(),ae(m,p),ae(u,b),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await me(l,e,E),l.observe(oe,{subtree:!0,childList:!0,attributes:!0}),ie(m,p),ie(u,b),function(e){e.loadDeferredImagesBlockCookies&&f(new h(i)),e.loadDeferredImagesBlockStorage&&f(new h(d)),e.loadDeferredImagesDispatchScrollEvent&&f(new h(r)),e.loadDeferredImagesKeepZoomLevel?f(new h(o)):f(new h(t))}(e)}))}(e)}}}async function ce(e,t,s){await ge("loadTimeout",(()=>ue(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function me(e,t,s){await ge("maxTimeout",(async()=>{await he("loadTimeout"),await ue(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function ue(e,t,o){await he("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&f(new h(a)),e.loadDeferredImagesBlockStorage&&f(new h(c)),e.loadDeferredImagesDispatchScrollEvent&&f(new h(l)),e.loadDeferredImagesKeepZoomLevel?f(new h(n)):f(new h(s))}(t),await ge("endTimeout",(async()=>{await he("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function ge(e,t,s,o){if(se&&se.runtime&&se.runtime.sendMessage&&!o){if(!re.get(e)||!re.get(e).pending){const o={callback:t,pending:!0};re.set(e,o);try{await se.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){fe(e,t,s)}o.pending=!1}}else fe(e,t,s)}function fe(e,t,s){const o=re.get(e);o&&globalThis.clearTimeout(o),re.set(e,t),globalThis.setTimeout(t,s)}async function he(e){if(se&&se.runtime&&se.runtime.sendMessage)try{await se.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){pe(e)}else pe(e)}function pe(e){const t=re.get(e);re.delete(e),t&&globalThis.clearTimeout(t)}se&&se.runtime&&se.runtime.onMessage&&se.runtime.onMessage.addListener&&se.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=re.get(e.type);if(t){re.delete(e.type);try{t.callback()}catch(t){pe(e.type)}}}}));const be={ON_BEFORE_CAPTURE_EVENT_NAME:"single-file-on-before-capture",ON_AFTER_CAPTURE_EVENT_NAME:"single-file-on-after-capture",WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not(["+k+"])").forEach((e=>{e.setAttribute(k,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(O).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+O+", html > body > "+O);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const s=e.createElement("template");s.setAttribute(L,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=j(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=X(t,e);s&&Z(e,s)&&(e.setAttribute(q,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(E.values()),stylesheets:$(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}},serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("["+k+"]").forEach((e=>{e.textContent=e.getAttribute(k),e.removeAttribute(k)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[w,v,I,S,N,R,M,F,C,_,P,D];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(w),e.removeAttribute(I),e.removeAttribute(A),e.removeAttribute(v),e.removeAttribute(S),e.removeAttribute(N),e.removeAttribute(R),e.removeAttribute(M),e.removeAttribute(F),e.removeAttribute(C),e.removeAttribute(_),e.removeAttribute(P),e.removeAttribute(D),e.removeAttribute(q)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))},getShadowRoot:Y},Ee="__frameTree__::",ye='iframe, frame, object[type="text/html"][data]',Te="*",we="singlefile.frameTree.initRequest",Ie="singlefile.frameTree.ackInitRequest",Ae="singlefile.frameTree.cleanupRequest",ve="singlefile.frameTree.initResponse",Se="*",_e=5e3,Ne=1e4,Re=".",Me=globalThis.window==globalThis.top,Fe=globalThis.browser,qe=globalThis.top,Ce=globalThis.MessageChannel,xe=globalThis.document;let Pe,ke=globalThis.sessions;var Le,De,Oe;function Ue(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function Ve(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Me||(Pe=globalThis.frameId=e.windowId),ze(xe,e.options,Pe,t),Me||(e.options.userScriptEnabled&&s&&await s(be.ON_BEFORE_CAPTURE_EVENT_NAME),Ye({frames:[Ze(xe,globalThis,Pe,e.options)],sessionId:t,requestedFrameId:xe.documentElement.dataset.requestedFrameId&&Pe}),e.options.userScriptEnabled&&s&&await s(be.ON_AFTER_CAPTURE_EVENT_NAME),delete xe.documentElement.dataset.requestedFrameId)}function We(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;Je($e(xe),e.windowId,t)}}function He(e){e.frames.forEach((t=>Be("responseTimeouts",e.sessionId,t.windowId)));const t=ke.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Re).length-e.windowId.split(Re).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function ze(e,t,s,o){const n=$e(e);!function(e,t,s,o,n){const i=[];let a;ke.get(n)?a=ke.get(n).requestTimeouts:(a={},ke.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+Re+t;e.setAttribute(be.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),Ye({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+Re+t;try{Ge(e.contentWindow,{method:we,windowId:i,sessionId:n,options:s})}catch(e){}a[i]=globalThis.setTimeout((()=>Ye({frames:[{windowId:i,processed:!0}],sessionId:n})),_e)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+Re+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Be("requestTimeouts",n,a),ze(r,s,a,n),i.push(Ze(r,t,a,s))}catch(e){i.push({windowId:a,processed:!0})}})),Ye({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Be(e,t,s){const o=ke.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function je(e,t){const s=ke.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>Ye({frames:[{windowId:t,processed:!0}],sessionId:e})),Ne))}function Je(e,t,s){e.forEach(((e,o)=>{const n=t+Re+o;e.removeAttribute(be.WIN_ID_ATTRIBUTE_NAME);try{Ge(e.contentWindow,{method:Ae,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Re+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{Je($e(i),n,s)}catch(e){}}))}function Ye(e){e.method=ve;try{qe.singlefile.processors.frameTree.initResponse(e)}catch(t){Ge(qe,e,!0)}}function Ge(e,t,s){if(e==qe&&Fe&&Fe.runtime&&Fe.runtime.sendMessage)Fe.runtime.sendMessage(t);else if(s){const s=new Ce;e.postMessage(Ee+JSON.stringify({method:t.method,sessionId:t.sessionId}),Se,[s.port2]),s.port1.postMessage(t)}else e.postMessage(Ee+JSON.stringify(t),Se)}function Ze(e,t,s,o){const n=be.preProcessDoc(e,t,o),i=be.serialize(e);be.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function $e(e){let t=Array.from(e.querySelectorAll(ye));return e.querySelectorAll(Te).forEach((e=>{const s=be.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(ye)))})),t}ke||(ke=globalThis.sessions=new Map),Me&&(Pe="0",Fe&&Fe.runtime&&Fe.runtime.onMessage&&Fe.runtime.onMessage.addListener&&Fe.runtime.onMessage.addListener((e=>e.method==ve?(He(e),Promise.resolve({})):e.method==Ie?(Be("requestTimeouts",e.sessionId,e.windowId),je(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Le="message",De=async e=>{if("string"==typeof e.data&&e.data.startsWith(Ee)){e.preventDefault(),e.stopPropagation();const t=JSON.parse(e.data.substring(Ee.length));t.method==we?(e.source&&Ge(e.source,{method:Ie,windowId:t.windowId,sessionId:t.sessionId}),Me||(globalThis.stop(),t.options.loadDeferredImages&&de(t.options),await Ve(t))):t.method==Ie?(Be("requestTimeouts",t.sessionId,t.windowId),je(t.sessionId,t.windowId)):t.method==Ae?We(t):t.method==ve&&ke.get(t.sessionId)&&(e.ports[0].onmessage=e=>He(e.data))}},Oe=!0,globalThis.addEventListener(Le,De,Oe),e.TIMEOUT_INIT_REQUEST_MESSAGE=_e,e.cleanup=function(e){ke.delete(e),We({windowId:Pe,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=Ue();return e=JSON.parse(JSON.stringify(e)),new Promise((s=>{ke.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),Ve({windowId:Pe,sessionId:t,options:e})}))},e.getSync=function(e){const t=Ue();e=JSON.parse(JSON.stringify(e)),ke.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,Me||(Pe=globalThis.frameId=e.windowId);ze(xe,e.options,Pe,t),Me||(e.options.userScriptEnabled&&s&&s(be.ON_BEFORE_CAPTURE_EVENT_NAME),Ye({frames:[Ze(xe,globalThis,Pe,e.options)],sessionId:t,requestedFrameId:xe.documentElement.dataset.requestedFrameId&&Pe}),e.options.userScriptEnabled&&s&&s(be.ON_AFTER_CAPTURE_EVENT_NAME),delete xe.documentElement.dataset.requestedFrameId)}({windowId:Pe,sessionId:t,options:e});const s=ke.get(t).frames;return s.sessionId=t,s},e.initResponse=He,Object.defineProperty(e,"__esModule",{value:!0})}));
1
+ !function(e,t){"object"==typeof exports&&"undefined"!=typeof module?t(exports):"function"==typeof define&&define.amd?define(["exports"],t):t((e="undefined"!=typeof globalThis?globalThis:e||self).singlefile={})}(this,(function(e){"use strict";const t="single-file-load-deferred-images-start",s="single-file-load-deferred-images-end",o="single-file-load-deferred-images-keep-zoom-level-start",n="single-file-load-deferred-images-keep-zoom-level-end",i="single-file-block-cookies-start",a="single-file-block-cookies-end",r="single-file-dispatch-scroll-event-start",l="single-file-dispatch-scroll-event-end",d="single-file-block-storage-start",c="single-file-block-storage-end",m="single-file-load-image",u="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),f=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},h=globalThis.CustomEvent,p=globalThis.document,b=globalThis.Document,E=globalThis.JSON;let y;y=window._singleFile_fontFaces?window._singleFile_fontFaces:window._singleFile_fontFaces=new Map,p instanceof b&&(g("single-file-new-font-face",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,y.set(E.stringify(s),t)})),g("single-file-delete-font",(e=>{const t=e.detail,s=Object.assign({},t);delete s.src,y.delete(E.stringify(s))})),g("single-file-clear-fonts",(()=>y=new Map)));const T="[\\x20\\t\\r\\n\\f]",w=new RegExp("\\\\([\\da-f]{1,6}"+T+"?|("+T+")|.)","ig");const I="data-single-file-removed-content",A="data-single-file-hidden-content",v="data-single-file-kept-content",S="data-single-file-hidden-frame",_="data-single-file-preserved-space-element",R="data-single-file-shadow-root-element",N="data-single-file-image",M="data-single-file-poster",F="data-single-file-video",q="data-single-file-canvas",C="data-single-file-movable-style",x="data-single-file-input-value",P="data-single-file-lazy-loaded-src",k="data-single-file-stylesheet",L="data-single-file-disabled-noscript",D="data-single-file-invalid-element",U="data-single-file-async-script",O="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",V=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],W=/^'(.*?)'$/,H=/^"(.*?)"$/,z={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},B="single-file-ui-element",j="data:,",Y=globalThis.JSON;function G(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){return Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let a,r,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=ee(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(r=(i||s.closest("html > head"))&&V.includes(s.tagName)||s.closest("details"),r||(a=i||K(s,l),a&&(s.setAttribute(A,""),n.markedElements.push(s)))),!a)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(_,""),n.markedElements.push(s))}o.removeUnusedFonts&&(Z(l,o,n.usedFonts),Z(ee(e,s,":first-letter"),o,n.usedFonts),Z(ee(e,s,":before"),o,n.usedFonts),Z(ee(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,a){if("CANVAS"==s.tagName)try{n.canvases.push({dataURI:s.toDataURL("image/png","")}),s.setAttribute(q,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==s.tagName){const t={currentSrc:i?j:o.loadDeferredImages&&s.getAttribute(P)||s.currentSrc};if(n.images.push(t),s.setAttribute(N,n.images.length-1),n.markedElements.push(s),s.removeAttribute(P),a=a||ee(e,s)){t.size=function(e,t,s){let o=t.naturalWidth,n=t.naturalHeight;if(!o&&!n){const i=null==t.getAttribute("style");if(s=s||ee(e,t)){let e,a,r,l,d,c,m,u,g=!1;if("content-box"==s.getPropertyValue("box-sizing")){const e=t.style.getPropertyValue("box-sizing"),s=t.style.getPropertyPriority("box-sizing"),o=t.clientWidth;t.style.setProperty("box-sizing","border-box","important"),g=t.clientWidth!=o,e?t.style.setProperty("box-sizing",e,s):t.style.removeProperty("box-sizing")}e=Q("padding-left",s),a=Q("padding-right",s),r=Q("padding-top",s),l=Q("padding-bottom",s),g?(d=Q("border-left-width",s),c=Q("border-right-width",s),m=Q("border-top-width",s),u=Q("border-bottom-width",s)):d=c=m=u=0,o=Math.max(0,t.clientWidth-e-a-d-c),n=Math.max(0,t.clientHeight-r-l-m-u),i&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,a);const o=a.getPropertyValue("box-shadow"),n=a.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=a.getPropertyValue("background-color"),t.objectFit=a.getPropertyValue("object-fit"),t.boxSizing=a.getPropertyValue("box-sizing"),t.objectPosition=a.getPropertyValue("object-position"))}}if("VIDEO"==s.tagName){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=ee(e,s.parentNode);n.videos.push({positionParent:t&&t.getPropertyValue("position"),src:o,size:{pxWidth:s.clientWidth,pxHeight:s.clientHeight},currentTime:s.currentTime}),s.setAttribute(F,n.videos.length-1)}if(!s.getAttribute("poster")){const e=t.createElement("canvas"),o=e.getContext("2d");e.width=s.clientWidth,e.height=s.clientHeight;try{o.drawImage(s,0,0,e.width,e.height),n.posters.push(e.toDataURL("image/png","")),s.setAttribute(M,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==s.tagName&&i&&o.removeHiddenElements&&(s.setAttribute(S,""),n.markedElements.push(s));"INPUT"==s.tagName&&("password"!=s.type&&(s.setAttribute(x,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(x,s.checked),n.markedElements.push(s)));"TEXTAREA"==s.tagName&&(s.setAttribute(x,s.value),n.markedElements.push(s));"SELECT"==s.tagName&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(x,""),n.markedElements.push(e))}));"SCRIPT"==s.tagName&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(U,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,a,l);const d=!(s instanceof e.SVGElement)&&J(s);if(d&&!s.classList.contains(B)){const i={};s.setAttribute(R,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i),G(e,t,d,o,n,a),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&d.adoptedStyleSheets.length&&(i.adoptedStyleSheets=Array.from(d.adoptedStyleSheets).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))))}catch(e){}}G(e,t,s,o,n,a),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(r||""==s.getAttribute(v)?s.parentElement&&(s.parentElement.setAttribute(v,""),n.markedElements.push(s.parentElement)):a&&(s.setAttribute(I,""),n.markedElements.push(s)))})),n}function Z(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=$(n),!t.loadedFonts||t.loadedFonts.find((e=>$(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),z[i.toLowerCase().trim()]||i),a=e.getPropertyValue("font-variant")||"normal",r=[n,t,o,a];s.set(Y.stringify(r),[n,t,o,a])}var i}))}}function J(e){const t=globalThis.chrome;if(e.openOrClosedShadowRoot)return e.openOrClosedShadowRoot;if(!(t&&t.dom&&t.dom.openOrClosedShadowRoot))return e.shadowRoot;try{return t.dom.openOrClosedShadowRoot(e)}catch(t){return e.shadowRoot}}function $(e=""){return function(e){e=e.match(W)?e.replace(W,"$1"):e.replace(H,"$1");return e.trim()}((t=e.trim(),t.replace(w,((e,t,s)=>{const o="0x"+t-65536;return o!=o||s?t:o<0?String.fromCharCode(o+65536):String.fromCharCode(o>>10|55296,1023&o|56320)})))).toLowerCase();var t}function K(e,t){let s=!1;if(t){const o=t.getPropertyValue("display"),n=t.getPropertyValue("opacity"),i=t.getPropertyValue("visibility");if(s="none"==o,!s&&("0"==n||"hidden"==i)&&e.getBoundingClientRect){const t=e.getBoundingClientRect();s=!t.width&&!t.height}}return Boolean(s)}function X(e){if(e){const t=[];return e.querySelectorAll("style").forEach(((s,o)=>{try{const n=e.createElement("style");n.textContent=s.textContent,e.body.appendChild(n);const i=n.sheet;n.remove(),i&&i.cssRules.length==s.sheet.cssRules.length||(s.setAttribute(k,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function Q(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function ee(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const te={LAZY_SRC_ATTRIBUTE_NAME:P,SINGLE_FILE_UI_ELEMENT_CLASS:B},se=10,oe="attributes",ne=globalThis.browser,ie=globalThis.document,ae=globalThis.MutationObserver,re=(e,t,s)=>globalThis.addEventListener(e,t,s),le=(e,t,s)=>globalThis.removeEventListener(e,t,s),de=new Map;let ce;async function me(e){if(ie.documentElement){de.clear();const s=ie.body&&ie.body.scrollHeight||ie.documentElement.scrollHeight,n=ie.body&&ie.body.scrollWidth||ie.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const a=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY<a||globalThis.scrollX<l)return function(e){return ce=0,new Promise((async s=>{let n;const a=new Set,l=new ae((async t=>{if((t=t.filter((e=>e.type==oe))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(te.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||"SOURCE"==e.target.tagName)return!e.target.classList||!e.target.classList.contains(te.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await ge(l,e,E),a.size||await ue(l,e,E))}}));async function c(t){await he("idleTimeout",(async()=>{n?ce<se&&(ce++,be("idleTimeout"),await c(Math.max(500,t/2))):(be("loadTimeout"),be("maxTimeout"),fe(l,e,E))}),t,e.loadDeferredImagesNativeTimeout)}function g(e){const t=e.target;t.removeAttribute(te.LAZY_SRC_ATTRIBUTE_NAME),t.removeEventListener("load",g)}async function p(t){n=!0,await ge(l,e,E),await ue(l,e,E),t.detail&&a.add(t.detail)}async function b(t){await ge(l,e,E),await ue(l,e,E),a.delete(t.detail),a.size||await ue(l,e,E)}function E(e){l.disconnect(),le(m,p),le(u,b),s(e)}await c(2*e.loadDeferredImagesMaxIdleTime),await ge(l,e,E),l.observe(ie,{subtree:!0,childList:!0,attributes:!0}),re(m,p),re(u,b),function(e){e.loadDeferredImagesBlockCookies&&f(new h(i)),e.loadDeferredImagesBlockStorage&&f(new h(d)),e.loadDeferredImagesDispatchScrollEvent&&f(new h(r)),e.loadDeferredImagesKeepZoomLevel?f(new h(o)):f(new h(t))}(e)}))}(e)}}}async function ue(e,t,s){await he("loadTimeout",(()=>fe(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function ge(e,t,s){await he("maxTimeout",(async()=>{await be("loadTimeout"),await fe(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function fe(e,t,o){await be("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&f(new h(a)),e.loadDeferredImagesBlockStorage&&f(new h(c)),e.loadDeferredImagesDispatchScrollEvent&&f(new h(l)),e.loadDeferredImagesKeepZoomLevel?f(new h(n)):f(new h(s))}(t),await he("endTimeout",(async()=>{await be("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function he(e,t,s,o){if(ne&&ne.runtime&&ne.runtime.sendMessage&&!o){if(!de.get(e)||!de.get(e).pending){const o={callback:t,pending:!0};de.set(e,o);try{await ne.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){pe(e,t,s)}o.pending=!1}}else pe(e,t,s)}function pe(e,t,s){const o=de.get(e);o&&globalThis.clearTimeout(o),de.set(e,t),globalThis.setTimeout(t,s)}async function be(e){if(ne&&ne.runtime&&ne.runtime.sendMessage)try{await ne.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Ee(e)}else Ee(e)}function Ee(e){const t=de.get(e);de.delete(e),t&&globalThis.clearTimeout(t)}ne&&ne.runtime&&ne.runtime.onMessage&&ne.runtime.onMessage.addListener&&ne.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=de.get(e.type);if(t){de.delete(e.type);try{t.callback()}catch(t){Ee(e.type)}}}}));const ye={ON_BEFORE_CAPTURE_EVENT_NAME:"single-file-on-before-capture",ON_AFTER_CAPTURE_EVENT_NAME:"single-file-on-after-capture",WIN_ID_ATTRIBUTE_NAME:"data-single-file-win-id",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not(["+L+"])").forEach((e=>{e.setAttribute(L,e.textContent),e.textContent=""})),function(e){e.querySelectorAll("meta[http-equiv=refresh]").forEach((e=>{e.removeAttribute("http-equiv"),e.setAttribute("disabled-http-equiv","refresh")}))}(e),e.head&&e.head.querySelectorAll(O).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+O+", html > body > "+O);t.length&&(Array.from(e.childNodes).forEach((e=>e.remove())),t.forEach((t=>e.appendChild(t))))}));const o=new Map;let n;return t&&e.documentElement?(e.querySelectorAll("button button, a a").forEach((t=>{const s=e.createElement("template");s.setAttribute(D,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=G(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=ee(t,e);s&&K(e,s)&&(e.setAttribute(C,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(y.values()),stylesheets:X(e),images:n.images,posters:n.posters,videos:n.videos,usedFonts:Array.from(n.usedFonts.values()),shadowRoots:n.shadowRoots,referrer:e.referrer,markedElements:n.markedElements,invalidElements:o}},serialize:function(e){const t=e.doctype;let s="";return t&&(s="<!DOCTYPE "+t.nodeName,t.publicId?(s+=' PUBLIC "'+t.publicId+'"',t.systemId&&(s+=' "'+t.systemId+'"')):t.systemId&&(s+=' SYSTEM "'+t.systemId+'"'),t.internalSubset&&(s+=" ["+t.internalSubset+"]"),s+="> "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("["+L+"]").forEach((e=>{e.textContent=e.getAttribute(L),e.removeAttribute(L)})),e.querySelectorAll("meta[disabled-http-equiv]").forEach((e=>{e.setAttribute("http-equiv",e.getAttribute("disabled-http-equiv")),e.removeAttribute("disabled-http-equiv")})),e.head&&e.head.querySelectorAll("*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)").forEach((e=>e.removeAttribute("hidden"))),!t){const s=[I,S,A,_,N,M,F,q,x,R,k,U];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(I),e.removeAttribute(A),e.removeAttribute(v),e.removeAttribute(S),e.removeAttribute(_),e.removeAttribute(N),e.removeAttribute(M),e.removeAttribute(F),e.removeAttribute(q),e.removeAttribute(x),e.removeAttribute(R),e.removeAttribute(k),e.removeAttribute(U),e.removeAttribute(C)})),s&&Array.from(s.entries()).forEach((([e,t])=>t.replaceWith(e)))},getShadowRoot:J},Te="__frameTree__::",we='iframe, frame, object[type="text/html"][data]',Ie="*",Ae="singlefile.frameTree.initRequest",ve="singlefile.frameTree.ackInitRequest",Se="singlefile.frameTree.cleanupRequest",_e="singlefile.frameTree.initResponse",Re="*",Ne=5e3,Me=1e4,Fe=".",qe=globalThis.window==globalThis.top,Ce=globalThis.browser,xe=globalThis.top,Pe=globalThis.MessageChannel,ke=globalThis.document,Le=globalThis.JSON;let De,Ue=globalThis.sessions;var Oe,Ve,We;function He(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function ze(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(De=globalThis.frameId=e.windowId),Ye(ke,e.options,De,t),qe||(e.options.userScriptEnabled&&s&&await s(ye.ON_BEFORE_CAPTURE_EVENT_NAME),$e({frames:[Xe(ke,globalThis,De,e.options)],sessionId:t,requestedFrameId:ke.documentElement.dataset.requestedFrameId&&De}),e.options.userScriptEnabled&&s&&await s(ye.ON_AFTER_CAPTURE_EVENT_NAME),delete ke.documentElement.dataset.requestedFrameId)}function Be(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;Je(Qe(ke),e.windowId,t)}}function je(e){e.frames.forEach((t=>Ge("responseTimeouts",e.sessionId,t.windowId)));const t=Ue.get(e.sessionId);if(t){e.requestedFrameId&&(t.requestedFrameId=e.requestedFrameId),e.frames.forEach((e=>{let s=t.frames.find((t=>e.windowId==t.windowId));s||(s={windowId:e.windowId},t.frames.push(s)),s.processed||(s.content=e.content,s.baseURI=e.baseURI,s.title=e.title,s.canvases=e.canvases,s.fonts=e.fonts,s.stylesheets=e.stylesheets,s.images=e.images,s.posters=e.posters,s.videos=e.videos,s.usedFonts=e.usedFonts,s.shadowRoots=e.shadowRoots,s.processed=e.processed)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Fe).length-e.windowId.split(Fe).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Ye(e,t,s,o){const n=Qe(e);!function(e,t,s,o,n){const i=[];let a;Ue.get(n)?a=Ue.get(n).requestTimeouts:(a={},Ue.set(n,{requestTimeouts:a}));t.forEach(((e,t)=>{const s=o+Fe+t;e.setAttribute(ye.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),$e({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+Fe+t;try{Ke(e.contentWindow,{method:Ae,windowId:i,sessionId:n,options:s})}catch(e){}a[i]=globalThis.setTimeout((()=>$e({frames:[{windowId:i,processed:!0}],sessionId:n})),Ne)})),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o),n.length&&function(e,t,s,o,n){const i=[];t.forEach(((e,t)=>{const a=o+Fe+t;let r;try{r=e.contentDocument}catch(e){}if(r)try{const t=e.contentWindow;t.stop(),Ge("requestTimeouts",n,a),Ye(r,s,a,n),i.push(Xe(r,t,a,s))}catch(e){i.push({windowId:a,processed:!0})}})),$e({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function Ge(e,t,s){const o=Ue.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function Ze(e,t){const s=Ue.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>$e({frames:[{windowId:t,processed:!0}],sessionId:e})),Me))}function Je(e,t,s){e.forEach(((e,o)=>{const n=t+Fe+o;e.removeAttribute(ye.WIN_ID_ATTRIBUTE_NAME);try{Ke(e.contentWindow,{method:Se,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Fe+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{Je(Qe(i),n,s)}catch(e){}}))}function $e(e){e.method=_e;try{xe.singlefile.processors.frameTree.initResponse(e)}catch(t){Ke(xe,e,!0)}}function Ke(e,t,s){if(e==xe&&Ce&&Ce.runtime&&Ce.runtime.sendMessage)Ce.runtime.sendMessage(t);else if(s){const s=new Pe;e.postMessage(Te+Le.stringify({method:t.method,sessionId:t.sessionId}),Re,[s.port2]),s.port1.postMessage(t)}else e.postMessage(Te+Le.stringify(t),Re)}function Xe(e,t,s,o){const n=ye.preProcessDoc(e,t,o),i=ye.serialize(e);ye.postProcessDoc(e,n.markedElements,n.invalidElements);return{windowId:s,content:i,baseURI:e.baseURI.split("#")[0],title:e.title,canvases:n.canvases,fonts:n.fonts,stylesheets:n.stylesheets,images:n.images,posters:n.posters,videos:n.videos,usedFonts:n.usedFonts,shadowRoots:n.shadowRoots,processed:!0}}function Qe(e){let t=Array.from(e.querySelectorAll(we));return e.querySelectorAll(Ie).forEach((e=>{const s=ye.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(we)))})),t}Ue||(Ue=globalThis.sessions=new Map),qe&&(De="0",Ce&&Ce.runtime&&Ce.runtime.onMessage&&Ce.runtime.onMessage.addListener&&Ce.runtime.onMessage.addListener((e=>e.method==_e?(je(e),Promise.resolve({})):e.method==ve?(Ge("requestTimeouts",e.sessionId,e.windowId),Ze(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Oe="message",Ve=async e=>{if("string"==typeof e.data&&e.data.startsWith(Te)){e.preventDefault(),e.stopPropagation();const t=Le.parse(e.data.substring(Te.length));t.method==Ae?(e.source&&Ke(e.source,{method:ve,windowId:t.windowId,sessionId:t.sessionId}),qe||(globalThis.stop(),t.options.loadDeferredImages&&me(t.options),await ze(t))):t.method==ve?(Ge("requestTimeouts",t.sessionId,t.windowId),Ze(t.sessionId,t.windowId)):t.method==Se?Be(t):t.method==_e&&Ue.get(t.sessionId)&&(e.ports[0].onmessage=e=>je(e.data))}},We=!0,globalThis.addEventListener(Oe,Ve,We),e.TIMEOUT_INIT_REQUEST_MESSAGE=Ne,e.cleanup=function(e){Ue.delete(e),Be({windowId:De,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=He();return e=Le.parse(Le.stringify(e)),new Promise((s=>{Ue.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),ze({windowId:De,sessionId:t,options:e})}))},e.getSync=function(e){const t=He();e=Le.parse(Le.stringify(e)),Ue.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis._singleFile_waitForUserScript;delete globalThis._singleFile_cleaningUp,qe||(De=globalThis.frameId=e.windowId);Ye(ke,e.options,De,t),qe||(e.options.userScriptEnabled&&s&&s(ye.ON_BEFORE_CAPTURE_EVENT_NAME),$e({frames:[Xe(ke,globalThis,De,e.options)],sessionId:t,requestedFrameId:ke.documentElement.dataset.requestedFrameId&&De}),e.options.userScriptEnabled&&s&&s(ye.ON_AFTER_CAPTURE_EVENT_NAME),delete ke.documentElement.dataset.requestedFrameId)}({windowId:De,sessionId:t,options:e});const s=Ue.get(t).frames;return s.sessionId=t,s},e.initResponse=je,Object.defineProperty(e,"__esModule",{value:!0})}));
@@ -1 +1 @@
1
- !function(){"use strict";(e=>{const t="single-file-lazy-load",n="single-file-load-image",i="single-file-image-loaded",r="single-file-new-font-face",o={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"},l=(t,n,i)=>e.addEventListener(t,n,i),s=t=>{try{e.dispatchEvent(t)}catch(e){}},c=e.CustomEvent,d=e.document,a=e.screen,g=e.Element,f=e.UIEvent,_=e.Event,m=e.FileReader,u=e.Blob,h=e.console,y=h&&h.warn&&((...e)=>h.warn(...e))||(()=>{}),p=new Map,F=new Map;let E;function w(r){const o=d.scrollingElement||d.documentElement,l=o.clientHeight,f=o.clientWidth,m=Math.max(o.scrollHeight-l,l),u=Math.max(o.scrollWidth-f,f);if(d.querySelectorAll("[loading=lazy]").forEach((e=>{e.loading="eager",e.setAttribute(t,"")})),o.__defineGetter__("clientHeight",(()=>m)),o.__defineGetter__("clientWidth",(()=>u)),a.__defineGetter__("height",(()=>m)),a.__defineGetter__("width",(()=>u)),e._singleFile_innerHeight=e.innerHeight,e._singleFile_innerWidth=e.innerWidth,e.__defineGetter__("innerHeight",(()=>m)),e.__defineGetter__("innerWidth",(()=>u)),r||e._singleFile_getBoundingClientRect||(e._singleFile_getBoundingClientRect=g.prototype.getBoundingClientRect,g.prototype.getBoundingClientRect=function(){const t=e._singleFile_getBoundingClientRect.call(this);return this==o&&(t.__defineGetter__("height",(()=>m)),t.__defineGetter__("bottom",(()=>m+t.top)),t.__defineGetter__("width",(()=>u)),t.__defineGetter__("right",(()=>u+t.left))),t}),!e._singleFileImage){const t=e.Image;e._singleFileImage=e.Image,e.__defineGetter__("Image",(function(){return function(){const e=new t(...arguments),r=new t(...arguments);return r.__defineSetter__("src",(t=>{e.src=t,s(new c(n,{detail:e.src}))})),r.__defineGetter__("src",(()=>e.src)),r.__defineSetter__("srcset",(t=>{s(new c(n)),e.srcset=t})),r.__defineGetter__("srcset",(()=>e.srcset)),r.__defineGetter__("height",(()=>e.height)),r.__defineGetter__("width",(()=>e.width)),r.__defineGetter__("naturalHeight",(()=>e.naturalHeight)),r.__defineGetter__("naturalWidth",(()=>e.naturalWidth)),e.decode&&r.__defineGetter__("decode",(()=>()=>e.decode())),e.onload=e.onloadend=e.onerror=t=>{s(new c(i,{detail:e.src})),r.dispatchEvent(new _(t.type,t))},r}}))}let h,y;r?(h=l/m,y=f/u):(h=(l+e.scrollY)/m,y=(f+e.scrollX)/u);const E=Math.min(h,y);if(E<1){const e=d.documentElement.style.getPropertyValue("transform"),t=d.documentElement.style.getPropertyPriority("transform"),n=d.documentElement.style.getPropertyValue("transform-origin"),i=d.documentElement.style.getPropertyPriority("transform-origin"),o=d.documentElement.style.getPropertyValue("min-height"),l=d.documentElement.style.getPropertyPriority("min-height");d.documentElement.style.setProperty("transform-origin",(h<1?"50%":"0")+" "+(y<1?"50%":"0")+" 0","important"),d.documentElement.style.setProperty("transform","scale3d("+E+", "+E+", 1)","important"),d.documentElement.style.setProperty("min-height",100/E+"vh","important"),B(),r?(d.documentElement.style.setProperty("-sf-transform",e,t),d.documentElement.style.setProperty("-sf-transform-origin",n,i),d.documentElement.style.setProperty("-sf-min-height",o,l)):(d.documentElement.style.setProperty("transform",e,t),d.documentElement.style.setProperty("transform-origin",n,i),d.documentElement.style.setProperty("min-height",o,l))}if(!r){B();const e=o.getBoundingClientRect();window==window.top&&[...p].forEach((([t,n])=>{const i=n.options&&n.options.root&&n.options.root.getBoundingClientRect,r=i&&n.options.root.getBoundingClientRect(),o=F.get(t);if(o){const l=o.map((t=>{const n=t.getBoundingClientRect();return{target:t,intersectionRatio:1,boundingClientRect:n,intersectionRect:n,isIntersecting:!0,rootBounds:i?r:e,time:0}}));n.callback(l,t)}}))}}function v(n){d.querySelectorAll("["+t+"]").forEach((e=>{e.loading="lazy",e.removeAttribute(t)})),n||e._singleFile_getBoundingClientRect&&(g.prototype.getBoundingClientRect=e._singleFile_getBoundingClientRect,delete e._singleFile_getBoundingClientRect),e._singleFileImage&&(delete e.Image,e.Image=e._singleFileImage,delete e._singleFileImage),n||B()}function P(){const t=d.scrollingElement||d.documentElement;null!=e._singleFile_innerHeight&&(delete e.innerHeight,e.innerHeight=e._singleFile_innerHeight,delete e._singleFile_innerHeight),null!=e._singleFile_innerWidth&&(delete e.innerWidth,e.innerWidth=e._singleFile_innerWidth,delete e._singleFile_innerWidth),delete t.clientHeight,delete t.clientWidth,delete a.height,delete a.width}if(l("single-file-load-deferred-images-start",(()=>w())),l("single-file-load-deferred-images-keep-zoom-level-start",(()=>w(!0))),l("single-file-load-deferred-images-end",(()=>v())),l("single-file-load-deferred-images-keep-zoom-level-end",(()=>v(!0))),l("single-file-load-deferred-images-reset",P),l("single-file-load-deferred-images-keep-zoom-level-reset",(()=>{const e=d.documentElement.style.getPropertyValue("-sf-transform"),t=d.documentElement.style.getPropertyPriority("-sf-transform"),n=d.documentElement.style.getPropertyValue("-sf-transform-origin"),i=d.documentElement.style.getPropertyPriority("-sf-transform-origin"),r=d.documentElement.style.getPropertyValue("-sf-min-height"),o=d.documentElement.style.getPropertyPriority("-sf-min-height");d.documentElement.style.setProperty("transform",e,t),d.documentElement.style.setProperty("transform-origin",n,i),d.documentElement.style.setProperty("min-height",r,o),d.documentElement.style.removeProperty("-sf-transform"),d.documentElement.style.removeProperty("-sf-transform-origin"),d.documentElement.style.removeProperty("-sf-min-height"),P()})),l("single-file-dispatch-scroll-event-start",(()=>{E=!0})),l("single-file-dispatch-scroll-event-end",(()=>{E=!1})),l("single-file-block-cookies-start",(()=>{try{d.__defineGetter__("cookie",(()=>{throw new Error("document.cookie temporary blocked by SingleFile")}))}catch(e){}})),l("single-file-block-cookies-end",(()=>{delete d.cookie})),l("single-file-block-storage-start",(()=>{e._singleFile_localStorage||(e._singleFile_localStorage=e.localStorage,e.__defineGetter__("localStorage",(()=>{throw new Error("localStorage temporary blocked by SingleFile")}))),e._singleFile_indexedDB||(e._singleFile_indexedDB=e.indexedDB,e.__defineGetter__("indexedDB",(()=>{throw new Error("indexedDB temporary blocked by SingleFile")})))})),l("single-file-block-storage-end",(()=>{e._singleFile_localStorage&&(delete e.localStorage,e.localStorage=e._singleFile_localStorage,delete e._singleFile_localStorage),e._singleFile_indexedDB||(delete e.indexedDB,e.indexedDB=e._singleFile_indexedDB,delete e._singleFile_indexedDB)})),l("single-file-request-fetch",(async t=>{s(new c("single-file-ack-fetch"));const{url:n,options:i}=JSON.parse(t.detail);let r;try{const t=await((t,n)=>e.fetch(t,n))(n,i);r={url:n,response:await t.arrayBuffer(),headers:[...t.headers],status:t.status}}catch(e){r={url:n,error:e&&e.toString()}}s(new c("single-file-response-fetch",{detail:r}))})),e.FontFace){const t=e.FontFace;let n;e.FontFace=function(){return n||(y("SingleFile is hooking the FontFace constructor, document.fonts.delete and document.fonts.clear to handle dynamically loaded fonts."),n=!0),b(...arguments).then((e=>s(new c(r,{detail:e})))),new t(...arguments)},e.FontFace.toString=function(){return"function FontFace() { [native code] }"};const i=d.fonts.delete;d.fonts.delete=function(e){return b(e.family).then((e=>s(new c("single-file-delete-font",{detail:e})))),i.call(d.fonts,e)},d.fonts.delete.toString=function(){return"function delete() { [native code] }"};const o=d.fonts.clear;d.fonts.clear=function(){return s(new c("single-file-clear-fonts")),o.call(d.fonts)},d.fonts.clear.toString=function(){return"function clear() { [native code] }"}}if(e.IntersectionObserver){const t=e.IntersectionObserver;let n;e.IntersectionObserver=function(){n||(y("SingleFile is hooking the IntersectionObserver API to detect and load deferred images."),n=!0);const e=new t(...arguments),i=t.prototype.observe||e.observe,r=t.prototype.unobserve||e.unobserve,o=arguments[0],l=arguments[1];return i&&(e.observe=function(t){let n=F.get(e);return n||(n=[],F.set(e,n)),n.push(t),i.call(e,t)}),r&&(e.unobserve=function(t){let n=F.get(e);return n&&(n=n.filter((e=>e!=t)),n.length?F.set(e,n):(F.delete(e),p.delete(e))),r.call(e,t)}),p.set(e,{callback:o,options:l}),e},e.IntersectionObserver.prototype=t.prototype,e.IntersectionObserver.toString=function(){return"function IntersectionObserver() { [native code] }"}}async function b(e,t,n){const i={};return i["font-family"]=e,i.src=t,n&&Object.keys(n).forEach((e=>{o[e]&&(i[o[e]]=n[e])})),new Promise((e=>{if(i.src instanceof ArrayBuffer){const t=new m;t.readAsDataURL(new u([i.src])),t.addEventListener("load",(()=>{i.src="url("+t.result+")",e(i)}))}else e(i)}))}function B(){try{s(new f("resize")),E&&s(new f("scroll"))}catch(e){}}})("object"==typeof globalThis?globalThis:window)}();
1
+ !function(){"use strict";(e=>{const t="single-file-lazy-load",n="single-file-load-image",i="single-file-image-loaded",r={family:"font-family",style:"font-style",weight:"font-weight",stretch:"font-stretch",unicodeRange:"unicode-range",variant:"font-variant",featureSettings:"font-feature-settings"},o=(t,n,i)=>e.addEventListener(t,n,i),l=t=>{try{e.dispatchEvent(t)}catch(e){}},s=e.CustomEvent,c=e.document,d=e.screen,a=e.Element,g=e.UIEvent,f=e.Event,_=e.FileReader,m=e.Blob,u=e.console,h=e.JSON,y=u&&u.warn&&((...e)=>u.warn(...e))||(()=>{}),p=new Map,F=new Map;let E;function w(r){const o=c.scrollingElement||c.documentElement,g=o.clientHeight,_=o.clientWidth,m=Math.max(o.scrollHeight-g,g),u=Math.max(o.scrollWidth-_,_);if(c.querySelectorAll("[loading=lazy]").forEach((e=>{e.loading="eager",e.setAttribute(t,"")})),o.__defineGetter__("clientHeight",(()=>m)),o.__defineGetter__("clientWidth",(()=>u)),d.__defineGetter__("height",(()=>m)),d.__defineGetter__("width",(()=>u)),e._singleFile_innerHeight=e.innerHeight,e._singleFile_innerWidth=e.innerWidth,e.__defineGetter__("innerHeight",(()=>m)),e.__defineGetter__("innerWidth",(()=>u)),r||e._singleFile_getBoundingClientRect||(e._singleFile_getBoundingClientRect=a.prototype.getBoundingClientRect,a.prototype.getBoundingClientRect=function(){const t=e._singleFile_getBoundingClientRect.call(this);return this==o&&(t.__defineGetter__("height",(()=>m)),t.__defineGetter__("bottom",(()=>m+t.top)),t.__defineGetter__("width",(()=>u)),t.__defineGetter__("right",(()=>u+t.left))),t}),!e._singleFileImage){const t=e.Image;e._singleFileImage=e.Image,e.__defineGetter__("Image",(function(){return function(){const e=new t(...arguments),r=new t(...arguments);return r.__defineSetter__("src",(t=>{e.src=t,l(new s(n,{detail:e.src}))})),r.__defineGetter__("src",(()=>e.src)),r.__defineSetter__("srcset",(t=>{l(new s(n)),e.srcset=t})),r.__defineGetter__("srcset",(()=>e.srcset)),r.__defineGetter__("height",(()=>e.height)),r.__defineGetter__("width",(()=>e.width)),r.__defineGetter__("naturalHeight",(()=>e.naturalHeight)),r.__defineGetter__("naturalWidth",(()=>e.naturalWidth)),e.decode&&r.__defineGetter__("decode",(()=>()=>e.decode())),e.onload=e.onloadend=e.onerror=t=>{l(new s(i,{detail:e.src})),r.dispatchEvent(new f(t.type,t))},r}}))}let h,y;r?(h=g/m,y=_/u):(h=(g+e.scrollY)/m,y=(_+e.scrollX)/u);const E=Math.min(h,y);if(E<1){const e=c.documentElement.style.getPropertyValue("transform"),t=c.documentElement.style.getPropertyPriority("transform"),n=c.documentElement.style.getPropertyValue("transform-origin"),i=c.documentElement.style.getPropertyPriority("transform-origin"),o=c.documentElement.style.getPropertyValue("min-height"),l=c.documentElement.style.getPropertyPriority("min-height");c.documentElement.style.setProperty("transform-origin",(h<1?"50%":"0")+" "+(y<1?"50%":"0")+" 0","important"),c.documentElement.style.setProperty("transform","scale3d("+E+", "+E+", 1)","important"),c.documentElement.style.setProperty("min-height",100/E+"vh","important"),B(),r?(c.documentElement.style.setProperty("-sf-transform",e,t),c.documentElement.style.setProperty("-sf-transform-origin",n,i),c.documentElement.style.setProperty("-sf-min-height",o,l)):(c.documentElement.style.setProperty("transform",e,t),c.documentElement.style.setProperty("transform-origin",n,i),c.documentElement.style.setProperty("min-height",o,l))}if(!r){B();const e=o.getBoundingClientRect();window==window.top&&[...p].forEach((([t,n])=>{const i=n.options&&n.options.root&&n.options.root.getBoundingClientRect,r=i&&n.options.root.getBoundingClientRect(),o=F.get(t);if(o){const l=o.map((t=>{const n=t.getBoundingClientRect();return{target:t,intersectionRatio:1,boundingClientRect:n,intersectionRect:n,isIntersecting:!0,rootBounds:i?r:e,time:0}}));n.callback(l,t)}}))}}function v(n){c.querySelectorAll("["+t+"]").forEach((e=>{e.loading="lazy",e.removeAttribute(t)})),n||e._singleFile_getBoundingClientRect&&(a.prototype.getBoundingClientRect=e._singleFile_getBoundingClientRect,delete e._singleFile_getBoundingClientRect),e._singleFileImage&&(delete e.Image,e.Image=e._singleFileImage,delete e._singleFileImage),n||B()}function P(){const t=c.scrollingElement||c.documentElement;null!=e._singleFile_innerHeight&&(delete e.innerHeight,e.innerHeight=e._singleFile_innerHeight,delete e._singleFile_innerHeight),null!=e._singleFile_innerWidth&&(delete e.innerWidth,e.innerWidth=e._singleFile_innerWidth,delete e._singleFile_innerWidth),delete t.clientHeight,delete t.clientWidth,delete d.height,delete d.width}if(o("single-file-load-deferred-images-start",(()=>w())),o("single-file-load-deferred-images-keep-zoom-level-start",(()=>w(!0))),o("single-file-load-deferred-images-end",(()=>v())),o("single-file-load-deferred-images-keep-zoom-level-end",(()=>v(!0))),o("single-file-load-deferred-images-reset",P),o("single-file-load-deferred-images-keep-zoom-level-reset",(()=>{const e=c.documentElement.style.getPropertyValue("-sf-transform"),t=c.documentElement.style.getPropertyPriority("-sf-transform"),n=c.documentElement.style.getPropertyValue("-sf-transform-origin"),i=c.documentElement.style.getPropertyPriority("-sf-transform-origin"),r=c.documentElement.style.getPropertyValue("-sf-min-height"),o=c.documentElement.style.getPropertyPriority("-sf-min-height");c.documentElement.style.setProperty("transform",e,t),c.documentElement.style.setProperty("transform-origin",n,i),c.documentElement.style.setProperty("min-height",r,o),c.documentElement.style.removeProperty("-sf-transform"),c.documentElement.style.removeProperty("-sf-transform-origin"),c.documentElement.style.removeProperty("-sf-min-height"),P()})),o("single-file-dispatch-scroll-event-start",(()=>{E=!0})),o("single-file-dispatch-scroll-event-end",(()=>{E=!1})),o("single-file-block-cookies-start",(()=>{try{c.__defineGetter__("cookie",(()=>{throw new Error("document.cookie temporary blocked by SingleFile")}))}catch(e){}})),o("single-file-block-cookies-end",(()=>{delete c.cookie})),o("single-file-block-storage-start",(()=>{e._singleFile_localStorage||(e._singleFile_localStorage=e.localStorage,e.__defineGetter__("localStorage",(()=>{throw new Error("localStorage temporary blocked by SingleFile")}))),e._singleFile_indexedDB||(e._singleFile_indexedDB=e.indexedDB,e.__defineGetter__("indexedDB",(()=>{throw new Error("indexedDB temporary blocked by SingleFile")})))})),o("single-file-block-storage-end",(()=>{e._singleFile_localStorage&&(delete e.localStorage,e.localStorage=e._singleFile_localStorage,delete e._singleFile_localStorage),e._singleFile_indexedDB||(delete e.indexedDB,e.indexedDB=e._singleFile_indexedDB,delete e._singleFile_indexedDB)})),o("single-file-request-fetch",(async t=>{l(new s("single-file-ack-fetch"));const{url:n,options:i}=h.parse(t.detail);let r;try{const t=await((t,n)=>e.fetch(t,n))(n,i);r={url:n,response:await t.arrayBuffer(),headers:[...t.headers],status:t.status}}catch(e){r={url:n,error:e&&e.toString()}}l(new s("single-file-response-fetch",{detail:r}))})),e.FontFace){const t=e.FontFace;let n;e.FontFace=function(){return n||(y("SingleFile is hooking the FontFace constructor, document.fonts.delete and document.fonts.clear to handle dynamically loaded fonts."),n=!0),b(...arguments).then((e=>l(new s("single-file-new-font-face",{detail:e})))),new t(...arguments)},e.FontFace.toString=function(){return"function FontFace() { [native code] }"};const i=c.fonts.delete;c.fonts.delete=function(e){return b(e.family).then((e=>l(new s("single-file-delete-font",{detail:e})))),i.call(c.fonts,e)},c.fonts.delete.toString=function(){return"function delete() { [native code] }"};const r=c.fonts.clear;c.fonts.clear=function(){return l(new s("single-file-clear-fonts")),r.call(c.fonts)},c.fonts.clear.toString=function(){return"function clear() { [native code] }"}}if(e.IntersectionObserver){const t=e.IntersectionObserver;let n;e.IntersectionObserver=function(){n||(y("SingleFile is hooking the IntersectionObserver API to detect and load deferred images."),n=!0);const e=new t(...arguments),i=t.prototype.observe||e.observe,r=t.prototype.unobserve||e.unobserve,o=arguments[0],l=arguments[1];return i&&(e.observe=function(t){let n=F.get(e);return n||(n=[],F.set(e,n)),n.push(t),i.call(e,t)}),r&&(e.unobserve=function(t){let n=F.get(e);return n&&(n=n.filter((e=>e!=t)),n.length?F.set(e,n):(F.delete(e),p.delete(e))),r.call(e,t)}),p.set(e,{callback:o,options:l}),e},e.IntersectionObserver.prototype=t.prototype,e.IntersectionObserver.toString=function(){return"function IntersectionObserver() { [native code] }"}}async function b(e,t,n){const i={};return i["font-family"]=e,i.src=t,n&&Object.keys(n).forEach((e=>{r[e]&&(i[r[e]]=n[e])})),new Promise((e=>{if(i.src instanceof ArrayBuffer){const t=new _;t.readAsDataURL(new m([i.src])),t.addEventListener("load",(()=>{i.src="url("+t.result+")",e(i)}))}else e(i)}))}function B(){try{l(new g("resize")),E&&l(new g("scroll"))}catch(e){}}})("object"==typeof globalThis?globalThis:window)}();