!function(){"use strict";const e=globalThis.browser,r=globalThis.document;if(r instanceof globalThis.Document&&e&&e.runtime&&e.runtime.getURL){const a=r.createElement("script");a.src=e.runtime.getURL("/lib/single-file-hooks-frames.js"),a.async=!1,(r.documentElement||r).appendChild(a),a.remove()}const a=window.fetch.bind(window);let t=new Map;browser.runtime.onMessage.addListener((e=>"singlefile.fetchFrame"==e.method&&window.frameId&&window.frameId==e.frameId?async function(e){try{const r=await a(e.url,{cache:"force-cache",headers:e.headers,referrerPolicy:"strict-origin-when-cross-origin"});return{status:r.status,headers:[...r.headers],array:Array.from(new Uint8Array(await r.arrayBuffer()))}}catch(e){return{error:e&&(e.message||e.toString())}}}(e):"singlefile.fetchResponse"==e.method?async function(e){const r=t.get(e.requestId);r&&(e.error?(r.reject(new Error(e.error)),t.delete(e.requestId)):(e.truncated&&(r.array?r.array=r.array.concat(e.array):(r.array=e.array,t.set(e.requestId,r)),e.finished&&(e.array=r.array)),e.truncated&&!e.finished||(r.resolve({status:e.status,headers:{get:r=>e.headers&&e.headers[r]},arrayBuffer:async()=>new Uint8Array(e.array).buffer}),t.delete(e.requestId))));return{}}(e):void 0))}();
