@spectosh/browser 0.2.0 → 0.2.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/specto-browser.cjs +1 -1
- package/dist/specto-browser.js +1 -1
- package/package.json +1 -1
- package/src/recorder.js +1 -1
package/dist/specto-browser.cjs
CHANGED
|
@@ -131,6 +131,6 @@ or you can use record.mirror to access the mirror instance during recording.`,Xi
|
|
|
131
131
|
};
|
|
132
132
|
})();
|
|
133
133
|
//# sourceMappingURL=image-bitmap-data-url-worker-IJpC7g_b.js.map
|
|
134
|
-
`,vo=typeof self<`u`&&self.Blob&&new Blob([_o],{type:`text/javascript;charset=utf-8`});function yo(e){let t;try{if(t=vo&&(self.URL||self.webkitURL).createObjectURL(vo),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(_o),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var bo=class{constructor(e){n(this,`pendingCanvasMutations`,new Map),n(this,`rafStamps`,{latestId:0,invokeId:null}),n(this,`mirror`),n(this,`mutationCb`),n(this,`resetObservers`),n(this,`frozen`,!1),n(this,`locked`,!1),n(this,`processMutation`,(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});let{sampling:t=`all`,win:r,blockClass:i,blockSelector:a,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&t===`all`&&this.initCanvasMutationObserver(r,i,a),o&&typeof t==`number`&&this.initCanvasFPSObserver(t,r,i,a,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){let a=mo(t,n,r,!0),o=new Map,s=new yo;s.onmessage=e=>{let{id:t}=e.data;if(o.set(t,!1),!(`base64`in e.data))return;let{base64:n,type:r,width:i,height:a}=e.data;this.mutationCb({id:t,type:_a[`2D`],commands:[{property:`clearRect`,args:[0,0,i,a]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:n}],type:r}]},0,0]}]})};let c=1e3/e,l=0,u,d=()=>{let e=[];return t.document.querySelectorAll(`canvas`).forEach(t=>{q(t,n,r,!0)||e.push(t)}),e},f=e=>{if(l&&e-l<c){u=requestAnimationFrame(f);return}l=e,d().forEach(async e=>{let t=this.mirror.getId(e);if(o.get(t)||e.width===0||e.height===0)return;if(o.set(t,!0),[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t.clear(t.COLOR_BUFFER_BIT)}let n=await createImageBitmap(e);s.postMessage({id:t,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])}),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let r=mo(e,t,n,!1),i=fo(this.processMutation.bind(this),e,t,n),a=go(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>{let{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},xo=class{constructor(e){n(this,`trackedLinkElements`,new WeakSet),n(this,`mutationCb`),n(this,`adoptedStyleSheetCb`),n(this,`styleMirror`,new da),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){`_cssText`in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(e.length===0)return;let n={id:t,styleIds:[]},r=[];for(let t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,n)=>({rule:L(e,t.href),index:n}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}},So=class{constructor(){n(this,`nodeMap`,new WeakMap),n(this,`active`,!1)}inOtherBuffer(e,t){let n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},Q,Co,wo,To=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement(`iframe`);document.body.appendChild(e),Array.from=e.contentWindow?.Array.from||Array.from,document.body.removeChild(e)}}catch(e){console.debug(`Unable to override Array.from`,e)}var $=ue();function Eo(e={}){let{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i=`rr-block`,blockSelector:a=null,ignoreClass:o=`rr-ignore`,ignoreSelector:s=null,maskTextClass:c=`rr-mask`,maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:f,slimDOMOptions:p,maskInputFn:m,maskTextFn:h,hooks:g,packFn:_,sampling:v={},dataURLOptions:y={},mousemoveWait:b,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:C=!1,recordAfter:w=e.recordAfter===`DOMContentLoaded`?e.recordAfter:`load`,userTriggeredOnInput:T=!1,collectFonts:E=!1,inlineImages:D=!1,plugins:O,keepIframeSrcFn:k=()=>!1,ignoreCSSAttributes:A=new Set([]),errorHandler:ee}=e;Da(ee);let j=!C||window.parent===window,M=!1;if(!j)try{window.parent.document&&(M=!1)}catch{M=!0}if(j&&!t)throw Error(`emit function is required`);if(!j&&!M)return()=>{};b!==void 0&&v.mousemove===void 0&&(v.mousemove=b),$.reset();let te=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:f===void 0?{password:!0}:f,ne=Ze(p);sa();let N,re=0,P=e=>{for(let t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return _&&!M&&(e=_(e)),e};Q=(e,i)=>{let a=e;if(a.timestamp=qi(),ka[0]?.isFrozen()&&a.type!==J.FullSnapshot&&(a.type!==J.IncrementalSnapshot||a.data.source!==Y.Mutation)&&ka.forEach(e=>e.unfreeze()),j)t?.(P(a),i);else if(M){let e={type:`rrweb`,event:P(a),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,`*`)}if(a.type===J.FullSnapshot)N=a,re=0;else if(a.type===J.IncrementalSnapshot){if(a.data.source===Y.Mutation&&a.data.isAttachIframe)return;re++;let e=r&&re>=r,t=n&&a.timestamp-N.timestamp>n;(e||t)&&Co(!0)}};let F=e=>{Q({type:J.IncrementalSnapshot,data:{source:Y.Mutation,...e}})},ie=e=>Q({type:J.IncrementalSnapshot,data:{source:Y.Scroll,...e}}),ae=e=>Q({type:J.IncrementalSnapshot,data:{source:Y.CanvasMutation,...e}}),I=new xo({mutationCb:F,adoptedStyleSheetCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.AdoptedStyleSheet,...e}})}),L=new $a({mirror:$,mutationCb:F,stylesheetManager:I,recordCrossOriginIframes:C,wrappedEmit:Q});for(let e of O||[])e.getMirror&&e.getMirror({nodeMirror:$,crossOriginIframeMirror:L.crossOriginIframeMirror,crossOriginIframeStyleMirror:L.crossOriginIframeStyleMirror});let oe=new So;wo=new bo({recordCanvas:S,mutationCb:ae,win:window,blockClass:i,blockSelector:a,mirror:$,sampling:v.canvas,dataURLOptions:y});let se=new eo({mutationCb:F,scrollCb:ie,bypassOptions:{blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:te,dataURLOptions:y,maskTextFn:h,maskInputFn:m,recordCanvas:S,inlineImages:D,sampling:v,slimDOMOptions:ne,iframeManager:L,stylesheetManager:I,canvasManager:wo,keepIframeSrcFn:k,processedNodeManager:oe},mirror:$});Co=(e=!1)=>{if(!x)return;Q({type:J.Meta,data:{href:window.location.href,width:ta(),height:ea()}},e),I.reset(),se.init(),ka.forEach(e=>e.lock());let t=et(document,{mirror:$,blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:te,maskTextFn:h,maskInputFn:m,slimDOM:ne,dataURLOptions:y,recordCanvas:S,inlineImages:D,onSerialize:e=>{ca(e,$)&&L.addIframe(e),la(e,$)&&I.trackLinkElement(e),ua(e)&&se.addShadowRoot(G.shadowRoot(e),document)},onIframeLoad:(e,t)=>{L.attachIframe(e,t),se.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{I.attachLinkElement(e,t)},keepIframeSrcFn:k});if(!t)return console.warn(`Failed to snapshot the document`);Q({type:J.FullSnapshot,data:{node:t,initialOffset:$i(window)}},e),ka.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&I.adoptStyleSheets(document.adoptedStyleSheets,$.getId(document))};try{let e=[],t=e=>Z(Ya)({mutationCb:F,mousemoveCb:(e,t)=>Q({type:J.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.MouseInteraction,...e}}),scrollCb:ie,viewportResizeCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.ViewportResize,...e}}),inputCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.Input,...e}}),mediaInteractionCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.MediaInteraction,...e}}),styleSheetRuleCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.StyleSheetRule,...e}}),styleDeclarationCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.StyleDeclaration,...e}}),canvasMutationCb:ae,fontCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.Font,...e}}),selectionCb:e=>{Q({type:J.IncrementalSnapshot,data:{source:Y.Selection,...e}})},customElementCb:e=>{Q({type:J.IncrementalSnapshot,data:{source:Y.CustomElement,...e}})},blockClass:i,ignoreClass:o,ignoreSelector:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:te,inlineStylesheet:u,sampling:v,recordDOM:x,recordCanvas:S,inlineImages:D,userTriggeredOnInput:T,collectFonts:E,doc:e,maskInputFn:m,maskTextFn:h,keepIframeSrcFn:k,blockSelector:a,slimDOMOptions:ne,dataURLOptions:y,mirror:$,iframeManager:L,stylesheetManager:I,shadowDomManager:se,processedNodeManager:oe,canvasManager:wo,ignoreCSSAttributes:A,plugins:(O?.filter(e=>e.observer))?.map(e=>({observer:e.observer,options:e.options,callback:t=>Q({type:J.Plugin,data:{plugin:e.name,payload:t}})}))||[]},g);L.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});let n=()=>{Co(),e.push(t(document)),To=!0};return[`interactive`,`complete`].includes(document.readyState)?n():(e.push(K(`DOMContentLoaded`,()=>{Q({type:J.DomContentLoaded,data:{}}),w===`DOMContentLoaded`&&n()})),e.push(K(`load`,()=>{Q({type:J.Load,data:{}}),w===`load`&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes(`cross-origin`)||console.warn(e)}}),oe.destroy(),To=!1,Oa()}}catch(e){console.warn(e)}}Eo.addCustomEvent=(e,t)=>{if(!To)throw Error(`please add custom event after start recording`);Q({type:J.Custom,data:{tag:e,payload:t}})},Eo.freezePage=()=>{ka.forEach(e=>e.freeze())},Eo.takeFullSnapshot=e=>{if(!To)throw Error(`please take full snapshot after start recording`);Co(e)},Eo.mirror=$;var Do;(function(e){e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`})(Do||={});var{addCustomEvent:Oo}=Eo,{freezePage:ko}=Eo,{takeFullSnapshot:Ao}=Eo,jo=40,Mo=7,No=6e4;async function Po(e){if(typeof CompressionStream>`u`)return null;try{return await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`))).blob()}catch{return null}}function Fo({endpoint:e,onEvent:t=()=>{}}){let n=[],r=!1,i=null,a=!1,o=(e,r)=>{if(e.tries++,e.tries>=Mo)return n.shift(),t({t:`drop`,b:e.b,reason:`retries`}),s();let a=r>0?r*1e3:Math.min(3e4,1e3*2**(e.tries-1))*(.75+Math.random()/2);i=setTimeout(()=>{i=null,s()},a)};async function s(){if(r||i||a||!n.length)return;r=!0;let c=n[0];try{let i=await Po(c.json),s=i||c.json,l=i?i.size:c.json.length,u=await fetch(e,{method:`POST`,body:s,credentials:`omit`,mode:`cors`,headers:{"Content-Type":`text/plain;charset=UTF-8`},keepalive:l<No});if(u.ok)n.shift(),t({t:`ack`,b:c.b});else{let e=``;try{e=(await u.json())?.code||``}catch{}if(e===`session_limit`||e===`session_key`)n.length=0,t({t:`rotate`,code:e});else if(e===`quota_exceeded`||e===`recording_disabled`||u.status===401||u.status===403)n.length=0,a=!0,t({t:`stop`,code:e||String(u.status)});else if(u.status===429||u.status>=500)return r=!1,o(c,Number(u.headers.get(`Retry-After`))||0);else n.shift(),t({t:`drop`,b:c.b,reason:String(u.status)})}}catch{return r=!1,o(c,0)}r=!1,s()}return{push(e){a||(n.push({...e,tries:0}),n.length>jo&&t({t:`drop`,b:n.shift().b,reason:`overflow`}),s())},nudge(){i&&=(clearTimeout(i),null),s()},stop(){a=!0,n.length=0,i&&clearTimeout(i)},pending:()=>n.length}}var Io=`0.2.0`,Lo=e=>(e=e.toLowerCase(),e.startsWith(`data-`)||e===`title`||e===`alt`||e===`placeholder`||e===`aria-label`||e===`value`);function Ro(e){if(e&&typeof e==`object`)for(let t of Object.keys(e))Lo(t)&&typeof e[t]==`string`&&e[t]&&(e[t]=`***`)}function zo(e){e&&typeof e==`object`&&(e.attributes&&Ro(e.attributes),Array.isArray(e.childNodes)&&e.childNodes.forEach(zo))}function Bo(e,t){try{e.type===4&&typeof e.data?.href==`string`?e.data.href=qo(e.data.href,t):e.type===2&&e.data?.node?zo(e.data.node):e.type===3&&e.data&&(Array.isArray(e.data.adds)&&e.data.adds.forEach(e=>zo(e.node)),Array.isArray(e.data.attributes)&&e.data.attributes.forEach(e=>Ro(e.attributes)))}catch{}return e}var Vo=[[/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,`[email]`],[/\beyJ[\w-]{6,}\.[\w-]{6,}\.[\w-]{6,}\b/g,`[jwt]`],[/\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi,`$1 [token]`],[/\b(?:\d[ -]?){13,19}\b/g,`[number]`],[/\b(sk|pk|rk)_(live|test)_[\w]{8,}\b/g,`[key]`]];function Ho(e){let t=String(e??``);for(let[e,n]of Vo)t=t.replace(e,n);return t}function Uo(e){return typeof e==`string`?e:e&&typeof e.href==`string`?e.href:e&&typeof e.url==`string`?e.url:e==null?``:String(e)}var Wo=600,Go=/(?:^|[-_.])(token|secret|password|passwd|auth|authorization|key|apikey|api[-_]?key|session|sid|code|signature|credential|email)s?$/i,Ko=e=>e.split(/[?&=]/)[0];function qo(e,t=!1){let n=String(e??``);try{let e=new URL(n,location.href),r=!1;(e.username||e.password)&&(e.username=``,e.password=``,r=!0),t&&(e.search||Ko(e.hash)!==e.hash)&&(e.search=``,e.hash=Ko(e.hash),r=!0);for(let t of[...e.searchParams.keys()])Go.test(t)&&(e.searchParams.set(t,`***`),r=!0);if(e.hash){let t=e.hash.replace(/([?&#]|^)([^=&?#]+)=([^&#]*)/g,(e,t,n)=>Go.test(n)?`${t}${n}=***`:e);t!==e.hash&&(e.hash=t,r=!0)}let i=Ho(decodeURIComponent(e.pathname));return i!==decodeURIComponent(e.pathname)&&(e.pathname=i,r=!0),r?(/^[a-z][a-z0-9+.-]*:/i.test(n)?e.href:e.pathname+e.search+e.hash).slice(0,Wo):n.slice(0,Wo)}catch{return Ho(t?n.split(`?`)[0]:n).slice(0,Wo)}}var Jo=e=>{try{return new URL(e,location.href).href}catch{return String(e??``)}},Yo=[`content-type`,`content-length`,`content-encoding`,`cache-control`,`etag`,`vary`,`age`,`server-timing`,`x-request-id`];function Xo(e){let t={};for(let n of Yo)try{let r=e(n);r&&(t[n]=String(r).slice(0,200))}catch{}return Object.keys(t).length?t:void 0}function Zo(e,t){try{if(!e)return;if(typeof e.get==`function`)return e.get(t)||void 0;if(Array.isArray(e)){let n=e.find(e=>String(e?.[0]).toLowerCase()===t);return n?String(n[1]):void 0}for(let n of Object.keys(e))if(n.toLowerCase()===t)return String(e[n])}catch{}}function Qo(e){try{return e==null?void 0:typeof e==`string`?e.length:typeof Blob<`u`&&e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?String(e).length:void 0}catch{return}}function $o(e,t,n){typeof performance<`u`&&performance.getEntriesByName&&setTimeout(()=>{try{let r=null;for(let e of performance.getEntriesByName(t,`resource`)){let t=Math.abs(e.startTime-n);t<1500&&(!r||t<Math.abs(r.startTime-n))&&(r=e)}if(!r)return;let i=e.detail||={};if(r.transferSize&&(i.xfer=Math.round(r.transferSize)),r.decodedBodySize&&i.resSize==null&&(i.resSize=Math.round(r.decodedBodySize)),r.responseStart>0){let e=r.secureConnectionStart>0?r.secureConnectionStart:r.connectEnd,t={dns:r.domainLookupEnd-r.domainLookupStart,tcp:e-r.connectStart,tls:r.secureConnectionStart>0?r.connectEnd-r.secureConnectionStart:0,ttfb:r.responseStart-r.requestStart,dl:r.responseEnd-r.responseStart};i.timing={};for(let e of Object.keys(t))t[e]>0&&(i.timing[e]=Math.round(t[e]*10)/10);Object.keys(i.timing).length||delete i.timing}}catch{}},300)}function es(e=`rec_`){return e+(typeof crypto<`u`&&crypto.getRandomValues?Array.from(crypto.getRandomValues(new Uint8Array(12))).map(e=>e.toString(16).padStart(2,`0`)).join(``):Math.abs(Date.now()^performance.now()*1e3|0).toString(16)+Math.random().toString(16).slice(2,10))}function ts(){if(typeof crypto>`u`||!crypto.getRandomValues)return null;let e=crypto.getRandomValues(new Uint8Array(16));return btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}var ns={get(e,t){try{return JSON.parse(window[e].getItem(t))}catch{return null}},set(e,t,n){try{window[e].setItem(t,JSON.stringify(n))}catch{}},del(e,t){try{window[e].removeItem(t)}catch{}}},rs=`specto-optout`,is=`specto-consent`,as=()=>ns.get(`localStorage`,rs)===!0,os=()=>ns.get(`localStorage`,is)===`granted`;function ss(){let e=ns.get(`localStorage`,`specto-vid`);return typeof e!=`string`&&(e=es(`v_`),ns.set(`localStorage`,`specto-vid`,e)),e}var cs=18e5,ls=144e5,us=4e3;async function ds(e,t){if(!e)return null;try{let n=typeof AbortController<`u`?new AbortController:null,r=n&&setTimeout(()=>n.abort(),3e3),i=await fetch(`${e}?key=${encodeURIComponent(t)}`,{credentials:`omit`,signal:n?.signal});return r&&clearTimeout(r),i.ok?await i.json():null}catch{return null}}function fs(e={}){if(typeof window>`u`)return{disabled:!0,reason:`no window`,stop(){}};if(window.__spectoRec&&!window.__spectoRec.disabled)return window.__spectoRec;if(!e.key)throw Error(`Specto: a publishable key is required`);let t=String(e.key),n=e.endpoint||`/api/ingest`,r=e.configUrl===!1?null:e.configUrl||String(n).replace(/\/api\/ingest$/,`/api/sdk/config`),i={disabled:!0,reason:`starting`,sessionId:null,stop(){},flushNow(){},count:()=>0,identify(){},track(){},sessionUrl:()=>null};if(navigator.doNotTrack===`1`||navigator.globalPrivacyControl)return Object.assign(i,{reason:`dnt`});if(as())return Object.assign(i,{reason:`opted-out`});if(e.consent===`required`&&!os())return Object.assign(i,{reason:`consent-required`});let a=ps(e,t,n);return window.__spectoRec=a,ds(r,t).then(e=>a._begin(e)).catch(()=>a._begin(null)),a}function ps(e,t,n){let r=[],i=0,a=!1,o=!1,s=null,c=[],l=performance.now(),u=()=>Math.round(performance.now()-l),d=`specto-session:${t}`,f=null,p=null,m=null,h=!1,g=[],_=null,v=Date.now(),y=[],b=(t,n)=>{if(!o){if(!a){y.length<50&&y.push([t,n]);return}r.push({kind:t,payload:n}),i++,e.onUpdate?.({total:i,kind:t})}},x=()=>ns.set(`sessionStorage`,d,f);function S(e){let t=Date.now(),n=e?null:ns.get(`sessionStorage`,d),r=!!(n&&typeof n.id==`string`&&t-n.active<cs&&t-n.started<ls);if(r)f=n;else{let e=Math.max(0,Math.min(1,p.sampleRate));f={id:es(),sk:ts(),b:0,started:t,active:t,sampled:Math.random()<e}}return f.active=t,x(),r}function C(){if(E(),S(!0),!f.sampled)return k.stop(`not-sampled`);try{Eo.takeFullSnapshot(!0)}catch{}}function w(e){if(!e.length||!f?.sampled)return;let n={b:f.b++,json:JSON.stringify({key:t,sessionId:f.id,...f.sk?{sk:f.sk}:{},b:f.b-1,sdk:Io,meta:{page:qo(location.pathname),userAgent:navigator.userAgent,visitorId:ss()},events:e})};f.active=Math.max(f.active,v),x(),m?(m.postMessage({t:`upload`,item:n}),h||g.push(n)):_.push(n)}function T(){if(!_){try{m?.terminate()}catch{}m=null,_=Fo({endpoint:n,onEvent:D});for(let e of g.splice(0))_.push(e)}}function E(){if(!r.length)return;let e=r;r=[],w(e)}function D(t){t.t===`stop`?k.stop(t.code):t.t===`rotate`&&C(),e.onDelivery?.(t)}function O(){if(!r.length||!navigator.sendBeacon||!f?.sampled)return;let e=r;r=[];let i=[],a=0,o=()=>{if(!i.length)return;let e=JSON.stringify({key:t,sessionId:f.id,...f.sk?{sk:f.sk}:{},b:f.b++,sdk:Io,meta:{page:qo(location.pathname)},events:i});try{navigator.sendBeacon(n,new Blob([e],{type:`text/plain;charset=UTF-8`}))}catch{}i=[],a=0};for(let t of e){let e=JSON.stringify(t).length;a+e>55e3&&o(),!(e>55e3)&&(i.push(t),a+=e)}o(),x()}let k={disabled:!1,get sessionId(){return f?.id||null},count:()=>i,flushNow:()=>E(),identify(e,t){e!=null&&e!==``&&b(`identify`,{id:String(e).slice(0,256),traits:t&&typeof t==`object`?t:void 0})},track(e,t){e&&b(`event`,{t:u(),type:`custom`,name:String(e).slice(0,120),props:t&&typeof t==`object`?JSON.parse(JSON.stringify(t,(e,t)=>typeof t==`string`?Ho(t).slice(0,500):t)):void 0})},sessionUrl(){try{return f?`${new URL(n,location.href).origin}/#replay/${f.id}`:null}catch{return null}},stop(e){if(o)return;o=!0,k.disabled=!0,k.reason=e||`stopped`;try{s?.()}catch{}for(let e of c.splice(0))try{e()}catch{}E(),m&&!h&&g.length&&T();let t=m;t&&setTimeout(()=>t.terminate(),2e3),window.__spectoRec===k&&delete window.__spectoRec},_begin(t){if(o||a)return;let r=t&&typeof t==`object`?t:{};if(r.enabled===!1)return k.stop(`recording-disabled`);p={strict:e.privacy===`strict`||r.privacy===`strict`,console:e.console!==!1&&r.captureConsole!==!1,networkDetails:e.networkDetails!==!1&&r.captureNetworkDetails!==!1,sampleRate:Math.min(e.sampleRate??1,typeof r.sampleRate==`number`?r.sampleRate:1)};let i=S(!1);if(!f.sampled)return k.stop(`not-sampled`);a=!0;for(let[e,t]of y.splice(0))b(e,t);try{if(m=e.createWorker?e.createWorker():null,m){m.onmessage=e=>{let t=e.data||{};if(t.t===`ready`){h=!0,g=[];return}D(t)},m.onerror=()=>{h||T()},m.postMessage({t:`init`,endpoint:n});let e=setTimeout(()=>{h||T()},us);c.push(()=>clearTimeout(e))}}catch{m=null}m||(_=Fo({endpoint:n,onEvent:D})),A(i);let s=setInterval(E,2e3);c.push(()=>clearInterval(s))}};function A(t){s=Eo({emit:e=>b(`dom`,Bo(e,p.strict)),maskAllInputs:!0,maskInputOptions:{password:!0,email:!0,tel:!0,color:!1},maskTextClass:`specto-mask`,maskTextSelector:p.strict?`*`:void 0,blockClass:`specto-block`,recordCanvas:!1,collectFonts:!1,checkoutEveryNms:3e5,sampling:{mousemove:50,scroll:150,input:`last`}});let r=()=>{let e=Date.now();if(e-v>cs){v=e,C();return}v=e};for(let e of[`click`,`keydown`,`scroll`,`pointerdown`])window.addEventListener(e,r,{capture:!0,passive:!0}),c.push(()=>window.removeEventListener(e,r,{capture:!0}));if(p.console)for(let e of[`log`,`info`,`warn`,`error`]){let t=console[e];console[e]=(...n)=>{try{b(`console`,{t:u(),level:e,text:p.strict?`[masked]`:Ho(n.map(_s).join(` `)).slice(0,2e3)})}catch{}t.apply(console,n)},c.push(()=>{console[e]=t})}if(p.networkDetails)try{performance.setResourceTimingBufferSize?.(1e3)}catch{}let i=window.fetch,a=null;try{a=new URL(n,location.href).href.split(/[?#]/)[0]}catch{}let o=e=>{try{return a!=null&&new URL(e,location.href).href.split(/[?#]/)[0]===a}catch{return!1}},l=new Set((Array.isArray(e.traceOrigins)?e.traceOrigins:[]).map(e=>{try{return new URL(e).origin}catch{return null}}).filter(Boolean)),d=!!e.traces||l.size>0,f=e=>{if(!d)return!1;try{let t=new URL(e,location.href).origin;return t===location.origin||l.has(t)}catch{return!1}},h=e=>{try{let[t,n]=e,r=typeof Request<`u`&&t instanceof Request,i=new Headers(n?.headers??(r?t.headers:void 0)),a=hs.exec(i.get(`traceparent`)||``);if(a)return[e,a[1].toLowerCase()];let o=ms(16);return i.set(`traceparent`,`00-${o}-${ms(8)}-01`),[[t,{...n,headers:i}],o]}catch{return[e,void 0]}};window.fetch=async(...e)=>{if(o(Uo(e[0])))return i.apply(window,e);let t=performance.now(),n=Uo(e[0]),r=qo(n,p.strict),a=(e[1]?.method||typeof e[0]!=`string`&&e[0]?.method||`GET`).toUpperCase(),s;f(n)&&([e,s]=h(e));try{let o=await i.apply(window,e),c=s;try{c=c||o.headers.get(`x-trace-id`)||void 0}catch{}let l={t:u(),method:a,url:r,status:o.status,dur:Math.round(performance.now()-t),...c?{traceId:c}:{}};if(p.networkDetails){let r={initiator:`fetch`};try{o.statusText&&(r.statusText=String(o.statusText).slice(0,80));let t=Xo(e=>o.headers.get(e));t&&(r.headers=t),t?.[`content-type`]&&(r.resType=t[`content-type`].split(`;`)[0]);let n=Number(t?.[`content-length`]);t?.[`content-length`]!=null&&Number.isFinite(n)&&(r.resSize=n);let i=Zo((e[1]||(typeof e[0]==`object`?e[0]:null))?.headers,`content-type`);i&&(r.reqType=i.split(`;`)[0].slice(0,80));let a=Qo(e[1]?.body);a!=null&&(r.reqSize=a)}catch{}l.detail=r,$o(l,Jo(n),t)}return b(`network`,l),o}catch(e){throw b(`network`,{t:u(),method:a,url:r,status:0,dur:Math.round(performance.now()-t),error:!0,...p.networkDetails?{detail:{initiator:`fetch`,message:Ho(String(e?.message||e)).slice(0,200)}}:{}}),e}},c.push(()=>{window.fetch=i});let g=window.XMLHttpRequest,y=g.prototype.open,x=g.prototype.send,S=g.prototype.setRequestHeader;g.prototype.open=function(e,t){return this.__specto={method:String(e).toUpperCase(),url:qo(t,p.strict),rawUrl:Jo(t),started:0,trace:f(t)},y.apply(this,arguments)},g.prototype.setRequestHeader=function(e,t){let n=String(e).toLowerCase();if(this.__specto&&n===`content-type`&&(this.__specto.reqType=String(t).split(`;`)[0].slice(0,80)),this.__specto&&n===`traceparent`){let e=hs.exec(String(t));e&&(this.__specto.traceId=e[1].toLowerCase()),this.__specto.trace=!1}return S.apply(this,arguments)},g.prototype.send=function(e){if(this.__specto){if(this.__specto.trace)try{let e=ms(16);S.call(this,`traceparent`,`00-${e}-${ms(8)}-01`),this.__specto.traceId=e}catch{}this.__specto.started=performance.now(),p.networkDetails&&(this.__specto.reqSize=Qo(e)),this.addEventListener(`loadend`,()=>{let e=this.__specto,t=e.traceId;try{t=t||this.getResponseHeader(`x-trace-id`)||void 0}catch{}let n={t:u(),method:e.method,url:e.url,status:this.status,dur:Math.round(performance.now()-e.started),...t?{traceId:t}:{},...this.status===0?{error:!0}:{}};if(p.networkDetails){let t={initiator:`xhr`};try{this.statusText&&(t.statusText=String(this.statusText).slice(0,80));let n=Xo(e=>this.getResponseHeader(e));n&&(t.headers=n),n?.[`content-type`]&&(t.resType=n[`content-type`].split(`;`)[0]);let r=Number(n?.[`content-length`]);n?.[`content-length`]!=null&&Number.isFinite(r)&&(t.resSize=r),e.reqType&&(t.reqType=e.reqType),e.reqSize!=null&&(t.reqSize=e.reqSize)}catch{}n.detail=t,$o(n,e.rawUrl,e.started)}b(`network`,n)})}return x.apply(this,arguments)},c.push(()=>{g.prototype.open=y,g.prototype.send=x,g.prototype.setRequestHeader=S});let w=e=>{let t=e.error||e.reason,n=t?.stack?Ho(String(t.stack)).split(`
|
|
134
|
+
`,vo=typeof self<`u`&&self.Blob&&new Blob([_o],{type:`text/javascript;charset=utf-8`});function yo(e){let t;try{if(t=vo&&(self.URL||self.webkitURL).createObjectURL(vo),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(_o),{name:e?.name})}finally{t&&(self.URL||self.webkitURL).revokeObjectURL(t)}}var bo=class{constructor(e){n(this,`pendingCanvasMutations`,new Map),n(this,`rafStamps`,{latestId:0,invokeId:null}),n(this,`mirror`),n(this,`mutationCb`),n(this,`resetObservers`),n(this,`frozen`,!1),n(this,`locked`,!1),n(this,`processMutation`,(e,t)=>{(this.rafStamps.invokeId&&this.rafStamps.latestId!==this.rafStamps.invokeId||!this.rafStamps.invokeId)&&(this.rafStamps.invokeId=this.rafStamps.latestId),this.pendingCanvasMutations.has(e)||this.pendingCanvasMutations.set(e,[]),this.pendingCanvasMutations.get(e).push(t)});let{sampling:t=`all`,win:r,blockClass:i,blockSelector:a,recordCanvas:o,dataURLOptions:s}=e;this.mutationCb=e.mutationCb,this.mirror=e.mirror,o&&t===`all`&&this.initCanvasMutationObserver(r,i,a),o&&typeof t==`number`&&this.initCanvasFPSObserver(t,r,i,a,{dataURLOptions:s})}reset(){this.pendingCanvasMutations.clear(),this.resetObservers&&this.resetObservers()}freeze(){this.frozen=!0}unfreeze(){this.frozen=!1}lock(){this.locked=!0}unlock(){this.locked=!1}initCanvasFPSObserver(e,t,n,r,i){let a=mo(t,n,r,!0),o=new Map,s=new yo;s.onmessage=e=>{let{id:t}=e.data;if(o.set(t,!1),!(`base64`in e.data))return;let{base64:n,type:r,width:i,height:a}=e.data;this.mutationCb({id:t,type:_a[`2D`],commands:[{property:`clearRect`,args:[0,0,i,a]},{property:`drawImage`,args:[{rr_type:`ImageBitmap`,args:[{rr_type:`Blob`,data:[{rr_type:`ArrayBuffer`,base64:n}],type:r}]},0,0]}]})};let c=1e3/e,l=0,u,d=()=>{let e=[];return t.document.querySelectorAll(`canvas`).forEach(t=>{q(t,n,r,!0)||e.push(t)}),e},f=e=>{if(l&&e-l<c){u=requestAnimationFrame(f);return}l=e,d().forEach(async e=>{let t=this.mirror.getId(e);if(o.get(t)||e.width===0||e.height===0)return;if(o.set(t,!0),[`webgl`,`webgl2`].includes(e.__context)){let t=e.getContext(e.__context);t?.getContextAttributes()?.preserveDrawingBuffer===!1&&t.clear(t.COLOR_BUFFER_BIT)}let n=await createImageBitmap(e);s.postMessage({id:t,bitmap:n,width:e.width,height:e.height,dataURLOptions:i.dataURLOptions},[n])}),u=requestAnimationFrame(f)};u=requestAnimationFrame(f),this.resetObservers=()=>{a(),cancelAnimationFrame(u)}}initCanvasMutationObserver(e,t,n){this.startRAFTimestamping(),this.startPendingCanvasMutationFlusher();let r=mo(e,t,n,!1),i=fo(this.processMutation.bind(this),e,t,n),a=go(this.processMutation.bind(this),e,t,n);this.resetObservers=()=>{r(),i(),a()}}startPendingCanvasMutationFlusher(){requestAnimationFrame(()=>this.flushPendingCanvasMutations())}startRAFTimestamping(){let e=t=>{this.rafStamps.latestId=t,requestAnimationFrame(e)};requestAnimationFrame(e)}flushPendingCanvasMutations(){this.pendingCanvasMutations.forEach((e,t)=>{let n=this.mirror.getId(t);this.flushPendingCanvasMutationFor(t,n)}),requestAnimationFrame(()=>this.flushPendingCanvasMutations())}flushPendingCanvasMutationFor(e,t){if(this.frozen||this.locked)return;let n=this.pendingCanvasMutations.get(e);if(!n||t===-1)return;let r=n.map(e=>{let{type:t,...n}=e;return n}),{type:i}=n[0];this.mutationCb({id:t,type:i,commands:r}),this.pendingCanvasMutations.delete(e)}},xo=class{constructor(e){n(this,`trackedLinkElements`,new WeakSet),n(this,`mutationCb`),n(this,`adoptedStyleSheetCb`),n(this,`styleMirror`,new da),this.mutationCb=e.mutationCb,this.adoptedStyleSheetCb=e.adoptedStyleSheetCb}attachLinkElement(e,t){`_cssText`in t.attributes&&this.mutationCb({adds:[],removes:[],texts:[],attributes:[{id:t.id,attributes:t.attributes}]}),this.trackLinkElement(e)}trackLinkElement(e){this.trackedLinkElements.has(e)||(this.trackedLinkElements.add(e),this.trackStylesheetInLinkElement(e))}adoptStyleSheets(e,t){if(e.length===0)return;let n={id:t,styleIds:[]},r=[];for(let t of e){let e;this.styleMirror.has(t)?e=this.styleMirror.getId(t):(e=this.styleMirror.add(t),r.push({styleId:e,rules:Array.from(t.rules||CSSRule,(e,n)=>({rule:L(e,t.href),index:n}))})),n.styleIds.push(e)}r.length>0&&(n.styles=r),this.adoptedStyleSheetCb(n)}reset(){this.styleMirror.reset(),this.trackedLinkElements=new WeakSet}trackStylesheetInLinkElement(e){}},So=class{constructor(){n(this,`nodeMap`,new WeakMap),n(this,`active`,!1)}inOtherBuffer(e,t){let n=this.nodeMap.get(e);return n&&Array.from(n).some(e=>e!==t)}add(e,t){this.active||(this.active=!0,requestAnimationFrame(()=>{this.nodeMap=new WeakMap,this.active=!1})),this.nodeMap.set(e,(this.nodeMap.get(e)||new Set).add(t))}destroy(){}},Q,Co,wo,To=!1;try{if(Array.from([1],e=>e*2)[0]!==2){let e=document.createElement(`iframe`);document.body.appendChild(e),Array.from=e.contentWindow?.Array.from||Array.from,document.body.removeChild(e)}}catch(e){console.debug(`Unable to override Array.from`,e)}var $=ue();function Eo(e={}){let{emit:t,checkoutEveryNms:n,checkoutEveryNth:r,blockClass:i=`rr-block`,blockSelector:a=null,ignoreClass:o=`rr-ignore`,ignoreSelector:s=null,maskTextClass:c=`rr-mask`,maskTextSelector:l=null,inlineStylesheet:u=!0,maskAllInputs:d,maskInputOptions:f,slimDOMOptions:p,maskInputFn:m,maskTextFn:h,hooks:g,packFn:_,sampling:v={},dataURLOptions:y={},mousemoveWait:b,recordDOM:x=!0,recordCanvas:S=!1,recordCrossOriginIframes:C=!1,recordAfter:w=e.recordAfter===`DOMContentLoaded`?e.recordAfter:`load`,userTriggeredOnInput:T=!1,collectFonts:E=!1,inlineImages:D=!1,plugins:O,keepIframeSrcFn:k=()=>!1,ignoreCSSAttributes:A=new Set([]),errorHandler:ee}=e;Da(ee);let j=!C||window.parent===window,M=!1;if(!j)try{window.parent.document&&(M=!1)}catch{M=!0}if(j&&!t)throw Error(`emit function is required`);if(!j&&!M)return()=>{};b!==void 0&&v.mousemove===void 0&&(v.mousemove=b),$.reset();let te=d===!0?{color:!0,date:!0,"datetime-local":!0,email:!0,month:!0,number:!0,range:!0,search:!0,tel:!0,text:!0,time:!0,url:!0,week:!0,textarea:!0,select:!0,password:!0}:f===void 0?{password:!0}:f,ne=Ze(p);sa();let N,re=0,P=e=>{for(let t of O||[])t.eventProcessor&&(e=t.eventProcessor(e));return _&&!M&&(e=_(e)),e};Q=(e,i)=>{let a=e;if(a.timestamp=qi(),ka[0]?.isFrozen()&&a.type!==J.FullSnapshot&&(a.type!==J.IncrementalSnapshot||a.data.source!==Y.Mutation)&&ka.forEach(e=>e.unfreeze()),j)t?.(P(a),i);else if(M){let e={type:`rrweb`,event:P(a),origin:window.location.origin,isCheckout:i};window.parent.postMessage(e,`*`)}if(a.type===J.FullSnapshot)N=a,re=0;else if(a.type===J.IncrementalSnapshot){if(a.data.source===Y.Mutation&&a.data.isAttachIframe)return;re++;let e=r&&re>=r,t=n&&a.timestamp-N.timestamp>n;(e||t)&&Co(!0)}};let F=e=>{Q({type:J.IncrementalSnapshot,data:{source:Y.Mutation,...e}})},ie=e=>Q({type:J.IncrementalSnapshot,data:{source:Y.Scroll,...e}}),ae=e=>Q({type:J.IncrementalSnapshot,data:{source:Y.CanvasMutation,...e}}),I=new xo({mutationCb:F,adoptedStyleSheetCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.AdoptedStyleSheet,...e}})}),L=new $a({mirror:$,mutationCb:F,stylesheetManager:I,recordCrossOriginIframes:C,wrappedEmit:Q});for(let e of O||[])e.getMirror&&e.getMirror({nodeMirror:$,crossOriginIframeMirror:L.crossOriginIframeMirror,crossOriginIframeStyleMirror:L.crossOriginIframeStyleMirror});let oe=new So;wo=new bo({recordCanvas:S,mutationCb:ae,win:window,blockClass:i,blockSelector:a,mirror:$,sampling:v.canvas,dataURLOptions:y});let se=new eo({mutationCb:F,scrollCb:ie,bypassOptions:{blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskInputOptions:te,dataURLOptions:y,maskTextFn:h,maskInputFn:m,recordCanvas:S,inlineImages:D,sampling:v,slimDOMOptions:ne,iframeManager:L,stylesheetManager:I,canvasManager:wo,keepIframeSrcFn:k,processedNodeManager:oe},mirror:$});Co=(e=!1)=>{if(!x)return;Q({type:J.Meta,data:{href:window.location.href,width:ta(),height:ea()}},e),I.reset(),se.init(),ka.forEach(e=>e.lock());let t=et(document,{mirror:$,blockClass:i,blockSelector:a,maskTextClass:c,maskTextSelector:l,inlineStylesheet:u,maskAllInputs:te,maskTextFn:h,maskInputFn:m,slimDOM:ne,dataURLOptions:y,recordCanvas:S,inlineImages:D,onSerialize:e=>{ca(e,$)&&L.addIframe(e),la(e,$)&&I.trackLinkElement(e),ua(e)&&se.addShadowRoot(G.shadowRoot(e),document)},onIframeLoad:(e,t)=>{L.attachIframe(e,t),se.observeAttachShadow(e)},onStylesheetLoad:(e,t)=>{I.attachLinkElement(e,t)},keepIframeSrcFn:k});if(!t)return console.warn(`Failed to snapshot the document`);Q({type:J.FullSnapshot,data:{node:t,initialOffset:$i(window)}},e),ka.forEach(e=>e.unlock()),document.adoptedStyleSheets&&document.adoptedStyleSheets.length>0&&I.adoptStyleSheets(document.adoptedStyleSheets,$.getId(document))};try{let e=[],t=e=>Z(Ya)({mutationCb:F,mousemoveCb:(e,t)=>Q({type:J.IncrementalSnapshot,data:{source:t,positions:e}}),mouseInteractionCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.MouseInteraction,...e}}),scrollCb:ie,viewportResizeCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.ViewportResize,...e}}),inputCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.Input,...e}}),mediaInteractionCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.MediaInteraction,...e}}),styleSheetRuleCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.StyleSheetRule,...e}}),styleDeclarationCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.StyleDeclaration,...e}}),canvasMutationCb:ae,fontCb:e=>Q({type:J.IncrementalSnapshot,data:{source:Y.Font,...e}}),selectionCb:e=>{Q({type:J.IncrementalSnapshot,data:{source:Y.Selection,...e}})},customElementCb:e=>{Q({type:J.IncrementalSnapshot,data:{source:Y.CustomElement,...e}})},blockClass:i,ignoreClass:o,ignoreSelector:s,maskTextClass:c,maskTextSelector:l,maskInputOptions:te,inlineStylesheet:u,sampling:v,recordDOM:x,recordCanvas:S,inlineImages:D,userTriggeredOnInput:T,collectFonts:E,doc:e,maskInputFn:m,maskTextFn:h,keepIframeSrcFn:k,blockSelector:a,slimDOMOptions:ne,dataURLOptions:y,mirror:$,iframeManager:L,stylesheetManager:I,shadowDomManager:se,processedNodeManager:oe,canvasManager:wo,ignoreCSSAttributes:A,plugins:(O?.filter(e=>e.observer))?.map(e=>({observer:e.observer,options:e.options,callback:t=>Q({type:J.Plugin,data:{plugin:e.name,payload:t}})}))||[]},g);L.addLoadListener(n=>{try{e.push(t(n.contentDocument))}catch(e){console.warn(e)}});let n=()=>{Co(),e.push(t(document)),To=!0};return[`interactive`,`complete`].includes(document.readyState)?n():(e.push(K(`DOMContentLoaded`,()=>{Q({type:J.DomContentLoaded,data:{}}),w===`DOMContentLoaded`&&n()})),e.push(K(`load`,()=>{Q({type:J.Load,data:{}}),w===`load`&&n()},window))),()=>{e.forEach(e=>{try{e()}catch(e){String(e).toLowerCase().includes(`cross-origin`)||console.warn(e)}}),oe.destroy(),To=!1,Oa()}}catch(e){console.warn(e)}}Eo.addCustomEvent=(e,t)=>{if(!To)throw Error(`please add custom event after start recording`);Q({type:J.Custom,data:{tag:e,payload:t}})},Eo.freezePage=()=>{ka.forEach(e=>e.freeze())},Eo.takeFullSnapshot=e=>{if(!To)throw Error(`please take full snapshot after start recording`);Co(e)},Eo.mirror=$;var Do;(function(e){e[e.NotStarted=0]=`NotStarted`,e[e.Running=1]=`Running`,e[e.Stopped=2]=`Stopped`})(Do||={});var{addCustomEvent:Oo}=Eo,{freezePage:ko}=Eo,{takeFullSnapshot:Ao}=Eo,jo=40,Mo=7,No=6e4;async function Po(e){if(typeof CompressionStream>`u`)return null;try{return await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`))).blob()}catch{return null}}function Fo({endpoint:e,onEvent:t=()=>{}}){let n=[],r=!1,i=null,a=!1,o=(e,r)=>{if(e.tries++,e.tries>=Mo)return n.shift(),t({t:`drop`,b:e.b,reason:`retries`}),s();let a=r>0?r*1e3:Math.min(3e4,1e3*2**(e.tries-1))*(.75+Math.random()/2);i=setTimeout(()=>{i=null,s()},a)};async function s(){if(r||i||a||!n.length)return;r=!0;let c=n[0];try{let i=await Po(c.json),s=i||c.json,l=i?i.size:c.json.length,u=await fetch(e,{method:`POST`,body:s,credentials:`omit`,mode:`cors`,headers:{"Content-Type":`text/plain;charset=UTF-8`},keepalive:l<No});if(u.ok)n.shift(),t({t:`ack`,b:c.b});else{let e=``;try{e=(await u.json())?.code||``}catch{}if(e===`session_limit`||e===`session_key`)n.length=0,t({t:`rotate`,code:e});else if(e===`quota_exceeded`||e===`recording_disabled`||u.status===401||u.status===403)n.length=0,a=!0,t({t:`stop`,code:e||String(u.status)});else if(u.status===429||u.status>=500)return r=!1,o(c,Number(u.headers.get(`Retry-After`))||0);else n.shift(),t({t:`drop`,b:c.b,reason:String(u.status)})}}catch{return r=!1,o(c,0)}r=!1,s()}return{push(e){a||(n.push({...e,tries:0}),n.length>jo&&t({t:`drop`,b:n.shift().b,reason:`overflow`}),s())},nudge(){i&&=(clearTimeout(i),null),s()},stop(){a=!0,n.length=0,i&&clearTimeout(i)},pending:()=>n.length}}var Io=`0.2.1`,Lo=e=>(e=e.toLowerCase(),e.startsWith(`data-`)||e===`title`||e===`alt`||e===`placeholder`||e===`aria-label`||e===`value`);function Ro(e){if(e&&typeof e==`object`)for(let t of Object.keys(e))Lo(t)&&typeof e[t]==`string`&&e[t]&&(e[t]=`***`)}function zo(e){e&&typeof e==`object`&&(e.attributes&&Ro(e.attributes),Array.isArray(e.childNodes)&&e.childNodes.forEach(zo))}function Bo(e,t){try{e.type===4&&typeof e.data?.href==`string`?e.data.href=qo(e.data.href,t):e.type===2&&e.data?.node?zo(e.data.node):e.type===3&&e.data&&(Array.isArray(e.data.adds)&&e.data.adds.forEach(e=>zo(e.node)),Array.isArray(e.data.attributes)&&e.data.attributes.forEach(e=>Ro(e.attributes)))}catch{}return e}var Vo=[[/[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,}/gi,`[email]`],[/\beyJ[\w-]{6,}\.[\w-]{6,}\.[\w-]{6,}\b/g,`[jwt]`],[/\b(Bearer|Basic)\s+[\w.~+/=-]{8,}/gi,`$1 [token]`],[/\b(?:\d[ -]?){13,19}\b/g,`[number]`],[/\b(sk|pk|rk)_(live|test)_[\w]{8,}\b/g,`[key]`]];function Ho(e){let t=String(e??``);for(let[e,n]of Vo)t=t.replace(e,n);return t}function Uo(e){return typeof e==`string`?e:e&&typeof e.href==`string`?e.href:e&&typeof e.url==`string`?e.url:e==null?``:String(e)}var Wo=600,Go=/(?:^|[-_.])(token|secret|password|passwd|auth|authorization|key|apikey|api[-_]?key|session|sid|code|signature|credential|email)s?$/i,Ko=e=>e.split(/[?&=]/)[0];function qo(e,t=!1){let n=String(e??``);try{let e=new URL(n,location.href),r=!1;(e.username||e.password)&&(e.username=``,e.password=``,r=!0),t&&(e.search||Ko(e.hash)!==e.hash)&&(e.search=``,e.hash=Ko(e.hash),r=!0);for(let t of[...e.searchParams.keys()])Go.test(t)&&(e.searchParams.set(t,`***`),r=!0);if(e.hash){let t=e.hash.replace(/([?&#]|^)([^=&?#]+)=([^&#]*)/g,(e,t,n)=>Go.test(n)?`${t}${n}=***`:e);t!==e.hash&&(e.hash=t,r=!0)}let i=Ho(decodeURIComponent(e.pathname));return i!==decodeURIComponent(e.pathname)&&(e.pathname=i,r=!0),r?(/^[a-z][a-z0-9+.-]*:/i.test(n)?e.href:e.pathname+e.search+e.hash).slice(0,Wo):n.slice(0,Wo)}catch{return Ho(t?n.split(`?`)[0]:n).slice(0,Wo)}}var Jo=e=>{try{return new URL(e,location.href).href}catch{return String(e??``)}},Yo=[`content-type`,`content-length`,`content-encoding`,`cache-control`,`etag`,`vary`,`age`,`server-timing`,`x-request-id`];function Xo(e){let t={};for(let n of Yo)try{let r=e(n);r&&(t[n]=String(r).slice(0,200))}catch{}return Object.keys(t).length?t:void 0}function Zo(e,t){try{if(!e)return;if(typeof e.get==`function`)return e.get(t)||void 0;if(Array.isArray(e)){let n=e.find(e=>String(e?.[0]).toLowerCase()===t);return n?String(n[1]):void 0}for(let n of Object.keys(e))if(n.toLowerCase()===t)return String(e[n])}catch{}}function Qo(e){try{return e==null?void 0:typeof e==`string`?e.length:typeof Blob<`u`&&e instanceof Blob?e.size:e instanceof ArrayBuffer||ArrayBuffer.isView(e)?e.byteLength:typeof URLSearchParams<`u`&&e instanceof URLSearchParams?String(e).length:void 0}catch{return}}function $o(e,t,n){typeof performance<`u`&&performance.getEntriesByName&&setTimeout(()=>{try{let r=null;for(let e of performance.getEntriesByName(t,`resource`)){let t=Math.abs(e.startTime-n);t<1500&&(!r||t<Math.abs(r.startTime-n))&&(r=e)}if(!r)return;let i=e.detail||={};if(r.transferSize&&(i.xfer=Math.round(r.transferSize)),r.decodedBodySize&&i.resSize==null&&(i.resSize=Math.round(r.decodedBodySize)),r.responseStart>0){let e=r.secureConnectionStart>0?r.secureConnectionStart:r.connectEnd,t={dns:r.domainLookupEnd-r.domainLookupStart,tcp:e-r.connectStart,tls:r.secureConnectionStart>0?r.connectEnd-r.secureConnectionStart:0,ttfb:r.responseStart-r.requestStart,dl:r.responseEnd-r.responseStart};i.timing={};for(let e of Object.keys(t))t[e]>0&&(i.timing[e]=Math.round(t[e]*10)/10);Object.keys(i.timing).length||delete i.timing}}catch{}},300)}function es(e=`rec_`){return e+(typeof crypto<`u`&&crypto.getRandomValues?Array.from(crypto.getRandomValues(new Uint8Array(12))).map(e=>e.toString(16).padStart(2,`0`)).join(``):Math.abs(Date.now()^performance.now()*1e3|0).toString(16)+Math.random().toString(16).slice(2,10))}function ts(){if(typeof crypto>`u`||!crypto.getRandomValues)return null;let e=crypto.getRandomValues(new Uint8Array(16));return btoa(String.fromCharCode(...e)).replace(/\+/g,`-`).replace(/\//g,`_`).replace(/=+$/,``)}var ns={get(e,t){try{return JSON.parse(window[e].getItem(t))}catch{return null}},set(e,t,n){try{window[e].setItem(t,JSON.stringify(n))}catch{}},del(e,t){try{window[e].removeItem(t)}catch{}}},rs=`specto-optout`,is=`specto-consent`,as=()=>ns.get(`localStorage`,rs)===!0,os=()=>ns.get(`localStorage`,is)===`granted`;function ss(){let e=ns.get(`localStorage`,`specto-vid`);return typeof e!=`string`&&(e=es(`v_`),ns.set(`localStorage`,`specto-vid`,e)),e}var cs=18e5,ls=144e5,us=4e3;async function ds(e,t){if(!e)return null;try{let n=typeof AbortController<`u`?new AbortController:null,r=n&&setTimeout(()=>n.abort(),3e3),i=await fetch(`${e}?key=${encodeURIComponent(t)}`,{credentials:`omit`,signal:n?.signal});return r&&clearTimeout(r),i.ok?await i.json():null}catch{return null}}function fs(e={}){if(typeof window>`u`)return{disabled:!0,reason:`no window`,stop(){}};if(window.__spectoRec&&!window.__spectoRec.disabled)return window.__spectoRec;if(!e.key)throw Error(`Specto: a publishable key is required`);let t=String(e.key),n=e.endpoint||`/api/ingest`,r=e.configUrl===!1?null:e.configUrl||String(n).replace(/\/api\/ingest$/,`/api/sdk/config`),i={disabled:!0,reason:`starting`,sessionId:null,stop(){},flushNow(){},count:()=>0,identify(){},track(){},sessionUrl:()=>null};if(navigator.doNotTrack===`1`||navigator.globalPrivacyControl)return Object.assign(i,{reason:`dnt`});if(as())return Object.assign(i,{reason:`opted-out`});if(e.consent===`required`&&!os())return Object.assign(i,{reason:`consent-required`});let a=ps(e,t,n);return window.__spectoRec=a,ds(r,t).then(e=>a._begin(e)).catch(()=>a._begin(null)),a}function ps(e,t,n){let r=[],i=0,a=!1,o=!1,s=null,c=[],l=performance.now(),u=()=>Math.round(performance.now()-l),d=`specto-session:${t}`,f=null,p=null,m=null,h=!1,g=[],_=null,v=Date.now(),y=[],b=(t,n)=>{if(!o){if(!a){y.length<50&&y.push([t,n]);return}r.push({kind:t,payload:n}),i++,e.onUpdate?.({total:i,kind:t})}},x=()=>ns.set(`sessionStorage`,d,f);function S(e){let t=Date.now(),n=e?null:ns.get(`sessionStorage`,d),r=!!(n&&typeof n.id==`string`&&t-n.active<cs&&t-n.started<ls);if(r)f=n;else{let e=Math.max(0,Math.min(1,p.sampleRate));f={id:es(),sk:ts(),b:0,started:t,active:t,sampled:Math.random()<e}}return f.active=t,x(),r}function C(){if(E(),S(!0),!f.sampled)return k.stop(`not-sampled`);try{Eo.takeFullSnapshot(!0)}catch{}}function w(e){if(!e.length||!f?.sampled)return;let n={b:f.b++,json:JSON.stringify({key:t,sessionId:f.id,...f.sk?{sk:f.sk}:{},b:f.b-1,sdk:Io,meta:{page:qo(location.pathname),userAgent:navigator.userAgent,visitorId:ss()},events:e})};f.active=Math.max(f.active,v),x(),m?(m.postMessage({t:`upload`,item:n}),h||g.push(n)):_.push(n)}function T(){if(!_){try{m?.terminate()}catch{}m=null,_=Fo({endpoint:n,onEvent:D});for(let e of g.splice(0))_.push(e)}}function E(){if(!r.length)return;let e=r;r=[],w(e)}function D(t){t.t===`stop`?k.stop(t.code):t.t===`rotate`&&C(),e.onDelivery?.(t)}function O(){if(!r.length||!navigator.sendBeacon||!f?.sampled)return;let e=r;r=[];let i=[],a=0,o=()=>{if(!i.length)return;let e=JSON.stringify({key:t,sessionId:f.id,...f.sk?{sk:f.sk}:{},b:f.b++,sdk:Io,meta:{page:qo(location.pathname)},events:i});try{navigator.sendBeacon(n,new Blob([e],{type:`text/plain;charset=UTF-8`}))}catch{}i=[],a=0};for(let t of e){let e=JSON.stringify(t).length;a+e>55e3&&o(),!(e>55e3)&&(i.push(t),a+=e)}o(),x()}let k={disabled:!1,get sessionId(){return f?.id||null},count:()=>i,flushNow:()=>E(),identify(e,t){e!=null&&e!==``&&b(`identify`,{id:String(e).slice(0,256),traits:t&&typeof t==`object`?t:void 0})},track(e,t){e&&b(`event`,{t:u(),type:`custom`,name:String(e).slice(0,120),props:t&&typeof t==`object`?JSON.parse(JSON.stringify(t,(e,t)=>typeof t==`string`?Ho(t).slice(0,500):t)):void 0})},sessionUrl(){try{return f?`${new URL(n,location.href).origin}/#replay/${f.id}`:null}catch{return null}},stop(e){if(o)return;o=!0,k.disabled=!0,k.reason=e||`stopped`;try{s?.()}catch{}for(let e of c.splice(0))try{e()}catch{}E(),m&&!h&&g.length&&T();let t=m;t&&setTimeout(()=>t.terminate(),2e3),window.__spectoRec===k&&delete window.__spectoRec},_begin(t){if(o||a)return;let r=t&&typeof t==`object`?t:{};if(r.enabled===!1)return k.stop(`recording-disabled`);p={strict:e.privacy===`strict`||r.privacy===`strict`,console:e.console!==!1&&r.captureConsole!==!1,networkDetails:e.networkDetails!==!1&&r.captureNetworkDetails!==!1,sampleRate:Math.min(e.sampleRate??1,typeof r.sampleRate==`number`?r.sampleRate:1)};let i=S(!1);if(!f.sampled)return k.stop(`not-sampled`);a=!0;for(let[e,t]of y.splice(0))b(e,t);try{if(m=e.createWorker?e.createWorker():null,m){m.onmessage=e=>{let t=e.data||{};if(t.t===`ready`){h=!0,g=[];return}D(t)},m.onerror=()=>{h||T()},m.postMessage({t:`init`,endpoint:n});let e=setTimeout(()=>{h||T()},us);c.push(()=>clearTimeout(e))}}catch{m=null}m||(_=Fo({endpoint:n,onEvent:D})),A(i);let s=setInterval(E,2e3);c.push(()=>clearInterval(s))}};function A(t){s=Eo({emit:e=>b(`dom`,Bo(e,p.strict)),maskAllInputs:!0,maskInputOptions:{password:!0,email:!0,tel:!0,color:!1},maskTextClass:`specto-mask`,maskTextSelector:p.strict?`*`:void 0,blockClass:`specto-block`,recordCanvas:!1,collectFonts:!1,checkoutEveryNms:3e5,sampling:{mousemove:50,scroll:150,input:`last`}});let r=()=>{let e=Date.now();if(e-v>cs){v=e,C();return}v=e};for(let e of[`click`,`keydown`,`scroll`,`pointerdown`])window.addEventListener(e,r,{capture:!0,passive:!0}),c.push(()=>window.removeEventListener(e,r,{capture:!0}));if(p.console)for(let e of[`log`,`info`,`warn`,`error`]){let t=console[e];console[e]=(...n)=>{try{b(`console`,{t:u(),level:e,text:p.strict?`[masked]`:Ho(n.map(_s).join(` `)).slice(0,2e3)})}catch{}t.apply(console,n)},c.push(()=>{console[e]=t})}if(p.networkDetails)try{performance.setResourceTimingBufferSize?.(1e3)}catch{}let i=window.fetch,a=null;try{a=new URL(n,location.href).href.split(/[?#]/)[0]}catch{}let o=e=>{try{return a!=null&&new URL(e,location.href).href.split(/[?#]/)[0]===a}catch{return!1}},l=new Set((Array.isArray(e.traceOrigins)?e.traceOrigins:[]).map(e=>{try{return new URL(e).origin}catch{return null}}).filter(Boolean)),d=!!e.traces||l.size>0,f=e=>{if(!d)return!1;try{let t=new URL(e,location.href).origin;return t===location.origin||l.has(t)}catch{return!1}},h=e=>{try{let[t,n]=e,r=typeof Request<`u`&&t instanceof Request,i=new Headers(n?.headers??(r?t.headers:void 0)),a=hs.exec(i.get(`traceparent`)||``);if(a)return[e,a[1].toLowerCase()];let o=ms(16);return i.set(`traceparent`,`00-${o}-${ms(8)}-01`),[[t,{...n,headers:i}],o]}catch{return[e,void 0]}};window.fetch=async(...e)=>{if(o(Uo(e[0])))return i.apply(window,e);let t=performance.now(),n=Uo(e[0]),r=qo(n,p.strict),a=(e[1]?.method||typeof e[0]!=`string`&&e[0]?.method||`GET`).toUpperCase(),s;f(n)&&([e,s]=h(e));try{let o=await i.apply(window,e),c=s;try{c=c||o.headers.get(`x-trace-id`)||void 0}catch{}let l={t:u(),method:a,url:r,status:o.status,dur:Math.round(performance.now()-t),...c?{traceId:c}:{}};if(p.networkDetails){let r={initiator:`fetch`};try{o.statusText&&(r.statusText=String(o.statusText).slice(0,80));let t=Xo(e=>o.headers.get(e));t&&(r.headers=t),t?.[`content-type`]&&(r.resType=t[`content-type`].split(`;`)[0]);let n=Number(t?.[`content-length`]);t?.[`content-length`]!=null&&Number.isFinite(n)&&(r.resSize=n);let i=Zo((e[1]||(typeof e[0]==`object`?e[0]:null))?.headers,`content-type`);i&&(r.reqType=i.split(`;`)[0].slice(0,80));let a=Qo(e[1]?.body);a!=null&&(r.reqSize=a)}catch{}l.detail=r,$o(l,Jo(n),t)}return b(`network`,l),o}catch(e){throw b(`network`,{t:u(),method:a,url:r,status:0,dur:Math.round(performance.now()-t),error:!0,...p.networkDetails?{detail:{initiator:`fetch`,message:Ho(String(e?.message||e)).slice(0,200)}}:{}}),e}},c.push(()=>{window.fetch=i});let g=window.XMLHttpRequest,y=g.prototype.open,x=g.prototype.send,S=g.prototype.setRequestHeader;g.prototype.open=function(e,t){return this.__specto={method:String(e).toUpperCase(),url:qo(t,p.strict),rawUrl:Jo(t),started:0,trace:f(t)},y.apply(this,arguments)},g.prototype.setRequestHeader=function(e,t){let n=String(e).toLowerCase();if(this.__specto&&n===`content-type`&&(this.__specto.reqType=String(t).split(`;`)[0].slice(0,80)),this.__specto&&n===`traceparent`){let e=hs.exec(String(t));e&&(this.__specto.traceId=e[1].toLowerCase()),this.__specto.trace=!1}return S.apply(this,arguments)},g.prototype.send=function(e){if(this.__specto){if(this.__specto.trace)try{let e=ms(16);S.call(this,`traceparent`,`00-${e}-${ms(8)}-01`),this.__specto.traceId=e}catch{}this.__specto.started=performance.now(),p.networkDetails&&(this.__specto.reqSize=Qo(e)),this.addEventListener(`loadend`,()=>{let e=this.__specto,t=e.traceId;try{t=t||this.getResponseHeader(`x-trace-id`)||void 0}catch{}let n={t:u(),method:e.method,url:e.url,status:this.status,dur:Math.round(performance.now()-e.started),...t?{traceId:t}:{},...this.status===0?{error:!0}:{}};if(p.networkDetails){let t={initiator:`xhr`};try{this.statusText&&(t.statusText=String(this.statusText).slice(0,80));let n=Xo(e=>this.getResponseHeader(e));n&&(t.headers=n),n?.[`content-type`]&&(t.resType=n[`content-type`].split(`;`)[0]);let r=Number(n?.[`content-length`]);n?.[`content-length`]!=null&&Number.isFinite(r)&&(t.resSize=r),e.reqType&&(t.reqType=e.reqType),e.reqSize!=null&&(t.reqSize=e.reqSize)}catch{}n.detail=t,$o(n,e.rawUrl,e.started)}b(`network`,n)})}return x.apply(this,arguments)},c.push(()=>{g.prototype.open=y,g.prototype.send=x,g.prototype.setRequestHeader=S});let w=e=>{let t=e.error||e.reason,n=t?.stack?Ho(String(t.stack)).split(`
|
|
135
135
|
`).slice(0,6).map(e=>e.replace(/\?[^\s:)]*/g,``).slice(0,300)).join(`
|
|
136
136
|
`):void 0;b(`event`,{t:u(),type:`error`,message:Ho(String(e.message||t?.message||e.reason||`error`)).slice(0,500),...n?{stack:n}:{}})};window.addEventListener(`error`,w),window.addEventListener(`unhandledrejection`,w),c.push(()=>{window.removeEventListener(`error`,w),window.removeEventListener(`unhandledrejection`,w)});let T=()=>{},E=()=>{T(),b(`event`,{t:u(),type:`nav`,path:qo(location.pathname+location.search+location.hash,p.strict).slice(0,300)})},D=history.pushState,k=history.replaceState;if(history.pushState=function(...e){let t=D.apply(this,e);try{E()}catch{}return t},history.replaceState=function(...e){let t=k.apply(this,e);try{E()}catch{}return t},window.addEventListener(`popstate`,E),window.addEventListener(`hashchange`,E),c.push(()=>{history.pushState=D,history.replaceState=k,window.removeEventListener(`popstate`,E),window.removeEventListener(`hashchange`,E)}),t||location.hash.length>1)try{E()}catch{}let A=[],ee=e=>{let t=performance.now();if(A=A.filter(n=>t-n.t<800&&Math.abs(n.x-e.clientX)<40&&Math.abs(n.y-e.clientY)<40),A.push({t,x:e.clientX,y:e.clientY}),A.length>=3){let t=e.target?.tagName?e.target.tagName.toLowerCase()+(e.target.id?`#`+e.target.id:``):`element`;b(`event`,{t:u(),type:`rage`,target:t.slice(0,80),count:A.length}),A=[]}};window.addEventListener(`click`,ee,!0),c.push(()=>window.removeEventListener(`click`,ee,!0));let j=()=>Math.max(document.documentElement?.scrollHeight||0,document.body?.scrollHeight||0),M=null,te=()=>{let e=j();M&&e>0&&(M.depth=Math.max(M.depth,Math.min(1,(window.scrollY+window.innerHeight)/e)))},ne=()=>{M={id:Math.random().toString(36).slice(2,10),path:qo(location.pathname,p.strict).slice(0,300),depth:0,clicks:0},te()},N=()=>{M&&b(`event`,{t:u(),type:`scroll`,path:M.path,pv:M.id,depth:Math.round(M.depth*1e3)/1e3,vw:window.innerWidth,dh:j()})};ne(),T=()=>{qo(location.pathname,p.strict).slice(0,300)!==M?.path&&(N(),ne())};let re=!1,P=()=>{re||(re=!0,requestAnimationFrame(()=>{re=!1,te()}))},F=e=>{!M||M.clicks>=300||(M.clicks++,b(`event`,{t:u(),type:`click`,path:M.path,pv:M.id,x:Math.round(e.pageX),y:Math.round(e.pageY),vw:window.innerWidth,dh:j(),sel:gs(e.target)}))};window.addEventListener(`scroll`,P,{passive:!0,capture:!0}),window.addEventListener(`click`,F,!0),c.push(()=>{window.removeEventListener(`scroll`,P,{capture:!0}),window.removeEventListener(`click`,F,!0)});let ie=()=>{N(),O()},ae=()=>{document.visibilityState===`hidden`&&(N(),O())},I=()=>{m?m.postMessage({t:`nudge`}):_?.nudge()};window.addEventListener(`pagehide`,ie),document.addEventListener(`visibilitychange`,ae),window.addEventListener(`online`,I),c.push(()=>{window.removeEventListener(`pagehide`,ie),document.removeEventListener(`visibilitychange`,ae),window.removeEventListener(`online`,I)})}return k}var ms=e=>{let t=new Uint8Array(e);return crypto.getRandomValues(t),Array.from(t,e=>e.toString(16).padStart(2,`0`)).join(``)},hs=/^00-([0-9a-f]{32})-[0-9a-f]{16}-[0-9a-f]{2}$/i;function gs(e){let t=[];for(let n=e,r=0;n&&n.nodeType===1&&r<3&&n!==document.body&&n!==document.documentElement;n=n.parentElement,r++){let e=String(n.tagName||``).toLowerCase();if(n.id){t.unshift(`${e}#${n.id}`);break}let r=typeof n.className==`string`?n.className.trim().split(/\s+/).filter(e=>e&&!e.startsWith(`specto-`)).slice(0,2):[];t.unshift(r.length?`${e}.${r.join(`.`)}`:e)}return Ho(t.join(` > `)||`body`).slice(0,160)}function _s(e){if(typeof e==`string`)return e;if(e instanceof Error)return`${e.name}: ${e.message}`;try{return JSON.stringify(e)}catch{return String(e)}}var vs='(function(){async function e(e){if(typeof CompressionStream>`u`)return null;try{return await new Response(new Blob([e]).stream().pipeThrough(new CompressionStream(`gzip`))).blob()}catch{return null}}function t({endpoint:t,onEvent:n=()=>{}}){let r=[],i=!1,a=null,o=!1,s=(e,t)=>{if(e.tries++,e.tries>=7)return r.shift(),n({t:`drop`,b:e.b,reason:`retries`}),c();let i=t>0?t*1e3:Math.min(3e4,1e3*2**(e.tries-1))*(.75+Math.random()/2);a=setTimeout(()=>{a=null,c()},i)};async function c(){if(i||a||o||!r.length)return;i=!0;let l=r[0];try{let a=await e(l.json),c=a||l.json,u=a?a.size:l.json.length,d=await fetch(t,{method:`POST`,body:c,credentials:`omit`,mode:`cors`,headers:{"Content-Type":`text/plain;charset=UTF-8`},keepalive:u<6e4});if(d.ok)r.shift(),n({t:`ack`,b:l.b});else{let e=``;try{e=(await d.json())?.code||``}catch{}if(e===`session_limit`||e===`session_key`)r.length=0,n({t:`rotate`,code:e});else if(e===`quota_exceeded`||e===`recording_disabled`||d.status===401||d.status===403)r.length=0,o=!0,n({t:`stop`,code:e||String(d.status)});else if(d.status===429||d.status>=500)return i=!1,s(l,Number(d.headers.get(`Retry-After`))||0);else r.shift(),n({t:`drop`,b:l.b,reason:String(d.status)})}}catch{return i=!1,s(l,0)}i=!1,c()}return{push(e){o||(r.push({...e,tries:0}),r.length>40&&n({t:`drop`,b:r.shift().b,reason:`overflow`}),c())},nudge(){a&&=(clearTimeout(a),null),c()},stop(){o=!0,r.length=0,a&&clearTimeout(a)},pending:()=>r.length}}let n=null;self.onmessage=e=>{let r=e.data||{};r.t===`init`?(n=t({endpoint:r.endpoint,onEvent:e=>self.postMessage(e)}),self.postMessage({t:`ready`})):r.t===`upload`?n?.push(r.item):r.t===`nudge`?n?.nudge():r.t===`stop`&&n?.stop()}})();',ys=typeof self<`u`&&self.Blob&&new Blob([`(self.URL || self.webkitURL).revokeObjectURL(self.location.href);`,vs],{type:`text/javascript;charset=utf-8`});function bs(e){let t;try{if(t=ys&&(self.URL||self.webkitURL).createObjectURL(ys),!t)throw``;let n=new Worker(t,{name:e?.name});return n.addEventListener(`error`,()=>{(self.URL||self.webkitURL).revokeObjectURL(t)}),n}catch{return new Worker(`data:text/javascript;charset=utf-8,`+encodeURIComponent(vs),{name:e?.name})}}var xs=null;function Ss(e={}){if(!e.endpoint)throw Error(`@spectosh/browser: opts.endpoint is required (https://<your-specto-host>/api/ingest)`);if(!e.key)throw Error(`@spectosh/browser: opts.key is required (your publishable pk_… key)`);return xs=e,fs({createWorker:()=>new bs,...e})}var Cs=()=>typeof window<`u`?window.__spectoRec:null,ws=(e,t)=>Cs()?.identify(e,t),Ts=(e,t)=>Cs()?.track(e,t),Es=()=>Cs()?.sessionUrl?.()||null,Ds=()=>Cs()?.stop();function Os(){try{localStorage.setItem(`specto-consent`,JSON.stringify(`granted`))}catch{}return xs?Ss(xs):null}function ks(){try{localStorage.removeItem(`specto-consent`)}catch{}Ds()}function As(){try{localStorage.setItem(`specto-optout`,`true`)}catch{}Ds()}function js(){try{localStorage.removeItem(`specto-optout`)}catch{}}var Ms={startRecording:Ss,identify:ws,track:Ts,sessionUrl:Es,stopRecording:Ds,grantConsent:Os,revokeConsent:ks,optOut:As,optIn:js};exports.SDK_VERSION=Io,exports.default=Ms,exports.grantConsent=Os,exports.hasConsent=os,exports.identify=ws,exports.isOptedOut=as,exports.optIn=js,exports.optOut=As,exports.revokeConsent=ks,exports.scrubText=Ho,exports.sessionUrl=Es,exports.startRecording=Ss,exports.stopRecording=Ds,exports.track=Ts;
|
package/dist/specto-browser.js
CHANGED
|
@@ -7272,7 +7272,7 @@ function Fo({ endpoint: e, onEvent: t = () => {} }) {
|
|
|
7272
7272
|
}
|
|
7273
7273
|
//#endregion
|
|
7274
7274
|
//#region src/recorder.js
|
|
7275
|
-
var Io = "0.2.
|
|
7275
|
+
var Io = "0.2.1", Lo = (e) => (e = e.toLowerCase(), e.startsWith("data-") || e === "title" || e === "alt" || e === "placeholder" || e === "aria-label" || e === "value");
|
|
7276
7276
|
function Ro(e) {
|
|
7277
7277
|
if (e && typeof e == "object") for (let t of Object.keys(e)) Lo(t) && typeof e[t] == "string" && e[t] && (e[t] = "***");
|
|
7278
7278
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@spectosh/browser",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"description": "Specto session-replay recorder for bundler users — rrweb DOM capture, console/network/error/rage signals, privacy-masked in the browser.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"publishConfig": {
|
package/src/recorder.js
CHANGED
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
import { record } from 'rrweb'
|
|
27
27
|
import { createUploader } from './uploader.js'
|
|
28
28
|
|
|
29
|
-
export const SDK_VERSION = '0.2.
|
|
29
|
+
export const SDK_VERSION = '0.2.1'
|
|
30
30
|
|
|
31
31
|
// ---- privacy helpers --------------------------------------------------------
|
|
32
32
|
// Attribute scrubbing — rrweb masks text/inputs but NOT element attributes,
|