replaywebpage 1.8.1 → 1.8.2

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.
Files changed (4) hide show
  1. package/package.json +4 -4
  2. package/src/coll.js +1 -1
  3. package/sw.js +1 -1
  4. package/ui.js +2 -2
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "replaywebpage",
3
3
  "productName": "ReplayWeb.page",
4
- "version": "1.8.1",
4
+ "version": "1.8.2",
5
5
  "description": "Serverless Web Archive Replay",
6
6
  "repository": "https://github.com/webrecorder/replayweb.page",
7
7
  "homepage": "https://replayweb.page/",
@@ -9,7 +9,7 @@
9
9
  "license": "AGPL-3.0-or-later",
10
10
  "dependencies": {
11
11
  "@fortawesome/fontawesome-free": "^5.15.4",
12
- "@webrecorder/wabac": "^2.16.1",
12
+ "@webrecorder/wabac": "^2.16.2",
13
13
  "bulma": "^0.9.3",
14
14
  "electron-log": "^4.4.1",
15
15
  "electron-updater": "^5.3.0",
@@ -36,9 +36,9 @@
36
36
  "eslint": "^8.23.1",
37
37
  "http-server": "^13.0.2",
38
38
  "mini-css-extract-plugin": "^2.3.0",
39
- "node-sass": "^8.0.0",
39
+ "node-sass": "^9.0.0",
40
40
  "raw-loader": "^4.0.2",
41
- "sass-loader": "^12.1.0",
41
+ "sass-loader": "^13.3.2",
42
42
  "style-loader": "^3.2.1",
43
43
  "svg-inline-loader": "^0.8.2",
44
44
  "webpack": "^5.75.0",
package/src/coll.js CHANGED
@@ -149,7 +149,7 @@ class Coll extends LitElement
149
149
  async runUpdateLoop() {
150
150
  try {
151
151
  // only autoupdate if interval is set, and number of pages < 100 to avoid messing up scrolling
152
- while (this.editable && this.autoUpdateInterval && (!this.collInfo || this.collInfo.pages.length < 100)) {
152
+ while (this.editable && this.autoUpdateInterval && (!this.collInfo || !this.collInfo.pages || this.collInfo.pages.length < 100)) {
153
153
  await new Promise(resolve => setTimeout(resolve, this.autoUpdateInterval * 1000));
154
154
  await this.doUpdateInfo(true);
155
155
  }
package/sw.js CHANGED
@@ -118,4 +118,4 @@ var ff=function(t,e){return ff=Object.setPrototypeOf||{__proto__:[]}instanceof A
118
118
  * SOFTWARE.
119
119
  *
120
120
  */
121
- const Wg="crypto.algorithm";const jg="crypto.algorithmProvider";var zg;Uf.registerSingleton(jg,class{getAlgorithms(){return Uf.resolveAll(Wg)}toAsnAlgorithm(t){for(const e of this.getAlgorithms()){const r=e.toAsnAlgorithm(t);if(r)return r}if(/[0-9.]+/.test(t.name)){const e=new Oh({algorithm:t.name});if("parameters"in t){const r=t;e.parameters=r.parameters}return e}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(t){for(const e of this.getAlgorithms()){const r=e.toWebAlgorithm(t);if(r)return r}return{name:t.algorithm,parameters:t.parameters}}});const Gg="1.3.36.3.3.2.8.1.1",qg=`${Gg}.1`,Qg=`${Gg}.2`,Vg=`${Gg}.3`,Kg=`${Gg}.4`,Yg=`${Gg}.5`,Jg=`${Gg}.6`,Xg=`${Gg}.7`,Zg=`${Gg}.8`,$g=`${Gg}.9`,tw=`${Gg}.10`,ew=`${Gg}.11`,rw=`${Gg}.12`,iw=`${Gg}.13`,nw=`${Gg}.14`,sw="brainpoolP160r1",ow="brainpoolP160t1",aw="brainpoolP192r1",cw="brainpoolP192t1",lw="brainpoolP224r1",uw="brainpoolP224t1",hw="brainpoolP256r1",pw="brainpoolP256t1",dw="brainpoolP320r1",fw="brainpoolP320t1",gw="brainpoolP384r1",ww="brainpoolP384t1",yw="brainpoolP512r1",mw="brainpoolP512t1",bw="ECDSA";let Aw=zg=class{toAsnAlgorithm(t){if(t.name.toLowerCase()===bw.toLowerCase())if("hash"in t){switch(("string"==typeof t.hash?t.hash:t.hash.name).toLowerCase()){case"sha-1":return Sd;case"sha-256":return Id;case"sha-384":return Cd;case"sha-512":return Rd}}else if("namedCurve"in t){let e="";switch(t.namedCurve){case"P-256":e=Ed;break;case"K-256":e=zg.SECP256K1;break;case"P-384":e=_d;break;case"P-521":e=vd;break;case sw:e=qg;break;case ow:e=Qg;break;case aw:e=Vg;break;case cw:e=Kg;break;case lw:e=Yg;break;case uw:e=Jg;break;case hw:e=Xg;break;case pw:e=Zg;break;case dw:e=$g;break;case fw:e=tw;break;case gw:e=ew;break;case ww:e=rw;break;case yw:e=iw;break;case mw:e=nw}if(e)return new Oh({algorithm:gd,parameters:Kl.serialize(new xd({namedCurve:e}))})}return null}toWebAlgorithm(t){switch(t.algorithm){case wd:return{name:bw,hash:{name:"SHA-1"}};case md:return{name:bw,hash:{name:"SHA-256"}};case bd:return{name:bw,hash:{name:"SHA-384"}};case Ad:return{name:bw,hash:{name:"SHA-512"}};case gd:if(!t.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(Kl.parse(t.parameters,xd).namedCurve){case Ed:return{name:bw,namedCurve:"P-256"};case zg.SECP256K1:return{name:bw,namedCurve:"K-256"};case _d:return{name:bw,namedCurve:"P-384"};case vd:return{name:bw,namedCurve:"P-521"};case qg:return{name:bw,namedCurve:sw};case Qg:return{name:bw,namedCurve:ow};case Vg:return{name:bw,namedCurve:aw};case Kg:return{name:bw,namedCurve:cw};case Yg:return{name:bw,namedCurve:lw};case Jg:return{name:bw,namedCurve:uw};case Xg:return{name:bw,namedCurve:hw};case Zg:return{name:bw,namedCurve:pw};case $g:return{name:bw,namedCurve:dw};case tw:return{name:bw,namedCurve:fw};case ew:return{name:bw,namedCurve:gw};case rw:return{name:bw,namedCurve:ww};case iw:return{name:bw,namedCurve:yw};case nw:return{name:bw,namedCurve:mw}}}return null}};Aw.SECP256K1="1.3.132.0.10",Aw=zg=hf([Ff()],Aw),Uf.registerSingleton(Wg,Aw);const Ew=Symbol("name"),_w=Symbol("value");class vw{constructor(t,e={},r=""){this[Ew]=t,this[_w]=r;for(const t in e)this[t]=e[t]}}vw.NAME=Ew,vw.VALUE=_w;class Tw{static toString(t){const e=this.items[t];return e||t}}Tw.items={[Qd]:"sha1",[Vd]:"sha224",[Kd]:"sha256",[Yd]:"sha384",[Jd]:"sha512",[Bd]:"rsaEncryption",[Fd]:"sha1WithRSAEncryption",[Hd]:"sha224WithRSAEncryption",[Wd]:"sha256WithRSAEncryption",[jd]:"sha384WithRSAEncryption",[zd]:"sha512WithRSAEncryption",[gd]:"ecPublicKey",[wd]:"ecdsaWithSHA1",[yd]:"ecdsaWithSHA224",[md]:"ecdsaWithSHA256",[bd]:"ecdsaWithSHA384",[Ad]:"ecdsaWithSHA512",[Ju]:"TLS WWW server authentication",[Xu]:"TLS WWW client authentication",[Zu]:"Code Signing",[$u]:"E-mail Protection",[th]:"Time Stamping",[eh]:"OCSP Signing","1.2.840.113549.1.7.2":"Signed Data"};class Sw{static serialize(t){return this.serializeObj(t).join("\n")}static pad(t=0){return"".padStart(2*t," ")}static serializeObj(t,e=0){const r=[];let i=this.pad(e++),n="";const s=t[vw.VALUE];s&&(n=` ${s}`),r.push(`${i}${t[vw.NAME]}:${n}`),i=this.pad(e);for(const n in t){if("symbol"==typeof n)continue;const s=t[n],o=n?`${n}: `:"";if("string"==typeof s||"number"==typeof s||"boolean"==typeof s)r.push(`${i}${o}${s}`);else if(s instanceof Date)r.push(`${i}${o}${s.toUTCString()}`);else if(Array.isArray(s))for(const t of s)t[vw.NAME]=n,r.push(...this.serializeObj(t,e));else if(s instanceof vw)s[vw.NAME]=n,r.push(...this.serializeObj(s,e));else if(Ko.vJ.isBufferSource(s))n?(r.push(`${i}${o}`),r.push(...this.serializeBufferSource(s,e+1))):r.push(...this.serializeBufferSource(s,e));else{if(!("toTextObject"in s))throw new TypeError("Cannot serialize data in text format. Unsupported type.");{const t=s.toTextObject();t[vw.NAME]=n,r.push(...this.serializeObj(t,e))}}}return r}static serializeBufferSource(t,e=0){const r=this.pad(e),i=Ko.vJ.toUint8Array(t),n=[];for(let t=0;t<i.length;){const e=[];for(let r=0;r<16&&t<i.length;r++){8===r&&e.push("");const n=i[t++].toString(16).padStart(2,"0");e.push(n)}n.push(`${r}${e.join(" ")}`)}return n}static serializeAlgorithm(t){return this.algorithmSerializer.toTextObject(t)}}Sw.oidSerializer=Tw,Sw.algorithmSerializer=class{static toTextObject(t){const e=new vw("Algorithm Identifier",{},Tw.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case gd:{const r=(new Aw).toWebAlgorithm(t);r&&"namedCurve"in r?e["Named Curve"]=r.namedCurve:e.Parameters=t.parameters;break}default:e.Parameters=t.parameters}return e}};class Iw{constructor(...t){if(1===t.length){const e=t[0];this.rawData=Kl.serialize(e),this.onInit(e)}else{const e=Kl.parse(t[0],t[1]);this.rawData=Ko.vJ.toArrayBuffer(t[0]),this.onInit(e)}}equal(t){return t instanceof Iw&&(0,Ko.Xy)(t.rawData,this.rawData)}toString(t="text"){switch(t){case"asn":return Kl.toString(this.rawData);case"text":return Sw.serialize(this.toTextObject());case"hex":return Ko.ep.ToHex(this.rawData);case"base64":return Ko.ep.ToBase64(this.rawData);case"base64url":return Ko.ep.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const t=this.toTextObjectEmpty();return t[""]=this.rawData,t}toTextObjectEmpty(t){return new vw(this.getTextName(),{},t)}}Iw.NAME="ASN";class Cw extends Iw{constructor(...t){let e;e=Ko.vJ.isBufferSource(t[0])?Ko.vJ.toArrayBuffer(t[0]):Kl.serialize(new Ph({extnID:t[0],critical:t[1],extnValue:new hl(Ko.vJ.toArrayBuffer(t[2]))})),super(e,Ph)}onInit(t){this.type=t.extnID,this.critical=t.critical,this.value=t.extnValue.buffer}toTextObject(){const t=this.toTextObjectWithoutValue();return t[""]=this.value,t}toTextObjectWithoutValue(){const t=this.toTextObjectEmpty(this.critical?"critical":void 0);return t[vw.NAME]===Cw.NAME&&(t[vw.NAME]=Tw.toString(this.type)),t}}var Rw;class xw{constructor(){this.items=new Map,this[Rw]="CryptoProvider","undefined"!=typeof self&&"undefined"!=typeof crypto&&this.set(xw.DEFAULT,crypto)}static isCryptoKeyPair(t){return t&&t.privateKey&&t.publicKey}static isCryptoKey(t){return t&&t.usages&&t.type&&t.algorithm&&void 0!==t.extractable}clear(){this.items.clear()}delete(t){return this.items.delete(t)}forEach(t,e){return this.items.forEach(t,e)}has(t){return this.items.has(t)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(t=xw.DEFAULT){const e=this.items.get(t.toLowerCase());if(!e)throw new Error(`Cannot get Crypto by name '${t}'`);return e}set(t,e){if("string"==typeof t){if(!e)throw new TypeError("Argument 'value' is required");this.items.set(t.toLowerCase(),e)}else this.items.set(xw.DEFAULT,t);return this}}Rw=Symbol.toStringTag,xw.DEFAULT="default";const Nw=new xw,Ow=/^[0-2](?:\.[1-9][0-9]*)+$/;class kw{constructor(t={}){this.items={};for(const e in t)this.register(e,t[e])}get(t){return this.items[t]||null}findId(t){return e=t,new RegExp(Ow).test(e)?t:this.get(t);var e}register(t,e){this.items[t]=e,this.items[e]=t}}const Bw=new kw;function Dw(t,e){return`\\${Ko.ep.ToHex(Ko.ep.FromUtf8String(e)).toUpperCase()}`}Bw.register("CN","2.5.4.3"),Bw.register("L","2.5.4.7"),Bw.register("ST","2.5.4.8"),Bw.register("O","2.5.4.10"),Bw.register("OU","2.5.4.11"),Bw.register("C","2.5.4.6"),Bw.register("DC","0.9.2342.19200300.100.1.25"),Bw.register("E","1.2.840.113549.1.9.1"),Bw.register("G","2.5.4.42"),Bw.register("I","2.5.4.43"),Bw.register("SN","2.5.4.4"),Bw.register("T","2.5.4.12");class Lw{constructor(t,e={}){this.extraNames=new kw,this.asn=new ou;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t];this.extraNames.register(t,r)}"string"==typeof t?this.asn=this.fromString(t):t instanceof ou?this.asn=t:Ko.vJ.isBufferSource(t)?this.asn=Kl.parse(t,ou):this.asn=this.fromJSON(t)}static isASCII(t){for(let e=0;e<t.length;e++){if(t.charCodeAt(e)>255)return!1}return!0}getField(t){const e=this.extraNames.findId(t)||Bw.findId(t),r=[];for(const t of this.asn)for(const i of t)i.type===e&&r.push(i.value.toString());return r}getName(t){return this.extraNames.get(t)||Bw.get(t)}toString(){return this.asn.map((t=>t.map((t=>{const e=this.getName(t.type)||t.type,r=t.value.anyValue?`#${Ko.ep.ToHex(t.value.anyValue)}`:function(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Dw)}(t.value.toString());return`${e}=${r}`})).join("+"))).join(", ")}toJSON(){var t;const e=[];for(const r of this.asn){const i={};for(const e of r){const r=this.getName(e.type)||e.type;null!==(t=i[r])&&void 0!==t||(i[r]=[]),i[r].push(e.value.anyValue?`#${Ko.ep.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(i)}return e}fromString(t){const e=new ou,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,n=",";for(;i=r.exec(`${t},`);){let[,t,r]=i;const s=r[r.length-1];","!==s&&"+"!==s||(r=r.slice(0,r.length-1),i[3]=s);const o=i[3];if(/[\d.]+/.test(t)||(t=this.getName(t)||""),!t)throw new Error(`Cannot get OID for name type '${t}'`);const a=new iu({type:t});if("#"===r.charAt(0))a.value.anyValue=Ko.ep.FromHex(r.slice(1));else{const e=/"(.*?[^\\])?"/.exec(r);e&&(r=e[1]),r=r.replace(/\\0a/gi,"\n").replace(/\\0d/gi,"\r").replace(/\\0g/gi,"\t").replace(/\\(.)/g,"$1"),t===this.getName("E")||t===this.getName("DC")?a.value.ia5String=r:Lw.isASCII(r)?a.value.printableString=r:a.value.utf8String=r}"+"===n?e[e.length-1].push(a):e.push(new nu([a])),n=o}return e}fromJSON(t){const e=new ou;for(const r of t){const t=new nu;for(const e in r){let i=e;if(/[\d.]+/.test(e)||(i=this.getName(e)||""),!i)throw new Error(`Cannot get OID for name type '${e}'`);const n=r[e];for(const e of n){const r=new iu({type:i});if("object"==typeof e)for(const t in e)switch(t){case"ia5String":r.value.ia5String=e[t];break;case"utf8String":r.value.utf8String=e[t];break;case"universalString":r.value.universalString=e[t];break;case"bmpString":r.value.bmpString=e[t];break;case"printableString":r.value.printableString=e[t]}else"#"===e[0]?r.value.anyValue=Ko.ep.FromHex(e.slice(1)):i===this.getName("E")||i===this.getName("DC")?r.value.ia5String=e:r.value.printableString=e;t.push(r)}}e.push(t)}return e}toArrayBuffer(){return Kl.serialize(this.asn)}async getThumbprint(...t){var e;let r,i="SHA-1";return t.length>=1&&!(null===(e=t[0])||void 0===e?void 0:e.subtle)?(i=t[0]||i,r=t[1]||Nw.get()):r=t[0]||Nw.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Pw="Cannot initialize GeneralName from ASN.1 data.",Uw=`${Pw} Unsupported string format in use.`,Mw=`${Pw} Value doesn't match to GUID regular expression.`,Fw=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Hw="1.3.6.1.4.1.311.25.1",Ww="1.3.6.1.4.1.311.20.2.3",jw="dns",zw="dn",Gw="email",qw="ip",Qw="url",Vw="guid",Kw="upn",Yw="id";class Jw extends Iw{constructor(...t){let e;if(2===t.length)switch(t[0]){case zw:{const r=new Lw(t[1]).toArrayBuffer(),i=Kl.parse(r,ou);e=new uu({directoryName:i});break}case jw:e=new uu({dNSName:t[1]});break;case Gw:e=new uu({rfc822Name:t[1]});break;case Vw:{const r=new RegExp(Fw,"i").exec(t[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map(((t,e)=>e<3?Ko.ep.ToHex(new Uint8Array(Ko.ep.FromHex(t)).reverse()):t)).join("");e=new uu({otherName:new cu({typeId:Hw,value:Kl.serialize(new hl(Ko.ep.FromHex(i)))})});break}case qw:e=new uu({iPAddress:t[1]});break;case Yw:e=new uu({registeredID:t[1]});break;case Kw:e=new uu({otherName:new cu({typeId:Ww,value:Kl.serialize(_l.toASN(t[1]))})});break;case Qw:e=new uu({uniformResourceIdentifier:t[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else e=Ko.vJ.isBufferSource(t[0])?Kl.parse(t[0],uu):t[0];super(e)}onInit(t){if(null!=t.dNSName)this.type=jw,this.value=t.dNSName;else if(null!=t.rfc822Name)this.type=Gw,this.value=t.rfc822Name;else if(null!=t.iPAddress)this.type=qw,this.value=t.iPAddress;else if(null!=t.uniformResourceIdentifier)this.type=Qw,this.value=t.uniformResourceIdentifier;else if(null!=t.registeredID)this.type=Yw,this.value=t.registeredID;else if(null!=t.directoryName)this.type=zw,this.value=new Lw(t.directoryName).toString();else{if(null==t.otherName)throw new Error(Uw);if(t.otherName.typeId===Hw){this.type=Vw;const e=Kl.parse(t.otherName.value,hl),r=new RegExp(Fw,"i").exec(Ko.ep.ToHex(e));if(!r)throw new Error(Mw);this.value=r.slice(1).map(((t,e)=>e<3?Ko.ep.ToHex(new Uint8Array(Ko.ep.FromHex(t)).reverse()):t)).join("-")}else{if(t.otherName.typeId!==Ww)throw new Error(Uw);this.type=Kw,this.value=Kl.parse(t.otherName.value,eu).toString()}}}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let t;switch(this.type){case zw:case jw:case Vw:case qw:case Yw:case Kw:case Qw:t=this.type.toUpperCase();break;case Gw:t="Email";break;default:throw new Error("Unsupported GeneralName type")}let e=this.value;return this.type===Yw&&(e=Tw.toString(e)),new vw(t,void 0,e)}}class Xw extends Iw{constructor(t){let e;if(t instanceof _u)e=t;else if(Array.isArray(t)){const r=[];for(const e of t)if(e instanceof uu)r.push(e);else{const t=Kl.parse(new Jw(e.type,e.value).rawData,uu);r.push(t)}e=new _u(r)}else{if(!Ko.vJ.isBufferSource(t))throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");e=Kl.parse(t,_u)}super(e)}onInit(t){const e=[];for(const r of t){let t=null;try{t=new Jw(r)}catch{continue}e.push(t)}this.items=e}toJSON(){return this.items.map((t=>t.toJSON()))}toTextObject(){const t=super.toTextObjectEmpty();for(const e of this.items){const r=e.toTextObject();let i=t[r[vw.NAME]];Array.isArray(i)||(i=[],t[r[vw.NAME]]=i),i.push(r)}return t}}Xw.NAME="GeneralNames";const Zw="\\n",$w="-{5}BEGIN ([^\\n]+(?=-{5}))-{5}\\n(?:((?:[^:\\n]+: (?:[^\\n]+\\n(?: +[^\\n]+\\n)*))+))?\\n?((?:[a-zA-Z0-9=+/]+\\n)+)-{5}END \\1-{5}";class ty{static isPem(t){return"string"==typeof t&&new RegExp($w,"g").test(t)}static decodeWithHeaders(t){t=t.replace(/\r/g,"");const e=new RegExp($w,"g"),r=[];let i=null;for(;i=e.exec(t);){const t=i[3].replace(new RegExp("[\\n]+","g"),""),e={type:i[1],headers:[],rawData:Ko.ep.FromBase64(t)},n=i[2];if(n){const t=n.split(new RegExp(Zw,"g"));let r=null;for(const i of t){const[t,n]=i.split(/:(.*)/);if(void 0===n){if(!r)throw new Error("Cannot parse PEM string. Incorrect header value");r.value+=t.trim()}else r&&e.headers.push(r),r={key:t,value:n.trim()}}r&&e.headers.push(r)}r.push(e)}return r}static decode(t){return this.decodeWithHeaders(t).map((t=>t.rawData))}static decodeFirst(t){const e=this.decode(t);if(!e.length)throw new RangeError("PEM string doesn't contain any objects");return e[0]}static encode(t,e){if(Array.isArray(t)){const r=new Array;return e?t.forEach((t=>{if(!Ko.vJ.isBufferSource(t))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:e,rawData:Ko.vJ.toArrayBuffer(t)}))})):t.forEach((t=>{if(!("type"in t))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(t))})),r.join("\n")}if(!e)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:e,rawData:Ko.vJ.toArrayBuffer(t)})}static encodeStruct(t){var e;const r=t.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),null===(e=t.headers)||void 0===e?void 0:e.length){for(const e of t.headers)i.push(`${e.key}: ${e.value}`);i.push("")}const n=Ko.ep.ToBase64(t.rawData);let s,o=0;const a=Array();for(;o<n.length&&(n.length-o<64?s=n.substring(o):(s=n.substring(o,o+64),o+=64),0!==s.length)&&(a.push(s),!(s.length<64)););return i.push(...a),i.push(`-----END ${r}-----`),i.join("\n")}}ty.CertificateTag="CERTIFICATE",ty.CrlTag="CRL",ty.CertificateRequestTag="CERTIFICATE REQUEST",ty.PublicKeyTag="PUBLIC KEY",ty.PrivateKeyTag="PRIVATE KEY";class ey extends Iw{static isAsnEncoded(t){return Ko.vJ.isBufferSource(t)||"string"==typeof t}static toArrayBuffer(t){if("string"==typeof t){if(ty.isPem(t))return ty.decode(t)[0];if(Ko.ep.isHex(t))return Ko.ep.FromHex(t);if(Ko.ep.isBase64(t))return Ko.ep.FromBase64(t);if(Ko.ep.isBase64Url(t))return Ko.ep.FromBase64Url(t);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}{const e=Ko.ep.ToBinary(t);return ty.isPem(e)?ty.decode(e)[0]:Ko.ep.isHex(e)?Ko.ep.FromHex(e):Ko.ep.isBase64(e)?Ko.ep.FromBase64(e):Ko.ep.isBase64Url(e)?Ko.ep.FromBase64Url(e):Ko.vJ.toArrayBuffer(t)}}constructor(...t){ey.isAsnEncoded(t[0])?super(ey.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(t="pem"){return"pem"===t?ty.encode(this.rawData,this.tag):super.toString(t)}}class ry extends ey{constructor(t){ey.isAsnEncoded(t)?super(t,kh):super(t),this.tag=ty.PublicKeyTag}async export(...t){let e,r=["verify"],i={hash:"SHA-256",...this.algorithm};return t.length>1?(i=t[0]||i,r=t[1]||r,e=t[2]||Nw.get()):e=t[0]||Nw.get(),e.subtle.importKey("spki",this.rawData,i,!0,r)}onInit(t){const e=Uf.resolve(jg),r=this.algorithm=e.toWebAlgorithm(t.algorithm);switch(t.algorithm.algorithm){case Bd:{const e=Kl.parse(t.subjectPublicKey,uf),i=Ko.vJ.toUint8Array(e.modulus);r.publicExponent=Ko.vJ.toUint8Array(e.publicExponent),r.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...t){var e;let r,i="SHA-1";return t.length>=1&&!(null===(e=t[0])||void 0===e?void 0:e.subtle)?(i=t[0]||i,r=t[1]||Nw.get()):r=t[0]||Nw.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(t){t||(t=Nw.get());const e=Kl.parse(this.rawData,kh);return await t.subtle.digest("SHA-1",e.subjectPublicKey)}toTextObject(){const t=this.toTextObjectEmpty(),e=Kl.parse(this.rawData,kh);if(t.Algorithm=Sw.serializeAlgorithm(e.algorithm),e.algorithm.algorithm===gd)t["EC Point"]=e.subjectPublicKey;else t["Raw Data"]=e.subjectPublicKey;return t}}class iy{static register(t,e){this.items.set(t,e)}static create(t){const e=new Cw(t),r=this.items.get(e.type);return r?new r(t):e}}iy.items=new Map;const ny="crypto.signatureFormatter";class sy extends ey{constructor(t){ey.isAsnEncoded(t)?super(t,Wh):super(t),this.tag=ty.CertificateTag}onInit(t){const e=t.tbsCertificate;this.tbs=Kl.serialize(e),this.serialNumber=Ko.ep.ToHex(e.serialNumber),this.subjectName=new Lw(e.subject),this.subject=new Lw(e.subject).toString(),this.issuerName=new Lw(e.issuer),this.issuer=this.issuerName.toString();const r=Uf.resolve(jg);this.signatureAlgorithm=r.toWebAlgorithm(t.signatureAlgorithm),this.signature=t.signatureValue;const i=e.validity.notBefore.utcTime||e.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const n=e.validity.notAfter.utcTime||e.validity.notAfter.generalTime;if(!n)throw new Error("Cannot get 'notAfter' value");this.notAfter=n,this.extensions=[],e.extensions&&(this.extensions=e.extensions.map((t=>iy.create(Kl.serialize(t))))),this.publicKey=new ry(e.subjectPublicKeyInfo)}getExtension(t){for(const e of this.extensions)if("string"==typeof t){if(e.type===t)return e}else if(e instanceof t)return e;return null}getExtensions(t){return this.extensions.filter((e=>"string"==typeof t?e.type===t:e instanceof t))}async verify(t={},e=Nw.get()){let r,i;const n=t.publicKey;try{if(n)if("publicKey"in n)r={...n.publicKey.algorithm,...this.signatureAlgorithm},i=await n.publicKey.export(r,["verify"]);else if(n instanceof ry)r={...n.algorithm,...this.signatureAlgorithm},i=await n.export(r,["verify"]);else if(Ko.vJ.isBufferSource(n)){const t=new ry(n);r={...t.algorithm,...this.signatureAlgorithm},i=await t.export(r,["verify"])}else r={...n.algorithm,...this.signatureAlgorithm},i=n;else r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],e)}catch(t){return!1}const s=Uf.resolveAll(ny).reverse();let o=null;for(const t of s)if(o=t.toWebSignature(r,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const a=await e.subtle.verify(this.signatureAlgorithm,i,o,this.tbs);if(t.signatureOnly)return a;{const e=(t.date||new Date).getTime();return a&&this.notBefore.getTime()<e&&e<this.notAfter.getTime()}}async getThumbprint(...t){let e,r="SHA-1";return t[0]&&(t[0].subtle?e=t[0]:(r=t[0]||r,e=t[1])),null!=e||(e=Nw.get()),await e.subtle.digest(r,this.rawData)}async isSelfSigned(t=Nw.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},t)}toTextObject(){const t=this.toTextObjectEmpty(),e=Kl.parse(this.rawData,Wh),r=e.tbsCertificate,i=new vw("",{Version:`${Mh[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Sw.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new vw("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const t=new vw("");for(const e of this.extensions){const r=e.toTextObject();t[r[vw.NAME]]=r}i.Extensions=t}return t.Data=i,t.Signature=new vw("",{Algorithm:Sw.serializeAlgorithm(e.signatureAlgorithm),"":e.signatureValue}),t}}sy.NAME="Certificate";class oy extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0]))super(t[0]);else if("string"==typeof t[0]){const e=new mu({keyIdentifier:new yu(Ko.ep.FromHex(t[0]))});super(wu,t[1],Kl.serialize(e))}else{const e=t[0],r=e.name instanceof Xw?Kl.parse(e.name.rawData,_u):e.name,i=new mu({authorityCertIssuer:r,authorityCertSerialNumber:Ko.ep.FromHex(e.serialNumber)});super(wu,t[1],Kl.serialize(i))}}static async create(t,e=!1,r=Nw.get()){if(t instanceof sy||xw.isCryptoKey(t)){const i=t instanceof sy?await t.publicKey.export(r):t,n=await r.subtle.exportKey("spki",i),s=new ry(n),o=await s.getKeyIdentifier(r);return new oy(Ko.ep.ToHex(o),e)}return new oy(t,e)}onInit(t){super.onInit(t);const e=Kl.parse(t.extnValue,mu);e.keyIdentifier&&(this.keyId=Ko.ep.ToHex(e.keyIdentifier)),e.authorityCertIssuer&&e.authorityCertSerialNumber&&(this.certId={name:e.authorityCertIssuer,serialNumber:Ko.ep.ToHex(e.authorityCertSerialNumber)})}toTextObject(){const t=this.toTextObjectWithoutValue(),e=Kl.parse(this.value,mu);return e.authorityCertIssuer&&(t["Authority Issuer"]=new Xw(e.authorityCertIssuer).toTextObject()),e.authorityCertSerialNumber&&(t["Authority Serial Number"]=e.authorityCertSerialNumber),e.keyIdentifier&&(t[""]=e.keyIdentifier),t}}oy.NAME="Authority Key Identifier";class ay extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Au);this.ca=e.cA,this.pathLength=e.pathLenConstraint}else{const e=new Au({cA:t[0],pathLenConstraint:t[1]});super(bu,t[2],Kl.serialize(e)),this.ca=t[0],this.pathLength=t[1]}}toTextObject(){const t=this.toTextObjectWithoutValue();return this.ca&&(t.CA=this.ca),void 0!==this.pathLength&&(t["Path Length"]=this.pathLength),t}}var cy,ly;ay.NAME="Basic Constraints",function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"}(cy||(cy={}));class uy extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Yu);this.usages=e.map((t=>t))}else{const e=new Yu(t[0]);super(Ku,t[1],Kl.serialize(e)),this.usages=t[0]}}toTextObject(){const t=this.toTextObjectWithoutValue();return t[""]=this.usages.map((t=>Tw.toString(t))).join(", "),t}}uy.NAME="Extended Key Usages",function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"}(ly||(ly={}));class hy extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,lh);this.usages=e.toNumber()}else{const e=new lh(t[0]);super(oh,t[1],Kl.serialize(e)),this.usages=t[0]}}toTextObject(){const t=this.toTextObjectWithoutValue(),e=Kl.parse(this.value,lh);return t[""]=e.toJSON().join(", "),t}}hy.NAME="Key Usages";class py extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Th);this.keyId=Ko.ep.ToHex(e)}else{const e="string"==typeof t[0]?Ko.ep.FromHex(t[0]):t[0],r=new Th(e);super(vh,t[1],Kl.serialize(r)),this.keyId=Ko.ep.ToHex(e)}}static async create(t,e=!1,r=Nw.get()){let i;i=t instanceof ry?t.rawData:"publicKey"in t?t.publicKey.rawData:Ko.vJ.isBufferSource(t)?t:await r.subtle.exportKey("spki",t);const n=new ry(i),s=await n.getKeyIdentifier(r);return new py(Ko.ep.ToHex(s),e)}toTextObject(){const t=this.toTextObjectWithoutValue(),e=Kl.parse(this.value,Th);return t[""]=e,t}}py.NAME="Subject Key Identifier";class dy extends Cw{constructor(...t){Ko.vJ.isBufferSource(t[0])?super(t[0]):super(mh,t[1],new Xw(t[0]||[]).rawData)}onInit(t){super.onInit(t);const e=Kl.parse(t.extnValue,bh);this.names=new Xw(e)}toTextObject(){const t=this.toTextObjectWithoutValue(),e=this.names.toTextObject();for(const r in e)t[r]=e[r];return t}}dy.NAME="Subject Alternative Name";class fy extends Cw{constructor(...t){var e;if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Bu);this.policies=e.map((t=>t.policyIdentifier))}else{const r=t[0],i=null!==(e=t[1])&&void 0!==e&&e,n=new Bu(r.map((t=>new ku({policyIdentifier:t}))));super(Iu,i,Kl.serialize(n)),this.policies=r}}toTextObject(){const t=this.toTextObjectWithoutValue();return t.Policy=this.policies.map((t=>new vw("",{},Tw.toString(t)))),t}}fy.NAME="Certificate Policies",iy.register(Iu,fy);class gy extends Iw{constructor(...t){let e;if(Ko.vJ.isBufferSource(t[0]))e=Ko.vJ.toArrayBuffer(t[0]);else{const r=t[0],i=Array.isArray(t[1])?t[1].map((t=>Ko.vJ.toArrayBuffer(t))):[];e=Kl.serialize(new Ah({type:r,values:i}))}super(e,Ah)}onInit(t){this.type=t.type,this.values=t.values}toTextObject(){const t=this.toTextObjectWithoutValue();return t.Value=this.values.map((t=>new vw("",{"":t}))),t}toTextObjectWithoutValue(){const t=this.toTextObjectEmpty();return t[vw.NAME]===gy.NAME&&(t[vw.NAME]=Tw.toString(this.type)),t}}gy.NAME="Attribute";class wy extends gy{constructor(...t){var e;if(Ko.vJ.isBufferSource(t[0]))super(t[0]);else{const e=new Og({printableString:t[0]});super(pg,[Kl.serialize(e)])}null!==(e=this.password)&&void 0!==e||(this.password="")}onInit(t){if(super.onInit(t),this.values[0]){const t=Kl.parse(this.values[0],Og);this.password=t.toString()}}toTextObject(){const t=this.toTextObjectWithoutValue();return t[vw.VALUE]=this.password,t}}wy.NAME="Challenge Password";class yy extends gy{constructor(...t){var e;if(Ko.vJ.isBufferSource(t[0]))super(t[0]);else{const e=t[0],r=new Uh;for(const t of e)r.push(Kl.parse(t.rawData,Ph));super(dg,[Kl.serialize(r)])}null!==(e=this.items)&&void 0!==e||(this.items=[])}onInit(t){if(super.onInit(t),this.values[0]){const t=Kl.parse(this.values[0],Uh);this.items=t.map((t=>iy.create(Kl.serialize(t))))}}toTextObject(){const t=this.toTextObjectWithoutValue(),e=this.items.map((t=>t.toTextObject()));for(const r of e)t[r[vw.NAME]]=r;return t}}yy.NAME="Extensions";class my{static register(t,e){this.items.set(t,e)}static create(t){const e=new gy(t),r=this.items.get(e.type);return r?new r(t):e}}my.items=new Map;let by=class{toAsnAlgorithm(t){if("rsassa-pkcs1-v1_5"===t.name.toLowerCase()){if(!t.hash)return new Oh({algorithm:Bd,parameters:null});switch(t.hash.name.toLowerCase()){case"sha-1":return new Oh({algorithm:Fd,parameters:null});case"sha-256":return new Oh({algorithm:Wd,parameters:null});case"sha-384":return new Oh({algorithm:jd,parameters:null});case"sha-512":return new Oh({algorithm:zd,parameters:null})}}return null}toWebAlgorithm(t){switch(t.algorithm){case Bd:return{name:"RSASSA-PKCS1-v1_5"};case Fd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Wd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case jd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case zd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}}}return null}};by=hf([Ff()],by),Uf.registerSingleton(Wg,by);class Ay{addPadding(t,e){const r=Ko.vJ.toUint8Array(e),i=new Uint8Array(t);return i.set(r,t-r.length),i}removePadding(t,e=!1){let r=Ko.vJ.toUint8Array(t);for(let t=0;t<r.length;t++)if(r[t]){r=r.slice(t);break}if(e&&r[0]>127){const t=new Uint8Array(r.length+1);return t.set(r,1),t.buffer}return r.buffer}toAsnSignature(t,e){if("ECDSA"===t.name){const r=t.namedCurve,i=Ay.namedCurveSize.get(r)||Ay.defaultNamedCurveSize,n=new Od,s=Ko.vJ.toUint8Array(e);return n.r=this.removePadding(s.slice(0,i),!0),n.s=this.removePadding(s.slice(i,i+i),!0),Kl.serialize(n)}return null}toWebSignature(t,e){if("ECDSA"===t.name){const r=Kl.parse(e,Od),i=t.namedCurve,n=Ay.namedCurveSize.get(i)||Ay.defaultNamedCurveSize,s=this.addPadding(n,this.removePadding(r.r)),o=this.addPadding(n,this.removePadding(r.s));return(0,Ko.$e)(s,o)}return null}}Ay.namedCurveSize=new Map,Ay.defaultNamedCurveSize=32;const Ey="1.3.101.110",_y="1.3.101.111",vy="1.3.101.112",Ty="1.3.101.113";let Sy=class{toAsnAlgorithm(t){let e=null;switch(t.name.toLowerCase()){case"eddsa":switch(t.namedCurve.toLowerCase()){case"ed25519":e=vy;break;case"ed448":e=Ty}break;case"ecdh-es":switch(t.namedCurve.toLowerCase()){case"x25519":e=Ey;break;case"x448":e=_y}}return e?new Oh({algorithm:e}):null}toWebAlgorithm(t){switch(t.algorithm){case vy:return{name:"EdDSA",namedCurve:"Ed25519"};case Ty:return{name:"EdDSA",namedCurve:"Ed448"};case Ey:return{name:"ECDH-ES",namedCurve:"X25519"};case _y:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Sy=hf([Ff()],Sy),Uf.registerSingleton(Wg,Sy);class Iy extends ey{constructor(t){ey.isAsnEncoded(t)?super(t,Hg):super(t),this.tag=ty.CertificateRequestTag}onInit(t){this.tbs=Kl.serialize(t.certificationRequestInfo),this.publicKey=new ry(t.certificationRequestInfo.subjectPKInfo);const e=Uf.resolve(jg);this.signatureAlgorithm=e.toWebAlgorithm(t.signatureAlgorithm),this.signature=t.signature,this.attributes=t.certificationRequestInfo.attributes.map((t=>my.create(Kl.serialize(t))));const r=this.getAttribute(dg);this.extensions=[],r instanceof yy&&(this.extensions=r.items),this.subjectName=new Lw(t.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(t){for(const e of this.attributes)if(e.type===t)return e;return null}getAttributes(t){return this.attributes.filter((e=>e.type===t))}getExtension(t){for(const e of this.extensions)if(e.type===t)return e;return null}getExtensions(t){return this.extensions.filter((e=>e.type===t))}async verify(t=Nw.get()){const e={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(e,["verify"],t),i=Uf.resolveAll(ny).reverse();let n=null;for(const t of i)if(n=t.toWebSignature(e,this.signature),n)break;if(!n)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await t.subtle.verify(this.signatureAlgorithm,r,n,this.tbs)}toTextObject(){const t=this.toTextObjectEmpty(),e=Kl.parse(this.rawData,Hg),r=e.certificationRequestInfo,i=new vw("",{Version:`${Mh[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const t=new vw("");for(const e of this.attributes){const r=e.toTextObject();t[r[vw.NAME]]=r}i.Attributes=t}return t.Data=i,t.Signature=new vw("",{Algorithm:Sw.serializeAlgorithm(e.signatureAlgorithm),"":e.signature}),t}}Iy.NAME="PKCS#10 Certificate Request";var Cy;!function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"}(Cy||(Cy={}));iy.register(bu,ay),iy.register(Ku,uy),iy.register(oh,hy),iy.register(vh,py),iy.register(wu,oy),iy.register(mh,dy),my.register(pg,wy),my.register(dg,yy),Uf.registerSingleton(ny,class{toAsnSignature(t,e){return Ko.vJ.toArrayBuffer(e)}toWebSignature(t,e){return Ko.vJ.toArrayBuffer(e)}}),Uf.registerSingleton(ny,Ay),Ay.namedCurveSize.set("P-256",32),Ay.namedCurveSize.set("K-256",32),Ay.namedCurveSize.set("P-384",48),Ay.namedCurveSize.set("P-521",66);const Ry=/-{5}(BEGIN|END) .*-{5}/gm;async function xy({hash:t,signature:e,publicKey:r,domain:i,domainCert:n,created:s,software:o}={}){let a;const c=[];if(e=(0,Vo.toByteArray)(e),n&&i&&!r){const t=n.split("\n\n"),i=(0,Vo.toByteArray)(t[0].replace(Ry,"").replace(/\s/gm,"")),s=f(await crypto.subtle.digest("SHA-256",i));c.push({id:"certFingerprint",expected:s,matched:null});const o=new sy(i);r=await o.publicKey.export();const l=(0,Vo.fromByteArray)(new Uint8Array(o.publicKey.rawData));c.push({id:"publicKey",expected:l,matched:null}),o.subject&&o.subject.startsWith("CN=")&&(a=o.subject.split(3)),e=function(t){try{const e=ql.parse(t,Od),r=0===e.r[0]?e.r.slice(1):e.r,i=0===e.s[0]?e.s.slice(1):e.s;t=z([r,i],r.length+i.length)}catch(t){console.log(t)}return t}(e)}else{const t={name:"ECDSA",namedCurve:"P-384"};c.push({id:"publicKey",expected:r,matched:null}),r=await crypto.subtle.importKey("spki",(0,Vo.toByteArray)(r),t,!0,["verify"])}const l=new TextEncoder,u=await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},r,e,l.encode(t));return c.push({id:"signature",expected:!0,matched:u}),s&&c.push({id:"created",expected:s,matched:null}),o&&c.push({id:"software",expected:o,matched:null}),i&&c.push({id:"domain",expected:i,matched:a}),c}const Ny="pages/pages.jsonl",Oy="pages/extraPages.jsonl",ky="datapackage.json",By="datapackage-digest.json",Dy="webarchive.yaml";class Ly{constructor(t,e,r=!0){this.file=e,this.waczname=e.waczname,this.store=t,this.isRoot=r}async loadFileFromWACZ(t,e){return this.store.loadFileFromWACZ?await this.store.loadFileFromWACZ(this.file,t,e):await this.file.loadFile(t,e)}async load(){let t,e=null;return this.file.containsFile(By)&&(e=await this.loadDigestData(By)),this.file.containsFile(ky)?t=await this.loadPackage(ky,e):this.file.containsFile(Dy)&&(t=await this.loadOldPackageYAML(Dy)),t||{}}async loadTextFileFromWACZ(t,e=!1){const{reader:r,hasher:i}=await this.loadFileFromWACZ(t,{computeHash:!!e}),n=(new TextDecoder).decode(await r.readFully());return e&&i&&await this.store.addVerifyData(this.waczname,t,e,i.getHash()),n}async loadDigestData(t){try{const e=JSON.parse(await this.loadTextFileFromWACZ(t));let r;e.path===ky&&e.hash&&(r=e.hash);const i=this.store,n=this.isRoot?"":this.waczname+":";if(!e.signedData||e.signedData.hash!==r)return void await i.addVerifyData(n,"signature");await i.addVerifyData(n,"datapackageHash",r);const s=await xy(e.signedData);return await i.addVerifyDataList(n,s),r}catch(t){console.warn(t)}}async loadPackage(t,e){const r=await this.loadTextFileFromWACZ(t,e),i=JSON.parse(r);switch(this.isRoot&&void 0!==i.config&&this.store.initConfig(i.config),i.profile){case"data-package":case"wacz-package":case void 0:case null:return await this.loadLeafWACZPackage(i);case"multi-wacz-package":return await this.loadMultiWACZPackage(i);default:throw new Error(`Unknown package profile: ${i.profile}`)}}async loadMultiWACZPackage(t){return this.file.markAsMultiWACZ(),await this.store.loadWACZFiles(t,this.file),t}async loadLeafWACZPackage(t){const e=t.metadata||{};let r=null;for(const e of t.resources)e.path===Ny?(r=e.hash,await this.store.addVerifyData(this.waczname,e.path,e.hash)):(e.path.endsWith(".idx")||e.path.endsWith(".cdx"))&&await this.store.addVerifyData(this.waczname,e.path,e.hash);if(this.file.containsFile(Ny)){(await this.loadPages(Ny,r)).hasText&&(this.store.textIndex=e.textIndex=Ny)}return this.file.containsFile(Oy)&&(this.store.textIndex=e.textIndex=Oy),e}async loadOldPackageYAML(t){const e=await this.loadTextFileFromWACZ(t),r=Qo.load(e),i={desc:r.desc,title:r.title};r.textIndex&&(i.textIndex=r.textIndex,r.config||(r.config={}),r.config.textIndex=r.textIndex),this.isRoot&&void 0!==r.config&&this.store.initConfig(r.config),i.title||(i.title=this.store.config.sourceName);const n=r.pages||[];n&&n.length&&await this.store.addPages(n);const s=r.pageLists||[];return s&&s.length&&await this.store.addCuratedPageLists(s,"pages","show"),i}async loadPages(t=Ny,e=null){const{reader:r,hasher:i}=await this.loadFileFromWACZ(t,{unzip:!0,computeHash:!0});let n=null,s=[];for await(const t of r.iterLines()){const e=JSON.parse(t);this.waczname&&(e.wacz=this.waczname),n?(s.push(e),500===s.length&&(await this.store.addPages(s),s=[])):n=e}return s.length&&await this.store.addPages(s),i&&e&&await this.store.addVerifyData(this.waczname,t,e,i.getHash()),n}}class Py{constructor(t,e,r=null){this.loader=t,this.loadId=r,this.loadUrl=e.loadUrl}async load(t){t.fullConfig&&this.loader.arrayBuffer&&this.loader.arrayBuffer.byteLength<=a&&(t.fullConfig.extra||(t.fullConfig.extra={}),t.fullConfig.extra.arrayBuffer=this.loader.arrayBuffer);const e=this.loadUrl,r=this.loader;return await t.addNewWACZ({name:"default",path:e,loader:r})}}class Uy{constructor(t,e,r=null){this.config=e,this.loadId=r,this.loader=t}async load(t,e=null,r=0){const i=new jn({loader:this.loader});await i.init();const n=i.zipreader,s=new Ly(t,i),o=await s.load();let a=0;const c=(t,i,n)=>{n+=a,e&&r&&e(Math.round(100*n/r),null,n,r)};for(const e of i.iterContainedFiles()){const r=n.getCompressedSize(e);(e.endsWith(".warc.gz")||e.endsWith(".warc"))&&await this.loadWARC(t,n,e,c,r),a+=r}return o||{}}async loadWARC(t,e,r,i,n){const{reader:s}=await e.loadFile(r,{unzip:!0}),o=new si(s,null,r);return o.detectPages=!1,await o.load(t,i,n)}}class My{constructor(t){this.response=t}async load(t){return await t.loadFromJSON(this.response)}}class Fy{constructor(t,{cloneResponse:e=!1,allowBody:r=!1,hostProxyOnly:i=!1}={}){if(t=t||{},this.prefix=t.prefix||"",this.proxyPathOnly=t.proxyPathOnly||!1,this.isLive=void 0===t.isLive||t.isLive,this.archivePrefix=t.archivePrefix||"",this.cloneResponse=e,this.allowBody=r,this.hostProxy=t.hostProxy,this.hostProxy instanceof Array){const t={};for(const e of this.hostProxy)t[e.host]=e;this.hostProxy=t}this.hostProxyOnly=i}async getAllPages(){return[]}getFetchUrl(t,e,r){let i;if(this.hostProxy){i=new URL(t);const e=this.hostProxy[i.host];if(e)return r.set("X-Proxy-Host",i.host),e.prefix+(e.pathOnly?i.pathname+i.search:t)}return this.hostProxyOnly?null:this.proxyPathOnly?(i||(i=new URL(t)),this.prefix+i.pathname+i.search):this.isLive||!e.timestamp?this.prefix+t:this.prefix+this.archivePrefix+e.timestamp+"id_/"+t}async getResource(t,e){const{headers:r,credentials:i,url:n}=t.prepareProxyRequest(e,!0),s=this.getFetchUrl(n,t,r);if(!s)return null;let o=null;!this.allowBody||"POST"!==t.method&&"PUT"!==t.method||(o=await t.getBody());const a=await fetch(s,{method:t.method,body:o,headers:r,credentials:i,mode:"cors",redirect:"follow"});let c=null;this.cloneResponse&&(c=a.clone());const l=mt.fromResponse({url:n,response:a,date:new Date,noRW:!1,isLive:this.isLive});return c&&(l.clonedResponse=c),l}}const Hy=/^([\w-]+,)*[\w-]+(:\d+)?,?\)\//;class Wy extends rn{constructor(t,e,r="wacz"){super(t.dbname,t.noCache),this.config=t,this.waczfiles={},this.waczNameForHash={},this.ziploadercache={},this.updating=null,this.rootSourceType=r,this.sourceLoader=e,this.externalSource=null,this.fuzzyUrlRules=[],this.textIndex=t&&t.metadata&&t.metadata.textIndex,t.extraConfig&&this.initConfig(t.extraConfig)}initConfig(t){if(void 0!==t.decodeResponses&&(this.config.decode=t.decodeResponses),t.hostProxy&&(this.externalSource=new Fy(t,{hostProxyOnly:!0})),t.fuzzy)for(const[e,r]of t.fuzzy){const t=new RegExp(e);this.fuzzyUrlRules.push({match:t,replace:r})}t.textIndex&&(this.textIndex=t.textIndex)}updateHeaders(t){this.sourceLoader&&(this.sourceLoader.headers=t)}_initDB(t,e,r,i){super._initDB(t,e,r,i),e||(t.createObjectStore("ziplines",{keyPath:["waczname","prefix"]}),t.createObjectStore("waczfiles",{keyPath:"waczname"}),t.createObjectStore("verification",{keyPath:"id"})),2===e&&this.convertV2WACZDB(t,i),3===e&&t.createObjectStore("verification",{keyPath:"id"})}async convertV2WACZDB(t,e){try{const r=await e.objectStore("ziplines").getAll(),i=await e.objectStore("zipEntries").getAll();t.deleteObjectStore("ziplines"),t.deleteObjectStore("zipEntries"),t.createObjectStore("ziplines",{keyPath:["waczname","prefix"]}),t.createObjectStore("waczfiles",{keyPath:"waczname"}),t.createObjectStore("verification",{keyPath:"id"});const n=this.config.loadUrl;for(const t of r)t.waczname=n,e.objectStore("ziplines").put(t);const s=r.length>0?2:1,o=await this.computeHash(n),a=new jn({waczname:n,hash:o,url:n,entries:i,indexType:s});e.objectStore("waczfiles").put(a.serialize()),await e.done}catch(t){console.warn(t)}}addWACZFile(t){return this.waczfiles[t.waczname]=new jn(t),this.waczNameForHash[t.hash]=t.waczname,this.waczfiles[t.waczname]}async init(){await super.init();const t=await this.db.getAll("waczfiles")||[];for(const e of t)this.addWACZFile({...e,parent:this});for(const[t,e]of Object.entries(this.waczfiles)){e.path=e.path||t;const r=e.path.lastIndexOf("#!/");if(r>0){const t=e.path.slice(0,r),i=this.waczfiles[t];e.parent=i}else"json"!==this.rootSourceType&&(e.loader=this.sourceLoader)}await this.checkUpdates()}async close(){super.close(),caches.delete("cache:"+this.name.slice("db:".length))}async clearZipData(){const t=["waczfiles","ziplines"];for(const e of t)await this.db.clear(e)}async addVerifyData(t="",e,r,i,n=!1){let s=null;t&&(e=t+e),i&&(s=r===i,n&&console.log(`verify ${e}: ${s}`)),await this.db.put("verification",{id:e,expected:r,matched:s})}async addVerifyDataList(t,e){const r=this.db.transaction("verification","readwrite");for(const i of e)t&&(i.id=t+i.id),r.store.put(i);try{await r.done}catch(t){console.warn(t)}}async getVerifyInfo(){const t=await this.db.getAll("verification");let e=0,r=0,i={};const n=["domain","created","certFingerprint","software","datapackageHash","publicKey"];for(const s of t)n.includes(s.id)?i[s.id]=s.expected:"signature"===s.id||!0===s.matched?e++:!1===s.matched&&r++;return i.numInvalid=r,i.numValid=e,i}async getVerifyExpected(t){const e=await this.db.get("verification",t);return e&&e.expected}async clearAll(){await super.clearAll(),await this.clearZipData()}async loadRecordFromSource(t){const{start:e,length:r,path:i,wacz:n}=t.source,s={offset:e,length:r,unzip:!0,computeHash:!0},o=n,{reader:a,hasher:c}=await this.loadFileFromNamedWACZ(o,"archive/"+i,s),l=new oi(a,c);await this.waczfiles[o].save(this.db);const u=await l.load();return t[un]&&(u.respHeaders["x-wabac-preset-cookie"]=t[un]),{remote:u,hasher:c}}async loadIndex(t){if(!this.waczfiles[t])throw new Error("unknown waczfile: "+t);if(this.waczfiles[t].indexType)return{indexType:this.waczfiles[t].indexType,isNew:!1};let e=0;for(const r of this.waczfiles[t].iterContainedFiles())r.endsWith(".cdx")||r.endsWith(".cdxj")?(console.log(`Loading CDX for ${t}`),await this.loadCDX(r,t),e=1):r.endsWith(".idx")&&(console.log(`Loading IDX for ${t}`),await this.loadIDX(r,t),e=2);return this.waczfiles[t].indexType=e,await this.waczfiles[t].save(this.db,!0),{indexType:e,isNew:!0}}async loadCDX(t,e,r,i){const{reader:n,hasher:s}=await this.loadFileFromNamedWACZ(e,t,{computeHash:!0}),o=new pn(n,null,e,{wacz:e}),a=await o.load(this,r,i);if(s){const r=await this.getVerifyExpected(t);r&&this.addVerifyData(e,t,r,s.getHash())}return a}async loadIDX(t,e,r,i){const{reader:n,hasher:s}=await this.loadFileFromNamedWACZ(e,t,{computeHash:!0});let o=[],a="",c=!0,l=0;for await(const t of n.iterLines()){if(l+=t.length,l===t.length&&t.startsWith("!meta")){const e=t.indexOf(" {");if(e<0){console.warn("Invalid Meta Line: "+t);continue}const r=JSON.parse(t.slice(e));r.filename&&(a=r.filename),"cdxj-gzip-1.0"!==r.format&&console.log(`Unknown CDXJ format "${r.format}", archive may not parse correctly`);continue}let n;if(t.indexOf("\t")>0){let[r,i,s,o]=t.split("\t");s=Number(s),o=Number(o),n={waczname:e,prefix:r,filename:i,offset:s,length:o,loaded:!1},c=!1}else{const r=t.indexOf(" {");if(r<0){console.log("Invalid Index Line: "+t);continue}const i=t.slice(0,r);let{offset:s,length:o,filename:l,digest:u}=JSON.parse(t.slice(r));c=c&&!Hy.test(i),l=l||a,n={waczname:e,prefix:i,filename:l,offset:s,length:o,digest:u,loaded:!1}}r&&r(l/i,l,i),o.push(n)}if(s){const r=await this.getVerifyExpected(t);r&&this.addVerifyData(e,t,r,s.getHash())}const u=this.db.transaction("ziplines","readwrite");for(const t of o)u.store.put(t);try{await u.done}catch(t){console.log("Error loading ziplines index: ",t)}c&&c!==this.waczfiles[e].nonSurt&&(this.waczfiles[e].nonSurt=c,await this.waczfiles[e].save(this.db,!0))}async loadCDXFromIDX(t,e,r=0,i=!1){const n=this.waczfiles[t].nonSurt?e:M(e),s=i?this.prefixUpperBound(n):n+" 9999",o=IDBKeyRange.upperBound([t,s],!0),a=this.db.transaction("ziplines","readonly"),c=[];for await(const e of a.store.iterate(o,"prev")){if(e.value.waczname!==t)break;if(c.unshift(e.value),!e.value.prefix.split(" ")[0].startsWith(n))break}await a.done;const l=[];c.length>3&&r&&c.sort(((t,e)=>{const i=t.prefix.split(" ")[1],n=e.prefix.split(" ")[1];if(!i||!n)return 0;const s=Math.abs(d(i).getTime()-r),o=Math.abs(d(n).getTime()-r);return s===o?0:s<o?-1:1}));let u=0;for(const e of c){if(e.loaded)continue;const r=t+":"+e.filename+":"+e.offset;let i=this.ziploadercache[r];if(i||(i=this.doCDXLoad(r,e,t),this.ziploadercache[r]=i),l.push(i),++u>3)break}return l.length&&await Promise.allSettled(l),await this.waczfiles[t].save(this.db),l.length>0}async doCDXLoad(t,e,r){try{const i="indexes/"+e.filename,n={offset:e.offset,length:e.length,unzip:!0,computeHash:!!e.digest},{reader:s,hasher:o}=await this.loadFileFromNamedWACZ(r,i,n),a=new pn(s,null,null,{wacz:r});if(await a.load(this),o){const t=o.getHash(),n=`${i}:${e.offset}-${e.length}`;await this.addVerifyData(r,n,e.digest,t)}e.loaded=!0,await this.db.put("ziplines",e)}catch(t){await T(t,this.config)||console.warn(t)}finally{delete this.ziploadercache[t]}}async findPageAtUrl(t,e){const r=await this.db.getAllFromIndex("pages","url",t);let i=null,n=Number.MAX_SAFE_INTEGER;for(const t of r){const r=Math.abs(t.ts-e);if(r<1e3)return t;r<n&&(i=t,n=r)}return i}async lookupUrl(t,e,r={}){try{let i=await super.lookupUrl(t,e,r);if(i&&(!r.noRevisits||"warc/revisit"!==i.mime))return i;const{waczname:n}=r;return n&&"local"!==n&&(i=await this.lookupUrlForWACZ(n,t,e,r)),i}catch(t){return console.warn(t),null}}async lookupUrlForWACZ(t,e,r,i){const{indexType:n,isNew:s}=await this.loadIndex(t);switch(n){case 2:if(!await this.loadCDXFromIDX(t,e,r,!1))return null;break;case 1:if(!s)return null;break;default:return null}return await super.lookupUrl(e,r,i)}async resourcesByUrlAndMime(t,...e){let r=await super.resourcesByUrlAndMime(t,...e);if(r.length>0)return r;for(const i of Object.keys(this.waczfiles))if(i&&"local"!==i){const{indexType:n,isNew:s}=await this.loadIndex(i);switch(n){case 2:if(!await this.loadCDXFromIDX(i,t,0,!0))continue;break;case 1:if(!s)continue;break;default:continue}const o=await super.resourcesByUrlAndMime(t,...e);o&&o.length&&(r=r.concat(o))}return r}async loadFileFromWACZ(t,e,r){try{return await t.loadFile(e,r)}catch(i){if(await this.retryLoad(i))return await t.loadFile(e,r);throw i}}async loadFileFromNamedWACZ(t,e,r){const i=this.waczfiles[t];if(!i)throw new Error("No WACZ Found for: "+t);return await this.loadFileFromWACZ(i,e,r)}async addNewWACZ({name:t,hash:e,path:r,parent:i=null,loader:n=null}={}){const s=t||r;e?e.indexOf(":")>0&&(e=e.split(":")[1]):e=await g(s,"sha-256","");const o=this.addWACZFile({waczname:s,hash:e,path:r,parent:i,loader:n},!0);await o.init(),await o.save(this.db,!0);const a=new Ly(this,o,!i);return await a.load()}async loadWACZFiles(t,e=this){const r=[],i=async(t,e)=>{await this.waczfiles[t].init(e),await this.waczfiles[t].save(this.db,!0)},n=t.resources.map((t=>{const r=e.getLoadPath(t.path);return{name:e.getName(t.name),hash:t.hash,path:r}}));for(const{name:t,hash:s,path:o}of n)this.waczfiles[t]?this.waczfiles[t].path!==o&&r.push(i(t,o)):r.push(this.addNewWACZ({name:t,hash:s,path:o,parent:e}));r.length&&await Promise.allSettled(r)}async getTextIndex(){const t={"Content-Type":"application/ndjson"},e=Object.keys(this.waczfiles);if(!this.textIndex||!e.length)return new Response("",{headers:t});const r=e[0];let i;try{i=await this.loadFileFromNamedWACZ(r,this.textIndex,{unzip:!0})}catch(e){return new Response("",{headers:t})}const{reader:n}=i,s=this.waczfiles[r].getSizeOf(this.textIndex);return s>0&&(t["Content-Length"]=""+s),new Response(n.getReadableStream(),{headers:t})}async getResource(t,e,r,{pageId:i}={}){if(await this.initing,this.externalSource){const i=await this.externalSource.getResource(t,e,r);if(i)return i}const n="navigate"===r.request.mode;let s=i,o=null,a=null;if(s){if(o=this.waczNameForHash[s],!o)return null;a=await super.getResource(t,e,r,{waczname:o})}if(a||!n)return a;for(const[i,n]of Object.entries(this.waczfiles))if(n.fileType===Wn&&(a=await super.getResource(t,e,r,{waczname:i,noFuzzyCheck:!0}),a)){o=i,s=n.hash;break}if(o)return Response.redirect(`${e}:${s}/${t.timestamp}mp_/${t.url}`);if(this.fuzzyUrlRules.length)for(const{match:i,replace:n}of this.fuzzyUrlRules){const s=decodeURIComponent(t.url.replace(i,n));if(s&&s!==t.url){t.url=s;const i=await super.getResource(t,e,r);if(i)return i}}return null}async retryLoad(t){return"json"===this.rootSourceType&&(t instanceof x?(this.updating||(this.updating=this.checkUpdates()),await this.updating,this.updating=null,!0):await T(t,this.config))}async checkUpdates(){"json"===this.rootSourceType&&await this.loadFromJSON()}async loadFromJSON(t=null){if(!t){t=(await this.sourceLoader.doInitialFetch(!1)).response}if(206!==t.status&&200!==t.status)return console.warn("WACZ update failed from: "+this.config.loadUrl),{};const e=await t.json();return e.profile,await this.loadWACZFiles(e),e}getLoadPath(t){return new URL(t,this.config.loadUrl).href}getName(t){return t}async createLoader(t){return await Vi(t)}}class jy{constructor(t){const e=t.extraConfig||{};this.sourceUrl=e.prefix,this.type=e.sourceType||"kiwix",this.notFoundPageUrl=e.notFoundPageUrl}async getAllPages(){return[]}async getResource(t,e){const{url:r,headers:i}=t.prepareProxyRequest(e);let n=i;if("kiwix"===this.type){let e=await this.resolveHeaders(r);if(!e)for(const t of Zr.getFuzzyCanonsWithArgs(r))if(t!==r&&(e=await this.resolveHeaders(t),e))break;if(!e){if(this.notFoundPageUrl&&"navigate"===t.mode){const t=await fetch(this.notFoundPageUrl);if(200===t.status){const e={"Content-Type":"text/html"},i=await t.text();return new Response(i.replace("$URL",r),{status:404,headers:e})}}return null}let{headers:i,encodedUrl:s,date:o,status:a,statusText:c,hasPayload:l}=e;if(n.has("Range")){const t=n.get("Range");n={Range:t}}let u=null,h=null;l&&(h=await fetch(this.sourceUrl+"A/"+s,{headers:n}),h.body&&(u=new K(h.body.getReader(),!1)),206===h.status&&(a=206,c="Partial Content",i.set("Content-Length",h.headers.get("Content-Length")),i.set("Content-Range",h.headers.get("Content-Range")),i.set("Accept-Ranges","bytes"))),u||(u=new Uint8Array([])),o||(o=new Date),i||(i=new Headers);return new mt({payload:u,status:a,statusText:c,headers:i,url:r,date:o,noRW:!1,isLive:!1})}}async resolveHeaders(t){const e=t.slice(t.indexOf("//")+2);let r=encodeURI(e);r=encodeURIComponent(e);let i=await fetch(this.sourceUrl+"H/"+r);if(200!==i.status)return null;let n=null,s=null,o=null,a=null,c=!1;try{const e=await ct.parse(i.body);if("revisit"===e.warcType){const r=e.warcHeaders.headers.get("WARC-Refers-To-Target-URI");if(r&&r!==t)return await this.resolveHeaders(r)}s=new Date(e.warcDate),e.httpHeaders?(n=e.httpHeaders.headers,o=Number(e.httpHeaders.statusCode),a=e.httpHeaders.statusText,c="0"!==e.httpHeaders.headers.get("Content-Length")):"resource"===e.warcType&&(n=new Headers,n.set("Content-Type",e.warcContentType),n.set("Content-Length",e.warcContentLength),o=200,a="OK",c=e.warcContentLength>0),o||(o=200)}catch(e){console.warn(e),console.warn("Ignoring headers, error parsing headers response for: "+t)}return{encodedUrl:r,headers:n,date:s,status:o,statusText:a,hasPayload:c}}}const zy=Qy([80,75,3,4]),Gy=Qy([31,139,8]),qy=Qy([87,65,82,67]);function Qy(t){return e=>{for(const[r,i]of t.entries())if(i!==e[r])return!1;return!0}}async function Vy(t){const e=t.body.getReader();let r="";const{value:i,done:n}=await e.read();var s;return!n&&i.length>=4&&(s=i.slice(0,4),r=zy(s)?".wacz":qy(s)?".warc":Gy(s)?".warc.gz":void 0,r||(r=function(t){try{const e=(new TextDecoder).decode(t).split("\n");if(e>1&&e.indexOf(" {"))return".cdxj"}catch(t){return""}}(i))),n||e.cancel(),r}globalThis.self||(globalThis.self=globalThis),self.interruptLoads={};class Ky extends class{constructor(){this.colldb=null,this.root=null,this.checkIpfs=!0,this._init_db=this._initDB()}async _initDB(){this.colldb=await Dr("collDB",1,{upgrade:t=>{t.createObjectStore("colls",{keyPath:"name"}).createIndex("type","type")}})}async loadAll(t){if(await this._init_db,t)for(const e of t.split(",")){const t=e.split(":");if(2===t.length){const e={dbname:t[1],sourceName:t[1],decode:!1},r={name:t[0],type:"archive",config:e};console.log("Adding Coll: "+JSON.stringify(r)),await this.colldb.put("colls",r)}}try{const t=(await this.listAll()).map((t=>this._initColl(t)));await Promise.all(t)}catch(t){console.warn(t.toString())}return!0}async listAll(){return await this._init_db,await this.colldb.getAll("colls")}async loadColl(t){await this._init_db;const e=await this.colldb.get("colls",t);return e?await this._initColl(e):null}async reload(t){return this.loadColl(t)}async deleteColl(t){await this._init_db;const e=await this.colldb.get("colls",t);if(!e)return!1;if(e.config.dbname)try{await Lr(e.config.dbname,{blocked(t,r){console.log(`Unable to delete ${e.config.dbname}, blocked: ${r}`)}})}catch(t){return console.warn(t),!1}return await this.colldb.delete("colls",t),!0}async updateAuth(t,e){await this._init_db;const r=await this.colldb.get("colls",t);return!!r&&(r.config.headers=e,await this.colldb.put("colls",r),!0)}async updateMetadata(t,e){await this._init_db;const r=await this.colldb.get("colls",t);return!!r&&(r.config.metadata={...r.config.metadata,...e},await this.colldb.put("colls",r),r.config.metadata)}async updateSize(t,e,r,i){await this._init_db;const n=await this.colldb.get("colls",t);if(!n)return!1;const s=n.config.metadata;return s.fullSize=(s.fullSize||0)+e,s.size=(s.size||0)+r,s.mtime=(new Date).getTime(),void 0!==i&&(n.config.decode=i),await this.colldb.put("colls",n),s}async initNewColl(t,e={},r="archive"){await this._init_db;const i=m(),n="local://"+i,s={name:i,type:r,config:{dbname:"db:"+i,ctime:(new Date).getTime(),decode:!1,metadata:t,sourceUrl:n,extraConfig:e}},o=await this._initColl(s);return await this.colldb.put("colls",s),o}async _initColl(t){const e=await this._initStore(t.type,t.config),r=t.name,i=t.config;return t.config.root&&!this.root&&(this.root=r),this._createCollection({name:r,store:e,config:i})}async _initStore(t,e){let r=null,i=null;switch(t){case"archive":i=new ei(e.dbname);break;case"remotesource":r=await Vi({url:e.loadUrl,headers:e.headers,size:e.size,extra:e.extra}),i=new nn(e.dbname,r,e.noCache);break;case"remoteprefix":i=new sn(e.dbname,e.remotePrefix,e.headers,e.noCache);break;case"wacz":case"remotezip":case"multiwacz":r=await Vi({url:e.loadUrl||e.sourceUrl,headers:e.headers,extra:e.extra}),i=new Wy(e,r,"multiwacz"===t?"json":"wacz");break;case"remotewarcproxy":i=new jy(e);break;case"live":i=new Fy(e.extraConfig)}return i?(i.initing&&await i.initing,i):(console.log("no store found: "+t),null)}_createCollection(t){return t}}{constructor(t){super(),this.registerListener(t)}async hasCollection(t){return await this._init_db,null!=await this.colldb.getKey("colls",t)}registerListener(t){t.addEventListener("message",(t=>{t.waitUntil?t.waitUntil(this._handleMessage(t)):this._handleMessage(t)}))}async _handleMessage(t){await this._init_db;const e=t.source||self;switch(t.data.msg_type){case"addColl":{const r=t.data.name,i=(t,i,n,s,o=null,a=null)=>{e.postMessage({msg_type:"collProgress",name:r,percent:t,error:i,currentSize:n,totalSize:s,fileHandle:o,extraMsg:a})};let n;try{if(n=await this.colldb.get("colls",r),n?t.data.skipExisting||(await this.deleteColl(r),n=await this.addCollection(t.data,i)):n=await this.addCollection(t.data,i),!n){if(t.data.name)try{await Lr("db:"+t.data.name,{blocked(e,r){console.log(`Load failed and unable to delete ${t.data.name}: ${r}`)}})}catch(t){console.warn(t)}return}}catch(t){if(t instanceof R)return console.warn(t),void i(0,"permission_needed",null,null,t.info&&t.info.fileHandle);if("ConstraintError"!==t.name)return console.warn(t),void i(0,"An unexpected error occured: "+t.toString());console.log("already being added, just continue..."),n=await this.colldb.get("colls",r)}e.postMessage({msg_type:"collAdded",name:r,sourceUrl:n.config.sourceUrl});break}case"cancelLoad":{const e=t.data.name,r=new Promise((t=>self.interruptLoads[e]=t));await r,await this.deleteColl(e),delete self.interruptLoads[e];break}case"removeColl":{const r=t.data.name;await this.hasCollection(r)&&(await this.deleteColl(r),this.doListAll(e));break}case"listAll":this.doListAll(e);break;case"reload":this.reload(t.data.name)}}async doListAll(t){const e=[],r=await this.listAll();for(const t of r)e.push({name:t.name,prefix:t.name,pageList:[],sourceName:t.config.sourceName});t.postMessage({msg_type:"listAll",colls:e})}async addCollection(t,e){let r=t.name,i=null,n={root:t.root||!1},s=null,o=null;const c=t.file;if(!c||!c.sourceUrl)return e(0,"Invalid Load Request"),!1;if(n.dbname="db:"+r,c.sourceUrl.startsWith("proxy:"))n.sourceUrl=c.sourceUrl.slice("proxy:".length),n.extraConfig=t.extraConfig,n.extraConfig.prefix||(n.extraConfig.prefix=n.sourceUrl),n.topTemplateUrl=t.topTemplateUrl,n.metadata={},i=t.type||n.extraConfig.type||"remotewarcproxy",s=await this._initStore(i,n);else{let l=null;if(c.newFullImport&&(r=m(),c.loadUrl=c.loadUrl||c.sourceUrl,c.name=c.name||c.sourceUrl,c.sourceUrl="local://"+r),i="archive",c.newFullImport&&c.importCollId){const t=await this.colldb.get("colls",c.importCollId);if(!t||"archive"!==t.type)return void e(0,"Invalid Existing Collection: "+c.importCollId);n.dbname=t.config.dbname,o=t.config,o.decode=!0}let u=c.loadUrl||c.sourceUrl;u.match(/[\w]+:\/\//)||(u=new URL(u,self.location.href).href),n.decode=!0,n.onDemand=!1,n.loadUrl=u,n.sourceUrl=c.sourceUrl,n.sourceName=c.name||c.sourceUrl;try{if(n.sourceName.match(/https?:\/\//)){const t=new URL(n.sourceName);n.sourceName=t.pathname+t.hash}}catch(t){}if(n.sourceName=n.sourceName.slice(n.sourceName.lastIndexOf("/")+1),n.size="number"==typeof c.size?c.size:null,n.extra=c.extra,n.loadUrl.startsWith("file://")&&!c.blob&&!n.extra){if(!this._fileHandles||!this._fileHandles[n.sourceUrl])return void e(0,"missing_local_file");n.extra={fileHandle:this._fileHandles[n.sourceUrl]}}n.extraConfig=t.extraConfig,n.headers=c.headers||n.extraConfig&&n.extraConfig.headers,n.noCache=c.noCache;let h=await Vi({url:u,headers:n.headers,size:c.size,extra:n.extra,blob:c.blob});if(c.loadEager){const{response:t}=await h.doInitialFetch(!1,!0),e={arrayBuffer:new Uint8Array(await t.arrayBuffer())};c.newFullImport=!0,h=await Vi({url:u,headers:n.headers,size:c.size,extra:e})}let p=function(t){const e=[".warc",".warc.gz",".cdx",".cdxj",".har",".json",".wacz",".zip"];for(const r of e)if(t.endsWith(r))return r;return""}(n.sourceName),{abort:d,response:f}=await h.doInitialFetch(".wacz"===p);p||(p=await Vy(await f.clone()));const g=f.body;if(n.onDemand=h.canLoadOnDemand&&!c.newFullImport,!h.isValid){const t=h.length<=1e3?await f.text():"";return e(0,`Sorry, this URL could not be loaded.\nMake sure this is a valid URL and you have access to this file.\nStatus: ${f.status} ${f.statusText}\nError Details:\n${t}`),d&&d.abort(),!1}if(!h.length)return e(0,"Sorry, this URL could not be loaded because the size of the file is not accessible.\nMake sure this is a valid URL and you have access to this file."),d&&d.abort(),!1;const w=h.length;if(".wacz"===p)if(n.onDemand)l=new Py(h,n,r),s=new Wy(n,h,"wacz"),i="wacz";else{if(!h.canLoadOnDemand||!c.newFullImport)return e(0,"Sorry, can't load this WACZ file due to lack of range request support on the server"),d&&d.abort(),!1;l=new Uy(h,n,r),s=null,delete n.extra}else".warc"===p||".warc.gz"===p?n.noCache||!(w<a)&&n.onDemand?(l=new hn(g,d,r),i="remotesource",s=new nn(n.dbname,h,n.noCache)):l=new si(g,d,r):".cdx"===p||".cdxj"===p?(n.remotePrefix=t.remotePrefix||u.slice(0,u.lastIndexOf("/")+1),l=new pn(g,d,r),i="remoteprefix",s=new sn(n.dbname,n.remotePrefix,n.headers,n.noCache)):".har"===p?(l=new ln(await f.json()),n.decode=!1):".json"===p&&(s=new Wy(n,h,"json"),l=new My(f),i="multiwacz");if(!l)return e(0,`The ${n.sourceName} is not a known archive format that could be loaded.`),d&&d.abort(),!1;s||(s=new ei(n.dbname)),await s.initing;try{n.metadata=await l.load(s,e,w)}catch(t){return t instanceof N||(e(0,`Unexpected Loading Error: ${t.toString()}`),console.warn(t)),!1}if(o)return await this.updateSize(c.importCollId,w,w,o.decode),{config:o};n.metadata.size||(n.metadata.size=w),n.metadata.title||(n.metadata.title=n.sourceName)}n.ctime=(new Date).getTime(),this._fileHandles&&n.extra&&n.extra.fileHandle&&delete this._fileHandles[n.sourceUrl];const l={name:r,type:i,config:n};return await this.colldb.add("colls",l),l.store=s,l}}class Yy{constructor(){this.timeRanges={}}updateStats(t,e,r,i){const n=i.clientId||i.resultingClientId;if(!n||!t)return;if(!r.url||r.url.indexOf("mp_/")<0)return;if("document"===r.destination&&e>300&&e<400)return;let s=null;void 0===this.timeRanges[n]?(s={count:0,children:[]},this.timeRanges[n]=s,r.referrer.indexOf("mp_/")>0&&self.clients.matchAll({type:"window"}).then((t=>this.updateStatsParent(n,r.referrer,t)))):s=this.timeRanges[n];const o=t.getTime();(!s.min||o<s.min)&&(s.min=o),(!s.max||o>s.max)&&(s.max=o),s.count++}updateStatsParent(t,e,r){for(let i of r)if(i.url===e){this.timeRanges[i.id]?this.timeRanges[i.id].children[t]=1:this.timeRanges[i.id]={count:0,children:{id:1}};break}}async getStats(t){const e=new URL(t.request.url);let r=0;const i=new URLSearchParams(e.search).get("url"),n=await self.clients.matchAll({type:"window"}),s={};for(let t of n)t.url===i&&(r=t.id),s[t.id]=1;const o=this.timeRanges[r]||{},a={count:o.count||0,min:o.min,max:o.max},c=this.timeRanges[r]&&Object.keys(this.timeRanges[r].children)||[];for(let t of c){const e=this.timeRanges[t];e&&((!a.min||e.min<a.min)&&(a.min=e.min),(!a.max||e.max>a.max)&&(a.max=e.max),a.count+=e.count)}for(let t of Object.keys(this.timeRanges))s[t]||delete this.timeRanges[t];return new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"}})}}var Jy=function(){return Jy=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},Jy.apply(this,arguments)};var Xy=function(t){return void 0===t&&(t={}),{arrayFormat:t.arrayFormat||"none",booleanFormat:t.booleanFormat||"none",nullFormat:t.nullFormat||"default"}},Zy=function(t){return encodeURIComponent(t)},$y=function(t){return decodeURIComponent(t)},tm=function(t,e,r){return null===e?function(t,e){return"hidden"===e.nullFormat?"":"string"===e.nullFormat?t+"=null":t}(t,r):"boolean"==typeof e?function(t,e,r){return"empty-true"===r.booleanFormat&&e?t:t+"="+("unicode"===r.booleanFormat?e?"✓":"✗":e.toString())}(t,e,r):Array.isArray(e)?function(t,e,r){var i=function(t){return"index"===t.arrayFormat?function(t,e){return t+"["+e+"]"}:"brackets"===t.arrayFormat?function(t){return t+"[]"}:function(t){return t}}(r);return e.map((function(e,r){return i(t,r)+"="+Zy(e)})).join("&")}(t,e,r):t+"="+Zy(e)},em=function(t){var e=t.indexOf("?");return-1===e?t:t.slice(e+1)},rm=function(t){var e=t.indexOf("["),r=-1!==e;return{hasBrackets:r,name:r?t.slice(0,e):t}},im=function(t,e){var r=Xy(e);return em(t).split("&").reduce((function(t,e){var i=e.split("="),n=i[0],s=i[1],o=rm(n),a=o.hasBrackets,c=o.name,l=t[c],u=function(t,e){if(void 0===t)return"empty-true"===e.booleanFormat||null;if("string"===e.booleanFormat){if("true"===t)return!0;if("false"===t)return!1}if("unicode"===e.booleanFormat){if("✓"===$y(t))return!0;if("✗"===$y(t))return!1}return"string"===e.nullFormat&&"null"===t?null:$y(t)}(s,r);return t[c]=void 0===l?a?[u]:u:(Array.isArray(l)?l:[l]).concat(u),t}),{})},nm=/[^!$'()*+,;|:]/g,sm=function(t){return t.replace(nm,(function(t){return encodeURIComponent(t)}))},om={default:sm,uri:encodeURI,uriComponent:encodeURIComponent,none:function(t){return t},legacy:encodeURI},am={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:function(t){return t},legacy:decodeURIComponent},cm=function(t,e,r){var i=om[e]||sm;return r?String(t).split("/").map(i).join("/"):i(String(t))},lm=function(t){return"("+(t?t.replace(/(^<|>$)/g,""):"[a-zA-Z0-9-_.~%':|=+\\*@$]+")+")"},um=[{name:"url-parameter",pattern:/^:([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})(<(.+?)>)?/,regex:function(t){return new RegExp(lm(t[2]))}},{name:"url-parameter-splat",pattern:/^\*([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})/,regex:/([^?]*)/},{name:"url-parameter-matrix",pattern:/^;([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})(<(.+?)>)?/,regex:function(t){return new RegExp(";"+t[1]+"="+lm(t[2]))}},{name:"query-parameter",pattern:/^(?:\?|&)(?::)?([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})/},{name:"delimiter",pattern:/^(\/|\?)/,regex:function(t){return new RegExp("\\"+t[0])}},{name:"sub-delimiter",pattern:/^(!|&|-|_|\.|;)/,regex:function(t){return new RegExp(t[0])}},{name:"fragment",pattern:/^([0-9a-zA-Z]+)/,regex:function(t){return new RegExp(t[0])}}],hm=function t(e,r){if(void 0===r&&(r=[]),!um.some((function(i){var n=e.match(i.pattern);return!!n&&(r.push({type:i.name,match:n[0],val:n.slice(1,2),otherVal:n.slice(2),regex:i.regex instanceof Function?i.regex(n):i.regex}),n[0].length<e.length&&(r=t(e.substr(n[0].length),r)),!0)})))throw new Error("Could not parse path '"+e+"'");return r},pm=function(t){return null!=t},dm={urlParamsEncoding:"default"},fm=function(){function t(t,e){if(!t)throw new Error("Missing path in Path constructor");this.path=t,this.options=Jy(Jy({},dm),e),this.tokens=hm(t),this.hasUrlParams=this.tokens.filter((function(t){return/^url-parameter/.test(t.type)})).length>0,this.hasSpatParam=this.tokens.filter((function(t){return/splat$/.test(t.type)})).length>0,this.hasMatrixParams=this.tokens.filter((function(t){return/matrix$/.test(t.type)})).length>0,this.hasQueryParams=this.tokens.filter((function(t){return/^query-parameter/.test(t.type)})).length>0,this.spatParams=this.getParams("url-parameter-splat"),this.urlParams=this.getParams(/^url-parameter/),this.queryParams=this.getParams("query-parameter"),this.params=this.urlParams.concat(this.queryParams),this.source=this.tokens.filter((function(t){return void 0!==t.regex})).map((function(t){return t.regex.source})).join("")}return t.createPath=function(e,r){return new t(e,r)},t.prototype.isQueryParam=function(t){return-1!==this.queryParams.indexOf(t)},t.prototype.isSpatParam=function(t){return-1!==this.spatParams.indexOf(t)},t.prototype.test=function(t,e){var r=this,i=Jy(Jy({caseSensitive:!1,strictTrailingSlash:!1},this.options),e),n=function(t,e){return e||"\\/"===t?t:t.replace(/\\\/$/,"")+"(?:\\/)?"}(this.source,i.strictTrailingSlash),s=this.urlTest(t,n+(this.hasQueryParams?"(\\?.*$|$)":"$"),i.caseSensitive,i.urlParamsEncoding);if(!s||!this.hasQueryParams)return s;var o=im(t,i.queryParams);return 0===Object.keys(o).filter((function(t){return!r.isQueryParam(t)})).length?(Object.keys(o).forEach((function(t){return s[t]=o[t]})),s):null},t.prototype.partialTest=function(t,e){var r=this,i=Jy(Jy({caseSensitive:!1,delimited:!0},this.options),e),n=function(t,e){return e?/(\/)$/.test(t)?t:t+"(\\/|\\?|\\.|;|$)":t}(this.source,i.delimited),s=this.urlTest(t,n,i.caseSensitive,i.urlParamsEncoding);if(!s)return s;if(!this.hasQueryParams)return s;var o=im(t,i.queryParams);return Object.keys(o).filter((function(t){return r.isQueryParam(t)})).forEach((function(t){return function(t,e,r){void 0===r&&(r="");var i=t[e];return t[e]=void 0===i?r:Array.isArray(i)?i.concat(r):[i,r],t}(s,t,o[t])})),s},t.prototype.build=function(t,e){var r=this;void 0===t&&(t={});var i=Jy(Jy({ignoreConstraints:!1,ignoreSearch:!1,queryParams:{}},this.options),e),n=Object.keys(t).filter((function(t){return!r.isQueryParam(t)})).reduce((function(e,n){if(!pm(t[n]))return e;var s=t[n],o=r.isSpatParam(n);return"boolean"==typeof s?e[n]=s:Array.isArray(s)?e[n]=s.map((function(t){return cm(t,i.urlParamsEncoding,o)})):e[n]=cm(s,i.urlParamsEncoding,o),e}),{});if(this.urlParams.some((function(e){return!pm(t[e])}))){var s=this.urlParams.filter((function(e){return!pm(t[e])}));throw new Error("Cannot build path: '"+this.path+"' requires missing parameters { "+s.join(", ")+" }")}if(!i.ignoreConstraints&&!this.tokens.filter((function(t){return/^url-parameter/.test(t.type)&&!/-splat$/.test(t.type)})).every((function(t){return new RegExp("^"+lm(t.otherVal[0])+"$").test(n[t.val])})))throw new Error("Some parameters of '"+this.path+"' are of invalid format");var o=this.tokens.filter((function(t){return!1===/^query-parameter/.test(t.type)})).map((function(t){return"url-parameter-matrix"===t.type?";"+t.val+"="+n[t.val[0]]:/^url-parameter/.test(t.type)?n[t.val[0]]:t.match})).join("");if(i.ignoreSearch)return o;var a=function(t,e){var r=Xy(e);return Object.keys(t).filter((function(e){return function(t){return void 0!==t}(t[e])})).map((function(e){return tm(e,t[e],r)})).filter(Boolean).join("&")}(this.queryParams.filter((function(e){return-1!==Object.keys(t).indexOf(e)})).reduce((function(e,r){return e[r]=t[r],e}),{}),i.queryParams);return a?o+"?"+a:o},t.prototype.getParams=function(t){var e=t instanceof RegExp?function(e){return t.test(e.type)}:function(e){return e.type===t};return this.tokens.filter(e).map((function(t){return t.val[0]}))},t.prototype.urlTest=function(t,e,r,i){var n=this,s=new RegExp("^"+e,r?"":"i"),o=t.match(s);return o?this.urlParams.length?o.slice(1,this.urlParams.length+1).reduce((function(t,e,r){return t[n.urlParams[r]]=(am[i]||decodeURIComponent)(e),t}),{}):{}:null},t}();class gm{constructor(t){this.routes={};for(const[e,r]of Object.entries(t)){let t,i;r instanceof Array?(t=r[0],i=r[1]||"GET"):(t=r,i="GET"),this.routes[i]=this.routes[i]||{},this.routes[i][e]=new fm(t)}}match(t,e="GET"){for(const[r,i]of Object.entries(this.routes[e]||[])){const e=t.split("?",2),n=e[0],s=i.test(n);if(s)return s._route=r,s._query=new URLSearchParams(2===e.length?e[1]:""),s}return{_route:null}}}class wm{constructor(t){this.router=new gm(this.routes),this.collections=t}get routes(){return{index:"coll-index",coll:"c/:coll",urls:"c/:coll/urls",createColl:["c/create","POST"],deleteColl:["c/:coll","DELETE"],updateAuth:["c/:coll/updateAuth","POST"],updateMetadata:["c/:coll/metadata","POST"],curated:"c/:coll/curated/:list",pages:"c/:coll/pages",textIndex:"c/:coll/textIndex",deletePage:["c/:coll/page/:page","DELETE"]}}async apiResponse(t,e,r){const i=this.router.match(t,e.method),n=await this.handleApi(e,i,r);if(n instanceof Response)return n;const s=n.error?404:200;return this.makeResponse(n,s)}async handleApi(t,e){switch(e._route){case"index":return await this.listAll(e._query.get("filter"));case"createColl":{const e=await t.json();return I(await this.collections.initNewColl(e.metadata||{},e.extraConfig||{}))}case"coll":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const r=I(t);return"1"===e._query.get("all")?(t.store.db?(r.pages=await t.store.getAllPages(),r.lists=await t.store.db.getAll("pageLists"),r.curatedPages=await t.store.db.getAll("curatedPages")):(r.pages=[],r.lists=[],r.curatedPages=[]),r.verify=await t.store.getVerifyInfo()):(r.numLists=await t.store.db.count("pageLists"),r.numPages=await t.store.db.count("pages")),t.config.metadata.ipfsPins&&(r.ipfsPins=t.config.metadata.ipfsPins),r}case"deleteColl":{const t="1"===e._query.get("reload");return await this.collections.deleteColl(e.coll,t)?await this.listAll():{error:"collection_not_found"}}case"updateAuth":{const r=await t.json();return{success:await this.collections.updateAuth(e.coll,r.headers)}}case"updateMetadata":{const r=await t.json();return{metadata:await this.collections.updateMetadata(e.coll,r)}}case"urls":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const r=e._query.get("url"),i=Number(e._query.get("count")||100),n=e._query.get("mime"),s="1"===e._query.get("prefix"),o=e._query.get("fromUrl"),a=e._query.get("fromTs"),c=e._query.get("fromMime"),l=Number(e._query.get("fromStatus")||0);if(!t.store.resourcesByMime)return{urls:[]};let u;return u=r?await t.store.resourcesByUrlAndMime(r,n,i,s,o,a):await t.store.resourcesByMime(n,i,c,o,l),u=u||[],{urls:u}}case"pages":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};return{pages:await t.store.getAllPages()}}case"textIndex":{const t=await this.collections.getColl(e.coll);return t?t.store.getTextIndex?await t.store.getTextIndex():{}:{error:"collection_not_found"}}case"curated":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const r=Number(e.list);return{curated:await t.store.db.getAllFromIndex("curatedPages","listPages",IDBKeyRange.bound([r],[r+1]))}}case"deletePage":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const{pageSize:r,deleteSize:i}=t.store.deletePage(e.page);return this.collections.updateSize(e.coll,r,i),{pageSize:r,deleteSize:i}}default:return{error:"not_found"}}}async listAll(t){const e=await this.collections.listAll(),r=[];return e.forEach((e=>{"live"!==e.type&&"remoteproxy"!==e.type&&(t&&0!==e.type.indexOf(t)||r.push(I(e)))})),{colls:r}}makeResponse(t,e=200){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json"}})}}const ym=/^(?::([\w-]+)\/)?(\d*)([a-z]+_|[$][a-z0-9:.-]+)?(?:\/|\||%7C|%7c)(.+)/;class mm{constructor(t,e,{isRoot:r=!1,mod:i="",ts:n="",proxyOrigin:s=null,localOrigin:o=null}={}){const a=ym.exec(t);if(this.url="",this.timestamp=n,this.mod=i,this.pageId="",this.hash="",!a&&(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("blob:")))this.url=t;else if(!a&&r)this.url="https://"+t;else{if(!a)return void(this.url=null);this.pageId=a[1]||"",this.timestamp=a[2],this.mod=a[3],this.url=a[4]}if(s&&o){const t=new URL(this.url);t.origin===o&&(this.url=s+t.pathname+(t.search?t.search:""))}const c=this.url.indexOf("#");c>0&&(this.hash=this.url.slice(c),this.url=this.url.substring(0,c)),this.request=e,this.method=e.method,this.mode=e.mode,this._postToGetConverted=!1}get headers(){return this.request.headers}get destination(){return this.request.destination}get referrer(){return this.request.referrer}async convertPostToGet(){if(this._postToGetConverted)return this.url;const t=this.request;if("POST"!==t.method&&"PUT"!==t.method)return this.url;const e={method:t.method,postData:await t.text(),headers:t.headers,url:this.url};return F(e)&&(this.url=e.url,this.method="GET",this.mode="navigate"===this.request.mode?"same-origin":this.request.mode,this._postToGetConverted=!0),this.url}prepareProxyRequest(t,e=!0){let r,i,n;if(e){r=new Headers(this.request.headers),i=this.request.referrer;const e=i.indexOf("/http",t.length-1);e>0&&(i=i.slice(e+1),r.set("X-Proxy-Referer",i)),n=this.request.credentials,this.cookie&&r.set("X-Proxy-Cookie",this.cookie)}else r=new Headers,n="omit";let s=this.url;if(s.startsWith("//"))try{s=new URL(i).protocol+s}catch(t){s="https:"+s}return{referrer:i,headers:r,credentials:n,url:s}}async getBody(){const t=this.request.clone();return new Uint8Array(await t.arrayBuffer())}}const bm="x-wabac-is-ajax-req";class Am extends Ky{constructor(t,e=null,r={}){super(self),this.prefixes=t,this.colls={},this.inited=null,this.root=e,this.defaultConfig=r,this._fileHandles={}}_createCollection(t){return new br(t,this.prefixes,this.defaultConfig)}loadAll(t){return this.colls={},this.inited=super.loadAll(t),this.inited}async getColl(t){return this.colls[t]||(this.colls[t]=await this.loadColl(t)),this.colls[t]}async reload(t){delete this.colls[t],await this.getColl(t)}async addCollection(t,e){const r=await super.addCollection(t,e);return r&&r.name&&(this.colls[r.name]=this._createCollection(r)),r}async deleteColl(t,e=!1){return this.colls[t]&&(this.colls[t].store&&this.colls[t].store.delete&&await this.colls[t].store.delete(),e&&this.colls[t].config&&this.colls[t].config.extra&&this.colls[t].config.extra.fileHandle&&(this._fileHandles[this.colls[t].config.sourceUrl]=this.colls[t].config.extra.fileHandle)),!!await super.deleteColl(t)&&(delete this.colls[t],!0)}async initNewColl(t,e={},r="archive"){const i=await super.initNewColl(t,e,r);return i&&(this.colls[i.name]=i),i}async updateAuth(t,e){this.colls[t]&&this.colls[t].store.updateHeaders&&this.colls[t].store.updateHeaders(e),await super.updateAuth(t,e)}async updateMetadata(t,e){const r=await super.updateMetadata(t,e);return this.colls[t]&&r&&(this.colls[t].config.metadata=r,this.colls[t].metadata=r),r}async updateSize(t,e,r,i){const n=await super.updateSize(t,e,r,i);return this.colls[t]&&n&&(this.colls[t].config.metadata=n,this.colls[t].metadata=n),void 0!==i&&this.colls[t]&&(this.colls[t].config.decode=i),n}}class Em{constructor({staticData:t=null,ApiClass:e=wm,defaultConfig:r={},CollectionsClass:i=Am}={}){this.prefix=self.registration?self.registration.scope:"",this.replayPrefix=this.prefix;const n=new URLSearchParams(self.location.search);let s="w";n.has("replayPrefix")&&(s=n.get("replayPrefix")),s&&(this.replayPrefix+=s+"/"),this.staticPrefix=this.prefix+"static/",this.distPrefix=this.prefix+"dist/";const o={static:this.staticPrefix,root:this.prefix,main:this.replayPrefix};this.staticData=t||new Map,this.staticData.set(this.staticPrefix+"wombat.js",{type:"application/javascript",content:'/*! wombat.js is part of Webrecorder project. Copyright (C) 2020-2023, Webrecorder Software. Licensed under the Affero General Public License v3. */(()=>{"use strict";function t(){this._map=[]}function e(t,e){void 0!==self.Symbol&&void 0!==self.Symbol.toStringTag&&Object.defineProperty(t.prototype,self.Symbol.toStringTag,{value:e,enumerable:!1})}function r(t){for(var e,r,i=t.__proto__||t.constructor.prototype||t.prototype,o=Object.getOwnPropertyNames(i),n=o.length,s=0;s<n;s++)r=t[e=o[s]],"constructor"!==e&&"function"==typeof r&&(t[e]=r.bind(t))}t.prototype.set=function(t,e){this._map.push([t,e])},t.prototype.get=function(t){for(var e=0;e<this._map.length;e++)if(this._map[e][0]===t)return this._map[e][1];return null},t.prototype.find=function(t){for(var e=0;e<this._map.length;e++)if(this._map[e][0]===t)return e;return-1},t.prototype.add_or_get=function(t,e){var r=this.get(t);return r||(r=e(),this.set(t,r)),r},t.prototype.remove=function(t){var e=this.find(t);return e>=0?this._map.splice(e,1)[0][1]:null},t.prototype.map=function(t){for(var e=0;e<this._map.length;e++)this._map[e][1](t)};var i={yes:!1},o=Symbol("__wb__storage_WOMBAT"),n=Symbol("__wb__storage_TYPE");function s(t,e,r){if(i.yes)throw new TypeError("Illegal constructor");if(r&&r.length)for(var s=0;s<r.length;s++)this[r[s][0]]=r[s][1].toString();Object.defineProperty(this,o,{value:t,enumerable:!1}),Object.defineProperty(this,n,{value:e,enumerable:!1})}function a(t,e,r){var i=new s(t,e,r);return t.$wbwindow.Proxy&&(i=new t.$wbwindow.Proxy(i,{get:function(t,e){var r=t.__proto__;if("__proto__"===e)return r;if(r.hasOwnProperty(e)||r.__proto__&&r.__proto__.hasOwnProperty(e)){var i=t[e];return"function"==typeof i&&(i=i.bind(t)),i}return t.hasOwnProperty(e)?t.getItem(e):void 0},set:function(t,e,r){return t.__proto__.hasOwnProperty(e)?(t[e]=r,!0):(t.setItem(e,r),!0)}})),t.defGetterProp(t.$wbwindow,e,(function(){return i})),i}function h(t,e){for(var r in Object.defineProperties(this,{_orig_loc:{configurable:!0,enumerable:!1,value:t},wombat:{configurable:!0,enumerable:!1,value:e},orig_getter:{enumerable:!1,value:function(t){return this._orig_loc[t]}},orig_setter:{enumerable:!1,value:function(t,e){this._orig_loc[t]!=e&&(this._orig_loc[t]=e)}}}),e.initLocOverride(this,this.orig_setter,this.orig_getter),e.setLoc(this,t.href),t)this.hasOwnProperty(r)||"function"==typeof t[r]||(this[r]=t[r])}function w(t,e){if(!(this instanceof w))return new w(t,e);this.elemSelector="img[srcset], img[data-srcset], img[data-src], video[srcset], video[data-srcset], video[data-src], audio[srcset], audio[data-srcset], audio[data-src], picture > source[srcset], picture > source[data-srcset], picture > source[data-src], video > source[srcset], video > source[data-srcset], video > source[data-src], audio > source[srcset], audio > source[data-srcset], audio > source[data-src]",this.wombat=t,this.$wbwindow=t.$wbwindow,this.worker=null,r(this),this._initWorker(e)}function p(t,e){return function(r){if(window==e)return t(r)}}function c(t,e,r){var i;return i="function"==typeof t?t:"object"==typeof t?t.handleEvent.bind(t):function(){},function(t){var o;if(t.data&&t.data.from&&t.data.message){if("*"!==t.data.to_origin&&e.WB_wombat_location&&!r.startsWith(t.data.to_origin,e.WB_wombat_location.origin))return void console.warn("Skipping message event to "+t.data.to_origin+" doesn\'t start with origin "+e.WB_wombat_location.origin);var n=t.source;t.data.from_top?n=e.__WB_top_frame:t.data.src_id&&e.__WB_win_id&&e.__WB_win_id[t.data.src_id]&&(n=e.__WB_win_id[t.data.src_id]),(o=new MessageEvent("message",{bubbles:t.bubbles,cancelable:t.cancelable,data:t.data.message,origin:t.data.from,lastEventId:t.lastEventId,source:r.proxyToObj(n),ports:t.ports}))._target=t.target,o._srcElement=t.srcElement,o._currentTarget=t.currentTarget,o._eventPhase=t.eventPhase}else o=t;return i(o)}}function l(t){let e;e="string"==typeof t?t:t&&t.length?t.reduce(((t,e)=>t+=String.fromCharCode(e)),""):t?t.toString():"";try{return"__wb_post_data="+btoa(e)}catch{return"__wb_post_data="}}function _(t){let{method:e,headers:r,postData:i}=t;if("GET"===e)return!1;function o(t){return t instanceof Uint8Array&&(t=(new TextDecoder).decode(t)),t}let n="";switch((r.get("content-type")||"").split(";")[0]){case"application/x-www-form-urlencoded":n=o(i);break;case"application/json":n=d(o(i));break;case"text/plain":try{n=d(o(i),!1)}catch{n=l(i)}break;case"multipart/form-data":{let t=r.get("content-type");if(!t)throw new Error("utils cannot call postToGetURL when missing content-type header");n=function(t,e){return function(t,e){let r=new URLSearchParams;t instanceof Uint8Array&&(t=(new TextDecoder).decode(t));try{let i=e.split("boundary=")[1],o=t.split(new RegExp("-*"+i+"-*","mi"));for(let t of o){let e=t.trim().match(/name="([^"]+)"\\r\\n\\r\\n(.*)/im);e&&r.set(e[1],e[2])}}catch{}return r}(t,e).toString()}(o(i),t);break}default:n=l(i)}return null!==n&&(t.url=function(t,e,r){if(!r)return t;let i=t.indexOf("?")>0?"&":"?";return`${t}${i}__wb_method=${r}&${e}`}(t.url,n,t.method),t.method="GET",t.requestBody=n,!0)}function u(t,e=!0){if("string"==typeof t)try{t=JSON.parse(t)}catch{t={}}let r=new URLSearchParams,i={};try{JSON.stringify(t,((t,e)=>(["object","function"].includes(typeof e)||r.set((t=>r.has(t)?(t in i||(i[t]=1),t+"."+ ++i[t]+"_"):t)(t),e),e)))}catch(t){if(!e)throw t}return r}function d(t,e=!0){return u(t,e).toString()}function f(e,i){if(!(this instanceof f))return new f(e,i);this.debug_rw=!1,this.$wbwindow=e,this.WBWindow=Window,this.origHost=e.location.host,this.origHostname=e.location.hostname,this.origProtocol=e.location.protocol,this.HTTP_PREFIX="http://",this.HTTPS_PREFIX="https://",this.REL_PREFIX="//",this.VALID_PREFIXES=[this.HTTP_PREFIX,this.HTTPS_PREFIX,this.REL_PREFIX],this.IGNORE_PREFIXES=["#","about:","data:","blob:","mailto:","javascript:","{","*"],"ignore_prefixes"in i&&(this.IGNORE_PREFIXES=this.IGNORE_PREFIXES.concat(i.ignore_prefixes)),this.WB_CHECK_THIS_FUNC="_____WB$wombat$check$this$function_____",this.WB_ASSIGN_FUNC="_____WB$wombat$assign$function_____",this.wb_setAttribute=e.Element.prototype.setAttribute,this.wb_getAttribute=e.Element.prototype.getAttribute,this.wb_funToString=Function.prototype.toString,this.WBAutoFetchWorker=null,this.wbUseAFWorker=i.enable_auto_fetch&&null!=e.Worker&&i.is_live,this.wb_rel_prefix="",this.wb_wombat_updating=!1,this.message_listeners=new t,this.storage_listeners=new t,this.linkAsTypes={script:"js_",worker:"js_",style:"cs_",image:"im_",document:"if_",fetch:"mp_",font:"oe_",audio:"oe_",video:"oe_",embed:"oe_",object:"oe_",track:"oe_","":"mp_",null:"mp_",undefined:"mp_"},this.linkTagMods={linkRelToAs:{import:this.linkAsTypes,preload:this.linkAsTypes},stylesheet:"cs_",null:"mp_",undefined:"mp_","":"mp_"},this.tagToMod={A:{href:"mp_"},AREA:{href:"mp_"},AUDIO:{src:"oe_",poster:"im_"},BASE:{href:"mp_"},EMBED:{src:"oe_"},FORM:{action:"mp_"},FRAME:{src:"fr_"},IFRAME:{src:"if_"},IMAGE:{href:"im_","xlink:href":"im_"},IMG:{src:"im_",srcset:"im_"},INPUT:{src:"oe_"},INS:{cite:"mp_"},META:{content:"mp_"},OBJECT:{data:"oe_",codebase:"oe_"},Q:{cite:"mp_"},SCRIPT:{src:"js_","xlink:href":"js_"},SOURCE:{src:"oe_",srcset:"oe_"},TRACK:{src:"oe_"},VIDEO:{src:"oe_",poster:"im_"},image:{href:"im_","xlink:href":"im_"}},this.URL_PROPS=["href","hash","pathname","host","hostname","protocol","origin","search","port"],this.wb_info=i,this.wb_opts=i.wombat_opts,this.wb_replay_prefix=i.prefix,this.wb_is_proxy=this.wb_info.proxy_magic||!this.wb_replay_prefix,this.wb_info.top_host=this.wb_info.top_host||"*",this.wb_curr_host=e.location.protocol+"//"+e.location.host,this.wb_info.wombat_opts=this.wb_info.wombat_opts||{},this.wb_orig_scheme=this.wb_info.wombat_scheme+"://",this.wb_orig_origin=this.wb_orig_scheme+this.wb_info.wombat_host,this.wb_abs_prefix=this.wb_replay_prefix,this.wb_capture_date_part="",!this.wb_info.is_live&&this.wb_info.wombat_ts&&(this.wb_capture_date_part="/"+this.wb_info.wombat_ts+"/"),this.BAD_PREFIXES=["http:"+this.wb_replay_prefix,"https:"+this.wb_replay_prefix,"http:/"+this.wb_replay_prefix,"https:/"+this.wb_replay_prefix],this.hostnamePortRe=/^[\\w-]+(\\.[\\w-_]+)+(:\\d+)(\\/|$)/,this.ipPortRe=/^\\d+\\.\\d+\\.\\d+\\.\\d+(:\\d+)?(\\/|$)/,this.workerBlobRe=/__WB_pmw\\(.*?\\)\\.(?=postMessage\\()/g,this.rmCheckThisInjectRe=/_____WB\\$wombat\\$check\\$this\\$function_____\\(.*?\\)/g,this.STYLE_REGEX=/(url\\s*\\(\\s*[\\\\"\']*)([^)\'"]+)([\\\\"\']*\\s*\\))/gi,this.IMPORT_REGEX=/(@import\\s*[\\\\"\']*)([^)\'";]+)([\\\\"\']*\\s*;?)/gi,this.IMPORT_JS_REGEX=/^(import\\s*\\([\'"]+)([^\'"]+)(["\'])/i,this.no_wombatRe=/WB_wombat_/g,this.srcsetRe=/\\s*(\\S*\\s+[\\d.]+[wx]),|(?:\\s*,(?:\\s+|(?=https?:)))/,this.cookie_path_regex=/\\bPath=\'?"?([^;\'"\\s]+)/i,this.cookie_domain_regex=/\\bDomain=([^;\'"\\s]+)/i,this.cookie_expires_regex=/\\bExpires=([^;\'"]+)/gi,this.SetCookieRe=/,(?![|])/,this.IP_RX=/^(\\d)+\\.(\\d)+\\.(\\d)+\\.(\\d)+$/,this.FullHTMLRegex=/^\\s*<(?:html|head|body|!doctype html)/i,this.IsTagRegex=/^\\s*</,this.DotPostMessageRe=/(\\.postMessage\\s*\\()/,this.extractPageUnderModifierRE=/\\/(?:[0-9]{14})?([a-z]{2, 3}_)\\//,this.write_buff="";var o=(e.EventTarget||{}).prototype;this.utilFns={cspViolationListener:function(t){if(console.group("CSP Violation"),console.log("Replayed Page URL",window.WB_wombat_location.href),console.log("The documentURI",t.documentURI),console.log("The blocked URL",t.blockedURI),console.log("The directive violated",t.violatedDirective),console.log("Our policy",t.originalPolicy),t.sourceFile){var e="File: "+t.sourceFile;t.lineNumber&&t.columnNumber?e+=" @ "+t.lineNumber+":"+t.columnNumber:t.lineNumber&&(e+=" @ "+t.lineNumber),console.log(e)}console.groupEnd()},addEventListener:o.addEventListener,removeEventListener:o.removeEventListener,objToString:Object.prototype.toString,wbSheetMediaQChecker:null,XHRopen:null,XHRsend:null},this.showCSPViolations={yesNo:!1,added:!1},r(this)}s.prototype.getItem=function(t){return this.hasOwnProperty(t)?this[t]:null},s.prototype.setItem=function(t,e){var r=String(t),i=String(e),o=this.getItem(r);this[r]=e,this.fireEvent(r,o,i)},s.prototype._deleteItem=function(t){delete this[t]},s.prototype.removeItem=function(t){var e=this.getItem(t);this._deleteItem(t),this.fireEvent(t,e,null)},s.prototype.clear=function(){for(var t in this)delete this[t];this.fireEvent(null,null,null)},s.prototype.key=function(t){var e=function(t){try{switch(typeof t){case"number":case"bigint":return t}var e=Number(t);return isNaN(e)?null:e}catch(t){}return null}(t);if(null==e||e<0)return null;var r=Object.keys(this);return e<r.length?r[e]:null},s.prototype.fireEvent=function(t,e,r){var i=new StorageEvent("storage",{key:t,newValue:r,oldValue:e,url:this[o].$wbwindow.WB_wombat_location.href});Object.defineProperty(i,"storageArea",{value:this,writable:!1,configurable:!1}),i._storageArea=this,this[o].storage_listeners.map(i)},s.prototype.valueOf=function(){return this[o].$wbwindow[this[n]]},s.prototype.toString=function(){return"[object Storage]"},Object.defineProperty(s.prototype,"length",{enumerable:!1,get:function(){return Object.keys(this).length}}),e(s,"Storage"),h.prototype.replace=function(t){var e=this.wombat.rewriteUrl(t),r=this.wombat.extractOriginalURL(e);return r===this.href?r:this._orig_loc.replace(e)},h.prototype.assign=function(t){var e=this.wombat.rewriteUrl(t),r=this.wombat.extractOriginalURL(e);return r===this.href?r:this._orig_loc.assign(e)},h.prototype.reload=function(t){},h.prototype.toString=function(){return this.href},h.prototype.valueOf=function(){return this},e(h,"Location"),w.prototype._initWorker=function(t){var e=this.wombat;if(t.isTop)try{this.worker=new Worker(t.workerURL,{type:"classic",credentials:"include"})}catch(t){console.error("Failed to create auto fetch worker\\n",t)}else this.worker={postMessage:function(t){t.wb_type||(t={wb_type:"aaworker",msg:t}),e.$wbwindow.__WB_replay_top.__orig_postMessage(t,"*")},terminate:function(){}}},w.prototype.extractMediaRulesFromSheet=function(t){var e,r=[];try{e=t.cssRules||t.rules}catch(t){return r}for(var i=0;i<e.length;++i){var o=e[i];o.type===CSSRule.MEDIA_RULE&&r.push(o.cssText)}return r},w.prototype.deferredSheetExtraction=function(t){var e=this;Promise.resolve().then((function(){var r=e.extractMediaRulesFromSheet(t);r.length>0&&e.preserveMedia(r)}))},w.prototype.terminate=function(){this.worker.terminate()},w.prototype.justFetch=function(t){this.worker.postMessage({type:"fetch-all",values:t})},w.prototype.fetchAsPage=function(t,e,r){if(t){var i={"X-Wombat-History-Page":e};if(r){var o=encodeURIComponent(r.trim());r&&(i["X-Wombat-History-Title"]=o)}var n={url:t,options:{headers:i,cache:"no-store"}};this.justFetch([n])}},w.prototype.postMessage=function(t,e){if(e){var r=this;Promise.resolve().then((function(){r.worker.postMessage(t)}))}else this.worker.postMessage(t)},w.prototype.preserveSrcset=function(t,e){this.postMessage({type:"values",srcset:{value:t,mod:e,presplit:!0}},!0)},w.prototype.preserveDataSrcset=function(t){this.postMessage({type:"values",srcset:{value:t.dataset.srcset,mod:this.rwMod(t),presplit:!1}},!0)},w.prototype.preserveMedia=function(t){this.postMessage({type:"values",media:t},!0)},w.prototype.getSrcset=function(t){return this.wombat.wb_getAttribute?this.wombat.wb_getAttribute.call(t,"srcset"):t.getAttribute("srcset")},w.prototype.rwMod=function(t){switch(t.tagName){case"SOURCE":return t.parentElement&&"PICTURE"===t.parentElement.tagName?"im_":"oe_";case"IMG":return"im_"}return"oe_"},w.prototype.extractFromLocalDoc=function(){var t=this;Promise.resolve().then((function(){for(var e={type:"values",context:{docBaseURI:document.baseURI}},r=[],i=0,o=document.styleSheets;i<o.length;++i)r=r.concat(t.extractMediaRulesFromSheet(o[i]));var n,s,a,h=document.querySelectorAll(t.elemSelector),w={values:[],presplit:!1},p={values:[]};for(i=0;i<h.length;++i)s=(n=h[i]).src?n.src:null,a=t.rwMod(n),n.srcset&&w.values.push({srcset:t.getSrcset(n),mod:a,tagSrc:s}),n.dataset.srcset&&w.values.push({srcset:n.dataset.srcset,mod:a,tagSrc:s}),n.dataset.src&&p.values.push({src:n.dataset.src,mod:a}),"SOURCE"===n.tagName&&s&&p.values.push({src:s,mod:a});r.length&&(e.media=r),w.values.length&&(e.srcset=w),p.values.length&&(e.src=p),(e.media||e.srcset||e.src)&&t.postMessage(e)}))},f.prototype._internalInit=function(){this.initTopFrame(this.$wbwindow),this.initWombatLoc(this.$wbwindow),this.initWombatTop(this.$wbwindow);var t=this.$wbwindow.__WB_replay_top.location.origin,e=this.$wbwindow.__WB_replay_top.location.host,r=this.$wbwindow.__WB_replay_top.location.protocol;this.wb_replay_prefix&&0===this.wb_replay_prefix.indexOf(t)?this.wb_rel_prefix=this.wb_replay_prefix.substring(t.length):this.wb_rel_prefix=this.wb_replay_prefix,this.wb_prefixes=[this.wb_abs_prefix,this.wb_rel_prefix];var i="(("+r+")?//"+e+")?"+this.wb_rel_prefix+"[^/]+/";this.wb_unrewrite_rx=new RegExp(i,"g"),this.wb_info.is_framed&&"bn_"!==this.wb_info.mod&&this.initTopFrameNotify(this.wb_info),this.initAutoFetchWorker()},f.prototype._addRemoveCSPViolationListener=function(t){this.showCSPViolations.yesNo=t,this.showCSPViolations.yesNo&&!this.showCSPViolations.added?(this.showCSPViolations.added=!0,this._addEventListener(document,"securitypolicyviolation",this.utilFns.cspViolationListener)):(this.showCSPViolations.added=!1,this._removeEventListener(document,"securitypolicyviolation",this.utilFns.cspViolationListener))},f.prototype._addEventListener=function(t,e,r){if(this.utilFns.addEventListener)return this.utilFns.addEventListener.call(t,e,r);t.addEventListener(e,r)},f.prototype._removeEventListener=function(t,e,r){if(this.utilFns.removeEventListener)return this.utilFns.removeEventListener.call(t,e,r);t.removeEventListener(e,r)},f.prototype.getPageUnderModifier=function(){try{var t=this.extractPageUnderModifierRE.exec(location.pathname);if(t&&t[1])return t[1].trim()||"mp_"}catch(t){}return"mp_"},f.prototype.isNativeFunction=function(t){return!(!t||"function"!=typeof t)&&(-1!=this.wb_funToString.call(t).indexOf("[native code]")&&(void 0===t.__WB_is_native_func__||!!t.__WB_is_native_func__))},f.prototype.isString=function(t){return null!=t&&Object.getPrototypeOf(t)===String.prototype},f.prototype.blobUrlForIframe=function(t,e){var r=new Blob([e],{type:"text/html"}),i=URL.createObjectURL(r);t.__wb_blobSrc=i,t.addEventListener("load",(function(){t.__wb_blobSrc&&(URL.revokeObjectURL(t.__wb_blobSrc),t.__wb_blobSrc=null)}),{once:!0}),t.__wb_origSrc=t.src;var o=i.slice(i.lastIndexOf("/")+1)+"/"+this.wb_info.url;t.src=this.wb_info.prefix+this.wb_info.request_ts+"mp_/blob:"+o},f.prototype.isSavedSrcSrcset=function(t){switch(t.tagName){case"IMG":case"VIDEO":case"AUDIO":return!0;case"SOURCE":if(!t.parentElement)return!1;switch(t.parentElement.tagName){case"PICTURE":case"VIDEO":case"AUDIO":return!0;default:return!1}default:return!1}},f.prototype.isSavedDataSrcSrcset=function(t){return!(!t.dataset||null==t.dataset.srcset)&&this.isSavedSrcSrcset(t)},f.prototype.isHostUrl=function(t){if(0===t.indexOf("www."))return!0;var e=t.match(this.hostnamePortRe);return!!(e&&e[0].length<64)||!!(e=t.match(this.ipPortRe))&&e[0].length<64},f.prototype.isArgumentsObj=function(t){if(!t||"function"!=typeof t.toString)return!1;try{return"[object Arguments]"===this.utilFns.objToString.call(t)}catch(t){return!1}},f.prototype.deproxyArrayHandlingArgumentsObj=function(t){if(!t||t instanceof NodeList||!t.length)return t;for(var e=this.isArgumentsObj(t)?new Array(t.length):t,r=0;r<t.length;++r){const i=this.proxyToObj(t[r]);i!==e[r]&&(e[r]=i)}return e},f.prototype.startsWith=function(t,e){if(t)return 0===t.indexOf(e)?e:void 0},f.prototype.startsWithOneOf=function(t,e){if(t)for(var r=0;r<e.length;r++)if(0===t.indexOf(e[r]))return e[r]},f.prototype.endsWith=function(t,e){if(t)return-1!==t.indexOf(e,t.length-e.length)?e:void 0},f.prototype.shouldRewriteAttr=function(t,e){switch(e){case"href":case"src":case"xlink:href":return!0}return!(!t||!this.tagToMod[t]||void 0===this.tagToMod[t][e])||("VIDEO"===t&&"poster"===e||"META"===t&&"content"===e)},f.prototype.skipWrapScriptBasedOnType=function(t){return!!t&&(!(t.indexOf("javascript")>=0||t.indexOf("ecmascript")>=0)&&(t.indexOf("json")>=0||t.indexOf("text/")>=0))},f.prototype.skipWrapScriptTextBasedOnText=function(t){if(!t||t.indexOf(this.WB_ASSIGN_FUNC)>=0||0===t.indexOf("<"))return!0;for(var e=["window","self","document","location","top","parent","frames","opener"],r=0;r<e.length;r++)if(t.indexOf(e[r])>=0)return!1;return!0},f.prototype.nodeHasChildren=function(t){if(!t)return!1;if("function"==typeof t.hasChildNodes)return t.hasChildNodes();var e=t.children||t.childNodes;return!!e&&e.length>0},f.prototype.rwModForElement=function(t,e){if(t){var r="mp_";if("LINK"===t.tagName&&"href"===e){if(t.rel){var i=t.rel.trim().toLowerCase(),o=this.wb_getAttribute.call(t,"as");if(o&&null!=this.linkTagMods.linkRelToAs[i])r=this.linkTagMods.linkRelToAs[i][o.toLowerCase()];else null!=this.linkTagMods[i]&&(r=this.linkTagMods[i])}}else{var n=this.tagToMod[t.tagName];null!=n&&(r=n[e])}return r}},f.prototype.removeWBOSRC=function(t){"SCRIPT"!==t.tagName||t.__$removedWBOSRC$__||(t.hasAttribute("__wb_orig_src")&&t.removeAttribute("__wb_orig_src"),t.__$removedWBOSRC$__=!0)},f.prototype.retrieveWBOSRC=function(t){var e;if("SCRIPT"===t.tagName&&!t.__$removedWBOSRC$__)return null==(e=this.wb_getAttribute?this.wb_getAttribute.call(t,"__wb_orig_src"):t.getAttribute("__wb_orig_src"))&&(t.__$removedWBOSRC$__=!0),e},f.prototype.wrapScriptTextJsProxy=function(t){return\'var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };\\nif (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }\\n{\\nlet window = _____WB$wombat$assign$function_____("window");\\nlet globalThis = _____WB$wombat$assign$function_____("globalThis");\\nlet self = _____WB$wombat$assign$function_____("self");\\nlet document = _____WB$wombat$assign$function_____("document");\\nlet location = _____WB$wombat$assign$function_____("location");\\nlet top = _____WB$wombat$assign$function_____("top");\\nlet parent = _____WB$wombat$assign$function_____("parent");\\nlet frames = _____WB$wombat$assign$function_____("frames");\\nlet opener = _____WB$wombat$assign$function_____("opener");\\n{\\n\'+t.replace(this.DotPostMessageRe,".__WB_pmw(self.window)$1")+"\\n\\n}}"},f.prototype.watchElem=function(t,e){if(!this.$wbwindow.MutationObserver)return!1;new this.$wbwindow.MutationObserver((function(t,r){for(var i=0;i<t.length;i++){var o=t[i];if("childList"===o.type)for(var n=0;n<o.addedNodes.length;n++)e(o.addedNodes[n])}})).observe(t,{childList:!0,subtree:!0})},f.prototype.reconstructDocType=function(t){return null==t?"":"<!doctype "+t.name+(t.publicId?\' PUBLIC "\'+t.publicId+\'"\':"")+(!t.publicId&&t.systemId?" SYSTEM":"")+(t.systemId?\' "\'+t.systemId+\'"\':"")+">"},f.prototype.getFinalUrl=function(t,e,r){var i=t?this.wb_rel_prefix:this.wb_abs_prefix;return null==e&&(e=this.wb_info.mod),this.wb_info.is_live||(i+=this.wb_info.wombat_ts),"/"!==(i+=e)[i.length-1]&&(i+="/"),i+r},f.prototype.resolveRelUrl=function(t,e){var r=e||this.$wbwindow.document,i=this.makeParser(r.baseURI,r),o=i.href.lastIndexOf("#"),n=o>=0?i.href.substring(0,o):i.href,s=n.lastIndexOf("/");return s>=0&&s!==n.length-1?i.href=n.substring(0,s+1)+t:i.href=n+t,i.href},f.prototype.extractOriginalURL=function(t){if(!t)return"";if(this.wb_is_proxy)return t;var e,r=t.toString(),i=r;if(this.startsWithOneOf(i,this.IGNORE_PREFIXES))return i;if(i.startsWith(this.wb_info.static_prefix))return i;e=this.startsWith(i,this.wb_abs_prefix)?this.wb_abs_prefix.length:this.wb_rel_prefix&&this.startsWith(i,this.wb_rel_prefix)?this.wb_rel_prefix.length:this.wb_rel_prefix?1:0;var o=i.indexOf("/http",e);return o<0&&(o=i.indexOf("///",e)),o<0&&(o=i.indexOf("/blob:",e)),o<0&&(o=i.indexOf("/about:blank",e)),o>=0?i=i.substr(o+1):((o=i.indexOf(this.wb_replay_prefix))>=0&&(i=i.substr(o+this.wb_replay_prefix.length)),i.length>4&&"_"===i.charAt(2)&&"/"===i.charAt(3)&&(i=i.substr(4)),i===r||this.startsWithOneOf(i,this.VALID_PREFIXES)||this.startsWith(i,"blob:")||(i=this.wb_orig_scheme+i)),"/"===r.charAt(0)&&"/"!==r.charAt(1)&&this.startsWith(i,this.wb_orig_origin)&&(i=i.substr(this.wb_orig_origin.length)),this.startsWith(i,this.REL_PREFIX)?this.wb_info.wombat_scheme+":"+i:i},f.prototype.makeParser=function(t,e){var r=this.extractOriginalURL(t),i=e;return e||(i="about:blank"===this.$wbwindow.location.href&&this.$wbwindow.opener?this.$wbwindow.opener.document:this.$wbwindow.document),this._makeURLParser(r,i)},f.prototype._makeURLParser=function(t,e){try{return new this.$wbwindow.URL(t,e.baseURI)}catch(t){}var r=e.createElement("a");return r._no_rewrite=!0,r.href=t,r},f.prototype.defProp=function(t,e,r,i,o){var n=Object.getOwnPropertyDescriptor(t,e);if(n&&!n.configurable)return!1;if(!i)return!1;var s={configurable:!0,enumerable:o||!1,get:i};r&&(s.set=r);try{return Object.defineProperty(t,e,s),!0}catch(t){return console.warn("Failed to redefine property %s",e,t.message),!1}},f.prototype.defGetterProp=function(t,e,r,i){var o=Object.getOwnPropertyDescriptor(t,e);if(o&&!o.configurable)return!1;if(!r)return!1;try{return Object.defineProperty(t,e,{configurable:!0,enumerable:i||!1,get:r}),!0}catch(t){return console.warn("Failed to redefine property %s",e,t.message),!1}},f.prototype.getOrigGetter=function(t,e){var r;if(t.__lookupGetter__&&(r=t.__lookupGetter__(e)),!r&&Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);i&&(r=i.get)}return r},f.prototype.getOrigSetter=function(t,e){var r;if(t.__lookupSetter__&&(r=t.__lookupSetter__(e)),!r&&Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);i&&(r=i.set)}return r},f.prototype.getAllOwnProps=function(t){for(var e=[],r=Object.getOwnPropertyNames(t),i=0;i<r.length;i++){var o=r[i];try{t[o]&&!t[o].prototype&&e.push(o)}catch(t){}}for(var n=Object.getPrototypeOf(t);n;){for(r=Object.getOwnPropertyNames(n),i=0;i<r.length;i++)e.push(r[i]);n=Object.getPrototypeOf(n)}return e},f.prototype.sendTopMessage=function(t,e,r){(r=r||this.$wbwindow).__WB_top_frame&&(e||r==r.__WB_replay_top)&&r.__WB_top_frame.postMessage(t,this.wb_info.top_host)},f.prototype.sendHistoryUpdate=function(t,e,r){this.sendTopMessage({url:t,ts:this.wb_info.timestamp,request_ts:this.wb_info.request_ts,is_live:this.wb_info.is_live,title:e,wb_type:"replace-url"},!1,r)},f.prototype.updateLocation=function(t,e,r){if(t&&t!==e){var i=this.extractOriginalURL(e),o=this.extractOriginalURL(t);if(i&&i!==o){var n=this.rewriteUrl(t);console.log(r.href+" -> "+n),r.href=n}}},f.prototype.checkLocationChange=function(t,e){var r=typeof t,i=e?this.$wbwindow.__WB_replay_top.location:this.$wbwindow.location;"string"===r?this.updateLocation(t,i.href,i):"object"===r&&this.updateLocation(t.href,t._orig_href,i)},f.prototype.checkAllLocations=function(){if(this.wb_wombat_updating)return!1;this.wb_wombat_updating=!0,this.checkLocationChange(this.$wbwindow.WB_wombat_location,!1),this.$wbwindow.WB_wombat_location!=this.$wbwindow.__WB_replay_top.WB_wombat_location&&this.checkLocationChange(this.$wbwindow.__WB_replay_top.WB_wombat_location,!0),this.wb_wombat_updating=!1},f.prototype.proxyToObj=function(t){if(t)try{var e=t.__WBProxyRealObj__;if(e)return e}catch(t){}return t},f.prototype.objToProxy=function(t){if(t)try{var e=t._WB_wombat_obj_proxy;if(e)return e}catch(t){}return t},f.prototype.defaultProxyGet=function(t,e,r,i){switch(e){case"__WBProxyRealObj__":return t;case"location":case"WB_wombat_location":return t.WB_wombat_location;case"_WB_wombat_obj_proxy":return t._WB_wombat_obj_proxy;case"__WB_pmw":case this.WB_ASSIGN_FUNC:case this.WB_CHECK_THIS_FUNC:return t[e];case"origin":return t.WB_wombat_location.origin;case"constructor":return t.constructor}var o=t[e],n=typeof o;if("function"===n&&-1!==r.indexOf(e)){switch(e){case"requestAnimationFrame":case"cancelAnimationFrame":if(!this.isNativeFunction(o))return o;break;case"eval":if(this.isNativeFunction(o))return this.wrappedEval(o)}var s=i[e];return s&&s.original===o||(s={original:o,boundFn:o.bind(t)},i[e]=s),s.boundFn}return"object"===n&&o&&o._WB_wombat_obj_proxy?(o instanceof this.WBWindow&&this.initNewWindowWombat(o),o._WB_wombat_obj_proxy):o},f.prototype.setLoc=function(t,e){var r=this.makeParser(e,t.ownerDocument);t._orig_href=e,t._parser=r;var i=r.href;t._hash=r.hash,t._href=i,t._host=r.host,t._hostname=r.hostname,r.origin?t._origin=r.host?r.origin:"null":t._origin=r.protocol+"//"+r.hostname+(r.port?":"+r.port:""),t._pathname=r.pathname,t._port=r.port,t._protocol=r.protocol,t._search=r.search,Object.defineProperty||(t.href=i,t.hash=r.hash,t.host=t._host,t.hostname=t._hostname,t.origin=t._origin,t.pathname=t._pathname,t.port=t._port,t.protocol=t._protocol,t.search=t._search)},f.prototype.makeGetLocProp=function(t,e){var r=this;return function(){if(this._no_rewrite)return e.call(this,t);var i=e.call(this,"href");return"href"===t?r.extractOriginalURL(i):"ancestorOrigins"===t?[]:(this._orig_href!==i&&r.setLoc(this,i),this["_"+t])}},f.prototype.makeSetLocProp=function(t,e,r){var i=this;return function(o){if(this._no_rewrite)return e.call(this,t,o);if(this["_"+t]!==o){if(this["_"+t]=o,!this._parser){var n=r.call(this);this._parser=i.makeParser(n,this.ownerDocument)}var s=!1;if("href"===t&&"string"==typeof o)if(o&&this._parser instanceof URL)try{o=new URL(o,this._parser).href}catch(t){console.warn("Error resolving URL",t)}else o&&("."===o[0]||"#"===o[0]?o=i.resolveRelUrl(o,this.ownerDocument):"/"===o[0]&&(o.length>1&&"/"===o[1]?o=this._parser.protocol+o:(s=!0,o=WB_wombat_location.origin+o)));try{this._parser[t]=o}catch(e){console.log("Error setting "+t+" = "+o)}"hash"===t?(o=this._parser[t],e.call(this,"hash",o)):(s=s||o===this._parser.pathname,o=i.rewriteUrl(this._parser.href,s),e.call(this,"href",o))}}},f.prototype.styleReplacer=function(t,e,r,i,o,n){return e+this.rewriteUrl(r)+i},f.prototype.domConstructorErrorChecker=function(t,e,r,i){var o,n="number"==typeof i?i:1;if(t instanceof this.WBWindow?o="Failed to construct \'"+e+"\': Please use the \'new\' operator, this DOM object constructor cannot be called as a function.":r&&r.length<n&&(o="Failed to construct \'"+e+"\': "+n+" argument required, but only 0 present."),o)throw new TypeError(o)},f.prototype.rewriteNodeFuncArgs=function(t,e,r,i){if(r)switch(r.nodeType){case Node.ELEMENT_NODE:this.rewriteElemComplete(r);break;case Node.TEXT_NODE:("STYLE"===t.tagName||r.parentNode&&"STYLE"===r.parentNode.tagName)&&(r.textContent=this.rewriteStyle(r.textContent));break;case Node.DOCUMENT_FRAGMENT_NODE:this.recurseRewriteElem(r)}var o=e.call(t,r,i);return o&&"IFRAME"===o.tagName&&(o.allow="autoplay \'self\'; fullscreen \'self\'",this.initIframeWombat(o)),o},f.prototype.rewriteWSURL=function(t){if(!t)return t;var e=typeof t,r=t;if("object"===e)r=t.toString();else if("string"!==e)return t;if(!r)return r;var i="ws://",o="wss://";if(this.wb_is_proxy)return this.wb_orig_scheme===this.HTTP_PREFIX&&this.startsWith(r,o)?i+r.substr(o.length):this.wb_orig_scheme===this.HTTPS_PREFIX&&this.startsWith(r,i)?o+r.substr(i.length):r;var n=0===this.wb_abs_prefix.indexOf(this.HTTPS_PREFIX),s=this.wb_abs_prefix.replace(n?this.HTTPS_PREFIX:this.HTTP_PREFIX,n?o:i);return s+=this.wb_info.wombat_ts+"ws_","/"!==r[r.length-1]&&(s+="/"),s+r.replace("WB_wombat_","")},f.prototype.rewriteUrl_=function(t,e,r,i){if(!t)return t;var o,n,s=typeof t;if("object"===s)o=t.toString();else{if("string"!==s)return t;o=t}if(!o)return o;if(this.wb_is_proxy)return this.wb_orig_scheme===this.HTTP_PREFIX&&this.startsWith(o,this.HTTPS_PREFIX)?this.HTTP_PREFIX+o.substr(this.HTTPS_PREFIX.length):this.wb_orig_scheme===this.HTTPS_PREFIX&&this.startsWith(o,this.HTTP_PREFIX)?this.HTTPS_PREFIX+o.substr(this.HTTP_PREFIX.length):o;if(o=o.replace("WB_wombat_",""),"if_"===r&&this.wb_info.isSW&&this.startsWith(o,"blob:"))return this.wb_info.prefix+this.wb_info.request_ts+"if_/"+o;if(this.startsWithOneOf(o.toLowerCase(),this.IGNORE_PREFIXES))return o;if(this.wb_opts.no_rewrite_prefixes&&this.startsWithOneOf(o,this.wb_opts.no_rewrite_prefixes))return o;if(n=0===o.indexOf("//")?this.origProtocol+o:o,this.startsWith(n,this.wb_abs_prefix)||this.startsWith(n,this.wb_rel_prefix))return o;if(this.origHost!==this.origHostname&&this.startsWith(o,this.origProtocol+"//"+this.origHostname+"/"))return o.replace("/"+this.origHostname+"/","/"+this.origHost+"/");if("/"===o.charAt(0)&&!this.startsWith(o,this.REL_PREFIX)){if(this.wb_capture_date_part&&o.indexOf(this.wb_capture_date_part)>=0)return o;if(0===o.indexOf(this.wb_rel_prefix)&&o.indexOf("http")>1){var a=o.indexOf(":/");return a>0&&"/"!==o[a+2]?o.substring(0,a+2)+"/"+o.substring(a+2):o}return this.getFinalUrl(!0,r,this.wb_orig_origin+o)}"."===o.charAt(0)&&(o=this.resolveRelUrl(o,i));var h=this.startsWithOneOf(o.toLowerCase(),this.VALID_PREFIXES);if(h){var w=this.replayTopHost,p=this.replayTopProtocol,c=h+w+"/";if(this.startsWith(o,c)){if(this.startsWith(o,this.wb_replay_prefix))return o;var l=p+"//",_=o.substring(c.length),u=!1;return _.indexOf(this.wb_rel_prefix)<0&&o.indexOf("/static/")<0&&(_=this.getFinalUrl(!0,r,WB_wombat_location.origin+"/"+_),u=!0),h!==l&&h!==this.REL_PREFIX&&(u=!0),u&&(o=e?"":l+w,_&&"/"!==_[0]&&(o+="/"),o+=_),o}return this.getFinalUrl(e,r,o)}return(h=this.startsWithOneOf(o,this.BAD_PREFIXES))?this.getFinalUrl(e,r,this.extractOriginalURL(o)):o},f.prototype.rewriteUrl=function(t,e,r,i){var o=this.rewriteUrl_(t,e,r,i);return this.debug_rw&&(t!==o?console.log("REWRITE: "+t+" -> "+o):console.log("NOT REWRITTEN "+t)),o},f.prototype.performAttributeRewrite=function(t,e,r,i){switch(e){case"innerHTML":case"outerHTML":return this.rewriteHtml(r);case"filter":return this.rewriteInlineStyle(r);case"style":return this.rewriteStyle(r);case"srcset":return this.rewriteSrcset(r,t)}if(i&&!this.startsWithOneOf(r,this.VALID_PREFIXES))return r;var o=this.rwModForElement(t,e);return this.wbUseAFWorker&&this.WBAutoFetchWorker&&this.isSavedDataSrcSrcset(t)&&this.WBAutoFetchWorker.preserveDataSrcset(t),this.rewriteUrl(r,!1,o,t.ownerDocument)},f.prototype.rewriteAttr=function(t,e,r){var i=!1;if(!t||!t.getAttribute||t._no_rewrite||t["_"+e])return i;var o=this.wb_getAttribute.call(t,e);if(!o||this.startsWith(o,"javascript:"))return i;var n=this.performAttributeRewrite(t,e,o,r);return n!==o&&(this.removeWBOSRC(t),this.wb_setAttribute.call(t,e,n),i=!0),i},f.prototype.noExceptRewriteStyle=function(t){try{return this.rewriteStyle(t)}catch(e){return t}},f.prototype.rewriteStyle=function(t){if(!t)return t;var e=t;return"object"==typeof t&&(e=t.toString()),"string"==typeof e?e.replace(this.STYLE_REGEX,this.styleReplacer).replace(this.IMPORT_REGEX,this.styleReplacer).replace(this.no_wombatRe,""):e},f.prototype.rewriteSrcset=function(t,e){if(!t)return"";for(var r=t.split(this.srcsetRe),i=[],o=this.rwModForElement(e,"srcset"),n=0;n<r.length;n++){var s=r[n];if(s){var a=s.trim().split(" ");a[0]=this.rewriteUrl(a[0],!0,o),i.push(a.join(" "))}}return this.wbUseAFWorker&&this.WBAutoFetchWorker&&this.isSavedSrcSrcset(e)&&this.WBAutoFetchWorker.preserveSrcset(i,this.WBAutoFetchWorker.rwMod(e)),i.join(", ")},f.prototype.rewriteFrameSrc=function(t,e){var r,i=this.wb_getAttribute.call(t,e);if(this.startsWith(i,"javascript:")&&i.indexOf("WB_wombat_")>=0){var o="javascript:";r=o+"window.parent._wb_wombat.initNewWindowWombat(window);"+i.substr(o.length)}return r||(r=this.rewriteUrl(i,!1,this.rwModForElement(t,e))),r!==i&&(this.wb_setAttribute.call(t,e,r),!0)},f.prototype.rewriteScript=function(t){if(t.hasAttribute("src")||!t.textContent||!this.$wbwindow.Proxy)return this.rewriteAttr(t,"src");if(this.skipWrapScriptBasedOnType(t.type))return!1;var e=t.textContent.trim();return!this.skipWrapScriptTextBasedOnText(e)&&(t.textContent=this.wrapScriptTextJsProxy(e),!0)},f.prototype.rewriteSVGElem=function(t){var e=this.rewriteAttr(t,"filter");return e=this.rewriteAttr(t,"style")||e,e=this.rewriteAttr(t,"xlink:href")||e,e=this.rewriteAttr(t,"href")||e,e=this.rewriteAttr(t,"src")||e},f.prototype.rewriteElem=function(t){var e=!1;if(!t)return e;if(t instanceof SVGElement)e=this.rewriteSVGElem(t);else switch(t.tagName){case"META":var r=this.wb_getAttribute.call(t,"http-equiv");r&&"content-security-policy"===r.toLowerCase()&&(this.wb_setAttribute.call(t,"http-equiv","_"+r),e=!0);break;case"STYLE":var i=this.rewriteStyle(t.textContent);t.textContent!==i&&(t.textContent=i,e=!0,this.wbUseAFWorker&&this.WBAutoFetchWorker&&null!=t.sheet&&this.WBAutoFetchWorker.deferredSheetExtraction(t.sheet));break;case"LINK":e=this.rewriteAttr(t,"href"),this.wbUseAFWorker&&"stylesheet"===t.rel&&this._addEventListener(t,"load",this.utilFns.wbSheetMediaQChecker);break;case"IMG":e=this.rewriteAttr(t,"src"),e=this.rewriteAttr(t,"srcset")||e,e=this.rewriteAttr(t,"style")||e,this.wbUseAFWorker&&this.WBAutoFetchWorker&&t.dataset.srcset&&this.WBAutoFetchWorker.preserveDataSrcset(t);break;case"OBJECT":if(this.wb_info.isSW&&t.parentElement&&"application/pdf"===t.getAttribute("type")){for(var o=this.$wbwindow.document.createElement("IFRAME"),n=0;n<t.attributes.length;n++){var s=t.attributes[n],a=s.name;"data"===a&&(a="src"),this.wb_setAttribute.call(o,a,s.value)}t.parentElement.replaceChild(o,t),e=!0;break}e=this.rewriteAttr(t,"data",!0),e=this.rewriteAttr(t,"style")||e;break;case"FORM":e=this.rewriteAttr(t,"poster"),e=this.rewriteAttr(t,"action")||e,e=this.rewriteAttr(t,"style")||e;break;case"IFRAME":if(e=this.rewriteFrameSrc(t,"src"),this.wb_info.isSW&&!e){var h=t.getAttribute("srcdoc");if(t.hasAttribute("srcdoc")&&t.removeAttribute("srcdoc"),h)this.blobUrlForIframe(t,h);else{var w=t.getAttribute("src");w&&"about:blank"!==w||(w||(t.__WB_blank=!0),t.src=this.wb_info.prefix+this.wb_info.request_ts+"mp_/about:blank")}}e=this.rewriteAttr(t,"style")||e;break;case"FRAME":e=this.rewriteFrameSrc(t,"src"),e=this.rewriteAttr(t,"style")||e;break;case"SCRIPT":e=this.rewriteScript(t);break;case"A":if(e=this.rewriteAttr(t,"href")||e,t.hasAttribute("target")){var p=this.rewriteAttrTarget(t.target);p!==t.target&&(t.target=p,e=!0)}break;default:e=this.rewriteAttr(t,"src"),e=this.rewriteAttr(t,"srcset")||e,e=this.rewriteAttr(t,"href")||e,e=this.rewriteAttr(t,"style")||e,e=this.rewriteAttr(t,"poster")||e}return t.hasAttribute&&t.removeAttribute&&(t.hasAttribute("crossorigin")&&(t.removeAttribute("crossorigin"),e=!0),t.hasAttribute("integrity")&&(t.removeAttribute("integrity"),e=!0)),e},f.prototype.recurseRewriteElem=function(t){if(!this.nodeHasChildren(t))return!1;for(var e=!1,r=[t.children||t.childNodes];r.length>0;)for(var i=r.shift(),o=0;o<i.length;o++){var n=i[o];n.nodeType===Node.ELEMENT_NODE&&(e=this.rewriteElem(n)||e,this.nodeHasChildren(n)&&r.push(n.children||n.childNodes))}return e},f.prototype.rewriteElemComplete=function(t){if(!t)return!1;var e=this.rewriteElem(t),r=this.recurseRewriteElem(t);return e||r},f.prototype.rewriteElementsInArguments=function(t){for(var e=new Array(t.length),r=0;r<t.length;r++){var i=t[r];i instanceof Node?(this.rewriteElemComplete(i),e[r]=i):e[r]="string"==typeof i?this.rewriteHtml(i):i}return e},f.prototype.rewriteHtml=function(t,e){if(!t)return t;var r=t;if("string"!=typeof t&&(r=t.toString()),this.write_buff&&(r=this.write_buff+r,this.write_buff=""),r.indexOf("<script")<=0&&(r=r.replace(/((id|class)=".*)WB_wombat_([^"]+)/,"$1$3")),!this.$wbwindow.HTMLTemplateElement||this.FullHTMLRegex.test(r))return this.rewriteHtmlFull(r,e);var i=(new DOMParser).parseFromString("<template>"+r+"</template>","text/html");if(!i||!this.nodeHasChildren(i.head)||!i.head.children[0].content)return r;var o=i.head.children[0];if(o._no_rewrite=!0,this.recurseRewriteElem(o.content)){var n=o.innerHTML;if(e){var s=o.content.children&&o.content.children[0];if(s){var a="</"+s.tagName.toLowerCase()+">";this.endsWith(n,a)&&!this.endsWith(r.toLowerCase(),a)&&(n=n.substring(0,n.length-a.length))}else if("<"!==r[0]||">"!==r[r.length-1])return void(this.write_buff+=r)}return n}return r},f.prototype.rewriteHtmlFull=function(t,e){var r=(new DOMParser).parseFromString(t,"text/html");if(!r)return t;for(var i=!1,o=0;o<r.all.length;o++)i=this.rewriteElem(r.all[o])||i;if(i){var n;if(t&&t.indexOf("<html")>=0)r.documentElement._no_rewrite=!0,n=this.reconstructDocType(r.doctype)+r.documentElement.outerHTML;else{r.head._no_rewrite=!0,r.body._no_rewrite=!0;var s=this.nodeHasChildren(r.head),a=this.nodeHasChildren(r.body);if(n=(s?r.head.outerHTML:"")+(a?r.body.outerHTML:""),e)if(r.all.length>3){var h="</"+r.all[3].tagName.toLowerCase()+">";this.endsWith(n,h)&&!this.endsWith(t.toLowerCase(),h)&&(n=n.substring(0,n.length-h.length))}else if("<"!==t[0]||">"!==t[t.length-1])return void(this.write_buff+=t);n=this.reconstructDocType(r.doctype)+n}return n}return t},f.prototype.rewriteInlineStyle=function(t){var e;try{e=decodeURIComponent(t)}catch(r){e=t}if(e!==t){var r=this.rewriteStyle(e).split(",",2);return r[0]+","+encodeURIComponent(r[1])}return this.rewriteStyle(t)},f.prototype.rewriteCookie=function(t){var e=this,r=t.replace(this.wb_abs_prefix,"").replace(this.wb_rel_prefix,"");return r=r.replace(this.cookie_domain_regex,(function(t,i){var o={domain:i,cookie:r,wb_type:"cookie"};return e.sendTopMessage(o,!0),e.$wbwindow.location.hostname.indexOf(".")>=0&&!e.IP_RX.test(e.$wbwindow.location.hostname)?"Domain=."+e.$wbwindow.location.hostname:""})).replace(this.cookie_path_regex,(function(t,r){var i=e.rewriteUrl(r);return 0===i.indexOf(e.wb_curr_host)&&(i=i.substring(e.wb_curr_host.length)),"Path="+i})),"https:"!==e.$wbwindow.location.protocol&&(r=r.replace("secure","")),r.replace(",|",",")},f.prototype.rewriteWorker=function(t){if(!t)return t;var e=0===(t=t.toString()).indexOf("blob:"),r=0===t.indexOf("javascript:");if(!e&&!r){if(!this.startsWithOneOf(t,this.VALID_PREFIXES)&&!this.startsWith(t,"/")&&!this.startsWithOneOf(t,this.BAD_PREFIXES)){var i=this.resolveRelUrl(t,this.$wbwindow.document);return this.rewriteUrl(i,!1,"wkr_",this.$wbwindow.document)}return this.rewriteUrl(t,!1,"wkr_",this.$wbwindow.document)}var o=r?t.replace("javascript:",""):null;if(e){var n=new XMLHttpRequest;this.utilFns.XHRopen.call(n,"GET",t,!1),this.utilFns.XHRsend.call(n),o=n.responseText.replace(this.workerBlobRe,"").replace(this.rmCheckThisInjectRe,"this")}if(this.wb_info.static_prefix||this.wb_info.ww_rw_script){var s=this.$wbwindow.document.baseURI;o="(function() { self.importScripts(\'"+(this.wb_info.ww_rw_script||this.wb_info.static_prefix+"wombatWorkers.js")+"\'); new WBWombat({\'prefix\': \'"+this.wb_abs_prefix+"\', \'prefixMod\': \'"+this.wb_abs_prefix+"wkrf_/\', \'originalURL\': \'"+s+"\'}); })();"+o}var a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)},f.prototype.rewriteTextNodeFn=function(t,e,r){var i,o=this.proxyToObj(t);if(r.length>0&&o.parentElement&&"STYLE"===o.parentElement.tagName){i=new Array(r.length);var n=r.length-1;2===n?(i[0]=r[0],i[1]=r[1]):1===n&&(i[0]=r[0]),i[n]=this.rewriteStyle(r[n])}else i=r;return e.__WB_orig_apply?e.__WB_orig_apply(o,i):e.apply(o,i)},f.prototype.rewriteChildNodeFn=function(t,e,r){var i=this.proxyToObj(t);if(0===r.length)return e.call(i);var o=this.rewriteElementsInArguments(r);return e.__WB_orig_apply?e.__WB_orig_apply(i,o):e.apply(i,o)},f.prototype.rewriteInsertAdjHTMLOrElemArgs=function(t,e,r,i,o){var n=this.proxyToObj(t);return n._no_rewrite?e.call(n,r,i):o?e.call(n,r,this.rewriteHtml(i)):(this.rewriteElemComplete(i),e.call(n,r,i))},f.prototype.rewriteSetTimeoutInterval=function(t,e,r){var i=this.isString(r[0]),o=i?new Array(r.length):r;if(i){this.$wbwindow.Proxy?o[0]=this.wrapScriptTextJsProxy(r[0]):o[0]=r[0].replace(/\\blocation\\b/g,"WB_wombat_$&");for(var n=1;n<r.length;++n)o[n]=this.proxyToObj(r[n])}var s=this.proxyToObj(t);return e.__WB_orig_apply?e.__WB_orig_apply(s,o):e.apply(s,o)},f.prototype.rewriteHTMLAssign=function(t,e,r){var i=r,o=t.tagName;t._no_rewrite||t instanceof this.$wbwindow.HTMLTemplateElement||("STYLE"===o?i=this.rewriteStyle(r):"SCRIPT"===o?(r&&this.IsTagRegex.test(r)&&(i=this.rewriteHtml(r)),i===r&&(this.skipWrapScriptBasedOnType(t.type)||this.skipWrapScriptTextBasedOnText(r)||(i=this.wrapScriptTextJsProxy(i)))):i=this.rewriteHtml(r)),e.call(t,i),this.wbUseAFWorker&&this.WBAutoFetchWorker&&"STYLE"===o&&null!=t.sheet&&this.WBAutoFetchWorker.deferredSheetExtraction(t.sheet)},f.prototype.rewriteEvalArg=function(t,e,r){return t(this.isString(e)&&!this.skipWrapScriptTextBasedOnText(e)?this.wrapScriptTextJsProxy(e):this.otherEvalRewrite(e),r)},f.prototype.otherEvalRewrite=function(t){return"string"!=typeof t?t:t.replace(this.IMPORT_JS_REGEX,this.styleReplacer)},f.prototype.addEventOverride=function(t,e){var r=e;e||(r=this.$wbwindow.MessageEvent.prototype);var i=this.getOrigGetter(r,t);i&&this.defGetterProp(r,t,(function(){return null!=this["_"+t]?this["_"+t]:i.call(this)}))},f.prototype.isAttrObjRewrite=function(t){if(!t)return!1;var e=t.ownerElement&&t.ownerElement.tagName;return this.shouldRewriteAttr(e,t.nodeName)},f.prototype.newAttrObjGetSet=function(t,e){var r=this,i=this.getOrigGetter(t,e),o=this.getOrigSetter(t,e);this.defProp(t,e,(function(t){var e=r.proxyToObj(this),i=t;return r.isAttrObjRewrite(e)&&(i=r.performAttributeRewrite(e.ownerElement,e.name,t,!1)),o.call(e,i)}),(function(){var t=r.proxyToObj(this),e=i.call(t);return r.isAttrObjRewrite(t)?r.extractOriginalURL(e):e}))},f.prototype.overrideAttrProps=function(){var t=this.$wbwindow.Attr.prototype;this.newAttrObjGetSet(t,"value"),this.newAttrObjGetSet(t,"nodeValue"),this.newAttrObjGetSet(t,"textContent")},f.prototype.overrideAttr=function(t,e,r){var i=this.getOrigGetter(t,e),o=this.getOrigSetter(t,e),n=this;this.defProp(t,e,(function(t){"js_"!==r||this.__$removedWBOSRC$__||n.removeWBOSRC(this);var i=n.rewriteUrl(t,!1,r);return o?o.call(this,i):n.wb_setAttribute?n.wb_setAttribute.call(this,e,i):void 0}),(function(){var t;return i?t=i.call(this):n.wb_getAttribute&&(t=n.wb_getAttribute.call(this,e)),t=n.extractOriginalURL(t),this.__WB_blank&&"about:blank"===t?"":t}))},f.prototype.overridePropExtract=function(t,e){var r=this.getOrigGetter(t,e),i=this;if(r){this.defGetterProp(t,e,(function(){var t=i.proxyToObj(this),e=r.call(t);return i.extractOriginalURL(e)}))}},f.prototype.overrideReferrer=function(t){var e=this.getOrigGetter(t,"referrer"),r=this;if(e){this.defGetterProp(t,"referrer",(function(){var t=r.proxyToObj(this),i=this.defaultView;if(i===i.__WB_replay_top)return"";var o=e.call(t);return r.extractOriginalURL(o)}))}},f.prototype.overridePropToProxy=function(t,e){var r=this.getOrigGetter(t,e);if(r){var i=this;this.defGetterProp(t,e,(function(){return i.objToProxy(r.call(this))}))}},f.prototype.overrideHistoryFunc=function(t){if(this.$wbwindow.history){var e=this.$wbwindow.history[t];if(e){this.$wbwindow.history["_orig_"+t]=e,this.$wbwindow.history.___wb_ownWindow=this.$wbwindow;var r=this,i=function(t,i,o){var n,s,a=this.___wb_ownWindow||r.$wbwindow,h=a.WB_wombat_location;if(o){var w=r._makeURLParser(o,a.document);if(s=w.href,n=r.rewriteUrl(s),s!==h.origin&&"about:blank"!==h.href&&!r.startsWith(s,h.origin+"/"))throw new DOMException("Invalid history change: "+s)}else s=h.href;e.call(this,t,i,n);var p=a.document.title;r.WBAutoFetchWorker&&a.setTimeout((function(){i||a.document.title===p||(i=a.document.title),r.WBAutoFetchWorker.fetchAsPage(n,s,i)}),100),r.sendHistoryUpdate(s,i,a)};return this.$wbwindow.history[t]=i,this.$wbwindow.History&&this.$wbwindow.History.prototype&&(this.$wbwindow.History.prototype[t]=i),i}}},f.prototype.overrideStyleAttr=function(t,e,r){var i=this.getOrigGetter(t,e),o=this.getOrigSetter(t,e),n=this,s=i,a=function(t,e,r,i,o){return e+(r||"")+n.extractOriginalURL(i)+o},h=/(url\\()([\'"])?(.*?)(\\2\\))/;i||(s=function(){var t=this.getPropertyValue(r);return t&&t.startsWith("url(")&&(t=t.replace(h,a)),t}),(o&&i||r)&&this.defProp(t,e,(function(t){var e=n.rewriteStyle(t);return o?o.call(this,e):this.setProperty(r,e),e}),s)},f.prototype.overrideStyleSetProp=function(t){var e=t.setProperty,r=this;t.setProperty=function(t,i,o){var n=r.rewriteStyle(i);return e.call(this,t,n,o)}},f.prototype.overrideAnchorAreaElem=function(t){if(t&&t.prototype){for(var e={},r=t.prototype,i=function(t,r){var i=e["set_"+t];return i?i.call(this,r):""},o=function(t){var r=e["get_"+t];return r?r.call(this):""},n=0;n<this.URL_PROPS.length;n++){var s=this.URL_PROPS[n];e["get_"+s]=this.getOrigGetter(r,s),e["set_"+s]=this.getOrigSetter(r,s),Object.defineProperty&&this.defProp(r,s,this.makeSetLocProp(s,i,o),this.makeGetLocProp(s,o),!0)}r.toString=function(){return this.href}}},f.prototype.overrideHtmlAssign=function(t,e,r){if(this.$wbwindow.DOMParser&&t&&t.prototype){var i=t.prototype,o=this.getOrigGetter(i,e),n=this.getOrigSetter(i,e);if(n){var s=this.rewriteHTMLAssign,a=this.wb_unrewrite_rx;this.defProp(i,e,(function(t){return s(this,n,t)}),r?function(){var t=o.call(this);return this._no_rewrite?t:t.replace(a,"")}:o)}}},f.prototype.overrideHtmlAssignSrcDoc=function(t,e){var r=t.prototype,i=(this.getOrigGetter(r,e),this.getOrigSetter(r,e)),o=this;this.defProp(r,e,(function(t){return this.__wb_srcdoc=t,o.wb_info.isSW?(o.blobUrlForIframe(this,t),t):o.rewriteHTMLAssign(this,i,t)}),(function(){return this.__wb_srcdoc}))},f.prototype.overrideDataSet=function(){var t=this.$wbwindow.HTMLElement.prototype,e=this.getOrigGetter(t,"dataset"),r=this;this.defProp(t,"dataset",null,(function(){var t=e.call(this);return new Proxy(t,{get(t,e,i){var o=t[e];return r.startsWithOneOf(o,r.wb_prefixes)?r.extractOriginalURL(o):o}})}))},f.prototype.overrideStyleProxy=function(t){var e=this.$wbwindow.HTMLElement.prototype,r=this.getOrigSetter(e,"style"),i=this.getOrigGetter(e,"style"),o=this;this.defProp(e,"style",r,(function(){var e=i.call(this),r={};return new Proxy(e,{set:(e,r,i)=>(t.includes(r)&&(i=o.rewriteStyle(i)),e[r]=i,!0),get(t,i,n){var s=t[i];return"function"!=typeof s||"setProperty"!==i&&!o.isNativeFunction(s)?s:(r[i]||(r[i]=s.bind(e)),r[i])}})}))},f.prototype.overrideIframeContentAccess=function(t){if(this.$wbwindow.HTMLIFrameElement&&this.$wbwindow.HTMLIFrameElement.prototype){var e=this.$wbwindow.HTMLIFrameElement.prototype,r=this.getOrigGetter(e,t);if(r){var i=this.getOrigSetter(e,t),o=this;this.defProp(e,t,i,(function(){return o.initIframeWombat(this),o.objToProxy(r.call(this))})),e["_get_"+t]=r}}},f.prototype.overrideFramesAccess=function(t){if(!t.Proxy||t!==t.frames){t.__wb_frames=t.frames;var e=this,r=function(){for(var t=0;t<this.__wb_frames.length;t++)try{e.initNewWindowWombat(this.__wb_frames[t])}catch(t){}return this.__wb_frames};this.defGetterProp(t,"frames",r),this.defGetterProp(t.Window.prototype,"frames",r)}},f.prototype.overrideSWAccess=function(t){if(t.navigator.serviceWorker&&t.navigator.serviceWorker.controller){t._WB_wombat_sw=t.navigator.serviceWorker;var e={controller:null,ready:Promise.resolve({unregister:function(){}}),register:function(){return Promise.reject()},addEventListener:function(){},removeEventListener:function(){},onmessage:null,oncontrollerchange:null,getRegistrations:function(){return Promise.resolve([])},getRegistration:function(){return Promise.resolve(void 0)},startMessages:function(){}};this.defGetterProp(t.navigator,"serviceWorker",(function(){return e}))}},f.prototype.overrideFuncThisProxyToObj=function(t,e,r){if(t){var i=r;if(!r&&t.prototype&&t.prototype[e]?i=t.prototype:!r&&t[e]&&(i=t),i){var o=this,n=i[e];i[e]=function(){return n.apply(o.proxyToObj(this),arguments)}}}},f.prototype.overrideFuncArgProxyToObj=function(t,e,r){if(t&&t.prototype){var i=r||0,o=t.prototype[e];if(o){var n=this;t.prototype[e]=function(){for(var t=new Array(arguments.length),e=0;e<t.length;e++)t[e]=e===i?n.proxyToObj(arguments[e]):arguments[e];var r=n.proxyToObj(this);return o.__WB_orig_apply?o.__WB_orig_apply(r,t):o.apply(r,t)}}}},f.prototype.overrideFunctionApply=function(t){if(!t.Function.prototype.__WB_orig_apply){var e=t.Function.prototype.apply;t.Function.prototype.__WB_orig_apply=e;var r=this;t.Function.prototype.apply=function(t,e){return r.isNativeFunction(this)&&(t=r.proxyToObj(t),e=r.deproxyArrayHandlingArgumentsObj(e)),this.__WB_orig_apply(t,e)},this.wb_funToString.apply=e}},f.prototype.overrideFunctionBind=function(t){if(!t.Function.prototype.__WB_orig_bind){var e=t.Function.prototype.bind;t.Function.prototype.__WB_orig_bind=e;var r=this;t.Function.prototype.bind=function(t){var e=r.isNativeFunction(this),i=this.__WB_orig_bind.apply(this,arguments);return i.__WB_is_native_func__=e,i}}},f.prototype.overrideSrcsetAttr=function(t,e){var r="srcset",i=this.getOrigGetter(t,r),o=this.getOrigSetter(t,r),n=this;this.defProp(t,r,(function(t){var e=n.rewriteSrcset(t,this);return o?o.call(this,e):n.wb_setAttribute?n.wb_setAttribute.call(this,r,e):void 0}),(function(){var t;return i?t=i.call(this):n.wb_getAttribute&&(t=n.wb_getAttribute.call(this,r)),t=n.extractOriginalURL(t)}))},f.prototype.overrideHrefAttr=function(t,e){var r=this.getOrigGetter(t,"href"),i=this.getOrigSetter(t,"href"),o=this;this.defProp(t,"href",(function(t){var r;return r="cs_"===e&&0===t.indexOf("data:text/css")?o.rewriteInlineStyle(t):"LINK"===this.tagName?o.rewriteUrl(t,!1,o.rwModForElement(this,"href")):o.rewriteUrl(t,!1,e,this.ownerDocument),i?i.call(this,r):o.wb_setAttribute?o.wb_setAttribute.call(this,"href",r):void 0}),(function(){var t;return r?t=r.call(this):o.wb_getAttribute&&(t=o.wb_getAttribute.call(this,"href")),this._no_rewrite?t:o.extractOriginalURL(t)}))},f.prototype.overrideTextProtoGetSet=function(t,e){var r,i=this.getOrigGetter(t,e),o=this;if("data"===e){var n=this.getOrigSetter(t,e);r=function(t){var e=t;return!this._no_rewrite&&this.parentElement&&"STYLE"===this.parentElement.tagName&&(e=o.rewriteStyle(t)),n.call(this,e)}}this.defProp(t,e,r,(function(){var t=i.call(this);return!this._no_rewrite&&this.parentElement&&"STYLE"===this.parentElement.tagName?t.replace(o.wb_unrewrite_rx,""):t}))},f.prototype.overrideAnUIEvent=function(t){var e="__wb_"+t+"_overridden",r=this.$wbwindow[t];if(r&&r.prototype&&!r.prototype[e]){var i=this;this.overridePropToProxy(r.prototype,"view");var o,n="init"+t;if(r.prototype[n]){var s=r.prototype[n];r.prototype[n]=function(){var t=i.proxyToObj(this);if(0===arguments.length||arguments.length<3)return s.__WB_orig_apply?s.__WB_orig_apply(t,arguments):s.apply(t,arguments);for(var e=new Array(arguments.length),r=0;r<arguments.length;r++)e[r]=3===r?i.proxyToObj(arguments[r]):arguments[r];return s.__WB_orig_apply?s.__WB_orig_apply(t,e):s.apply(t,e)}}this.$wbwindow[t]=(o=r,function(e,r){return i.domConstructorErrorChecker(this,t,arguments),r&&(null!=r.view&&(r.view=i.proxyToObj(r.view)),null!=r.relatedTarget&&(r.relatedTarget=i.proxyToObj(r.relatedTarget)),null!=r.target&&(r.target=i.proxyToObj(r.target))),new o(e,r)}),this.$wbwindow[t].prototype=r.prototype,Object.defineProperty(this.$wbwindow[t].prototype,"constructor",{value:this.$wbwindow[t]}),this.$wbwindow[t].prototype[e]=!0}},f.prototype.rewriteParentNodeFn=function(t,e,r){var i=this._no_rewrite?r:this.rewriteElementsInArguments(r),o=this.proxyToObj(t);return e.__WB_orig_apply?e.__WB_orig_apply(o,i):e.apply(o,i)},f.prototype.overrideParentNodeAppendPrepend=function(t){var e=this.rewriteParentNodeFn;if(t.prototype.append){var r=t.prototype.append;t.prototype.append=function(){return e(this,r,arguments)}}if(t.prototype.prepend){var i=t.prototype.prepend;t.prototype.prepend=function(){return e(this,i,arguments)}}},f.prototype.overrideShadowDom=function(){this.$wbwindow.ShadowRoot&&this.$wbwindow.ShadowRoot.prototype&&(this.overrideHtmlAssign(this.$wbwindow.ShadowRoot,"innerHTML",!0),this.overrideParentNodeAppendPrepend(this.$wbwindow.ShadowRoot))},f.prototype.overrideChildNodeInterface=function(t,e){if(t&&t.prototype){var r=e?this.rewriteTextNodeFn:this.rewriteChildNodeFn;if(t.prototype.before){var i=t.prototype.before;t.prototype.before=function(){return r(this,i,arguments)}}if(t.prototype.after){var o=t.prototype.after;t.prototype.after=function(){return r(this,o,arguments)}}if(t.prototype.replaceWith){var n=t.prototype.replaceWith;t.prototype.replaceWith=function(){return r(this,n,arguments)}}}},f.prototype.initTextNodeOverrides=function(){var t=this.$wbwindow.Text;if(t&&t.prototype){var e=t.prototype,r=this.rewriteTextNodeFn;if(e.appendData){var i=e.appendData;e.appendData=function(){return r(this,i,arguments)}}if(e.insertData){var o=e.insertData;e.insertData=function(){return r(this,o,arguments)}}if(e.replaceData){var n=e.replaceData;e.replaceData=function(){return r(this,n,arguments)}}this.overrideChildNodeInterface(t,!0),this.overrideTextProtoGetSet(e,"data"),this.overrideTextProtoGetSet(e,"wholeText")}},f.prototype.initAttrOverrides=function(){this.overrideHrefAttr(this.$wbwindow.HTMLLinkElement.prototype,"cs_"),this.overrideHrefAttr(this.$wbwindow.CSSStyleSheet.prototype,"cs_"),this.overrideHrefAttr(this.$wbwindow.HTMLBaseElement.prototype,"mp_"),this.overrideSrcsetAttr(this.$wbwindow.HTMLImageElement.prototype,"im_"),this.overrideSrcsetAttr(this.$wbwindow.HTMLSourceElement.prototype,"oe_"),this.overrideAttr(this.$wbwindow.HTMLVideoElement.prototype,"poster","im_"),this.overrideAttr(this.$wbwindow.HTMLAudioElement.prototype,"poster","im_"),this.overrideAttr(this.$wbwindow.HTMLImageElement.prototype,"src","im_"),this.overrideAttr(this.$wbwindow.HTMLInputElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLEmbedElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLMediaElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLVideoElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLAudioElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLSourceElement.prototype,"src","oe_"),window.HTMLTrackElement&&window.HTMLTrackElement.prototype&&this.overrideAttr(this.$wbwindow.HTMLTrackElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLIFrameElement.prototype,"src","if_"),this.$wbwindow.HTMLFrameElement&&this.$wbwindow.HTMLFrameElement.prototype&&this.overrideAttr(this.$wbwindow.HTMLFrameElement.prototype,"src","fr_"),this.overrideAttr(this.$wbwindow.HTMLScriptElement.prototype,"src","js_"),this.overrideAttr(this.$wbwindow.HTMLObjectElement.prototype,"data","oe_"),this.overrideAttr(this.$wbwindow.HTMLObjectElement.prototype,"codebase","oe_"),this.overrideAttr(this.$wbwindow.HTMLMetaElement.prototype,"content","mp_"),this.overrideAttr(this.$wbwindow.HTMLFormElement.prototype,"action","mp_"),this.overrideAttr(this.$wbwindow.HTMLQuoteElement.prototype,"cite","mp_"),this.overrideAttr(this.$wbwindow.HTMLModElement.prototype,"cite","mp_"),this.overrideAnchorAreaElem(this.$wbwindow.HTMLAnchorElement),this.overrideAnchorAreaElem(this.$wbwindow.HTMLAreaElement);var t=this.$wbwindow.CSSStyleDeclaration.prototype,e={background:"background",backgroundImage:"background-image",cursor:"cursor",listStyle:"list-style",listStyleImage:"list-style-image",border:"border",borderImage:"border-image",borderImageSource:"border-image-source",maskImage:"mask-image"};for(var[r,i]of(this.overrideStyleProxy(Object.values(e)),this.$wbwindow.CSS2Properties&&(t=this.$wbwindow.CSS2Properties.prototype),this.overrideStyleAttr(t,"cssText"),Object.entries(e)))this.overrideStyleAttr(t,r,i);if(this.overrideStyleSetProp(t),this.$wbwindow.CSSStyleSheet&&this.$wbwindow.CSSStyleSheet.prototype){var o=this,n=this.$wbwindow.CSSStyleSheet.prototype.insertRule;this.$wbwindow.CSSStyleSheet.prototype.insertRule=function(t,e){return n.call(this,o.rewriteStyle(t),e)}}this.$wbwindow.CSSRule&&this.$wbwindow.CSSRule.prototype&&this.overrideStyleAttr(this.$wbwindow.CSSRule.prototype,"cssText")},f.prototype.initCSSOMOverrides=function(){var t,r=this;if(this.$wbwindow.CSSStyleValue){var i=function(t,e){var i=t[e];t[e]=function(t,e){if(null==e)return i.call(this,t,e);var o=r.noExceptRewriteStyle(e);return i.call(this,t,o)}};this.$wbwindow.CSSStyleValue.parse&&this.$wbwindow.CSSStyleValue.parse.toString().indexOf("[native code]")>0&&i(this.$wbwindow.CSSStyleValue,"parse"),this.$wbwindow.CSSStyleValue.parseAll&&this.$wbwindow.CSSStyleValue.parseAll.toString().indexOf("[native code]")>0&&i(this.$wbwindow.CSSStyleValue,"parseAll")}if(this.$wbwindow.CSSKeywordValue&&this.$wbwindow.CSSKeywordValue.prototype){var o=this.$wbwindow.CSSKeywordValue;this.$wbwindow.CSSKeywordValue=(t=this.$wbwindow.CSSKeywordValue,function(e){return r.domConstructorErrorChecker(this,"CSSKeywordValue",arguments),new t(r.rewriteStyle(e))}),this.$wbwindow.CSSKeywordValue.prototype=o.prototype,Object.defineProperty(this.$wbwindow.CSSKeywordValue.prototype,"constructor",{value:this.$wbwindow.CSSKeywordValue}),e(this.$wbwindow.CSSKeywordValue,"CSSKeywordValue")}if(this.$wbwindow.StylePropertyMap&&this.$wbwindow.StylePropertyMap.prototype){var n=this.$wbwindow.StylePropertyMap.prototype.set;this.$wbwindow.StylePropertyMap.prototype.set=function(){if(arguments.length<=1)return n.__WB_orig_apply?n.__WB_orig_apply(this,arguments):n.apply(this,arguments);var t=new Array(arguments.length);t[0]=arguments[0];for(var e=1;e<arguments.length;e++)t[e]=r.noExceptRewriteStyle(arguments[e]);return n.__WB_orig_apply?n.__WB_orig_apply(this,t):n.apply(this,t)};var s=this.$wbwindow.StylePropertyMap.prototype.append;this.$wbwindow.StylePropertyMap.prototype.append=function(){if(arguments.length<=1)return n.__WB_orig_apply?s.__WB_orig_apply(this,arguments):s.apply(this,arguments);var t=new Array(arguments.length);t[0]=arguments[0];for(var e=1;e<arguments.length;e++)t[e]=r.noExceptRewriteStyle(arguments[e]);return s.__WB_orig_apply?s.__WB_orig_apply(this,t):s.apply(this,t)}}},f.prototype.initAudioOverride=function(){if(this.$wbwindow.Audio){var t,r=this.$wbwindow.Audio,i=this;this.$wbwindow.Audio=(t=this.$wbwindow.Audio,function(e){return i.domConstructorErrorChecker(this,"Audio"),new t(i.rewriteUrl(e,!0,"oe_"))}),this.$wbwindow.Audio.prototype=r.prototype,Object.defineProperty(this.$wbwindow.Audio.prototype,"constructor",{value:this.$wbwindow.Audio}),e(this.$wbwindow.Audio,"HTMLAudioElement")}},f.prototype.initBadPrefixes=function(t){this.BAD_PREFIXES=["http:"+t,"https:"+t,"http:/"+t,"https:/"+t]},f.prototype.initCryptoRandom=function(){if(this.$wbwindow.crypto&&this.$wbwindow.Crypto){var t=this,e=function(e){for(var r=0;r<e.length;r++)e[r]=parseInt(4294967296*t.$wbwindow.Math.random());return e};this.$wbwindow.Crypto.prototype.getRandomValues=e,this.$wbwindow.crypto.getRandomValues=e}},f.prototype.initDateOverride=function(t){if(!this.$wbwindow.__wb_Date_now){var e,r=1e3*parseInt(t),i=this.$wbwindow.Date.now()-(r-0),o=this.$wbwindow.Date,n=this.$wbwindow.Date.UTC,s=this.$wbwindow.Date.parse,a=this.$wbwindow.Date.now;this.$wbwindow.__wb_Date_now=a,this.$wbwindow.Date=(e=this.$wbwindow.Date,function(t,r,o,n,s,h,w){return void 0===t?new e(a()-i):void 0===r?new e(t):void 0===o?new e(t,r):void 0===n?new e(t,r,o):void 0===s?new e(t,r,o,n):void 0===h?new e(t,r,o,n,s):void 0===w?new e(t,r,o,n,s,h):new e(t,r,o,n,s,h,w)}),this.$wbwindow.Date.prototype=o.prototype,this.$wbwindow.Date.now=function(){return a()-i},this.$wbwindow.Date.UTC=n,this.$wbwindow.Date.parse=s,this.$wbwindow.Date.__WB_timediff=i,this.$wbwindow.Date.prototype.getTimezoneOffset=function(){return 0};var h=this.$wbwindow.Date.prototype.toString;this.$wbwindow.Date.prototype.toString=function(){return h.call(this).split(" GMT")[0]+" GMT+0000 (Coordinated Universal Time)"};var w=this.$wbwindow.Date.prototype.toTimeString;this.$wbwindow.Date.prototype.toTimeString=function(){return w.call(this).split(" GMT")[0]+" GMT+0000 (Coordinated Universal Time)"},Object.defineProperty(this.$wbwindow.Date.prototype,"constructor",{value:this.$wbwindow.Date})}},f.prototype.initBlobOverride=function(){if(this.$wbwindow.Blob&&!this.wb_info.isSW){var t,e=this.$wbwindow.Blob,r=this;this.$wbwindow.Blob=(t=this.$wbwindow.Blob,function(e,i){return!i||"application/xhtml+xml"!==i.type&&"text/html"!==i.type||1===e.length&&"string"==typeof e[0]&&r.startsWith(e[0],"<!DOCTYPE html>")&&(e[0]=r.rewriteHtml(e[0]),i.type="text/html"),new t(e,i)}),this.$wbwindow.Blob.prototype=e.prototype}},f.prototype.initWSOverride=function(){this.$wbwindow.WebSocket&&this.$wbwindow.WebSocket.prototype&&(this.$wbwindow.WebSocket=function(t){function e(t,e){this.addEventListener=function(){},this.removeEventListener=function(){},this.close=function(){},this.send=function(t){console.log("ws send",t)},this.protocol=e&&e.length?e[0]:"",this.url=t,this.readyState=0}return e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}(this.$wbwindow.WebSocket),Object.defineProperty(this.$wbwindow.WebSocket.prototype,"constructor",{value:this.$wbwindow.WebSocket}),e(this.$wbwindow.WebSocket,"WebSocket"))},f.prototype.initDocTitleOverride=function(){var t=this.getOrigGetter(this.$wbwindow.document,"title"),e=this.getOrigSetter(this.$wbwindow.document,"title"),r=this;this.defProp(this.$wbwindow.document,"title",(function(t){var i=e.call(this,t),o={wb_type:"title",title:t};return r.sendTopMessage(o),i}),t)},f.prototype.initFontFaceOverride=function(){if(this.$wbwindow.FontFace){var t,r=this,i=this.$wbwindow.FontFace;this.$wbwindow.FontFace=(t=this.$wbwindow.FontFace,function(e,i,o){r.domConstructorErrorChecker(this,"FontFace",arguments,2);var n=i;return null!=i&&(n="string"!=typeof i?r.rewriteInlineStyle(i.toString()):r.rewriteInlineStyle(i)),new t(e,n,o)}),this.$wbwindow.FontFace.prototype=i.prototype,Object.defineProperty(this.$wbwindow.FontFace.prototype,"constructor",{value:this.$wbwindow.FontFace}),e(this.$wbwindow.FontFace,"FontFace")}},f.prototype.initFixedRatio=function(t){try{this.$wbwindow.devicePixelRatio=t}catch(t){}if(Object.defineProperty)try{Object.defineProperty(this.$wbwindow,"devicePixelRatio",{value:t,writable:!1})}catch(t){}},f.prototype.initPaths=function(t){t.wombat_opts=t.wombat_opts||{},Object.assign(this.wb_info,t),this.wb_opts=t.wombat_opts,this.wb_replay_prefix=t.prefix,this.wb_is_proxy=t.proxy_magic||!this.wb_replay_prefix,this.wb_info.top_host=this.wb_info.top_host||"*",this.wb_curr_host=this.$wbwindow.location.protocol+"//"+this.$wbwindow.location.host,this.wb_info.wombat_opts=this.wb_info.wombat_opts||{},this.wb_orig_scheme=t.wombat_scheme+"://",this.wb_orig_origin=this.wb_orig_scheme+t.wombat_host,this.wb_abs_prefix=this.wb_replay_prefix,!t.is_live&&t.wombat_ts?this.wb_capture_date_part="/"+t.wombat_ts+"/":this.wb_capture_date_part="",this.initBadPrefixes(this.wb_replay_prefix),this.initCookiePreset()},f.prototype.initSeededRandom=function(t){this.$wbwindow.Math.seed=parseInt(t);var e=this;this.$wbwindow.Math.random=function(){return e.$wbwindow.Math.seed=(9301*e.$wbwindow.Math.seed+49297)%233280,e.$wbwindow.Math.seed/233280}},f.prototype.initHistoryOverrides=function(){this.overrideHistoryFunc("pushState"),this.overrideHistoryFunc("replaceState");var t=this;this.$wbwindow.addEventListener("popstate",(function(e){t.sendHistoryUpdate(t.$wbwindow.WB_wombat_location.href,t.$wbwindow.document.title)}))},f.prototype.initCookiePreset=function(){if(this.wb_info.presetCookie)for(var t=this.wb_info.presetCookie.split(";"),e=0;e<t.length;e++)this.$wbwindow.document.cookie=t[e].trim()+"; Path="+this.rewriteUrl("./",!0)},f.prototype.initHTTPOverrides=function(){var t,r,i=this;if(this.overridePropExtract(this.$wbwindow.XMLHttpRequest.prototype,"responseURL"),this.wb_info.isSW){var o=this.$wbwindow.XMLHttpRequest.prototype.open,n=this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader,s=this.$wbwindow.XMLHttpRequest.prototype.send;this.utilFns.XHRopen=o,this.utilFns.XHRsend=s,this.$wbwindow.XMLHttpRequest.prototype.open=function(){this.__WB_xhr_open_arguments=arguments,this.__WB_xhr_headers=new Headers},this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader=function(t,e){this.__WB_xhr_headers.set(t,e)};i=this;var a=!!this.wb_info.convert_post_to_get;this.$wbwindow.XMLHttpRequest.prototype.send=async function(t){if(a&&("POST"===this.__WB_xhr_open_arguments[0]||"PUT"===this.__WB_xhr_open_arguments[0])){var e={url:this.__WB_xhr_open_arguments[1],method:this.__WB_xhr_open_arguments[0],headers:this.__WB_xhr_headers,postData:t};_(e)&&(this.__WB_xhr_open_arguments[1]=e.url,this.__WB_xhr_open_arguments[0]="GET",t=null)}if(this.__WB_xhr_open_arguments.length>2&&!this.__WB_xhr_open_arguments[2]&&-1===navigator.userAgent.indexOf("Firefox")&&(this.__WB_xhr_open_arguments[2]=!0,console.warn("wombat.js: Sync XHR not supported in SW-based replay in this browser, converted to async")),this._no_rewrite||(this.__WB_xhr_open_arguments[1]=i.rewriteUrl(this.__WB_xhr_open_arguments[1])),o.apply(this,this.__WB_xhr_open_arguments),!i.startsWith(this.__WB_xhr_open_arguments[1],"data:")){for(const[t,e]of this.__WB_xhr_headers.entries())n.call(this,t,e);n.call(this,"X-Pywb-Requested-With","XMLHttpRequest")}return s.call(this,t)}}else if(this.$wbwindow.XMLHttpRequest.prototype.open){var h=this.$wbwindow.XMLHttpRequest.prototype.open;this.utilFns.XHRopen=h,this.utilFns.XHRsend=this.$wbwindow.XMLHttpRequest.prototype.send,this.$wbwindow.XMLHttpRequest.prototype.open=function(t,e,r,o,n){var s=this._no_rewrite?e:i.rewriteUrl(e),a=!0;null==r||r||(a=!1),h.call(this,t,s,a,o,n),i.startsWith(s,"data:")||this.setRequestHeader("X-Pywb-Requested-With","XMLHttpRequest")}}if(this.$wbwindow.fetch){var w=this.$wbwindow.fetch;this.$wbwindow.fetch=function(t,e){var r=t,o=typeof t;if("string"===o)r=i.rewriteUrl(t);else if("object"===o&&t.url){var n=i.rewriteUrl(t.url);n!==t.url&&(r=new Request(n,e))}else"object"===o&&t.href&&(r=i.rewriteUrl(t.href));if(e||(e={}),void 0===e.credentials)try{e.credentials="include"}catch(t){}return w.call(i.proxyToObj(this),r,e)}}if(this.$wbwindow.Request&&this.$wbwindow.Request.prototype){var p=this.$wbwindow.Request;this.$wbwindow.Request=(t=this.$wbwindow.Request,function(e,r){i.domConstructorErrorChecker(this,"Request",arguments);var o=r||{},n=e,s=typeof e;switch(s){case"string":n=i.rewriteUrl(e);break;case"object":if(n=e,e.url){var a=i.rewriteUrl(e.url);a!==e.url&&(n=new t(a,e))}else e.href&&(n=i.rewriteUrl(e.toString(),!0))}return o.credentials="include",o.referrer&&(o.referrer=i.rewriteUrl(o.referrer)),new t(n,o)}),this.$wbwindow.Request.prototype=p.prototype,Object.defineProperty(this.$wbwindow.Request.prototype,"constructor",{value:this.$wbwindow.Request}),this.overridePropExtract(this.$wbwindow.Request.prototype,"url"),this.overridePropExtract(this.$wbwindow.Request.prototype,"referrer")}if(this.$wbwindow.Response&&this.$wbwindow.Response.prototype){var c=this.$wbwindow.Response.prototype.redirect;this.$wbwindow.Response.prototype.redirect=function(t,e){var r=i.rewriteUrl(t,!0,null,i.$wbwindow.document);return c.call(this,r,e)},this.overridePropExtract(this.$wbwindow.Response.prototype,"url")}if(this.$wbwindow.EventSource&&this.$wbwindow.EventSource.prototype){var l=this.$wbwindow.EventSource;this.$wbwindow.EventSource=(r=this.$wbwindow.EventSource,function(t,e){i.domConstructorErrorChecker(this,"EventSource",arguments);var o=t;return null!=t&&(o=i.rewriteUrl(t)),new r(o,e)}),this.$wbwindow.EventSource.prototype=l.prototype,Object.defineProperty(this.$wbwindow.EventSource.prototype,"constructor",{value:this.$wbwindow.EventSource}),e(this.$wbwindow.EventSource,"EventSource")}},f.prototype.initElementGetSetAttributeOverride=function(){if(!this.wb_opts.skip_setAttribute&&this.$wbwindow.Element&&this.$wbwindow.Element.prototype){var t=this,e=this.$wbwindow.Element.prototype;if(e.setAttribute){var r=e.setAttribute;e._orig_setAttribute=r,e.setAttribute=function(e,i){var o=i;if(e&&"string"==typeof o){var n=e.toLowerCase();if("LINK"===this.tagName&&"href"===n&&0===o.indexOf("data:text/css"))o=t.rewriteInlineStyle(i);else if("style"===n)o=t.rewriteStyle(i);else if("srcset"===n||"imagesrcset"===n&&"LINK"===this.tagName)o=t.rewriteSrcset(i,this);else{t.shouldRewriteAttr(this.tagName,n)&&(t.removeWBOSRC(this),this._no_rewrite||(o=t.rewriteUrl(i,!1,t.rwModForElement(this,n))))}}return r.call(this,e,o)}}if(e.getAttribute){var i=e.getAttribute;this.wb_getAttribute=i,e.getAttribute=function(e){var r=i.call(this,e);if(null===r)return r;var o=e;if(e&&(o=e.toLowerCase()),t.shouldRewriteAttr(this.tagName,o)){var n=t.retrieveWBOSRC(this);return n||t.extractOriginalURL(r)}return t.startsWith(o,"data-")&&t.startsWithOneOf(r,t.wb_prefixes)?t.extractOriginalURL(r):r}}}},f.prototype.initSvgImageOverrides=function(){if(this.$wbwindow.SVGImageElement){var t=this.$wbwindow.SVGImageElement.prototype,e=t.getAttribute,r=t.getAttributeNS,i=t.setAttribute,o=t.setAttributeNS,n=this;t.getAttribute=function(t){var r=e.call(this,t);return t.indexOf("xlink:href")>=0||"href"===t?n.extractOriginalURL(r):r},t.getAttributeNS=function(t,e){var i=r.call(this,t,e);return e.indexOf("xlink:href")>=0||"href"===e?n.extractOriginalURL(i):i},t.setAttribute=function(t,e){var r=e;return(t.indexOf("xlink:href")>=0||"href"===t)&&(r=n.rewriteUrl(e)),i.call(this,t,r)},t.setAttributeNS=function(t,e,r){var i=r;return(e.indexOf("xlink:href")>=0||"href"===e)&&(i=n.rewriteUrl(r)),o.call(this,t,e,i)}}},f.prototype.initCreateElementNSFix=function(){if(this.$wbwindow.document.createElementNS&&this.$wbwindow.Document.prototype.createElementNS){var t=this.$wbwindow.document.createElementNS,e=this,r=function(r,i){return t.call(e.proxyToObj(this),e.extractOriginalURL(r),i)};this.$wbwindow.Document.prototype.createElementNS=r,this.$wbwindow.document.createElementNS=r}},f.prototype.initInsertAdjacentElementHTMLOverrides=function(){var t=this.$wbwindow.Element;if(t&&t.prototype){var e=t.prototype,r=this.rewriteInsertAdjHTMLOrElemArgs;if(e.insertAdjacentHTML){var i=e.insertAdjacentHTML;e.insertAdjacentHTML=function(t,e){return r(this,i,t,e,!0)}}if(e.insertAdjacentElement){var o=e.insertAdjacentElement;e.insertAdjacentElement=function(t,e){return r(this,o,t,e,!1)}}}},f.prototype.initDomOverride=function(){var t=this.$wbwindow.Node;if(t&&t.prototype){var e=this.rewriteNodeFuncArgs;if(t.prototype.appendChild){var r=t.prototype.appendChild;t.prototype.appendChild=function(t,i){return e(this,r,t,i)}}if(t.prototype.insertBefore){var i=t.prototype.insertBefore;t.prototype.insertBefore=function(t,r){return e(this,i,t,r)}}if(t.prototype.replaceChild){var o=t.prototype.replaceChild;t.prototype.replaceChild=function(t,r){return e(this,o,t,r)}}this.overridePropToProxy(t.prototype,"ownerDocument"),this.overridePropToProxy(this.$wbwindow.HTMLHtmlElement.prototype,"parentNode"),this.overridePropToProxy(this.$wbwindow.Event.prototype,"target")}this.$wbwindow.Element&&this.$wbwindow.Element.prototype&&(this.overrideParentNodeAppendPrepend(this.$wbwindow.Element),this.overrideChildNodeInterface(this.$wbwindow.Element,!1)),this.$wbwindow.DocumentFragment&&this.$wbwindow.DocumentFragment.prototype&&this.overrideParentNodeAppendPrepend(this.$wbwindow.DocumentFragment)},f.prototype.initDocOverrides=function(t){if(Object.defineProperty){this.overrideReferrer(t),this.defGetterProp(t,"origin",(function(){return this.WB_wombat_location.origin})),this.defGetterProp(this.$wbwindow,"origin",(function(){return this.WB_wombat_location.origin}));var e=this;this.defProp(t,"domain",(function(t){var r=this.WB_wombat_location;r&&e.endsWith(r.hostname,t)&&(this.__wb_domain=t)}),(function(){return this.__wb_domain||this.WB_wombat_location.hostname}))}},f.prototype.initDocWriteOpenCloseOverride=function(){if(this.$wbwindow.DOMParser){var t=this.$wbwindow.Document.prototype,e=this.$wbwindow.document;this._writeBuff="";var r=this,i=e.write,o=function(){return d(this,i,u(arguments))};e.write=o,t.write=o;var n=e.writeln,s=function(){return d(this,n,u(arguments))};e.writeln=s,t.writeln=s;var a=e.open,h=function(){var t,e=r.proxyToObj(this);if(3===arguments.length){var i=r.rewriteUrl(arguments[0],!1,"mp_");t=a.call(e,i,arguments[1],arguments[2]),r.initNewWindowWombat(t,arguments[0])}else t=a.call(e),_()?r._writeBuff="":r.initNewWindowWombat(e.defaultView);return t};e.open=h,t.open=h;var w=e.close,p=function(){if(r._writeBuff)return r.blobUrlForIframe(r.$wbwindow.frameElement,r._writeBuff),void(r._writeBuff="");var t=r.proxyToObj(this);return r.initNewWindowWombat(t.defaultView),w.__WB_orig_apply?w.__WB_orig_apply(t,arguments):w.apply(t,arguments)};e.close=p,t.close=p;var c=this.getOrigGetter(t,"body"),l=this.getOrigSetter(t,"body");c&&l&&this.defProp(t,"body",(function(t){return t&&(t instanceof HTMLBodyElement||t instanceof HTMLFrameSetElement)&&r.rewriteElemComplete(t),l.call(r.proxyToObj(this),t)}),c)}function _(){return r.wb_info.isSW&&r.$wbwindow.frameElement}function u(t){return 0===t.length?"":1===t.length?t[0]:Array.prototype.join.call(t,"")}function d(t,e,i){r.$wbwindow;if(!_()){i=r.rewriteHtml(i,!0);var o=r.proxyToObj(t),n=e.call(o,i);return r.initNewWindowWombat(o.defaultView),n}r._writeBuff+=i}},f.prototype.initIframeWombat=function(t){var e;e=t._get_contentWindow?t._get_contentWindow.call(t):t.contentWindow;try{if(!e||e===this.$wbwindow||e._skip_wombat||e._wb_wombat)return}catch(t){return}var r=t.src;this.initNewWindowWombat(e,r)},f.prototype.initNewWindowWombat=function(t,e){var r=!1;if(t&&!t._wb_wombat){if(e&&""!==e&&!this.startsWithOneOf(e,["about:blank","javascript:"])||(r=!0),!r&&this.wb_info.isSW){var i=this.extractOriginalURL(e);("about:blank"===i||i.startsWith("srcdoc:")||i.startsWith("blob:"))&&(r=!0)}if(r){var o={};Object.assign(o,this.wb_info);var n=new f(t,o);t._wb_wombat=n.wombatInit()}else this.initProtoPmOrigin(t),this.initPostMessageOverride(t),this.initMessageEventOverride(t),this.initCheckThisFunc(t),this.initImportWrapperFunc(t)}},f.prototype.initTimeoutIntervalOverrides=function(){var t=this.rewriteSetTimeoutInterval;if(this.$wbwindow.setTimeout&&!this.$wbwindow.setTimeout.__$wbpatched$__){var e=this.$wbwindow.setTimeout;this.$wbwindow.setTimeout=function(){return t(this,e,arguments)},this.$wbwindow.setTimeout.__$wbpatched$__=!0}if(this.$wbwindow.setInterval&&!this.$wbwindow.setInterval.__$wbpatched$__){var r=this.$wbwindow.setInterval;this.$wbwindow.setInterval=function(){return t(this,r,arguments)},this.$wbwindow.setInterval.__$wbpatched$__=!0}},f.prototype.initWorkerOverrides=function(){var t,e,r=this;if(this.$wbwindow.Worker&&!this.$wbwindow.Worker._wb_worker_overridden){var i=this.$wbwindow.Worker;this.$wbwindow.Worker=(t=i,function(e,i){return r.domConstructorErrorChecker(this,"Worker",arguments),new t(r.rewriteWorker(e),i)}),this.$wbwindow.Worker.prototype=i.prototype,Object.defineProperty(this.$wbwindow.Worker.prototype,"constructor",{value:this.$wbwindow.Worker}),this.$wbwindow.Worker._wb_worker_overridden=!0}if(this.$wbwindow.SharedWorker&&!this.$wbwindow.SharedWorker.__wb_sharedWorker_overridden){var o=this.$wbwindow.SharedWorker;this.$wbwindow.SharedWorker=(e=o,function(t,i){return r.domConstructorErrorChecker(this,"SharedWorker",arguments),new e(r.rewriteWorker(t),i)}),this.$wbwindow.SharedWorker.prototype=o.prototype,Object.defineProperty(this.$wbwindow.SharedWorker.prototype,"constructor",{value:this.$wbwindow.SharedWorker}),this.$wbwindow.SharedWorker.__wb_sharedWorker_overridden=!0}if(this.$wbwindow.ServiceWorkerContainer&&this.$wbwindow.ServiceWorkerContainer.prototype&&this.$wbwindow.ServiceWorkerContainer.prototype.register){var n=this.$wbwindow.ServiceWorkerContainer.prototype.register;this.$wbwindow.ServiceWorkerContainer.prototype.register=function(t,e){var i=new URL(t,r.$wbwindow.document.baseURI).href,o=r.getPageUnderModifier();return e&&e.scope?e.scope=r.rewriteUrl(e.scope,!1,o):e={scope:r.rewriteUrl("/",!1,o)},n.call(this,r.rewriteUrl(i,!1,"sw_"),e)}}if(this.$wbwindow.Worklet&&this.$wbwindow.Worklet.prototype&&this.$wbwindow.Worklet.prototype.addModule&&!this.$wbwindow.Worklet.__wb_workerlet_overridden){var s=this.$wbwindow.Worklet.prototype.addModule;this.$wbwindow.Worklet.prototype.addModule=function(t,e){var i=r.rewriteUrl(t,!1,"js_");return s.call(this,i,e)},this.$wbwindow.Worklet.__wb_workerlet_overridden=!0}},f.prototype.initLocOverride=function(t,e,r){if(Object.defineProperty)for(var i=0;i<this.URL_PROPS.length;i++){var o=this.URL_PROPS[i];this.defProp(t,o,this.makeSetLocProp(o,e,r),this.makeGetLocProp(o,r),!0)}},f.prototype.initWombatLoc=function(t){if(!(!t||t.WB_wombat_location&&t.document.WB_wombat_location)){var e=new h(t.location,this),r=this;if(Object.defineProperty){this.defProp(t.Object.prototype,"WB_wombat_location",(function(e){var i=this._WB_wombat_location||this.defaultView&&this.defaultView._WB_wombat_location;i&&(i.href=e),t.location=r.rewriteUrl(e)}),(function(){return this._WB_wombat_location||this.defaultView&&this.defaultView._WB_wombat_location||this.location})),this.initProtoPmOrigin(t),t._WB_wombat_location=e}else t.WB_wombat_location=e,setTimeout(this.checkAllLocations,500),setInterval(this.checkAllLocations,500)}},f.prototype.initProtoPmOrigin=function(t){if(!t.Object.prototype.__WB_pmw){var e=function(t){return this.__WB_source=t,this};try{t.Object.defineProperty(t.Object.prototype,"__WB_pmw",{get:function(){return e},set:function(){},configurable:!0,enumerable:!1})}catch(t){}t.__WB_check_loc=function(t,e){if(t instanceof Location||t instanceof h){if(e)for(var r=0;r<e.length;r++)if(t===e[r])return{};return this.WB_wombat_location}return{}}}},f.prototype.initCheckThisFunc=function(t){try{t.Object.prototype[this.WB_CHECK_THIS_FUNC]||t.Object.defineProperty(t.Object.prototype,this.WB_CHECK_THIS_FUNC,{configutable:!1,enumerable:!1,value:function(t){return t&&t._WB_wombat_obj_proxy?t._WB_wombat_obj_proxy:t}})}catch(t){}},f.prototype.initImportWrapperFunc=function(t){var e=this;t.____wb_rewrite_import__=function(t,r){return t&&(r=new URL(r,t).href),import(e.rewriteUrl(r,!1,"esm_"))}},f.prototype.overrideGetOwnPropertyNames=function(t){var e=t.Object.getOwnPropertyNames,r=[this.WB_CHECK_THIS_FUNC,"WB_wombat_location","__WB_pmw","WB_wombat_top","WB_wombat_eval","WB_wombat_runEval"];try{t.Object.defineProperty(t.Object,"getOwnPropertyNames",{value:function(t){for(var i=e(t),o=0;o<r.length;o++){var n=i.indexOf(r[o]);n>=0&&i.splice(n,1)}return i}})}catch(t){console.log(t)}},f.prototype.initHashChange=function(){if(this.$wbwindow.__WB_top_frame){var t=this;this.$wbwindow.addEventListener("message",(function(e){if(e.data&&e.data.from_top){var r=e.data.message;r.wb_type&&"outer_hashchange"===r.wb_type&&t.$wbwindow.location.hash!=r.hash&&(t.$wbwindow.location.hash=r.hash)}})),this.$wbwindow.addEventListener("hashchange",(function(){var e={wb_type:"hashchange",hash:t.$wbwindow.location.hash};t.sendTopMessage(e)}))}},f.prototype.initPostMessageOverride=function(t){if(t.postMessage&&!t.__orig_postMessage){var e=t.postMessage,r=this;t.__orig_postMessage=e;var i=function(i,o,n,s){var a,h,w=r.proxyToObj(this);if(w||((w=t).__WB_source=t),w.__WB_source&&w.__WB_source.WB_wombat_location){var p=w.__WB_source;if(a=p.WB_wombat_location.origin,w.__WB_win_id||(w.__WB_win_id={},w.__WB_counter=0),!p.__WB_id){var c=w.__WB_counter;p.__WB_id=c+p.WB_wombat_location.href,w.__WB_counter+=1}w.__WB_win_id[p.__WB_id]=p,h=p.__WB_id,w.__WB_source=void 0}else a=window.WB_wombat_location.origin;var l=o;l===w.location.origin&&(l=a);var _={from:a,to_origin:l,src_id:h,message:i,from_top:s};if("*"!==o){if("null"===w.location.origin||""===w.location.origin)return;o=w.location.origin}return e.call(w,_,o,n)};t.postMessage=i,t.Window.prototype.postMessage=i;var o=null,n=(o=t.EventTarget&&t.EventTarget.prototype?t.EventTarget.prototype:t).addEventListener;o.addEventListener=function(t,e,i){var o,s=r.proxyToObj(this);if("message"===t?o=r.message_listeners.add_or_get(e,(function(){return c(e,s,r)})):"storage"===t?r.storage_listeners.add_or_get(e,(function(){return p(e,s)})):o=e,o)return n.call(s,t,o,i)};var s=o.removeEventListener;o.removeEventListener=function(t,e,i){var o,n=r.proxyToObj(this);if("message"===t?o=r.message_listeners.remove(e):"storage"===t?r.storage_listeners.remove(e):o=e,o)return s.call(n,t,o,i)};var a=function(e,i){var o=r.getOrigSetter(t,e);r.defProp(t,e,(function(t){this["__orig_"+e]=t;var n=r.proxyToObj(this),s=t?i(t,n,r):t;return o.call(n,s)}),(function(){return this["__orig_"+e]}))};a("onmessage",c),a("onstorage",p)}},f.prototype.initMessageEventOverride=function(t){t.MessageEvent&&!t.MessageEvent.prototype.__extended&&(this.addEventOverride("target"),this.addEventOverride("srcElement"),this.addEventOverride("currentTarget"),this.addEventOverride("eventPhase"),this.addEventOverride("path"),this.overridePropToProxy(t.MessageEvent.prototype,"source"),t.MessageEvent.prototype.__extended=!0)},f.prototype.initUIEventsOverrides=function(){this.overrideAnUIEvent("UIEvent"),this.overrideAnUIEvent("MouseEvent"),this.overrideAnUIEvent("TouchEvent"),this.overrideAnUIEvent("FocusEvent"),this.overrideAnUIEvent("KeyboardEvent"),this.overrideAnUIEvent("WheelEvent"),this.overrideAnUIEvent("InputEvent"),this.overrideAnUIEvent("CompositionEvent")},f.prototype.initOpenOverride=function(){var t=this.$wbwindow.open;this.$wbwindow.Window.prototype.open&&(t=this.$wbwindow.Window.prototype.open);var e=this,r=function(r,i,o){i&&(i=e.rewriteAttrTarget(i));var n=e.rewriteUrl(r,!1),s=t.call(e.proxyToObj(this),n,i,o);return e.initNewWindowWombat(s,r),s};this.$wbwindow.open=r,this.$wbwindow.Window.prototype.open&&(this.$wbwindow.Window.prototype.open=r);for(var i=0;i<this.$wbwindow.frames.length;i++)try{this.$wbwindow.frames[i].open=r}catch(t){console.log(t)}},f.prototype.rewriteAttrTarget=function(t){return this.wb_info.target_frame&&("_blank"===t||"_parent"===t||"_top"===t||t&&this.$wbwindow===this.$wbwindow.__WB_replay_top)?this.wb_info.target_frame:t},f.prototype.initCookiesOverride=function(){var t=this.getOrigGetter(this.$wbwindow.document,"cookie"),e=this.getOrigSetter(this.$wbwindow.document,"cookie");t||(t=this.getOrigGetter(this.$wbwindow.Document.prototype,"cookie")),e||(e=this.getOrigSetter(this.$wbwindow.Document.prototype,"cookie"));var r=function(t,e){var r=new Date(e);return isNaN(r.getTime())?"Expires=Thu,| 01 Jan 1970 00:00:00 GMT":"Expires="+new Date(r.getTime()+Date.__WB_timediff).toUTCString().replace(",",",|")},i=this;this.defProp(this.$wbwindow.document,"cookie",(function(t){if(t){for(var o=t.replace(i.cookie_expires_regex,r).split(i.SetCookieRe),n=0;n<o.length;n++)o[n]=i.rewriteCookie(o[n]);return e.call(i.proxyToObj(this),o.join(","))}}),(function(){return t.call(i.proxyToObj(this))}))},f.prototype.initRegisterUnRegPHOverride=function(){var t=this,e=this.$wbwindow.navigator;if(e.registerProtocolHandler){var r=e.registerProtocolHandler;e.registerProtocolHandler=function(e,i,o){return r.call(this,e,t.rewriteUrl(i),o)}}if(e.unregisterProtocolHandler){var i=e.unregisterProtocolHandler;e.unregisterProtocolHandler=function(e,r){return i.call(this,e,t.rewriteUrl(r))}}},f.prototype.initBeaconOverride=function(){if(this.$wbwindow.navigator.sendBeacon){var t=this.$wbwindow.navigator.sendBeacon,e=this;this.$wbwindow.navigator.sendBeacon=function(r,i){try{return t.call(this,e.rewriteUrl(r),i)}catch(t){return!0}}}},f.prototype.initMiscNavigatorOverrides=function(){this.$wbwindow.navigator.mediaDevices&&(this.$wbwindow.navigator.mediaDevices.setCaptureHandleConfig=function(){})},f.prototype.initPresentationRequestOverride=function(){if(this.$wbwindow.PresentationRequest&&this.$wbwindow.PresentationRequest.prototype){var t=this,e=this.$wbwindow.PresentationRequest;this.$wbwindow.PresentationRequest=(r=this.$wbwindow.PresentationRequest,function(e){t.domConstructorErrorChecker(this,"PresentationRequest",arguments);var i=e;if(null!=e)if(Array.isArray(i))for(var o=0;o<i.length;o++)i[o]=t.rewriteUrl(i[o],!0,"mp_");else i=t.rewriteUrl(e,!0,"mp_");return new r(i)}),this.$wbwindow.PresentationRequest.prototype=e.prototype,Object.defineProperty(this.$wbwindow.PresentationRequest.prototype,"constructor",{value:this.$wbwindow.PresentationRequest})}var r},f.prototype.initDisableNotificationsGeoLocation=function(){window.Notification&&(window.Notification.requestPermission=function(t){return t&&t("denied"),Promise.resolve("denied")});var t=function(t){t&&(t.getCurrentPosition&&(t.getCurrentPosition=function(t,e,r){e&&e({code:2,message:"not available"})}),t.watchPosition&&(t.watchPosition=function(t,e,r){e&&e({code:2,message:"not available"})}))};window.geolocation&&t(window.geolocation),window.navigator.geolocation&&t(window.navigator.geolocation)},f.prototype.initStorageOverride=function(){this.addEventOverride("storageArea",this.$wbwindow.StorageEvent.prototype),i.yes=!1;var t={};if(this.wb_info.storage)try{t=JSON.parse(atob(this.wb_info.storage))}catch(t){console.warn("Error parsing storage, storages not loaded")}a(this,"localStorage",t.local),a(this,"sessionStorage",t.session),this.$wbwindow.Storage=s,i.yes=!0},f.prototype.initIndexedDBOverride=function(){if(this.$wbwindow.IDBFactory){var t=this.$wbwindow.IDBFactory.prototype,e="wb-"+this.wb_orig_origin+"-",r=t.open;t.open=function(t,i){return r.call(this,e+t,i)};var i=t.deleteDatabase;t.delete=function(t){return i.call(this,e+t,options)};var o=t.databases;t.databases=function(){var t=this;return new Promise((function(r,i){o.call(t).then((function(t){for(var i=[],o=0;o<t.length;o++)0===t[o].name.indexOf(e)&&i.push({name:t[o].name.substring(e.length),version:t[o].version});r(i)})).catch((function(t){i(t)}))}))}}},f.prototype.initCachesOverride=function(){if(this.$wbwindow.CacheStorage){this.$wbwindow.chrome&&(this.$wbwindow.chrome={});var t=this.$wbwindow.CacheStorage.prototype,e="wb-"+this.wb_orig_origin+"-",r=t.open;t.open=function(t){return r.call(this,e+t)};var i=t.has;t.has=function(t){return i.call(this,e+t)};var o=t.delete;t.delete=function(t){return o.call(this,e+t)};var n=t.keys;t.keys=function(){var t=this;return new Promise((function(r,i){n.call(t).then((function(t){for(var i=[],o=0;o<t.length;o++)0===t[o].indexOf(e)&&i.push(t[o].substring(e.length));r(i)})).catch((function(t){i(t)}))}))};t.match;t.match=function(t,e){var r=this;return this.keys().then((function(i){var o;return i.reduce((function(i,n){return i.then((function(){return o||r.open(n).then((function(r){return r.match(t,e)})).then((function(t){return o=t}))}))}),Promise.resolve())}))}}},f.prototype.initWindowObjProxy=function(t){if(t.Proxy){var e=this.getAllOwnProps(t),r={},i=this,o=new t.Proxy({},{get:function(o,n){switch(n){case"top":return i.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy;case"parent":if(i.$wbwindow===i.$wbwindow.WB_wombat_top)return i.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy;try{var s=i.$wbwindow.parent._WB_wombat_obj_proxy;if(s)return s}catch(t){}return i.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy}return i.defaultProxyGet(t,n,e,r)},set:function(e,r,i){switch(r){case"location":return t.WB_wombat_location=i,!0;case"postMessage":case"document":return!0}try{if(!Reflect.set(e,r,i))return!1}catch(t){}return Reflect.set(t,r,i)},has:function(e,r){return r in t},ownKeys:function(e){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))},getOwnPropertyDescriptor:function(e,r){var i=Object.getOwnPropertyDescriptor(e,r);return i||(i=Object.getOwnPropertyDescriptor(t,r))&&(i.configurable=!0),i},getPrototypeOf:function(e){return Object.getPrototypeOf(t)},setPrototypeOf:function(t,e){return!1},isExtensible:function(e){return Object.isExtensible(t)},preventExtensions:function(e){return Object.preventExtensions(t),!0},deleteProperty:function(e,r){var i=Object.getOwnPropertyDescriptor(t,r);return void 0===i||!1!==i.configurable&&(delete e[r],delete t[r],!0)},defineProperty:function(e,r,i){var o=i||{};return void 0===o.value&&void 0===o.get&&(o.value=t[r]),Reflect.defineProperty(t,r,o),Reflect.defineProperty(e,r,o)}});return t._WB_wombat_obj_proxy=o,o}},f.prototype.initDocumentObjProxy=function(t){if(this.initDocOverrides(t),this.$wbwindow.Proxy){var e={},r=this.getAllOwnProps(t),i=this,o=new this.$wbwindow.Proxy(t,{get:function(o,n){return i.defaultProxyGet(t,n,r,e)},set:function(e,r,i){return"location"===r?t.WB_wombat_location=i:e[r]=i,!0}});return t._WB_wombat_obj_proxy=o,o}},f.prototype.initAutoFetchWorker=function(){if(this.wbUseAFWorker){var t=new w(this,{isTop:this.$wbwindow===this.$wbwindow.__WB_replay_top,workerURL:(this.wb_info.auto_fetch_worker_prefix||this.wb_info.static_prefix)+"autoFetchWorker.js?init="+encodeURIComponent(JSON.stringify({mod:this.wb_info.mod,prefix:this.wb_abs_prefix,rwRe:this.wb_unrewrite_rx.source}))});this.WBAutoFetchWorker=t,this.$wbwindow.$WBAutoFetchWorker$=t;var e=this;this.utilFns.wbSheetMediaQChecker=function(){e._removeEventListener(this,"load",e.utilFns.wbSheetMediaQChecker),null!=this.sheet&&e.WBAutoFetchWorker&&e.WBAutoFetchWorker.deferredSheetExtraction(this.sheet)}}},f.prototype.initTopFrameNotify=function(t){var e=this,r=function(r){if(e.$wbwindow.__WB_top_frame){if(e.$wbwindow.WB_wombat_location){var i=e.$wbwindow.WB_wombat_location.href;if("string"==typeof i&&"about:blank"!==i&&0!==i.indexOf("javascript:")&&("complete"===e.$wbwindow.document.readyState&&e.wbUseAFWorker&&e.WBAutoFetchWorker&&e.WBAutoFetchWorker.extractFromLocalDoc(),e.$wbwindow===e.$wbwindow.__WB_replay_top)){for(var o=[],n=e.$wbwindow.document.querySelectorAll("link[rel*=\'icon\']"),s=0;s<n.length;s++){var a=n[s];o.push({rel:a.rel,href:e.wb_getAttribute.call(a,"href")})}o.push({rel:"icon",href:e.rewriteUrl("/favicon.ico")});var h={icons:o,url:e.$wbwindow.WB_wombat_location.href,ts:e.wb_info.timestamp,request_ts:e.wb_info.request_ts,is_live:e.wb_info.is_live,title:e.$wbwindow.document?e.$wbwindow.document.title:"",readyState:e.$wbwindow.document.readyState,wb_type:"load"};e.sendTopMessage(h)}}}else{var w=e.$wbwindow.location.hash;e.$wbwindow.location.replace(t.top_url+w)}};"complete"===this.$wbwindow.document.readyState?r():this.$wbwindow.addEventListener?this.$wbwindow.document.addEventListener("readystatechange",r):this.$wbwindow.attachEvent&&this.$wbwindow.document.attachEvent("onreadystatechange",r)},f.prototype.initTopFrame=function(t){if(this.wb_is_proxy)return t.__WB_replay_top=t.top,t.__WB_top_frame=void 0,this.replayTopHost=r.location.host,void(this.replayTopProtocol=r.location.protocol);for(var e=function(t){try{return!!t&&(t.wbinfo?t.wbinfo.is_framed:null!=t._wb_wombat)}catch(t){return!1}},r=t;r.parent!=r&&e(r.parent);)r=r.parent;t.__WB_replay_top=r,this.replayTopHost=r.location.host,this.replayTopProtocol=r.location.protocol;var i=r.parent;if(i!=t&&this.wb_info.is_framed||(i=void 0),i?(t.__WB_top_frame=i,this.initFrameElementOverride(t)):t.__WB_top_frame=void 0,!this.wb_opts.embedded&&r==t&&this.wbUseAFWorker){var o=this;this.$wbwindow.addEventListener("message",(function(t){t.data&&"aaworker"===t.data.wb_type&&o.WBAutoFetchWorker&&o.WBAutoFetchWorker.postMessage(t.data.msg)}),!1)}},f.prototype.initFrameElementOverride=function(t){if(Object.defineProperty&&this.proxyToObj(t.__WB_replay_top)==this.proxyToObj(t))try{Object.defineProperty(t,"frameElement",{value:null,configurable:!1})}catch(t){}},f.prototype.initWombatTop=function(t){if(Object.defineProperty){this.defProp(t.Object.prototype,"WB_wombat_top",(function(t){this.top=t}),(function(){return this.__WB_replay_top?this.__WB_replay_top:(t=this,(void 0===window.constructor?t instanceof window.constructor:t.window==t)?this:this.top);var t}))}},f.prototype.initEvalOverride=function(){var t=this.rewriteEvalArg,e=function(){};this.wrappedEval=function(e){return function(r){return t(e,r)}};var r=this,i=function(e){var r=this;return r&&r.eval&&r.eval!==eval?{eval:function(){return r.eval.__WB_orig_apply(r,arguments)}}:{eval:function(r){return t(e,r)}}},o=function(e){var i=this;return i&&i.eval&&i.eval!==eval?{eval:function(){return i.eval.__WB_orig_apply(i,[].slice.call(arguments,2))}}:{eval:function(i,o,n){var s=i===r.proxyToObj(r.$wbwindow);try{s=s&&!o.callee.caller}catch(t){s=!1}return t(e,n,s)}}};this.defProp(this.$wbwindow.Object.prototype,"WB_wombat_runEval",e,(function(){return i})),this.defProp(this.$wbwindow.Object.prototype,"WB_wombat_runEval2",e,(function(){return o}))},f.prototype.wombatInit=function(){this._internalInit(),this.initCookiePreset(),this.initHistoryOverrides(),this.overrideFunctionApply(this.$wbwindow),this.overrideFunctionBind(this.$wbwindow),this.initDocTitleOverride(),this.initHashChange(),this.wb_opts.skip_postmessage||(this.initPostMessageOverride(this.$wbwindow),this.initMessageEventOverride(this.$wbwindow)),this.initCheckThisFunc(this.$wbwindow),this.initImportWrapperFunc(this.$wbwindow),this.overrideGetOwnPropertyNames(this.$wbwindow),this.initUIEventsOverrides(),this.initDocWriteOpenCloseOverride(),this.initEvalOverride(),this.initHTTPOverrides(),this.initAudioOverride(),this.initFontFaceOverride(this.$wbwindow),this.initWorkerOverrides(),this.initTextNodeOverrides(),this.initCSSOMOverrides(),this.overrideHtmlAssign(this.$wbwindow.Element,"innerHTML",!0),this.overrideHtmlAssign(this.$wbwindow.Element,"outerHTML",!0),this.overrideHtmlAssignSrcDoc(this.$wbwindow.HTMLIFrameElement,"srcdoc",!0),this.overrideHtmlAssign(this.$wbwindow.HTMLStyleElement,"textContent"),this.overrideShadowDom(),this.overridePropExtract(this.$wbwindow.Document.prototype,"URL"),this.overridePropExtract(this.$wbwindow.Document.prototype,"documentURI"),this.overridePropExtract(this.$wbwindow.Node.prototype,"baseURI"),this.overrideAttrProps(),this.overrideDataSet(),this.initInsertAdjacentElementHTMLOverrides(),this.overrideIframeContentAccess("contentWindow"),this.overrideIframeContentAccess("contentDocument"),this.overrideFuncArgProxyToObj(this.$wbwindow.MutationObserver,"observe"),this.overrideFuncArgProxyToObj(this.$wbwindow.Node,"compareDocumentPosition"),this.overrideFuncArgProxyToObj(this.$wbwindow.Node,"contains"),this.overrideFuncArgProxyToObj(this.$wbwindow.Document,"createTreeWalker"),this.overrideFuncArgProxyToObj(this.$wbwindow.Document,"evaluate",1),this.overrideFuncArgProxyToObj(this.$wbwindow.XSLTProcessor,"transformToFragment",1),this.overrideFuncThisProxyToObj(this.$wbwindow,"getComputedStyle",this.$wbwindow),this.overrideFuncThisProxyToObj(this.$wbwindow,"clearTimeout"),this.overrideFuncThisProxyToObj(this.$wbwindow,"clearInterval"),this.overrideFuncThisProxyToObj(this.$wbwindow.EventTarget.prototype,"dispatchEvent"),this.initTimeoutIntervalOverrides(),this.overrideFramesAccess(this.$wbwindow),this.overrideSWAccess(this.$wbwindow),this.initElementGetSetAttributeOverride(),this.initSvgImageOverrides(),this.initAttrOverrides(),this.initCookiesOverride(),this.initCreateElementNSFix(),this.wb_opts.skip_dom||this.initDomOverride(),this.initRegisterUnRegPHOverride(),this.initPresentationRequestOverride(),this.initBeaconOverride(),this.initMiscNavigatorOverrides(),this.initSeededRandom(this.wb_info.wombat_sec),this.initCryptoRandom(),this.initFixedRatio(this.wb_info.pixel_ratio||1),this.initDateOverride(this.wb_info.wombat_sec),this.initBlobOverride(),this.initWSOverride(),this.initOpenOverride(),this.initDisableNotificationsGeoLocation(),this.initStorageOverride(),this.initCachesOverride(),this.initIndexedDBOverride(),this.initWindowObjProxy(this.$wbwindow),this.initDocumentObjProxy(this.$wbwindow.document);var t=this;return{extract_orig:this.extractOriginalURL,rewrite_url:this.rewriteUrl,watch_elem:this.watchElem,init_new_window_wombat:this.initNewWindowWombat,init_paths:this.initPaths,local_init:function(e){var r=t.$wbwindow._WB_wombat_obj_proxy[e];return"document"===e&&r&&!r._WB_wombat_obj_proxy&&t.initDocumentObjProxy(r)||r},showCSPViolations:function(e){t._addRemoveCSPViolationListener(e)}}};const b=f;window._WBWombat=b,window._WBWombatInit=function(t){if(this._wb_wombat)this._wb_wombat.init_paths(t);else{var e=new b(this,t);this._wb_wombat=e.wombatInit()}}})();'}),this.staticData.set(this.staticPrefix+"wombatWorkers.js",{type:"application/javascript",content:"/**\n * Mini wombat for performing URL rewriting within the\n * Web/Shared/Service Worker context\n * @param {Object} info\n * @return {WBWombat}\n */\nfunction WBWombat(info) {\n if (!(this instanceof WBWombat)) return new WBWombat(info);\n /** @type {Object} */\n this.info = info;\n this.initImportScriptsRewrite();\n this.initHTTPOverrides();\n this.initClientApisOverride();\n this.initCacheApisOverride();\n}\n\n/**\n * Returns T/F indicating if the supplied URL is not to be rewritten\n * @param {string} url\n * @return {boolean}\n */\nWBWombat.prototype.noRewrite = function(url) {\n return (\n !url ||\n url.indexOf('blob:') === 0 ||\n url.indexOf('javascript:') === 0 ||\n url.indexOf('data:') === 0 ||\n url.indexOf(this.info.prefix) === 0\n );\n};\n\n/**\n * Returns T/F indicating if the supplied URL is an relative URL\n * @param {string} url\n * @return {boolean}\n */\nWBWombat.prototype.isRelURL = function(url) {\n return url.indexOf('/') === 0 || url.indexOf('http:') !== 0;\n};\n\n/**\n * Attempts to resolve the supplied relative URL against\n * the origin this worker was created on\n * @param {string} maybeRelURL\n * @param {string} against\n * @return {string}\n */\nWBWombat.prototype.maybeResolveURL = function(maybeRelURL, against) {\n if (!against) return maybeRelURL;\n try {\n var resolved = new URL(maybeRelURL, against);\n return resolved.href;\n } catch (e) {}\n return maybeRelURL;\n};\n\n/**\n * Returns null to indicate that the supplied URL is not to be rewritten.\n * Otherwise returns a URL that can be rewritten\n * @param {*} url\n * @param {string} resolveAgainst\n * @return {?string}\n */\nWBWombat.prototype.ensureURL = function(url, resolveAgainst) {\n if (!url) return url;\n var newURL;\n switch (typeof url) {\n case 'string':\n newURL = url;\n break;\n case 'object':\n newURL = url.toString();\n break;\n default:\n return null;\n }\n if (this.noRewrite(newURL)) return null;\n if (this.isRelURL(newURL)) {\n return this.maybeResolveURL(newURL, resolveAgainst);\n }\n\n // if url starts with current origin, but not properly rewritten, rewrite against current baseUr\n if (newURL.indexOf(self.location.origin) === 0) {\n return this.maybeResolveURL(newURL.slice(self.location.origin.length), resolveAgainst);\n }\n return newURL;\n};\n\n/**\n * Rewrites the supplied URL\n * @param {string} url\n * @return {string}\n */\nWBWombat.prototype.rewriteURL = function(url) {\n var rwURL = this.ensureURL(url, this.info.originalURL);\n if (!rwURL) return url;\n if (this.info.prefixMod) {\n return this.info.prefixMod + rwURL;\n }\n return rwURL;\n};\n\n/**\n * Rewrites the supplied URL of an controlled page using the mp\\_ modifier\n * @param {string} url\n * @param {WindowClient} [client]\n * @return {string}\n */\nWBWombat.prototype.rewriteClientWindowURL = function(url, client) {\n var rwURL = this.ensureURL(url, client ? client.url : this.info.originalURL);\n if (!rwURL) return url;\n if (this.info.prefix) {\n return this.info.prefix + 'mp_/' + rwURL;\n }\n return rwURL;\n};\n\n/**\n * Mini url rewriter specifically for rewriting web sockets\n * @param {?string} originalURL\n * @return {string}\n */\nWBWombat.prototype.rewriteWSURL = function(originalURL) {\n // If undefined, just return it\n if (!originalURL) return originalURL;\n\n var urltype_ = typeof originalURL;\n var url = originalURL;\n\n // If object, use toString\n if (urltype_ === 'object') {\n url = originalURL.toString();\n } else if (urltype_ !== 'string') {\n return originalURL;\n }\n\n // empty string check\n if (!url) return url;\n\n var wsScheme = 'ws://';\n var wssScheme = 'wss://';\n var https = 'https://';\n\n var wbSecure = this.info.prefix.indexOf(https) === 0;\n var wbPrefix =\n this.info.prefix.replace(\n wbSecure ? https : 'http://',\n wbSecure ? wssScheme : wsScheme\n ) + 'ws_/';\n return wbPrefix + url;\n};\n\n/**\n * Rewrites all URLs in the supplied arguments object\n * @param {Object} argsObj\n * @return {Array<string>}\n */\nWBWombat.prototype.rewriteArgs = function(argsObj) {\n // recreate the original arguments object just with URLs rewritten\n var newArgObj = new Array(argsObj.length);\n for (var i = 0; i < newArgObj.length; i++) {\n newArgObj[i] = this.rewriteURL(argsObj[i]);\n }\n return newArgObj;\n};\n\n/**\n * Rewrites the input to one of the Fetch APIs\n * @param {*|string|Request} input\n * @return {*|string|Request}\n */\nWBWombat.prototype.rewriteFetchApi = function(input) {\n var rwInput = input;\n switch (typeof input) {\n case 'string':\n rwInput = this.rewriteURL(input);\n break;\n case 'object':\n if (input.url) {\n var new_url = this.rewriteURL(input.url);\n if (new_url !== input.url) {\n // not much we can do here Request.url is read only\n // https://developer.mozilla.org/en-US/docs/Web/API/Request/url\n rwInput = new Request(new_url, input);\n }\n } else if (input.href) {\n // it is likely that input is either self.location or self.URL\n // we cant do anything here so just let it go\n rwInput = input.href;\n }\n break;\n }\n return rwInput;\n};\n\n/**\n * Rewrites the input to one of the Cache APIs\n * @param {*|string|Request} request\n * @return {*|string|Request}\n */\nWBWombat.prototype.rewriteCacheApi = function(request) {\n var rwRequest = request;\n if (typeof request === 'string') {\n rwRequest = this.rewriteURL(request);\n }\n return rwRequest;\n};\n\n/**\n * Applies an override to the importScripts function\n * @see https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts\n */\nWBWombat.prototype.initImportScriptsRewrite = function() {\n if (!self.importScripts) return;\n var wombat = this;\n var origImportScripts = self.importScripts;\n self.importScripts = function importScripts() {\n // rewrite the arguments object and call original function via fn.apply\n var rwArgs = wombat.rewriteArgs(arguments);\n return origImportScripts.apply(this, rwArgs);\n };\n};\n\n/**\n * Applies overrides to the XMLHttpRequest.open and XMLHttpRequest.responseURL\n * in order to ensure URLs are rewritten.\n *\n * Applies an override to window.fetch in order to rewrite URLs and URLs of\n * the supplied Request objects used as arguments to fetch.\n *\n * Applies overrides to window.Request, window.Response, window.EventSource,\n * and window.WebSocket in order to ensure URLs they operate on are rewritten.\n *\n * @see https://xhr.spec.whatwg.org/\n * @see https://fetch.spec.whatwg.org/\n * @see https://html.spec.whatwg.org/multipage/web-sockets.html#websocket\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface\n */\nWBWombat.prototype.initHTTPOverrides = function() {\n var wombat = this;\n if (\n self.XMLHttpRequest &&\n self.XMLHttpRequest.prototype &&\n self.XMLHttpRequest.prototype.open\n ) {\n var oXHROpen = self.XMLHttpRequest.prototype.open;\n self.XMLHttpRequest.prototype.open = function open(\n method,\n url,\n async,\n user,\n password\n ) {\n var rwURL = wombat.rewriteURL(url);\n var openAsync = true;\n if (async != null && !async) openAsync = false;\n oXHROpen.call(this, method, rwURL, openAsync, user, password);\n if (rwURL.indexOf('data:') === -1) {\n this.setRequestHeader('X-Pywb-Requested-With', 'XMLHttpRequest');\n }\n };\n }\n\n if (self.fetch != null) {\n // this fetch is Worker.fetch\n var orig_fetch = self.fetch;\n self.fetch = function fetch(input, init_opts) {\n var rwInput = wombat.rewriteFetchApi(input);\n var newInitOpts = init_opts || {};\n newInitOpts['credentials'] = 'include';\n return orig_fetch.call(this, rwInput, newInitOpts);\n };\n }\n\n if (self.Request && self.Request.prototype) {\n var orig_request = self.Request;\n self.Request = (function(Request_) {\n return function Request(input, init_opts) {\n var newInitOpts = init_opts || {};\n var newInput = wombat.rewriteFetchApi(input);\n newInitOpts['credentials'] = 'include';\n return new Request_(newInput, newInitOpts);\n };\n })(self.Request);\n self.Request.prototype = orig_request.prototype;\n }\n\n if (self.Response && self.Response.prototype) {\n var originalRedirect = self.Response.prototype.redirect;\n self.Response.prototype.redirect = function redirect(url, status) {\n var rwURL = wombat.rewriteUrl(url);\n return originalRedirect.call(this, rwURL, status);\n };\n }\n\n if (self.EventSource && self.EventSource.prototype) {\n var origEventSource = self.EventSource;\n self.EventSource = (function(EventSource_) {\n return function EventSource(url, configuration) {\n var rwURL = url;\n if (url != null) {\n rwURL = wombat.rewriteUrl(url);\n }\n return new EventSource_(rwURL, configuration);\n };\n })(self.EventSource);\n self.EventSource.prototype = origEventSource.prototype;\n Object.defineProperty(self.EventSource.prototype, 'constructor', {\n value: self.EventSource\n });\n }\n\n if (self.WebSocket && self.WebSocket.prototype) {\n var origWebSocket = self.WebSocket;\n self.WebSocket = (function(WebSocket_) {\n return function WebSocket(url, configuration) {\n var rwURL = url;\n if (url != null) {\n rwURL = wombat.rewriteWSURL(url);\n }\n return new WebSocket_(rwURL, configuration);\n };\n })(self.WebSocket);\n self.WebSocket.prototype = origWebSocket.prototype;\n Object.defineProperty(self.WebSocket.prototype, 'constructor', {\n value: self.WebSocket\n });\n }\n};\n\n/**\n * Applies an override to Clients.openWindow and WindowClient.navigate that rewrites\n * the supplied URL that represents a controlled window\n * @see https://w3c.github.io/ServiceWorker/#window-client-interface\n * @see https://w3c.github.io/ServiceWorker/#clients-interface\n */\nWBWombat.prototype.initClientApisOverride = function() {\n var wombat = this;\n if (\n self.Clients &&\n self.Clients.prototype &&\n self.Clients.prototype.openWindow\n ) {\n var oClientsOpenWindow = self.Clients.prototype.openWindow;\n self.Clients.prototype.openWindow = function openWindow(url) {\n var rwURL = wombat.rewriteClientWindowURL(url);\n return oClientsOpenWindow.call(this, rwURL);\n };\n }\n\n if (\n self.WindowClient &&\n self.WindowClient.prototype &&\n self.WindowClient.prototype.navigate\n ) {\n var oWinClientNavigate = self.WindowClient.prototype.navigate;\n self.WindowClient.prototype.navigate = function navigate(url) {\n var rwURL = wombat.rewriteClientWindowURL(url, this);\n return oWinClientNavigate.call(this, rwURL);\n };\n }\n};\n\n/**\n * Applies overrides to the CacheStorage and Cache interfaces in order\n * to rewrite the URLs they operate on\n * @see https://w3c.github.io/ServiceWorker/#cachestorage\n * @see https://w3c.github.io/ServiceWorker/#cache-interface\n */\nWBWombat.prototype.initCacheApisOverride = function() {\n var wombat = this;\n if (\n self.CacheStorage &&\n self.CacheStorage.prototype &&\n self.CacheStorage.prototype.match\n ) {\n var oCacheStorageMatch = self.CacheStorage.prototype.match;\n self.CacheStorage.prototype.match = function match(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheStorageMatch.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache && self.Cache.prototype) {\n if (self.Cache.prototype.match) {\n var oCacheMatch = self.Cache.prototype.match;\n self.Cache.prototype.match = function match(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheMatch.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.matchAll) {\n var oCacheMatchAll = self.Cache.prototype.matchAll;\n self.Cache.prototype.matchAll = function matchAll(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheMatchAll.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.add) {\n var oCacheAdd = self.Cache.prototype.add;\n self.Cache.prototype.add = function add(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheAdd.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.addAll) {\n var oCacheAddAll = self.Cache.prototype.addAll;\n self.Cache.prototype.addAll = function addAll(requests) {\n var rwRequests = requests;\n if (Array.isArray(requests)) {\n rwRequests = new Array(requests.length);\n for (var i = 0; i < requests.length; i++) {\n rwRequests[i] = wombat.rewriteCacheApi(requests[i]);\n }\n }\n return oCacheAddAll.call(this, rwRequests);\n };\n }\n\n if (self.Cache.prototype.put) {\n var oCachePut = self.Cache.prototype.put;\n self.Cache.prototype.put = function put(request, response) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCachePut.call(this, rwRequest, response);\n };\n }\n\n if (self.Cache.prototype.delete) {\n var oCacheDelete = self.Cache.prototype.delete;\n self.Cache.prototype.delete = function newCacheDelete(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheDelete.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.keys) {\n var oCacheKeys = self.Cache.prototype.keys;\n self.Cache.prototype.keys = function keys(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheKeys.call(this, rwRequest, options);\n };\n }\n }\n};\n\nself.WBWombat = WBWombat;\n"}),r.injectScripts&&(r.injectScripts=r.injectScripts.map((t=>this.staticPrefix+"proxy/"+t))),this.collections=new i(o,n.get("root"),r),this.collections.loadAll(n.get("dbColl")),this.proxyOriginMode=!!n.get("proxyOriginMode"),this.api=new e(this.collections),this.apiPrefix=this.replayPrefix+"api/",this.allowRewrittenCache=!!n.get("allowCache"),this.stats=n.get("stats")?new Yy:null,self.addEventListener("install",(()=>{self.skipWaiting()})),self.addEventListener("activate",(t=>{t.waitUntil(self.clients.claim()),console.log("Activate!")})),self.addEventListener("fetch",(t=>{t.respondWith(this.handleFetch(t))})),self.addEventListener("message",(t=>{"reload_all"===t.data.msg_type&&t.waitUntil(this.collections.loadAll())}))}handleFetch(t){const e=t.request.url;if(this.proxyOriginMode)return this.getResponseFor(t.request,t);if(!e.startsWith(this.prefix))return"chrome-extension://invalid/"===e?S(t.request,"Invalid URL"):this.defaultFetch(t.request);if(this.collections.root&&e.slice(this.prefix.length).indexOf("/")<0)return this.defaultFetch(t.request);if(e.startsWith(this.staticPrefix+"proxy/"))return this.staticPathProxy(e,t.request);if(e.startsWith(this.replayPrefix)&&!e.startsWith(this.staticPrefix))return this.getResponseFor(t.request,t);const r=new URL(e);r.search="",r.hash="";const i=r.href;for(const t of this.staticData.keys())if(t===i){const{content:e,type:r}=this.staticData.get(t);return new Response(e,{headers:{"Content-Type":r}})}return("http:"==r.protocol||"https:"==r.protocol)&&r.pathname.indexOf("/",1)<0?this.handleOffline(t.request):this.defaultFetch(t.request)}staticPathProxy(t,e){return t=t.slice((this.staticPrefix+"proxy/").length),t=new URL(t,self.location.href).href,e=new Request(t),this.defaultFetch(e)}defaultFetch(t){const e={};return"only-if-cached"===t.cache&&"same-origin"!==t.mode&&(e.cache="default"),self.fetch(t,e)}async ensureCached(t){const e=await caches.open("wabac-offline");for(let r of t){r=new URL(r,self.location.href).href;let t=await e.match(r,{ignoreSearch:!0});if(!t)try{t=await this.defaultFetch(r),await e.put(r,t)}catch(t){console.warn(`Failed to Auto Cache: ${r}`,t)}}}async handleOffline(t){let e=null;const r=await caches.open("wabac-offline");try{e=await this.defaultFetch(t)}catch(i){return e=await r.match(t,{ignoreSearch:!0}),e||(e=S(t,"Sorry, this url was not cached for offline use")),e}if(t.url.startsWith(this.prefix+"?"))return e;if(200===e.status){const i=e.clone();await r.put(t,i)}else console.warn(`Not Cacheing ${t.url} - Status ${e.status}`);return e}async getResponseFor(t,e){if(!this.proxyOriginMode&&t.url.startsWith(this.apiPrefix))return this.stats&&t.url.startsWith(this.apiPrefix+"stats.json")?await this.stats.getStats(e):await this.api.apiResponse(t.url.slice(this.apiPrefix.length),t,e);await this.collections.inited;const r=v(t),i=t.headers.get("range");try{if(this.allowRewrittenCache&&!i){const e=await self.caches.match(t);if(e&&!!e.headers.get(bm)===r)return e}}catch(t){}let n=this.collections.root;n||(n=t.url.slice(this.replayPrefix.length).split("/",1)[0]);const s=await this.collections.getColl(n);if(!s||!this.proxyOriginMode&&!t.url.startsWith(s.prefix))return S(t);const o=this.proxyOriginMode?t.url:t.url.substring(s.prefix.length),a={isRoot:!!this.collections.root};this.proxyOriginMode&&(a.mod="id_",a.proxyOrigin=s.config.extraConfig.proxyOrigin,a.localOrigin=self.location.origin);const c=new mm(o,t,a);if(!c.url)return S(t,`Replay URL ${o} not found`);const l=await s.handleRequest(c,e);if(l){if(this.stats&&this.stats.updateStats(l.date,l.status,t,e),this.allowRewrittenCache&&200===l.status)try{const e=await self.caches.open("wabac-"+s.name);r&&l.headers.set(bm,"true");const i=l.clone();await e.put(t,i)}catch(t){console.warn(t)}return l}return i&&console.log("Not Found Range!: "+i),S(t)}}if(self.registration){const t=new Map,r=self.registration.scope;t.set(r,{type:"text/html",content:e}),t.set(r+"index.html",{type:"text/html",content:e});const i={};"1"==new URLSearchParams(self.location.search).get("ruffle")&&(i.injectScripts=["ruffle/ruffle.js"]),self.sw=new Em({staticData:t,defaultConfig:i})}else new Ky(self)})();var n=self;for(var s in i)n[s]=i[s];i.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
121
+ const Wg="crypto.algorithm";const jg="crypto.algorithmProvider";var zg;Uf.registerSingleton(jg,class{getAlgorithms(){return Uf.resolveAll(Wg)}toAsnAlgorithm(t){for(const e of this.getAlgorithms()){const r=e.toAsnAlgorithm(t);if(r)return r}if(/[0-9.]+/.test(t.name)){const e=new Oh({algorithm:t.name});if("parameters"in t){const r=t;e.parameters=r.parameters}return e}throw new Error("Cannot convert WebCrypto algorithm to ASN.1 algorithm")}toWebAlgorithm(t){for(const e of this.getAlgorithms()){const r=e.toWebAlgorithm(t);if(r)return r}return{name:t.algorithm,parameters:t.parameters}}});const Gg="1.3.36.3.3.2.8.1.1",qg=`${Gg}.1`,Qg=`${Gg}.2`,Vg=`${Gg}.3`,Kg=`${Gg}.4`,Yg=`${Gg}.5`,Jg=`${Gg}.6`,Xg=`${Gg}.7`,Zg=`${Gg}.8`,$g=`${Gg}.9`,tw=`${Gg}.10`,ew=`${Gg}.11`,rw=`${Gg}.12`,iw=`${Gg}.13`,nw=`${Gg}.14`,sw="brainpoolP160r1",ow="brainpoolP160t1",aw="brainpoolP192r1",cw="brainpoolP192t1",lw="brainpoolP224r1",uw="brainpoolP224t1",hw="brainpoolP256r1",pw="brainpoolP256t1",dw="brainpoolP320r1",fw="brainpoolP320t1",gw="brainpoolP384r1",ww="brainpoolP384t1",yw="brainpoolP512r1",mw="brainpoolP512t1",bw="ECDSA";let Aw=zg=class{toAsnAlgorithm(t){if(t.name.toLowerCase()===bw.toLowerCase())if("hash"in t){switch(("string"==typeof t.hash?t.hash:t.hash.name).toLowerCase()){case"sha-1":return Sd;case"sha-256":return Id;case"sha-384":return Cd;case"sha-512":return Rd}}else if("namedCurve"in t){let e="";switch(t.namedCurve){case"P-256":e=Ed;break;case"K-256":e=zg.SECP256K1;break;case"P-384":e=_d;break;case"P-521":e=vd;break;case sw:e=qg;break;case ow:e=Qg;break;case aw:e=Vg;break;case cw:e=Kg;break;case lw:e=Yg;break;case uw:e=Jg;break;case hw:e=Xg;break;case pw:e=Zg;break;case dw:e=$g;break;case fw:e=tw;break;case gw:e=ew;break;case ww:e=rw;break;case yw:e=iw;break;case mw:e=nw}if(e)return new Oh({algorithm:gd,parameters:Kl.serialize(new xd({namedCurve:e}))})}return null}toWebAlgorithm(t){switch(t.algorithm){case wd:return{name:bw,hash:{name:"SHA-1"}};case md:return{name:bw,hash:{name:"SHA-256"}};case bd:return{name:bw,hash:{name:"SHA-384"}};case Ad:return{name:bw,hash:{name:"SHA-512"}};case gd:if(!t.parameters)throw new TypeError("Cannot get required parameters from EC algorithm");switch(Kl.parse(t.parameters,xd).namedCurve){case Ed:return{name:bw,namedCurve:"P-256"};case zg.SECP256K1:return{name:bw,namedCurve:"K-256"};case _d:return{name:bw,namedCurve:"P-384"};case vd:return{name:bw,namedCurve:"P-521"};case qg:return{name:bw,namedCurve:sw};case Qg:return{name:bw,namedCurve:ow};case Vg:return{name:bw,namedCurve:aw};case Kg:return{name:bw,namedCurve:cw};case Yg:return{name:bw,namedCurve:lw};case Jg:return{name:bw,namedCurve:uw};case Xg:return{name:bw,namedCurve:hw};case Zg:return{name:bw,namedCurve:pw};case $g:return{name:bw,namedCurve:dw};case tw:return{name:bw,namedCurve:fw};case ew:return{name:bw,namedCurve:gw};case rw:return{name:bw,namedCurve:ww};case iw:return{name:bw,namedCurve:yw};case nw:return{name:bw,namedCurve:mw}}}return null}};Aw.SECP256K1="1.3.132.0.10",Aw=zg=hf([Ff()],Aw),Uf.registerSingleton(Wg,Aw);const Ew=Symbol("name"),_w=Symbol("value");class vw{constructor(t,e={},r=""){this[Ew]=t,this[_w]=r;for(const t in e)this[t]=e[t]}}vw.NAME=Ew,vw.VALUE=_w;class Tw{static toString(t){const e=this.items[t];return e||t}}Tw.items={[Qd]:"sha1",[Vd]:"sha224",[Kd]:"sha256",[Yd]:"sha384",[Jd]:"sha512",[Bd]:"rsaEncryption",[Fd]:"sha1WithRSAEncryption",[Hd]:"sha224WithRSAEncryption",[Wd]:"sha256WithRSAEncryption",[jd]:"sha384WithRSAEncryption",[zd]:"sha512WithRSAEncryption",[gd]:"ecPublicKey",[wd]:"ecdsaWithSHA1",[yd]:"ecdsaWithSHA224",[md]:"ecdsaWithSHA256",[bd]:"ecdsaWithSHA384",[Ad]:"ecdsaWithSHA512",[Ju]:"TLS WWW server authentication",[Xu]:"TLS WWW client authentication",[Zu]:"Code Signing",[$u]:"E-mail Protection",[th]:"Time Stamping",[eh]:"OCSP Signing","1.2.840.113549.1.7.2":"Signed Data"};class Sw{static serialize(t){return this.serializeObj(t).join("\n")}static pad(t=0){return"".padStart(2*t," ")}static serializeObj(t,e=0){const r=[];let i=this.pad(e++),n="";const s=t[vw.VALUE];s&&(n=` ${s}`),r.push(`${i}${t[vw.NAME]}:${n}`),i=this.pad(e);for(const n in t){if("symbol"==typeof n)continue;const s=t[n],o=n?`${n}: `:"";if("string"==typeof s||"number"==typeof s||"boolean"==typeof s)r.push(`${i}${o}${s}`);else if(s instanceof Date)r.push(`${i}${o}${s.toUTCString()}`);else if(Array.isArray(s))for(const t of s)t[vw.NAME]=n,r.push(...this.serializeObj(t,e));else if(s instanceof vw)s[vw.NAME]=n,r.push(...this.serializeObj(s,e));else if(Ko.vJ.isBufferSource(s))n?(r.push(`${i}${o}`),r.push(...this.serializeBufferSource(s,e+1))):r.push(...this.serializeBufferSource(s,e));else{if(!("toTextObject"in s))throw new TypeError("Cannot serialize data in text format. Unsupported type.");{const t=s.toTextObject();t[vw.NAME]=n,r.push(...this.serializeObj(t,e))}}}return r}static serializeBufferSource(t,e=0){const r=this.pad(e),i=Ko.vJ.toUint8Array(t),n=[];for(let t=0;t<i.length;){const e=[];for(let r=0;r<16&&t<i.length;r++){8===r&&e.push("");const n=i[t++].toString(16).padStart(2,"0");e.push(n)}n.push(`${r}${e.join(" ")}`)}return n}static serializeAlgorithm(t){return this.algorithmSerializer.toTextObject(t)}}Sw.oidSerializer=Tw,Sw.algorithmSerializer=class{static toTextObject(t){const e=new vw("Algorithm Identifier",{},Tw.toString(t.algorithm));if(t.parameters)switch(t.algorithm){case gd:{const r=(new Aw).toWebAlgorithm(t);r&&"namedCurve"in r?e["Named Curve"]=r.namedCurve:e.Parameters=t.parameters;break}default:e.Parameters=t.parameters}return e}};class Iw{constructor(...t){if(1===t.length){const e=t[0];this.rawData=Kl.serialize(e),this.onInit(e)}else{const e=Kl.parse(t[0],t[1]);this.rawData=Ko.vJ.toArrayBuffer(t[0]),this.onInit(e)}}equal(t){return t instanceof Iw&&(0,Ko.Xy)(t.rawData,this.rawData)}toString(t="text"){switch(t){case"asn":return Kl.toString(this.rawData);case"text":return Sw.serialize(this.toTextObject());case"hex":return Ko.ep.ToHex(this.rawData);case"base64":return Ko.ep.ToBase64(this.rawData);case"base64url":return Ko.ep.ToBase64Url(this.rawData);default:throw TypeError("Argument 'format' is unsupported value")}}getTextName(){return this.constructor.NAME}toTextObject(){const t=this.toTextObjectEmpty();return t[""]=this.rawData,t}toTextObjectEmpty(t){return new vw(this.getTextName(),{},t)}}Iw.NAME="ASN";class Cw extends Iw{constructor(...t){let e;e=Ko.vJ.isBufferSource(t[0])?Ko.vJ.toArrayBuffer(t[0]):Kl.serialize(new Ph({extnID:t[0],critical:t[1],extnValue:new hl(Ko.vJ.toArrayBuffer(t[2]))})),super(e,Ph)}onInit(t){this.type=t.extnID,this.critical=t.critical,this.value=t.extnValue.buffer}toTextObject(){const t=this.toTextObjectWithoutValue();return t[""]=this.value,t}toTextObjectWithoutValue(){const t=this.toTextObjectEmpty(this.critical?"critical":void 0);return t[vw.NAME]===Cw.NAME&&(t[vw.NAME]=Tw.toString(this.type)),t}}var Rw;class xw{constructor(){this.items=new Map,this[Rw]="CryptoProvider","undefined"!=typeof self&&"undefined"!=typeof crypto&&this.set(xw.DEFAULT,crypto)}static isCryptoKeyPair(t){return t&&t.privateKey&&t.publicKey}static isCryptoKey(t){return t&&t.usages&&t.type&&t.algorithm&&void 0!==t.extractable}clear(){this.items.clear()}delete(t){return this.items.delete(t)}forEach(t,e){return this.items.forEach(t,e)}has(t){return this.items.has(t)}get size(){return this.items.size}entries(){return this.items.entries()}keys(){return this.items.keys()}values(){return this.items.values()}[Symbol.iterator](){return this.items[Symbol.iterator]()}get(t=xw.DEFAULT){const e=this.items.get(t.toLowerCase());if(!e)throw new Error(`Cannot get Crypto by name '${t}'`);return e}set(t,e){if("string"==typeof t){if(!e)throw new TypeError("Argument 'value' is required");this.items.set(t.toLowerCase(),e)}else this.items.set(xw.DEFAULT,t);return this}}Rw=Symbol.toStringTag,xw.DEFAULT="default";const Nw=new xw,Ow=/^[0-2](?:\.[1-9][0-9]*)+$/;class kw{constructor(t={}){this.items={};for(const e in t)this.register(e,t[e])}get(t){return this.items[t]||null}findId(t){return e=t,new RegExp(Ow).test(e)?t:this.get(t);var e}register(t,e){this.items[t]=e,this.items[e]=t}}const Bw=new kw;function Dw(t,e){return`\\${Ko.ep.ToHex(Ko.ep.FromUtf8String(e)).toUpperCase()}`}Bw.register("CN","2.5.4.3"),Bw.register("L","2.5.4.7"),Bw.register("ST","2.5.4.8"),Bw.register("O","2.5.4.10"),Bw.register("OU","2.5.4.11"),Bw.register("C","2.5.4.6"),Bw.register("DC","0.9.2342.19200300.100.1.25"),Bw.register("E","1.2.840.113549.1.9.1"),Bw.register("G","2.5.4.42"),Bw.register("I","2.5.4.43"),Bw.register("SN","2.5.4.4"),Bw.register("T","2.5.4.12");class Lw{constructor(t,e={}){this.extraNames=new kw,this.asn=new ou;for(const t in e)if(Object.prototype.hasOwnProperty.call(e,t)){const r=e[t];this.extraNames.register(t,r)}"string"==typeof t?this.asn=this.fromString(t):t instanceof ou?this.asn=t:Ko.vJ.isBufferSource(t)?this.asn=Kl.parse(t,ou):this.asn=this.fromJSON(t)}static isASCII(t){for(let e=0;e<t.length;e++){if(t.charCodeAt(e)>255)return!1}return!0}getField(t){const e=this.extraNames.findId(t)||Bw.findId(t),r=[];for(const t of this.asn)for(const i of t)i.type===e&&r.push(i.value.toString());return r}getName(t){return this.extraNames.get(t)||Bw.get(t)}toString(){return this.asn.map((t=>t.map((t=>{const e=this.getName(t.type)||t.type,r=t.value.anyValue?`#${Ko.ep.ToHex(t.value.anyValue)}`:function(t){return t.replace(/([,+"\\<>;])/g,"\\$1").replace(/^([ #])/,"\\$1").replace(/([ ]$)/,"\\$1").replace(/([\r\n\t])/,Dw)}(t.value.toString());return`${e}=${r}`})).join("+"))).join(", ")}toJSON(){var t;const e=[];for(const r of this.asn){const i={};for(const e of r){const r=this.getName(e.type)||e.type;null!==(t=i[r])&&void 0!==t||(i[r]=[]),i[r].push(e.value.anyValue?`#${Ko.ep.ToHex(e.value.anyValue)}`:e.value.toString())}e.push(i)}return e}fromString(t){const e=new ou,r=/(\d\.[\d.]*\d|[A-Za-z]+)=((?:"")|(?:".*?[^\\]")|(?:[^,+].*?(?:[^\\][,+]))|(?:))([,+])?/g;let i=null,n=",";for(;i=r.exec(`${t},`);){let[,t,r]=i;const s=r[r.length-1];","!==s&&"+"!==s||(r=r.slice(0,r.length-1),i[3]=s);const o=i[3];if(/[\d.]+/.test(t)||(t=this.getName(t)||""),!t)throw new Error(`Cannot get OID for name type '${t}'`);const a=new iu({type:t});if("#"===r.charAt(0))a.value.anyValue=Ko.ep.FromHex(r.slice(1));else{const e=/"(.*?[^\\])?"/.exec(r);e&&(r=e[1]),r=r.replace(/\\0a/gi,"\n").replace(/\\0d/gi,"\r").replace(/\\0g/gi,"\t").replace(/\\(.)/g,"$1"),t===this.getName("E")||t===this.getName("DC")?a.value.ia5String=r:Lw.isASCII(r)?a.value.printableString=r:a.value.utf8String=r}"+"===n?e[e.length-1].push(a):e.push(new nu([a])),n=o}return e}fromJSON(t){const e=new ou;for(const r of t){const t=new nu;for(const e in r){let i=e;if(/[\d.]+/.test(e)||(i=this.getName(e)||""),!i)throw new Error(`Cannot get OID for name type '${e}'`);const n=r[e];for(const e of n){const r=new iu({type:i});if("object"==typeof e)for(const t in e)switch(t){case"ia5String":r.value.ia5String=e[t];break;case"utf8String":r.value.utf8String=e[t];break;case"universalString":r.value.universalString=e[t];break;case"bmpString":r.value.bmpString=e[t];break;case"printableString":r.value.printableString=e[t]}else"#"===e[0]?r.value.anyValue=Ko.ep.FromHex(e.slice(1)):i===this.getName("E")||i===this.getName("DC")?r.value.ia5String=e:r.value.printableString=e;t.push(r)}}e.push(t)}return e}toArrayBuffer(){return Kl.serialize(this.asn)}async getThumbprint(...t){var e;let r,i="SHA-1";return t.length>=1&&!(null===(e=t[0])||void 0===e?void 0:e.subtle)?(i=t[0]||i,r=t[1]||Nw.get()):r=t[0]||Nw.get(),await r.subtle.digest(i,this.toArrayBuffer())}}const Pw="Cannot initialize GeneralName from ASN.1 data.",Uw=`${Pw} Unsupported string format in use.`,Mw=`${Pw} Value doesn't match to GUID regular expression.`,Fw=/^([0-9a-f]{8})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{4})-?([0-9a-f]{12})$/i,Hw="1.3.6.1.4.1.311.25.1",Ww="1.3.6.1.4.1.311.20.2.3",jw="dns",zw="dn",Gw="email",qw="ip",Qw="url",Vw="guid",Kw="upn",Yw="id";class Jw extends Iw{constructor(...t){let e;if(2===t.length)switch(t[0]){case zw:{const r=new Lw(t[1]).toArrayBuffer(),i=Kl.parse(r,ou);e=new uu({directoryName:i});break}case jw:e=new uu({dNSName:t[1]});break;case Gw:e=new uu({rfc822Name:t[1]});break;case Vw:{const r=new RegExp(Fw,"i").exec(t[1]);if(!r)throw new Error("Cannot parse GUID value. Value doesn't match to regular expression");const i=r.slice(1).map(((t,e)=>e<3?Ko.ep.ToHex(new Uint8Array(Ko.ep.FromHex(t)).reverse()):t)).join("");e=new uu({otherName:new cu({typeId:Hw,value:Kl.serialize(new hl(Ko.ep.FromHex(i)))})});break}case qw:e=new uu({iPAddress:t[1]});break;case Yw:e=new uu({registeredID:t[1]});break;case Kw:e=new uu({otherName:new cu({typeId:Ww,value:Kl.serialize(_l.toASN(t[1]))})});break;case Qw:e=new uu({uniformResourceIdentifier:t[1]});break;default:throw new Error("Cannot create GeneralName. Unsupported type of the name")}else e=Ko.vJ.isBufferSource(t[0])?Kl.parse(t[0],uu):t[0];super(e)}onInit(t){if(null!=t.dNSName)this.type=jw,this.value=t.dNSName;else if(null!=t.rfc822Name)this.type=Gw,this.value=t.rfc822Name;else if(null!=t.iPAddress)this.type=qw,this.value=t.iPAddress;else if(null!=t.uniformResourceIdentifier)this.type=Qw,this.value=t.uniformResourceIdentifier;else if(null!=t.registeredID)this.type=Yw,this.value=t.registeredID;else if(null!=t.directoryName)this.type=zw,this.value=new Lw(t.directoryName).toString();else{if(null==t.otherName)throw new Error(Uw);if(t.otherName.typeId===Hw){this.type=Vw;const e=Kl.parse(t.otherName.value,hl),r=new RegExp(Fw,"i").exec(Ko.ep.ToHex(e));if(!r)throw new Error(Mw);this.value=r.slice(1).map(((t,e)=>e<3?Ko.ep.ToHex(new Uint8Array(Ko.ep.FromHex(t)).reverse()):t)).join("-")}else{if(t.otherName.typeId!==Ww)throw new Error(Uw);this.type=Kw,this.value=Kl.parse(t.otherName.value,eu).toString()}}}toJSON(){return{type:this.type,value:this.value}}toTextObject(){let t;switch(this.type){case zw:case jw:case Vw:case qw:case Yw:case Kw:case Qw:t=this.type.toUpperCase();break;case Gw:t="Email";break;default:throw new Error("Unsupported GeneralName type")}let e=this.value;return this.type===Yw&&(e=Tw.toString(e)),new vw(t,void 0,e)}}class Xw extends Iw{constructor(t){let e;if(t instanceof _u)e=t;else if(Array.isArray(t)){const r=[];for(const e of t)if(e instanceof uu)r.push(e);else{const t=Kl.parse(new Jw(e.type,e.value).rawData,uu);r.push(t)}e=new _u(r)}else{if(!Ko.vJ.isBufferSource(t))throw new Error("Cannot initialize GeneralNames. Incorrect incoming arguments");e=Kl.parse(t,_u)}super(e)}onInit(t){const e=[];for(const r of t){let t=null;try{t=new Jw(r)}catch{continue}e.push(t)}this.items=e}toJSON(){return this.items.map((t=>t.toJSON()))}toTextObject(){const t=super.toTextObjectEmpty();for(const e of this.items){const r=e.toTextObject();let i=t[r[vw.NAME]];Array.isArray(i)||(i=[],t[r[vw.NAME]]=i),i.push(r)}return t}}Xw.NAME="GeneralNames";const Zw="\\n",$w="-{5}BEGIN ([^\\n]+(?=-{5}))-{5}\\n(?:((?:[^:\\n]+: (?:[^\\n]+\\n(?: +[^\\n]+\\n)*))+))?\\n?((?:[a-zA-Z0-9=+/]+\\n)+)-{5}END \\1-{5}";class ty{static isPem(t){return"string"==typeof t&&new RegExp($w,"g").test(t)}static decodeWithHeaders(t){t=t.replace(/\r/g,"");const e=new RegExp($w,"g"),r=[];let i=null;for(;i=e.exec(t);){const t=i[3].replace(new RegExp("[\\n]+","g"),""),e={type:i[1],headers:[],rawData:Ko.ep.FromBase64(t)},n=i[2];if(n){const t=n.split(new RegExp(Zw,"g"));let r=null;for(const i of t){const[t,n]=i.split(/:(.*)/);if(void 0===n){if(!r)throw new Error("Cannot parse PEM string. Incorrect header value");r.value+=t.trim()}else r&&e.headers.push(r),r={key:t,value:n.trim()}}r&&e.headers.push(r)}r.push(e)}return r}static decode(t){return this.decodeWithHeaders(t).map((t=>t.rawData))}static decodeFirst(t){const e=this.decode(t);if(!e.length)throw new RangeError("PEM string doesn't contain any objects");return e[0]}static encode(t,e){if(Array.isArray(t)){const r=new Array;return e?t.forEach((t=>{if(!Ko.vJ.isBufferSource(t))throw new TypeError("Cannot encode array of BufferSource in PEM format. Not all items of the array are BufferSource");r.push(this.encodeStruct({type:e,rawData:Ko.vJ.toArrayBuffer(t)}))})):t.forEach((t=>{if(!("type"in t))throw new TypeError("Cannot encode array of PemStruct in PEM format. Not all items of the array are PemStrut");r.push(this.encodeStruct(t))})),r.join("\n")}if(!e)throw new Error("Required argument 'tag' is missed");return this.encodeStruct({type:e,rawData:Ko.vJ.toArrayBuffer(t)})}static encodeStruct(t){var e;const r=t.type.toLocaleUpperCase(),i=[];if(i.push(`-----BEGIN ${r}-----`),null===(e=t.headers)||void 0===e?void 0:e.length){for(const e of t.headers)i.push(`${e.key}: ${e.value}`);i.push("")}const n=Ko.ep.ToBase64(t.rawData);let s,o=0;const a=Array();for(;o<n.length&&(n.length-o<64?s=n.substring(o):(s=n.substring(o,o+64),o+=64),0!==s.length)&&(a.push(s),!(s.length<64)););return i.push(...a),i.push(`-----END ${r}-----`),i.join("\n")}}ty.CertificateTag="CERTIFICATE",ty.CrlTag="CRL",ty.CertificateRequestTag="CERTIFICATE REQUEST",ty.PublicKeyTag="PUBLIC KEY",ty.PrivateKeyTag="PRIVATE KEY";class ey extends Iw{static isAsnEncoded(t){return Ko.vJ.isBufferSource(t)||"string"==typeof t}static toArrayBuffer(t){if("string"==typeof t){if(ty.isPem(t))return ty.decode(t)[0];if(Ko.ep.isHex(t))return Ko.ep.FromHex(t);if(Ko.ep.isBase64(t))return Ko.ep.FromBase64(t);if(Ko.ep.isBase64Url(t))return Ko.ep.FromBase64Url(t);throw new TypeError("Unsupported format of 'raw' argument. Must be one of DER, PEM, HEX, Base64, or Base4Url")}{const e=Ko.ep.ToBinary(t);return ty.isPem(e)?ty.decode(e)[0]:Ko.ep.isHex(e)?Ko.ep.FromHex(e):Ko.ep.isBase64(e)?Ko.ep.FromBase64(e):Ko.ep.isBase64Url(e)?Ko.ep.FromBase64Url(e):Ko.vJ.toArrayBuffer(t)}}constructor(...t){ey.isAsnEncoded(t[0])?super(ey.toArrayBuffer(t[0]),t[1]):super(t[0])}toString(t="pem"){return"pem"===t?ty.encode(this.rawData,this.tag):super.toString(t)}}class ry extends ey{constructor(t){ey.isAsnEncoded(t)?super(t,kh):super(t),this.tag=ty.PublicKeyTag}async export(...t){let e,r=["verify"],i={hash:"SHA-256",...this.algorithm};return t.length>1?(i=t[0]||i,r=t[1]||r,e=t[2]||Nw.get()):e=t[0]||Nw.get(),e.subtle.importKey("spki",this.rawData,i,!0,r)}onInit(t){const e=Uf.resolve(jg),r=this.algorithm=e.toWebAlgorithm(t.algorithm);switch(t.algorithm.algorithm){case Bd:{const e=Kl.parse(t.subjectPublicKey,uf),i=Ko.vJ.toUint8Array(e.modulus);r.publicExponent=Ko.vJ.toUint8Array(e.publicExponent),r.modulusLength=(i[0]?i:i.slice(1)).byteLength<<3;break}}}async getThumbprint(...t){var e;let r,i="SHA-1";return t.length>=1&&!(null===(e=t[0])||void 0===e?void 0:e.subtle)?(i=t[0]||i,r=t[1]||Nw.get()):r=t[0]||Nw.get(),await r.subtle.digest(i,this.rawData)}async getKeyIdentifier(t){t||(t=Nw.get());const e=Kl.parse(this.rawData,kh);return await t.subtle.digest("SHA-1",e.subjectPublicKey)}toTextObject(){const t=this.toTextObjectEmpty(),e=Kl.parse(this.rawData,kh);if(t.Algorithm=Sw.serializeAlgorithm(e.algorithm),e.algorithm.algorithm===gd)t["EC Point"]=e.subjectPublicKey;else t["Raw Data"]=e.subjectPublicKey;return t}}class iy{static register(t,e){this.items.set(t,e)}static create(t){const e=new Cw(t),r=this.items.get(e.type);return r?new r(t):e}}iy.items=new Map;const ny="crypto.signatureFormatter";class sy extends ey{constructor(t){ey.isAsnEncoded(t)?super(t,Wh):super(t),this.tag=ty.CertificateTag}onInit(t){const e=t.tbsCertificate;this.tbs=Kl.serialize(e),this.serialNumber=Ko.ep.ToHex(e.serialNumber),this.subjectName=new Lw(e.subject),this.subject=new Lw(e.subject).toString(),this.issuerName=new Lw(e.issuer),this.issuer=this.issuerName.toString();const r=Uf.resolve(jg);this.signatureAlgorithm=r.toWebAlgorithm(t.signatureAlgorithm),this.signature=t.signatureValue;const i=e.validity.notBefore.utcTime||e.validity.notBefore.generalTime;if(!i)throw new Error("Cannot get 'notBefore' value");this.notBefore=i;const n=e.validity.notAfter.utcTime||e.validity.notAfter.generalTime;if(!n)throw new Error("Cannot get 'notAfter' value");this.notAfter=n,this.extensions=[],e.extensions&&(this.extensions=e.extensions.map((t=>iy.create(Kl.serialize(t))))),this.publicKey=new ry(e.subjectPublicKeyInfo)}getExtension(t){for(const e of this.extensions)if("string"==typeof t){if(e.type===t)return e}else if(e instanceof t)return e;return null}getExtensions(t){return this.extensions.filter((e=>"string"==typeof t?e.type===t:e instanceof t))}async verify(t={},e=Nw.get()){let r,i;const n=t.publicKey;try{if(n)if("publicKey"in n)r={...n.publicKey.algorithm,...this.signatureAlgorithm},i=await n.publicKey.export(r,["verify"]);else if(n instanceof ry)r={...n.algorithm,...this.signatureAlgorithm},i=await n.export(r,["verify"]);else if(Ko.vJ.isBufferSource(n)){const t=new ry(n);r={...t.algorithm,...this.signatureAlgorithm},i=await t.export(r,["verify"])}else r={...n.algorithm,...this.signatureAlgorithm},i=n;else r={...this.publicKey.algorithm,...this.signatureAlgorithm},i=await this.publicKey.export(r,["verify"],e)}catch(t){return!1}const s=Uf.resolveAll(ny).reverse();let o=null;for(const t of s)if(o=t.toWebSignature(r,this.signature),o)break;if(!o)throw Error("Cannot convert ASN.1 signature value to WebCrypto format");const a=await e.subtle.verify(this.signatureAlgorithm,i,o,this.tbs);if(t.signatureOnly)return a;{const e=(t.date||new Date).getTime();return a&&this.notBefore.getTime()<e&&e<this.notAfter.getTime()}}async getThumbprint(...t){let e,r="SHA-1";return t[0]&&(t[0].subtle?e=t[0]:(r=t[0]||r,e=t[1])),null!=e||(e=Nw.get()),await e.subtle.digest(r,this.rawData)}async isSelfSigned(t=Nw.get()){return this.subject===this.issuer&&await this.verify({signatureOnly:!0},t)}toTextObject(){const t=this.toTextObjectEmpty(),e=Kl.parse(this.rawData,Wh),r=e.tbsCertificate,i=new vw("",{Version:`${Mh[r.version]} (${r.version})`,"Serial Number":r.serialNumber,"Signature Algorithm":Sw.serializeAlgorithm(r.signature),Issuer:this.issuer,Validity:new vw("",{"Not Before":r.validity.notBefore.getTime(),"Not After":r.validity.notAfter.getTime()}),Subject:this.subject,"Subject Public Key Info":this.publicKey});if(r.issuerUniqueID&&(i["Issuer Unique ID"]=r.issuerUniqueID),r.subjectUniqueID&&(i["Subject Unique ID"]=r.subjectUniqueID),this.extensions.length){const t=new vw("");for(const e of this.extensions){const r=e.toTextObject();t[r[vw.NAME]]=r}i.Extensions=t}return t.Data=i,t.Signature=new vw("",{Algorithm:Sw.serializeAlgorithm(e.signatureAlgorithm),"":e.signatureValue}),t}}sy.NAME="Certificate";class oy extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0]))super(t[0]);else if("string"==typeof t[0]){const e=new mu({keyIdentifier:new yu(Ko.ep.FromHex(t[0]))});super(wu,t[1],Kl.serialize(e))}else{const e=t[0],r=e.name instanceof Xw?Kl.parse(e.name.rawData,_u):e.name,i=new mu({authorityCertIssuer:r,authorityCertSerialNumber:Ko.ep.FromHex(e.serialNumber)});super(wu,t[1],Kl.serialize(i))}}static async create(t,e=!1,r=Nw.get()){if(t instanceof sy||xw.isCryptoKey(t)){const i=t instanceof sy?await t.publicKey.export(r):t,n=await r.subtle.exportKey("spki",i),s=new ry(n),o=await s.getKeyIdentifier(r);return new oy(Ko.ep.ToHex(o),e)}return new oy(t,e)}onInit(t){super.onInit(t);const e=Kl.parse(t.extnValue,mu);e.keyIdentifier&&(this.keyId=Ko.ep.ToHex(e.keyIdentifier)),e.authorityCertIssuer&&e.authorityCertSerialNumber&&(this.certId={name:e.authorityCertIssuer,serialNumber:Ko.ep.ToHex(e.authorityCertSerialNumber)})}toTextObject(){const t=this.toTextObjectWithoutValue(),e=Kl.parse(this.value,mu);return e.authorityCertIssuer&&(t["Authority Issuer"]=new Xw(e.authorityCertIssuer).toTextObject()),e.authorityCertSerialNumber&&(t["Authority Serial Number"]=e.authorityCertSerialNumber),e.keyIdentifier&&(t[""]=e.keyIdentifier),t}}oy.NAME="Authority Key Identifier";class ay extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Au);this.ca=e.cA,this.pathLength=e.pathLenConstraint}else{const e=new Au({cA:t[0],pathLenConstraint:t[1]});super(bu,t[2],Kl.serialize(e)),this.ca=t[0],this.pathLength=t[1]}}toTextObject(){const t=this.toTextObjectWithoutValue();return this.ca&&(t.CA=this.ca),void 0!==this.pathLength&&(t["Path Length"]=this.pathLength),t}}var cy,ly;ay.NAME="Basic Constraints",function(t){t.serverAuth="1.3.6.1.5.5.7.3.1",t.clientAuth="1.3.6.1.5.5.7.3.2",t.codeSigning="1.3.6.1.5.5.7.3.3",t.emailProtection="1.3.6.1.5.5.7.3.4",t.timeStamping="1.3.6.1.5.5.7.3.8",t.ocspSigning="1.3.6.1.5.5.7.3.9"}(cy||(cy={}));class uy extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Yu);this.usages=e.map((t=>t))}else{const e=new Yu(t[0]);super(Ku,t[1],Kl.serialize(e)),this.usages=t[0]}}toTextObject(){const t=this.toTextObjectWithoutValue();return t[""]=this.usages.map((t=>Tw.toString(t))).join(", "),t}}uy.NAME="Extended Key Usages",function(t){t[t.digitalSignature=1]="digitalSignature",t[t.nonRepudiation=2]="nonRepudiation",t[t.keyEncipherment=4]="keyEncipherment",t[t.dataEncipherment=8]="dataEncipherment",t[t.keyAgreement=16]="keyAgreement",t[t.keyCertSign=32]="keyCertSign",t[t.cRLSign=64]="cRLSign",t[t.encipherOnly=128]="encipherOnly",t[t.decipherOnly=256]="decipherOnly"}(ly||(ly={}));class hy extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,lh);this.usages=e.toNumber()}else{const e=new lh(t[0]);super(oh,t[1],Kl.serialize(e)),this.usages=t[0]}}toTextObject(){const t=this.toTextObjectWithoutValue(),e=Kl.parse(this.value,lh);return t[""]=e.toJSON().join(", "),t}}hy.NAME="Key Usages";class py extends Cw{constructor(...t){if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Th);this.keyId=Ko.ep.ToHex(e)}else{const e="string"==typeof t[0]?Ko.ep.FromHex(t[0]):t[0],r=new Th(e);super(vh,t[1],Kl.serialize(r)),this.keyId=Ko.ep.ToHex(e)}}static async create(t,e=!1,r=Nw.get()){let i;i=t instanceof ry?t.rawData:"publicKey"in t?t.publicKey.rawData:Ko.vJ.isBufferSource(t)?t:await r.subtle.exportKey("spki",t);const n=new ry(i),s=await n.getKeyIdentifier(r);return new py(Ko.ep.ToHex(s),e)}toTextObject(){const t=this.toTextObjectWithoutValue(),e=Kl.parse(this.value,Th);return t[""]=e,t}}py.NAME="Subject Key Identifier";class dy extends Cw{constructor(...t){Ko.vJ.isBufferSource(t[0])?super(t[0]):super(mh,t[1],new Xw(t[0]||[]).rawData)}onInit(t){super.onInit(t);const e=Kl.parse(t.extnValue,bh);this.names=new Xw(e)}toTextObject(){const t=this.toTextObjectWithoutValue(),e=this.names.toTextObject();for(const r in e)t[r]=e[r];return t}}dy.NAME="Subject Alternative Name";class fy extends Cw{constructor(...t){var e;if(Ko.vJ.isBufferSource(t[0])){super(t[0]);const e=Kl.parse(this.value,Bu);this.policies=e.map((t=>t.policyIdentifier))}else{const r=t[0],i=null!==(e=t[1])&&void 0!==e&&e,n=new Bu(r.map((t=>new ku({policyIdentifier:t}))));super(Iu,i,Kl.serialize(n)),this.policies=r}}toTextObject(){const t=this.toTextObjectWithoutValue();return t.Policy=this.policies.map((t=>new vw("",{},Tw.toString(t)))),t}}fy.NAME="Certificate Policies",iy.register(Iu,fy);class gy extends Iw{constructor(...t){let e;if(Ko.vJ.isBufferSource(t[0]))e=Ko.vJ.toArrayBuffer(t[0]);else{const r=t[0],i=Array.isArray(t[1])?t[1].map((t=>Ko.vJ.toArrayBuffer(t))):[];e=Kl.serialize(new Ah({type:r,values:i}))}super(e,Ah)}onInit(t){this.type=t.type,this.values=t.values}toTextObject(){const t=this.toTextObjectWithoutValue();return t.Value=this.values.map((t=>new vw("",{"":t}))),t}toTextObjectWithoutValue(){const t=this.toTextObjectEmpty();return t[vw.NAME]===gy.NAME&&(t[vw.NAME]=Tw.toString(this.type)),t}}gy.NAME="Attribute";class wy extends gy{constructor(...t){var e;if(Ko.vJ.isBufferSource(t[0]))super(t[0]);else{const e=new Og({printableString:t[0]});super(pg,[Kl.serialize(e)])}null!==(e=this.password)&&void 0!==e||(this.password="")}onInit(t){if(super.onInit(t),this.values[0]){const t=Kl.parse(this.values[0],Og);this.password=t.toString()}}toTextObject(){const t=this.toTextObjectWithoutValue();return t[vw.VALUE]=this.password,t}}wy.NAME="Challenge Password";class yy extends gy{constructor(...t){var e;if(Ko.vJ.isBufferSource(t[0]))super(t[0]);else{const e=t[0],r=new Uh;for(const t of e)r.push(Kl.parse(t.rawData,Ph));super(dg,[Kl.serialize(r)])}null!==(e=this.items)&&void 0!==e||(this.items=[])}onInit(t){if(super.onInit(t),this.values[0]){const t=Kl.parse(this.values[0],Uh);this.items=t.map((t=>iy.create(Kl.serialize(t))))}}toTextObject(){const t=this.toTextObjectWithoutValue(),e=this.items.map((t=>t.toTextObject()));for(const r of e)t[r[vw.NAME]]=r;return t}}yy.NAME="Extensions";class my{static register(t,e){this.items.set(t,e)}static create(t){const e=new gy(t),r=this.items.get(e.type);return r?new r(t):e}}my.items=new Map;let by=class{toAsnAlgorithm(t){if("rsassa-pkcs1-v1_5"===t.name.toLowerCase()){if(!t.hash)return new Oh({algorithm:Bd,parameters:null});switch(t.hash.name.toLowerCase()){case"sha-1":return new Oh({algorithm:Fd,parameters:null});case"sha-256":return new Oh({algorithm:Wd,parameters:null});case"sha-384":return new Oh({algorithm:jd,parameters:null});case"sha-512":return new Oh({algorithm:zd,parameters:null})}}return null}toWebAlgorithm(t){switch(t.algorithm){case Bd:return{name:"RSASSA-PKCS1-v1_5"};case Fd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-1"}};case Wd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-256"}};case jd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-384"}};case zd:return{name:"RSASSA-PKCS1-v1_5",hash:{name:"SHA-512"}}}return null}};by=hf([Ff()],by),Uf.registerSingleton(Wg,by);class Ay{addPadding(t,e){const r=Ko.vJ.toUint8Array(e),i=new Uint8Array(t);return i.set(r,t-r.length),i}removePadding(t,e=!1){let r=Ko.vJ.toUint8Array(t);for(let t=0;t<r.length;t++)if(r[t]){r=r.slice(t);break}if(e&&r[0]>127){const t=new Uint8Array(r.length+1);return t.set(r,1),t.buffer}return r.buffer}toAsnSignature(t,e){if("ECDSA"===t.name){const r=t.namedCurve,i=Ay.namedCurveSize.get(r)||Ay.defaultNamedCurveSize,n=new Od,s=Ko.vJ.toUint8Array(e);return n.r=this.removePadding(s.slice(0,i),!0),n.s=this.removePadding(s.slice(i,i+i),!0),Kl.serialize(n)}return null}toWebSignature(t,e){if("ECDSA"===t.name){const r=Kl.parse(e,Od),i=t.namedCurve,n=Ay.namedCurveSize.get(i)||Ay.defaultNamedCurveSize,s=this.addPadding(n,this.removePadding(r.r)),o=this.addPadding(n,this.removePadding(r.s));return(0,Ko.$e)(s,o)}return null}}Ay.namedCurveSize=new Map,Ay.defaultNamedCurveSize=32;const Ey="1.3.101.110",_y="1.3.101.111",vy="1.3.101.112",Ty="1.3.101.113";let Sy=class{toAsnAlgorithm(t){let e=null;switch(t.name.toLowerCase()){case"eddsa":switch(t.namedCurve.toLowerCase()){case"ed25519":e=vy;break;case"ed448":e=Ty}break;case"ecdh-es":switch(t.namedCurve.toLowerCase()){case"x25519":e=Ey;break;case"x448":e=_y}}return e?new Oh({algorithm:e}):null}toWebAlgorithm(t){switch(t.algorithm){case vy:return{name:"EdDSA",namedCurve:"Ed25519"};case Ty:return{name:"EdDSA",namedCurve:"Ed448"};case Ey:return{name:"ECDH-ES",namedCurve:"X25519"};case _y:return{name:"ECDH-ES",namedCurve:"X448"}}return null}};Sy=hf([Ff()],Sy),Uf.registerSingleton(Wg,Sy);class Iy extends ey{constructor(t){ey.isAsnEncoded(t)?super(t,Hg):super(t),this.tag=ty.CertificateRequestTag}onInit(t){this.tbs=Kl.serialize(t.certificationRequestInfo),this.publicKey=new ry(t.certificationRequestInfo.subjectPKInfo);const e=Uf.resolve(jg);this.signatureAlgorithm=e.toWebAlgorithm(t.signatureAlgorithm),this.signature=t.signature,this.attributes=t.certificationRequestInfo.attributes.map((t=>my.create(Kl.serialize(t))));const r=this.getAttribute(dg);this.extensions=[],r instanceof yy&&(this.extensions=r.items),this.subjectName=new Lw(t.certificationRequestInfo.subject),this.subject=this.subjectName.toString()}getAttribute(t){for(const e of this.attributes)if(e.type===t)return e;return null}getAttributes(t){return this.attributes.filter((e=>e.type===t))}getExtension(t){for(const e of this.extensions)if(e.type===t)return e;return null}getExtensions(t){return this.extensions.filter((e=>e.type===t))}async verify(t=Nw.get()){const e={...this.publicKey.algorithm,...this.signatureAlgorithm},r=await this.publicKey.export(e,["verify"],t),i=Uf.resolveAll(ny).reverse();let n=null;for(const t of i)if(n=t.toWebSignature(e,this.signature),n)break;if(!n)throw Error("Cannot convert WebCrypto signature value to ASN.1 format");return await t.subtle.verify(this.signatureAlgorithm,r,n,this.tbs)}toTextObject(){const t=this.toTextObjectEmpty(),e=Kl.parse(this.rawData,Hg),r=e.certificationRequestInfo,i=new vw("",{Version:`${Mh[r.version]} (${r.version})`,Subject:this.subject,"Subject Public Key Info":this.publicKey});if(this.attributes.length){const t=new vw("");for(const e of this.attributes){const r=e.toTextObject();t[r[vw.NAME]]=r}i.Attributes=t}return t.Data=i,t.Signature=new vw("",{Algorithm:Sw.serializeAlgorithm(e.signatureAlgorithm),"":e.signature}),t}}Iy.NAME="PKCS#10 Certificate Request";var Cy;!function(t){t[t.unspecified=0]="unspecified",t[t.keyCompromise=1]="keyCompromise",t[t.cACompromise=2]="cACompromise",t[t.affiliationChanged=3]="affiliationChanged",t[t.superseded=4]="superseded",t[t.cessationOfOperation=5]="cessationOfOperation",t[t.certificateHold=6]="certificateHold",t[t.removeFromCRL=8]="removeFromCRL",t[t.privilegeWithdrawn=9]="privilegeWithdrawn",t[t.aACompromise=10]="aACompromise"}(Cy||(Cy={}));iy.register(bu,ay),iy.register(Ku,uy),iy.register(oh,hy),iy.register(vh,py),iy.register(wu,oy),iy.register(mh,dy),my.register(pg,wy),my.register(dg,yy),Uf.registerSingleton(ny,class{toAsnSignature(t,e){return Ko.vJ.toArrayBuffer(e)}toWebSignature(t,e){return Ko.vJ.toArrayBuffer(e)}}),Uf.registerSingleton(ny,Ay),Ay.namedCurveSize.set("P-256",32),Ay.namedCurveSize.set("K-256",32),Ay.namedCurveSize.set("P-384",48),Ay.namedCurveSize.set("P-521",66);const Ry=/-{5}(BEGIN|END) .*-{5}/gm;async function xy({hash:t,signature:e,publicKey:r,domain:i,domainCert:n,created:s,software:o}={}){let a;const c=[];if(e=(0,Vo.toByteArray)(e),n&&i&&!r){const t=n.split("\n\n"),i=(0,Vo.toByteArray)(t[0].replace(Ry,"").replace(/\s/gm,"")),s=f(await crypto.subtle.digest("SHA-256",i));c.push({id:"certFingerprint",expected:s,matched:null});const o=new sy(i);r=await o.publicKey.export();const l=(0,Vo.fromByteArray)(new Uint8Array(o.publicKey.rawData));c.push({id:"publicKey",expected:l,matched:null}),o.subject&&o.subject.startsWith("CN=")&&(a=o.subject.split(3)),e=function(t){try{const e=ql.parse(t,Od),r=0===e.r[0]?e.r.slice(1):e.r,i=0===e.s[0]?e.s.slice(1):e.s;t=z([r,i],r.length+i.length)}catch(t){console.log(t)}return t}(e)}else{const t={name:"ECDSA",namedCurve:"P-384"};c.push({id:"publicKey",expected:r,matched:null}),r=await crypto.subtle.importKey("spki",(0,Vo.toByteArray)(r),t,!0,["verify"])}const l=new TextEncoder,u=await crypto.subtle.verify({name:"ECDSA",hash:"SHA-256"},r,e,l.encode(t));return c.push({id:"signature",expected:!0,matched:u}),s&&c.push({id:"created",expected:s,matched:null}),o&&c.push({id:"software",expected:o,matched:null}),i&&c.push({id:"domain",expected:i,matched:a}),c}const Ny="pages/pages.jsonl",Oy="pages/extraPages.jsonl",ky="datapackage.json",By="datapackage-digest.json",Dy="webarchive.yaml";class Ly{constructor(t,e,r=!0){this.file=e,this.waczname=e.waczname,this.store=t,this.isRoot=r}async loadFileFromWACZ(t,e){return this.store.loadFileFromWACZ?await this.store.loadFileFromWACZ(this.file,t,e):await this.file.loadFile(t,e)}async load(){let t,e=null;return this.file.containsFile(By)&&(e=await this.loadDigestData(By)),this.file.containsFile(ky)?t=await this.loadPackage(ky,e):this.file.containsFile(Dy)&&(t=await this.loadOldPackageYAML(Dy)),t||{}}async loadTextFileFromWACZ(t,e=!1){const{reader:r,hasher:i}=await this.loadFileFromWACZ(t,{computeHash:!!e}),n=(new TextDecoder).decode(await r.readFully());return e&&i&&await this.store.addVerifyData(this.waczname,t,e,i.getHash()),n}async loadDigestData(t){try{const e=JSON.parse(await this.loadTextFileFromWACZ(t));let r;e.path===ky&&e.hash&&(r=e.hash);const i=this.store,n=this.isRoot?"":this.waczname+":";if(!e.signedData||e.signedData.hash!==r)return void await i.addVerifyData(n,"signature");await i.addVerifyData(n,"datapackageHash",r);const s=await xy(e.signedData);return await i.addVerifyDataList(n,s),r}catch(t){console.warn(t)}}async loadPackage(t,e){const r=await this.loadTextFileFromWACZ(t,e),i=JSON.parse(r);switch(this.isRoot&&void 0!==i.config&&this.store.initConfig(i.config),i.profile){case"data-package":case"wacz-package":case void 0:case null:return await this.loadLeafWACZPackage(i);case"multi-wacz-package":return await this.loadMultiWACZPackage(i);default:throw new Error(`Unknown package profile: ${i.profile}`)}}async loadMultiWACZPackage(t){return this.file.markAsMultiWACZ(),await this.store.loadWACZFiles(t,this.file),t}async loadLeafWACZPackage(t){const e=t.metadata||{};let r=null;for(const e of t.resources)e.path===Ny?(r=e.hash,await this.store.addVerifyData(this.waczname,e.path,e.hash)):(e.path.endsWith(".idx")||e.path.endsWith(".cdx"))&&await this.store.addVerifyData(this.waczname,e.path,e.hash);if(this.file.containsFile(Ny)){(await this.loadPages(Ny,r)).hasText&&(this.store.textIndex=e.textIndex=Ny)}return this.file.containsFile(Oy)&&(this.store.textIndex=e.textIndex=Oy),e}async loadOldPackageYAML(t){const e=await this.loadTextFileFromWACZ(t),r=Qo.load(e),i={desc:r.desc,title:r.title};r.textIndex&&(i.textIndex=r.textIndex,r.config||(r.config={}),r.config.textIndex=r.textIndex),this.isRoot&&void 0!==r.config&&this.store.initConfig(r.config),i.title||(i.title=this.store.config.sourceName);const n=r.pages||[];n&&n.length&&await this.store.addPages(n);const s=r.pageLists||[];return s&&s.length&&await this.store.addCuratedPageLists(s,"pages","show"),i}async loadPages(t=Ny,e=null){const{reader:r,hasher:i}=await this.loadFileFromWACZ(t,{unzip:!0,computeHash:!0});let n=null,s=[];for await(const t of r.iterLines()){const e=JSON.parse(t);this.waczname&&(e.wacz=this.waczname),n?(s.push(e),500===s.length&&(await this.store.addPages(s),s=[])):n=e}return s.length&&await this.store.addPages(s),i&&e&&await this.store.addVerifyData(this.waczname,t,e,i.getHash()),n}}class Py{constructor(t,e,r=null){this.loader=t,this.loadId=r,this.loadUrl=e.loadUrl}async load(t){t.fullConfig&&this.loader.arrayBuffer&&this.loader.arrayBuffer.byteLength<=a&&(t.fullConfig.extra||(t.fullConfig.extra={}),t.fullConfig.extra.arrayBuffer=this.loader.arrayBuffer);const e=this.loadUrl,r=this.loader;return await t.addNewWACZ({name:"default",path:e,loader:r})}}class Uy{constructor(t,e,r=null){this.config=e,this.loadId=r,this.loader=t}async load(t,e=null,r=0){const i=new jn({loader:this.loader});await i.init();const n=i.zipreader,s=new Ly(t,i),o=await s.load();let a=0;const c=(t,i,n)=>{n+=a,e&&r&&e(Math.round(100*n/r),null,n,r)};for(const e of i.iterContainedFiles()){const r=n.getCompressedSize(e);(e.endsWith(".warc.gz")||e.endsWith(".warc"))&&await this.loadWARC(t,n,e,c,r),a+=r}return o||{}}async loadWARC(t,e,r,i,n){const{reader:s}=await e.loadFile(r,{unzip:!0}),o=new si(s,null,r);return o.detectPages=!1,await o.load(t,i,n)}}class My{constructor(t){this.response=t}async load(t){return await t.loadFromJSON(this.response)}}class Fy{constructor(t,{cloneResponse:e=!1,allowBody:r=!1,hostProxyOnly:i=!1}={}){if(t=t||{},this.prefix=t.prefix||"",this.proxyPathOnly=t.proxyPathOnly||!1,this.isLive=void 0===t.isLive||t.isLive,this.archivePrefix=t.archivePrefix||"",this.cloneResponse=e,this.allowBody=r,this.hostProxy=t.hostProxy,this.hostProxy instanceof Array){const t={};for(const e of this.hostProxy)t[e.host]=e;this.hostProxy=t}this.hostProxyOnly=i}async getAllPages(){return[]}getFetchUrl(t,e,r){let i;if(this.hostProxy){i=new URL(t);const e=this.hostProxy[i.host];if(e)return r.set("X-Proxy-Host",i.host),e.prefix+(e.pathOnly?i.pathname+i.search:t)}return this.hostProxyOnly?null:this.proxyPathOnly?(i||(i=new URL(t)),this.prefix+i.pathname+i.search):this.isLive||!e.timestamp?this.prefix+t:this.prefix+this.archivePrefix+e.timestamp+"id_/"+t}async getResource(t,e){const{headers:r,credentials:i,url:n}=t.prepareProxyRequest(e,!0),s=this.getFetchUrl(n,t,r);if(!s)return null;let o=null;!this.allowBody||"POST"!==t.method&&"PUT"!==t.method||(o=await t.getBody());const a=await fetch(s,{method:t.method,body:o,headers:r,credentials:i,mode:"cors",redirect:"follow"});let c=null;this.cloneResponse&&(c=a.clone());const l=mt.fromResponse({url:n,response:a,date:new Date,noRW:!1,isLive:this.isLive});return c&&(l.clonedResponse=c),l}}const Hy=/^([\w-]+,)*[\w-]+(:\d+)?,?\)\//;class Wy extends rn{constructor(t,e,r="wacz"){super(t.dbname,t.noCache),this.config=t,this.waczfiles={},this.waczNameForHash={},this.ziploadercache={},this.updating=null,this.rootSourceType=r,this.sourceLoader=e,this.externalSource=null,this.fuzzyUrlRules=[],this.textIndex=t&&t.metadata&&t.metadata.textIndex,t.extraConfig&&this.initConfig(t.extraConfig)}initConfig(t){if(void 0!==t.decodeResponses&&(this.config.decode=t.decodeResponses),t.hostProxy&&(this.externalSource=new Fy(t,{hostProxyOnly:!0})),t.fuzzy)for(const[e,r]of t.fuzzy){const t=new RegExp(e);this.fuzzyUrlRules.push({match:t,replace:r})}t.textIndex&&(this.textIndex=t.textIndex)}updateHeaders(t){this.sourceLoader&&(this.sourceLoader.headers=t)}_initDB(t,e,r,i){super._initDB(t,e,r,i),e||(t.createObjectStore("ziplines",{keyPath:["waczname","prefix"]}),t.createObjectStore("waczfiles",{keyPath:"waczname"}),t.createObjectStore("verification",{keyPath:"id"})),2===e&&this.convertV2WACZDB(t,i),3===e&&t.createObjectStore("verification",{keyPath:"id"})}async convertV2WACZDB(t,e){try{const r=await e.objectStore("ziplines").getAll(),i=await e.objectStore("zipEntries").getAll();t.deleteObjectStore("ziplines"),t.deleteObjectStore("zipEntries"),t.createObjectStore("ziplines",{keyPath:["waczname","prefix"]}),t.createObjectStore("waczfiles",{keyPath:"waczname"}),t.createObjectStore("verification",{keyPath:"id"});const n=this.config.loadUrl;for(const t of r)t.waczname=n,e.objectStore("ziplines").put(t);const s=r.length>0?2:1,o=await this.computeHash(n),a=new jn({waczname:n,hash:o,url:n,entries:i,indexType:s});e.objectStore("waczfiles").put(a.serialize()),await e.done}catch(t){console.warn(t)}}addWACZFile(t){return this.waczfiles[t.waczname]=new jn(t),this.waczNameForHash[t.hash]=t.waczname,this.waczfiles[t.waczname]}async init(){await super.init();const t=await this.db.getAll("waczfiles")||[];for(const e of t)this.addWACZFile({...e,parent:this});for(const[t,e]of Object.entries(this.waczfiles)){e.path=e.path||t;const r=e.path.lastIndexOf("#!/");if(r>0){const t=e.path.slice(0,r),i=this.waczfiles[t];e.parent=i}else"json"!==this.rootSourceType&&(e.loader=this.sourceLoader)}await this.checkUpdates()}async close(){super.close(),caches.delete("cache:"+this.name.slice("db:".length))}async clearZipData(){const t=["waczfiles","ziplines"];for(const e of t)await this.db.clear(e)}async addVerifyData(t="",e,r,i,n=!1){let s=null;t&&(e=t+e),i&&(s=r===i,n&&console.log(`verify ${e}: ${s}`)),await this.db.put("verification",{id:e,expected:r,matched:s})}async addVerifyDataList(t,e){const r=this.db.transaction("verification","readwrite");for(const i of e)t&&(i.id=t+i.id),r.store.put(i);try{await r.done}catch(t){console.warn(t)}}async getVerifyInfo(){const t=await this.db.getAll("verification");let e=0,r=0,i={};const n=["domain","created","certFingerprint","software","datapackageHash","publicKey"];for(const s of t)n.includes(s.id)?i[s.id]=s.expected:"signature"===s.id||!0===s.matched?e++:!1===s.matched&&r++;return i.numInvalid=r,i.numValid=e,i}async getVerifyExpected(t){const e=await this.db.get("verification",t);return e&&e.expected}async clearAll(){await super.clearAll(),await this.clearZipData()}async loadRecordFromSource(t){const{start:e,length:r,path:i,wacz:n}=t.source,s={offset:e,length:r,unzip:!0,computeHash:!0},o=n,{reader:a,hasher:c}=await this.loadFileFromNamedWACZ(o,"archive/"+i,s),l=new oi(a,c);await this.waczfiles[o].save(this.db);const u=await l.load();return t[un]&&(u.respHeaders["x-wabac-preset-cookie"]=t[un]),{remote:u,hasher:c}}async loadIndex(t){if(!this.waczfiles[t])throw new Error("unknown waczfile: "+t);if(this.waczfiles[t].indexType)return{indexType:this.waczfiles[t].indexType,isNew:!1};let e=0;for(const r of this.waczfiles[t].iterContainedFiles())r.endsWith(".cdx")||r.endsWith(".cdxj")?(console.log(`Loading CDX for ${t}`),await this.loadCDX(r,t),e=1):r.endsWith(".idx")&&(console.log(`Loading IDX for ${t}`),await this.loadIDX(r,t),e=2);return this.waczfiles[t].indexType=e,await this.waczfiles[t].save(this.db,!0),{indexType:e,isNew:!0}}async loadCDX(t,e,r,i){const{reader:n,hasher:s}=await this.loadFileFromNamedWACZ(e,t,{computeHash:!0}),o=new pn(n,null,e,{wacz:e}),a=await o.load(this,r,i);if(s){const r=await this.getVerifyExpected(t);r&&this.addVerifyData(e,t,r,s.getHash())}return a}async loadIDX(t,e,r,i){const{reader:n,hasher:s}=await this.loadFileFromNamedWACZ(e,t,{computeHash:!0});let o=[],a="",c=!0,l=0;for await(const t of n.iterLines()){if(l+=t.length,l===t.length&&t.startsWith("!meta")){const e=t.indexOf(" {");if(e<0){console.warn("Invalid Meta Line: "+t);continue}const r=JSON.parse(t.slice(e));r.filename&&(a=r.filename),"cdxj-gzip-1.0"!==r.format&&console.log(`Unknown CDXJ format "${r.format}", archive may not parse correctly`);continue}let n;if(t.indexOf("\t")>0){let[r,i,s,o]=t.split("\t");s=Number(s),o=Number(o),n={waczname:e,prefix:r,filename:i,offset:s,length:o,loaded:!1},c=!1}else{const r=t.indexOf(" {");if(r<0){console.log("Invalid Index Line: "+t);continue}const i=t.slice(0,r);let{offset:s,length:o,filename:l,digest:u}=JSON.parse(t.slice(r));c=c&&!Hy.test(i),l=l||a,n={waczname:e,prefix:i,filename:l,offset:s,length:o,digest:u,loaded:!1}}r&&r(l/i,l,i),o.push(n)}if(s){const r=await this.getVerifyExpected(t);r&&this.addVerifyData(e,t,r,s.getHash())}const u=this.db.transaction("ziplines","readwrite");for(const t of o)u.store.put(t);try{await u.done}catch(t){console.log("Error loading ziplines index: ",t)}c&&c!==this.waczfiles[e].nonSurt&&(this.waczfiles[e].nonSurt=c,await this.waczfiles[e].save(this.db,!0))}async loadCDXFromIDX(t,e,r=0,i=!1){const n=this.waczfiles[t].nonSurt?e:M(e),s=i?this.prefixUpperBound(n):n+" 9999",o=IDBKeyRange.upperBound([t,s],!0),a=this.db.transaction("ziplines","readonly"),c=[];for await(const e of a.store.iterate(o,"prev")){if(e.value.waczname!==t)break;if(c.unshift(e.value),!e.value.prefix.split(" ")[0].startsWith(n))break}await a.done;const l=[];c.length>3&&r&&c.sort(((t,e)=>{const i=t.prefix.split(" ")[1],n=e.prefix.split(" ")[1];if(!i||!n)return 0;const s=Math.abs(d(i).getTime()-r),o=Math.abs(d(n).getTime()-r);return s===o?0:s<o?-1:1}));let u=0;for(const e of c){if(e.loaded)continue;const r=t+":"+e.filename+":"+e.offset;let i=this.ziploadercache[r];if(i||(i=this.doCDXLoad(r,e,t),this.ziploadercache[r]=i),l.push(i),++u>3)break}return l.length&&await Promise.allSettled(l),await this.waczfiles[t].save(this.db),l.length>0}async doCDXLoad(t,e,r){try{const i="indexes/"+e.filename,n={offset:e.offset,length:e.length,unzip:!0,computeHash:!!e.digest},{reader:s,hasher:o}=await this.loadFileFromNamedWACZ(r,i,n),a=new pn(s,null,null,{wacz:r});if(await a.load(this),o){const t=o.getHash(),n=`${i}:${e.offset}-${e.length}`;await this.addVerifyData(r,n,e.digest,t)}e.loaded=!0,await this.db.put("ziplines",e)}catch(t){await T(t,this.config)||console.warn(t)}finally{delete this.ziploadercache[t]}}async findPageAtUrl(t,e){const r=await this.db.getAllFromIndex("pages","url",t);let i=null,n=Number.MAX_SAFE_INTEGER;for(const t of r){const r=Math.abs(t.ts-e);if(r<1e3)return t;r<n&&(i=t,n=r)}return i}async lookupUrl(t,e,r={}){try{let i=await super.lookupUrl(t,e,r);if(i&&(!r.noRevisits||"warc/revisit"!==i.mime))return i;const{waczname:n}=r;return n&&"local"!==n&&(i=await this.lookupUrlForWACZ(n,t,e,r)),i}catch(t){return console.warn(t),null}}async lookupUrlForWACZ(t,e,r,i){const{indexType:n,isNew:s}=await this.loadIndex(t);switch(n){case 2:if(!await this.loadCDXFromIDX(t,e,r,!1))return null;break;case 1:if(!s)return null;break;default:return null}return await super.lookupUrl(e,r,i)}async resourcesByUrlAndMime(t,...e){let r=await super.resourcesByUrlAndMime(t,...e);if(r.length>0)return r;for(const i of Object.keys(this.waczfiles))if(i&&"local"!==i){const{indexType:n,isNew:s}=await this.loadIndex(i);switch(n){case 2:if(!await this.loadCDXFromIDX(i,t,0,!0))continue;break;case 1:if(!s)continue;break;default:continue}const o=await super.resourcesByUrlAndMime(t,...e);o&&o.length&&(r=r.concat(o))}return r}async loadFileFromWACZ(t,e,r){try{return await t.loadFile(e,r)}catch(i){if(await this.retryLoad(i))return await t.loadFile(e,r);throw i}}async loadFileFromNamedWACZ(t,e,r){const i=this.waczfiles[t];if(!i)throw new Error("No WACZ Found for: "+t);return await this.loadFileFromWACZ(i,e,r)}async addNewWACZ({name:t,hash:e,path:r,parent:i=null,loader:n=null}={}){const s=t||r;e?e.indexOf(":")>0&&(e=e.split(":")[1]):e=await g(s,"sha-256","");const o=this.addWACZFile({waczname:s,hash:e,path:r,parent:i,loader:n},!0);await o.init(),await o.save(this.db,!0);const a=new Ly(this,o,!i);return await a.load()}async loadWACZFiles(t,e=this){const r=[],i=async(t,e)=>{await this.waczfiles[t].init(e),await this.waczfiles[t].save(this.db,!0)},n=t.resources.map((t=>{const r=e.getLoadPath(t.path);return{name:e.getName(t.name),hash:t.hash,path:r}}));for(const{name:t,hash:s,path:o}of n)this.waczfiles[t]?this.waczfiles[t].path!==o&&r.push(i(t,o)):r.push(this.addNewWACZ({name:t,hash:s,path:o,parent:e}));r.length&&await Promise.allSettled(r)}async getTextIndex(){const t={"Content-Type":"application/ndjson"},e=Object.keys(this.waczfiles);if(!this.textIndex||!e.length)return new Response("",{headers:t});const r=e[0];let i;try{i=await this.loadFileFromNamedWACZ(r,this.textIndex,{unzip:!0})}catch(e){return new Response("",{headers:t})}const{reader:n}=i,s=this.waczfiles[r].getSizeOf(this.textIndex);return s>0&&(t["Content-Length"]=""+s),new Response(n.getReadableStream(),{headers:t})}async getResource(t,e,r,{pageId:i}={}){if(await this.initing,this.externalSource){const i=await this.externalSource.getResource(t,e,r);if(i)return i}const n="navigate"===r.request.mode;let s=i,o=null,a=null;if(s){if(o=this.waczNameForHash[s],!o)return null;a=await super.getResource(t,e,r,{waczname:o})}if(a||!n)return a;let c=null;for(const[i,n]of Object.entries(this.waczfiles))if(n.fileType===Wn&&(a=await super.getResource(t,e,r,{waczname:i,noFuzzyCheck:!0}),a)){o=i,c=n.hash;break}if(o)return Response.redirect(`${e}:${c}/${t.timestamp}mp_/${t.url}`);if(this.fuzzyUrlRules.length)for(const{match:i,replace:n}of this.fuzzyUrlRules){const s=decodeURIComponent(t.url.replace(i,n));if(s&&s!==t.url){t.url=s;const i=await super.getResource(t,e,r);if(i)return i}}return null}async retryLoad(t){return"json"===this.rootSourceType&&(t instanceof x?(this.updating||(this.updating=this.checkUpdates()),await this.updating,this.updating=null,!0):await T(t,this.config))}async checkUpdates(){"json"===this.rootSourceType&&await this.loadFromJSON()}async loadFromJSON(t=null){if(!t){t=(await this.sourceLoader.doInitialFetch(!1)).response}if(206!==t.status&&200!==t.status)return console.warn("WACZ update failed from: "+this.config.loadUrl),{};const e=await t.json();return e.profile,await this.loadWACZFiles(e),e}getLoadPath(t){return new URL(t,this.config.loadUrl).href}getName(t){return t}async createLoader(t){return await Vi(t)}}class jy{constructor(t){const e=t.extraConfig||{};this.sourceUrl=e.prefix,this.type=e.sourceType||"kiwix",this.notFoundPageUrl=e.notFoundPageUrl}async getAllPages(){return[]}async getResource(t,e){const{url:r,headers:i}=t.prepareProxyRequest(e);let n=i;if("kiwix"===this.type){let e=await this.resolveHeaders(r);if(!e)for(const t of Zr.getFuzzyCanonsWithArgs(r))if(t!==r&&(e=await this.resolveHeaders(t),e))break;if(!e){if(this.notFoundPageUrl&&"navigate"===t.mode){const t=await fetch(this.notFoundPageUrl);if(200===t.status){const e={"Content-Type":"text/html"},i=await t.text();return new Response(i.replace("$URL",r),{status:404,headers:e})}}return null}let{headers:i,encodedUrl:s,date:o,status:a,statusText:c,hasPayload:l}=e;if(n.has("Range")){const t=n.get("Range");n={Range:t}}let u=null,h=null;l&&(h=await fetch(this.sourceUrl+"A/"+s,{headers:n}),h.body&&(u=new K(h.body.getReader(),!1)),206===h.status&&(a=206,c="Partial Content",i.set("Content-Length",h.headers.get("Content-Length")),i.set("Content-Range",h.headers.get("Content-Range")),i.set("Accept-Ranges","bytes"))),u||(u=new Uint8Array([])),o||(o=new Date),i||(i=new Headers);return new mt({payload:u,status:a,statusText:c,headers:i,url:r,date:o,noRW:!1,isLive:!1})}}async resolveHeaders(t){const e=t.slice(t.indexOf("//")+2);let r=encodeURI(e);r=encodeURIComponent(e);let i=await fetch(this.sourceUrl+"H/"+r);if(200!==i.status)return null;let n=null,s=null,o=null,a=null,c=!1;try{const e=await ct.parse(i.body);if("revisit"===e.warcType){const r=e.warcHeaders.headers.get("WARC-Refers-To-Target-URI");if(r&&r!==t)return await this.resolveHeaders(r)}s=new Date(e.warcDate),e.httpHeaders?(n=e.httpHeaders.headers,o=Number(e.httpHeaders.statusCode),a=e.httpHeaders.statusText,c="0"!==e.httpHeaders.headers.get("Content-Length")):"resource"===e.warcType&&(n=new Headers,n.set("Content-Type",e.warcContentType),n.set("Content-Length",e.warcContentLength),o=200,a="OK",c=e.warcContentLength>0),o||(o=200)}catch(e){console.warn(e),console.warn("Ignoring headers, error parsing headers response for: "+t)}return{encodedUrl:r,headers:n,date:s,status:o,statusText:a,hasPayload:c}}}const zy=Qy([80,75,3,4]),Gy=Qy([31,139,8]),qy=Qy([87,65,82,67]);function Qy(t){return e=>{for(const[r,i]of t.entries())if(i!==e[r])return!1;return!0}}async function Vy(t){const e=t.body.getReader();let r="";const{value:i,done:n}=await e.read();var s;return!n&&i.length>=4&&(s=i.slice(0,4),r=zy(s)?".wacz":qy(s)?".warc":Gy(s)?".warc.gz":void 0,r||(r=function(t){try{const e=(new TextDecoder).decode(t).split("\n");if(e>1&&e.indexOf(" {"))return".cdxj"}catch(t){return""}}(i))),n||e.cancel(),r}globalThis.self||(globalThis.self=globalThis),self.interruptLoads={};class Ky extends class{constructor(){this.colldb=null,this.root=null,this.checkIpfs=!0,this._init_db=this._initDB()}async _initDB(){this.colldb=await Dr("collDB",1,{upgrade:t=>{t.createObjectStore("colls",{keyPath:"name"}).createIndex("type","type")}})}async loadAll(t){if(await this._init_db,t)for(const e of t.split(",")){const t=e.split(":");if(2===t.length){const e={dbname:t[1],sourceName:t[1],decode:!1},r={name:t[0],type:"archive",config:e};console.log("Adding Coll: "+JSON.stringify(r)),await this.colldb.put("colls",r)}}try{const t=(await this.listAll()).map((t=>this._initColl(t)));await Promise.all(t)}catch(t){console.warn(t.toString())}return!0}async listAll(){return await this._init_db,await this.colldb.getAll("colls")}async loadColl(t){await this._init_db;const e=await this.colldb.get("colls",t);return e?await this._initColl(e):null}async reload(t){return this.loadColl(t)}async deleteColl(t){await this._init_db;const e=await this.colldb.get("colls",t);if(!e)return!1;if(e.config.dbname)try{await Lr(e.config.dbname,{blocked(t,r){console.log(`Unable to delete ${e.config.dbname}, blocked: ${r}`)}})}catch(t){return console.warn(t),!1}return await this.colldb.delete("colls",t),!0}async updateAuth(t,e){await this._init_db;const r=await this.colldb.get("colls",t);return!!r&&(r.config.headers=e,await this.colldb.put("colls",r),!0)}async updateMetadata(t,e){await this._init_db;const r=await this.colldb.get("colls",t);return!!r&&(r.config.metadata={...r.config.metadata,...e},await this.colldb.put("colls",r),r.config.metadata)}async updateSize(t,e,r,i){await this._init_db;const n=await this.colldb.get("colls",t);if(!n)return!1;const s=n.config.metadata;return s.fullSize=(s.fullSize||0)+e,s.size=(s.size||0)+r,s.mtime=(new Date).getTime(),void 0!==i&&(n.config.decode=i),await this.colldb.put("colls",n),s}async initNewColl(t,e={},r="archive"){await this._init_db;const i=m(),n="local://"+i,s={name:i,type:r,config:{dbname:"db:"+i,ctime:(new Date).getTime(),decode:!1,metadata:t,sourceUrl:n,extraConfig:e}},o=await this._initColl(s);return await this.colldb.put("colls",s),o}async _initColl(t){const e=await this._initStore(t.type,t.config),r=t.name,i=t.config;return t.config.root&&!this.root&&(this.root=r),this._createCollection({name:r,store:e,config:i})}async _initStore(t,e){let r=null,i=null;switch(t){case"archive":i=new ei(e.dbname);break;case"remotesource":r=await Vi({url:e.loadUrl,headers:e.headers,size:e.size,extra:e.extra}),i=new nn(e.dbname,r,e.noCache);break;case"remoteprefix":i=new sn(e.dbname,e.remotePrefix,e.headers,e.noCache);break;case"wacz":case"remotezip":case"multiwacz":r=await Vi({url:e.loadUrl||e.sourceUrl,headers:e.headers,extra:e.extra}),i=new Wy(e,r,"multiwacz"===t?"json":"wacz");break;case"remotewarcproxy":i=new jy(e);break;case"live":i=new Fy(e.extraConfig)}return i?(i.initing&&await i.initing,i):(console.log("no store found: "+t),null)}_createCollection(t){return t}}{constructor(t){super(),this.registerListener(t)}async hasCollection(t){return await this._init_db,null!=await this.colldb.getKey("colls",t)}registerListener(t){t.addEventListener("message",(t=>{t.waitUntil?t.waitUntil(this._handleMessage(t)):this._handleMessage(t)}))}async _handleMessage(t){await this._init_db;const e=t.source||self;switch(t.data.msg_type){case"addColl":{const r=t.data.name,i=(t,i,n,s,o=null,a=null)=>{e.postMessage({msg_type:"collProgress",name:r,percent:t,error:i,currentSize:n,totalSize:s,fileHandle:o,extraMsg:a})};let n;try{if(n=await this.colldb.get("colls",r),n?t.data.skipExisting||(await this.deleteColl(r),n=await this.addCollection(t.data,i)):n=await this.addCollection(t.data,i),!n){if(t.data.name)try{await Lr("db:"+t.data.name,{blocked(e,r){console.log(`Load failed and unable to delete ${t.data.name}: ${r}`)}})}catch(t){console.warn(t)}return}}catch(t){if(t instanceof R)return console.warn(t),void i(0,"permission_needed",null,null,t.info&&t.info.fileHandle);if("ConstraintError"!==t.name)return console.warn(t),void i(0,"An unexpected error occured: "+t.toString());console.log("already being added, just continue..."),n=await this.colldb.get("colls",r)}e.postMessage({msg_type:"collAdded",name:r,sourceUrl:n.config.sourceUrl});break}case"cancelLoad":{const e=t.data.name,r=new Promise((t=>self.interruptLoads[e]=t));await r,await this.deleteColl(e),delete self.interruptLoads[e];break}case"removeColl":{const r=t.data.name;await this.hasCollection(r)&&(await this.deleteColl(r),this.doListAll(e));break}case"listAll":this.doListAll(e);break;case"reload":this.reload(t.data.name)}}async doListAll(t){const e=[],r=await this.listAll();for(const t of r)e.push({name:t.name,prefix:t.name,pageList:[],sourceName:t.config.sourceName});t.postMessage({msg_type:"listAll",colls:e})}async addCollection(t,e){let r=t.name,i=null,n={root:t.root||!1},s=null,o=null;const c=t.file;if(!c||!c.sourceUrl)return e(0,"Invalid Load Request"),!1;if(n.dbname="db:"+r,c.sourceUrl.startsWith("proxy:"))n.sourceUrl=c.sourceUrl.slice("proxy:".length),n.extraConfig=t.extraConfig,n.extraConfig.prefix||(n.extraConfig.prefix=n.sourceUrl),n.topTemplateUrl=t.topTemplateUrl,n.metadata={},i=t.type||n.extraConfig.type||"remotewarcproxy",s=await this._initStore(i,n);else{let l=null;if(c.newFullImport&&(r=m(),c.loadUrl=c.loadUrl||c.sourceUrl,c.name=c.name||c.sourceUrl,c.sourceUrl="local://"+r),i="archive",c.newFullImport&&c.importCollId){const t=await this.colldb.get("colls",c.importCollId);if(!t||"archive"!==t.type)return void e(0,"Invalid Existing Collection: "+c.importCollId);n.dbname=t.config.dbname,o=t.config,o.decode=!0}let u=c.loadUrl||c.sourceUrl;u.match(/[\w]+:\/\//)||(u=new URL(u,self.location.href).href),n.decode=!0,n.onDemand=!1,n.loadUrl=u,n.sourceUrl=c.sourceUrl,n.sourceName=c.name||c.sourceUrl;try{if(n.sourceName.match(/https?:\/\//)){const t=new URL(n.sourceName);n.sourceName=t.pathname+t.hash}}catch(t){}if(n.sourceName=n.sourceName.slice(n.sourceName.lastIndexOf("/")+1),n.size="number"==typeof c.size?c.size:null,n.extra=c.extra,n.loadUrl.startsWith("file://")&&!c.blob&&!n.extra){if(!this._fileHandles||!this._fileHandles[n.sourceUrl])return void e(0,"missing_local_file");n.extra={fileHandle:this._fileHandles[n.sourceUrl]}}n.extraConfig=t.extraConfig,n.headers=c.headers||n.extraConfig&&n.extraConfig.headers,n.noCache=c.noCache;let h=await Vi({url:u,headers:n.headers,size:c.size,extra:n.extra,blob:c.blob});if(c.loadEager){const{response:t}=await h.doInitialFetch(!1,!0),e={arrayBuffer:new Uint8Array(await t.arrayBuffer())};c.newFullImport=!0,h=await Vi({url:u,headers:n.headers,size:c.size,extra:e})}let p=function(t){const e=[".warc",".warc.gz",".cdx",".cdxj",".har",".json",".wacz",".zip"];for(const r of e)if(t.endsWith(r))return r;return""}(n.sourceName),{abort:d,response:f}=await h.doInitialFetch(".wacz"===p);p||(p=await Vy(await f.clone()));const g=f.body;if(n.onDemand=h.canLoadOnDemand&&!c.newFullImport,!h.isValid){const t=h.length<=1e3?await f.text():"";return e(0,`Sorry, this URL could not be loaded.\nMake sure this is a valid URL and you have access to this file.\nStatus: ${f.status} ${f.statusText}\nError Details:\n${t}`),d&&d.abort(),!1}if(!h.length)return e(0,"Sorry, this URL could not be loaded because the size of the file is not accessible.\nMake sure this is a valid URL and you have access to this file."),d&&d.abort(),!1;const w=h.length;if(".wacz"===p)if(n.onDemand)l=new Py(h,n,r),s=new Wy(n,h,"wacz"),i="wacz";else{if(!h.canLoadOnDemand||!c.newFullImport)return e(0,"Sorry, can't load this WACZ file due to lack of range request support on the server"),d&&d.abort(),!1;l=new Uy(h,n,r),s=null,delete n.extra}else".warc"===p||".warc.gz"===p?n.noCache||!(w<a)&&n.onDemand?(l=new hn(g,d,r),i="remotesource",s=new nn(n.dbname,h,n.noCache)):l=new si(g,d,r):".cdx"===p||".cdxj"===p?(n.remotePrefix=t.remotePrefix||u.slice(0,u.lastIndexOf("/")+1),l=new pn(g,d,r),i="remoteprefix",s=new sn(n.dbname,n.remotePrefix,n.headers,n.noCache)):".har"===p?(l=new ln(await f.json()),n.decode=!1):".json"===p&&(s=new Wy(n,h,"json"),l=new My(f),i="multiwacz");if(!l)return e(0,`The ${n.sourceName} is not a known archive format that could be loaded.`),d&&d.abort(),!1;s||(s=new ei(n.dbname)),await s.initing;try{n.metadata=await l.load(s,e,w)}catch(t){return t instanceof N||(e(0,`Unexpected Loading Error: ${t.toString()}`),console.warn(t)),!1}if(o)return await this.updateSize(c.importCollId,w,w,o.decode),{config:o};n.metadata.size||(n.metadata.size=w),n.metadata.title||(n.metadata.title=n.sourceName)}n.ctime=(new Date).getTime(),this._fileHandles&&n.extra&&n.extra.fileHandle&&delete this._fileHandles[n.sourceUrl];const l={name:r,type:i,config:n};return await this.colldb.add("colls",l),l.store=s,l}}class Yy{constructor(){this.timeRanges={}}updateStats(t,e,r,i){const n=i.clientId||i.resultingClientId;if(!n||!t)return;if(!r.url||r.url.indexOf("mp_/")<0)return;if("document"===r.destination&&e>300&&e<400)return;let s=null;void 0===this.timeRanges[n]?(s={count:0,children:[]},this.timeRanges[n]=s,r.referrer.indexOf("mp_/")>0&&self.clients.matchAll({type:"window"}).then((t=>this.updateStatsParent(n,r.referrer,t)))):s=this.timeRanges[n];const o=t.getTime();(!s.min||o<s.min)&&(s.min=o),(!s.max||o>s.max)&&(s.max=o),s.count++}updateStatsParent(t,e,r){for(let i of r)if(i.url===e){this.timeRanges[i.id]?this.timeRanges[i.id].children[t]=1:this.timeRanges[i.id]={count:0,children:{id:1}};break}}async getStats(t){const e=new URL(t.request.url);let r=0;const i=new URLSearchParams(e.search).get("url"),n=await self.clients.matchAll({type:"window"}),s={};for(let t of n)t.url===i&&(r=t.id),s[t.id]=1;const o=this.timeRanges[r]||{},a={count:o.count||0,min:o.min,max:o.max},c=this.timeRanges[r]&&Object.keys(this.timeRanges[r].children)||[];for(let t of c){const e=this.timeRanges[t];e&&((!a.min||e.min<a.min)&&(a.min=e.min),(!a.max||e.max>a.max)&&(a.max=e.max),a.count+=e.count)}for(let t of Object.keys(this.timeRanges))s[t]||delete this.timeRanges[t];return new Response(JSON.stringify(a),{headers:{"Content-Type":"application/json"}})}}var Jy=function(){return Jy=Object.assign||function(t){for(var e,r=1,i=arguments.length;r<i;r++)for(var n in e=arguments[r])Object.prototype.hasOwnProperty.call(e,n)&&(t[n]=e[n]);return t},Jy.apply(this,arguments)};var Xy=function(t){return void 0===t&&(t={}),{arrayFormat:t.arrayFormat||"none",booleanFormat:t.booleanFormat||"none",nullFormat:t.nullFormat||"default"}},Zy=function(t){return encodeURIComponent(t)},$y=function(t){return decodeURIComponent(t)},tm=function(t,e,r){return null===e?function(t,e){return"hidden"===e.nullFormat?"":"string"===e.nullFormat?t+"=null":t}(t,r):"boolean"==typeof e?function(t,e,r){return"empty-true"===r.booleanFormat&&e?t:t+"="+("unicode"===r.booleanFormat?e?"✓":"✗":e.toString())}(t,e,r):Array.isArray(e)?function(t,e,r){var i=function(t){return"index"===t.arrayFormat?function(t,e){return t+"["+e+"]"}:"brackets"===t.arrayFormat?function(t){return t+"[]"}:function(t){return t}}(r);return e.map((function(e,r){return i(t,r)+"="+Zy(e)})).join("&")}(t,e,r):t+"="+Zy(e)},em=function(t){var e=t.indexOf("?");return-1===e?t:t.slice(e+1)},rm=function(t){var e=t.indexOf("["),r=-1!==e;return{hasBrackets:r,name:r?t.slice(0,e):t}},im=function(t,e){var r=Xy(e);return em(t).split("&").reduce((function(t,e){var i=e.split("="),n=i[0],s=i[1],o=rm(n),a=o.hasBrackets,c=o.name,l=t[c],u=function(t,e){if(void 0===t)return"empty-true"===e.booleanFormat||null;if("string"===e.booleanFormat){if("true"===t)return!0;if("false"===t)return!1}if("unicode"===e.booleanFormat){if("✓"===$y(t))return!0;if("✗"===$y(t))return!1}return"string"===e.nullFormat&&"null"===t?null:$y(t)}(s,r);return t[c]=void 0===l?a?[u]:u:(Array.isArray(l)?l:[l]).concat(u),t}),{})},nm=/[^!$'()*+,;|:]/g,sm=function(t){return t.replace(nm,(function(t){return encodeURIComponent(t)}))},om={default:sm,uri:encodeURI,uriComponent:encodeURIComponent,none:function(t){return t},legacy:encodeURI},am={default:decodeURIComponent,uri:decodeURI,uriComponent:decodeURIComponent,none:function(t){return t},legacy:decodeURIComponent},cm=function(t,e,r){var i=om[e]||sm;return r?String(t).split("/").map(i).join("/"):i(String(t))},lm=function(t){return"("+(t?t.replace(/(^<|>$)/g,""):"[a-zA-Z0-9-_.~%':|=+\\*@$]+")+")"},um=[{name:"url-parameter",pattern:/^:([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})(<(.+?)>)?/,regex:function(t){return new RegExp(lm(t[2]))}},{name:"url-parameter-splat",pattern:/^\*([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})/,regex:/([^?]*)/},{name:"url-parameter-matrix",pattern:/^;([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})(<(.+?)>)?/,regex:function(t){return new RegExp(";"+t[1]+"="+lm(t[2]))}},{name:"query-parameter",pattern:/^(?:\?|&)(?::)?([a-zA-Z0-9-_]*[a-zA-Z0-9]{1})/},{name:"delimiter",pattern:/^(\/|\?)/,regex:function(t){return new RegExp("\\"+t[0])}},{name:"sub-delimiter",pattern:/^(!|&|-|_|\.|;)/,regex:function(t){return new RegExp(t[0])}},{name:"fragment",pattern:/^([0-9a-zA-Z]+)/,regex:function(t){return new RegExp(t[0])}}],hm=function t(e,r){if(void 0===r&&(r=[]),!um.some((function(i){var n=e.match(i.pattern);return!!n&&(r.push({type:i.name,match:n[0],val:n.slice(1,2),otherVal:n.slice(2),regex:i.regex instanceof Function?i.regex(n):i.regex}),n[0].length<e.length&&(r=t(e.substr(n[0].length),r)),!0)})))throw new Error("Could not parse path '"+e+"'");return r},pm=function(t){return null!=t},dm={urlParamsEncoding:"default"},fm=function(){function t(t,e){if(!t)throw new Error("Missing path in Path constructor");this.path=t,this.options=Jy(Jy({},dm),e),this.tokens=hm(t),this.hasUrlParams=this.tokens.filter((function(t){return/^url-parameter/.test(t.type)})).length>0,this.hasSpatParam=this.tokens.filter((function(t){return/splat$/.test(t.type)})).length>0,this.hasMatrixParams=this.tokens.filter((function(t){return/matrix$/.test(t.type)})).length>0,this.hasQueryParams=this.tokens.filter((function(t){return/^query-parameter/.test(t.type)})).length>0,this.spatParams=this.getParams("url-parameter-splat"),this.urlParams=this.getParams(/^url-parameter/),this.queryParams=this.getParams("query-parameter"),this.params=this.urlParams.concat(this.queryParams),this.source=this.tokens.filter((function(t){return void 0!==t.regex})).map((function(t){return t.regex.source})).join("")}return t.createPath=function(e,r){return new t(e,r)},t.prototype.isQueryParam=function(t){return-1!==this.queryParams.indexOf(t)},t.prototype.isSpatParam=function(t){return-1!==this.spatParams.indexOf(t)},t.prototype.test=function(t,e){var r=this,i=Jy(Jy({caseSensitive:!1,strictTrailingSlash:!1},this.options),e),n=function(t,e){return e||"\\/"===t?t:t.replace(/\\\/$/,"")+"(?:\\/)?"}(this.source,i.strictTrailingSlash),s=this.urlTest(t,n+(this.hasQueryParams?"(\\?.*$|$)":"$"),i.caseSensitive,i.urlParamsEncoding);if(!s||!this.hasQueryParams)return s;var o=im(t,i.queryParams);return 0===Object.keys(o).filter((function(t){return!r.isQueryParam(t)})).length?(Object.keys(o).forEach((function(t){return s[t]=o[t]})),s):null},t.prototype.partialTest=function(t,e){var r=this,i=Jy(Jy({caseSensitive:!1,delimited:!0},this.options),e),n=function(t,e){return e?/(\/)$/.test(t)?t:t+"(\\/|\\?|\\.|;|$)":t}(this.source,i.delimited),s=this.urlTest(t,n,i.caseSensitive,i.urlParamsEncoding);if(!s)return s;if(!this.hasQueryParams)return s;var o=im(t,i.queryParams);return Object.keys(o).filter((function(t){return r.isQueryParam(t)})).forEach((function(t){return function(t,e,r){void 0===r&&(r="");var i=t[e];return t[e]=void 0===i?r:Array.isArray(i)?i.concat(r):[i,r],t}(s,t,o[t])})),s},t.prototype.build=function(t,e){var r=this;void 0===t&&(t={});var i=Jy(Jy({ignoreConstraints:!1,ignoreSearch:!1,queryParams:{}},this.options),e),n=Object.keys(t).filter((function(t){return!r.isQueryParam(t)})).reduce((function(e,n){if(!pm(t[n]))return e;var s=t[n],o=r.isSpatParam(n);return"boolean"==typeof s?e[n]=s:Array.isArray(s)?e[n]=s.map((function(t){return cm(t,i.urlParamsEncoding,o)})):e[n]=cm(s,i.urlParamsEncoding,o),e}),{});if(this.urlParams.some((function(e){return!pm(t[e])}))){var s=this.urlParams.filter((function(e){return!pm(t[e])}));throw new Error("Cannot build path: '"+this.path+"' requires missing parameters { "+s.join(", ")+" }")}if(!i.ignoreConstraints&&!this.tokens.filter((function(t){return/^url-parameter/.test(t.type)&&!/-splat$/.test(t.type)})).every((function(t){return new RegExp("^"+lm(t.otherVal[0])+"$").test(n[t.val])})))throw new Error("Some parameters of '"+this.path+"' are of invalid format");var o=this.tokens.filter((function(t){return!1===/^query-parameter/.test(t.type)})).map((function(t){return"url-parameter-matrix"===t.type?";"+t.val+"="+n[t.val[0]]:/^url-parameter/.test(t.type)?n[t.val[0]]:t.match})).join("");if(i.ignoreSearch)return o;var a=function(t,e){var r=Xy(e);return Object.keys(t).filter((function(e){return function(t){return void 0!==t}(t[e])})).map((function(e){return tm(e,t[e],r)})).filter(Boolean).join("&")}(this.queryParams.filter((function(e){return-1!==Object.keys(t).indexOf(e)})).reduce((function(e,r){return e[r]=t[r],e}),{}),i.queryParams);return a?o+"?"+a:o},t.prototype.getParams=function(t){var e=t instanceof RegExp?function(e){return t.test(e.type)}:function(e){return e.type===t};return this.tokens.filter(e).map((function(t){return t.val[0]}))},t.prototype.urlTest=function(t,e,r,i){var n=this,s=new RegExp("^"+e,r?"":"i"),o=t.match(s);return o?this.urlParams.length?o.slice(1,this.urlParams.length+1).reduce((function(t,e,r){return t[n.urlParams[r]]=(am[i]||decodeURIComponent)(e),t}),{}):{}:null},t}();class gm{constructor(t){this.routes={};for(const[e,r]of Object.entries(t)){let t,i;r instanceof Array?(t=r[0],i=r[1]||"GET"):(t=r,i="GET"),this.routes[i]=this.routes[i]||{},this.routes[i][e]=new fm(t)}}match(t,e="GET"){for(const[r,i]of Object.entries(this.routes[e]||[])){const e=t.split("?",2),n=e[0],s=i.test(n);if(s)return s._route=r,s._query=new URLSearchParams(2===e.length?e[1]:""),s}return{_route:null}}}class wm{constructor(t){this.router=new gm(this.routes),this.collections=t}get routes(){return{index:"coll-index",coll:"c/:coll",urls:"c/:coll/urls",createColl:["c/create","POST"],deleteColl:["c/:coll","DELETE"],updateAuth:["c/:coll/updateAuth","POST"],updateMetadata:["c/:coll/metadata","POST"],curated:"c/:coll/curated/:list",pages:"c/:coll/pages",textIndex:"c/:coll/textIndex",deletePage:["c/:coll/page/:page","DELETE"]}}async apiResponse(t,e,r){const i=this.router.match(t,e.method),n=await this.handleApi(e,i,r);if(n instanceof Response)return n;const s=n.error?404:200;return this.makeResponse(n,s)}async handleApi(t,e){switch(e._route){case"index":return await this.listAll(e._query.get("filter"));case"createColl":{const e=await t.json();return I(await this.collections.initNewColl(e.metadata||{},e.extraConfig||{}))}case"coll":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const r=I(t);return"1"===e._query.get("all")?(t.store.db?(r.pages=await t.store.getAllPages(),r.lists=await t.store.db.getAll("pageLists"),r.curatedPages=await t.store.db.getAll("curatedPages")):(r.pages=[],r.lists=[],r.curatedPages=[]),r.verify=await t.store.getVerifyInfo()):(r.numLists=await t.store.db.count("pageLists"),r.numPages=await t.store.db.count("pages")),t.config.metadata.ipfsPins&&(r.ipfsPins=t.config.metadata.ipfsPins),r}case"deleteColl":{const t="1"===e._query.get("reload");return await this.collections.deleteColl(e.coll,t)?await this.listAll():{error:"collection_not_found"}}case"updateAuth":{const r=await t.json();return{success:await this.collections.updateAuth(e.coll,r.headers)}}case"updateMetadata":{const r=await t.json();return{metadata:await this.collections.updateMetadata(e.coll,r)}}case"urls":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const r=e._query.get("url"),i=Number(e._query.get("count")||100),n=e._query.get("mime"),s="1"===e._query.get("prefix"),o=e._query.get("fromUrl"),a=e._query.get("fromTs"),c=e._query.get("fromMime"),l=Number(e._query.get("fromStatus")||0);if(!t.store.resourcesByMime)return{urls:[]};let u;return u=r?await t.store.resourcesByUrlAndMime(r,n,i,s,o,a):await t.store.resourcesByMime(n,i,c,o,l),u=u||[],{urls:u}}case"pages":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};return{pages:await t.store.getAllPages()}}case"textIndex":{const t=await this.collections.getColl(e.coll);return t?t.store.getTextIndex?await t.store.getTextIndex():{}:{error:"collection_not_found"}}case"curated":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const r=Number(e.list);return{curated:await t.store.db.getAllFromIndex("curatedPages","listPages",IDBKeyRange.bound([r],[r+1]))}}case"deletePage":{const t=await this.collections.getColl(e.coll);if(!t)return{error:"collection_not_found"};const{pageSize:r,deleteSize:i}=t.store.deletePage(e.page);return this.collections.updateSize(e.coll,r,i),{pageSize:r,deleteSize:i}}default:return{error:"not_found"}}}async listAll(t){const e=await this.collections.listAll(),r=[];return e.forEach((e=>{"live"!==e.type&&"remoteproxy"!==e.type&&(t&&0!==e.type.indexOf(t)||r.push(I(e)))})),{colls:r}}makeResponse(t,e=200){return new Response(JSON.stringify(t),{status:e,headers:{"Content-Type":"application/json"}})}}const ym=/^(?::([\w-]+)\/)?(\d*)([a-z]+_|[$][a-z0-9:.-]+)?(?:\/|\||%7C|%7c)(.+)/;class mm{constructor(t,e,{isRoot:r=!1,mod:i="",ts:n="",proxyOrigin:s=null,localOrigin:o=null}={}){const a=ym.exec(t);if(this.url="",this.timestamp=n,this.mod=i,this.pageId="",this.hash="",!a&&(t.startsWith("https:")||t.startsWith("http:")||t.startsWith("blob:")))this.url=t;else if(!a&&r)this.url="https://"+t;else{if(!a)return void(this.url=null);this.pageId=a[1]||"",this.timestamp=a[2],this.mod=a[3],this.url=a[4]}if(s&&o){const t=new URL(this.url);t.origin===o&&(this.url=s+t.pathname+(t.search?t.search:""))}const c=this.url.indexOf("#");c>0&&(this.hash=this.url.slice(c),this.url=this.url.substring(0,c)),this.request=e,this.method=e.method,this.mode=e.mode,this._postToGetConverted=!1}get headers(){return this.request.headers}get destination(){return this.request.destination}get referrer(){return this.request.referrer}async convertPostToGet(){if(this._postToGetConverted)return this.url;const t=this.request;if("POST"!==t.method&&"PUT"!==t.method)return this.url;const e={method:t.method,postData:await t.text(),headers:t.headers,url:this.url};return F(e)&&(this.url=e.url,this.method="GET",this.mode="navigate"===this.request.mode?"same-origin":this.request.mode,this._postToGetConverted=!0),this.url}prepareProxyRequest(t,e=!0){let r,i,n;if(e){r=new Headers(this.request.headers),i=this.request.referrer;const e=i.indexOf("/http",t.length-1);e>0&&(i=i.slice(e+1),r.set("X-Proxy-Referer",i)),n=this.request.credentials,this.cookie&&r.set("X-Proxy-Cookie",this.cookie)}else r=new Headers,n="omit";let s=this.url;if(s.startsWith("//"))try{s=new URL(i).protocol+s}catch(t){s="https:"+s}return{referrer:i,headers:r,credentials:n,url:s}}async getBody(){const t=this.request.clone();return new Uint8Array(await t.arrayBuffer())}}const bm="x-wabac-is-ajax-req";class Am extends Ky{constructor(t,e=null,r={}){super(self),this.prefixes=t,this.colls={},this.inited=null,this.root=e,this.defaultConfig=r,this._fileHandles={}}_createCollection(t){return new br(t,this.prefixes,this.defaultConfig)}loadAll(t){return this.colls={},this.inited=super.loadAll(t),this.inited}async getColl(t){return this.colls[t]||(this.colls[t]=await this.loadColl(t)),this.colls[t]}async reload(t){delete this.colls[t],await this.getColl(t)}async addCollection(t,e){const r=await super.addCollection(t,e);return r&&r.name&&(this.colls[r.name]=this._createCollection(r)),r}async deleteColl(t,e=!1){return this.colls[t]&&(this.colls[t].store&&this.colls[t].store.delete&&await this.colls[t].store.delete(),e&&this.colls[t].config&&this.colls[t].config.extra&&this.colls[t].config.extra.fileHandle&&(this._fileHandles[this.colls[t].config.sourceUrl]=this.colls[t].config.extra.fileHandle)),!!await super.deleteColl(t)&&(delete this.colls[t],!0)}async initNewColl(t,e={},r="archive"){const i=await super.initNewColl(t,e,r);return i&&(this.colls[i.name]=i),i}async updateAuth(t,e){this.colls[t]&&this.colls[t].store.updateHeaders&&this.colls[t].store.updateHeaders(e),await super.updateAuth(t,e)}async updateMetadata(t,e){const r=await super.updateMetadata(t,e);return this.colls[t]&&r&&(this.colls[t].config.metadata=r,this.colls[t].metadata=r),r}async updateSize(t,e,r,i){const n=await super.updateSize(t,e,r,i);return this.colls[t]&&n&&(this.colls[t].config.metadata=n,this.colls[t].metadata=n),void 0!==i&&this.colls[t]&&(this.colls[t].config.decode=i),n}}class Em{constructor({staticData:t=null,ApiClass:e=wm,defaultConfig:r={},CollectionsClass:i=Am}={}){this.prefix=self.registration?self.registration.scope:"",this.replayPrefix=this.prefix;const n=new URLSearchParams(self.location.search);let s="w";n.has("replayPrefix")&&(s=n.get("replayPrefix")),s&&(this.replayPrefix+=s+"/"),this.staticPrefix=this.prefix+"static/",this.distPrefix=this.prefix+"dist/";const o={static:this.staticPrefix,root:this.prefix,main:this.replayPrefix};this.staticData=t||new Map,this.staticData.set(this.staticPrefix+"wombat.js",{type:"application/javascript",content:'/*! wombat.js is part of Webrecorder project. Copyright (C) 2020-2023, Webrecorder Software. Licensed under the Affero General Public License v3. */(()=>{"use strict";function t(){this._map=[]}function e(t,e){void 0!==self.Symbol&&void 0!==self.Symbol.toStringTag&&Object.defineProperty(t.prototype,self.Symbol.toStringTag,{value:e,enumerable:!1})}function r(t){for(var e,r,i=t.__proto__||t.constructor.prototype||t.prototype,o=Object.getOwnPropertyNames(i),n=o.length,s=0;s<n;s++)r=t[e=o[s]],"constructor"!==e&&"function"==typeof r&&(t[e]=r.bind(t))}t.prototype.set=function(t,e){this._map.push([t,e])},t.prototype.get=function(t){for(var e=0;e<this._map.length;e++)if(this._map[e][0]===t)return this._map[e][1];return null},t.prototype.find=function(t){for(var e=0;e<this._map.length;e++)if(this._map[e][0]===t)return e;return-1},t.prototype.add_or_get=function(t,e){var r=this.get(t);return r||(r=e(),this.set(t,r)),r},t.prototype.remove=function(t){var e=this.find(t);return e>=0?this._map.splice(e,1)[0][1]:null},t.prototype.map=function(t){for(var e=0;e<this._map.length;e++)this._map[e][1](t)};var i={yes:!1},o=Symbol("__wb__storage_WOMBAT"),n=Symbol("__wb__storage_TYPE");function s(t,e,r){if(i.yes)throw new TypeError("Illegal constructor");if(r&&r.length)for(var s=0;s<r.length;s++)this[r[s][0]]=r[s][1].toString();Object.defineProperty(this,o,{value:t,enumerable:!1}),Object.defineProperty(this,n,{value:e,enumerable:!1})}function a(t,e,r){var i=new s(t,e,r);return t.$wbwindow.Proxy&&(i=new t.$wbwindow.Proxy(i,{get:function(t,e){var r=t.__proto__;if("__proto__"===e)return r;if(r.hasOwnProperty(e)||r.__proto__&&r.__proto__.hasOwnProperty(e)){var i=t[e];return"function"==typeof i&&(i=i.bind(t)),i}return t.hasOwnProperty(e)?t.getItem(e):void 0},set:function(t,e,r){return t.__proto__.hasOwnProperty(e)?(t[e]=r,!0):(t.setItem(e,r),!0)}})),t.defGetterProp(t.$wbwindow,e,(function(){return i})),i}function h(t,e){for(var r in Object.defineProperties(this,{_orig_loc:{configurable:!0,enumerable:!1,value:t},wombat:{configurable:!0,enumerable:!1,value:e},orig_getter:{enumerable:!1,value:function(t){return this._orig_loc[t]}},orig_setter:{enumerable:!1,value:function(t,e){this._orig_loc[t]!=e&&(this._orig_loc[t]=e)}}}),e.initLocOverride(this,this.orig_setter,this.orig_getter),e.setLoc(this,t.href),t)this.hasOwnProperty(r)||"function"==typeof t[r]||(this[r]=t[r])}function w(t,e){if(!(this instanceof w))return new w(t,e);this.elemSelector="img[srcset], img[data-srcset], img[data-src], video[srcset], video[data-srcset], video[data-src], audio[srcset], audio[data-srcset], audio[data-src], picture > source[srcset], picture > source[data-srcset], picture > source[data-src], video > source[srcset], video > source[data-srcset], video > source[data-src], audio > source[srcset], audio > source[data-srcset], audio > source[data-src]",this.wombat=t,this.$wbwindow=t.$wbwindow,this.worker=null,r(this),this._initWorker(e)}function p(t,e){return function(r){if(window==e)return t(r)}}function c(t,e,r){var i;return i="function"==typeof t?t:"object"==typeof t?t.handleEvent.bind(t):function(){},function(t){var o;if(t.data&&t.data.from&&t.data.message){if("*"!==t.data.to_origin&&e.WB_wombat_location&&!r.startsWith(t.data.to_origin,e.WB_wombat_location.origin))return void console.warn("Skipping message event to "+t.data.to_origin+" doesn\'t start with origin "+e.WB_wombat_location.origin);var n=t.source;t.data.from_top?n=e.__WB_top_frame:t.data.src_id&&e.__WB_win_id&&e.__WB_win_id[t.data.src_id]&&(n=e.__WB_win_id[t.data.src_id]),(o=new MessageEvent("message",{bubbles:t.bubbles,cancelable:t.cancelable,data:t.data.message,origin:t.data.from,lastEventId:t.lastEventId,source:r.proxyToObj(n),ports:t.ports}))._target=t.target,o._srcElement=t.srcElement,o._currentTarget=t.currentTarget,o._eventPhase=t.eventPhase}else o=t;return i(o)}}function l(t){let e;e="string"==typeof t?t:t&&t.length?t.reduce(((t,e)=>t+=String.fromCharCode(e)),""):t?t.toString():"";try{return"__wb_post_data="+btoa(e)}catch{return"__wb_post_data="}}function _(t){let{method:e,headers:r,postData:i}=t;if("GET"===e)return!1;function o(t){return t instanceof Uint8Array&&(t=(new TextDecoder).decode(t)),t}let n="";switch((r.get("content-type")||"").split(";")[0]){case"application/x-www-form-urlencoded":n=o(i);break;case"application/json":n=d(o(i));break;case"text/plain":try{n=d(o(i),!1)}catch{n=l(i)}break;case"multipart/form-data":{let t=r.get("content-type");if(!t)throw new Error("utils cannot call postToGetURL when missing content-type header");n=function(t,e){return function(t,e){let r=new URLSearchParams;t instanceof Uint8Array&&(t=(new TextDecoder).decode(t));try{let i=e.split("boundary=")[1],o=t.split(new RegExp("-*"+i+"-*","mi"));for(let t of o){let e=t.trim().match(/name="([^"]+)"\\r\\n\\r\\n(.*)/im);e&&r.set(e[1],e[2])}}catch{}return r}(t,e).toString()}(o(i),t);break}default:n=l(i)}return null!==n&&(t.url=function(t,e,r){if(!r)return t;let i=t.indexOf("?")>0?"&":"?";return`${t}${i}__wb_method=${r}&${e}`}(t.url,n,t.method),t.method="GET",t.requestBody=n,!0)}function u(t,e=!0){if("string"==typeof t)try{t=JSON.parse(t)}catch{t={}}let r=new URLSearchParams,i={};try{JSON.stringify(t,((t,e)=>(["object","function"].includes(typeof e)||r.set((t=>r.has(t)?(t in i||(i[t]=1),t+"."+ ++i[t]+"_"):t)(t),e),e)))}catch(t){if(!e)throw t}return r}function d(t,e=!0){return u(t,e).toString()}function f(e,i){if(!(this instanceof f))return new f(e,i);this.debug_rw=!1,this.$wbwindow=e,this.WBWindow=Window,this.origHost=e.location.host,this.origHostname=e.location.hostname,this.origProtocol=e.location.protocol,this.HTTP_PREFIX="http://",this.HTTPS_PREFIX="https://",this.REL_PREFIX="//",this.VALID_PREFIXES=[this.HTTP_PREFIX,this.HTTPS_PREFIX,this.REL_PREFIX],this.IGNORE_PREFIXES=["#","about:","data:","blob:","mailto:","javascript:","{","*"],"ignore_prefixes"in i&&(this.IGNORE_PREFIXES=this.IGNORE_PREFIXES.concat(i.ignore_prefixes)),this.WB_CHECK_THIS_FUNC="_____WB$wombat$check$this$function_____",this.WB_ASSIGN_FUNC="_____WB$wombat$assign$function_____",this.wb_setAttribute=e.Element.prototype.setAttribute,this.wb_getAttribute=e.Element.prototype.getAttribute,this.wb_funToString=Function.prototype.toString,this.WBAutoFetchWorker=null,this.wbUseAFWorker=i.enable_auto_fetch&&null!=e.Worker&&i.is_live,this.wb_rel_prefix="",this.wb_wombat_updating=!1,this.message_listeners=new t,this.storage_listeners=new t,this.linkAsTypes={script:"js_",worker:"js_",style:"cs_",image:"im_",document:"if_",fetch:"mp_",font:"oe_",audio:"oe_",video:"oe_",embed:"oe_",object:"oe_",track:"oe_","":"mp_",null:"mp_",undefined:"mp_"},this.linkTagMods={linkRelToAs:{import:this.linkAsTypes,preload:this.linkAsTypes},stylesheet:"cs_",null:"mp_",undefined:"mp_","":"mp_"},this.tagToMod={A:{href:"mp_"},AREA:{href:"mp_"},AUDIO:{src:"oe_",poster:"im_"},BASE:{href:"mp_"},EMBED:{src:"oe_"},FORM:{action:"mp_"},FRAME:{src:"fr_"},IFRAME:{src:"if_"},IMAGE:{href:"im_","xlink:href":"im_"},IMG:{src:"im_",srcset:"im_"},INPUT:{src:"oe_"},INS:{cite:"mp_"},META:{content:"mp_"},OBJECT:{data:"oe_",codebase:"oe_"},Q:{cite:"mp_"},SCRIPT:{src:"js_","xlink:href":"js_"},SOURCE:{src:"oe_",srcset:"oe_"},TRACK:{src:"oe_"},VIDEO:{src:"oe_",poster:"im_"},image:{href:"im_","xlink:href":"im_"}},this.URL_PROPS=["href","hash","pathname","host","hostname","protocol","origin","search","port"],this.wb_info=i,this.wb_opts=i.wombat_opts,this.wb_replay_prefix=i.prefix,this.wb_is_proxy=this.wb_info.proxy_magic||!this.wb_replay_prefix,this.wb_info.top_host=this.wb_info.top_host||"*",this.wb_curr_host=e.location.protocol+"//"+e.location.host,this.wb_info.wombat_opts=this.wb_info.wombat_opts||{},this.wb_orig_scheme=this.wb_info.wombat_scheme+"://",this.wb_orig_origin=this.wb_orig_scheme+this.wb_info.wombat_host,this.wb_abs_prefix=this.wb_replay_prefix,this.wb_capture_date_part="",!this.wb_info.is_live&&this.wb_info.wombat_ts&&(this.wb_capture_date_part="/"+this.wb_info.wombat_ts+"/"),this.BAD_PREFIXES=["http:"+this.wb_replay_prefix,"https:"+this.wb_replay_prefix,"http:/"+this.wb_replay_prefix,"https:/"+this.wb_replay_prefix],this.hostnamePortRe=/^[\\w-]+(\\.[\\w-_]+)+(:\\d+)(\\/|$)/,this.ipPortRe=/^\\d+\\.\\d+\\.\\d+\\.\\d+(:\\d+)?(\\/|$)/,this.workerBlobRe=/__WB_pmw\\(.*?\\)\\.(?=postMessage\\()/g,this.rmCheckThisInjectRe=/_____WB\\$wombat\\$check\\$this\\$function_____\\(.*?\\)/g,this.STYLE_REGEX=/(url\\s*\\(\\s*[\\\\"\']*)([^)\'"]+)([\\\\"\']*\\s*\\))/gi,this.IMPORT_REGEX=/(@import\\s*[\\\\"\']*)([^)\'";]+)([\\\\"\']*\\s*;?)/gi,this.IMPORT_JS_REGEX=/^(import\\s*\\([\'"]+)([^\'"]+)(["\'])/i,this.no_wombatRe=/WB_wombat_/g,this.srcsetRe=/\\s*(\\S*\\s+[\\d.]+[wx]),|(?:\\s*,(?:\\s+|(?=https?:)))/,this.cookie_path_regex=/\\bPath=\'?"?([^;\'"\\s]+)/i,this.cookie_domain_regex=/\\bDomain=([^;\'"\\s]+)/i,this.cookie_expires_regex=/\\bExpires=([^;\'"]+)/gi,this.SetCookieRe=/,(?![|])/,this.IP_RX=/^(\\d)+\\.(\\d)+\\.(\\d)+\\.(\\d)+$/,this.FullHTMLRegex=/^\\s*<(?:html|head|body|!doctype html)/i,this.IsTagRegex=/^\\s*</,this.DotPostMessageRe=/(\\.postMessage\\s*\\()/,this.extractPageUnderModifierRE=/\\/(?:[0-9]{14})?([a-z]{2, 3}_)\\//,this.write_buff="";var o=(e.EventTarget||{}).prototype;this.utilFns={cspViolationListener:function(t){if(console.group("CSP Violation"),console.log("Replayed Page URL",window.WB_wombat_location.href),console.log("The documentURI",t.documentURI),console.log("The blocked URL",t.blockedURI),console.log("The directive violated",t.violatedDirective),console.log("Our policy",t.originalPolicy),t.sourceFile){var e="File: "+t.sourceFile;t.lineNumber&&t.columnNumber?e+=" @ "+t.lineNumber+":"+t.columnNumber:t.lineNumber&&(e+=" @ "+t.lineNumber),console.log(e)}console.groupEnd()},addEventListener:o.addEventListener,removeEventListener:o.removeEventListener,objToString:Object.prototype.toString,wbSheetMediaQChecker:null,XHRopen:null,XHRsend:null},this.showCSPViolations={yesNo:!1,added:!1},r(this)}s.prototype.getItem=function(t){return this.hasOwnProperty(t)?this[t]:null},s.prototype.setItem=function(t,e){var r=String(t),i=String(e),o=this.getItem(r);this[r]=e,this.fireEvent(r,o,i)},s.prototype._deleteItem=function(t){delete this[t]},s.prototype.removeItem=function(t){var e=this.getItem(t);this._deleteItem(t),this.fireEvent(t,e,null)},s.prototype.clear=function(){for(var t in this)delete this[t];this.fireEvent(null,null,null)},s.prototype.key=function(t){var e=function(t){try{switch(typeof t){case"number":case"bigint":return t}var e=Number(t);return isNaN(e)?null:e}catch(t){}return null}(t);if(null==e||e<0)return null;var r=Object.keys(this);return e<r.length?r[e]:null},s.prototype.fireEvent=function(t,e,r){var i=new StorageEvent("storage",{key:t,newValue:r,oldValue:e,url:this[o].$wbwindow.WB_wombat_location.href});Object.defineProperty(i,"storageArea",{value:this,writable:!1,configurable:!1}),i._storageArea=this,this[o].storage_listeners.map(i)},s.prototype.valueOf=function(){return this[o].$wbwindow[this[n]]},s.prototype.toString=function(){return"[object Storage]"},Object.defineProperty(s.prototype,"length",{enumerable:!1,get:function(){return Object.keys(this).length}}),e(s,"Storage"),h.prototype.replace=function(t){var e=this.wombat.rewriteUrl(t),r=this.wombat.extractOriginalURL(e);return r===this.href?r:this._orig_loc.replace(e)},h.prototype.assign=function(t){var e=this.wombat.rewriteUrl(t),r=this.wombat.extractOriginalURL(e);return r===this.href?r:this._orig_loc.assign(e)},h.prototype.reload=function(t){},h.prototype.toString=function(){return this.href},h.prototype.valueOf=function(){return this},e(h,"Location"),w.prototype._initWorker=function(t){var e=this.wombat;if(t.isTop)try{this.worker=new Worker(t.workerURL,{type:"classic",credentials:"include"})}catch(t){console.error("Failed to create auto fetch worker\\n",t)}else this.worker={postMessage:function(t){t.wb_type||(t={wb_type:"aaworker",msg:t}),e.$wbwindow.__WB_replay_top.__orig_postMessage(t,"*")},terminate:function(){}}},w.prototype.extractMediaRulesFromSheet=function(t){var e,r=[];try{e=t.cssRules||t.rules}catch(t){return r}for(var i=0;i<e.length;++i){var o=e[i];o.type===CSSRule.MEDIA_RULE&&r.push(o.cssText)}return r},w.prototype.deferredSheetExtraction=function(t){var e=this;Promise.resolve().then((function(){var r=e.extractMediaRulesFromSheet(t);r.length>0&&e.preserveMedia(r)}))},w.prototype.terminate=function(){this.worker.terminate()},w.prototype.justFetch=function(t){this.worker.postMessage({type:"fetch-all",values:t})},w.prototype.fetchAsPage=function(t,e,r){if(t){var i={"X-Wombat-History-Page":e};if(r){var o=encodeURIComponent(r.trim());r&&(i["X-Wombat-History-Title"]=o)}var n={url:t,options:{headers:i,cache:"no-store"}};this.justFetch([n])}},w.prototype.postMessage=function(t,e){if(e){var r=this;Promise.resolve().then((function(){r.worker.postMessage(t)}))}else this.worker.postMessage(t)},w.prototype.preserveSrcset=function(t,e){this.postMessage({type:"values",srcset:{value:t,mod:e,presplit:!0}},!0)},w.prototype.preserveDataSrcset=function(t){this.postMessage({type:"values",srcset:{value:t.dataset.srcset,mod:this.rwMod(t),presplit:!1}},!0)},w.prototype.preserveMedia=function(t){this.postMessage({type:"values",media:t},!0)},w.prototype.getSrcset=function(t){return this.wombat.wb_getAttribute?this.wombat.wb_getAttribute.call(t,"srcset"):t.getAttribute("srcset")},w.prototype.rwMod=function(t){switch(t.tagName){case"SOURCE":return t.parentElement&&"PICTURE"===t.parentElement.tagName?"im_":"oe_";case"IMG":return"im_"}return"oe_"},w.prototype.extractFromLocalDoc=function(){var t=this;Promise.resolve().then((function(){for(var e={type:"values",context:{docBaseURI:document.baseURI}},r=[],i=0,o=document.styleSheets;i<o.length;++i)r=r.concat(t.extractMediaRulesFromSheet(o[i]));var n,s,a,h=document.querySelectorAll(t.elemSelector),w={values:[],presplit:!1},p={values:[]};for(i=0;i<h.length;++i)s=(n=h[i]).src?n.src:null,a=t.rwMod(n),n.srcset&&w.values.push({srcset:t.getSrcset(n),mod:a,tagSrc:s}),n.dataset.srcset&&w.values.push({srcset:n.dataset.srcset,mod:a,tagSrc:s}),n.dataset.src&&p.values.push({src:n.dataset.src,mod:a}),"SOURCE"===n.tagName&&s&&p.values.push({src:s,mod:a});r.length&&(e.media=r),w.values.length&&(e.srcset=w),p.values.length&&(e.src=p),(e.media||e.srcset||e.src)&&t.postMessage(e)}))},f.prototype._internalInit=function(){this.initTopFrame(this.$wbwindow),this.initWombatLoc(this.$wbwindow),this.initWombatTop(this.$wbwindow);var t=this.$wbwindow.__WB_replay_top.location.origin,e=this.$wbwindow.__WB_replay_top.location.host,r=this.$wbwindow.__WB_replay_top.location.protocol;this.wb_replay_prefix&&0===this.wb_replay_prefix.indexOf(t)?this.wb_rel_prefix=this.wb_replay_prefix.substring(t.length):this.wb_rel_prefix=this.wb_replay_prefix,this.wb_prefixes=[this.wb_abs_prefix,this.wb_rel_prefix];var i="(("+r+")?//"+e+")?"+this.wb_rel_prefix+"[^/]+/";this.wb_unrewrite_rx=new RegExp(i,"g"),this.wb_info.is_framed&&"bn_"!==this.wb_info.mod&&this.initTopFrameNotify(this.wb_info),this.initAutoFetchWorker()},f.prototype._addRemoveCSPViolationListener=function(t){this.showCSPViolations.yesNo=t,this.showCSPViolations.yesNo&&!this.showCSPViolations.added?(this.showCSPViolations.added=!0,this._addEventListener(document,"securitypolicyviolation",this.utilFns.cspViolationListener)):(this.showCSPViolations.added=!1,this._removeEventListener(document,"securitypolicyviolation",this.utilFns.cspViolationListener))},f.prototype._addEventListener=function(t,e,r){if(this.utilFns.addEventListener)return this.utilFns.addEventListener.call(t,e,r);t.addEventListener(e,r)},f.prototype._removeEventListener=function(t,e,r){if(this.utilFns.removeEventListener)return this.utilFns.removeEventListener.call(t,e,r);t.removeEventListener(e,r)},f.prototype.getPageUnderModifier=function(){try{var t=this.extractPageUnderModifierRE.exec(location.pathname);if(t&&t[1])return t[1].trim()||"mp_"}catch(t){}return"mp_"},f.prototype.isNativeFunction=function(t){return!(!t||"function"!=typeof t)&&(-1!=this.wb_funToString.call(t).indexOf("[native code]")&&(void 0===t.__WB_is_native_func__||!!t.__WB_is_native_func__))},f.prototype.isString=function(t){return null!=t&&Object.getPrototypeOf(t)===String.prototype},f.prototype.blobUrlForIframe=function(t,e){var r=new Blob([e],{type:"text/html"}),i=URL.createObjectURL(r);t.__wb_blobSrc=i,t.addEventListener("load",(function(){t.__wb_blobSrc&&(URL.revokeObjectURL(t.__wb_blobSrc),t.__wb_blobSrc=null)}),{once:!0}),t.__wb_origSrc=t.src;var o=i.slice(i.lastIndexOf("/")+1)+"/"+this.wb_info.url;t.src=this.wb_info.prefix+this.wb_info.request_ts+"mp_/blob:"+o},f.prototype.isSavedSrcSrcset=function(t){switch(t.tagName){case"IMG":case"VIDEO":case"AUDIO":return!0;case"SOURCE":if(!t.parentElement)return!1;switch(t.parentElement.tagName){case"PICTURE":case"VIDEO":case"AUDIO":return!0;default:return!1}default:return!1}},f.prototype.isSavedDataSrcSrcset=function(t){return!(!t.dataset||null==t.dataset.srcset)&&this.isSavedSrcSrcset(t)},f.prototype.isHostUrl=function(t){if(0===t.indexOf("www."))return!0;var e=t.match(this.hostnamePortRe);return!!(e&&e[0].length<64)||!!(e=t.match(this.ipPortRe))&&e[0].length<64},f.prototype.isArgumentsObj=function(t){if(!t||"function"!=typeof t.toString)return!1;try{return"[object Arguments]"===this.utilFns.objToString.call(t)}catch(t){return!1}},f.prototype.deproxyArrayHandlingArgumentsObj=function(t){if(!t||t instanceof NodeList||!t.length)return t;for(var e=this.isArgumentsObj(t)?new Array(t.length):t,r=0;r<t.length;++r){const i=this.proxyToObj(t[r]);i!==e[r]&&(e[r]=i)}return e},f.prototype.startsWith=function(t,e){if(t)return 0===t.indexOf(e)?e:void 0},f.prototype.startsWithOneOf=function(t,e){if(t)for(var r=0;r<e.length;r++)if(0===t.indexOf(e[r]))return e[r]},f.prototype.endsWith=function(t,e){if(t)return-1!==t.indexOf(e,t.length-e.length)?e:void 0},f.prototype.shouldRewriteAttr=function(t,e){switch(e){case"href":case"src":case"xlink:href":return!0}return!(!t||!this.tagToMod[t]||void 0===this.tagToMod[t][e])||("VIDEO"===t&&"poster"===e||"META"===t&&"content"===e)},f.prototype.skipWrapScriptBasedOnType=function(t){return!!t&&(!(t.indexOf("javascript")>=0||t.indexOf("ecmascript")>=0)&&(t.indexOf("json")>=0||t.indexOf("text/")>=0))},f.prototype.skipWrapScriptTextBasedOnText=function(t){if(!t||t.indexOf(this.WB_ASSIGN_FUNC)>=0||0===t.indexOf("<"))return!0;for(var e=["window","self","document","location","top","parent","frames","opener"],r=0;r<e.length;r++)if(t.indexOf(e[r])>=0)return!1;return!0},f.prototype.nodeHasChildren=function(t){if(!t)return!1;if("function"==typeof t.hasChildNodes)return t.hasChildNodes();var e=t.children||t.childNodes;return!!e&&e.length>0},f.prototype.rwModForElement=function(t,e){if(t){var r="mp_";if("LINK"===t.tagName&&"href"===e){if(t.rel){var i=t.rel.trim().toLowerCase(),o=this.wb_getAttribute.call(t,"as");if(o&&null!=this.linkTagMods.linkRelToAs[i])r=this.linkTagMods.linkRelToAs[i][o.toLowerCase()];else null!=this.linkTagMods[i]&&(r=this.linkTagMods[i])}}else{var n=this.tagToMod[t.tagName];null!=n&&(r=n[e])}return r}},f.prototype.removeWBOSRC=function(t){"SCRIPT"!==t.tagName||t.__$removedWBOSRC$__||(t.hasAttribute("__wb_orig_src")&&t.removeAttribute("__wb_orig_src"),t.__$removedWBOSRC$__=!0)},f.prototype.retrieveWBOSRC=function(t){var e;if("SCRIPT"===t.tagName&&!t.__$removedWBOSRC$__)return null==(e=this.wb_getAttribute?this.wb_getAttribute.call(t,"__wb_orig_src"):t.getAttribute("__wb_orig_src"))&&(t.__$removedWBOSRC$__=!0),e},f.prototype.wrapScriptTextJsProxy=function(t){return\'var _____WB$wombat$assign$function_____ = function(name) {return (self._wb_wombat && self._wb_wombat.local_init && self._wb_wombat.local_init(name)) || self[name]; };\\nif (!self.__WB_pmw) { self.__WB_pmw = function(obj) { this.__WB_source = obj; return this; } }\\n{\\nlet window = _____WB$wombat$assign$function_____("window");\\nlet globalThis = _____WB$wombat$assign$function_____("globalThis");\\nlet self = _____WB$wombat$assign$function_____("self");\\nlet document = _____WB$wombat$assign$function_____("document");\\nlet location = _____WB$wombat$assign$function_____("location");\\nlet top = _____WB$wombat$assign$function_____("top");\\nlet parent = _____WB$wombat$assign$function_____("parent");\\nlet frames = _____WB$wombat$assign$function_____("frames");\\nlet opener = _____WB$wombat$assign$function_____("opener");\\n{\\n\'+t.replace(this.DotPostMessageRe,".__WB_pmw(self.window)$1")+"\\n\\n}}"},f.prototype.watchElem=function(t,e){if(!this.$wbwindow.MutationObserver)return!1;new this.$wbwindow.MutationObserver((function(t,r){for(var i=0;i<t.length;i++){var o=t[i];if("childList"===o.type)for(var n=0;n<o.addedNodes.length;n++)e(o.addedNodes[n])}})).observe(t,{childList:!0,subtree:!0})},f.prototype.reconstructDocType=function(t){return null==t?"":"<!doctype "+t.name+(t.publicId?\' PUBLIC "\'+t.publicId+\'"\':"")+(!t.publicId&&t.systemId?" SYSTEM":"")+(t.systemId?\' "\'+t.systemId+\'"\':"")+">"},f.prototype.getFinalUrl=function(t,e,r){var i=t?this.wb_rel_prefix:this.wb_abs_prefix;return null==e&&(e=this.wb_info.mod),this.wb_info.is_live||(i+=this.wb_info.wombat_ts),"/"!==(i+=e)[i.length-1]&&(i+="/"),i+r},f.prototype.resolveRelUrl=function(t,e){var r=e||this.$wbwindow.document,i=this.makeParser(r.baseURI,r),o=i.href.lastIndexOf("#"),n=o>=0?i.href.substring(0,o):i.href,s=n.lastIndexOf("/");return s>=0&&s!==n.length-1?i.href=n.substring(0,s+1)+t:i.href=n+t,i.href},f.prototype.extractOriginalURL=function(t){if(!t)return"";if(this.wb_is_proxy)return t;var e,r=t.toString(),i=r;if(this.startsWithOneOf(i,this.IGNORE_PREFIXES))return i;if(i.startsWith(this.wb_info.static_prefix))return i;e=this.startsWith(i,this.wb_abs_prefix)?this.wb_abs_prefix.length:this.wb_rel_prefix&&this.startsWith(i,this.wb_rel_prefix)?this.wb_rel_prefix.length:this.wb_rel_prefix?1:0;var o=i.indexOf("/http",e);return o<0&&(o=i.indexOf("///",e)),o<0&&(o=i.indexOf("/blob:",e)),o<0&&(o=i.indexOf("/about:blank",e)),o>=0?i=i.substr(o+1):((o=i.indexOf(this.wb_replay_prefix))>=0&&(i=i.substr(o+this.wb_replay_prefix.length)),i.length>4&&"_"===i.charAt(2)&&"/"===i.charAt(3)&&(i=i.substr(4)),i===r||this.startsWithOneOf(i,this.VALID_PREFIXES)||this.startsWith(i,"blob:")||(i=this.wb_orig_scheme+i)),"/"===r.charAt(0)&&"/"!==r.charAt(1)&&this.startsWith(i,this.wb_orig_origin)&&(i=i.substr(this.wb_orig_origin.length)),this.startsWith(i,this.REL_PREFIX)?this.wb_info.wombat_scheme+":"+i:i},f.prototype.makeParser=function(t,e){var r=this.extractOriginalURL(t),i=e;return e||(i="about:blank"===this.$wbwindow.location.href&&this.$wbwindow.opener?this.$wbwindow.opener.document:this.$wbwindow.document),this._makeURLParser(r,i)},f.prototype._makeURLParser=function(t,e){try{return new this.$wbwindow.URL(t,e.baseURI)}catch(t){}var r=e.createElement("a");return r._no_rewrite=!0,r.href=t,r},f.prototype.defProp=function(t,e,r,i,o){var n=Object.getOwnPropertyDescriptor(t,e);if(n&&!n.configurable)return!1;if(!i)return!1;var s={configurable:!0,enumerable:o||!1,get:i};r&&(s.set=r);try{return Object.defineProperty(t,e,s),!0}catch(t){return console.warn("Failed to redefine property %s",e,t.message),!1}},f.prototype.defGetterProp=function(t,e,r,i){var o=Object.getOwnPropertyDescriptor(t,e);if(o&&!o.configurable)return!1;if(!r)return!1;try{return Object.defineProperty(t,e,{configurable:!0,enumerable:i||!1,get:r}),!0}catch(t){return console.warn("Failed to redefine property %s",e,t.message),!1}},f.prototype.getOrigGetter=function(t,e){var r;if(t.__lookupGetter__&&(r=t.__lookupGetter__(e)),!r&&Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);i&&(r=i.get)}return r},f.prototype.getOrigSetter=function(t,e){var r;if(t.__lookupSetter__&&(r=t.__lookupSetter__(e)),!r&&Object.getOwnPropertyDescriptor){var i=Object.getOwnPropertyDescriptor(t,e);i&&(r=i.set)}return r},f.prototype.getAllOwnProps=function(t){for(var e=[],r=Object.getOwnPropertyNames(t),i=0;i<r.length;i++){var o=r[i];try{t[o]&&!t[o].prototype&&e.push(o)}catch(t){}}for(var n=Object.getPrototypeOf(t);n;){for(r=Object.getOwnPropertyNames(n),i=0;i<r.length;i++)e.push(r[i]);n=Object.getPrototypeOf(n)}return e},f.prototype.sendTopMessage=function(t,e,r){(r=r||this.$wbwindow).__WB_top_frame&&(e||r==r.__WB_replay_top)&&r.__WB_top_frame.postMessage(t,this.wb_info.top_host)},f.prototype.sendHistoryUpdate=function(t,e,r){this.sendTopMessage({url:t,ts:this.wb_info.timestamp,request_ts:this.wb_info.request_ts,is_live:this.wb_info.is_live,title:e,wb_type:"replace-url"},!1,r)},f.prototype.updateLocation=function(t,e,r){if(t&&t!==e){var i=this.extractOriginalURL(e),o=this.extractOriginalURL(t);if(i&&i!==o){var n=this.rewriteUrl(t);console.log(r.href+" -> "+n),r.href=n}}},f.prototype.checkLocationChange=function(t,e){var r=typeof t,i=e?this.$wbwindow.__WB_replay_top.location:this.$wbwindow.location;"string"===r?this.updateLocation(t,i.href,i):"object"===r&&this.updateLocation(t.href,t._orig_href,i)},f.prototype.checkAllLocations=function(){if(this.wb_wombat_updating)return!1;this.wb_wombat_updating=!0,this.checkLocationChange(this.$wbwindow.WB_wombat_location,!1),this.$wbwindow.WB_wombat_location!=this.$wbwindow.__WB_replay_top.WB_wombat_location&&this.checkLocationChange(this.$wbwindow.__WB_replay_top.WB_wombat_location,!0),this.wb_wombat_updating=!1},f.prototype.proxyToObj=function(t){if(t)try{var e=t.__WBProxyRealObj__;if(e)return e}catch(t){}return t},f.prototype.objToProxy=function(t){if(t)try{var e=t._WB_wombat_obj_proxy;if(e)return e}catch(t){}return t},f.prototype.defaultProxyGet=function(t,e,r,i){switch(e){case"__WBProxyRealObj__":return t;case"location":case"WB_wombat_location":return t.WB_wombat_location;case"_WB_wombat_obj_proxy":return t._WB_wombat_obj_proxy;case"__WB_pmw":case this.WB_ASSIGN_FUNC:case this.WB_CHECK_THIS_FUNC:return t[e];case"origin":return t.WB_wombat_location.origin;case"constructor":return t.constructor}var o=t[e],n=typeof o;if("function"===n&&-1!==r.indexOf(e)){switch(e){case"requestAnimationFrame":case"cancelAnimationFrame":if(!this.isNativeFunction(o))return o;break;case"eval":if(this.isNativeFunction(o))return this.wrappedEval(o)}var s=i[e];return s&&s.original===o||(s={original:o,boundFn:o.bind(t)},i[e]=s),s.boundFn}return"object"===n&&o&&o._WB_wombat_obj_proxy?(o instanceof this.WBWindow&&this.initNewWindowWombat(o),o._WB_wombat_obj_proxy):o},f.prototype.setLoc=function(t,e){var r=this.makeParser(e,t.ownerDocument);t._orig_href=e,t._parser=r;var i=r.href;t._hash=r.hash,t._href=i,t._host=r.host,t._hostname=r.hostname,r.origin?t._origin=r.host?r.origin:"null":t._origin=r.protocol+"//"+r.hostname+(r.port?":"+r.port:""),t._pathname=r.pathname,t._port=r.port,t._protocol=r.protocol,t._search=r.search,Object.defineProperty||(t.href=i,t.hash=r.hash,t.host=t._host,t.hostname=t._hostname,t.origin=t._origin,t.pathname=t._pathname,t.port=t._port,t.protocol=t._protocol,t.search=t._search)},f.prototype.makeGetLocProp=function(t,e){var r=this;return function(){if(this._no_rewrite)return e.call(this,t);var i=e.call(this,"href");return"href"===t?r.extractOriginalURL(i):"ancestorOrigins"===t?[]:(this._orig_href!==i&&r.setLoc(this,i),this["_"+t])}},f.prototype.makeSetLocProp=function(t,e,r){var i=this;return function(o){if(this._no_rewrite)return e.call(this,t,o);if(this["_"+t]!==o){if(this["_"+t]=o,!this._parser){var n=r.call(this);this._parser=i.makeParser(n,this.ownerDocument)}var s=!1;if("href"===t&&"string"==typeof o)if(o&&this._parser instanceof URL)try{o=new URL(o,this._parser).href}catch(t){console.warn("Error resolving URL",t)}else o&&("."===o[0]||"#"===o[0]?o=i.resolveRelUrl(o,this.ownerDocument):"/"===o[0]&&(o.length>1&&"/"===o[1]?o=this._parser.protocol+o:(s=!0,o=WB_wombat_location.origin+o)));try{this._parser[t]=o}catch(e){console.log("Error setting "+t+" = "+o)}"hash"===t?(o=this._parser[t],e.call(this,"hash",o)):(s=s||o===this._parser.pathname,o=i.rewriteUrl(this._parser.href,s),e.call(this,"href",o))}}},f.prototype.styleReplacer=function(t,e,r,i,o,n){return e+this.rewriteUrl(r)+i},f.prototype.domConstructorErrorChecker=function(t,e,r,i){var o,n="number"==typeof i?i:1;if(t instanceof this.WBWindow?o="Failed to construct \'"+e+"\': Please use the \'new\' operator, this DOM object constructor cannot be called as a function.":r&&r.length<n&&(o="Failed to construct \'"+e+"\': "+n+" argument required, but only 0 present."),o)throw new TypeError(o)},f.prototype.rewriteNodeFuncArgs=function(t,e,r,i){if(r)switch(r.nodeType){case Node.ELEMENT_NODE:this.rewriteElemComplete(r);break;case Node.TEXT_NODE:("STYLE"===t.tagName||r.parentNode&&"STYLE"===r.parentNode.tagName)&&(r.textContent=this.rewriteStyle(r.textContent));break;case Node.DOCUMENT_FRAGMENT_NODE:this.recurseRewriteElem(r)}var o=e.call(t,r,i);return o&&"IFRAME"===o.tagName&&(o.allow="autoplay \'self\'; fullscreen \'self\'",this.initIframeWombat(o)),o},f.prototype.rewriteWSURL=function(t){if(!t)return t;var e=typeof t,r=t;if("object"===e)r=t.toString();else if("string"!==e)return t;if(!r)return r;var i="ws://",o="wss://";if(this.wb_is_proxy)return this.wb_orig_scheme===this.HTTP_PREFIX&&this.startsWith(r,o)?i+r.substr(o.length):this.wb_orig_scheme===this.HTTPS_PREFIX&&this.startsWith(r,i)?o+r.substr(i.length):r;var n=0===this.wb_abs_prefix.indexOf(this.HTTPS_PREFIX),s=this.wb_abs_prefix.replace(n?this.HTTPS_PREFIX:this.HTTP_PREFIX,n?o:i);return s+=this.wb_info.wombat_ts+"ws_","/"!==r[r.length-1]&&(s+="/"),s+r.replace("WB_wombat_","")},f.prototype.rewriteUrl_=function(t,e,r,i){if(!t)return t;var o,n,s=typeof t;if("object"===s)o=t.toString();else{if("string"!==s)return t;o=t}if(!o)return o;if(this.wb_is_proxy)return this.wb_orig_scheme===this.HTTP_PREFIX&&this.startsWith(o,this.HTTPS_PREFIX)?this.HTTP_PREFIX+o.substr(this.HTTPS_PREFIX.length):this.wb_orig_scheme===this.HTTPS_PREFIX&&this.startsWith(o,this.HTTP_PREFIX)?this.HTTPS_PREFIX+o.substr(this.HTTP_PREFIX.length):o;if(o=o.replace("WB_wombat_",""),"if_"===r&&this.wb_info.isSW&&this.startsWith(o,"blob:"))return this.wb_info.prefix+this.wb_info.request_ts+"if_/"+o;if(this.startsWithOneOf(o.toLowerCase(),this.IGNORE_PREFIXES))return o;if(this.wb_opts.no_rewrite_prefixes&&this.startsWithOneOf(o,this.wb_opts.no_rewrite_prefixes))return o;if(n=0===o.indexOf("//")?this.origProtocol+o:o,this.startsWith(n,this.wb_abs_prefix)||this.startsWith(n,this.wb_rel_prefix))return o;if(this.origHost!==this.origHostname&&this.startsWith(o,this.origProtocol+"//"+this.origHostname+"/"))return o.replace("/"+this.origHostname+"/","/"+this.origHost+"/");if("/"===o.charAt(0)&&!this.startsWith(o,this.REL_PREFIX)){if(this.wb_capture_date_part&&o.indexOf(this.wb_capture_date_part)>=0)return o;if(0===o.indexOf(this.wb_rel_prefix)&&o.indexOf("http")>1){var a=o.indexOf(":/");return a>0&&"/"!==o[a+2]?o.substring(0,a+2)+"/"+o.substring(a+2):o}return this.getFinalUrl(!0,r,this.wb_orig_origin+o)}"."===o.charAt(0)&&(o=this.resolveRelUrl(o,i));var h=this.startsWithOneOf(o.toLowerCase(),this.VALID_PREFIXES);if(h){var w=this.replayTopHost,p=this.replayTopProtocol,c=h+w+"/";if(this.startsWith(o,c)){if(this.startsWith(o,this.wb_replay_prefix))return o;var l=p+"//",_=o.substring(c.length),u=!1;return _.indexOf(this.wb_rel_prefix)<0&&o.indexOf("/static/")<0&&(_=this.getFinalUrl(!0,r,WB_wombat_location.origin+"/"+_),u=!0),h!==l&&h!==this.REL_PREFIX&&(u=!0),u&&(o=e?"":l+w,_&&"/"!==_[0]&&(o+="/"),o+=_),o}return this.getFinalUrl(e,r,o)}return(h=this.startsWithOneOf(o,this.BAD_PREFIXES))?this.getFinalUrl(e,r,this.extractOriginalURL(o)):o},f.prototype.rewriteUrl=function(t,e,r,i){var o=this.rewriteUrl_(t,e,r,i);return this.debug_rw&&(t!==o?console.log("REWRITE: "+t+" -> "+o):console.log("NOT REWRITTEN "+t)),o},f.prototype.performAttributeRewrite=function(t,e,r,i){switch(e){case"innerHTML":case"outerHTML":return this.rewriteHtml(r);case"filter":return this.rewriteInlineStyle(r);case"style":return this.rewriteStyle(r);case"srcset":return this.rewriteSrcset(r,t)}if(i&&!this.startsWithOneOf(r,this.VALID_PREFIXES))return r;var o=this.rwModForElement(t,e);return this.wbUseAFWorker&&this.WBAutoFetchWorker&&this.isSavedDataSrcSrcset(t)&&this.WBAutoFetchWorker.preserveDataSrcset(t),this.rewriteUrl(r,!1,o,t.ownerDocument)},f.prototype.rewriteAttr=function(t,e,r){var i=!1;if(!t||!t.getAttribute||t._no_rewrite||t["_"+e])return i;var o=this.wb_getAttribute.call(t,e);if(!o||this.startsWith(o,"javascript:"))return i;var n=this.performAttributeRewrite(t,e,o,r);return n!==o&&(this.removeWBOSRC(t),this.wb_setAttribute.call(t,e,n),i=!0),i},f.prototype.noExceptRewriteStyle=function(t){try{return this.rewriteStyle(t)}catch(e){return t}},f.prototype.rewriteStyle=function(t){if(!t)return t;var e=t;return"object"==typeof t&&(e=t.toString()),"string"==typeof e?e.replace(this.STYLE_REGEX,this.styleReplacer).replace(this.IMPORT_REGEX,this.styleReplacer).replace(this.no_wombatRe,""):e},f.prototype.rewriteSrcset=function(t,e){if(!t)return"";for(var r=t.split(this.srcsetRe),i=[],o=this.rwModForElement(e,"srcset"),n=0;n<r.length;n++){var s=r[n];if(s){var a=s.trim().split(" ");a[0]=this.rewriteUrl(a[0],!0,o),i.push(a.join(" "))}}return this.wbUseAFWorker&&this.WBAutoFetchWorker&&this.isSavedSrcSrcset(e)&&this.WBAutoFetchWorker.preserveSrcset(i,this.WBAutoFetchWorker.rwMod(e)),i.join(", ")},f.prototype.rewriteFrameSrc=function(t,e){var r,i=this.wb_getAttribute.call(t,e);if(this.startsWith(i,"javascript:")&&i.indexOf("WB_wombat_")>=0){var o="javascript:";r=o+"window.parent._wb_wombat.initNewWindowWombat(window);"+i.substr(o.length)}return r||(r=this.rewriteUrl(i,!1,this.rwModForElement(t,e))),r!==i&&(this.wb_setAttribute.call(t,e,r),!0)},f.prototype.rewriteScript=function(t){if(t.hasAttribute("src")||!t.textContent||!this.$wbwindow.Proxy)return this.rewriteAttr(t,"src");if(this.skipWrapScriptBasedOnType(t.type))return!1;var e=t.textContent.trim();return!this.skipWrapScriptTextBasedOnText(e)&&(t.textContent=this.wrapScriptTextJsProxy(e),!0)},f.prototype.rewriteSVGElem=function(t){var e=this.rewriteAttr(t,"filter");return e=this.rewriteAttr(t,"style")||e,e=this.rewriteAttr(t,"xlink:href")||e,e=this.rewriteAttr(t,"href")||e,e=this.rewriteAttr(t,"src")||e},f.prototype.rewriteElem=function(t){var e=!1;if(!t)return e;if(t instanceof SVGElement)e=this.rewriteSVGElem(t);else switch(t.tagName){case"META":var r=this.wb_getAttribute.call(t,"http-equiv");r&&"content-security-policy"===r.toLowerCase()&&(this.wb_setAttribute.call(t,"http-equiv","_"+r),e=!0);break;case"STYLE":var i=this.rewriteStyle(t.textContent);t.textContent!==i&&(t.textContent=i,e=!0,this.wbUseAFWorker&&this.WBAutoFetchWorker&&null!=t.sheet&&this.WBAutoFetchWorker.deferredSheetExtraction(t.sheet));break;case"LINK":e=this.rewriteAttr(t,"href"),this.wbUseAFWorker&&"stylesheet"===t.rel&&this._addEventListener(t,"load",this.utilFns.wbSheetMediaQChecker);break;case"IMG":e=this.rewriteAttr(t,"src"),e=this.rewriteAttr(t,"srcset")||e,e=this.rewriteAttr(t,"style")||e,this.wbUseAFWorker&&this.WBAutoFetchWorker&&t.dataset.srcset&&this.WBAutoFetchWorker.preserveDataSrcset(t);break;case"OBJECT":if(this.wb_info.isSW&&t.parentElement&&"application/pdf"===t.getAttribute("type")){for(var o=this.$wbwindow.document.createElement("IFRAME"),n=0;n<t.attributes.length;n++){var s=t.attributes[n],a=s.name;"data"===a&&(a="src"),this.wb_setAttribute.call(o,a,s.value)}t.parentElement.replaceChild(o,t),e=!0;break}e=this.rewriteAttr(t,"data",!0),e=this.rewriteAttr(t,"style")||e;break;case"FORM":e=this.rewriteAttr(t,"poster"),e=this.rewriteAttr(t,"action")||e,e=this.rewriteAttr(t,"style")||e;break;case"IFRAME":if(e=this.rewriteFrameSrc(t,"src"),this.wb_info.isSW&&!e){var h=t.getAttribute("srcdoc");if(t.hasAttribute("srcdoc")&&t.removeAttribute("srcdoc"),h)this.blobUrlForIframe(t,h);else{var w=t.getAttribute("src");w&&"about:blank"!==w||(w||(t.__WB_blank=!0),t.src=this.wb_info.prefix+this.wb_info.request_ts+"mp_/about:blank")}}e=this.rewriteAttr(t,"style")||e;break;case"FRAME":e=this.rewriteFrameSrc(t,"src"),e=this.rewriteAttr(t,"style")||e;break;case"SCRIPT":e=this.rewriteScript(t);break;case"A":if(e=this.rewriteAttr(t,"href")||e,t.hasAttribute("target")){var p=this.rewriteAttrTarget(t.target);p!==t.target&&(t.target=p,e=!0)}break;default:e=this.rewriteAttr(t,"src"),e=this.rewriteAttr(t,"srcset")||e,e=this.rewriteAttr(t,"href")||e,e=this.rewriteAttr(t,"style")||e,e=this.rewriteAttr(t,"poster")||e}return t.hasAttribute&&t.removeAttribute&&(t.hasAttribute("crossorigin")&&(t.removeAttribute("crossorigin"),e=!0),t.hasAttribute("integrity")&&(t.removeAttribute("integrity"),e=!0)),e},f.prototype.recurseRewriteElem=function(t){if(!this.nodeHasChildren(t))return!1;for(var e=!1,r=[t.children||t.childNodes];r.length>0;)for(var i=r.shift(),o=0;o<i.length;o++){var n=i[o];n.nodeType===Node.ELEMENT_NODE&&(e=this.rewriteElem(n)||e,this.nodeHasChildren(n)&&r.push(n.children||n.childNodes))}return e},f.prototype.rewriteElemComplete=function(t){if(!t)return!1;var e=this.rewriteElem(t),r=this.recurseRewriteElem(t);return e||r},f.prototype.rewriteElementsInArguments=function(t){for(var e=new Array(t.length),r=0;r<t.length;r++){var i=t[r];i instanceof Node?(this.rewriteElemComplete(i),e[r]=i):e[r]="string"==typeof i?this.rewriteHtml(i):i}return e},f.prototype.rewriteHtml=function(t,e){if(!t)return t;var r=t;if("string"!=typeof t&&(r=t.toString()),this.write_buff&&(r=this.write_buff+r,this.write_buff=""),r.indexOf("<script")<=0&&(r=r.replace(/((id|class)=".*)WB_wombat_([^"]+)/,"$1$3")),!this.$wbwindow.HTMLTemplateElement||this.FullHTMLRegex.test(r))return this.rewriteHtmlFull(r,e);var i=(new DOMParser).parseFromString("<template>"+r+"</template>","text/html");if(!i||!this.nodeHasChildren(i.head)||!i.head.children[0].content)return r;var o=i.head.children[0];if(o._no_rewrite=!0,this.recurseRewriteElem(o.content)){var n=o.innerHTML;if(e){var s=o.content.children&&o.content.children[0];if(s){var a="</"+s.tagName.toLowerCase()+">";this.endsWith(n,a)&&!this.endsWith(r.toLowerCase(),a)&&(n=n.substring(0,n.length-a.length))}else if("<"!==r[0]||">"!==r[r.length-1])return void(this.write_buff+=r)}return n}return r},f.prototype.rewriteHtmlFull=function(t,e){var r=(new DOMParser).parseFromString(t,"text/html");if(!r)return t;for(var i=!1,o=0;o<r.all.length;o++)i=this.rewriteElem(r.all[o])||i;if(i){var n;if(t&&t.indexOf("<html")>=0)r.documentElement._no_rewrite=!0,n=this.reconstructDocType(r.doctype)+r.documentElement.outerHTML;else{r.head._no_rewrite=!0,r.body._no_rewrite=!0;var s=this.nodeHasChildren(r.head),a=this.nodeHasChildren(r.body);if(n=(s?r.head.outerHTML:"")+(a?r.body.outerHTML:""),e)if(r.all.length>3){var h="</"+r.all[3].tagName.toLowerCase()+">";this.endsWith(n,h)&&!this.endsWith(t.toLowerCase(),h)&&(n=n.substring(0,n.length-h.length))}else if("<"!==t[0]||">"!==t[t.length-1])return void(this.write_buff+=t);n=this.reconstructDocType(r.doctype)+n}return n}return t},f.prototype.rewriteInlineStyle=function(t){var e;try{e=decodeURIComponent(t)}catch(r){e=t}if(e!==t){var r=this.rewriteStyle(e).split(",",2);return r[0]+","+encodeURIComponent(r[1])}return this.rewriteStyle(t)},f.prototype.rewriteCookie=function(t){var e=this,r=t.replace(this.wb_abs_prefix,"").replace(this.wb_rel_prefix,"");return r=r.replace(this.cookie_domain_regex,(function(t,i){var o={domain:i,cookie:r,wb_type:"cookie"};return e.sendTopMessage(o,!0),e.$wbwindow.location.hostname.indexOf(".")>=0&&!e.IP_RX.test(e.$wbwindow.location.hostname)?"Domain=."+e.$wbwindow.location.hostname:""})).replace(this.cookie_path_regex,(function(t,r){var i=e.rewriteUrl(r);return 0===i.indexOf(e.wb_curr_host)&&(i=i.substring(e.wb_curr_host.length)),"Path="+i})),"https:"!==e.$wbwindow.location.protocol&&(r=r.replace("secure","")),r.replace(",|",",")},f.prototype.rewriteWorker=function(t){if(!t)return t;var e=0===(t=t.toString()).indexOf("blob:"),r=0===t.indexOf("javascript:");if(!e&&!r){if(!this.startsWithOneOf(t,this.VALID_PREFIXES)&&!this.startsWith(t,"/")&&!this.startsWithOneOf(t,this.BAD_PREFIXES)){var i=this.resolveRelUrl(t,this.$wbwindow.document);return this.rewriteUrl(i,!1,"wkr_",this.$wbwindow.document)}return this.rewriteUrl(t,!1,"wkr_",this.$wbwindow.document)}var o=r?t.replace("javascript:",""):null;if(e){var n=new XMLHttpRequest;this.utilFns.XHRopen.call(n,"GET",t,!1),this.utilFns.XHRsend.call(n),o=n.responseText.replace(this.workerBlobRe,"").replace(this.rmCheckThisInjectRe,"this")}if(this.wb_info.static_prefix||this.wb_info.ww_rw_script){var s=this.$wbwindow.document.baseURI;o="(function() { self.importScripts(\'"+(this.wb_info.ww_rw_script||this.wb_info.static_prefix+"wombatWorkers.js")+"\'); new WBWombat({\'prefix\': \'"+this.wb_abs_prefix+"\', \'prefixMod\': \'"+this.wb_abs_prefix+"wkrf_/\', \'originalURL\': \'"+s+"\'}); })();"+o}var a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)},f.prototype.rewriteTextNodeFn=function(t,e,r){var i,o=this.proxyToObj(t);if(r.length>0&&o.parentElement&&"STYLE"===o.parentElement.tagName){i=new Array(r.length);var n=r.length-1;2===n?(i[0]=r[0],i[1]=r[1]):1===n&&(i[0]=r[0]),i[n]=this.rewriteStyle(r[n])}else i=r;return e.__WB_orig_apply?e.__WB_orig_apply(o,i):e.apply(o,i)},f.prototype.rewriteChildNodeFn=function(t,e,r){var i=this.proxyToObj(t);if(0===r.length)return e.call(i);var o=this.rewriteElementsInArguments(r);return e.__WB_orig_apply?e.__WB_orig_apply(i,o):e.apply(i,o)},f.prototype.rewriteInsertAdjHTMLOrElemArgs=function(t,e,r,i,o){var n=this.proxyToObj(t);return n._no_rewrite?e.call(n,r,i):o?e.call(n,r,this.rewriteHtml(i)):(this.rewriteElemComplete(i),e.call(n,r,i))},f.prototype.rewriteSetTimeoutInterval=function(t,e,r){var i=this.isString(r[0]),o=i?new Array(r.length):r;if(i){this.$wbwindow.Proxy?o[0]=this.wrapScriptTextJsProxy(r[0]):o[0]=r[0].replace(/\\blocation\\b/g,"WB_wombat_$&");for(var n=1;n<r.length;++n)o[n]=this.proxyToObj(r[n])}var s=this.proxyToObj(t);return e.__WB_orig_apply?e.__WB_orig_apply(s,o):e.apply(s,o)},f.prototype.rewriteHTMLAssign=function(t,e,r){var i=r,o=t.tagName;t._no_rewrite||t instanceof this.$wbwindow.HTMLTemplateElement||("STYLE"===o?i=this.rewriteStyle(r):"SCRIPT"===o?(r&&this.IsTagRegex.test(r)&&(i=this.rewriteHtml(r)),i===r&&(this.skipWrapScriptBasedOnType(t.type)||this.skipWrapScriptTextBasedOnText(r)||(i=this.wrapScriptTextJsProxy(i)))):i=this.rewriteHtml(r)),e.call(t,i),this.wbUseAFWorker&&this.WBAutoFetchWorker&&"STYLE"===o&&null!=t.sheet&&this.WBAutoFetchWorker.deferredSheetExtraction(t.sheet)},f.prototype.rewriteEvalArg=function(t,e,r){return t(this.isString(e)&&!this.skipWrapScriptTextBasedOnText(e)?this.wrapScriptTextJsProxy(e):this.otherEvalRewrite(e),r)},f.prototype.otherEvalRewrite=function(t){return"string"!=typeof t?t:t.replace(this.IMPORT_JS_REGEX,this.styleReplacer)},f.prototype.addEventOverride=function(t,e){var r=e;e||(r=this.$wbwindow.MessageEvent.prototype);var i=this.getOrigGetter(r,t);i&&this.defGetterProp(r,t,(function(){return null!=this["_"+t]?this["_"+t]:i.call(this)}))},f.prototype.isAttrObjRewrite=function(t){if(!t)return!1;var e=t.ownerElement&&t.ownerElement.tagName;return this.shouldRewriteAttr(e,t.nodeName)},f.prototype.newAttrObjGetSet=function(t,e){var r=this,i=this.getOrigGetter(t,e),o=this.getOrigSetter(t,e);this.defProp(t,e,(function(t){var e=r.proxyToObj(this),i=t;return r.isAttrObjRewrite(e)&&(i=r.performAttributeRewrite(e.ownerElement,e.name,t,!1)),o.call(e,i)}),(function(){var t=r.proxyToObj(this),e=i.call(t);return r.isAttrObjRewrite(t)?r.extractOriginalURL(e):e}))},f.prototype.overrideAttrProps=function(){var t=this.$wbwindow.Attr.prototype;this.newAttrObjGetSet(t,"value"),this.newAttrObjGetSet(t,"nodeValue"),this.newAttrObjGetSet(t,"textContent")},f.prototype.overrideAttr=function(t,e,r){var i=this.getOrigGetter(t,e),o=this.getOrigSetter(t,e),n=this;this.defProp(t,e,(function(t){"js_"!==r||this.__$removedWBOSRC$__||n.removeWBOSRC(this);var i=n.rewriteUrl(t,!1,r);return o?o.call(this,i):n.wb_setAttribute?n.wb_setAttribute.call(this,e,i):void 0}),(function(){var t;return i?t=i.call(this):n.wb_getAttribute&&(t=n.wb_getAttribute.call(this,e)),t=n.extractOriginalURL(t),this.__WB_blank&&"about:blank"===t?"":t}))},f.prototype.overridePropExtract=function(t,e){var r=this.getOrigGetter(t,e),i=this;if(r){this.defGetterProp(t,e,(function(){var t=i.proxyToObj(this),e=r.call(t);return i.extractOriginalURL(e)}))}},f.prototype.overrideReferrer=function(t){var e=this.getOrigGetter(t,"referrer"),r=this;if(e){this.defGetterProp(t,"referrer",(function(){var t=r.proxyToObj(this),i=this.defaultView;if(i===i.__WB_replay_top)return"";var o=e.call(t);return r.extractOriginalURL(o)}))}},f.prototype.overridePropToProxy=function(t,e){var r=this.getOrigGetter(t,e);if(r){var i=this;this.defGetterProp(t,e,(function(){return i.objToProxy(r.call(this))}))}},f.prototype.overrideHistoryFunc=function(t){if(this.$wbwindow.history){var e=this.$wbwindow.history[t];if(e){this.$wbwindow.history["_orig_"+t]=e,this.$wbwindow.history.___wb_ownWindow=this.$wbwindow;var r=this,i=function(t,i,o){var n,s,a=this.___wb_ownWindow||r.$wbwindow,h=a.WB_wombat_location;if(o){var w=r._makeURLParser(o,a.document);if(s=w.href,n=r.rewriteUrl(s),s!==h.origin&&"about:blank"!==h.href&&!r.startsWith(s,h.origin+"/"))throw new DOMException("Invalid history change: "+s)}else s=h.href;e.call(this,t,i,n);var p=a.document.title;r.WBAutoFetchWorker&&a.setTimeout((function(){i||a.document.title===p||(i=a.document.title),r.WBAutoFetchWorker.fetchAsPage(n,s,i)}),100),r.sendHistoryUpdate(s,i,a)};return this.$wbwindow.history[t]=i,this.$wbwindow.History&&this.$wbwindow.History.prototype&&(this.$wbwindow.History.prototype[t]=i),i}}},f.prototype.overrideStyleAttr=function(t,e,r){var i=this.getOrigGetter(t,e),o=this.getOrigSetter(t,e),n=this,s=i,a=function(t,e,r,i,o){return e+(r||"")+n.extractOriginalURL(i)+o},h=/(url\\()([\'"])?(.*?)(\\2\\))/;i||(s=function(){var t=this.getPropertyValue(r);return t&&t.startsWith("url(")&&(t=t.replace(h,a)),t}),(o&&i||r)&&this.defProp(t,e,(function(t){var e=n.rewriteStyle(t);return o?o.call(this,e):this.setProperty(r,e),e}),s)},f.prototype.overrideStyleSetProp=function(t){var e=t.setProperty,r=this;t.setProperty=function(t,i,o){var n=r.rewriteStyle(i);return e.call(this,t,n,o)}},f.prototype.overrideAnchorAreaElem=function(t){if(t&&t.prototype){for(var e={},r=t.prototype,i=function(t,r){var i=e["set_"+t];return i?i.call(this,r):""},o=function(t){var r=e["get_"+t];return r?r.call(this):""},n=0;n<this.URL_PROPS.length;n++){var s=this.URL_PROPS[n];e["get_"+s]=this.getOrigGetter(r,s),e["set_"+s]=this.getOrigSetter(r,s),Object.defineProperty&&this.defProp(r,s,this.makeSetLocProp(s,i,o),this.makeGetLocProp(s,o),!0)}r.toString=function(){return this.href}}},f.prototype.overrideHtmlAssign=function(t,e,r){if(this.$wbwindow.DOMParser&&t&&t.prototype){var i=t.prototype,o=this.getOrigGetter(i,e),n=this.getOrigSetter(i,e);if(n){var s=this.rewriteHTMLAssign,a=this.wb_unrewrite_rx;this.defProp(i,e,(function(t){return s(this,n,t)}),r?function(){var t=o.call(this);return this._no_rewrite?t:t.replace(a,"")}:o)}}},f.prototype.overrideHtmlAssignSrcDoc=function(t,e){var r=t.prototype,i=(this.getOrigGetter(r,e),this.getOrigSetter(r,e)),o=this;this.defProp(r,e,(function(t){return this.__wb_srcdoc=t,o.wb_info.isSW?(o.blobUrlForIframe(this,t),t):o.rewriteHTMLAssign(this,i,t)}),(function(){return this.__wb_srcdoc}))},f.prototype.overrideDataSet=function(){var t=this.$wbwindow.HTMLElement.prototype,e=this.getOrigGetter(t,"dataset"),r=this;this.defProp(t,"dataset",null,(function(){var t=e.call(this);return new Proxy(t,{get(t,e,i){var o=t[e];return r.startsWithOneOf(o,r.wb_prefixes)?r.extractOriginalURL(o):o}})}))},f.prototype.overrideStyleProxy=function(t){var e=this.$wbwindow.HTMLElement.prototype,r=this.getOrigSetter(e,"style"),i=this.getOrigGetter(e,"style"),o=this;this.defProp(e,"style",r,(function(){var e=i.call(this),r={};return new Proxy(e,{set:(e,r,i)=>(t.includes(r)&&(i=o.rewriteStyle(i)),e[r]=i,!0),get(t,i,n){var s=t[i];return"function"!=typeof s||"setProperty"!==i&&!o.isNativeFunction(s)?s:(r[i]||(r[i]=s.bind(e)),r[i])}})}))},f.prototype.overrideIframeContentAccess=function(t){if(this.$wbwindow.HTMLIFrameElement&&this.$wbwindow.HTMLIFrameElement.prototype){var e=this.$wbwindow.HTMLIFrameElement.prototype,r=this.getOrigGetter(e,t);if(r){var i=this.getOrigSetter(e,t),o=this;this.defProp(e,t,i,(function(){return o.initIframeWombat(this),o.objToProxy(r.call(this))})),e["_get_"+t]=r}}},f.prototype.overrideFramesAccess=function(t){if(!t.Proxy||t!==t.frames){t.__wb_frames=t.frames;var e=this,r=function(){for(var t=0;t<this.__wb_frames.length;t++)try{e.initNewWindowWombat(this.__wb_frames[t])}catch(t){}return this.__wb_frames};this.defGetterProp(t,"frames",r),this.defGetterProp(t.Window.prototype,"frames",r)}},f.prototype.overrideSWAccess=function(t){if(t.navigator.serviceWorker&&t.navigator.serviceWorker.controller){t._WB_wombat_sw=t.navigator.serviceWorker;var e={controller:null,ready:Promise.resolve({unregister:function(){}}),register:function(){return Promise.reject()},addEventListener:function(){},removeEventListener:function(){},onmessage:null,oncontrollerchange:null,getRegistrations:function(){return Promise.resolve([])},getRegistration:function(){return Promise.resolve(void 0)},startMessages:function(){}};this.defGetterProp(t.navigator,"serviceWorker",(function(){return e}))}},f.prototype.overrideFuncThisProxyToObj=function(t,e,r){if(t){var i=r;if(!r&&t.prototype&&t.prototype[e]?i=t.prototype:!r&&t[e]&&(i=t),i){var o=this,n=i[e];i[e]=function(){return n.apply(o.proxyToObj(this),arguments)}}}},f.prototype.overrideFuncArgProxyToObj=function(t,e,r){if(t&&t.prototype){var i=r||0,o=t.prototype[e];if(o){var n=this;t.prototype[e]=function(){for(var t=new Array(arguments.length),e=0;e<t.length;e++)t[e]=e===i?n.proxyToObj(arguments[e]):arguments[e];var r=n.proxyToObj(this);return o.__WB_orig_apply?o.__WB_orig_apply(r,t):o.apply(r,t)}}}},f.prototype.overrideFunctionApply=function(t){if(!t.Function.prototype.__WB_orig_apply){var e=t.Function.prototype.apply;t.Function.prototype.__WB_orig_apply=e;var r=this;t.Function.prototype.apply=function(t,e){return r.isNativeFunction(this)&&(t=r.proxyToObj(t),e=r.deproxyArrayHandlingArgumentsObj(e)),this.__WB_orig_apply(t,e)},this.wb_funToString.apply=e}},f.prototype.overrideFunctionBind=function(t){if(!t.Function.prototype.__WB_orig_bind){var e=t.Function.prototype.bind;t.Function.prototype.__WB_orig_bind=e;var r=this;t.Function.prototype.bind=function(t){var e=r.isNativeFunction(this),i=this.__WB_orig_bind.apply(this,arguments);return i.__WB_is_native_func__=e,i}}},f.prototype.overrideSrcsetAttr=function(t,e){var r="srcset",i=this.getOrigGetter(t,r),o=this.getOrigSetter(t,r),n=this;this.defProp(t,r,(function(t){var e=n.rewriteSrcset(t,this);return o?o.call(this,e):n.wb_setAttribute?n.wb_setAttribute.call(this,r,e):void 0}),(function(){var t;return i?t=i.call(this):n.wb_getAttribute&&(t=n.wb_getAttribute.call(this,r)),t=n.extractOriginalURL(t)}))},f.prototype.overrideHrefAttr=function(t,e){var r=this.getOrigGetter(t,"href"),i=this.getOrigSetter(t,"href"),o=this;this.defProp(t,"href",(function(t){var r;return r="cs_"===e&&0===t.indexOf("data:text/css")?o.rewriteInlineStyle(t):"LINK"===this.tagName?o.rewriteUrl(t,!1,o.rwModForElement(this,"href")):o.rewriteUrl(t,!1,e,this.ownerDocument),i?i.call(this,r):o.wb_setAttribute?o.wb_setAttribute.call(this,"href",r):void 0}),(function(){var t;return r?t=r.call(this):o.wb_getAttribute&&(t=o.wb_getAttribute.call(this,"href")),this._no_rewrite?t:o.extractOriginalURL(t)}))},f.prototype.overrideTextProtoGetSet=function(t,e){var r,i=this.getOrigGetter(t,e),o=this;if("data"===e){var n=this.getOrigSetter(t,e);r=function(t){var e=t;return!this._no_rewrite&&this.parentElement&&"STYLE"===this.parentElement.tagName&&(e=o.rewriteStyle(t)),n.call(this,e)}}this.defProp(t,e,r,(function(){var t=i.call(this);return!this._no_rewrite&&this.parentElement&&"STYLE"===this.parentElement.tagName?t.replace(o.wb_unrewrite_rx,""):t}))},f.prototype.overrideAnUIEvent=function(t){var e="__wb_"+t+"_overridden",r=this.$wbwindow[t];if(r&&r.prototype&&!r.prototype[e]){var i=this;this.overridePropToProxy(r.prototype,"view");var o,n="init"+t;if(r.prototype[n]){var s=r.prototype[n];r.prototype[n]=function(){var t=i.proxyToObj(this);if(0===arguments.length||arguments.length<3)return s.__WB_orig_apply?s.__WB_orig_apply(t,arguments):s.apply(t,arguments);for(var e=new Array(arguments.length),r=0;r<arguments.length;r++)e[r]=3===r?i.proxyToObj(arguments[r]):arguments[r];return s.__WB_orig_apply?s.__WB_orig_apply(t,e):s.apply(t,e)}}this.$wbwindow[t]=(o=r,function(e,r){return i.domConstructorErrorChecker(this,t,arguments),r&&(null!=r.view&&(r.view=i.proxyToObj(r.view)),null!=r.relatedTarget&&(r.relatedTarget=i.proxyToObj(r.relatedTarget)),null!=r.target&&(r.target=i.proxyToObj(r.target))),new o(e,r)}),this.$wbwindow[t].prototype=r.prototype,Object.defineProperty(this.$wbwindow[t].prototype,"constructor",{value:this.$wbwindow[t]}),this.$wbwindow[t].prototype[e]=!0}},f.prototype.rewriteParentNodeFn=function(t,e,r){var i=this._no_rewrite?r:this.rewriteElementsInArguments(r),o=this.proxyToObj(t);return e.__WB_orig_apply?e.__WB_orig_apply(o,i):e.apply(o,i)},f.prototype.overrideParentNodeAppendPrepend=function(t){var e=this.rewriteParentNodeFn;if(t.prototype.append){var r=t.prototype.append;t.prototype.append=function(){return e(this,r,arguments)}}if(t.prototype.prepend){var i=t.prototype.prepend;t.prototype.prepend=function(){return e(this,i,arguments)}}},f.prototype.overrideShadowDom=function(){this.$wbwindow.ShadowRoot&&this.$wbwindow.ShadowRoot.prototype&&(this.overrideHtmlAssign(this.$wbwindow.ShadowRoot,"innerHTML",!0),this.overrideParentNodeAppendPrepend(this.$wbwindow.ShadowRoot))},f.prototype.overrideChildNodeInterface=function(t,e){if(t&&t.prototype){var r=e?this.rewriteTextNodeFn:this.rewriteChildNodeFn;if(t.prototype.before){var i=t.prototype.before;t.prototype.before=function(){return r(this,i,arguments)}}if(t.prototype.after){var o=t.prototype.after;t.prototype.after=function(){return r(this,o,arguments)}}if(t.prototype.replaceWith){var n=t.prototype.replaceWith;t.prototype.replaceWith=function(){return r(this,n,arguments)}}}},f.prototype.initTextNodeOverrides=function(){var t=this.$wbwindow.Text;if(t&&t.prototype){var e=t.prototype,r=this.rewriteTextNodeFn;if(e.appendData){var i=e.appendData;e.appendData=function(){return r(this,i,arguments)}}if(e.insertData){var o=e.insertData;e.insertData=function(){return r(this,o,arguments)}}if(e.replaceData){var n=e.replaceData;e.replaceData=function(){return r(this,n,arguments)}}this.overrideChildNodeInterface(t,!0),this.overrideTextProtoGetSet(e,"data"),this.overrideTextProtoGetSet(e,"wholeText")}},f.prototype.initAttrOverrides=function(){this.overrideHrefAttr(this.$wbwindow.HTMLLinkElement.prototype,"cs_"),this.overrideHrefAttr(this.$wbwindow.CSSStyleSheet.prototype,"cs_"),this.overrideHrefAttr(this.$wbwindow.HTMLBaseElement.prototype,"mp_"),this.overrideSrcsetAttr(this.$wbwindow.HTMLImageElement.prototype,"im_"),this.overrideSrcsetAttr(this.$wbwindow.HTMLSourceElement.prototype,"oe_"),this.overrideAttr(this.$wbwindow.HTMLVideoElement.prototype,"poster","im_"),this.overrideAttr(this.$wbwindow.HTMLAudioElement.prototype,"poster","im_"),this.overrideAttr(this.$wbwindow.HTMLImageElement.prototype,"src","im_"),this.overrideAttr(this.$wbwindow.HTMLInputElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLEmbedElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLMediaElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLVideoElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLAudioElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLSourceElement.prototype,"src","oe_"),window.HTMLTrackElement&&window.HTMLTrackElement.prototype&&this.overrideAttr(this.$wbwindow.HTMLTrackElement.prototype,"src","oe_"),this.overrideAttr(this.$wbwindow.HTMLIFrameElement.prototype,"src","if_"),this.$wbwindow.HTMLFrameElement&&this.$wbwindow.HTMLFrameElement.prototype&&this.overrideAttr(this.$wbwindow.HTMLFrameElement.prototype,"src","fr_"),this.overrideAttr(this.$wbwindow.HTMLScriptElement.prototype,"src","js_"),this.overrideAttr(this.$wbwindow.HTMLObjectElement.prototype,"data","oe_"),this.overrideAttr(this.$wbwindow.HTMLObjectElement.prototype,"codebase","oe_"),this.overrideAttr(this.$wbwindow.HTMLMetaElement.prototype,"content","mp_"),this.overrideAttr(this.$wbwindow.HTMLFormElement.prototype,"action","mp_"),this.overrideAttr(this.$wbwindow.HTMLQuoteElement.prototype,"cite","mp_"),this.overrideAttr(this.$wbwindow.HTMLModElement.prototype,"cite","mp_"),this.overrideAnchorAreaElem(this.$wbwindow.HTMLAnchorElement),this.overrideAnchorAreaElem(this.$wbwindow.HTMLAreaElement);var t=this.$wbwindow.CSSStyleDeclaration.prototype,e={background:"background",backgroundImage:"background-image",cursor:"cursor",listStyle:"list-style",listStyleImage:"list-style-image",border:"border",borderImage:"border-image",borderImageSource:"border-image-source",maskImage:"mask-image"};for(var[r,i]of(this.overrideStyleProxy(Object.values(e)),this.$wbwindow.CSS2Properties&&(t=this.$wbwindow.CSS2Properties.prototype),this.overrideStyleAttr(t,"cssText"),Object.entries(e)))this.overrideStyleAttr(t,r,i);if(this.overrideStyleSetProp(t),this.$wbwindow.CSSStyleSheet&&this.$wbwindow.CSSStyleSheet.prototype){var o=this,n=this.$wbwindow.CSSStyleSheet.prototype.insertRule;this.$wbwindow.CSSStyleSheet.prototype.insertRule=function(t,e){return n.call(this,o.rewriteStyle(t),e)}}this.$wbwindow.CSSRule&&this.$wbwindow.CSSRule.prototype&&this.overrideStyleAttr(this.$wbwindow.CSSRule.prototype,"cssText")},f.prototype.initCSSOMOverrides=function(){var t,r=this;if(this.$wbwindow.CSSStyleValue){var i=function(t,e){var i=t[e];t[e]=function(t,e){if(null==e)return i.call(this,t,e);var o=r.noExceptRewriteStyle(e);return i.call(this,t,o)}};this.$wbwindow.CSSStyleValue.parse&&this.$wbwindow.CSSStyleValue.parse.toString().indexOf("[native code]")>0&&i(this.$wbwindow.CSSStyleValue,"parse"),this.$wbwindow.CSSStyleValue.parseAll&&this.$wbwindow.CSSStyleValue.parseAll.toString().indexOf("[native code]")>0&&i(this.$wbwindow.CSSStyleValue,"parseAll")}if(this.$wbwindow.CSSKeywordValue&&this.$wbwindow.CSSKeywordValue.prototype){var o=this.$wbwindow.CSSKeywordValue;this.$wbwindow.CSSKeywordValue=(t=this.$wbwindow.CSSKeywordValue,function(e){return r.domConstructorErrorChecker(this,"CSSKeywordValue",arguments),new t(r.rewriteStyle(e))}),this.$wbwindow.CSSKeywordValue.prototype=o.prototype,Object.defineProperty(this.$wbwindow.CSSKeywordValue.prototype,"constructor",{value:this.$wbwindow.CSSKeywordValue}),e(this.$wbwindow.CSSKeywordValue,"CSSKeywordValue")}if(this.$wbwindow.StylePropertyMap&&this.$wbwindow.StylePropertyMap.prototype){var n=this.$wbwindow.StylePropertyMap.prototype.set;this.$wbwindow.StylePropertyMap.prototype.set=function(){if(arguments.length<=1)return n.__WB_orig_apply?n.__WB_orig_apply(this,arguments):n.apply(this,arguments);var t=new Array(arguments.length);t[0]=arguments[0];for(var e=1;e<arguments.length;e++)t[e]=r.noExceptRewriteStyle(arguments[e]);return n.__WB_orig_apply?n.__WB_orig_apply(this,t):n.apply(this,t)};var s=this.$wbwindow.StylePropertyMap.prototype.append;this.$wbwindow.StylePropertyMap.prototype.append=function(){if(arguments.length<=1)return n.__WB_orig_apply?s.__WB_orig_apply(this,arguments):s.apply(this,arguments);var t=new Array(arguments.length);t[0]=arguments[0];for(var e=1;e<arguments.length;e++)t[e]=r.noExceptRewriteStyle(arguments[e]);return s.__WB_orig_apply?s.__WB_orig_apply(this,t):s.apply(this,t)}}},f.prototype.initAudioOverride=function(){if(this.$wbwindow.Audio){var t,r=this.$wbwindow.Audio,i=this;this.$wbwindow.Audio=(t=this.$wbwindow.Audio,function(e){return i.domConstructorErrorChecker(this,"Audio"),new t(i.rewriteUrl(e,!0,"oe_"))}),this.$wbwindow.Audio.prototype=r.prototype,Object.defineProperty(this.$wbwindow.Audio.prototype,"constructor",{value:this.$wbwindow.Audio}),e(this.$wbwindow.Audio,"HTMLAudioElement")}},f.prototype.initBadPrefixes=function(t){this.BAD_PREFIXES=["http:"+t,"https:"+t,"http:/"+t,"https:/"+t]},f.prototype.initCryptoRandom=function(){if(this.$wbwindow.crypto&&this.$wbwindow.Crypto){var t=this,e=function(e){for(var r=0;r<e.length;r++)e[r]=parseInt(4294967296*t.$wbwindow.Math.random());return e};this.$wbwindow.Crypto.prototype.getRandomValues=e,this.$wbwindow.crypto.getRandomValues=e}},f.prototype.initDateOverride=function(t){if(!this.$wbwindow.__wb_Date_now){var e,r=1e3*parseInt(t),i=this.$wbwindow.Date.now()-(r-0),o=this.$wbwindow.Date,n=this.$wbwindow.Date.UTC,s=this.$wbwindow.Date.parse,a=this.$wbwindow.Date.now;this.$wbwindow.__wb_Date_now=a,this.$wbwindow.Date=(e=this.$wbwindow.Date,function(t,r,o,n,s,h,w){return void 0===t?new e(a()-i):void 0===r?new e(t):void 0===o?new e(t,r):void 0===n?new e(t,r,o):void 0===s?new e(t,r,o,n):void 0===h?new e(t,r,o,n,s):void 0===w?new e(t,r,o,n,s,h):new e(t,r,o,n,s,h,w)}),this.$wbwindow.Date.prototype=o.prototype,this.$wbwindow.Date.now=function(){return a()-i},this.$wbwindow.Date.UTC=n,this.$wbwindow.Date.parse=s,this.$wbwindow.Date.__WB_timediff=i,this.$wbwindow.Date.prototype.getTimezoneOffset=function(){return 0};var h=this.$wbwindow.Date.prototype.toString;this.$wbwindow.Date.prototype.toString=function(){return h.call(this).split(" GMT")[0]+" GMT+0000 (Coordinated Universal Time)"};var w=this.$wbwindow.Date.prototype.toTimeString;this.$wbwindow.Date.prototype.toTimeString=function(){return w.call(this).split(" GMT")[0]+" GMT+0000 (Coordinated Universal Time)"},Object.defineProperty(this.$wbwindow.Date.prototype,"constructor",{value:this.$wbwindow.Date})}},f.prototype.initBlobOverride=function(){if(this.$wbwindow.Blob&&!this.wb_info.isSW){var t,e=this.$wbwindow.Blob,r=this;this.$wbwindow.Blob=(t=this.$wbwindow.Blob,function(e,i){return!i||"application/xhtml+xml"!==i.type&&"text/html"!==i.type||1===e.length&&"string"==typeof e[0]&&r.startsWith(e[0],"<!DOCTYPE html>")&&(e[0]=r.rewriteHtml(e[0]),i.type="text/html"),new t(e,i)}),this.$wbwindow.Blob.prototype=e.prototype}},f.prototype.initWSOverride=function(){this.$wbwindow.WebSocket&&this.$wbwindow.WebSocket.prototype&&(this.$wbwindow.WebSocket=function(t){function e(t,e){this.addEventListener=function(){},this.removeEventListener=function(){},this.close=function(){},this.send=function(t){console.log("ws send",t)},this.protocol=e&&e.length?e[0]:"",this.url=t,this.readyState=0}return e.CONNECTING=0,e.OPEN=1,e.CLOSING=2,e.CLOSED=3,e}(this.$wbwindow.WebSocket),Object.defineProperty(this.$wbwindow.WebSocket.prototype,"constructor",{value:this.$wbwindow.WebSocket}),e(this.$wbwindow.WebSocket,"WebSocket"))},f.prototype.initDocTitleOverride=function(){var t=this.getOrigGetter(this.$wbwindow.document,"title"),e=this.getOrigSetter(this.$wbwindow.document,"title"),r=this;this.defProp(this.$wbwindow.document,"title",(function(t){var i=e.call(this,t),o={wb_type:"title",title:t};return r.sendTopMessage(o),i}),t)},f.prototype.initFontFaceOverride=function(){if(this.$wbwindow.FontFace){var t,r=this,i=this.$wbwindow.FontFace;this.$wbwindow.FontFace=(t=this.$wbwindow.FontFace,function(e,i,o){r.domConstructorErrorChecker(this,"FontFace",arguments,2);var n=i;return null!=i&&(n="string"!=typeof i?r.rewriteInlineStyle(i.toString()):r.rewriteInlineStyle(i)),new t(e,n,o)}),this.$wbwindow.FontFace.prototype=i.prototype,Object.defineProperty(this.$wbwindow.FontFace.prototype,"constructor",{value:this.$wbwindow.FontFace}),e(this.$wbwindow.FontFace,"FontFace")}},f.prototype.initFixedRatio=function(t){try{this.$wbwindow.devicePixelRatio=t}catch(t){}if(Object.defineProperty)try{Object.defineProperty(this.$wbwindow,"devicePixelRatio",{value:t,writable:!1})}catch(t){}},f.prototype.initPaths=function(t){t.wombat_opts=t.wombat_opts||{},Object.assign(this.wb_info,t),this.wb_opts=t.wombat_opts,this.wb_replay_prefix=t.prefix,this.wb_is_proxy=t.proxy_magic||!this.wb_replay_prefix,this.wb_info.top_host=this.wb_info.top_host||"*",this.wb_curr_host=this.$wbwindow.location.protocol+"//"+this.$wbwindow.location.host,this.wb_info.wombat_opts=this.wb_info.wombat_opts||{},this.wb_orig_scheme=t.wombat_scheme+"://",this.wb_orig_origin=this.wb_orig_scheme+t.wombat_host,this.wb_abs_prefix=this.wb_replay_prefix,!t.is_live&&t.wombat_ts?this.wb_capture_date_part="/"+t.wombat_ts+"/":this.wb_capture_date_part="",this.initBadPrefixes(this.wb_replay_prefix),this.initCookiePreset()},f.prototype.initSeededRandom=function(t){this.$wbwindow.Math.seed=parseInt(t);var e=this;this.$wbwindow.Math.random=function(){return e.$wbwindow.Math.seed=(9301*e.$wbwindow.Math.seed+49297)%233280,e.$wbwindow.Math.seed/233280}},f.prototype.initHistoryOverrides=function(){this.overrideHistoryFunc("pushState"),this.overrideHistoryFunc("replaceState");var t=this;this.$wbwindow.addEventListener("popstate",(function(e){t.sendHistoryUpdate(t.$wbwindow.WB_wombat_location.href,t.$wbwindow.document.title)}))},f.prototype.initCookiePreset=function(){if(this.wb_info.presetCookie)for(var t=this.wb_info.presetCookie.split(";"),e=0;e<t.length;e++)this.$wbwindow.document.cookie=t[e].trim()+"; Path="+this.rewriteUrl("./",!0)},f.prototype.initHTTPOverrides=function(){var t,r,i=this;if(this.overridePropExtract(this.$wbwindow.XMLHttpRequest.prototype,"responseURL"),this.wb_info.isSW){var o=this.$wbwindow.XMLHttpRequest.prototype.open,n=this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader,s=this.$wbwindow.XMLHttpRequest.prototype.send;this.utilFns.XHRopen=o,this.utilFns.XHRsend=s,this.$wbwindow.XMLHttpRequest.prototype.open=function(){this.__WB_xhr_open_arguments=arguments,this.__WB_xhr_headers=new Headers},this.$wbwindow.XMLHttpRequest.prototype.setRequestHeader=function(t,e){this.__WB_xhr_headers.set(t,e)};i=this;var a=!!this.wb_info.convert_post_to_get;this.$wbwindow.XMLHttpRequest.prototype.send=async function(t){if(a&&("POST"===this.__WB_xhr_open_arguments[0]||"PUT"===this.__WB_xhr_open_arguments[0])){var e={url:this.__WB_xhr_open_arguments[1],method:this.__WB_xhr_open_arguments[0],headers:this.__WB_xhr_headers,postData:t};_(e)&&(this.__WB_xhr_open_arguments[1]=e.url,this.__WB_xhr_open_arguments[0]="GET",t=null)}if(this.__WB_xhr_open_arguments.length>2&&!this.__WB_xhr_open_arguments[2]&&-1===navigator.userAgent.indexOf("Firefox")&&(this.__WB_xhr_open_arguments[2]=!0,console.warn("wombat.js: Sync XHR not supported in SW-based replay in this browser, converted to async")),this._no_rewrite||(this.__WB_xhr_open_arguments[1]=i.rewriteUrl(this.__WB_xhr_open_arguments[1])),o.apply(this,this.__WB_xhr_open_arguments),!i.startsWith(this.__WB_xhr_open_arguments[1],"data:")){for(const[t,e]of this.__WB_xhr_headers.entries())n.call(this,t,e);n.call(this,"X-Pywb-Requested-With","XMLHttpRequest")}return s.call(this,t)}}else if(this.$wbwindow.XMLHttpRequest.prototype.open){var h=this.$wbwindow.XMLHttpRequest.prototype.open;this.utilFns.XHRopen=h,this.utilFns.XHRsend=this.$wbwindow.XMLHttpRequest.prototype.send,this.$wbwindow.XMLHttpRequest.prototype.open=function(t,e,r,o,n){var s=this._no_rewrite?e:i.rewriteUrl(e),a=!0;null==r||r||(a=!1),h.call(this,t,s,a,o,n),i.startsWith(s,"data:")||this.setRequestHeader("X-Pywb-Requested-With","XMLHttpRequest")}}if(this.$wbwindow.fetch){var w=this.$wbwindow.fetch;this.$wbwindow.fetch=function(t,e){var r=t,o=typeof t;if("string"===o)r=i.rewriteUrl(t);else if("object"===o&&t.url){var n=i.rewriteUrl(t.url);n!==t.url&&(r=new Request(n,e))}else"object"===o&&t.href&&(r=i.rewriteUrl(t.href));if(e||(e={}),void 0===e.credentials)try{e.credentials="include"}catch(t){}return w.call(i.proxyToObj(this),r,e)}}if(this.$wbwindow.Request&&this.$wbwindow.Request.prototype){var p=this.$wbwindow.Request;this.$wbwindow.Request=(t=this.$wbwindow.Request,function(e,r){i.domConstructorErrorChecker(this,"Request",arguments);var o=r||{},n=e,s=typeof e;switch(s){case"string":n=i.rewriteUrl(e);break;case"object":if(n=e,e.url){var a=i.rewriteUrl(e.url);a!==e.url&&(n=new t(a,e))}else e.href&&(n=i.rewriteUrl(e.toString(),!0))}return o.credentials="include",o.referrer&&(o.referrer=i.rewriteUrl(o.referrer)),new t(n,o)}),this.$wbwindow.Request.prototype=p.prototype,Object.defineProperty(this.$wbwindow.Request.prototype,"constructor",{value:this.$wbwindow.Request}),this.overridePropExtract(this.$wbwindow.Request.prototype,"url"),this.overridePropExtract(this.$wbwindow.Request.prototype,"referrer")}if(this.$wbwindow.Response&&this.$wbwindow.Response.prototype){var c=this.$wbwindow.Response.prototype.redirect;this.$wbwindow.Response.prototype.redirect=function(t,e){var r=i.rewriteUrl(t,!0,null,i.$wbwindow.document);return c.call(this,r,e)},this.overridePropExtract(this.$wbwindow.Response.prototype,"url")}if(this.$wbwindow.EventSource&&this.$wbwindow.EventSource.prototype){var l=this.$wbwindow.EventSource;this.$wbwindow.EventSource=(r=this.$wbwindow.EventSource,function(t,e){i.domConstructorErrorChecker(this,"EventSource",arguments);var o=t;return null!=t&&(o=i.rewriteUrl(t)),new r(o,e)}),this.$wbwindow.EventSource.prototype=l.prototype,Object.defineProperty(this.$wbwindow.EventSource.prototype,"constructor",{value:this.$wbwindow.EventSource}),e(this.$wbwindow.EventSource,"EventSource")}},f.prototype.initElementGetSetAttributeOverride=function(){if(!this.wb_opts.skip_setAttribute&&this.$wbwindow.Element&&this.$wbwindow.Element.prototype){var t=this,e=this.$wbwindow.Element.prototype;if(e.setAttribute){var r=e.setAttribute;e._orig_setAttribute=r,e.setAttribute=function(e,i){var o=i;if(e&&"string"==typeof o){var n=e.toLowerCase();if("LINK"===this.tagName&&"href"===n&&0===o.indexOf("data:text/css"))o=t.rewriteInlineStyle(i);else if("style"===n)o=t.rewriteStyle(i);else if("srcset"===n||"imagesrcset"===n&&"LINK"===this.tagName)o=t.rewriteSrcset(i,this);else{t.shouldRewriteAttr(this.tagName,n)&&(t.removeWBOSRC(this),this._no_rewrite||(o=t.rewriteUrl(i,!1,t.rwModForElement(this,n))))}}return r.call(this,e,o)}}if(e.getAttribute){var i=e.getAttribute;this.wb_getAttribute=i,e.getAttribute=function(e){var r=i.call(this,e);if(null===r)return r;var o=e;if(e&&(o=e.toLowerCase()),t.shouldRewriteAttr(this.tagName,o)){var n=t.retrieveWBOSRC(this);return n||t.extractOriginalURL(r)}return t.startsWith(o,"data-")&&t.startsWithOneOf(r,t.wb_prefixes)?t.extractOriginalURL(r):r}}}},f.prototype.initSvgImageOverrides=function(){if(this.$wbwindow.SVGImageElement){var t=this.$wbwindow.SVGImageElement.prototype,e=t.getAttribute,r=t.getAttributeNS,i=t.setAttribute,o=t.setAttributeNS,n=this;t.getAttribute=function(t){var r=e.call(this,t);return t.indexOf("xlink:href")>=0||"href"===t?n.extractOriginalURL(r):r},t.getAttributeNS=function(t,e){var i=r.call(this,t,e);return e.indexOf("xlink:href")>=0||"href"===e?n.extractOriginalURL(i):i},t.setAttribute=function(t,e){var r=e;return(t.indexOf("xlink:href")>=0||"href"===t)&&(r=n.rewriteUrl(e)),i.call(this,t,r)},t.setAttributeNS=function(t,e,r){var i=r;return(e.indexOf("xlink:href")>=0||"href"===e)&&(i=n.rewriteUrl(r)),o.call(this,t,e,i)}}},f.prototype.initCreateElementNSFix=function(){if(this.$wbwindow.document.createElementNS&&this.$wbwindow.Document.prototype.createElementNS){var t=this.$wbwindow.document.createElementNS,e=this,r=function(r,i){return t.call(e.proxyToObj(this),e.extractOriginalURL(r),i)};this.$wbwindow.Document.prototype.createElementNS=r,this.$wbwindow.document.createElementNS=r}},f.prototype.initInsertAdjacentElementHTMLOverrides=function(){var t=this.$wbwindow.Element;if(t&&t.prototype){var e=t.prototype,r=this.rewriteInsertAdjHTMLOrElemArgs;if(e.insertAdjacentHTML){var i=e.insertAdjacentHTML;e.insertAdjacentHTML=function(t,e){return r(this,i,t,e,!0)}}if(e.insertAdjacentElement){var o=e.insertAdjacentElement;e.insertAdjacentElement=function(t,e){return r(this,o,t,e,!1)}}}},f.prototype.initDomOverride=function(){var t=this.$wbwindow.Node;if(t&&t.prototype){var e=this.rewriteNodeFuncArgs;if(t.prototype.appendChild){var r=t.prototype.appendChild;t.prototype.appendChild=function(t,i){return e(this,r,t,i)}}if(t.prototype.insertBefore){var i=t.prototype.insertBefore;t.prototype.insertBefore=function(t,r){return e(this,i,t,r)}}if(t.prototype.replaceChild){var o=t.prototype.replaceChild;t.prototype.replaceChild=function(t,r){return e(this,o,t,r)}}this.overridePropToProxy(t.prototype,"ownerDocument"),this.overridePropToProxy(this.$wbwindow.HTMLHtmlElement.prototype,"parentNode"),this.overridePropToProxy(this.$wbwindow.Event.prototype,"target")}this.$wbwindow.Element&&this.$wbwindow.Element.prototype&&(this.overrideParentNodeAppendPrepend(this.$wbwindow.Element),this.overrideChildNodeInterface(this.$wbwindow.Element,!1)),this.$wbwindow.DocumentFragment&&this.$wbwindow.DocumentFragment.prototype&&this.overrideParentNodeAppendPrepend(this.$wbwindow.DocumentFragment)},f.prototype.initDocOverrides=function(t){if(Object.defineProperty){this.overrideReferrer(t),this.defGetterProp(t,"origin",(function(){return this.WB_wombat_location.origin})),this.defGetterProp(this.$wbwindow,"origin",(function(){return this.WB_wombat_location.origin}));var e=this;this.defProp(t,"domain",(function(t){var r=this.WB_wombat_location;r&&e.endsWith(r.hostname,t)&&(this.__wb_domain=t)}),(function(){return this.__wb_domain||this.WB_wombat_location.hostname}))}},f.prototype.initDocWriteOpenCloseOverride=function(){if(this.$wbwindow.DOMParser){var t=this.$wbwindow.Document.prototype,e=this.$wbwindow.document;this._writeBuff="";var r=this,i=e.write,o=function(){return d(this,i,u(arguments))};e.write=o,t.write=o;var n=e.writeln,s=function(){return d(this,n,u(arguments))};e.writeln=s,t.writeln=s;var a=e.open,h=function(){var t,e=r.proxyToObj(this);if(3===arguments.length){var i=r.rewriteUrl(arguments[0],!1,"mp_");t=a.call(e,i,arguments[1],arguments[2]),r.initNewWindowWombat(t,arguments[0])}else t=a.call(e),_()?r._writeBuff="":r.initNewWindowWombat(e.defaultView);return t};e.open=h,t.open=h;var w=e.close,p=function(){if(r._writeBuff)return r.blobUrlForIframe(r.$wbwindow.frameElement,r._writeBuff),void(r._writeBuff="");var t=r.proxyToObj(this);return r.initNewWindowWombat(t.defaultView),w.__WB_orig_apply?w.__WB_orig_apply(t,arguments):w.apply(t,arguments)};e.close=p,t.close=p;var c=this.getOrigGetter(t,"body"),l=this.getOrigSetter(t,"body");c&&l&&this.defProp(t,"body",(function(t){return t&&(t instanceof HTMLBodyElement||t instanceof HTMLFrameSetElement)&&r.rewriteElemComplete(t),l.call(r.proxyToObj(this),t)}),c)}function _(){return r.wb_info.isSW&&r.$wbwindow.frameElement}function u(t){return 0===t.length?"":1===t.length?t[0]:Array.prototype.join.call(t,"")}function d(t,e,i){r.$wbwindow;if(!_()){i=r.rewriteHtml(i,!0);var o=r.proxyToObj(t),n=e.call(o,i);return r.initNewWindowWombat(o.defaultView),n}r._writeBuff+=i}},f.prototype.initIframeWombat=function(t){var e;e=t._get_contentWindow?t._get_contentWindow.call(t):t.contentWindow;try{if(!e||e===this.$wbwindow||e._skip_wombat||e._wb_wombat)return}catch(t){return}var r=t.src;this.initNewWindowWombat(e,r)},f.prototype.initNewWindowWombat=function(t,e){var r=!1;if(t&&!t._wb_wombat){if(e&&""!==e&&!this.startsWithOneOf(e,["about:blank","javascript:"])||(r=!0),!r&&this.wb_info.isSW){var i=this.extractOriginalURL(e);("about:blank"===i||i.startsWith("srcdoc:")||i.startsWith("blob:"))&&(r=!0)}if(r){var o={};Object.assign(o,this.wb_info);var n=new f(t,o);t._wb_wombat=n.wombatInit()}else this.initProtoPmOrigin(t),this.initPostMessageOverride(t),this.initMessageEventOverride(t),this.initCheckThisFunc(t),this.initImportWrapperFunc(t)}},f.prototype.initTimeoutIntervalOverrides=function(){var t=this.rewriteSetTimeoutInterval;if(this.$wbwindow.setTimeout&&!this.$wbwindow.setTimeout.__$wbpatched$__){var e=this.$wbwindow.setTimeout;this.$wbwindow.setTimeout=function(){return t(this,e,arguments)},this.$wbwindow.setTimeout.__$wbpatched$__=!0}if(this.$wbwindow.setInterval&&!this.$wbwindow.setInterval.__$wbpatched$__){var r=this.$wbwindow.setInterval;this.$wbwindow.setInterval=function(){return t(this,r,arguments)},this.$wbwindow.setInterval.__$wbpatched$__=!0}},f.prototype.initWorkerOverrides=function(){var t,e,r=this;if(this.$wbwindow.Worker&&!this.$wbwindow.Worker._wb_worker_overridden){var i=this.$wbwindow.Worker;this.$wbwindow.Worker=(t=i,function(e,i){return r.domConstructorErrorChecker(this,"Worker",arguments),new t(r.rewriteWorker(e),i)}),this.$wbwindow.Worker.prototype=i.prototype,Object.defineProperty(this.$wbwindow.Worker.prototype,"constructor",{value:this.$wbwindow.Worker}),this.$wbwindow.Worker._wb_worker_overridden=!0}if(this.$wbwindow.SharedWorker&&!this.$wbwindow.SharedWorker.__wb_sharedWorker_overridden){var o=this.$wbwindow.SharedWorker;this.$wbwindow.SharedWorker=(e=o,function(t,i){return r.domConstructorErrorChecker(this,"SharedWorker",arguments),new e(r.rewriteWorker(t),i)}),this.$wbwindow.SharedWorker.prototype=o.prototype,Object.defineProperty(this.$wbwindow.SharedWorker.prototype,"constructor",{value:this.$wbwindow.SharedWorker}),this.$wbwindow.SharedWorker.__wb_sharedWorker_overridden=!0}if(this.$wbwindow.ServiceWorkerContainer&&this.$wbwindow.ServiceWorkerContainer.prototype&&this.$wbwindow.ServiceWorkerContainer.prototype.register){var n=this.$wbwindow.ServiceWorkerContainer.prototype.register;this.$wbwindow.ServiceWorkerContainer.prototype.register=function(t,e){var i=new URL(t,r.$wbwindow.document.baseURI).href,o=r.getPageUnderModifier();return e&&e.scope?e.scope=r.rewriteUrl(e.scope,!1,o):e={scope:r.rewriteUrl("/",!1,o)},n.call(this,r.rewriteUrl(i,!1,"sw_"),e)}}if(this.$wbwindow.Worklet&&this.$wbwindow.Worklet.prototype&&this.$wbwindow.Worklet.prototype.addModule&&!this.$wbwindow.Worklet.__wb_workerlet_overridden){var s=this.$wbwindow.Worklet.prototype.addModule;this.$wbwindow.Worklet.prototype.addModule=function(t,e){var i=r.rewriteUrl(t,!1,"js_");return s.call(this,i,e)},this.$wbwindow.Worklet.__wb_workerlet_overridden=!0}},f.prototype.initLocOverride=function(t,e,r){if(Object.defineProperty)for(var i=0;i<this.URL_PROPS.length;i++){var o=this.URL_PROPS[i];this.defProp(t,o,this.makeSetLocProp(o,e,r),this.makeGetLocProp(o,r),!0)}},f.prototype.initWombatLoc=function(t){if(!(!t||t.WB_wombat_location&&t.document.WB_wombat_location)){var e=new h(t.location,this),r=this;if(Object.defineProperty){this.defProp(t.Object.prototype,"WB_wombat_location",(function(e){var i=this._WB_wombat_location||this.defaultView&&this.defaultView._WB_wombat_location;i&&(i.href=e),t.location=r.rewriteUrl(e)}),(function(){return this._WB_wombat_location||this.defaultView&&this.defaultView._WB_wombat_location||this.location})),this.initProtoPmOrigin(t),t._WB_wombat_location=e}else t.WB_wombat_location=e,setTimeout(this.checkAllLocations,500),setInterval(this.checkAllLocations,500)}},f.prototype.initProtoPmOrigin=function(t){if(!t.Object.prototype.__WB_pmw){var e=function(t){return this.__WB_source=t,this};try{t.Object.defineProperty(t.Object.prototype,"__WB_pmw",{get:function(){return e},set:function(){},configurable:!0,enumerable:!1})}catch(t){}t.__WB_check_loc=function(t,e){if(t instanceof Location||t instanceof h){if(e)for(var r=0;r<e.length;r++)if(t===e[r])return{};return this.WB_wombat_location}return{}}}},f.prototype.initCheckThisFunc=function(t){try{t.Object.prototype[this.WB_CHECK_THIS_FUNC]||t.Object.defineProperty(t.Object.prototype,this.WB_CHECK_THIS_FUNC,{configutable:!1,enumerable:!1,value:function(t){return t&&t._WB_wombat_obj_proxy?t._WB_wombat_obj_proxy:t}})}catch(t){}},f.prototype.initImportWrapperFunc=function(t){var e=this;t.____wb_rewrite_import__=function(t,r){return t&&(r=new URL(r,t).href),import(e.rewriteUrl(r,!1,"esm_"))}},f.prototype.overrideGetOwnPropertyNames=function(t){var e=t.Object.getOwnPropertyNames,r=[this.WB_CHECK_THIS_FUNC,"WB_wombat_location","__WB_pmw","WB_wombat_top","WB_wombat_eval","WB_wombat_runEval"];try{t.Object.defineProperty(t.Object,"getOwnPropertyNames",{value:function(t){for(var i=e(t),o=0;o<r.length;o++){var n=i.indexOf(r[o]);n>=0&&i.splice(n,1)}return i}})}catch(t){console.log(t)}},f.prototype.initHashChange=function(){if(this.$wbwindow.__WB_top_frame){var t=this;this.$wbwindow.addEventListener("message",(function(e){if(e.data&&e.data.from_top){var r=e.data.message;r.wb_type&&"outer_hashchange"===r.wb_type&&t.$wbwindow.location.hash!=r.hash&&(t.$wbwindow.location.hash=r.hash)}})),this.$wbwindow.addEventListener("hashchange",(function(){var e={wb_type:"hashchange",hash:t.$wbwindow.location.hash};t.sendTopMessage(e)}))}},f.prototype.initPostMessageOverride=function(t){if(t.postMessage&&!t.__orig_postMessage){var e=t.postMessage,r=this;t.__orig_postMessage=e;var i=function(i,o,n,s){var a,h,w=r.proxyToObj(this);if(w||((w=t).__WB_source=t),w.__WB_source&&w.__WB_source.WB_wombat_location){var p=w.__WB_source;if(a=p.WB_wombat_location.origin,w.__WB_win_id||(w.__WB_win_id={},w.__WB_counter=0),!p.__WB_id){var c=w.__WB_counter;p.__WB_id=c+p.WB_wombat_location.href,w.__WB_counter+=1}w.__WB_win_id[p.__WB_id]=p,h=p.__WB_id,w.__WB_source=void 0}else a=window.WB_wombat_location.origin;var l=o;l===w.location.origin&&(l=a);var _={from:a,to_origin:l,src_id:h,message:i,from_top:s};if("*"!==o){if("null"===w.location.origin||""===w.location.origin)return;o=w.location.origin}return e.call(w,_,o,n)};t.postMessage=i,t.Window.prototype.postMessage=i;var o=null,n=(o=t.EventTarget&&t.EventTarget.prototype?t.EventTarget.prototype:t).addEventListener;o.addEventListener=function(t,e,i){var o,s=r.proxyToObj(this);if("message"===t?o=r.message_listeners.add_or_get(e,(function(){return c(e,s,r)})):"storage"===t?r.storage_listeners.add_or_get(e,(function(){return p(e,s)})):o=e,o)return n.call(s,t,o,i)};var s=o.removeEventListener;o.removeEventListener=function(t,e,i){var o,n=r.proxyToObj(this);if("message"===t?o=r.message_listeners.remove(e):"storage"===t?r.storage_listeners.remove(e):o=e,o)return s.call(n,t,o,i)};var a=function(e,i){var o=r.getOrigSetter(t,e);r.defProp(t,e,(function(t){this["__orig_"+e]=t;var n=r.proxyToObj(this),s=t?i(t,n,r):t;return o.call(n,s)}),(function(){return this["__orig_"+e]}))};a("onmessage",c),a("onstorage",p)}},f.prototype.initMessageEventOverride=function(t){t.MessageEvent&&!t.MessageEvent.prototype.__extended&&(this.addEventOverride("target"),this.addEventOverride("srcElement"),this.addEventOverride("currentTarget"),this.addEventOverride("eventPhase"),this.addEventOverride("path"),this.overridePropToProxy(t.MessageEvent.prototype,"source"),t.MessageEvent.prototype.__extended=!0)},f.prototype.initUIEventsOverrides=function(){this.overrideAnUIEvent("UIEvent"),this.overrideAnUIEvent("MouseEvent"),this.overrideAnUIEvent("TouchEvent"),this.overrideAnUIEvent("FocusEvent"),this.overrideAnUIEvent("KeyboardEvent"),this.overrideAnUIEvent("WheelEvent"),this.overrideAnUIEvent("InputEvent"),this.overrideAnUIEvent("CompositionEvent")},f.prototype.initOpenOverride=function(){var t=this.$wbwindow.open;this.$wbwindow.Window.prototype.open&&(t=this.$wbwindow.Window.prototype.open);var e=this,r=function(r,i,o){i&&(i=e.rewriteAttrTarget(i));var n=e.rewriteUrl(r,!1),s=t.call(e.proxyToObj(this),n,i,o);return e.initNewWindowWombat(s,r),s};this.$wbwindow.open=r,this.$wbwindow.Window.prototype.open&&(this.$wbwindow.Window.prototype.open=r);for(var i=0;i<this.$wbwindow.frames.length;i++)try{this.$wbwindow.frames[i].open=r}catch(t){console.log(t)}},f.prototype.rewriteAttrTarget=function(t){return this.wb_info.target_frame&&("_blank"===t||"_parent"===t||"_top"===t||t&&this.$wbwindow===this.$wbwindow.__WB_replay_top)?this.wb_info.target_frame:t},f.prototype.initCookiesOverride=function(){var t=this.getOrigGetter(this.$wbwindow.document,"cookie"),e=this.getOrigSetter(this.$wbwindow.document,"cookie");t||(t=this.getOrigGetter(this.$wbwindow.Document.prototype,"cookie")),e||(e=this.getOrigSetter(this.$wbwindow.Document.prototype,"cookie"));var r=function(t,e){var r=new Date(e);return isNaN(r.getTime())?"Expires=Thu,| 01 Jan 1970 00:00:00 GMT":"Expires="+new Date(r.getTime()+Date.__WB_timediff).toUTCString().replace(",",",|")},i=this;this.defProp(this.$wbwindow.document,"cookie",(function(t){if(t){for(var o=t.replace(i.cookie_expires_regex,r).split(i.SetCookieRe),n=0;n<o.length;n++)o[n]=i.rewriteCookie(o[n]);return e.call(i.proxyToObj(this),o.join(","))}}),(function(){return t.call(i.proxyToObj(this))}))},f.prototype.initRegisterUnRegPHOverride=function(){var t=this,e=this.$wbwindow.navigator;if(e.registerProtocolHandler){var r=e.registerProtocolHandler;e.registerProtocolHandler=function(e,i,o){return r.call(this,e,t.rewriteUrl(i),o)}}if(e.unregisterProtocolHandler){var i=e.unregisterProtocolHandler;e.unregisterProtocolHandler=function(e,r){return i.call(this,e,t.rewriteUrl(r))}}},f.prototype.initBeaconOverride=function(){if(this.$wbwindow.navigator.sendBeacon){var t=this.$wbwindow.navigator.sendBeacon,e=this;this.$wbwindow.navigator.sendBeacon=function(r,i){try{return t.call(this,e.rewriteUrl(r),i)}catch(t){return!0}}}},f.prototype.initMiscNavigatorOverrides=function(){this.$wbwindow.navigator.mediaDevices&&(this.$wbwindow.navigator.mediaDevices.setCaptureHandleConfig=function(){})},f.prototype.initPresentationRequestOverride=function(){if(this.$wbwindow.PresentationRequest&&this.$wbwindow.PresentationRequest.prototype){var t=this,e=this.$wbwindow.PresentationRequest;this.$wbwindow.PresentationRequest=(r=this.$wbwindow.PresentationRequest,function(e){t.domConstructorErrorChecker(this,"PresentationRequest",arguments);var i=e;if(null!=e)if(Array.isArray(i))for(var o=0;o<i.length;o++)i[o]=t.rewriteUrl(i[o],!0,"mp_");else i=t.rewriteUrl(e,!0,"mp_");return new r(i)}),this.$wbwindow.PresentationRequest.prototype=e.prototype,Object.defineProperty(this.$wbwindow.PresentationRequest.prototype,"constructor",{value:this.$wbwindow.PresentationRequest})}var r},f.prototype.initDisableNotificationsGeoLocation=function(){window.Notification&&(window.Notification.requestPermission=function(t){return t&&t("denied"),Promise.resolve("denied")});var t=function(t){t&&(t.getCurrentPosition&&(t.getCurrentPosition=function(t,e,r){e&&e({code:2,message:"not available"})}),t.watchPosition&&(t.watchPosition=function(t,e,r){e&&e({code:2,message:"not available"})}))};window.geolocation&&t(window.geolocation),window.navigator.geolocation&&t(window.navigator.geolocation)},f.prototype.initStorageOverride=function(){this.addEventOverride("storageArea",this.$wbwindow.StorageEvent.prototype),i.yes=!1;var t={};if(this.wb_info.storage)try{t=JSON.parse(atob(this.wb_info.storage))}catch(t){console.warn("Error parsing storage, storages not loaded")}a(this,"localStorage",t.local),a(this,"sessionStorage",t.session),this.$wbwindow.Storage=s,i.yes=!0},f.prototype.initIndexedDBOverride=function(){if(this.$wbwindow.IDBFactory){var t=this.$wbwindow.IDBFactory.prototype,e="wb-"+this.wb_orig_origin+"-",r=t.open;t.open=function(t,i){return r.call(this,e+t,i)};var i=t.deleteDatabase;t.delete=function(t){return i.call(this,e+t,options)};var o=t.databases;t.databases=function(){var t=this;return new Promise((function(r,i){o.call(t).then((function(t){for(var i=[],o=0;o<t.length;o++)0===t[o].name.indexOf(e)&&i.push({name:t[o].name.substring(e.length),version:t[o].version});r(i)})).catch((function(t){i(t)}))}))}}},f.prototype.initCachesOverride=function(){if(this.$wbwindow.CacheStorage){this.$wbwindow.chrome&&(this.$wbwindow.chrome={});var t=this.$wbwindow.CacheStorage.prototype,e="wb-"+this.wb_orig_origin+"-",r=t.open;t.open=function(t){return r.call(this,e+t)};var i=t.has;t.has=function(t){return i.call(this,e+t)};var o=t.delete;t.delete=function(t){return o.call(this,e+t)};var n=t.keys;t.keys=function(){var t=this;return new Promise((function(r,i){n.call(t).then((function(t){for(var i=[],o=0;o<t.length;o++)0===t[o].indexOf(e)&&i.push(t[o].substring(e.length));r(i)})).catch((function(t){i(t)}))}))};t.match;t.match=function(t,e){var r=this;return this.keys().then((function(i){var o;return i.reduce((function(i,n){return i.then((function(){return o||r.open(n).then((function(r){return r.match(t,e)})).then((function(t){return o=t}))}))}),Promise.resolve())}))}}},f.prototype.initWindowObjProxy=function(t){if(t.Proxy){var e=this.getAllOwnProps(t),r={},i=this,o=new t.Proxy({},{get:function(o,n){switch(n){case"top":return i.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy;case"parent":if(i.$wbwindow===i.$wbwindow.WB_wombat_top)return i.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy;try{var s=i.$wbwindow.parent._WB_wombat_obj_proxy;if(s)return s}catch(t){}return i.$wbwindow.WB_wombat_top._WB_wombat_obj_proxy}return i.defaultProxyGet(t,n,e,r)},set:function(e,r,i){switch(r){case"location":return t.WB_wombat_location=i,!0;case"postMessage":case"document":return!0}try{if(!Reflect.set(e,r,i))return!1}catch(t){}return Reflect.set(t,r,i)},has:function(e,r){return r in t},ownKeys:function(e){return Object.getOwnPropertyNames(t).concat(Object.getOwnPropertySymbols(t))},getOwnPropertyDescriptor:function(e,r){var i=Object.getOwnPropertyDescriptor(e,r);return i||(i=Object.getOwnPropertyDescriptor(t,r))&&(i.configurable=!0),i},getPrototypeOf:function(e){return Object.getPrototypeOf(t)},setPrototypeOf:function(t,e){return!1},isExtensible:function(e){return Object.isExtensible(t)},preventExtensions:function(e){return Object.preventExtensions(t),!0},deleteProperty:function(e,r){var i=Object.getOwnPropertyDescriptor(t,r);return void 0===i||!1!==i.configurable&&(delete e[r],delete t[r],!0)},defineProperty:function(e,r,i){var o=i||{};return void 0===o.value&&void 0===o.get&&(o.value=t[r]),Reflect.defineProperty(t,r,o),Reflect.defineProperty(e,r,o)}});return t._WB_wombat_obj_proxy=o,o}},f.prototype.initDocumentObjProxy=function(t){if(this.initDocOverrides(t),this.$wbwindow.Proxy){var e={},r=this.getAllOwnProps(t),i=this,o=new this.$wbwindow.Proxy(t,{get:function(o,n){return i.defaultProxyGet(t,n,r,e)},set:function(e,r,i){return"location"===r?t.WB_wombat_location=i:e[r]=i,!0}});return t._WB_wombat_obj_proxy=o,o}},f.prototype.initAutoFetchWorker=function(){if(this.wbUseAFWorker){var t=new w(this,{isTop:this.$wbwindow===this.$wbwindow.__WB_replay_top,workerURL:(this.wb_info.auto_fetch_worker_prefix||this.wb_info.static_prefix)+"autoFetchWorker.js?init="+encodeURIComponent(JSON.stringify({mod:this.wb_info.mod,prefix:this.wb_abs_prefix,rwRe:this.wb_unrewrite_rx.source}))});this.WBAutoFetchWorker=t,this.$wbwindow.$WBAutoFetchWorker$=t;var e=this;this.utilFns.wbSheetMediaQChecker=function(){e._removeEventListener(this,"load",e.utilFns.wbSheetMediaQChecker),null!=this.sheet&&e.WBAutoFetchWorker&&e.WBAutoFetchWorker.deferredSheetExtraction(this.sheet)}}},f.prototype.initTopFrameNotify=function(t){var e=this,r=function(r){if(e.$wbwindow.__WB_top_frame){if(e.$wbwindow.WB_wombat_location){var i=e.$wbwindow.WB_wombat_location.href;if("string"==typeof i&&"about:blank"!==i&&0!==i.indexOf("javascript:")&&("complete"===e.$wbwindow.document.readyState&&e.wbUseAFWorker&&e.WBAutoFetchWorker&&e.WBAutoFetchWorker.extractFromLocalDoc(),e.$wbwindow===e.$wbwindow.__WB_replay_top)){for(var o=[],n=e.$wbwindow.document.querySelectorAll("link[rel*=\'icon\']"),s=0;s<n.length;s++){var a=n[s];o.push({rel:a.rel,href:e.wb_getAttribute.call(a,"href")})}o.push({rel:"icon",href:e.rewriteUrl("/favicon.ico")});var h={icons:o,url:e.$wbwindow.WB_wombat_location.href,ts:e.wb_info.timestamp,request_ts:e.wb_info.request_ts,is_live:e.wb_info.is_live,title:e.$wbwindow.document?e.$wbwindow.document.title:"",readyState:e.$wbwindow.document.readyState,wb_type:"load"};e.sendTopMessage(h)}}}else{var w=e.$wbwindow.location.hash;e.$wbwindow.location.replace(t.top_url+w)}};"complete"===this.$wbwindow.document.readyState?r():this.$wbwindow.addEventListener?this.$wbwindow.document.addEventListener("readystatechange",r):this.$wbwindow.attachEvent&&this.$wbwindow.document.attachEvent("onreadystatechange",r)},f.prototype.initTopFrame=function(t){if(this.wb_is_proxy)return t.__WB_replay_top=t.top,t.__WB_top_frame=void 0,this.replayTopHost=r.location.host,void(this.replayTopProtocol=r.location.protocol);for(var e=function(t){try{return!!t&&(t.wbinfo?t.wbinfo.is_framed:null!=t._wb_wombat)}catch(t){return!1}},r=t;r.parent!=r&&e(r.parent);)r=r.parent;t.__WB_replay_top=r,this.replayTopHost=r.location.host,this.replayTopProtocol=r.location.protocol;var i=r.parent;if(i!=t&&this.wb_info.is_framed||(i=void 0),i?(t.__WB_top_frame=i,this.initFrameElementOverride(t)):t.__WB_top_frame=void 0,!this.wb_opts.embedded&&r==t&&this.wbUseAFWorker){var o=this;this.$wbwindow.addEventListener("message",(function(t){t.data&&"aaworker"===t.data.wb_type&&o.WBAutoFetchWorker&&o.WBAutoFetchWorker.postMessage(t.data.msg)}),!1)}},f.prototype.initFrameElementOverride=function(t){if(Object.defineProperty&&this.proxyToObj(t.__WB_replay_top)==this.proxyToObj(t))try{Object.defineProperty(t,"frameElement",{value:null,configurable:!1})}catch(t){}},f.prototype.initWombatTop=function(t){if(Object.defineProperty){this.defProp(t.Object.prototype,"WB_wombat_top",(function(t){this.top=t}),(function(){return this.__WB_replay_top?this.__WB_replay_top:(t=this,(void 0===window.constructor?t instanceof window.constructor:t.window==t)?this:this.top);var t}))}},f.prototype.initEvalOverride=function(){var t=this.rewriteEvalArg,e=function(){};this.wrappedEval=function(e){return function(r){return t(e,r)}};var r=this,i=function(e){var r=this;return r&&r.eval&&r.eval!==eval?{eval:function(){return r.eval.__WB_orig_apply(r,arguments)}}:{eval:function(r){return t(e,r)}}},o=function(e){var i=this;return i&&i.eval&&i.eval!==eval?{eval:function(){return i.eval.__WB_orig_apply(i,[].slice.call(arguments,2))}}:{eval:function(i,o,n){var s=i===r.proxyToObj(r.$wbwindow);try{s=s&&!o.callee.caller}catch(t){s=!1}return t(e,n,s)}}};this.defProp(this.$wbwindow.Object.prototype,"WB_wombat_runEval",e,(function(){return i})),this.defProp(this.$wbwindow.Object.prototype,"WB_wombat_runEval2",e,(function(){return o}))},f.prototype.wombatInit=function(){this._internalInit(),this.initCookiePreset(),this.initHistoryOverrides(),this.overrideFunctionApply(this.$wbwindow),this.overrideFunctionBind(this.$wbwindow),this.initDocTitleOverride(),this.initHashChange(),this.wb_opts.skip_postmessage||(this.initPostMessageOverride(this.$wbwindow),this.initMessageEventOverride(this.$wbwindow)),this.initCheckThisFunc(this.$wbwindow),this.initImportWrapperFunc(this.$wbwindow),this.overrideGetOwnPropertyNames(this.$wbwindow),this.initUIEventsOverrides(),this.initDocWriteOpenCloseOverride(),this.initEvalOverride(),this.initHTTPOverrides(),this.initAudioOverride(),this.initFontFaceOverride(this.$wbwindow),this.initWorkerOverrides(),this.initTextNodeOverrides(),this.initCSSOMOverrides(),this.overrideHtmlAssign(this.$wbwindow.Element,"innerHTML",!0),this.overrideHtmlAssign(this.$wbwindow.Element,"outerHTML",!0),this.overrideHtmlAssignSrcDoc(this.$wbwindow.HTMLIFrameElement,"srcdoc",!0),this.overrideHtmlAssign(this.$wbwindow.HTMLStyleElement,"textContent"),this.overrideShadowDom(),this.overridePropExtract(this.$wbwindow.Document.prototype,"URL"),this.overridePropExtract(this.$wbwindow.Document.prototype,"documentURI"),this.overridePropExtract(this.$wbwindow.Node.prototype,"baseURI"),this.overrideAttrProps(),this.overrideDataSet(),this.initInsertAdjacentElementHTMLOverrides(),this.overrideIframeContentAccess("contentWindow"),this.overrideIframeContentAccess("contentDocument"),this.overrideFuncArgProxyToObj(this.$wbwindow.MutationObserver,"observe"),this.overrideFuncArgProxyToObj(this.$wbwindow.Node,"compareDocumentPosition"),this.overrideFuncArgProxyToObj(this.$wbwindow.Node,"contains"),this.overrideFuncArgProxyToObj(this.$wbwindow.Document,"createTreeWalker"),this.overrideFuncArgProxyToObj(this.$wbwindow.Document,"evaluate",1),this.overrideFuncArgProxyToObj(this.$wbwindow.XSLTProcessor,"transformToFragment",1),this.overrideFuncThisProxyToObj(this.$wbwindow,"getComputedStyle",this.$wbwindow),this.overrideFuncThisProxyToObj(this.$wbwindow,"clearTimeout"),this.overrideFuncThisProxyToObj(this.$wbwindow,"clearInterval"),this.overrideFuncThisProxyToObj(this.$wbwindow.EventTarget.prototype,"dispatchEvent"),this.initTimeoutIntervalOverrides(),this.overrideFramesAccess(this.$wbwindow),this.overrideSWAccess(this.$wbwindow),this.initElementGetSetAttributeOverride(),this.initSvgImageOverrides(),this.initAttrOverrides(),this.initCookiesOverride(),this.initCreateElementNSFix(),this.wb_opts.skip_dom||this.initDomOverride(),this.initRegisterUnRegPHOverride(),this.initPresentationRequestOverride(),this.initBeaconOverride(),this.initMiscNavigatorOverrides(),this.initSeededRandom(this.wb_info.wombat_sec),this.initCryptoRandom(),this.initFixedRatio(this.wb_info.pixel_ratio||1),this.initDateOverride(this.wb_info.wombat_sec),this.initBlobOverride(),this.initWSOverride(),this.initOpenOverride(),this.initDisableNotificationsGeoLocation(),this.initStorageOverride(),this.initCachesOverride(),this.initIndexedDBOverride(),this.initWindowObjProxy(this.$wbwindow),this.initDocumentObjProxy(this.$wbwindow.document);var t=this;return{extract_orig:this.extractOriginalURL,rewrite_url:this.rewriteUrl,watch_elem:this.watchElem,init_new_window_wombat:this.initNewWindowWombat,init_paths:this.initPaths,local_init:function(e){var r=t.$wbwindow._WB_wombat_obj_proxy[e];return"document"===e&&r&&!r._WB_wombat_obj_proxy&&t.initDocumentObjProxy(r)||r},showCSPViolations:function(e){t._addRemoveCSPViolationListener(e)}}};const b=f;window._WBWombat=b,window._WBWombatInit=function(t){if(this._wb_wombat)this._wb_wombat.init_paths(t);else{var e=new b(this,t);this._wb_wombat=e.wombatInit()}}})();'}),this.staticData.set(this.staticPrefix+"wombatWorkers.js",{type:"application/javascript",content:"/**\n * Mini wombat for performing URL rewriting within the\n * Web/Shared/Service Worker context\n * @param {Object} info\n * @return {WBWombat}\n */\nfunction WBWombat(info) {\n if (!(this instanceof WBWombat)) return new WBWombat(info);\n /** @type {Object} */\n this.info = info;\n this.initImportScriptsRewrite();\n this.initHTTPOverrides();\n this.initClientApisOverride();\n this.initCacheApisOverride();\n}\n\n/**\n * Returns T/F indicating if the supplied URL is not to be rewritten\n * @param {string} url\n * @return {boolean}\n */\nWBWombat.prototype.noRewrite = function(url) {\n return (\n !url ||\n url.indexOf('blob:') === 0 ||\n url.indexOf('javascript:') === 0 ||\n url.indexOf('data:') === 0 ||\n url.indexOf(this.info.prefix) === 0\n );\n};\n\n/**\n * Returns T/F indicating if the supplied URL is an relative URL\n * @param {string} url\n * @return {boolean}\n */\nWBWombat.prototype.isRelURL = function(url) {\n return url.indexOf('/') === 0 || url.indexOf('http:') !== 0;\n};\n\n/**\n * Attempts to resolve the supplied relative URL against\n * the origin this worker was created on\n * @param {string} maybeRelURL\n * @param {string} against\n * @return {string}\n */\nWBWombat.prototype.maybeResolveURL = function(maybeRelURL, against) {\n if (!against) return maybeRelURL;\n try {\n var resolved = new URL(maybeRelURL, against);\n return resolved.href;\n } catch (e) {}\n return maybeRelURL;\n};\n\n/**\n * Returns null to indicate that the supplied URL is not to be rewritten.\n * Otherwise returns a URL that can be rewritten\n * @param {*} url\n * @param {string} resolveAgainst\n * @return {?string}\n */\nWBWombat.prototype.ensureURL = function(url, resolveAgainst) {\n if (!url) return url;\n var newURL;\n switch (typeof url) {\n case 'string':\n newURL = url;\n break;\n case 'object':\n newURL = url.toString();\n break;\n default:\n return null;\n }\n if (this.noRewrite(newURL)) return null;\n if (this.isRelURL(newURL)) {\n return this.maybeResolveURL(newURL, resolveAgainst);\n }\n\n // if url starts with current origin, but not properly rewritten, rewrite against current baseUr\n if (newURL.indexOf(self.location.origin) === 0) {\n return this.maybeResolveURL(newURL.slice(self.location.origin.length), resolveAgainst);\n }\n return newURL;\n};\n\n/**\n * Rewrites the supplied URL\n * @param {string} url\n * @return {string}\n */\nWBWombat.prototype.rewriteURL = function(url) {\n var rwURL = this.ensureURL(url, this.info.originalURL);\n if (!rwURL) return url;\n if (this.info.prefixMod) {\n return this.info.prefixMod + rwURL;\n }\n return rwURL;\n};\n\n/**\n * Rewrites the supplied URL of an controlled page using the mp\\_ modifier\n * @param {string} url\n * @param {WindowClient} [client]\n * @return {string}\n */\nWBWombat.prototype.rewriteClientWindowURL = function(url, client) {\n var rwURL = this.ensureURL(url, client ? client.url : this.info.originalURL);\n if (!rwURL) return url;\n if (this.info.prefix) {\n return this.info.prefix + 'mp_/' + rwURL;\n }\n return rwURL;\n};\n\n/**\n * Mini url rewriter specifically for rewriting web sockets\n * @param {?string} originalURL\n * @return {string}\n */\nWBWombat.prototype.rewriteWSURL = function(originalURL) {\n // If undefined, just return it\n if (!originalURL) return originalURL;\n\n var urltype_ = typeof originalURL;\n var url = originalURL;\n\n // If object, use toString\n if (urltype_ === 'object') {\n url = originalURL.toString();\n } else if (urltype_ !== 'string') {\n return originalURL;\n }\n\n // empty string check\n if (!url) return url;\n\n var wsScheme = 'ws://';\n var wssScheme = 'wss://';\n var https = 'https://';\n\n var wbSecure = this.info.prefix.indexOf(https) === 0;\n var wbPrefix =\n this.info.prefix.replace(\n wbSecure ? https : 'http://',\n wbSecure ? wssScheme : wsScheme\n ) + 'ws_/';\n return wbPrefix + url;\n};\n\n/**\n * Rewrites all URLs in the supplied arguments object\n * @param {Object} argsObj\n * @return {Array<string>}\n */\nWBWombat.prototype.rewriteArgs = function(argsObj) {\n // recreate the original arguments object just with URLs rewritten\n var newArgObj = new Array(argsObj.length);\n for (var i = 0; i < newArgObj.length; i++) {\n newArgObj[i] = this.rewriteURL(argsObj[i]);\n }\n return newArgObj;\n};\n\n/**\n * Rewrites the input to one of the Fetch APIs\n * @param {*|string|Request} input\n * @return {*|string|Request}\n */\nWBWombat.prototype.rewriteFetchApi = function(input) {\n var rwInput = input;\n switch (typeof input) {\n case 'string':\n rwInput = this.rewriteURL(input);\n break;\n case 'object':\n if (input.url) {\n var new_url = this.rewriteURL(input.url);\n if (new_url !== input.url) {\n // not much we can do here Request.url is read only\n // https://developer.mozilla.org/en-US/docs/Web/API/Request/url\n rwInput = new Request(new_url, input);\n }\n } else if (input.href) {\n // it is likely that input is either self.location or self.URL\n // we cant do anything here so just let it go\n rwInput = input.href;\n }\n break;\n }\n return rwInput;\n};\n\n/**\n * Rewrites the input to one of the Cache APIs\n * @param {*|string|Request} request\n * @return {*|string|Request}\n */\nWBWombat.prototype.rewriteCacheApi = function(request) {\n var rwRequest = request;\n if (typeof request === 'string') {\n rwRequest = this.rewriteURL(request);\n }\n return rwRequest;\n};\n\n/**\n * Applies an override to the importScripts function\n * @see https://html.spec.whatwg.org/multipage/workers.html#dom-workerglobalscope-importscripts\n */\nWBWombat.prototype.initImportScriptsRewrite = function() {\n if (!self.importScripts) return;\n var wombat = this;\n var origImportScripts = self.importScripts;\n self.importScripts = function importScripts() {\n // rewrite the arguments object and call original function via fn.apply\n var rwArgs = wombat.rewriteArgs(arguments);\n return origImportScripts.apply(this, rwArgs);\n };\n};\n\n/**\n * Applies overrides to the XMLHttpRequest.open and XMLHttpRequest.responseURL\n * in order to ensure URLs are rewritten.\n *\n * Applies an override to window.fetch in order to rewrite URLs and URLs of\n * the supplied Request objects used as arguments to fetch.\n *\n * Applies overrides to window.Request, window.Response, window.EventSource,\n * and window.WebSocket in order to ensure URLs they operate on are rewritten.\n *\n * @see https://xhr.spec.whatwg.org/\n * @see https://fetch.spec.whatwg.org/\n * @see https://html.spec.whatwg.org/multipage/web-sockets.html#websocket\n * @see https://html.spec.whatwg.org/multipage/server-sent-events.html#the-eventsource-interface\n */\nWBWombat.prototype.initHTTPOverrides = function() {\n var wombat = this;\n if (\n self.XMLHttpRequest &&\n self.XMLHttpRequest.prototype &&\n self.XMLHttpRequest.prototype.open\n ) {\n var oXHROpen = self.XMLHttpRequest.prototype.open;\n self.XMLHttpRequest.prototype.open = function open(\n method,\n url,\n async,\n user,\n password\n ) {\n var rwURL = wombat.rewriteURL(url);\n var openAsync = true;\n if (async != null && !async) openAsync = false;\n oXHROpen.call(this, method, rwURL, openAsync, user, password);\n if (rwURL.indexOf('data:') === -1) {\n this.setRequestHeader('X-Pywb-Requested-With', 'XMLHttpRequest');\n }\n };\n }\n\n if (self.fetch != null) {\n // this fetch is Worker.fetch\n var orig_fetch = self.fetch;\n self.fetch = function fetch(input, init_opts) {\n var rwInput = wombat.rewriteFetchApi(input);\n var newInitOpts = init_opts || {};\n newInitOpts['credentials'] = 'include';\n return orig_fetch.call(this, rwInput, newInitOpts);\n };\n }\n\n if (self.Request && self.Request.prototype) {\n var orig_request = self.Request;\n self.Request = (function(Request_) {\n return function Request(input, init_opts) {\n var newInitOpts = init_opts || {};\n var newInput = wombat.rewriteFetchApi(input);\n newInitOpts['credentials'] = 'include';\n return new Request_(newInput, newInitOpts);\n };\n })(self.Request);\n self.Request.prototype = orig_request.prototype;\n }\n\n if (self.Response && self.Response.prototype) {\n var originalRedirect = self.Response.prototype.redirect;\n self.Response.prototype.redirect = function redirect(url, status) {\n var rwURL = wombat.rewriteUrl(url);\n return originalRedirect.call(this, rwURL, status);\n };\n }\n\n if (self.EventSource && self.EventSource.prototype) {\n var origEventSource = self.EventSource;\n self.EventSource = (function(EventSource_) {\n return function EventSource(url, configuration) {\n var rwURL = url;\n if (url != null) {\n rwURL = wombat.rewriteUrl(url);\n }\n return new EventSource_(rwURL, configuration);\n };\n })(self.EventSource);\n self.EventSource.prototype = origEventSource.prototype;\n Object.defineProperty(self.EventSource.prototype, 'constructor', {\n value: self.EventSource\n });\n }\n\n if (self.WebSocket && self.WebSocket.prototype) {\n var origWebSocket = self.WebSocket;\n self.WebSocket = (function(WebSocket_) {\n return function WebSocket(url, configuration) {\n var rwURL = url;\n if (url != null) {\n rwURL = wombat.rewriteWSURL(url);\n }\n return new WebSocket_(rwURL, configuration);\n };\n })(self.WebSocket);\n self.WebSocket.prototype = origWebSocket.prototype;\n Object.defineProperty(self.WebSocket.prototype, 'constructor', {\n value: self.WebSocket\n });\n }\n};\n\n/**\n * Applies an override to Clients.openWindow and WindowClient.navigate that rewrites\n * the supplied URL that represents a controlled window\n * @see https://w3c.github.io/ServiceWorker/#window-client-interface\n * @see https://w3c.github.io/ServiceWorker/#clients-interface\n */\nWBWombat.prototype.initClientApisOverride = function() {\n var wombat = this;\n if (\n self.Clients &&\n self.Clients.prototype &&\n self.Clients.prototype.openWindow\n ) {\n var oClientsOpenWindow = self.Clients.prototype.openWindow;\n self.Clients.prototype.openWindow = function openWindow(url) {\n var rwURL = wombat.rewriteClientWindowURL(url);\n return oClientsOpenWindow.call(this, rwURL);\n };\n }\n\n if (\n self.WindowClient &&\n self.WindowClient.prototype &&\n self.WindowClient.prototype.navigate\n ) {\n var oWinClientNavigate = self.WindowClient.prototype.navigate;\n self.WindowClient.prototype.navigate = function navigate(url) {\n var rwURL = wombat.rewriteClientWindowURL(url, this);\n return oWinClientNavigate.call(this, rwURL);\n };\n }\n};\n\n/**\n * Applies overrides to the CacheStorage and Cache interfaces in order\n * to rewrite the URLs they operate on\n * @see https://w3c.github.io/ServiceWorker/#cachestorage\n * @see https://w3c.github.io/ServiceWorker/#cache-interface\n */\nWBWombat.prototype.initCacheApisOverride = function() {\n var wombat = this;\n if (\n self.CacheStorage &&\n self.CacheStorage.prototype &&\n self.CacheStorage.prototype.match\n ) {\n var oCacheStorageMatch = self.CacheStorage.prototype.match;\n self.CacheStorage.prototype.match = function match(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheStorageMatch.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache && self.Cache.prototype) {\n if (self.Cache.prototype.match) {\n var oCacheMatch = self.Cache.prototype.match;\n self.Cache.prototype.match = function match(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheMatch.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.matchAll) {\n var oCacheMatchAll = self.Cache.prototype.matchAll;\n self.Cache.prototype.matchAll = function matchAll(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheMatchAll.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.add) {\n var oCacheAdd = self.Cache.prototype.add;\n self.Cache.prototype.add = function add(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheAdd.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.addAll) {\n var oCacheAddAll = self.Cache.prototype.addAll;\n self.Cache.prototype.addAll = function addAll(requests) {\n var rwRequests = requests;\n if (Array.isArray(requests)) {\n rwRequests = new Array(requests.length);\n for (var i = 0; i < requests.length; i++) {\n rwRequests[i] = wombat.rewriteCacheApi(requests[i]);\n }\n }\n return oCacheAddAll.call(this, rwRequests);\n };\n }\n\n if (self.Cache.prototype.put) {\n var oCachePut = self.Cache.prototype.put;\n self.Cache.prototype.put = function put(request, response) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCachePut.call(this, rwRequest, response);\n };\n }\n\n if (self.Cache.prototype.delete) {\n var oCacheDelete = self.Cache.prototype.delete;\n self.Cache.prototype.delete = function newCacheDelete(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheDelete.call(this, rwRequest, options);\n };\n }\n\n if (self.Cache.prototype.keys) {\n var oCacheKeys = self.Cache.prototype.keys;\n self.Cache.prototype.keys = function keys(request, options) {\n var rwRequest = wombat.rewriteCacheApi(request);\n return oCacheKeys.call(this, rwRequest, options);\n };\n }\n }\n};\n\nself.WBWombat = WBWombat;\n"}),r.injectScripts&&(r.injectScripts=r.injectScripts.map((t=>this.staticPrefix+"proxy/"+t))),this.collections=new i(o,n.get("root"),r),this.collections.loadAll(n.get("dbColl")),this.proxyOriginMode=!!n.get("proxyOriginMode"),this.api=new e(this.collections),this.apiPrefix=this.replayPrefix+"api/",this.allowRewrittenCache=!!n.get("allowCache"),this.stats=n.get("stats")?new Yy:null,self.addEventListener("install",(()=>{self.skipWaiting()})),self.addEventListener("activate",(t=>{t.waitUntil(self.clients.claim()),console.log("Activate!")})),self.addEventListener("fetch",(t=>{t.respondWith(this.handleFetch(t))})),self.addEventListener("message",(t=>{"reload_all"===t.data.msg_type&&t.waitUntil(this.collections.loadAll())}))}handleFetch(t){const e=t.request.url;if(this.proxyOriginMode)return this.getResponseFor(t.request,t);if(!e.startsWith(this.prefix))return"chrome-extension://invalid/"===e?S(t.request,"Invalid URL"):this.defaultFetch(t.request);if(this.collections.root&&e.slice(this.prefix.length).indexOf("/")<0)return this.defaultFetch(t.request);if(e.startsWith(this.staticPrefix+"proxy/"))return this.staticPathProxy(e,t.request);if(e.startsWith(this.replayPrefix)&&!e.startsWith(this.staticPrefix))return this.getResponseFor(t.request,t);const r=new URL(e);r.search="",r.hash="";const i=r.href;for(const t of this.staticData.keys())if(t===i){const{content:e,type:r}=this.staticData.get(t);return new Response(e,{headers:{"Content-Type":r}})}return("http:"==r.protocol||"https:"==r.protocol)&&r.pathname.indexOf("/",1)<0?this.handleOffline(t.request):this.defaultFetch(t.request)}staticPathProxy(t,e){return t=t.slice((this.staticPrefix+"proxy/").length),t=new URL(t,self.location.href).href,e=new Request(t),this.defaultFetch(e)}defaultFetch(t){const e={};return"only-if-cached"===t.cache&&"same-origin"!==t.mode&&(e.cache="default"),self.fetch(t,e)}async ensureCached(t){const e=await caches.open("wabac-offline");for(let r of t){r=new URL(r,self.location.href).href;let t=await e.match(r,{ignoreSearch:!0});if(!t)try{t=await this.defaultFetch(r),await e.put(r,t)}catch(t){console.warn(`Failed to Auto Cache: ${r}`,t)}}}async handleOffline(t){let e=null;const r=await caches.open("wabac-offline");try{e=await this.defaultFetch(t)}catch(i){return e=await r.match(t,{ignoreSearch:!0}),e||(e=S(t,"Sorry, this url was not cached for offline use")),e}if(t.url.startsWith(this.prefix+"?"))return e;if(200===e.status){const i=e.clone();await r.put(t,i)}else console.warn(`Not Cacheing ${t.url} - Status ${e.status}`);return e}async getResponseFor(t,e){if(!this.proxyOriginMode&&t.url.startsWith(this.apiPrefix))return this.stats&&t.url.startsWith(this.apiPrefix+"stats.json")?await this.stats.getStats(e):await this.api.apiResponse(t.url.slice(this.apiPrefix.length),t,e);await this.collections.inited;const r=v(t),i=t.headers.get("range");try{if(this.allowRewrittenCache&&!i){const e=await self.caches.match(t);if(e&&!!e.headers.get(bm)===r)return e}}catch(t){}let n=this.collections.root;n||(n=t.url.slice(this.replayPrefix.length).split("/",1)[0]);const s=await this.collections.getColl(n);if(!s||!this.proxyOriginMode&&!t.url.startsWith(s.prefix))return S(t);const o=this.proxyOriginMode?t.url:t.url.substring(s.prefix.length),a={isRoot:!!this.collections.root};this.proxyOriginMode&&(a.mod="id_",a.proxyOrigin=s.config.extraConfig.proxyOrigin,a.localOrigin=self.location.origin);const c=new mm(o,t,a);if(!c.url)return S(t,`Replay URL ${o} not found`);const l=await s.handleRequest(c,e);if(l){if(this.stats&&this.stats.updateStats(l.date,l.status,t,e),this.allowRewrittenCache&&200===l.status)try{const e=await self.caches.open("wabac-"+s.name);r&&l.headers.set(bm,"true");const i=l.clone();await e.put(t,i)}catch(t){console.warn(t)}return l}return i&&console.log("Not Found Range!: "+i),S(t)}}if(self.registration){const t=new Map,r=self.registration.scope;t.set(r,{type:"text/html",content:e}),t.set(r+"index.html",{type:"text/html",content:e});const i={};"1"==new URLSearchParams(self.location.search).get("ruffle")&&(i.injectScripts=["ruffle/ruffle.js"]),self.sw=new Em({staticData:t,defaultConfig:i})}else new Ky(self)})();var n=self;for(var s in i)n[s]=i[s];i.__esModule&&Object.defineProperty(n,"__esModule",{value:!0})})();
package/ui.js CHANGED
@@ -48,7 +48,7 @@ class oe extends re{constructor(e){if(super(e),this.it=R,e.type!==ie)throw Error
48
48
  * Copyright 2017 Google LLC
49
49
  * SPDX-License-Identifier: BSD-3-Clause
50
50
  */
51
- class se extends oe{}se.directiveName="unsafeSVG",se.resultType=2;const le=ae(se),ce=ae(class extends re{constructor(e){var t;if(super(e),e.type!==te||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const a=e[i];return null==a?t:t+`${i=i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${a};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ct){this.ct=new Set;for(const e in t)this.ct.add(e);return this.render(t)}this.ct.forEach((e=>{null==t[e]&&(this.ct.delete(e),e.includes("-")?i.removeProperty(e):i[e]="")}));for(const e in t){const a=t[e];null!=a&&(this.ct.add(e),e.includes("-")?i.setProperty(e,a):i[e]=a)}return U}});var de=__webpack_require__(6274),he=__webpack_require__(3029),fe=__webpack_require__.n(he);const be=r(de.Z);function ue(e){return[be,e]}const pe=window.IS_APP||window.electron&&window.electron.IS_APP||window.matchMedia("(display-mode: standalone)").matches,me="1.8.1";function ge(e){" "==e.key&&(e.preventDefault(),e.target.click())}class ve extends X{constructor(){super(),this.size="1.1em",this.width=null,this.height=null}static get properties(){return{svg:{type:String},size:{type:String},width:{type:String},height:{type:String}}}static get styles(){return o`
51
+ class se extends oe{}se.directiveName="unsafeSVG",se.resultType=2;const le=ae(se),ce=ae(class extends re{constructor(e){var t;if(super(e),e.type!==te||"style"!==e.name||(null===(t=e.strings)||void 0===t?void 0:t.length)>2)throw Error("The `styleMap` directive must be used in the `style` attribute and must be the only part in the attribute.")}render(e){return Object.keys(e).reduce(((t,i)=>{const a=e[i];return null==a?t:t+`${i=i.replace(/(?:^(webkit|moz|ms|o)|)(?=[A-Z])/g,"-$&").toLowerCase()}:${a};`}),"")}update(e,[t]){const{style:i}=e.element;if(void 0===this.ct){this.ct=new Set;for(const e in t)this.ct.add(e);return this.render(t)}this.ct.forEach((e=>{null==t[e]&&(this.ct.delete(e),e.includes("-")?i.removeProperty(e):i[e]="")}));for(const e in t){const a=t[e];null!=a&&(this.ct.add(e),e.includes("-")?i.setProperty(e,a):i[e]=a)}return U}});var de=__webpack_require__(6274),he=__webpack_require__(3029),fe=__webpack_require__.n(he);const be=r(de.Z);function ue(e){return[be,e]}const pe=window.IS_APP||window.electron&&window.electron.IS_APP||window.matchMedia("(display-mode: standalone)").matches,me="1.8.2";function ge(e){" "==e.key&&(e.preventDefault(),e.target.click())}class ve extends X{constructor(){super(),this.size="1.1em",this.width=null,this.height=null}static get properties(){return{svg:{type:String},size:{type:String},width:{type:String},height:{type:String}}}static get styles(){return o`
52
52
  :host {
53
53
  display: inline-block;
54
54
  padding: 0;
@@ -929,7 +929,7 @@ class se extends oe{}se.directiveName="unsafeSVG",se.resultType=2;const le=ae(se
929
929
  </div>
930
930
  </div>
931
931
  </div>
932
- `}onEmbedDrop(e){e.stopPropagation(),this.active=!this.active}}customElements.define("rwp-embed-receipt",Pt);var Lt="undefined"!=typeof window?window:null,Tt=null===Lt,Ut=Tt?void 0:Lt.document,Rt="horizontal",qt=function(){return!1},Mt=Tt?"calc":["","-webkit-","-moz-","-o-"].filter((function(e){var t=Ut.createElement("div");return t.style.cssText="width:"+e+"calc(9px)",!!t.style.length})).shift()+"calc",Ft=function(e){return"string"==typeof e||e instanceof String},jt=function(e){if(Ft(e)){var t=Ut.querySelector(e);if(!t)throw new Error("Selector "+e+" did not match a DOM element");return t}return e},Bt=function(e,t,i){var a=e[t];return void 0!==a?a:i},Nt=function(e,t,i,a){if(t){if("end"===a)return 0;if("center"===a)return e/2}else if(i){if("start"===a)return 0;if("center"===a)return e/2}return e},Ot=function(e,t){var i=Ut.createElement("div");return i.className="gutter gutter-"+t,i},Ht=function(e,t,i){var a={};return Ft(t)?a[e]=t:a[e]=Mt+"("+t+"% - "+i+"px)",a},Wt=function(e,t){var i;return(i={})[e]=t+"px",i};const Gt=function(e,t){if(void 0===t&&(t={}),Tt)return{};var i,a,r,o,n,s,l=e;Array.from&&(l=Array.from(l));var c=jt(l[0]).parentNode,d=getComputedStyle?getComputedStyle(c):null,h=d?d.flexDirection:null,f=Bt(t,"sizes")||l.map((function(){return 100/l.length})),b=Bt(t,"minSize",100),u=Array.isArray(b)?b:l.map((function(){return b})),p=Bt(t,"maxSize",1/0),m=Array.isArray(p)?p:l.map((function(){return p})),g=Bt(t,"expandToMin",!1),v=Bt(t,"gutterSize",10),w=Bt(t,"gutterAlign","center"),x=Bt(t,"snapOffset",30),k=Bt(t,"dragInterval",1),y=Bt(t,"direction",Rt),_=Bt(t,"cursor",y===Rt?"col-resize":"row-resize"),$=Bt(t,"gutter",Ot),S=Bt(t,"elementStyle",Ht),z=Bt(t,"gutterStyle",Wt);function A(e,t,a,r){var o=S(i,t,a,r);Object.keys(o).forEach((function(t){e.style[t]=o[t]}))}function C(){return s.map((function(e){return e.size}))}function D(e){return"touches"in e?e.touches[0][a]:e[a]}function E(e){var t=s[this.a],i=s[this.b],a=t.size+i.size;t.size=e/this.size*a,i.size=a-e/this.size*a,A(t.element,t.size,this._b,t.i),A(i.element,i.size,this._c,i.i)}function I(e){var i,a=s[this.a],r=s[this.b];this.dragging&&(i=D(e)-this.start+(this._b-this.dragOffset),k>1&&(i=Math.round(i/k)*k),i<=a.minSize+x+this._b?i=a.minSize+this._b:i>=this.size-(r.minSize+x+this._c)&&(i=this.size-(r.minSize+this._c)),i>=a.maxSize-x+this._b?i=a.maxSize+this._b:i<=this.size-(r.maxSize-x+this._c)&&(i=this.size-(r.maxSize+this._c)),E.call(this,i),Bt(t,"onDrag",qt)(C()))}function P(){var e=s[this.a].element,t=s[this.b].element,a=e.getBoundingClientRect(),n=t.getBoundingClientRect();this.size=a[i]+n[i]+this._b+this._c,this.start=a[r],this.end=a[o]}function L(e){var t=function(e){if(!getComputedStyle)return null;var t=getComputedStyle(e);if(!t)return null;var i=e[n];return 0===i?null:i-=y===Rt?parseFloat(t.paddingLeft)+parseFloat(t.paddingRight):parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)}(c);if(null===t)return e;if(u.reduce((function(e,t){return e+t}),0)>t)return e;var i=0,a=[],r=e.map((function(r,o){var n=t*r/100,s=Nt(v,0===o,o===e.length-1,w),l=u[o]+s;return n<l?(i+=l-n,a.push(0),l):(a.push(n-l),n)}));return 0===i?e:r.map((function(e,r){var o=e;if(i>0&&a[r]-i>0){var n=Math.min(i,a[r]-i);i-=n,o=e-n}return o/t*100}))}function T(){var e=this,i=s[e.a].element,a=s[e.b].element;e.dragging&&Bt(t,"onDragEnd",qt)(C()),e.dragging=!1,Lt.removeEventListener("mouseup",e.stop),Lt.removeEventListener("touchend",e.stop),Lt.removeEventListener("touchcancel",e.stop),Lt.removeEventListener("mousemove",e.move),Lt.removeEventListener("touchmove",e.move),e.stop=null,e.move=null,i.removeEventListener("selectstart",qt),i.removeEventListener("dragstart",qt),a.removeEventListener("selectstart",qt),a.removeEventListener("dragstart",qt),i.style.userSelect="",i.style.webkitUserSelect="",i.style.MozUserSelect="",i.style.pointerEvents="",a.style.userSelect="",a.style.webkitUserSelect="",a.style.MozUserSelect="",a.style.pointerEvents="",e.gutter.style.cursor="",e.parent.style.cursor="",Ut.body.style.cursor=""}function U(e){if(!("button"in e)||0===e.button){var i=this,a=s[i.a].element,r=s[i.b].element;i.dragging||Bt(t,"onDragStart",qt)(C()),e.preventDefault(),i.dragging=!0,i.move=I.bind(i),i.stop=T.bind(i),Lt.addEventListener("mouseup",i.stop),Lt.addEventListener("touchend",i.stop),Lt.addEventListener("touchcancel",i.stop),Lt.addEventListener("mousemove",i.move),Lt.addEventListener("touchmove",i.move),a.addEventListener("selectstart",qt),a.addEventListener("dragstart",qt),r.addEventListener("selectstart",qt),r.addEventListener("dragstart",qt),a.style.userSelect="none",a.style.webkitUserSelect="none",a.style.MozUserSelect="none",a.style.pointerEvents="none",r.style.userSelect="none",r.style.webkitUserSelect="none",r.style.MozUserSelect="none",r.style.pointerEvents="none",i.gutter.style.cursor=_,i.parent.style.cursor=_,Ut.body.style.cursor=_,P.call(i),i.dragOffset=D(e)-i.end}}y===Rt?(i="width",a="clientX",r="left",o="right",n="clientWidth"):"vertical"===y&&(i="height",a="clientY",r="top",o="bottom",n="clientHeight"),f=L(f);var R=[];function q(e){var t=e.i===R.length,i=t?R[e.i-1]:R[e.i];P.call(i);var a=t?i.size-e.minSize-i._c:e.minSize+i._b;E.call(i,a)}return s=l.map((function(e,t){var a,r={element:jt(e),size:f[t],minSize:u[t],maxSize:m[t],i:t};if(t>0&&((a={a:t-1,b:t,dragging:!1,direction:y,parent:c})._b=Nt(v,t-1==0,!1,w),a._c=Nt(v,!1,t===l.length-1,w),"row-reverse"===h||"column-reverse"===h)){var o=a.a;a.a=a.b,a.b=o}if(t>0){var n=$(t,y,r.element);!function(e,t,a){var r=z(i,t,a);Object.keys(r).forEach((function(t){e.style[t]=r[t]}))}(n,v,t),a._a=U.bind(a),n.addEventListener("mousedown",a._a),n.addEventListener("touchstart",a._a),c.insertBefore(n,r.element),a.gutter=n}return A(r.element,r.size,Nt(v,0===t,t===l.length-1,w),t),t>0&&R.push(a),r})),s.forEach((function(e){var t=e.element.getBoundingClientRect()[i];t<e.minSize&&(g?q(e):e.minSize=t)})),{setSizes:function(e){var t=L(e);t.forEach((function(e,i){if(i>0){var a=R[i-1],r=s[a.a],o=s[a.b];r.size=t[i-1],o.size=e,A(r.element,r.size,a._b,r.i),A(o.element,o.size,a._c,o.i)}}))},getSizes:C,collapse:function(e){q(s[e])},destroy:function(e,t){R.forEach((function(a){if(!0!==t?a.parent.removeChild(a.gutter):(a.gutter.removeEventListener("mousedown",a._a),a.gutter.removeEventListener("touchstart",a._a)),!0!==e){var r=S(i,a.a.size,a._b);Object.keys(r).forEach((function(e){s[a.a].element.style[e]="",s[a.b].element.style[e]=""}))}}))},parent:c,pairs:R}},Kt="search://";class Vt extends X{constructor(){super(),this.sourceUrl=null,this.inited=!1,this.isLoading=!1,this.coll="",this.collInfo=null,this._replaceLoc=!1,this._locUpdateNeeded=!1,this._locationHash="",this.tabData={},this.url="",this.ts="",this.tabNames=["pages","story","resources","info"],this.tabLabels={pages:"Pages",story:"Story",resources:"URLs",info:"Archive Info"},this.menuActive=!1,this.embedDropdownActive=!1,this.hasStory=!1,this.editable=!1,this.browsable=!0,this.clearable=!0,this.showSidebar="1"===localStorage.getItem("pages:showSidebar"),this.splitter=null,this.isVisible=!0,this.favIconUrl="",this.autoUpdateInterval=10,this._autoUpdater=null,this.appName="ReplayWeb.page",this.appVersion=me,this.appLogo=fe()}static get properties(){return{inited:{type:Boolean},sourceUrl:{type:String},loadInfo:{type:Object,attribute:!1},showSidebar:{type:Boolean},collInfo:{type:Object,attribute:!1},coll:{type:String},hasStory:{type:Boolean},isLoading:{type:Boolean},tabData:{type:Object,attribute:!1},url:{type:String},ts:{type:String},isFullscreen:{type:Boolean},menuActive:{type:Boolean},embed:{type:String},embedDropdownActive:{type:Boolean},editable:{type:Boolean},browsable:{type:Boolean},clearable:{type:Boolean},isVisible:{type:Boolean},favIconUrl:{type:String},appName:{type:String},appVersion:{type:String},appLogo:{type:String},autoUpdateInterval:{type:Number},swName:{type:String}}}firstUpdated(){this.inited=!0,window.addEventListener("hashchange",(e=>this.onHashChange(e))),this.addEventListener("fullscreenchange",(()=>{this.isFullscreen=!!document.fullscreenElement})),this.embed&&this.loadInfo&&this.loadInfo.hideOffscreen&&(this.observer=new IntersectionObserver((e=>{this.isVisible=e[0].isIntersecting})),this.observer.observe(this))}async runUpdateLoop(){try{for(;this.editable&&this.autoUpdateInterval&&(!this.collInfo||this.collInfo.pages.length<100);)await new Promise((e=>setTimeout(e,1e3*this.autoUpdateInterval))),await this.doUpdateInfo(!0)}finally{this._autoUpdater=null}}updated(e){if(e.has("sourceUrl")&&this.doUpdateInfo(),e.has("editable")&&this.editable&&this.autoUpdateInterval&&!this._autoUpdater&&(this._autoUpdater=this.runUpdateLoop()),e.has("tabData")){if(!this.collInfo||!this.collInfo.coll)return;Object.keys(this.tabData).forEach((e=>!this.tabData[e]&&delete this.tabData[e]));const t="#"+new URLSearchParams(this.tabData).toString();if(this.tabData.url||(this.url=Kt+decodeURIComponent(this._paramsToString(this.tabData))),t!==this._locationHash){if(this._locationHash=t,this._replaceLoc||0===Object.keys(e.get("tabData")).length){const e=new URL(window.location.href);e.hash=this._locationHash,window.history.replaceState({},"",e.href),this._replaceLoc=!1}else if(window.location.hash=this._locationHash,!this.showSidebar){const e=this.renderRoot.querySelector("wr-coll-replay");e&&e.focus()}this.embed&&window.parent!==window&&window.parent.postMessage(this.tabData,"*")}this._locUpdateNeeded=!1}e.has("showSidebar")&&(this.embed||localStorage.setItem("pages:showSidebar",this.showSidebar?"1":"0")),(e.has("tabData")||e.has("showSidebar"))&&this.configureSplitter()}configureSplitter(){if(this.tabData.url&&this.showSidebar){const e=this.renderRoot.querySelector("#contents"),t=this.renderRoot.querySelector("wr-coll-replay");if(e&&t&&!this.splitter){const i={sizes:[30,70],minSize:[300,300],gutterSize:4,onDragStart(){t.setDisablePointer(!0)},onDragEnd(){t.setDisablePointer(!1)}};this.splitter=Gt([e,t],i)}}else if(this.splitter){try{this.splitter.destroy()}catch(e){}this.splitter=null}}async doUpdateInfo(e=!1){if(e&&this.tabData.url&&!this.showSidebar)return;let t=this.loadInfo&&this.loadInfo.customColl;if(!t){t=(await Je(this.sourceUrl)).coll}this.coll=t;const i="./w/api/c/"+t,a="./w/"+t,r=await fetch(i+"?all=1");if(200!=r.status)return void(this.collInfo={});const o=await r.json();if(this.collInfo={apiPrefix:i,replayPrefix:a,coll:t,...o},this.loadInfo&&this.loadInfo.extraConfig&&this.loadInfo.extraConfig.headers){const e=this.loadInfo.extraConfig.headers;await fetch(`${i}/updateAuth`,{method:"POST",body:JSON.stringify({headers:e})})}this.collInfo.title||(this.collInfo.title=this.collInfo.filename),"replayonly"!==this.embed&&"replay-with-info"!==this.embed||(this.showSidebar=!1),this.hasStory=this.collInfo.desc||this.collInfo.lists.length,this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{collInfo:this.collInfo,alreadyLoaded:!0}})),this.onHashChange()}onCollLoaded(e){this.doUpdateInfo(),this.loadInfo=null,e.detail.sourceUrl&&(this.sourceUrl=e.detail.sourceUrl),this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{sourceUrl:this.sourceUrl,collInfo:this.collInfo}}))}onCollUpdate(e){this.editable&&(this.collInfo={...this.collInfo,...e.detail})}onHashChange(){const e=window.location.hash;if(e&&e!==this._locationHash&&(this.tabData=Object.fromEntries(new URLSearchParams(e.slice(1)).entries()),this._locationHash=e),this.collInfo.coll&&!this.tabNames.includes(this.tabData.view)){const e=this.hasStory?"story":this.editable||this.collInfo.pages.length?"pages":"resources";this.tabData={...this.tabData,view:e}}if(this.tabData.url&&this.tabData.url.startsWith("page:")){const e=Number(this.tabData.url.slice("page:".length));if(!isNaN(e)&&e<this.collInfo.pages.length){const t=this.collInfo.pages[e];this.tabData.url=t.url,this.tabData.ts=Ve(t).timestamp}}this.hasStory||"story"!==this.tabData.view||(this.tabData.view="pages"),this.tabData.url&&this.tabData.query&&(this.showSidebar=!0)}onTabClick(e){e.preventDefault();const t=e.currentTarget.getAttribute("href");return this.tabData={...this.tabData,view:t.slice(1)},!1}onCollTabNav(e){e.detail.reload?this.onRefresh(null,!0):e.target.id===this.tabData.view||"replay"===e.target.id&&this.tabData.url?this.updateTabData(e.detail.data,e.detail.replaceLoc,!1):this.showSidebar&&this.tabData.url&&this.updateTabData(e.detail.data,e.detail.replaceLoc,!0)}updateTabData(e,t=!1){this.tabData={...this.tabData,...e},this.tabData.url&&(this.url=this.tabData.url||""),this.tabData.ts&&(this.ts=this.tabData.ts||""),this._replaceLoc=!this._locUpdateNeeded&&t,this._locUpdateNeeded=!0}static get styles(){return ue(Vt.compStyles)}static get compStyles(){return o`
932
+ `}onEmbedDrop(e){e.stopPropagation(),this.active=!this.active}}customElements.define("rwp-embed-receipt",Pt);var Lt="undefined"!=typeof window?window:null,Tt=null===Lt,Ut=Tt?void 0:Lt.document,Rt="horizontal",qt=function(){return!1},Mt=Tt?"calc":["","-webkit-","-moz-","-o-"].filter((function(e){var t=Ut.createElement("div");return t.style.cssText="width:"+e+"calc(9px)",!!t.style.length})).shift()+"calc",Ft=function(e){return"string"==typeof e||e instanceof String},jt=function(e){if(Ft(e)){var t=Ut.querySelector(e);if(!t)throw new Error("Selector "+e+" did not match a DOM element");return t}return e},Bt=function(e,t,i){var a=e[t];return void 0!==a?a:i},Nt=function(e,t,i,a){if(t){if("end"===a)return 0;if("center"===a)return e/2}else if(i){if("start"===a)return 0;if("center"===a)return e/2}return e},Ot=function(e,t){var i=Ut.createElement("div");return i.className="gutter gutter-"+t,i},Ht=function(e,t,i){var a={};return Ft(t)?a[e]=t:a[e]=Mt+"("+t+"% - "+i+"px)",a},Wt=function(e,t){var i;return(i={})[e]=t+"px",i};const Gt=function(e,t){if(void 0===t&&(t={}),Tt)return{};var i,a,r,o,n,s,l=e;Array.from&&(l=Array.from(l));var c=jt(l[0]).parentNode,d=getComputedStyle?getComputedStyle(c):null,h=d?d.flexDirection:null,f=Bt(t,"sizes")||l.map((function(){return 100/l.length})),b=Bt(t,"minSize",100),u=Array.isArray(b)?b:l.map((function(){return b})),p=Bt(t,"maxSize",1/0),m=Array.isArray(p)?p:l.map((function(){return p})),g=Bt(t,"expandToMin",!1),v=Bt(t,"gutterSize",10),w=Bt(t,"gutterAlign","center"),x=Bt(t,"snapOffset",30),k=Bt(t,"dragInterval",1),y=Bt(t,"direction",Rt),_=Bt(t,"cursor",y===Rt?"col-resize":"row-resize"),$=Bt(t,"gutter",Ot),S=Bt(t,"elementStyle",Ht),z=Bt(t,"gutterStyle",Wt);function A(e,t,a,r){var o=S(i,t,a,r);Object.keys(o).forEach((function(t){e.style[t]=o[t]}))}function C(){return s.map((function(e){return e.size}))}function D(e){return"touches"in e?e.touches[0][a]:e[a]}function E(e){var t=s[this.a],i=s[this.b],a=t.size+i.size;t.size=e/this.size*a,i.size=a-e/this.size*a,A(t.element,t.size,this._b,t.i),A(i.element,i.size,this._c,i.i)}function I(e){var i,a=s[this.a],r=s[this.b];this.dragging&&(i=D(e)-this.start+(this._b-this.dragOffset),k>1&&(i=Math.round(i/k)*k),i<=a.minSize+x+this._b?i=a.minSize+this._b:i>=this.size-(r.minSize+x+this._c)&&(i=this.size-(r.minSize+this._c)),i>=a.maxSize-x+this._b?i=a.maxSize+this._b:i<=this.size-(r.maxSize-x+this._c)&&(i=this.size-(r.maxSize+this._c)),E.call(this,i),Bt(t,"onDrag",qt)(C()))}function P(){var e=s[this.a].element,t=s[this.b].element,a=e.getBoundingClientRect(),n=t.getBoundingClientRect();this.size=a[i]+n[i]+this._b+this._c,this.start=a[r],this.end=a[o]}function L(e){var t=function(e){if(!getComputedStyle)return null;var t=getComputedStyle(e);if(!t)return null;var i=e[n];return 0===i?null:i-=y===Rt?parseFloat(t.paddingLeft)+parseFloat(t.paddingRight):parseFloat(t.paddingTop)+parseFloat(t.paddingBottom)}(c);if(null===t)return e;if(u.reduce((function(e,t){return e+t}),0)>t)return e;var i=0,a=[],r=e.map((function(r,o){var n=t*r/100,s=Nt(v,0===o,o===e.length-1,w),l=u[o]+s;return n<l?(i+=l-n,a.push(0),l):(a.push(n-l),n)}));return 0===i?e:r.map((function(e,r){var o=e;if(i>0&&a[r]-i>0){var n=Math.min(i,a[r]-i);i-=n,o=e-n}return o/t*100}))}function T(){var e=this,i=s[e.a].element,a=s[e.b].element;e.dragging&&Bt(t,"onDragEnd",qt)(C()),e.dragging=!1,Lt.removeEventListener("mouseup",e.stop),Lt.removeEventListener("touchend",e.stop),Lt.removeEventListener("touchcancel",e.stop),Lt.removeEventListener("mousemove",e.move),Lt.removeEventListener("touchmove",e.move),e.stop=null,e.move=null,i.removeEventListener("selectstart",qt),i.removeEventListener("dragstart",qt),a.removeEventListener("selectstart",qt),a.removeEventListener("dragstart",qt),i.style.userSelect="",i.style.webkitUserSelect="",i.style.MozUserSelect="",i.style.pointerEvents="",a.style.userSelect="",a.style.webkitUserSelect="",a.style.MozUserSelect="",a.style.pointerEvents="",e.gutter.style.cursor="",e.parent.style.cursor="",Ut.body.style.cursor=""}function U(e){if(!("button"in e)||0===e.button){var i=this,a=s[i.a].element,r=s[i.b].element;i.dragging||Bt(t,"onDragStart",qt)(C()),e.preventDefault(),i.dragging=!0,i.move=I.bind(i),i.stop=T.bind(i),Lt.addEventListener("mouseup",i.stop),Lt.addEventListener("touchend",i.stop),Lt.addEventListener("touchcancel",i.stop),Lt.addEventListener("mousemove",i.move),Lt.addEventListener("touchmove",i.move),a.addEventListener("selectstart",qt),a.addEventListener("dragstart",qt),r.addEventListener("selectstart",qt),r.addEventListener("dragstart",qt),a.style.userSelect="none",a.style.webkitUserSelect="none",a.style.MozUserSelect="none",a.style.pointerEvents="none",r.style.userSelect="none",r.style.webkitUserSelect="none",r.style.MozUserSelect="none",r.style.pointerEvents="none",i.gutter.style.cursor=_,i.parent.style.cursor=_,Ut.body.style.cursor=_,P.call(i),i.dragOffset=D(e)-i.end}}y===Rt?(i="width",a="clientX",r="left",o="right",n="clientWidth"):"vertical"===y&&(i="height",a="clientY",r="top",o="bottom",n="clientHeight"),f=L(f);var R=[];function q(e){var t=e.i===R.length,i=t?R[e.i-1]:R[e.i];P.call(i);var a=t?i.size-e.minSize-i._c:e.minSize+i._b;E.call(i,a)}return s=l.map((function(e,t){var a,r={element:jt(e),size:f[t],minSize:u[t],maxSize:m[t],i:t};if(t>0&&((a={a:t-1,b:t,dragging:!1,direction:y,parent:c})._b=Nt(v,t-1==0,!1,w),a._c=Nt(v,!1,t===l.length-1,w),"row-reverse"===h||"column-reverse"===h)){var o=a.a;a.a=a.b,a.b=o}if(t>0){var n=$(t,y,r.element);!function(e,t,a){var r=z(i,t,a);Object.keys(r).forEach((function(t){e.style[t]=r[t]}))}(n,v,t),a._a=U.bind(a),n.addEventListener("mousedown",a._a),n.addEventListener("touchstart",a._a),c.insertBefore(n,r.element),a.gutter=n}return A(r.element,r.size,Nt(v,0===t,t===l.length-1,w),t),t>0&&R.push(a),r})),s.forEach((function(e){var t=e.element.getBoundingClientRect()[i];t<e.minSize&&(g?q(e):e.minSize=t)})),{setSizes:function(e){var t=L(e);t.forEach((function(e,i){if(i>0){var a=R[i-1],r=s[a.a],o=s[a.b];r.size=t[i-1],o.size=e,A(r.element,r.size,a._b,r.i),A(o.element,o.size,a._c,o.i)}}))},getSizes:C,collapse:function(e){q(s[e])},destroy:function(e,t){R.forEach((function(a){if(!0!==t?a.parent.removeChild(a.gutter):(a.gutter.removeEventListener("mousedown",a._a),a.gutter.removeEventListener("touchstart",a._a)),!0!==e){var r=S(i,a.a.size,a._b);Object.keys(r).forEach((function(e){s[a.a].element.style[e]="",s[a.b].element.style[e]=""}))}}))},parent:c,pairs:R}},Kt="search://";class Vt extends X{constructor(){super(),this.sourceUrl=null,this.inited=!1,this.isLoading=!1,this.coll="",this.collInfo=null,this._replaceLoc=!1,this._locUpdateNeeded=!1,this._locationHash="",this.tabData={},this.url="",this.ts="",this.tabNames=["pages","story","resources","info"],this.tabLabels={pages:"Pages",story:"Story",resources:"URLs",info:"Archive Info"},this.menuActive=!1,this.embedDropdownActive=!1,this.hasStory=!1,this.editable=!1,this.browsable=!0,this.clearable=!0,this.showSidebar="1"===localStorage.getItem("pages:showSidebar"),this.splitter=null,this.isVisible=!0,this.favIconUrl="",this.autoUpdateInterval=10,this._autoUpdater=null,this.appName="ReplayWeb.page",this.appVersion=me,this.appLogo=fe()}static get properties(){return{inited:{type:Boolean},sourceUrl:{type:String},loadInfo:{type:Object,attribute:!1},showSidebar:{type:Boolean},collInfo:{type:Object,attribute:!1},coll:{type:String},hasStory:{type:Boolean},isLoading:{type:Boolean},tabData:{type:Object,attribute:!1},url:{type:String},ts:{type:String},isFullscreen:{type:Boolean},menuActive:{type:Boolean},embed:{type:String},embedDropdownActive:{type:Boolean},editable:{type:Boolean},browsable:{type:Boolean},clearable:{type:Boolean},isVisible:{type:Boolean},favIconUrl:{type:String},appName:{type:String},appVersion:{type:String},appLogo:{type:String},autoUpdateInterval:{type:Number},swName:{type:String}}}firstUpdated(){this.inited=!0,window.addEventListener("hashchange",(e=>this.onHashChange(e))),this.addEventListener("fullscreenchange",(()=>{this.isFullscreen=!!document.fullscreenElement})),this.embed&&this.loadInfo&&this.loadInfo.hideOffscreen&&(this.observer=new IntersectionObserver((e=>{this.isVisible=e[0].isIntersecting})),this.observer.observe(this))}async runUpdateLoop(){try{for(;this.editable&&this.autoUpdateInterval&&(!this.collInfo||!this.collInfo.pages||this.collInfo.pages.length<100);)await new Promise((e=>setTimeout(e,1e3*this.autoUpdateInterval))),await this.doUpdateInfo(!0)}finally{this._autoUpdater=null}}updated(e){if(e.has("sourceUrl")&&this.doUpdateInfo(),e.has("editable")&&this.editable&&this.autoUpdateInterval&&!this._autoUpdater&&(this._autoUpdater=this.runUpdateLoop()),e.has("tabData")){if(!this.collInfo||!this.collInfo.coll)return;Object.keys(this.tabData).forEach((e=>!this.tabData[e]&&delete this.tabData[e]));const t="#"+new URLSearchParams(this.tabData).toString();if(this.tabData.url||(this.url=Kt+decodeURIComponent(this._paramsToString(this.tabData))),t!==this._locationHash){if(this._locationHash=t,this._replaceLoc||0===Object.keys(e.get("tabData")).length){const e=new URL(window.location.href);e.hash=this._locationHash,window.history.replaceState({},"",e.href),this._replaceLoc=!1}else if(window.location.hash=this._locationHash,!this.showSidebar){const e=this.renderRoot.querySelector("wr-coll-replay");e&&e.focus()}this.embed&&window.parent!==window&&window.parent.postMessage(this.tabData,"*")}this._locUpdateNeeded=!1}e.has("showSidebar")&&(this.embed||localStorage.setItem("pages:showSidebar",this.showSidebar?"1":"0")),(e.has("tabData")||e.has("showSidebar"))&&this.configureSplitter()}configureSplitter(){if(this.tabData.url&&this.showSidebar){const e=this.renderRoot.querySelector("#contents"),t=this.renderRoot.querySelector("wr-coll-replay");if(e&&t&&!this.splitter){const i={sizes:[30,70],minSize:[300,300],gutterSize:4,onDragStart(){t.setDisablePointer(!0)},onDragEnd(){t.setDisablePointer(!1)}};this.splitter=Gt([e,t],i)}}else if(this.splitter){try{this.splitter.destroy()}catch(e){}this.splitter=null}}async doUpdateInfo(e=!1){if(e&&this.tabData.url&&!this.showSidebar)return;let t=this.loadInfo&&this.loadInfo.customColl;if(!t){t=(await Je(this.sourceUrl)).coll}this.coll=t;const i="./w/api/c/"+t,a="./w/"+t,r=await fetch(i+"?all=1");if(200!=r.status)return void(this.collInfo={});const o=await r.json();if(this.collInfo={apiPrefix:i,replayPrefix:a,coll:t,...o},this.loadInfo&&this.loadInfo.extraConfig&&this.loadInfo.extraConfig.headers){const e=this.loadInfo.extraConfig.headers;await fetch(`${i}/updateAuth`,{method:"POST",body:JSON.stringify({headers:e})})}this.collInfo.title||(this.collInfo.title=this.collInfo.filename),"replayonly"!==this.embed&&"replay-with-info"!==this.embed||(this.showSidebar=!1),this.hasStory=this.collInfo.desc||this.collInfo.lists.length,this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{collInfo:this.collInfo,alreadyLoaded:!0}})),this.onHashChange()}onCollLoaded(e){this.doUpdateInfo(),this.loadInfo=null,e.detail.sourceUrl&&(this.sourceUrl=e.detail.sourceUrl),this.dispatchEvent(new CustomEvent("coll-loaded",{detail:{sourceUrl:this.sourceUrl,collInfo:this.collInfo}}))}onCollUpdate(e){this.editable&&(this.collInfo={...this.collInfo,...e.detail})}onHashChange(){const e=window.location.hash;if(e&&e!==this._locationHash&&(this.tabData=Object.fromEntries(new URLSearchParams(e.slice(1)).entries()),this._locationHash=e),this.collInfo.coll&&!this.tabNames.includes(this.tabData.view)){const e=this.hasStory?"story":this.editable||this.collInfo.pages.length?"pages":"resources";this.tabData={...this.tabData,view:e}}if(this.tabData.url&&this.tabData.url.startsWith("page:")){const e=Number(this.tabData.url.slice("page:".length));if(!isNaN(e)&&e<this.collInfo.pages.length){const t=this.collInfo.pages[e];this.tabData.url=t.url,this.tabData.ts=Ve(t).timestamp}}this.hasStory||"story"!==this.tabData.view||(this.tabData.view="pages"),this.tabData.url&&this.tabData.query&&(this.showSidebar=!0)}onTabClick(e){e.preventDefault();const t=e.currentTarget.getAttribute("href");return this.tabData={...this.tabData,view:t.slice(1)},!1}onCollTabNav(e){e.detail.reload?this.onRefresh(null,!0):e.target.id===this.tabData.view||"replay"===e.target.id&&this.tabData.url?this.updateTabData(e.detail.data,e.detail.replaceLoc,!1):this.showSidebar&&this.tabData.url&&this.updateTabData(e.detail.data,e.detail.replaceLoc,!0)}updateTabData(e,t=!1){this.tabData={...this.tabData,...e},this.tabData.url&&(this.url=this.tabData.url||""),this.tabData.ts&&(this.ts=this.tabData.ts||""),this._replaceLoc=!this._locUpdateNeeded&&t,this._locUpdateNeeded=!0}static get styles(){return ue(Vt.compStyles)}static get compStyles(){return o`
933
933
  :host {
934
934
  display: flex;
935
935
  flex-direction: column;