@bugspotter/sdk 0.1.0-alpha.1 → 0.1.0-alpha.3

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.
@@ -1,2 +1,2 @@
1
1
  /*! For license information please see bugspotter.min.js.LICENSE.txt */
2
- !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BugSpotter=e():t.BugSpotter=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{BugSpotter:()=>Xs});const n=(()=>{let t=0;return()=>(t+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${t}`)})();function i(t){const e=[];for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}let r=null;function s(t={}){return r||(t.includeStyleProperties?(r=t.includeStyleProperties,r):(r=i(window.getComputedStyle(document.documentElement)),r))}function o(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function a(t,e={}){return{width:e.width||function(t){const e=o(t,"border-left-width"),n=o(t,"border-right-width");return t.clientWidth+e+n}(t),height:e.height||function(t){const e=o(t,"border-top-width"),n=o(t,"border-bottom-width");return t.clientHeight+e+n}(t)}}const l=16384;function c(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>e(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=t})}const d=(t,e)=>{if(t instanceof e)return!0;const n=Object.getPrototypeOf(t);return null!==n&&(n.constructor.name===e.name||d(n,e))};function h(t,e,i,r){const o=window.getComputedStyle(t,i),a=o.getPropertyValue("content");if(""===a||"none"===a)return;const l=n();try{e.className=`${e.className} ${l}`}catch(t){return}const c=document.createElement("style");c.appendChild(function(t,e,n,i){const r=`.${t}:${e}`,o=n.cssText?function(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}(n):function(t,e){return s(e).map(e=>`${e}: ${t.getPropertyValue(e)}${t.getPropertyPriority(e)?" !important":""};`).join(" ")}(n,i);return document.createTextNode(`${r}{${o}}`)}(l,i,o,r)),e.appendChild(c)}const u="application/font-woff",g="image/jpeg",p={woff:u,woff2:u,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:g,jpeg:g,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function m(t){const e=function(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return p[e]||""}function f(t){return-1!==t.search(/^(data:)/)}function y(t,e){return`data:${e};base64,${t}`}async function b(t,e,n){const i=await fetch(t,e);if(404===i.status)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((t,e)=>{const s=new FileReader;s.onerror=e,s.onloadend=()=>{try{t(n({res:i,result:s.result}))}catch(t){e(t)}},s.readAsDataURL(r)})}const w={};async function v(t,e,n){const i=function(t,e,n){let i=t.replace(/\?.*/,"");return n&&(i=t),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),e?`[${e}]${i}`:i}(t,e,n.includeQueryParams);if(null!=w[i])return w[i];let r;n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());try{const i=await b(t,n.fetchRequestInit,({res:t,result:n})=>(e||(e=t.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n)));r=y(i,e)}catch(e){r=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${t}`;e&&(i="string"==typeof e?e:e.message),i&&console.warn(i)}return w[i]=r,r}const C=t=>null!=t.tagName&&"SLOT"===t.tagName.toUpperCase(),I=t=>null!=t.tagName&&"SVG"===t.tagName.toUpperCase();async function _(t,e,n){return n||!e.filter||e.filter(t)?Promise.resolve(t).then(t=>async function(t,e){return d(t,HTMLCanvasElement)?async function(t){const e=t.toDataURL();return"data:,"===e?t.cloneNode(!1):c(e)}(t):d(t,HTMLVideoElement)?async function(t,e){if(t.currentSrc){const e=document.createElement("canvas"),n=e.getContext("2d");return e.width=t.clientWidth,e.height=t.clientHeight,null==n||n.drawImage(t,0,0,e.width,e.height),c(e.toDataURL())}const n=t.poster,i=m(n);return c(await v(n,i,e))}(t,e):d(t,HTMLIFrameElement)?async function(t,e){var n;try{if(null===(n=null==t?void 0:t.contentDocument)||void 0===n?void 0:n.body)return await _(t.contentDocument.body,e,!0)}catch(t){}return t.cloneNode(!1)}(t,e):t.cloneNode(I(t))}(t,e)).then(n=>async function(t,e,n){var r,s;if(I(e))return e;let o=[];return o=C(t)&&t.assignedNodes?i(t.assignedNodes()):d(t,HTMLIFrameElement)&&(null===(r=t.contentDocument)||void 0===r?void 0:r.body)?i(t.contentDocument.body.childNodes):i((null!==(s=t.shadowRoot)&&void 0!==s?s:t).childNodes),0===o.length||d(t,HTMLVideoElement)||await o.reduce((t,i)=>t.then(()=>_(i,n)).then(t=>{t&&e.appendChild(t)}),Promise.resolve()),e}(t,n,e)).then(n=>function(t,e,n){return d(e,Element)&&(function(t,e,n){const i=e.style;if(!i)return;const r=window.getComputedStyle(t);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):s(n).forEach(n=>{let s=r.getPropertyValue(n);if("font-size"===n&&s.endsWith("px")){const t=Math.floor(parseFloat(s.substring(0,s.length-2)))-.1;s=`${t}px`}d(t,HTMLIFrameElement)&&"display"===n&&"inline"===s&&(s="block"),"d"===n&&e.getAttribute("d")&&(s=`path(${e.getAttribute("d")})`),i.setProperty(n,s,r.getPropertyPriority(n))})}(t,e,n),function(t,e,n){h(t,e,":before",n),h(t,e,":after",n)}(t,e,n),function(t,e){d(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),d(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,e),function(t,e){if(d(t,HTMLSelectElement)){const n=e,i=Array.from(n.children).find(e=>t.value===e.getAttribute("value"));i&&i.setAttribute("selected","")}}(t,e)),e}(t,n,e)).then(t=>async function(t,e){const n=t.querySelectorAll?t.querySelectorAll("use"):[];if(0===n.length)return t;const i={};for(let r=0;r<n.length;r++){const s=n[r].getAttribute("xlink:href");if(s){const n=t.querySelector(s),r=document.querySelector(s);n||!r||i[s]||(i[s]=await _(r,e,!0))}}const r=Object.values(i);if(r.length){const e="http://www.w3.org/1999/xhtml",n=document.createElementNS(e,"svg");n.setAttribute("xmlns",e),n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.style.display="none";const i=document.createElementNS(e,"defs");n.appendChild(i);for(let t=0;t<r.length;t++)i.appendChild(r[t]);t.appendChild(n)}return t}(t,e)):null}const S=/url\((['"]?)([^'"]+?)\1\)/g,k=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,x=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function A(t){return-1!==t.search(S)}async function E(t,e,n){if(!A(t))return t;const i=function(t,{preferredFontFormat:e}){return e?t.replace(x,t=>{for(;;){const[n,,i]=k.exec(t)||[];if(!i)return"";if(i===e)return`src: ${n};`}}):t}(t,n),r=function(t){const e=[];return t.replace(S,(t,n,i)=>(e.push(i),t)),e.filter(t=>!f(t))}(i);return r.reduce((t,i)=>t.then(t=>async function(t,e,n,i,r){try{const s=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),e&&(i.href=e),r.href=t,r.href}(e,n):e,o=m(e);let a;return a=r?y(await r(s),o):await v(s,o,i),t.replace(function(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}(e),`$1${a}$3`)}catch(t){}return t}(t,i,e,n)),Promise.resolve(i))}async function R(t,e,n){var i;const r=null===(i=e.style)||void 0===i?void 0:i.getPropertyValue(t);if(r){const i=await E(r,null,n);return e.style.setProperty(t,i,e.style.getPropertyPriority(t)),!0}return!1}async function M(t,e){d(t,Element)&&(await async function(t,e){await R("background",t,e)||await R("background-image",t,e),await R("mask",t,e)||await R("-webkit-mask",t,e)||await R("mask-image",t,e)||await R("-webkit-mask-image",t,e)}(t,e),await async function(t,e){const n=d(t,HTMLImageElement);if((!n||f(t.src))&&(!d(t,SVGImageElement)||f(t.href.baseVal)))return;const i=n?t.src:t.href.baseVal,r=await v(i,m(i),e);await new Promise((i,s)=>{t.onload=i,t.onerror=e.onImageErrorHandler?(...t)=>{try{i(e.onImageErrorHandler(...t))}catch(t){s(t)}}:s;const o=t;o.decode&&(o.decode=i),"lazy"===o.loading&&(o.loading="eager"),n?(t.srcset="",t.src=r):t.href.baseVal=r})}(t,e),await async function(t,e){const n=i(t.childNodes).map(t=>M(t,e));await Promise.all(n).then(()=>t)}(t,e))}const T={};async function z(t){let e=T[t];if(null!=e)return e;const n=await fetch(t);return e={url:t,cssText:await n.text()},T[t]=e,e}async function O(t,e){let n=t.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,r=(n.match(/url\([^)]+\)/g)||[]).map(async r=>{let s=r.replace(i,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),b(s,e.fetchRequestInit,({result:t})=>(n=n.replace(r,`url(${t})`),[r,t]))});return Promise.all(r).then(()=>n)}function N(t){if(null==t)return[];const e=[];let n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const t=i.exec(n);if(null===t)break;e.push(t[0])}n=n.replace(i,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let t=r.exec(n);if(null===t){if(t=s.exec(n),null===t)break;r.lastIndex=s.lastIndex}else s.lastIndex=r.lastIndex;e.push(t[0])}return e}function D(t){return t.trim().replace(/["']/g,"")}async function L(t,e){const n=await async function(t,e){if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");const n=i(t.ownerDocument.styleSheets),r=await async function(t,e){const n=[],r=[];return t.forEach(n=>{if("cssRules"in n)try{i(n.cssRules||[]).forEach((t,i)=>{if(t.type===CSSRule.IMPORT_RULE){let s=i+1;const o=z(t.href).then(t=>O(t,e)).then(t=>N(t).forEach(t=>{try{n.insertRule(t,t.startsWith("@import")?s+=1:n.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}})).catch(t=>{console.error("Error loading remote css",t.toString())});r.push(o)}})}catch(i){const s=t.find(t=>null==t.href)||document.styleSheets[0];null!=n.href&&r.push(z(n.href).then(t=>O(t,e)).then(t=>N(t).forEach(t=>{s.insertRule(t,s.cssRules.length)})).catch(t=>{console.error("Error loading remote stylesheet",t)})),console.error("Error inlining remote css file",i)}}),Promise.all(r).then(()=>(t.forEach(t=>{if("cssRules"in t)try{i(t.cssRules||[]).forEach(t=>{n.push(t)})}catch(e){console.error(`Error while reading CSS rules from ${t.href}`,e)}}),n))}(n,e);return function(t){return t.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>A(t.style.getPropertyValue("src")))}(r)}(t,e),r=function(t){const e=new Set;return function t(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(t=>{e.add(D(t))}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&t(e)})}(t),e}(t);return(await Promise.all(n.filter(t=>r.has(D(t.style.fontFamily))).map(t=>{const n=t.parentStyleSheet?t.parentStyleSheet.href:null;return E(t.cssText,n,e)}))).join("\n")}async function F(t,e={}){const{width:n,height:i}=a(t,e),r=await _(t,e,!0);return await async function(t,e){const n=null!=e.fontEmbedCSS?e.fontEmbedCSS:e.skipFonts?null:await L(t,e);if(n){const e=document.createElement("style"),i=document.createTextNode(n);e.appendChild(i),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}}(r,e),await M(r,e),function(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const i=e.style;null!=i&&Object.keys(i).forEach(t=>{n[t]=i[t]})}(r,e),await async function(t,e,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${e}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${e} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(t),async function(t){return Promise.resolve().then(()=>(new XMLSerializer).serializeToString(t)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}(r)}(r,n,i)}const B={debug:0,log:1,warn:2,error:3,none:4};const U=new class{constructor(t={}){var e,n,i;this.enabled=null===(e=t.enabled)||void 0===e||e,this.level=null!==(n=t.level)&&void 0!==n?n:"log",this.prefix=null!==(i=t.prefix)&&void 0!==i?i:"[BugSpotter]"}shouldLog(t){return!!this.enabled&&B[t]>=B[this.level]}formatMessage(t){return this.prefix?`${this.prefix} ${t}`:t}debug(t,...e){this.shouldLog("debug")&&console.debug(this.formatMessage(t),...e)}log(t,...e){this.shouldLog("log")&&console.log(this.formatMessage(t),...e)}warn(t,...e){this.shouldLog("warn")&&console.warn(this.formatMessage(t),...e)}error(t,...e){this.shouldLog("error")&&console.error(this.formatMessage(t),...e)}configure(t){void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.level&&(this.level=t.level),void 0!==t.prefix&&(this.prefix=t.prefix)}};function Z(){return U}const W=Z();class P{constructor(t){this.options=t,this.sanitizer=t.sanitizer}handleError(t,e){const n=e instanceof Error?e:new Error(String(e));W.error(`${this.constructor.name} ${t}:`,n)}}function V(t){let e=t.length;for(;--e>=0;)t[e]=0}const G=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),H=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),j=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),q=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K=new Array(576);V(K);const $=new Array(60);V($);const Y=new Array(512);V(Y);const Q=new Array(256);V(Q);const J=new Array(29);V(J);const X=new Array(30);function tt(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}let et,nt,it;function rt(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}V(X);const st=t=>t<256?Y[t]:Y[256+(t>>>7)],ot=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},at=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,ot(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},lt=(t,e,n)=>{at(t,n[2*e],n[2*e+1])},ct=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},dt=(t,e,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=15;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=ct(i[e]++,e))}},ht=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},ut=t=>{t.bi_valid>8?ot(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},gt=(t,e,n,i)=>{const r=2*e,s=2*n;return t[r]<t[s]||t[r]===t[s]&&i[e]<=i[n]},pt=(t,e,n)=>{const i=t.heap[n];let r=n<<1;for(;r<=t.heap_len&&(r<t.heap_len&&gt(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!gt(e,i,t.heap[r],t.depth));)t.heap[n]=t.heap[r],n=r,r<<=1;t.heap[n]=i},mt=(t,e,n)=>{let i,r,s,o,a=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+a++],i+=(255&t.pending_buf[t.sym_buf+a++])<<8,r=t.pending_buf[t.sym_buf+a++],0===i?lt(t,r,e):(s=Q[r],lt(t,s+256+1,e),o=G[s],0!==o&&(r-=J[s],at(t,r,o)),i--,s=st(i),lt(t,s,n),o=H[s],0!==o&&(i-=X[s],at(t,i,o)))}while(a<t.sym_next);lt(t,256,e)},ft=(t,e)=>{const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,l,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==n[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):n[2*o+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,n[2*l]=1,t.depth[l]=0,t.opt_len--,r&&(t.static_len-=i[2*l+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)pt(t,n,o);l=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],pt(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,n[2*l]=n[2*o]+n[2*a],t.depth[l]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,n[2*o+1]=n[2*a+1]=l,t.heap[1]=l++,pt(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,i=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let c,d,h,u,g,p,m=0;for(u=0;u<=15;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)d=t.heap[c],u=n[2*n[2*d+1]+1]+1,u>l&&(u=l,m++),n[2*d+1]=u,d>i||(t.bl_count[u]++,g=0,d>=a&&(g=o[d-a]),p=n[2*d],t.opt_len+=p*(u+g),s&&(t.static_len+=p*(r[2*d+1]+g)));if(0!==m){do{for(u=l-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(d=t.bl_count[u];0!==d;)h=t.heap[--c],h>i||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),d--)}})(t,e),dt(n,c,t.bl_count)},yt=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=e[2*(i+1)+1],++a<l&&r===o||(a<c?t.bl_tree[2*r]+=a:0!==r?(r!==s&&t.bl_tree[2*r]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4))},bt=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),i=0;i<=n;i++)if(r=o,o=e[2*(i+1)+1],!(++a<l&&r===o)){if(a<c)do{lt(t,r,t.bl_tree)}while(0!==--a);else 0!==r?(r!==s&&(lt(t,r,t.bl_tree),a--),lt(t,16,t.bl_tree),at(t,a-3,2)):a<=10?(lt(t,17,t.bl_tree),at(t,a-3,3)):(lt(t,18,t.bl_tree),at(t,a-11,7));a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4)}};let wt=!1;const vt=(t,e,n,i)=>{at(t,0+(i?1:0),3),ut(t),ot(t,n),ot(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var Ct={_tr_init:t=>{wt||((()=>{let t,e,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(J[i]=n,t=0;t<1<<G[i];t++)Q[n++]=i;for(Q[n-1]=i,r=0,i=0;i<16;i++)for(X[i]=r,t=0;t<1<<H[i];t++)Y[r++]=i;for(r>>=7;i<30;i++)for(X[i]=r<<7,t=0;t<1<<H[i]-7;t++)Y[256+r++]=i;for(e=0;e<=15;e++)s[e]=0;for(t=0;t<=143;)K[2*t+1]=8,t++,s[8]++;for(;t<=255;)K[2*t+1]=9,t++,s[9]++;for(;t<=279;)K[2*t+1]=7,t++,s[7]++;for(;t<=287;)K[2*t+1]=8,t++,s[8]++;for(dt(K,287,s),t=0;t<30;t++)$[2*t+1]=5,$[2*t]=ct(t,5);et=new tt(K,G,257,286,15),nt=new tt($,H,0,30,15),it=new tt(new Array(0),j,0,19,7)})(),wt=!0),t.l_desc=new rt(t.dyn_ltree,et),t.d_desc=new rt(t.dyn_dtree,nt),t.bl_desc=new rt(t.bl_tree,it),t.bi_buf=0,t.bi_valid=0,ht(t)},_tr_stored_block:vt,_tr_flush_block:(t,e,n,i)=>{let r,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),ft(t,t.l_desc),ft(t,t.d_desc),o=(t=>{let e;for(yt(t,t.dyn_ltree,t.l_desc.max_code),yt(t,t.dyn_dtree,t.d_desc.max_code),ft(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*q[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==e?vt(t,e,n,i):4===t.strategy||s===r?(at(t,2+(i?1:0),3),mt(t,K,$)):(at(t,4+(i?1:0),3),((t,e,n,i)=>{let r;for(at(t,e-257,5),at(t,n-1,5),at(t,i-4,4),r=0;r<i;r++)at(t,t.bl_tree[2*q[r]+1],3);bt(t,t.dyn_ltree,e-1),bt(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),mt(t,t.dyn_ltree,t.dyn_dtree)),ht(t),i&&ut(t)},_tr_tally:(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(Q[n]+256+1)]++,t.dyn_dtree[2*st(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{at(t,2,3),lt(t,256,K),(t=>{16===t.bi_valid?(ot(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},It=(t,e,n,i)=>{let r=65535&t,s=t>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+e[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const _t=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var St=(t,e,n,i)=>{const r=_t,s=i+n;t^=-1;for(let n=i;n<s;n++)t=t>>>8^r[255&(t^e[n])];return-1^t},kt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:At,_tr_stored_block:Et,_tr_flush_block:Rt,_tr_tally:Mt,_tr_align:Tt}=Ct,{Z_NO_FLUSH:zt,Z_PARTIAL_FLUSH:Ot,Z_FULL_FLUSH:Nt,Z_FINISH:Dt,Z_BLOCK:Lt,Z_OK:Ft,Z_STREAM_END:Bt,Z_STREAM_ERROR:Ut,Z_DATA_ERROR:Zt,Z_BUF_ERROR:Wt,Z_DEFAULT_COMPRESSION:Pt,Z_FILTERED:Vt,Z_HUFFMAN_ONLY:Gt,Z_RLE:Ht,Z_FIXED:jt,Z_DEFAULT_STRATEGY:qt,Z_UNKNOWN:Kt,Z_DEFLATED:$t}=xt,Yt=258,Qt=262,Jt=42,Xt=113,te=666,ee=(t,e)=>(t.msg=kt[e],e),ne=t=>2*t-(t>4?9:0),ie=t=>{let e=t.length;for(;--e>=0;)t[e]=0},re=t=>{let e,n,i,r=t.w_size;e=t.hash_size,i=e;do{n=t.head[--i],t.head[i]=n>=r?n-r:0}while(--e);e=r,i=e;do{n=t.prev[--i],t.prev[i]=n>=r?n-r:0}while(--e)};let se=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const oe=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},ae=(t,e)=>{Rt(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,oe(t.strm)},le=(t,e)=>{t.pending_buf[t.pending++]=e},ce=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},de=(t,e,n,i)=>{let r=t.avail_in;return r>i&&(r=i),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),n),1===t.state.wrap?t.adler=It(t.adler,e,r,n):2===t.state.wrap&&(t.adler=St(t.adler,e,r,n)),t.next_in+=r,t.total_in+=r,r)},he=(t,e)=>{let n,i,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-Qt?t.strstart-(t.w_size-Qt):0,c=t.window,d=t.w_mask,h=t.prev,u=t.strstart+Yt;let g=c[s+o-1],p=c[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,c[n+o]===p&&c[n+o-1]===g&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&s<u);if(i=Yt-(u-s),s=u-Yt,i>o){if(t.match_start=e,o=i,i>=a)break;g=c[s+o-1],p=c[s+o]}}}while((e=h[e&d])>l&&0!==--r);return o<=t.lookahead?o:t.lookahead},ue=t=>{const e=t.w_size;let n,i,r;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Qt)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),re(t),i+=e),0===t.strm.avail_in)break;if(n=de(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=se(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=se(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<Qt&&0!==t.strm.avail_in)},ge=(t,e)=>{let n,i,r,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(n=65535,r=t.bi_valid+42>>3,t.strm.avail_out<r)break;if(r=t.strm.avail_out-r,i=t.strstart-t.block_start,n>i+t.strm.avail_in&&(n=i+t.strm.avail_in),n>r&&(n=r),n<s&&(0===n&&e!==Dt||e===zt||n!==i+t.strm.avail_in))break;o=e===Dt&&n===i+t.strm.avail_in?1:0,Et(t,0,0,o),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,oe(t.strm),i&&(i>n&&(i=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,n-=i),n&&(de(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===o);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==zt&&e!==Dt&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(r=t.window_size-t.strstart,t.strm.avail_in>r&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(de(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water<t.strstart&&(t.high_water=t.strstart),r=t.bi_valid+42>>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,s=r>t.w_size?t.w_size:r,i=t.strstart-t.block_start,(i>=s||(i||e===Dt)&&e!==zt&&0===t.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=e===Dt&&0===t.strm.avail_in&&n===i?1:0,Et(t,t.block_start,n,o),t.block_start+=n,oe(t.strm)),o?3:1)},pe=(t,e)=>{let n,i;for(;;){if(t.lookahead<Qt){if(ue(t),t.lookahead<Qt&&e===zt)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-Qt&&(t.match_length=he(t,n)),t.match_length>=3)if(i=Mt(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=se(t,t.ins_h,t.window[t.strstart+1]);else i=Mt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ae(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2},me=(t,e)=>{let n,i,r;for(;;){if(t.lookahead<Qt){if(ue(t),t.lookahead<Qt&&e===zt)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-Qt&&(t.match_length=he(t,n),t.match_length<=5&&(t.strategy===Vt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,i=Mt(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(ae(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=Mt(t,0,t.window[t.strstart-1]),i&&ae(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=Mt(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2};function fe(t,e,n,i,r){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=i,this.func=r}const ye=[new fe(0,0,0,0,ge),new fe(4,4,8,4,pe),new fe(4,5,16,8,pe),new fe(4,6,32,32,pe),new fe(4,4,16,16,me),new fe(8,16,32,32,me),new fe(8,16,128,128,me),new fe(8,32,128,256,me),new fe(32,128,258,1024,me),new fe(32,258,258,4096,me)];function be(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$t,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ie(this.dyn_ltree),ie(this.dyn_dtree),ie(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ie(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ie(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const we=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Jt&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==Xt&&e.status!==te?1:0},ve=t=>{if(we(t))return ee(t,Ut);t.total_in=t.total_out=0,t.data_type=Kt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Jt:Xt,t.adler=2===e.wrap?0:1,e.last_flush=-2,At(e),Ft},Ce=t=>{const e=ve(t);var n;return e===Ft&&((n=t.state).window_size=2*n.w_size,ie(n.head),n.max_lazy_match=ye[n.level].max_lazy,n.good_match=ye[n.level].good_length,n.nice_match=ye[n.level].nice_length,n.max_chain_length=ye[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},Ie=(t,e,n,i,r,s)=>{if(!t)return Ut;let o=1;if(e===Pt&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==$t||i<8||i>15||e<0||e>9||s<0||s>jt||8===i&&1!==o)return ee(t,Ut);8===i&&(i=9);const a=new be;return t.state=a,a.strm=t,a.status=Jt,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=s,a.method=n,Ce(t)};var _e=Ie,Se=(t,e)=>we(t)||2!==t.state.wrap?Ut:(t.state.gzhead=e,Ft),ke=(t,e)=>{if(we(t)||e>Lt||e<0)return t?ee(t,Ut):Ut;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===te&&e!==Dt)return ee(t,0===t.avail_out?Wt:Ut);const i=n.last_flush;if(n.last_flush=e,0!==n.pending){if(oe(t),0===t.avail_out)return n.last_flush=-1,Ft}else if(0===t.avail_in&&ne(e)<=ne(i)&&e!==Dt)return ee(t,Wt);if(n.status===te&&0!==t.avail_in)return ee(t,Wt);if(n.status===Jt&&0===n.wrap&&(n.status=Xt),n.status===Jt){let e=$t+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=Gt||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,ce(n,e),0!==n.strstart&&(ce(n,t.adler>>>16),ce(n,65535&t.adler)),t.adler=1,n.status=Xt,oe(t),0!==n.pending)return n.last_flush=-1,Ft}if(57===n.status)if(t.adler=0,le(n,31),le(n,139),le(n,8),n.gzhead)le(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),le(n,255&n.gzhead.time),le(n,n.gzhead.time>>8&255),le(n,n.gzhead.time>>16&255),le(n,n.gzhead.time>>24&255),le(n,9===n.level?2:n.strategy>=Gt||n.level<2?4:0),le(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(le(n,255&n.gzhead.extra.length),le(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=St(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(le(n,0),le(n,0),le(n,0),le(n,0),le(n,0),le(n,9===n.level?2:n.strategy>=Gt||n.level<2?4:0),le(n,3),n.status=Xt,oe(t),0!==n.pending)return n.last_flush=-1,Ft;if(69===n.status){if(n.gzhead.extra){let e=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=St(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=r,oe(t),0!==n.pending)return n.last_flush=-1,Ft;e=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>e&&(t.adler=St(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i)),oe(t),0!==n.pending)return n.last_flush=-1,Ft;i=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,le(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i)),oe(t),0!==n.pending)return n.last_flush=-1,Ft;i=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,le(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(oe(t),0!==n.pending))return n.last_flush=-1,Ft;le(n,255&t.adler),le(n,t.adler>>8&255),t.adler=0}if(n.status=Xt,oe(t),0!==n.pending)return n.last_flush=-1,Ft}if(0!==t.avail_in||0!==n.lookahead||e!==zt&&n.status!==te){let i=0===n.level?ge(n,e):n.strategy===Gt?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(ue(t),0===t.lookahead)){if(e===zt)return 1;break}if(t.match_length=0,n=Mt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(ae(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===Ht?((t,e)=>{let n,i,r,s;const o=t.window;for(;;){if(t.lookahead<=Yt){if(ue(t),t.lookahead<=Yt&&e===zt)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=t.strstart+Yt;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<s);t.match_length=Yt-(s-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=Mt(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=Mt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(ae(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2})(n,e):ye[n.level].func(n,e);if(3!==i&&4!==i||(n.status=te),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),Ft;if(2===i&&(e===Ot?Tt(n):e!==Lt&&(Et(n,0,0,!1),e===Nt&&(ie(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),oe(t),0===t.avail_out))return n.last_flush=-1,Ft}return e!==Dt?Ft:n.wrap<=0?Bt:(2===n.wrap?(le(n,255&t.adler),le(n,t.adler>>8&255),le(n,t.adler>>16&255),le(n,t.adler>>24&255),le(n,255&t.total_in),le(n,t.total_in>>8&255),le(n,t.total_in>>16&255),le(n,t.total_in>>24&255)):(ce(n,t.adler>>>16),ce(n,65535&t.adler)),oe(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Ft:Bt)},xe=t=>{if(we(t))return Ut;const e=t.state.status;return t.state=null,e===Xt?ee(t,Zt):Ft},Ae=(t,e)=>{let n=e.length;if(we(t))return Ut;const i=t.state,r=i.wrap;if(2===r||1===r&&i.status!==Jt||i.lookahead)return Ut;if(1===r&&(t.adler=It(t.adler,e,n,0)),i.wrap=0,n>=i.w_size){0===r&&(ie(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(n-i.w_size,n),0),e=t,n=i.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,ue(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=se(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,ue(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,i.wrap=r,Ft};const Ee=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Re=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)Ee(n,e)&&(t[e]=n[e])}}return t},Me=t=>{let e=0;for(let n=0,i=t.length;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,i=0,r=t.length;e<r;e++){let r=t[e];n.set(r,i),i+=r.length}return n};let Te=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Te=!1}const ze=new Uint8Array(256);for(let t=0;t<256;t++)ze[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;ze[254]=ze[254]=1;var Oe=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,i,r,s,o=t.length,a=0;for(r=0;r<o;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),s=0,r=0;s<a;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?e[s++]=n:n<2048?(e[s++]=192|n>>>6,e[s++]=128|63&n):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|63&n):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|63&n);return e},Ne=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,r;const s=new Array(2*n);for(r=0,i=0;i<n;){let e=t[i++];if(e<128){s[r++]=e;continue}let o=ze[e];if(o>4)s[r++]=65533,i+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&i<n;)e=e<<6|63&t[i++],o--;o>1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Te)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let i=0;i<e;i++)n+=String.fromCharCode(t[i]);return n})(s,r)},De=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+ze[t[n]]>e?n:e},Le=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Fe=Object.prototype.toString,{Z_NO_FLUSH:Be,Z_SYNC_FLUSH:Ue,Z_FULL_FLUSH:Ze,Z_FINISH:We,Z_OK:Pe,Z_STREAM_END:Ve,Z_DEFAULT_COMPRESSION:Ge,Z_DEFAULT_STRATEGY:He,Z_DEFLATED:je}=xt;function qe(t){this.options=Re({level:Ge,method:je,chunkSize:16384,windowBits:15,memLevel:8,strategy:He},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Le,this.strm.avail_out=0;let n=_e(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==Pe)throw new Error(kt[n]);if(e.header&&Se(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?Oe(e.dictionary):"[object ArrayBuffer]"===Fe.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=Ae(this.strm,t),n!==Pe)throw new Error(kt[n]);this._dict_set=!0}}function Ke(t,e){const n=new qe(e);if(n.push(t,!0),n.err)throw n.msg||kt[n.err];return n.result}qe.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?We:Be,"string"==typeof t?n.input=Oe(t):"[object ArrayBuffer]"===Fe.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(s===Ue||s===Ze)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=ke(n,s),r===Ve)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=xe(this.strm),this.onEnd(r),this.ended=!0,r===Pe;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},qe.prototype.onData=function(t){this.chunks.push(t)},qe.prototype.onEnd=function(t){t===Pe&&(this.result=Me(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var $e={Deflate:qe,deflate:Ke,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Ke(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Ke(t,e)},constants:xt};const Ye=16209;var Qe=function(t,e){let n,i,r,s,o,a,l,c,d,h,u,g,p,m,f,y,b,w,v,C,I,_,S,k;const x=t.state;n=t.next_in,S=t.input,i=n+(t.avail_in-5),r=t.next_out,k=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=x.dmax,l=x.wsize,c=x.whave,d=x.wnext,h=x.window,u=x.hold,g=x.bits,p=x.lencode,m=x.distcode,f=(1<<x.lenbits)-1,y=(1<<x.distbits)-1;t:do{g<15&&(u+=S[n++]<<g,g+=8,u+=S[n++]<<g,g+=8),b=p[u&f];e:for(;;){if(w=b>>>24,u>>>=w,g-=w,w=b>>>16&255,0===w)k[r++]=65535&b;else{if(!(16&w)){if(64&w){if(32&w){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=Ye;break t}b=p[(65535&b)+(u&(1<<w)-1)];continue e}for(v=65535&b,w&=15,w&&(g<w&&(u+=S[n++]<<g,g+=8),v+=u&(1<<w)-1,u>>>=w,g-=w),g<15&&(u+=S[n++]<<g,g+=8,u+=S[n++]<<g,g+=8),b=m[u&y];;){if(w=b>>>24,u>>>=w,g-=w,w=b>>>16&255,16&w){if(C=65535&b,w&=15,g<w&&(u+=S[n++]<<g,g+=8,g<w&&(u+=S[n++]<<g,g+=8)),C+=u&(1<<w)-1,C>a){t.msg="invalid distance too far back",x.mode=Ye;break t}if(u>>>=w,g-=w,w=r-s,C>w){if(w=C-w,w>c&&x.sane){t.msg="invalid distance too far back",x.mode=Ye;break t}if(I=0,_=h,0===d){if(I+=l-w,w<v){v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}}else if(d<w){if(I+=l+d-w,w-=d,w<v){v-=w;do{k[r++]=h[I++]}while(--w);if(I=0,d<v){w=d,v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}}}else if(I+=d-w,w<v){v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}for(;v>2;)k[r++]=_[I++],k[r++]=_[I++],k[r++]=_[I++],v-=3;v&&(k[r++]=_[I++],v>1&&(k[r++]=_[I++]))}else{I=r-C;do{k[r++]=k[I++],k[r++]=k[I++],k[r++]=k[I++],v-=3}while(v>2);v&&(k[r++]=k[I++],v>1&&(k[r++]=k[I++]))}break}if(64&w){t.msg="invalid distance code",x.mode=Ye;break t}b=m[(65535&b)+(u&(1<<w)-1)]}}break}}while(n<i&&r<o);v=g>>3,n-=v,g-=v<<3,u&=(1<<g)-1,t.next_in=n,t.next_out=r,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=r<o?o-r+257:257-(r-o),x.hold=u,x.bits=g};const Je=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Xe=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),tn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),en=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var nn=(t,e,n,i,r,s,o,a)=>{const l=a.bits;let c,d,h,u,g,p,m=0,f=0,y=0,b=0,w=0,v=0,C=0,I=0,_=0,S=0,k=null;const x=new Uint16Array(16),A=new Uint16Array(16);let E,R,M,T=null;for(m=0;m<=15;m++)x[m]=0;for(f=0;f<i;f++)x[e[n+f]]++;for(w=l,b=15;b>=1&&0===x[b];b--);if(w>b&&(w=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(y=1;y<b&&0===x[y];y++);for(w<y&&(w=y),I=1,m=1;m<=15;m++)if(I<<=1,I-=x[m],I<0)return-1;if(I>0&&(0===t||1!==b))return-1;for(A[1]=0,m=1;m<15;m++)A[m+1]=A[m]+x[m];for(f=0;f<i;f++)0!==e[n+f]&&(o[A[e[n+f]]++]=f);if(0===t?(k=T=o,p=20):1===t?(k=Je,T=Xe,p=257):(k=tn,T=en,p=0),S=0,f=0,m=y,g=s,v=w,C=0,h=-1,_=1<<w,u=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){E=m-C,o[f]+1<p?(R=0,M=o[f]):o[f]>=p?(R=T[o[f]-p],M=k[o[f]-p]):(R=96,M=0),c=1<<m-C,d=1<<v,y=d;do{d-=c,r[g+(S>>C)+d]=E<<24|R<<16|M}while(0!==d);for(c=1<<m-1;S&c;)c>>=1;if(0!==c?(S&=c-1,S+=c):S=0,f++,0===--x[m]){if(m===b)break;m=e[n+o[f]]}if(m>w&&(S&u)!==h){for(0===C&&(C=w),g+=y,v=m-C,I=1<<v;v+C<b&&(I-=x[v+C],!(I<=0));)v++,I<<=1;if(_+=1<<v,1===t&&_>852||2===t&&_>592)return 1;h=S&u,r[h]=w<<24|v<<16|g-s}}return 0!==S&&(r[g+S]=m-C<<24|64<<16),a.bits=w,0};const{Z_FINISH:rn,Z_BLOCK:sn,Z_TREES:on,Z_OK:an,Z_STREAM_END:ln,Z_NEED_DICT:cn,Z_STREAM_ERROR:dn,Z_DATA_ERROR:hn,Z_MEM_ERROR:un,Z_BUF_ERROR:gn,Z_DEFLATED:pn}=xt,mn=16180,fn=16190,yn=16191,bn=16192,wn=16194,vn=16199,Cn=16200,In=16206,_n=16209,Sn=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function kn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const xn=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<mn||e.mode>16211?1:0},An=t=>{if(xn(t))return dn;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=mn,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,an},En=t=>{if(xn(t))return dn;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,An(t)},Rn=(t,e)=>{let n;if(xn(t))return dn;const i=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?dn:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,En(t))},Mn=(t,e)=>{if(!t)return dn;const n=new kn;t.state=n,n.strm=t,n.window=null,n.mode=mn;const i=Rn(t,e);return i!==an&&(t.state=null),i};let Tn,zn,On=!0;const Nn=t=>{if(On){Tn=new Int32Array(512),zn=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(nn(1,t.lens,0,288,Tn,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;nn(2,t.lens,0,32,zn,0,t.work,{bits:5}),On=!1}t.lencode=Tn,t.lenbits=9,t.distcode=zn,t.distbits=5},Dn=(t,e,n,i)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(e.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(e.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var Ln=En,Fn=Mn,Bn=(t,e)=>{let n,i,r,s,o,a,l,c,d,h,u,g,p,m,f,y,b,w,v,C,I,_,S=0;const k=new Uint8Array(4);let x,A;const E=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(xn(t)||!t.output||!t.input&&0!==t.avail_in)return dn;n=t.state,n.mode===yn&&(n.mode=bn),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,h=a,u=l,_=an;t:for(;;)switch(n.mode){case mn:if(0===n.wrap){n.mode=bn;break}for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(2&n.wrap&&35615===c){0===n.wbits&&(n.wbits=15),n.check=0,k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0),c=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",n.mode=_n;break}if((15&c)!==pn){t.msg="unknown compression method",n.mode=_n;break}if(c>>>=4,d-=4,I=8+(15&c),0===n.wbits&&(n.wbits=I),I>15||I>n.wbits){t.msg="invalid window size",n.mode=_n;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&c?16189:yn,c=0,d=0;break;case 16181:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.flags=c,(255&n.flags)!==pn){t.msg="unknown compression method",n.mode=_n;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=_n;break}n.head&&(n.head.text=c>>8&1),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0)),c=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.time=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,k[2]=c>>>16&255,k[3]=c>>>24&255,n.check=St(n.check,k,4,0)),c=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.xflags=255&c,n.head.os=c>>8),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0)),c=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(g=n.length,g>a&&(g=a),g&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(s,s+g),I)),512&n.flags&&4&n.wrap&&(n.check=St(n.check,i,g,s)),a-=g,s+=g,n.length-=g),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break t;g=0;do{I=i[s+g++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I))}while(I&&g<a);if(512&n.flags&&4&n.wrap&&(n.check=St(n.check,i,g,s)),a-=g,s+=g,I)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===a)break t;g=0;do{I=i[s+g++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I))}while(I&&g<a);if(512&n.flags&&4&n.wrap&&(n.check=St(n.check,i,g,s)),a-=g,s+=g,I)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(65535&n.check)){t.msg="header crc mismatch",n.mode=_n;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=yn;break;case 16189:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}t.adler=n.check=Sn(c),c=0,d=0,n.mode=fn;case fn:if(0===n.havedict)return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,cn;t.adler=n.check=1,n.mode=yn;case yn:if(e===sn||e===on)break t;case bn:if(n.last){c>>>=7&d,d-=7&d,n.mode=In;break}for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}switch(n.last=1&c,c>>>=1,d-=1,3&c){case 0:n.mode=16193;break;case 1:if(Nn(n),n.mode=vn,e===on){c>>>=2,d-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=_n}c>>>=2,d-=2;break;case 16193:for(c>>>=7&d,d-=7&d;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",n.mode=_n;break}if(n.length=65535&c,c=0,d=0,n.mode=wn,e===on)break t;case wn:n.mode=16195;case 16195:if(g=n.length,g){if(g>a&&(g=a),g>l&&(g=l),0===g)break t;r.set(i.subarray(s,s+g),o),a-=g,s+=g,l-=g,o+=g,n.length-=g;break}n.mode=yn;break;case 16196:for(;d<14;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.nlen=257+(31&c),c>>>=5,d-=5,n.ndist=1+(31&c),c>>>=5,d-=5,n.ncode=4+(15&c),c>>>=4,d-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=_n;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.lens[E[n.have++]]=7&c,c>>>=3,d-=3}for(;n.have<19;)n.lens[E[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},_=nn(0,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,_){t.msg="invalid code lengths set",n.mode=_n;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;S=n.lencode[c&(1<<n.lenbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(b<16)c>>>=f,d-=f,n.lens[n.have++]=b;else{if(16===b){for(A=f+2;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(c>>>=f,d-=f,0===n.have){t.msg="invalid bit length repeat",n.mode=_n;break}I=n.lens[n.have-1],g=3+(3&c),c>>>=2,d-=2}else if(17===b){for(A=f+3;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,I=0,g=3+(7&c),c>>>=3,d-=3}else{for(A=f+7;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,I=0,g=11+(127&c),c>>>=7,d-=7}if(n.have+g>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=_n;break}for(;g--;)n.lens[n.have++]=I}}if(n.mode===_n)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=_n;break}if(n.lenbits=9,x={bits:n.lenbits},_=nn(1,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,_){t.msg="invalid literal/lengths set",n.mode=_n;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},_=nn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,_){t.msg="invalid distances set",n.mode=_n;break}if(n.mode=vn,e===on)break t;case vn:n.mode=Cn;case Cn:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,Qe(t,u),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,n.mode===yn&&(n.back=-1);break}for(n.back=0;S=n.lencode[c&(1<<n.lenbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(y&&!(240&y)){for(w=f,v=y,C=b;S=n.lencode[C+((c&(1<<w+v)-1)>>w)],f=S>>>24,y=S>>>16&255,b=65535&S,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,n.length=b,0===y){n.mode=16205;break}if(32&y){n.back=-1,n.mode=yn;break}if(64&y){t.msg="invalid literal/length code",n.mode=_n;break}n.extra=15&y,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;S=n.distcode[c&(1<<n.distbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(!(240&y)){for(w=f,v=y,C=b;S=n.distcode[C+((c&(1<<w+v)-1)>>w)],f=S>>>24,y=S>>>16&255,b=65535&S,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,64&y){t.msg="invalid distance code",n.mode=_n;break}n.offset=b,n.extra=15&y,n.mode=16203;case 16203:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=_n;break}n.mode=16204;case 16204:if(0===l)break t;if(g=u-l,n.offset>g){if(g=n.offset-g,g>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=_n;break}g>n.wnext?(g-=n.wnext,p=n.wsize-g):p=n.wnext-g,g>n.length&&(g=n.length),m=n.window}else m=r,p=o-n.offset,g=n.length;g>l&&(g=l),l-=g,n.length-=g;do{r[o++]=m[p++]}while(--g);0===n.length&&(n.mode=Cn);break;case 16205:if(0===l)break t;r[o++]=n.length,l--,n.mode=Cn;break;case In:if(n.wrap){for(;d<32;){if(0===a)break t;a--,c|=i[s++]<<d,d+=8}if(u-=l,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?St(n.check,r,u,o-u):It(n.check,r,u,o-u)),u=l,4&n.wrap&&(n.flags?c:Sn(c))!==n.check){t.msg="incorrect data check",n.mode=_n;break}c=0,d=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=_n;break}c=0,d=0}n.mode=16208;case 16208:_=ln;break t;case _n:_=hn;break t;case 16210:return un;default:return dn}return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,(n.wsize||u!==t.avail_out&&n.mode<_n&&(n.mode<In||e!==rn))&&Dn(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?St(n.check,r,u,t.next_out-u):It(n.check,r,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===yn?128:0)+(n.mode===vn||n.mode===wn?256:0),(0===h&&0===u||e===rn)&&_===an&&(_=gn),_},Un=t=>{if(xn(t))return dn;let e=t.state;return e.window&&(e.window=null),t.state=null,an},Zn=(t,e)=>{if(xn(t))return dn;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,an):dn},Wn=(t,e)=>{const n=e.length;let i,r,s;return xn(t)?dn:(i=t.state,0!==i.wrap&&i.mode!==fn?dn:i.mode===fn&&(r=1,r=It(r,e,n,0),r!==i.check)?hn:(s=Dn(t,e,n,n),s?(i.mode=16210,un):(i.havedict=1,an)))},Pn=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Vn=Object.prototype.toString,{Z_NO_FLUSH:Gn,Z_FINISH:Hn,Z_OK:jn,Z_STREAM_END:qn,Z_NEED_DICT:Kn,Z_STREAM_ERROR:$n,Z_DATA_ERROR:Yn,Z_MEM_ERROR:Qn}=xt;function Jn(t){this.options=Re({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Le,this.strm.avail_out=0;let n=Fn(this.strm,e.windowBits);if(n!==jn)throw new Error(kt[n]);if(this.header=new Pn,Zn(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=Oe(e.dictionary):"[object ArrayBuffer]"===Vn.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Wn(this.strm,e.dictionary),n!==jn)))throw new Error(kt[n])}function Xn(t,e){const n=new Jn(e);if(n.push(t),n.err)throw n.msg||kt[n.err];return n.result}Jn.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?Hn:Gn,"[object ArrayBuffer]"===Vn.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),s=Bn(n,o),s===Kn&&r&&(s=Wn(n,r),s===jn?s=Bn(n,o):s===Yn&&(s=Kn));n.avail_in>0&&s===qn&&n.state.wrap>0&&0!==t[n.next_in];)Ln(n),s=Bn(n,o);switch(s){case $n:case Yn:case Kn:case Qn:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===qn))if("string"===this.options.to){let t=De(n.output,n.next_out),e=n.next_out-t,r=Ne(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==jn||0!==a){if(s===qn)return s=Un(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Jn.prototype.onData=function(t){this.chunks.push(t)},Jn.prototype.onEnd=function(t){t===jn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Me(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ti={Inflate:Jn,inflate:Xn,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Xn(t,e)},ungzip:Xn,constants:xt};const{Deflate:ei,deflate:ni,deflateRaw:ii,gzip:ri}=$e,{Inflate:si,inflate:oi,inflateRaw:ai,ungzip:li}=ti;var ci={Deflate:ei,deflate:ni,deflateRaw:ii,gzip:ri,Inflate:si,inflate:oi,inflateRaw:ai,ungzip:li,constants:xt};const di=Z();let hi=null,ui=null;function gi(){return hi||(hi=new TextEncoder),hi}function pi(t){return"string"==typeof t?t:JSON.stringify(t)}function mi(){return"undefined"!=typeof document&&"undefined"!=typeof Image&&"undefined"!=typeof HTMLCanvasElement}class fi extends P{constructor(t={}){super(t)}getErrorPlaceholder(){var t;return null!==(t=this.options.errorPlaceholder)&&void 0!==t?t:"SCREENSHOT_FAILED"}shouldIncludeNode(t){if(!("hasAttribute"in t))return!0;const e=t,n=this.options.excludeAttribute||"data-bugspotter-exclude";return!e.hasAttribute(n)}buildCaptureOptions(){var t,e,n,i;return Object.assign(Object.assign(Object.assign({quality:null!==(t=this.options.quality)&&void 0!==t?t:.8,cacheBust:null===(e=this.options.cacheBust)||void 0===e||e,pixelRatio:null!==(n=this.options.pixelRatio)&&void 0!==n?n:window.devicePixelRatio,backgroundColor:null!==(i=this.options.backgroundColor)&&void 0!==i?i:"#ffffff"},this.options.width&&{width:this.options.width}),this.options.height&&{height:this.options.height}),{filter:t=>this.shouldIncludeNode(t)})}async capture(t){try{const e=t||this.options.targetElement||document.body,n=this.buildCaptureOptions(),i=await async function(t,e={}){return(await async function(t,e={}){const{width:n,height:i}=a(t,e),r=await F(t,e),s=await c(r),o=document.createElement("canvas"),d=o.getContext("2d"),h=e.pixelRatio||function(){let t,e;try{e=process}catch(t){}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),u=e.canvasWidth||n,g=e.canvasHeight||i;return o.width=u*h,o.height=g*h,e.skipAutoScale||function(t){(t.width>l||t.height>l)&&(t.width>l&&t.height>l?t.width>t.height?(t.height*=l/t.width,t.width=l):(t.width*=l/t.height,t.height=l):t.width>l?(t.height*=l/t.width,t.width=l):(t.width*=l/t.height,t.height=l))}(o),o.style.width=`${u}`,o.style.height=`${g}`,e.backgroundColor&&(d.fillStyle=e.backgroundColor,d.fillRect(0,0,o.width,o.height)),d.drawImage(s,0,0,o.width,o.height),o}(t,e)).toDataURL()}(e,n);return await async function(t,e){var n,i,r,s;try{if(!mi())return t;const o=null!==(n=null==e?void 0:e.imageMaxWidth)&&void 0!==n?n:1920,a=null!==(i=null==e?void 0:e.imageMaxHeight)&&void 0!==i?i:1080,l=null!==(r=null==e?void 0:e.webpQuality)&&void 0!==r?r:.8,c=null!==(s=null==e?void 0:e.jpegQuality)&&void 0!==s?s:.85,d=3e3,h=await function(t,e){return new Promise((n,i)=>{const r=new Image,s=setTimeout(()=>{i(new Error(`Image load timeout after ${e}ms`))},e);r.onload=()=>{clearTimeout(s),n(r)},r.onerror=()=>{clearTimeout(s),i(new Error("Failed to load image"))},r.src=t})}(t,d),u=document.createElement("canvas"),g=u.getContext("2d");if(!g)throw new Error("Failed to get 2D canvas context");const{width:p,height:m}=function(t,e,n,i){let r=t,s=e;return r>n&&(s=s*n/r,r=n),s>i&&(r=r*i/s,s=i),{width:r,height:s}}(h.width,h.height,o,a);return u.width=p,u.height=m,g.drawImage(h,0,0,p,m),function(){if(null!==ui)return ui;if(!mi())return ui=!1,!1;try{const t=document.createElement("canvas");ui=0===t.toDataURL("image/webp").indexOf("data:image/webp")}catch(t){ui=!1}return ui}()?u.toDataURL("image/webp",l):u.toDataURL("image/jpeg",c)}catch(n){return!1!==(null==e?void 0:e.verbose)&&Z().error("Image compression failed:",n),t}}(i)}catch(t){return this.handleError("capturing screenshot",t),this.getErrorPlaceholder()}}}class yi{constructor(t){if(this.maxSize=t,this.items=[],this.index=0,this.count=0,t<=0)throw new Error("CircularBuffer maxSize must be greater than 0")}add(t){this.count<this.maxSize?(this.items.push(t),this.count++):this.items[this.index]=t,this.index=(this.index+1)%this.maxSize}getAll(){return this.count<this.maxSize?[...this.items]:[...this.items.slice(this.index),...this.items.slice(0,this.index)]}clear(){this.items=[],this.index=0,this.count=0}get size(){return this.count}get capacity(){return this.maxSize}get isEmpty(){return 0===this.count}get isFull(){return this.count>=this.maxSize}}const bi=["log","warn","error","info","debug"];class wi extends P{constructor(t={}){var e,n,i;super(t),this.originalMethods=new Map;const r=null!==(e=t.maxLogs)&&void 0!==e?e:100;this.buffer=new yi(r),this.captureStackTrace=null===(n=t.captureStackTrace)||void 0===n||n,this.interceptConsole(null!==(i=t.levels)&&void 0!==i?i:bi)}capture(){return this.getLogs()}formatMessage(t){return t&&0!==t.length?(this.sanitizer?this.sanitizer.sanitizeConsoleArgs(t):t).map(t=>{var e;if(null===t)return"null";if(void 0===t)return"undefined";if("object"==typeof t)try{return JSON.stringify(t)}catch(n){return`[${(null===(e=t.constructor)||void 0===e?void 0:e.name)||"Object"}]`}return String(t)}).join(" "):""}createLogEntry(t,e){const n={level:t,message:this.formatMessage(e),timestamp:Date.now()};if(this.captureStackTrace&&"error"===t){const t=this.captureStack();n.stack=this.sanitizer&&t?this.sanitizer.sanitize(t):t}return n}captureStack(){const t=(new Error).stack;return null==t?void 0:t.split("\n").slice(3).join("\n")}addLog(t){this.buffer.add(t)}interceptConsole(t=bi){t.forEach(t=>{try{const e=console[t];this.originalMethods.set(t,e),console[t]=(...n)=>{try{const e=this.createLogEntry(t,n);this.addLog(e)}catch(t){this.handleError("creating log entry",t)}e.apply(console,n)}}catch(e){this.handleError(`intercepting console.${t}`,e)}})}getLogs(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){try{this.originalMethods.forEach((t,e)=>{console[e]=t}),this.originalMethods.clear()}catch(t){this.handleError("destroying console capture",t)}}}class vi extends P{constructor(t={}){var e;super(t),this.isIntercepting=!1;const n=null!==(e=t.maxRequests)&&void 0!==e?e:50;this.buffer=new yi(n),this.filterUrls=t.filterUrls,this.originalFetch=window.fetch,this.originalXHR={open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send},this.interceptFetch(),this.interceptXHR(),this.isIntercepting=!0}capture(){return this.getRequests()}parseFetchArgs(t){const[e,n]=t;let i,r="GET";return"string"==typeof e?i=e:e instanceof Request?(i=e.url,r=e.method.toUpperCase()||"GET"):i=e.toString(),(null==n?void 0:n.method)&&(r=n.method.toUpperCase()),{url:i,method:r}}createNetworkRequest(t,e,n,i,r){const s=Object.assign({url:t,method:e,status:n,duration:Date.now()-i,timestamp:i},r&&{error:r});if(this.sanitizer){const t=this.sanitizer.sanitizeNetworkData(Object.assign({url:s.url,method:s.method,status:s.status},s.error&&{error:s.error}));return Object.assign(Object.assign({},s),{url:t.url||s.url,error:t.error})}return s}addRequest(t){this.filterUrls&&!this.filterUrls(t.url)||this.buffer.add(t)}interceptFetch(){const t=this.originalFetch;window.fetch=async(...e)=>{const n=Date.now();let i="",r="GET";try{({url:i,method:r}=this.parseFetchArgs(e))}catch(t){this.handleError("parsing fetch arguments",t)}try{const s=await t(...e),o=this.createNetworkRequest(i,r,s.status,n);return this.addRequest(o),s}catch(t){const e=this.createNetworkRequest(i,r,0,n,t.message);throw this.addRequest(e),t}}}interceptXHR(){const t=this.originalXHR.open,e=this.originalXHR.send,n=this.createNetworkRequest.bind(this),i=this.addRequest.bind(this);XMLHttpRequest.prototype.open=function(e,n,...i){return this._method=e.toUpperCase(),this._url=n.toString(),this._startTime=Date.now(),t.apply(this,[e,n,...i])},XMLHttpRequest.prototype.send=function(...t){return this.addEventListener("load",()=>{const t=n(this._url||"",this._method||"GET",this.status,this._startTime||Date.now());i(t)}),this.addEventListener("error",()=>{const t=n(this._url||"",this._method||"GET",0,this._startTime||Date.now(),"XMLHttpRequest failed");i(t)}),e.apply(this,t)}}getRequests(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){if(this.isIntercepting)try{window.fetch=this.originalFetch,XMLHttpRequest.prototype.open=this.originalXHR.open,XMLHttpRequest.prototype.send=this.originalXHR.send,this.isIntercepting=!1}catch(t){this.handleError("destroying network capture",t)}}}class Ci extends P{constructor(t={}){super(t),this.browserPatterns=[{pattern:"Edg",name:"Edge"},{pattern:"Chrome",exclude:"Edge",name:"Chrome"},{pattern:"Firefox",name:"Firefox"},{pattern:"Safari",exclude:"Chrome",name:"Safari"}],this.osPatterns=[{patterns:["iPhone","iPad"],name:"iOS"},{patterns:["Android"],name:"Android"},{patterns:["Win"],name:"Windows"},{patterns:["Mac"],name:"macOS"},{patterns:["Linux"],name:"Linux"}]}capture(){try{const t={userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},browser:this.detectBrowser(),os:this.detectOS(),url:window.location.href,timestamp:Date.now()};return this.sanitizer&&(t.url=this.sanitizer.sanitize(t.url),t.userAgent=this.sanitizer.sanitize(t.userAgent)),t}catch(t){return this.handleError("capturing metadata",t),{userAgent:"Unknown",viewport:{width:0,height:0},browser:"Unknown",os:"Unknown",url:"Unknown",timestamp:Date.now()}}}detectBrowser(){const t=navigator.userAgent;for(const{pattern:e,exclude:n,name:i}of this.browserPatterns)if(t.includes(e)&&(!n||!t.includes(n)))return i;return"Unknown"}detectOS(){const t=navigator.userAgent;for(const{patterns:e,name:n}of this.osPatterns)if(e.some(e=>t.includes(e)))return n;return"Unknown"}}const Ii={position:"bottom-right",icon:"🐛",backgroundColor:"#ef4444",size:60,offset:{x:20,y:20},zIndex:999999},_i="0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",Si="0 10px 15px rgba(0, 0, 0, 0.2), 0 4px 6px rgba(0, 0, 0, 0.1)",ki="scale(1)",xi="scale(1.1)",Ai="scale(0.95)";class Ei{constructor(t={}){var e,n,i,r,s,o;this.eventHandlers=new Map,this.handleMouseEnter=()=>{this.button.style.transform=xi,this.button.style.boxShadow=Si},this.handleMouseLeave=()=>{this.button.style.transform=ki,this.button.style.boxShadow=_i},this.handleMouseDown=()=>{this.button.style.transform=Ai},this.handleMouseUp=()=>{this.button.style.transform=xi},this.options={position:null!==(e=t.position)&&void 0!==e?e:Ii.position,icon:null!==(n=t.icon)&&void 0!==n?n:Ii.icon,backgroundColor:null!==(i=t.backgroundColor)&&void 0!==i?i:Ii.backgroundColor,size:null!==(r=t.size)&&void 0!==r?r:Ii.size,offset:null!==(s=t.offset)&&void 0!==s?s:Ii.offset,zIndex:null!==(o=t.zIndex)&&void 0!==o?o:Ii.zIndex},this.button=this.createButton(),document.body?document.body.appendChild(this.button):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.button)})}createButton(){const t=document.createElement("button");return t.textContent=this.options.icon,t.setAttribute("aria-label","Report Bug"),t.setAttribute("data-bugspotter-exclude","true"),t.style.cssText=this.getButtonStyles(),this.addHoverEffects(t),t}getButtonStyles(){const{position:t,size:e,offset:n,backgroundColor:i,zIndex:r}=this.options;return`\n position: fixed;\n ${this.getPositionStyles(t,n)}\n width: ${e}px;\n height: ${e}px;\n border-radius: 50%;\n background: ${i};\n color: white;\n border: none;\n cursor: pointer;\n font-size: ${.5*e}px;\n display: flex;\n align-items: center;\n justify-content: center;\n box-shadow: ${_i};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n z-index: ${r};\n `}getPositionStyles(t,e){switch(t){case"bottom-right":default:return`bottom: ${e.y}px; right: ${e.x}px;`;case"bottom-left":return`bottom: ${e.y}px; left: ${e.x}px;`;case"top-right":return`top: ${e.y}px; right: ${e.x}px;`;case"top-left":return`top: ${e.y}px; left: ${e.x}px;`}}addHoverEffects(t){const e={mouseenter:this.handleMouseEnter,mouseleave:this.handleMouseLeave,mousedown:this.handleMouseDown,mouseup:this.handleMouseUp};Object.entries(e).forEach(([e,n])=>{t.addEventListener(e,n),this.eventHandlers.set(e,n)})}onClick(t){this.button.addEventListener("click",t)}show(){this.button.style.display="flex"}hide(){this.button.style.display="none"}setIcon(t){this.button.textContent=t}setBackgroundColor(t){this.button.style.backgroundColor=t}destroy(){this.eventHandlers.forEach((t,e)=>{this.button.removeEventListener(e,t)}),this.eventHandlers.clear(),this.button.remove()}}class Ri{constructor(t={}){this.config={primaryColor:t.primaryColor||"#007bff",dangerColor:t.dangerColor||"#dc3545",borderRadius:t.borderRadius||"4px",fontFamily:t.fontFamily||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',zIndex:t.zIndex||999999}}generateStyles(){return`\n .overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${this.config.zIndex};\n font-family: ${this.config.fontFamily};\n }\n \n .modal {\n background: white;\n border-radius: 8px;\n width: 90%;\n max-width: 600px;\n max-height: 90vh;\n overflow-y: auto;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n }\n \n .header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n .header h2 {\n margin: 0;\n font-size: 20px;\n font-weight: 600;\n }\n \n .close {\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 30px;\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: ${this.config.borderRadius};\n }\n \n .close:hover {\n background: #f0f0f0;\n }\n \n .body {\n padding: 20px;\n }\n \n .form-group {\n margin-bottom: 20px;\n }\n \n .label {\n display: block;\n margin-bottom: 8px;\n font-weight: 500;\n font-size: 14px;\n }\n \n .input,\n .textarea {\n width: 100%;\n padding: 10px;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n font-size: 14px;\n font-family: ${this.config.fontFamily};\n box-sizing: border-box;\n }\n \n .input:focus,\n .textarea:focus {\n outline: none;\n border-color: ${this.config.primaryColor};\n }\n \n .textarea {\n min-height: 100px;\n resize: vertical;\n }\n \n .screenshot-container {\n margin-top: 10px;\n position: relative;\n }\n \n .screenshot {\n max-width: 100%;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-canvas {\n position: absolute;\n top: 0;\n left: 0;\n cursor: crosshair;\n border: 2px solid ${this.config.primaryColor};\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-controls {\n margin-top: 10px;\n display: flex;\n gap: 10px;\n }\n \n .btn-redact,\n .btn-clear {\n padding: 8px 16px;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n background: white;\n cursor: pointer;\n font-size: 14px;\n }\n \n .btn-redact:hover,\n .btn-clear:hover {\n background: #f5f5f5;\n }\n \n .btn-redact.active {\n background: ${this.config.primaryColor};\n color: white;\n border-color: ${this.config.primaryColor};\n }\n \n .pii-section {\n margin-top: 20px;\n padding: 15px;\n background: #fff3cd;\n border: 1px solid #ffc107;\n border-radius: ${this.config.borderRadius};\n }\n \n .pii-title {\n margin: 0 0 10px 0;\n font-size: 14px;\n font-weight: 600;\n color: #856404;\n }\n \n .pii-list {\n margin: 0;\n padding-left: 20px;\n font-size: 13px;\n color: #856404;\n }\n \n .pii-badge {\n display: inline-block;\n padding: 2px 8px;\n margin: 2px;\n background: #ffc107;\n color: #856404;\n border-radius: 12px;\n font-size: 12px;\n font-weight: 500;\n }\n \n .checkbox-group {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 15px;\n }\n \n .checkbox {\n width: 18px;\n height: 18px;\n cursor: pointer;\n }\n \n .checkbox-label {\n margin: 0;\n font-size: 14px;\n cursor: pointer;\n user-select: none;\n }\n \n .footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n }\n \n .btn {\n padding: 10px 20px;\n border: none;\n border-radius: ${this.config.borderRadius};\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n }\n \n .btn-primary {\n background: ${this.config.primaryColor};\n color: white;\n }\n \n .btn-primary:hover {\n opacity: 0.9;\n }\n \n .btn-primary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .btn-secondary {\n background: #6c757d;\n color: white;\n }\n \n .btn-secondary:hover {\n opacity: 0.9;\n }\n \n .error {\n color: ${this.config.dangerColor};\n font-size: 12px;\n margin-top: 4px;\n }\n `}injectStyles(){const t=document.createElement("style");return t.textContent=this.generateStyles(),document.head.appendChild(t),t}removeStyles(t){t&&t.parentNode&&t.parentNode.removeChild(t)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class Mi{constructor(t={}){this.config={title:t.title||"Report a Bug",titlePlaceholder:t.titlePlaceholder||"Brief description of the issue",descriptionPlaceholder:t.descriptionPlaceholder||"Detailed description of what happened...",submitButtonText:t.submitButtonText||"Submit Bug Report",cancelButtonText:t.cancelButtonText||"Cancel",showScreenshot:!1!==t.showScreenshot}}generateModalHTML(t){return`\n <div class="overlay">\n <div class="modal">\n ${this.generateHeader()}\n ${this.generateBody(t)}\n ${this.generateFooter()}\n </div>\n </div>\n `}generateHeader(){return`\n <div class="header">\n <h2>${this.escapeHtml(this.config.title)}</h2>\n <button class="close" aria-label="Close">&times;</button>\n </div>\n `}generateBody(t){return`\n <div class="body">\n <form class="form">\n ${this.generateTitleField()}\n ${this.generateDescriptionField()}\n ${this.config.showScreenshot&&t?this.generateScreenshotSection(t):""}\n ${this.generatePIISection()}\n </form>\n </div>\n `}generateTitleField(){return`\n <div class="form-group">\n <label class="label" for="title">Title *</label>\n <input\n type="text"\n id="title"\n class="input"\n placeholder="${this.escapeHtml(this.config.titlePlaceholder)}"\n required\n />\n <div class="error" id="title-error"></div>\n </div>\n `}generateDescriptionField(){return`\n <div class="form-group">\n <label class="label" for="description">Description *</label>\n <textarea\n id="description"\n class="textarea"\n placeholder="${this.escapeHtml(this.config.descriptionPlaceholder)}"\n required\n ></textarea>\n <div class="error" id="description-error"></div>\n </div>\n `}generateScreenshotSection(t){return`\n <div class="form-group">\n <label class="label">Screenshot</label>\n <div class="screenshot-container">\n <img \n src="${t}" \n alt="Bug screenshot" \n class="screenshot"\n id="screenshot"\n />\n <canvas \n class="redaction-canvas" \n id="redaction-canvas"\n style="display: none;"\n ></canvas>\n </div>\n <div class="redaction-controls">\n <button \n type="button" \n class="btn-redact" \n id="btn-redact"\n >\n ✏️ Redact Area\n </button>\n <button \n type="button" \n class="btn-clear" \n id="btn-clear"\n >\n 🗑️ Clear Redactions\n </button>\n </div>\n </div>\n `}generatePIISection(){return'\n <div class="pii-section" id="pii-section" style="display: none;">\n <h3 class="pii-title">⚠️ Potential PII Detected</h3>\n <div id="pii-content"></div>\n <div class="checkbox-group">\n <input \n type="checkbox" \n id="pii-confirm" \n class="checkbox"\n />\n <label for="pii-confirm" class="checkbox-label">\n I have reviewed and redacted sensitive information\n </label>\n </div>\n </div>\n '}generateFooter(){return`\n <div class="footer">\n <button type="button" class="btn btn-secondary" id="btn-cancel">\n ${this.escapeHtml(this.config.cancelButtonText)}\n </button>\n <button type="submit" class="btn btn-primary submit" id="btn-submit">\n ${this.escapeHtml(this.config.submitButtonText)}\n </button>\n </div>\n `}generatePIIBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class Ti{constructor(){this.elements=null,this.container=null}initialize(t){this.container=t;const e=this.getRequiredElement(".overlay",t),n=this.getRequiredElement(".modal",e),i=this.getRequiredElement(".form",n);return this.elements={overlay:e,modal:n,closeButton:this.getRequiredElement(".close",n),form:i,titleInput:this.getRequiredElement("#title",i),titleError:this.getRequiredElement("#title-error",i),descriptionTextarea:this.getRequiredElement("#description",i),descriptionError:this.getRequiredElement("#description-error",i),screenshotImg:this.getOptionalElement("#screenshot",n),redactionCanvas:this.getOptionalElement("#redaction-canvas",n),redactButton:this.getOptionalElement("#btn-redact",n),clearButton:this.getOptionalElement("#btn-clear",n),piiSection:this.getRequiredElement("#pii-section",n),piiContent:this.getRequiredElement("#pii-content",n),piiConfirmCheckbox:this.getRequiredElement("#pii-confirm",n),cancelButton:this.getRequiredElement("#btn-cancel",n),submitButton:this.getRequiredElement("#btn-submit",n)},this.elements}get(){if(!this.elements)throw new Error("DOMElementCache not initialized. Call initialize() first.");return this.elements}isInitialized(){return null!==this.elements}clear(){this.elements=null,this.container=null}getRequiredElement(t,e){const n=(e||this.container||document).querySelector(t);if(!n)throw new Error(`Required element not found: ${t}`);return n}getOptionalElement(t,e){return(e||this.container||document).querySelector(t)||void 0}refreshElement(t,e){if(!this.elements||!this.container)throw new Error("DOMElementCache not initialized");const n=this.container.querySelector(e);n&&(this.elements[t]=n)}getContainer(){return this.container}}class zi{constructor(t={}){this.minTitleLength=t.minTitleLength||3,this.maxTitleLength=t.maxTitleLength||200,this.minDescriptionLength=t.minDescriptionLength||10,this.maxDescriptionLength=t.maxDescriptionLength||5e3}validate(t){const e={},n=this.validateTitle(t.title);n&&(e.title=n);const i=this.validateDescription(t.description);return i&&(e.description=i),t.piiDetected&&!t.piiConfirmed&&(e.piiConfirmation="Please confirm you have reviewed sensitive information"),{isValid:0===Object.keys(e).length,errors:e}}validateTitle(t){const e=t.trim();return e?e.length<this.minTitleLength?`Title must be at least ${this.minTitleLength} characters`:e.length>this.maxTitleLength?`Title must not exceed ${this.maxTitleLength} characters`:null:"Title is required"}validateDescription(t){const e=t.trim();return e?e.length<this.minDescriptionLength?`Description must be at least ${this.minDescriptionLength} characters`:e.length>this.maxDescriptionLength?`Description must not exceed ${this.maxDescriptionLength} characters`:null:"Description is required"}validateField(t,e,n){switch(t){case"title":return this.validateTitle(e);case"description":return this.validateDescription(e);case"piiConfirmed":return(null==n?void 0:n.piiDetected)&&!e?"Please confirm you have reviewed sensitive information":null;default:return null}}isEmpty(t){return!t||0===t.trim().length}sanitizeInput(t){return t.trim()}getConfig(){return{minTitleLength:this.minTitleLength,maxTitleLength:this.maxTitleLength,minDescriptionLength:this.minDescriptionLength,maxDescriptionLength:this.maxDescriptionLength}}}class Oi{constructor(t={}){this.config={showExamples:!1!==t.showExamples,groupByType:!1!==t.groupByType,maxExamplesPerType:t.maxExamplesPerType||3}}render(t,e){t&&0!==t.length?this.config.groupByType?e.innerHTML=this.renderGroupedPII(t):e.innerHTML=this.renderListPII(t):e.innerHTML=""}renderGroupedPII(t){const e=this.groupByType(t),n=[];for(const[t,i]of Object.entries(e)){const e=i.reduce((t,e)=>t+e.count,0);n.push(this.createBadge(t,e))}let i=`<div class="bugspotter-pii-badges">${n.join("")}</div>`;if(this.config.showExamples){i+='<div class="bugspotter-pii-details">',i+='<p style="margin: 10px 0 5px 0; font-size: 13px; color: #856404;">Detected types:</p>',i+='<ul class="bugspotter-pii-list">';for(const[t,n]of Object.entries(e)){const e=n.reduce((t,e)=>t+e.count,0);i+=`<li><strong>${this.escapeHtml(t)}:</strong> ${e} occurrence${1!==e?"s":""}</li>`}i+="</ul></div>"}return i}renderListPII(t){let e='<ul class="bugspotter-pii-list">';for(const n of t)e+=`<li>${this.escapeHtml(n.type)}: ${n.count} occurrence${1!==n.count?"s":""}</li>`;return e+="</ul>",e}createBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}groupByType(t){const e={};for(const n of t)e[n.type]||(e[n.type]=[]),e[n.type].push(n);return e}getSummary(t){const e=new Set;for(const n of t)e.add(n.type);return{totalCount:t.length,typeCount:e.size,types:Array.from(e)}}hasType(t,e){return t.some(t=>t.type===e)}filterByType(t,e){return t.filter(t=>t.type===e)}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class Ni{constructor(t,e={}){this.isDrawing=!1,this.isRedactionMode=!1,this.startX=0,this.startY=0,this.redactionRects=[],this.canvas=t;const n=t.getContext("2d");if(!n)throw new Error("Failed to get 2D context from canvas");this.ctx=n,this.config={redactionColor:e.redactionColor||"#000000",cursorStyle:e.cursorStyle||"crosshair"},this.handleMouseDown=this.onMouseDown.bind(this),this.handleMouseMove=this.onMouseMove.bind(this),this.handleMouseUp=this.onMouseUp.bind(this)}initializeCanvas(t){const e=()=>{const e=t.getBoundingClientRect(),n=e.width||t.width,i=e.height||t.height;this.canvas.width=t.naturalWidth||t.width,this.canvas.height=t.naturalHeight||t.height,this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`};t.complete&&t.naturalWidth>0?e():t.addEventListener("load",e,{once:!0})}enableRedactionMode(){this.isRedactionMode||(this.isRedactionMode=!0,this.canvas.style.display="block",this.canvas.style.cursor=this.config.cursorStyle,this.canvas.addEventListener("mousedown",this.handleMouseDown),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseup",this.handleMouseUp),this.redraw())}disableRedactionMode(){this.isRedactionMode&&(this.isRedactionMode=!1,this.isDrawing=!1,this.canvas.removeEventListener("mousedown",this.handleMouseDown),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseup",this.handleMouseUp),this.canvas.style.cursor="default")}toggleRedactionMode(){return this.isRedactionMode?this.disableRedactionMode():this.enableRedactionMode(),this.isRedactionMode}clearRedactions(){this.redactionRects=[],this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getRedactions(){return[...this.redactionRects]}setRedactions(t){this.redactionRects=[...t],this.redraw()}isActive(){return this.isRedactionMode}getCanvas(){return this.canvas}toDataURL(t="image/png",e){return this.canvas.toDataURL(t,e)}hide(){this.canvas.style.display="none"}show(){this.canvas.style.display="block"}destroy(){this.disableRedactionMode(),this.clearRedactions()}onMouseDown(t){if(!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.startX=(t.clientX-e.left)*n,this.startY=(t.clientY-e.top)*i,this.isDrawing=!0}onMouseMove(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i;this.redraw(),this.drawRect(this.startX,this.startY,r-this.startX,s-this.startY)}onMouseUp(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i,o=r-this.startX,a=s-this.startY;Math.abs(o)>5&&Math.abs(a)>5&&this.redactionRects.push({x:this.startX,y:this.startY,width:o,height:a}),this.isDrawing=!1,this.redraw()}redraw(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.redactionRects)this.drawRect(t.x,t.y,t.width,t.height)}drawRect(t,e,n,i){this.ctx.fillStyle=this.config.redactionColor,this.ctx.fillRect(t,e,n,i)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t),this.isRedactionMode&&(this.canvas.style.cursor=this.config.cursorStyle)}getConfig(){return Object.assign({},this.config)}}class Di{async mergeRedactions(t,e){return new Promise((n,i)=>{const r=new Image;r.onload=()=>{try{const t=document.createElement("canvas");t.width=r.naturalWidth||r.width,t.height=r.naturalHeight||r.height;const s=t.getContext("2d");if(!s)return void i(new Error("Failed to get canvas context"));s.drawImage(r,0,0),s.drawImage(e,0,0),n(t.toDataURL())}catch(t){i(t)}},r.onerror=()=>{i(new Error("Failed to load screenshot image"))},r.src=t})}async applyRedactions(t,e,n="#000000"){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),o.fillStyle=n;for(const t of e)o.fillRect(t.x,t.y,t.width,t.height);i(t.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async resize(t,e,n){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{let t=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(t>e||o>n){const i=t/o;t>o?(t=e,o=t/i):(o=n,t=o*i)}const a=document.createElement("canvas");a.width=t,a.height=o;const l=a.getContext("2d");if(!l)return void r(new Error("Failed to get canvas context"));l.drawImage(s,0,0,t,o),i(a.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async convert(t,e,n=.92){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),i(t.toDataURL(e,n))}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async getDimensions(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{e({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height})},i.onerror=()=>{n(new Error("Failed to load image"))},i.src=t})}isValidDataURL(t){return/^data:image\/(png|jpeg|jpg|webp|gif);base64,/.test(t)}getEstimatedSize(t){const e=t.split(",")[1]||"";return Math.ceil(3*e.length/4)}getFormat(t){const e=t.match(/^data:image\/([a-z]+);base64,/);return e?e[1]:null}}const Li={email:{name:"email",regex:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,description:"Email addresses",examples:["user@example.com","john.doe+tag@company.co.uk","test_user@sub.domain.com"],priority:1},creditcard:{name:"creditcard",regex:/\b(?:\d{4}[-\s]){3}\d{4}\b|\b\d{4}[-\s]\d{6}[-\s]\d{5}\b|\b\d{13,19}\b/g,description:"Credit card numbers (Visa, MC, Amex, Discover, etc.)",examples:["4532-1488-0343-6467","4532148803436467","5425 2334 3010 9903","3782 822463 10005"],priority:2},ssn:{name:"ssn",regex:/\b\d{3}-\d{2}-\d{4}\b|\b(?<!\d)\d{9}(?!\d)\b/g,description:"US Social Security Numbers",examples:["123-45-6789","987654321"],priority:3},iin:{name:"iin",regex:/\b[0-9]{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])\d{6}\b/g,description:"Kazakhstan IIN/BIN (12 digits with date validation)",examples:["950315300123","880612500456","021225123456"],priority:4},ip:{name:"ip",regex:/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b/g,description:"IPv4 and IPv6 addresses",examples:["192.168.1.100","127.0.0.1","2001:0db8:85a3:0000:0000:8a2e:0370:7334"],priority:5},phone:{name:"phone",regex:/\+\d{1,3}[-.\s]\d{3}[-.\s]\d{4}\b|\+\d{1,3}[-.\s]\d{3}[-.\s]\d{3}[-.\s]\d{4}\b|\(\d{3}\)\s*\d{3}[-.\s]\d{4}\b|\b\d{3}[-.\s]\d{3}[-.\s]\d{4}\b/g,description:"International phone numbers",examples:["+1-555-1234","+1-555-123-4567","(555) 123-4567","555-123-4567","+7 777 123 4567"],priority:6},apikey:{name:"apikey",regex:/\b(?:sk|pk)_(?:live|test)_[a-zA-Z0-9]{24,}\b|AIza[a-zA-Z0-9_-]{35}|ya29\.[a-zA-Z0-9_-]+|AKIA[a-zA-Z0-9]{16}\b/g,description:"API keys (Stripe, Google, AWS, etc.)",examples:["sk_live_abc123def456ghi789jkl","pk_test_xyz789abc123def456","AIzaSyD1234567890abcdefghijklmnopqrst","AKIAIOSFODNN7EXAMPLE"],priority:7},token:{name:"token",regex:/\b(?:Bearer\s+)?[a-zA-Z0-9_-]{32,}\b|ghp_[a-zA-Z0-9]{36}|gho_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9_]{82}/g,description:"Authentication tokens (Bearer, GitHub, JWT-like)",examples:["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9","ghp_abc123def456ghi789jkl012mno345pqr","gho_xyz789abc123def456ghi789jkl012mno"],priority:8},password:{name:"password",regex:/(?:password|passwd|pwd)[\s:=]+[^\s]{6,}|(?:password|passwd|pwd)["']?\s*[:=]\s*["']?[^\s"']{6,}/gi,description:"Password fields in text (password=..., pwd:...)",examples:["password: MySecret123!","passwd=SecurePass456",'pwd: "MyP@ssw0rd"'],priority:9}},Fi={financial:["creditcard","ssn"],contact:["email","phone"],identification:["ssn","iin"],network:["ip","email"],credentials:["apikey","token","password"],kazakhstan:["iin"]};const Bi={all:Object.keys(Li),minimal:["email","creditcard","ssn"],financial:Fi.financial,contact:Fi.contact,identification:Fi.identification,credentials:Fi.credentials,kazakhstan:["email","phone","iin"],gdpr:["email","phone","ip"],pci:["creditcard"],security:["email","phone","creditcard","ssn","apikey","token","password"]};class Ui{constructor(t,e){this.patterns=new Map,this.initializePatterns(t,e)}initializePatterns(t,e){let n;var i;n="string"==typeof t?Bi[t]:t.filter(t=>"custom"!==t),(i=n.map(t=>Li[t]),[...i].sort((t,e)=>t.priority-e.priority)).forEach(t=>{this.patterns.set(t.name,t.regex)}),e.forEach(t=>{this.patterns.set(t.name,t.regex)})}getPatterns(){return this.patterns}}class Zi{constructor(t){this.patterns=t}sanitize(t){if("string"!=typeof t)return t;let e=t;return this.patterns.forEach((t,n)=>{const i=n.toUpperCase();e=e.replace(t,`[REDACTED-${i}]`)}),e}}class Wi{constructor(t){this.stringSanitizer=t}sanitize(t){return null==t?t:"string"==typeof t?this.stringSanitizer.sanitize(t):Array.isArray(t)?t.map(t=>this.sanitize(t)):"object"==typeof t?this.sanitizeObject(t):t}sanitizeObject(t){const e={};for(const[n,i]of Object.entries(t))e[this.stringSanitizer.sanitize(n)]=this.sanitize(i);return e}}class Pi{constructor(t){this.excludeSelectors=t}shouldExclude(t){return!(!t||!this.excludeSelectors.length)&&this.excludeSelectors.some(e=>{try{return t.matches(e)}catch(t){return!1}})}}class Vi{constructor(t){var e,n,i,r;if(this.enabled=null===(e=t.enabled)||void 0===e||e,!this.enabled)return this.stringSanitizer=new Zi(new Map),this.valueSanitizer=new Wi(this.stringSanitizer),void(this.elementMatcher=new Pi([]));const s=null!==(n=t.patterns)&&void 0!==n?n:"all",o=null!==(i=t.customPatterns)&&void 0!==i?i:[],a=null!==(r=t.excludeSelectors)&&void 0!==r?r:[],l=new Ui(s,o);this.stringSanitizer=new Zi(l.getPatterns()),this.valueSanitizer=new Wi(this.stringSanitizer),this.elementMatcher=new Pi(a)}guardDisabled(t){return this.enabled?void 0:t}sanitize(t){const e=this.guardDisabled(t);return void 0!==e?e:this.valueSanitizer.sanitize(t)}sanitizeConsoleArgs(t){const e=this.guardDisabled(t);return void 0!==e?e:t.map(t=>this.sanitize(t))}sanitizeNetworkData(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}sanitizeError(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}shouldExclude(t){return!!this.enabled&&this.elementMatcher.shouldExclude(t)}sanitizeTextNode(t,e){const n=this.guardDisabled(t);return void 0!==n?n:this.elementMatcher.shouldExclude(e)?t:this.stringSanitizer.sanitize(t)}detectPII(t){const e=new Map;if(!this.enabled||!t)return e;for(const[n,i]of this.stringSanitizer.patterns){const r=t.match(new RegExp(i,"g"));r&&r.length>0&&e.set(n,r.length)}return e}}function Gi(t){return new Vi(t)}const Hi=Z();class ji{constructor(t){this.redactionCanvas=null,this.originalScreenshot="",this.piiDetections=[],this.options=t,this.container=document.createElement("div"),this.shadow=this.container.attachShadow({mode:"open"}),this.styleManager=new Ri,this.templateManager=new Mi,this.domCache=new Ti,this.validator=new zi,this.piiDisplay=new Oi,this.screenshotProcessor=new Di,this.handleEscapeKey=this.onEscapeKey.bind(this)}show(t){t&&(this.originalScreenshot=t),this.shadow.innerHTML=`\n <style>\n ${this.styleManager.generateStyles()}\n </style>\n ${this.templateManager.generateModalHTML(this.originalScreenshot)}\n `,this.domCache.initialize(this.shadow);const e=this.domCache.get();e.titleError.style.display="none",e.descriptionError.style.display="none",this.setupRedactionCanvas(),this.attachEventListeners(),document.body.appendChild(this.container),e.titleInput.focus()}close(){document.removeEventListener("keydown",this.handleEscapeKey),this.redactionCanvas&&(this.redactionCanvas.destroy(),this.redactionCanvas=null),this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.domCache.clear(),this.options.onClose&&this.options.onClose()}destroy(){this.close()}setupRedactionCanvas(){const t=this.domCache.get();if(t.redactionCanvas&&t.screenshotImg)try{this.redactionCanvas=new Ni(t.redactionCanvas),this.redactionCanvas.initializeCanvas(t.screenshotImg)}catch(t){Z().warn("Canvas redaction not available:",t),this.redactionCanvas=null}}attachEventListeners(){const t=this.domCache.get();t.closeButton.addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.handleEscapeKey),t.form.addEventListener("submit",t=>this.handleSubmit(t)),t.submitButton.addEventListener("click",()=>{const e=new Event("submit",{bubbles:!0,cancelable:!0});t.form.dispatchEvent(e)}),t.cancelButton.addEventListener("click",()=>this.close()),t.titleInput.addEventListener("input",()=>this.validateField("title")),t.descriptionTextarea.addEventListener("input",()=>{this.validateField("description"),this.checkForPII()}),t.redactButton&&this.redactionCanvas&&t.redactButton.addEventListener("click",()=>this.toggleRedactionMode()),t.clearButton&&this.redactionCanvas&&t.clearButton.addEventListener("click",()=>this.clearRedactions()),t.piiConfirmCheckbox.addEventListener("change",()=>this.updateSubmitButton())}validateField(t){const e=this.domCache.get(),n="title"===t?e.titleInput.value:e.descriptionTextarea.value,i=this.validator.validateField(t,n),r="title"===t?e.titleError:e.descriptionError;i?(r.textContent=i,r.style.display="block"):(r.textContent="",r.style.display="none")}checkForPII(){const t=this.domCache.get(),e=`${t.titleInput.value} ${t.descriptionTextarea.value}`,n=Gi({enabled:!0}).detectPII(e);this.piiDetections=Array.from(n.entries()).map(([t,e])=>({type:t,count:e})),this.piiDetections.length>0?(t.piiSection.style.display="block",this.piiDisplay.render(this.piiDetections,t.piiContent)):(t.piiSection.style.display="none",t.piiConfirmCheckbox.checked=!1),this.updateSubmitButton()}updateSubmitButton(){const t=this.domCache.get(),e=this.piiDetections.length>0,n=t.piiConfirmCheckbox.checked;t.submitButton.disabled=e&&!n}toggleRedactionMode(){const t=this.domCache.get();this.redactionCanvas&&t.redactButton&&(this.redactionCanvas.toggleRedactionMode()?(t.redactButton.classList.add("active"),t.redactButton.textContent="✓ Redacting..."):(t.redactButton.classList.remove("active"),t.redactButton.textContent="✏️ Redact Area"))}clearRedactions(){this.redactionCanvas&&this.redactionCanvas.clearRedactions()}async handleSubmit(t){t.preventDefault();const e=this.domCache.get(),n={title:e.titleInput.value,description:e.descriptionTextarea.value,piiDetected:this.piiDetections.length>0,piiConfirmed:e.piiConfirmCheckbox.checked},i=this.validator.validate(n);if(!i.isValid)return i.errors.title?(e.titleError.textContent=i.errors.title,e.titleError.style.display="block"):(e.titleError.textContent="",e.titleError.style.display="none"),i.errors.description?(e.descriptionError.textContent=i.errors.description,e.descriptionError.style.display="block"):(e.descriptionError.textContent="",e.descriptionError.style.display="none"),void(i.errors.piiConfirmation&&alert(i.errors.piiConfirmation));e.titleError.style.display="none",e.descriptionError.style.display="none";let r=this.originalScreenshot;if(this.redactionCanvas&&this.redactionCanvas.getRedactions().length>0)try{r=await this.screenshotProcessor.mergeRedactions(this.originalScreenshot,this.redactionCanvas.getCanvas())}catch(t){Hi.error("Failed to merge redactions:",t),r=this.originalScreenshot}this.originalScreenshot=r;const s={title:n.title.trim(),description:n.description.trim()};try{await this.options.onSubmit(s),this.close()}catch(t){Z().error("Error submitting bug report:",t),alert("Failed to submit bug report. Please try again.")}}getScreenshot(){return this.originalScreenshot}onEscapeKey(t){"Escape"===t.key&&this.close()}}var qi;function Ki(t){var e=null==t?void 0:t.host;return Boolean((null==e?void 0:e.shadowRoot)===t)}function $i(t){return"[object ShadowRoot]"===Object.prototype.toString.call(t)}function Yi(t){try{var e=t.rules||t.cssRules;return e?((n=Array.from(e).map(Qi).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(t){return null}var n}function Qi(t){var e=t.cssText;if(function(t){return"styleSheet"in t}(t))try{e=Yi(t.styleSheet)||e}catch(t){}return e}!function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"}(qi||(qi={}));var Ji=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(t){var e;if(!t)return-1;var n=null===(e=this.getMeta(t))||void 0===e?void 0:e.id;return null!=n?n:-1},t.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},t.prototype.removeNodeFromMap=function(t){var e=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(t){return e.removeNodeFromMap(t)})},t.prototype.has=function(t){return this.idNodeMap.has(t)},t.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},t.prototype.add=function(t,e){var n=e.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,e)},t.prototype.replace=function(t,e){var n=this.getNode(t);if(n){var i=this.nodeMetaMap.get(n);i&&this.nodeMetaMap.set(e,i)}this.idNodeMap.set(t,e)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function Xi(t){var e=t.maskInputOptions,n=t.tagName,i=t.type,r=t.value,s=t.maskInputFn,o=r||"";return(e[n.toLowerCase()]||e[i])&&(o=s?s(o):"*".repeat(o.length)),o}var tr,er,nr="__rrweb_original__",ir=1,rr=new RegExp("[^a-z0-9-_:]");function sr(){return ir++}var or=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,ar=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,lr=/^(data:)([^,]*),(.*)/i;function cr(t,e){return(t||"").replace(or,function(t,n,i,r,s,o){var a,l=i||s||o,c=n||r||"";if(!l)return t;if(!ar.test(l))return"url(".concat(c).concat(l).concat(c,")");if(lr.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=e,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var d=e.split("/"),h=l.split("/");d.pop();for(var u=0,g=h;u<g.length;u++){var p=g[u];"."!==p&&(".."===p?d.pop():d.push(p))}return"url(".concat(c).concat(d.join("/")).concat(c,")")})}var dr=/^[^ \t\n\r\u000c]+/,hr=/^[, \t\n\r\u000c]+/;function ur(t,e){if(!e||""===e.trim())return e;var n=t.createElement("a");return n.href=e,n.href}function gr(){var t=document.createElement("a");return t.href="",t.href}function pr(t,e,n,i){return"src"===n||"href"===n&&i&&("use"!==e||"#"!==i[0])||"xlink:href"===n&&i&&"#"!==i[0]?ur(t,i):"background"!==n||!i||"table"!==e&&"td"!==e&&"th"!==e?"srcset"===n&&i?function(t,e){if(""===e.trim())return e;var n=0;function i(t){var i,r=t.exec(e.substring(n));return r?(i=r[0],n+=i.length,i):""}for(var r=[];i(hr),!(n>=e.length);){var s=i(dr);if(","===s.slice(-1))s=ur(t,s.substring(0,s.length-1)),r.push(s);else{var o="";s=ur(t,s);for(var a=!1;;){var l=e.charAt(n);if(""===l){r.push((s+o).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,r.push((s+o).trim());break}"("===l&&(a=!0)}o+=l,n+=1}}}return r.join(", ")}(t,i):"style"===n&&i?cr(i,gr()):"object"===e&&"data"===n&&i?ur(t,i):i:ur(t,i)}function mr(t,e,n){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return!!n&&mr(t.parentNode,e,n);for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&mr(t.parentNode,e,n)}function fr(t,e,n){var i=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(null===i)return!1;if("string"==typeof e){if(i.classList.contains(e))return!0;if(i.closest(".".concat(e)))return!0}else if(mr(i,e,!0))return!0;if(n){if(i.matches(n))return!0;if(i.closest(n))return!0}return!1}function yr(t){return void 0===t?"":t.toLowerCase()}function br(t,e){var n,i=e.doc,r=e.mirror,s=e.blockClass,o=e.blockSelector,a=e.maskTextClass,l=e.maskTextSelector,c=e.skipChild,d=void 0!==c&&c,h=e.inlineStylesheet,u=void 0===h||h,g=e.maskInputOptions,p=void 0===g?{}:g,m=e.maskTextFn,f=e.maskInputFn,y=e.slimDOMOptions,b=e.dataURLOptions,w=void 0===b?{}:b,v=e.inlineImages,C=void 0!==v&&v,I=e.recordCanvas,_=void 0!==I&&I,S=e.onSerialize,k=e.onIframeLoad,x=e.iframeLoadTimeout,A=void 0===x?5e3:x,E=e.onStylesheetLoad,R=e.stylesheetLoadTimeout,M=void 0===R?5e3:R,T=e.keepIframeSrcFn,z=void 0===T?function(){return!1}:T,O=e.newlyAddedElement,N=void 0!==O&&O,D=e.preserveWhiteSpace,L=void 0===D||D,F=function(t,e){var n=e.doc,i=e.mirror,r=e.blockClass,s=e.blockSelector,o=e.maskTextClass,a=e.maskTextSelector,l=e.inlineStylesheet,c=e.maskInputOptions,d=void 0===c?{}:c,h=e.maskTextFn,u=e.maskInputFn,g=e.dataURLOptions,p=void 0===g?{}:g,m=e.inlineImages,f=e.recordCanvas,y=e.keepIframeSrcFn,b=e.newlyAddedElement,w=void 0!==b&&b,v=function(t,e){if(e.hasNode(t)){var n=e.getId(t);return 1===n?void 0:n}}(n,i);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:qi.Document,childNodes:[],compatMode:t.compatMode}:{type:qi.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:qi.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:v};case t.ELEMENT_NODE:return function(t,e){for(var n=e.doc,i=e.inlineStylesheet,r=e.maskInputOptions,s=void 0===r?{}:r,o=e.maskInputFn,a=e.dataURLOptions,l=void 0===a?{}:a,c=e.inlineImages,d=e.recordCanvas,h=e.keepIframeSrcFn,u=e.newlyAddedElement,g=void 0!==u&&u,p=e.rootId,m=function(t,e,n){if("string"==typeof e){if(t.classList.contains(e))return!0}else for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&t.matches(n)}(t,e.blockClass,e.blockSelector),f=function(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return rr.test(e)?"div":e}(t),y={},b=t.attributes.length,w=0;w<b;w++){var v=t.attributes[w];y[v.name]=pr(n,f,v.name,v.value)}if("link"===f&&i){var C=Array.from(n.styleSheets).find(function(e){return e.href===t.href}),I=null;C&&(I=Yi(C)),I&&(delete y.rel,delete y.href,y._cssText=cr(I,C.href))}if("style"===f&&t.sheet&&!(t.innerText||t.textContent||"").trim().length&&(I=Yi(t.sheet))&&(y._cssText=cr(I,gr())),"input"===f||"textarea"===f||"select"===f){var _=t.value,S=t.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&_?y.value=Xi({type:y.type,tagName:f,value:_,maskInputOptions:s,maskInputFn:o}):S&&(y.checked=S)}if("option"===f&&(t.selected&&!s.select?y.selected=!0:delete y.selected),"canvas"===f&&d)if("2d"===t.__context)(function(t){var e=t.getContext("2d");if(!e)return!0;for(var n=0;n<t.width;n+=50)for(var i=0;i<t.height;i+=50){var r=e.getImageData,s=nr in r?r[nr]:r;if(new Uint32Array(s.call(e,n,i,Math.min(50,t.width-n),Math.min(50,t.height-i)).data.buffer).some(function(t){return 0!==t}))return!1}return!0})(t)||(y.rr_dataURL=t.toDataURL(l.type,l.quality));else if(!("__context"in t)){var k=t.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=t.width,x.height=t.height,k!==x.toDataURL(l.type,l.quality)&&(y.rr_dataURL=k)}if("img"===f&&c){tr||(tr=n.createElement("canvas"),er=tr.getContext("2d"));var A=t,E=A.crossOrigin;A.crossOrigin="anonymous";var R=function(){try{tr.width=A.naturalWidth,tr.height=A.naturalHeight,er.drawImage(A,0,0),y.rr_dataURL=tr.toDataURL(l.type,l.quality)}catch(t){console.warn("Cannot inline img src=".concat(A.currentSrc,"! Error: ").concat(t))}E?y.crossOrigin=E:A.removeAttribute("crossorigin")};A.complete&&0!==A.naturalWidth?R():A.onload=R}if("audio"!==f&&"video"!==f||(y.rr_mediaState=t.paused?"paused":"played",y.rr_mediaCurrentTime=t.currentTime),g||(t.scrollLeft&&(y.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(y.rr_scrollTop=t.scrollTop)),m){var M=t.getBoundingClientRect(),T=M.width,z=M.height;y={class:y.class,rr_width:"".concat(T,"px"),rr_height:"".concat(z,"px")}}return"iframe"!==f||h(y.src)||(t.contentDocument||(y.rr_src=y.src),delete y.src),{type:qi.Element,tagName:f,attributes:y,childNodes:[],isSVG:(O=t,Boolean("svg"===O.tagName||O.ownerSVGElement)||void 0),needBlock:m,rootId:p};var O}(t,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:l,maskInputOptions:d,maskInputFn:u,dataURLOptions:p,inlineImages:m,recordCanvas:f,keepIframeSrcFn:y,newlyAddedElement:w,rootId:v});case t.TEXT_NODE:return function(t,e){var n,i,r=e.maskTextClass,s=e.maskTextSelector,o=e.maskTextFn,a=e.rootId,l=t.parentNode&&t.parentNode.tagName,c=t.textContent,d="STYLE"===l||void 0,h="SCRIPT"===l||void 0;if(d&&c){try{t.nextSibling||t.previousSibling||(null===(n=t.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(i=t.parentNode.sheet).cssRules?Array.from(i.cssRules).map(function(t){return t.cssText||""}).join(""):"")}catch(e){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(e),t)}c=cr(c,gr())}return h&&(c="SCRIPT_PLACEHOLDER"),!d&&!h&&c&&fr(t,r,s)&&(c=o?o(c):c.replace(/[\S]/g,"*")),{type:qi.Text,textContent:c||"",isStyle:d,rootId:a}}(t,{maskTextClass:o,maskTextSelector:a,maskTextFn:h,rootId:v});case t.CDATA_SECTION_NODE:return{type:qi.CDATA,textContent:"",rootId:v};case t.COMMENT_NODE:return{type:qi.Comment,textContent:t.textContent||"",rootId:v};default:return!1}}(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:p,maskTextFn:m,maskInputFn:f,dataURLOptions:w,inlineImages:C,recordCanvas:_,keepIframeSrcFn:z,newlyAddedElement:N});if(!F)return console.warn(t,"not serialized"),null;n=r.hasNode(t)?r.getId(t):!function(t,e){if(e.comment&&t.type===qi.Comment)return!0;if(t.type===qi.Element){if(e.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(e.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(yr(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===yr(t.attributes.name)||"icon"===yr(t.attributes.rel)||"apple-touch-icon"===yr(t.attributes.rel)||"shortcut icon"===yr(t.attributes.rel))))return!0;if("meta"===t.tagName){if(e.headMetaDescKeywords&&yr(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(yr(t.attributes.property).match(/^(og|twitter|fb):/)||yr(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===yr(t.attributes.name)))return!0;if(e.headMetaRobots&&("robots"===yr(t.attributes.name)||"googlebot"===yr(t.attributes.name)||"bingbot"===yr(t.attributes.name)))return!0;if(e.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(e.headMetaAuthorship&&("author"===yr(t.attributes.name)||"generator"===yr(t.attributes.name)||"framework"===yr(t.attributes.name)||"publisher"===yr(t.attributes.name)||"progid"===yr(t.attributes.name)||yr(t.attributes.property).match(/^article:/)||yr(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&("google-site-verification"===yr(t.attributes.name)||"yandex-verification"===yr(t.attributes.name)||"csrf-token"===yr(t.attributes.name)||"p:domain_verify"===yr(t.attributes.name)||"verify-v1"===yr(t.attributes.name)||"verification"===yr(t.attributes.name)||"shopify-checkout-api-token"===yr(t.attributes.name)))return!0}}return!1}(F,y)&&(L||F.type!==qi.Text||F.isStyle||F.textContent.replace(/^\s+|\s+$/gm,"").length)?sr():-2;var B=Object.assign(F,{id:n});if(r.add(t,B),-2===n)return null;S&&S(t);var U=!d;if(B.type===qi.Element){U=U&&!B.needBlock,delete B.needBlock;var Z=t.shadowRoot;Z&&$i(Z)&&(B.isShadowHost=!0)}if((B.type===qi.Document||B.type===qi.Element)&&U){y.headWhitespace&&B.type===qi.Element&&"head"===B.tagName&&(L=!1);for(var W={doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:d,inlineStylesheet:u,maskInputOptions:p,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:L,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:z},P=0,V=Array.from(t.childNodes);P<V.length;P++)(j=br(V[P],W))&&B.childNodes.push(j);if(function(t){return t.nodeType===t.ELEMENT_NODE}(t)&&t.shadowRoot)for(var G=0,H=Array.from(t.shadowRoot.childNodes);G<H.length;G++){var j;(j=br(H[G],W))&&($i(t.shadowRoot)&&(j.isShadow=!0),B.childNodes.push(j))}}return t.parentNode&&Ki(t.parentNode)&&$i(t.parentNode)&&(B.isShadow=!0),B.type===qi.Element&&"iframe"===B.tagName&&function(t,e,n){var i=t.contentWindow;if(i){var r,s=!1;try{r=i.document.readyState}catch(t){return}if("complete"===r){var o="about:blank";if(i.location.href!==o||t.src===o||""===t.src)return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}else{var a=setTimeout(function(){s||(e(),s=!0)},n);t.addEventListener("load",function(){clearTimeout(a),s=!0,e()})}}}(t,function(){var e=t.contentDocument;if(e&&k){var n=br(e,{doc:e,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:p,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:L,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:z});n&&k(t,n)}},A),B.type===qi.Element&&"link"===B.tagName&&"stylesheet"===B.attributes.rel&&function(t,e,n){var i,r=!1;try{i=t.sheet}catch(t){return}if(!i){var s=setTimeout(function(){r||(e(),r=!0)},n);t.addEventListener("load",function(){clearTimeout(s),r=!0,e()})}}(t,function(){if(E){var e=br(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:p,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:L,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:z});e&&E(t,e)}},M),B}function wr(t,e,n=document){const i={capture:!0,passive:!0};return n.addEventListener(t,e,i),()=>n.removeEventListener(t,e,i)}new RegExp(/([^\\]):hover/.source,"g");const vr="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let Cr={map:{},getId:()=>(console.error(vr),-1),getNode:()=>(console.error(vr),null),removeNodeFromMap(){console.error(vr)},has:()=>(console.error(vr),!1),reset(){console.error(vr)}};function Ir(t,e,n={}){let i=null,r=0;return function(...s){const o=Date.now();r||!1!==n.leading||(r=o);const a=e-(o-r),l=this;a<=0||a>e?(i&&(clearTimeout(i),i=null),r=o,t.apply(l,s)):i||!1===n.trailing||(i=setTimeout(()=>{r=!1===n.leading?0:Date.now(),i=null,t.apply(l,s)},a))}}function _r(t,e,n,i,r=window){const s=r.Object.getOwnPropertyDescriptor(t,e);return r.Object.defineProperty(t,e,i?n:{set(t){setTimeout(()=>{n.set.call(this,t)},0),s&&s.set&&s.set.call(this,t)}}),()=>_r(t,e,s||{},!0)}function Sr(t,e,n){try{if(!(e in t))return()=>{};const i=t[e],r=n(i);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:i}})),t[e]=r,()=>{t[e]=i}}catch(t){return()=>{}}}function kr(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function xr(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function Ar(t,e,n,i){if(!t)return!1;const r=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(!r)return!1;if("string"==typeof e){if(r.classList.contains(e))return!0;if(i&&null!==r.closest("."+e))return!0}else if(mr(r,e,i))return!0;if(n){if(t.matches(n))return!0;if(i&&null!==r.closest(n))return!0}return!1}function Er(t,e){return-2===e.getId(t)}function Rr(t,e){if(Ki(t))return!1;const n=e.getId(t);return!e.has(n)||(!t.parentNode||t.parentNode.nodeType!==t.DOCUMENT_NODE)&&(!t.parentNode||Rr(t.parentNode,e))}function Mr(t){return Boolean(t.changedTouches)}function Tr(t,e){return Boolean("IFRAME"===t.nodeName&&e.getMeta(t))}function zr(t,e){return Boolean("LINK"===t.nodeName&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&"stylesheet"===t.getAttribute("rel")&&e.getMeta(t))}function Or(t){return Boolean(null==t?void 0:t.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(Cr=new Proxy(Cr,{get:(t,e,n)=>("map"===e&&console.error(vr),Reflect.get(t,e,n))}));class Nr{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var e;return null!==(e=this.styleIDMap.get(t))&&void 0!==e?e:-1}has(t){return this.styleIDMap.has(t)}add(t,e){if(this.has(t))return this.getId(t);let n;return n=void 0===e?this.id++:e,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var Dr=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Dr||{}),Lr=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t))(Lr||{}),Fr=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(Fr||{}),Br=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(Br||{});function Ur(t){return"__ln"in t}class Zr{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let e=this.head;for(let n=0;n<t;n++)e=(null==e?void 0:e.next)||null;return e}addNode(t){const e={value:t,previous:null,next:null};if(t.__ln=e,t.previousSibling&&Ur(t.previousSibling)){const n=t.previousSibling.__ln.next;e.next=n,e.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=e,n&&(n.previous=e)}else if(t.nextSibling&&Ur(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;e.previous=n,e.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=e,n&&(n.next=e)}else this.head&&(this.head.previous=e),e.next=this.head,this.head=e;this.length++}removeNode(t){const e=t.__ln;this.head&&(e.previous?(e.previous.next=e.next,e.next&&(e.next.previous=e.previous)):(this.head=e.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const Wr=(t,e)=>`${t}@${e}`;class Pr{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],e=new Zr,n=t=>{let e=t,n=-2;for(;-2===n;)e=e&&e.nextSibling,n=e&&this.mirror.getId(e);return n},i=i=>{var r,s,o,a;let l=null;(null===(s=null===(r=i.getRootNode)||void 0===r?void 0:r.call(i))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&i.getRootNode().host&&(l=i.getRootNode().host);let c=l;for(;(null===(a=null===(o=null==c?void 0:c.getRootNode)||void 0===o?void 0:o.call(c))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host;)c=c.getRootNode().host;const d=!(this.doc.contains(i)||c&&this.doc.contains(c));if(!i.parentNode||d)return;const h=Ki(i.parentNode)?this.mirror.getId(l):this.mirror.getId(i.parentNode),u=n(i);if(-1===h||-1===u)return e.addNode(i);const g=br(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:t=>{Tr(t,this.mirror)&&this.iframeManager.addIframe(t),zr(t,this.mirror)&&this.stylesheetManager.trackLinkElement(t),Or(i)&&this.shadowDomManager.addShadowRoot(i.shadowRoot,this.doc)},onIframeLoad:(t,e)=>{this.iframeManager.attachIframe(t,e),this.shadowDomManager.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{this.stylesheetManager.attachLinkElement(t,e)}});g&&t.push({parentId:h,nextId:u,node:g})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const t of Array.from(this.movedSet.values()))Gr(this.removes,t,this.mirror)&&!this.movedSet.has(t.parentNode)||i(t);for(const t of Array.from(this.addedSet.values()))jr(this.droppedSet,t)||Gr(this.removes,t,this.mirror)?jr(this.movedSet,t)?i(t):this.droppedSet.add(t):i(t);let r=null;for(;e.length;){let t=null;if(r){const e=this.mirror.getId(r.value.parentNode),i=n(r.value);-1!==e&&-1!==i&&(t=r)}if(!t)for(let i=e.length-1;i>=0;i--){const r=e.get(i);if(r){const e=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==e){t=r;break}{const e=r.value;if(e.parentNode&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=e.parentNode.host;if(-1!==this.mirror.getId(n)){t=r;break}}}}}if(!t){for(;e.head;)e.removeNode(e.head.value);break}r=t.previous,e.removeNode(t.value),i(t.value)}const s={texts:this.texts.map(t=>({id:this.mirror.getId(t.node),value:t.value})).filter(t=>this.mirror.has(t.id)),attributes:this.attributes.map(t=>({id:this.mirror.getId(t.node),attributes:t.attributes})).filter(t=>this.mirror.has(t.id)),removes:this.removes,adds:t};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=t=>{if(!Er(t.target,this.mirror))switch(t.type){case"characterData":{const e=t.target.textContent;Ar(t.target,this.blockClass,this.blockSelector,!1)||e===t.oldValue||this.texts.push({value:fr(t.target,this.maskTextClass,this.maskTextSelector)&&e?this.maskTextFn?this.maskTextFn(e):e.replace(/[\S]/g,"*"):e,node:t.target});break}case"attributes":{const e=t.target;let n=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(n=Xi({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),Ar(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let i=this.attributes.find(e=>e.node===t.target);if("IFRAME"===e.tagName&&"src"===t.attributeName&&!this.keepIframeSrcFn(n)){if(e.contentDocument)return;t.attributeName="rr_src"}if(i||(i={node:t.target,attributes:{}},this.attributes.push(i)),"style"===t.attributeName){const n=this.doc.createElement("span");t.oldValue&&n.setAttribute("style",t.oldValue),void 0!==i.attributes.style&&null!==i.attributes.style||(i.attributes.style={});const r=i.attributes.style;for(const t of Array.from(e.style)){const i=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);i===n.style.getPropertyValue(t)&&s===n.style.getPropertyPriority(t)||(r[t]=""===s?i:[i,s])}for(const t of Array.from(n.style))""===e.style.getPropertyValue(t)&&(r[t]=!1)}else i.attributes[t.attributeName]=pr(this.doc,e.tagName,t.attributeName,n);break}case"childList":if(Ar(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(e=>this.genAdds(e,t.target)),t.removedNodes.forEach(e=>{const n=this.mirror.getId(e),i=Ki(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);Ar(t.target,this.blockClass,this.blockSelector,!1)||Er(e,this.mirror)||!function(t,e){return-1!==e.getId(t)}(e,this.mirror)||(this.addedSet.has(e)?(Vr(this.addedSet,e),this.droppedSet.add(e)):this.addedSet.has(t.target)&&-1===n||Rr(t.target,this.mirror)||(this.movedSet.has(e)&&this.movedMap[Wr(n,i)]?Vr(this.movedSet,e):this.removes.push({parentId:i,id:n,isShadow:!(!Ki(t.target)||!$i(t.target))||void 0})),this.mapRemoves.push(e))})}},this.genAdds=(t,e)=>{if(this.mirror.hasNode(t)){if(Er(t,this.mirror))return;this.movedSet.add(t);let n=null;e&&this.mirror.hasNode(e)&&(n=this.mirror.getId(e)),n&&-1!==n&&(this.movedMap[Wr(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);Ar(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(t=>this.genAdds(t))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(e=>{this[e]=t[e]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Vr(t,e){t.delete(e),e.childNodes.forEach(e=>Vr(t,e))}function Gr(t,e,n){return 0!==t.length&&Hr(t,e,n)}function Hr(t,e,n){const{parentNode:i}=e;if(!i)return!1;const r=n.getId(i);return!!t.some(t=>t.id===r)||Hr(t,i,n)}function jr(t,e){return 0!==t.size&&qr(t,e)}function qr(t,e){const{parentNode:n}=e;return!!n&&(!!t.has(n)||qr(t,n))}const Kr=[],$r="undefined"!=typeof CSSGroupingRule,Yr="undefined"!=typeof CSSMediaRule,Qr="undefined"!=typeof CSSSupportsRule,Jr="undefined"!=typeof CSSConditionRule;function Xr(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch(e){return t.target}}function ts(t,e){var n,i;const r=new Pr;Kr.push(r),r.init(t);let s=window.MutationObserver||window.__rrMutationObserver;const o=null===(i=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===i?void 0:i.call(n,"MutationObserver");o&&window[o]&&(s=window[o]);const a=new s(r.processMutations.bind(r));return a.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function es({scrollCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){return wr("scroll",Ir(s=>{const o=Xr(s);if(!o||Ar(o,i,r,!0))return;const a=n.getId(o);if(o===e){const n=e.scrollingElement||e.documentElement;t({id:a,x:n.scrollLeft,y:n.scrollTop})}else t({id:a,x:o.scrollLeft,y:o.scrollTop})},s.scroll||100),e)}function ns(t,e){const n=Object.assign({},t);return e||delete n.userTriggered,n}const is=["INPUT","TEXTAREA","SELECT"],rs=new WeakMap;function ss(t){return function(t,e){if($r&&t.parentRule instanceof CSSGroupingRule||Yr&&t.parentRule instanceof CSSMediaRule||Qr&&t.parentRule instanceof CSSSupportsRule||Jr&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);e.unshift(n)}else if(t.parentStyleSheet){const n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);e.unshift(n)}return e}(t,[])}function os(t,e,n){let i,r;return t?(t.ownerNode?i=e.getId(t.ownerNode):r=n.getId(t),{styleId:r,id:i}):{}}function as({mirror:t,stylesheetManager:e},n){var i,r,s;let o=null;o="#document"===n.nodeName?t.getId(n):t.getId(n.host);const a="#document"===n.nodeName?null===(i=n.defaultView)||void 0===i?void 0:i.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==o&&-1!==o&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var t;return null===(t=l.get)||void 0===t?void 0:t.call(this)},set(t){var n;const i=null===(n=l.set)||void 0===n?void 0:n.call(this,t);if(null!==o&&-1!==o)try{e.adoptStyleSheets(t,o)}catch(t){}return i}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}):()=>{}}function ls(t,e={}){const n=t.doc.defaultView;if(!n)return()=>{};!function(t,e){const{mutationCb:n,mousemoveCb:i,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:h,fontCb:u,selectionCb:g}=t;t.mutationCb=(...t)=>{e.mutation&&e.mutation(...t),n(...t)},t.mousemoveCb=(...t)=>{e.mousemove&&e.mousemove(...t),i(...t)},t.mouseInteractionCb=(...t)=>{e.mouseInteraction&&e.mouseInteraction(...t),r(...t)},t.scrollCb=(...t)=>{e.scroll&&e.scroll(...t),s(...t)},t.viewportResizeCb=(...t)=>{e.viewportResize&&e.viewportResize(...t),o(...t)},t.inputCb=(...t)=>{e.input&&e.input(...t),a(...t)},t.mediaInteractionCb=(...t)=>{e.mediaInteaction&&e.mediaInteaction(...t),l(...t)},t.styleSheetRuleCb=(...t)=>{e.styleSheetRule&&e.styleSheetRule(...t),c(...t)},t.styleDeclarationCb=(...t)=>{e.styleDeclaration&&e.styleDeclaration(...t),d(...t)},t.canvasMutationCb=(...t)=>{e.canvasMutation&&e.canvasMutation(...t),h(...t)},t.fontCb=(...t)=>{e.font&&e.font(...t),u(...t)},t.selectionCb=(...t)=>{e.selection&&e.selection(...t),g(...t)}}(t,e);const i=ts(t,t.doc),r=function({mousemoveCb:t,sampling:e,doc:n,mirror:i}){if(!1===e.mousemove)return()=>{};const r="number"==typeof e.mousemove?e.mousemove:50,s="number"==typeof e.mousemoveCallback?e.mousemoveCallback:500;let o,a=[];const l=Ir(e=>{const n=Date.now()-o;t(a.map(t=>(t.timeOffset-=n,t)),e),a=[],o=null},s),c=Ir(t=>{const e=Xr(t),{clientX:n,clientY:r}=Mr(t)?t.changedTouches[0]:t;o||(o=Date.now()),a.push({x:n,y:r,id:i.getId(e),timeOffset:Date.now()-o}),l("undefined"!=typeof DragEvent&&t instanceof DragEvent?Lr.Drag:t instanceof MouseEvent?Lr.MouseMove:Lr.TouchMove)},r,{trailing:!1}),d=[wr("mousemove",c,n),wr("touchmove",c,n),wr("drag",c,n)];return()=>{d.forEach(t=>t())}}(t),s=function({mouseInteractionCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const o=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(Fr).filter(t=>Number.isNaN(Number(t))&&!t.endsWith("_Departed")&&!1!==o[t]).forEach(s=>{const o=s.toLowerCase(),l=(e=>s=>{const o=Xr(s);if(Ar(o,i,r,!0))return;const a=Mr(s)?s.changedTouches[0]:s;if(!a)return;const l=n.getId(o),{clientX:c,clientY:d}=a;t({type:Fr[e],id:l,x:c,y:d})})(s);a.push(wr(o,l,e))}),()=>{a.forEach(t=>t())}}(t),o=es(t),a=function({viewportResizeCb:t}){let e=-1,n=-1;return wr("resize",Ir(()=>{const i=kr(),r=xr();e===i&&n===r||(t({width:Number(r),height:Number(i)}),e=i,n=r)},200),window)}(t),l=function({inputCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,ignoreClass:s,maskInputOptions:o,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function d(t){let n=Xr(t);const l=t.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||is.indexOf(n.tagName)<0||Ar(n,i,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let u=n.value,g=!1;"radio"===d||"checkbox"===d?g=n.checked:(o[n.tagName.toLowerCase()]||o[d])&&(u=Xi({maskInputOptions:o,tagName:n.tagName,type:d,value:u,maskInputFn:a})),h(n,ns({text:u,isChecked:g,userTriggered:l},c));const p=n.name;"radio"===d&&p&&g&&e.querySelectorAll(`input[type="radio"][name="${p}"]`).forEach(t=>{t!==n&&h(t,ns({text:t.value,isChecked:!g,userTriggered:!1},c))})}function h(e,i){const r=rs.get(e);if(!r||r.text!==i.text||r.isChecked!==i.isChecked){rs.set(e,i);const r=n.getId(e);t(Object.assign(Object.assign({},i),{id:r}))}}const u=("last"===l.input?["change"]:["input","change"]).map(t=>wr(t,d,e)),g=e.defaultView;if(!g)return()=>{u.forEach(t=>t())};const p=g.Object.getOwnPropertyDescriptor(g.HTMLInputElement.prototype,"value"),m=[[g.HTMLInputElement.prototype,"value"],[g.HTMLInputElement.prototype,"checked"],[g.HTMLSelectElement.prototype,"value"],[g.HTMLTextAreaElement.prototype,"value"],[g.HTMLSelectElement.prototype,"selectedIndex"],[g.HTMLOptionElement.prototype,"selected"]];return p&&p.set&&u.push(...m.map(t=>_r(t[0],t[1],{set(){d({target:this})}},!1,g))),()=>{u.forEach(t=>t())}}(t),c=function({mediaInteractionCb:t,blockClass:e,blockSelector:n,mirror:i,sampling:r}){const s=s=>Ir(r=>{const o=Xr(r);if(!o||Ar(o,e,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d}=o;t({type:s,id:i.getId(o),currentTime:a,volume:l,muted:c,playbackRate:d})},r.media||500),o=[wr("play",s(0)),wr("pause",s(1)),wr("seeked",s(2)),wr("volumechange",s(3)),wr("ratechange",s(4))];return()=>{o.forEach(t=>t())}}(t),d=function({styleSheetRuleCb:t,mirror:e,stylesheetManager:n},{win:i}){const r=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=function(i,s){const{id:o,styleId:a}=os(this,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:i,index:s}]}),r.apply(this,[i,s])};const s=i.CSSStyleSheet.prototype.deleteRule;let o,a;i.CSSStyleSheet.prototype.deleteRule=function(i){const{id:r,styleId:o}=os(this,e,n.styleMirror);return(r&&-1!==r||o&&-1!==o)&&t({id:r,styleId:o,removes:[{index:i}]}),s.apply(this,[i])},i.CSSStyleSheet.prototype.replace&&(o=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=function(i){const{id:r,styleId:s}=os(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replace:i}),o.apply(this,[i])}),i.CSSStyleSheet.prototype.replaceSync&&(a=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=function(i){const{id:r,styleId:s}=os(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replaceSync:i}),a.apply(this,[i])});const l={};$r?l.CSSGroupingRule=i.CSSGroupingRule:(Yr&&(l.CSSMediaRule=i.CSSMediaRule),Jr&&(l.CSSConditionRule=i.CSSConditionRule),Qr&&(l.CSSSupportsRule=i.CSSSupportsRule));const c={};return Object.entries(l).forEach(([i,r])=>{c[i]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:o,styleId:a}=os(this.parentStyleSheet,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:r,index:[...ss(this),s||0]}]}),c[i].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:o}=os(this.parentStyleSheet,e,n.styleMirror);return(s&&-1!==s||o&&-1!==o)&&t({id:s,styleId:o,removes:[{index:[...ss(this),r]}]}),c[i].deleteRule.apply(this,[r])}}),()=>{i.CSSStyleSheet.prototype.insertRule=r,i.CSSStyleSheet.prototype.deleteRule=s,o&&(i.CSSStyleSheet.prototype.replace=o),a&&(i.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([t,e])=>{e.prototype.insertRule=c[t].insertRule,e.prototype.deleteRule=c[t].deleteRule})}}(t,{win:n}),h=as(t,t.doc),u=function({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:n,stylesheetManager:i},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,o,a){var l;if(n.has(r))return s.apply(this,[r,o,a]);const{id:c,styleId:d}=os(null===(l=this.parentRule)||void 0===l?void 0:l.parentStyleSheet,e,i.styleMirror);return(c&&-1!==c||d&&-1!==d)&&t({id:c,styleId:d,set:{property:r,value:o,priority:a},index:ss(this.parentRule)}),s.apply(this,[r,o,a])};const o=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return o.apply(this,[r]);const{id:a,styleId:l}=os(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,e,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&t({id:a,styleId:l,remove:{property:r},index:ss(this.parentRule)}),o.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=o}}(t,{win:n}),g=t.collectFonts?function({fontCb:t,doc:e}){const n=e.defaultView;if(!n)return()=>{};const i=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(t,e,n){const i=new s(t,e,n);return r.set(i,{family:t,buffer:"string"!=typeof e,descriptors:n,fontSource:"string"==typeof e?e:JSON.stringify(Array.from(new Uint8Array(e)))}),i};const o=Sr(e.fonts,"add",function(e){return function(n){return setTimeout(()=>{const e=r.get(n);e&&(t(e),r.delete(n))},0),e.apply(this,[n])}});return i.push(()=>{n.FontFace=s}),i.push(o),()=>{i.forEach(t=>t())}}(t):()=>{},p=function(t){const{doc:e,mirror:n,blockClass:i,blockSelector:r,selectionCb:s}=t;let o=!0;const a=()=>{const t=e.getSelection();if(!t||o&&(null==t?void 0:t.isCollapsed))return;o=t.isCollapsed||!1;const a=[],l=t.rangeCount||0;for(let e=0;e<l;e++){const s=t.getRangeAt(e),{startContainer:o,startOffset:l,endContainer:c,endOffset:d}=s;Ar(o,i,r,!0)||Ar(c,i,r,!0)||a.push({start:n.getId(o),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})};return a(),wr("selectionchange",a)}(t),m=[];for(const e of t.plugins)m.push(e.observer(e.callback,n,e.options));return()=>{Kr.forEach(t=>t.reset()),i.disconnect(),r(),s(),o(),a(),l(),c(),d(),h(),u(),g(),p(),m.forEach(t=>t())}}class cs{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,e,n,i){const r=n||this.getIdToRemoteIdMap(t),s=i||this.getRemoteIdToIdMap(t);let o=r.get(e);return o||(o=this.generateIdFn(),r.set(e,o),s.set(o,e)),o}getIds(t,e){const n=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return e.map(e=>this.getId(t,e,n,i))}getRemoteId(t,e,n){const i=n||this.getRemoteIdToIdMap(t);if("number"!=typeof e)return e;return i.get(e)||-1}getRemoteIds(t,e){const n=this.getRemoteIdToIdMap(t);return e.map(e=>this.getRemoteId(t,e,n))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let e=this.iframeIdToRemoteIdMap.get(t);return e||(e=new Map,this.iframeIdToRemoteIdMap.set(t,e)),e}getRemoteIdToIdMap(t){let e=this.iframeRemoteIdToIdMap.get(t);return e||(e=new Map,this.iframeRemoteIdToIdMap.set(t,e)),e}}class ds{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new cs(sr),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new cs(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,e){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if("rrweb"===t.data.type){if(!t.source)return;const e=this.crossOriginIframeMap.get(t.source);if(!e)return;const n=this.transformCrossOriginEvent(e,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}transformCrossOriginEvent(t,e){var n;switch(e.type){case Dr.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(e.data.node,t),{timestamp:e.timestamp,type:Dr.IncrementalSnapshot,data:{source:Lr.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:e.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Dr.Meta:case Dr.Load:case Dr.DomContentLoaded:return!1;case Dr.Plugin:return e;case Dr.Custom:return this.replaceIds(e.data.payload,t,["id","parentId","previousId","nextId"]),e;case Dr.IncrementalSnapshot:switch(e.data.source){case Lr.Mutation:return e.data.adds.forEach(e=>{this.replaceIds(e,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(e.node,t)}),e.data.removes.forEach(e=>{this.replaceIds(e,t,["parentId","id"])}),e.data.attributes.forEach(e=>{this.replaceIds(e,t,["id"])}),e.data.texts.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Lr.Drag:case Lr.TouchMove:case Lr.MouseMove:return e.data.positions.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Lr.ViewportResize:return!1;case Lr.MediaInteraction:case Lr.MouseInteraction:case Lr.Scroll:case Lr.CanvasMutation:case Lr.Input:return this.replaceIds(e.data,t,["id"]),e;case Lr.StyleSheetRule:case Lr.StyleDeclaration:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleId"]),e;case Lr.Font:return e;case Lr.Selection:return e.data.ranges.forEach(e=>{this.replaceIds(e,t,["start","end"])}),e;case Lr.AdoptedStyleSheet:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleIds"]),null===(n=e.data.styles)||void 0===n||n.forEach(e=>{this.replaceStyleIds(e,t,["styleId"])}),e}}}replace(t,e,n,i){for(const r of i)(Array.isArray(e[r])||"number"==typeof e[r])&&(Array.isArray(e[r])?e[r]=t.getIds(n,e[r]):e[r]=t.getId(n,e[r]));return e}replaceIds(t,e,n){return this.replace(this.crossOriginIframeMirror,t,e,n)}replaceStyleIds(t,e,n){return this.replace(this.crossOriginIframeStyleMirror,t,e,n)}replaceIdOnNode(t,e){this.replaceIds(t,e,["id"]),"childNodes"in t&&t.childNodes.forEach(t=>{this.replaceIdOnNode(t,e)})}}class hs{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const e=this;this.restorePatches.push(Sr(Element.prototype,"attachShadow",function(t){return function(n){const i=t.call(this,n);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,this.ownerDocument),i}}))}addShadowRoot(t,e){$i(t)&&(this.shadowDoms.has(t)||(this.shadowDoms.add(t),ts(Object.assign(Object.assign({},this.bypassOptions),{doc:e,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),es(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),as({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0)))}observeAttachShadow(t){if(t.contentWindow){const e=this;this.restorePatches.push(Sr(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(i){const r=n.call(this,i);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,t.contentDocument),r}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var us="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",gs="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ps=0;ps<64;ps++)gs[us.charCodeAt(ps)]=ps;const ms=new Map,fs=(t,e,n)=>{if(!t||!ws(t,e)&&"object"!=typeof t)return;const i=function(t,e){let n=ms.get(t);return n||(n=new Map,ms.set(t,n)),n.has(e)||n.set(e,[]),n.get(e)}(n,t.constructor.name);let r=i.indexOf(t);return-1===r&&(r=i.length,i.push(t)),r};function ys(t,e,n){if(t instanceof Array)return t.map(t=>ys(t,e,n));if(null===t)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){const e=t.constructor.name,n=function(t){var e,n=new Uint8Array(t),i=n.length,r="";for(e=0;e<i;e+=3)r+=us[n[e]>>2],r+=us[(3&n[e])<<4|n[e+1]>>4],r+=us[(15&n[e+1])<<2|n[e+2]>>6],r+=us[63&n[e+2]];return i%3==2?r=r.substring(0,r.length-1)+"=":i%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(t);return{rr_type:e,base64:n}}if(t instanceof DataView)return{rr_type:t.constructor.name,args:[ys(t.buffer,e,n),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){const e=t.constructor.name,{src:n}=t;return{rr_type:e,src:n}}return t instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:t.toDataURL()}:t instanceof ImageData?{rr_type:t.constructor.name,args:[ys(t.data,e,n),t.width,t.height]}:ws(t,e)||"object"==typeof t?{rr_type:t.constructor.name,index:fs(t,e,n)}:t}const bs=(t,e,n)=>[...t].map(t=>ys(t,e,n)),ws=(t,e)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(t=>"function"==typeof e[t]);return Boolean(n.find(n=>t instanceof e[n]))};function vs(t,e,n){const i=[];try{const r=Sr(t.HTMLCanvasElement.prototype,"getContext",function(t){return function(i,...r){return Ar(this,e,n,!0)||"__context"in this||(this.__context=i),t.apply(this,[i,...r])}});i.push(r)}catch(t){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(t=>t())}}function Cs(t,e,n,i,r,s,o){const a=[],l=Object.getOwnPropertyNames(t);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof t[s])continue;const l=Sr(t,s,function(t){return function(...a){const l=t.apply(this,a);if(fs(l,o,this),!Ar(this.canvas,i,r,!0)){const t=bs([...a],o,this),i={type:e,property:s,args:t};n(this.canvas,i)}return l}});a.push(l)}catch(i){const r=_r(t,s,{set(t){n(this.canvas,{type:e,property:s,args:[t],setter:!0})}});a.push(r)}return a}var Is=null;try{var _s="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof require&&require("worker_threads")||"function"==typeof require&&require("worker_threads");Is=_s.Worker}catch(t){}var Ss,ks,xs=(Ss="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",ks=!1,"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?function(t,e,n){var i=void 0===e?null:e,r=function(t,e){return Buffer.from(t,"base64").toString(e?"utf16":"utf8")}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:"");return function(t){return new Is(o,Object.assign({},t,{eval:!0}))}}(Ss,null,ks):function(t){var e;return function(n){return e=e||function(t,e,n){var i=void 0===e?null:e,r=function(t,e){var n=atob(t);if(e){for(var i=new Uint8Array(n.length),r=0,s=n.length;r<s;++r)i[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return n}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:""),a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}(t,null,false),new Worker(e,n)}}(Ss));class As{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(t,e)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(t)||this.pendingCanvasMutations.set(t,[]),this.pendingCanvasMutations.get(t).push(e)};const{sampling:e="all",win:n,blockClass:i,blockSelector:r,recordCanvas:s,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,s&&"all"===e&&this.initCanvasMutationObserver(n,i,r),s&&"number"==typeof e&&this.initCanvasFPSObserver(e,n,i,r,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,e,n,i,r){const s=vs(e,n,i),o=new Map,a=new xs;a.onmessage=t=>{const{id:e}=t.data;if(o.set(e,!1),!("base64"in t.data))return;const{base64:n,type:i,width:r,height:s}=t.data;this.mutationCb({id:e,type:Br["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:i}]},0,0]}]})};const l=1e3/t;let c,d=0;const h=t=>{d&&t-d<l||(d=t,(()=>{const t=[];return e.document.querySelectorAll("canvas").forEach(e=>{Ar(e,n,i,!0)||t.push(e)}),t})().forEach(t=>{return e=this,n=void 0,s=function*(){var e;const n=this.mirror.getId(t);if(o.get(n))return;if(o.set(n,!0),["webgl","webgl2"].includes(t.__context)){const n=t.getContext(t.__context);!1===(null===(e=null==n?void 0:n.getContextAttributes())||void 0===e?void 0:e.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const i=yield createImageBitmap(t);a.postMessage({id:n,bitmap:i,width:t.width,height:t.height,dataURLOptions:r.dataURLOptions},[i])},new((i=void 0)||(i=Promise))(function(t,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(o,a)}l((s=s.apply(e,n||[])).next())});var e,n,i,s})),c=requestAnimationFrame(h)};c=requestAnimationFrame(h),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(t,e,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=vs(t,e,n),r=function(t,e,n,i){const r=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(const o of s)try{if("function"!=typeof e.CanvasRenderingContext2D.prototype[o])continue;const s=Sr(e.CanvasRenderingContext2D.prototype,o,function(r){return function(...s){return Ar(this.canvas,n,i,!0)||setTimeout(()=>{const n=bs([...s],e,this);t(this.canvas,{type:Br["2D"],property:o,args:n})},0),r.apply(this,s)}});r.push(s)}catch(n){const i=_r(e.CanvasRenderingContext2D.prototype,o,{set(e){t(this.canvas,{type:Br["2D"],property:o,args:[e],setter:!0})}});r.push(i)}return()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n),s=function(t,e,n,i){const r=[];return r.push(...Cs(e.WebGLRenderingContext.prototype,Br.WebGL,t,n,i,0,e)),void 0!==e.WebGL2RenderingContext&&r.push(...Cs(e.WebGL2RenderingContext.prototype,Br.WebGL2,t,n,i,0,e)),()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n,this.mirror);this.resetObservers=()=>{i(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=e=>{this.rafStamps.latestId=e,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,e)=>{const n=this.mirror.getId(e);this.flushPendingCanvasMutationFor(e,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,e){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||-1===e)return;const i=n.map(t=>{const e=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["type"]);return e}),{type:r}=n[0];this.mutationCb({id:e,type:r,commands:i}),this.pendingCanvasMutations.delete(t)}}class Es{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new Nr,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,e){"_cssText"in e.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:e.id,attributes:e.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,e){if(0===t.length)return;const n={id:e,styleIds:[]},i=[];for(const e of t){let t;if(this.styleMirror.has(e))t=this.styleMirror.getId(e);else{t=this.styleMirror.add(e);const n=Array.from(e.rules||CSSRule);i.push({styleId:t,rules:n.map((t,e)=>({rule:Qi(t),index:e}))})}n.styleIds.push(t)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function Rs(t){return Object.assign(Object.assign({},t),{timestamp:Date.now()})}let Ms,Ts,zs,Os=!1;const Ns=new Ji;function Ds(t={}){const{emit:e,checkoutEveryNms:n,checkoutEveryNth:i,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:u,maskInputFn:g,maskTextFn:p,hooks:m,packFn:f,sampling:y={},dataURLOptions:b={},mousemoveWait:w,recordCanvas:v=!1,recordCrossOriginIframes:C=!1,userTriggeredOnInput:I=!1,collectFonts:_=!1,inlineImages:S=!1,plugins:k,keepIframeSrcFn:x=()=>!1,ignoreCSSAttributes:A=new Set([])}=t,E=!C||window.parent===window;let R=!1;if(!E)try{window.parent.document,R=!1}catch(t){R=!0}if(E&&!e)throw new Error("emit function is required");void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),Ns.reset();const M=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},T=!0===u||"all"===u?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===u,headMetaDescKeywords:"all"===u}:u||{};let z;!function(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let e=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}();let O=0;const N=t=>{for(const e of k||[])e.eventProcessor&&(t=e.eventProcessor(t));return f&&(t=f(t)),t};Ms=(t,r)=>{var s;if(!(null===(s=Kr[0])||void 0===s?void 0:s.isFrozen())||t.type===Dr.FullSnapshot||t.type===Dr.IncrementalSnapshot&&t.data.source===Lr.Mutation||Kr.forEach(t=>t.unfreeze()),E)null==e||e(N(t),r);else if(R){const e={type:"rrweb",event:N(t),isCheckout:r};window.parent.postMessage(e,"*")}if(t.type===Dr.FullSnapshot)z=t,O=0;else if(t.type===Dr.IncrementalSnapshot){if(t.data.source===Lr.Mutation&&t.data.isAttachIframe)return;O++;const e=i&&O>=i,r=n&&t.timestamp-z.timestamp>n;(e||r)&&Ts(!0)}};const D=t=>{Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.Mutation},t)}))},L=t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.Scroll},t)})),F=t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.CanvasMutation},t)})),B=new Es({mutationCb:D,adoptedStyleSheetCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.AdoptedStyleSheet},t)}))}),U=new ds({mirror:Ns,mutationCb:D,stylesheetManager:B,recordCrossOriginIframes:C,wrappedEmit:Ms});for(const t of k||[])t.getMirror&&t.getMirror({nodeMirror:Ns,crossOriginIframeMirror:U.crossOriginIframeMirror,crossOriginIframeStyleMirror:U.crossOriginIframeStyleMirror});zs=new As({recordCanvas:v,mutationCb:F,win:window,blockClass:r,blockSelector:s,mirror:Ns,sampling:y.canvas,dataURLOptions:b});const Z=new hs({mutationCb:D,scrollCb:L,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskInputOptions:M,dataURLOptions:b,maskTextFn:p,maskInputFn:g,recordCanvas:v,inlineImages:S,sampling:y,slimDOMOptions:T,iframeManager:U,stylesheetManager:B,canvasManager:zs,keepIframeSrcFn:x},mirror:Ns});Ts=(t=!1)=>{var e,n,i,o,d,h;Ms(Rs({type:Dr.Meta,data:{href:window.location.href,width:xr(),height:kr()}}),t),B.reset(),Kr.forEach(t=>t.lock());const u=function(t,e){var n=e||{},i=n.mirror,r=void 0===i?new Ji:i,s=n.blockClass,o=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,c=n.inlineStylesheet,d=n.inlineImages,h=n.recordCanvas,u=n.maskAllInputs,g=void 0!==u&&u,p=n.slimDOM,m=void 0!==p&&p,f=n.keepIframeSrcFn;return br(t,{doc:t,mirror:r,blockClass:void 0===s?"rr-block":s,blockSelector:void 0===o?null:o,maskTextClass:void 0===a?"rr-mask":a,maskTextSelector:void 0===l?null:l,skipChild:!1,inlineStylesheet:void 0===c||c,maskInputOptions:!0===g?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===g?{password:!0}:g,maskTextFn:n.maskTextFn,maskInputFn:n.maskInputFn,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,dataURLOptions:n.dataURLOptions,inlineImages:void 0!==d&&d,recordCanvas:void 0!==h&&h,preserveWhiteSpace:n.preserveWhiteSpace,onSerialize:n.onSerialize,onIframeLoad:n.onIframeLoad,iframeLoadTimeout:n.iframeLoadTimeout,onStylesheetLoad:n.onStylesheetLoad,stylesheetLoadTimeout:n.stylesheetLoadTimeout,keepIframeSrcFn:void 0===f?function(){return!1}:f,newlyAddedElement:!1})}(document,{mirror:Ns,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskAllInputs:M,maskTextFn:p,slimDOM:T,dataURLOptions:b,recordCanvas:v,inlineImages:S,onSerialize:t=>{Tr(t,Ns)&&U.addIframe(t),zr(t,Ns)&&B.trackLinkElement(t),Or(t)&&Z.addShadowRoot(t.shadowRoot,document)},onIframeLoad:(t,e)=>{U.attachIframe(t,e),Z.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{B.attachLinkElement(t,e)},keepIframeSrcFn:x});if(!u)return console.warn("Failed to snapshot the document");Ms(Rs({type:Dr.FullSnapshot,data:{node:u,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(e=null===document||void 0===document?void 0:document.body)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),Kr.forEach(t=>t.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&B.adoptStyleSheets(document.adoptedStyleSheets,Ns.getId(document))};try{const t=[];t.push(wr("DOMContentLoaded",()=>{Ms(Rs({type:Dr.DomContentLoaded,data:{}}))}));const e=t=>{var e;return ls({mutationCb:D,mousemoveCb:(t,e)=>Ms(Rs({type:Dr.IncrementalSnapshot,data:{source:e,positions:t}})),mouseInteractionCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.MouseInteraction},t)})),scrollCb:L,viewportResizeCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.ViewportResize},t)})),inputCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.Input},t)})),mediaInteractionCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.MediaInteraction},t)})),styleSheetRuleCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.StyleSheetRule},t)})),styleDeclarationCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.StyleDeclaration},t)})),canvasMutationCb:F,fontCb:t=>Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.Font},t)})),selectionCb:t=>{Ms(Rs({type:Dr.IncrementalSnapshot,data:Object.assign({source:Lr.Selection},t)}))},blockClass:r,ignoreClass:o,maskTextClass:a,maskTextSelector:l,maskInputOptions:M,inlineStylesheet:c,sampling:y,recordCanvas:v,inlineImages:S,userTriggeredOnInput:I,collectFonts:_,doc:t,maskInputFn:g,maskTextFn:p,keepIframeSrcFn:x,blockSelector:s,slimDOMOptions:T,dataURLOptions:b,mirror:Ns,iframeManager:U,stylesheetManager:B,shadowDomManager:Z,canvasManager:zs,ignoreCSSAttributes:A,plugins:(null===(e=null==k?void 0:k.filter(t=>t.observer))||void 0===e?void 0:e.map(t=>({observer:t.observer,options:t.options,callback:e=>Ms(Rs({type:Dr.Plugin,data:{plugin:t.name,payload:e}}))})))||[]},m)};U.addLoadListener(n=>{t.push(e(n.contentDocument))});const n=()=>{Ts(),t.push(e(document)),Os=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():t.push(wr("load",()=>{Ms(Rs({type:Dr.Load,data:{}})),n()},window)),()=>{t.forEach(t=>t()),Os=!1}}catch(t){console.warn(t)}}Ds.addCustomEvent=(t,e)=>{if(!Os)throw new Error("please add custom event after start recording");Ms(Rs({type:Dr.Custom,data:{tag:t,payload:e}}))},Ds.freezePage=()=>{Kr.forEach(t=>t.freeze())},Ds.takeFullSnapshot=t=>{if(!Os)throw new Error("please take full snapshot after start recording");Ts(t)},Ds.mirror=Ns;class Ls{constructor(t){this.events=[],this.duration=1e3*t.duration}add(t){this.events.push(t),this.prune()}addBatch(t){this.events.push(...t),this.prune()}prune(){if(0===this.events.length)return;const t=Date.now()-this.duration;let e=0;for(let n=0;n<this.events.length;n++)if(this.events[n].timestamp>=t){e=n;break}e>0&&(this.events=this.events.slice(e))}getEvents(){return this.prune(),[...this.events]}getCompressedEvents(){return this.getEvents()}clear(){this.events=[]}size(){return this.events.length}setDuration(t){this.duration=1e3*t,this.prune()}getDuration(){return this.duration/1e3}}const Fs=Z();class Bs{constructor(t={}){var e,n,i,r,s,o,a;this.isRecording=!1,this.sanitizer=t.sanitizer,this.config={duration:null!==(e=t.duration)&&void 0!==e?e:15,sampling:{mousemove:null!==(i=null===(n=t.sampling)||void 0===n?void 0:n.mousemove)&&void 0!==i?i:50,scroll:null!==(s=null===(r=t.sampling)||void 0===r?void 0:r.scroll)&&void 0!==s?s:100},recordCanvas:null!==(o=t.recordCanvas)&&void 0!==o&&o,recordCrossOriginIframes:null!==(a=t.recordCrossOriginIframes)&&void 0!==a&&a,sanitizer:t.sanitizer},this.buffer=new Ls({duration:this.config.duration})}startRecording(){var t,e,n,i;if(this.isRecording)Z().warn("DOMCollector: Recording already in progress");else try{const r={emit:t=>{this.buffer.add(t)},sampling:{mousemove:null!==(e=null===(t=this.config.sampling)||void 0===t?void 0:t.mousemove)&&void 0!==e?e:50,scroll:null!==(i=null===(n=this.config.sampling)||void 0===n?void 0:n.scroll)&&void 0!==i?i:100,mouseInteraction:{MouseUp:!1,MouseDown:!1,Click:!1,ContextMenu:!1,DblClick:!1,Focus:!1,Blur:!1,TouchStart:!1,TouchEnd:!1}},recordCanvas:this.config.recordCanvas,recordCrossOriginIframes:this.config.recordCrossOriginIframes,maskTextFn:this.sanitizer?(t,e)=>this.sanitizer.sanitizeTextNode(t,e):void 0,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},inlineImages:!1,collectFonts:!1};this.stopRecordingFn=Ds(r),this.isRecording=!0,Z().debug("DOMCollector: Started recording")}catch(t){Z().error("DOMCollector: Failed to start recording",t),this.isRecording=!1}}stopRecording(){if(this.isRecording&&this.stopRecordingFn)try{this.stopRecordingFn(),this.isRecording=!1,this.stopRecordingFn=void 0,Fs.debug("DOMCollector: Stopped recording")}catch(t){Fs.error("DOMCollector: Failed to stop recording",t)}else Fs.warn("DOMCollector: No recording in progress")}getEvents(){return this.buffer.getEvents()}getCompressedEvents(){return this.buffer.getCompressedEvents()}clearBuffer(){this.buffer.clear()}isCurrentlyRecording(){return this.isRecording}getBufferSize(){return this.buffer.size()}setDuration(t){this.config.duration=t,this.buffer.setDuration(t)}getDuration(){return this.config.duration}destroy(){this.stopRecording(),this.clearBuffer()}}class Us{getItem(t){try{return"undefined"==typeof localStorage?null:localStorage.getItem(t)}catch(t){return null}}setItem(t,e){"undefined"!=typeof localStorage&&localStorage.setItem(t,e)}removeItem(t){try{if("undefined"==typeof localStorage)return;localStorage.removeItem(t)}catch(t){}}}const Zs="bugspotter_offline_queue",Ws={enabled:!1,maxQueueSize:10};class Ps{constructor(t,e,n){this.requestCounter=0,this.config=Object.assign(Object.assign({},Ws),t),this.logger=e||Z(),this.storage=n||new Us}enqueue(t,e,n){try{const i=this.serializeBody(e);if(!i||!this.validateItemSize(i))return;const r=this.getQueue();r.length>=this.config.maxQueueSize&&(this.logger.warn(`Offline queue is full (${this.config.maxQueueSize}), removing oldest request`),r.shift()),r.push(this.createQueuedRequest(t,i,n)),this.saveQueue(r),this.logger.log(`Request queued for offline retry (queue size: ${r.length})`)}catch(t){this.logger.error("Failed to queue request for offline retry:",t)}}async process(t){const e=this.getQueue();if(0===e.length)return;this.logger.log(`Processing offline queue (${e.length} requests)`);const n=[],i=[];for(const r of e)if(r.attempts>=5)this.logger.warn(`Max retry attempts (5) reached for request (id: ${r.id}), removing`);else if(Date.now()-r.timestamp>6048e5)this.logger.warn(`Removing expired queued request (id: ${r.id})`);else try{const e=await fetch(r.endpoint,{method:"POST",headers:r.headers,body:r.body});e.ok?(this.logger.log(`Successfully sent queued request (id: ${r.id})`),n.push(r.id)):t.includes(e.status)?(r.attempts++,i.push(r),this.logger.warn(`Queued request failed with status ${e.status}, will retry later (id: ${r.id})`)):this.logger.warn(`Queued request failed with non-retryable status ${e.status}, removing (id: ${r.id})`)}catch(t){r.attempts++,i.push(r),this.logger.warn(`Queued request failed with network error, will retry later (id: ${r.id}):`,t)}this.saveQueue(i),(n.length>0||i.length<e.length)&&this.logger.log(`Offline queue processed: ${n.length} successful, ${i.length} remaining`)}clear(){try{this.storage.removeItem(Zs)}catch(t){}}size(){return this.getQueue().length}serializeBody(t){return"string"==typeof t?t:t instanceof Blob?(this.logger.warn("Cannot queue Blob for offline retry, skipping"),null):JSON.stringify(t)}createQueuedRequest(t,e,n){return{id:this.generateRequestId(),endpoint:t,body:e,headers:n,timestamp:Date.now(),attempts:0}}validateItemSize(t){const e=new Blob([t]).size;return!(e>102400&&(this.logger.warn(`Request body too large (${e} bytes), skipping queue`),1))}getQueue(){try{const t=this.storage.getItem(Zs);return t?JSON.parse(t):[]}catch(t){return this.logger.warn("Failed to parse offline queue data, clearing corrupted queue:",t),this.clear(),[]}}saveQueue(t){try{this.storage.setItem(Zs,JSON.stringify(t))}catch(e){this.isQuotaExceededError(e)?(this.logger.error("localStorage quota exceeded, clearing oldest items"),this.clearOldestItems(t)):this.logger.error("Failed to save offline queue:",e)}}isQuotaExceededError(t){if(!(t instanceof Error))return!1;if("QuotaExceededError"===t.name)return!0;if("code"in t&&22===t.code)return!0;const e=t.message.toLowerCase();return e.includes("quota")||e.includes("storage")||e.includes("exceeded")}clearOldestItems(t){try{const e=t.slice(Math.floor(t.length/2));this.storage.setItem(Zs,JSON.stringify(e)),this.logger.log(`Trimmed offline queue to ${e.length} items due to quota`)}catch(t){this.logger.error("Failed to save even after trimming, clearing queue"),this.clear()}}generateRequestId(){let t;if(this.requestCounter=(this.requestCounter+1)%1e4,"undefined"!=typeof crypto&&crypto.getRandomValues){const e=new Uint32Array(2);crypto.getRandomValues(e),t=Array.from(e,t=>t.toString(36)).join("")}else t=Math.random().toString(36).substring(2,9)+Math.random().toString(36).substring(2,9);return`req_${Date.now()}_${this.requestCounter}_${t}`}}const Vs=!0;Error;const Gs={maxRetries:3,baseDelay:1e3,maxDelay:3e4,retryOn:[502,503,504,429]},Hs={enabled:!1,maxQueueSize:10},js={"api-key":t=>{const e=t.apiKey;return e?{"X-API-Key":e}:{}},jwt:t=>{const e=t.token;return e?{Authorization:`Bearer ${e}`}:{}},bearer:t=>{const e=t.token;return e?{Authorization:`Bearer ${e}`}:{}},custom:t=>{const e=t.customHeader;if(!e)return{};const{name:n,value:i}=e;return n&&i?{[n]:i}:{}},none:()=>({})};class qs{constructor(t,e){this.config=t,this.logger=e}async executeWithRetry(t,e){let n=null;for(let i=0;i<=this.config.maxRetries;i++)try{const n=await t();if(e(n.status)&&i<this.config.maxRetries){const t=this.calculateDelay(i,n);this.logger.warn(`Request failed with status ${n.status}, retrying in ${t}ms (attempt ${i+1}/${this.config.maxRetries})`),await Qs(t);continue}return n}catch(t){if(n=t,i<this.config.maxRetries){const e=this.calculateDelay(i);this.logger.warn(`Network error, retrying in ${e}ms (attempt ${i+1}/${this.config.maxRetries}):`,t),await Qs(e);continue}}throw n||new Error("Request failed after all retry attempts")}calculateDelay(t,e){var n,i;if(null===(i=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n.has)||void 0===i?void 0:i.call(n,"Retry-After")){const t=e.headers.get("Retry-After"),n=parseInt(t,10);if(!isNaN(n))return Math.min(1e3*n,this.config.maxDelay)}const r=this.config.baseDelay*Math.pow(2,t),s=r+.1*r*(2*Math.random()-1);return Math.min(s,this.config.maxDelay)}}function Ks(t){if(!t)return{};const e=js[t.type];return e?e(t):{}}async function $s(t,e,n,i){const{auth:r,logger:s,enableRetry:o,retryConfig:a,offlineConfig:l}=function(t){var e,n;return"object"==typeof(n=t)&&null!==n&&!("type"in n)&&("auth"in n||"retry"in n||"offline"in n||"logger"in n||"enableRetry"in n)?{auth:t.auth,logger:t.logger||Z(),enableRetry:null!==(e=t.enableRetry)&&void 0!==e?e:Vs,retryConfig:Object.assign(Object.assign({},Gs),t.retry),offlineConfig:Object.assign(Object.assign({},Hs),t.offline)}:{auth:t,logger:Z(),enableRetry:Vs,retryConfig:Gs,offlineConfig:Hs}}(i);!async function(t,e,n){t.enabled&&new Ps(t,n).process(e.retryOn).catch(t=>{n.warn("Failed to process offline queue:",t)})}(l,a,s);try{const i=await async function(t,e,n,i,r,s,o){const a=new qs(r,s);let l=!1;return a.executeWithRetry(async()=>{const r=await Ys(t,e,n,i);if(401===r.status&&o&&!l&&function(t){return"object"==typeof t&&("jwt"===t.type||"bearer"===t.type)&&"function"==typeof t.onTokenExpired}(i)){l=!0;const r=await async function(t,e,n,i,r){try{r.warn("Token expired, attempting refresh...");const s=await i.onTokenExpired(),o=Object.assign(Object.assign({},i),{token:s}),a=await Ys(t,e,n,o);return r.log("Request retried with refreshed token"),a}catch(t){return r.error("Token refresh failed:",t),new Response(null,{status:401,statusText:"Unauthorized"})}}(t,e,n,i,s);return r}return r},t=>r.retryOn.includes(t))}(t,e,n,r,a,s,o);return i}catch(i){throw await async function(t,e,n,i,r,s,o){if(!s.enabled||!function(t){if(!(t instanceof Error))return!1;const e=t.message.toLowerCase();return e.includes("failed to fetch")||e.includes("network request failed")||e.includes("networkerror")||e.includes("network error")||e.includes("connection")||e.includes("timeout")||"NetworkError"===t.name||"AbortError"===t.name||"TypeError"===t.name&&(e.includes("fetch")||e.includes("network"))}(t))return;o.warn("Network error detected, queueing request for offline retry");const a=new Ps(s,o),l=Ks(r);await a.enqueue(e,n,Object.assign(Object.assign({},i),l))}(i,t,e,n,r,l,s),i}}async function Ys(t,e,n,i){const r=Ks(i),s=Object.assign(Object.assign({},n),r);return fetch(t,{method:"POST",headers:s,body:e})}function Qs(t){return new Promise(e=>setTimeout(e,t))}const Js=Z();class Xs{constructor(t){var e,n,i,r,s,o,a,l,c,d;this.config=t,!1!==(null===(e=t.sanitize)||void 0===e?void 0:e.enabled)&&(this.sanitizer=Gi({enabled:null===(i=null===(n=t.sanitize)||void 0===n?void 0:n.enabled)||void 0===i||i,patterns:null===(r=t.sanitize)||void 0===r?void 0:r.patterns,customPatterns:null===(s=t.sanitize)||void 0===s?void 0:s.customPatterns,excludeSelectors:null===(o=t.sanitize)||void 0===o?void 0:o.excludeSelectors})),this.screenshot=new fi,this.console=new wi({sanitizer:this.sanitizer}),this.network=new vi({sanitizer:this.sanitizer}),this.metadata=new Ci({sanitizer:this.sanitizer}),!1!==(null===(a=t.replay)||void 0===a?void 0:a.enabled)&&(this.domCollector=new Bs({duration:null!==(c=null===(l=t.replay)||void 0===l?void 0:l.duration)&&void 0!==c?c:15,sampling:null===(d=t.replay)||void 0===d?void 0:d.sampling,sanitizer:this.sanitizer}),this.domCollector.startRecording()),!1!==t.showWidget&&(this.widget=new Ei(t.widgetOptions),this.widget.onClick(async()=>{await this.handleBugReport()}))}static init(t){return Xs.instance||(Xs.instance=new Xs(t)),Xs.instance}static getInstance(){return Xs.instance||null}async capture(){var t,e;const n=await this.screenshot.capture(),i=null!==(e=null===(t=this.domCollector)||void 0===t?void 0:t.getEvents())&&void 0!==e?e:[];return{console:this.console.getLogs(),network:this.network.getRequests(),metadata:this.metadata.capture(),replay:i,_screenshotPreview:n}}async handleBugReport(){const t=await this.capture();new ji({onSubmit:async e=>{if(Js.log("Submitting bug:",Object.assign(Object.assign({},e),{report:t})),this.config.endpoint)try{await this.submitBugReport(Object.assign(Object.assign({},e),{report:t})),Js.log("Bug report submitted successfully")}catch(t){throw Js.error("Failed to submit bug report:",t),t}}}).show(t._screenshotPreview||"")}async submitBugReport(t){if(!this.config.endpoint)throw new Error("No endpoint configured for bug report submission");const e={"Content-Type":"application/json"};let n;Js.warn(`Submitting bug report to ${this.config.endpoint}`);try{const i=function(t){const e=pi(t);return gi().encode(e).length}(t),r=await async function(t){try{const e=pi(t),n=gi().encode(e),i=6;return ci.gzip(n,{level:i})}catch(t){throw di.error("Compression failed:",t),t}}(t),s=r.byteLength,o=function(t,e){return t<=0?0:Math.round(100*(1-e/t))}(i,s);Js.log(`Payload compression: ${(i/1024).toFixed(1)}KB → ${(s/1024).toFixed(1)}KB (${o}% reduction)`),s<i?(n=new Blob([new Uint8Array(r)],{type:"application/gzip"}),e["Content-Encoding"]="gzip",e["Content-Type"]="application/gzip"):n=JSON.stringify(t)}catch(e){Js.warn("Compression failed, sending uncompressed payload:",e),n=JSON.stringify(t)}const i=this.config.auth,r=await $s(this.config.endpoint,n,e,{auth:i,retry:this.config.retry,offline:this.config.offline});if(Js.warn(`${JSON.stringify(r)}`),!r.ok){const t=await r.text().catch(()=>"Unknown error");throw new Error(`Failed to submit bug report: ${r.status} ${r.statusText}. ${t}`)}return r.json().catch(()=>{})}getConfig(){return Object.assign({},this.config)}destroy(){var t,e;this.console.destroy(),this.network.destroy(),null===(t=this.domCollector)||void 0===t||t.destroy(),null===(e=this.widget)||void 0===e||e.destroy(),Xs.instance=void 0}}return e.BugSpotter})());
2
+ !function(t,e){"object"==typeof exports&&"object"==typeof module?module.exports=e():"function"==typeof define&&define.amd?define([],e):"object"==typeof exports?exports.BugSpotter=e():t.BugSpotter=e()}(this,()=>(()=>{"use strict";var t={d:(e,n)=>{for(var i in n)t.o(n,i)&&!t.o(e,i)&&Object.defineProperty(e,i,{enumerable:!0,get:n[i]})},o:(t,e)=>Object.prototype.hasOwnProperty.call(t,e)},e={};t.d(e,{BugSpotter:()=>Js});const n=(()=>{let t=0;return()=>(t+=1,`u${`0000${(Math.random()*36**4|0).toString(36)}`.slice(-4)}${t}`)})();function i(t){const e=[];for(let n=0,i=t.length;n<i;n++)e.push(t[n]);return e}let r=null;function s(t={}){return r||(t.includeStyleProperties?(r=t.includeStyleProperties,r):(r=i(window.getComputedStyle(document.documentElement)),r))}function o(t,e){const n=(t.ownerDocument.defaultView||window).getComputedStyle(t).getPropertyValue(e);return n?parseFloat(n.replace("px","")):0}function a(t,e={}){return{width:e.width||function(t){const e=o(t,"border-left-width"),n=o(t,"border-right-width");return t.clientWidth+e+n}(t),height:e.height||function(t){const e=o(t,"border-top-width"),n=o(t,"border-bottom-width");return t.clientHeight+e+n}(t)}}const l=16384;function c(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{i.decode().then(()=>{requestAnimationFrame(()=>e(i))})},i.onerror=n,i.crossOrigin="anonymous",i.decoding="async",i.src=t})}const d=(t,e)=>{if(t instanceof e)return!0;const n=Object.getPrototypeOf(t);return null!==n&&(n.constructor.name===e.name||d(n,e))};function h(t,e,i,r){const o=window.getComputedStyle(t,i),a=o.getPropertyValue("content");if(""===a||"none"===a)return;const l=n();try{e.className=`${e.className} ${l}`}catch(t){return}const c=document.createElement("style");c.appendChild(function(t,e,n,i){const r=`.${t}:${e}`,o=n.cssText?function(t){const e=t.getPropertyValue("content");return`${t.cssText} content: '${e.replace(/'|"/g,"")}';`}(n):function(t,e){return s(e).map(e=>`${e}: ${t.getPropertyValue(e)}${t.getPropertyPriority(e)?" !important":""};`).join(" ")}(n,i);return document.createTextNode(`${r}{${o}}`)}(l,i,o,r)),e.appendChild(c)}const u="application/font-woff",p="image/jpeg",g={woff:u,woff2:u,ttf:"application/font-truetype",eot:"application/vnd.ms-fontobject",png:"image/png",jpg:p,jpeg:p,gif:"image/gif",tiff:"image/tiff",svg:"image/svg+xml",webp:"image/webp"};function m(t){const e=function(t){const e=/\.([^./]*?)$/g.exec(t);return e?e[1]:""}(t).toLowerCase();return g[e]||""}function f(t){return-1!==t.search(/^(data:)/)}function y(t,e){return`data:${e};base64,${t}`}async function b(t,e,n){const i=await fetch(t,e);if(404===i.status)throw new Error(`Resource "${i.url}" not found`);const r=await i.blob();return new Promise((t,e)=>{const s=new FileReader;s.onerror=e,s.onloadend=()=>{try{t(n({res:i,result:s.result}))}catch(t){e(t)}},s.readAsDataURL(r)})}const w={};async function v(t,e,n){const i=function(t,e,n){let i=t.replace(/\?.*/,"");return n&&(i=t),/ttf|otf|eot|woff2?/i.test(i)&&(i=i.replace(/.*\//,"")),e?`[${e}]${i}`:i}(t,e,n.includeQueryParams);if(null!=w[i])return w[i];let r;n.cacheBust&&(t+=(/\?/.test(t)?"&":"?")+(new Date).getTime());try{const i=await b(t,n.fetchRequestInit,({res:t,result:n})=>(e||(e=t.headers.get("Content-Type")||""),function(t){return t.split(/,/)[1]}(n)));r=y(i,e)}catch(e){r=n.imagePlaceholder||"";let i=`Failed to fetch resource: ${t}`;e&&(i="string"==typeof e?e:e.message),i&&console.warn(i)}return w[i]=r,r}const C=t=>null!=t.tagName&&"SLOT"===t.tagName.toUpperCase(),I=t=>null!=t.tagName&&"SVG"===t.tagName.toUpperCase();async function _(t,e,n){return n||!e.filter||e.filter(t)?Promise.resolve(t).then(t=>async function(t,e){return d(t,HTMLCanvasElement)?async function(t){const e=t.toDataURL();return"data:,"===e?t.cloneNode(!1):c(e)}(t):d(t,HTMLVideoElement)?async function(t,e){if(t.currentSrc){const e=document.createElement("canvas"),n=e.getContext("2d");return e.width=t.clientWidth,e.height=t.clientHeight,null==n||n.drawImage(t,0,0,e.width,e.height),c(e.toDataURL())}const n=t.poster,i=m(n);return c(await v(n,i,e))}(t,e):d(t,HTMLIFrameElement)?async function(t,e){var n;try{if(null===(n=null==t?void 0:t.contentDocument)||void 0===n?void 0:n.body)return await _(t.contentDocument.body,e,!0)}catch(t){}return t.cloneNode(!1)}(t,e):t.cloneNode(I(t))}(t,e)).then(n=>async function(t,e,n){var r,s;if(I(e))return e;let o=[];return o=C(t)&&t.assignedNodes?i(t.assignedNodes()):d(t,HTMLIFrameElement)&&(null===(r=t.contentDocument)||void 0===r?void 0:r.body)?i(t.contentDocument.body.childNodes):i((null!==(s=t.shadowRoot)&&void 0!==s?s:t).childNodes),0===o.length||d(t,HTMLVideoElement)||await o.reduce((t,i)=>t.then(()=>_(i,n)).then(t=>{t&&e.appendChild(t)}),Promise.resolve()),e}(t,n,e)).then(n=>function(t,e,n){return d(e,Element)&&(function(t,e,n){const i=e.style;if(!i)return;const r=window.getComputedStyle(t);r.cssText?(i.cssText=r.cssText,i.transformOrigin=r.transformOrigin):s(n).forEach(n=>{let s=r.getPropertyValue(n);if("font-size"===n&&s.endsWith("px")){const t=Math.floor(parseFloat(s.substring(0,s.length-2)))-.1;s=`${t}px`}d(t,HTMLIFrameElement)&&"display"===n&&"inline"===s&&(s="block"),"d"===n&&e.getAttribute("d")&&(s=`path(${e.getAttribute("d")})`),i.setProperty(n,s,r.getPropertyPriority(n))})}(t,e,n),function(t,e,n){h(t,e,":before",n),h(t,e,":after",n)}(t,e,n),function(t,e){d(t,HTMLTextAreaElement)&&(e.innerHTML=t.value),d(t,HTMLInputElement)&&e.setAttribute("value",t.value)}(t,e),function(t,e){if(d(t,HTMLSelectElement)){const n=e,i=Array.from(n.children).find(e=>t.value===e.getAttribute("value"));i&&i.setAttribute("selected","")}}(t,e)),e}(t,n,e)).then(t=>async function(t,e){const n=t.querySelectorAll?t.querySelectorAll("use"):[];if(0===n.length)return t;const i={};for(let r=0;r<n.length;r++){const s=n[r].getAttribute("xlink:href");if(s){const n=t.querySelector(s),r=document.querySelector(s);n||!r||i[s]||(i[s]=await _(r,e,!0))}}const r=Object.values(i);if(r.length){const e="http://www.w3.org/1999/xhtml",n=document.createElementNS(e,"svg");n.setAttribute("xmlns",e),n.style.position="absolute",n.style.width="0",n.style.height="0",n.style.overflow="hidden",n.style.display="none";const i=document.createElementNS(e,"defs");n.appendChild(i);for(let t=0;t<r.length;t++)i.appendChild(r[t]);t.appendChild(n)}return t}(t,e)):null}const S=/url\((['"]?)([^'"]+?)\1\)/g,k=/url\([^)]+\)\s*format\((["']?)([^"']+)\1\)/g,x=/src:\s*(?:url\([^)]+\)\s*format\([^)]+\)[,;]\s*)+/g;function A(t){return-1!==t.search(S)}async function E(t,e,n){if(!A(t))return t;const i=function(t,{preferredFontFormat:e}){return e?t.replace(x,t=>{for(;;){const[n,,i]=k.exec(t)||[];if(!i)return"";if(i===e)return`src: ${n};`}}):t}(t,n),r=function(t){const e=[];return t.replace(S,(t,n,i)=>(e.push(i),t)),e.filter(t=>!f(t))}(i);return r.reduce((t,i)=>t.then(t=>async function(t,e,n,i,r){try{const s=n?function(t,e){if(t.match(/^[a-z]+:\/\//i))return t;if(t.match(/^\/\//))return window.location.protocol+t;if(t.match(/^[a-z]+:/i))return t;const n=document.implementation.createHTMLDocument(),i=n.createElement("base"),r=n.createElement("a");return n.head.appendChild(i),n.body.appendChild(r),e&&(i.href=e),r.href=t,r.href}(e,n):e,o=m(e);let a;return a=r?y(await r(s),o):await v(s,o,i),t.replace(function(t){const e=t.replace(/([.*+?^${}()|\[\]\/\\])/g,"\\$1");return new RegExp(`(url\\(['"]?)(${e})(['"]?\\))`,"g")}(e),`$1${a}$3`)}catch(t){}return t}(t,i,e,n)),Promise.resolve(i))}async function R(t,e,n){var i;const r=null===(i=e.style)||void 0===i?void 0:i.getPropertyValue(t);if(r){const i=await E(r,null,n);return e.style.setProperty(t,i,e.style.getPropertyPriority(t)),!0}return!1}async function M(t,e){d(t,Element)&&(await async function(t,e){await R("background",t,e)||await R("background-image",t,e),await R("mask",t,e)||await R("-webkit-mask",t,e)||await R("mask-image",t,e)||await R("-webkit-mask-image",t,e)}(t,e),await async function(t,e){const n=d(t,HTMLImageElement);if((!n||f(t.src))&&(!d(t,SVGImageElement)||f(t.href.baseVal)))return;const i=n?t.src:t.href.baseVal,r=await v(i,m(i),e);await new Promise((i,s)=>{t.onload=i,t.onerror=e.onImageErrorHandler?(...t)=>{try{i(e.onImageErrorHandler(...t))}catch(t){s(t)}}:s;const o=t;o.decode&&(o.decode=i),"lazy"===o.loading&&(o.loading="eager"),n?(t.srcset="",t.src=r):t.href.baseVal=r})}(t,e),await async function(t,e){const n=i(t.childNodes).map(t=>M(t,e));await Promise.all(n).then(()=>t)}(t,e))}const T={};async function O(t){let e=T[t];if(null!=e)return e;const n=await fetch(t);return e={url:t,cssText:await n.text()},T[t]=e,e}async function z(t,e){let n=t.cssText;const i=/url\(["']?([^"')]+)["']?\)/g,r=(n.match(/url\([^)]+\)/g)||[]).map(async r=>{let s=r.replace(i,"$1");return s.startsWith("https://")||(s=new URL(s,t.url).href),b(s,e.fetchRequestInit,({result:t})=>(n=n.replace(r,`url(${t})`),[r,t]))});return Promise.all(r).then(()=>n)}function L(t){if(null==t)return[];const e=[];let n=t.replace(/(\/\*[\s\S]*?\*\/)/gi,"");const i=new RegExp("((@.*?keyframes [\\s\\S]*?){([\\s\\S]*?}\\s*?)})","gi");for(;;){const t=i.exec(n);if(null===t)break;e.push(t[0])}n=n.replace(i,"");const r=/@import[\s\S]*?url\([^)]*\)[\s\S]*?;/gi,s=new RegExp("((\\s*?(?:\\/\\*[\\s\\S]*?\\*\\/)?\\s*?@media[\\s\\S]*?){([\\s\\S]*?)}\\s*?})|(([\\s\\S]*?){([\\s\\S]*?)})","gi");for(;;){let t=r.exec(n);if(null===t){if(t=s.exec(n),null===t)break;r.lastIndex=s.lastIndex}else s.lastIndex=r.lastIndex;e.push(t[0])}return e}function D(t){return t.trim().replace(/["']/g,"")}async function N(t,e){const n=await async function(t,e){if(null==t.ownerDocument)throw new Error("Provided element is not within a Document");const n=i(t.ownerDocument.styleSheets),r=await async function(t,e){const n=[],r=[];return t.forEach(n=>{if("cssRules"in n)try{i(n.cssRules||[]).forEach((t,i)=>{if(t.type===CSSRule.IMPORT_RULE){let s=i+1;const o=O(t.href).then(t=>z(t,e)).then(t=>L(t).forEach(t=>{try{n.insertRule(t,t.startsWith("@import")?s+=1:n.cssRules.length)}catch(e){console.error("Error inserting rule from remote css",{rule:t,error:e})}})).catch(t=>{console.error("Error loading remote css",t.toString())});r.push(o)}})}catch(i){const s=t.find(t=>null==t.href)||document.styleSheets[0];null!=n.href&&r.push(O(n.href).then(t=>z(t,e)).then(t=>L(t).forEach(t=>{s.insertRule(t,s.cssRules.length)})).catch(t=>{console.error("Error loading remote stylesheet",t)})),console.error("Error inlining remote css file",i)}}),Promise.all(r).then(()=>(t.forEach(t=>{if("cssRules"in t)try{i(t.cssRules||[]).forEach(t=>{n.push(t)})}catch(e){console.error(`Error while reading CSS rules from ${t.href}`,e)}}),n))}(n,e);return function(t){return t.filter(t=>t.type===CSSRule.FONT_FACE_RULE).filter(t=>A(t.style.getPropertyValue("src")))}(r)}(t,e),r=function(t){const e=new Set;return function t(n){(n.style.fontFamily||getComputedStyle(n).fontFamily).split(",").forEach(t=>{e.add(D(t))}),Array.from(n.children).forEach(e=>{e instanceof HTMLElement&&t(e)})}(t),e}(t);return(await Promise.all(n.filter(t=>r.has(D(t.style.fontFamily))).map(t=>{const n=t.parentStyleSheet?t.parentStyleSheet.href:null;return E(t.cssText,n,e)}))).join("\n")}async function F(t,e={}){const{width:n,height:i}=a(t,e),r=await _(t,e,!0);return await async function(t,e){const n=null!=e.fontEmbedCSS?e.fontEmbedCSS:e.skipFonts?null:await N(t,e);if(n){const e=document.createElement("style"),i=document.createTextNode(n);e.appendChild(i),t.firstChild?t.insertBefore(e,t.firstChild):t.appendChild(e)}}(r,e),await M(r,e),function(t,e){const{style:n}=t;e.backgroundColor&&(n.backgroundColor=e.backgroundColor),e.width&&(n.width=`${e.width}px`),e.height&&(n.height=`${e.height}px`);const i=e.style;null!=i&&Object.keys(i).forEach(t=>{n[t]=i[t]})}(r,e),await async function(t,e,n){const i="http://www.w3.org/2000/svg",r=document.createElementNS(i,"svg"),s=document.createElementNS(i,"foreignObject");return r.setAttribute("width",`${e}`),r.setAttribute("height",`${n}`),r.setAttribute("viewBox",`0 0 ${e} ${n}`),s.setAttribute("width","100%"),s.setAttribute("height","100%"),s.setAttribute("x","0"),s.setAttribute("y","0"),s.setAttribute("externalResourcesRequired","true"),r.appendChild(s),s.appendChild(t),async function(t){return Promise.resolve().then(()=>(new XMLSerializer).serializeToString(t)).then(encodeURIComponent).then(t=>`data:image/svg+xml;charset=utf-8,${t}`)}(r)}(r,n,i)}const B={debug:0,log:1,warn:2,error:3,none:4};const U=new class{constructor(t={}){var e,n,i;this.enabled=null===(e=t.enabled)||void 0===e||e,this.level=null!==(n=t.level)&&void 0!==n?n:"log",this.prefix=null!==(i=t.prefix)&&void 0!==i?i:"[BugSpotter]"}shouldLog(t){return!!this.enabled&&B[t]>=B[this.level]}formatMessage(t){return this.prefix?`${this.prefix} ${t}`:t}debug(t,...e){this.shouldLog("debug")&&console.debug(this.formatMessage(t),...e)}log(t,...e){this.shouldLog("log")&&console.log(this.formatMessage(t),...e)}warn(t,...e){this.shouldLog("warn")&&console.warn(this.formatMessage(t),...e)}error(t,...e){this.shouldLog("error")&&console.error(this.formatMessage(t),...e)}configure(t){void 0!==t.enabled&&(this.enabled=t.enabled),void 0!==t.level&&(this.level=t.level),void 0!==t.prefix&&(this.prefix=t.prefix)}};function Z(){return U}const P=Z();class W{constructor(t){this.options=t,this.sanitizer=t.sanitizer}handleError(t,e){const n=e instanceof Error?e:new Error(String(e));P.error(`${this.constructor.name} ${t}:`,n)}}function V(t){let e=t.length;for(;--e>=0;)t[e]=0}const G=new Uint8Array([0,0,0,0,0,0,0,0,1,1,1,1,2,2,2,2,3,3,3,3,4,4,4,4,5,5,5,5,0]),j=new Uint8Array([0,0,0,0,1,1,2,2,3,3,4,4,5,5,6,6,7,7,8,8,9,9,10,10,11,11,12,12,13,13]),q=new Uint8Array([0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,2,3,7]),H=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]),K=new Array(576);V(K);const $=new Array(60);V($);const Y=new Array(512);V(Y);const Q=new Array(256);V(Q);const J=new Array(29);V(J);const X=new Array(30);function tt(t,e,n,i,r){this.static_tree=t,this.extra_bits=e,this.extra_base=n,this.elems=i,this.max_length=r,this.has_stree=t&&t.length}let et,nt,it;function rt(t,e){this.dyn_tree=t,this.max_code=0,this.stat_desc=e}V(X);const st=t=>t<256?Y[t]:Y[256+(t>>>7)],ot=(t,e)=>{t.pending_buf[t.pending++]=255&e,t.pending_buf[t.pending++]=e>>>8&255},at=(t,e,n)=>{t.bi_valid>16-n?(t.bi_buf|=e<<t.bi_valid&65535,ot(t,t.bi_buf),t.bi_buf=e>>16-t.bi_valid,t.bi_valid+=n-16):(t.bi_buf|=e<<t.bi_valid&65535,t.bi_valid+=n)},lt=(t,e,n)=>{at(t,n[2*e],n[2*e+1])},ct=(t,e)=>{let n=0;do{n|=1&t,t>>>=1,n<<=1}while(--e>0);return n>>>1},dt=(t,e,n)=>{const i=new Array(16);let r,s,o=0;for(r=1;r<=15;r++)o=o+n[r-1]<<1,i[r]=o;for(s=0;s<=e;s++){let e=t[2*s+1];0!==e&&(t[2*s]=ct(i[e]++,e))}},ht=t=>{let e;for(e=0;e<286;e++)t.dyn_ltree[2*e]=0;for(e=0;e<30;e++)t.dyn_dtree[2*e]=0;for(e=0;e<19;e++)t.bl_tree[2*e]=0;t.dyn_ltree[512]=1,t.opt_len=t.static_len=0,t.sym_next=t.matches=0},ut=t=>{t.bi_valid>8?ot(t,t.bi_buf):t.bi_valid>0&&(t.pending_buf[t.pending++]=t.bi_buf),t.bi_buf=0,t.bi_valid=0},pt=(t,e,n,i)=>{const r=2*e,s=2*n;return t[r]<t[s]||t[r]===t[s]&&i[e]<=i[n]},gt=(t,e,n)=>{const i=t.heap[n];let r=n<<1;for(;r<=t.heap_len&&(r<t.heap_len&&pt(e,t.heap[r+1],t.heap[r],t.depth)&&r++,!pt(e,i,t.heap[r],t.depth));)t.heap[n]=t.heap[r],n=r,r<<=1;t.heap[n]=i},mt=(t,e,n)=>{let i,r,s,o,a=0;if(0!==t.sym_next)do{i=255&t.pending_buf[t.sym_buf+a++],i+=(255&t.pending_buf[t.sym_buf+a++])<<8,r=t.pending_buf[t.sym_buf+a++],0===i?lt(t,r,e):(s=Q[r],lt(t,s+256+1,e),o=G[s],0!==o&&(r-=J[s],at(t,r,o)),i--,s=st(i),lt(t,s,n),o=j[s],0!==o&&(i-=X[s],at(t,i,o)))}while(a<t.sym_next);lt(t,256,e)},ft=(t,e)=>{const n=e.dyn_tree,i=e.stat_desc.static_tree,r=e.stat_desc.has_stree,s=e.stat_desc.elems;let o,a,l,c=-1;for(t.heap_len=0,t.heap_max=573,o=0;o<s;o++)0!==n[2*o]?(t.heap[++t.heap_len]=c=o,t.depth[o]=0):n[2*o+1]=0;for(;t.heap_len<2;)l=t.heap[++t.heap_len]=c<2?++c:0,n[2*l]=1,t.depth[l]=0,t.opt_len--,r&&(t.static_len-=i[2*l+1]);for(e.max_code=c,o=t.heap_len>>1;o>=1;o--)gt(t,n,o);l=s;do{o=t.heap[1],t.heap[1]=t.heap[t.heap_len--],gt(t,n,1),a=t.heap[1],t.heap[--t.heap_max]=o,t.heap[--t.heap_max]=a,n[2*l]=n[2*o]+n[2*a],t.depth[l]=(t.depth[o]>=t.depth[a]?t.depth[o]:t.depth[a])+1,n[2*o+1]=n[2*a+1]=l,t.heap[1]=l++,gt(t,n,1)}while(t.heap_len>=2);t.heap[--t.heap_max]=t.heap[1],((t,e)=>{const n=e.dyn_tree,i=e.max_code,r=e.stat_desc.static_tree,s=e.stat_desc.has_stree,o=e.stat_desc.extra_bits,a=e.stat_desc.extra_base,l=e.stat_desc.max_length;let c,d,h,u,p,g,m=0;for(u=0;u<=15;u++)t.bl_count[u]=0;for(n[2*t.heap[t.heap_max]+1]=0,c=t.heap_max+1;c<573;c++)d=t.heap[c],u=n[2*n[2*d+1]+1]+1,u>l&&(u=l,m++),n[2*d+1]=u,d>i||(t.bl_count[u]++,p=0,d>=a&&(p=o[d-a]),g=n[2*d],t.opt_len+=g*(u+p),s&&(t.static_len+=g*(r[2*d+1]+p)));if(0!==m){do{for(u=l-1;0===t.bl_count[u];)u--;t.bl_count[u]--,t.bl_count[u+1]+=2,t.bl_count[l]--,m-=2}while(m>0);for(u=l;0!==u;u--)for(d=t.bl_count[u];0!==d;)h=t.heap[--c],h>i||(n[2*h+1]!==u&&(t.opt_len+=(u-n[2*h+1])*n[2*h],n[2*h+1]=u),d--)}})(t,e),dt(n,c,t.bl_count)},yt=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),e[2*(n+1)+1]=65535,i=0;i<=n;i++)r=o,o=e[2*(i+1)+1],++a<l&&r===o||(a<c?t.bl_tree[2*r]+=a:0!==r?(r!==s&&t.bl_tree[2*r]++,t.bl_tree[32]++):a<=10?t.bl_tree[34]++:t.bl_tree[36]++,a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4))},bt=(t,e,n)=>{let i,r,s=-1,o=e[1],a=0,l=7,c=4;for(0===o&&(l=138,c=3),i=0;i<=n;i++)if(r=o,o=e[2*(i+1)+1],!(++a<l&&r===o)){if(a<c)do{lt(t,r,t.bl_tree)}while(0!==--a);else 0!==r?(r!==s&&(lt(t,r,t.bl_tree),a--),lt(t,16,t.bl_tree),at(t,a-3,2)):a<=10?(lt(t,17,t.bl_tree),at(t,a-3,3)):(lt(t,18,t.bl_tree),at(t,a-11,7));a=0,s=r,0===o?(l=138,c=3):r===o?(l=6,c=3):(l=7,c=4)}};let wt=!1;const vt=(t,e,n,i)=>{at(t,0+(i?1:0),3),ut(t),ot(t,n),ot(t,~n),n&&t.pending_buf.set(t.window.subarray(e,e+n),t.pending),t.pending+=n};var Ct={_tr_init:t=>{wt||((()=>{let t,e,n,i,r;const s=new Array(16);for(n=0,i=0;i<28;i++)for(J[i]=n,t=0;t<1<<G[i];t++)Q[n++]=i;for(Q[n-1]=i,r=0,i=0;i<16;i++)for(X[i]=r,t=0;t<1<<j[i];t++)Y[r++]=i;for(r>>=7;i<30;i++)for(X[i]=r<<7,t=0;t<1<<j[i]-7;t++)Y[256+r++]=i;for(e=0;e<=15;e++)s[e]=0;for(t=0;t<=143;)K[2*t+1]=8,t++,s[8]++;for(;t<=255;)K[2*t+1]=9,t++,s[9]++;for(;t<=279;)K[2*t+1]=7,t++,s[7]++;for(;t<=287;)K[2*t+1]=8,t++,s[8]++;for(dt(K,287,s),t=0;t<30;t++)$[2*t+1]=5,$[2*t]=ct(t,5);et=new tt(K,G,257,286,15),nt=new tt($,j,0,30,15),it=new tt(new Array(0),q,0,19,7)})(),wt=!0),t.l_desc=new rt(t.dyn_ltree,et),t.d_desc=new rt(t.dyn_dtree,nt),t.bl_desc=new rt(t.bl_tree,it),t.bi_buf=0,t.bi_valid=0,ht(t)},_tr_stored_block:vt,_tr_flush_block:(t,e,n,i)=>{let r,s,o=0;t.level>0?(2===t.strm.data_type&&(t.strm.data_type=(t=>{let e,n=4093624447;for(e=0;e<=31;e++,n>>>=1)if(1&n&&0!==t.dyn_ltree[2*e])return 0;if(0!==t.dyn_ltree[18]||0!==t.dyn_ltree[20]||0!==t.dyn_ltree[26])return 1;for(e=32;e<256;e++)if(0!==t.dyn_ltree[2*e])return 1;return 0})(t)),ft(t,t.l_desc),ft(t,t.d_desc),o=(t=>{let e;for(yt(t,t.dyn_ltree,t.l_desc.max_code),yt(t,t.dyn_dtree,t.d_desc.max_code),ft(t,t.bl_desc),e=18;e>=3&&0===t.bl_tree[2*H[e]+1];e--);return t.opt_len+=3*(e+1)+5+5+4,e})(t),r=t.opt_len+3+7>>>3,s=t.static_len+3+7>>>3,s<=r&&(r=s)):r=s=n+5,n+4<=r&&-1!==e?vt(t,e,n,i):4===t.strategy||s===r?(at(t,2+(i?1:0),3),mt(t,K,$)):(at(t,4+(i?1:0),3),((t,e,n,i)=>{let r;for(at(t,e-257,5),at(t,n-1,5),at(t,i-4,4),r=0;r<i;r++)at(t,t.bl_tree[2*H[r]+1],3);bt(t,t.dyn_ltree,e-1),bt(t,t.dyn_dtree,n-1)})(t,t.l_desc.max_code+1,t.d_desc.max_code+1,o+1),mt(t,t.dyn_ltree,t.dyn_dtree)),ht(t),i&&ut(t)},_tr_tally:(t,e,n)=>(t.pending_buf[t.sym_buf+t.sym_next++]=e,t.pending_buf[t.sym_buf+t.sym_next++]=e>>8,t.pending_buf[t.sym_buf+t.sym_next++]=n,0===e?t.dyn_ltree[2*n]++:(t.matches++,e--,t.dyn_ltree[2*(Q[n]+256+1)]++,t.dyn_dtree[2*st(e)]++),t.sym_next===t.sym_end),_tr_align:t=>{at(t,2,3),lt(t,256,K),(t=>{16===t.bi_valid?(ot(t,t.bi_buf),t.bi_buf=0,t.bi_valid=0):t.bi_valid>=8&&(t.pending_buf[t.pending++]=255&t.bi_buf,t.bi_buf>>=8,t.bi_valid-=8)})(t)}},It=(t,e,n,i)=>{let r=65535&t,s=t>>>16&65535,o=0;for(;0!==n;){o=n>2e3?2e3:n,n-=o;do{r=r+e[i++]|0,s=s+r|0}while(--o);r%=65521,s%=65521}return r|s<<16};const _t=new Uint32Array((()=>{let t,e=[];for(var n=0;n<256;n++){t=n;for(var i=0;i<8;i++)t=1&t?3988292384^t>>>1:t>>>1;e[n]=t}return e})());var St=(t,e,n,i)=>{const r=_t,s=i+n;t^=-1;for(let n=i;n<s;n++)t=t>>>8^r[255&(t^e[n])];return-1^t},kt={2:"need dictionary",1:"stream end",0:"","-1":"file error","-2":"stream error","-3":"data error","-4":"insufficient memory","-5":"buffer error","-6":"incompatible version"},xt={Z_NO_FLUSH:0,Z_PARTIAL_FLUSH:1,Z_SYNC_FLUSH:2,Z_FULL_FLUSH:3,Z_FINISH:4,Z_BLOCK:5,Z_TREES:6,Z_OK:0,Z_STREAM_END:1,Z_NEED_DICT:2,Z_ERRNO:-1,Z_STREAM_ERROR:-2,Z_DATA_ERROR:-3,Z_MEM_ERROR:-4,Z_BUF_ERROR:-5,Z_NO_COMPRESSION:0,Z_BEST_SPEED:1,Z_BEST_COMPRESSION:9,Z_DEFAULT_COMPRESSION:-1,Z_FILTERED:1,Z_HUFFMAN_ONLY:2,Z_RLE:3,Z_FIXED:4,Z_DEFAULT_STRATEGY:0,Z_BINARY:0,Z_TEXT:1,Z_UNKNOWN:2,Z_DEFLATED:8};const{_tr_init:At,_tr_stored_block:Et,_tr_flush_block:Rt,_tr_tally:Mt,_tr_align:Tt}=Ct,{Z_NO_FLUSH:Ot,Z_PARTIAL_FLUSH:zt,Z_FULL_FLUSH:Lt,Z_FINISH:Dt,Z_BLOCK:Nt,Z_OK:Ft,Z_STREAM_END:Bt,Z_STREAM_ERROR:Ut,Z_DATA_ERROR:Zt,Z_BUF_ERROR:Pt,Z_DEFAULT_COMPRESSION:Wt,Z_FILTERED:Vt,Z_HUFFMAN_ONLY:Gt,Z_RLE:jt,Z_FIXED:qt,Z_DEFAULT_STRATEGY:Ht,Z_UNKNOWN:Kt,Z_DEFLATED:$t}=xt,Yt=258,Qt=262,Jt=42,Xt=113,te=666,ee=(t,e)=>(t.msg=kt[e],e),ne=t=>2*t-(t>4?9:0),ie=t=>{let e=t.length;for(;--e>=0;)t[e]=0},re=t=>{let e,n,i,r=t.w_size;e=t.hash_size,i=e;do{n=t.head[--i],t.head[i]=n>=r?n-r:0}while(--e);e=r,i=e;do{n=t.prev[--i],t.prev[i]=n>=r?n-r:0}while(--e)};let se=(t,e,n)=>(e<<t.hash_shift^n)&t.hash_mask;const oe=t=>{const e=t.state;let n=e.pending;n>t.avail_out&&(n=t.avail_out),0!==n&&(t.output.set(e.pending_buf.subarray(e.pending_out,e.pending_out+n),t.next_out),t.next_out+=n,e.pending_out+=n,t.total_out+=n,t.avail_out-=n,e.pending-=n,0===e.pending&&(e.pending_out=0))},ae=(t,e)=>{Rt(t,t.block_start>=0?t.block_start:-1,t.strstart-t.block_start,e),t.block_start=t.strstart,oe(t.strm)},le=(t,e)=>{t.pending_buf[t.pending++]=e},ce=(t,e)=>{t.pending_buf[t.pending++]=e>>>8&255,t.pending_buf[t.pending++]=255&e},de=(t,e,n,i)=>{let r=t.avail_in;return r>i&&(r=i),0===r?0:(t.avail_in-=r,e.set(t.input.subarray(t.next_in,t.next_in+r),n),1===t.state.wrap?t.adler=It(t.adler,e,r,n):2===t.state.wrap&&(t.adler=St(t.adler,e,r,n)),t.next_in+=r,t.total_in+=r,r)},he=(t,e)=>{let n,i,r=t.max_chain_length,s=t.strstart,o=t.prev_length,a=t.nice_match;const l=t.strstart>t.w_size-Qt?t.strstart-(t.w_size-Qt):0,c=t.window,d=t.w_mask,h=t.prev,u=t.strstart+Yt;let p=c[s+o-1],g=c[s+o];t.prev_length>=t.good_match&&(r>>=2),a>t.lookahead&&(a=t.lookahead);do{if(n=e,c[n+o]===g&&c[n+o-1]===p&&c[n]===c[s]&&c[++n]===c[s+1]){s+=2,n++;do{}while(c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&c[++s]===c[++n]&&s<u);if(i=Yt-(u-s),s=u-Yt,i>o){if(t.match_start=e,o=i,i>=a)break;p=c[s+o-1],g=c[s+o]}}}while((e=h[e&d])>l&&0!==--r);return o<=t.lookahead?o:t.lookahead},ue=t=>{const e=t.w_size;let n,i,r;do{if(i=t.window_size-t.lookahead-t.strstart,t.strstart>=e+(e-Qt)&&(t.window.set(t.window.subarray(e,e+e-i),0),t.match_start-=e,t.strstart-=e,t.block_start-=e,t.insert>t.strstart&&(t.insert=t.strstart),re(t),i+=e),0===t.strm.avail_in)break;if(n=de(t.strm,t.window,t.strstart+t.lookahead,i),t.lookahead+=n,t.lookahead+t.insert>=3)for(r=t.strstart-t.insert,t.ins_h=t.window[r],t.ins_h=se(t,t.ins_h,t.window[r+1]);t.insert&&(t.ins_h=se(t,t.ins_h,t.window[r+3-1]),t.prev[r&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=r,r++,t.insert--,!(t.lookahead+t.insert<3)););}while(t.lookahead<Qt&&0!==t.strm.avail_in)},pe=(t,e)=>{let n,i,r,s=t.pending_buf_size-5>t.w_size?t.w_size:t.pending_buf_size-5,o=0,a=t.strm.avail_in;do{if(n=65535,r=t.bi_valid+42>>3,t.strm.avail_out<r)break;if(r=t.strm.avail_out-r,i=t.strstart-t.block_start,n>i+t.strm.avail_in&&(n=i+t.strm.avail_in),n>r&&(n=r),n<s&&(0===n&&e!==Dt||e===Ot||n!==i+t.strm.avail_in))break;o=e===Dt&&n===i+t.strm.avail_in?1:0,Et(t,0,0,o),t.pending_buf[t.pending-4]=n,t.pending_buf[t.pending-3]=n>>8,t.pending_buf[t.pending-2]=~n,t.pending_buf[t.pending-1]=~n>>8,oe(t.strm),i&&(i>n&&(i=n),t.strm.output.set(t.window.subarray(t.block_start,t.block_start+i),t.strm.next_out),t.strm.next_out+=i,t.strm.avail_out-=i,t.strm.total_out+=i,t.block_start+=i,n-=i),n&&(de(t.strm,t.strm.output,t.strm.next_out,n),t.strm.next_out+=n,t.strm.avail_out-=n,t.strm.total_out+=n)}while(0===o);return a-=t.strm.avail_in,a&&(a>=t.w_size?(t.matches=2,t.window.set(t.strm.input.subarray(t.strm.next_in-t.w_size,t.strm.next_in),0),t.strstart=t.w_size,t.insert=t.strstart):(t.window_size-t.strstart<=a&&(t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,t.insert>t.strstart&&(t.insert=t.strstart)),t.window.set(t.strm.input.subarray(t.strm.next_in-a,t.strm.next_in),t.strstart),t.strstart+=a,t.insert+=a>t.w_size-t.insert?t.w_size-t.insert:a),t.block_start=t.strstart),t.high_water<t.strstart&&(t.high_water=t.strstart),o?4:e!==Ot&&e!==Dt&&0===t.strm.avail_in&&t.strstart===t.block_start?2:(r=t.window_size-t.strstart,t.strm.avail_in>r&&t.block_start>=t.w_size&&(t.block_start-=t.w_size,t.strstart-=t.w_size,t.window.set(t.window.subarray(t.w_size,t.w_size+t.strstart),0),t.matches<2&&t.matches++,r+=t.w_size,t.insert>t.strstart&&(t.insert=t.strstart)),r>t.strm.avail_in&&(r=t.strm.avail_in),r&&(de(t.strm,t.window,t.strstart,r),t.strstart+=r,t.insert+=r>t.w_size-t.insert?t.w_size-t.insert:r),t.high_water<t.strstart&&(t.high_water=t.strstart),r=t.bi_valid+42>>3,r=t.pending_buf_size-r>65535?65535:t.pending_buf_size-r,s=r>t.w_size?t.w_size:r,i=t.strstart-t.block_start,(i>=s||(i||e===Dt)&&e!==Ot&&0===t.strm.avail_in&&i<=r)&&(n=i>r?r:i,o=e===Dt&&0===t.strm.avail_in&&n===i?1:0,Et(t,t.block_start,n,o),t.block_start+=n,oe(t.strm)),o?3:1)},ge=(t,e)=>{let n,i;for(;;){if(t.lookahead<Qt){if(ue(t),t.lookahead<Qt&&e===Ot)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),0!==n&&t.strstart-n<=t.w_size-Qt&&(t.match_length=he(t,n)),t.match_length>=3)if(i=Mt(t,t.strstart-t.match_start,t.match_length-3),t.lookahead-=t.match_length,t.match_length<=t.max_lazy_match&&t.lookahead>=3){t.match_length--;do{t.strstart++,t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart}while(0!==--t.match_length);t.strstart++}else t.strstart+=t.match_length,t.match_length=0,t.ins_h=t.window[t.strstart],t.ins_h=se(t,t.ins_h,t.window[t.strstart+1]);else i=Mt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++;if(i&&(ae(t,!1),0===t.strm.avail_out))return 1}return t.insert=t.strstart<2?t.strstart:2,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2},me=(t,e)=>{let n,i,r;for(;;){if(t.lookahead<Qt){if(ue(t),t.lookahead<Qt&&e===Ot)return 1;if(0===t.lookahead)break}if(n=0,t.lookahead>=3&&(t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart),t.prev_length=t.match_length,t.prev_match=t.match_start,t.match_length=2,0!==n&&t.prev_length<t.max_lazy_match&&t.strstart-n<=t.w_size-Qt&&(t.match_length=he(t,n),t.match_length<=5&&(t.strategy===Vt||3===t.match_length&&t.strstart-t.match_start>4096)&&(t.match_length=2)),t.prev_length>=3&&t.match_length<=t.prev_length){r=t.strstart+t.lookahead-3,i=Mt(t,t.strstart-1-t.prev_match,t.prev_length-3),t.lookahead-=t.prev_length-1,t.prev_length-=2;do{++t.strstart<=r&&(t.ins_h=se(t,t.ins_h,t.window[t.strstart+3-1]),n=t.prev[t.strstart&t.w_mask]=t.head[t.ins_h],t.head[t.ins_h]=t.strstart)}while(0!==--t.prev_length);if(t.match_available=0,t.match_length=2,t.strstart++,i&&(ae(t,!1),0===t.strm.avail_out))return 1}else if(t.match_available){if(i=Mt(t,0,t.window[t.strstart-1]),i&&ae(t,!1),t.strstart++,t.lookahead--,0===t.strm.avail_out)return 1}else t.match_available=1,t.strstart++,t.lookahead--}return t.match_available&&(i=Mt(t,0,t.window[t.strstart-1]),t.match_available=0),t.insert=t.strstart<2?t.strstart:2,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2};function fe(t,e,n,i,r){this.good_length=t,this.max_lazy=e,this.nice_length=n,this.max_chain=i,this.func=r}const ye=[new fe(0,0,0,0,pe),new fe(4,4,8,4,ge),new fe(4,5,16,8,ge),new fe(4,6,32,32,ge),new fe(4,4,16,16,me),new fe(8,16,32,32,me),new fe(8,16,128,128,me),new fe(8,32,128,256,me),new fe(32,128,258,1024,me),new fe(32,258,258,4096,me)];function be(){this.strm=null,this.status=0,this.pending_buf=null,this.pending_buf_size=0,this.pending_out=0,this.pending=0,this.wrap=0,this.gzhead=null,this.gzindex=0,this.method=$t,this.last_flush=-1,this.w_size=0,this.w_bits=0,this.w_mask=0,this.window=null,this.window_size=0,this.prev=null,this.head=null,this.ins_h=0,this.hash_size=0,this.hash_bits=0,this.hash_mask=0,this.hash_shift=0,this.block_start=0,this.match_length=0,this.prev_match=0,this.match_available=0,this.strstart=0,this.match_start=0,this.lookahead=0,this.prev_length=0,this.max_chain_length=0,this.max_lazy_match=0,this.level=0,this.strategy=0,this.good_match=0,this.nice_match=0,this.dyn_ltree=new Uint16Array(1146),this.dyn_dtree=new Uint16Array(122),this.bl_tree=new Uint16Array(78),ie(this.dyn_ltree),ie(this.dyn_dtree),ie(this.bl_tree),this.l_desc=null,this.d_desc=null,this.bl_desc=null,this.bl_count=new Uint16Array(16),this.heap=new Uint16Array(573),ie(this.heap),this.heap_len=0,this.heap_max=0,this.depth=new Uint16Array(573),ie(this.depth),this.sym_buf=0,this.lit_bufsize=0,this.sym_next=0,this.sym_end=0,this.opt_len=0,this.static_len=0,this.matches=0,this.insert=0,this.bi_buf=0,this.bi_valid=0}const we=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.status!==Jt&&57!==e.status&&69!==e.status&&73!==e.status&&91!==e.status&&103!==e.status&&e.status!==Xt&&e.status!==te?1:0},ve=t=>{if(we(t))return ee(t,Ut);t.total_in=t.total_out=0,t.data_type=Kt;const e=t.state;return e.pending=0,e.pending_out=0,e.wrap<0&&(e.wrap=-e.wrap),e.status=2===e.wrap?57:e.wrap?Jt:Xt,t.adler=2===e.wrap?0:1,e.last_flush=-2,At(e),Ft},Ce=t=>{const e=ve(t);var n;return e===Ft&&((n=t.state).window_size=2*n.w_size,ie(n.head),n.max_lazy_match=ye[n.level].max_lazy,n.good_match=ye[n.level].good_length,n.nice_match=ye[n.level].nice_length,n.max_chain_length=ye[n.level].max_chain,n.strstart=0,n.block_start=0,n.lookahead=0,n.insert=0,n.match_length=n.prev_length=2,n.match_available=0,n.ins_h=0),e},Ie=(t,e,n,i,r,s)=>{if(!t)return Ut;let o=1;if(e===Wt&&(e=6),i<0?(o=0,i=-i):i>15&&(o=2,i-=16),r<1||r>9||n!==$t||i<8||i>15||e<0||e>9||s<0||s>qt||8===i&&1!==o)return ee(t,Ut);8===i&&(i=9);const a=new be;return t.state=a,a.strm=t,a.status=Jt,a.wrap=o,a.gzhead=null,a.w_bits=i,a.w_size=1<<a.w_bits,a.w_mask=a.w_size-1,a.hash_bits=r+7,a.hash_size=1<<a.hash_bits,a.hash_mask=a.hash_size-1,a.hash_shift=~~((a.hash_bits+3-1)/3),a.window=new Uint8Array(2*a.w_size),a.head=new Uint16Array(a.hash_size),a.prev=new Uint16Array(a.w_size),a.lit_bufsize=1<<r+6,a.pending_buf_size=4*a.lit_bufsize,a.pending_buf=new Uint8Array(a.pending_buf_size),a.sym_buf=a.lit_bufsize,a.sym_end=3*(a.lit_bufsize-1),a.level=e,a.strategy=s,a.method=n,Ce(t)};var _e=Ie,Se=(t,e)=>we(t)||2!==t.state.wrap?Ut:(t.state.gzhead=e,Ft),ke=(t,e)=>{if(we(t)||e>Nt||e<0)return t?ee(t,Ut):Ut;const n=t.state;if(!t.output||0!==t.avail_in&&!t.input||n.status===te&&e!==Dt)return ee(t,0===t.avail_out?Pt:Ut);const i=n.last_flush;if(n.last_flush=e,0!==n.pending){if(oe(t),0===t.avail_out)return n.last_flush=-1,Ft}else if(0===t.avail_in&&ne(e)<=ne(i)&&e!==Dt)return ee(t,Pt);if(n.status===te&&0!==t.avail_in)return ee(t,Pt);if(n.status===Jt&&0===n.wrap&&(n.status=Xt),n.status===Jt){let e=$t+(n.w_bits-8<<4)<<8,i=-1;if(i=n.strategy>=Gt||n.level<2?0:n.level<6?1:6===n.level?2:3,e|=i<<6,0!==n.strstart&&(e|=32),e+=31-e%31,ce(n,e),0!==n.strstart&&(ce(n,t.adler>>>16),ce(n,65535&t.adler)),t.adler=1,n.status=Xt,oe(t),0!==n.pending)return n.last_flush=-1,Ft}if(57===n.status)if(t.adler=0,le(n,31),le(n,139),le(n,8),n.gzhead)le(n,(n.gzhead.text?1:0)+(n.gzhead.hcrc?2:0)+(n.gzhead.extra?4:0)+(n.gzhead.name?8:0)+(n.gzhead.comment?16:0)),le(n,255&n.gzhead.time),le(n,n.gzhead.time>>8&255),le(n,n.gzhead.time>>16&255),le(n,n.gzhead.time>>24&255),le(n,9===n.level?2:n.strategy>=Gt||n.level<2?4:0),le(n,255&n.gzhead.os),n.gzhead.extra&&n.gzhead.extra.length&&(le(n,255&n.gzhead.extra.length),le(n,n.gzhead.extra.length>>8&255)),n.gzhead.hcrc&&(t.adler=St(t.adler,n.pending_buf,n.pending,0)),n.gzindex=0,n.status=69;else if(le(n,0),le(n,0),le(n,0),le(n,0),le(n,0),le(n,9===n.level?2:n.strategy>=Gt||n.level<2?4:0),le(n,3),n.status=Xt,oe(t),0!==n.pending)return n.last_flush=-1,Ft;if(69===n.status){if(n.gzhead.extra){let e=n.pending,i=(65535&n.gzhead.extra.length)-n.gzindex;for(;n.pending+i>n.pending_buf_size;){let r=n.pending_buf_size-n.pending;if(n.pending_buf.set(n.gzhead.extra.subarray(n.gzindex,n.gzindex+r),n.pending),n.pending=n.pending_buf_size,n.gzhead.hcrc&&n.pending>e&&(t.adler=St(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex+=r,oe(t),0!==n.pending)return n.last_flush=-1,Ft;e=0,i-=r}let r=new Uint8Array(n.gzhead.extra);n.pending_buf.set(r.subarray(n.gzindex,n.gzindex+i),n.pending),n.pending+=i,n.gzhead.hcrc&&n.pending>e&&(t.adler=St(t.adler,n.pending_buf,n.pending-e,e)),n.gzindex=0}n.status=73}if(73===n.status){if(n.gzhead.name){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i)),oe(t),0!==n.pending)return n.last_flush=-1,Ft;i=0}e=n.gzindex<n.gzhead.name.length?255&n.gzhead.name.charCodeAt(n.gzindex++):0,le(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i)),n.gzindex=0}n.status=91}if(91===n.status){if(n.gzhead.comment){let e,i=n.pending;do{if(n.pending===n.pending_buf_size){if(n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i)),oe(t),0!==n.pending)return n.last_flush=-1,Ft;i=0}e=n.gzindex<n.gzhead.comment.length?255&n.gzhead.comment.charCodeAt(n.gzindex++):0,le(n,e)}while(0!==e);n.gzhead.hcrc&&n.pending>i&&(t.adler=St(t.adler,n.pending_buf,n.pending-i,i))}n.status=103}if(103===n.status){if(n.gzhead.hcrc){if(n.pending+2>n.pending_buf_size&&(oe(t),0!==n.pending))return n.last_flush=-1,Ft;le(n,255&t.adler),le(n,t.adler>>8&255),t.adler=0}if(n.status=Xt,oe(t),0!==n.pending)return n.last_flush=-1,Ft}if(0!==t.avail_in||0!==n.lookahead||e!==Ot&&n.status!==te){let i=0===n.level?pe(n,e):n.strategy===Gt?((t,e)=>{let n;for(;;){if(0===t.lookahead&&(ue(t),0===t.lookahead)){if(e===Ot)return 1;break}if(t.match_length=0,n=Mt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++,n&&(ae(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2})(n,e):n.strategy===jt?((t,e)=>{let n,i,r,s;const o=t.window;for(;;){if(t.lookahead<=Yt){if(ue(t),t.lookahead<=Yt&&e===Ot)return 1;if(0===t.lookahead)break}if(t.match_length=0,t.lookahead>=3&&t.strstart>0&&(r=t.strstart-1,i=o[r],i===o[++r]&&i===o[++r]&&i===o[++r])){s=t.strstart+Yt;do{}while(i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&i===o[++r]&&r<s);t.match_length=Yt-(s-r),t.match_length>t.lookahead&&(t.match_length=t.lookahead)}if(t.match_length>=3?(n=Mt(t,1,t.match_length-3),t.lookahead-=t.match_length,t.strstart+=t.match_length,t.match_length=0):(n=Mt(t,0,t.window[t.strstart]),t.lookahead--,t.strstart++),n&&(ae(t,!1),0===t.strm.avail_out))return 1}return t.insert=0,e===Dt?(ae(t,!0),0===t.strm.avail_out?3:4):t.sym_next&&(ae(t,!1),0===t.strm.avail_out)?1:2})(n,e):ye[n.level].func(n,e);if(3!==i&&4!==i||(n.status=te),1===i||3===i)return 0===t.avail_out&&(n.last_flush=-1),Ft;if(2===i&&(e===zt?Tt(n):e!==Nt&&(Et(n,0,0,!1),e===Lt&&(ie(n.head),0===n.lookahead&&(n.strstart=0,n.block_start=0,n.insert=0))),oe(t),0===t.avail_out))return n.last_flush=-1,Ft}return e!==Dt?Ft:n.wrap<=0?Bt:(2===n.wrap?(le(n,255&t.adler),le(n,t.adler>>8&255),le(n,t.adler>>16&255),le(n,t.adler>>24&255),le(n,255&t.total_in),le(n,t.total_in>>8&255),le(n,t.total_in>>16&255),le(n,t.total_in>>24&255)):(ce(n,t.adler>>>16),ce(n,65535&t.adler)),oe(t),n.wrap>0&&(n.wrap=-n.wrap),0!==n.pending?Ft:Bt)},xe=t=>{if(we(t))return Ut;const e=t.state.status;return t.state=null,e===Xt?ee(t,Zt):Ft},Ae=(t,e)=>{let n=e.length;if(we(t))return Ut;const i=t.state,r=i.wrap;if(2===r||1===r&&i.status!==Jt||i.lookahead)return Ut;if(1===r&&(t.adler=It(t.adler,e,n,0)),i.wrap=0,n>=i.w_size){0===r&&(ie(i.head),i.strstart=0,i.block_start=0,i.insert=0);let t=new Uint8Array(i.w_size);t.set(e.subarray(n-i.w_size,n),0),e=t,n=i.w_size}const s=t.avail_in,o=t.next_in,a=t.input;for(t.avail_in=n,t.next_in=0,t.input=e,ue(i);i.lookahead>=3;){let t=i.strstart,e=i.lookahead-2;do{i.ins_h=se(i,i.ins_h,i.window[t+3-1]),i.prev[t&i.w_mask]=i.head[i.ins_h],i.head[i.ins_h]=t,t++}while(--e);i.strstart=t,i.lookahead=2,ue(i)}return i.strstart+=i.lookahead,i.block_start=i.strstart,i.insert=i.lookahead,i.lookahead=0,i.match_length=i.prev_length=2,i.match_available=0,t.next_in=o,t.input=a,t.avail_in=s,i.wrap=r,Ft};const Ee=(t,e)=>Object.prototype.hasOwnProperty.call(t,e);var Re=function(t){const e=Array.prototype.slice.call(arguments,1);for(;e.length;){const n=e.shift();if(n){if("object"!=typeof n)throw new TypeError(n+"must be non-object");for(const e in n)Ee(n,e)&&(t[e]=n[e])}}return t},Me=t=>{let e=0;for(let n=0,i=t.length;n<i;n++)e+=t[n].length;const n=new Uint8Array(e);for(let e=0,i=0,r=t.length;e<r;e++){let r=t[e];n.set(r,i),i+=r.length}return n};let Te=!0;try{String.fromCharCode.apply(null,new Uint8Array(1))}catch(t){Te=!1}const Oe=new Uint8Array(256);for(let t=0;t<256;t++)Oe[t]=t>=252?6:t>=248?5:t>=240?4:t>=224?3:t>=192?2:1;Oe[254]=Oe[254]=1;var ze=t=>{if("function"==typeof TextEncoder&&TextEncoder.prototype.encode)return(new TextEncoder).encode(t);let e,n,i,r,s,o=t.length,a=0;for(r=0;r<o;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),a+=n<128?1:n<2048?2:n<65536?3:4;for(e=new Uint8Array(a),s=0,r=0;s<a;r++)n=t.charCodeAt(r),55296==(64512&n)&&r+1<o&&(i=t.charCodeAt(r+1),56320==(64512&i)&&(n=65536+(n-55296<<10)+(i-56320),r++)),n<128?e[s++]=n:n<2048?(e[s++]=192|n>>>6,e[s++]=128|63&n):n<65536?(e[s++]=224|n>>>12,e[s++]=128|n>>>6&63,e[s++]=128|63&n):(e[s++]=240|n>>>18,e[s++]=128|n>>>12&63,e[s++]=128|n>>>6&63,e[s++]=128|63&n);return e},Le=(t,e)=>{const n=e||t.length;if("function"==typeof TextDecoder&&TextDecoder.prototype.decode)return(new TextDecoder).decode(t.subarray(0,e));let i,r;const s=new Array(2*n);for(r=0,i=0;i<n;){let e=t[i++];if(e<128){s[r++]=e;continue}let o=Oe[e];if(o>4)s[r++]=65533,i+=o-1;else{for(e&=2===o?31:3===o?15:7;o>1&&i<n;)e=e<<6|63&t[i++],o--;o>1?s[r++]=65533:e<65536?s[r++]=e:(e-=65536,s[r++]=55296|e>>10&1023,s[r++]=56320|1023&e)}}return((t,e)=>{if(e<65534&&t.subarray&&Te)return String.fromCharCode.apply(null,t.length===e?t:t.subarray(0,e));let n="";for(let i=0;i<e;i++)n+=String.fromCharCode(t[i]);return n})(s,r)},De=(t,e)=>{(e=e||t.length)>t.length&&(e=t.length);let n=e-1;for(;n>=0&&128==(192&t[n]);)n--;return n<0||0===n?e:n+Oe[t[n]]>e?n:e},Ne=function(){this.input=null,this.next_in=0,this.avail_in=0,this.total_in=0,this.output=null,this.next_out=0,this.avail_out=0,this.total_out=0,this.msg="",this.state=null,this.data_type=2,this.adler=0};const Fe=Object.prototype.toString,{Z_NO_FLUSH:Be,Z_SYNC_FLUSH:Ue,Z_FULL_FLUSH:Ze,Z_FINISH:Pe,Z_OK:We,Z_STREAM_END:Ve,Z_DEFAULT_COMPRESSION:Ge,Z_DEFAULT_STRATEGY:je,Z_DEFLATED:qe}=xt;function He(t){this.options=Re({level:Ge,method:qe,chunkSize:16384,windowBits:15,memLevel:8,strategy:je},t||{});let e=this.options;e.raw&&e.windowBits>0?e.windowBits=-e.windowBits:e.gzip&&e.windowBits>0&&e.windowBits<16&&(e.windowBits+=16),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ne,this.strm.avail_out=0;let n=_e(this.strm,e.level,e.method,e.windowBits,e.memLevel,e.strategy);if(n!==We)throw new Error(kt[n]);if(e.header&&Se(this.strm,e.header),e.dictionary){let t;if(t="string"==typeof e.dictionary?ze(e.dictionary):"[object ArrayBuffer]"===Fe.call(e.dictionary)?new Uint8Array(e.dictionary):e.dictionary,n=Ae(this.strm,t),n!==We)throw new Error(kt[n]);this._dict_set=!0}}function Ke(t,e){const n=new He(e);if(n.push(t,!0),n.err)throw n.msg||kt[n.err];return n.result}He.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize;let r,s;if(this.ended)return!1;for(s=e===~~e?e:!0===e?Pe:Be,"string"==typeof t?n.input=ze(t):"[object ArrayBuffer]"===Fe.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;)if(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),(s===Ue||s===Ze)&&n.avail_out<=6)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else{if(r=ke(n,s),r===Ve)return n.next_out>0&&this.onData(n.output.subarray(0,n.next_out)),r=xe(this.strm),this.onEnd(r),this.ended=!0,r===We;if(0!==n.avail_out){if(s>0&&n.next_out>0)this.onData(n.output.subarray(0,n.next_out)),n.avail_out=0;else if(0===n.avail_in)break}else this.onData(n.output)}return!0},He.prototype.onData=function(t){this.chunks.push(t)},He.prototype.onEnd=function(t){t===We&&(this.result=Me(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var $e={Deflate:He,deflate:Ke,deflateRaw:function(t,e){return(e=e||{}).raw=!0,Ke(t,e)},gzip:function(t,e){return(e=e||{}).gzip=!0,Ke(t,e)},constants:xt};const Ye=16209;var Qe=function(t,e){let n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w,v,C,I,_,S,k;const x=t.state;n=t.next_in,S=t.input,i=n+(t.avail_in-5),r=t.next_out,k=t.output,s=r-(e-t.avail_out),o=r+(t.avail_out-257),a=x.dmax,l=x.wsize,c=x.whave,d=x.wnext,h=x.window,u=x.hold,p=x.bits,g=x.lencode,m=x.distcode,f=(1<<x.lenbits)-1,y=(1<<x.distbits)-1;t:do{p<15&&(u+=S[n++]<<p,p+=8,u+=S[n++]<<p,p+=8),b=g[u&f];e:for(;;){if(w=b>>>24,u>>>=w,p-=w,w=b>>>16&255,0===w)k[r++]=65535&b;else{if(!(16&w)){if(64&w){if(32&w){x.mode=16191;break t}t.msg="invalid literal/length code",x.mode=Ye;break t}b=g[(65535&b)+(u&(1<<w)-1)];continue e}for(v=65535&b,w&=15,w&&(p<w&&(u+=S[n++]<<p,p+=8),v+=u&(1<<w)-1,u>>>=w,p-=w),p<15&&(u+=S[n++]<<p,p+=8,u+=S[n++]<<p,p+=8),b=m[u&y];;){if(w=b>>>24,u>>>=w,p-=w,w=b>>>16&255,16&w){if(C=65535&b,w&=15,p<w&&(u+=S[n++]<<p,p+=8,p<w&&(u+=S[n++]<<p,p+=8)),C+=u&(1<<w)-1,C>a){t.msg="invalid distance too far back",x.mode=Ye;break t}if(u>>>=w,p-=w,w=r-s,C>w){if(w=C-w,w>c&&x.sane){t.msg="invalid distance too far back",x.mode=Ye;break t}if(I=0,_=h,0===d){if(I+=l-w,w<v){v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}}else if(d<w){if(I+=l+d-w,w-=d,w<v){v-=w;do{k[r++]=h[I++]}while(--w);if(I=0,d<v){w=d,v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}}}else if(I+=d-w,w<v){v-=w;do{k[r++]=h[I++]}while(--w);I=r-C,_=k}for(;v>2;)k[r++]=_[I++],k[r++]=_[I++],k[r++]=_[I++],v-=3;v&&(k[r++]=_[I++],v>1&&(k[r++]=_[I++]))}else{I=r-C;do{k[r++]=k[I++],k[r++]=k[I++],k[r++]=k[I++],v-=3}while(v>2);v&&(k[r++]=k[I++],v>1&&(k[r++]=k[I++]))}break}if(64&w){t.msg="invalid distance code",x.mode=Ye;break t}b=m[(65535&b)+(u&(1<<w)-1)]}}break}}while(n<i&&r<o);v=p>>3,n-=v,p-=v<<3,u&=(1<<p)-1,t.next_in=n,t.next_out=r,t.avail_in=n<i?i-n+5:5-(n-i),t.avail_out=r<o?o-r+257:257-(r-o),x.hold=u,x.bits=p};const Je=new Uint16Array([3,4,5,6,7,8,9,10,11,13,15,17,19,23,27,31,35,43,51,59,67,83,99,115,131,163,195,227,258,0,0]),Xe=new Uint8Array([16,16,16,16,16,16,16,16,17,17,17,17,18,18,18,18,19,19,19,19,20,20,20,20,21,21,21,21,16,72,78]),tn=new Uint16Array([1,2,3,4,5,7,9,13,17,25,33,49,65,97,129,193,257,385,513,769,1025,1537,2049,3073,4097,6145,8193,12289,16385,24577,0,0]),en=new Uint8Array([16,16,16,16,17,17,18,18,19,19,20,20,21,21,22,22,23,23,24,24,25,25,26,26,27,27,28,28,29,29,64,64]);var nn=(t,e,n,i,r,s,o,a)=>{const l=a.bits;let c,d,h,u,p,g,m=0,f=0,y=0,b=0,w=0,v=0,C=0,I=0,_=0,S=0,k=null;const x=new Uint16Array(16),A=new Uint16Array(16);let E,R,M,T=null;for(m=0;m<=15;m++)x[m]=0;for(f=0;f<i;f++)x[e[n+f]]++;for(w=l,b=15;b>=1&&0===x[b];b--);if(w>b&&(w=b),0===b)return r[s++]=20971520,r[s++]=20971520,a.bits=1,0;for(y=1;y<b&&0===x[y];y++);for(w<y&&(w=y),I=1,m=1;m<=15;m++)if(I<<=1,I-=x[m],I<0)return-1;if(I>0&&(0===t||1!==b))return-1;for(A[1]=0,m=1;m<15;m++)A[m+1]=A[m]+x[m];for(f=0;f<i;f++)0!==e[n+f]&&(o[A[e[n+f]]++]=f);if(0===t?(k=T=o,g=20):1===t?(k=Je,T=Xe,g=257):(k=tn,T=en,g=0),S=0,f=0,m=y,p=s,v=w,C=0,h=-1,_=1<<w,u=_-1,1===t&&_>852||2===t&&_>592)return 1;for(;;){E=m-C,o[f]+1<g?(R=0,M=o[f]):o[f]>=g?(R=T[o[f]-g],M=k[o[f]-g]):(R=96,M=0),c=1<<m-C,d=1<<v,y=d;do{d-=c,r[p+(S>>C)+d]=E<<24|R<<16|M}while(0!==d);for(c=1<<m-1;S&c;)c>>=1;if(0!==c?(S&=c-1,S+=c):S=0,f++,0===--x[m]){if(m===b)break;m=e[n+o[f]]}if(m>w&&(S&u)!==h){for(0===C&&(C=w),p+=y,v=m-C,I=1<<v;v+C<b&&(I-=x[v+C],!(I<=0));)v++,I<<=1;if(_+=1<<v,1===t&&_>852||2===t&&_>592)return 1;h=S&u,r[h]=w<<24|v<<16|p-s}}return 0!==S&&(r[p+S]=m-C<<24|64<<16),a.bits=w,0};const{Z_FINISH:rn,Z_BLOCK:sn,Z_TREES:on,Z_OK:an,Z_STREAM_END:ln,Z_NEED_DICT:cn,Z_STREAM_ERROR:dn,Z_DATA_ERROR:hn,Z_MEM_ERROR:un,Z_BUF_ERROR:pn,Z_DEFLATED:gn}=xt,mn=16180,fn=16190,yn=16191,bn=16192,wn=16194,vn=16199,Cn=16200,In=16206,_n=16209,Sn=t=>(t>>>24&255)+(t>>>8&65280)+((65280&t)<<8)+((255&t)<<24);function kn(){this.strm=null,this.mode=0,this.last=!1,this.wrap=0,this.havedict=!1,this.flags=0,this.dmax=0,this.check=0,this.total=0,this.head=null,this.wbits=0,this.wsize=0,this.whave=0,this.wnext=0,this.window=null,this.hold=0,this.bits=0,this.length=0,this.offset=0,this.extra=0,this.lencode=null,this.distcode=null,this.lenbits=0,this.distbits=0,this.ncode=0,this.nlen=0,this.ndist=0,this.have=0,this.next=null,this.lens=new Uint16Array(320),this.work=new Uint16Array(288),this.lendyn=null,this.distdyn=null,this.sane=0,this.back=0,this.was=0}const xn=t=>{if(!t)return 1;const e=t.state;return!e||e.strm!==t||e.mode<mn||e.mode>16211?1:0},An=t=>{if(xn(t))return dn;const e=t.state;return t.total_in=t.total_out=e.total=0,t.msg="",e.wrap&&(t.adler=1&e.wrap),e.mode=mn,e.last=0,e.havedict=0,e.flags=-1,e.dmax=32768,e.head=null,e.hold=0,e.bits=0,e.lencode=e.lendyn=new Int32Array(852),e.distcode=e.distdyn=new Int32Array(592),e.sane=1,e.back=-1,an},En=t=>{if(xn(t))return dn;const e=t.state;return e.wsize=0,e.whave=0,e.wnext=0,An(t)},Rn=(t,e)=>{let n;if(xn(t))return dn;const i=t.state;return e<0?(n=0,e=-e):(n=5+(e>>4),e<48&&(e&=15)),e&&(e<8||e>15)?dn:(null!==i.window&&i.wbits!==e&&(i.window=null),i.wrap=n,i.wbits=e,En(t))},Mn=(t,e)=>{if(!t)return dn;const n=new kn;t.state=n,n.strm=t,n.window=null,n.mode=mn;const i=Rn(t,e);return i!==an&&(t.state=null),i};let Tn,On,zn=!0;const Ln=t=>{if(zn){Tn=new Int32Array(512),On=new Int32Array(32);let e=0;for(;e<144;)t.lens[e++]=8;for(;e<256;)t.lens[e++]=9;for(;e<280;)t.lens[e++]=7;for(;e<288;)t.lens[e++]=8;for(nn(1,t.lens,0,288,Tn,0,t.work,{bits:9}),e=0;e<32;)t.lens[e++]=5;nn(2,t.lens,0,32,On,0,t.work,{bits:5}),zn=!1}t.lencode=Tn,t.lenbits=9,t.distcode=On,t.distbits=5},Dn=(t,e,n,i)=>{let r;const s=t.state;return null===s.window&&(s.wsize=1<<s.wbits,s.wnext=0,s.whave=0,s.window=new Uint8Array(s.wsize)),i>=s.wsize?(s.window.set(e.subarray(n-s.wsize,n),0),s.wnext=0,s.whave=s.wsize):(r=s.wsize-s.wnext,r>i&&(r=i),s.window.set(e.subarray(n-i,n-i+r),s.wnext),(i-=r)?(s.window.set(e.subarray(n-i,n),0),s.wnext=i,s.whave=s.wsize):(s.wnext+=r,s.wnext===s.wsize&&(s.wnext=0),s.whave<s.wsize&&(s.whave+=r))),0};var Nn=En,Fn=Mn,Bn=(t,e)=>{let n,i,r,s,o,a,l,c,d,h,u,p,g,m,f,y,b,w,v,C,I,_,S=0;const k=new Uint8Array(4);let x,A;const E=new Uint8Array([16,17,18,0,8,7,9,6,10,5,11,4,12,3,13,2,14,1,15]);if(xn(t)||!t.output||!t.input&&0!==t.avail_in)return dn;n=t.state,n.mode===yn&&(n.mode=bn),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,h=a,u=l,_=an;t:for(;;)switch(n.mode){case mn:if(0===n.wrap){n.mode=bn;break}for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(2&n.wrap&&35615===c){0===n.wbits&&(n.wbits=15),n.check=0,k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0),c=0,d=0,n.mode=16181;break}if(n.head&&(n.head.done=!1),!(1&n.wrap)||(((255&c)<<8)+(c>>8))%31){t.msg="incorrect header check",n.mode=_n;break}if((15&c)!==gn){t.msg="unknown compression method",n.mode=_n;break}if(c>>>=4,d-=4,I=8+(15&c),0===n.wbits&&(n.wbits=I),I>15||I>n.wbits){t.msg="invalid window size",n.mode=_n;break}n.dmax=1<<n.wbits,n.flags=0,t.adler=n.check=1,n.mode=512&c?16189:yn,c=0,d=0;break;case 16181:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.flags=c,(255&n.flags)!==gn){t.msg="unknown compression method",n.mode=_n;break}if(57344&n.flags){t.msg="unknown header flags set",n.mode=_n;break}n.head&&(n.head.text=c>>8&1),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0)),c=0,d=0,n.mode=16182;case 16182:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.time=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,k[2]=c>>>16&255,k[3]=c>>>24&255,n.check=St(n.check,k,4,0)),c=0,d=0,n.mode=16183;case 16183:for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.head&&(n.head.xflags=255&c,n.head.os=c>>8),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0)),c=0,d=0,n.mode=16184;case 16184:if(1024&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length=c,n.head&&(n.head.extra_len=c),512&n.flags&&4&n.wrap&&(k[0]=255&c,k[1]=c>>>8&255,n.check=St(n.check,k,2,0)),c=0,d=0}else n.head&&(n.head.extra=null);n.mode=16185;case 16185:if(1024&n.flags&&(p=n.length,p>a&&(p=a),p&&(n.head&&(I=n.head.extra_len-n.length,n.head.extra||(n.head.extra=new Uint8Array(n.head.extra_len)),n.head.extra.set(i.subarray(s,s+p),I)),512&n.flags&&4&n.wrap&&(n.check=St(n.check,i,p,s)),a-=p,s+=p,n.length-=p),n.length))break t;n.length=0,n.mode=16186;case 16186:if(2048&n.flags){if(0===a)break t;p=0;do{I=i[s+p++],n.head&&I&&n.length<65536&&(n.head.name+=String.fromCharCode(I))}while(I&&p<a);if(512&n.flags&&4&n.wrap&&(n.check=St(n.check,i,p,s)),a-=p,s+=p,I)break t}else n.head&&(n.head.name=null);n.length=0,n.mode=16187;case 16187:if(4096&n.flags){if(0===a)break t;p=0;do{I=i[s+p++],n.head&&I&&n.length<65536&&(n.head.comment+=String.fromCharCode(I))}while(I&&p<a);if(512&n.flags&&4&n.wrap&&(n.check=St(n.check,i,p,s)),a-=p,s+=p,I)break t}else n.head&&(n.head.comment=null);n.mode=16188;case 16188:if(512&n.flags){for(;d<16;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(65535&n.check)){t.msg="header crc mismatch",n.mode=_n;break}c=0,d=0}n.head&&(n.head.hcrc=n.flags>>9&1,n.head.done=!0),t.adler=n.check=0,n.mode=yn;break;case 16189:for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}t.adler=n.check=Sn(c),c=0,d=0,n.mode=fn;case fn:if(0===n.havedict)return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,cn;t.adler=n.check=1,n.mode=yn;case yn:if(e===sn||e===on)break t;case bn:if(n.last){c>>>=7&d,d-=7&d,n.mode=In;break}for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}switch(n.last=1&c,c>>>=1,d-=1,3&c){case 0:n.mode=16193;break;case 1:if(Ln(n),n.mode=vn,e===on){c>>>=2,d-=2;break t}break;case 2:n.mode=16196;break;case 3:t.msg="invalid block type",n.mode=_n}c>>>=2,d-=2;break;case 16193:for(c>>>=7&d,d-=7&d;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if((65535&c)!=(c>>>16^65535)){t.msg="invalid stored block lengths",n.mode=_n;break}if(n.length=65535&c,c=0,d=0,n.mode=wn,e===on)break t;case wn:n.mode=16195;case 16195:if(p=n.length,p){if(p>a&&(p=a),p>l&&(p=l),0===p)break t;r.set(i.subarray(s,s+p),o),a-=p,s+=p,l-=p,o+=p,n.length-=p;break}n.mode=yn;break;case 16196:for(;d<14;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(n.nlen=257+(31&c),c>>>=5,d-=5,n.ndist=1+(31&c),c>>>=5,d-=5,n.ncode=4+(15&c),c>>>=4,d-=4,n.nlen>286||n.ndist>30){t.msg="too many length or distance symbols",n.mode=_n;break}n.have=0,n.mode=16197;case 16197:for(;n.have<n.ncode;){for(;d<3;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.lens[E[n.have++]]=7&c,c>>>=3,d-=3}for(;n.have<19;)n.lens[E[n.have++]]=0;if(n.lencode=n.lendyn,n.lenbits=7,x={bits:n.lenbits},_=nn(0,n.lens,0,19,n.lencode,0,n.work,x),n.lenbits=x.bits,_){t.msg="invalid code lengths set",n.mode=_n;break}n.have=0,n.mode=16198;case 16198:for(;n.have<n.nlen+n.ndist;){for(;S=n.lencode[c&(1<<n.lenbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(b<16)c>>>=f,d-=f,n.lens[n.have++]=b;else{if(16===b){for(A=f+2;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(c>>>=f,d-=f,0===n.have){t.msg="invalid bit length repeat",n.mode=_n;break}I=n.lens[n.have-1],p=3+(3&c),c>>>=2,d-=2}else if(17===b){for(A=f+3;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,I=0,p=3+(7&c),c>>>=3,d-=3}else{for(A=f+7;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=f,d-=f,I=0,p=11+(127&c),c>>>=7,d-=7}if(n.have+p>n.nlen+n.ndist){t.msg="invalid bit length repeat",n.mode=_n;break}for(;p--;)n.lens[n.have++]=I}}if(n.mode===_n)break;if(0===n.lens[256]){t.msg="invalid code -- missing end-of-block",n.mode=_n;break}if(n.lenbits=9,x={bits:n.lenbits},_=nn(1,n.lens,0,n.nlen,n.lencode,0,n.work,x),n.lenbits=x.bits,_){t.msg="invalid literal/lengths set",n.mode=_n;break}if(n.distbits=6,n.distcode=n.distdyn,x={bits:n.distbits},_=nn(2,n.lens,n.nlen,n.ndist,n.distcode,0,n.work,x),n.distbits=x.bits,_){t.msg="invalid distances set",n.mode=_n;break}if(n.mode=vn,e===on)break t;case vn:n.mode=Cn;case Cn:if(a>=6&&l>=258){t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,Qe(t,u),o=t.next_out,r=t.output,l=t.avail_out,s=t.next_in,i=t.input,a=t.avail_in,c=n.hold,d=n.bits,n.mode===yn&&(n.back=-1);break}for(n.back=0;S=n.lencode[c&(1<<n.lenbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(y&&!(240&y)){for(w=f,v=y,C=b;S=n.lencode[C+((c&(1<<w+v)-1)>>w)],f=S>>>24,y=S>>>16&255,b=65535&S,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,n.length=b,0===y){n.mode=16205;break}if(32&y){n.back=-1,n.mode=yn;break}if(64&y){t.msg="invalid literal/length code",n.mode=_n;break}n.extra=15&y,n.mode=16201;case 16201:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.length+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}n.was=n.length,n.mode=16202;case 16202:for(;S=n.distcode[c&(1<<n.distbits)-1],f=S>>>24,y=S>>>16&255,b=65535&S,!(f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(!(240&y)){for(w=f,v=y,C=b;S=n.distcode[C+((c&(1<<w+v)-1)>>w)],f=S>>>24,y=S>>>16&255,b=65535&S,!(w+f<=d);){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}c>>>=w,d-=w,n.back+=w}if(c>>>=f,d-=f,n.back+=f,64&y){t.msg="invalid distance code",n.mode=_n;break}n.offset=b,n.extra=15&y,n.mode=16203;case 16203:if(n.extra){for(A=n.extra;d<A;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}n.offset+=c&(1<<n.extra)-1,c>>>=n.extra,d-=n.extra,n.back+=n.extra}if(n.offset>n.dmax){t.msg="invalid distance too far back",n.mode=_n;break}n.mode=16204;case 16204:if(0===l)break t;if(p=u-l,n.offset>p){if(p=n.offset-p,p>n.whave&&n.sane){t.msg="invalid distance too far back",n.mode=_n;break}p>n.wnext?(p-=n.wnext,g=n.wsize-p):g=n.wnext-p,p>n.length&&(p=n.length),m=n.window}else m=r,g=o-n.offset,p=n.length;p>l&&(p=l),l-=p,n.length-=p;do{r[o++]=m[g++]}while(--p);0===n.length&&(n.mode=Cn);break;case 16205:if(0===l)break t;r[o++]=n.length,l--,n.mode=Cn;break;case In:if(n.wrap){for(;d<32;){if(0===a)break t;a--,c|=i[s++]<<d,d+=8}if(u-=l,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?St(n.check,r,u,o-u):It(n.check,r,u,o-u)),u=l,4&n.wrap&&(n.flags?c:Sn(c))!==n.check){t.msg="incorrect data check",n.mode=_n;break}c=0,d=0}n.mode=16207;case 16207:if(n.wrap&&n.flags){for(;d<32;){if(0===a)break t;a--,c+=i[s++]<<d,d+=8}if(4&n.wrap&&c!==(4294967295&n.total)){t.msg="incorrect length check",n.mode=_n;break}c=0,d=0}n.mode=16208;case 16208:_=ln;break t;case _n:_=hn;break t;case 16210:return un;default:return dn}return t.next_out=o,t.avail_out=l,t.next_in=s,t.avail_in=a,n.hold=c,n.bits=d,(n.wsize||u!==t.avail_out&&n.mode<_n&&(n.mode<In||e!==rn))&&Dn(t,t.output,t.next_out,u-t.avail_out),h-=t.avail_in,u-=t.avail_out,t.total_in+=h,t.total_out+=u,n.total+=u,4&n.wrap&&u&&(t.adler=n.check=n.flags?St(n.check,r,u,t.next_out-u):It(n.check,r,u,t.next_out-u)),t.data_type=n.bits+(n.last?64:0)+(n.mode===yn?128:0)+(n.mode===vn||n.mode===wn?256:0),(0===h&&0===u||e===rn)&&_===an&&(_=pn),_},Un=t=>{if(xn(t))return dn;let e=t.state;return e.window&&(e.window=null),t.state=null,an},Zn=(t,e)=>{if(xn(t))return dn;const n=t.state;return 2&n.wrap?(n.head=e,e.done=!1,an):dn},Pn=(t,e)=>{const n=e.length;let i,r,s;return xn(t)?dn:(i=t.state,0!==i.wrap&&i.mode!==fn?dn:i.mode===fn&&(r=1,r=It(r,e,n,0),r!==i.check)?hn:(s=Dn(t,e,n,n),s?(i.mode=16210,un):(i.havedict=1,an)))},Wn=function(){this.text=0,this.time=0,this.xflags=0,this.os=0,this.extra=null,this.extra_len=0,this.name="",this.comment="",this.hcrc=0,this.done=!1};const Vn=Object.prototype.toString,{Z_NO_FLUSH:Gn,Z_FINISH:jn,Z_OK:qn,Z_STREAM_END:Hn,Z_NEED_DICT:Kn,Z_STREAM_ERROR:$n,Z_DATA_ERROR:Yn,Z_MEM_ERROR:Qn}=xt;function Jn(t){this.options=Re({chunkSize:65536,windowBits:15,to:""},t||{});const e=this.options;e.raw&&e.windowBits>=0&&e.windowBits<16&&(e.windowBits=-e.windowBits,0===e.windowBits&&(e.windowBits=-15)),!(e.windowBits>=0&&e.windowBits<16)||t&&t.windowBits||(e.windowBits+=32),e.windowBits>15&&e.windowBits<48&&(15&e.windowBits||(e.windowBits|=15)),this.err=0,this.msg="",this.ended=!1,this.chunks=[],this.strm=new Ne,this.strm.avail_out=0;let n=Fn(this.strm,e.windowBits);if(n!==qn)throw new Error(kt[n]);if(this.header=new Wn,Zn(this.strm,this.header),e.dictionary&&("string"==typeof e.dictionary?e.dictionary=ze(e.dictionary):"[object ArrayBuffer]"===Vn.call(e.dictionary)&&(e.dictionary=new Uint8Array(e.dictionary)),e.raw&&(n=Pn(this.strm,e.dictionary),n!==qn)))throw new Error(kt[n])}function Xn(t,e){const n=new Jn(e);if(n.push(t),n.err)throw n.msg||kt[n.err];return n.result}Jn.prototype.push=function(t,e){const n=this.strm,i=this.options.chunkSize,r=this.options.dictionary;let s,o,a;if(this.ended)return!1;for(o=e===~~e?e:!0===e?jn:Gn,"[object ArrayBuffer]"===Vn.call(t)?n.input=new Uint8Array(t):n.input=t,n.next_in=0,n.avail_in=n.input.length;;){for(0===n.avail_out&&(n.output=new Uint8Array(i),n.next_out=0,n.avail_out=i),s=Bn(n,o),s===Kn&&r&&(s=Pn(n,r),s===qn?s=Bn(n,o):s===Yn&&(s=Kn));n.avail_in>0&&s===Hn&&n.state.wrap>0&&0!==t[n.next_in];)Nn(n),s=Bn(n,o);switch(s){case $n:case Yn:case Kn:case Qn:return this.onEnd(s),this.ended=!0,!1}if(a=n.avail_out,n.next_out&&(0===n.avail_out||s===Hn))if("string"===this.options.to){let t=De(n.output,n.next_out),e=n.next_out-t,r=Le(n.output,t);n.next_out=e,n.avail_out=i-e,e&&n.output.set(n.output.subarray(t,t+e),0),this.onData(r)}else this.onData(n.output.length===n.next_out?n.output:n.output.subarray(0,n.next_out));if(s!==qn||0!==a){if(s===Hn)return s=Un(this.strm),this.onEnd(s),this.ended=!0,!0;if(0===n.avail_in)break}}return!0},Jn.prototype.onData=function(t){this.chunks.push(t)},Jn.prototype.onEnd=function(t){t===qn&&("string"===this.options.to?this.result=this.chunks.join(""):this.result=Me(this.chunks)),this.chunks=[],this.err=t,this.msg=this.strm.msg};var ti={Inflate:Jn,inflate:Xn,inflateRaw:function(t,e){return(e=e||{}).raw=!0,Xn(t,e)},ungzip:Xn,constants:xt};const{Deflate:ei,deflate:ni,deflateRaw:ii,gzip:ri}=$e,{Inflate:si,inflate:oi,inflateRaw:ai,ungzip:li}=ti;var ci={Deflate:ei,deflate:ni,deflateRaw:ii,gzip:ri,Inflate:si,inflate:oi,inflateRaw:ai,ungzip:li,constants:xt};const di=Z();let hi=null,ui=null;function pi(){return"undefined"!=typeof document&&"undefined"!=typeof Image&&"undefined"!=typeof HTMLCanvasElement}class gi extends W{constructor(t={}){super(t)}getErrorPlaceholder(){var t;return null!==(t=this.options.errorPlaceholder)&&void 0!==t?t:"SCREENSHOT_FAILED"}shouldIncludeNode(t){if(!("hasAttribute"in t))return!0;const e=t,n=this.options.excludeAttribute||"data-bugspotter-exclude";return!e.hasAttribute(n)}buildCaptureOptions(){var t,e,n,i;return Object.assign(Object.assign(Object.assign({quality:null!==(t=this.options.quality)&&void 0!==t?t:.8,cacheBust:null===(e=this.options.cacheBust)||void 0===e||e,pixelRatio:null!==(n=this.options.pixelRatio)&&void 0!==n?n:window.devicePixelRatio,backgroundColor:null!==(i=this.options.backgroundColor)&&void 0!==i?i:"#ffffff"},this.options.width&&{width:this.options.width}),this.options.height&&{height:this.options.height}),{filter:t=>this.shouldIncludeNode(t)})}async capture(t){try{const e=t||this.options.targetElement||document.body,n=this.buildCaptureOptions(),i=await async function(t,e={}){return(await async function(t,e={}){const{width:n,height:i}=a(t,e),r=await F(t,e),s=await c(r),o=document.createElement("canvas"),d=o.getContext("2d"),h=e.pixelRatio||function(){let t,e;try{e=process}catch(t){}const n=e&&e.env?e.env.devicePixelRatio:null;return n&&(t=parseInt(n,10),Number.isNaN(t)&&(t=1)),t||window.devicePixelRatio||1}(),u=e.canvasWidth||n,p=e.canvasHeight||i;return o.width=u*h,o.height=p*h,e.skipAutoScale||function(t){(t.width>l||t.height>l)&&(t.width>l&&t.height>l?t.width>t.height?(t.height*=l/t.width,t.width=l):(t.width*=l/t.height,t.height=l):t.width>l?(t.height*=l/t.width,t.width=l):(t.width*=l/t.height,t.height=l))}(o),o.style.width=`${u}`,o.style.height=`${p}`,e.backgroundColor&&(d.fillStyle=e.backgroundColor,d.fillRect(0,0,o.width,o.height)),d.drawImage(s,0,0,o.width,o.height),o}(t,e)).toDataURL()}(e,n);return await async function(t,e){var n,i,r,s;try{if(!pi())return t;const o=null!==(n=null==e?void 0:e.imageMaxWidth)&&void 0!==n?n:1920,a=null!==(i=null==e?void 0:e.imageMaxHeight)&&void 0!==i?i:1080,l=null!==(r=null==e?void 0:e.webpQuality)&&void 0!==r?r:.8,c=null!==(s=null==e?void 0:e.jpegQuality)&&void 0!==s?s:.85,d=3e3,h=await function(t,e){return new Promise((n,i)=>{const r=new Image,s=setTimeout(()=>{i(new Error(`Image load timeout after ${e}ms`))},e);r.onload=()=>{clearTimeout(s),n(r)},r.onerror=()=>{clearTimeout(s),i(new Error("Failed to load image"))},r.src=t})}(t,d),u=document.createElement("canvas"),p=u.getContext("2d");if(!p)throw new Error("Failed to get 2D canvas context");const{width:g,height:m}=function(t,e,n,i){let r=t,s=e;return r>n&&(s=s*n/r,r=n),s>i&&(r=r*i/s,s=i),{width:r,height:s}}(h.width,h.height,o,a);return u.width=g,u.height=m,p.drawImage(h,0,0,g,m),function(){if(null!==ui)return ui;if(!pi())return ui=!1,!1;try{const t=document.createElement("canvas");ui=0===t.toDataURL("image/webp").indexOf("data:image/webp")}catch(t){ui=!1}return ui}()?u.toDataURL("image/webp",l):u.toDataURL("image/jpeg",c)}catch(n){return!1!==(null==e?void 0:e.verbose)&&Z().error("Image compression failed:",n),t}}(i)}catch(t){return this.handleError("capturing screenshot",t),this.getErrorPlaceholder()}}}class mi{constructor(t){if(this.maxSize=t,this.items=[],this.index=0,this.count=0,t<=0)throw new Error("CircularBuffer maxSize must be greater than 0")}add(t){this.count<this.maxSize?(this.items.push(t),this.count++):this.items[this.index]=t,this.index=(this.index+1)%this.maxSize}getAll(){return this.count<this.maxSize?[...this.items]:[...this.items.slice(this.index),...this.items.slice(0,this.index)]}clear(){this.items=[],this.index=0,this.count=0}get size(){return this.count}get capacity(){return this.maxSize}get isEmpty(){return 0===this.count}get isFull(){return this.count>=this.maxSize}}const fi=["log","warn","error","info","debug"];class yi extends W{constructor(t={}){var e,n,i;super(t),this.originalMethods=new Map;const r=null!==(e=t.maxLogs)&&void 0!==e?e:100;this.buffer=new mi(r),this.captureStackTrace=null===(n=t.captureStackTrace)||void 0===n||n,this.interceptConsole(null!==(i=t.levels)&&void 0!==i?i:fi)}capture(){return this.getLogs()}formatMessage(t){return t&&0!==t.length?(this.sanitizer?this.sanitizer.sanitizeConsoleArgs(t):t).map(t=>{var e;if(null===t)return"null";if(void 0===t)return"undefined";if("object"==typeof t)try{return JSON.stringify(t)}catch(n){return`[${(null===(e=t.constructor)||void 0===e?void 0:e.name)||"Object"}]`}return String(t)}).join(" "):""}createLogEntry(t,e){const n={level:t,message:this.formatMessage(e),timestamp:Date.now()};if(this.captureStackTrace&&"error"===t){const t=this.captureStack();n.stack=this.sanitizer&&t?this.sanitizer.sanitize(t):t}return n}captureStack(){const t=(new Error).stack;return null==t?void 0:t.split("\n").slice(3).join("\n")}addLog(t){this.buffer.add(t)}interceptConsole(t=fi){t.forEach(t=>{try{const e=console[t];this.originalMethods.set(t,e),console[t]=(...n)=>{try{const e=this.createLogEntry(t,n);this.addLog(e)}catch(t){this.handleError("creating log entry",t)}e.apply(console,n)}}catch(e){this.handleError(`intercepting console.${t}`,e)}})}getLogs(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){try{this.originalMethods.forEach((t,e)=>{console[e]=t}),this.originalMethods.clear()}catch(t){this.handleError("destroying console capture",t)}}}class bi extends W{constructor(t={}){var e;super(t),this.isIntercepting=!1;const n=null!==(e=t.maxRequests)&&void 0!==e?e:50;this.buffer=new mi(n),this.filterUrls=t.filterUrls,this.originalFetch=window.fetch,this.originalXHR={open:XMLHttpRequest.prototype.open,send:XMLHttpRequest.prototype.send},this.interceptFetch(),this.interceptXHR(),this.isIntercepting=!0}capture(){return this.getRequests()}parseFetchArgs(t){const[e,n]=t;let i,r="GET";return"string"==typeof e?i=e:e instanceof Request?(i=e.url,r=e.method.toUpperCase()||"GET"):i=e.toString(),(null==n?void 0:n.method)&&(r=n.method.toUpperCase()),{url:i,method:r}}createNetworkRequest(t,e,n,i,r){const s=Object.assign({url:t,method:e,status:n,duration:Date.now()-i,timestamp:i},r&&{error:r});if(this.sanitizer){const t=this.sanitizer.sanitizeNetworkData(Object.assign({url:s.url,method:s.method,status:s.status},s.error&&{error:s.error}));return Object.assign(Object.assign({},s),{url:t.url||s.url,error:t.error})}return s}addRequest(t){this.filterUrls&&!this.filterUrls(t.url)||this.buffer.add(t)}interceptFetch(){const t=this.originalFetch;window.fetch=async(...e)=>{const n=Date.now();let i="",r="GET";try{({url:i,method:r}=this.parseFetchArgs(e))}catch(t){this.handleError("parsing fetch arguments",t)}try{const s=await t(...e);if(s&&"number"==typeof s.status){const t=this.createNetworkRequest(i,r,s.status,n);this.addRequest(t)}return s}catch(t){const e=this.createNetworkRequest(i,r,0,n,t.message);throw this.addRequest(e),t}}}interceptXHR(){const t=this.originalXHR.open,e=this.originalXHR.send,n=this.createNetworkRequest.bind(this),i=this.addRequest.bind(this);XMLHttpRequest.prototype.open=function(e,n,...i){return this._method=e.toUpperCase(),this._url=n.toString(),this._startTime=Date.now(),t.apply(this,[e,n,...i])},XMLHttpRequest.prototype.send=function(...t){return this.addEventListener("load",()=>{const t=n(this._url||"",this._method||"GET",this.status,this._startTime||Date.now());i(t)}),this.addEventListener("error",()=>{const t=n(this._url||"",this._method||"GET",0,this._startTime||Date.now(),"XMLHttpRequest failed");i(t)}),e.apply(this,t)}}getRequests(){return this.buffer.getAll()}clear(){this.buffer.clear()}destroy(){if(this.isIntercepting)try{window.fetch=this.originalFetch,XMLHttpRequest.prototype.open=this.originalXHR.open,XMLHttpRequest.prototype.send=this.originalXHR.send,this.isIntercepting=!1}catch(t){this.handleError("destroying network capture",t)}}}class wi extends W{constructor(t={}){super(t),this.browserPatterns=[{pattern:"Edg",name:"Edge"},{pattern:"Chrome",exclude:"Edge",name:"Chrome"},{pattern:"Firefox",name:"Firefox"},{pattern:"Safari",exclude:"Chrome",name:"Safari"}],this.osPatterns=[{patterns:["iPhone","iPad"],name:"iOS"},{patterns:["Android"],name:"Android"},{patterns:["Win"],name:"Windows"},{patterns:["Mac"],name:"macOS"},{patterns:["Linux"],name:"Linux"}]}capture(){try{const t={userAgent:navigator.userAgent,viewport:{width:window.innerWidth,height:window.innerHeight},browser:this.detectBrowser(),os:this.detectOS(),url:window.location.href,timestamp:Date.now()};return this.sanitizer&&(t.url=this.sanitizer.sanitize(t.url),t.userAgent=this.sanitizer.sanitize(t.userAgent)),t}catch(t){return this.handleError("capturing metadata",t),{userAgent:"Unknown",viewport:{width:0,height:0},browser:"Unknown",os:"Unknown",url:"Unknown",timestamp:Date.now()}}}detectBrowser(){const t=navigator.userAgent;for(const{pattern:e,exclude:n,name:i}of this.browserPatterns)if(t.includes(e)&&(!n||!t.includes(n)))return i;return"Unknown"}detectOS(){const t=navigator.userAgent;for(const{patterns:e,name:n}of this.osPatterns)if(e.some(e=>t.includes(e)))return n;return"Unknown"}}const vi='<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round">\n<path d="M8 2v4"/>\n<path d="M16 2v4"/>\n<path d="M12 12v5"/>\n<circle cx="12" cy="10" r="4"/>\n<path d="M9 16c-1.5 1-3 2-3 4h12c0-2-1.5-3-3-4"/>\n<path d="M3 8h4"/>\n<path d="M17 8h4"/>\n<path d="M5 12h2"/>\n<path d="M17 12h2"/>\n<path d="M6 16h2"/>\n<path d="M16 16h2"/>\n</svg>',Ci={position:"bottom-right",icon:"svg",customSvg:void 0,backgroundColor:"#2563eb",size:56,offset:{x:20,y:20},zIndex:999999,tooltip:"Report an Issue"},Ii="0 4px 6px rgba(0, 0, 0, 0.1), 0 2px 4px rgba(0, 0, 0, 0.06)",_i="0 10px 15px rgba(0, 0, 0, 0.2), 0 4px 6px rgba(0, 0, 0, 0.1)",Si="scale(1)",ki="scale(1.1)",xi="scale(0.95)";class Ai{constructor(t={}){var e,n,i,r,s,o,a,l;this.eventHandlers=new Map,this.handleMouseEnter=()=>{this.button.style.transform=ki,this.button.style.boxShadow=_i},this.handleMouseLeave=()=>{this.button.style.transform=Si,this.button.style.boxShadow=Ii},this.handleMouseDown=()=>{this.button.style.transform=xi},this.handleMouseUp=()=>{this.button.style.transform=ki},this.options={position:null!==(e=t.position)&&void 0!==e?e:Ci.position,icon:null!==(n=t.icon)&&void 0!==n?n:Ci.icon,customSvg:null!==(i=t.customSvg)&&void 0!==i?i:Ci.customSvg,backgroundColor:null!==(r=t.backgroundColor)&&void 0!==r?r:Ci.backgroundColor,size:null!==(s=t.size)&&void 0!==s?s:Ci.size,offset:null!==(o=t.offset)&&void 0!==o?o:Ci.offset,zIndex:null!==(a=t.zIndex)&&void 0!==a?a:Ci.zIndex,tooltip:null!==(l=t.tooltip)&&void 0!==l?l:Ci.tooltip},this.button=this.createButton(),document.body?document.body.appendChild(this.button):document.addEventListener("DOMContentLoaded",()=>{document.body.appendChild(this.button)})}createButton(){const t=document.createElement("button");return this.options.customSvg?t.innerHTML=this.options.customSvg:"svg"===this.options.icon?t.innerHTML=vi:t.textContent=this.options.icon,t.setAttribute("aria-label",this.options.tooltip),t.setAttribute("title",this.options.tooltip),t.setAttribute("data-bugspotter-exclude","true"),t.style.cssText=this.getButtonStyles(),this.addHoverEffects(t),t}getButtonStyles(){const{position:t,size:e,offset:n,backgroundColor:i,zIndex:r}=this.options;return`\n position: fixed;\n ${this.getPositionStyles(t,n)}\n width: ${e}px;\n height: ${e}px;\n border-radius: 50%;\n background: ${i};\n color: white;\n border: none;\n cursor: pointer;\n font-size: ${.5*e}px;\n display: flex;\n align-items: center;\n justify-content: center;\n padding: ${this.options.customSvg||"svg"===this.options.icon?.25*e:0}px;\n box-shadow: ${Ii};\n transition: transform 0.2s ease, box-shadow 0.2s ease;\n z-index: ${r};\n `}getPositionStyles(t,e){switch(t){case"bottom-right":default:return`bottom: ${e.y}px; right: ${e.x}px;`;case"bottom-left":return`bottom: ${e.y}px; left: ${e.x}px;`;case"top-right":return`top: ${e.y}px; right: ${e.x}px;`;case"top-left":return`top: ${e.y}px; left: ${e.x}px;`}}addHoverEffects(t){const e={mouseenter:this.handleMouseEnter,mouseleave:this.handleMouseLeave,mousedown:this.handleMouseDown,mouseup:this.handleMouseUp};Object.entries(e).forEach(([e,n])=>{t.addEventListener(e,n),this.eventHandlers.set(e,n)})}onClick(t){this.button.addEventListener("click",t)}show(){this.button.style.display="flex"}hide(){this.button.style.display="none"}setIcon(t){this.options.icon=t,"svg"===t?this.button.innerHTML=vi:this.button.textContent=t}setBackgroundColor(t){this.button.style.backgroundColor=t}destroy(){this.eventHandlers.forEach((t,e)=>{this.button.removeEventListener(e,t)}),this.eventHandlers.clear(),this.button.remove()}}class Ei{constructor(t={}){this.config={primaryColor:t.primaryColor||"#007bff",dangerColor:t.dangerColor||"#dc3545",borderRadius:t.borderRadius||"4px",fontFamily:t.fontFamily||'-apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, sans-serif',zIndex:t.zIndex||999999}}generateStyles(){return`\n .overlay {\n position: fixed;\n top: 0;\n left: 0;\n width: 100%;\n height: 100%;\n background: rgba(0, 0, 0, 0.5);\n display: flex;\n align-items: center;\n justify-content: center;\n z-index: ${this.config.zIndex};\n font-family: ${this.config.fontFamily};\n }\n \n .modal {\n background: white;\n border-radius: 8px;\n width: 90%;\n max-width: 600px;\n max-height: 90vh;\n overflow-y: auto;\n box-shadow: 0 4px 6px rgba(0, 0, 0, 0.1);\n }\n \n .header {\n padding: 20px;\n border-bottom: 1px solid #e0e0e0;\n display: flex;\n justify-content: space-between;\n align-items: center;\n }\n \n .header h2 {\n margin: 0;\n font-size: 20px;\n font-weight: 600;\n }\n \n .close {\n background: none;\n border: none;\n font-size: 24px;\n cursor: pointer;\n color: #666;\n padding: 0;\n width: 30px;\n height: 30px;\n display: flex;\n align-items: center;\n justify-content: center;\n border-radius: ${this.config.borderRadius};\n }\n \n .close:hover {\n background: #f0f0f0;\n }\n \n .body {\n padding: 20px;\n }\n \n .form-group {\n margin-bottom: 20px;\n }\n \n .label {\n display: block;\n margin-bottom: 8px;\n font-weight: 500;\n font-size: 14px;\n }\n \n .input,\n .textarea {\n width: 100%;\n padding: 10px;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n font-size: 14px;\n font-family: ${this.config.fontFamily};\n box-sizing: border-box;\n }\n \n .input:focus,\n .textarea:focus {\n outline: none;\n border-color: ${this.config.primaryColor};\n }\n \n .textarea {\n min-height: 100px;\n resize: vertical;\n }\n \n .screenshot-container {\n margin-top: 10px;\n position: relative;\n }\n \n .screenshot {\n max-width: 100%;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-canvas {\n position: absolute;\n top: 0;\n left: 0;\n cursor: crosshair;\n border: 2px solid ${this.config.primaryColor};\n border-radius: ${this.config.borderRadius};\n }\n \n .redaction-controls {\n margin-top: 10px;\n display: flex;\n gap: 10px;\n }\n \n .btn-redact,\n .btn-clear {\n padding: 8px 16px;\n border: 1px solid #ddd;\n border-radius: ${this.config.borderRadius};\n background: white;\n cursor: pointer;\n font-size: 14px;\n }\n \n .btn-redact:hover,\n .btn-clear:hover {\n background: #f5f5f5;\n }\n \n .btn-redact.active {\n background: ${this.config.primaryColor};\n color: white;\n border-color: ${this.config.primaryColor};\n }\n \n .pii-section {\n margin-top: 20px;\n padding: 15px;\n background: #fff3cd;\n border: 1px solid #ffc107;\n border-radius: ${this.config.borderRadius};\n }\n \n .pii-title {\n margin: 0 0 10px 0;\n font-size: 14px;\n font-weight: 600;\n color: #856404;\n }\n \n .pii-list {\n margin: 0;\n padding-left: 20px;\n font-size: 13px;\n color: #856404;\n }\n \n .pii-badge {\n display: inline-block;\n padding: 2px 8px;\n margin: 2px;\n background: #ffc107;\n color: #856404;\n border-radius: 12px;\n font-size: 12px;\n font-weight: 500;\n }\n \n .checkbox-group {\n display: flex;\n align-items: center;\n gap: 8px;\n margin-top: 15px;\n }\n \n .checkbox {\n width: 18px;\n height: 18px;\n cursor: pointer;\n }\n \n .checkbox-label {\n margin: 0;\n font-size: 14px;\n cursor: pointer;\n user-select: none;\n }\n \n .footer {\n padding: 20px;\n border-top: 1px solid #e0e0e0;\n display: flex;\n justify-content: flex-end;\n gap: 10px;\n }\n \n .btn {\n padding: 10px 20px;\n border: none;\n border-radius: ${this.config.borderRadius};\n cursor: pointer;\n font-size: 14px;\n font-weight: 500;\n }\n \n .btn-primary {\n background: ${this.config.primaryColor};\n color: white;\n }\n \n .btn-primary:hover {\n opacity: 0.9;\n }\n \n .btn-primary:disabled {\n opacity: 0.5;\n cursor: not-allowed;\n }\n \n .btn-secondary {\n background: #6c757d;\n color: white;\n }\n \n .btn-secondary:hover {\n opacity: 0.9;\n }\n \n .error {\n color: ${this.config.dangerColor};\n font-size: 12px;\n margin-top: 4px;\n }\n `}injectStyles(){const t=document.createElement("style");return t.textContent=this.generateStyles(),document.head.appendChild(t),t}removeStyles(t){t&&t.parentNode&&t.parentNode.removeChild(t)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class Ri{constructor(t={}){this.config={title:t.title||"Report a Bug",titlePlaceholder:t.titlePlaceholder||"Brief description of the issue",descriptionPlaceholder:t.descriptionPlaceholder||"Detailed description of what happened...",submitButtonText:t.submitButtonText||"Submit Bug Report",cancelButtonText:t.cancelButtonText||"Cancel",showScreenshot:!1!==t.showScreenshot}}generateModalHTML(t){return`\n <div class="overlay">\n <div class="modal">\n ${this.generateHeader()}\n ${this.generateBody(t)}\n ${this.generateFooter()}\n </div>\n </div>\n `}generateHeader(){return`\n <div class="header">\n <h2>${this.escapeHtml(this.config.title)}</h2>\n <button class="close" aria-label="Close">&times;</button>\n </div>\n `}generateBody(t){return`\n <div class="body">\n <form class="form">\n ${this.generateTitleField()}\n ${this.generateDescriptionField()}\n ${this.config.showScreenshot&&t?this.generateScreenshotSection(t):""}\n ${this.generatePIISection()}\n </form>\n </div>\n `}generateTitleField(){return`\n <div class="form-group">\n <label class="label" for="title">Title *</label>\n <input\n type="text"\n id="title"\n class="input"\n placeholder="${this.escapeHtml(this.config.titlePlaceholder)}"\n required\n />\n <div class="error" id="title-error"></div>\n </div>\n `}generateDescriptionField(){return`\n <div class="form-group">\n <label class="label" for="description">Description *</label>\n <textarea\n id="description"\n class="textarea"\n placeholder="${this.escapeHtml(this.config.descriptionPlaceholder)}"\n required\n ></textarea>\n <div class="error" id="description-error"></div>\n </div>\n `}generateScreenshotSection(t){return`\n <div class="form-group">\n <label class="label">Screenshot</label>\n <div class="screenshot-container">\n <img \n src="${t}" \n alt="Bug screenshot" \n class="screenshot"\n id="screenshot"\n />\n <canvas \n class="redaction-canvas" \n id="redaction-canvas"\n style="display: none;"\n ></canvas>\n </div>\n <div class="redaction-controls">\n <button \n type="button" \n class="btn-redact" \n id="btn-redact"\n >\n ✏️ Redact Area\n </button>\n <button \n type="button" \n class="btn-clear" \n id="btn-clear"\n >\n 🗑️ Clear Redactions\n </button>\n </div>\n </div>\n `}generatePIISection(){return'\n <div class="pii-section" id="pii-section" style="display: none;">\n <h3 class="pii-title">⚠️ Potential PII Detected</h3>\n <div id="pii-content"></div>\n <div class="checkbox-group">\n <input \n type="checkbox" \n id="pii-confirm" \n class="checkbox"\n />\n <label for="pii-confirm" class="checkbox-label">\n I have reviewed and redacted sensitive information\n </label>\n </div>\n </div>\n '}generateFooter(){return`\n <div class="footer">\n <button type="button" class="btn btn-secondary" id="btn-cancel">\n ${this.escapeHtml(this.config.cancelButtonText)}\n </button>\n <button type="submit" class="btn btn-primary submit" id="btn-submit">\n ${this.escapeHtml(this.config.submitButtonText)}\n </button>\n </div>\n `}generatePIIBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class Mi{constructor(){this.elements=null,this.container=null}initialize(t){this.container=t;const e=this.getRequiredElement(".overlay",t),n=this.getRequiredElement(".modal",e),i=this.getRequiredElement(".form",n);return this.elements={overlay:e,modal:n,closeButton:this.getRequiredElement(".close",n),form:i,titleInput:this.getRequiredElement("#title",i),titleError:this.getRequiredElement("#title-error",i),descriptionTextarea:this.getRequiredElement("#description",i),descriptionError:this.getRequiredElement("#description-error",i),screenshotImg:this.getOptionalElement("#screenshot",n),redactionCanvas:this.getOptionalElement("#redaction-canvas",n),redactButton:this.getOptionalElement("#btn-redact",n),clearButton:this.getOptionalElement("#btn-clear",n),piiSection:this.getRequiredElement("#pii-section",n),piiContent:this.getRequiredElement("#pii-content",n),piiConfirmCheckbox:this.getRequiredElement("#pii-confirm",n),cancelButton:this.getRequiredElement("#btn-cancel",n),submitButton:this.getRequiredElement("#btn-submit",n)},this.elements}get(){if(!this.elements)throw new Error("DOMElementCache not initialized. Call initialize() first.");return this.elements}isInitialized(){return null!==this.elements}clear(){this.elements=null,this.container=null}getRequiredElement(t,e){const n=(e||this.container||document).querySelector(t);if(!n)throw new Error(`Required element not found: ${t}`);return n}getOptionalElement(t,e){return(e||this.container||document).querySelector(t)||void 0}refreshElement(t,e){if(!this.elements||!this.container)throw new Error("DOMElementCache not initialized");const n=this.container.querySelector(e);n&&(this.elements[t]=n)}getContainer(){return this.container}}class Ti{constructor(t={}){this.minTitleLength=t.minTitleLength||3,this.maxTitleLength=t.maxTitleLength||200,this.minDescriptionLength=t.minDescriptionLength||10,this.maxDescriptionLength=t.maxDescriptionLength||5e3}validate(t){const e={},n=this.validateTitle(t.title);n&&(e.title=n);const i=this.validateDescription(t.description);return i&&(e.description=i),t.piiDetected&&!t.piiConfirmed&&(e.piiConfirmation="Please confirm you have reviewed sensitive information"),{isValid:0===Object.keys(e).length,errors:e}}validateTitle(t){const e=t.trim();return e?e.length<this.minTitleLength?`Title must be at least ${this.minTitleLength} characters`:e.length>this.maxTitleLength?`Title must not exceed ${this.maxTitleLength} characters`:null:"Title is required"}validateDescription(t){const e=t.trim();return e?e.length<this.minDescriptionLength?`Description must be at least ${this.minDescriptionLength} characters`:e.length>this.maxDescriptionLength?`Description must not exceed ${this.maxDescriptionLength} characters`:null:"Description is required"}validateField(t,e,n){switch(t){case"title":return this.validateTitle(e);case"description":return this.validateDescription(e);case"piiConfirmed":return(null==n?void 0:n.piiDetected)&&!e?"Please confirm you have reviewed sensitive information":null;default:return null}}isEmpty(t){return!t||0===t.trim().length}sanitizeInput(t){return t.trim()}getConfig(){return{minTitleLength:this.minTitleLength,maxTitleLength:this.maxTitleLength,minDescriptionLength:this.minDescriptionLength,maxDescriptionLength:this.maxDescriptionLength}}}class Oi{constructor(t={}){this.config={showExamples:!1!==t.showExamples,groupByType:!1!==t.groupByType,maxExamplesPerType:t.maxExamplesPerType||3}}render(t,e){t&&0!==t.length?this.config.groupByType?e.innerHTML=this.renderGroupedPII(t):e.innerHTML=this.renderListPII(t):e.innerHTML=""}renderGroupedPII(t){const e=this.groupByType(t),n=[];for(const[t,i]of Object.entries(e)){const e=i.reduce((t,e)=>t+e.count,0);n.push(this.createBadge(t,e))}let i=`<div class="bugspotter-pii-badges">${n.join("")}</div>`;if(this.config.showExamples){i+='<div class="bugspotter-pii-details">',i+='<p style="margin: 10px 0 5px 0; font-size: 13px; color: #856404;">Detected types:</p>',i+='<ul class="bugspotter-pii-list">';for(const[t,n]of Object.entries(e)){const e=n.reduce((t,e)=>t+e.count,0);i+=`<li><strong>${this.escapeHtml(t)}:</strong> ${e} occurrence${1!==e?"s":""}</li>`}i+="</ul></div>"}return i}renderListPII(t){let e='<ul class="bugspotter-pii-list">';for(const n of t)e+=`<li>${this.escapeHtml(n.type)}: ${n.count} occurrence${1!==n.count?"s":""}</li>`;return e+="</ul>",e}createBadge(t,e){return`<span class="bugspotter-pii-badge">${this.escapeHtml(t)}: ${e}</span>`}groupByType(t){const e={};for(const n of t)e[n.type]||(e[n.type]=[]),e[n.type].push(n);return e}getSummary(t){const e=new Set;for(const n of t)e.add(n.type);return{totalCount:t.length,typeCount:e.size,types:Array.from(e)}}hasType(t,e){return t.some(t=>t.type===e)}filterByType(t,e){return t.filter(t=>t.type===e)}escapeHtml(t){const e=document.createElement("div");return e.textContent=t,e.innerHTML}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t)}getConfig(){return Object.assign({},this.config)}}class zi{constructor(t,e={}){this.isDrawing=!1,this.isRedactionMode=!1,this.startX=0,this.startY=0,this.redactionRects=[],this.canvas=t;const n=t.getContext("2d");if(!n)throw new Error("Failed to get 2D context from canvas");this.ctx=n,this.config={redactionColor:e.redactionColor||"#000000",cursorStyle:e.cursorStyle||"crosshair"},this.handleMouseDown=this.onMouseDown.bind(this),this.handleMouseMove=this.onMouseMove.bind(this),this.handleMouseUp=this.onMouseUp.bind(this)}initializeCanvas(t){const e=()=>{const e=t.getBoundingClientRect(),n=e.width||t.width,i=e.height||t.height;this.canvas.width=t.naturalWidth||t.width,this.canvas.height=t.naturalHeight||t.height,this.canvas.style.width=`${n}px`,this.canvas.style.height=`${i}px`};t.complete&&t.naturalWidth>0?e():t.addEventListener("load",e,{once:!0})}enableRedactionMode(){this.isRedactionMode||(this.isRedactionMode=!0,this.canvas.style.display="block",this.canvas.style.cursor=this.config.cursorStyle,this.canvas.addEventListener("mousedown",this.handleMouseDown),this.canvas.addEventListener("mousemove",this.handleMouseMove),this.canvas.addEventListener("mouseup",this.handleMouseUp),this.redraw())}disableRedactionMode(){this.isRedactionMode&&(this.isRedactionMode=!1,this.isDrawing=!1,this.canvas.removeEventListener("mousedown",this.handleMouseDown),this.canvas.removeEventListener("mousemove",this.handleMouseMove),this.canvas.removeEventListener("mouseup",this.handleMouseUp),this.canvas.style.cursor="default")}toggleRedactionMode(){return this.isRedactionMode?this.disableRedactionMode():this.enableRedactionMode(),this.isRedactionMode}clearRedactions(){this.redactionRects=[],this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height)}getRedactions(){return[...this.redactionRects]}setRedactions(t){this.redactionRects=[...t],this.redraw()}isActive(){return this.isRedactionMode}getCanvas(){return this.canvas}toDataURL(t="image/png",e){return this.canvas.toDataURL(t,e)}hide(){this.canvas.style.display="none"}show(){this.canvas.style.display="block"}destroy(){this.disableRedactionMode(),this.clearRedactions()}onMouseDown(t){if(!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height;this.startX=(t.clientX-e.left)*n,this.startY=(t.clientY-e.top)*i,this.isDrawing=!0}onMouseMove(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i;this.redraw(),this.drawRect(this.startX,this.startY,r-this.startX,s-this.startY)}onMouseUp(t){if(!this.isDrawing||!this.isRedactionMode)return;const e=this.canvas.getBoundingClientRect(),n=this.canvas.width/e.width,i=this.canvas.height/e.height,r=(t.clientX-e.left)*n,s=(t.clientY-e.top)*i,o=r-this.startX,a=s-this.startY;Math.abs(o)>5&&Math.abs(a)>5&&this.redactionRects.push({x:this.startX,y:this.startY,width:o,height:a}),this.isDrawing=!1,this.redraw()}redraw(){this.ctx.clearRect(0,0,this.canvas.width,this.canvas.height);for(const t of this.redactionRects)this.drawRect(t.x,t.y,t.width,t.height)}drawRect(t,e,n,i){this.ctx.fillStyle=this.config.redactionColor,this.ctx.fillRect(t,e,n,i)}updateConfig(t){this.config=Object.assign(Object.assign({},this.config),t),this.isRedactionMode&&(this.canvas.style.cursor=this.config.cursorStyle)}getConfig(){return Object.assign({},this.config)}}class Li{async mergeRedactions(t,e){return new Promise((n,i)=>{const r=new Image;r.onload=()=>{try{const t=document.createElement("canvas");t.width=r.naturalWidth||r.width,t.height=r.naturalHeight||r.height;const s=t.getContext("2d");if(!s)return void i(new Error("Failed to get canvas context"));s.drawImage(r,0,0),s.drawImage(e,0,0),n(t.toDataURL())}catch(t){i(t)}},r.onerror=()=>{i(new Error("Failed to load screenshot image"))},r.src=t})}async applyRedactions(t,e,n="#000000"){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),o.fillStyle=n;for(const t of e)o.fillRect(t.x,t.y,t.width,t.height);i(t.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async resize(t,e,n){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{let t=s.naturalWidth||s.width,o=s.naturalHeight||s.height;if(t>e||o>n){const i=t/o;t>o?(t=e,o=t/i):(o=n,t=o*i)}const a=document.createElement("canvas");a.width=t,a.height=o;const l=a.getContext("2d");if(!l)return void r(new Error("Failed to get canvas context"));l.drawImage(s,0,0,t,o),i(a.toDataURL())}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async convert(t,e,n=.92){return new Promise((i,r)=>{const s=new Image;s.onload=()=>{try{const t=document.createElement("canvas");t.width=s.naturalWidth||s.width,t.height=s.naturalHeight||s.height;const o=t.getContext("2d");if(!o)return void r(new Error("Failed to get canvas context"));o.drawImage(s,0,0),i(t.toDataURL(e,n))}catch(t){r(t)}},s.onerror=()=>{r(new Error("Failed to load image"))},s.src=t})}async getDimensions(t){return new Promise((e,n)=>{const i=new Image;i.onload=()=>{e({width:i.naturalWidth||i.width,height:i.naturalHeight||i.height})},i.onerror=()=>{n(new Error("Failed to load image"))},i.src=t})}isValidDataURL(t){return/^data:image\/(png|jpeg|jpg|webp|gif);base64,/.test(t)}getEstimatedSize(t){const e=t.split(",")[1]||"";return Math.ceil(3*e.length/4)}getFormat(t){const e=t.match(/^data:image\/([a-z]+);base64,/);return e?e[1]:null}}const Di={email:{name:"email",regex:/\b[A-Za-z0-9._%+-]+@[A-Za-z0-9.-]+\.[A-Z|a-z]{2,}\b/g,description:"Email addresses",examples:["user@example.com","john.doe+tag@company.co.uk","test_user@sub.domain.com"],priority:1},creditcard:{name:"creditcard",regex:/\b(?:\d{4}[-\s]){3}\d{4}\b|\b\d{4}[-\s]\d{6}[-\s]\d{5}\b|\b\d{13,19}\b/g,description:"Credit card numbers (Visa, MC, Amex, Discover, etc.)",examples:["4532-1488-0343-6467","4532148803436467","5425 2334 3010 9903","3782 822463 10005"],priority:2},ssn:{name:"ssn",regex:/\b\d{3}-\d{2}-\d{4}\b|\b(?<!\d)\d{9}(?!\d)\b/g,description:"US Social Security Numbers",examples:["123-45-6789","987654321"],priority:3},iin:{name:"iin",regex:/\b[0-9]{2}(?:0[1-9]|1[0-2])(?:0[1-9]|[12][0-9]|3[01])\d{6}\b/g,description:"Kazakhstan IIN/BIN (12 digits with date validation)",examples:["950315300123","880612500456","021225123456"],priority:4},ip:{name:"ip",regex:/\b(?:(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\.){3}(?:25[0-5]|2[0-4][0-9]|[01]?[0-9][0-9]?)\b|(?:[0-9a-fA-F]{1,4}:){7}[0-9a-fA-F]{1,4}\b/g,description:"IPv4 and IPv6 addresses",examples:["192.168.1.100","127.0.0.1","2001:0db8:85a3:0000:0000:8a2e:0370:7334"],priority:5},phone:{name:"phone",regex:/\+\d{1,3}[-.\s]\d{3}[-.\s]\d{4}\b|\+\d{1,3}[-.\s]\d{3}[-.\s]\d{3}[-.\s]\d{4}\b|\(\d{3}\)\s*\d{3}[-.\s]\d{4}\b|\b\d{3}[-.\s]\d{3}[-.\s]\d{4}\b/g,description:"International phone numbers",examples:["+1-555-1234","+1-555-123-4567","(555) 123-4567","555-123-4567","+7 777 123 4567"],priority:6},apikey:{name:"apikey",regex:/\b(?:sk|pk)_(?:live|test)_[a-zA-Z0-9]{24,}\b|AIza[a-zA-Z0-9_-]{35}|ya29\.[a-zA-Z0-9_-]+|AKIA[a-zA-Z0-9]{16}\b/g,description:"API keys (Stripe, Google, AWS, etc.)",examples:["sk_live_abc123def456ghi789jkl","pk_test_xyz789abc123def456","AIzaSyD1234567890abcdefghijklmnopqrst","AKIAIOSFODNN7EXAMPLE"],priority:7},token:{name:"token",regex:/\b(?:Bearer\s+)?[a-zA-Z0-9_-]{32,}\b|ghp_[a-zA-Z0-9]{36}|gho_[a-zA-Z0-9]{36}|github_pat_[a-zA-Z0-9_]{82}/g,description:"Authentication tokens (Bearer, GitHub, JWT-like)",examples:["Bearer eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9","ghp_abc123def456ghi789jkl012mno345pqr","gho_xyz789abc123def456ghi789jkl012mno"],priority:8},password:{name:"password",regex:/(?:password|passwd|pwd)[\s:=]+[^\s]{6,}|(?:password|passwd|pwd)["']?\s*[:=]\s*["']?[^\s"']{6,}/gi,description:"Password fields in text (password=..., pwd:...)",examples:["password: MySecret123!","passwd=SecurePass456",'pwd: "MyP@ssw0rd"'],priority:9}},Ni={financial:["creditcard","ssn"],contact:["email","phone"],identification:["ssn","iin"],network:["ip","email"],credentials:["apikey","token","password"],kazakhstan:["iin"]};const Fi={all:Object.keys(Di),minimal:["email","creditcard","ssn"],financial:Ni.financial,contact:Ni.contact,identification:Ni.identification,credentials:Ni.credentials,kazakhstan:["email","phone","iin"],gdpr:["email","phone","ip"],pci:["creditcard"],security:["email","phone","creditcard","ssn","apikey","token","password"]};class Bi{constructor(t,e){this.patterns=new Map,this.initializePatterns(t,e)}initializePatterns(t,e){let n;var i;n="string"==typeof t?Fi[t]:t.filter(t=>"custom"!==t),(i=n.map(t=>Di[t]),[...i].sort((t,e)=>t.priority-e.priority)).forEach(t=>{this.patterns.set(t.name,t.regex)}),e.forEach(t=>{this.patterns.set(t.name,t.regex)})}getPatterns(){return this.patterns}}class Ui{constructor(t){this.patterns=t}sanitize(t){if("string"!=typeof t)return t;let e=t;return this.patterns.forEach((t,n)=>{const i=n.toUpperCase();e=e.replace(t,`[REDACTED-${i}]`)}),e}}class Zi{constructor(t){this.stringSanitizer=t}sanitize(t){return null==t?t:"string"==typeof t?this.stringSanitizer.sanitize(t):Array.isArray(t)?t.map(t=>this.sanitize(t)):"object"==typeof t?this.sanitizeObject(t):t}sanitizeObject(t){const e={};for(const[n,i]of Object.entries(t))e[this.stringSanitizer.sanitize(n)]=this.sanitize(i);return e}}class Pi{constructor(t){this.excludeSelectors=t}shouldExclude(t){return!(!t||!this.excludeSelectors.length)&&this.excludeSelectors.some(e=>{try{return t.matches(e)}catch(t){return!1}})}}class Wi{constructor(t){var e,n,i,r;if(this.enabled=null===(e=t.enabled)||void 0===e||e,!this.enabled)return this.stringSanitizer=new Ui(new Map),this.valueSanitizer=new Zi(this.stringSanitizer),void(this.elementMatcher=new Pi([]));const s=null!==(n=t.patterns)&&void 0!==n?n:"all",o=null!==(i=t.customPatterns)&&void 0!==i?i:[],a=null!==(r=t.excludeSelectors)&&void 0!==r?r:[],l=new Bi(s,o);this.stringSanitizer=new Ui(l.getPatterns()),this.valueSanitizer=new Zi(this.stringSanitizer),this.elementMatcher=new Pi(a)}guardDisabled(t){return this.enabled?void 0:t}sanitize(t){const e=this.guardDisabled(t);return void 0!==e?e:this.valueSanitizer.sanitize(t)}sanitizeConsoleArgs(t){const e=this.guardDisabled(t);return void 0!==e?e:t.map(t=>this.sanitize(t))}sanitizeNetworkData(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}sanitizeError(t){const e=this.guardDisabled(t);return void 0!==e?e:this.sanitize(t)}shouldExclude(t){return!!this.enabled&&this.elementMatcher.shouldExclude(t)}sanitizeTextNode(t,e){const n=this.guardDisabled(t);return void 0!==n?n:this.elementMatcher.shouldExclude(e)?t:this.stringSanitizer.sanitize(t)}detectPII(t){const e=new Map;if(!this.enabled||!t)return e;for(const[n,i]of this.stringSanitizer.patterns){const r=t.match(new RegExp(i,"g"));r&&r.length>0&&e.set(n,r.length)}return e}}function Vi(t){return new Wi(t)}const Gi=Z();class ji{constructor(t){this.redactionCanvas=null,this.originalScreenshot="",this.piiDetections=[],this.options=t,this.container=document.createElement("div"),this.shadow=this.container.attachShadow({mode:"open"}),this.styleManager=new Ei,this.templateManager=new Ri,this.domCache=new Mi,this.validator=new Ti,this.piiDisplay=new Oi,this.screenshotProcessor=new Li,this.handleEscapeKey=this.onEscapeKey.bind(this)}show(t){t&&(this.originalScreenshot=t),this.shadow.innerHTML=`\n <style>\n ${this.styleManager.generateStyles()}\n </style>\n ${this.templateManager.generateModalHTML(this.originalScreenshot)}\n `,this.domCache.initialize(this.shadow);const e=this.domCache.get();e.titleError.style.display="none",e.descriptionError.style.display="none",this.setupRedactionCanvas(),this.attachEventListeners(),document.body.appendChild(this.container),e.titleInput.focus()}close(){document.removeEventListener("keydown",this.handleEscapeKey),this.redactionCanvas&&(this.redactionCanvas.destroy(),this.redactionCanvas=null),this.container.parentNode&&this.container.parentNode.removeChild(this.container),this.domCache.clear(),this.options.onClose&&this.options.onClose()}destroy(){this.close()}setupRedactionCanvas(){const t=this.domCache.get();if(t.redactionCanvas&&t.screenshotImg)try{this.redactionCanvas=new zi(t.redactionCanvas),this.redactionCanvas.initializeCanvas(t.screenshotImg)}catch(t){Z().warn("Canvas redaction not available:",t),this.redactionCanvas=null}}attachEventListeners(){const t=this.domCache.get();t.closeButton.addEventListener("click",()=>this.close()),document.addEventListener("keydown",this.handleEscapeKey),t.form.addEventListener("submit",t=>this.handleSubmit(t)),t.submitButton.addEventListener("click",()=>{const e=new Event("submit",{bubbles:!0,cancelable:!0});t.form.dispatchEvent(e)}),t.cancelButton.addEventListener("click",()=>this.close()),t.titleInput.addEventListener("input",()=>this.validateField("title")),t.descriptionTextarea.addEventListener("input",()=>{this.validateField("description"),this.checkForPII()}),t.redactButton&&this.redactionCanvas&&t.redactButton.addEventListener("click",()=>this.toggleRedactionMode()),t.clearButton&&this.redactionCanvas&&t.clearButton.addEventListener("click",()=>this.clearRedactions()),t.piiConfirmCheckbox.addEventListener("change",()=>this.updateSubmitButton())}validateField(t){const e=this.domCache.get(),n="title"===t?e.titleInput.value:e.descriptionTextarea.value,i=this.validator.validateField(t,n),r="title"===t?e.titleError:e.descriptionError;i?(r.textContent=i,r.style.display="block"):(r.textContent="",r.style.display="none")}checkForPII(){const t=this.domCache.get(),e=`${t.titleInput.value} ${t.descriptionTextarea.value}`,n=Vi({enabled:!0}).detectPII(e);this.piiDetections=Array.from(n.entries()).map(([t,e])=>({type:t,count:e})),this.piiDetections.length>0?(t.piiSection.style.display="block",this.piiDisplay.render(this.piiDetections,t.piiContent)):(t.piiSection.style.display="none",t.piiConfirmCheckbox.checked=!1),this.updateSubmitButton()}updateSubmitButton(){const t=this.domCache.get(),e=this.piiDetections.length>0,n=t.piiConfirmCheckbox.checked;t.submitButton.disabled=e&&!n}toggleRedactionMode(){const t=this.domCache.get();this.redactionCanvas&&t.redactButton&&(this.redactionCanvas.toggleRedactionMode()?(t.redactButton.classList.add("active"),t.redactButton.textContent="✓ Redacting..."):(t.redactButton.classList.remove("active"),t.redactButton.textContent="✏️ Redact Area"))}clearRedactions(){this.redactionCanvas&&this.redactionCanvas.clearRedactions()}async handleSubmit(t){t.preventDefault();const e=this.domCache.get(),n={title:e.titleInput.value,description:e.descriptionTextarea.value,piiDetected:this.piiDetections.length>0,piiConfirmed:e.piiConfirmCheckbox.checked},i=this.validator.validate(n);if(!i.isValid)return i.errors.title?(e.titleError.textContent=i.errors.title,e.titleError.style.display="block"):(e.titleError.textContent="",e.titleError.style.display="none"),i.errors.description?(e.descriptionError.textContent=i.errors.description,e.descriptionError.style.display="block"):(e.descriptionError.textContent="",e.descriptionError.style.display="none"),void(i.errors.piiConfirmation&&alert(i.errors.piiConfirmation));e.titleError.style.display="none",e.descriptionError.style.display="none";let r=this.originalScreenshot;if(this.redactionCanvas&&this.redactionCanvas.getRedactions().length>0)try{r=await this.screenshotProcessor.mergeRedactions(this.originalScreenshot,this.redactionCanvas.getCanvas())}catch(t){Gi.error("Failed to merge redactions:",t),r=this.originalScreenshot}this.originalScreenshot=r;const s={title:n.title.trim(),description:n.description.trim()};try{await this.options.onSubmit(s),this.close()}catch(t){Z().error("Error submitting bug report:",t),alert("Failed to submit bug report. Please try again.")}}getScreenshot(){return this.originalScreenshot}onEscapeKey(t){"Escape"===t.key&&this.close()}}var qi;function Hi(t){var e=null==t?void 0:t.host;return Boolean((null==e?void 0:e.shadowRoot)===t)}function Ki(t){return"[object ShadowRoot]"===Object.prototype.toString.call(t)}function $i(t){try{var e=t.rules||t.cssRules;return e?((n=Array.from(e).map(Yi).join("")).includes(" background-clip: text;")&&!n.includes(" -webkit-background-clip: text;")&&(n=n.replace(" background-clip: text;"," -webkit-background-clip: text; background-clip: text;")),n):null}catch(t){return null}var n}function Yi(t){var e=t.cssText;if(function(t){return"styleSheet"in t}(t))try{e=$i(t.styleSheet)||e}catch(t){}return e}!function(t){t[t.Document=0]="Document",t[t.DocumentType=1]="DocumentType",t[t.Element=2]="Element",t[t.Text=3]="Text",t[t.CDATA=4]="CDATA",t[t.Comment=5]="Comment"}(qi||(qi={}));var Qi=function(){function t(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap}return t.prototype.getId=function(t){var e;if(!t)return-1;var n=null===(e=this.getMeta(t))||void 0===e?void 0:e.id;return null!=n?n:-1},t.prototype.getNode=function(t){return this.idNodeMap.get(t)||null},t.prototype.getIds=function(){return Array.from(this.idNodeMap.keys())},t.prototype.getMeta=function(t){return this.nodeMetaMap.get(t)||null},t.prototype.removeNodeFromMap=function(t){var e=this,n=this.getId(t);this.idNodeMap.delete(n),t.childNodes&&t.childNodes.forEach(function(t){return e.removeNodeFromMap(t)})},t.prototype.has=function(t){return this.idNodeMap.has(t)},t.prototype.hasNode=function(t){return this.nodeMetaMap.has(t)},t.prototype.add=function(t,e){var n=e.id;this.idNodeMap.set(n,t),this.nodeMetaMap.set(t,e)},t.prototype.replace=function(t,e){var n=this.getNode(t);if(n){var i=this.nodeMetaMap.get(n);i&&this.nodeMetaMap.set(e,i)}this.idNodeMap.set(t,e)},t.prototype.reset=function(){this.idNodeMap=new Map,this.nodeMetaMap=new WeakMap},t}();function Ji(t){var e=t.maskInputOptions,n=t.tagName,i=t.type,r=t.value,s=t.maskInputFn,o=r||"";return(e[n.toLowerCase()]||e[i])&&(o=s?s(o):"*".repeat(o.length)),o}var Xi,tr,er="__rrweb_original__",nr=1,ir=new RegExp("[^a-z0-9-_:]");function rr(){return nr++}var sr=/url\((?:(')([^']*)'|(")(.*?)"|([^)]*))\)/gm,or=/^(?!www\.|(?:http|ftp)s?:\/\/|[A-Za-z]:\\|\/\/|#).*/,ar=/^(data:)([^,]*),(.*)/i;function lr(t,e){return(t||"").replace(sr,function(t,n,i,r,s,o){var a,l=i||s||o,c=n||r||"";if(!l)return t;if(!or.test(l))return"url(".concat(c).concat(l).concat(c,")");if(ar.test(l))return"url(".concat(c).concat(l).concat(c,")");if("/"===l[0])return"url(".concat(c).concat((a=e,(a.indexOf("//")>-1?a.split("/").slice(0,3).join("/"):a.split("/")[0]).split("?")[0]+l)).concat(c,")");var d=e.split("/"),h=l.split("/");d.pop();for(var u=0,p=h;u<p.length;u++){var g=p[u];"."!==g&&(".."===g?d.pop():d.push(g))}return"url(".concat(c).concat(d.join("/")).concat(c,")")})}var cr=/^[^ \t\n\r\u000c]+/,dr=/^[, \t\n\r\u000c]+/;function hr(t,e){if(!e||""===e.trim())return e;var n=t.createElement("a");return n.href=e,n.href}function ur(){var t=document.createElement("a");return t.href="",t.href}function pr(t,e,n,i){return"src"===n||"href"===n&&i&&("use"!==e||"#"!==i[0])||"xlink:href"===n&&i&&"#"!==i[0]?hr(t,i):"background"!==n||!i||"table"!==e&&"td"!==e&&"th"!==e?"srcset"===n&&i?function(t,e){if(""===e.trim())return e;var n=0;function i(t){var i,r=t.exec(e.substring(n));return r?(i=r[0],n+=i.length,i):""}for(var r=[];i(dr),!(n>=e.length);){var s=i(cr);if(","===s.slice(-1))s=hr(t,s.substring(0,s.length-1)),r.push(s);else{var o="";s=hr(t,s);for(var a=!1;;){var l=e.charAt(n);if(""===l){r.push((s+o).trim());break}if(a)")"===l&&(a=!1);else{if(","===l){n+=1,r.push((s+o).trim());break}"("===l&&(a=!0)}o+=l,n+=1}}}return r.join(", ")}(t,i):"style"===n&&i?lr(i,ur()):"object"===e&&"data"===n&&i?hr(t,i):i:hr(t,i)}function gr(t,e,n){if(!t)return!1;if(t.nodeType!==t.ELEMENT_NODE)return!!n&&gr(t.parentNode,e,n);for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&gr(t.parentNode,e,n)}function mr(t,e,n){var i=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(null===i)return!1;if("string"==typeof e){if(i.classList.contains(e))return!0;if(i.closest(".".concat(e)))return!0}else if(gr(i,e,!0))return!0;if(n){if(i.matches(n))return!0;if(i.closest(n))return!0}return!1}function fr(t){return void 0===t?"":t.toLowerCase()}function yr(t,e){var n,i=e.doc,r=e.mirror,s=e.blockClass,o=e.blockSelector,a=e.maskTextClass,l=e.maskTextSelector,c=e.skipChild,d=void 0!==c&&c,h=e.inlineStylesheet,u=void 0===h||h,p=e.maskInputOptions,g=void 0===p?{}:p,m=e.maskTextFn,f=e.maskInputFn,y=e.slimDOMOptions,b=e.dataURLOptions,w=void 0===b?{}:b,v=e.inlineImages,C=void 0!==v&&v,I=e.recordCanvas,_=void 0!==I&&I,S=e.onSerialize,k=e.onIframeLoad,x=e.iframeLoadTimeout,A=void 0===x?5e3:x,E=e.onStylesheetLoad,R=e.stylesheetLoadTimeout,M=void 0===R?5e3:R,T=e.keepIframeSrcFn,O=void 0===T?function(){return!1}:T,z=e.newlyAddedElement,L=void 0!==z&&z,D=e.preserveWhiteSpace,N=void 0===D||D,F=function(t,e){var n=e.doc,i=e.mirror,r=e.blockClass,s=e.blockSelector,o=e.maskTextClass,a=e.maskTextSelector,l=e.inlineStylesheet,c=e.maskInputOptions,d=void 0===c?{}:c,h=e.maskTextFn,u=e.maskInputFn,p=e.dataURLOptions,g=void 0===p?{}:p,m=e.inlineImages,f=e.recordCanvas,y=e.keepIframeSrcFn,b=e.newlyAddedElement,w=void 0!==b&&b,v=function(t,e){if(e.hasNode(t)){var n=e.getId(t);return 1===n?void 0:n}}(n,i);switch(t.nodeType){case t.DOCUMENT_NODE:return"CSS1Compat"!==t.compatMode?{type:qi.Document,childNodes:[],compatMode:t.compatMode}:{type:qi.Document,childNodes:[]};case t.DOCUMENT_TYPE_NODE:return{type:qi.DocumentType,name:t.name,publicId:t.publicId,systemId:t.systemId,rootId:v};case t.ELEMENT_NODE:return function(t,e){for(var n=e.doc,i=e.inlineStylesheet,r=e.maskInputOptions,s=void 0===r?{}:r,o=e.maskInputFn,a=e.dataURLOptions,l=void 0===a?{}:a,c=e.inlineImages,d=e.recordCanvas,h=e.keepIframeSrcFn,u=e.newlyAddedElement,p=void 0!==u&&u,g=e.rootId,m=function(t,e,n){if("string"==typeof e){if(t.classList.contains(e))return!0}else for(var i=t.classList.length;i--;){var r=t.classList[i];if(e.test(r))return!0}return!!n&&t.matches(n)}(t,e.blockClass,e.blockSelector),f=function(t){if(t instanceof HTMLFormElement)return"form";var e=t.tagName.toLowerCase().trim();return ir.test(e)?"div":e}(t),y={},b=t.attributes.length,w=0;w<b;w++){var v=t.attributes[w];y[v.name]=pr(n,f,v.name,v.value)}if("link"===f&&i){var C=Array.from(n.styleSheets).find(function(e){return e.href===t.href}),I=null;C&&(I=$i(C)),I&&(delete y.rel,delete y.href,y._cssText=lr(I,C.href))}if("style"===f&&t.sheet&&!(t.innerText||t.textContent||"").trim().length&&(I=$i(t.sheet))&&(y._cssText=lr(I,ur())),"input"===f||"textarea"===f||"select"===f){var _=t.value,S=t.checked;"radio"!==y.type&&"checkbox"!==y.type&&"submit"!==y.type&&"button"!==y.type&&_?y.value=Ji({type:y.type,tagName:f,value:_,maskInputOptions:s,maskInputFn:o}):S&&(y.checked=S)}if("option"===f&&(t.selected&&!s.select?y.selected=!0:delete y.selected),"canvas"===f&&d)if("2d"===t.__context)(function(t){var e=t.getContext("2d");if(!e)return!0;for(var n=0;n<t.width;n+=50)for(var i=0;i<t.height;i+=50){var r=e.getImageData,s=er in r?r[er]:r;if(new Uint32Array(s.call(e,n,i,Math.min(50,t.width-n),Math.min(50,t.height-i)).data.buffer).some(function(t){return 0!==t}))return!1}return!0})(t)||(y.rr_dataURL=t.toDataURL(l.type,l.quality));else if(!("__context"in t)){var k=t.toDataURL(l.type,l.quality),x=document.createElement("canvas");x.width=t.width,x.height=t.height,k!==x.toDataURL(l.type,l.quality)&&(y.rr_dataURL=k)}if("img"===f&&c){Xi||(Xi=n.createElement("canvas"),tr=Xi.getContext("2d"));var A=t,E=A.crossOrigin;A.crossOrigin="anonymous";var R=function(){try{Xi.width=A.naturalWidth,Xi.height=A.naturalHeight,tr.drawImage(A,0,0),y.rr_dataURL=Xi.toDataURL(l.type,l.quality)}catch(t){console.warn("Cannot inline img src=".concat(A.currentSrc,"! Error: ").concat(t))}E?y.crossOrigin=E:A.removeAttribute("crossorigin")};A.complete&&0!==A.naturalWidth?R():A.onload=R}if("audio"!==f&&"video"!==f||(y.rr_mediaState=t.paused?"paused":"played",y.rr_mediaCurrentTime=t.currentTime),p||(t.scrollLeft&&(y.rr_scrollLeft=t.scrollLeft),t.scrollTop&&(y.rr_scrollTop=t.scrollTop)),m){var M=t.getBoundingClientRect(),T=M.width,O=M.height;y={class:y.class,rr_width:"".concat(T,"px"),rr_height:"".concat(O,"px")}}return"iframe"!==f||h(y.src)||(t.contentDocument||(y.rr_src=y.src),delete y.src),{type:qi.Element,tagName:f,attributes:y,childNodes:[],isSVG:(z=t,Boolean("svg"===z.tagName||z.ownerSVGElement)||void 0),needBlock:m,rootId:g};var z}(t,{doc:n,blockClass:r,blockSelector:s,inlineStylesheet:l,maskInputOptions:d,maskInputFn:u,dataURLOptions:g,inlineImages:m,recordCanvas:f,keepIframeSrcFn:y,newlyAddedElement:w,rootId:v});case t.TEXT_NODE:return function(t,e){var n,i,r=e.maskTextClass,s=e.maskTextSelector,o=e.maskTextFn,a=e.rootId,l=t.parentNode&&t.parentNode.tagName,c=t.textContent,d="STYLE"===l||void 0,h="SCRIPT"===l||void 0;if(d&&c){try{t.nextSibling||t.previousSibling||(null===(n=t.parentNode.sheet)||void 0===n?void 0:n.cssRules)&&(c=(i=t.parentNode.sheet).cssRules?Array.from(i.cssRules).map(function(t){return t.cssText||""}).join(""):"")}catch(e){console.warn("Cannot get CSS styles from text's parentNode. Error: ".concat(e),t)}c=lr(c,ur())}return h&&(c="SCRIPT_PLACEHOLDER"),!d&&!h&&c&&mr(t,r,s)&&(c=o?o(c):c.replace(/[\S]/g,"*")),{type:qi.Text,textContent:c||"",isStyle:d,rootId:a}}(t,{maskTextClass:o,maskTextSelector:a,maskTextFn:h,rootId:v});case t.CDATA_SECTION_NODE:return{type:qi.CDATA,textContent:"",rootId:v};case t.COMMENT_NODE:return{type:qi.Comment,textContent:t.textContent||"",rootId:v};default:return!1}}(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,dataURLOptions:w,inlineImages:C,recordCanvas:_,keepIframeSrcFn:O,newlyAddedElement:L});if(!F)return console.warn(t,"not serialized"),null;n=r.hasNode(t)?r.getId(t):!function(t,e){if(e.comment&&t.type===qi.Comment)return!0;if(t.type===qi.Element){if(e.script&&("script"===t.tagName||"link"===t.tagName&&"preload"===t.attributes.rel&&"script"===t.attributes.as||"link"===t.tagName&&"prefetch"===t.attributes.rel&&"string"==typeof t.attributes.href&&t.attributes.href.endsWith(".js")))return!0;if(e.headFavicon&&("link"===t.tagName&&"shortcut icon"===t.attributes.rel||"meta"===t.tagName&&(fr(t.attributes.name).match(/^msapplication-tile(image|color)$/)||"application-name"===fr(t.attributes.name)||"icon"===fr(t.attributes.rel)||"apple-touch-icon"===fr(t.attributes.rel)||"shortcut icon"===fr(t.attributes.rel))))return!0;if("meta"===t.tagName){if(e.headMetaDescKeywords&&fr(t.attributes.name).match(/^description|keywords$/))return!0;if(e.headMetaSocial&&(fr(t.attributes.property).match(/^(og|twitter|fb):/)||fr(t.attributes.name).match(/^(og|twitter):/)||"pinterest"===fr(t.attributes.name)))return!0;if(e.headMetaRobots&&("robots"===fr(t.attributes.name)||"googlebot"===fr(t.attributes.name)||"bingbot"===fr(t.attributes.name)))return!0;if(e.headMetaHttpEquiv&&void 0!==t.attributes["http-equiv"])return!0;if(e.headMetaAuthorship&&("author"===fr(t.attributes.name)||"generator"===fr(t.attributes.name)||"framework"===fr(t.attributes.name)||"publisher"===fr(t.attributes.name)||"progid"===fr(t.attributes.name)||fr(t.attributes.property).match(/^article:/)||fr(t.attributes.property).match(/^product:/)))return!0;if(e.headMetaVerification&&("google-site-verification"===fr(t.attributes.name)||"yandex-verification"===fr(t.attributes.name)||"csrf-token"===fr(t.attributes.name)||"p:domain_verify"===fr(t.attributes.name)||"verify-v1"===fr(t.attributes.name)||"verification"===fr(t.attributes.name)||"shopify-checkout-api-token"===fr(t.attributes.name)))return!0}}return!1}(F,y)&&(N||F.type!==qi.Text||F.isStyle||F.textContent.replace(/^\s+|\s+$/gm,"").length)?rr():-2;var B=Object.assign(F,{id:n});if(r.add(t,B),-2===n)return null;S&&S(t);var U=!d;if(B.type===qi.Element){U=U&&!B.needBlock,delete B.needBlock;var Z=t.shadowRoot;Z&&Ki(Z)&&(B.isShadowHost=!0)}if((B.type===qi.Document||B.type===qi.Element)&&U){y.headWhitespace&&B.type===qi.Element&&"head"===B.tagName&&(N=!1);for(var P={doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:d,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:N,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:O},W=0,V=Array.from(t.childNodes);W<V.length;W++)(q=yr(V[W],P))&&B.childNodes.push(q);if(function(t){return t.nodeType===t.ELEMENT_NODE}(t)&&t.shadowRoot)for(var G=0,j=Array.from(t.shadowRoot.childNodes);G<j.length;G++){var q;(q=yr(j[G],P))&&(Ki(t.shadowRoot)&&(q.isShadow=!0),B.childNodes.push(q))}}return t.parentNode&&Hi(t.parentNode)&&Ki(t.parentNode)&&(B.isShadow=!0),B.type===qi.Element&&"iframe"===B.tagName&&function(t,e,n){var i=t.contentWindow;if(i){var r,s=!1;try{r=i.document.readyState}catch(t){return}if("complete"===r){var o="about:blank";if(i.location.href!==o||t.src===o||""===t.src)return setTimeout(e,0),t.addEventListener("load",e);t.addEventListener("load",e)}else{var a=setTimeout(function(){s||(e(),s=!0)},n);t.addEventListener("load",function(){clearTimeout(a),s=!0,e()})}}}(t,function(){var e=t.contentDocument;if(e&&k){var n=yr(e,{doc:e,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:N,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:O});n&&k(t,n)}},A),B.type===qi.Element&&"link"===B.tagName&&"stylesheet"===B.attributes.rel&&function(t,e,n){var i,r=!1;try{i=t.sheet}catch(t){return}if(!i){var s=setTimeout(function(){r||(e(),r=!0)},n);t.addEventListener("load",function(){clearTimeout(s),r=!0,e()})}}(t,function(){if(E){var e=yr(t,{doc:i,mirror:r,blockClass:s,blockSelector:o,maskTextClass:a,maskTextSelector:l,skipChild:!1,inlineStylesheet:u,maskInputOptions:g,maskTextFn:m,maskInputFn:f,slimDOMOptions:y,dataURLOptions:w,inlineImages:C,recordCanvas:_,preserveWhiteSpace:N,onSerialize:S,onIframeLoad:k,iframeLoadTimeout:A,onStylesheetLoad:E,stylesheetLoadTimeout:M,keepIframeSrcFn:O});e&&E(t,e)}},M),B}function br(t,e,n=document){const i={capture:!0,passive:!0};return n.addEventListener(t,e,i),()=>n.removeEventListener(t,e,i)}new RegExp(/([^\\]):hover/.source,"g");const wr="Please stop import mirror directly. Instead of that,\r\nnow you can use replayer.getMirror() to access the mirror instance of a replayer,\r\nor you can use record.mirror to access the mirror instance during recording.";let vr={map:{},getId:()=>(console.error(wr),-1),getNode:()=>(console.error(wr),null),removeNodeFromMap(){console.error(wr)},has:()=>(console.error(wr),!1),reset(){console.error(wr)}};function Cr(t,e,n={}){let i=null,r=0;return function(...s){const o=Date.now();r||!1!==n.leading||(r=o);const a=e-(o-r),l=this;a<=0||a>e?(i&&(clearTimeout(i),i=null),r=o,t.apply(l,s)):i||!1===n.trailing||(i=setTimeout(()=>{r=!1===n.leading?0:Date.now(),i=null,t.apply(l,s)},a))}}function Ir(t,e,n,i,r=window){const s=r.Object.getOwnPropertyDescriptor(t,e);return r.Object.defineProperty(t,e,i?n:{set(t){setTimeout(()=>{n.set.call(this,t)},0),s&&s.set&&s.set.call(this,t)}}),()=>Ir(t,e,s||{},!0)}function _r(t,e,n){try{if(!(e in t))return()=>{};const i=t[e],r=n(i);return"function"==typeof r&&(r.prototype=r.prototype||{},Object.defineProperties(r,{__rrweb_original__:{enumerable:!1,value:i}})),t[e]=r,()=>{t[e]=i}}catch(t){return()=>{}}}function Sr(){return window.innerHeight||document.documentElement&&document.documentElement.clientHeight||document.body&&document.body.clientHeight}function kr(){return window.innerWidth||document.documentElement&&document.documentElement.clientWidth||document.body&&document.body.clientWidth}function xr(t,e,n,i){if(!t)return!1;const r=t.nodeType===t.ELEMENT_NODE?t:t.parentElement;if(!r)return!1;if("string"==typeof e){if(r.classList.contains(e))return!0;if(i&&null!==r.closest("."+e))return!0}else if(gr(r,e,i))return!0;if(n){if(t.matches(n))return!0;if(i&&null!==r.closest(n))return!0}return!1}function Ar(t,e){return-2===e.getId(t)}function Er(t,e){if(Hi(t))return!1;const n=e.getId(t);return!e.has(n)||(!t.parentNode||t.parentNode.nodeType!==t.DOCUMENT_NODE)&&(!t.parentNode||Er(t.parentNode,e))}function Rr(t){return Boolean(t.changedTouches)}function Mr(t,e){return Boolean("IFRAME"===t.nodeName&&e.getMeta(t))}function Tr(t,e){return Boolean("LINK"===t.nodeName&&t.nodeType===t.ELEMENT_NODE&&t.getAttribute&&"stylesheet"===t.getAttribute("rel")&&e.getMeta(t))}function Or(t){return Boolean(null==t?void 0:t.shadowRoot)}"undefined"!=typeof window&&window.Proxy&&window.Reflect&&(vr=new Proxy(vr,{get:(t,e,n)=>("map"===e&&console.error(wr),Reflect.get(t,e,n))}));class zr{constructor(){this.id=1,this.styleIDMap=new WeakMap,this.idStyleMap=new Map}getId(t){var e;return null!==(e=this.styleIDMap.get(t))&&void 0!==e?e:-1}has(t){return this.styleIDMap.has(t)}add(t,e){if(this.has(t))return this.getId(t);let n;return n=void 0===e?this.id++:e,this.styleIDMap.set(t,n),this.idStyleMap.set(n,t),n}getStyle(t){return this.idStyleMap.get(t)||null}reset(){this.styleIDMap=new WeakMap,this.idStyleMap=new Map,this.id=1}generateId(){return this.id++}}var Lr=(t=>(t[t.DomContentLoaded=0]="DomContentLoaded",t[t.Load=1]="Load",t[t.FullSnapshot=2]="FullSnapshot",t[t.IncrementalSnapshot=3]="IncrementalSnapshot",t[t.Meta=4]="Meta",t[t.Custom=5]="Custom",t[t.Plugin=6]="Plugin",t))(Lr||{}),Dr=(t=>(t[t.Mutation=0]="Mutation",t[t.MouseMove=1]="MouseMove",t[t.MouseInteraction=2]="MouseInteraction",t[t.Scroll=3]="Scroll",t[t.ViewportResize=4]="ViewportResize",t[t.Input=5]="Input",t[t.TouchMove=6]="TouchMove",t[t.MediaInteraction=7]="MediaInteraction",t[t.StyleSheetRule=8]="StyleSheetRule",t[t.CanvasMutation=9]="CanvasMutation",t[t.Font=10]="Font",t[t.Log=11]="Log",t[t.Drag=12]="Drag",t[t.StyleDeclaration=13]="StyleDeclaration",t[t.Selection=14]="Selection",t[t.AdoptedStyleSheet=15]="AdoptedStyleSheet",t))(Dr||{}),Nr=(t=>(t[t.MouseUp=0]="MouseUp",t[t.MouseDown=1]="MouseDown",t[t.Click=2]="Click",t[t.ContextMenu=3]="ContextMenu",t[t.DblClick=4]="DblClick",t[t.Focus=5]="Focus",t[t.Blur=6]="Blur",t[t.TouchStart=7]="TouchStart",t[t.TouchMove_Departed=8]="TouchMove_Departed",t[t.TouchEnd=9]="TouchEnd",t[t.TouchCancel=10]="TouchCancel",t))(Nr||{}),Fr=(t=>(t[t["2D"]=0]="2D",t[t.WebGL=1]="WebGL",t[t.WebGL2=2]="WebGL2",t))(Fr||{});function Br(t){return"__ln"in t}class Ur{constructor(){this.length=0,this.head=null}get(t){if(t>=this.length)throw new Error("Position outside of list range");let e=this.head;for(let n=0;n<t;n++)e=(null==e?void 0:e.next)||null;return e}addNode(t){const e={value:t,previous:null,next:null};if(t.__ln=e,t.previousSibling&&Br(t.previousSibling)){const n=t.previousSibling.__ln.next;e.next=n,e.previous=t.previousSibling.__ln,t.previousSibling.__ln.next=e,n&&(n.previous=e)}else if(t.nextSibling&&Br(t.nextSibling)&&t.nextSibling.__ln.previous){const n=t.nextSibling.__ln.previous;e.previous=n,e.next=t.nextSibling.__ln,t.nextSibling.__ln.previous=e,n&&(n.next=e)}else this.head&&(this.head.previous=e),e.next=this.head,this.head=e;this.length++}removeNode(t){const e=t.__ln;this.head&&(e.previous?(e.previous.next=e.next,e.next&&(e.next.previous=e.previous)):(this.head=e.next,this.head&&(this.head.previous=null)),t.__ln&&delete t.__ln,this.length--)}}const Zr=(t,e)=>`${t}@${e}`;class Pr{constructor(){this.frozen=!1,this.locked=!1,this.texts=[],this.attributes=[],this.removes=[],this.mapRemoves=[],this.movedMap={},this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.processMutations=t=>{t.forEach(this.processMutation),this.emit()},this.emit=()=>{if(this.frozen||this.locked)return;const t=[],e=new Ur,n=t=>{let e=t,n=-2;for(;-2===n;)e=e&&e.nextSibling,n=e&&this.mirror.getId(e);return n},i=i=>{var r,s,o,a;let l=null;(null===(s=null===(r=i.getRootNode)||void 0===r?void 0:r.call(i))||void 0===s?void 0:s.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&i.getRootNode().host&&(l=i.getRootNode().host);let c=l;for(;(null===(a=null===(o=null==c?void 0:c.getRootNode)||void 0===o?void 0:o.call(c))||void 0===a?void 0:a.nodeType)===Node.DOCUMENT_FRAGMENT_NODE&&c.getRootNode().host;)c=c.getRootNode().host;const d=!(this.doc.contains(i)||c&&this.doc.contains(c));if(!i.parentNode||d)return;const h=Hi(i.parentNode)?this.mirror.getId(l):this.mirror.getId(i.parentNode),u=n(i);if(-1===h||-1===u)return e.addNode(i);const p=yr(i,{doc:this.doc,mirror:this.mirror,blockClass:this.blockClass,blockSelector:this.blockSelector,maskTextClass:this.maskTextClass,maskTextSelector:this.maskTextSelector,skipChild:!0,newlyAddedElement:!0,inlineStylesheet:this.inlineStylesheet,maskInputOptions:this.maskInputOptions,maskTextFn:this.maskTextFn,maskInputFn:this.maskInputFn,slimDOMOptions:this.slimDOMOptions,dataURLOptions:this.dataURLOptions,recordCanvas:this.recordCanvas,inlineImages:this.inlineImages,onSerialize:t=>{Mr(t,this.mirror)&&this.iframeManager.addIframe(t),Tr(t,this.mirror)&&this.stylesheetManager.trackLinkElement(t),Or(i)&&this.shadowDomManager.addShadowRoot(i.shadowRoot,this.doc)},onIframeLoad:(t,e)=>{this.iframeManager.attachIframe(t,e),this.shadowDomManager.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{this.stylesheetManager.attachLinkElement(t,e)}});p&&t.push({parentId:h,nextId:u,node:p})};for(;this.mapRemoves.length;)this.mirror.removeNodeFromMap(this.mapRemoves.shift());for(const t of Array.from(this.movedSet.values()))Vr(this.removes,t,this.mirror)&&!this.movedSet.has(t.parentNode)||i(t);for(const t of Array.from(this.addedSet.values()))jr(this.droppedSet,t)||Vr(this.removes,t,this.mirror)?jr(this.movedSet,t)?i(t):this.droppedSet.add(t):i(t);let r=null;for(;e.length;){let t=null;if(r){const e=this.mirror.getId(r.value.parentNode),i=n(r.value);-1!==e&&-1!==i&&(t=r)}if(!t)for(let i=e.length-1;i>=0;i--){const r=e.get(i);if(r){const e=this.mirror.getId(r.value.parentNode);if(-1===n(r.value))continue;if(-1!==e){t=r;break}{const e=r.value;if(e.parentNode&&e.parentNode.nodeType===Node.DOCUMENT_FRAGMENT_NODE){const n=e.parentNode.host;if(-1!==this.mirror.getId(n)){t=r;break}}}}}if(!t){for(;e.head;)e.removeNode(e.head.value);break}r=t.previous,e.removeNode(t.value),i(t.value)}const s={texts:this.texts.map(t=>({id:this.mirror.getId(t.node),value:t.value})).filter(t=>this.mirror.has(t.id)),attributes:this.attributes.map(t=>({id:this.mirror.getId(t.node),attributes:t.attributes})).filter(t=>this.mirror.has(t.id)),removes:this.removes,adds:t};(s.texts.length||s.attributes.length||s.removes.length||s.adds.length)&&(this.texts=[],this.attributes=[],this.removes=[],this.addedSet=new Set,this.movedSet=new Set,this.droppedSet=new Set,this.movedMap={},this.mutationCb(s))},this.processMutation=t=>{if(!Ar(t.target,this.mirror))switch(t.type){case"characterData":{const e=t.target.textContent;xr(t.target,this.blockClass,this.blockSelector,!1)||e===t.oldValue||this.texts.push({value:mr(t.target,this.maskTextClass,this.maskTextSelector)&&e?this.maskTextFn?this.maskTextFn(e):e.replace(/[\S]/g,"*"):e,node:t.target});break}case"attributes":{const e=t.target;let n=t.target.getAttribute(t.attributeName);if("value"===t.attributeName&&(n=Ji({maskInputOptions:this.maskInputOptions,tagName:t.target.tagName,type:t.target.getAttribute("type"),value:n,maskInputFn:this.maskInputFn})),xr(t.target,this.blockClass,this.blockSelector,!1)||n===t.oldValue)return;let i=this.attributes.find(e=>e.node===t.target);if("IFRAME"===e.tagName&&"src"===t.attributeName&&!this.keepIframeSrcFn(n)){if(e.contentDocument)return;t.attributeName="rr_src"}if(i||(i={node:t.target,attributes:{}},this.attributes.push(i)),"style"===t.attributeName){const n=this.doc.createElement("span");t.oldValue&&n.setAttribute("style",t.oldValue),void 0!==i.attributes.style&&null!==i.attributes.style||(i.attributes.style={});const r=i.attributes.style;for(const t of Array.from(e.style)){const i=e.style.getPropertyValue(t),s=e.style.getPropertyPriority(t);i===n.style.getPropertyValue(t)&&s===n.style.getPropertyPriority(t)||(r[t]=""===s?i:[i,s])}for(const t of Array.from(n.style))""===e.style.getPropertyValue(t)&&(r[t]=!1)}else i.attributes[t.attributeName]=pr(this.doc,e.tagName,t.attributeName,n);break}case"childList":if(xr(t.target,this.blockClass,this.blockSelector,!0))return;t.addedNodes.forEach(e=>this.genAdds(e,t.target)),t.removedNodes.forEach(e=>{const n=this.mirror.getId(e),i=Hi(t.target)?this.mirror.getId(t.target.host):this.mirror.getId(t.target);xr(t.target,this.blockClass,this.blockSelector,!1)||Ar(e,this.mirror)||!function(t,e){return-1!==e.getId(t)}(e,this.mirror)||(this.addedSet.has(e)?(Wr(this.addedSet,e),this.droppedSet.add(e)):this.addedSet.has(t.target)&&-1===n||Er(t.target,this.mirror)||(this.movedSet.has(e)&&this.movedMap[Zr(n,i)]?Wr(this.movedSet,e):this.removes.push({parentId:i,id:n,isShadow:!(!Hi(t.target)||!Ki(t.target))||void 0})),this.mapRemoves.push(e))})}},this.genAdds=(t,e)=>{if(this.mirror.hasNode(t)){if(Ar(t,this.mirror))return;this.movedSet.add(t);let n=null;e&&this.mirror.hasNode(e)&&(n=this.mirror.getId(e)),n&&-1!==n&&(this.movedMap[Zr(this.mirror.getId(t),n)]=!0)}else this.addedSet.add(t),this.droppedSet.delete(t);xr(t,this.blockClass,this.blockSelector,!1)||t.childNodes.forEach(t=>this.genAdds(t))}}init(t){["mutationCb","blockClass","blockSelector","maskTextClass","maskTextSelector","inlineStylesheet","maskInputOptions","maskTextFn","maskInputFn","keepIframeSrcFn","recordCanvas","inlineImages","slimDOMOptions","dataURLOptions","doc","mirror","iframeManager","stylesheetManager","shadowDomManager","canvasManager"].forEach(e=>{this[e]=t[e]})}freeze(){this.frozen=!0,this.canvasManager.freeze()}unfreeze(){this.frozen=!1,this.canvasManager.unfreeze(),this.emit()}isFrozen(){return this.frozen}lock(){this.locked=!0,this.canvasManager.lock()}unlock(){this.locked=!1,this.canvasManager.unlock(),this.emit()}reset(){this.shadowDomManager.reset(),this.canvasManager.reset()}}function Wr(t,e){t.delete(e),e.childNodes.forEach(e=>Wr(t,e))}function Vr(t,e,n){return 0!==t.length&&Gr(t,e,n)}function Gr(t,e,n){const{parentNode:i}=e;if(!i)return!1;const r=n.getId(i);return!!t.some(t=>t.id===r)||Gr(t,i,n)}function jr(t,e){return 0!==t.size&&qr(t,e)}function qr(t,e){const{parentNode:n}=e;return!!n&&(!!t.has(n)||qr(t,n))}const Hr=[],Kr="undefined"!=typeof CSSGroupingRule,$r="undefined"!=typeof CSSMediaRule,Yr="undefined"!=typeof CSSSupportsRule,Qr="undefined"!=typeof CSSConditionRule;function Jr(t){try{if("composedPath"in t){const e=t.composedPath();if(e.length)return e[0]}else if("path"in t&&t.path.length)return t.path[0];return t.target}catch(e){return t.target}}function Xr(t,e){var n,i;const r=new Pr;Hr.push(r),r.init(t);let s=window.MutationObserver||window.__rrMutationObserver;const o=null===(i=null===(n=null===window||void 0===window?void 0:window.Zone)||void 0===n?void 0:n.__symbol__)||void 0===i?void 0:i.call(n,"MutationObserver");o&&window[o]&&(s=window[o]);const a=new s(r.processMutations.bind(r));return a.observe(e,{attributes:!0,attributeOldValue:!0,characterData:!0,characterDataOldValue:!0,childList:!0,subtree:!0}),a}function ts({scrollCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){return br("scroll",Cr(s=>{const o=Jr(s);if(!o||xr(o,i,r,!0))return;const a=n.getId(o);if(o===e){const n=e.scrollingElement||e.documentElement;t({id:a,x:n.scrollLeft,y:n.scrollTop})}else t({id:a,x:o.scrollLeft,y:o.scrollTop})},s.scroll||100),e)}function es(t,e){const n=Object.assign({},t);return e||delete n.userTriggered,n}const ns=["INPUT","TEXTAREA","SELECT"],is=new WeakMap;function rs(t){return function(t,e){if(Kr&&t.parentRule instanceof CSSGroupingRule||$r&&t.parentRule instanceof CSSMediaRule||Yr&&t.parentRule instanceof CSSSupportsRule||Qr&&t.parentRule instanceof CSSConditionRule){const n=Array.from(t.parentRule.cssRules).indexOf(t);e.unshift(n)}else if(t.parentStyleSheet){const n=Array.from(t.parentStyleSheet.cssRules).indexOf(t);e.unshift(n)}return e}(t,[])}function ss(t,e,n){let i,r;return t?(t.ownerNode?i=e.getId(t.ownerNode):r=n.getId(t),{styleId:r,id:i}):{}}function os({mirror:t,stylesheetManager:e},n){var i,r,s;let o=null;o="#document"===n.nodeName?t.getId(n):t.getId(n.host);const a="#document"===n.nodeName?null===(i=n.defaultView)||void 0===i?void 0:i.Document:null===(s=null===(r=n.ownerDocument)||void 0===r?void 0:r.defaultView)||void 0===s?void 0:s.ShadowRoot,l=Object.getOwnPropertyDescriptor(null==a?void 0:a.prototype,"adoptedStyleSheets");return null!==o&&-1!==o&&a&&l?(Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get(){var t;return null===(t=l.get)||void 0===t?void 0:t.call(this)},set(t){var n;const i=null===(n=l.set)||void 0===n?void 0:n.call(this,t);if(null!==o&&-1!==o)try{e.adoptStyleSheets(t,o)}catch(t){}return i}}),()=>{Object.defineProperty(n,"adoptedStyleSheets",{configurable:l.configurable,enumerable:l.enumerable,get:l.get,set:l.set})}):()=>{}}function as(t,e={}){const n=t.doc.defaultView;if(!n)return()=>{};!function(t,e){const{mutationCb:n,mousemoveCb:i,mouseInteractionCb:r,scrollCb:s,viewportResizeCb:o,inputCb:a,mediaInteractionCb:l,styleSheetRuleCb:c,styleDeclarationCb:d,canvasMutationCb:h,fontCb:u,selectionCb:p}=t;t.mutationCb=(...t)=>{e.mutation&&e.mutation(...t),n(...t)},t.mousemoveCb=(...t)=>{e.mousemove&&e.mousemove(...t),i(...t)},t.mouseInteractionCb=(...t)=>{e.mouseInteraction&&e.mouseInteraction(...t),r(...t)},t.scrollCb=(...t)=>{e.scroll&&e.scroll(...t),s(...t)},t.viewportResizeCb=(...t)=>{e.viewportResize&&e.viewportResize(...t),o(...t)},t.inputCb=(...t)=>{e.input&&e.input(...t),a(...t)},t.mediaInteractionCb=(...t)=>{e.mediaInteaction&&e.mediaInteaction(...t),l(...t)},t.styleSheetRuleCb=(...t)=>{e.styleSheetRule&&e.styleSheetRule(...t),c(...t)},t.styleDeclarationCb=(...t)=>{e.styleDeclaration&&e.styleDeclaration(...t),d(...t)},t.canvasMutationCb=(...t)=>{e.canvasMutation&&e.canvasMutation(...t),h(...t)},t.fontCb=(...t)=>{e.font&&e.font(...t),u(...t)},t.selectionCb=(...t)=>{e.selection&&e.selection(...t),p(...t)}}(t,e);const i=Xr(t,t.doc),r=function({mousemoveCb:t,sampling:e,doc:n,mirror:i}){if(!1===e.mousemove)return()=>{};const r="number"==typeof e.mousemove?e.mousemove:50,s="number"==typeof e.mousemoveCallback?e.mousemoveCallback:500;let o,a=[];const l=Cr(e=>{const n=Date.now()-o;t(a.map(t=>(t.timeOffset-=n,t)),e),a=[],o=null},s),c=Cr(t=>{const e=Jr(t),{clientX:n,clientY:r}=Rr(t)?t.changedTouches[0]:t;o||(o=Date.now()),a.push({x:n,y:r,id:i.getId(e),timeOffset:Date.now()-o}),l("undefined"!=typeof DragEvent&&t instanceof DragEvent?Dr.Drag:t instanceof MouseEvent?Dr.MouseMove:Dr.TouchMove)},r,{trailing:!1}),d=[br("mousemove",c,n),br("touchmove",c,n),br("drag",c,n)];return()=>{d.forEach(t=>t())}}(t),s=function({mouseInteractionCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,sampling:s}){if(!1===s.mouseInteraction)return()=>{};const o=!0===s.mouseInteraction||void 0===s.mouseInteraction?{}:s.mouseInteraction,a=[];return Object.keys(Nr).filter(t=>Number.isNaN(Number(t))&&!t.endsWith("_Departed")&&!1!==o[t]).forEach(s=>{const o=s.toLowerCase(),l=(e=>s=>{const o=Jr(s);if(xr(o,i,r,!0))return;const a=Rr(s)?s.changedTouches[0]:s;if(!a)return;const l=n.getId(o),{clientX:c,clientY:d}=a;t({type:Nr[e],id:l,x:c,y:d})})(s);a.push(br(o,l,e))}),()=>{a.forEach(t=>t())}}(t),o=ts(t),a=function({viewportResizeCb:t}){let e=-1,n=-1;return br("resize",Cr(()=>{const i=Sr(),r=kr();e===i&&n===r||(t({width:Number(r),height:Number(i)}),e=i,n=r)},200),window)}(t),l=function({inputCb:t,doc:e,mirror:n,blockClass:i,blockSelector:r,ignoreClass:s,maskInputOptions:o,maskInputFn:a,sampling:l,userTriggeredOnInput:c}){function d(t){let n=Jr(t);const l=t.isTrusted;if(n&&"OPTION"===n.tagName&&(n=n.parentElement),!n||!n.tagName||ns.indexOf(n.tagName)<0||xr(n,i,r,!0))return;const d=n.type;if(n.classList.contains(s))return;let u=n.value,p=!1;"radio"===d||"checkbox"===d?p=n.checked:(o[n.tagName.toLowerCase()]||o[d])&&(u=Ji({maskInputOptions:o,tagName:n.tagName,type:d,value:u,maskInputFn:a})),h(n,es({text:u,isChecked:p,userTriggered:l},c));const g=n.name;"radio"===d&&g&&p&&e.querySelectorAll(`input[type="radio"][name="${g}"]`).forEach(t=>{t!==n&&h(t,es({text:t.value,isChecked:!p,userTriggered:!1},c))})}function h(e,i){const r=is.get(e);if(!r||r.text!==i.text||r.isChecked!==i.isChecked){is.set(e,i);const r=n.getId(e);t(Object.assign(Object.assign({},i),{id:r}))}}const u=("last"===l.input?["change"]:["input","change"]).map(t=>br(t,d,e)),p=e.defaultView;if(!p)return()=>{u.forEach(t=>t())};const g=p.Object.getOwnPropertyDescriptor(p.HTMLInputElement.prototype,"value"),m=[[p.HTMLInputElement.prototype,"value"],[p.HTMLInputElement.prototype,"checked"],[p.HTMLSelectElement.prototype,"value"],[p.HTMLTextAreaElement.prototype,"value"],[p.HTMLSelectElement.prototype,"selectedIndex"],[p.HTMLOptionElement.prototype,"selected"]];return g&&g.set&&u.push(...m.map(t=>Ir(t[0],t[1],{set(){d({target:this})}},!1,p))),()=>{u.forEach(t=>t())}}(t),c=function({mediaInteractionCb:t,blockClass:e,blockSelector:n,mirror:i,sampling:r}){const s=s=>Cr(r=>{const o=Jr(r);if(!o||xr(o,e,n,!0))return;const{currentTime:a,volume:l,muted:c,playbackRate:d}=o;t({type:s,id:i.getId(o),currentTime:a,volume:l,muted:c,playbackRate:d})},r.media||500),o=[br("play",s(0)),br("pause",s(1)),br("seeked",s(2)),br("volumechange",s(3)),br("ratechange",s(4))];return()=>{o.forEach(t=>t())}}(t),d=function({styleSheetRuleCb:t,mirror:e,stylesheetManager:n},{win:i}){const r=i.CSSStyleSheet.prototype.insertRule;i.CSSStyleSheet.prototype.insertRule=function(i,s){const{id:o,styleId:a}=ss(this,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:i,index:s}]}),r.apply(this,[i,s])};const s=i.CSSStyleSheet.prototype.deleteRule;let o,a;i.CSSStyleSheet.prototype.deleteRule=function(i){const{id:r,styleId:o}=ss(this,e,n.styleMirror);return(r&&-1!==r||o&&-1!==o)&&t({id:r,styleId:o,removes:[{index:i}]}),s.apply(this,[i])},i.CSSStyleSheet.prototype.replace&&(o=i.CSSStyleSheet.prototype.replace,i.CSSStyleSheet.prototype.replace=function(i){const{id:r,styleId:s}=ss(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replace:i}),o.apply(this,[i])}),i.CSSStyleSheet.prototype.replaceSync&&(a=i.CSSStyleSheet.prototype.replaceSync,i.CSSStyleSheet.prototype.replaceSync=function(i){const{id:r,styleId:s}=ss(this,e,n.styleMirror);return(r&&-1!==r||s&&-1!==s)&&t({id:r,styleId:s,replaceSync:i}),a.apply(this,[i])});const l={};Kr?l.CSSGroupingRule=i.CSSGroupingRule:($r&&(l.CSSMediaRule=i.CSSMediaRule),Qr&&(l.CSSConditionRule=i.CSSConditionRule),Yr&&(l.CSSSupportsRule=i.CSSSupportsRule));const c={};return Object.entries(l).forEach(([i,r])=>{c[i]={insertRule:r.prototype.insertRule,deleteRule:r.prototype.deleteRule},r.prototype.insertRule=function(r,s){const{id:o,styleId:a}=ss(this.parentStyleSheet,e,n.styleMirror);return(o&&-1!==o||a&&-1!==a)&&t({id:o,styleId:a,adds:[{rule:r,index:[...rs(this),s||0]}]}),c[i].insertRule.apply(this,[r,s])},r.prototype.deleteRule=function(r){const{id:s,styleId:o}=ss(this.parentStyleSheet,e,n.styleMirror);return(s&&-1!==s||o&&-1!==o)&&t({id:s,styleId:o,removes:[{index:[...rs(this),r]}]}),c[i].deleteRule.apply(this,[r])}}),()=>{i.CSSStyleSheet.prototype.insertRule=r,i.CSSStyleSheet.prototype.deleteRule=s,o&&(i.CSSStyleSheet.prototype.replace=o),a&&(i.CSSStyleSheet.prototype.replaceSync=a),Object.entries(l).forEach(([t,e])=>{e.prototype.insertRule=c[t].insertRule,e.prototype.deleteRule=c[t].deleteRule})}}(t,{win:n}),h=os(t,t.doc),u=function({styleDeclarationCb:t,mirror:e,ignoreCSSAttributes:n,stylesheetManager:i},{win:r}){const s=r.CSSStyleDeclaration.prototype.setProperty;r.CSSStyleDeclaration.prototype.setProperty=function(r,o,a){var l;if(n.has(r))return s.apply(this,[r,o,a]);const{id:c,styleId:d}=ss(null===(l=this.parentRule)||void 0===l?void 0:l.parentStyleSheet,e,i.styleMirror);return(c&&-1!==c||d&&-1!==d)&&t({id:c,styleId:d,set:{property:r,value:o,priority:a},index:rs(this.parentRule)}),s.apply(this,[r,o,a])};const o=r.CSSStyleDeclaration.prototype.removeProperty;return r.CSSStyleDeclaration.prototype.removeProperty=function(r){var s;if(n.has(r))return o.apply(this,[r]);const{id:a,styleId:l}=ss(null===(s=this.parentRule)||void 0===s?void 0:s.parentStyleSheet,e,i.styleMirror);return(a&&-1!==a||l&&-1!==l)&&t({id:a,styleId:l,remove:{property:r},index:rs(this.parentRule)}),o.apply(this,[r])},()=>{r.CSSStyleDeclaration.prototype.setProperty=s,r.CSSStyleDeclaration.prototype.removeProperty=o}}(t,{win:n}),p=t.collectFonts?function({fontCb:t,doc:e}){const n=e.defaultView;if(!n)return()=>{};const i=[],r=new WeakMap,s=n.FontFace;n.FontFace=function(t,e,n){const i=new s(t,e,n);return r.set(i,{family:t,buffer:"string"!=typeof e,descriptors:n,fontSource:"string"==typeof e?e:JSON.stringify(Array.from(new Uint8Array(e)))}),i};const o=_r(e.fonts,"add",function(e){return function(n){return setTimeout(()=>{const e=r.get(n);e&&(t(e),r.delete(n))},0),e.apply(this,[n])}});return i.push(()=>{n.FontFace=s}),i.push(o),()=>{i.forEach(t=>t())}}(t):()=>{},g=function(t){const{doc:e,mirror:n,blockClass:i,blockSelector:r,selectionCb:s}=t;let o=!0;const a=()=>{const t=e.getSelection();if(!t||o&&(null==t?void 0:t.isCollapsed))return;o=t.isCollapsed||!1;const a=[],l=t.rangeCount||0;for(let e=0;e<l;e++){const s=t.getRangeAt(e),{startContainer:o,startOffset:l,endContainer:c,endOffset:d}=s;xr(o,i,r,!0)||xr(c,i,r,!0)||a.push({start:n.getId(o),startOffset:l,end:n.getId(c),endOffset:d})}s({ranges:a})};return a(),br("selectionchange",a)}(t),m=[];for(const e of t.plugins)m.push(e.observer(e.callback,n,e.options));return()=>{Hr.forEach(t=>t.reset()),i.disconnect(),r(),s(),o(),a(),l(),c(),d(),h(),u(),p(),g(),m.forEach(t=>t())}}class ls{constructor(t){this.generateIdFn=t,this.iframeIdToRemoteIdMap=new WeakMap,this.iframeRemoteIdToIdMap=new WeakMap}getId(t,e,n,i){const r=n||this.getIdToRemoteIdMap(t),s=i||this.getRemoteIdToIdMap(t);let o=r.get(e);return o||(o=this.generateIdFn(),r.set(e,o),s.set(o,e)),o}getIds(t,e){const n=this.getIdToRemoteIdMap(t),i=this.getRemoteIdToIdMap(t);return e.map(e=>this.getId(t,e,n,i))}getRemoteId(t,e,n){const i=n||this.getRemoteIdToIdMap(t);if("number"!=typeof e)return e;return i.get(e)||-1}getRemoteIds(t,e){const n=this.getRemoteIdToIdMap(t);return e.map(e=>this.getRemoteId(t,e,n))}reset(t){if(!t)return this.iframeIdToRemoteIdMap=new WeakMap,void(this.iframeRemoteIdToIdMap=new WeakMap);this.iframeIdToRemoteIdMap.delete(t),this.iframeRemoteIdToIdMap.delete(t)}getIdToRemoteIdMap(t){let e=this.iframeIdToRemoteIdMap.get(t);return e||(e=new Map,this.iframeIdToRemoteIdMap.set(t,e)),e}getRemoteIdToIdMap(t){let e=this.iframeRemoteIdToIdMap.get(t);return e||(e=new Map,this.iframeRemoteIdToIdMap.set(t,e)),e}}class cs{constructor(t){this.iframes=new WeakMap,this.crossOriginIframeMap=new WeakMap,this.crossOriginIframeMirror=new ls(rr),this.mutationCb=t.mutationCb,this.wrappedEmit=t.wrappedEmit,this.stylesheetManager=t.stylesheetManager,this.recordCrossOriginIframes=t.recordCrossOriginIframes,this.crossOriginIframeStyleMirror=new ls(this.stylesheetManager.styleMirror.generateId.bind(this.stylesheetManager.styleMirror)),this.mirror=t.mirror,this.recordCrossOriginIframes&&window.addEventListener("message",this.handleMessage.bind(this))}addIframe(t){this.iframes.set(t,!0),t.contentWindow&&this.crossOriginIframeMap.set(t.contentWindow,t)}addLoadListener(t){this.loadListener=t}attachIframe(t,e){var n;this.mutationCb({adds:[{parentId:this.mirror.getId(t),nextId:null,node:e}],removes:[],texts:[],attributes:[],isAttachIframe:!0}),null===(n=this.loadListener)||void 0===n||n.call(this,t),t.contentDocument&&t.contentDocument.adoptedStyleSheets&&t.contentDocument.adoptedStyleSheets.length>0&&this.stylesheetManager.adoptStyleSheets(t.contentDocument.adoptedStyleSheets,this.mirror.getId(t.contentDocument))}handleMessage(t){if("rrweb"===t.data.type){if(!t.source)return;const e=this.crossOriginIframeMap.get(t.source);if(!e)return;const n=this.transformCrossOriginEvent(e,t.data.event);n&&this.wrappedEmit(n,t.data.isCheckout)}}transformCrossOriginEvent(t,e){var n;switch(e.type){case Lr.FullSnapshot:return this.crossOriginIframeMirror.reset(t),this.crossOriginIframeStyleMirror.reset(t),this.replaceIdOnNode(e.data.node,t),{timestamp:e.timestamp,type:Lr.IncrementalSnapshot,data:{source:Dr.Mutation,adds:[{parentId:this.mirror.getId(t),nextId:null,node:e.data.node}],removes:[],texts:[],attributes:[],isAttachIframe:!0}};case Lr.Meta:case Lr.Load:case Lr.DomContentLoaded:return!1;case Lr.Plugin:return e;case Lr.Custom:return this.replaceIds(e.data.payload,t,["id","parentId","previousId","nextId"]),e;case Lr.IncrementalSnapshot:switch(e.data.source){case Dr.Mutation:return e.data.adds.forEach(e=>{this.replaceIds(e,t,["parentId","nextId","previousId"]),this.replaceIdOnNode(e.node,t)}),e.data.removes.forEach(e=>{this.replaceIds(e,t,["parentId","id"])}),e.data.attributes.forEach(e=>{this.replaceIds(e,t,["id"])}),e.data.texts.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Dr.Drag:case Dr.TouchMove:case Dr.MouseMove:return e.data.positions.forEach(e=>{this.replaceIds(e,t,["id"])}),e;case Dr.ViewportResize:return!1;case Dr.MediaInteraction:case Dr.MouseInteraction:case Dr.Scroll:case Dr.CanvasMutation:case Dr.Input:return this.replaceIds(e.data,t,["id"]),e;case Dr.StyleSheetRule:case Dr.StyleDeclaration:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleId"]),e;case Dr.Font:return e;case Dr.Selection:return e.data.ranges.forEach(e=>{this.replaceIds(e,t,["start","end"])}),e;case Dr.AdoptedStyleSheet:return this.replaceIds(e.data,t,["id"]),this.replaceStyleIds(e.data,t,["styleIds"]),null===(n=e.data.styles)||void 0===n||n.forEach(e=>{this.replaceStyleIds(e,t,["styleId"])}),e}}}replace(t,e,n,i){for(const r of i)(Array.isArray(e[r])||"number"==typeof e[r])&&(Array.isArray(e[r])?e[r]=t.getIds(n,e[r]):e[r]=t.getId(n,e[r]));return e}replaceIds(t,e,n){return this.replace(this.crossOriginIframeMirror,t,e,n)}replaceStyleIds(t,e,n){return this.replace(this.crossOriginIframeStyleMirror,t,e,n)}replaceIdOnNode(t,e){this.replaceIds(t,e,["id"]),"childNodes"in t&&t.childNodes.forEach(t=>{this.replaceIdOnNode(t,e)})}}class ds{constructor(t){this.shadowDoms=new WeakSet,this.restorePatches=[],this.mutationCb=t.mutationCb,this.scrollCb=t.scrollCb,this.bypassOptions=t.bypassOptions,this.mirror=t.mirror;const e=this;this.restorePatches.push(_r(Element.prototype,"attachShadow",function(t){return function(n){const i=t.call(this,n);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,this.ownerDocument),i}}))}addShadowRoot(t,e){Ki(t)&&(this.shadowDoms.has(t)||(this.shadowDoms.add(t),Xr(Object.assign(Object.assign({},this.bypassOptions),{doc:e,mutationCb:this.mutationCb,mirror:this.mirror,shadowDomManager:this}),t),ts(Object.assign(Object.assign({},this.bypassOptions),{scrollCb:this.scrollCb,doc:t,mirror:this.mirror})),setTimeout(()=>{t.adoptedStyleSheets&&t.adoptedStyleSheets.length>0&&this.bypassOptions.stylesheetManager.adoptStyleSheets(t.adoptedStyleSheets,this.mirror.getId(t.host)),os({mirror:this.mirror,stylesheetManager:this.bypassOptions.stylesheetManager},t)},0)))}observeAttachShadow(t){if(t.contentWindow){const e=this;this.restorePatches.push(_r(t.contentWindow.HTMLElement.prototype,"attachShadow",function(n){return function(i){const r=n.call(this,i);return this.shadowRoot&&e.addShadowRoot(this.shadowRoot,t.contentDocument),r}}))}}reset(){this.restorePatches.forEach(t=>t()),this.shadowDoms=new WeakSet}}for(var hs="ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/",us="undefined"==typeof Uint8Array?[]:new Uint8Array(256),ps=0;ps<64;ps++)us[hs.charCodeAt(ps)]=ps;const gs=new Map,ms=(t,e,n)=>{if(!t||!bs(t,e)&&"object"!=typeof t)return;const i=function(t,e){let n=gs.get(t);return n||(n=new Map,gs.set(t,n)),n.has(e)||n.set(e,[]),n.get(e)}(n,t.constructor.name);let r=i.indexOf(t);return-1===r&&(r=i.length,i.push(t)),r};function fs(t,e,n){if(t instanceof Array)return t.map(t=>fs(t,e,n));if(null===t)return t;if(t instanceof Float32Array||t instanceof Float64Array||t instanceof Int32Array||t instanceof Uint32Array||t instanceof Uint8Array||t instanceof Uint16Array||t instanceof Int16Array||t instanceof Int8Array||t instanceof Uint8ClampedArray)return{rr_type:t.constructor.name,args:[Object.values(t)]};if(t instanceof ArrayBuffer){const e=t.constructor.name,n=function(t){var e,n=new Uint8Array(t),i=n.length,r="";for(e=0;e<i;e+=3)r+=hs[n[e]>>2],r+=hs[(3&n[e])<<4|n[e+1]>>4],r+=hs[(15&n[e+1])<<2|n[e+2]>>6],r+=hs[63&n[e+2]];return i%3==2?r=r.substring(0,r.length-1)+"=":i%3==1&&(r=r.substring(0,r.length-2)+"=="),r}(t);return{rr_type:e,base64:n}}if(t instanceof DataView)return{rr_type:t.constructor.name,args:[fs(t.buffer,e,n),t.byteOffset,t.byteLength]};if(t instanceof HTMLImageElement){const e=t.constructor.name,{src:n}=t;return{rr_type:e,src:n}}return t instanceof HTMLCanvasElement?{rr_type:"HTMLImageElement",src:t.toDataURL()}:t instanceof ImageData?{rr_type:t.constructor.name,args:[fs(t.data,e,n),t.width,t.height]}:bs(t,e)||"object"==typeof t?{rr_type:t.constructor.name,index:ms(t,e,n)}:t}const ys=(t,e,n)=>[...t].map(t=>fs(t,e,n)),bs=(t,e)=>{const n=["WebGLActiveInfo","WebGLBuffer","WebGLFramebuffer","WebGLProgram","WebGLRenderbuffer","WebGLShader","WebGLShaderPrecisionFormat","WebGLTexture","WebGLUniformLocation","WebGLVertexArrayObject","WebGLVertexArrayObjectOES"].filter(t=>"function"==typeof e[t]);return Boolean(n.find(n=>t instanceof e[n]))};function ws(t,e,n){const i=[];try{const r=_r(t.HTMLCanvasElement.prototype,"getContext",function(t){return function(i,...r){return xr(this,e,n,!0)||"__context"in this||(this.__context=i),t.apply(this,[i,...r])}});i.push(r)}catch(t){console.error("failed to patch HTMLCanvasElement.prototype.getContext")}return()=>{i.forEach(t=>t())}}function vs(t,e,n,i,r,s,o){const a=[],l=Object.getOwnPropertyNames(t);for(const s of l)if(!["isContextLost","canvas","drawingBufferWidth","drawingBufferHeight"].includes(s))try{if("function"!=typeof t[s])continue;const l=_r(t,s,function(t){return function(...a){const l=t.apply(this,a);if(ms(l,o,this),!xr(this.canvas,i,r,!0)){const t=ys([...a],o,this),i={type:e,property:s,args:t};n(this.canvas,i)}return l}});a.push(l)}catch(i){const r=Ir(t,s,{set(t){n(this.canvas,{type:e,property:s,args:[t],setter:!0})}});a.push(r)}return a}var Cs=null;try{var Is="undefined"!=typeof module&&"function"==typeof module.require&&module.require("worker_threads")||"function"==typeof require&&require("worker_threads")||"function"==typeof require&&require("worker_threads");Cs=Is.Worker}catch(t){}var _s,Ss,ks=(_s="Lyogcm9sbHVwLXBsdWdpbi13ZWItd29ya2VyLWxvYWRlciAqLwooZnVuY3Rpb24gKCkgewogICAgJ3VzZSBzdHJpY3QnOwoKICAgIC8qISAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKg0KICAgIENvcHlyaWdodCAoYykgTWljcm9zb2Z0IENvcnBvcmF0aW9uLg0KDQogICAgUGVybWlzc2lvbiB0byB1c2UsIGNvcHksIG1vZGlmeSwgYW5kL29yIGRpc3RyaWJ1dGUgdGhpcyBzb2Z0d2FyZSBmb3IgYW55DQogICAgcHVycG9zZSB3aXRoIG9yIHdpdGhvdXQgZmVlIGlzIGhlcmVieSBncmFudGVkLg0KDQogICAgVEhFIFNPRlRXQVJFIElTIFBST1ZJREVEICJBUyBJUyIgQU5EIFRIRSBBVVRIT1IgRElTQ0xBSU1TIEFMTCBXQVJSQU5USUVTIFdJVEgNCiAgICBSRUdBUkQgVE8gVEhJUyBTT0ZUV0FSRSBJTkNMVURJTkcgQUxMIElNUExJRUQgV0FSUkFOVElFUyBPRiBNRVJDSEFOVEFCSUxJVFkNCiAgICBBTkQgRklUTkVTUy4gSU4gTk8gRVZFTlQgU0hBTEwgVEhFIEFVVEhPUiBCRSBMSUFCTEUgRk9SIEFOWSBTUEVDSUFMLCBESVJFQ1QsDQogICAgSU5ESVJFQ1QsIE9SIENPTlNFUVVFTlRJQUwgREFNQUdFUyBPUiBBTlkgREFNQUdFUyBXSEFUU09FVkVSIFJFU1VMVElORyBGUk9NDQogICAgTE9TUyBPRiBVU0UsIERBVEEgT1IgUFJPRklUUywgV0hFVEhFUiBJTiBBTiBBQ1RJT04gT0YgQ09OVFJBQ1QsIE5FR0xJR0VOQ0UgT1INCiAgICBPVEhFUiBUT1JUSU9VUyBBQ1RJT04sIEFSSVNJTkcgT1VUIE9GIE9SIElOIENPTk5FQ1RJT04gV0lUSCBUSEUgVVNFIE9SDQogICAgUEVSRk9STUFOQ0UgT0YgVEhJUyBTT0ZUV0FSRS4NCiAgICAqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKioqKiAqLw0KDQogICAgZnVuY3Rpb24gX19hd2FpdGVyKHRoaXNBcmcsIF9hcmd1bWVudHMsIFAsIGdlbmVyYXRvcikgew0KICAgICAgICBmdW5jdGlvbiBhZG9wdCh2YWx1ZSkgeyByZXR1cm4gdmFsdWUgaW5zdGFuY2VvZiBQID8gdmFsdWUgOiBuZXcgUChmdW5jdGlvbiAocmVzb2x2ZSkgeyByZXNvbHZlKHZhbHVlKTsgfSk7IH0NCiAgICAgICAgcmV0dXJuIG5ldyAoUCB8fCAoUCA9IFByb21pc2UpKShmdW5jdGlvbiAocmVzb2x2ZSwgcmVqZWN0KSB7DQogICAgICAgICAgICBmdW5jdGlvbiBmdWxmaWxsZWQodmFsdWUpIHsgdHJ5IHsgc3RlcChnZW5lcmF0b3IubmV4dCh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiByZWplY3RlZCh2YWx1ZSkgeyB0cnkgeyBzdGVwKGdlbmVyYXRvclsidGhyb3ciXSh2YWx1ZSkpOyB9IGNhdGNoIChlKSB7IHJlamVjdChlKTsgfSB9DQogICAgICAgICAgICBmdW5jdGlvbiBzdGVwKHJlc3VsdCkgeyByZXN1bHQuZG9uZSA/IHJlc29sdmUocmVzdWx0LnZhbHVlKSA6IGFkb3B0KHJlc3VsdC52YWx1ZSkudGhlbihmdWxmaWxsZWQsIHJlamVjdGVkKTsgfQ0KICAgICAgICAgICAgc3RlcCgoZ2VuZXJhdG9yID0gZ2VuZXJhdG9yLmFwcGx5KHRoaXNBcmcsIF9hcmd1bWVudHMgfHwgW10pKS5uZXh0KCkpOw0KICAgICAgICB9KTsNCiAgICB9CgogICAgLyoKICAgICAqIGJhc2U2NC1hcnJheWJ1ZmZlciAxLjAuMSA8aHR0cHM6Ly9naXRodWIuY29tL25pa2xhc3ZoL2Jhc2U2NC1hcnJheWJ1ZmZlcj4KICAgICAqIENvcHlyaWdodCAoYykgMjAyMSBOaWtsYXMgdm9uIEhlcnR6ZW4gPGh0dHBzOi8vaGVydHplbi5jb20+CiAgICAgKiBSZWxlYXNlZCB1bmRlciBNSVQgTGljZW5zZQogICAgICovCiAgICB2YXIgY2hhcnMgPSAnQUJDREVGR0hJSktMTU5PUFFSU1RVVldYWVphYmNkZWZnaGlqa2xtbm9wcXJzdHV2d3h5ejAxMjM0NTY3ODkrLyc7CiAgICAvLyBVc2UgYSBsb29rdXAgdGFibGUgdG8gZmluZCB0aGUgaW5kZXguCiAgICB2YXIgbG9va3VwID0gdHlwZW9mIFVpbnQ4QXJyYXkgPT09ICd1bmRlZmluZWQnID8gW10gOiBuZXcgVWludDhBcnJheSgyNTYpOwogICAgZm9yICh2YXIgaSA9IDA7IGkgPCBjaGFycy5sZW5ndGg7IGkrKykgewogICAgICAgIGxvb2t1cFtjaGFycy5jaGFyQ29kZUF0KGkpXSA9IGk7CiAgICB9CiAgICB2YXIgZW5jb2RlID0gZnVuY3Rpb24gKGFycmF5YnVmZmVyKSB7CiAgICAgICAgdmFyIGJ5dGVzID0gbmV3IFVpbnQ4QXJyYXkoYXJyYXlidWZmZXIpLCBpLCBsZW4gPSBieXRlcy5sZW5ndGgsIGJhc2U2NCA9ICcnOwogICAgICAgIGZvciAoaSA9IDA7IGkgPCBsZW47IGkgKz0gMykgewogICAgICAgICAgICBiYXNlNjQgKz0gY2hhcnNbYnl0ZXNbaV0gPj4gMl07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1soKGJ5dGVzW2ldICYgMykgPDwgNCkgfCAoYnl0ZXNbaSArIDFdID4+IDQpXTsKICAgICAgICAgICAgYmFzZTY0ICs9IGNoYXJzWygoYnl0ZXNbaSArIDFdICYgMTUpIDw8IDIpIHwgKGJ5dGVzW2kgKyAyXSA+PiA2KV07CiAgICAgICAgICAgIGJhc2U2NCArPSBjaGFyc1tieXRlc1tpICsgMl0gJiA2M107CiAgICAgICAgfQogICAgICAgIGlmIChsZW4gJSAzID09PSAyKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDEpICsgJz0nOwogICAgICAgIH0KICAgICAgICBlbHNlIGlmIChsZW4gJSAzID09PSAxKSB7CiAgICAgICAgICAgIGJhc2U2NCA9IGJhc2U2NC5zdWJzdHJpbmcoMCwgYmFzZTY0Lmxlbmd0aCAtIDIpICsgJz09JzsKICAgICAgICB9CiAgICAgICAgcmV0dXJuIGJhc2U2NDsKICAgIH07CgogICAgY29uc3QgbGFzdEJsb2JNYXAgPSBuZXcgTWFwKCk7DQogICAgY29uc3QgdHJhbnNwYXJlbnRCbG9iTWFwID0gbmV3IE1hcCgpOw0KICAgIGZ1bmN0aW9uIGdldFRyYW5zcGFyZW50QmxvYkZvcih3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucykgew0KICAgICAgICByZXR1cm4gX19hd2FpdGVyKHRoaXMsIHZvaWQgMCwgdm9pZCAwLCBmdW5jdGlvbiogKCkgew0KICAgICAgICAgICAgY29uc3QgaWQgPSBgJHt3aWR0aH0tJHtoZWlnaHR9YDsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgaWYgKHRyYW5zcGFyZW50QmxvYk1hcC5oYXMoaWQpKQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gdHJhbnNwYXJlbnRCbG9iTWFwLmdldChpZCk7DQogICAgICAgICAgICAgICAgY29uc3Qgb2Zmc2NyZWVuID0gbmV3IE9mZnNjcmVlbkNhbnZhcyh3aWR0aCwgaGVpZ2h0KTsNCiAgICAgICAgICAgICAgICBvZmZzY3JlZW4uZ2V0Q29udGV4dCgnMmQnKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGFycmF5QnVmZmVyID0geWllbGQgYmxvYi5hcnJheUJ1ZmZlcigpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGJhc2U2NCA9IGVuY29kZShhcnJheUJ1ZmZlcik7DQogICAgICAgICAgICAgICAgdHJhbnNwYXJlbnRCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICByZXR1cm4gYmFzZTY0Ow0KICAgICAgICAgICAgfQ0KICAgICAgICAgICAgZWxzZSB7DQogICAgICAgICAgICAgICAgcmV0dXJuICcnOw0KICAgICAgICAgICAgfQ0KICAgICAgICB9KTsNCiAgICB9DQogICAgY29uc3Qgd29ya2VyID0gc2VsZjsNCiAgICB3b3JrZXIub25tZXNzYWdlID0gZnVuY3Rpb24gKGUpIHsNCiAgICAgICAgcmV0dXJuIF9fYXdhaXRlcih0aGlzLCB2b2lkIDAsIHZvaWQgMCwgZnVuY3Rpb24qICgpIHsNCiAgICAgICAgICAgIGlmICgnT2Zmc2NyZWVuQ2FudmFzJyBpbiBnbG9iYWxUaGlzKSB7DQogICAgICAgICAgICAgICAgY29uc3QgeyBpZCwgYml0bWFwLCB3aWR0aCwgaGVpZ2h0LCBkYXRhVVJMT3B0aW9ucyB9ID0gZS5kYXRhOw0KICAgICAgICAgICAgICAgIGNvbnN0IHRyYW5zcGFyZW50QmFzZTY0ID0gZ2V0VHJhbnNwYXJlbnRCbG9iRm9yKHdpZHRoLCBoZWlnaHQsIGRhdGFVUkxPcHRpb25zKTsNCiAgICAgICAgICAgICAgICBjb25zdCBvZmZzY3JlZW4gPSBuZXcgT2Zmc2NyZWVuQ2FudmFzKHdpZHRoLCBoZWlnaHQpOw0KICAgICAgICAgICAgICAgIGNvbnN0IGN0eCA9IG9mZnNjcmVlbi5nZXRDb250ZXh0KCcyZCcpOw0KICAgICAgICAgICAgICAgIGN0eC5kcmF3SW1hZ2UoYml0bWFwLCAwLCAwKTsNCiAgICAgICAgICAgICAgICBiaXRtYXAuY2xvc2UoKTsNCiAgICAgICAgICAgICAgICBjb25zdCBibG9iID0geWllbGQgb2Zmc2NyZWVuLmNvbnZlcnRUb0Jsb2IoZGF0YVVSTE9wdGlvbnMpOw0KICAgICAgICAgICAgICAgIGNvbnN0IHR5cGUgPSBibG9iLnR5cGU7DQogICAgICAgICAgICAgICAgY29uc3QgYXJyYXlCdWZmZXIgPSB5aWVsZCBibG9iLmFycmF5QnVmZmVyKCk7DQogICAgICAgICAgICAgICAgY29uc3QgYmFzZTY0ID0gZW5jb2RlKGFycmF5QnVmZmVyKTsNCiAgICAgICAgICAgICAgICBpZiAoIWxhc3RCbG9iTWFwLmhhcyhpZCkgJiYgKHlpZWxkIHRyYW5zcGFyZW50QmFzZTY0KSA9PT0gYmFzZTY0KSB7DQogICAgICAgICAgICAgICAgICAgIGxhc3RCbG9iTWFwLnNldChpZCwgYmFzZTY0KTsNCiAgICAgICAgICAgICAgICAgICAgcmV0dXJuIHdvcmtlci5wb3N0TWVzc2FnZSh7IGlkIH0pOw0KICAgICAgICAgICAgICAgIH0NCiAgICAgICAgICAgICAgICBpZiAobGFzdEJsb2JNYXAuZ2V0KGlkKSA9PT0gYmFzZTY0KQ0KICAgICAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQgfSk7DQogICAgICAgICAgICAgICAgd29ya2VyLnBvc3RNZXNzYWdlKHsNCiAgICAgICAgICAgICAgICAgICAgaWQsDQogICAgICAgICAgICAgICAgICAgIHR5cGUsDQogICAgICAgICAgICAgICAgICAgIGJhc2U2NCwNCiAgICAgICAgICAgICAgICAgICAgd2lkdGgsDQogICAgICAgICAgICAgICAgICAgIGhlaWdodCwNCiAgICAgICAgICAgICAgICB9KTsNCiAgICAgICAgICAgICAgICBsYXN0QmxvYk1hcC5zZXQoaWQsIGJhc2U2NCk7DQogICAgICAgICAgICB9DQogICAgICAgICAgICBlbHNlIHsNCiAgICAgICAgICAgICAgICByZXR1cm4gd29ya2VyLnBvc3RNZXNzYWdlKHsgaWQ6IGUuZGF0YS5pZCB9KTsNCiAgICAgICAgICAgIH0NCiAgICAgICAgfSk7DQogICAgfTsKCn0pKCk7Cgo=",Ss=!1,"[object process]"===Object.prototype.toString.call("undefined"!=typeof process?process:0)?function(t,e,n){var i=void 0===e?null:e,r=function(t,e){return Buffer.from(t,"base64").toString(e?"utf16":"utf8")}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:"");return function(t){return new Cs(o,Object.assign({},t,{eval:!0}))}}(_s,null,Ss):function(t){var e;return function(n){return e=e||function(t,e,n){var i=void 0===e?null:e,r=function(t,e){var n=atob(t);if(e){for(var i=new Uint8Array(n.length),r=0,s=n.length;r<s;++r)i[r]=n.charCodeAt(r);return String.fromCharCode.apply(null,new Uint16Array(i.buffer))}return n}(t,void 0!==n&&n),s=r.indexOf("\n",10)+1,o=r.substring(s)+(i?"//# sourceMappingURL="+i:""),a=new Blob([o],{type:"application/javascript"});return URL.createObjectURL(a)}(t,null,false),new Worker(e,n)}}(_s));class xs{constructor(t){this.pendingCanvasMutations=new Map,this.rafStamps={latestId:0,invokeId:null},this.frozen=!1,this.locked=!1,this.processMutation=(t,e)=>{!(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId)&&this.rafStamps.invokeId||(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(t)||this.pendingCanvasMutations.set(t,[]),this.pendingCanvasMutations.get(t).push(e)};const{sampling:e="all",win:n,blockClass:i,blockSelector:r,recordCanvas:s,dataURLOptions:o}=t;this.mutationCb=t.mutationCb,this.mirror=t.mirror,s&&"all"===e&&this.initCanvasMutationObserver(n,i,r),s&&"number"==typeof e&&this.initCanvasFPSObserver(e,n,i,r,{dataURLOptions:o})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(t,e,n,i,r){const s=ws(e,n,i),o=new Map,a=new ks;a.onmessage=t=>{const{id:e}=t.data;if(o.set(e,!1),!("base64"in t.data))return;const{base64:n,type:i,width:r,height:s}=t.data;this.mutationCb({id:e,type:Fr["2D"],commands:[{property:"clearRect",args:[0,0,r,s]},{property:"drawImage",args:[{rr_type:"ImageBitmap",args:[{rr_type:"Blob",data:[{rr_type:"ArrayBuffer",base64:n}],type:i}]},0,0]}]})};const l=1e3/t;let c,d=0;const h=t=>{d&&t-d<l||(d=t,(()=>{const t=[];return e.document.querySelectorAll("canvas").forEach(e=>{xr(e,n,i,!0)||t.push(e)}),t})().forEach(t=>{return e=this,n=void 0,s=function*(){var e;const n=this.mirror.getId(t);if(o.get(n))return;if(o.set(n,!0),["webgl","webgl2"].includes(t.__context)){const n=t.getContext(t.__context);!1===(null===(e=null==n?void 0:n.getContextAttributes())||void 0===e?void 0:e.preserveDrawingBuffer)&&(null==n||n.clear(n.COLOR_BUFFER_BIT))}const i=yield createImageBitmap(t);a.postMessage({id:n,bitmap:i,width:t.width,height:t.height,dataURLOptions:r.dataURLOptions},[i])},new((i=void 0)||(i=Promise))(function(t,r){function o(t){try{l(s.next(t))}catch(t){r(t)}}function a(t){try{l(s.throw(t))}catch(t){r(t)}}function l(e){var n;e.done?t(e.value):(n=e.value,n instanceof i?n:new i(function(t){t(n)})).then(o,a)}l((s=s.apply(e,n||[])).next())});var e,n,i,s})),c=requestAnimationFrame(h)};c=requestAnimationFrame(h),this.resetObservers=()=>{s(),cancelAnimationFrame(c)}}initCanvasMutationObserver(t,e,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();const i=ws(t,e,n),r=function(t,e,n,i){const r=[],s=Object.getOwnPropertyNames(e.CanvasRenderingContext2D.prototype);for(const o of s)try{if("function"!=typeof e.CanvasRenderingContext2D.prototype[o])continue;const s=_r(e.CanvasRenderingContext2D.prototype,o,function(r){return function(...s){return xr(this.canvas,n,i,!0)||setTimeout(()=>{const n=ys([...s],e,this);t(this.canvas,{type:Fr["2D"],property:o,args:n})},0),r.apply(this,s)}});r.push(s)}catch(n){const i=Ir(e.CanvasRenderingContext2D.prototype,o,{set(e){t(this.canvas,{type:Fr["2D"],property:o,args:[e],setter:!0})}});r.push(i)}return()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n),s=function(t,e,n,i){const r=[];return r.push(...vs(e.WebGLRenderingContext.prototype,Fr.WebGL,t,n,i,0,e)),void 0!==e.WebGL2RenderingContext&&r.push(...vs(e.WebGL2RenderingContext.prototype,Fr.WebGL2,t,n,i,0,e)),()=>{r.forEach(t=>t())}}(this.processMutation.bind(this),t,e,n,this.mirror);this.resetObservers=()=>{i(),r(),s()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){const t=e=>{this.rafStamps.latestId=e,requestAnimationFrame(t)};requestAnimationFrame(t)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((t,e)=>{const n=this.mirror.getId(e);this.flushPendingCanvasMutationFor(e,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(t,e){if(this.frozen||this.locked)return;const n=this.pendingCanvasMutations.get(t);if(!n||-1===e)return;const i=n.map(t=>{const e=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["type"]);return e}),{type:r}=n[0];this.mutationCb({id:e,type:r,commands:i}),this.pendingCanvasMutations.delete(t)}}class As{constructor(t){this.trackedLinkElements=new WeakSet,this.styleMirror=new zr,this.mutationCb=t.mutationCb,this.adoptedStyleSheetCb=t.adoptedStyleSheetCb}attachLinkElement(t,e){"_cssText"in e.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:e.id,attributes:e.attributes}]}),this.trackLinkElement(t)}trackLinkElement(t){this.trackedLinkElements.has(t)||(this.trackedLinkElements.add(t),this.trackStylesheetInLinkElement(t))}adoptStyleSheets(t,e){if(0===t.length)return;const n={id:e,styleIds:[]},i=[];for(const e of t){let t;if(this.styleMirror.has(e))t=this.styleMirror.getId(e);else{t=this.styleMirror.add(e);const n=Array.from(e.rules||CSSRule);i.push({styleId:t,rules:n.map((t,e)=>({rule:Yi(t),index:e}))})}n.styleIds.push(t)}i.length>0&&(n.styles=i),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(t){}}function Es(t){return Object.assign(Object.assign({},t),{timestamp:Date.now()})}let Rs,Ms,Ts,Os=!1;const zs=new Qi;function Ls(t={}){const{emit:e,checkoutEveryNms:n,checkoutEveryNth:i,blockClass:r="rr-block",blockSelector:s=null,ignoreClass:o="rr-ignore",maskTextClass:a="rr-mask",maskTextSelector:l=null,inlineStylesheet:c=!0,maskAllInputs:d,maskInputOptions:h,slimDOMOptions:u,maskInputFn:p,maskTextFn:g,hooks:m,packFn:f,sampling:y={},dataURLOptions:b={},mousemoveWait:w,recordCanvas:v=!1,recordCrossOriginIframes:C=!1,userTriggeredOnInput:I=!1,collectFonts:_=!1,inlineImages:S=!1,plugins:k,keepIframeSrcFn:x=()=>!1,ignoreCSSAttributes:A=new Set([])}=t,E=!C||window.parent===window;let R=!1;if(!E)try{window.parent.document,R=!1}catch(t){R=!0}if(E&&!e)throw new Error("emit function is required");void 0!==w&&void 0===y.mousemove&&(y.mousemove=w),zs.reset();const M=!0===d?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:void 0!==h?h:{password:!0},T=!0===u||"all"===u?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaVerification:!0,headMetaAuthorship:"all"===u,headMetaDescKeywords:"all"===u}:u||{};let O;!function(t=window){"NodeList"in t&&!t.NodeList.prototype.forEach&&(t.NodeList.prototype.forEach=Array.prototype.forEach),"DOMTokenList"in t&&!t.DOMTokenList.prototype.forEach&&(t.DOMTokenList.prototype.forEach=Array.prototype.forEach),Node.prototype.contains||(Node.prototype.contains=(...t)=>{let e=t[0];if(!(0 in t))throw new TypeError("1 argument is required");do{if(this===e)return!0}while(e=e&&e.parentNode);return!1})}();let z=0;const L=t=>{for(const e of k||[])e.eventProcessor&&(t=e.eventProcessor(t));return f&&(t=f(t)),t};Rs=(t,r)=>{var s;if(!(null===(s=Hr[0])||void 0===s?void 0:s.isFrozen())||t.type===Lr.FullSnapshot||t.type===Lr.IncrementalSnapshot&&t.data.source===Dr.Mutation||Hr.forEach(t=>t.unfreeze()),E)null==e||e(L(t),r);else if(R){const e={type:"rrweb",event:L(t),isCheckout:r};window.parent.postMessage(e,"*")}if(t.type===Lr.FullSnapshot)O=t,z=0;else if(t.type===Lr.IncrementalSnapshot){if(t.data.source===Dr.Mutation&&t.data.isAttachIframe)return;z++;const e=i&&z>=i,r=n&&t.timestamp-O.timestamp>n;(e||r)&&Ms(!0)}};const D=t=>{Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.Mutation},t)}))},N=t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.Scroll},t)})),F=t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.CanvasMutation},t)})),B=new As({mutationCb:D,adoptedStyleSheetCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.AdoptedStyleSheet},t)}))}),U=new cs({mirror:zs,mutationCb:D,stylesheetManager:B,recordCrossOriginIframes:C,wrappedEmit:Rs});for(const t of k||[])t.getMirror&&t.getMirror({nodeMirror:zs,crossOriginIframeMirror:U.crossOriginIframeMirror,crossOriginIframeStyleMirror:U.crossOriginIframeStyleMirror});Ts=new xs({recordCanvas:v,mutationCb:F,win:window,blockClass:r,blockSelector:s,mirror:zs,sampling:y.canvas,dataURLOptions:b});const Z=new ds({mutationCb:D,scrollCb:N,bypassOptions:{blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskInputOptions:M,dataURLOptions:b,maskTextFn:g,maskInputFn:p,recordCanvas:v,inlineImages:S,sampling:y,slimDOMOptions:T,iframeManager:U,stylesheetManager:B,canvasManager:Ts,keepIframeSrcFn:x},mirror:zs});Ms=(t=!1)=>{var e,n,i,o,d,h;Rs(Es({type:Lr.Meta,data:{href:window.location.href,width:kr(),height:Sr()}}),t),B.reset(),Hr.forEach(t=>t.lock());const u=function(t,e){var n=e||{},i=n.mirror,r=void 0===i?new Qi:i,s=n.blockClass,o=n.blockSelector,a=n.maskTextClass,l=n.maskTextSelector,c=n.inlineStylesheet,d=n.inlineImages,h=n.recordCanvas,u=n.maskAllInputs,p=void 0!==u&&u,g=n.slimDOM,m=void 0!==g&&g,f=n.keepIframeSrcFn;return yr(t,{doc:t,mirror:r,blockClass:void 0===s?"rr-block":s,blockSelector:void 0===o?null:o,maskTextClass:void 0===a?"rr-mask":a,maskTextSelector:void 0===l?null:l,skipChild:!1,inlineStylesheet:void 0===c||c,maskInputOptions:!0===p?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:!1===p?{password:!0}:p,maskTextFn:n.maskTextFn,maskInputFn:n.maskInputFn,slimDOMOptions:!0===m||"all"===m?{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaDescKeywords:"all"===m,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0}:!1===m?{}:m,dataURLOptions:n.dataURLOptions,inlineImages:void 0!==d&&d,recordCanvas:void 0!==h&&h,preserveWhiteSpace:n.preserveWhiteSpace,onSerialize:n.onSerialize,onIframeLoad:n.onIframeLoad,iframeLoadTimeout:n.iframeLoadTimeout,onStylesheetLoad:n.onStylesheetLoad,stylesheetLoadTimeout:n.stylesheetLoadTimeout,keepIframeSrcFn:void 0===f?function(){return!1}:f,newlyAddedElement:!1})}(document,{mirror:zs,blockClass:r,blockSelector:s,maskTextClass:a,maskTextSelector:l,inlineStylesheet:c,maskAllInputs:M,maskTextFn:g,slimDOM:T,dataURLOptions:b,recordCanvas:v,inlineImages:S,onSerialize:t=>{Mr(t,zs)&&U.addIframe(t),Tr(t,zs)&&B.trackLinkElement(t),Or(t)&&Z.addShadowRoot(t.shadowRoot,document)},onIframeLoad:(t,e)=>{U.attachIframe(t,e),Z.observeAttachShadow(t)},onStylesheetLoad:(t,e)=>{B.attachLinkElement(t,e)},keepIframeSrcFn:x});if(!u)return console.warn("Failed to snapshot the document");Rs(Es({type:Lr.FullSnapshot,data:{node:u,initialOffset:{left:void 0!==window.pageXOffset?window.pageXOffset:(null===document||void 0===document?void 0:document.documentElement.scrollLeft)||(null===(n=null===(e=null===document||void 0===document?void 0:document.body)||void 0===e?void 0:e.parentElement)||void 0===n?void 0:n.scrollLeft)||(null===(i=null===document||void 0===document?void 0:document.body)||void 0===i?void 0:i.scrollLeft)||0,top:void 0!==window.pageYOffset?window.pageYOffset:(null===document||void 0===document?void 0:document.documentElement.scrollTop)||(null===(d=null===(o=null===document||void 0===document?void 0:document.body)||void 0===o?void 0:o.parentElement)||void 0===d?void 0:d.scrollTop)||(null===(h=null===document||void 0===document?void 0:document.body)||void 0===h?void 0:h.scrollTop)||0}}})),Hr.forEach(t=>t.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&B.adoptStyleSheets(document.adoptedStyleSheets,zs.getId(document))};try{const t=[];t.push(br("DOMContentLoaded",()=>{Rs(Es({type:Lr.DomContentLoaded,data:{}}))}));const e=t=>{var e;return as({mutationCb:D,mousemoveCb:(t,e)=>Rs(Es({type:Lr.IncrementalSnapshot,data:{source:e,positions:t}})),mouseInteractionCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.MouseInteraction},t)})),scrollCb:N,viewportResizeCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.ViewportResize},t)})),inputCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.Input},t)})),mediaInteractionCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.MediaInteraction},t)})),styleSheetRuleCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.StyleSheetRule},t)})),styleDeclarationCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.StyleDeclaration},t)})),canvasMutationCb:F,fontCb:t=>Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.Font},t)})),selectionCb:t=>{Rs(Es({type:Lr.IncrementalSnapshot,data:Object.assign({source:Dr.Selection},t)}))},blockClass:r,ignoreClass:o,maskTextClass:a,maskTextSelector:l,maskInputOptions:M,inlineStylesheet:c,sampling:y,recordCanvas:v,inlineImages:S,userTriggeredOnInput:I,collectFonts:_,doc:t,maskInputFn:p,maskTextFn:g,keepIframeSrcFn:x,blockSelector:s,slimDOMOptions:T,dataURLOptions:b,mirror:zs,iframeManager:U,stylesheetManager:B,shadowDomManager:Z,canvasManager:Ts,ignoreCSSAttributes:A,plugins:(null===(e=null==k?void 0:k.filter(t=>t.observer))||void 0===e?void 0:e.map(t=>({observer:t.observer,options:t.options,callback:e=>Rs(Es({type:Lr.Plugin,data:{plugin:t.name,payload:e}}))})))||[]},m)};U.addLoadListener(n=>{t.push(e(n.contentDocument))});const n=()=>{Ms(),t.push(e(document)),Os=!0};return"interactive"===document.readyState||"complete"===document.readyState?n():t.push(br("load",()=>{Rs(Es({type:Lr.Load,data:{}})),n()},window)),()=>{t.forEach(t=>t()),Os=!1}}catch(t){console.warn(t)}}Ls.addCustomEvent=(t,e)=>{if(!Os)throw new Error("please add custom event after start recording");Rs(Es({type:Lr.Custom,data:{tag:t,payload:e}}))},Ls.freezePage=()=>{Hr.forEach(t=>t.freeze())},Ls.takeFullSnapshot=t=>{if(!Os)throw new Error("please take full snapshot after start recording");Ms(t)},Ls.mirror=zs;class Ds{constructor(t){this.events=[],this.duration=1e3*t.duration}add(t){this.events.push(t),this.prune()}addBatch(t){this.events.push(...t),this.prune()}prune(){if(0===this.events.length)return;const t=Date.now()-this.duration;let e=0;for(let n=0;n<this.events.length;n++)if(this.events[n].timestamp>=t){e=n;break}e>0&&(this.events=this.events.slice(e))}getEvents(){return this.prune(),[...this.events]}getCompressedEvents(){return this.getEvents()}clear(){this.events=[]}size(){return this.events.length}setDuration(t){this.duration=1e3*t,this.prune()}getDuration(){return this.duration/1e3}}const Ns=Z();class Fs{constructor(t={}){var e,n,i,r,s,o,a;this.isRecording=!1,this.sanitizer=t.sanitizer,this.config={duration:null!==(e=t.duration)&&void 0!==e?e:15,sampling:{mousemove:null!==(i=null===(n=t.sampling)||void 0===n?void 0:n.mousemove)&&void 0!==i?i:50,scroll:null!==(s=null===(r=t.sampling)||void 0===r?void 0:r.scroll)&&void 0!==s?s:100},recordCanvas:null!==(o=t.recordCanvas)&&void 0!==o&&o,recordCrossOriginIframes:null!==(a=t.recordCrossOriginIframes)&&void 0!==a&&a,sanitizer:t.sanitizer},this.buffer=new Ds({duration:this.config.duration})}startRecording(){var t,e,n,i;if(this.isRecording)Z().warn("DOMCollector: Recording already in progress");else try{const r={emit:t=>{this.buffer.add(t)},sampling:{mousemove:null!==(e=null===(t=this.config.sampling)||void 0===t?void 0:t.mousemove)&&void 0!==e?e:50,scroll:null!==(i=null===(n=this.config.sampling)||void 0===n?void 0:n.scroll)&&void 0!==i?i:100,mouseInteraction:{MouseUp:!1,MouseDown:!1,Click:!1,ContextMenu:!1,DblClick:!1,Focus:!1,Blur:!1,TouchStart:!1,TouchEnd:!1}},recordCanvas:this.config.recordCanvas,recordCrossOriginIframes:this.config.recordCrossOriginIframes,maskTextFn:this.sanitizer?(t,e)=>this.sanitizer.sanitizeTextNode(t,e):void 0,slimDOMOptions:{script:!0,comment:!0,headFavicon:!0,headWhitespace:!0,headMetaSocial:!0,headMetaRobots:!0,headMetaHttpEquiv:!0,headMetaAuthorship:!0,headMetaVerification:!0},inlineImages:!1,collectFonts:!1};this.stopRecordingFn=Ls(r),this.isRecording=!0,Z().debug("DOMCollector: Started recording")}catch(t){Z().error("DOMCollector: Failed to start recording",t),this.isRecording=!1}}stopRecording(){if(this.isRecording&&this.stopRecordingFn)try{this.stopRecordingFn(),this.isRecording=!1,this.stopRecordingFn=void 0,Ns.debug("DOMCollector: Stopped recording")}catch(t){Ns.error("DOMCollector: Failed to stop recording",t)}else Ns.warn("DOMCollector: No recording in progress")}getEvents(){return this.buffer.getEvents()}getCompressedEvents(){return this.buffer.getCompressedEvents()}clearBuffer(){this.buffer.clear()}isCurrentlyRecording(){return this.isRecording}getBufferSize(){return this.buffer.size()}setDuration(t){this.config.duration=t,this.buffer.setDuration(t)}getDuration(){return this.config.duration}destroy(){this.stopRecording(),this.clearBuffer()}}class Bs{getItem(t){try{return"undefined"==typeof localStorage?null:localStorage.getItem(t)}catch(t){return null}}setItem(t,e){"undefined"!=typeof localStorage&&localStorage.setItem(t,e)}removeItem(t){try{if("undefined"==typeof localStorage)return;localStorage.removeItem(t)}catch(t){}}}const Us="bugspotter_offline_queue",Zs={enabled:!1,maxQueueSize:10};class Ps{constructor(t,e,n){this.requestCounter=0,this.config=Object.assign(Object.assign({},Zs),t),this.logger=e||Z(),this.storage=n||new Bs}enqueue(t,e,n){try{const i=this.serializeBody(e);if(!i||!this.validateItemSize(i))return;const r=this.getQueue();r.length>=this.config.maxQueueSize&&(this.logger.warn(`Offline queue is full (${this.config.maxQueueSize}), removing oldest request`),r.shift()),r.push(this.createQueuedRequest(t,i,n)),this.saveQueue(r),this.logger.log(`Request queued for offline retry (queue size: ${r.length})`)}catch(t){this.logger.error("Failed to queue request for offline retry:",t)}}async process(t){const e=this.getQueue();if(0===e.length)return;this.logger.log(`Processing offline queue (${e.length} requests)`);const n=[],i=[];for(const r of e)if(r.attempts>=5)this.logger.warn(`Max retry attempts (5) reached for request (id: ${r.id}), removing`);else if(Date.now()-r.timestamp>6048e5)this.logger.warn(`Removing expired queued request (id: ${r.id})`);else try{const e=await fetch(r.endpoint,{method:"POST",headers:r.headers,body:r.body});e.ok?(this.logger.log(`Successfully sent queued request (id: ${r.id})`),n.push(r.id)):t.includes(e.status)?(r.attempts++,i.push(r),this.logger.warn(`Queued request failed with status ${e.status}, will retry later (id: ${r.id})`)):this.logger.warn(`Queued request failed with non-retryable status ${e.status}, removing (id: ${r.id})`)}catch(t){r.attempts++,i.push(r),this.logger.warn(`Queued request failed with network error, will retry later (id: ${r.id}):`,t)}this.saveQueue(i),(n.length>0||i.length<e.length)&&this.logger.log(`Offline queue processed: ${n.length} successful, ${i.length} remaining`)}clear(){try{this.storage.removeItem(Us)}catch(t){}}size(){return this.getQueue().length}serializeBody(t){return"string"==typeof t?t:t instanceof Blob?(this.logger.warn("Cannot queue Blob for offline retry, skipping"),null):JSON.stringify(t)}createQueuedRequest(t,e,n){return{id:this.generateRequestId(),endpoint:t,body:e,headers:n,timestamp:Date.now(),attempts:0}}validateItemSize(t){const e=new Blob([t]).size;return!(e>102400&&(this.logger.warn(`Request body too large (${e} bytes), skipping queue`),1))}getQueue(){try{const t=this.storage.getItem(Us);return t?JSON.parse(t):[]}catch(t){return this.logger.warn("Failed to parse offline queue data, clearing corrupted queue:",t),this.clear(),[]}}saveQueue(t){try{this.storage.setItem(Us,JSON.stringify(t))}catch(e){this.isQuotaExceededError(e)?(this.logger.error("localStorage quota exceeded, clearing oldest items"),this.clearOldestItems(t)):this.logger.error("Failed to save offline queue:",e)}}isQuotaExceededError(t){if(!(t instanceof Error))return!1;if("QuotaExceededError"===t.name)return!0;if("code"in t&&22===t.code)return!0;const e=t.message.toLowerCase();return e.includes("quota")||e.includes("storage")||e.includes("exceeded")}clearOldestItems(t){try{const e=t.slice(Math.floor(t.length/2));this.storage.setItem(Us,JSON.stringify(e)),this.logger.log(`Trimmed offline queue to ${e.length} items due to quota`)}catch(t){this.logger.error("Failed to save even after trimming, clearing queue"),this.clear()}}generateRequestId(){let t;if(this.requestCounter=(this.requestCounter+1)%1e4,"undefined"!=typeof crypto&&crypto.getRandomValues){const e=new Uint32Array(2);crypto.getRandomValues(e),t=Array.from(e,t=>t.toString(36)).join("")}else t=Math.random().toString(36).substring(2,9)+Math.random().toString(36).substring(2,9);return`req_${Date.now()}_${this.requestCounter}_${t}`}}Error;class Ws extends Error{constructor(t){super(t),this.name="AuthenticationError"}}const Vs={maxRetries:3,baseDelay:1e3,maxDelay:3e4,retryOn:[502,503,504,429]},Gs={enabled:!1,maxQueueSize:10};function js(t){if(!t||!t.apiKey)throw new Ws("Authentication is required: API key must be provided");return{"X-API-Key":t.apiKey}}class qs{constructor(t,e){this.config=t,this.logger=e}async executeWithRetry(t,e){let n=null;for(let i=0;i<=this.config.maxRetries;i++)try{const n=await t();if(e(n.status)&&i<this.config.maxRetries){const t=this.calculateDelay(i,n);this.logger.warn(`Request failed with status ${n.status}, retrying in ${t}ms (attempt ${i+1}/${this.config.maxRetries})`),await Ks(t);continue}return n}catch(t){if(n=t,t instanceof Ws)throw t;if(i<this.config.maxRetries){const e=this.calculateDelay(i);this.logger.warn(`Network error, retrying in ${e}ms (attempt ${i+1}/${this.config.maxRetries}):`,t),await Ks(e);continue}}throw n||new Error("Request failed after all retry attempts")}calculateDelay(t,e){var n,i;if(null===(i=null===(n=null==e?void 0:e.headers)||void 0===n?void 0:n.has)||void 0===i?void 0:i.call(n,"Retry-After")){const t=e.headers.get("Retry-After"),n=parseInt(t,10);if(!isNaN(n))return Math.min(1e3*n,this.config.maxDelay)}const r=this.config.baseDelay*Math.pow(2,t),s=r+.1*r*(2*Math.random()-1);return Math.min(s,this.config.maxDelay)}}async function Hs(t,e,n={},i){const r=i.logger||Z(),s=Object.assign(Object.assign({},Vs),i.retry),o=Object.assign(Object.assign({},Gs),i.offline);!async function(t,e,n){t.enabled&&new Ps(t,n).process(e.retryOn).catch(t=>{n.warn("Failed to process offline queue:",t)})}(o,s,r);try{const o=await async function(t,e,n,i,r,s){return new qs(r,s).executeWithRetry(async()=>async function(t,e,n,i){const r=js(i),s=Object.assign(Object.assign({},n),r);return fetch(t,{method:"POST",headers:s,body:e})}(t,e,n,i),t=>r.retryOn.includes(t))}(t,e,n,i.auth,s,r);return o}catch(s){throw await async function(t,e,n,i,r,s,o){if(!s.enabled||!function(t){if(!(t instanceof Error))return!1;const e=t.message.toLowerCase();return e.includes("failed to fetch")||e.includes("network request failed")||e.includes("networkerror")||e.includes("network error")||e.includes("connection")||e.includes("timeout")||"NetworkError"===t.name||"AbortError"===t.name||"TypeError"===t.name&&(e.includes("fetch")||e.includes("network"))}(t))return;o.warn("Network error detected, queueing request for offline retry");const a=new Ps(s,o),l=js(r);await a.enqueue(e,n,Object.assign(Object.assign({},i),l))}(s,t,e,n,i.auth,o,r),s}}function Ks(t){return new Promise(e=>setTimeout(e,t))}const $s=Z();class Ys{constructor(t,e){this.apiEndpoint=t,this.apiKey=e}async uploadFiles(t,e,n){const i=await this.prepareFiles(e,n);0!==i.length&&(await this.uploadToStorage(i),await this.confirmUploads(i,t))}async prepareFiles(t,e){const n=[];if(t._screenshotPreview&&t._screenshotPreview.startsWith("data:image/")){const i=this.getPresignedUrl("screenshot",e),r=await this.dataUrlToBlob(t._screenshotPreview);n.push({type:"screenshot",url:i.uploadUrl,key:i.storageKey,blob:r})}if(t.replay&&t.replay.length>0){const i=this.getPresignedUrl("replay",e),r=await async function(t){try{const e=function(t){return"string"==typeof t?t:JSON.stringify(t)}(t),n=(hi||(hi=new TextEncoder),hi).encode(e),i=6;return ci.gzip(n,{level:i})}catch(t){throw di.error("Compression failed:",t),t}}(t.replay),s=new Blob([r],{type:"application/gzip"});n.push({type:"replay",url:i.uploadUrl,key:i.storageKey,blob:s})}return n}async uploadToStorage(t){const e=t.map(async t=>{const e=new AbortController,n=setTimeout(()=>e.abort(),Ys.UPLOAD_TIMEOUT_MS);try{const i=await fetch(t.url,{method:"PUT",headers:{"Content-Type":t.blob.type||"application/octet-stream"},body:t.blob,signal:e.signal});return clearTimeout(n),{success:i.ok,type:t.type}}catch(e){return clearTimeout(n),$s.error(`Upload failed for ${t.type}:`,e),{success:!1,type:t.type}}}),n=await Promise.all(e);for(const t of n)if(!t.success)throw new Error(`${this.formatFileType(t.type)} upload failed: Upload to storage failed`)}async confirmUploads(t,e){const n=t.map(async t=>{try{return{success:(await fetch(`${this.apiEndpoint}/api/v1/reports/${e}/confirm-upload`,{method:"POST",headers:{"Content-Type":"application/json","X-API-Key":this.apiKey},body:JSON.stringify({fileType:t.type})})).ok,type:t.type}}catch(e){return $s.error(`Confirmation failed for ${t.type}:`,e),{success:!1,type:t.type}}}),i=await Promise.all(n);for(const t of i)if(!t.success)throw new Error(`${this.formatFileType(t.type)} confirmation failed: Backend did not acknowledge upload`)}getPresignedUrl(t,e){const n=e[t];if(!n)throw new Error(`${this.formatFileType(t)} presigned URL not provided by server`);return n}async dataUrlToBlob(t){if(!t||!t.startsWith("data:"))throw new Error("Invalid data URL");const e=await fetch(t);if(!e||!e.blob)throw new Error("Failed to convert data URL to Blob");return await e.blob()}formatFileType(t){return t.charAt(0).toUpperCase()+t.slice(1)}}Ys.UPLOAD_TIMEOUT_MS=6e4;const Qs=Z();class Js{constructor(t){var e,n,i,r,s,o,a,l,c,d;this.config=t,!1!==(null===(e=t.sanitize)||void 0===e?void 0:e.enabled)&&(this.sanitizer=Vi({enabled:null===(i=null===(n=t.sanitize)||void 0===n?void 0:n.enabled)||void 0===i||i,patterns:null===(r=t.sanitize)||void 0===r?void 0:r.patterns,customPatterns:null===(s=t.sanitize)||void 0===s?void 0:s.customPatterns,excludeSelectors:null===(o=t.sanitize)||void 0===o?void 0:o.excludeSelectors})),this.screenshot=new gi,this.console=new yi({sanitizer:this.sanitizer}),this.network=new bi({sanitizer:this.sanitizer}),this.metadata=new wi({sanitizer:this.sanitizer}),!1!==(null===(a=t.replay)||void 0===a?void 0:a.enabled)&&(this.domCollector=new Fs({duration:null!==(c=null===(l=t.replay)||void 0===l?void 0:l.duration)&&void 0!==c?c:15,sampling:null===(d=t.replay)||void 0===d?void 0:d.sampling,sanitizer:this.sanitizer}),this.domCollector.startRecording()),!1!==t.showWidget&&(this.widget=new Ai(t.widgetOptions),this.widget.onClick(async()=>{await this.handleBugReport()}))}static init(t){return Js.instance||(Js.instance=new Js(t)),Js.instance}static getInstance(){return Js.instance||null}async capture(){var t,e;const n=await this.screenshot.capture(),i=null!==(e=null===(t=this.domCollector)||void 0===t?void 0:t.getEvents())&&void 0!==e?e:[];return{console:this.console.getLogs(),network:this.network.getRequests(),metadata:this.metadata.capture(),replay:i,_screenshotPreview:n}}async handleBugReport(){const t=await this.capture();new ji({onSubmit:async e=>{if(Qs.log("Submitting bug:",Object.assign(Object.assign({},e),{report:t})),this.config.endpoint)try{await this.submitBugReport(Object.assign(Object.assign({},e),{report:t})),Qs.log("Bug report submitted successfully")}catch(t){throw Qs.error("Failed to submit bug report:",t),t}}}).show(t._screenshotPreview||"")}validateAuthConfig(){if(!this.config.endpoint)throw new Error("No endpoint configured for bug report submission");if(!this.config.auth)throw new Error("API key authentication is required");if("api-key"!==this.config.auth.type)throw new Error("API key authentication is required");if(!this.config.auth.apiKey)throw new Error("API key is required in auth configuration");if(!this.config.auth.projectId)throw new Error("Project ID is required in auth configuration")}stripEndpointSuffix(t){return t.endsWith("/bugs")?t.slice(0,-5):t.includes("/api/v1/reports")?t.substring(0,t.indexOf("/api/v1/reports")):t.replace(/\/$/,"")||""}getApiBaseUrl(){if(!this.config.endpoint)throw new Error("No endpoint configured");try{const t=new URL(this.config.endpoint),e=this.stripEndpointSuffix(t.pathname);return t.origin+e}catch(t){return Qs.warn("Failed to parse endpoint URL, using fallback",{endpoint:this.config.endpoint,error:t instanceof Error?t.message:String(t)}),this.stripEndpointSuffix(this.config.endpoint)}}async submitBugReport(t){var e;this.validateAuthConfig(),Qs.warn(`Submitting bug report to ${this.config.endpoint}`);const{report:n}=t,i=function(t,e){var n={};for(var i in t)Object.prototype.hasOwnProperty.call(t,i)&&e.indexOf(i)<0&&(n[i]=t[i]);if(null!=t&&"function"==typeof Object.getOwnPropertySymbols){var r=0;for(i=Object.getOwnPropertySymbols(t);r<i.length;r++)e.indexOf(i[r])<0&&Object.prototype.propertyIsEnumerable.call(t,i[r])&&(n[i[r]]=t[i[r]])}return n}(t,["report"]),r=!(!n._screenshotPreview||!n._screenshotPreview.startsWith("data:image/")),s=!!(n.replay&&n.replay.length>0),o=Object.assign(Object.assign({},i),{report:{console:n.console,network:n.network,metadata:n.metadata},hasScreenshot:r,hasReplay:s}),a=await Hs(this.config.endpoint,JSON.stringify(o),{"Content-Type":"application/json"},{auth:this.config.auth,retry:this.config.retry,offline:this.config.offline});if(Qs.warn(`${JSON.stringify(a)}`),!a.ok){const t=await a.text().catch(()=>"Unknown error");throw new Error(`Failed to submit bug report: ${a.status} ${a.statusText}. ${t}`)}const l=await a.json().catch(()=>({success:!1}));if(!l.success||!(null===(e=l.data)||void 0===e?void 0:e.id))throw new Error("Bug report ID not returned from server");const c=l.data.id;if(!r&&!s)return;const d=this.getApiBaseUrl(),h=new Ys(d,this.config.auth.apiKey);await h.uploadFiles(c,n,l.data.presignedUrls)}getConfig(){return Object.assign({},this.config)}destroy(){var t,e;this.console.destroy(),this.network.destroy(),null===(t=this.domCollector)||void 0===t||t.destroy(),null===(e=this.widget)||void 0===e||e.destroy(),Js.instance=void 0}}return e.BugSpotter})());