!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",r="single-file-block-cookies-end",a="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",u="single-file-load-image",m="single-file-image-loaded",g=(e,t,s)=>globalThis.addEventListener(e,t,s),h=e=>{try{globalThis.dispatchEvent(e)}catch(e){}},f=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="single-file-",A="__frameTree__::",v=I+"on-before-capture",S=I+"on-after-capture",_=I+"request-get-adopted-stylesheets",R=I+"response-get-adopted-stylesheets",M=I+"unregister-request-get-adopted-stylesheets",P="data-"+I+"removed-content",N="data-"+I+"hidden-content",C="data-"+I+"kept-content",F="data-"+I+"hidden-frame",q="data-"+I+"preserved-space-element",x="data-"+I+"shadow-root-element",k="data-"+I+"win-id",L="data-"+I+"image",U="data-"+I+"poster",D="data-"+I+"video",O="data-"+I+"canvas",V="data-"+I+"movable-style",W="data-"+I+"input-value",H="data-"+I+"lazy-loaded-src",z="data-"+I+"stylesheet",B="data-"+I+"disabled-noscript",j="data-"+I+"invalid-element",Y="data-"+I+"async-script",G="*:not(base):not(link):not(meta):not(noscript):not(script):not(style):not(template):not(title)",Z=["NOSCRIPT","DISABLED-NOSCRIPT","META","LINK","STYLE","TITLE","TEMPLATE","SOURCE","OBJECT","SCRIPT","HEAD","BODY"],J=/^'(.*?)'$/,$=/^"(.*?)"$/,K={regular:"400",normal:"400",bold:"700",bolder:"700",lighter:"100"},X="single-file-ui-element",Q="data:,",ee=globalThis.JSON;function te(e,t,s,o,n={usedFonts:new Map,canvases:[],images:[],posters:[],videos:[],shadowRoots:[],markedElements:[]},i){if(s.childNodes){Array.from(s.childNodes).filter((t=>t instanceof e.HTMLElement||t instanceof e.SVGElement)).forEach((s=>{let r,a,l;if(!o.autoSaveExternalSave&&(o.removeHiddenElements||o.removeUnusedFonts||o.compressHTML)&&(l=de(e,s),s instanceof e.HTMLElement&&o.removeHiddenElements&&(a=(i||s.closest("html > head"))&&Z.includes(s.tagName.toUpperCase())||s.closest("details"),a||(r=i||re(s,l),r&&(s.setAttribute(N,""),n.markedElements.push(s)))),!r)){if(o.compressHTML&&l){const e=l.getPropertyValue("white-space");e&&e.startsWith("pre")&&(s.setAttribute(q,""),n.markedElements.push(s))}o.removeUnusedFonts&&(oe(l,o,n.usedFonts),oe(de(e,s,":first-letter"),o,n.usedFonts),oe(de(e,s,":before"),o,n.usedFonts),oe(de(e,s,":after"),o,n.usedFonts))}!function(e,t,s,o,n,i,r){const a=s.tagName&&s.tagName.toUpperCase();if("CANVAS"==a)try{n.canvases.push({dataURI:s.toDataURL("image/png",""),backgroundColor:r.getPropertyValue("background-color")}),s.setAttribute(O,n.canvases.length-1),n.markedElements.push(s)}catch(e){}if("IMG"==a){const t={currentSrc:i?Q:o.loadDeferredImages&&s.getAttribute(H)||s.currentSrc};if(n.images.push(t),s.setAttribute(L,n.images.length-1),n.markedElements.push(s),s.removeAttribute(H),r=r||de(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||de(e,t)){let e,r,a,l,d,c,u,m,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=le("padding-left",s),r=le("padding-right",s),a=le("padding-top",s),l=le("padding-bottom",s),g?(d=le("border-left-width",s),c=le("border-right-width",s),u=le("border-top-width",s),m=le("border-bottom-width",s)):d=c=u=m=0,o=Math.max(0,t.clientWidth-e-r-d-c),n=Math.max(0,t.clientHeight-a-l-u-m),i&&t.removeAttribute("style")}}return{pxWidth:o,pxHeight:n}}(e,s,r);const o=r.getPropertyValue("box-shadow"),n=r.getPropertyValue("background-image");o&&"none"!=o||n&&"none"!=n||!(t.size.pxWidth>1||t.size.pxHeight>1)||(t.replaceable=!0,t.backgroundColor=r.getPropertyValue("background-color"),t.objectFit=r.getPropertyValue("object-fit"),t.boxSizing=r.getPropertyValue("box-sizing"),t.objectPosition=r.getPropertyValue("object-position"))}}if("VIDEO"==a){const o=s.currentSrc;if(o&&!o.startsWith("blob:")&&!o.startsWith("data:")){const t=de(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(D,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(U,n.posters.length-1),n.markedElements.push(s)}catch(e){}}}"IFRAME"==a&&i&&o.removeHiddenElements&&(s.setAttribute(F,""),n.markedElements.push(s));"INPUT"==a&&("password"!=s.type&&(s.setAttribute(W,s.value),n.markedElements.push(s)),"radio"!=s.type&&"checkbox"!=s.type||(s.setAttribute(W,s.checked),n.markedElements.push(s)));"TEXTAREA"==a&&(s.setAttribute(W,s.value),n.markedElements.push(s));"SELECT"==a&&s.querySelectorAll("option").forEach((e=>{e.selected&&(e.setAttribute(W,""),n.markedElements.push(e))}));"SCRIPT"==a&&(s.async&&""!=s.getAttribute("async")&&"async"!=s.getAttribute("async")&&(s.setAttribute(Y,""),n.markedElements.push(s)),s.textContent=s.textContent.replace(/<\/script>/gi,"<\\/script>"))}(e,t,s,o,n,r,l);const d=!(s instanceof e.SVGElement)&&ne(s);if(d&&!s.classList.contains(X)){const i={};s.setAttribute(x,n.shadowRoots.length),n.markedElements.push(s),n.shadowRoots.push(i);try{if(d.adoptedStyleSheets)if(d.adoptedStyleSheets.length)i.adoptedStyleSheets=se(d.adoptedStyleSheets);else if(void 0===d.adoptedStyleSheets.length){const e=e=>i.adoptedStyleSheets=e.detail.adoptedStyleSheets;s.addEventListener(R,e),s.dispatchEvent(new CustomEvent(_,{bubbles:!0})),s.removeEventListener(R,e)}}catch(e){}te(e,t,d,o,n,r),i.content=d.innerHTML,i.mode=d.mode;try{d.adoptedStyleSheets&&void 0===d.adoptedStyleSheets.length&&s.dispatchEvent(new CustomEvent(M,{bubbles:!0}))}catch(e){}}te(e,t,s,o,n,r),!o.autoSaveExternalSave&&o.removeHiddenElements&&i&&(a||""==s.getAttribute(C)?s.parentElement&&(s.parentElement.setAttribute(C,""),n.markedElements.push(s.parentElement)):r&&(s.setAttribute(P,""),n.markedElements.push(s)))}))}return n}function se(e){return e?Array.from(e).map((e=>Array.from(e.cssRules).map((e=>e.cssText)).join("\n"))):[]}function oe(e,t,s){if(e){const o=e.getPropertyValue("font-style")||"normal";e.getPropertyValue("font-family").split(",").forEach((n=>{if(n=ie(n),!t.loadedFonts||t.loadedFonts.find((e=>ie(e.family)==n&&e.style==o))){const t=(i=e.getPropertyValue("font-weight"),K[i.toLowerCase().trim()]||i),r=e.getPropertyValue("font-variant")||"normal",a=[n,t,o,r];s.set(ee.stringify(a),[n,t,o,r])}var i}))}}function ne(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 ie(e=""){return function(e){e=e.match(J)?e.replace(J,"$1"):e.replace($,"$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 re(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 ae(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(z,o),t[o]=Array.from(s.sheet.cssRules).map((e=>e.cssText)).join("\n"))}catch(e){}})),t}}function le(e,t){if(t.getPropertyValue(e).endsWith("px"))return parseFloat(t.getPropertyValue(e))}function de(e,t,s){try{return e.getComputedStyle(t,s)}catch(e){}}const ce={LAZY_SRC_ATTRIBUTE_NAME:H,SINGLE_FILE_UI_ELEMENT_CLASS:X},ue=10,me="attributes",ge=globalThis.browser,he=globalThis.document,fe=globalThis.MutationObserver,pe=(e,t,s)=>globalThis.addEventListener(e,t,s),be=(e,t,s)=>globalThis.removeEventListener(e,t,s),Ee=new Map;let ye;async function Te(e){if(he.documentElement){Ee.clear();const s=he.body?Math.max(he.body.scrollHeight,he.documentElement.scrollHeight):he.documentElement.scrollHeight,n=he.body?Math.max(he.body.scrollWidth,he.documentElement.scrollWidth):he.documentElement.scrollWidth;if(s>globalThis.innerHeight||n>globalThis.innerWidth){const r=Math.max(s-1.5*globalThis.innerHeight,0),l=Math.max(n-1.5*globalThis.innerWidth,0);if(globalThis.scrollY{let n;const r=new Set,l=new fe((async t=>{if((t=t.filter((e=>e.type==me))).length){t.filter((e=>{if("src"==e.attributeName&&(e.target.setAttribute(ce.LAZY_SRC_ATTRIBUTE_NAME,e.target.src),e.target.addEventListener("load",g)),"src"==e.attributeName||"srcset"==e.attributeName||e.target.tagName&&"SOURCE"==e.target.tagName.toUpperCase())return!e.target.classList||!e.target.classList.contains(ce.SINGLE_FILE_UI_ELEMENT_CLASS)})).length&&(n=!0,await Ie(l,e,E),r.size||await we(l,e,E))}}));async function c(t){await ve("idleTimeout",(async()=>{n?yeAe(e,t,s)),t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ie(e,t,s){await ve("maxTimeout",(async()=>{await _e("loadTimeout"),await Ae(e,t,s)}),10*t.loadDeferredImagesMaxIdleTime,t.loadDeferredImagesNativeTimeout)}async function Ae(e,t,o){await _e("idleTimeout"),function(e){e.loadDeferredImagesBlockCookies&&h(new f(r)),e.loadDeferredImagesBlockStorage&&h(new f(c)),e.loadDeferredImagesDispatchScrollEvent&&h(new f(l)),e.loadDeferredImagesKeepZoomLevel?h(new f(n)):h(new f(s))}(t),await ve("endTimeout",(async()=>{await _e("maxTimeout"),o()}),t.loadDeferredImagesMaxIdleTime/2,t.loadDeferredImagesNativeTimeout),e.disconnect()}async function ve(e,t,s,o){if(ge&&ge.runtime&&ge.runtime.sendMessage&&!o){if(!Ee.get(e)||!Ee.get(e).pending){const o={callback:t,pending:!0};Ee.set(e,o);try{await ge.runtime.sendMessage({method:"singlefile.lazyTimeout.setTimeout",type:e,delay:s})}catch(o){Se(e,t,s)}o.pending=!1}}else Se(e,t,s)}function Se(e,t,s){const o=Ee.get(e);o&&globalThis.clearTimeout(o),Ee.set(e,t),globalThis.setTimeout(t,s)}async function _e(e){if(ge&&ge.runtime&&ge.runtime.sendMessage)try{await ge.runtime.sendMessage({method:"singlefile.lazyTimeout.clearTimeout",type:e})}catch(t){Re(e)}else Re(e)}function Re(e){const t=Ee.get(e);Ee.delete(e),t&&globalThis.clearTimeout(t)}ge&&ge.runtime&&ge.runtime.onMessage&&ge.runtime.onMessage.addListener&&ge.runtime.onMessage.addListener((e=>{if("singlefile.lazyTimeout.onTimeout"==e.method){const t=Ee.get(e.type);if(t){Ee.delete(e.type);try{t.callback()}catch(t){Re(e.type)}}}}));const Me={ON_BEFORE_CAPTURE_EVENT_NAME:v,ON_AFTER_CAPTURE_EVENT_NAME:S,WIN_ID_ATTRIBUTE_NAME:k,WAIT_FOR_USERSCRIPT_PROPERTY_NAME:"_singleFile_waitForUserScript",preProcessDoc:function(e,t,s){e.querySelectorAll("noscript:not(["+B+"])").forEach((e=>{e.setAttribute(B,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(G).forEach((e=>e.hidden=!0)),e.querySelectorAll("svg foreignObject").forEach((e=>{const t=e.querySelectorAll("html > head > "+G+", html > body > "+G);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(j,""),s.content.appendChild(t.cloneNode(!0)),o.set(t,s),t.replaceWith(s)})),n=te(t,e,e.documentElement,s),s.moveStylesInHead&&e.querySelectorAll("body style, body ~ style").forEach((e=>{const s=de(t,e);s&&re(e,s)&&(e.setAttribute(V,""),n.markedElements.push(e))}))):n={canvases:[],images:[],posters:[],videos:[],usedFonts:[],shadowRoots:[],markedElements:[]},{canvases:n.canvases,fonts:Array.from(y.values()),stylesheets:ae(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,scrollPosition:{x:t.scrollX,y:t.scrollY},adoptedStyleSheets:se(e.adoptedStyleSheets)}},serialize:function(e){const t=e.doctype;let s="";return t&&(s=" "),s+e.documentElement.outerHTML},postProcessDoc:function(e,t,s){if(e.querySelectorAll("["+B+"]").forEach((e=>{e.textContent=e.getAttribute(B),e.removeAttribute(B)})),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=[P,F,N,q,L,U,D,O,W,x,z,Y];t=e.querySelectorAll(s.map((e=>"["+e+"]")).join(","))}t.forEach((e=>{e.removeAttribute(P),e.removeAttribute(N),e.removeAttribute(C),e.removeAttribute(F),e.removeAttribute(q),e.removeAttribute(L),e.removeAttribute(U),e.removeAttribute(D),e.removeAttribute(O),e.removeAttribute(W),e.removeAttribute(x),e.removeAttribute(z),e.removeAttribute(Y),e.removeAttribute(V)})),s&&s.forEach(((e,t)=>e.replaceWith(t)))},getShadowRoot:ne},Pe='iframe, frame, object[type="text/html"][data]',Ne="*",Ce="singlefile.frameTree.initRequest",Fe="singlefile.frameTree.ackInitRequest",qe="singlefile.frameTree.cleanupRequest",xe="singlefile.frameTree.initResponse",ke="*",Le=5e3,Ue=".",De=globalThis.window==globalThis.top,Oe=globalThis.browser,Ve=globalThis.top,We=globalThis.MessageChannel,He=globalThis.document,ze=globalThis.JSON;let Be,je=globalThis.sessions;var Ye,Ge,Ze;function Je(){return globalThis.crypto.getRandomValues(new Uint32Array(32)).join("")}async function $e(e){const t=e.sessionId,s=globalThis[Me.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,De||(Be=globalThis.frameId=e.windowId),Qe(He,e.options,Be,t),De||(e.options.userScriptEnabled&&s&&await s(Me.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(He,globalThis,Be,e.options,e.scrolling)],sessionId:t,requestedFrameId:He.documentElement.dataset.requestedFrameId&&Be}),e.options.userScriptEnabled&&s&&await s(Me.ON_AFTER_CAPTURE_EVENT_NAME),delete He.documentElement.dataset.requestedFrameId)}function Ke(e){if(!globalThis._singleFile_cleaningUp){globalThis._singleFile_cleaningUp=!0;const t=e.sessionId;st(rt(He),e.windowId,t)}}function Xe(e){e.frames.forEach((t=>et("responseTimeouts",e.sessionId,t.windowId)));const t=je.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.url=e.url,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,s.scrollPosition=e.scrollPosition,s.scrolling=e.scrolling,s.adoptedStyleSheets=e.adoptedStyleSheets)}));t.frames.filter((e=>!e.processed)).length||(t.frames=t.frames.sort(((e,t)=>t.windowId.split(Ue).length-e.windowId.split(Ue).length)),t.resolve&&(t.requestedFrameId&&t.frames.forEach((e=>{e.windowId==t.requestedFrameId&&(e.requestedFrame=!0)})),t.resolve(t.frames)))}}function Qe(e,t,s,o){const n=rt(e);!function(e,t,s,o,n){const i=[];let r;je.get(n)?r=je.get(n).requestTimeouts:(r={},je.set(n,{requestTimeouts:r}));t.forEach(((e,t)=>{const s=o+Ue+t;e.setAttribute(Me.WIN_ID_ATTRIBUTE_NAME,s),i.push({windowId:s})})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),t.forEach(((e,t)=>{const i=o+Ue+t;try{nt(e.contentWindow,{method:Ce,windowId:i,sessionId:n,options:s,scrolling:e.scrolling})}catch(e){}r[i]=globalThis.setTimeout((()=>ot({frames:[{windowId:i,processed:!0}],sessionId:n})),Le)})),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 r=o+Ue+t;let a;try{a=e.contentDocument}catch(e){}if(a)try{const t=e.contentWindow;t.stop(),et("requestTimeouts",n,r),Qe(a,s,r,n),i.push(it(a,t,r,s,e.scrolling))}catch(e){i.push({windowId:r,processed:!0})}})),ot({frames:i,sessionId:n,requestedFrameId:e.documentElement.dataset.requestedFrameId&&o}),delete e.documentElement.dataset.requestedFrameId}(e,n,t,s,o)}function et(e,t,s){const o=je.get(t);if(o&&o[e]){const t=o[e][s];t&&(globalThis.clearTimeout(t),delete o[e][s])}}function tt(e,t){const s=je.get(e);s&&s.responseTimeouts&&(s.responseTimeouts[t]=globalThis.setTimeout((()=>ot({frames:[{windowId:t,processed:!0}],sessionId:e})),1e4))}function st(e,t,s){e.forEach(((e,o)=>{const n=t+Ue+o;e.removeAttribute(Me.WIN_ID_ATTRIBUTE_NAME);try{nt(e.contentWindow,{method:qe,windowId:n,sessionId:s})}catch(e){}})),e.forEach(((e,o)=>{const n=t+Ue+o;let i;try{i=e.contentDocument}catch(e){}if(i)try{st(rt(i),n,s)}catch(e){}}))}function ot(e){e.method=xe;try{Ve.singlefile.processors.frameTree.initResponse(e)}catch(t){nt(Ve,e,!0)}}function nt(e,t,s){if(e==Ve&&Oe&&Oe.runtime&&Oe.runtime.sendMessage)Oe.runtime.sendMessage(t);else if(s){const s=new We;e.postMessage(A+ze.stringify({method:t.method,sessionId:t.sessionId}),ke,[s.port2]),s.port1.postMessage(t)}else e.postMessage(A+ze.stringify(t),ke)}function it(e,t,s,o,n){const i=Me.preProcessDoc(e,t,o),r=Me.serialize(e);Me.postProcessDoc(e,i.markedElements,i.invalidElements);return{windowId:s,content:r,baseURI:e.baseURI.split("#")[0],url:e.location.href,title:e.title,canvases:i.canvases,fonts:i.fonts,stylesheets:i.stylesheets,images:i.images,posters:i.posters,videos:i.videos,usedFonts:i.usedFonts,shadowRoots:i.shadowRoots,scrollPosition:i.scrollPosition,scrolling:n,adoptedStyleSheets:i.adoptedStyleSheets,processed:!0}}function rt(e){let t=Array.from(e.querySelectorAll(Pe));return e.querySelectorAll(Ne).forEach((e=>{const s=Me.getShadowRoot(e);s&&(t=t.concat(...s.querySelectorAll(Pe)))})),t}je||(je=globalThis.sessions=new Map),De&&(Be="0",Oe&&Oe.runtime&&Oe.runtime.onMessage&&Oe.runtime.onMessage.addListener&&Oe.runtime.onMessage.addListener((e=>e.method==xe?(Xe(e),Promise.resolve({})):e.method==Fe?(et("requestTimeouts",e.sessionId,e.windowId),tt(e.sessionId,e.windowId),Promise.resolve({})):void 0))),Ye="message",Ge=async e=>{if("string"==typeof e.data&&e.data.startsWith(A)){e.preventDefault(),e.stopPropagation();const t=ze.parse(e.data.substring(A.length));t.method==Ce?(e.source&&nt(e.source,{method:Fe,windowId:t.windowId,sessionId:t.sessionId}),De||(globalThis.stop(),t.options.loadDeferredImages&&Te(t.options),await $e(t))):t.method==Fe?(et("requestTimeouts",t.sessionId,t.windowId),tt(t.sessionId,t.windowId)):t.method==qe?Ke(t):t.method==xe&&je.get(t.sessionId)&&(e.ports[0].onmessage=e=>Xe(e.data))}},Ze=!0,globalThis.addEventListener(Ye,Ge,Ze),e.TIMEOUT_INIT_REQUEST_MESSAGE=Le,e.cleanup=function(e){je.delete(e),Ke({windowId:Be,sessionId:e,options:{sessionId:e}})},e.getAsync=function(e){const t=Je();return e=ze.parse(ze.stringify(e)),new Promise((s=>{je.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{},resolve:e=>{e.sessionId=t,s(e)}}),$e({windowId:Be,sessionId:t,options:e})}))},e.getSync=function(e){const t=Je();e=ze.parse(ze.stringify(e)),je.set(t,{frames:[],requestTimeouts:{},responseTimeouts:{}}),function(e){const t=e.sessionId,s=globalThis[Me.WAIT_FOR_USERSCRIPT_PROPERTY_NAME];delete globalThis._singleFile_cleaningUp,De||(Be=globalThis.frameId=e.windowId);Qe(He,e.options,Be,t),De||(e.options.userScriptEnabled&&s&&s(Me.ON_BEFORE_CAPTURE_EVENT_NAME),ot({frames:[it(He,globalThis,Be,e.options,e.scrolling)],sessionId:t,requestedFrameId:He.documentElement.dataset.requestedFrameId&&Be}),e.options.userScriptEnabled&&s&&s(Me.ON_AFTER_CAPTURE_EVENT_NAME),delete He.documentElement.dataset.requestedFrameId)}({windowId:Be,sessionId:t,options:e});const s=je.get(t).frames;return s.sessionId=t,s},e.initResponse=Xe,Object.defineProperty(e,"__esModule",{value:!0})}));