single-file-extension.js 41 KB

1
  1. !function(){"use strict";const t=[0],e=Symbol(),n=new TextEncoder,r=new TextDecoder,o=new Array(256);let a=0;function i(e,n,r,i){if(void 0===i){if(a++,!(o.length-a>=t.length))throw new Error("Reached maximum number of custom types");o[o.length-a]={serialize:e,parse:n,test:r}}else o[i]={serialize:e,parse:n,test:r}}async function s(t,e){const n=d(t,e);let r=new Uint8Array([]);for await(const t of n){const e=r;r=new Uint8Array(e.length+t.length),r.set(e,0),r.set(t,e.length)}return r}i(async function(t,e){const n=t.objects.indexOf(e);await u(t,n)},async function(t){const e=await E(t);return new g(e,t)},I,0),i(null,function(){return{}},R),i(f,v,x),i(m,S,function(t){return"string"==typeof t}),i(p,async function(t){const e=await E(t),n=await t.consume(8*e);return new Float64Array(n.buffer)},function(t){return"Float64Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(4*e);return new Float32Array(n.buffer)},function(t){return"Float32Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(4*e);return new Uint32Array(n.buffer)},function(t){return"Uint32Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(4*e);return new Int32Array(n.buffer)},function(t){return"Int32Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(2*e);return new Uint16Array(n.buffer)},function(t){return"Uint16Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(2*e);return new Int16Array(n.buffer)},function(t){return"Int16Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(e);return new Uint8ClampedArray(n.buffer)},function(t){return"Uint8ClampedArray"==t.constructor.name}),i(p,async function(t){const e=await E(t);return await t.consume(e)},function(t){return"Uint8Array"==t.constructor.name}),i(p,async function(t){const e=await E(t),n=await t.consume(e);return new Int8Array(n.buffer)},function(t){return"Int8Array"==t.constructor.name}),i(async function(t,e){await u(t,e.byteLength),await t.append(new Uint8Array(e))},async function(t){const e=await E(t);return(await t.consume(e)).buffer},function(t){return"ArrayBuffer"==t.constructor.name}),i(h,T,L),i(async function(t,e){const n=new Uint8Array(new Uint32Array([e]).buffer);await t.append(n)},async function(t){const e=await t.consume(4);return new Uint32Array(e.buffer)[0]},function(t){return D(t)&&t>=0&&t<=4294967295}),i(async function(t,e){const n=new Uint8Array(new Int32Array([e]).buffer);await t.append(n)},async function(t){const e=await t.consume(4);return new Int32Array(e.buffer)[0]},function(t){return D(t)&&t>=-2147483648&&t<=2147483647}),i(async function(t,e){const n=new Uint8Array(new Uint16Array([e]).buffer);await t.append(n)},async function(t){const e=await t.consume(2);return new Uint16Array(e.buffer)[0]},function(t){return D(t)&&t>=0&&t<=65535}),i(async function(t,e){const n=new Uint8Array(new Int16Array([e]).buffer);await t.append(n)},async function(t){const e=await t.consume(2);return new Int16Array(e.buffer)[0]},function(t){return D(t)&&t>=-32768&&t<=32767}),i(async function(t,e){const n=new Uint8Array([e]);await t.append(n)},async function(t){const e=await t.consume(1);return new Uint8Array(e.buffer)[0]},function(t){return D(t)&&t>=0&&t<=255}),i(async function(t,e){const n=new Uint8Array(new Int8Array([e]).buffer);await t.append(n)},async function(t){const e=await t.consume(1);return new Int8Array(e.buffer)[0]},function(t){return D(t)&&t>=-128&&t<=127}),i(null,function(){return},function(t){return void 0===t}),i(null,function(){return null},function(t){return null===t}),i(null,function(){return NaN},function(t){return Number.isNaN(t)}),i(y,P,function(t){return"boolean"==typeof t}),i(async function(t,e){await m(t,e.description)},async function(t){const e=await S(t);return Symbol(e)},k),i(null,function(){return e},U),i(async function(t,e){const n=e.entries();await u(t,e.size);for(const[e,r]of n)await u(t,e),await u(t,r)},async function(t){const e=await E(t),n=new Map;e&&await async function r(o=0){const a=await E(t),i=await E(t);t.setObject([a,i],(t,e)=>n.set(t,e)),o<e-1&&await r(o+1)}();return n},function(t){return t instanceof Map}),i(async function(t,e){await u(t,e.size);for(const n of e)await u(t,n)},async function(t){const e=await E(t),n=new Set;e&&await async function r(o=0){const a=await E(t);t.setObject([a],t=>n.add(t)),o<e-1&&await r(o+1)}();return n},function(t){return t instanceof Set}),i(async function(t,e){await h(t,e.getTime())},async function(t){const e=await T(t);return new Date(e)},function(t){return t instanceof Date}),i(async function(t,e){await m(t,e.message),await m(t,e.stack)},async function(t){const e=await S(t),n=await S(t),r=new Error(e);return r.stack=n,r},function(t){return t instanceof Error}),i(async function(t,e){await m(t,e.source),await m(t,e.flags)},async function(t){const e=await S(t),n=await S(t);return new RegExp(e,n)},function(t){return t instanceof RegExp}),i(async function(t,e){await m(t,e.valueOf())},async function(t){return new String(await S(t))},function(t){return t instanceof String}),i(async function(t,e){await h(t,e.valueOf())},async function(t){return new Number(await T(t))},function(t){return t instanceof Number}),i(async function(t,e){await y(t,e.valueOf())},async function(t){return new Boolean(await P(t))},function(t){return t instanceof Boolean});class c{constructor(t,e){this.stream=new l(t,e),this.objects=[]}append(t){return this.stream.append(t)}flush(){return this.stream.flush()}addObject(t){this.objects.push(M(t)&&!I(t,this)?t:void 0)}}class l{constructor(t,e){this.offset=0,this.appendData=t,this.value=new Uint8Array(e)}async append(t){if(this.offset+t.length>this.value.length){const e=this.value.length-this.offset;await this.append(new Uint8Array(t).subarray(0,e)),await this.appendData({value:this.value}),this.offset=0,await this.append(new Uint8Array(t).subarray(e))}else this.value.set(t,this.offset),this.offset+=t.length}async flush(){this.offset&&await this.appendData({value:new Uint8Array(this.value).subarray(0,this.offset),done:!0})}}function d(t,{chunkSize:e=8388608}={}){let n,r,o,a,i,s;return{[Symbol.asyncIterator]:()=>({next:()=>a?{done:a}:async function(){s?s():l().catch(()=>{});i=new Promise(t=>s=t);const t=await async function(){const{value:t,done:e}=await r;a=e,e||d();return t}();return{value:t}}(),return:()=>({done:!0})})};async function l(){d(),n=new c(f,e),await u(n,t),await n.flush()}function d(){r=new Promise(t=>o=t)}async function f(t){o(t),await i}}async function u(t,e){const n=o.findIndex(({test:n}={})=>n&&n(e,t));t.addObject(e),await t.append(new Uint8Array([n]));const r=o[n].serialize;r&&await r(t,e),0!=n&&R(e)&&(await async function(t,e){const n=Object.getOwnPropertySymbols(e),r=n.map(t=>[t,e[t]]);await f(t,r)}(t,e),await async function(t,e){if(ArrayBuffer.isView(e))await u(t,0);else{let n=Object.entries(e);x(e)&&(n=n.filter(([t])=>!D(Number(t)))),await u(t,n.length);for(const[e,r]of n)await m(t,e),await u(t,r)}}(t,e))}async function f(t,n){await u(t,n.length);const r=Object.keys(n).filter(t=>D(Number(t))).map(t=>Number(t));let o=0,a=r[o];for(const[i,s]of n.entries())a==i?(a=r[++o],await u(t,s)):await u(t,e)}async function m(t,e){const r=n.encode(e);await u(t,r.length),await t.append(r)}async function p(t,e){await u(t,e.length),await t.append("Uint8Array"==e.constructor.name?e:new Uint8Array(e.buffer))}async function h(t,e){const n=new Uint8Array(new Float64Array([e]).buffer);await t.append(n)}async function y(t,e){const n=new Uint8Array([Number(e)]);await t.append(n)}class g{constructor(t,e){this.index=t,this.data=e}getObject(){return this.data.objects[this.index]}}class w{constructor(t){this.stream=new b(t),this.objects=[],this.setters=[]}consume(t){return this.stream.consume(t)}getObjectId(){const t=this.objects.length;return this.objects.push(void 0),t}resolveObject(t,e){M(e)&&!C(e)&&(this.objects[t]=e)}setObject(t,e){this.setters.push({functionArguments:t,setterFunction:e})}executeSetters(){this.setters.forEach(({functionArguments:t,setterFunction:e})=>{e(...t.map(t=>C(t)?t.getObject():t))})}}class b{constructor(t){this.offset=0,this.value=new Uint8Array(0),this.consumeData=t}async consume(t){if(this.offset+t>this.value.length){const e=new Uint8Array(this.value).subarray(this.offset,this.value.length),n=await this.consumeData();return e.length+n.length!=this.value.length&&(this.value=new Uint8Array(e.length+n.length)),this.value.set(e),this.value.set(n,e.length),this.offset=0,this.consume(t)}{const e=this.value.slice(this.offset,this.offset+t);return this.offset+=e.length,e}}}function A(){let t,e,n,r,o,a;return{next:async e=>e?async function(e){o?await o:async function(){let e;r=new Promise(t=>e=t),t=new w(s),i();const n=await E(t);t.executeSetters(),e(n)}().catch(()=>{});return function(){o=new Promise(t=>a=t)}(),n(e),{done:!1}}(e):{value:await r,done:!0},return:()=>({done:!0})};function i(){e=new Promise(t=>n=t)}async function s(){const t=await e;return i(),a&&a(),t}}async function E(t){const e=(await t.consume(1))[0],n=o[e].parse,r=t.getObjectId(),a=await n(t);return 0!=e&&R(a)&&(await async function(t,e){const n=await v(t);t.setObject([n],t=>t.forEach(([t,n])=>e[t]=n))}(t,a),await async function(t,e){const n=await E(t);n&&await r();async function r(o=0){const a=await S(t),i=await E(t);t.setObject([i],t=>e[a]=t),o<n-1&&await r(o+1)}}(t,a)),t.resolveObject(r,a),a}async function v(t){const e=await E(t),n=new Array(e);return e&&await async function r(o=0){const a=await E(t);U(a)||t.setObject([a],t=>n[o]=t);o<e-1&&await r(o+1)}(),n}async function S(t){const e=await E(t),n=await t.consume(e);return r.decode(n)}async function T(t){const e=await t.consume(8);return new Float64Array(e.buffer)[0]}async function P(t){const e=await t.consume(1);return Boolean(e[0])}function I(t,e){return R(t)&&e.objects.includes(t)}function C(t){return t instanceof g}function R(t){return t===Object(t)}function x(t){return"number"==typeof t.length}function U(t){return t===e}function L(t){return"number"==typeof t}function D(t){return L(t)&&Number.isInteger(t)}function k(t){return"symbol"==typeof t}function M(t){return R(t)||k(t)}const O=globalThis.singlefile,N=O.helper.SELECTED_CONTENT_ATTRIBUTE_NAME,B="singlefile-mask",F="singlefile-mask-content",_="singlefile-progress-bar",j="singlefile-progress-bar-content",W="single-file-selection-zone",G="singlefile-logs-window",H="singlefile-logs",q="singlefile-logs-line",z="singlefile-logs-line-text",V="singlefile-logs-line-icon",X=O.helper.SINGLE_FILE_UI_ELEMENT_CLASS,K=new Set(Array.from(getComputedStyle(document.documentElement)));let Z,Q,J,Y,$,tt,et;try{Z=browser.i18n.getMessage("logPanelWidth"),Q=browser.i18n.getMessage("logPanelDeferredImages"),J=browser.i18n.getMessage("logPanelFrameContents"),Y=browser.i18n.getMessage("logPanelEmbeddedImage"),$=browser.i18n.getMessage("logPanelStep")}catch(t){}function nt(t,e){return prompt(t,e)}function rt(t){const e=document.querySelector(B);e&&e.style.setProperty("display",t?"block":"none"),et&&et.style.setProperty("display",t?"block":"none")}function ot(t){if(!document.querySelector(B)&&(t.logsEnabled&&document.documentElement.appendChild(et),t.shadowEnabled)){const e=function(){try{let t=document.querySelector(B);if(!t){t=bt(B,document.documentElement);const e=t.attachShadow({mode:"open"}),n=document.createElement("style");n.textContent=`\n\t\t\t\t@keyframes single-file-progress { \n\t\t\t\t\t0% { \n\t\t\t\t\t\tleft: -50px;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\tleft: 0;\n\t\t\t\t\t}\n\t\t\t\t}\n\t\t\t\t.${_} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 0;\n\t\t\t\t\theight: 8px;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: .5;\n\t\t\t\t\toverflow: hidden;\t\t\t\t\t\n\t\t\t\t\ttransition: width 200ms ease-in-out;\n\t\t\t\t}\n\t\t\t\t.${j} {\n\t\t\t\t\tposition: absolute;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\tanimation: single-file-progress 3s linear infinite reverse;\n\t\t\t\t\tbackground: \n\t\t\t\t\t\twhite \n\t\t\t\t\t\tlinear-gradient(-45deg, rgba(0, 0, 0, 0.075) 25%, \n\t\t\t\t\t\t\ttransparent 25%, \n\t\t\t\t\t\t\ttransparent 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 50%, \n\t\t\t\t\t\t\trgba(0, 0, 0, 0.075) 75%, \n\t\t\t\t\t\t\ttransparent 75%, transparent)\n\t\t\t\t\t\trepeat scroll 0% 0% / 50px 50px padding-box border-box;\n\t\t\t\t\twidth: calc(100% + 50px);\n\t\t\t\t\theight: 100%;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\t.${F} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0;\n\t\t\t\t\tleft: 0;\n\t\t\t\t\twidth: 100%;\n\t\t\t\t\theight: 100%;\n\t\t\t\t\tz-index: 2147483646;\n\t\t\t\t\topacity: 0;\n\t\t\t\t\tbackground-color: black;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t}\n\t\t\t`,e.appendChild(n);let r=document.createElement("div");r.classList.add(F),e.appendChild(r),t.offsetWidth,r.style.setProperty("opacity",.3),t.offsetWidth}return t}catch(t){}}();t.progressBarEnabled&&function(t){try{if(!t.shadowRoot.querySelector("."+_)){let e=document.createElement("div");e.classList.add(_),t.shadowRoot.appendChild(e);const n=document.createElement("div");n.classList.add(j),e.appendChild(n)}}catch(t){}}(e)}}function at(){const t=document.querySelector(B);t&&t.remove(),et.remove(),ht()}function it(t,e,n){n.shadowEnabled&&n.progressBarEnabled&&function(t,e){try{const n=document.querySelector(B);if(n){const r=n.shadowRoot.querySelector("."+_);if(r&&e){const n=Math.floor(t/e*100)+"%";r.style.getPropertyValue("width")!=n&&(r.style.setProperty("width",n),r.offsetWidth)}}}catch(t){}}(t,e)}function st(t){yt("insert-embedded-image",Y,"…",t)}function ct(t){yt("insert-embedded-image",Y,"✓",t)}function lt(){let t;const e=[],n=getSelection();for(let r=0;r<n.rangeCount;r++){let o=n.getRangeAt(r);if(o&&o.commonAncestorContainer){const n=document.createTreeWalker(o.commonAncestorContainer);let r=!1,a=!1;for(;!a;){if((r||n.currentNode==o.startContainer||n.currentNode==o.endContainer)&&(r=!0,(o.startContainer!=o.endContainer||o.startOffset!=o.endOffset)&&(t=!0,"A"==n.currentNode.tagName&&n.currentNode.href))){const t=new URL(n.currentNode.href);t.hash="",e.push(t.href)}n.currentNode==o.endContainer?a=!0:n.nextNode()}t&&n.currentNode==o.endContainer&&n.currentNode.querySelectorAll&&n.currentNode.querySelectorAll("*").forEach(t=>{if("A"==t.tagName&&t.href){const n=new URL(t.href);n.hash="",e.push(n.href)}})}}return Array.from(new Set(e))}async function dt(t){let e=ut();return e||t?e:(e=await new Promise(t=>{let e=[];function n(t){e=[],s(),t.preventDefault()}function r(t){const e=function(t){let e,n=t.target,r=n.getBoundingClientRect();for(e=wt("floor",n,t.clientX-r.left,gt(n,"left")),e==n&&(e=wt("ceil",n,r.left+r.width-t.clientX,gt(n,"right"))),e==n&&(e=wt("floor",n,t.clientY-r.top,gt(n,"top"))),e==n&&(e=wt("ceil",n,r.top+r.height-t.clientY,gt(n,"bottom"))),n=e;n&&n.clientWidth<=8&&n.clientHeight<=8;)n=n.parentElement;return n}(t);var n;e&&(tt=e,n=e,requestAnimationFrame(()=>{const t=pt(),e=n.getBoundingClientRect(),r=document.scrollingElement||document.documentElement;t.style.setProperty("top",r.scrollTop+e.top-10+"px"),t.style.setProperty("left",r.scrollLeft+e.left-10+"px"),t.style.setProperty("width",e.width+20+"px"),t.style.setProperty("height",e.height+20+"px")}))}function o(t){t.preventDefault(),t.stopPropagation(),0==t.button?s(tt,t.ctrlKey):i()}function a(t){"Escape"==t.key&&i()}function i(){e.length&&getSelection().removeAllRanges(),e=[],l()}function s(t,e){if(t){e||d();const n=document.createRange();n.selectNodeContents(t),c(),getSelection().addRange(n),u(),e||l()}else l()}function c(){const t=getSelection();for(let e=t.rangeCount-1;e>=0;e--){const n=t.getRangeAt(e);n.startOffset==n.endOffset&&(t.removeRange(n),e--)}}function l(){pt().remove(),removeEventListener("mousemove",r,!0),removeEventListener("click",o,!0),removeEventListener("keyup",a,!0),tt=null,t(Boolean(e.length)),setTimeout(()=>document.removeEventListener("contextmenu",n,!0),0)}function d(){getSelection().removeAllRanges(),e.forEach(t=>getSelection().addRange(t))}function u(){e=[];for(let t=0;t<getSelection().rangeCount;t++){const n=getSelection().getRangeAt(t);e.push(n)}}addEventListener("mousemove",r,!0),addEventListener("click",o,!0),addEventListener("keyup",a,!0),document.addEventListener("contextmenu",n,!0),getSelection().removeAllRanges()}),e?ut():void 0)}function ut(){const t=getSelection();let e;for(let n=0;n<t.rangeCount;n++){let r=t.getRangeAt(n);if(r&&r.commonAncestorContainer){const n=document.createTreeWalker(r.commonAncestorContainer);let o=!1,a=!1;for(;!a;)(o||n.currentNode==r.startContainer||n.currentNode==r.endContainer)&&(o=!0,r.startContainer==r.endContainer&&r.startOffset==r.endOffset||(e=!0,ft(n.currentNode)),r.startContainer===r.endContainer&&1==t.rangeCount&&0==r.startOffset&&0==r.endOffset&&("IMG"!==r.startContainer.tagName&&"VIDEO"!==r.startContainer.tagName||(e=!0,ft(n.currentNode)))),e&&n.currentNode==r.startContainer&&mt(n.currentNode),n.currentNode==r.endContainer?a=!0:n.nextNode();if(e&&n.currentNode==r.endContainer&&n.currentNode.querySelectorAll)for(let t=r.startContainer===r.endContainer?r.startOffset:0;t<r.endOffset;t++){const e=r.endContainer.childNodes[t];e&&(ft(e),e.querySelectorAll&&e.querySelectorAll("*").forEach(ft))}}}return e}function ft(t){(t.nodeType==Node.ELEMENT_NODE?t:t.parentElement).setAttribute(N,"")}function mt(t){t.parentElement&&(ft(t),mt(t.parentElement))}function pt(){let t=document.querySelector(W);return t||(t=bt(W,document.body),t.style.setProperty("box-sizing","border-box","important"),t.style.setProperty("background-color","#3ea9d7","important"),t.style.setProperty("border","10px solid #0b4892","important"),t.style.setProperty("border-radius","2px","important"),t.style.setProperty("opacity",".25","important"),t.style.setProperty("pointer-events","none","important"),t.style.setProperty("position","absolute","important"),t.style.setProperty("transition","all 100ms","important"),t.style.setProperty("cursor","pointer","important"),t.style.setProperty("z-index","2147483647","important"),t.style.removeProperty("border-inline-end"),t.style.removeProperty("border-inline-start"),t.style.removeProperty("inline-size"),t.style.removeProperty("block-size"),t.style.removeProperty("inset-block-start"),t.style.removeProperty("inset-inline-end"),t.style.removeProperty("inset-block-end"),t.style.removeProperty("inset-inline-start")),t}function ht(){try{if(et=document.querySelector(G),!et){et=bt(G);const t=et.attachShadow({mode:"open"}),e=document.createElement("style");e.textContent=`\n\t\t\t\t@keyframes single-file-pulse { \n\t\t\t\t\t0% { \n\t\t\t\t\t\topacity: .25;\n\t\t\t\t\t} \n\t\t\t\t\t100% { \n\t\t\t\t\t\topacity: 1;\n\t\t\t\t\t} \n\t\t\t\t}\n\t\t\t\t.${H} {\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\tbottom: 24px;\n\t\t\t\t\tleft: 8px;\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\topacity: 0.9;\n\t\t\t\t\tpadding: 4px;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t\tmin-width: ${Z}px;\n\t\t\t\t\tmin-height: 16px;\n\t\t\t\t\ttransition: height 100ms;\n\t\t\t\t}\n\t\t\t\t.${q} {\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tjustify-content: space-between;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: arial, sans-serif;\n\t\t\t\t\tcolor: black;\n\t\t\t\t\tbackground-color: white;\n\t\t\t\t}\n\t\t\t\t.${z} {\n\t\t\t\t\tfont-size: 13px;\n\t\t\t\t\topacity: 1;\n\t\t\t\t\ttransition: opacity 200ms;\n\t\t\t\t}\n\t\t\t\t.${V} {\n\t\t\t\t\tfont-size: 11px;\n\t\t\t\t\tmin-width: 15px;\n\t\t\t\t\ttext-align: center;\n\t\t\t\t\tposition: relative;\n\t\t\t\t\ttop: 1px;\n\t\t\t\t}\n\t\t\t`,t.appendChild(e);const n=document.createElement("div");n.classList.add(H),t.appendChild(n)}}catch(t){}}function yt(t,e,n,r){try{if(r.logsEnabled){const r=et.shadowRoot.querySelector("."+H);let o=r.querySelector("[data-id='"+t+"']");if(!o){o=document.createElement("div"),o.classList.add(q),r.appendChild(o),o.setAttribute("data-id",t);const n=document.createElement("div");n.classList.add(z),o.appendChild(n),n.textContent=e;const a=document.createElement("div");a.classList.add(V),o.appendChild(a)}!function(t,e,n){const r=t.childNodes[0],o=t.childNodes[1];r.textContent=e,o.style.setProperty("color","✓"==n?"#055000":"black"),"✓"==n?(r.style.setProperty("opacity",".5"),o.style.setProperty("opacity",".5"),o.style.setProperty("animation","none")):o.style.setProperty("animation","1s ease-in-out 0s infinite alternate none running single-file-pulse");o.textContent=n}(o,e,n)}}catch(t){}}function gt(t,e){let n,r=t,o=[];do{const t=r.getBoundingClientRect();if(r.parentElement){const a=r.parentElement.getBoundingClientRect();n=Math.abs(a[e]-t[e])<=8,n&&(r.parentElement.clientWidth>8&&r.parentElement.clientHeight>8&&(r.parentElement.clientWidth-r.clientWidth>8||r.parentElement.clientHeight-r.clientHeight>8)&&o.push(r.parentElement),r=r.parentElement)}else n=!1}while(n&&r);return o}function wt(t,e,n,r){return Math[t](n/8)<=r.length&&(e=r[r.length-Math[t](n/8)-1]),e}function bt(t,e){const n=document.createElement(t);return n.className=X,e&&e.appendChild(n),K.forEach(t=>n.style.setProperty(t,"initial","important")),n}ht();const At=globalThis.singlefile,Et=At.helper.SINGLE_FILE_UI_ELEMENT_CLASS,vt="singlefile-open-file-bar",St="singlefile-share-page-bar";let Tt,Pt,It,Ct;const Rt=new Set(Array.from(getComputedStyle(document.documentElement)));function xt(t){({EMBEDDED_IMAGE_BUTTON_MESSAGE:Tt,SHARE_PAGE_BUTTON_MESSAGE:Pt,SHARE_SELECTION_BUTTON_MESSAGE:It,ERROR_TITLE_MESSAGE:Ct}=t)}function Ut(t,e){console.error("SingleFile",t,e),Lt("singlefile-error-bar",Ct+t,{link:e})}function Lt(t,e,{link:n,buttonLabel:r,buttonOnclick:o}={}){try{if(!document.querySelector(t)){const a=function(t){const e=document.createElement(t);return e.className=Et,Rt.forEach(t=>e.style.setProperty(t,"initial","important")),e}(t),i=a.attachShadow({mode:"open"}),s=document.createElement("style");s.textContent="\n\t\t\t\t.container {\n\t\t\t\t\tbackground-color: #ff6c00;\n\t\t\t\t\tcolor: white;\n\t\t\t\t\tdisplay: flex;\n\t\t\t\t\tposition: fixed;\n\t\t\t\t\ttop: 0px;\n\t\t\t\t\tleft: 0px;\n\t\t\t\t\tright: 0px;\n\t\t\t\t\theight: auto;\n\t\t\t\t\twidth: auto;\n\t\t\t\t\tmin-height: 24px;\n\t\t\t\t\tmin-width: 24px;\t\t\t\t\t\n\t\t\t\t\tz-index: 2147483647;\n\t\t\t\t\tmargin: 0;\n\t\t\t\t\tpadding: 2px;\n\t\t\t\t\tfont-family: Arial;\n\t\t\t\t}\n\t\t\t\t.singlefile-open-file-bar.container, .singlefile-share-page-bar.container {\n\t\t\t\t\tbackground-color: gainsboro;\n\t\t\t\t\tborder-block-end: gray 1px solid;\n\t\t\t\t}\n\t\t\t\t.text {\n\t\t\t\t\tflex: 1;\n\t\t\t\t\tpadding-top: 4px;\n\t\t\t\t\tpadding-bottom: 4px;\n\t\t\t\t\tpadding-left: 8px;\t\t\t\t\t\n\t\t\t\t}\n\t\t\t\tbutton {\n\t\t\t\t\tbackground-color: grey;\n\t\t\t\t\tcolor: white;\n\t\t\t\t\tborder: 1px solid darkgrey;\n\t\t\t\t\tpadding: 3px;\n\t\t\t\t\tpadding-left: 8px;\n\t\t\t\t\tpadding-right: 8px;\n\t\t\t\t\tborder-radius: 4px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t}\n\t\t\t\t.close-button {\n\t\t\t\t\topacity: .7;\n\t\t\t\t\tpadding-left: 8px;\n\t\t\t\t\tpadding-right: 8px;\n\t\t\t\t\tcursor: pointer;\n\t\t\t\t\ttransition: opacity 250ms;\n\t\t\t\t\theight: 16px;\n\t\t\t\t\tfont-size: .8rem;\n\t\t\t\t\talign-self: center;\n\t\t\t\t}\n\t\t\t\t.singlefile-open-file-bar button, .singlefile-share-page-bar button{\n\t\t\t\t\tbackground-color: dimgrey;\n\t\t\t\t}\n\t\t\t\t.singlefile-open-file-bar .close-button, .singlefile-share-page-bar .close-button{\n\t\t\t\t\tfilter: invert(1);\n\t\t\t\t}\n\t\t\t\ta {\n\t\t\t\t\tcolor: #303036;\n\t\t\t\t}\n\t\t\t\t.close-button:hover {\n\t\t\t\t\topacity: 1;\n\t\t\t\t}\n\t\t\t",i.appendChild(s);const c=document.createElement("div");c.classList.add(t),c.classList.add("container");const l=document.createElement("span");l.classList.add("text");const d=e.split("__DOC_LINK__");if(l.textContent=d[0],n&&2==d.length){const t=document.createElement("a");t.textContent=n,t.href=n,t.target="_blank",l.appendChild(t),l.appendChild(document.createTextNode(d[1]))}if(r&&o){const t=document.createElement("button");t.textContent=r,t.onclick=()=>o(),l.appendChild(t)}c.appendChild(l);const u=document.createElement("img");u.classList.add("close-button"),c.appendChild(u),i.appendChild(c),u.src="data:image/png;base64,iVBORw0KGgoAAAANSUhEUgAAAEAAAABACAYAAACqaXHeAAABhmlDQ1BJQ0MgcHJvZmlsZQAAKJF9kT1Iw0AYht+mSlUqHewg4hChOogFURFHqWIRLJS2QqsOJpf+CE0akhQXR8G14ODPYtXBxVlXB1dBEPwBcXNzUnSREr9LCi1ivOO4h/e+9+XuO0Col5lqdowDqmYZqXhMzOZWxMAruhGiOYohiZl6Ir2Qgef4uoeP73dRnuVd9+foVfImA3wi8SzTDYt4nXh609I57xOHWUlSiM+Jxwy6IPEj12WX3zgXHRZ4ZtjIpOaIw8RisY3lNmYlQyWeIo4oqkb5QtZlhfMWZ7VcZc178hcG89pymuu0BhHHIhJIQoSMKjZQhoUo7RopJlJ0HvPwDzj+JLlkcm2AkWMeFaiQHD/4H/zurVmYnHCTgjGg88W2P4aBwC7QqNn297FtN04A/zNwpbX8lTow80l6raVFjoDQNnBx3dLkPeByB+h/0iVDciQ/LaFQAN7P6JtyQN8t0LPq9q15jtMHIEO9WroBDg6BkSJlr3m8u6u9b//WNPv3A6mTcr3f/E/sAAAABmJLR0QAigCKAIrj2uckAAAACXBIWXMAAC4jAAAuIwF4pT92AAAAB3RJTUUH5QkPDysvCdPVuwAAABl0RVh0Q29tbWVudABDcmVhdGVkIHdpdGggR0lNUFeBDhcAAAELSURBVHja7ZpLFsIwDAPj3v/OsGHDe1BIa8tKO7Mnlkw+dpoxAAAAAGCfx4ur6Yx/B337UUS4mp/VuWUEcjSfOgO+BXCZCWe0hSqQo/npBLglIUNLdAV2MH84Ad1JyIwdLkK6YoabIHWscBWmihHuAqvHtv+XqmdXOK9TxdKy3axUm2vZkXXGgPJksTuz1bVFeeU2Y6ijsLIpXbtKa1kDs2ews69o7+A+ihJ2lvI+/lcS1G21zUVG18XKNm4OS4BNkGOQQohSmGaIdpgLESvzyiRwKepsXjE2H0ZWMF8Zi4+jK5mviM0DiRXNZ2rhkdTK5jO0xermz2o8dCnq+FS2XNNVH0sDAAAA3JYnre9cH8BZmhEAAAAASUVORK5CYII=",u.onclick=t=>{0===t.button&&(o&&o(!0),a.remove())},document.documentElement.appendChild(a)}}catch(t){}}const Dt=16777216;let kt,Mt,Ot,Nt,Bt;try{kt=browser.i18n.getMessage("topPanelEmbeddedImageButton"),Mt=browser.i18n.getMessage("topPanelSharePageButton"),Ot=browser.i18n.getMessage("topPanelShareSelectionButton"),Nt=browser.i18n.getMessage("topPanelError")}catch(t){}async function Ft(t,e){e.includeBOM&&(t.content="\ufeff"+t.content);const n=e.embeddedImage,r={method:"downloads.download",taskId:e.taskId,insertTextBody:e.insertTextBody,confirmFilename:e.confirmFilename,filenameConflictAction:e.filenameConflictAction,filename:t.filename,mimeType:t.mimeType,saveToClipboard:e.saveToClipboard,saveToGDrive:e.saveToGDrive,saveToDropbox:e.saveToDropbox,saveWithWebDAV:e.saveWithWebDAV,webDAVURL:e.webDAVURL,webDAVUser:e.webDAVUser,webDAVPassword:e.webDAVPassword,saveWithMCP:e.saveWithMCP,mcpServerUrl:e.mcpServerUrl,mcpAuthToken:e.mcpAuthToken,saveToGitHub:e.saveToGitHub,githubToken:e.githubToken,githubUser:e.githubUser,githubRepository:e.githubRepository,githubBranch:e.githubBranch,saveWithCompanion:e.saveWithCompanion,forceWebAuthFlow:e.forceWebAuthFlow,filenameReplacementCharacter:e.filenameReplacementCharacter,openEditor:e.openEditor,openSavedPage:e.openSavedPage,compressHTML:e.compressHTML,backgroundSave:e.backgroundSave,bookmarkId:e.bookmarkId,replaceBookmarkURL:e.replaceBookmarkURL,applySystemTheme:e.applySystemTheme,contentWidth:e.contentWidth,defaultEditorMode:e.defaultEditorMode,includeInfobar:e.includeInfobar,openInfobar:e.openInfobar,warnUnsavedPage:e.warnUnsavedPage,createRootDirectory:e.createRootDirectory,selfExtractingArchive:e.selfExtractingArchive,embeddedImage:n?Array.from(n):null,preventAppendedData:e.preventAppendedData,extractDataFromPage:e.extractDataFromPage,insertCanonicalLink:e.insertCanonicalLink,insertMetaNoIndex:e.insertMetaNoIndex,insertMetaCSP:e.insertMetaCSP,password:e.password,compressContent:e.compressContent,foregroundSave:e.foregroundSave,sharePage:e.sharePage,saveToRestFormApi:e.saveToRestFormApi,saveToRestFormApiUrl:e.saveToRestFormApiUrl,saveToRestFormApiFileFieldName:e.saveToRestFormApiFileFieldName,saveToRestFormApiUrlFieldName:e.saveToRestFormApiUrlFieldName,saveToRestFormApiToken:e.saveToRestFormApiToken,saveToS3:e.saveToS3,S3Domain:e.S3Domain,S3Region:e.S3Region,S3Bucket:e.S3Bucket,S3AccessKey:e.S3AccessKey,S3SecretKey:e.S3SecretKey,infobarPositionAbsolute:e.infobarPositionAbsolute,infobarPositionTop:e.infobarPositionTop,infobarPositionBottom:e.infobarPositionBottom,infobarPositionLeft:e.infobarPositionLeft,infobarPositionRight:e.infobarPositionRight,originalUrl:e.url,title:t.title},o=setInterval(()=>{browser.runtime.sendMessage({method:"ping"}).then(()=>{})},15e3);if(e.compressContent)if((!e.backgroundSave||e.saveToGDrive||e.saveToGitHub||e.saveWithCompanion||e.saveWithWebDAV||e.saveWithMCP||e.saveToDropbox||e.saveToRestFormApi||e.saveToS3)&&e.confirmFilename&&!e.openEditor&&(t.filename=nt("Save as",t.filename)),t.filename){const o=new Blob([await s(t)],{type:t.mimeType}),a=URL.createObjectURL(o);r.filename=t.filename,r.blobURL=a;const i=await browser.runtime.sendMessage(r);if(URL.revokeObjectURL(a),i.error){r.embeddedImage=n,r.blobURL=null,r.pageData=t;const e=d(r);for await(const t of e)await browser.runtime.sendMessage({method:"downloads.download",compressContent:!0,data:Array.from(t)});await browser.runtime.sendMessage({method:"downloads.download",compressContent:!0,mimeType:t.mimeType})}if(e.backgroundSave){const n=e.openEditor?null:t.hash;await browser.runtime.sendMessage({method:"downloads.end",taskId:e.taskId,hash:n,woleetKey:e.woleetKey})}}else browser.runtime.sendMessage({method:"downloads.cancel"}),browser.runtime.sendMessage({method:"ui.processCancelled"});else{if(e.backgroundSave&&!e.sharePage||e.openEditor||e.saveToGDrive||e.saveToGitHub||e.saveWithCompanion||e.saveWithWebDAV||e.saveWithMCP||e.saveToDropbox||e.saveToRestFormApi||e.saveToS3){let n=t.filename;if((e.saveToGDrive||e.saveToGitHub||e.saveWithCompanion||e.saveWithWebDAV||e.saveWithMCP||e.saveToDropbox||e.saveToRestFormApi||e.saveToS3)&&e.confirmFilename&&!e.openEditor&&(n=nt("Save as",t.filename)),n){r.filename=t.filename=n;const e=URL.createObjectURL(new Blob([t.content],{type:t.mimeType}));r.blobURL=e;const o=await browser.runtime.sendMessage(r);if(URL.revokeObjectURL(e),o.error){r.blobURL=null;for(let e=0;e*Dt<t.content.length;e++)r.truncated=t.content.length>Dt,r.truncated?(r.finished=(e+1)*Dt>t.content.length,r.content=t.content.substring(e*Dt,(e+1)*Dt)):r.content=t.content,await browser.runtime.sendMessage(r)}}else browser.runtime.sendMessage({method:"downloads.cancel"}),browser.runtime.sendMessage({method:"ui.processCancelled"})}else e.saveToClipboard?function(t){const e="copy";function n(e){e.clipboardData.setData(t.mimeType,t.content),e.clipboardData.setData("text/plain",t.content),e.preventDefault()}document.addEventListener(e,n),document.execCommand(e),document.removeEventListener(e,n)}(t):await _t(t,e),e.openSavedPage&&open(URL.createObjectURL(new Blob([t.content],{type:t.mimeType}))),browser.runtime.sendMessage({method:"ui.processEnd"});const n=e.openEditor?null:t.hash;await browser.runtime.sendMessage({method:"downloads.end",taskId:e.taskId,hash:n,woleetKey:e.woleetKey})}clearInterval(o)}async function _t(t,e){if(Array.isArray(t.content)&&(t.content=new Uint8Array(t.content)),e.sharePage&&navigator.share)await jt(t,e);else{let n=t.filename;if(e.confirmFilename&&(n=nt("Save as",t.filename),n?t.filename=n:(browser.runtime.sendMessage({method:"downloads.cancel"}),browser.runtime.sendMessage({method:"ui.processCancelled"}))),n){const e=document.createElement("a");return e.download=t.filename,e.href=URL.createObjectURL(new Blob([t.content],{type:t.mimeType})),e.dispatchEvent(new MouseEvent("click")),new Promise(t=>setTimeout(()=>{URL.revokeObjectURL(e.href),t()},1e3))}}}async function jt(t,e){Bt=function(){let t;return{display:async function(e){return new Promise(n=>{t=n,Lt(St,"",{buttonLabel:e?It:Pt,buttonOnclick:n})})},hide:function(){const t=document.querySelector(St);t&&t.remove()},cancel:function(){this.hide(),t&&t(!0)}}}();if(!await Bt.display(e.selected)){const n={files:[new File([t.content],t.filename,{type:t.mimeType})]};try{await navigator.share(n),Bt.hide()}catch(n){if(Bt.hide(),"AbortError"!==n.name)throw n;await jt(t,e)}}}xt({EMBEDDED_IMAGE_BUTTON_MESSAGE:kt,SHARE_PAGE_BUTTON_MESSAGE:Mt,SHARE_SELECTION_BUTTON_MESSAGE:Ot,ERROR_TITLE_MESSAGE:Nt});const Wt="single-file-response-fetch",Gt="Host fetch error (SingleFile)",Ht=Boolean(window.wrappedJSObject),qt=window.fetch.bind(window);let zt,Vt=0,Xt=new Map;async function Kt(t,e={},n=!0){try{const r={cache:e.cache||"force-cache",headers:e.headers,referrerPolicy:e.referrerPolicy||"strict-origin-when-cross-origin"};let o;try{o=e.referrer&&!Ht||!n?await qt(t,r):await async function(t,e){if(void 0===zt&&(zt=!1,document.addEventListener("single-file-response-fetch-supported",()=>zt=!0,!1),document.dispatchEvent(new CustomEvent("single-file-request-fetch-supported"))),zt)return new Promise((n,r)=>{document.dispatchEvent(new CustomEvent("single-file-request-fetch",{detail:JSON.stringify({url:t,options:e})})),document.addEventListener(Wt,function e(o){o.detail?o.detail.url==t&&(document.removeEventListener(Wt,e,!1),o.detail.response?n({status:o.detail.status,headers:new Map(o.detail.headers),arrayBuffer:async()=>o.detail.response}):r(o.detail.error)):r()},!1)});throw new Error(Gt)}(t,r),401!=o.status&&403!=o.status&&404!=o.status||"no-referrer"==r.referrerPolicy||e.referrer||(o=await Kt(t,{...r,referrerPolicy:"no-referrer"},n))}catch(a){if(a&&a.message==Gt)o=await Kt(t,{...r},!1);else{if("no-referrer"==r.referrerPolicy||e.referrer)throw a;o=await Kt(t,{...r,referrerPolicy:"no-referrer"},n)}}return o}catch(n){Vt++;const r=new Promise((t,e)=>Xt.set(Vt,{resolve:t,reject:e}));return await Zt({method:"singlefile.fetch",url:t,requestId:Vt,referrer:e.referrer,headers:e.headers}),r}}async function Zt(t){const e=await browser.runtime.sendMessage(t);if(!e||e.error)throw new Error(e&&e.error&&e.error.toString());return e}browser.runtime.onMessage.addListener(t=>"singlefile.fetchFrame"==t.method&&window.frameId&&window.frameId==t.frameId?async function(t){try{const e=await qt(t.url,{cache:"force-cache",headers:t.headers,referrerPolicy:"strict-origin-when-cross-origin"});return{status:e.status,headers:[...e.headers],array:Array.from(new Uint8Array(await e.arrayBuffer()))}}catch(t){return{error:t&&(t.message||t.toString())}}}(t):"singlefile.fetchResponse"==t.method?async function(t){const e=Xt.get(t.requestId);e&&(t.error?(e.reject(new Error(t.error)),Xt.delete(t.requestId)):(t.truncated&&(e.array?e.array=e.array.concat(t.array):(e.array=t.array,Xt.set(t.requestId,e)),t.finished&&(t.array=e.array)),t.truncated&&!t.finished||(e.resolve({status:t.status,headers:{get:e=>t.headers&&t.headers[e]},arrayBuffer:async()=>new Uint8Array(t.array).buffer}),Xt.delete(t.requestId))));return{}}(t):void 0);const Qt=globalThis.singlefile,Jt=globalThis.singlefileBootstrap,Yt="moz-extension:",$t=browser.i18n.getMessage("topPanelEmbeddedImageButton"),te=browser.i18n.getMessage("topPanelSharePageButton"),ee=browser.i18n.getMessage("topPanelShareSelectionButton"),ne=browser.i18n.getMessage("topPanelError"),re="_singleFile_waitForUserScript",oe="single-file-on-init-capture";let ae,ie,se,ce,le,de,ue;xt({EMBEDDED_IMAGE_BUTTON_MESSAGE:$t,SHARE_PAGE_BUTTON_MESSAGE:te,SHARE_SELECTION_BUTTON_MESSAGE:ee,ERROR_TITLE_MESSAGE:ne}),Jt&&Jt.initializedSingleFile||(Qt.init({fetch:Kt,frameFetch:async function(t,e){const n=await Zt({method:"singlefile.fetchFrame",url:t,frameId:e.frameId,referrer:e.referrer,headers:e.headers});return{status:n.status,headers:new Map(n.headers),arrayBuffer:async()=>new Uint8Array(n.array).buffer}}}),browser.runtime.onMessage.addListener(t=>{if("content.save"==t.method||"content.cancelSave"==t.method||"content.download"==t.method||"content.getSelectedLinks"==t.method||"content.error"==t.method||"content.prompt"==t.method||"content.beginScrollTo"==t.method||"content.scrollTo"==t.method||"content.endScrollTo"==t.method)return async function(t){if(!location.href.startsWith(Yt)){if("content.save"==t.method)return await async function(t){const e=setInterval(()=>{browser.runtime.sendMessage({method:"ping"}).then(()=>{})},15e3),n=t.options;let r;(n.selected||n.optionallySelected)&&(r=await dt(n.optionallySelected));if(!(ie||Jt&&Jt.pageInfo.processing)){if(n.visitDate=Jt?Jt.pageInfo.visitDate:new Date,n.optionallySelected&&r&&(n.selected=!0),!n.selected||r){Jt&&(Jt.pageInfo.processing=!0),ie=!0;try{const t=await async function(t){const e=Qt.processors.frameTree;let n;Qt.helper.initDoc(document),ot(t),ae=new Qt.SingleFile(t);const r=[];t.insertCanonicalLink=!0;let o,a=0,i=0;t.onprogress=async t=>{const{options:e}=t.detail;if(!ae.cancelled){if(t.type==t.RESOURCES_INITIALIZING&&!o&&e.insertEmbeddedScreenshotImage&&e.compressContent){o=!0,rt(!1);const t=await browser.runtime.sendMessage({method:"tabs.getScreenshot",width:document.documentElement.scrollWidth,height:document.documentElement.scrollHeight,innerHeight:globalThis.innerHeight});rt(!0),st(e),e.embeddedImage=new Uint8Array(await(await Kt(t)).arrayBuffer()),URL.revokeObjectURL(t),ct(e)}t.type==t.RESOURCES_INITIALIZED&&(i=t.detail.max,e.loadDeferredImages&&Qt.processors.lazy.resetZoomLevel(e)),t.type==t.RESOURCES_INITIALIZED||t.type==t.RESOURCE_LOADED?(t.type==t.RESOURCE_LOADED&&a++,await browser.runtime.sendMessage({method:"ui.processProgress",index:a,maxIndex:i}),it(a,i,e)):t.detail.frame||t.type==t.PAGE_LOADING||t.type==t.PAGE_LOADED||(t.type==t.STAGE_STARTED?t.detail.step<3&&function(t,e){yt("step-"+t,`${$} ${t+1} / 3`,"…",e)}(t.detail.step,e):t.type==t.STAGE_ENDED&&t.detail.step<3&&function(t,e){yt("step-"+t,`${$} ${t+1} / 3`,"✓",e)}(t.detail.step,e))}};const s=globalThis[re];t.userScriptEnabled&&s&&await s(oe,t);const c=ae.cancel.bind(ae);if(t.insertEmbeddedImage&&t.compressContent){st(t),ce=function(){let t;return{display:async function(){return new Promise(e=>{t=e,Lt(vt,"",{buttonLabel:Tt,buttonOnclick:e})})},hide:function(){const t=document.querySelector(vt);t&&t.remove()},cancel:function(){this.hide(),t&&t(!0)}}}();await ce.display()||(t.embeddedImage=await function({accept:t}={accept:"image/*"}){const e=document.createElement("input");return e.type="file",e.accept=t,e.click(),new Promise(t=>{e.addEventListener("change",async e=>{if(e.target.files.length){const n=e.target.files[0];if("image/png"==n.type){const e=new FileReader;e.addEventListener("load",async()=>t(new Uint8Array(e.result))),e.addEventListener("error",()=>t()),e.readAsArrayBuffer(n)}else{const e=await new Promise(t=>{const e=new FileReader;e.addEventListener("load",()=>t(e.result)),e.addEventListener("error",()=>t()),e.readAsDataURL(n)});if(e){const r=await createImageBitmap(n),o=new Image;o.src=e,o.addEventListener("error",()=>t()),await new Promise(t=>o.addEventListener("load",t));const a=new OffscreenCanvas(o.width,o.height);a.getContext("2d").drawImage(r,0,0);const i=await a.convertToBlob({type:"image/png"}),s=new FileReader;s.addEventListener("load",()=>t(new Uint8Array(s.result))),s.addEventListener("error",()=>t()),s.readAsArrayBuffer(i)}else t()}}else t()}),e.addEventListener("cancel",()=>t())})}({accept:"image/*"}),ce.hide()),ct(t)}if(!t.saveRawPage&&!ae.cancelled){let n;if(t.loadDeferredImages&&(n=Qt.processors.lazy.process(t),function(t){yt("load-deferred-images",Q,"…",t)}(t),n.then(()=>{ae.cancelled||function(t){yt("load-deferred-images",Q,"✓",t)}(t)}),t.loadDeferredImagesBeforeFrames&&await n),!t.removeFrames&&e&&globalThis.frames){let n;n=t.loadDeferredImages?new Promise(n=>globalThis.setTimeout(()=>n(e.getAsync(t)),t.loadDeferredImagesBeforeFrames||!t.loadDeferredImages?0:t.loadDeferredImagesMaxIdleTime)):e.getAsync(t),function(t){yt("load-frames",J,"…",t)}(t),n.then(()=>{ae.cancelled||function(t){yt("load-frames",J,"✓",t)}(t)}),t.loadDeferredImagesBeforeFrames?t.frames=await new Promise(t=>{ae.cancel=function(){c(),t([])},n.then(t)}):r.push(n)}t.loadDeferredImages&&!t.loadDeferredImagesBeforeFrames&&r.push(n)}t.loadDeferredImagesBeforeFrames||ae.cancelled||([t.frames]=await new Promise(t=>{const e=Promise.all(r);ae.cancel=function(){c(),t([[]])},e.then(()=>t(e))}));t.delayBeforeProcessing&&await new Promise(e=>setTimeout(e,1e3*t.delayBeforeProcessing));n=t.frames&&t.frames.sessionId;const l=t.frames&&t.frames.find(t=>t.requestedFrame);t.win=globalThis,l?(t.content=l.content,t.url=l.baseURI,t.canvases=l.canvases,t.fonts=l.fonts,t.stylesheets=l.stylesheets,t.images=l.images,t.posters=l.posters,t.videos=l.videos,t.usedFonts=l.usedFonts,t.shadowRoots=l.shadowRoots,t.adoptedStyleSheets=l.adoptedStyleSheets,t.worklets=l.worklets):t.doc=document;ae.cancelled||await ae.run();n&&e.cleanup(n);let d;ae.cancelled||(t.confirmInfobarContent&&(t.infobarContent=nt("Infobar content",t.infobarContent)||""),d=await ae.getPageData(),(t.selected||t.optionallySelected)&&document.querySelectorAll("["+N+"]").forEach(t=>t.removeAttribute(N)),at(),t.displayStats&&(console.log("SingleFile stats"),console.table(d.stats)));t.delayAfterProcessing&&await new Promise(e=>setTimeout(e,1e3*t.delayAfterProcessing));return d}(n);t&&await Ft(t,n)}catch(t){if(!ae.cancelled){console.error(t);const e=t&&(t.message||t.toString());browser.runtime.sendMessage({method:"ui.processError",error:e}),Ut(e)}}}else browser.runtime.sendMessage({method:"ui.processCancelled"});ie=!1,Jt&&(Jt.pageInfo.processing=!1)}clearInterval(e)}(t),{};if("content.cancelSave"==t.method)return ae&&(ae.cancel(),at(),ce&&(ce.cancel(),ce=null),browser.runtime.sendMessage({method:"ui.processCancelled"})),t.options.loadDeferredImages&&Qt.processors.lazy.resetZoomLevel(t.options),{};if("content.getSelectedLinks"==t.method)return{urls:lt()};if("content.download"==t.method){se||(se=A());const e=await se.next(t.data);if(e.done){se=null;try{await _t(e.value,{foregroundSave:e.value.foregroundSave,sharePage:e.value.sharePage})}catch(t){return{error:t&&(t.message||t.toString())}}finally{await browser.runtime.sendMessage({method:"downloads.end",taskId:e.value.taskId})}}return{}}if("content.error"==t.method)return Ut(t.error,t.link),{};if("content.prompt"==t.method)return nt(t.message,t.value);if("content.beginScrollTo"==t.method)return le=globalThis.scrollY,de=document.documentElement.style.getPropertyValue("transform"),ue=document.documentElement.style.getPropertyValue("overflow"),globalThis.scrollTo(0,0),document.documentElement.style.setProperty("transform","translateY(0px)"),document.documentElement.style.setProperty("overflow","hidden"),{};if("content.scrollTo"==t.method)return document.documentElement.style.setProperty("transform","translateY(-"+t.y+"px)"),await new Promise(t=>setTimeout(t,500)),{};if("content.endScrollTo"==t.method)return globalThis.scrollTo(0,le),document.documentElement.style.setProperty("transform",de),document.documentElement.style.setProperty("overflow",ue),{}}}(t)}),Jt?Jt.initializedSingleFile=!0:globalThis.singlefileBootstrap={initializedSingleFile:!0})}();