@arvoretech/bug-jar 0.2.0 → 0.3.1

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.
package/dist/index.d.mts CHANGED
@@ -18,6 +18,8 @@ interface BugJarConfig {
18
18
  ui: boolean;
19
19
  uiPosition: "bottom-right" | "bottom-left" | "top-right" | "top-left";
20
20
  uiLabel: string;
21
+ hideOnMobile?: boolean;
22
+ uiCompactOnMobile?: boolean;
21
23
  }
22
24
  interface NetworkEntry {
23
25
  id: string;
package/dist/index.d.ts CHANGED
@@ -18,6 +18,8 @@ interface BugJarConfig {
18
18
  ui: boolean;
19
19
  uiPosition: "bottom-right" | "bottom-left" | "top-right" | "top-left";
20
20
  uiLabel: string;
21
+ hideOnMobile?: boolean;
22
+ uiCompactOnMobile?: boolean;
21
23
  }
22
24
  interface NetworkEntry {
23
25
  id: string;
@@ -1,12 +1,20 @@
1
- "use strict";var BugJar=(()=>{var H=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var F=(o,e)=>{for(var t in e)H(o,t,{get:e[t],enumerable:!0})},z=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!P.call(o,r)&&r!==t&&H(o,r,{get:()=>e[r],enumerable:!(n=q(e,r))||n.enumerable});return o};var I=o=>z(H({},"__esModule",{value:!0}),o);var Q={};F(Q,{BugJar:()=>m,default:()=>K,exportAsZip:()=>B,generateSummary:()=>T,init:()=>$});function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function A(o,e=1e4){try{let t=new WeakSet,n=JSON.stringify(o,(r,s)=>{if(typeof s=="object"&&s!==null){if(t.has(s))return"[Circular]";t.add(s)}return s instanceof Error?{message:s.message,stack:s.stack,name:s.name}:typeof s=="function"?"[Function]":s instanceof HTMLElement?h(s):s});return n&&n.length>e?n.slice(0,e)+"...[truncated]":n||""}catch{return"[Unserializable]"}}function h(o){if(!o||!(o instanceof Element))return"unknown";let e=o.tagName.toLowerCase(),t=o.id?`#${o.id}`:"",n=o.className&&typeof o.className=="string"?`.${o.className.trim().split(/\s+/).join(".")}`:"",r=o.textContent?.trim().slice(0,30)||"",s=r?` "${r}"`:"";return`${e}${t}${n}${s}`}function d(o,e){if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>d(n,e));let t={};for(let[n,r]of Object.entries(o))e.some(a=>n.toLowerCase().includes(a.toLowerCase()))?t[n]="[REDACTED]":typeof r=="object"&&r!==null?t[n]=d(r,e):t[n]=r;return t}var l=class{constructor(e){this.buffer=[];this.maxSize=e}push(e){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push(e)}getAll(){return[...this.buffer]}clear(){this.buffer=[]}get length(){return this.buffer.length}};var y=class{constructor(e){this.originalFetch=null;this.originalXhrOpen=null;this.originalXhrSend=null;this.originalXhrSetRequestHeader=null;this.originalSendBeacon=null;this.config=e,this.buffer=new l(e.maxNetworkEntries)}start(){this.interceptFetch(),this.interceptXHR(),this.interceptBeacon()}stop(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&this.originalXhrSend&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrOpen=null,this.originalXhrSend=null),this.originalXhrSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetRequestHeader,this.originalXhrSetRequestHeader=null),this.originalSendBeacon&&(Navigator.prototype.sendBeacon=this.originalSendBeacon,this.originalSendBeacon=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}interceptFetch(){this.originalFetch=window.fetch.bind(window);let e=this;window.fetch=async function(t,n){let r=performance.now(),s={id:g(),timestamp:Date.now(),method:(n?.method||"GET").toUpperCase(),url:typeof t=="string"?t:t instanceof URL?t.href:t.url,requestHeaders:e.extractHeaders(n?.headers),requestBody:e.safeParseBody(n?.body),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"fetch",error:null,initiator:e.getInitiator()};try{let a=await e.originalFetch(t,n);s.status=a.status,s.statusText=a.statusText,s.responseHeaders=e.extractResponseHeaders(a.headers),s.duration=performance.now()-r;let c=a.clone();try{let i=await c.text();s.responseSize=i.length,s.responseBody=e.safeParseJson(i)}catch{s.responseBody="[Unable to read response]"}return s.requestBody=d(s.requestBody,e.config.sensitiveFields),s.responseBody=d(s.responseBody,e.config.sensitiveFields),e.buffer.push(s),a}catch(a){throw s.duration=performance.now()-r,s.error=a instanceof Error?a.message:String(a),e.buffer.push(s),a}}}interceptXHR(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,this.originalXhrSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this.__bugjar_method=t,this.__bugjar_url=typeof n=="string"?n:n.href,this.__bugjar_headers={},e.originalXhrOpen.apply(this,arguments)},XMLHttpRequest.prototype.setRequestHeader=function(t,n){return this.__bugjar_headers&&(this.__bugjar_headers[t]=n),e.originalXhrSetRequestHeader.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=performance.now(),r={id:g(),timestamp:Date.now(),method:(this.__bugjar_method||"GET").toUpperCase(),url:this.__bugjar_url||"",requestHeaders:this.__bugjar_headers||{},requestBody:e.safeParseBody(t),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"xhr",error:null,initiator:e.getInitiator()};return this.addEventListener("load",function(){r.status=this.status,r.statusText=this.statusText,r.responseHeaders=e.parseXhrHeaders(this.getAllResponseHeaders()),r.duration=performance.now()-n,r.responseSize=this.responseText?.length||null,r.responseBody=e.safeParseJson(this.responseText),r.requestBody=d(r.requestBody,e.config.sensitiveFields),r.responseBody=d(r.responseBody,e.config.sensitiveFields),e.buffer.push(r)}),this.addEventListener("error",function(){r.duration=performance.now()-n,r.error="Network error",e.buffer.push(r)}),this.addEventListener("timeout",function(){r.duration=performance.now()-n,r.error="Request timeout",e.buffer.push(r)}),e.originalXhrSend.apply(this,arguments)}}interceptBeacon(){if(!navigator.sendBeacon)return;this.originalSendBeacon=navigator.sendBeacon.bind(navigator);let e=this;Navigator.prototype.sendBeacon=function(t,n){let r={id:g(),timestamp:Date.now(),method:"POST",url:typeof t=="string"?t:t.href,requestHeaders:{},requestBody:e.safeParseBody(n),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"beacon",error:null,initiator:"sendBeacon"};return r.requestBody=d(r.requestBody,e.config.sensitiveFields),e.buffer.push(r),e.originalSendBeacon(t,n)}}extractHeaders(e){let t={};return e&&(e instanceof Headers?e.forEach((n,r)=>{t[r]=n}):Array.isArray(e)?e.forEach(([n,r])=>{t[n]=r}):Object.assign(t,e)),t}extractResponseHeaders(e){let t={};return e.forEach((n,r)=>{t[r]=n}),t}parseXhrHeaders(e){let t={};return e&&e.trim().split(/[\r\n]+/).forEach(n=>{let r=n.split(": "),s=r.shift();s&&(t[s]=r.join(": "))}),t}safeParseBody(e){if(!e)return null;if(typeof e=="string")return this.safeParseJson(e);if(e instanceof FormData){let t={};return e.forEach((n,r)=>{t[r]=n instanceof File?`[File: ${n.name}]`:n}),t}return e instanceof URLSearchParams?Object.fromEntries(e.entries()):e instanceof Blob?`[Blob: ${e.size} bytes]`:e instanceof ArrayBuffer?`[ArrayBuffer: ${e.byteLength} bytes]`:String(e)}safeParseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return e.length>5e3?e.slice(0,5e3)+"...[truncated]":e}}getInitiator(){try{let e=new Error().stack;if(!e)return null;let t=e.split(`
2
- `);for(let n of t)if(!n.includes("bug-jar")&&n.includes("at "))return n.trim().slice(0,200);return null}catch{return null}}};var v=class{constructor(e){this.originals={};this.levels=["log","warn","error","info","debug"];this.buffer=new l(e.maxConsoleEntries)}start(){for(let e of this.levels){this.originals[e]=console[e].bind(console);let t=this;console[e]=(...n)=>{t.capture(e,n),t.originals[e](...n)}}}stop(){for(let e of this.levels)this.originals[e]&&(console[e]=this.originals[e]);this.originals={}}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}capture(e,t){let n={timestamp:Date.now(),level:e,args:t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:JSON.parse(A(r))),stack:e==="error"||e==="warn"?this.getStack():null};this.buffer.push(n)}getStack(){try{return new Error().stack?.split(`
1
+ "use strict";var BugJar=(()=>{var U=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var I=(o,e)=>{for(var t in e)U(o,t,{get:e[t],enumerable:!0})},X=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of F(e))!z.call(o,r)&&r!==t&&U(o,r,{get:()=>e[r],enumerable:!(n=P(e,r))||n.enumerable});return o};var N=o=>X(U({},"__esModule",{value:!0}),o);var te={};I(te,{BugJar:()=>v,default:()=>ee,exportAsZip:()=>M,generateSummary:()=>H,init:()=>$});function m(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function A(o,e=1e4){try{let t=new WeakSet,n=JSON.stringify(o,(r,s)=>{if(typeof s=="object"&&s!==null){if(t.has(s))return"[Circular]";t.add(s)}return s instanceof Error?{message:s.message,stack:s.stack,name:s.name}:typeof s=="function"?"[Function]":s instanceof HTMLElement?b(s):s});return n&&n.length>e?n.slice(0,e)+"...[truncated]":n||""}catch{return"[Unserializable]"}}function b(o){if(!o||!(o instanceof Element))return"unknown";let e=o.tagName.toLowerCase(),t=o.id?`#${o.id}`:"",n=o.className&&typeof o.className=="string"?`.${o.className.trim().split(/\s+/).join(".")}`:"",r=o.textContent?.trim().slice(0,30)||"",s=r?` "${r}"`:"";return`${e}${t}${n}${s}`}function h(o,e){if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>h(n,e));let t={};for(let[n,r]of Object.entries(o))e.some(a=>n.toLowerCase().includes(a.toLowerCase()))?t[n]="[REDACTED]":typeof r=="object"&&r!==null?t[n]=h(r,e):t[n]=r;return t}var f=class{constructor(e){this.buffer=[];this.maxSize=e}push(e){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push(e)}getAll(){return[...this.buffer]}clear(){this.buffer=[]}get length(){return this.buffer.length}};var w=class{constructor(e){this.originalFetch=null;this.originalXhrOpen=null;this.originalXhrSend=null;this.originalXhrSetRequestHeader=null;this.originalSendBeacon=null;this.config=e,this.buffer=new f(e.maxNetworkEntries)}start(){this.interceptFetch(),this.interceptXHR(),this.interceptBeacon()}stop(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&this.originalXhrSend&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrOpen=null,this.originalXhrSend=null),this.originalXhrSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetRequestHeader,this.originalXhrSetRequestHeader=null),this.originalSendBeacon&&(Navigator.prototype.sendBeacon=this.originalSendBeacon,this.originalSendBeacon=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}interceptFetch(){this.originalFetch=window.fetch.bind(window);let e=this;window.fetch=async function(t,n){let r=performance.now(),s={id:m(),timestamp:Date.now(),method:(n?.method||"GET").toUpperCase(),url:typeof t=="string"?t:t instanceof URL?t.href:t.url,requestHeaders:e.extractHeaders(n?.headers),requestBody:e.safeParseBody(n?.body),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"fetch",error:null,initiator:e.getInitiator()};try{let a=await e.originalFetch(t,n);s.status=a.status,s.statusText=a.statusText,s.responseHeaders=e.extractResponseHeaders(a.headers),s.duration=performance.now()-r;let c=a.clone();try{let i=await c.text();s.responseSize=i.length,s.responseBody=e.safeParseJson(i)}catch{s.responseBody="[Unable to read response]"}return s.requestBody=h(s.requestBody,e.config.sensitiveFields),s.responseBody=h(s.responseBody,e.config.sensitiveFields),e.buffer.push(s),a}catch(a){throw s.duration=performance.now()-r,s.error=a instanceof Error?a.message:String(a),e.buffer.push(s),a}}}interceptXHR(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,this.originalXhrSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this.__bugjar_method=t,this.__bugjar_url=typeof n=="string"?n:n.href,this.__bugjar_headers={},e.originalXhrOpen.apply(this,arguments)},XMLHttpRequest.prototype.setRequestHeader=function(t,n){return this.__bugjar_headers&&(this.__bugjar_headers[t]=n),e.originalXhrSetRequestHeader.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=performance.now(),r={id:m(),timestamp:Date.now(),method:(this.__bugjar_method||"GET").toUpperCase(),url:this.__bugjar_url||"",requestHeaders:this.__bugjar_headers||{},requestBody:e.safeParseBody(t),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"xhr",error:null,initiator:e.getInitiator()};return this.addEventListener("load",function(){r.status=this.status,r.statusText=this.statusText,r.responseHeaders=e.parseXhrHeaders(this.getAllResponseHeaders()),r.duration=performance.now()-n,r.responseSize=this.responseText?.length||null,r.responseBody=e.safeParseJson(this.responseText),r.requestBody=h(r.requestBody,e.config.sensitiveFields),r.responseBody=h(r.responseBody,e.config.sensitiveFields),e.buffer.push(r)}),this.addEventListener("error",function(){r.duration=performance.now()-n,r.error="Network error",e.buffer.push(r)}),this.addEventListener("timeout",function(){r.duration=performance.now()-n,r.error="Request timeout",e.buffer.push(r)}),e.originalXhrSend.apply(this,arguments)}}interceptBeacon(){if(!navigator.sendBeacon)return;this.originalSendBeacon=navigator.sendBeacon.bind(navigator);let e=this;Navigator.prototype.sendBeacon=function(t,n){let r={id:m(),timestamp:Date.now(),method:"POST",url:typeof t=="string"?t:t.href,requestHeaders:{},requestBody:e.safeParseBody(n),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"beacon",error:null,initiator:"sendBeacon"};return r.requestBody=h(r.requestBody,e.config.sensitiveFields),e.buffer.push(r),e.originalSendBeacon(t,n)}}extractHeaders(e){let t={};return e&&(e instanceof Headers?e.forEach((n,r)=>{t[r]=n}):Array.isArray(e)?e.forEach(([n,r])=>{t[n]=r}):Object.assign(t,e)),t}extractResponseHeaders(e){let t={};return e.forEach((n,r)=>{t[r]=n}),t}parseXhrHeaders(e){let t={};return e&&e.trim().split(/[\r\n]+/).forEach(n=>{let r=n.split(": "),s=r.shift();s&&(t[s]=r.join(": "))}),t}safeParseBody(e){if(!e)return null;if(typeof e=="string")return this.safeParseJson(e);if(e instanceof FormData){let t={};return e.forEach((n,r)=>{t[r]=n instanceof File?`[File: ${n.name}]`:n}),t}return e instanceof URLSearchParams?Object.fromEntries(e.entries()):e instanceof Blob?`[Blob: ${e.size} bytes]`:e instanceof ArrayBuffer?`[ArrayBuffer: ${e.byteLength} bytes]`:String(e)}safeParseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return e.length>5e3?e.slice(0,5e3)+"...[truncated]":e}}getInitiator(){try{let e=new Error().stack;if(!e)return null;let t=e.split(`
2
+ `);for(let n of t)if(!n.includes("bug-jar")&&n.includes("at "))return n.trim().slice(0,200);return null}catch{return null}}};var E=class{constructor(e){this.originals={};this.levels=["log","warn","error","info","debug"];this.buffer=new f(e.maxConsoleEntries)}start(){for(let e of this.levels){this.originals[e]=console[e].bind(console);let t=this;console[e]=(...n)=>{t.capture(e,n),t.originals[e](...n)}}}stop(){for(let e of this.levels)this.originals[e]&&(console[e]=this.originals[e]);this.originals={}}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}capture(e,t){let n={timestamp:Date.now(),level:e,args:t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:JSON.parse(A(r))),stack:e==="error"||e==="warn"?this.getStack():null};this.buffer.push(n)}getStack(){try{return new Error().stack?.split(`
3
3
  `).slice(4).join(`
4
- `)||null}catch{return null}}};var w=class{constructor(e){this.errorHandler=null;this.rejectionHandler=null;this.resourceErrorHandler=null;this.buffer=new l(e.maxErrors)}start(){this.errorHandler=e=>{this.buffer.push({timestamp:Date.now(),message:e.message||"Unknown error",stack:e.error?.stack||null,filename:e.filename||null,lineno:e.lineno||null,colno:e.colno||null,type:"uncaught",context:this.getContext(e.error)})},this.rejectionHandler=e=>{let t=e.reason;this.buffer.push({timestamp:Date.now(),message:t instanceof Error?t.message:String(t),stack:t instanceof Error&&t.stack||null,filename:null,lineno:null,colno:null,type:"unhandledrejection",context:t instanceof Error?this.getContext(t):null})},this.resourceErrorHandler=e=>{let t=e.target;!t||!(t instanceof HTMLElement)||(t.tagName==="SCRIPT"||t.tagName==="LINK"||t.tagName==="IMG")&&this.buffer.push({timestamp:Date.now(),message:`Failed to load ${t.tagName.toLowerCase()}: ${t.src||t.href||"unknown"}`,stack:null,filename:t.src||t.href||null,lineno:null,colno:null,type:"resource",context:null})},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.rejectionHandler),window.addEventListener("error",this.resourceErrorHandler,!0)}stop(){this.errorHandler&&(window.removeEventListener("error",this.errorHandler),this.errorHandler=null),this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null),this.resourceErrorHandler&&(window.removeEventListener("error",this.resourceErrorHandler,!0),this.resourceErrorHandler=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}getContext(e){if(!e)return null;try{let t=e.stack;if(!t)return null;let n=t.match(/at\s+(.+?)\s+\(/);return n?n[1]:null}catch{return null}}};var E=class{constructor(e){this.listeners=[];this.buffer=new l(e.maxUserActions)}start(){this.addListener("click",r=>{let s=r.target;this.buffer.push({timestamp:Date.now(),type:"click",target:h(s),metadata:{x:r.clientX,y:r.clientY,button:r.button}})},!0),this.addListener("input",r=>{let s=r.target,a=s.type==="password"||s.type==="hidden"||s.name?.toLowerCase().includes("password")||s.name?.toLowerCase().includes("token")||s.name?.toLowerCase().includes("secret");this.buffer.push({timestamp:Date.now(),type:"input",target:h(s),value:a?"[REDACTED]":s.value?.slice(0,50)||"",metadata:{inputType:s.type,name:s.name}})},!0),this.addListener("scroll",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"scroll",target:"window",metadata:{scrollX:window.scrollX,scrollY:window.scrollY,scrollHeight:document.documentElement.scrollHeight}})},500)),this.addListener("resize",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"resize",target:"window",metadata:{width:window.innerWidth,height:window.innerHeight}})},500)),this.addListener("visibilitychange",()=>{this.buffer.push({timestamp:Date.now(),type:"visibility",target:"document",value:document.visibilityState})}),this.addListener("copy",r=>{this.buffer.push({timestamp:Date.now(),type:"copy",target:h(r.target)})}),this.addListener("paste",r=>{this.buffer.push({timestamp:Date.now(),type:"paste",target:h(r.target)})});let e=history.pushState.bind(history),t=history.replaceState.bind(history),n=this;history.pushState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"pushState"}}),e(...r)},history.replaceState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"replaceState"}}),t(...r)},this.addListener("popstate",()=>{this.buffer.push({timestamp:Date.now(),type:"navigation",target:window.location.href,metadata:{method:"popstate"}})})}stop(){for(let{event:e,handler:t,options:n}of this.listeners)(e==="visibilitychange"?document:window).removeEventListener(e,t,n);this.listeners=[]}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}addListener(e,t,n){(e==="visibilitychange"?document:window).addEventListener(e,t,n),this.listeners.push({event:e,handler:t,options:n})}throttle(e,t){let n=0;return()=>{let r=Date.now();r-n>=t&&(n=r,e())}}};var x=class{collect(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset(),screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,cookiesEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,online:navigator.onLine,hardwareConcurrency:navigator.hardwareConcurrency||0,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,connection:this.getConnection(),memory:this.getMemory()}}getConnection(){let e=navigator.connection;return e?{effectiveType:e.effectiveType||"unknown",downlink:e.downlink||0,rtt:e.rtt||0,saveData:e.saveData||!1}:null}getMemory(){let e=performance.memory;return e?{jsHeapSizeLimit:e.jsHeapSizeLimit,totalJSHeapSize:e.totalJSHeapSize,usedJSHeapSize:e.usedJSHeapSize}:null}};var S=class{constructor(){this.lcp=null;this.fid=null;this.cls=null;this.observers=[]}start(){this.observeLCP(),this.observeFID(),this.observeCLS()}stop(){for(let e of this.observers)e.disconnect();this.observers=[]}collect(){let e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("paint"),n=performance.getEntriesByType("resource"),r=t.find(a=>a.name==="first-paint"),s=t.find(a=>a.name==="first-contentful-paint");return{navigationTiming:e?{redirectTime:e.redirectEnd-e.redirectStart,dnsTime:e.domainLookupEnd-e.domainLookupStart,tcpTime:e.connectEnd-e.connectStart,tlsTime:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,downloadTime:e.responseEnd-e.responseStart,domParsing:e.domInteractive-e.responseEnd,domContentLoaded:e.domContentLoadedEventEnd-e.domContentLoadedEventStart,loadEvent:e.loadEventEnd-e.loadEventStart,totalTime:e.loadEventEnd-e.startTime}:{},resourceCount:n.length,totalTransferSize:n.reduce((a,c)=>a+(c.transferSize||0),0),domContentLoaded:e?e.domContentLoadedEventEnd-e.startTime:null,loadComplete:e?e.loadEventEnd-e.startTime:null,firstPaint:r?r.startTime:null,firstContentfulPaint:s?s.startTime:null,largestContentfulPaint:this.lcp,firstInputDelay:this.fid,cumulativeLayoutShift:this.cls,timeToInteractive:null}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.lcp=n[n.length-1].startTime)});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch{}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.fid=n[0].processingStart-n[0].startTime)});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch{}}observeCLS(){try{let e=0,t=new PerformanceObserver(n=>{for(let r of n.getEntries())r.hadRecentInput||(e+=r.value);this.cls=e});t.observe({type:"layout-shift",buffered:!0}),this.observers.push(t)}catch{}}};var R=class{constructor(e){this.config=e}collect(){return{localStorage:this.config.captureLocalStorage?this.collectStorage(localStorage):{},sessionStorage:this.config.captureSessionStorage?this.collectStorage(sessionStorage):{},cookies:this.config.captureCookies?this.collectCookies():[]}}collectStorage(e){let t={};try{for(let n=0;n<e.length;n++){let r=e.key(n);if(!r)continue;if(this.config.sensitiveFields.some(a=>r.toLowerCase().includes(a.toLowerCase())))t[r]="[REDACTED]";else{let a=e.getItem(r)||"";t[r]=a.length>500?a.slice(0,500)+"...[truncated]":a}}}catch{}return t}collectCookies(){try{return document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean)}catch{return[]}}};var j=class{async capture(){try{let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;let n=window.innerWidth,r=window.innerHeight,s=Math.min(window.devicePixelRatio,2);e.width=n*s,e.height=r*s,t.scale(s,s);let a=this.domToSvg(n,r);return a?new Promise(c=>{let i=new Image;i.onload=()=>{t.drawImage(i,0,0);try{let u=e.toDataURL("image/png",.8);c(u)}catch{c(null)}},i.onerror=()=>c(null),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,setTimeout(()=>c(null),3e3)}):null}catch{return null}}domToSvg(e,t){try{let n=document.documentElement.cloneNode(!0);n.querySelectorAll("script").forEach(a=>a.remove());let s=new XMLSerializer().serializeToString(n);return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}">
4
+ `)||null}catch{return null}}};var x=class{constructor(e){this.errorHandler=null;this.rejectionHandler=null;this.resourceErrorHandler=null;this.buffer=new f(e.maxErrors)}start(){this.errorHandler=e=>{this.buffer.push({timestamp:Date.now(),message:e.message||"Unknown error",stack:e.error?.stack||null,filename:e.filename||null,lineno:e.lineno||null,colno:e.colno||null,type:"uncaught",context:this.getContext(e.error)})},this.rejectionHandler=e=>{let t=e.reason;this.buffer.push({timestamp:Date.now(),message:t instanceof Error?t.message:String(t),stack:t instanceof Error&&t.stack||null,filename:null,lineno:null,colno:null,type:"unhandledrejection",context:t instanceof Error?this.getContext(t):null})},this.resourceErrorHandler=e=>{let t=e.target;!t||!(t instanceof HTMLElement)||(t.tagName==="SCRIPT"||t.tagName==="LINK"||t.tagName==="IMG")&&this.buffer.push({timestamp:Date.now(),message:`Failed to load ${t.tagName.toLowerCase()}: ${t.src||t.href||"unknown"}`,stack:null,filename:t.src||t.href||null,lineno:null,colno:null,type:"resource",context:null})},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.rejectionHandler),window.addEventListener("error",this.resourceErrorHandler,!0)}stop(){this.errorHandler&&(window.removeEventListener("error",this.errorHandler),this.errorHandler=null),this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null),this.resourceErrorHandler&&(window.removeEventListener("error",this.resourceErrorHandler,!0),this.resourceErrorHandler=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}getContext(e){if(!e)return null;try{let t=e.stack;if(!t)return null;let n=t.match(/at\s+(.+?)\s+\(/);return n?n[1]:null}catch{return null}}};var S=class{constructor(e){this.listeners=[];this.buffer=new f(e.maxUserActions)}start(){this.addListener("click",r=>{let s=r.target;this.buffer.push({timestamp:Date.now(),type:"click",target:b(s),metadata:{x:r.clientX,y:r.clientY,button:r.button}})},!0),this.addListener("input",r=>{let s=r.target,a=s.type==="password"||s.type==="hidden"||s.name?.toLowerCase().includes("password")||s.name?.toLowerCase().includes("token")||s.name?.toLowerCase().includes("secret");this.buffer.push({timestamp:Date.now(),type:"input",target:b(s),value:a?"[REDACTED]":s.value?.slice(0,50)||"",metadata:{inputType:s.type,name:s.name}})},!0),this.addListener("scroll",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"scroll",target:"window",metadata:{scrollX:window.scrollX,scrollY:window.scrollY,scrollHeight:document.documentElement.scrollHeight}})},500)),this.addListener("resize",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"resize",target:"window",metadata:{width:window.innerWidth,height:window.innerHeight}})},500)),this.addListener("visibilitychange",()=>{this.buffer.push({timestamp:Date.now(),type:"visibility",target:"document",value:document.visibilityState})}),this.addListener("copy",r=>{this.buffer.push({timestamp:Date.now(),type:"copy",target:b(r.target)})}),this.addListener("paste",r=>{this.buffer.push({timestamp:Date.now(),type:"paste",target:b(r.target)})});let e=history.pushState.bind(history),t=history.replaceState.bind(history),n=this;history.pushState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"pushState"}}),e(...r)},history.replaceState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"replaceState"}}),t(...r)},this.addListener("popstate",()=>{this.buffer.push({timestamp:Date.now(),type:"navigation",target:window.location.href,metadata:{method:"popstate"}})})}stop(){for(let{event:e,handler:t,options:n}of this.listeners)(e==="visibilitychange"?document:window).removeEventListener(e,t,n);this.listeners=[]}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}addListener(e,t,n){(e==="visibilitychange"?document:window).addEventListener(e,t,n),this.listeners.push({event:e,handler:t,options:n})}throttle(e,t){let n=0;return()=>{let r=Date.now();r-n>=t&&(n=r,e())}}};var R=class{collect(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset(),screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,cookiesEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,online:navigator.onLine,hardwareConcurrency:navigator.hardwareConcurrency||0,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,connection:this.getConnection(),memory:this.getMemory()}}getConnection(){let e=navigator.connection;return e?{effectiveType:e.effectiveType||"unknown",downlink:e.downlink||0,rtt:e.rtt||0,saveData:e.saveData||!1}:null}getMemory(){let e=performance.memory;return e?{jsHeapSizeLimit:e.jsHeapSizeLimit,totalJSHeapSize:e.totalJSHeapSize,usedJSHeapSize:e.usedJSHeapSize}:null}};var j=class{constructor(){this.lcp=null;this.fid=null;this.cls=null;this.observers=[]}start(){this.observeLCP(),this.observeFID(),this.observeCLS()}stop(){for(let e of this.observers)e.disconnect();this.observers=[]}collect(){let e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("paint"),n=performance.getEntriesByType("resource"),r=t.find(a=>a.name==="first-paint"),s=t.find(a=>a.name==="first-contentful-paint");return{navigationTiming:e?{redirectTime:e.redirectEnd-e.redirectStart,dnsTime:e.domainLookupEnd-e.domainLookupStart,tcpTime:e.connectEnd-e.connectStart,tlsTime:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,downloadTime:e.responseEnd-e.responseStart,domParsing:e.domInteractive-e.responseEnd,domContentLoaded:e.domContentLoadedEventEnd-e.domContentLoadedEventStart,loadEvent:e.loadEventEnd-e.loadEventStart,totalTime:e.loadEventEnd-e.startTime}:{},resourceCount:n.length,totalTransferSize:n.reduce((a,c)=>a+(c.transferSize||0),0),domContentLoaded:e?e.domContentLoadedEventEnd-e.startTime:null,loadComplete:e?e.loadEventEnd-e.startTime:null,firstPaint:r?r.startTime:null,firstContentfulPaint:s?s.startTime:null,largestContentfulPaint:this.lcp,firstInputDelay:this.fid,cumulativeLayoutShift:this.cls,timeToInteractive:null}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.lcp=n[n.length-1].startTime)});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch{}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.fid=n[0].processingStart-n[0].startTime)});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch{}}observeCLS(){try{let e=0,t=new PerformanceObserver(n=>{for(let r of n.getEntries())r.hadRecentInput||(e+=r.value);this.cls=e});t.observe({type:"layout-shift",buffered:!0}),this.observers.push(t)}catch{}}};var L=class{constructor(e){this.config=e}collect(){return{localStorage:this.config.captureLocalStorage?this.collectStorage(localStorage):{},sessionStorage:this.config.captureSessionStorage?this.collectStorage(sessionStorage):{},cookies:this.config.captureCookies?this.collectCookies():[]}}collectStorage(e){let t={};try{for(let n=0;n<e.length;n++){let r=e.key(n);if(!r)continue;if(this.config.sensitiveFields.some(a=>r.toLowerCase().includes(a.toLowerCase())))t[r]="[REDACTED]";else{let a=e.getItem(r)||"";t[r]=a.length>500?a.slice(0,500)+"...[truncated]":a}}}catch{}return t}collectCookies(){try{return document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean)}catch{return[]}}};var k=class{async capture(){try{let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;let n=window.innerWidth,r=window.innerHeight,s=Math.min(window.devicePixelRatio,2);e.width=n*s,e.height=r*s,t.scale(s,s);let a=this.domToSvg(n,r);return a?new Promise(c=>{let i=new Image;i.onload=()=>{t.drawImage(i,0,0);try{let u=e.toDataURL("image/png",.8);c(u)}catch{c(null)}},i.onerror=()=>c(null),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,setTimeout(()=>c(null),3e3)}):null}catch{return null}}domToSvg(e,t){try{let n=document.documentElement.cloneNode(!0);n.querySelectorAll("script").forEach(a=>a.remove());let s=new XMLSerializer().serializeToString(n);return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}">
5
5
  <foreignObject width="100%" height="100%">
6
6
  ${s}
7
7
  </foreignObject>
8
- </svg>`}catch{return null}}captureHtml(){try{let e=document.documentElement.cloneNode(!0);return e.querySelectorAll("script").forEach(r=>r.remove()),e.querySelectorAll('input[type="password"], input[name*="token"], input[name*="secret"]').forEach(r=>r.value="[REDACTED]"),e.outerHTML.slice(0,5e5)}catch{return null}}};var k=class{collect(){let e={},t=!1,n=window.posthog;if(n?.getFeatureFlag)try{let c=n.getAllFlags?.()||n.getFeatureFlags?.()||{};e.posthog=c,t=!0}catch{}let r=window.ldclient;if(r?.allFlags)try{e.launchdarkly=r.allFlags(),t=!0}catch{}let s=window.statsig;if(s?.getExperiment||s?.checkGate)try{e.statsig={detected:!0},t=!0}catch{}let a=window.unleash;if(a?.getAllToggles)try{e.unleash=a.getAllToggles(),t=!0}catch{}return t?e:null}};var L=class{constructor(){this.mediaRecorder=null;this.chunks=[];this.stream=null;this.recording=!1}get isRecording(){return this.recording}async start(){if(!this.recording)try{this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0}),this.chunks=[],this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:this.getSupportedMimeType(),videoBitsPerSecond:1e6}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks()},this.stream.getVideoTracks()[0].onended=()=>{this.stop()},this.mediaRecorder.start(1e3),this.recording=!0}catch{this.recording=!1,this.stream=null,this.mediaRecorder=null}}stop(){return new Promise(e=>{if(!this.mediaRecorder||!this.recording){e(null);return}this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks();let t=new Blob(this.chunks,{type:this.getSupportedMimeType()});this.chunks=[],e(t)},this.mediaRecorder.stop()})}stopTracks(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null)}getSupportedMimeType(){let e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(let t of e)if(MediaRecorder.isTypeSupported(t))return t;return"video/webm"}};var C=class{constructor(e,t,n){this.container=null;this.config=e,this.onReport=t,this.screenRecorder=n}mount(){this.container||(this.container=document.createElement("div"),this.container.id="bug-jar-widget",this.container.innerHTML=this.getWidgetHTML(),document.body.appendChild(this.container),this.injectStyles(),this.bindEvents())}unmount(){this.container&&(this.container.remove(),this.container=null);let e=document.getElementById("bug-jar-styles");e&&e.remove()}getWidgetHTML(){return`
9
- <button class="bug-jar-trigger ${`bug-jar--${this.config.uiPosition}`}" aria-label="${this.config.uiLabel}">
8
+ </svg>`}catch{return null}}captureHtml(){try{let e=document.documentElement.cloneNode(!0);return e.querySelectorAll("script").forEach(r=>r.remove()),e.querySelectorAll('input[type="password"], input[name*="token"], input[name*="secret"]').forEach(r=>r.value="[REDACTED]"),e.outerHTML.slice(0,5e5)}catch{return null}}};var C=class{collect(){let e={},t=!1,n=window.posthog;if(n?.getFeatureFlag)try{let c=n.getAllFlags?.()||n.getFeatureFlags?.()||{};e.posthog=c,t=!0}catch{}let r=window.ldclient;if(r?.allFlags)try{e.launchdarkly=r.allFlags(),t=!0}catch{}let s=window.statsig;if(s?.getExperiment||s?.checkGate)try{e.statsig={detected:!0},t=!0}catch{}let a=window.unleash;if(a?.getAllToggles)try{e.unleash=a.getAllToggles(),t=!0}catch{}return t?e:null}};var T=class{constructor(){this.mediaRecorder=null;this.chunks=[];this.stream=null;this.recording=!1}get isRecording(){return this.recording}async start(){if(!this.recording)try{this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0}),this.chunks=[],this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:this.getSupportedMimeType(),videoBitsPerSecond:1e6}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks()},this.stream.getVideoTracks()[0].onended=()=>{this.stop()},this.mediaRecorder.start(1e3),this.recording=!0}catch{this.recording=!1,this.stream=null,this.mediaRecorder=null}}stop(){return new Promise(e=>{if(!this.mediaRecorder||!this.recording){e(null);return}this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks();let t=new Blob(this.chunks,{type:this.getSupportedMimeType()});this.chunks=[],e(t)},this.mediaRecorder.stop()})}stopTracks(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null)}getSupportedMimeType(){let e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(let t of e)if(MediaRecorder.isTypeSupported(t))return t;return"video/webm"}};var B=class{constructor(e,t,n){this.container=null;this.config=e,this.onReport=t,this.screenRecorder=n}mount(){if(this.container)return;let e=typeof window<"u"&&window.innerWidth<=768;if(this.config.hideOnMobile&&e)return;this.container=document.createElement("div"),this.container.id="bug-jar-widget";let t=e&&this.config.uiCompactOnMobile;this.container.innerHTML=this.getWidgetHTML(t),this.container.dataset.compact=String(t),document.body.appendChild(this.container),this.injectStyles(t),this.bindEvents(),this.makeDraggable()}unmount(){this.container&&(this.container.remove(),this.container=null);let e=document.getElementById("bug-jar-styles");e&&e.remove()}getWidgetHTML(e=!1){let n=`bug-jar--${this.config.uiPosition}`,r=e?" bug-jar-trigger--compact":"";return e?`
9
+ <button class="bug-jar-trigger ${n}${r}" aria-label="${this.config.uiLabel}">
10
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
+ <path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 116 0v1"/>
12
+ <path d="M12 20c-3.3 0-6-2.7-6-6v-3a6 6 0 0112 0v3c0 3.3-2.7 6-6 6z"/>
13
+ <path d="M12 20v2M6 13H2M22 13h-4M6 17l-2 2M18 17l2 2M6 9l-2-2M18 9l2-2"/>
14
+ </svg>
15
+ </button>
16
+ `:`
17
+ <button class="bug-jar-trigger ${n}" aria-label="${this.config.uiLabel}">
10
18
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
19
  <path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 116 0v1"/>
12
20
  <path d="M12 20c-3.3 0-6-2.7-6-6v-3a6 6 0 0112 0v3c0 3.3-2.7 6-6 6z"/>
@@ -40,7 +48,7 @@
40
48
  <div class="bug-jar-status" hidden></div>
41
49
  </div>
42
50
  </div>
43
- `}bindEvents(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger"),t=this.container.querySelector(".bug-jar-modal"),n=this.container.querySelector(".bug-jar-modal-backdrop"),r=this.container.querySelector(".bug-jar-close"),s=this.container.querySelector(".bug-jar-cancel"),a=this.container.querySelector(".bug-jar-submit"),c=this.container.querySelector("#bug-jar-description"),i=this.container.querySelector(".bug-jar-status"),u=this.container.querySelector(".bug-jar-record-btn"),f=this.container.querySelector(".bug-jar-recording-status"),b=()=>{t.hidden=!1,c.focus(),this.updateRecordingUI(u,f)},p=()=>{t.hidden=!0,c.value="",i.hidden=!0};e.addEventListener("click",b),n.addEventListener("click",p),r.addEventListener("click",p),s.addEventListener("click",p),u.addEventListener("click",async()=>{this.screenRecorder.isRecording||(p(),await this.screenRecorder.start(),this.updateTriggerForRecording(e))}),a.addEventListener("click",async()=>{let U=c.value.trim();if(!U){c.classList.add("bug-jar-error");return}c.classList.remove("bug-jar-error"),a.setAttribute("disabled","true"),a.textContent="Capturando...",i.hidden=!0;try{await this.onReport(U),i.textContent="\u2713 Relat\xF3rio baixado como .zip!",i.className="bug-jar-status bug-jar-status--success",i.hidden=!1,this.resetTrigger(e),setTimeout(p,2e3)}catch(M){i.textContent=`Erro: ${M instanceof Error?M.message:"Falha ao gerar relat\xF3rio"}`,i.className="bug-jar-status bug-jar-status--error",i.hidden=!1}finally{a.removeAttribute("disabled"),a.textContent="Enviar Relat\xF3rio"}}),c.addEventListener("input",()=>{c.classList.remove("bug-jar-error")})}updateRecordingUI(e,t){if(this.screenRecorder.isRecording){e.classList.add("bug-jar-record-btn--active"),t.hidden=!1;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravando...")}else{e.classList.remove("bug-jar-record-btn--active"),t.hidden=!0;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravar Tela")}}updateTriggerForRecording(e){e.classList.add("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent="\u23FA Gravando...")}resetTrigger(e){e.classList.remove("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent=this.config.uiLabel)}injectStyles(){if(document.getElementById("bug-jar-styles"))return;let e=document.createElement("style");e.id="bug-jar-styles",e.textContent=`
51
+ `}bindEvents(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger"),t=this.container.querySelector(".bug-jar-modal"),n=this.container.querySelector(".bug-jar-modal-backdrop"),r=this.container.querySelector(".bug-jar-close"),s=this.container.querySelector(".bug-jar-cancel"),a=this.container.querySelector(".bug-jar-submit"),c=this.container.querySelector("#bug-jar-description"),i=this.container.querySelector(".bug-jar-status"),u=this.container.querySelector(".bug-jar-record-btn"),p=this.container.querySelector(".bug-jar-recording-status"),l=()=>{this.container?.dataset.compact==="true"&&this.container.querySelector(".bug-jar-trigger")?.classList.add("bug-jar-trigger--expanded"),t&&(t.hidden=!1),c?.focus(),this.updateRecordingUI(u,p)},d=()=>{t&&(t.hidden=!0),c&&(c.value=""),i&&(i.hidden=!0),this.container?.dataset.compact==="true"&&this.container.querySelector(".bug-jar-trigger")?.classList.remove("bug-jar-trigger--expanded")};e.addEventListener("click",l),n&&n.addEventListener("click",d),r&&r.addEventListener("click",d),s&&s.addEventListener("click",d),u?.addEventListener("click",async()=>{this.screenRecorder.isRecording||(d(),await this.screenRecorder.start(),this.updateTriggerForRecording(e))}),a?.addEventListener("click",async()=>{let g=c?.value.trim();if(!(!g||!c||!a||!i)){c.classList.remove("bug-jar-error"),a.setAttribute("disabled","true"),a.textContent="Capturando...",i.hidden=!0;try{await this.onReport(g),i.textContent="\u2713 Relat\xF3rio baixado como .zip!",i.className="bug-jar-status bug-jar-status--success",i.hidden=!1,this.resetTrigger(e),setTimeout(d,2e3)}catch(y){i.textContent=`Erro: ${y instanceof Error?y.message:"Falha ao gerar relat\xF3rio"}`,i.className="bug-jar-status bug-jar-status--error",i.hidden=!1}finally{a.removeAttribute("disabled"),a.textContent="Enviar Relat\xF3rio"}}}),c?.addEventListener("input",()=>{c?.classList.remove("bug-jar-error")})}updateRecordingUI(e,t){if(!(!e||!t))if(this.screenRecorder.isRecording){e.classList.add("bug-jar-record-btn--active"),t.hidden=!1;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravando...")}else{e.classList.remove("bug-jar-record-btn--active"),t.hidden=!0;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravar Tela")}}updateTriggerForRecording(e){e.classList.add("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent="\u23FA Gravando...")}resetTrigger(e){e.classList.remove("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent=this.config.uiLabel)}makeDraggable(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger");if(!e)return;let t=!1,n=0,r=0,s=0,a=0,c=!1,i=l=>{let d="touches"in l?l.touches[0]:l;n=d.clientX,r=d.clientY;let g=e.getBoundingClientRect();s=g.left,a=g.top,c=!1,t=!0,e.classList.add("bug-jar-trigger--dragging"),document.addEventListener("mousemove",u),document.addEventListener("mouseup",p),document.addEventListener("touchmove",u,{passive:!1}),document.addEventListener("touchend",p)},u=l=>{if(!t)return;l.preventDefault();let d="touches"in l?l.touches[0]:l,g=d.clientX-n,y=d.clientY-r;(Math.abs(g)>5||Math.abs(y)>5)&&(c=!0);let q=s+g,D=a+y;e.style.position="fixed",e.style.left=`${q}px`,e.style.top=`${D}px`,e.style.right="auto",e.style.bottom="auto",e.classList.remove("bug-jar--bottom-right","bug-jar--bottom-left","bug-jar--top-right","bug-jar--top-left")},p=()=>{t=!1,e.classList.remove("bug-jar-trigger--dragging"),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",u),document.removeEventListener("touchend",p),c&&(e.style.cursor="")};e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!0})}injectStyles(e=!1){if(document.getElementById("bug-jar-styles"))return;let t=document.createElement("style");t.id="bug-jar-styles",t.textContent=`
44
52
  #bug-jar-widget {
45
53
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
46
54
  font-size: 14px;
@@ -64,6 +72,8 @@
64
72
  cursor: pointer;
65
73
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
66
74
  transition: transform 0.15s, box-shadow 0.15s, background 0.3s;
75
+ user-select: none;
76
+ touch-action: none;
67
77
  }
68
78
 
69
79
  .bug-jar-trigger:hover {
@@ -71,6 +81,31 @@
71
81
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
72
82
  }
73
83
 
84
+ .bug-jar-trigger--compact {
85
+ padding: 12px;
86
+ border-radius: 50%;
87
+ width: 44px;
88
+ height: 44px;
89
+ justify-content: center;
90
+ }
91
+
92
+ .bug-jar-trigger--compact span {
93
+ display: none;
94
+ }
95
+
96
+ .bug-jar-trigger--expanded {
97
+ padding: 10px 16px;
98
+ width: auto;
99
+ height: auto;
100
+ border-radius: 24px;
101
+ }
102
+
103
+ .bug-jar-trigger--dragging {
104
+ cursor: grabbing;
105
+ transform: scale(1.1);
106
+ box-shadow: 0 8px 25px rgba(0,0,0,0.3);
107
+ }
108
+
74
109
  .bug-jar-trigger--recording {
75
110
  background: #dc2626;
76
111
  animation: bug-jar-pulse 1.5s infinite;
@@ -262,5 +297,5 @@
262
297
 
263
298
  .bug-jar-status--success { color: #16a34a; background: #f0fdf4; }
264
299
  .bug-jar-status--error { color: #dc2626; background: #fef2f2; }
265
- `,document.head.appendChild(e)}};function T(o){let e=[];e.push(`Bug Report: ${o.id}`),e.push(`URL: ${o.url}`),e.push(`Time: ${new Date(o.timestamp).toISOString()}`),e.push(`User Description: "${o.userDescription}"`),e.push(""),e.push("## Environment"),e.push(`Browser: ${N(o.environment.userAgent)}`),e.push(`Viewport: ${o.environment.viewportWidth}x${o.environment.viewportHeight}`),e.push(`Connection: ${o.environment.connection?.effectiveType||"unknown"}`),e.push(`Online: ${o.environment.online}`),e.push(""),e.push("## Network Activity");let t=o.network.length,n=o.network.filter(i=>i.error||i.status&&i.status>=400),r=o.network.filter(i=>i.duration&&i.duration>3e3);if(e.push(`Total requests: ${t}`),n.length>0){e.push(`Failed requests (${n.length}):`);for(let i of n)e.push(` - ${i.method} ${i.url} \u2192 ${i.error||`HTTP ${i.status}`}`)}if(r.length>0){e.push(`Slow requests >3s (${r.length}):`);for(let i of r)e.push(` - ${i.method} ${i.url} (${Math.round(i.duration)}ms)`)}if(e.push(""),e.push("## Errors"),o.errors.length===0)e.push("No errors captured.");else{e.push(`Total errors: ${o.errors.length}`);for(let i of o.errors)e.push(` - [${i.type}] ${i.message}`),i.filename&&e.push(` at ${i.filename}:${i.lineno}:${i.colno}`)}e.push(""),e.push("## Console");let s={log:0,warn:0,error:0,info:0,debug:0};for(let i of o.console)s[i.level]++;e.push(`Logs: ${s.log}, Warnings: ${s.warn}, Errors: ${s.error}, Info: ${s.info}, Debug: ${s.debug}`);let a=o.console.filter(i=>i.level==="error");if(a.length>0){e.push("Console errors:");for(let i of a)e.push(` - ${i.args.map(u=>typeof u=="string"?u:JSON.stringify(u)).join(" ")}`)}e.push(""),e.push("## User Actions"),e.push(`Total actions: ${o.userActions.length}`);let c={};for(let i of o.userActions)c[i.type]=(c[i.type]||0)+1;for(let[i,u]of Object.entries(c))e.push(` - ${i}: ${u}`);if(o.userActions.length>0){let i=o.userActions[0].timestamp,f=((o.userActions[o.userActions.length-1].timestamp-i)/1e3).toFixed(1);e.push(`Session duration: ${f}s`)}if(e.push(""),o.performance){e.push("## Performance");let i=o.performance;i.largestContentfulPaint&&e.push(`LCP: ${Math.round(i.largestContentfulPaint)}ms`),i.firstInputDelay&&e.push(`FID: ${Math.round(i.firstInputDelay)}ms`),i.cumulativeLayoutShift!==null&&e.push(`CLS: ${i.cumulativeLayoutShift?.toFixed(3)}`),i.loadComplete&&e.push(`Page Load: ${Math.round(i.loadComplete)}ms`),e.push(`Resources: ${i.resourceCount} (${J(i.totalTransferSize)})`)}return e.join(`
266
- `)}function N(o){return o.includes("Chrome/")?`Chrome ${o.match(/Chrome\/(\d+)/)?.[1]||""}`:o.includes("Firefox/")?`Firefox ${o.match(/Firefox\/(\d+)/)?.[1]||""}`:o.includes("Safari/")&&!o.includes("Chrome")?`Safari ${o.match(/Version\/(\d+)/)?.[1]||""}`:o.slice(0,50)}function J(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/(1024*1024)).toFixed(1)}MB`}async function B(o,e){let t=[],n=JSON.stringify(o,null,2);t.push({name:"report.json",content:new TextEncoder().encode(n)});let r=T(o);if(t.push({name:"summary.md",content:new TextEncoder().encode(r)}),o.screenshot){let s=X(o.screenshot);s&&t.push({name:"screenshot.png",content:s})}if(e){let s=new Uint8Array(await e.arrayBuffer());t.push({name:"recording.webm",content:s})}return O(t)}function X(o){try{let e=o.split(",")[1];if(!e)return null;let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch{return null}}function O(o){let e=[],t=[],n=0;for(let i of o){let u=new TextEncoder().encode(i.name),f=V(i.content),b=_(u,i.content.length,f);e.push(b),e.push(u),e.push(i.content);let p=W(u,i.content.length,f,n);t.push(p),t.push(u),n+=b.length+u.length+i.content.length}let r=n,s=0;for(let i of t)s+=i.length;let a=G(o.length,s,r),c=[...e,...t,a].map(i=>i.buffer);return new Blob(c,{type:"application/zip"})}function _(o,e,t){let n=new Uint8Array(30),r=new DataView(n.buffer);return r.setUint32(0,67324752,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,0,!0),r.setUint16(10,0,!0),r.setUint16(12,0,!0),r.setUint32(14,t,!0),r.setUint32(18,e,!0),r.setUint32(22,e,!0),r.setUint16(26,o.length,!0),r.setUint16(28,0,!0),n}function W(o,e,t,n){let r=new Uint8Array(46),s=new DataView(r.buffer);return s.setUint32(0,33639248,!0),s.setUint16(4,20,!0),s.setUint16(6,20,!0),s.setUint16(8,0,!0),s.setUint16(10,0,!0),s.setUint16(12,0,!0),s.setUint16(14,0,!0),s.setUint32(16,t,!0),s.setUint32(20,e,!0),s.setUint32(24,e,!0),s.setUint16(28,o.length,!0),s.setUint16(30,0,!0),s.setUint16(32,0,!0),s.setUint16(34,0,!0),s.setUint16(36,0,!0),s.setUint32(38,0,!0),s.setUint32(42,n,!0),r}function G(o,e,t){let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,o,!0),r.setUint16(10,o,!0),r.setUint32(12,e,!0),r.setUint32(16,t,!0),r.setUint16(20,0,!0),n}function V(o){let e=4294967295;for(let t=0;t<o.length;t++){e^=o[t];for(let n=0;n<8;n++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}var Z="0.2.0",Y={maxNetworkEntries:100,maxConsoleEntries:200,maxUserActions:150,maxErrors:50,captureScreenshot:!0,captureHtmlSnapshot:!0,captureCookies:!0,captureLocalStorage:!0,captureSessionStorage:!0,capturePerformance:!0,captureWebVitals:!0,captureMemory:!0,captureConnectivity:!0,sensitiveFields:["password","token","secret","authorization","cookie","session","credit_card","cvv","ssn","cpf"],endpoint:void 0,onCapture:void 0,ui:!0,uiPosition:"bottom-right",uiLabel:"Reportar Bug"},m=class{constructor(e={}){this.ui=null;this.started=!1;this.config={...Y,...e},this.network=new y(this.config),this.console=new v(this.config),this.errors=new w(this.config),this.userActions=new E(this.config),this.environment=new x,this.performance=new S,this.storage=new R(this.config),this.screenshot=new j,this.featureFlags=new k,this.screenRecorder=new L}start(){this.started||(this.started=!0,this.network.start(),this.console.start(),this.errors.start(),this.userActions.start(),this.config.captureWebVitals&&this.performance.start(),this.config.ui&&(this.ui=new C(this.config,e=>this.captureAndExport(e),this.screenRecorder),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.ui?.mount()):this.ui.mount()))}stop(){this.started&&(this.started=!1,this.network.stop(),this.console.stop(),this.errors.stop(),this.userActions.stop(),this.performance.stop(),this.ui?.unmount())}async startRecording(){await this.screenRecorder.start()}get isRecording(){return this.screenRecorder.isRecording}async capture(e=""){let t={id:g(),timestamp:Date.now(),url:window.location.href,title:document.title,userDescription:e,environment:this.environment.collect(),network:this.network.getEntries(),console:this.console.getEntries(),errors:this.errors.getEntries(),userActions:this.userActions.getEntries(),performance:this.config.capturePerformance?this.performance.collect():null,storage:this.storage.collect(),screenshot:this.config.captureScreenshot?await this.screenshot.capture():null,htmlSnapshot:this.config.captureHtmlSnapshot?this.screenshot.captureHtml():null,featureFlags:this.featureFlags.collect(),metadata:{},version:Z};return this.config.onCapture&&this.config.onCapture(t),t}async captureAndExport(e=""){let t=await this.screenRecorder.stop(),n=await this.capture(e);if(this.config.endpoint)if(t){let r=new FormData;r.append("report",JSON.stringify(n)),r.append("video",t,"recording.webm"),await fetch(this.config.endpoint,{method:"POST",body:r})}else await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});else{let r=await B(n,t),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`bug-report-${n.id}.zip`,a.click(),URL.revokeObjectURL(s)}return n}getReport(){return this.capture()}};function $(o={}){let e=new m(o);return e.start(),e}typeof window<"u"&&(window.BugJar={BugJar:m,init:$});var K=m;return I(Q);})();
300
+ `,document.head.appendChild(t)}};function H(o){let e=[];e.push(`Bug Report: ${o.id}`),e.push(`URL: ${o.url}`),e.push(`Time: ${new Date(o.timestamp).toISOString()}`),e.push(`User Description: "${o.userDescription}"`),e.push(""),e.push("## Environment"),e.push(`Browser: ${O(o.environment.userAgent)}`),e.push(`Viewport: ${o.environment.viewportWidth}x${o.environment.viewportHeight}`),e.push(`Connection: ${o.environment.connection?.effectiveType||"unknown"}`),e.push(`Online: ${o.environment.online}`),e.push(""),e.push("## Network Activity");let t=o.network.length,n=o.network.filter(i=>i.error||i.status&&i.status>=400),r=o.network.filter(i=>i.duration&&i.duration>3e3);if(e.push(`Total requests: ${t}`),n.length>0){e.push(`Failed requests (${n.length}):`);for(let i of n)e.push(` - ${i.method} ${i.url} \u2192 ${i.error||`HTTP ${i.status}`}`)}if(r.length>0){e.push(`Slow requests >3s (${r.length}):`);for(let i of r)e.push(` - ${i.method} ${i.url} (${Math.round(i.duration)}ms)`)}if(e.push(""),e.push("## Errors"),o.errors.length===0)e.push("No errors captured.");else{e.push(`Total errors: ${o.errors.length}`);for(let i of o.errors)e.push(` - [${i.type}] ${i.message}`),i.filename&&e.push(` at ${i.filename}:${i.lineno}:${i.colno}`)}e.push(""),e.push("## Console");let s={log:0,warn:0,error:0,info:0,debug:0};for(let i of o.console)s[i.level]++;e.push(`Logs: ${s.log}, Warnings: ${s.warn}, Errors: ${s.error}, Info: ${s.info}, Debug: ${s.debug}`);let a=o.console.filter(i=>i.level==="error");if(a.length>0){e.push("Console errors:");for(let i of a)e.push(` - ${i.args.map(u=>typeof u=="string"?u:JSON.stringify(u)).join(" ")}`)}e.push(""),e.push("## User Actions"),e.push(`Total actions: ${o.userActions.length}`);let c={};for(let i of o.userActions)c[i.type]=(c[i.type]||0)+1;for(let[i,u]of Object.entries(c))e.push(` - ${i}: ${u}`);if(o.userActions.length>0){let i=o.userActions[0].timestamp,p=((o.userActions[o.userActions.length-1].timestamp-i)/1e3).toFixed(1);e.push(`Session duration: ${p}s`)}if(e.push(""),o.performance){e.push("## Performance");let i=o.performance;i.largestContentfulPaint&&e.push(`LCP: ${Math.round(i.largestContentfulPaint)}ms`),i.firstInputDelay&&e.push(`FID: ${Math.round(i.firstInputDelay)}ms`),i.cumulativeLayoutShift!==null&&e.push(`CLS: ${i.cumulativeLayoutShift?.toFixed(3)}`),i.loadComplete&&e.push(`Page Load: ${Math.round(i.loadComplete)}ms`),e.push(`Resources: ${i.resourceCount} (${J(i.totalTransferSize)})`)}return e.join(`
301
+ `)}function O(o){return o.includes("Chrome/")?`Chrome ${o.match(/Chrome\/(\d+)/)?.[1]||""}`:o.includes("Firefox/")?`Firefox ${o.match(/Firefox\/(\d+)/)?.[1]||""}`:o.includes("Safari/")&&!o.includes("Chrome")?`Safari ${o.match(/Version\/(\d+)/)?.[1]||""}`:o.slice(0,50)}function J(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/(1024*1024)).toFixed(1)}MB`}async function M(o,e){let t=[],n=JSON.stringify(o,null,2);t.push({name:"report.json",content:new TextEncoder().encode(n)});let r=H(o);if(t.push({name:"summary.md",content:new TextEncoder().encode(r)}),o.screenshot){let s=_(o.screenshot);s&&t.push({name:"screenshot.png",content:s})}if(e){let s=new Uint8Array(await e.arrayBuffer());t.push({name:"recording.webm",content:s})}return W(t)}function _(o){try{let e=o.split(",")[1];if(!e)return null;let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch{return null}}function W(o){let e=[],t=[],n=0;for(let i of o){let u=new TextEncoder().encode(i.name),p=Z(i.content),l=G(u,i.content.length,p);e.push(l),e.push(u),e.push(i.content);let d=V(u,i.content.length,p,n);t.push(d),t.push(u),n+=l.length+u.length+i.content.length}let r=n,s=0;for(let i of t)s+=i.length;let a=Y(o.length,s,r),c=[...e,...t,a].map(i=>i.buffer);return new Blob(c,{type:"application/zip"})}function G(o,e,t){let n=new Uint8Array(30),r=new DataView(n.buffer);return r.setUint32(0,67324752,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,0,!0),r.setUint16(10,0,!0),r.setUint16(12,0,!0),r.setUint32(14,t,!0),r.setUint32(18,e,!0),r.setUint32(22,e,!0),r.setUint16(26,o.length,!0),r.setUint16(28,0,!0),n}function V(o,e,t,n){let r=new Uint8Array(46),s=new DataView(r.buffer);return s.setUint32(0,33639248,!0),s.setUint16(4,20,!0),s.setUint16(6,20,!0),s.setUint16(8,0,!0),s.setUint16(10,0,!0),s.setUint16(12,0,!0),s.setUint16(14,0,!0),s.setUint32(16,t,!0),s.setUint32(20,e,!0),s.setUint32(24,e,!0),s.setUint16(28,o.length,!0),s.setUint16(30,0,!0),s.setUint16(32,0,!0),s.setUint16(34,0,!0),s.setUint16(36,0,!0),s.setUint32(38,0,!0),s.setUint32(42,n,!0),r}function Y(o,e,t){let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,o,!0),r.setUint16(10,o,!0),r.setUint32(12,e,!0),r.setUint32(16,t,!0),r.setUint16(20,0,!0),n}function Z(o){let e=4294967295;for(let t=0;t<o.length;t++){e^=o[t];for(let n=0;n<8;n++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}var K="0.2.0",Q={maxNetworkEntries:100,maxConsoleEntries:200,maxUserActions:150,maxErrors:50,captureScreenshot:!0,captureHtmlSnapshot:!0,captureCookies:!0,captureLocalStorage:!0,captureSessionStorage:!0,capturePerformance:!0,captureWebVitals:!0,captureMemory:!0,captureConnectivity:!0,sensitiveFields:["password","token","secret","authorization","cookie","session","credit_card","cvv","ssn","cpf"],endpoint:void 0,onCapture:void 0,ui:!0,uiPosition:"bottom-right",uiLabel:"Reportar Bug"},v=class{constructor(e={}){this.ui=null;this.started=!1;this.config={...Q,...e},this.network=new w(this.config),this.console=new E(this.config),this.errors=new x(this.config),this.userActions=new S(this.config),this.environment=new R,this.performance=new j,this.storage=new L(this.config),this.screenshot=new k,this.featureFlags=new C,this.screenRecorder=new T}start(){this.started||(this.started=!0,this.network.start(),this.console.start(),this.errors.start(),this.userActions.start(),this.config.captureWebVitals&&this.performance.start(),this.config.ui&&(this.ui=new B(this.config,e=>this.captureAndExport(e),this.screenRecorder),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.ui?.mount()):this.ui.mount()))}stop(){this.started&&(this.started=!1,this.network.stop(),this.console.stop(),this.errors.stop(),this.userActions.stop(),this.performance.stop(),this.ui?.unmount())}async startRecording(){await this.screenRecorder.start()}get isRecording(){return this.screenRecorder.isRecording}async capture(e=""){let t={id:m(),timestamp:Date.now(),url:window.location.href,title:document.title,userDescription:e,environment:this.environment.collect(),network:this.network.getEntries(),console:this.console.getEntries(),errors:this.errors.getEntries(),userActions:this.userActions.getEntries(),performance:this.config.capturePerformance?this.performance.collect():null,storage:this.storage.collect(),screenshot:this.config.captureScreenshot?await this.screenshot.capture():null,htmlSnapshot:this.config.captureHtmlSnapshot?this.screenshot.captureHtml():null,featureFlags:this.featureFlags.collect(),metadata:{},version:K};return this.config.onCapture&&this.config.onCapture(t),t}async captureAndExport(e=""){let t=await this.screenRecorder.stop(),n=await this.capture(e);if(this.config.endpoint)if(t){let r=new FormData;r.append("report",JSON.stringify(n)),r.append("video",t,"recording.webm"),await fetch(this.config.endpoint,{method:"POST",body:r})}else await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});else{let r=await M(n,t),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`bug-report-${n.id}.zip`,a.click(),URL.revokeObjectURL(s)}return n}getReport(){return this.capture()}};function $(o={}){let e=new v(o);return e.start(),e}typeof window<"u"&&(window.BugJar={BugJar:v,init:$});var ee=v;return N(te);})();
package/dist/index.js CHANGED
@@ -1,12 +1,20 @@
1
- "use strict";var H=Object.defineProperty;var q=Object.getOwnPropertyDescriptor;var D=Object.getOwnPropertyNames;var P=Object.prototype.hasOwnProperty;var F=(o,e)=>{for(var t in e)H(o,t,{get:e[t],enumerable:!0})},z=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of D(e))!P.call(o,r)&&r!==t&&H(o,r,{get:()=>e[r],enumerable:!(n=q(e,r))||n.enumerable});return o};var I=o=>z(H({},"__esModule",{value:!0}),o);var Q={};F(Q,{BugJar:()=>m,default:()=>K,exportAsZip:()=>B,generateSummary:()=>T,init:()=>$});module.exports=I(Q);function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function A(o,e=1e4){try{let t=new WeakSet,n=JSON.stringify(o,(r,s)=>{if(typeof s=="object"&&s!==null){if(t.has(s))return"[Circular]";t.add(s)}return s instanceof Error?{message:s.message,stack:s.stack,name:s.name}:typeof s=="function"?"[Function]":s instanceof HTMLElement?h(s):s});return n&&n.length>e?n.slice(0,e)+"...[truncated]":n||""}catch{return"[Unserializable]"}}function h(o){if(!o||!(o instanceof Element))return"unknown";let e=o.tagName.toLowerCase(),t=o.id?`#${o.id}`:"",n=o.className&&typeof o.className=="string"?`.${o.className.trim().split(/\s+/).join(".")}`:"",r=o.textContent?.trim().slice(0,30)||"",s=r?` "${r}"`:"";return`${e}${t}${n}${s}`}function d(o,e){if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>d(n,e));let t={};for(let[n,r]of Object.entries(o))e.some(a=>n.toLowerCase().includes(a.toLowerCase()))?t[n]="[REDACTED]":typeof r=="object"&&r!==null?t[n]=d(r,e):t[n]=r;return t}var l=class{constructor(e){this.buffer=[];this.maxSize=e}push(e){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push(e)}getAll(){return[...this.buffer]}clear(){this.buffer=[]}get length(){return this.buffer.length}};var y=class{constructor(e){this.originalFetch=null;this.originalXhrOpen=null;this.originalXhrSend=null;this.originalXhrSetRequestHeader=null;this.originalSendBeacon=null;this.config=e,this.buffer=new l(e.maxNetworkEntries)}start(){this.interceptFetch(),this.interceptXHR(),this.interceptBeacon()}stop(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&this.originalXhrSend&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrOpen=null,this.originalXhrSend=null),this.originalXhrSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetRequestHeader,this.originalXhrSetRequestHeader=null),this.originalSendBeacon&&(Navigator.prototype.sendBeacon=this.originalSendBeacon,this.originalSendBeacon=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}interceptFetch(){this.originalFetch=window.fetch.bind(window);let e=this;window.fetch=async function(t,n){let r=performance.now(),s={id:g(),timestamp:Date.now(),method:(n?.method||"GET").toUpperCase(),url:typeof t=="string"?t:t instanceof URL?t.href:t.url,requestHeaders:e.extractHeaders(n?.headers),requestBody:e.safeParseBody(n?.body),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"fetch",error:null,initiator:e.getInitiator()};try{let a=await e.originalFetch(t,n);s.status=a.status,s.statusText=a.statusText,s.responseHeaders=e.extractResponseHeaders(a.headers),s.duration=performance.now()-r;let c=a.clone();try{let i=await c.text();s.responseSize=i.length,s.responseBody=e.safeParseJson(i)}catch{s.responseBody="[Unable to read response]"}return s.requestBody=d(s.requestBody,e.config.sensitiveFields),s.responseBody=d(s.responseBody,e.config.sensitiveFields),e.buffer.push(s),a}catch(a){throw s.duration=performance.now()-r,s.error=a instanceof Error?a.message:String(a),e.buffer.push(s),a}}}interceptXHR(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,this.originalXhrSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this.__bugjar_method=t,this.__bugjar_url=typeof n=="string"?n:n.href,this.__bugjar_headers={},e.originalXhrOpen.apply(this,arguments)},XMLHttpRequest.prototype.setRequestHeader=function(t,n){return this.__bugjar_headers&&(this.__bugjar_headers[t]=n),e.originalXhrSetRequestHeader.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=performance.now(),r={id:g(),timestamp:Date.now(),method:(this.__bugjar_method||"GET").toUpperCase(),url:this.__bugjar_url||"",requestHeaders:this.__bugjar_headers||{},requestBody:e.safeParseBody(t),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"xhr",error:null,initiator:e.getInitiator()};return this.addEventListener("load",function(){r.status=this.status,r.statusText=this.statusText,r.responseHeaders=e.parseXhrHeaders(this.getAllResponseHeaders()),r.duration=performance.now()-n,r.responseSize=this.responseText?.length||null,r.responseBody=e.safeParseJson(this.responseText),r.requestBody=d(r.requestBody,e.config.sensitiveFields),r.responseBody=d(r.responseBody,e.config.sensitiveFields),e.buffer.push(r)}),this.addEventListener("error",function(){r.duration=performance.now()-n,r.error="Network error",e.buffer.push(r)}),this.addEventListener("timeout",function(){r.duration=performance.now()-n,r.error="Request timeout",e.buffer.push(r)}),e.originalXhrSend.apply(this,arguments)}}interceptBeacon(){if(!navigator.sendBeacon)return;this.originalSendBeacon=navigator.sendBeacon.bind(navigator);let e=this;Navigator.prototype.sendBeacon=function(t,n){let r={id:g(),timestamp:Date.now(),method:"POST",url:typeof t=="string"?t:t.href,requestHeaders:{},requestBody:e.safeParseBody(n),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"beacon",error:null,initiator:"sendBeacon"};return r.requestBody=d(r.requestBody,e.config.sensitiveFields),e.buffer.push(r),e.originalSendBeacon(t,n)}}extractHeaders(e){let t={};return e&&(e instanceof Headers?e.forEach((n,r)=>{t[r]=n}):Array.isArray(e)?e.forEach(([n,r])=>{t[n]=r}):Object.assign(t,e)),t}extractResponseHeaders(e){let t={};return e.forEach((n,r)=>{t[r]=n}),t}parseXhrHeaders(e){let t={};return e&&e.trim().split(/[\r\n]+/).forEach(n=>{let r=n.split(": "),s=r.shift();s&&(t[s]=r.join(": "))}),t}safeParseBody(e){if(!e)return null;if(typeof e=="string")return this.safeParseJson(e);if(e instanceof FormData){let t={};return e.forEach((n,r)=>{t[r]=n instanceof File?`[File: ${n.name}]`:n}),t}return e instanceof URLSearchParams?Object.fromEntries(e.entries()):e instanceof Blob?`[Blob: ${e.size} bytes]`:e instanceof ArrayBuffer?`[ArrayBuffer: ${e.byteLength} bytes]`:String(e)}safeParseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return e.length>5e3?e.slice(0,5e3)+"...[truncated]":e}}getInitiator(){try{let e=new Error().stack;if(!e)return null;let t=e.split(`
2
- `);for(let n of t)if(!n.includes("bug-jar")&&n.includes("at "))return n.trim().slice(0,200);return null}catch{return null}}};var v=class{constructor(e){this.originals={};this.levels=["log","warn","error","info","debug"];this.buffer=new l(e.maxConsoleEntries)}start(){for(let e of this.levels){this.originals[e]=console[e].bind(console);let t=this;console[e]=(...n)=>{t.capture(e,n),t.originals[e](...n)}}}stop(){for(let e of this.levels)this.originals[e]&&(console[e]=this.originals[e]);this.originals={}}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}capture(e,t){let n={timestamp:Date.now(),level:e,args:t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:JSON.parse(A(r))),stack:e==="error"||e==="warn"?this.getStack():null};this.buffer.push(n)}getStack(){try{return new Error().stack?.split(`
1
+ "use strict";var U=Object.defineProperty;var P=Object.getOwnPropertyDescriptor;var F=Object.getOwnPropertyNames;var z=Object.prototype.hasOwnProperty;var I=(o,e)=>{for(var t in e)U(o,t,{get:e[t],enumerable:!0})},X=(o,e,t,n)=>{if(e&&typeof e=="object"||typeof e=="function")for(let r of F(e))!z.call(o,r)&&r!==t&&U(o,r,{get:()=>e[r],enumerable:!(n=P(e,r))||n.enumerable});return o};var N=o=>X(U({},"__esModule",{value:!0}),o);var te={};I(te,{BugJar:()=>v,default:()=>ee,exportAsZip:()=>M,generateSummary:()=>H,init:()=>$});module.exports=N(te);function m(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function A(o,e=1e4){try{let t=new WeakSet,n=JSON.stringify(o,(r,s)=>{if(typeof s=="object"&&s!==null){if(t.has(s))return"[Circular]";t.add(s)}return s instanceof Error?{message:s.message,stack:s.stack,name:s.name}:typeof s=="function"?"[Function]":s instanceof HTMLElement?b(s):s});return n&&n.length>e?n.slice(0,e)+"...[truncated]":n||""}catch{return"[Unserializable]"}}function b(o){if(!o||!(o instanceof Element))return"unknown";let e=o.tagName.toLowerCase(),t=o.id?`#${o.id}`:"",n=o.className&&typeof o.className=="string"?`.${o.className.trim().split(/\s+/).join(".")}`:"",r=o.textContent?.trim().slice(0,30)||"",s=r?` "${r}"`:"";return`${e}${t}${n}${s}`}function h(o,e){if(!o||typeof o!="object")return o;if(Array.isArray(o))return o.map(n=>h(n,e));let t={};for(let[n,r]of Object.entries(o))e.some(a=>n.toLowerCase().includes(a.toLowerCase()))?t[n]="[REDACTED]":typeof r=="object"&&r!==null?t[n]=h(r,e):t[n]=r;return t}var f=class{constructor(e){this.buffer=[];this.maxSize=e}push(e){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push(e)}getAll(){return[...this.buffer]}clear(){this.buffer=[]}get length(){return this.buffer.length}};var w=class{constructor(e){this.originalFetch=null;this.originalXhrOpen=null;this.originalXhrSend=null;this.originalXhrSetRequestHeader=null;this.originalSendBeacon=null;this.config=e,this.buffer=new f(e.maxNetworkEntries)}start(){this.interceptFetch(),this.interceptXHR(),this.interceptBeacon()}stop(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&this.originalXhrSend&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrOpen=null,this.originalXhrSend=null),this.originalXhrSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetRequestHeader,this.originalXhrSetRequestHeader=null),this.originalSendBeacon&&(Navigator.prototype.sendBeacon=this.originalSendBeacon,this.originalSendBeacon=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}interceptFetch(){this.originalFetch=window.fetch.bind(window);let e=this;window.fetch=async function(t,n){let r=performance.now(),s={id:m(),timestamp:Date.now(),method:(n?.method||"GET").toUpperCase(),url:typeof t=="string"?t:t instanceof URL?t.href:t.url,requestHeaders:e.extractHeaders(n?.headers),requestBody:e.safeParseBody(n?.body),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"fetch",error:null,initiator:e.getInitiator()};try{let a=await e.originalFetch(t,n);s.status=a.status,s.statusText=a.statusText,s.responseHeaders=e.extractResponseHeaders(a.headers),s.duration=performance.now()-r;let c=a.clone();try{let i=await c.text();s.responseSize=i.length,s.responseBody=e.safeParseJson(i)}catch{s.responseBody="[Unable to read response]"}return s.requestBody=h(s.requestBody,e.config.sensitiveFields),s.responseBody=h(s.responseBody,e.config.sensitiveFields),e.buffer.push(s),a}catch(a){throw s.duration=performance.now()-r,s.error=a instanceof Error?a.message:String(a),e.buffer.push(s),a}}}interceptXHR(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,this.originalXhrSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this.__bugjar_method=t,this.__bugjar_url=typeof n=="string"?n:n.href,this.__bugjar_headers={},e.originalXhrOpen.apply(this,arguments)},XMLHttpRequest.prototype.setRequestHeader=function(t,n){return this.__bugjar_headers&&(this.__bugjar_headers[t]=n),e.originalXhrSetRequestHeader.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=performance.now(),r={id:m(),timestamp:Date.now(),method:(this.__bugjar_method||"GET").toUpperCase(),url:this.__bugjar_url||"",requestHeaders:this.__bugjar_headers||{},requestBody:e.safeParseBody(t),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"xhr",error:null,initiator:e.getInitiator()};return this.addEventListener("load",function(){r.status=this.status,r.statusText=this.statusText,r.responseHeaders=e.parseXhrHeaders(this.getAllResponseHeaders()),r.duration=performance.now()-n,r.responseSize=this.responseText?.length||null,r.responseBody=e.safeParseJson(this.responseText),r.requestBody=h(r.requestBody,e.config.sensitiveFields),r.responseBody=h(r.responseBody,e.config.sensitiveFields),e.buffer.push(r)}),this.addEventListener("error",function(){r.duration=performance.now()-n,r.error="Network error",e.buffer.push(r)}),this.addEventListener("timeout",function(){r.duration=performance.now()-n,r.error="Request timeout",e.buffer.push(r)}),e.originalXhrSend.apply(this,arguments)}}interceptBeacon(){if(!navigator.sendBeacon)return;this.originalSendBeacon=navigator.sendBeacon.bind(navigator);let e=this;Navigator.prototype.sendBeacon=function(t,n){let r={id:m(),timestamp:Date.now(),method:"POST",url:typeof t=="string"?t:t.href,requestHeaders:{},requestBody:e.safeParseBody(n),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"beacon",error:null,initiator:"sendBeacon"};return r.requestBody=h(r.requestBody,e.config.sensitiveFields),e.buffer.push(r),e.originalSendBeacon(t,n)}}extractHeaders(e){let t={};return e&&(e instanceof Headers?e.forEach((n,r)=>{t[r]=n}):Array.isArray(e)?e.forEach(([n,r])=>{t[n]=r}):Object.assign(t,e)),t}extractResponseHeaders(e){let t={};return e.forEach((n,r)=>{t[r]=n}),t}parseXhrHeaders(e){let t={};return e&&e.trim().split(/[\r\n]+/).forEach(n=>{let r=n.split(": "),s=r.shift();s&&(t[s]=r.join(": "))}),t}safeParseBody(e){if(!e)return null;if(typeof e=="string")return this.safeParseJson(e);if(e instanceof FormData){let t={};return e.forEach((n,r)=>{t[r]=n instanceof File?`[File: ${n.name}]`:n}),t}return e instanceof URLSearchParams?Object.fromEntries(e.entries()):e instanceof Blob?`[Blob: ${e.size} bytes]`:e instanceof ArrayBuffer?`[ArrayBuffer: ${e.byteLength} bytes]`:String(e)}safeParseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return e.length>5e3?e.slice(0,5e3)+"...[truncated]":e}}getInitiator(){try{let e=new Error().stack;if(!e)return null;let t=e.split(`
2
+ `);for(let n of t)if(!n.includes("bug-jar")&&n.includes("at "))return n.trim().slice(0,200);return null}catch{return null}}};var E=class{constructor(e){this.originals={};this.levels=["log","warn","error","info","debug"];this.buffer=new f(e.maxConsoleEntries)}start(){for(let e of this.levels){this.originals[e]=console[e].bind(console);let t=this;console[e]=(...n)=>{t.capture(e,n),t.originals[e](...n)}}}stop(){for(let e of this.levels)this.originals[e]&&(console[e]=this.originals[e]);this.originals={}}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}capture(e,t){let n={timestamp:Date.now(),level:e,args:t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:JSON.parse(A(r))),stack:e==="error"||e==="warn"?this.getStack():null};this.buffer.push(n)}getStack(){try{return new Error().stack?.split(`
3
3
  `).slice(4).join(`
4
- `)||null}catch{return null}}};var w=class{constructor(e){this.errorHandler=null;this.rejectionHandler=null;this.resourceErrorHandler=null;this.buffer=new l(e.maxErrors)}start(){this.errorHandler=e=>{this.buffer.push({timestamp:Date.now(),message:e.message||"Unknown error",stack:e.error?.stack||null,filename:e.filename||null,lineno:e.lineno||null,colno:e.colno||null,type:"uncaught",context:this.getContext(e.error)})},this.rejectionHandler=e=>{let t=e.reason;this.buffer.push({timestamp:Date.now(),message:t instanceof Error?t.message:String(t),stack:t instanceof Error&&t.stack||null,filename:null,lineno:null,colno:null,type:"unhandledrejection",context:t instanceof Error?this.getContext(t):null})},this.resourceErrorHandler=e=>{let t=e.target;!t||!(t instanceof HTMLElement)||(t.tagName==="SCRIPT"||t.tagName==="LINK"||t.tagName==="IMG")&&this.buffer.push({timestamp:Date.now(),message:`Failed to load ${t.tagName.toLowerCase()}: ${t.src||t.href||"unknown"}`,stack:null,filename:t.src||t.href||null,lineno:null,colno:null,type:"resource",context:null})},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.rejectionHandler),window.addEventListener("error",this.resourceErrorHandler,!0)}stop(){this.errorHandler&&(window.removeEventListener("error",this.errorHandler),this.errorHandler=null),this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null),this.resourceErrorHandler&&(window.removeEventListener("error",this.resourceErrorHandler,!0),this.resourceErrorHandler=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}getContext(e){if(!e)return null;try{let t=e.stack;if(!t)return null;let n=t.match(/at\s+(.+?)\s+\(/);return n?n[1]:null}catch{return null}}};var E=class{constructor(e){this.listeners=[];this.buffer=new l(e.maxUserActions)}start(){this.addListener("click",r=>{let s=r.target;this.buffer.push({timestamp:Date.now(),type:"click",target:h(s),metadata:{x:r.clientX,y:r.clientY,button:r.button}})},!0),this.addListener("input",r=>{let s=r.target,a=s.type==="password"||s.type==="hidden"||s.name?.toLowerCase().includes("password")||s.name?.toLowerCase().includes("token")||s.name?.toLowerCase().includes("secret");this.buffer.push({timestamp:Date.now(),type:"input",target:h(s),value:a?"[REDACTED]":s.value?.slice(0,50)||"",metadata:{inputType:s.type,name:s.name}})},!0),this.addListener("scroll",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"scroll",target:"window",metadata:{scrollX:window.scrollX,scrollY:window.scrollY,scrollHeight:document.documentElement.scrollHeight}})},500)),this.addListener("resize",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"resize",target:"window",metadata:{width:window.innerWidth,height:window.innerHeight}})},500)),this.addListener("visibilitychange",()=>{this.buffer.push({timestamp:Date.now(),type:"visibility",target:"document",value:document.visibilityState})}),this.addListener("copy",r=>{this.buffer.push({timestamp:Date.now(),type:"copy",target:h(r.target)})}),this.addListener("paste",r=>{this.buffer.push({timestamp:Date.now(),type:"paste",target:h(r.target)})});let e=history.pushState.bind(history),t=history.replaceState.bind(history),n=this;history.pushState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"pushState"}}),e(...r)},history.replaceState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"replaceState"}}),t(...r)},this.addListener("popstate",()=>{this.buffer.push({timestamp:Date.now(),type:"navigation",target:window.location.href,metadata:{method:"popstate"}})})}stop(){for(let{event:e,handler:t,options:n}of this.listeners)(e==="visibilitychange"?document:window).removeEventListener(e,t,n);this.listeners=[]}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}addListener(e,t,n){(e==="visibilitychange"?document:window).addEventListener(e,t,n),this.listeners.push({event:e,handler:t,options:n})}throttle(e,t){let n=0;return()=>{let r=Date.now();r-n>=t&&(n=r,e())}}};var x=class{collect(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset(),screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,cookiesEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,online:navigator.onLine,hardwareConcurrency:navigator.hardwareConcurrency||0,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,connection:this.getConnection(),memory:this.getMemory()}}getConnection(){let e=navigator.connection;return e?{effectiveType:e.effectiveType||"unknown",downlink:e.downlink||0,rtt:e.rtt||0,saveData:e.saveData||!1}:null}getMemory(){let e=performance.memory;return e?{jsHeapSizeLimit:e.jsHeapSizeLimit,totalJSHeapSize:e.totalJSHeapSize,usedJSHeapSize:e.usedJSHeapSize}:null}};var S=class{constructor(){this.lcp=null;this.fid=null;this.cls=null;this.observers=[]}start(){this.observeLCP(),this.observeFID(),this.observeCLS()}stop(){for(let e of this.observers)e.disconnect();this.observers=[]}collect(){let e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("paint"),n=performance.getEntriesByType("resource"),r=t.find(a=>a.name==="first-paint"),s=t.find(a=>a.name==="first-contentful-paint");return{navigationTiming:e?{redirectTime:e.redirectEnd-e.redirectStart,dnsTime:e.domainLookupEnd-e.domainLookupStart,tcpTime:e.connectEnd-e.connectStart,tlsTime:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,downloadTime:e.responseEnd-e.responseStart,domParsing:e.domInteractive-e.responseEnd,domContentLoaded:e.domContentLoadedEventEnd-e.domContentLoadedEventStart,loadEvent:e.loadEventEnd-e.loadEventStart,totalTime:e.loadEventEnd-e.startTime}:{},resourceCount:n.length,totalTransferSize:n.reduce((a,c)=>a+(c.transferSize||0),0),domContentLoaded:e?e.domContentLoadedEventEnd-e.startTime:null,loadComplete:e?e.loadEventEnd-e.startTime:null,firstPaint:r?r.startTime:null,firstContentfulPaint:s?s.startTime:null,largestContentfulPaint:this.lcp,firstInputDelay:this.fid,cumulativeLayoutShift:this.cls,timeToInteractive:null}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.lcp=n[n.length-1].startTime)});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch{}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.fid=n[0].processingStart-n[0].startTime)});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch{}}observeCLS(){try{let e=0,t=new PerformanceObserver(n=>{for(let r of n.getEntries())r.hadRecentInput||(e+=r.value);this.cls=e});t.observe({type:"layout-shift",buffered:!0}),this.observers.push(t)}catch{}}};var R=class{constructor(e){this.config=e}collect(){return{localStorage:this.config.captureLocalStorage?this.collectStorage(localStorage):{},sessionStorage:this.config.captureSessionStorage?this.collectStorage(sessionStorage):{},cookies:this.config.captureCookies?this.collectCookies():[]}}collectStorage(e){let t={};try{for(let n=0;n<e.length;n++){let r=e.key(n);if(!r)continue;if(this.config.sensitiveFields.some(a=>r.toLowerCase().includes(a.toLowerCase())))t[r]="[REDACTED]";else{let a=e.getItem(r)||"";t[r]=a.length>500?a.slice(0,500)+"...[truncated]":a}}}catch{}return t}collectCookies(){try{return document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean)}catch{return[]}}};var j=class{async capture(){try{let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;let n=window.innerWidth,r=window.innerHeight,s=Math.min(window.devicePixelRatio,2);e.width=n*s,e.height=r*s,t.scale(s,s);let a=this.domToSvg(n,r);return a?new Promise(c=>{let i=new Image;i.onload=()=>{t.drawImage(i,0,0);try{let u=e.toDataURL("image/png",.8);c(u)}catch{c(null)}},i.onerror=()=>c(null),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,setTimeout(()=>c(null),3e3)}):null}catch{return null}}domToSvg(e,t){try{let n=document.documentElement.cloneNode(!0);n.querySelectorAll("script").forEach(a=>a.remove());let s=new XMLSerializer().serializeToString(n);return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}">
4
+ `)||null}catch{return null}}};var x=class{constructor(e){this.errorHandler=null;this.rejectionHandler=null;this.resourceErrorHandler=null;this.buffer=new f(e.maxErrors)}start(){this.errorHandler=e=>{this.buffer.push({timestamp:Date.now(),message:e.message||"Unknown error",stack:e.error?.stack||null,filename:e.filename||null,lineno:e.lineno||null,colno:e.colno||null,type:"uncaught",context:this.getContext(e.error)})},this.rejectionHandler=e=>{let t=e.reason;this.buffer.push({timestamp:Date.now(),message:t instanceof Error?t.message:String(t),stack:t instanceof Error&&t.stack||null,filename:null,lineno:null,colno:null,type:"unhandledrejection",context:t instanceof Error?this.getContext(t):null})},this.resourceErrorHandler=e=>{let t=e.target;!t||!(t instanceof HTMLElement)||(t.tagName==="SCRIPT"||t.tagName==="LINK"||t.tagName==="IMG")&&this.buffer.push({timestamp:Date.now(),message:`Failed to load ${t.tagName.toLowerCase()}: ${t.src||t.href||"unknown"}`,stack:null,filename:t.src||t.href||null,lineno:null,colno:null,type:"resource",context:null})},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.rejectionHandler),window.addEventListener("error",this.resourceErrorHandler,!0)}stop(){this.errorHandler&&(window.removeEventListener("error",this.errorHandler),this.errorHandler=null),this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null),this.resourceErrorHandler&&(window.removeEventListener("error",this.resourceErrorHandler,!0),this.resourceErrorHandler=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}getContext(e){if(!e)return null;try{let t=e.stack;if(!t)return null;let n=t.match(/at\s+(.+?)\s+\(/);return n?n[1]:null}catch{return null}}};var S=class{constructor(e){this.listeners=[];this.buffer=new f(e.maxUserActions)}start(){this.addListener("click",r=>{let s=r.target;this.buffer.push({timestamp:Date.now(),type:"click",target:b(s),metadata:{x:r.clientX,y:r.clientY,button:r.button}})},!0),this.addListener("input",r=>{let s=r.target,a=s.type==="password"||s.type==="hidden"||s.name?.toLowerCase().includes("password")||s.name?.toLowerCase().includes("token")||s.name?.toLowerCase().includes("secret");this.buffer.push({timestamp:Date.now(),type:"input",target:b(s),value:a?"[REDACTED]":s.value?.slice(0,50)||"",metadata:{inputType:s.type,name:s.name}})},!0),this.addListener("scroll",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"scroll",target:"window",metadata:{scrollX:window.scrollX,scrollY:window.scrollY,scrollHeight:document.documentElement.scrollHeight}})},500)),this.addListener("resize",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"resize",target:"window",metadata:{width:window.innerWidth,height:window.innerHeight}})},500)),this.addListener("visibilitychange",()=>{this.buffer.push({timestamp:Date.now(),type:"visibility",target:"document",value:document.visibilityState})}),this.addListener("copy",r=>{this.buffer.push({timestamp:Date.now(),type:"copy",target:b(r.target)})}),this.addListener("paste",r=>{this.buffer.push({timestamp:Date.now(),type:"paste",target:b(r.target)})});let e=history.pushState.bind(history),t=history.replaceState.bind(history),n=this;history.pushState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"pushState"}}),e(...r)},history.replaceState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"replaceState"}}),t(...r)},this.addListener("popstate",()=>{this.buffer.push({timestamp:Date.now(),type:"navigation",target:window.location.href,metadata:{method:"popstate"}})})}stop(){for(let{event:e,handler:t,options:n}of this.listeners)(e==="visibilitychange"?document:window).removeEventListener(e,t,n);this.listeners=[]}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}addListener(e,t,n){(e==="visibilitychange"?document:window).addEventListener(e,t,n),this.listeners.push({event:e,handler:t,options:n})}throttle(e,t){let n=0;return()=>{let r=Date.now();r-n>=t&&(n=r,e())}}};var R=class{collect(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset(),screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,cookiesEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,online:navigator.onLine,hardwareConcurrency:navigator.hardwareConcurrency||0,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,connection:this.getConnection(),memory:this.getMemory()}}getConnection(){let e=navigator.connection;return e?{effectiveType:e.effectiveType||"unknown",downlink:e.downlink||0,rtt:e.rtt||0,saveData:e.saveData||!1}:null}getMemory(){let e=performance.memory;return e?{jsHeapSizeLimit:e.jsHeapSizeLimit,totalJSHeapSize:e.totalJSHeapSize,usedJSHeapSize:e.usedJSHeapSize}:null}};var j=class{constructor(){this.lcp=null;this.fid=null;this.cls=null;this.observers=[]}start(){this.observeLCP(),this.observeFID(),this.observeCLS()}stop(){for(let e of this.observers)e.disconnect();this.observers=[]}collect(){let e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("paint"),n=performance.getEntriesByType("resource"),r=t.find(a=>a.name==="first-paint"),s=t.find(a=>a.name==="first-contentful-paint");return{navigationTiming:e?{redirectTime:e.redirectEnd-e.redirectStart,dnsTime:e.domainLookupEnd-e.domainLookupStart,tcpTime:e.connectEnd-e.connectStart,tlsTime:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,downloadTime:e.responseEnd-e.responseStart,domParsing:e.domInteractive-e.responseEnd,domContentLoaded:e.domContentLoadedEventEnd-e.domContentLoadedEventStart,loadEvent:e.loadEventEnd-e.loadEventStart,totalTime:e.loadEventEnd-e.startTime}:{},resourceCount:n.length,totalTransferSize:n.reduce((a,c)=>a+(c.transferSize||0),0),domContentLoaded:e?e.domContentLoadedEventEnd-e.startTime:null,loadComplete:e?e.loadEventEnd-e.startTime:null,firstPaint:r?r.startTime:null,firstContentfulPaint:s?s.startTime:null,largestContentfulPaint:this.lcp,firstInputDelay:this.fid,cumulativeLayoutShift:this.cls,timeToInteractive:null}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.lcp=n[n.length-1].startTime)});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch{}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.fid=n[0].processingStart-n[0].startTime)});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch{}}observeCLS(){try{let e=0,t=new PerformanceObserver(n=>{for(let r of n.getEntries())r.hadRecentInput||(e+=r.value);this.cls=e});t.observe({type:"layout-shift",buffered:!0}),this.observers.push(t)}catch{}}};var L=class{constructor(e){this.config=e}collect(){return{localStorage:this.config.captureLocalStorage?this.collectStorage(localStorage):{},sessionStorage:this.config.captureSessionStorage?this.collectStorage(sessionStorage):{},cookies:this.config.captureCookies?this.collectCookies():[]}}collectStorage(e){let t={};try{for(let n=0;n<e.length;n++){let r=e.key(n);if(!r)continue;if(this.config.sensitiveFields.some(a=>r.toLowerCase().includes(a.toLowerCase())))t[r]="[REDACTED]";else{let a=e.getItem(r)||"";t[r]=a.length>500?a.slice(0,500)+"...[truncated]":a}}}catch{}return t}collectCookies(){try{return document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean)}catch{return[]}}};var k=class{async capture(){try{let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;let n=window.innerWidth,r=window.innerHeight,s=Math.min(window.devicePixelRatio,2);e.width=n*s,e.height=r*s,t.scale(s,s);let a=this.domToSvg(n,r);return a?new Promise(c=>{let i=new Image;i.onload=()=>{t.drawImage(i,0,0);try{let u=e.toDataURL("image/png",.8);c(u)}catch{c(null)}},i.onerror=()=>c(null),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,setTimeout(()=>c(null),3e3)}):null}catch{return null}}domToSvg(e,t){try{let n=document.documentElement.cloneNode(!0);n.querySelectorAll("script").forEach(a=>a.remove());let s=new XMLSerializer().serializeToString(n);return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}">
5
5
  <foreignObject width="100%" height="100%">
6
6
  ${s}
7
7
  </foreignObject>
8
- </svg>`}catch{return null}}captureHtml(){try{let e=document.documentElement.cloneNode(!0);return e.querySelectorAll("script").forEach(r=>r.remove()),e.querySelectorAll('input[type="password"], input[name*="token"], input[name*="secret"]').forEach(r=>r.value="[REDACTED]"),e.outerHTML.slice(0,5e5)}catch{return null}}};var k=class{collect(){let e={},t=!1,n=window.posthog;if(n?.getFeatureFlag)try{let c=n.getAllFlags?.()||n.getFeatureFlags?.()||{};e.posthog=c,t=!0}catch{}let r=window.ldclient;if(r?.allFlags)try{e.launchdarkly=r.allFlags(),t=!0}catch{}let s=window.statsig;if(s?.getExperiment||s?.checkGate)try{e.statsig={detected:!0},t=!0}catch{}let a=window.unleash;if(a?.getAllToggles)try{e.unleash=a.getAllToggles(),t=!0}catch{}return t?e:null}};var L=class{constructor(){this.mediaRecorder=null;this.chunks=[];this.stream=null;this.recording=!1}get isRecording(){return this.recording}async start(){if(!this.recording)try{this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0}),this.chunks=[],this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:this.getSupportedMimeType(),videoBitsPerSecond:1e6}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks()},this.stream.getVideoTracks()[0].onended=()=>{this.stop()},this.mediaRecorder.start(1e3),this.recording=!0}catch{this.recording=!1,this.stream=null,this.mediaRecorder=null}}stop(){return new Promise(e=>{if(!this.mediaRecorder||!this.recording){e(null);return}this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks();let t=new Blob(this.chunks,{type:this.getSupportedMimeType()});this.chunks=[],e(t)},this.mediaRecorder.stop()})}stopTracks(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null)}getSupportedMimeType(){let e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(let t of e)if(MediaRecorder.isTypeSupported(t))return t;return"video/webm"}};var C=class{constructor(e,t,n){this.container=null;this.config=e,this.onReport=t,this.screenRecorder=n}mount(){this.container||(this.container=document.createElement("div"),this.container.id="bug-jar-widget",this.container.innerHTML=this.getWidgetHTML(),document.body.appendChild(this.container),this.injectStyles(),this.bindEvents())}unmount(){this.container&&(this.container.remove(),this.container=null);let e=document.getElementById("bug-jar-styles");e&&e.remove()}getWidgetHTML(){return`
9
- <button class="bug-jar-trigger ${`bug-jar--${this.config.uiPosition}`}" aria-label="${this.config.uiLabel}">
8
+ </svg>`}catch{return null}}captureHtml(){try{let e=document.documentElement.cloneNode(!0);return e.querySelectorAll("script").forEach(r=>r.remove()),e.querySelectorAll('input[type="password"], input[name*="token"], input[name*="secret"]').forEach(r=>r.value="[REDACTED]"),e.outerHTML.slice(0,5e5)}catch{return null}}};var C=class{collect(){let e={},t=!1,n=window.posthog;if(n?.getFeatureFlag)try{let c=n.getAllFlags?.()||n.getFeatureFlags?.()||{};e.posthog=c,t=!0}catch{}let r=window.ldclient;if(r?.allFlags)try{e.launchdarkly=r.allFlags(),t=!0}catch{}let s=window.statsig;if(s?.getExperiment||s?.checkGate)try{e.statsig={detected:!0},t=!0}catch{}let a=window.unleash;if(a?.getAllToggles)try{e.unleash=a.getAllToggles(),t=!0}catch{}return t?e:null}};var T=class{constructor(){this.mediaRecorder=null;this.chunks=[];this.stream=null;this.recording=!1}get isRecording(){return this.recording}async start(){if(!this.recording)try{this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0}),this.chunks=[],this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:this.getSupportedMimeType(),videoBitsPerSecond:1e6}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks()},this.stream.getVideoTracks()[0].onended=()=>{this.stop()},this.mediaRecorder.start(1e3),this.recording=!0}catch{this.recording=!1,this.stream=null,this.mediaRecorder=null}}stop(){return new Promise(e=>{if(!this.mediaRecorder||!this.recording){e(null);return}this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks();let t=new Blob(this.chunks,{type:this.getSupportedMimeType()});this.chunks=[],e(t)},this.mediaRecorder.stop()})}stopTracks(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null)}getSupportedMimeType(){let e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(let t of e)if(MediaRecorder.isTypeSupported(t))return t;return"video/webm"}};var B=class{constructor(e,t,n){this.container=null;this.config=e,this.onReport=t,this.screenRecorder=n}mount(){if(this.container)return;let e=typeof window<"u"&&window.innerWidth<=768;if(this.config.hideOnMobile&&e)return;this.container=document.createElement("div"),this.container.id="bug-jar-widget";let t=e&&this.config.uiCompactOnMobile;this.container.innerHTML=this.getWidgetHTML(t),this.container.dataset.compact=String(t),document.body.appendChild(this.container),this.injectStyles(t),this.bindEvents(),this.makeDraggable()}unmount(){this.container&&(this.container.remove(),this.container=null);let e=document.getElementById("bug-jar-styles");e&&e.remove()}getWidgetHTML(e=!1){let n=`bug-jar--${this.config.uiPosition}`,r=e?" bug-jar-trigger--compact":"";return e?`
9
+ <button class="bug-jar-trigger ${n}${r}" aria-label="${this.config.uiLabel}">
10
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
+ <path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 116 0v1"/>
12
+ <path d="M12 20c-3.3 0-6-2.7-6-6v-3a6 6 0 0112 0v3c0 3.3-2.7 6-6 6z"/>
13
+ <path d="M12 20v2M6 13H2M22 13h-4M6 17l-2 2M18 17l2 2M6 9l-2-2M18 9l2-2"/>
14
+ </svg>
15
+ </button>
16
+ `:`
17
+ <button class="bug-jar-trigger ${n}" aria-label="${this.config.uiLabel}">
10
18
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
19
  <path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 116 0v1"/>
12
20
  <path d="M12 20c-3.3 0-6-2.7-6-6v-3a6 6 0 0112 0v3c0 3.3-2.7 6-6 6z"/>
@@ -40,7 +48,7 @@
40
48
  <div class="bug-jar-status" hidden></div>
41
49
  </div>
42
50
  </div>
43
- `}bindEvents(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger"),t=this.container.querySelector(".bug-jar-modal"),n=this.container.querySelector(".bug-jar-modal-backdrop"),r=this.container.querySelector(".bug-jar-close"),s=this.container.querySelector(".bug-jar-cancel"),a=this.container.querySelector(".bug-jar-submit"),c=this.container.querySelector("#bug-jar-description"),i=this.container.querySelector(".bug-jar-status"),u=this.container.querySelector(".bug-jar-record-btn"),f=this.container.querySelector(".bug-jar-recording-status"),b=()=>{t.hidden=!1,c.focus(),this.updateRecordingUI(u,f)},p=()=>{t.hidden=!0,c.value="",i.hidden=!0};e.addEventListener("click",b),n.addEventListener("click",p),r.addEventListener("click",p),s.addEventListener("click",p),u.addEventListener("click",async()=>{this.screenRecorder.isRecording||(p(),await this.screenRecorder.start(),this.updateTriggerForRecording(e))}),a.addEventListener("click",async()=>{let U=c.value.trim();if(!U){c.classList.add("bug-jar-error");return}c.classList.remove("bug-jar-error"),a.setAttribute("disabled","true"),a.textContent="Capturando...",i.hidden=!0;try{await this.onReport(U),i.textContent="\u2713 Relat\xF3rio baixado como .zip!",i.className="bug-jar-status bug-jar-status--success",i.hidden=!1,this.resetTrigger(e),setTimeout(p,2e3)}catch(M){i.textContent=`Erro: ${M instanceof Error?M.message:"Falha ao gerar relat\xF3rio"}`,i.className="bug-jar-status bug-jar-status--error",i.hidden=!1}finally{a.removeAttribute("disabled"),a.textContent="Enviar Relat\xF3rio"}}),c.addEventListener("input",()=>{c.classList.remove("bug-jar-error")})}updateRecordingUI(e,t){if(this.screenRecorder.isRecording){e.classList.add("bug-jar-record-btn--active"),t.hidden=!1;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravando...")}else{e.classList.remove("bug-jar-record-btn--active"),t.hidden=!0;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravar Tela")}}updateTriggerForRecording(e){e.classList.add("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent="\u23FA Gravando...")}resetTrigger(e){e.classList.remove("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent=this.config.uiLabel)}injectStyles(){if(document.getElementById("bug-jar-styles"))return;let e=document.createElement("style");e.id="bug-jar-styles",e.textContent=`
51
+ `}bindEvents(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger"),t=this.container.querySelector(".bug-jar-modal"),n=this.container.querySelector(".bug-jar-modal-backdrop"),r=this.container.querySelector(".bug-jar-close"),s=this.container.querySelector(".bug-jar-cancel"),a=this.container.querySelector(".bug-jar-submit"),c=this.container.querySelector("#bug-jar-description"),i=this.container.querySelector(".bug-jar-status"),u=this.container.querySelector(".bug-jar-record-btn"),p=this.container.querySelector(".bug-jar-recording-status"),l=()=>{this.container?.dataset.compact==="true"&&this.container.querySelector(".bug-jar-trigger")?.classList.add("bug-jar-trigger--expanded"),t&&(t.hidden=!1),c?.focus(),this.updateRecordingUI(u,p)},d=()=>{t&&(t.hidden=!0),c&&(c.value=""),i&&(i.hidden=!0),this.container?.dataset.compact==="true"&&this.container.querySelector(".bug-jar-trigger")?.classList.remove("bug-jar-trigger--expanded")};e.addEventListener("click",l),n&&n.addEventListener("click",d),r&&r.addEventListener("click",d),s&&s.addEventListener("click",d),u?.addEventListener("click",async()=>{this.screenRecorder.isRecording||(d(),await this.screenRecorder.start(),this.updateTriggerForRecording(e))}),a?.addEventListener("click",async()=>{let g=c?.value.trim();if(!(!g||!c||!a||!i)){c.classList.remove("bug-jar-error"),a.setAttribute("disabled","true"),a.textContent="Capturando...",i.hidden=!0;try{await this.onReport(g),i.textContent="\u2713 Relat\xF3rio baixado como .zip!",i.className="bug-jar-status bug-jar-status--success",i.hidden=!1,this.resetTrigger(e),setTimeout(d,2e3)}catch(y){i.textContent=`Erro: ${y instanceof Error?y.message:"Falha ao gerar relat\xF3rio"}`,i.className="bug-jar-status bug-jar-status--error",i.hidden=!1}finally{a.removeAttribute("disabled"),a.textContent="Enviar Relat\xF3rio"}}}),c?.addEventListener("input",()=>{c?.classList.remove("bug-jar-error")})}updateRecordingUI(e,t){if(!(!e||!t))if(this.screenRecorder.isRecording){e.classList.add("bug-jar-record-btn--active"),t.hidden=!1;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravando...")}else{e.classList.remove("bug-jar-record-btn--active"),t.hidden=!0;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravar Tela")}}updateTriggerForRecording(e){e.classList.add("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent="\u23FA Gravando...")}resetTrigger(e){e.classList.remove("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent=this.config.uiLabel)}makeDraggable(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger");if(!e)return;let t=!1,n=0,r=0,s=0,a=0,c=!1,i=l=>{let d="touches"in l?l.touches[0]:l;n=d.clientX,r=d.clientY;let g=e.getBoundingClientRect();s=g.left,a=g.top,c=!1,t=!0,e.classList.add("bug-jar-trigger--dragging"),document.addEventListener("mousemove",u),document.addEventListener("mouseup",p),document.addEventListener("touchmove",u,{passive:!1}),document.addEventListener("touchend",p)},u=l=>{if(!t)return;l.preventDefault();let d="touches"in l?l.touches[0]:l,g=d.clientX-n,y=d.clientY-r;(Math.abs(g)>5||Math.abs(y)>5)&&(c=!0);let q=s+g,D=a+y;e.style.position="fixed",e.style.left=`${q}px`,e.style.top=`${D}px`,e.style.right="auto",e.style.bottom="auto",e.classList.remove("bug-jar--bottom-right","bug-jar--bottom-left","bug-jar--top-right","bug-jar--top-left")},p=()=>{t=!1,e.classList.remove("bug-jar-trigger--dragging"),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",u),document.removeEventListener("touchend",p),c&&(e.style.cursor="")};e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!0})}injectStyles(e=!1){if(document.getElementById("bug-jar-styles"))return;let t=document.createElement("style");t.id="bug-jar-styles",t.textContent=`
44
52
  #bug-jar-widget {
45
53
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
46
54
  font-size: 14px;
@@ -64,6 +72,8 @@
64
72
  cursor: pointer;
65
73
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
66
74
  transition: transform 0.15s, box-shadow 0.15s, background 0.3s;
75
+ user-select: none;
76
+ touch-action: none;
67
77
  }
68
78
 
69
79
  .bug-jar-trigger:hover {
@@ -71,6 +81,31 @@
71
81
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
72
82
  }
73
83
 
84
+ .bug-jar-trigger--compact {
85
+ padding: 12px;
86
+ border-radius: 50%;
87
+ width: 44px;
88
+ height: 44px;
89
+ justify-content: center;
90
+ }
91
+
92
+ .bug-jar-trigger--compact span {
93
+ display: none;
94
+ }
95
+
96
+ .bug-jar-trigger--expanded {
97
+ padding: 10px 16px;
98
+ width: auto;
99
+ height: auto;
100
+ border-radius: 24px;
101
+ }
102
+
103
+ .bug-jar-trigger--dragging {
104
+ cursor: grabbing;
105
+ transform: scale(1.1);
106
+ box-shadow: 0 8px 25px rgba(0,0,0,0.3);
107
+ }
108
+
74
109
  .bug-jar-trigger--recording {
75
110
  background: #dc2626;
76
111
  animation: bug-jar-pulse 1.5s infinite;
@@ -262,5 +297,5 @@
262
297
 
263
298
  .bug-jar-status--success { color: #16a34a; background: #f0fdf4; }
264
299
  .bug-jar-status--error { color: #dc2626; background: #fef2f2; }
265
- `,document.head.appendChild(e)}};function T(o){let e=[];e.push(`Bug Report: ${o.id}`),e.push(`URL: ${o.url}`),e.push(`Time: ${new Date(o.timestamp).toISOString()}`),e.push(`User Description: "${o.userDescription}"`),e.push(""),e.push("## Environment"),e.push(`Browser: ${N(o.environment.userAgent)}`),e.push(`Viewport: ${o.environment.viewportWidth}x${o.environment.viewportHeight}`),e.push(`Connection: ${o.environment.connection?.effectiveType||"unknown"}`),e.push(`Online: ${o.environment.online}`),e.push(""),e.push("## Network Activity");let t=o.network.length,n=o.network.filter(i=>i.error||i.status&&i.status>=400),r=o.network.filter(i=>i.duration&&i.duration>3e3);if(e.push(`Total requests: ${t}`),n.length>0){e.push(`Failed requests (${n.length}):`);for(let i of n)e.push(` - ${i.method} ${i.url} \u2192 ${i.error||`HTTP ${i.status}`}`)}if(r.length>0){e.push(`Slow requests >3s (${r.length}):`);for(let i of r)e.push(` - ${i.method} ${i.url} (${Math.round(i.duration)}ms)`)}if(e.push(""),e.push("## Errors"),o.errors.length===0)e.push("No errors captured.");else{e.push(`Total errors: ${o.errors.length}`);for(let i of o.errors)e.push(` - [${i.type}] ${i.message}`),i.filename&&e.push(` at ${i.filename}:${i.lineno}:${i.colno}`)}e.push(""),e.push("## Console");let s={log:0,warn:0,error:0,info:0,debug:0};for(let i of o.console)s[i.level]++;e.push(`Logs: ${s.log}, Warnings: ${s.warn}, Errors: ${s.error}, Info: ${s.info}, Debug: ${s.debug}`);let a=o.console.filter(i=>i.level==="error");if(a.length>0){e.push("Console errors:");for(let i of a)e.push(` - ${i.args.map(u=>typeof u=="string"?u:JSON.stringify(u)).join(" ")}`)}e.push(""),e.push("## User Actions"),e.push(`Total actions: ${o.userActions.length}`);let c={};for(let i of o.userActions)c[i.type]=(c[i.type]||0)+1;for(let[i,u]of Object.entries(c))e.push(` - ${i}: ${u}`);if(o.userActions.length>0){let i=o.userActions[0].timestamp,f=((o.userActions[o.userActions.length-1].timestamp-i)/1e3).toFixed(1);e.push(`Session duration: ${f}s`)}if(e.push(""),o.performance){e.push("## Performance");let i=o.performance;i.largestContentfulPaint&&e.push(`LCP: ${Math.round(i.largestContentfulPaint)}ms`),i.firstInputDelay&&e.push(`FID: ${Math.round(i.firstInputDelay)}ms`),i.cumulativeLayoutShift!==null&&e.push(`CLS: ${i.cumulativeLayoutShift?.toFixed(3)}`),i.loadComplete&&e.push(`Page Load: ${Math.round(i.loadComplete)}ms`),e.push(`Resources: ${i.resourceCount} (${J(i.totalTransferSize)})`)}return e.join(`
266
- `)}function N(o){return o.includes("Chrome/")?`Chrome ${o.match(/Chrome\/(\d+)/)?.[1]||""}`:o.includes("Firefox/")?`Firefox ${o.match(/Firefox\/(\d+)/)?.[1]||""}`:o.includes("Safari/")&&!o.includes("Chrome")?`Safari ${o.match(/Version\/(\d+)/)?.[1]||""}`:o.slice(0,50)}function J(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/(1024*1024)).toFixed(1)}MB`}async function B(o,e){let t=[],n=JSON.stringify(o,null,2);t.push({name:"report.json",content:new TextEncoder().encode(n)});let r=T(o);if(t.push({name:"summary.md",content:new TextEncoder().encode(r)}),o.screenshot){let s=X(o.screenshot);s&&t.push({name:"screenshot.png",content:s})}if(e){let s=new Uint8Array(await e.arrayBuffer());t.push({name:"recording.webm",content:s})}return O(t)}function X(o){try{let e=o.split(",")[1];if(!e)return null;let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch{return null}}function O(o){let e=[],t=[],n=0;for(let i of o){let u=new TextEncoder().encode(i.name),f=V(i.content),b=_(u,i.content.length,f);e.push(b),e.push(u),e.push(i.content);let p=W(u,i.content.length,f,n);t.push(p),t.push(u),n+=b.length+u.length+i.content.length}let r=n,s=0;for(let i of t)s+=i.length;let a=G(o.length,s,r),c=[...e,...t,a].map(i=>i.buffer);return new Blob(c,{type:"application/zip"})}function _(o,e,t){let n=new Uint8Array(30),r=new DataView(n.buffer);return r.setUint32(0,67324752,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,0,!0),r.setUint16(10,0,!0),r.setUint16(12,0,!0),r.setUint32(14,t,!0),r.setUint32(18,e,!0),r.setUint32(22,e,!0),r.setUint16(26,o.length,!0),r.setUint16(28,0,!0),n}function W(o,e,t,n){let r=new Uint8Array(46),s=new DataView(r.buffer);return s.setUint32(0,33639248,!0),s.setUint16(4,20,!0),s.setUint16(6,20,!0),s.setUint16(8,0,!0),s.setUint16(10,0,!0),s.setUint16(12,0,!0),s.setUint16(14,0,!0),s.setUint32(16,t,!0),s.setUint32(20,e,!0),s.setUint32(24,e,!0),s.setUint16(28,o.length,!0),s.setUint16(30,0,!0),s.setUint16(32,0,!0),s.setUint16(34,0,!0),s.setUint16(36,0,!0),s.setUint32(38,0,!0),s.setUint32(42,n,!0),r}function G(o,e,t){let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,o,!0),r.setUint16(10,o,!0),r.setUint32(12,e,!0),r.setUint32(16,t,!0),r.setUint16(20,0,!0),n}function V(o){let e=4294967295;for(let t=0;t<o.length;t++){e^=o[t];for(let n=0;n<8;n++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}var Z="0.2.0",Y={maxNetworkEntries:100,maxConsoleEntries:200,maxUserActions:150,maxErrors:50,captureScreenshot:!0,captureHtmlSnapshot:!0,captureCookies:!0,captureLocalStorage:!0,captureSessionStorage:!0,capturePerformance:!0,captureWebVitals:!0,captureMemory:!0,captureConnectivity:!0,sensitiveFields:["password","token","secret","authorization","cookie","session","credit_card","cvv","ssn","cpf"],endpoint:void 0,onCapture:void 0,ui:!0,uiPosition:"bottom-right",uiLabel:"Reportar Bug"},m=class{constructor(e={}){this.ui=null;this.started=!1;this.config={...Y,...e},this.network=new y(this.config),this.console=new v(this.config),this.errors=new w(this.config),this.userActions=new E(this.config),this.environment=new x,this.performance=new S,this.storage=new R(this.config),this.screenshot=new j,this.featureFlags=new k,this.screenRecorder=new L}start(){this.started||(this.started=!0,this.network.start(),this.console.start(),this.errors.start(),this.userActions.start(),this.config.captureWebVitals&&this.performance.start(),this.config.ui&&(this.ui=new C(this.config,e=>this.captureAndExport(e),this.screenRecorder),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.ui?.mount()):this.ui.mount()))}stop(){this.started&&(this.started=!1,this.network.stop(),this.console.stop(),this.errors.stop(),this.userActions.stop(),this.performance.stop(),this.ui?.unmount())}async startRecording(){await this.screenRecorder.start()}get isRecording(){return this.screenRecorder.isRecording}async capture(e=""){let t={id:g(),timestamp:Date.now(),url:window.location.href,title:document.title,userDescription:e,environment:this.environment.collect(),network:this.network.getEntries(),console:this.console.getEntries(),errors:this.errors.getEntries(),userActions:this.userActions.getEntries(),performance:this.config.capturePerformance?this.performance.collect():null,storage:this.storage.collect(),screenshot:this.config.captureScreenshot?await this.screenshot.capture():null,htmlSnapshot:this.config.captureHtmlSnapshot?this.screenshot.captureHtml():null,featureFlags:this.featureFlags.collect(),metadata:{},version:Z};return this.config.onCapture&&this.config.onCapture(t),t}async captureAndExport(e=""){let t=await this.screenRecorder.stop(),n=await this.capture(e);if(this.config.endpoint)if(t){let r=new FormData;r.append("report",JSON.stringify(n)),r.append("video",t,"recording.webm"),await fetch(this.config.endpoint,{method:"POST",body:r})}else await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});else{let r=await B(n,t),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`bug-report-${n.id}.zip`,a.click(),URL.revokeObjectURL(s)}return n}getReport(){return this.capture()}};function $(o={}){let e=new m(o);return e.start(),e}typeof window<"u"&&(window.BugJar={BugJar:m,init:$});var K=m;0&&(module.exports={BugJar,exportAsZip,generateSummary,init});
300
+ `,document.head.appendChild(t)}};function H(o){let e=[];e.push(`Bug Report: ${o.id}`),e.push(`URL: ${o.url}`),e.push(`Time: ${new Date(o.timestamp).toISOString()}`),e.push(`User Description: "${o.userDescription}"`),e.push(""),e.push("## Environment"),e.push(`Browser: ${O(o.environment.userAgent)}`),e.push(`Viewport: ${o.environment.viewportWidth}x${o.environment.viewportHeight}`),e.push(`Connection: ${o.environment.connection?.effectiveType||"unknown"}`),e.push(`Online: ${o.environment.online}`),e.push(""),e.push("## Network Activity");let t=o.network.length,n=o.network.filter(i=>i.error||i.status&&i.status>=400),r=o.network.filter(i=>i.duration&&i.duration>3e3);if(e.push(`Total requests: ${t}`),n.length>0){e.push(`Failed requests (${n.length}):`);for(let i of n)e.push(` - ${i.method} ${i.url} \u2192 ${i.error||`HTTP ${i.status}`}`)}if(r.length>0){e.push(`Slow requests >3s (${r.length}):`);for(let i of r)e.push(` - ${i.method} ${i.url} (${Math.round(i.duration)}ms)`)}if(e.push(""),e.push("## Errors"),o.errors.length===0)e.push("No errors captured.");else{e.push(`Total errors: ${o.errors.length}`);for(let i of o.errors)e.push(` - [${i.type}] ${i.message}`),i.filename&&e.push(` at ${i.filename}:${i.lineno}:${i.colno}`)}e.push(""),e.push("## Console");let s={log:0,warn:0,error:0,info:0,debug:0};for(let i of o.console)s[i.level]++;e.push(`Logs: ${s.log}, Warnings: ${s.warn}, Errors: ${s.error}, Info: ${s.info}, Debug: ${s.debug}`);let a=o.console.filter(i=>i.level==="error");if(a.length>0){e.push("Console errors:");for(let i of a)e.push(` - ${i.args.map(u=>typeof u=="string"?u:JSON.stringify(u)).join(" ")}`)}e.push(""),e.push("## User Actions"),e.push(`Total actions: ${o.userActions.length}`);let c={};for(let i of o.userActions)c[i.type]=(c[i.type]||0)+1;for(let[i,u]of Object.entries(c))e.push(` - ${i}: ${u}`);if(o.userActions.length>0){let i=o.userActions[0].timestamp,p=((o.userActions[o.userActions.length-1].timestamp-i)/1e3).toFixed(1);e.push(`Session duration: ${p}s`)}if(e.push(""),o.performance){e.push("## Performance");let i=o.performance;i.largestContentfulPaint&&e.push(`LCP: ${Math.round(i.largestContentfulPaint)}ms`),i.firstInputDelay&&e.push(`FID: ${Math.round(i.firstInputDelay)}ms`),i.cumulativeLayoutShift!==null&&e.push(`CLS: ${i.cumulativeLayoutShift?.toFixed(3)}`),i.loadComplete&&e.push(`Page Load: ${Math.round(i.loadComplete)}ms`),e.push(`Resources: ${i.resourceCount} (${J(i.totalTransferSize)})`)}return e.join(`
301
+ `)}function O(o){return o.includes("Chrome/")?`Chrome ${o.match(/Chrome\/(\d+)/)?.[1]||""}`:o.includes("Firefox/")?`Firefox ${o.match(/Firefox\/(\d+)/)?.[1]||""}`:o.includes("Safari/")&&!o.includes("Chrome")?`Safari ${o.match(/Version\/(\d+)/)?.[1]||""}`:o.slice(0,50)}function J(o){return o<1024?`${o}B`:o<1024*1024?`${(o/1024).toFixed(1)}KB`:`${(o/(1024*1024)).toFixed(1)}MB`}async function M(o,e){let t=[],n=JSON.stringify(o,null,2);t.push({name:"report.json",content:new TextEncoder().encode(n)});let r=H(o);if(t.push({name:"summary.md",content:new TextEncoder().encode(r)}),o.screenshot){let s=_(o.screenshot);s&&t.push({name:"screenshot.png",content:s})}if(e){let s=new Uint8Array(await e.arrayBuffer());t.push({name:"recording.webm",content:s})}return W(t)}function _(o){try{let e=o.split(",")[1];if(!e)return null;let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch{return null}}function W(o){let e=[],t=[],n=0;for(let i of o){let u=new TextEncoder().encode(i.name),p=Z(i.content),l=G(u,i.content.length,p);e.push(l),e.push(u),e.push(i.content);let d=V(u,i.content.length,p,n);t.push(d),t.push(u),n+=l.length+u.length+i.content.length}let r=n,s=0;for(let i of t)s+=i.length;let a=Y(o.length,s,r),c=[...e,...t,a].map(i=>i.buffer);return new Blob(c,{type:"application/zip"})}function G(o,e,t){let n=new Uint8Array(30),r=new DataView(n.buffer);return r.setUint32(0,67324752,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,0,!0),r.setUint16(10,0,!0),r.setUint16(12,0,!0),r.setUint32(14,t,!0),r.setUint32(18,e,!0),r.setUint32(22,e,!0),r.setUint16(26,o.length,!0),r.setUint16(28,0,!0),n}function V(o,e,t,n){let r=new Uint8Array(46),s=new DataView(r.buffer);return s.setUint32(0,33639248,!0),s.setUint16(4,20,!0),s.setUint16(6,20,!0),s.setUint16(8,0,!0),s.setUint16(10,0,!0),s.setUint16(12,0,!0),s.setUint16(14,0,!0),s.setUint32(16,t,!0),s.setUint32(20,e,!0),s.setUint32(24,e,!0),s.setUint16(28,o.length,!0),s.setUint16(30,0,!0),s.setUint16(32,0,!0),s.setUint16(34,0,!0),s.setUint16(36,0,!0),s.setUint32(38,0,!0),s.setUint32(42,n,!0),r}function Y(o,e,t){let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,o,!0),r.setUint16(10,o,!0),r.setUint32(12,e,!0),r.setUint32(16,t,!0),r.setUint16(20,0,!0),n}function Z(o){let e=4294967295;for(let t=0;t<o.length;t++){e^=o[t];for(let n=0;n<8;n++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}var K="0.2.0",Q={maxNetworkEntries:100,maxConsoleEntries:200,maxUserActions:150,maxErrors:50,captureScreenshot:!0,captureHtmlSnapshot:!0,captureCookies:!0,captureLocalStorage:!0,captureSessionStorage:!0,capturePerformance:!0,captureWebVitals:!0,captureMemory:!0,captureConnectivity:!0,sensitiveFields:["password","token","secret","authorization","cookie","session","credit_card","cvv","ssn","cpf"],endpoint:void 0,onCapture:void 0,ui:!0,uiPosition:"bottom-right",uiLabel:"Reportar Bug"},v=class{constructor(e={}){this.ui=null;this.started=!1;this.config={...Q,...e},this.network=new w(this.config),this.console=new E(this.config),this.errors=new x(this.config),this.userActions=new S(this.config),this.environment=new R,this.performance=new j,this.storage=new L(this.config),this.screenshot=new k,this.featureFlags=new C,this.screenRecorder=new T}start(){this.started||(this.started=!0,this.network.start(),this.console.start(),this.errors.start(),this.userActions.start(),this.config.captureWebVitals&&this.performance.start(),this.config.ui&&(this.ui=new B(this.config,e=>this.captureAndExport(e),this.screenRecorder),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.ui?.mount()):this.ui.mount()))}stop(){this.started&&(this.started=!1,this.network.stop(),this.console.stop(),this.errors.stop(),this.userActions.stop(),this.performance.stop(),this.ui?.unmount())}async startRecording(){await this.screenRecorder.start()}get isRecording(){return this.screenRecorder.isRecording}async capture(e=""){let t={id:m(),timestamp:Date.now(),url:window.location.href,title:document.title,userDescription:e,environment:this.environment.collect(),network:this.network.getEntries(),console:this.console.getEntries(),errors:this.errors.getEntries(),userActions:this.userActions.getEntries(),performance:this.config.capturePerformance?this.performance.collect():null,storage:this.storage.collect(),screenshot:this.config.captureScreenshot?await this.screenshot.capture():null,htmlSnapshot:this.config.captureHtmlSnapshot?this.screenshot.captureHtml():null,featureFlags:this.featureFlags.collect(),metadata:{},version:K};return this.config.onCapture&&this.config.onCapture(t),t}async captureAndExport(e=""){let t=await this.screenRecorder.stop(),n=await this.capture(e);if(this.config.endpoint)if(t){let r=new FormData;r.append("report",JSON.stringify(n)),r.append("video",t,"recording.webm"),await fetch(this.config.endpoint,{method:"POST",body:r})}else await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});else{let r=await M(n,t),s=URL.createObjectURL(r),a=document.createElement("a");a.href=s,a.download=`bug-report-${n.id}.zip`,a.click(),URL.revokeObjectURL(s)}return n}getReport(){return this.capture()}};function $(o={}){let e=new v(o);return e.start(),e}typeof window<"u"&&(window.BugJar={BugJar:v,init:$});var ee=v;0&&(module.exports={BugJar,exportAsZip,generateSummary,init});
package/dist/index.mjs CHANGED
@@ -1,12 +1,20 @@
1
- function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function M(s,e=1e4){try{let t=new WeakSet,n=JSON.stringify(s,(r,o)=>{if(typeof o=="object"&&o!==null){if(t.has(o))return"[Circular]";t.add(o)}return o instanceof Error?{message:o.message,stack:o.stack,name:o.name}:typeof o=="function"?"[Function]":o instanceof HTMLElement?h(o):o});return n&&n.length>e?n.slice(0,e)+"...[truncated]":n||""}catch{return"[Unserializable]"}}function h(s){if(!s||!(s instanceof Element))return"unknown";let e=s.tagName.toLowerCase(),t=s.id?`#${s.id}`:"",n=s.className&&typeof s.className=="string"?`.${s.className.trim().split(/\s+/).join(".")}`:"",r=s.textContent?.trim().slice(0,30)||"",o=r?` "${r}"`:"";return`${e}${t}${n}${o}`}function d(s,e){if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(n=>d(n,e));let t={};for(let[n,r]of Object.entries(s))e.some(a=>n.toLowerCase().includes(a.toLowerCase()))?t[n]="[REDACTED]":typeof r=="object"&&r!==null?t[n]=d(r,e):t[n]=r;return t}var l=class{constructor(e){this.buffer=[];this.maxSize=e}push(e){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push(e)}getAll(){return[...this.buffer]}clear(){this.buffer=[]}get length(){return this.buffer.length}};var y=class{constructor(e){this.originalFetch=null;this.originalXhrOpen=null;this.originalXhrSend=null;this.originalXhrSetRequestHeader=null;this.originalSendBeacon=null;this.config=e,this.buffer=new l(e.maxNetworkEntries)}start(){this.interceptFetch(),this.interceptXHR(),this.interceptBeacon()}stop(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&this.originalXhrSend&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrOpen=null,this.originalXhrSend=null),this.originalXhrSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetRequestHeader,this.originalXhrSetRequestHeader=null),this.originalSendBeacon&&(Navigator.prototype.sendBeacon=this.originalSendBeacon,this.originalSendBeacon=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}interceptFetch(){this.originalFetch=window.fetch.bind(window);let e=this;window.fetch=async function(t,n){let r=performance.now(),o={id:g(),timestamp:Date.now(),method:(n?.method||"GET").toUpperCase(),url:typeof t=="string"?t:t instanceof URL?t.href:t.url,requestHeaders:e.extractHeaders(n?.headers),requestBody:e.safeParseBody(n?.body),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"fetch",error:null,initiator:e.getInitiator()};try{let a=await e.originalFetch(t,n);o.status=a.status,o.statusText=a.statusText,o.responseHeaders=e.extractResponseHeaders(a.headers),o.duration=performance.now()-r;let c=a.clone();try{let i=await c.text();o.responseSize=i.length,o.responseBody=e.safeParseJson(i)}catch{o.responseBody="[Unable to read response]"}return o.requestBody=d(o.requestBody,e.config.sensitiveFields),o.responseBody=d(o.responseBody,e.config.sensitiveFields),e.buffer.push(o),a}catch(a){throw o.duration=performance.now()-r,o.error=a instanceof Error?a.message:String(a),e.buffer.push(o),a}}}interceptXHR(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,this.originalXhrSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this.__bugjar_method=t,this.__bugjar_url=typeof n=="string"?n:n.href,this.__bugjar_headers={},e.originalXhrOpen.apply(this,arguments)},XMLHttpRequest.prototype.setRequestHeader=function(t,n){return this.__bugjar_headers&&(this.__bugjar_headers[t]=n),e.originalXhrSetRequestHeader.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=performance.now(),r={id:g(),timestamp:Date.now(),method:(this.__bugjar_method||"GET").toUpperCase(),url:this.__bugjar_url||"",requestHeaders:this.__bugjar_headers||{},requestBody:e.safeParseBody(t),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"xhr",error:null,initiator:e.getInitiator()};return this.addEventListener("load",function(){r.status=this.status,r.statusText=this.statusText,r.responseHeaders=e.parseXhrHeaders(this.getAllResponseHeaders()),r.duration=performance.now()-n,r.responseSize=this.responseText?.length||null,r.responseBody=e.safeParseJson(this.responseText),r.requestBody=d(r.requestBody,e.config.sensitiveFields),r.responseBody=d(r.responseBody,e.config.sensitiveFields),e.buffer.push(r)}),this.addEventListener("error",function(){r.duration=performance.now()-n,r.error="Network error",e.buffer.push(r)}),this.addEventListener("timeout",function(){r.duration=performance.now()-n,r.error="Request timeout",e.buffer.push(r)}),e.originalXhrSend.apply(this,arguments)}}interceptBeacon(){if(!navigator.sendBeacon)return;this.originalSendBeacon=navigator.sendBeacon.bind(navigator);let e=this;Navigator.prototype.sendBeacon=function(t,n){let r={id:g(),timestamp:Date.now(),method:"POST",url:typeof t=="string"?t:t.href,requestHeaders:{},requestBody:e.safeParseBody(n),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"beacon",error:null,initiator:"sendBeacon"};return r.requestBody=d(r.requestBody,e.config.sensitiveFields),e.buffer.push(r),e.originalSendBeacon(t,n)}}extractHeaders(e){let t={};return e&&(e instanceof Headers?e.forEach((n,r)=>{t[r]=n}):Array.isArray(e)?e.forEach(([n,r])=>{t[n]=r}):Object.assign(t,e)),t}extractResponseHeaders(e){let t={};return e.forEach((n,r)=>{t[r]=n}),t}parseXhrHeaders(e){let t={};return e&&e.trim().split(/[\r\n]+/).forEach(n=>{let r=n.split(": "),o=r.shift();o&&(t[o]=r.join(": "))}),t}safeParseBody(e){if(!e)return null;if(typeof e=="string")return this.safeParseJson(e);if(e instanceof FormData){let t={};return e.forEach((n,r)=>{t[r]=n instanceof File?`[File: ${n.name}]`:n}),t}return e instanceof URLSearchParams?Object.fromEntries(e.entries()):e instanceof Blob?`[Blob: ${e.size} bytes]`:e instanceof ArrayBuffer?`[ArrayBuffer: ${e.byteLength} bytes]`:String(e)}safeParseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return e.length>5e3?e.slice(0,5e3)+"...[truncated]":e}}getInitiator(){try{let e=new Error().stack;if(!e)return null;let t=e.split(`
2
- `);for(let n of t)if(!n.includes("bug-jar")&&n.includes("at "))return n.trim().slice(0,200);return null}catch{return null}}};var v=class{constructor(e){this.originals={};this.levels=["log","warn","error","info","debug"];this.buffer=new l(e.maxConsoleEntries)}start(){for(let e of this.levels){this.originals[e]=console[e].bind(console);let t=this;console[e]=(...n)=>{t.capture(e,n),t.originals[e](...n)}}}stop(){for(let e of this.levels)this.originals[e]&&(console[e]=this.originals[e]);this.originals={}}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}capture(e,t){let n={timestamp:Date.now(),level:e,args:t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:JSON.parse(M(r))),stack:e==="error"||e==="warn"?this.getStack():null};this.buffer.push(n)}getStack(){try{return new Error().stack?.split(`
1
+ function m(){return`${Date.now().toString(36)}-${Math.random().toString(36).slice(2,8)}`}function U(s,e=1e4){try{let t=new WeakSet,n=JSON.stringify(s,(r,o)=>{if(typeof o=="object"&&o!==null){if(t.has(o))return"[Circular]";t.add(o)}return o instanceof Error?{message:o.message,stack:o.stack,name:o.name}:typeof o=="function"?"[Function]":o instanceof HTMLElement?b(o):o});return n&&n.length>e?n.slice(0,e)+"...[truncated]":n||""}catch{return"[Unserializable]"}}function b(s){if(!s||!(s instanceof Element))return"unknown";let e=s.tagName.toLowerCase(),t=s.id?`#${s.id}`:"",n=s.className&&typeof s.className=="string"?`.${s.className.trim().split(/\s+/).join(".")}`:"",r=s.textContent?.trim().slice(0,30)||"",o=r?` "${r}"`:"";return`${e}${t}${n}${o}`}function h(s,e){if(!s||typeof s!="object")return s;if(Array.isArray(s))return s.map(n=>h(n,e));let t={};for(let[n,r]of Object.entries(s))e.some(a=>n.toLowerCase().includes(a.toLowerCase()))?t[n]="[REDACTED]":typeof r=="object"&&r!==null?t[n]=h(r,e):t[n]=r;return t}var f=class{constructor(e){this.buffer=[];this.maxSize=e}push(e){this.buffer.length>=this.maxSize&&this.buffer.shift(),this.buffer.push(e)}getAll(){return[...this.buffer]}clear(){this.buffer=[]}get length(){return this.buffer.length}};var w=class{constructor(e){this.originalFetch=null;this.originalXhrOpen=null;this.originalXhrSend=null;this.originalXhrSetRequestHeader=null;this.originalSendBeacon=null;this.config=e,this.buffer=new f(e.maxNetworkEntries)}start(){this.interceptFetch(),this.interceptXHR(),this.interceptBeacon()}stop(){this.originalFetch&&(window.fetch=this.originalFetch,this.originalFetch=null),this.originalXhrOpen&&this.originalXhrSend&&(XMLHttpRequest.prototype.open=this.originalXhrOpen,XMLHttpRequest.prototype.send=this.originalXhrSend,this.originalXhrOpen=null,this.originalXhrSend=null),this.originalXhrSetRequestHeader&&(XMLHttpRequest.prototype.setRequestHeader=this.originalXhrSetRequestHeader,this.originalXhrSetRequestHeader=null),this.originalSendBeacon&&(Navigator.prototype.sendBeacon=this.originalSendBeacon,this.originalSendBeacon=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}interceptFetch(){this.originalFetch=window.fetch.bind(window);let e=this;window.fetch=async function(t,n){let r=performance.now(),o={id:m(),timestamp:Date.now(),method:(n?.method||"GET").toUpperCase(),url:typeof t=="string"?t:t instanceof URL?t.href:t.url,requestHeaders:e.extractHeaders(n?.headers),requestBody:e.safeParseBody(n?.body),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"fetch",error:null,initiator:e.getInitiator()};try{let a=await e.originalFetch(t,n);o.status=a.status,o.statusText=a.statusText,o.responseHeaders=e.extractResponseHeaders(a.headers),o.duration=performance.now()-r;let c=a.clone();try{let i=await c.text();o.responseSize=i.length,o.responseBody=e.safeParseJson(i)}catch{o.responseBody="[Unable to read response]"}return o.requestBody=h(o.requestBody,e.config.sensitiveFields),o.responseBody=h(o.responseBody,e.config.sensitiveFields),e.buffer.push(o),a}catch(a){throw o.duration=performance.now()-r,o.error=a instanceof Error?a.message:String(a),e.buffer.push(o),a}}}interceptXHR(){this.originalXhrOpen=XMLHttpRequest.prototype.open,this.originalXhrSend=XMLHttpRequest.prototype.send,this.originalXhrSetRequestHeader=XMLHttpRequest.prototype.setRequestHeader;let e=this;XMLHttpRequest.prototype.open=function(t,n){return this.__bugjar_method=t,this.__bugjar_url=typeof n=="string"?n:n.href,this.__bugjar_headers={},e.originalXhrOpen.apply(this,arguments)},XMLHttpRequest.prototype.setRequestHeader=function(t,n){return this.__bugjar_headers&&(this.__bugjar_headers[t]=n),e.originalXhrSetRequestHeader.apply(this,arguments)},XMLHttpRequest.prototype.send=function(t){let n=performance.now(),r={id:m(),timestamp:Date.now(),method:(this.__bugjar_method||"GET").toUpperCase(),url:this.__bugjar_url||"",requestHeaders:this.__bugjar_headers||{},requestBody:e.safeParseBody(t),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"xhr",error:null,initiator:e.getInitiator()};return this.addEventListener("load",function(){r.status=this.status,r.statusText=this.statusText,r.responseHeaders=e.parseXhrHeaders(this.getAllResponseHeaders()),r.duration=performance.now()-n,r.responseSize=this.responseText?.length||null,r.responseBody=e.safeParseJson(this.responseText),r.requestBody=h(r.requestBody,e.config.sensitiveFields),r.responseBody=h(r.responseBody,e.config.sensitiveFields),e.buffer.push(r)}),this.addEventListener("error",function(){r.duration=performance.now()-n,r.error="Network error",e.buffer.push(r)}),this.addEventListener("timeout",function(){r.duration=performance.now()-n,r.error="Request timeout",e.buffer.push(r)}),e.originalXhrSend.apply(this,arguments)}}interceptBeacon(){if(!navigator.sendBeacon)return;this.originalSendBeacon=navigator.sendBeacon.bind(navigator);let e=this;Navigator.prototype.sendBeacon=function(t,n){let r={id:m(),timestamp:Date.now(),method:"POST",url:typeof t=="string"?t:t.href,requestHeaders:{},requestBody:e.safeParseBody(n),status:null,statusText:"",responseHeaders:{},responseBody:null,responseSize:null,duration:null,type:"beacon",error:null,initiator:"sendBeacon"};return r.requestBody=h(r.requestBody,e.config.sensitiveFields),e.buffer.push(r),e.originalSendBeacon(t,n)}}extractHeaders(e){let t={};return e&&(e instanceof Headers?e.forEach((n,r)=>{t[r]=n}):Array.isArray(e)?e.forEach(([n,r])=>{t[n]=r}):Object.assign(t,e)),t}extractResponseHeaders(e){let t={};return e.forEach((n,r)=>{t[r]=n}),t}parseXhrHeaders(e){let t={};return e&&e.trim().split(/[\r\n]+/).forEach(n=>{let r=n.split(": "),o=r.shift();o&&(t[o]=r.join(": "))}),t}safeParseBody(e){if(!e)return null;if(typeof e=="string")return this.safeParseJson(e);if(e instanceof FormData){let t={};return e.forEach((n,r)=>{t[r]=n instanceof File?`[File: ${n.name}]`:n}),t}return e instanceof URLSearchParams?Object.fromEntries(e.entries()):e instanceof Blob?`[Blob: ${e.size} bytes]`:e instanceof ArrayBuffer?`[ArrayBuffer: ${e.byteLength} bytes]`:String(e)}safeParseJson(e){if(!e)return null;try{return JSON.parse(e)}catch{return e.length>5e3?e.slice(0,5e3)+"...[truncated]":e}}getInitiator(){try{let e=new Error().stack;if(!e)return null;let t=e.split(`
2
+ `);for(let n of t)if(!n.includes("bug-jar")&&n.includes("at "))return n.trim().slice(0,200);return null}catch{return null}}};var E=class{constructor(e){this.originals={};this.levels=["log","warn","error","info","debug"];this.buffer=new f(e.maxConsoleEntries)}start(){for(let e of this.levels){this.originals[e]=console[e].bind(console);let t=this;console[e]=(...n)=>{t.capture(e,n),t.originals[e](...n)}}}stop(){for(let e of this.levels)this.originals[e]&&(console[e]=this.originals[e]);this.originals={}}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}capture(e,t){let n={timestamp:Date.now(),level:e,args:t.map(r=>typeof r=="string"||typeof r=="number"||typeof r=="boolean"?r:JSON.parse(U(r))),stack:e==="error"||e==="warn"?this.getStack():null};this.buffer.push(n)}getStack(){try{return new Error().stack?.split(`
3
3
  `).slice(4).join(`
4
- `)||null}catch{return null}}};var w=class{constructor(e){this.errorHandler=null;this.rejectionHandler=null;this.resourceErrorHandler=null;this.buffer=new l(e.maxErrors)}start(){this.errorHandler=e=>{this.buffer.push({timestamp:Date.now(),message:e.message||"Unknown error",stack:e.error?.stack||null,filename:e.filename||null,lineno:e.lineno||null,colno:e.colno||null,type:"uncaught",context:this.getContext(e.error)})},this.rejectionHandler=e=>{let t=e.reason;this.buffer.push({timestamp:Date.now(),message:t instanceof Error?t.message:String(t),stack:t instanceof Error&&t.stack||null,filename:null,lineno:null,colno:null,type:"unhandledrejection",context:t instanceof Error?this.getContext(t):null})},this.resourceErrorHandler=e=>{let t=e.target;!t||!(t instanceof HTMLElement)||(t.tagName==="SCRIPT"||t.tagName==="LINK"||t.tagName==="IMG")&&this.buffer.push({timestamp:Date.now(),message:`Failed to load ${t.tagName.toLowerCase()}: ${t.src||t.href||"unknown"}`,stack:null,filename:t.src||t.href||null,lineno:null,colno:null,type:"resource",context:null})},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.rejectionHandler),window.addEventListener("error",this.resourceErrorHandler,!0)}stop(){this.errorHandler&&(window.removeEventListener("error",this.errorHandler),this.errorHandler=null),this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null),this.resourceErrorHandler&&(window.removeEventListener("error",this.resourceErrorHandler,!0),this.resourceErrorHandler=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}getContext(e){if(!e)return null;try{let t=e.stack;if(!t)return null;let n=t.match(/at\s+(.+?)\s+\(/);return n?n[1]:null}catch{return null}}};var E=class{constructor(e){this.listeners=[];this.buffer=new l(e.maxUserActions)}start(){this.addListener("click",r=>{let o=r.target;this.buffer.push({timestamp:Date.now(),type:"click",target:h(o),metadata:{x:r.clientX,y:r.clientY,button:r.button}})},!0),this.addListener("input",r=>{let o=r.target,a=o.type==="password"||o.type==="hidden"||o.name?.toLowerCase().includes("password")||o.name?.toLowerCase().includes("token")||o.name?.toLowerCase().includes("secret");this.buffer.push({timestamp:Date.now(),type:"input",target:h(o),value:a?"[REDACTED]":o.value?.slice(0,50)||"",metadata:{inputType:o.type,name:o.name}})},!0),this.addListener("scroll",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"scroll",target:"window",metadata:{scrollX:window.scrollX,scrollY:window.scrollY,scrollHeight:document.documentElement.scrollHeight}})},500)),this.addListener("resize",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"resize",target:"window",metadata:{width:window.innerWidth,height:window.innerHeight}})},500)),this.addListener("visibilitychange",()=>{this.buffer.push({timestamp:Date.now(),type:"visibility",target:"document",value:document.visibilityState})}),this.addListener("copy",r=>{this.buffer.push({timestamp:Date.now(),type:"copy",target:h(r.target)})}),this.addListener("paste",r=>{this.buffer.push({timestamp:Date.now(),type:"paste",target:h(r.target)})});let e=history.pushState.bind(history),t=history.replaceState.bind(history),n=this;history.pushState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"pushState"}}),e(...r)},history.replaceState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"replaceState"}}),t(...r)},this.addListener("popstate",()=>{this.buffer.push({timestamp:Date.now(),type:"navigation",target:window.location.href,metadata:{method:"popstate"}})})}stop(){for(let{event:e,handler:t,options:n}of this.listeners)(e==="visibilitychange"?document:window).removeEventListener(e,t,n);this.listeners=[]}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}addListener(e,t,n){(e==="visibilitychange"?document:window).addEventListener(e,t,n),this.listeners.push({event:e,handler:t,options:n})}throttle(e,t){let n=0;return()=>{let r=Date.now();r-n>=t&&(n=r,e())}}};var x=class{collect(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset(),screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,cookiesEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,online:navigator.onLine,hardwareConcurrency:navigator.hardwareConcurrency||0,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,connection:this.getConnection(),memory:this.getMemory()}}getConnection(){let e=navigator.connection;return e?{effectiveType:e.effectiveType||"unknown",downlink:e.downlink||0,rtt:e.rtt||0,saveData:e.saveData||!1}:null}getMemory(){let e=performance.memory;return e?{jsHeapSizeLimit:e.jsHeapSizeLimit,totalJSHeapSize:e.totalJSHeapSize,usedJSHeapSize:e.usedJSHeapSize}:null}};var S=class{constructor(){this.lcp=null;this.fid=null;this.cls=null;this.observers=[]}start(){this.observeLCP(),this.observeFID(),this.observeCLS()}stop(){for(let e of this.observers)e.disconnect();this.observers=[]}collect(){let e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("paint"),n=performance.getEntriesByType("resource"),r=t.find(a=>a.name==="first-paint"),o=t.find(a=>a.name==="first-contentful-paint");return{navigationTiming:e?{redirectTime:e.redirectEnd-e.redirectStart,dnsTime:e.domainLookupEnd-e.domainLookupStart,tcpTime:e.connectEnd-e.connectStart,tlsTime:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,downloadTime:e.responseEnd-e.responseStart,domParsing:e.domInteractive-e.responseEnd,domContentLoaded:e.domContentLoadedEventEnd-e.domContentLoadedEventStart,loadEvent:e.loadEventEnd-e.loadEventStart,totalTime:e.loadEventEnd-e.startTime}:{},resourceCount:n.length,totalTransferSize:n.reduce((a,c)=>a+(c.transferSize||0),0),domContentLoaded:e?e.domContentLoadedEventEnd-e.startTime:null,loadComplete:e?e.loadEventEnd-e.startTime:null,firstPaint:r?r.startTime:null,firstContentfulPaint:o?o.startTime:null,largestContentfulPaint:this.lcp,firstInputDelay:this.fid,cumulativeLayoutShift:this.cls,timeToInteractive:null}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.lcp=n[n.length-1].startTime)});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch{}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.fid=n[0].processingStart-n[0].startTime)});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch{}}observeCLS(){try{let e=0,t=new PerformanceObserver(n=>{for(let r of n.getEntries())r.hadRecentInput||(e+=r.value);this.cls=e});t.observe({type:"layout-shift",buffered:!0}),this.observers.push(t)}catch{}}};var R=class{constructor(e){this.config=e}collect(){return{localStorage:this.config.captureLocalStorage?this.collectStorage(localStorage):{},sessionStorage:this.config.captureSessionStorage?this.collectStorage(sessionStorage):{},cookies:this.config.captureCookies?this.collectCookies():[]}}collectStorage(e){let t={};try{for(let n=0;n<e.length;n++){let r=e.key(n);if(!r)continue;if(this.config.sensitiveFields.some(a=>r.toLowerCase().includes(a.toLowerCase())))t[r]="[REDACTED]";else{let a=e.getItem(r)||"";t[r]=a.length>500?a.slice(0,500)+"...[truncated]":a}}}catch{}return t}collectCookies(){try{return document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean)}catch{return[]}}};var j=class{async capture(){try{let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;let n=window.innerWidth,r=window.innerHeight,o=Math.min(window.devicePixelRatio,2);e.width=n*o,e.height=r*o,t.scale(o,o);let a=this.domToSvg(n,r);return a?new Promise(c=>{let i=new Image;i.onload=()=>{t.drawImage(i,0,0);try{let u=e.toDataURL("image/png",.8);c(u)}catch{c(null)}},i.onerror=()=>c(null),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,setTimeout(()=>c(null),3e3)}):null}catch{return null}}domToSvg(e,t){try{let n=document.documentElement.cloneNode(!0);n.querySelectorAll("script").forEach(a=>a.remove());let o=new XMLSerializer().serializeToString(n);return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}">
4
+ `)||null}catch{return null}}};var x=class{constructor(e){this.errorHandler=null;this.rejectionHandler=null;this.resourceErrorHandler=null;this.buffer=new f(e.maxErrors)}start(){this.errorHandler=e=>{this.buffer.push({timestamp:Date.now(),message:e.message||"Unknown error",stack:e.error?.stack||null,filename:e.filename||null,lineno:e.lineno||null,colno:e.colno||null,type:"uncaught",context:this.getContext(e.error)})},this.rejectionHandler=e=>{let t=e.reason;this.buffer.push({timestamp:Date.now(),message:t instanceof Error?t.message:String(t),stack:t instanceof Error&&t.stack||null,filename:null,lineno:null,colno:null,type:"unhandledrejection",context:t instanceof Error?this.getContext(t):null})},this.resourceErrorHandler=e=>{let t=e.target;!t||!(t instanceof HTMLElement)||(t.tagName==="SCRIPT"||t.tagName==="LINK"||t.tagName==="IMG")&&this.buffer.push({timestamp:Date.now(),message:`Failed to load ${t.tagName.toLowerCase()}: ${t.src||t.href||"unknown"}`,stack:null,filename:t.src||t.href||null,lineno:null,colno:null,type:"resource",context:null})},window.addEventListener("error",this.errorHandler),window.addEventListener("unhandledrejection",this.rejectionHandler),window.addEventListener("error",this.resourceErrorHandler,!0)}stop(){this.errorHandler&&(window.removeEventListener("error",this.errorHandler),this.errorHandler=null),this.rejectionHandler&&(window.removeEventListener("unhandledrejection",this.rejectionHandler),this.rejectionHandler=null),this.resourceErrorHandler&&(window.removeEventListener("error",this.resourceErrorHandler,!0),this.resourceErrorHandler=null)}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}getContext(e){if(!e)return null;try{let t=e.stack;if(!t)return null;let n=t.match(/at\s+(.+?)\s+\(/);return n?n[1]:null}catch{return null}}};var S=class{constructor(e){this.listeners=[];this.buffer=new f(e.maxUserActions)}start(){this.addListener("click",r=>{let o=r.target;this.buffer.push({timestamp:Date.now(),type:"click",target:b(o),metadata:{x:r.clientX,y:r.clientY,button:r.button}})},!0),this.addListener("input",r=>{let o=r.target,a=o.type==="password"||o.type==="hidden"||o.name?.toLowerCase().includes("password")||o.name?.toLowerCase().includes("token")||o.name?.toLowerCase().includes("secret");this.buffer.push({timestamp:Date.now(),type:"input",target:b(o),value:a?"[REDACTED]":o.value?.slice(0,50)||"",metadata:{inputType:o.type,name:o.name}})},!0),this.addListener("scroll",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"scroll",target:"window",metadata:{scrollX:window.scrollX,scrollY:window.scrollY,scrollHeight:document.documentElement.scrollHeight}})},500)),this.addListener("resize",this.throttle(()=>{this.buffer.push({timestamp:Date.now(),type:"resize",target:"window",metadata:{width:window.innerWidth,height:window.innerHeight}})},500)),this.addListener("visibilitychange",()=>{this.buffer.push({timestamp:Date.now(),type:"visibility",target:"document",value:document.visibilityState})}),this.addListener("copy",r=>{this.buffer.push({timestamp:Date.now(),type:"copy",target:b(r.target)})}),this.addListener("paste",r=>{this.buffer.push({timestamp:Date.now(),type:"paste",target:b(r.target)})});let e=history.pushState.bind(history),t=history.replaceState.bind(history),n=this;history.pushState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"pushState"}}),e(...r)},history.replaceState=function(...r){return n.buffer.push({timestamp:Date.now(),type:"navigation",target:String(r[2]||window.location.href),metadata:{method:"replaceState"}}),t(...r)},this.addListener("popstate",()=>{this.buffer.push({timestamp:Date.now(),type:"navigation",target:window.location.href,metadata:{method:"popstate"}})})}stop(){for(let{event:e,handler:t,options:n}of this.listeners)(e==="visibilitychange"?document:window).removeEventListener(e,t,n);this.listeners=[]}getEntries(){return this.buffer.getAll()}clear(){this.buffer.clear()}addListener(e,t,n){(e==="visibilitychange"?document:window).addEventListener(e,t,n),this.listeners.push({event:e,handler:t,options:n})}throttle(e,t){let n=0;return()=>{let r=Date.now();r-n>=t&&(n=r,e())}}};var R=class{collect(){return{userAgent:navigator.userAgent,platform:navigator.platform,language:navigator.language,languages:[...navigator.languages],timezone:Intl.DateTimeFormat().resolvedOptions().timeZone,timezoneOffset:new Date().getTimezoneOffset(),screenWidth:screen.width,screenHeight:screen.height,viewportWidth:window.innerWidth,viewportHeight:window.innerHeight,devicePixelRatio:window.devicePixelRatio,colorDepth:screen.colorDepth,cookiesEnabled:navigator.cookieEnabled,doNotTrack:navigator.doNotTrack,online:navigator.onLine,hardwareConcurrency:navigator.hardwareConcurrency||0,maxTouchPoints:navigator.maxTouchPoints||0,vendor:navigator.vendor,connection:this.getConnection(),memory:this.getMemory()}}getConnection(){let e=navigator.connection;return e?{effectiveType:e.effectiveType||"unknown",downlink:e.downlink||0,rtt:e.rtt||0,saveData:e.saveData||!1}:null}getMemory(){let e=performance.memory;return e?{jsHeapSizeLimit:e.jsHeapSizeLimit,totalJSHeapSize:e.totalJSHeapSize,usedJSHeapSize:e.usedJSHeapSize}:null}};var j=class{constructor(){this.lcp=null;this.fid=null;this.cls=null;this.observers=[]}start(){this.observeLCP(),this.observeFID(),this.observeCLS()}stop(){for(let e of this.observers)e.disconnect();this.observers=[]}collect(){let e=performance.getEntriesByType("navigation")[0],t=performance.getEntriesByType("paint"),n=performance.getEntriesByType("resource"),r=t.find(a=>a.name==="first-paint"),o=t.find(a=>a.name==="first-contentful-paint");return{navigationTiming:e?{redirectTime:e.redirectEnd-e.redirectStart,dnsTime:e.domainLookupEnd-e.domainLookupStart,tcpTime:e.connectEnd-e.connectStart,tlsTime:e.secureConnectionStart>0?e.connectEnd-e.secureConnectionStart:0,ttfb:e.responseStart-e.requestStart,downloadTime:e.responseEnd-e.responseStart,domParsing:e.domInteractive-e.responseEnd,domContentLoaded:e.domContentLoadedEventEnd-e.domContentLoadedEventStart,loadEvent:e.loadEventEnd-e.loadEventStart,totalTime:e.loadEventEnd-e.startTime}:{},resourceCount:n.length,totalTransferSize:n.reduce((a,c)=>a+(c.transferSize||0),0),domContentLoaded:e?e.domContentLoadedEventEnd-e.startTime:null,loadComplete:e?e.loadEventEnd-e.startTime:null,firstPaint:r?r.startTime:null,firstContentfulPaint:o?o.startTime:null,largestContentfulPaint:this.lcp,firstInputDelay:this.fid,cumulativeLayoutShift:this.cls,timeToInteractive:null}}observeLCP(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.lcp=n[n.length-1].startTime)});e.observe({type:"largest-contentful-paint",buffered:!0}),this.observers.push(e)}catch{}}observeFID(){try{let e=new PerformanceObserver(t=>{let n=t.getEntries();n.length>0&&(this.fid=n[0].processingStart-n[0].startTime)});e.observe({type:"first-input",buffered:!0}),this.observers.push(e)}catch{}}observeCLS(){try{let e=0,t=new PerformanceObserver(n=>{for(let r of n.getEntries())r.hadRecentInput||(e+=r.value);this.cls=e});t.observe({type:"layout-shift",buffered:!0}),this.observers.push(t)}catch{}}};var L=class{constructor(e){this.config=e}collect(){return{localStorage:this.config.captureLocalStorage?this.collectStorage(localStorage):{},sessionStorage:this.config.captureSessionStorage?this.collectStorage(sessionStorage):{},cookies:this.config.captureCookies?this.collectCookies():[]}}collectStorage(e){let t={};try{for(let n=0;n<e.length;n++){let r=e.key(n);if(!r)continue;if(this.config.sensitiveFields.some(a=>r.toLowerCase().includes(a.toLowerCase())))t[r]="[REDACTED]";else{let a=e.getItem(r)||"";t[r]=a.length>500?a.slice(0,500)+"...[truncated]":a}}}catch{}return t}collectCookies(){try{return document.cookie.split(";").map(e=>e.trim().split("=")[0]).filter(Boolean)}catch{return[]}}};var k=class{async capture(){try{let e=document.createElement("canvas"),t=e.getContext("2d");if(!t)return null;let n=window.innerWidth,r=window.innerHeight,o=Math.min(window.devicePixelRatio,2);e.width=n*o,e.height=r*o,t.scale(o,o);let a=this.domToSvg(n,r);return a?new Promise(c=>{let i=new Image;i.onload=()=>{t.drawImage(i,0,0);try{let u=e.toDataURL("image/png",.8);c(u)}catch{c(null)}},i.onerror=()=>c(null),i.src=`data:image/svg+xml;charset=utf-8,${encodeURIComponent(a)}`,setTimeout(()=>c(null),3e3)}):null}catch{return null}}domToSvg(e,t){try{let n=document.documentElement.cloneNode(!0);n.querySelectorAll("script").forEach(a=>a.remove());let o=new XMLSerializer().serializeToString(n);return`<svg xmlns="http://www.w3.org/2000/svg" width="${e}" height="${t}">
5
5
  <foreignObject width="100%" height="100%">
6
6
  ${o}
7
7
  </foreignObject>
8
- </svg>`}catch{return null}}captureHtml(){try{let e=document.documentElement.cloneNode(!0);return e.querySelectorAll("script").forEach(r=>r.remove()),e.querySelectorAll('input[type="password"], input[name*="token"], input[name*="secret"]').forEach(r=>r.value="[REDACTED]"),e.outerHTML.slice(0,5e5)}catch{return null}}};var k=class{collect(){let e={},t=!1,n=window.posthog;if(n?.getFeatureFlag)try{let c=n.getAllFlags?.()||n.getFeatureFlags?.()||{};e.posthog=c,t=!0}catch{}let r=window.ldclient;if(r?.allFlags)try{e.launchdarkly=r.allFlags(),t=!0}catch{}let o=window.statsig;if(o?.getExperiment||o?.checkGate)try{e.statsig={detected:!0},t=!0}catch{}let a=window.unleash;if(a?.getAllToggles)try{e.unleash=a.getAllToggles(),t=!0}catch{}return t?e:null}};var L=class{constructor(){this.mediaRecorder=null;this.chunks=[];this.stream=null;this.recording=!1}get isRecording(){return this.recording}async start(){if(!this.recording)try{this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0}),this.chunks=[],this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:this.getSupportedMimeType(),videoBitsPerSecond:1e6}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks()},this.stream.getVideoTracks()[0].onended=()=>{this.stop()},this.mediaRecorder.start(1e3),this.recording=!0}catch{this.recording=!1,this.stream=null,this.mediaRecorder=null}}stop(){return new Promise(e=>{if(!this.mediaRecorder||!this.recording){e(null);return}this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks();let t=new Blob(this.chunks,{type:this.getSupportedMimeType()});this.chunks=[],e(t)},this.mediaRecorder.stop()})}stopTracks(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null)}getSupportedMimeType(){let e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(let t of e)if(MediaRecorder.isTypeSupported(t))return t;return"video/webm"}};var C=class{constructor(e,t,n){this.container=null;this.config=e,this.onReport=t,this.screenRecorder=n}mount(){this.container||(this.container=document.createElement("div"),this.container.id="bug-jar-widget",this.container.innerHTML=this.getWidgetHTML(),document.body.appendChild(this.container),this.injectStyles(),this.bindEvents())}unmount(){this.container&&(this.container.remove(),this.container=null);let e=document.getElementById("bug-jar-styles");e&&e.remove()}getWidgetHTML(){return`
9
- <button class="bug-jar-trigger ${`bug-jar--${this.config.uiPosition}`}" aria-label="${this.config.uiLabel}">
8
+ </svg>`}catch{return null}}captureHtml(){try{let e=document.documentElement.cloneNode(!0);return e.querySelectorAll("script").forEach(r=>r.remove()),e.querySelectorAll('input[type="password"], input[name*="token"], input[name*="secret"]').forEach(r=>r.value="[REDACTED]"),e.outerHTML.slice(0,5e5)}catch{return null}}};var C=class{collect(){let e={},t=!1,n=window.posthog;if(n?.getFeatureFlag)try{let c=n.getAllFlags?.()||n.getFeatureFlags?.()||{};e.posthog=c,t=!0}catch{}let r=window.ldclient;if(r?.allFlags)try{e.launchdarkly=r.allFlags(),t=!0}catch{}let o=window.statsig;if(o?.getExperiment||o?.checkGate)try{e.statsig={detected:!0},t=!0}catch{}let a=window.unleash;if(a?.getAllToggles)try{e.unleash=a.getAllToggles(),t=!0}catch{}return t?e:null}};var T=class{constructor(){this.mediaRecorder=null;this.chunks=[];this.stream=null;this.recording=!1}get isRecording(){return this.recording}async start(){if(!this.recording)try{this.stream=await navigator.mediaDevices.getDisplayMedia({video:{frameRate:15},audio:!1,preferCurrentTab:!0}),this.chunks=[],this.mediaRecorder=new MediaRecorder(this.stream,{mimeType:this.getSupportedMimeType(),videoBitsPerSecond:1e6}),this.mediaRecorder.ondataavailable=e=>{e.data.size>0&&this.chunks.push(e.data)},this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks()},this.stream.getVideoTracks()[0].onended=()=>{this.stop()},this.mediaRecorder.start(1e3),this.recording=!0}catch{this.recording=!1,this.stream=null,this.mediaRecorder=null}}stop(){return new Promise(e=>{if(!this.mediaRecorder||!this.recording){e(null);return}this.mediaRecorder.onstop=()=>{this.recording=!1,this.stopTracks();let t=new Blob(this.chunks,{type:this.getSupportedMimeType()});this.chunks=[],e(t)},this.mediaRecorder.stop()})}stopTracks(){this.stream&&(this.stream.getTracks().forEach(e=>e.stop()),this.stream=null)}getSupportedMimeType(){let e=["video/webm;codecs=vp9","video/webm;codecs=vp8","video/webm","video/mp4"];for(let t of e)if(MediaRecorder.isTypeSupported(t))return t;return"video/webm"}};var B=class{constructor(e,t,n){this.container=null;this.config=e,this.onReport=t,this.screenRecorder=n}mount(){if(this.container)return;let e=typeof window<"u"&&window.innerWidth<=768;if(this.config.hideOnMobile&&e)return;this.container=document.createElement("div"),this.container.id="bug-jar-widget";let t=e&&this.config.uiCompactOnMobile;this.container.innerHTML=this.getWidgetHTML(t),this.container.dataset.compact=String(t),document.body.appendChild(this.container),this.injectStyles(t),this.bindEvents(),this.makeDraggable()}unmount(){this.container&&(this.container.remove(),this.container=null);let e=document.getElementById("bug-jar-styles");e&&e.remove()}getWidgetHTML(e=!1){let n=`bug-jar--${this.config.uiPosition}`,r=e?" bug-jar-trigger--compact":"";return e?`
9
+ <button class="bug-jar-trigger ${n}${r}" aria-label="${this.config.uiLabel}">
10
+ <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
+ <path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 116 0v1"/>
12
+ <path d="M12 20c-3.3 0-6-2.7-6-6v-3a6 6 0 0112 0v3c0 3.3-2.7 6-6 6z"/>
13
+ <path d="M12 20v2M6 13H2M22 13h-4M6 17l-2 2M18 17l2 2M6 9l-2-2M18 9l2-2"/>
14
+ </svg>
15
+ </button>
16
+ `:`
17
+ <button class="bug-jar-trigger ${n}" aria-label="${this.config.uiLabel}">
10
18
  <svg width="20" height="20" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2">
11
19
  <path d="M8 2l1.88 1.88M14.12 3.88L16 2M9 7.13v-1a3.003 3.003 0 116 0v1"/>
12
20
  <path d="M12 20c-3.3 0-6-2.7-6-6v-3a6 6 0 0112 0v3c0 3.3-2.7 6-6 6z"/>
@@ -40,7 +48,7 @@ function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slic
40
48
  <div class="bug-jar-status" hidden></div>
41
49
  </div>
42
50
  </div>
43
- `}bindEvents(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger"),t=this.container.querySelector(".bug-jar-modal"),n=this.container.querySelector(".bug-jar-modal-backdrop"),r=this.container.querySelector(".bug-jar-close"),o=this.container.querySelector(".bug-jar-cancel"),a=this.container.querySelector(".bug-jar-submit"),c=this.container.querySelector("#bug-jar-description"),i=this.container.querySelector(".bug-jar-status"),u=this.container.querySelector(".bug-jar-record-btn"),f=this.container.querySelector(".bug-jar-recording-status"),b=()=>{t.hidden=!1,c.focus(),this.updateRecordingUI(u,f)},p=()=>{t.hidden=!0,c.value="",i.hidden=!0};e.addEventListener("click",b),n.addEventListener("click",p),r.addEventListener("click",p),o.addEventListener("click",p),u.addEventListener("click",async()=>{this.screenRecorder.isRecording||(p(),await this.screenRecorder.start(),this.updateTriggerForRecording(e))}),a.addEventListener("click",async()=>{let H=c.value.trim();if(!H){c.classList.add("bug-jar-error");return}c.classList.remove("bug-jar-error"),a.setAttribute("disabled","true"),a.textContent="Capturando...",i.hidden=!0;try{await this.onReport(H),i.textContent="\u2713 Relat\xF3rio baixado como .zip!",i.className="bug-jar-status bug-jar-status--success",i.hidden=!1,this.resetTrigger(e),setTimeout(p,2e3)}catch(U){i.textContent=`Erro: ${U instanceof Error?U.message:"Falha ao gerar relat\xF3rio"}`,i.className="bug-jar-status bug-jar-status--error",i.hidden=!1}finally{a.removeAttribute("disabled"),a.textContent="Enviar Relat\xF3rio"}}),c.addEventListener("input",()=>{c.classList.remove("bug-jar-error")})}updateRecordingUI(e,t){if(this.screenRecorder.isRecording){e.classList.add("bug-jar-record-btn--active"),t.hidden=!1;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravando...")}else{e.classList.remove("bug-jar-record-btn--active"),t.hidden=!0;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravar Tela")}}updateTriggerForRecording(e){e.classList.add("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent="\u23FA Gravando...")}resetTrigger(e){e.classList.remove("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent=this.config.uiLabel)}injectStyles(){if(document.getElementById("bug-jar-styles"))return;let e=document.createElement("style");e.id="bug-jar-styles",e.textContent=`
51
+ `}bindEvents(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger"),t=this.container.querySelector(".bug-jar-modal"),n=this.container.querySelector(".bug-jar-modal-backdrop"),r=this.container.querySelector(".bug-jar-close"),o=this.container.querySelector(".bug-jar-cancel"),a=this.container.querySelector(".bug-jar-submit"),c=this.container.querySelector("#bug-jar-description"),i=this.container.querySelector(".bug-jar-status"),u=this.container.querySelector(".bug-jar-record-btn"),p=this.container.querySelector(".bug-jar-recording-status"),l=()=>{this.container?.dataset.compact==="true"&&this.container.querySelector(".bug-jar-trigger")?.classList.add("bug-jar-trigger--expanded"),t&&(t.hidden=!1),c?.focus(),this.updateRecordingUI(u,p)},d=()=>{t&&(t.hidden=!0),c&&(c.value=""),i&&(i.hidden=!0),this.container?.dataset.compact==="true"&&this.container.querySelector(".bug-jar-trigger")?.classList.remove("bug-jar-trigger--expanded")};e.addEventListener("click",l),n&&n.addEventListener("click",d),r&&r.addEventListener("click",d),o&&o.addEventListener("click",d),u?.addEventListener("click",async()=>{this.screenRecorder.isRecording||(d(),await this.screenRecorder.start(),this.updateTriggerForRecording(e))}),a?.addEventListener("click",async()=>{let g=c?.value.trim();if(!(!g||!c||!a||!i)){c.classList.remove("bug-jar-error"),a.setAttribute("disabled","true"),a.textContent="Capturando...",i.hidden=!0;try{await this.onReport(g),i.textContent="\u2713 Relat\xF3rio baixado como .zip!",i.className="bug-jar-status bug-jar-status--success",i.hidden=!1,this.resetTrigger(e),setTimeout(d,2e3)}catch(v){i.textContent=`Erro: ${v instanceof Error?v.message:"Falha ao gerar relat\xF3rio"}`,i.className="bug-jar-status bug-jar-status--error",i.hidden=!1}finally{a.removeAttribute("disabled"),a.textContent="Enviar Relat\xF3rio"}}}),c?.addEventListener("input",()=>{c?.classList.remove("bug-jar-error")})}updateRecordingUI(e,t){if(!(!e||!t))if(this.screenRecorder.isRecording){e.classList.add("bug-jar-record-btn--active"),t.hidden=!1;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravando...")}else{e.classList.remove("bug-jar-record-btn--active"),t.hidden=!0;let n=e.querySelector(".bug-jar-record-label");n&&(n.textContent="Gravar Tela")}}updateTriggerForRecording(e){e.classList.add("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent="\u23FA Gravando...")}resetTrigger(e){e.classList.remove("bug-jar-trigger--recording");let t=e.querySelector("span");t&&(t.textContent=this.config.uiLabel)}makeDraggable(){if(!this.container)return;let e=this.container.querySelector(".bug-jar-trigger");if(!e)return;let t=!1,n=0,r=0,o=0,a=0,c=!1,i=l=>{let d="touches"in l?l.touches[0]:l;n=d.clientX,r=d.clientY;let g=e.getBoundingClientRect();o=g.left,a=g.top,c=!1,t=!0,e.classList.add("bug-jar-trigger--dragging"),document.addEventListener("mousemove",u),document.addEventListener("mouseup",p),document.addEventListener("touchmove",u,{passive:!1}),document.addEventListener("touchend",p)},u=l=>{if(!t)return;l.preventDefault();let d="touches"in l?l.touches[0]:l,g=d.clientX-n,v=d.clientY-r;(Math.abs(g)>5||Math.abs(v)>5)&&(c=!0);let A=o+g,$=a+v;e.style.position="fixed",e.style.left=`${A}px`,e.style.top=`${$}px`,e.style.right="auto",e.style.bottom="auto",e.classList.remove("bug-jar--bottom-right","bug-jar--bottom-left","bug-jar--top-right","bug-jar--top-left")},p=()=>{t=!1,e.classList.remove("bug-jar-trigger--dragging"),document.removeEventListener("mousemove",u),document.removeEventListener("mouseup",p),document.removeEventListener("touchmove",u),document.removeEventListener("touchend",p),c&&(e.style.cursor="")};e.addEventListener("mousedown",i),e.addEventListener("touchstart",i,{passive:!0})}injectStyles(e=!1){if(document.getElementById("bug-jar-styles"))return;let t=document.createElement("style");t.id="bug-jar-styles",t.textContent=`
44
52
  #bug-jar-widget {
45
53
  font-family: -apple-system, BlinkMacSystemFont, 'Segoe UI', Roboto, sans-serif;
46
54
  font-size: 14px;
@@ -64,6 +72,8 @@ function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slic
64
72
  cursor: pointer;
65
73
  box-shadow: 0 4px 12px rgba(0,0,0,0.15);
66
74
  transition: transform 0.15s, box-shadow 0.15s, background 0.3s;
75
+ user-select: none;
76
+ touch-action: none;
67
77
  }
68
78
 
69
79
  .bug-jar-trigger:hover {
@@ -71,6 +81,31 @@ function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slic
71
81
  box-shadow: 0 6px 20px rgba(0,0,0,0.2);
72
82
  }
73
83
 
84
+ .bug-jar-trigger--compact {
85
+ padding: 12px;
86
+ border-radius: 50%;
87
+ width: 44px;
88
+ height: 44px;
89
+ justify-content: center;
90
+ }
91
+
92
+ .bug-jar-trigger--compact span {
93
+ display: none;
94
+ }
95
+
96
+ .bug-jar-trigger--expanded {
97
+ padding: 10px 16px;
98
+ width: auto;
99
+ height: auto;
100
+ border-radius: 24px;
101
+ }
102
+
103
+ .bug-jar-trigger--dragging {
104
+ cursor: grabbing;
105
+ transform: scale(1.1);
106
+ box-shadow: 0 8px 25px rgba(0,0,0,0.3);
107
+ }
108
+
74
109
  .bug-jar-trigger--recording {
75
110
  background: #dc2626;
76
111
  animation: bug-jar-pulse 1.5s infinite;
@@ -262,5 +297,5 @@ function g(){return`${Date.now().toString(36)}-${Math.random().toString(36).slic
262
297
 
263
298
  .bug-jar-status--success { color: #16a34a; background: #f0fdf4; }
264
299
  .bug-jar-status--error { color: #dc2626; background: #fef2f2; }
265
- `,document.head.appendChild(e)}};function T(s){let e=[];e.push(`Bug Report: ${s.id}`),e.push(`URL: ${s.url}`),e.push(`Time: ${new Date(s.timestamp).toISOString()}`),e.push(`User Description: "${s.userDescription}"`),e.push(""),e.push("## Environment"),e.push(`Browser: ${A(s.environment.userAgent)}`),e.push(`Viewport: ${s.environment.viewportWidth}x${s.environment.viewportHeight}`),e.push(`Connection: ${s.environment.connection?.effectiveType||"unknown"}`),e.push(`Online: ${s.environment.online}`),e.push(""),e.push("## Network Activity");let t=s.network.length,n=s.network.filter(i=>i.error||i.status&&i.status>=400),r=s.network.filter(i=>i.duration&&i.duration>3e3);if(e.push(`Total requests: ${t}`),n.length>0){e.push(`Failed requests (${n.length}):`);for(let i of n)e.push(` - ${i.method} ${i.url} \u2192 ${i.error||`HTTP ${i.status}`}`)}if(r.length>0){e.push(`Slow requests >3s (${r.length}):`);for(let i of r)e.push(` - ${i.method} ${i.url} (${Math.round(i.duration)}ms)`)}if(e.push(""),e.push("## Errors"),s.errors.length===0)e.push("No errors captured.");else{e.push(`Total errors: ${s.errors.length}`);for(let i of s.errors)e.push(` - [${i.type}] ${i.message}`),i.filename&&e.push(` at ${i.filename}:${i.lineno}:${i.colno}`)}e.push(""),e.push("## Console");let o={log:0,warn:0,error:0,info:0,debug:0};for(let i of s.console)o[i.level]++;e.push(`Logs: ${o.log}, Warnings: ${o.warn}, Errors: ${o.error}, Info: ${o.info}, Debug: ${o.debug}`);let a=s.console.filter(i=>i.level==="error");if(a.length>0){e.push("Console errors:");for(let i of a)e.push(` - ${i.args.map(u=>typeof u=="string"?u:JSON.stringify(u)).join(" ")}`)}e.push(""),e.push("## User Actions"),e.push(`Total actions: ${s.userActions.length}`);let c={};for(let i of s.userActions)c[i.type]=(c[i.type]||0)+1;for(let[i,u]of Object.entries(c))e.push(` - ${i}: ${u}`);if(s.userActions.length>0){let i=s.userActions[0].timestamp,f=((s.userActions[s.userActions.length-1].timestamp-i)/1e3).toFixed(1);e.push(`Session duration: ${f}s`)}if(e.push(""),s.performance){e.push("## Performance");let i=s.performance;i.largestContentfulPaint&&e.push(`LCP: ${Math.round(i.largestContentfulPaint)}ms`),i.firstInputDelay&&e.push(`FID: ${Math.round(i.firstInputDelay)}ms`),i.cumulativeLayoutShift!==null&&e.push(`CLS: ${i.cumulativeLayoutShift?.toFixed(3)}`),i.loadComplete&&e.push(`Page Load: ${Math.round(i.loadComplete)}ms`),e.push(`Resources: ${i.resourceCount} (${$(i.totalTransferSize)})`)}return e.join(`
266
- `)}function A(s){return s.includes("Chrome/")?`Chrome ${s.match(/Chrome\/(\d+)/)?.[1]||""}`:s.includes("Firefox/")?`Firefox ${s.match(/Firefox\/(\d+)/)?.[1]||""}`:s.includes("Safari/")&&!s.includes("Chrome")?`Safari ${s.match(/Version\/(\d+)/)?.[1]||""}`:s.slice(0,50)}function $(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}async function B(s,e){let t=[],n=JSON.stringify(s,null,2);t.push({name:"report.json",content:new TextEncoder().encode(n)});let r=T(s);if(t.push({name:"summary.md",content:new TextEncoder().encode(r)}),s.screenshot){let o=q(s.screenshot);o&&t.push({name:"screenshot.png",content:o})}if(e){let o=new Uint8Array(await e.arrayBuffer());t.push({name:"recording.webm",content:o})}return D(t)}function q(s){try{let e=s.split(",")[1];if(!e)return null;let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch{return null}}function D(s){let e=[],t=[],n=0;for(let i of s){let u=new TextEncoder().encode(i.name),f=I(i.content),b=P(u,i.content.length,f);e.push(b),e.push(u),e.push(i.content);let p=F(u,i.content.length,f,n);t.push(p),t.push(u),n+=b.length+u.length+i.content.length}let r=n,o=0;for(let i of t)o+=i.length;let a=z(s.length,o,r),c=[...e,...t,a].map(i=>i.buffer);return new Blob(c,{type:"application/zip"})}function P(s,e,t){let n=new Uint8Array(30),r=new DataView(n.buffer);return r.setUint32(0,67324752,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,0,!0),r.setUint16(10,0,!0),r.setUint16(12,0,!0),r.setUint32(14,t,!0),r.setUint32(18,e,!0),r.setUint32(22,e,!0),r.setUint16(26,s.length,!0),r.setUint16(28,0,!0),n}function F(s,e,t,n){let r=new Uint8Array(46),o=new DataView(r.buffer);return o.setUint32(0,33639248,!0),o.setUint16(4,20,!0),o.setUint16(6,20,!0),o.setUint16(8,0,!0),o.setUint16(10,0,!0),o.setUint16(12,0,!0),o.setUint16(14,0,!0),o.setUint32(16,t,!0),o.setUint32(20,e,!0),o.setUint32(24,e,!0),o.setUint16(28,s.length,!0),o.setUint16(30,0,!0),o.setUint16(32,0,!0),o.setUint16(34,0,!0),o.setUint16(36,0,!0),o.setUint32(38,0,!0),o.setUint32(42,n,!0),r}function z(s,e,t){let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,s,!0),r.setUint16(10,s,!0),r.setUint32(12,e,!0),r.setUint32(16,t,!0),r.setUint16(20,0,!0),n}function I(s){let e=4294967295;for(let t=0;t<s.length;t++){e^=s[t];for(let n=0;n<8;n++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}var N="0.2.0",J={maxNetworkEntries:100,maxConsoleEntries:200,maxUserActions:150,maxErrors:50,captureScreenshot:!0,captureHtmlSnapshot:!0,captureCookies:!0,captureLocalStorage:!0,captureSessionStorage:!0,capturePerformance:!0,captureWebVitals:!0,captureMemory:!0,captureConnectivity:!0,sensitiveFields:["password","token","secret","authorization","cookie","session","credit_card","cvv","ssn","cpf"],endpoint:void 0,onCapture:void 0,ui:!0,uiPosition:"bottom-right",uiLabel:"Reportar Bug"},m=class{constructor(e={}){this.ui=null;this.started=!1;this.config={...J,...e},this.network=new y(this.config),this.console=new v(this.config),this.errors=new w(this.config),this.userActions=new E(this.config),this.environment=new x,this.performance=new S,this.storage=new R(this.config),this.screenshot=new j,this.featureFlags=new k,this.screenRecorder=new L}start(){this.started||(this.started=!0,this.network.start(),this.console.start(),this.errors.start(),this.userActions.start(),this.config.captureWebVitals&&this.performance.start(),this.config.ui&&(this.ui=new C(this.config,e=>this.captureAndExport(e),this.screenRecorder),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.ui?.mount()):this.ui.mount()))}stop(){this.started&&(this.started=!1,this.network.stop(),this.console.stop(),this.errors.stop(),this.userActions.stop(),this.performance.stop(),this.ui?.unmount())}async startRecording(){await this.screenRecorder.start()}get isRecording(){return this.screenRecorder.isRecording}async capture(e=""){let t={id:g(),timestamp:Date.now(),url:window.location.href,title:document.title,userDescription:e,environment:this.environment.collect(),network:this.network.getEntries(),console:this.console.getEntries(),errors:this.errors.getEntries(),userActions:this.userActions.getEntries(),performance:this.config.capturePerformance?this.performance.collect():null,storage:this.storage.collect(),screenshot:this.config.captureScreenshot?await this.screenshot.capture():null,htmlSnapshot:this.config.captureHtmlSnapshot?this.screenshot.captureHtml():null,featureFlags:this.featureFlags.collect(),metadata:{},version:N};return this.config.onCapture&&this.config.onCapture(t),t}async captureAndExport(e=""){let t=await this.screenRecorder.stop(),n=await this.capture(e);if(this.config.endpoint)if(t){let r=new FormData;r.append("report",JSON.stringify(n)),r.append("video",t,"recording.webm"),await fetch(this.config.endpoint,{method:"POST",body:r})}else await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});else{let r=await B(n,t),o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=`bug-report-${n.id}.zip`,a.click(),URL.revokeObjectURL(o)}return n}getReport(){return this.capture()}};function X(s={}){let e=new m(s);return e.start(),e}typeof window<"u"&&(window.BugJar={BugJar:m,init:X});var Se=m;export{m as BugJar,Se as default,B as exportAsZip,T as generateSummary,X as init};
300
+ `,document.head.appendChild(t)}};function H(s){let e=[];e.push(`Bug Report: ${s.id}`),e.push(`URL: ${s.url}`),e.push(`Time: ${new Date(s.timestamp).toISOString()}`),e.push(`User Description: "${s.userDescription}"`),e.push(""),e.push("## Environment"),e.push(`Browser: ${q(s.environment.userAgent)}`),e.push(`Viewport: ${s.environment.viewportWidth}x${s.environment.viewportHeight}`),e.push(`Connection: ${s.environment.connection?.effectiveType||"unknown"}`),e.push(`Online: ${s.environment.online}`),e.push(""),e.push("## Network Activity");let t=s.network.length,n=s.network.filter(i=>i.error||i.status&&i.status>=400),r=s.network.filter(i=>i.duration&&i.duration>3e3);if(e.push(`Total requests: ${t}`),n.length>0){e.push(`Failed requests (${n.length}):`);for(let i of n)e.push(` - ${i.method} ${i.url} \u2192 ${i.error||`HTTP ${i.status}`}`)}if(r.length>0){e.push(`Slow requests >3s (${r.length}):`);for(let i of r)e.push(` - ${i.method} ${i.url} (${Math.round(i.duration)}ms)`)}if(e.push(""),e.push("## Errors"),s.errors.length===0)e.push("No errors captured.");else{e.push(`Total errors: ${s.errors.length}`);for(let i of s.errors)e.push(` - [${i.type}] ${i.message}`),i.filename&&e.push(` at ${i.filename}:${i.lineno}:${i.colno}`)}e.push(""),e.push("## Console");let o={log:0,warn:0,error:0,info:0,debug:0};for(let i of s.console)o[i.level]++;e.push(`Logs: ${o.log}, Warnings: ${o.warn}, Errors: ${o.error}, Info: ${o.info}, Debug: ${o.debug}`);let a=s.console.filter(i=>i.level==="error");if(a.length>0){e.push("Console errors:");for(let i of a)e.push(` - ${i.args.map(u=>typeof u=="string"?u:JSON.stringify(u)).join(" ")}`)}e.push(""),e.push("## User Actions"),e.push(`Total actions: ${s.userActions.length}`);let c={};for(let i of s.userActions)c[i.type]=(c[i.type]||0)+1;for(let[i,u]of Object.entries(c))e.push(` - ${i}: ${u}`);if(s.userActions.length>0){let i=s.userActions[0].timestamp,p=((s.userActions[s.userActions.length-1].timestamp-i)/1e3).toFixed(1);e.push(`Session duration: ${p}s`)}if(e.push(""),s.performance){e.push("## Performance");let i=s.performance;i.largestContentfulPaint&&e.push(`LCP: ${Math.round(i.largestContentfulPaint)}ms`),i.firstInputDelay&&e.push(`FID: ${Math.round(i.firstInputDelay)}ms`),i.cumulativeLayoutShift!==null&&e.push(`CLS: ${i.cumulativeLayoutShift?.toFixed(3)}`),i.loadComplete&&e.push(`Page Load: ${Math.round(i.loadComplete)}ms`),e.push(`Resources: ${i.resourceCount} (${D(i.totalTransferSize)})`)}return e.join(`
301
+ `)}function q(s){return s.includes("Chrome/")?`Chrome ${s.match(/Chrome\/(\d+)/)?.[1]||""}`:s.includes("Firefox/")?`Firefox ${s.match(/Firefox\/(\d+)/)?.[1]||""}`:s.includes("Safari/")&&!s.includes("Chrome")?`Safari ${s.match(/Version\/(\d+)/)?.[1]||""}`:s.slice(0,50)}function D(s){return s<1024?`${s}B`:s<1024*1024?`${(s/1024).toFixed(1)}KB`:`${(s/(1024*1024)).toFixed(1)}MB`}async function M(s,e){let t=[],n=JSON.stringify(s,null,2);t.push({name:"report.json",content:new TextEncoder().encode(n)});let r=H(s);if(t.push({name:"summary.md",content:new TextEncoder().encode(r)}),s.screenshot){let o=P(s.screenshot);o&&t.push({name:"screenshot.png",content:o})}if(e){let o=new Uint8Array(await e.arrayBuffer());t.push({name:"recording.webm",content:o})}return F(t)}function P(s){try{let e=s.split(",")[1];if(!e)return null;let t=atob(e),n=new Uint8Array(t.length);for(let r=0;r<t.length;r++)n[r]=t.charCodeAt(r);return n}catch{return null}}function F(s){let e=[],t=[],n=0;for(let i of s){let u=new TextEncoder().encode(i.name),p=N(i.content),l=z(u,i.content.length,p);e.push(l),e.push(u),e.push(i.content);let d=I(u,i.content.length,p,n);t.push(d),t.push(u),n+=l.length+u.length+i.content.length}let r=n,o=0;for(let i of t)o+=i.length;let a=X(s.length,o,r),c=[...e,...t,a].map(i=>i.buffer);return new Blob(c,{type:"application/zip"})}function z(s,e,t){let n=new Uint8Array(30),r=new DataView(n.buffer);return r.setUint32(0,67324752,!0),r.setUint16(4,20,!0),r.setUint16(6,0,!0),r.setUint16(8,0,!0),r.setUint16(10,0,!0),r.setUint16(12,0,!0),r.setUint32(14,t,!0),r.setUint32(18,e,!0),r.setUint32(22,e,!0),r.setUint16(26,s.length,!0),r.setUint16(28,0,!0),n}function I(s,e,t,n){let r=new Uint8Array(46),o=new DataView(r.buffer);return o.setUint32(0,33639248,!0),o.setUint16(4,20,!0),o.setUint16(6,20,!0),o.setUint16(8,0,!0),o.setUint16(10,0,!0),o.setUint16(12,0,!0),o.setUint16(14,0,!0),o.setUint32(16,t,!0),o.setUint32(20,e,!0),o.setUint32(24,e,!0),o.setUint16(28,s.length,!0),o.setUint16(30,0,!0),o.setUint16(32,0,!0),o.setUint16(34,0,!0),o.setUint16(36,0,!0),o.setUint32(38,0,!0),o.setUint32(42,n,!0),r}function X(s,e,t){let n=new Uint8Array(22),r=new DataView(n.buffer);return r.setUint32(0,101010256,!0),r.setUint16(4,0,!0),r.setUint16(6,0,!0),r.setUint16(8,s,!0),r.setUint16(10,s,!0),r.setUint32(12,e,!0),r.setUint32(16,t,!0),r.setUint16(20,0,!0),n}function N(s){let e=4294967295;for(let t=0;t<s.length;t++){e^=s[t];for(let n=0;n<8;n++)e=e>>>1^(e&1?3988292384:0)}return(e^4294967295)>>>0}var O="0.2.0",J={maxNetworkEntries:100,maxConsoleEntries:200,maxUserActions:150,maxErrors:50,captureScreenshot:!0,captureHtmlSnapshot:!0,captureCookies:!0,captureLocalStorage:!0,captureSessionStorage:!0,capturePerformance:!0,captureWebVitals:!0,captureMemory:!0,captureConnectivity:!0,sensitiveFields:["password","token","secret","authorization","cookie","session","credit_card","cvv","ssn","cpf"],endpoint:void 0,onCapture:void 0,ui:!0,uiPosition:"bottom-right",uiLabel:"Reportar Bug"},y=class{constructor(e={}){this.ui=null;this.started=!1;this.config={...J,...e},this.network=new w(this.config),this.console=new E(this.config),this.errors=new x(this.config),this.userActions=new S(this.config),this.environment=new R,this.performance=new j,this.storage=new L(this.config),this.screenshot=new k,this.featureFlags=new C,this.screenRecorder=new T}start(){this.started||(this.started=!0,this.network.start(),this.console.start(),this.errors.start(),this.userActions.start(),this.config.captureWebVitals&&this.performance.start(),this.config.ui&&(this.ui=new B(this.config,e=>this.captureAndExport(e),this.screenRecorder),document.readyState==="loading"?document.addEventListener("DOMContentLoaded",()=>this.ui?.mount()):this.ui.mount()))}stop(){this.started&&(this.started=!1,this.network.stop(),this.console.stop(),this.errors.stop(),this.userActions.stop(),this.performance.stop(),this.ui?.unmount())}async startRecording(){await this.screenRecorder.start()}get isRecording(){return this.screenRecorder.isRecording}async capture(e=""){let t={id:m(),timestamp:Date.now(),url:window.location.href,title:document.title,userDescription:e,environment:this.environment.collect(),network:this.network.getEntries(),console:this.console.getEntries(),errors:this.errors.getEntries(),userActions:this.userActions.getEntries(),performance:this.config.capturePerformance?this.performance.collect():null,storage:this.storage.collect(),screenshot:this.config.captureScreenshot?await this.screenshot.capture():null,htmlSnapshot:this.config.captureHtmlSnapshot?this.screenshot.captureHtml():null,featureFlags:this.featureFlags.collect(),metadata:{},version:O};return this.config.onCapture&&this.config.onCapture(t),t}async captureAndExport(e=""){let t=await this.screenRecorder.stop(),n=await this.capture(e);if(this.config.endpoint)if(t){let r=new FormData;r.append("report",JSON.stringify(n)),r.append("video",t,"recording.webm"),await fetch(this.config.endpoint,{method:"POST",body:r})}else await fetch(this.config.endpoint,{method:"POST",headers:{"Content-Type":"application/json"},body:JSON.stringify(n)});else{let r=await M(n,t),o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=`bug-report-${n.id}.zip`,a.click(),URL.revokeObjectURL(o)}return n}getReport(){return this.capture()}};function _(s={}){let e=new y(s);return e.start(),e}typeof window<"u"&&(window.BugJar={BugJar:y,init:_});var je=y;export{y as BugJar,je as default,M as exportAsZip,H as generateSummary,_ as init};
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arvoretech/bug-jar",
3
- "version": "0.2.0",
3
+ "version": "0.3.1",
4
4
  "description": "Capture everything for non-technical people to help debug. One script tag, zero config.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",
@@ -16,6 +16,11 @@
16
16
  "files": [
17
17
  "dist"
18
18
  ],
19
+ "scripts": {
20
+ "dev": "vite",
21
+ "build": "tsup src/index.ts --format cjs,esm,iife --global-name BugJar --dts --minify",
22
+ "preview": "vite preview"
23
+ },
19
24
  "keywords": [
20
25
  "bug-report",
21
26
  "debug",
@@ -28,19 +33,18 @@
28
33
  "license": "MIT",
29
34
  "repository": {
30
35
  "type": "git",
31
- "url": "https://github.com/ArvoreEducacao/bug-jar.git"
36
+ "url": "https://github.com/arvoreeducacao/bug-jar"
32
37
  },
38
+ "packageManager": "pnpm@10.28.1",
33
39
  "publishConfig": {
34
40
  "access": "public"
35
41
  },
42
+ "pnpm": {
43
+ "onlyBuiltDependencies": ["esbuild"]
44
+ },
36
45
  "devDependencies": {
37
46
  "tsup": "^8.4.0",
38
47
  "typescript": "^5.7.0",
39
48
  "vite": "^6.0.0"
40
- },
41
- "scripts": {
42
- "dev": "vite",
43
- "build": "tsup src/index.ts --format cjs,esm,iife --global-name BugJar --dts --minify",
44
- "preview": "vite preview"
45
49
  }
46
- }
50
+ }